diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-07-01 17:53:21 +0300 | 
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-07-01 17:53:21 +0300 | 
| commit | 13ccce6e7e5b6f7801910fca53c4c45502bf6213 (patch) | |
| tree | 1137ab12737b73f976df3df678ab826a8d335c71 | |
| parent | 936fbaef4794277a56185c535574df0f2771c117 (diff) | |
*: Convert numeric 128 into IPV6_MAX_BITLEN for prefixlen
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
| -rw-r--r-- | bgpd/bgp_label.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_mplsvpn.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi.c | 4 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_private.h | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 4 | ||||
| -rw-r--r-- | bgpd/rfapi/vnc_export_bgp.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/vnc_import_bgp.c | 6 | ||||
| -rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 5 | ||||
| -rw-r--r-- | isisd/isis_route.c | 2 | ||||
| -rw-r--r-- | isisd/isis_tlvs.c | 4 | ||||
| -rw-r--r-- | ldpd/lde.c | 4 | ||||
| -rw-r--r-- | ldpd/util.c | 2 | ||||
| -rw-r--r-- | lib/command_match.c | 2 | ||||
| -rw-r--r-- | lib/zclient.c | 2 | ||||
| -rw-r--r-- | pbrd/pbr_zebra.c | 2 | ||||
| -rw-r--r-- | ripngd/ripngd.c | 2 | ||||
| -rw-r--r-- | sharpd/sharp_vty.c | 8 | ||||
| -rw-r--r-- | zebra/router-id.c | 8 | ||||
| -rw-r--r-- | zebra/zebra_nhg.c | 14 | 
19 files changed, 40 insertions, 37 deletions
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index 73ca9f07e0..975f7ecbd7 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -391,7 +391,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,  		}  		if ((afi == AFI_IP && p.prefixlen > 32) -		    || (afi == AFI_IP6 && p.prefixlen > 128)) +		    || (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..8e794a1635 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -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/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index f89ef7b0d2..814fc8e3f6 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1615,7 +1615,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,  			if (target->addr_family == AF_INET) {  				rprefix.length = 32;  			} else { -				rprefix.length = 128; +				rprefix.length = IPV6_MAX_BITLEN;  			}  			pNHE = rfapiEthRouteTable2NextHopList( @@ -1692,7 +1692,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,  		if (target->addr_family == AF_INET) {  			rprefix.length = 32;  		} else { -			rprefix.length = 128; +			rprefix.length = IPV6_MAX_BITLEN;  		}  		pNHE = rfapiEthRouteNode2NextHopList( diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index e7825e8bfc..2451298ed4 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -269,7 +269,7 @@ struct rfapi {  	(((prefix)->family == AF_INET)                                         \  		 ? ((prefix)->prefixlen == 32)                                 \  		 : (((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 0c40aeb54e..9cf21a7db4 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -179,7 +179,7 @@ int rfapiQprefix2Raddr(struct prefix *qprefix, struct rfapi_ip_addr *raddr)  		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; @@ -1741,7 +1741,7 @@ int rfapiCliGetPrefixAddr(struct vty *vty, const char *str, struct prefix *p)  		}  		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 f8b8c7d680..dc5d3f73ef 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -600,7 +600,7 @@ encap_attr_export(struct attr *new, struct attr *orig,  			orig_nexthop.prefixlen = 32;  			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..21fe1fac69 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -110,7 +110,7 @@ static int is_host_prefix(const struct prefix *p)  	case AF_INET:  		return (p->prefixlen == 32);  	case AF_INET6: -		return (p->prefixlen == 128); +		return (p->prefixlen == IPV6_MAX_BITLEN);  	}  	return 0;  } @@ -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); @@ -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..a6a64d30ed 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -117,7 +117,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__, @@ -161,7 +162,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..4fd15f6c42 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -225,7 +225,7 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p,  				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..2a486c754e 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; @@ -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/lde.c b/ldpd/lde.c index 724e83adb2..1249db9937 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -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..ce74e9099b 100644 --- a/ldpd/util.c +++ b/ldpd/util.c @@ -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..367362f7b5 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -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/zclient.c b/lib/zclient.c index 7979f13f22..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; diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index eb41bf6043..6c353d9492 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -466,7 +466,7 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg)  	case NEXTHOP_TYPE_IPV6_IFINDEX:  		p.family = AF_INET6;  		memcpy(&p.u.prefix6, &nhop->gate.ipv6, 16); -		p.prefixlen = 128; +		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/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..271696daf9 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -97,7 +97,7 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,  	if (n) {  		type_import = false; -		p.prefixlen = 128; +		p.prefixlen = IPV6_MAX_BITLEN;  		memcpy(&p.u.prefix6, &nhop, 16);  		p.family = AF_INET6;  	} else { @@ -243,7 +243,7 @@ DEFPY (install_routes,  		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; @@ -387,7 +387,7 @@ DEFPY (install_seg6_routes,  		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; @@ -572,7 +572,7 @@ DEFPY (remove_routes,  		prefix.u.prefix4 = start4;  	} else {  		prefix.family = AF_INET6; -		prefix.prefixlen = 128; +		prefix.prefixlen = IPV6_MAX_BITLEN;  		prefix.u.prefix6 = start6;  	} diff --git a/zebra/router-id.c b/zebra/router-id.c index 3b556c92b5..e10eec55de 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -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)) { @@ -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); @@ -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); @@ -601,5 +601,5 @@ void router_id_init(struct zebra_vrf *zvrf)  	zvrf->rid_user_assigned.family = AF_INET;  	zvrf->rid_user_assigned.prefixlen = 32;  	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/zebra_nhg.c b/zebra/zebra_nhg.c index 7495a3a69a..3535bffd54 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2048,11 +2048,12 @@ 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 == 32 +		 && 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, 16) +			       == 0))) {  		if (IS_ZEBRA_DEBUG_RIB_DETAILED)  			zlog_debug(  				"        :%s: Attempting to install a max prefixlength route through itself", @@ -2151,7 +2152,8 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,  		 */  		if (prefix_same(&rn->p, top))  			if (((afi == AFI_IP) && (rn->p.prefixlen != 32)) -			    || ((afi == AFI_IP6) && (rn->p.prefixlen != 128))) { +			    || ((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",  | 
