diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 035481aaf2..becd99167f 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -3714,38 +3714,26 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh, api.distance = ZEBRA_EBGP_DISTANCE_DEFAULT; SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE); + api_nh->vrf_id = nh->vrf_id; + + if (BGP_DEBUG(zebra, ZEBRA)) { + struct vrf *vrf; + + vrf = vrf_lookup_by_id(nh->vrf_id); + zlog_debug("%s: %s default route to %pNHvv(%s) table %d", + bgp->name_pretty, announce ? "adding" : "withdrawing", + nh, VRF_LOGNAME(vrf), table_id); + } + /* redirect IP */ if (afi == AFI_IP && nh->gate.ipv4.s_addr != INADDR_ANY) { - api_nh->vrf_id = nh->vrf_id; api_nh->gate.ipv4 = nh->gate.ipv4; api_nh->type = NEXTHOP_TYPE_IPV4; - - if (BGP_DEBUG(zebra, ZEBRA)) - zlog_debug( - "BGP: %s default route to %pI4 table %d (redirect IP)", - announce ? "adding" : "withdrawing", - &nh->gate.ipv4, table_id); - - zclient_route_send(announce ? ZEBRA_ROUTE_ADD - : ZEBRA_ROUTE_DELETE, - zclient, &api); - } else if (afi == AFI_IP6 && - memcmp(&nh->gate.ipv6, - &in6addr_any, sizeof(struct in6_addr))) { - api_nh->vrf_id = nh->vrf_id; + } else if (afi == AFI_IP6 && memcmp(&nh->gate.ipv6, &in6addr_any, + sizeof(struct in6_addr))) { memcpy(&api_nh->gate.ipv6, &nh->gate.ipv6, sizeof(struct in6_addr)); api_nh->type = NEXTHOP_TYPE_IPV6; - - if (BGP_DEBUG(zebra, ZEBRA)) - zlog_debug( - "BGP: %s default route to %pI6 table %d (redirect IP)", - announce ? "adding" : "withdrawing", - &nh->gate.ipv6, table_id); - - zclient_route_send(announce ? ZEBRA_ROUTE_ADD - : ZEBRA_ROUTE_DELETE, - zclient, &api); } else if (nh->vrf_id != bgp->vrf_id) { struct vrf *vrf; struct interface *ifp; @@ -3759,18 +3747,12 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh, ifp = if_lookup_by_name_vrf(vrf->name, vrf); if (!ifp) return; - api_nh->vrf_id = nh->vrf_id; api_nh->type = NEXTHOP_TYPE_IFINDEX; api_nh->ifindex = ifp->ifindex; - if (BGP_DEBUG(zebra, ZEBRA)) - zlog_info("BGP: %s default route to %s table %d (redirect VRF)", - announce ? "adding" : "withdrawing", - vrf->name, table_id); - zclient_route_send(announce ? ZEBRA_ROUTE_ADD - : ZEBRA_ROUTE_DELETE, - zclient, &api); - return; } + + zclient_route_send(announce ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE, + zclient, &api); } /* Send capabilities to RIB */ diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 716cb8db5b..4c7bc91213 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -2893,7 +2893,6 @@ int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty, struct prefix grp; struct pim_nexthop nexthop; struct vrf *v; - char grp_str[PREFIX_STRLEN]; v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); @@ -2929,9 +2928,7 @@ int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty, return CMD_SUCCESS; } - pim_addr_dump("", &grp, grp_str, sizeof(grp_str)); - - vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s\n", grp_str, + vty_out(vty, "Group %pFXh --- Nexthop %pPAs Interface %s\n", &grp, &nexthop.mrib_nexthop_addr, nexthop.interface->name); return CMD_SUCCESS; diff --git a/pimd/pim_str.c b/pimd/pim_str.c deleted file mode 100644 index a0453769e9..0000000000 --- a/pimd/pim_str.c +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * PIM for Quagga - * Copyright (C) 2008 Everton da Silva Marques - */ - -#include - -#include -#include -#include - -#include "log.h" - -#include "pim_str.h" - -void pim_addr_dump(const char *onfail, struct prefix *p, char *buf, - int buf_size) -{ - int save_errno = errno; - - if (!inet_ntop(p->family, &p->u.prefix, buf, buf_size)) { - zlog_warn("pim_addr_dump: inet_ntop(buf_size=%d): errno=%d: %s", - buf_size, errno, safe_strerror(errno)); - if (onfail) - snprintf(buf, buf_size, "%s", onfail); - } - - errno = save_errno; -} diff --git a/pimd/pim_str.h b/pimd/pim_str.h index cc27d23c0e..029a9f49ce 100644 --- a/pimd/pim_str.h +++ b/pimd/pim_str.h @@ -35,8 +35,6 @@ #define pim_inet4_dump prefix_mcast_inet4_dump -void pim_addr_dump(const char *onfail, struct prefix *p, char *buf, - int buf_size); void pim_inet4_dump(const char *onfail, struct in_addr addr, char *buf, int buf_size); diff --git a/pimd/subdir.am b/pimd/subdir.am index 9a7901ec3f..1e787a3525 100644 --- a/pimd/subdir.am +++ b/pimd/subdir.am @@ -43,7 +43,6 @@ pim_common = \ pimd/pim_ssm.c \ pimd/pim_ssmpingd.c \ pimd/pim_static.c \ - pimd/pim_str.c \ pimd/pim_tib.c \ pimd/pim_time.c \ pimd/pim_tlv.c \ diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index c98f1ce60c..6f9c5008af 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -741,58 +741,6 @@ void nl_attr_rtnh_end(struct nlmsghdr *n, struct rtnexthop *rtnh) rtnh->rtnh_len = (uint8_t *)NLMSG_TAIL(n) - (uint8_t *)rtnh; } -bool nl_rta_put(struct rtattr *rta, unsigned int maxlen, int type, - const void *data, int alen) -{ - struct rtattr *subrta; - int len = RTA_LENGTH(alen); - - if (RTA_ALIGN(rta->rta_len) + RTA_ALIGN(len) > maxlen) { - zlog_err("ERROR max allowed bound %d exceeded for rtattr", - maxlen); - return false; - } - subrta = (struct rtattr *)(((char *)rta) + RTA_ALIGN(rta->rta_len)); - subrta->rta_type = type; - subrta->rta_len = len; - if (alen) - memcpy(RTA_DATA(subrta), data, alen); - rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len); - - return true; -} - -bool nl_rta_put16(struct rtattr *rta, unsigned int maxlen, int type, - uint16_t data) -{ - return nl_rta_put(rta, maxlen, type, &data, sizeof(uint16_t)); -} - -bool nl_rta_put64(struct rtattr *rta, unsigned int maxlen, int type, - uint64_t data) -{ - return nl_rta_put(rta, maxlen, type, &data, sizeof(uint64_t)); -} - -struct rtattr *nl_rta_nest(struct rtattr *rta, unsigned int maxlen, int type) -{ - struct rtattr *nest = RTA_TAIL(rta); - - if (nl_rta_put(rta, maxlen, type, NULL, 0)) - return NULL; - - nest->rta_type |= NLA_F_NESTED; - - return nest; -} - -int nl_rta_nest_end(struct rtattr *rta, struct rtattr *nest) -{ - nest->rta_len = (uint8_t *)RTA_TAIL(rta) - (uint8_t *)nest; - - return rta->rta_len; -} - const char *nl_msg_type_to_str(uint16_t msg_type) { return lookup_msg(nlmsg_str, msg_type, ""); diff --git a/zebra/kernel_netlink.h b/zebra/kernel_netlink.h index 446c860327..e910f62444 100644 --- a/zebra/kernel_netlink.h +++ b/zebra/kernel_netlink.h @@ -85,35 +85,6 @@ extern void netlink_parse_rtattr_nested(struct rtattr **tb, int max, */ extern bool nl_addraw_l(struct nlmsghdr *n, unsigned int maxlen, const void *data, unsigned int len); -/* - * nl_rta_put - add an additional optional attribute(rtattr) to the - * Netlink message buffer. - * - * Returns true if the attribute could be added to the message (fits into the - * buffer), otherwise false is returned. - */ -extern bool nl_rta_put(struct rtattr *rta, unsigned int maxlen, int type, - const void *data, int alen); -extern bool nl_rta_put16(struct rtattr *rta, unsigned int maxlen, int type, - uint16_t data); -extern bool nl_rta_put64(struct rtattr *rta, unsigned int maxlen, int type, - uint64_t data); -/* - * nl_rta_nest - start an additional optional attribute (rtattr) nest. - * - * Returns a valid pointer to the beginning of the nest if the attribute - * describing the nest could be added to the message (fits into the buffer), - * otherwise NULL is returned. - */ -extern struct rtattr *nl_rta_nest(struct rtattr *rta, unsigned int maxlen, - int type); -/* - * nl_rta_nest_end - finalize nesting of an aditionl optionl attributes. - * - * Updates the length field of the attribute header to include the appeneded - * attributes. Returns a total length of the Netlink message. - */ -extern int nl_rta_nest_end(struct rtattr *rta, struct rtattr *nest); extern const char *nl_msg_type_to_str(uint16_t msg_type); extern const char *nl_rtproto_to_str(uint8_t rtproto); extern const char *nl_family_to_str(uint8_t family);