diff options
67 files changed, 371 insertions, 340 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 41391c51ac..43ed97cf17 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -177,10 +177,11 @@ babel_interface_address_delete (ZAPI_CALLBACK_ARGS) if (prefix->family == AF_INET) { flush_interface_routes(ifc->ifp, 0); babel_ifp = babel_get_if_nfo(ifc->ifp); - if (babel_ifp->ipv4 != NULL - && memcmp(babel_ifp->ipv4, &prefix->u.prefix4, 4) == 0) { - free(babel_ifp->ipv4); - babel_ifp->ipv4 = NULL; + if (babel_ifp->ipv4 != NULL + && memcmp(babel_ifp->ipv4, &prefix->u.prefix4, IPV4_MAX_BYTELEN) + == 0) { + free(babel_ifp->ipv4); + babel_ifp->ipv4 = NULL; } } @@ -825,9 +826,11 @@ is_interface_ll_address(struct interface *ifp, const unsigned char *address) return 0; FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node) { - if(connected->address->family == AF_INET6 && - memcmp(&connected->address->u.prefix6, address, 16) == 0) - return 1; + if (connected->address->family == AF_INET6 + && memcmp(&connected->address->u.prefix6, address, + IPV6_MAX_BYTELEN) + == 0) + return 1; } return 0; @@ -941,13 +944,13 @@ static int babel_prefix_eq(struct prefix *prefix, unsigned char *p, int plen) { if(prefix->family == AF_INET6) { - if(prefix->prefixlen != plen || - memcmp(&prefix->u.prefix6, p, 16) != 0) - return 0; + if (prefix->prefixlen != plen + || memcmp(&prefix->u.prefix6, p, IPV6_MAX_BYTELEN) != 0) + return 0; } else if(prefix->family == AF_INET) { - if(plen < 96 || !v4mapped(p) || prefix->prefixlen != plen - 96 || - memcmp(&prefix->u.prefix4, p + 12, 4) != 0) - return 0; + if (plen < 96 || !v4mapped(p) || prefix->prefixlen != plen - 96 + || memcmp(&prefix->u.prefix4, p + 12, IPV4_MAX_BYTELEN) != 0) + return 0; } else { return 0; } @@ -959,31 +962,35 @@ static void show_babel_routes_sub(struct babel_route *route, struct vty *vty, struct prefix *prefix) { - const unsigned char *nexthop = - memcmp(route->nexthop, route->neigh->address, 16) == 0 ? - NULL : route->nexthop; - char channels[100]; - - if(prefix && !babel_prefix_eq(prefix, route->src->prefix, route->src->plen)) - return; - - if(route->channels[0] == 0) - channels[0] = '\0'; - else { - int k, j = 0; - snprintf(channels, sizeof(channels), " chan ("); - j = strlen(channels); - for(k = 0; k < DIVERSITY_HOPS; k++) { - if(route->channels[k] == 0) - break; - if(k > 0) - channels[j++] = ','; - snprintf(channels + j, 100 - j, "%u", route->channels[k]); - j = strlen(channels); - } - snprintf(channels + j, 100 - j, ")"); - if(k == 0) - channels[0] = '\0'; + const unsigned char *nexthop = + memcmp(route->nexthop, route->neigh->address, IPV6_MAX_BYTELEN) + == 0 + ? NULL + : route->nexthop; + char channels[100]; + + if (prefix + && !babel_prefix_eq(prefix, route->src->prefix, route->src->plen)) + return; + + if (route->channels[0] == 0) + channels[0] = '\0'; + else { + int k, j = 0; + snprintf(channels, sizeof(channels), " chan ("); + j = strlen(channels); + for (k = 0; k < DIVERSITY_HOPS; k++) { + if (route->channels[k] == 0) + break; + if (k > 0) + channels[j++] = ','; + snprintf(channels + j, 100 - j, "%u", + route->channels[k]); + j = strlen(channels); + } + snprintf(channels + j, 100 - j, ")"); + if (k == 0) + channels[0] = '\0'; } vty_out (vty, diff --git a/babeld/kernel.c b/babeld/kernel.c index e3c76bdd92..3941db8d5f 100644 --- a/babeld/kernel.c +++ b/babeld/kernel.c @@ -176,11 +176,11 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen, switch (family) { case AF_INET: uchar_to_inaddr(&api_nh->gate.ipv4, gate); - if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) && - quagga_prefix.prefixlen == 32) { - api_nh->type = NEXTHOP_TYPE_IFINDEX; - } else { - api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX; + if (IPV4_ADDR_SAME(&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) + && quagga_prefix.prefixlen == IPV4_MAX_BITLEN) { + api_nh->type = NEXTHOP_TYPE_IFINDEX; + } else { + api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX; } break; case AF_INET6: diff --git a/babeld/util.c b/babeld/util.c index e99bd861dc..e2db75996e 100644 --- a/babeld/util.c +++ b/babeld/util.c @@ -216,33 +216,13 @@ parse_nat(const char *string) return (int)l; } -int -in_prefix(const unsigned char *restrict address, - const unsigned char *restrict prefix, unsigned char plen) -{ - unsigned char m; - - if(plen > 128) - plen = 128; - - if(memcmp(address, prefix, plen / 8) != 0) - return 0; - - if(plen % 8 == 0) - return 1; - - m = 0xFF << (8 - (plen % 8)); - - return ((address[plen / 8] & m) == (prefix[plen / 8] & m)); -} - unsigned char * mask_prefix(unsigned char *restrict ret, const unsigned char *restrict prefix, unsigned char plen) { - if(plen >= 128) { - memcpy(ret, prefix, 16); - return ret; + if (plen >= IPV6_MAX_BITLEN) { + memcpy(ret, prefix, IPV6_MAX_BYTELEN); + return ret; } memset(ret, 0, 16); @@ -329,9 +309,10 @@ parse_address(const char *address, unsigned char *addr_r, int *af_r) rc = inet_pton(AF_INET6, address, &ina6); if(rc > 0) { - memcpy(addr_r, &ina6, 16); - if(af_r) *af_r = AF_INET6; - return 0; + memcpy(addr_r, &ina6, IPV6_MAX_BYTELEN); + if (af_r) + *af_r = AF_INET6; + return 0; } return -1; @@ -433,13 +414,13 @@ uchar_to_inaddr(struct in_addr *dest, const unsigned char *src) void in6addr_to_uchar(unsigned char *dest, const struct in6_addr *src) { - memcpy(dest, src, 16); + memcpy(dest, src, IPV6_MAX_BYTELEN); } void uchar_to_in6addr(struct in6_addr *dest, const unsigned char *src) { - memcpy(dest, src, 16); + memcpy(dest, src, IPV6_MAX_BYTELEN); } int diff --git a/babeld/util.h b/babeld/util.h index 037ebe3666..ef1387364c 100644 --- a/babeld/util.h +++ b/babeld/util.h @@ -100,9 +100,6 @@ void timeval_min(struct timeval *d, const struct timeval *s); void timeval_min_sec(struct timeval *d, time_t secs); int parse_nat(const char *string) ATTRIBUTE ((pure)); int parse_msec(const char *string) ATTRIBUTE ((pure)); -int in_prefix(const unsigned char *restrict address, - const unsigned char *restrict prefix, unsigned char plen) - ATTRIBUTE ((pure)); unsigned char *mask_prefix(unsigned char *restrict ret, const unsigned char *restrict prefix, unsigned char plen); diff --git a/bgpd/bgp_encap_tlv.c b/bgpd/bgp_encap_tlv.c index 964adec9b6..fd429120e6 100644 --- a/bgpd/bgp_encap_tlv.c +++ b/bgpd/bgp_encap_tlv.c @@ -212,12 +212,12 @@ subtlv_encode_remote_endpoint(struct bgp_tea_subtlv_remote_endpoint *st) new->length = total; p = new->value; if (st->family == AF_INET) { - memcpy(p, &(st->ip_address.v4.s_addr), 4); - p += 4; + memcpy(p, &(st->ip_address.v4.s_addr), IPV4_MAX_BYTELEN); + p += IPV4_MAX_BYTELEN; } else { assert(st->family == AF_INET6); - memcpy(p, &(st->ip_address.v6.s6_addr), 16); - p += 16; + memcpy(p, &(st->ip_address.v6.s6_addr), IPV6_MAX_BYTELEN); + p += IPV6_MAX_BYTELEN; } memcpy(p, &(st->as4), 4); return new; @@ -577,10 +577,12 @@ subtlv_decode_remote_endpoint(struct bgp_attr_encap_subtlv *subtlv, } if (subtlv->length == 8) { st->family = AF_INET; - memcpy(&st->ip_address.v4.s_addr, subtlv->value, 4); + memcpy(&st->ip_address.v4.s_addr, subtlv->value, + IPV4_MAX_BYTELEN); } else { st->family = AF_INET6; - memcpy(&(st->ip_address.v6.s6_addr), subtlv->value, 16); + memcpy(&(st->ip_address.v6.s6_addr), subtlv->value, + IPV6_MAX_BYTELEN); } i = subtlv->length - 4; ptr_get_be32(subtlv->value + i, &st->as4); diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 5ef593b9c0..c99f539c7b 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -4114,10 +4114,11 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi, gw_afi = AF_INET; } else { SET_IPADDR_V6(&p.prefix.prefix_addr.ip); - memcpy(&p.prefix.prefix_addr.ip.ipaddr_v6, pfx, 16); - pfx += 16; - memcpy(&evpn.gw_ip.ipv6, pfx, 16); - pfx += 16; + memcpy(&p.prefix.prefix_addr.ip.ipaddr_v6, pfx, + IPV6_MAX_BYTELEN); + pfx += IPV6_MAX_BYTELEN; + memcpy(&evpn.gw_ip.ipv6, pfx, IPV6_MAX_BYTELEN); + pfx += IPV6_MAX_BYTELEN; gw_afi = AF_INET6; } diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index 73ca9f07e0..3c8f2f3668 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -390,8 +390,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, return BGP_NLRI_PARSE_ERROR_LABEL_LENGTH; } - if ((afi == AFI_IP && p.prefixlen > 32) - || (afi == AFI_IP6 && p.prefixlen > 128)) + if ((afi == AFI_IP && p.prefixlen > IPV4_MAX_BITLEN) + || (afi == AFI_IP6 && p.prefixlen > IPV6_MAX_BITLEN)) return BGP_NLRI_PARSE_ERROR_PREFIX_LENGTH; /* Fetch prefix from NLRI packet */ diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 564424a082..0de48dcf78 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1440,7 +1440,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ case AF_INET: /* save */ nexthop_orig.u.prefix4 = path_vpn->attr->mp_nexthop_global_in; - nexthop_orig.prefixlen = 32; + nexthop_orig.prefixlen = IPV4_MAX_BITLEN; if (CHECK_FLAG(bgp_vrf->af_flags[afi][safi], BGP_CONFIG_VRF_TO_VRF_IMPORT)) { @@ -1457,7 +1457,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ case AF_INET6: /* save */ nexthop_orig.u.prefix6 = path_vpn->attr->mp_nexthop_global; - nexthop_orig.prefixlen = 128; + nexthop_orig.prefixlen = IPV6_MAX_BITLEN; if (CHECK_FLAG(bgp_vrf->af_flags[afi][safi], BGP_CONFIG_VRF_TO_VRF_IMPORT)) { diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index a51816116e..3c061ef1e0 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -101,9 +101,8 @@ static int bgp_md5_set_socket(int socket, union sockunion *su, su2.sin6.sin6_port = 0; /* For addresses, use the non-extended signature functionality */ - if ((su2.sa.sa_family == AF_INET && prefixlen == IPV4_MAX_PREFIXLEN) - || (su2.sa.sa_family == AF_INET6 - && prefixlen == IPV6_MAX_PREFIXLEN)) + if ((su2.sa.sa_family == AF_INET && prefixlen == IPV4_MAX_BITLEN) + || (su2.sa.sa_family == AF_INET6 && prefixlen == IPV6_MAX_BITLEN)) ret = sockopt_tcp_signature(socket, &su2, password); else ret = sockopt_tcp_signature_ext(socket, &su2, prefixlen, @@ -164,8 +163,8 @@ static int bgp_md5_set_password(struct peer *peer, const char *password) peer->su.sa.sa_family) { uint16_t prefixlen = peer->su.sa.sa_family == AF_INET - ? IPV4_MAX_PREFIXLEN - : IPV6_MAX_PREFIXLEN; + ? IPV4_MAX_BITLEN + : IPV6_MAX_BITLEN; /* * if we have stored a BGP vrf instance in the @@ -745,8 +744,8 @@ int bgp_connect(struct peer *peer) if (peer->password) { uint16_t prefixlen = peer->su.sa.sa_family == AF_INET - ? IPV4_MAX_PREFIXLEN - : IPV6_MAX_PREFIXLEN; + ? IPV4_MAX_BITLEN + : IPV6_MAX_BITLEN; bgp_md5_set_connect(peer->fd, &peer->su, prefixlen, peer->password); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 5d3176537b..ec71e17034 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -683,7 +683,7 @@ static int if_get_ipv6_global(struct interface *ifp, struct in6_addr *addr) return 0; } -static int if_get_ipv6_local(struct interface *ifp, struct in6_addr *addr) +static bool if_get_ipv6_local(struct interface *ifp, struct in6_addr *addr) { struct listnode *cnode; struct connected *connected; @@ -695,10 +695,10 @@ static int if_get_ipv6_local(struct interface *ifp, struct in6_addr *addr) if (cp->family == AF_INET6) if (IN6_IS_ADDR_LINKLOCAL(&cp->u.prefix6)) { memcpy(addr, &cp->u.prefix6, IPV6_MAX_BYTELEN); - return 1; + return true; } } - return 0; + return false; } static int if_get_ipv4_address(struct interface *ifp, struct in_addr *addr) @@ -724,6 +724,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, { int ret = 0; struct interface *ifp = NULL; + bool v6_ll_avail = true; memset(nexthop, 0, sizeof(struct bgp_nexthop)); @@ -793,12 +794,20 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, * route-map to * specify the global IPv6 nexthop. */ - if_get_ipv6_local(ifp, &nexthop->v6_global); + v6_ll_avail = + if_get_ipv6_local(ifp, &nexthop->v6_global); memcpy(&nexthop->v6_local, &nexthop->v6_global, IPV6_MAX_BYTELEN); } else - if_get_ipv6_local(ifp, &nexthop->v6_local); + v6_ll_avail = + if_get_ipv6_local(ifp, &nexthop->v6_local); + /* + * If we are a v4 connection and we are not doing unnumbered + * not having a v6 LL address is ok + */ + if (!v6_ll_avail && !peer->conf_if) + v6_ll_avail = true; if (if_lookup_by_ipv4(&remote->sin.sin_addr, peer->bgp->vrf_id)) peer->shared_network = 1; else @@ -824,7 +833,8 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, remote->sin6.sin6_scope_id, peer->bgp->vrf_id); if (direct) - if_get_ipv6_local(ifp, &nexthop->v6_local); + v6_ll_avail = if_get_ipv6_local( + ifp, &nexthop->v6_local); } else /* Link-local address. */ { @@ -871,7 +881,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, /* If we have identified the local interface, there is no error for now. */ - return true; + return v6_ll_avail; } static struct in6_addr * diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index f89ef7b0d2..8bed5156b7 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1613,9 +1613,9 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, memset(&rprefix, 0, sizeof(rprefix)); rprefix.prefix.addr_family = target->addr_family; if (target->addr_family == AF_INET) { - rprefix.length = 32; + rprefix.length = IPV4_MAX_BITLEN; } else { - rprefix.length = 128; + rprefix.length = IPV6_MAX_BITLEN; } pNHE = rfapiEthRouteTable2NextHopList( @@ -1690,9 +1690,9 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, memset(&rprefix, 0, sizeof(rprefix)); rprefix.prefix.addr_family = target->addr_family; if (target->addr_family == AF_INET) { - rprefix.length = 32; + rprefix.length = IPV4_MAX_BITLEN; } else { - rprefix.length = 128; + rprefix.length = IPV6_MAX_BITLEN; } pNHE = rfapiEthRouteNode2NextHopList( diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 51e051d688..07aed045ca 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -405,7 +405,7 @@ int rfapiGetVncTunnelUnAddr(struct attr *attr, struct prefix *p) case 8: if (p) { p->family = AF_INET; - p->prefixlen = 32; + p->prefixlen = IPV4_MAX_BITLEN; memcpy(p->u.val, pEncap->value, 4); } @@ -414,7 +414,7 @@ int rfapiGetVncTunnelUnAddr(struct attr *attr, struct prefix *p) case 20: if (p) { p->family = AF_INET6; - p->prefixlen = 128; + p->prefixlen = IPV6_MAX_BITLEN; memcpy(p->u.val, pEncap->value, 16); } @@ -445,14 +445,14 @@ int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bpi, struct prefix *p) if (p) { p->family = bpi->extra->vnc.import.un_family; p->u.prefix4 = bpi->extra->vnc.import.un.addr4; - p->prefixlen = 32; + p->prefixlen = IPV4_MAX_BITLEN; } return 0; case AF_INET6: if (p) { p->family = bpi->extra->vnc.import.un_family; p->u.prefix6 = bpi->extra->vnc.import.un.addr6; - p->prefixlen = 128; + p->prefixlen = IPV6_MAX_BITLEN; } return 0; default: @@ -2519,12 +2519,12 @@ void rfapiNexthop2Prefix(struct attr *attr, struct prefix *p) switch (p->family = BGP_MP_NEXTHOP_FAMILY(attr->mp_nexthop_len)) { case AF_INET: p->u.prefix4 = attr->mp_nexthop_global_in; - p->prefixlen = 32; + p->prefixlen = IPV4_MAX_BITLEN; break; case AF_INET6: p->u.prefix6 = attr->mp_nexthop_global; - p->prefixlen = 128; + p->prefixlen = IPV6_MAX_BITLEN; break; default: @@ -2537,7 +2537,7 @@ void rfapiUnicastNexthop2Prefix(afi_t afi, struct attr *attr, struct prefix *p) { if (afi == AFI_IP) { p->family = AF_INET; - p->prefixlen = 32; + p->prefixlen = IPV4_MAX_BITLEN; p->u.prefix4 = attr->nexthop; } else { rfapiNexthop2Prefix(attr, p); @@ -2871,12 +2871,12 @@ static int rfapiGetNexthop(struct attr *attr, struct prefix *prefix) switch (BGP_MP_NEXTHOP_FAMILY(attr->mp_nexthop_len)) { case AF_INET: prefix->family = AF_INET; - prefix->prefixlen = 32; + prefix->prefixlen = IPV4_MAX_BITLEN; prefix->u.prefix4 = attr->mp_nexthop_global_in; break; case AF_INET6: prefix->family = AF_INET6; - prefix->prefixlen = 128; + prefix->prefixlen = IPV6_MAX_BITLEN; prefix->u.prefix6 = attr->mp_nexthop_global; break; default: diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index e7825e8bfc..bc0e192ae2 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -267,9 +267,9 @@ struct rfapi { #define RFAPI_HOST_PREFIX(prefix) \ (((prefix)->family == AF_INET) \ - ? ((prefix)->prefixlen == 32) \ + ? ((prefix)->prefixlen == IPV4_MAX_BITLEN) \ : (((prefix)->family == AF_INET6) \ - ? ((prefix)->prefixlen == 128) \ + ? ((prefix)->prefixlen == IPV6_MAX_BITLEN) \ : 0)) extern int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 40d5111e8c..45ef7230b5 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -174,12 +174,12 @@ int rfapiQprefix2Raddr(struct prefix *qprefix, struct rfapi_ip_addr *raddr) raddr->addr_family = qprefix->family; switch (qprefix->family) { case AF_INET: - if (qprefix->prefixlen != 32) + if (qprefix->prefixlen != IPV4_MAX_BITLEN) return -1; raddr->addr.v4 = qprefix->u.prefix4; break; case AF_INET6: - if (qprefix->prefixlen != 128) + if (qprefix->prefixlen != IPV6_MAX_BITLEN) return -1; raddr->addr.v6 = qprefix->u.prefix6; break; @@ -260,11 +260,11 @@ int rfapiRaddr2Qprefix(struct rfapi_ip_addr *hia, struct prefix *pfx) switch (hia->addr_family) { case AF_INET: - pfx->prefixlen = 32; + pfx->prefixlen = IPV4_MAX_BITLEN; pfx->u.prefix4 = hia->addr.v4; break; case AF_INET6: - pfx->prefixlen = 128; + pfx->prefixlen = IPV6_MAX_BITLEN; pfx->u.prefix6 = hia->addr.v6; break; default: @@ -1734,14 +1734,14 @@ int rfapiCliGetPrefixAddr(struct vty *vty, const char *str, struct prefix *p) } switch (p->family) { case AF_INET: - if (p->prefixlen != 32) { + if (p->prefixlen != IPV4_MAX_BITLEN) { vty_out(vty, "Not a host address: \"%s\"%s", str, HVTYNL); return CMD_WARNING; } break; case AF_INET6: - if (p->prefixlen != 128) { + if (p->prefixlen != IPV6_MAX_BITLEN) { vty_out(vty, "Not a host address: \"%s\"%s", str, HVTYNL); return CMD_WARNING; diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index c90fcf8d72..68dc5a4f60 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -164,7 +164,7 @@ static int getce(struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce) memset((uint8_t *)pfx_ce, 0, sizeof(*pfx_ce)); memcpy(&pfx_ce->u.prefix4, ecp + 2, 4); pfx_ce->family = AF_INET; - pfx_ce->prefixlen = 32; + pfx_ce->prefixlen = IPV4_MAX_BITLEN; return 0; } @@ -597,10 +597,10 @@ encap_attr_export(struct attr *new, struct attr *orig, orig_nexthop.family = BGP_MP_NEXTHOP_FAMILY(orig->mp_nexthop_len); if (orig_nexthop.family == AF_INET) { - orig_nexthop.prefixlen = 32; + orig_nexthop.prefixlen = IPV4_MAX_BITLEN; orig_nexthop.u.prefix4 = orig->mp_nexthop_global_in; } else if (orig_nexthop.family == AF_INET6) { - orig_nexthop.prefixlen = 128; + orig_nexthop.prefixlen = IPV6_MAX_BITLEN; orig_nexthop.u.prefix6 = orig->mp_nexthop_global; } else { return -1; /* FAIL - can't compute nexthop */ diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index b23c1eda76..0358c8d665 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -108,9 +108,9 @@ static int is_host_prefix(const struct prefix *p) { switch (p->family) { case AF_INET: - return (p->prefixlen == 32); + return (p->prefixlen == IPV4_MAX_BITLEN); case AF_INET6: - return (p->prefixlen == 128); + return (p->prefixlen == IPV6_MAX_BITLEN); } return 0; } @@ -1073,7 +1073,7 @@ static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp, vnaddr.addr_family = vn_pfx->family; switch (vn_pfx->family) { case AF_INET: - if (vn_pfx->prefixlen != 32) { + if (vn_pfx->prefixlen != IPV4_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist VN plen (%d) != 32, skipping", __func__, vn_pfx->prefixlen); @@ -1083,7 +1083,7 @@ static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp, break; case AF_INET6: - if (vn_pfx->prefixlen != 128) { + if (vn_pfx->prefixlen != IPV6_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist VN plen (%d) != 128, skipping", __func__, vn_pfx->prefixlen); @@ -1147,7 +1147,7 @@ static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp, vnaddr.addr_family = vn_pfx->family; switch (vn_pfx->family) { case AF_INET: - if (vn_pfx->prefixlen != 32) { + if (vn_pfx->prefixlen != IPV4_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist VN plen (%d) != 32, skipping", __func__, vn_pfx->prefixlen); @@ -1157,7 +1157,7 @@ static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp, break; case AF_INET6: - if (vn_pfx->prefixlen != 128) { + if (vn_pfx->prefixlen != IPV6_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist VN plen (%d) != 128, skipping", __func__, vn_pfx->prefixlen); diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index b254f11ce7..ba849e4e0b 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -105,7 +105,8 @@ static void vnc_redistribute_add(struct prefix *p, uint32_t metric, vnaddr.addr_family = bgp->rfapi_cfg->rfg_redist->vn_prefix.family; switch (bgp->rfapi_cfg->rfg_redist->vn_prefix.family) { case AF_INET: - if (bgp->rfapi_cfg->rfg_redist->vn_prefix.prefixlen != 32) { + if (bgp->rfapi_cfg->rfg_redist->vn_prefix.prefixlen + != IPV4_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist nve group VN prefix len (%d) != 32, skipping", __func__, @@ -117,7 +118,8 @@ static void vnc_redistribute_add(struct prefix *p, uint32_t metric, bgp->rfapi_cfg->rfg_redist->vn_prefix.u.prefix4; break; case AF_INET6: - if (bgp->rfapi_cfg->rfg_redist->vn_prefix.prefixlen != 128) { + if (bgp->rfapi_cfg->rfg_redist->vn_prefix.prefixlen + != IPV6_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist nve group VN prefix len (%d) != 128, skipping", __func__, @@ -153,7 +155,7 @@ static void vnc_redistribute_add(struct prefix *p, uint32_t metric, switch (pfx_un.prefix.addr_family) { case AF_INET: - if (pfx_un.length != 32) { + if (pfx_un.length != IPV4_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist nve group UN prefix len (%d) != 32, skipping", __func__, pfx_un.length); @@ -161,7 +163,7 @@ static void vnc_redistribute_add(struct prefix *p, uint32_t metric, } break; case AF_INET6: - if (pfx_un.length != 128) { + if (pfx_un.length != IPV6_MAX_BITLEN) { vnc_zlog_debug_verbose( "%s: redist nve group UN prefix len (%d) != 128, skipping", __func__, pfx_un.length); diff --git a/isisd/isis_route.c b/isisd/isis_route.c index eb534a543a..bf0079d814 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -221,11 +221,11 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, /* update neighbor router address */ switch (prefix->family) { case AF_INET: - if (depth == 2 && prefix->prefixlen == 32) + if (depth == 2 && prefix->prefixlen == IPV4_MAX_BITLEN) adj->router_address = prefix->u.prefix4; break; case AF_INET6: - if (depth == 2 && prefix->prefixlen == 128 + if (depth == 2 && prefix->prefixlen == IPV6_MAX_BITLEN && (!src_p || !src_p->prefixlen)) { adj->router_address6 = prefix->u.prefix6; } diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 2bac8e7fd5..17dbb1903d 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -967,7 +967,7 @@ static int unpack_subtlv_ipv6_source_prefix(enum isis_tlv_context context, } p.prefixlen = stream_getc(s); - if (p.prefixlen > 128) { + if (p.prefixlen > IPV6_MAX_BITLEN) { sbuf_push(log, indent, "Prefixlen %u is implausible for IPv6\n", p.prefixlen); return 1; @@ -2057,7 +2057,7 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len, rv->down = (control & ISIS_EXTENDED_IP_REACH_DOWN); rv->prefix.family = AF_INET; rv->prefix.prefixlen = control & 0x3f; - if (rv->prefix.prefixlen > 32) { + if (rv->prefix.prefixlen > IPV4_MAX_BITLEN) { sbuf_push(log, indent, "Prefixlen %u is implausible for IPv4\n", rv->prefix.prefixlen); goto out; @@ -2542,7 +2542,7 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, rv->prefix.family = AF_INET6; rv->prefix.prefixlen = stream_getc(s); - if (rv->prefix.prefixlen > 128) { + if (rv->prefix.prefixlen > IPV6_MAX_BITLEN) { sbuf_push(log, indent, "Prefixlen %u is implausible for IPv6\n", rv->prefix.prefixlen); goto out; diff --git a/ldpd/labelmapping.c b/ldpd/labelmapping.c index cee9d527e8..13d3243124 100644 --- a/ldpd/labelmapping.c +++ b/ldpd/labelmapping.c @@ -724,9 +724,9 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf, map->fec.prefix.prefixlen = buf[off]; off += sizeof(uint8_t); if ((map->fec.prefix.af == AF_IPV4 - && map->fec.prefix.prefixlen > IPV4_MAX_PREFIXLEN) + && map->fec.prefix.prefixlen > IPV4_MAX_BITLEN) || (map->fec.prefix.af == AF_IPV6 - && map->fec.prefix.prefixlen > IPV6_MAX_PREFIXLEN)) { + && map->fec.prefix.prefixlen > IPV6_MAX_BITLEN)) { session_shutdown(nbr, S_BAD_TLV_VAL, msg->id, msg->type); return (-1); diff --git a/ldpd/lde.c b/ldpd/lde.c index 724e83adb2..2d35d097a1 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -751,8 +751,8 @@ lde_update_label(struct fec_node *fn) /* should we allocate a label for this fec? */ switch (fn->fec.type) { case FEC_TYPE_IPV4: - if ((ldeconf->ipv4.flags & F_LDPD_AF_ALLOCHOSTONLY) && - fn->fec.u.ipv4.prefixlen != 32) + if ((ldeconf->ipv4.flags & F_LDPD_AF_ALLOCHOSTONLY) + && fn->fec.u.ipv4.prefixlen != IPV4_MAX_BITLEN) return (NO_LABEL); if (lde_acl_check(ldeconf->ipv4.acl_label_allocate_for, AF_INET, (union ldpd_addr *)&fn->fec.u.ipv4.prefix, @@ -760,8 +760,8 @@ lde_update_label(struct fec_node *fn) return (NO_LABEL); break; case FEC_TYPE_IPV6: - if ((ldeconf->ipv6.flags & F_LDPD_AF_ALLOCHOSTONLY) && - fn->fec.u.ipv6.prefixlen != 128) + if ((ldeconf->ipv6.flags & F_LDPD_AF_ALLOCHOSTONLY) + && fn->fec.u.ipv6.prefixlen != IPV6_MAX_BITLEN) return (NO_LABEL); if (lde_acl_check(ldeconf->ipv6.acl_label_allocate_for, AF_INET6, (union ldpd_addr *)&fn->fec.u.ipv6.prefix, diff --git a/ldpd/util.c b/ldpd/util.c index b4d74f1950..019d846ada 100644 --- a/ldpd/util.c +++ b/ldpd/util.c @@ -182,7 +182,7 @@ ldp_prefixcmp(int af, const union ldpd_addr *a, const union ldpd_addr *b, case AF_INET: if (prefixlen == 0) return (0); - if (prefixlen > 32) + if (prefixlen > IPV4_MAX_BITLEN) fatalx("ldp_prefixcmp: bad IPv4 prefixlen"); mask = htonl(prefixlen2mask(prefixlen)); aa = htonl(a->v4.s_addr) & mask; @@ -191,7 +191,7 @@ ldp_prefixcmp(int af, const union ldpd_addr *a, const union ldpd_addr *b, case AF_INET6: if (prefixlen == 0) return (0); - if (prefixlen > 128) + if (prefixlen > IPV6_MAX_BITLEN) fatalx("ldp_prefixcmp: bad IPv6 prefixlen"); for (i = 0; i < prefixlen / 8; i++) if (a->v6.s6_addr[i] != b->v6.s6_addr[i]) diff --git a/lib/command_match.c b/lib/command_match.c index e9e8466ffd..5703510148 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -813,7 +813,7 @@ static enum match_type match_ipv4_prefix(const char *str) str++; } - if (atoi(sp) > 32) + if (atoi(sp) > IPV4_MAX_BITLEN) return no_match; return exact_match; @@ -948,7 +948,7 @@ static enum match_type match_ipv6_prefix(const char *str, bool prefix) if (*endptr != '\0') return no_match; - if (mask < 0 || mask > 128) + if (mask < 0 || mask > IPV6_MAX_BITLEN) return no_match; return exact_match; diff --git a/lib/filter.c b/lib/filter.c index b7a935d076..72a66d85ad 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -108,10 +108,14 @@ static int filter_match_cisco(struct filter *mfilter, const struct prefix *p) masklen2ip(p->prefixlen, &mask); check_mask = mask.s_addr & ~filter->mask_mask.s_addr; - if (memcmp(&check_addr, &filter->addr.s_addr, 4) == 0 - && memcmp(&check_mask, &filter->mask.s_addr, 4) == 0) + if (memcmp(&check_addr, &filter->addr.s_addr, IPV4_MAX_BYTELEN) + == 0 + && memcmp(&check_mask, &filter->mask.s_addr, + IPV4_MAX_BYTELEN) + == 0) return 1; - } else if (memcmp(&check_addr, &filter->addr.s_addr, 4) == 0) + } else if (memcmp(&check_addr, &filter->addr.s_addr, IPV4_MAX_BYTELEN) + == 0) return 1; return 0; diff --git a/lib/prefix.c b/lib/prefix.c index 7dbb5f07f0..1c57715e8f 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -577,7 +577,7 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p) /* Get prefix length. */ plen = (uint8_t)atoi(++pnt); - if (plen > IPV4_MAX_PREFIXLEN) + if (plen > IPV4_MAX_BITLEN) return 0; p->family = AF_INET; @@ -1128,7 +1128,7 @@ void apply_classful_mask_ipv4(struct prefix_ipv4 *p) destination = ntohl(p->prefix.s_addr); - if (p->prefixlen == IPV4_MAX_PREFIXLEN) + if (p->prefixlen == IPV4_MAX_BITLEN) ; /* do nothing for host routes */ else if (IN_CLASSC(destination)) { @@ -1148,12 +1148,13 @@ in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen) struct in_addr mask; masklen2ip(masklen, &mask); - return (masklen != IPV4_MAX_PREFIXLEN - 1) ? - /* normal case */ - (hostaddr | ~mask.s_addr) - : - /* For prefix 31 return 255.255.255.255 (RFC3021) */ - htonl(0xFFFFFFFF); + return (masklen != IPV4_MAX_BITLEN - 1) + ? + /* normal case */ + (hostaddr | ~mask.s_addr) + : + /* For prefix 31 return 255.255.255.255 (RFC3021) */ + htonl(0xFFFFFFFF); } /* Utility function to convert ipv4 netmask to prefixes diff --git a/lib/prefix.h b/lib/prefix.h index c47e701dfd..bc4cb7f441 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -372,7 +372,6 @@ union prefixconstptr { /* Max bit/byte length of IPv4 address. */ #define IPV4_MAX_BYTELEN 4 #define IPV4_MAX_BITLEN 32 -#define IPV4_MAX_PREFIXLEN 32 #define IPV4_ADDR_CMP(D,S) memcmp ((D), (S), IPV4_MAX_BYTELEN) static inline bool ipv4_addr_same(const struct in_addr *a, @@ -398,7 +397,6 @@ static inline void ipv4_addr_copy(struct in_addr *dst, /* Max bit/byte length of IPv6 address. */ #define IPV6_MAX_BYTELEN 16 #define IPV6_MAX_BITLEN 128 -#define IPV6_MAX_PREFIXLEN 128 #define IPV6_ADDR_CMP(D,S) memcmp ((D), (S), IPV6_MAX_BYTELEN) #define IPV6_ADDR_SAME(D,S) (memcmp ((D), (S), IPV6_MAX_BYTELEN) == 0) #define IPV6_ADDR_COPY(D,S) memcpy ((D), (S), IPV6_MAX_BYTELEN) diff --git a/lib/table.c b/lib/table.c index dfd92c6189..e6030ca4ca 100644 --- a/lib/table.c +++ b/lib/table.c @@ -230,7 +230,7 @@ struct route_node *route_node_match_ipv4(struct route_table *table, memset(&p, 0, sizeof(struct prefix_ipv4)); p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = *addr; return route_node_match(table, (struct prefix *)&p); @@ -243,7 +243,7 @@ struct route_node *route_node_match_ipv6(struct route_table *table, memset(&p, 0, sizeof(struct prefix_ipv6)); p.family = AF_INET6; - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; p.prefix = *addr; return route_node_match(table, &p); diff --git a/lib/zclient.c b/lib/zclient.c index ffae1332af..1b4ac080cd 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -446,7 +446,7 @@ enum zclient_send_status zclient_send_localsid(struct zclient *zclient, struct nexthop nh = {}; p.family = AF_INET6; - p.prefixlen = 128; + p.prefixlen = IPV6_MAX_BITLEN; p.prefix = *sid; api.vrf_id = VRF_DEFAULT; @@ -1432,7 +1432,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) STREAM_GETC(s, api->prefix.prefixlen); switch (api->prefix.family) { case AF_INET: - if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) { + if (api->prefix.prefixlen > IPV4_MAX_BITLEN) { flog_err( EC_LIB_ZAPI_ENCODE, "%s: V4 prefixlen is %d which should not be more than 32", @@ -1441,7 +1441,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) } break; case AF_INET6: - if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) { + if (api->prefix.prefixlen > IPV6_MAX_BITLEN) { flog_err( EC_LIB_ZAPI_ENCODE, "%s: v6 prefixlen is %d which should not be more than 128", @@ -1460,7 +1460,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) { api->src_prefix.family = AF_INET6; STREAM_GETC(s, api->src_prefix.prefixlen); - if (api->src_prefix.prefixlen > IPV6_MAX_PREFIXLEN) { + if (api->src_prefix.prefixlen > IPV6_MAX_BITLEN) { flog_err( EC_LIB_ZAPI_ENCODE, "%s: SRC Prefix prefixlen received: %d is too large", diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index d7307fe375..91e33c858e 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -556,7 +556,7 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa) + OSPF6_PREFIX_SPACE(external->prefix.prefix_length); memset(&fwd_addr, 0, sizeof(struct prefix)); fwd_addr.family = AF_INET6; - fwd_addr.prefixlen = IPV6_MAX_PREFIXLEN; + fwd_addr.prefixlen = IPV6_MAX_BITLEN; memcpy(&fwd_addr.u.prefix6, (caddr_t)external + offset, sizeof(struct in6_addr)); @@ -1010,53 +1010,55 @@ static void ospf6_asbr_routemap_unset(struct ospf6_redist *red) static int ospf6_asbr_routemap_update_timer(struct thread *thread) { - void **arg; - int arg_type; - struct ospf6 *ospf6; + struct ospf6 *ospf6 = THREAD_ARG(thread); struct ospf6_redist *red; - - arg = THREAD_ARG(thread); - ospf6 = (struct ospf6 *)arg[0]; - arg_type = (int)(intptr_t)arg[1]; + int type; ospf6->t_distribute_update = NULL; - red = ospf6_redist_lookup(ospf6, arg_type, 0); + for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { + red = ospf6_redist_lookup(ospf6, type, 0); + + if (!red) + continue; - if (red && ROUTEMAP_NAME(red)) - ROUTEMAP(red) = route_map_lookup_by_name(ROUTEMAP_NAME(red)); - if (red && ROUTEMAP(red)) { - if (IS_OSPF6_DEBUG_ASBR) - zlog_debug("%s: route-map %s update, reset redist %s", - __func__, ROUTEMAP_NAME(red), - ZROUTE_NAME(arg_type)); + if (!CHECK_FLAG(red->flag, OSPF6_IS_RMAP_CHANGED)) + continue; + + if (ROUTEMAP_NAME(red)) + ROUTEMAP(red) = + route_map_lookup_by_name(ROUTEMAP_NAME(red)); + + if (ROUTEMAP(red)) { + if (IS_OSPF6_DEBUG_ASBR) + zlog_debug( + "%s: route-map %s update, reset redist %s", + __func__, ROUTEMAP_NAME(red), + ZROUTE_NAME(type)); - ospf6_zebra_no_redistribute(arg_type, ospf6->vrf_id); - ospf6_zebra_redistribute(arg_type, ospf6->vrf_id); + ospf6_zebra_no_redistribute(type, ospf6->vrf_id); + ospf6_zebra_redistribute(type, ospf6->vrf_id); + } + + UNSET_FLAG(red->flag, OSPF6_IS_RMAP_CHANGED); } - XFREE(MTYPE_OSPF6_DIST_ARGS, arg); return 0; } -void ospf6_asbr_distribute_list_update(int type, struct ospf6 *ospf6) +void ospf6_asbr_distribute_list_update(struct ospf6 *ospf6, + struct ospf6_redist *red) { - void **args = NULL; + SET_FLAG(red->flag, OSPF6_IS_RMAP_CHANGED); if (ospf6->t_distribute_update) return; - args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *) * 2); - - args[0] = ospf6; - args[1] = (void *)((ptrdiff_t)type); - if (IS_OSPF6_DEBUG_ASBR) - zlog_debug("%s: trigger redistribute %s reset thread", __func__, - ZROUTE_NAME(type)); + zlog_debug("%s: trigger redistribute reset thread", __func__); ospf6->t_distribute_update = NULL; - thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer, args, + thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer, ospf6, OSPF_MIN_LS_INTERVAL, &ospf6->t_distribute_update); } @@ -1092,8 +1094,7 @@ void ospf6_asbr_routemap_update(const char *mapname) type)); route_map_counter_increment(ROUTEMAP(red)); - - ospf6_asbr_distribute_list_update(type, ospf6); + ospf6_asbr_distribute_list_update(ospf6, red); } else { /* * if the mapname matches a @@ -1131,7 +1132,7 @@ static void ospf6_asbr_routemap_event(const char *name) red = ospf6_redist_lookup(ospf6, type, 0); if (red && ROUTEMAP_NAME(red) && (strcmp(ROUTEMAP_NAME(red), name) == 0)) - ospf6_asbr_distribute_list_update(type, ospf6); + ospf6_asbr_distribute_list_update(ospf6, red); } } } @@ -1399,7 +1400,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, /* create/update binding in external_id_table */ prefix_id.family = AF_INET; - prefix_id.prefixlen = 32; + prefix_id.prefixlen = IPV4_MAX_BITLEN; prefix_id.u.prefix4.s_addr = htonl(info->id); node = route_node_get(ospf6->external_id_table, &prefix_id); node->info = match; @@ -1464,7 +1465,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, /* create/update binding in external_id_table */ prefix_id.family = AF_INET; - prefix_id.prefixlen = 32; + prefix_id.prefixlen = IPV4_MAX_BITLEN; prefix_id.u.prefix4.s_addr = htonl(info->id); node = route_node_get(ospf6->external_id_table, &prefix_id); node->info = route; @@ -1547,7 +1548,7 @@ void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex, /* remove binding in external_id_table */ prefix_id.family = AF_INET; - prefix_id.prefixlen = 32; + prefix_id.prefixlen = IPV4_MAX_BITLEN; prefix_id.u.prefix4.s_addr = htonl(info->id); node = route_node_lookup(ospf6->external_id_table, &prefix_id); assert(node); @@ -2483,21 +2484,23 @@ void ospf6_asbr_redistribute_disable(struct ospf6 *ospf6) int type; struct ospf6_redist *red; - for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { + for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { + if (type == ZEBRA_ROUTE_OSPF6) + continue; red = ospf6_redist_lookup(ospf6, type, 0); if (!red) continue; - if (type == ZEBRA_ROUTE_OSPF6) + + if (type == DEFAULT_ROUTE) { + ospf6_asbr_routemap_unset(red); + ospf6_redist_del(ospf6, red, type); + ospf6_redistribute_default_set(ospf6, + DEFAULT_ORIGINATE_NONE); continue; + } ospf6_asbr_redistribute_unset(ospf6, red, type); ospf6_redist_del(ospf6, red, type); } - red = ospf6_redist_lookup(ospf6, DEFAULT_ROUTE, 0); - if (red) { - ospf6_asbr_routemap_unset(red); - ospf6_redist_del(ospf6, red, type); - ospf6_redistribute_default_set(ospf6, DEFAULT_ORIGINATE_NONE); - } } void ospf6_asbr_redistribute_reset(struct ospf6 *ospf6) diff --git a/ospf6d/ospf6_asbr.h b/ospf6d/ospf6_asbr.h index 8f2135ef30..7ccd1c992b 100644 --- a/ospf6d/ospf6_asbr.h +++ b/ospf6d/ospf6_asbr.h @@ -105,7 +105,8 @@ extern void install_element_ospf6_debug_asbr(void); extern void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, struct ospf6_route *route, struct ospf6 *ospf6); -extern void ospf6_asbr_distribute_list_update(int type, struct ospf6 *ospf6); +extern void ospf6_asbr_distribute_list_update(struct ospf6 *ospf6, + struct ospf6_redist *red); struct ospf6_redist *ospf6_redist_lookup(struct ospf6 *ospf6, int type, unsigned short instance); extern void ospf6_asbr_routemap_update(const char *mapname); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 6f40989efd..d4557e0ef6 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -73,6 +73,8 @@ struct ospf6_master *om6; static void ospf6_disable(struct ospf6 *o); +static void ospf6_process_reset(struct ospf6 *ospf6); + static void ospf6_add(struct ospf6 *ospf6) { listnode_add(om6->ospf6, ospf6); @@ -225,7 +227,7 @@ static int ospf6_vrf_enable(struct vrf *vrf) thread_add_read(master, ospf6_receive, ospf6, ospf6->fd, &ospf6->t_ospf6_receive); - ospf6_router_id_update(ospf6); + ospf6_router_id_update(ospf6, true, NULL); } } @@ -440,7 +442,7 @@ struct ospf6 *ospf6_instance_create(const char *name) if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES) SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); if (ospf6->router_id == 0) - ospf6_router_id_update(ospf6); + ospf6_router_id_update(ospf6, true, NULL); ospf6_add(ospf6); if (ospf6->vrf_id != VRF_UNKNOWN) { vrf = vrf_lookup_by_id(ospf6->vrf_id); @@ -594,15 +596,43 @@ void ospf6_maxage_remove(struct ospf6 *o) &o->maxage_remover); } -void ospf6_router_id_update(struct ospf6 *ospf6) +void ospf6_router_id_update(struct ospf6 *ospf6, bool init, struct vty *vty) { + in_addr_t new_router_id; + struct listnode *node; + struct ospf6_area *oa; + if (!ospf6) return; if (ospf6->router_id_static != 0) - ospf6->router_id = ospf6->router_id_static; + new_router_id = ospf6->router_id_static; else - ospf6->router_id = ospf6->router_id_zebra; + new_router_id = ospf6->router_id_zebra; + + if (ospf6->router_id == new_router_id) + return; + + if (!init) + for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { + if (oa->full_nbrs) { + if (vty) + vty_out(vty, + "For this router-id change to take effect," + " run the \"clear ipv6 ospf6 process\" command\n"); + else + zlog_err( + "%s: cannot update router-id." + " Run the \"clear ipv6 ospf6 process\" command\n", + __func__); + return; + } + } + + ospf6->router_id = new_router_id; + + if (!init) + ospf6_process_reset(ospf6); } /* start ospf6 */ @@ -694,7 +724,7 @@ static void ospf6_process_reset(struct ospf6 *ospf6) ospf6->inst_shutdown = 0; ospf6_db_clear(ospf6); - ospf6_router_id_update(ospf6); + ospf6_router_id_update(ospf6, true, NULL); ospf6_asbr_redistribute_reset(ospf6); FOR_ALL_INTERFACES (vrf, ifp) @@ -738,8 +768,6 @@ DEFUN(ospf6_router_id, int ret; const char *router_id_str; uint32_t router_id; - struct ospf6_area *oa; - struct listnode *node; argv_find(argv, argc, "A.B.C.D", &idx); router_id_str = argv[idx]->arg; @@ -752,15 +780,7 @@ DEFUN(ospf6_router_id, o->router_id_static = router_id; - for (ALL_LIST_ELEMENTS_RO(o->area_list, node, oa)) { - if (oa->full_nbrs) { - vty_out(vty, - "For this router-id change to take effect, run the \"clear ipv6 ospf6 process\" command\n"); - return CMD_SUCCESS; - } - } - - o->router_id = router_id; + ospf6_router_id_update(o, false, vty); return CMD_SUCCESS; } @@ -773,21 +793,10 @@ DEFUN(no_ospf6_router_id, V4NOTATION_STR) { VTY_DECLVAR_CONTEXT(ospf6, o); - struct ospf6_area *oa; - struct listnode *node; o->router_id_static = 0; - for (ALL_LIST_ELEMENTS_RO(o->area_list, node, oa)) { - if (oa->full_nbrs) { - vty_out(vty, - "For this router-id change to take effect, run the \"clear ipv6 ospf6 process\" command\n"); - return CMD_SUCCESS; - } - } - o->router_id = 0; - if (o->router_id_zebra) - o->router_id = o->router_id_zebra; + ospf6_router_id_update(o, false, vty); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h index f0251bcb62..820622c743 100644 --- a/ospf6d/ospf6_top.h +++ b/ospf6d/ospf6_top.h @@ -37,9 +37,12 @@ enum { OSPF6_LOG_ADJACENCY_DETAIL = (1 << 1), }; +/* For processing route-map change update in the callback */ +#define OSPF6_IS_RMAP_CHANGED 0x01 struct ospf6_redist { uint8_t instance; + uint8_t flag; /* Redistribute metric info. */ struct { int type; /* External metric type (E1 or E2). */ @@ -175,7 +178,8 @@ extern void ospf6_master_init(struct thread_master *master); extern void install_element_ospf6_clear_process(void); extern void ospf6_top_init(void); extern void ospf6_delete(struct ospf6 *o); -extern void ospf6_router_id_update(struct ospf6 *ospf6); +extern void ospf6_router_id_update(struct ospf6 *ospf6, bool init, + struct vty *vty); extern void ospf6_maxage_remove(struct ospf6 *o); extern struct ospf6 *ospf6_instance_create(const char *name); diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index a7e15c68ae..727e6f7fef 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -101,7 +101,7 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS) o->router_id_zebra = router_id.u.prefix4.s_addr; - ospf6_router_id_update(o); + ospf6_router_id_update(o, false, NULL); return 0; } diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 2fd195bb6d..192dbe4fc8 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -361,7 +361,7 @@ bool is_valid_summary_addr(struct prefix_ipv4 *p) return false; /*Host route shouldn't be configured as summary addres*/ - if (p->prefixlen == IPV4_MAX_PREFIXLEN) + if (p->prefixlen == IPV4_MAX_BITLEN) return false; return true; diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index b3aba247df..029f929c11 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -188,7 +188,7 @@ struct ospf_interface *ospf_if_table_lookup(struct interface *ifp, struct ospf_interface *rninfo = NULL; p = *prefix; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; /* route_node_get implicitely locks */ if ((rn = route_node_lookup(IF_OIFS(ifp), &p))) { @@ -205,7 +205,7 @@ static void ospf_add_to_if(struct interface *ifp, struct ospf_interface *oi) struct prefix p; p = *oi->address; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; apply_mask(&p); rn = route_node_get(IF_OIFS(ifp), &p); @@ -223,7 +223,7 @@ static void ospf_delete_from_if(struct interface *ifp, struct prefix p; p = *oi->address; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; rn = route_node_lookup(IF_OIFS(oi->ifp), &p); assert(rn); @@ -566,7 +566,7 @@ void ospf_free_if_params(struct interface *ifp, struct in_addr addr) struct route_node *rn; p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = addr; rn = route_node_lookup(IF_OIFS_PARAMS(ifp), (struct prefix *)&p); if (!rn || !rn->info) @@ -601,7 +601,7 @@ struct ospf_if_params *ospf_lookup_if_params(struct interface *ifp, struct route_node *rn; p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = addr; rn = route_node_lookup(IF_OIFS_PARAMS(ifp), (struct prefix *)&p); @@ -621,7 +621,7 @@ struct ospf_if_params *ospf_get_if_params(struct interface *ifp, struct route_node *rn; p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = addr; apply_mask_ipv4(&p); diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 333fa6a3a1..d95e677f6f 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1840,7 +1840,7 @@ static void ospf_te_update_subnet(struct ls_ted *ted, struct ls_vertex *vertex, /** * Delete Subnet that correspond to the given IPv4 address and export deletion - * information before removal. Prefix length is fixed to IPV4_MAX_PREFIXLEN. + * information before removal. Prefix length is fixed to IPV4_MAX_BITLEN. * * @param ted Links State Database * @param addr IPv4 address @@ -1852,7 +1852,7 @@ static void ospf_te_delete_subnet(struct ls_ted *ted, struct in_addr addr) /* Search subnet that correspond to the address/32 as prefix */ p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = addr; subnet = ls_find_subnet(ted, p); @@ -1944,7 +1944,7 @@ static int ospf_te_parse_router_lsa(struct ls_ted *ted, struct ospf_lsa *lsa) ntohs(rl->link[i].metric)); /* Add corresponding subnet */ p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = rl->link[i].link_data; metric = ntohs(rl->link[i].metric); ospf_te_update_subnet(ted, vertex, p, metric); @@ -1952,7 +1952,7 @@ static int ospf_te_parse_router_lsa(struct ls_ted *ted, struct ospf_lsa *lsa) case LSA_LINK_TYPE_STUB: /* Keep only /32 prefix */ p.prefixlen = ip_masklen(rl->link[i].link_data); - if (p.prefixlen == IPV4_MAX_PREFIXLEN) { + if (p.prefixlen == IPV4_MAX_BITLEN) { p.family = AF_INET; p.u.prefix4 = rl->link[i].link_id; metric = ntohs(rl->link[i].metric); @@ -2086,12 +2086,12 @@ static void ospf_te_update_remote_asbr(struct ls_ted *ted, struct ls_edge *edge) /* Update corresponding Subnets */ p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = attr->standard.local; ospf_te_update_subnet(ted, edge->source, p, attr->standard.te_metric); p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = attr->standard.remote_addr; ospf_te_update_subnet(ted, vertex, p, attr->standard.te_metric); diff --git a/ospfd/ospf_ti_lfa.c b/ospfd/ospf_ti_lfa.c index 59b3b624e3..347128a4f4 100644 --- a/ospfd/ospf_ti_lfa.c +++ b/ospfd/ospf_ti_lfa.c @@ -849,7 +849,7 @@ void ospf_ti_lfa_generate_p_spaces(struct ospf_area *area, stub_prefix.family = AF_INET; child_prefix.family = AF_INET; - child_prefix.prefixlen = IPV4_MAX_PREFIXLEN; + child_prefix.prefixlen = IPV4_MAX_BITLEN; p = ((uint8_t *)root->lsa) + OSPF_LSA_HEADER_SIZE + 4; lim = ((uint8_t *)root->lsa) + ntohs(root->lsa->length); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 54ce248d89..db8e961b8b 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -6616,7 +6616,7 @@ static void show_lsa_prefix_set(struct vty *vty, struct prefix_ls *lp, if (id == NULL) lp->prefixlen = 0; else if (adv_router == NULL) { - lp->prefixlen = 32; + lp->prefixlen = IPV4_MAX_BITLEN; lp->id = *id; } else { lp->prefixlen = 64; @@ -10913,6 +10913,8 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, "N E1"); json_object_int_add(json_route, "cost", er->cost); + json_object_int_add(json_route, "tag", + er->u.ext.tag); } else { vty_out(vty, "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI @@ -10926,6 +10928,10 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, "N E2"); json_object_int_add(json_route, "cost", er->cost); + json_object_int_add(json_route, "type2cost", + er->u.ext.type2_cost); + json_object_int_add(json_route, "tag", + er->u.ext.tag); } else { vty_out(vty, "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index df112edc68..017915e0ee 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -138,7 +138,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS) ifp = c->ifp; p = *c->address; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; rn = route_node_lookup(IF_OIFS(ifp), &p); if (!rn) { diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index eb41bf6043..fc5303c9d8 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -286,11 +286,13 @@ static void route_add_helper(struct zapi_route *api, struct nexthop_group nhg, api_nh->ifindex = nhop->ifindex; break; case NEXTHOP_TYPE_IPV6: - memcpy(&api_nh->gate.ipv6, &nhop->gate.ipv6, 16); + memcpy(&api_nh->gate.ipv6, &nhop->gate.ipv6, + IPV6_MAX_BYTELEN); break; case NEXTHOP_TYPE_IPV6_IFINDEX: api_nh->ifindex = nhop->ifindex; - memcpy(&api_nh->gate.ipv6, &nhop->gate.ipv6, 16); + memcpy(&api_nh->gate.ipv6, &nhop->gate.ipv6, + IPV6_MAX_BYTELEN); break; case NEXTHOP_TYPE_BLACKHOLE: api_nh->bh_type = nhop->bh_type; @@ -460,13 +462,13 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg) case NEXTHOP_TYPE_IPV4_IFINDEX: p.family = AF_INET; p.u.prefix4.s_addr = nhop->gate.ipv4.s_addr; - p.prefixlen = 32; + p.prefixlen = IPV4_MAX_BITLEN; break; case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6_IFINDEX: p.family = AF_INET6; - memcpy(&p.u.prefix6, &nhop->gate.ipv6, 16); - p.prefixlen = 128; + memcpy(&p.u.prefix6, &nhop->gate.ipv6, IPV6_MAX_BYTELEN); + p.prefixlen = IPV6_MAX_BITLEN; if (IN6_IS_ADDR_LINKLOCAL(&nhop->gate.ipv6)) /* * Don't bother tracking link locals, just track their diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index ad5257630b..0181e885fd 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -1253,7 +1253,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf, bshdr = (struct bsm_hdr *)(buf + PIM_MSG_HEADER_LEN); pim_inet4_dump("<bsr?>", bshdr->bsr_addr.addr, bsr_str, sizeof(bsr_str)); - if (bshdr->hm_len > 32) { + if (bshdr->hm_len > IPV4_MAX_BITLEN) { zlog_warn("Bad hashmask length for IPv4; got %hhu, expected value in range 0-32", bshdr->hm_len); pim->bsm_dropped++; diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 353f133001..48b019c8c8 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -1139,7 +1139,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp, p.family = AF_INET; p.u.prefix4 = addr; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) { diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 1bf3a619bf..9ee06edfc1 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -1248,7 +1248,7 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, AFI_IP, pim->spt.plist); struct prefix g; g.family = AF_INET; - g.prefixlen = IPV4_MAX_PREFIXLEN; + g.prefixlen = IPV4_MAX_BITLEN; g.u.prefix4 = up->sg.grp; if (prefix_list_apply(plist, &g) diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index 3ae7744eb0..afa2db5f15 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -1953,7 +1953,7 @@ int igmp_v3_recv_report(struct igmp_sock *igmp, struct in_addr from, g.family = AF_INET; g.u.prefix4 = rec_group; - g.prefixlen = 32; + g.prefixlen = IPV4_MAX_BITLEN; /* determine filtering status for group */ filtered = pim_is_group_filtered(ifp->info, &rec_group); diff --git a/pimd/pim_msdp_packet.c b/pimd/pim_msdp_packet.c index 6d49708827..eb5f46951e 100644 --- a/pimd/pim_msdp_packet.c +++ b/pimd/pim_msdp_packet.c @@ -505,7 +505,7 @@ static void pim_msdp_pkt_sa_rx_one(struct pim_msdp_peer *mp, struct in_addr rp) sg.grp.s_addr = stream_get_ipv4(mp->ibuf); sg.src.s_addr = stream_get_ipv4(mp->ibuf); - if (prefix_len != 32) { + if (prefix_len != IPV4_MAX_BITLEN) { /* ignore SA update if the prefix length is not 32 */ flog_err(EC_PIM_MSDP_PACKET, "rxed sa update with invalid prefix length %d", diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 90b69a54f2..9d5b864ab0 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -89,7 +89,7 @@ void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg, p.family = AF_INET; p.u.prefix4 = sg->src; - p.prefixlen = 32; + p.prefixlen = IPV4_MAX_BITLEN; length = pim_encode_addr_ucast(b1, &p); b1length += length; @@ -393,7 +393,7 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr, plist = prefix_list_lookup(AFI_IP, pim->register_plist); src.family = AF_INET; - src.prefixlen = IPV4_MAX_PREFIXLEN; + src.prefixlen = IPV4_MAX_BITLEN; src.u.prefix4 = sg.src; if (prefix_list_apply(plist, &src) == PREFIX_DENY) { diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index a31fec036f..b6521132f7 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -124,7 +124,7 @@ void pim_rp_init(struct pim_instance *pim) } rp_info->group.family = AF_INET; rp_info->rp.rpf_addr.family = AF_INET; - rp_info->rp.rpf_addr.prefixlen = IPV4_MAX_PREFIXLEN; + rp_info->rp.rpf_addr.prefixlen = IPV4_MAX_BITLEN; rp_info->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE; listnode_add(pim->rp_list, rp_info); @@ -417,7 +417,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr, rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info)); rp_info->rp.rpf_addr.family = AF_INET; - rp_info->rp.rpf_addr.prefixlen = IPV4_MAX_PREFIXLEN; + rp_info->rp.rpf_addr.prefixlen = IPV4_MAX_BITLEN; rp_info->rp.rpf_addr.u.prefix4 = rp_addr; prefix_copy(&rp_info->group, &group); rp_info->rp_src = rp_src_flag; @@ -1036,7 +1036,7 @@ int pim_rp_i_am_rp(struct pim_instance *pim, struct in_addr group) memset(&g, 0, sizeof(g)); g.family = AF_INET; - g.prefixlen = 32; + g.prefixlen = IPV4_MAX_BITLEN; g.u.prefix4 = group; rp_info = pim_rp_find_match_group(pim, &g); @@ -1059,7 +1059,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group) memset(&g, 0, sizeof(g)); g.family = AF_INET; - g.prefixlen = 32; + g.prefixlen = IPV4_MAX_BITLEN; g.u.prefix4 = group; rp_info = pim_rp_find_match_group(pim, &g); @@ -1103,7 +1103,7 @@ int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up, memset(&g, 0, sizeof(g)); g.family = AF_INET; - g.prefixlen = 32; + g.prefixlen = IPV4_MAX_BITLEN; g.u.prefix4 = group; rp_info = pim_rp_find_match_group(pim, &g); diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index f21c369b8d..8e6ff2f3a7 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -481,7 +481,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size) p->family = AF_INET; /* notice: AF_INET != PIM_MSG_ADDRESS_FAMILY_IPV4 */ memcpy(&p->u.prefix4, addr, sizeof(struct in_addr)); - p->prefixlen = IPV4_MAX_PREFIXLEN; + p->prefixlen = IPV4_MAX_BITLEN; addr += sizeof(struct in_addr); break; @@ -495,7 +495,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size) } p->family = AF_INET6; - p->prefixlen = IPV6_MAX_PREFIXLEN; + p->prefixlen = IPV6_MAX_BITLEN; memcpy(&p->u.prefix6, addr, sizeof(struct in6_addr)); addr += sizeof(struct in6_addr); @@ -626,7 +626,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags, messages received with any other mask length. */ - if (mask_len != 32) { + if (mask_len != IPV4_MAX_BITLEN) { zlog_warn("%s: IPv4 bad source address mask: %d", __func__, mask_len); return -4; diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 918a9a9c7d..2b674b4234 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -2174,7 +2174,7 @@ void pim_upstream_remove_lhr_star_pimreg(struct pim_instance *pim, np = prefix_list_lookup(AFI_IP, nlist); g.family = AF_INET; - g.prefixlen = IPV4_MAX_PREFIXLEN; + g.prefixlen = IPV4_MAX_BITLEN; frr_each (rb_pim_upstream, &pim->upstream_head, up) { if (up->sg.src.s_addr != INADDR_ANY) diff --git a/pimd/pim_util.c b/pimd/pim_util.c index 15bde256da..decc491ede 100644 --- a/pimd/pim_util.c +++ b/pimd/pim_util.c @@ -115,7 +115,7 @@ int pim_is_group_224_0_0_0_24(struct in_addr group_addr) group.family = AF_INET; group.u.prefix4 = group_addr; - group.prefixlen = IPV4_MAX_PREFIXLEN; + group.prefixlen = IPV4_MAX_BITLEN; return prefix_match(&group_224, &group); } @@ -134,7 +134,7 @@ int pim_is_group_224_4(struct in_addr group_addr) group.family = AF_INET; group.u.prefix4 = group_addr; - group.prefixlen = 32; + group.prefixlen = IPV4_MAX_BITLEN; return prefix_match(&group_all, &group); } @@ -148,7 +148,7 @@ bool pim_is_group_filtered(struct pim_interface *pim_ifp, struct in_addr *grp) return false; grp_pfx.family = AF_INET; - grp_pfx.prefixlen = 32; + grp_pfx.prefixlen = IPV4_MAX_BITLEN; grp_pfx.u.prefix4 = *grp; pl = prefix_list_lookup(AFI_IP, pim_ifp->boundary_oil_plist); diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 9ccf1fedd4..dce936b8a9 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -276,7 +276,7 @@ static int zclient_read_nexthop(struct pim_instance *pim, nexthop_tab[num_ifindex].ifindex = stream_getl(s); p.family = AF_INET6; - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; memcpy(&p.u.prefix6, &nexthop_tab[num_ifindex].nexthop_addr.u.prefix6, sizeof(struct in6_addr)); diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index bdae2c5ef5..7a8e10f30b 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -160,7 +160,7 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version) * destination addr */ to.sin_addr = connected->destination->u.prefix4; else if (connected->address->prefixlen - < IPV4_MAX_PREFIXLEN) + < IPV4_MAX_BITLEN) /* calculate the appropriate broadcast * address */ to.sin_addr.s_addr = ipv4_broadcast_addr( diff --git a/ripd/ripd.c b/ripd/ripd.c index 7d940efd9c..ccd4bf1bac 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2143,7 +2143,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to, &rp->p)) { if ((ifc->address->prefixlen != rp->p.prefixlen) - && (rp->p.prefixlen != 32)) + && (rp->p.prefixlen + != IPV4_MAX_BITLEN)) continue; } else { memcpy(&classfull, &rp->p, @@ -2429,7 +2430,7 @@ static void rip_update_interface(struct connected *ifc, uint8_t version, /* use specified broadcast or peer destination * addr */ to.sin_addr = ifc->destination->u.prefix4; - else if (ifc->address->prefixlen < IPV4_MAX_PREFIXLEN) + else if (ifc->address->prefixlen < IPV4_MAX_BITLEN) /* calculate the appropriate broadcast address */ to.sin_addr.s_addr = ipv4_broadcast_addr( diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index a0ea18f3e9..cbd2c22893 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1194,7 +1194,7 @@ static void ripng_response_process(struct ripng_packet *packet, int size, /* - is the prefix length valid (i.e., between 0 and 128, inclusive) */ - if (rte->prefixlen > 128) { + if (rte->prefixlen > IPV6_MAX_BITLEN) { zlog_warn("Invalid prefix length %pI6/%d from %pI6%%%s", &rte->addr, rte->prefixlen, &from->sin6_addr, ifp->name); diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 250151b1fa..b6581cd9e6 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -97,8 +97,8 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd, if (n) { type_import = false; - p.prefixlen = 128; - memcpy(&p.u.prefix6, &nhop, 16); + p.prefixlen = IPV6_MAX_BITLEN; + memcpy(&p.u.prefix6, &nhop, IPV6_MAX_BYTELEN); p.family = AF_INET6; } else { type_import = true; @@ -141,7 +141,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd, if (n) { type_import = false; - p.prefixlen = 32; + p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = nhop; p.family = AF_INET; } @@ -239,11 +239,11 @@ DEFPY (install_routes, if (start4.s_addr != INADDR_ANY) { prefix.family = AF_INET; - prefix.prefixlen = 32; + prefix.prefixlen = IPV4_MAX_BITLEN; prefix.u.prefix4 = start4; } else { prefix.family = AF_INET6; - prefix.prefixlen = 128; + prefix.prefixlen = IPV6_MAX_BITLEN; prefix.u.prefix6 = start6; } sg.r.orig_prefix = prefix; @@ -383,11 +383,11 @@ DEFPY (install_seg6_routes, if (start4.s_addr != INADDR_ANY) { prefix.family = AF_INET; - prefix.prefixlen = 32; + prefix.prefixlen = IPV4_MAX_BITLEN; prefix.u.prefix4 = start4; } else { prefix.family = AF_INET6; - prefix.prefixlen = 128; + prefix.prefixlen = IPV6_MAX_BITLEN; prefix.u.prefix6 = start6; } sg.r.orig_prefix = prefix; @@ -568,11 +568,11 @@ DEFPY (remove_routes, if (start4.s_addr != INADDR_ANY) { prefix.family = AF_INET; - prefix.prefixlen = 32; + prefix.prefixlen = IPV4_MAX_BITLEN; prefix.u.prefix4 = start4; } else { prefix.family = AF_INET6; - prefix.prefixlen = 128; + prefix.prefixlen = IPV6_MAX_BITLEN; prefix.u.prefix6 = start6; } @@ -878,7 +878,7 @@ DEFPY (neigh_discover, if (dst4.s_addr != INADDR_ANY) { prefix.family = AF_INET; - prefix.prefixlen = 32; + prefix.prefixlen = IPV4_MAX_BITLEN; prefix.u.prefix4 = dst4; } else { prefix.family = AF_INET6; diff --git a/staticd/static_nht.c b/staticd/static_nht.c index feb6e0f993..d42c5c2777 100644 --- a/staticd/static_nht.c +++ b/staticd/static_nht.c @@ -52,7 +52,8 @@ static void static_nht_update_path(struct route_node *rn, nh->nh_valid = !!nh_num; if (nhp->family == AF_INET6 - && memcmp(&nhp->u.prefix6, &nh->addr.ipv6, 16) == 0) + && memcmp(&nhp->u.prefix6, &nh->addr.ipv6, IPV6_MAX_BYTELEN) + == 0) nh->nh_valid = !!nh_num; if (nh->state == STATIC_START) diff --git a/zebra/connected.c b/zebra/connected.c index dc7193eb4c..e1dd0dbdff 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -75,7 +75,7 @@ static void connected_announce(struct interface *ifp, struct connected *ifc) if (!if_is_loopback(ifp) && ifc->address->family == AF_INET && !IS_ZEBRA_IF_VRF(ifp)) { - if (ifc->address->prefixlen == 32) + if (ifc->address->prefixlen == IPV4_MAX_BITLEN) SET_FLAG(ifc->flags, ZEBRA_IFA_UNNUMBERED); else UNSET_FLAG(ifc->flags, ZEBRA_IFA_UNNUMBERED); @@ -330,8 +330,8 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr, p = prefix_ipv4_new(); p->family = AF_INET; p->prefix = *addr; - p->prefixlen = CHECK_FLAG(flags, ZEBRA_IFA_PEER) ? IPV4_MAX_PREFIXLEN - : prefixlen; + p->prefixlen = + CHECK_FLAG(flags, ZEBRA_IFA_PEER) ? IPV4_MAX_BITLEN : prefixlen; ifc->address = (struct prefix *)p; /* If there is a peer address. */ @@ -358,8 +358,7 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr, } /* no destination address was supplied */ - if (!dest && (prefixlen == IPV4_MAX_PREFIXLEN) - && if_is_pointopoint(ifp)) + if (!dest && (prefixlen == IPV4_MAX_BITLEN) && if_is_pointopoint(ifp)) zlog_debug( "PtP interface %s with addr %pI4/%d needs a peer address", ifp->name, addr, prefixlen); @@ -512,8 +511,8 @@ void connected_delete_ipv4(struct interface *ifp, int flags, memset(&p, 0, sizeof(struct prefix)); p.family = AF_INET; p.u.prefix4 = *addr; - p.prefixlen = CHECK_FLAG(flags, ZEBRA_IFA_PEER) ? IPV4_MAX_PREFIXLEN - : prefixlen; + p.prefixlen = + CHECK_FLAG(flags, ZEBRA_IFA_PEER) ? IPV4_MAX_BITLEN : prefixlen; if (dest) { memset(&d, 0, sizeof(struct prefix)); diff --git a/zebra/interface.c b/zebra/interface.c index 7fd967dd8b..408c016494 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -3055,7 +3055,7 @@ static int ip_address_install(struct vty *vty, struct interface *ifp, } if (peer_str) { - if (lp.prefixlen != 32) { + if (lp.prefixlen != IPV4_MAX_BITLEN) { vty_out(vty, "%% Local prefix length for P-t-P address must be /32\n"); return CMD_WARNING_CONFIG_FAILED; @@ -3186,7 +3186,7 @@ static int ip_address_uninstall(struct vty *vty, struct interface *ifp, } if (peer_str) { - if (lp.prefixlen != 32) { + if (lp.prefixlen != IPV4_MAX_BITLEN) { vty_out(vty, "%% Local prefix length for P-t-P address must be /32\n"); return CMD_WARNING_CONFIG_FAILED; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 03884a9168..252bf04782 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -1066,7 +1066,7 @@ void rtm_read(struct rt_msghdr *rtm) p.family = AF_INET; p.u.prefix4 = dest.sin.sin_addr; if (flags & RTF_HOST) - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; else p.prefixlen = ip_masklen(mask.sin.sin_addr); @@ -1079,7 +1079,7 @@ void rtm_read(struct rt_msghdr *rtm) p.family = AF_INET6; p.u.prefix6 = dest.sin6.sin6_addr; if (flags & RTF_HOST) - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; else p.prefixlen = ip6_masklen(mask.sin6.sin6_addr); diff --git a/zebra/router-id.c b/zebra/router-id.c index 3b556c92b5..689b9787ee 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -81,7 +81,7 @@ int router_id_get(afi_t afi, struct prefix *p, struct zebra_vrf *zvrf) case AFI_IP: p->u.prefix4.s_addr = INADDR_ANY; p->family = AF_INET; - p->prefixlen = 32; + p->prefixlen = IPV4_MAX_BITLEN; if (zvrf->rid_user_assigned.u.prefix4.s_addr != INADDR_ANY) p->u.prefix4.s_addr = zvrf->rid_user_assigned.u.prefix4.s_addr; @@ -98,7 +98,7 @@ int router_id_get(afi_t afi, struct prefix *p, struct zebra_vrf *zvrf) case AFI_IP6: p->u.prefix6 = in6addr_any; p->family = AF_INET6; - p->prefixlen = 128; + p->prefixlen = IPV6_MAX_BITLEN; if (!router_id_v6_is_any(&zvrf->rid6_user_assigned)) addr = &zvrf->rid6_user_assigned.u.prefix6; else if (!list_isempty(zvrf->rid6_lo_sorted_list)) { @@ -276,7 +276,7 @@ DEFUN (ip_router_id, if (!inet_pton(AF_INET, argv[idx]->arg, &rid.u.prefix4)) return CMD_WARNING_CONFIG_FAILED; - rid.prefixlen = 32; + rid.prefixlen = IPV4_MAX_BITLEN; rid.family = AF_INET; argv_find(argv, argc, "NAME", &idx); @@ -313,7 +313,7 @@ DEFUN (ipv6_router_id, if (!inet_pton(AF_INET6, argv[idx]->arg, &rid.u.prefix6)) return CMD_WARNING_CONFIG_FAILED; - rid.prefixlen = 128; + rid.prefixlen = IPV6_MAX_BITLEN; rid.family = AF_INET6; argv_find(argv, argc, "NAME", &idx); @@ -342,7 +342,7 @@ DEFUN (ip_router_id_in_vrf, if (!inet_pton(AF_INET, argv[idx]->arg, &rid.u.prefix4)) return CMD_WARNING_CONFIG_FAILED; - rid.prefixlen = 32; + rid.prefixlen = IPV4_MAX_BITLEN; rid.family = AF_INET; router_id_set(AFI_IP, &rid, zvrf); @@ -372,7 +372,7 @@ DEFUN (ipv6_router_id_in_vrf, if (!inet_pton(AF_INET6, argv[idx]->arg, &rid.u.prefix6)) return CMD_WARNING_CONFIG_FAILED; - rid.prefixlen = 128; + rid.prefixlen = IPV6_MAX_BITLEN; rid.family = AF_INET6; router_id_set(AFI_IP6, &rid, zvrf); @@ -599,7 +599,7 @@ void router_id_init(struct zebra_vrf *zvrf) zvrf->rid6_lo_sorted_list->cmp = router_id_v6_cmp; zvrf->rid_user_assigned.family = AF_INET; - zvrf->rid_user_assigned.prefixlen = 32; + zvrf->rid_user_assigned.prefixlen = IPV4_MAX_BITLEN; zvrf->rid6_user_assigned.family = AF_INET6; - zvrf->rid6_user_assigned.prefixlen = 128; + zvrf->rid6_user_assigned.prefixlen = IPV6_MAX_BITLEN; } diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 8cb0223a46..976beefab0 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -693,7 +693,7 @@ static void rtadv_process_advert(uint8_t *msg, unsigned int len, /* Create entry for neighbor if not known. */ p.family = AF_INET6; IPV6_ADDR_COPY(&p.u.prefix6, &addr->sin6_addr); - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; if (!nbr_connected_check(ifp, &p)) nbr_connected_add_ipv6(ifp, &addr->sin6_addr); diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index d5969ab9bb..8f2aa2fb09 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -480,7 +480,7 @@ void nbr_connected_add_ipv6(struct interface *ifp, struct in6_addr *address) p.family = AF_INET6; IPV6_ADDR_COPY(&p.u.prefix6, address); - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; ifc = listnode_head(ifp->nbr_connected); if (!ifc) { @@ -505,7 +505,7 @@ void nbr_connected_delete_ipv6(struct interface *ifp, struct in6_addr *address) p.family = AF_INET6; IPV6_ADDR_COPY(&p.u.prefix6, address); - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; ifc = nbr_connected_check(ifp, &p); if (!ifc) diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index a5d672987d..04411fa0d2 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -2537,8 +2537,7 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx, */ memcpy(&p.u, &pw->nexthop, sizeof(pw->nexthop)); p.family = pw->af; - p.prefixlen = ((pw->af == AF_INET) ? - IPV4_MAX_PREFIXLEN : IPV6_MAX_PREFIXLEN); + p.prefixlen = ((pw->af == AF_INET) ? IPV4_MAX_BITLEN : IPV6_MAX_BITLEN); afi = (pw->af == AF_INET) ? AFI_IP : AFI_IP6; table = zebra_vrf_table(afi, SAFI_UNICAST, pw->vrf_id); diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index a4576b310e..a2d1513ce4 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -613,7 +613,7 @@ static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe, /* Lookup nexthop in IPv4 routing table. */ memset(&p, 0, sizeof(struct prefix_ipv4)); p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.prefix = nexthop->gate.ipv4; rn = route_node_match(table, (struct prefix *)&p); @@ -662,7 +662,7 @@ static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe, /* Lookup nexthop in IPv6 routing table. */ memset(&p, 0, sizeof(struct prefix_ipv6)); p.family = AF_INET6; - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; p.prefix = nexthop->gate.ipv6; rn = route_node_match(table, (struct prefix *)&p); diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index face0ef3bc..af86263a16 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2048,11 +2048,13 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, return 1; } - if (top && - ((top->family == AF_INET && top->prefixlen == 32 - && nexthop->gate.ipv4.s_addr == top->u.prefix4.s_addr) - || (top->family == AF_INET6 && top->prefixlen == 128 - && memcmp(&nexthop->gate.ipv6, &top->u.prefix6, 16) == 0))) { + if (top + && ((top->family == AF_INET && top->prefixlen == IPV4_MAX_BITLEN + && nexthop->gate.ipv4.s_addr == top->u.prefix4.s_addr) + || (top->family == AF_INET6 && top->prefixlen == IPV6_MAX_BITLEN + && memcmp(&nexthop->gate.ipv6, &top->u.prefix6, + IPV6_MAX_BYTELEN) + == 0))) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug( " :%s: Attempting to install a max prefixlength route through itself", @@ -2118,12 +2120,12 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, switch (afi) { case AFI_IP: p.family = AF_INET; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; p.u.prefix4 = *ipv4; break; case AFI_IP6: p.family = AF_INET6; - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; p.u.prefix6 = nexthop->gate.ipv6; break; default: @@ -2150,8 +2152,10 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, * host route. */ if (prefix_same(&rn->p, top)) - if (((afi == AFI_IP) && (rn->p.prefixlen != 32)) - || ((afi == AFI_IP6) && (rn->p.prefixlen != 128))) { + if (((afi == AFI_IP) + && (rn->p.prefixlen != IPV4_MAX_BITLEN)) + || ((afi == AFI_IP6) + && (rn->p.prefixlen != IPV6_MAX_BITLEN))) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug( " %s: Matched against ourself and prefix length is not max bit length", diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 73c2c3dda3..7bcd097371 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -925,8 +925,8 @@ static const char *zebra_pbr_prefix2str(union prefixconstptr pu, const struct prefix *p = pu.p; char buf[PREFIX2STR_BUFFER]; - if ((p->family == AF_INET && p->prefixlen == IPV4_MAX_PREFIXLEN) || - (p->family == AF_INET6 && p->prefixlen == IPV6_MAX_PREFIXLEN)) { + if ((p->family == AF_INET && p->prefixlen == IPV4_MAX_BITLEN) + || (p->family == AF_INET6 && p->prefixlen == IPV6_MAX_BITLEN)) { snprintf(str, size, "%s", inet_ntop(p->family, &p->u.prefix, buf, PREFIX2STR_BUFFER)); return str; diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index d0acf77936..12cc0b4e8a 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -349,10 +349,10 @@ struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id, p.family = afi; if (afi == AFI_IP) { p.u.prefix4 = addr->ipv4; - p.prefixlen = IPV4_MAX_PREFIXLEN; + p.prefixlen = IPV4_MAX_BITLEN; } else { p.u.prefix6 = addr->ipv6; - p.prefixlen = IPV6_MAX_PREFIXLEN; + p.prefixlen = IPV6_MAX_BITLEN; } rn = route_node_match(table, &p); |
