From 801a9bcc7fc9a4f5553f5febcddccd4ae0f5978e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 18:04:00 -0700 Subject: [PATCH] Use #define for mp_nexthop_len values --- bgpd/bgp_attr.c | 41 ++++++++++++++++---------------- bgpd/bgp_attr.h | 6 +++++ bgpd/bgp_debug.c | 6 ++--- bgpd/bgp_mpath.c | 11 +++++---- bgpd/bgp_nexthop.c | 4 ++-- bgpd/bgp_nht.c | 2 +- bgpd/bgp_route.c | 54 +++++++++++++++++++++---------------------- bgpd/bgp_routemap.c | 14 +++++------ bgpd/bgp_updgrp_adv.c | 4 ++-- bgpd/bgp_zebra.c | 12 +++++----- 10 files changed, 81 insertions(+), 73 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 72d130b442..153c4064bc 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -456,8 +456,8 @@ attrhash_key_make (void *p) #ifdef HAVE_IPV6 MIX(extra->mp_nexthop_len); - key = jhash(extra->mp_nexthop_global.s6_addr, 16, key); - key = jhash(extra->mp_nexthop_local.s6_addr, 16, key); + key = jhash(extra->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); + key = jhash(extra->mp_nexthop_local.s6_addr, IPV6_MAX_BYTELEN, key); #endif /* HAVE_IPV6 */ } @@ -1584,24 +1584,24 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, /* Nexthop length check. */ switch (attre->mp_nexthop_len) { - case 4: - stream_get (&attre->mp_nexthop_global_in, s, 4); + case BGP_ATTR_NHLEN_IPV4: + stream_get (&attre->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); /* Probably needed for RFC 2283 */ if (attr->nexthop.s_addr == 0) - memcpy(&attr->nexthop.s_addr, &attre->mp_nexthop_global_in, 4); + memcpy(&attr->nexthop.s_addr, &attre->mp_nexthop_global_in, IPV4_MAX_BYTELEN); break; - case 12: + case BGP_ATTR_NHLEN_VPNV4: stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ - stream_get (&attre->mp_nexthop_global_in, s, 4); + stream_get (&attre->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); break; #ifdef HAVE_IPV6 - case 16: - stream_get (&attre->mp_nexthop_global, s, 16); + case BGP_ATTR_NHLEN_IPV6_GLOBAL: + stream_get (&attre->mp_nexthop_global, s, IPV6_MAX_BYTELEN); break; - case 32: - stream_get (&attre->mp_nexthop_global, s, 16); - stream_get (&attre->mp_nexthop_local, s, 16); + case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: + stream_get (&attre->mp_nexthop_global, s, IPV6_MAX_BYTELEN); + stream_get (&attre->mp_nexthop_local, s, IPV6_MAX_BYTELEN); if (! IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local)) { char buf1[INET6_ADDRSTRLEN]; @@ -1614,7 +1614,7 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, inet_ntop (AF_INET6, &attre->mp_nexthop_local, buf2, INET6_ADDRSTRLEN)); - attre->mp_nexthop_len = 16; + attre->mp_nexthop_len = IPV6_MAX_BYTELEN; } break; #endif /* HAVE_IPV6 */ @@ -2189,9 +2189,9 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, assert (attr->extra); bpacket_attr_vec_arr_set_vec (vecarr, BGP_ATTR_VEC_NH, s, attr); stream_putc (s, attre->mp_nexthop_len); - stream_put (s, &attre->mp_nexthop_global, 16); - if (attre->mp_nexthop_len == 32) - stream_put (s, &attre->mp_nexthop_local, 16); + stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); + if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + stream_put (s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN); } default: break; @@ -2760,7 +2760,8 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, #ifdef HAVE_IPV6 /* Add a MP_NLRI attribute to dump the IPv6 next hop */ if (prefix != NULL && prefix->family == AF_INET6 && attr->extra && - (attr->extra->mp_nexthop_len == 16 || attr->extra->mp_nexthop_len == 32) ) + (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || + attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) ) { int sizep; struct attr_extra *attre = attr->extra; @@ -2776,9 +2777,9 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, /* Next hop */ stream_putc(s, attre->mp_nexthop_len); - stream_put(s, &attre->mp_nexthop_global, 16); - if (attre->mp_nexthop_len == 32) - stream_put(s, &attre->mp_nexthop_local, 16); + stream_put(s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); + if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + stream_put(s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN); /* SNPA */ stream_putc(s, 0); diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 67d92b2bdd..4fbfcb900d 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -47,6 +47,12 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define BGP_ATTR_MIN_LEN 3 /* Attribute flag, type length. */ #define BGP_ATTR_DEFAULT_WEIGHT 32768 +/* Valid lengths for mp_nexthop_len */ +#define BGP_ATTR_NHLEN_IPV4 IPV4_MAX_BYTELEN +#define BGP_ATTR_NHLEN_VPNV4 12 +#define BGP_ATTR_NHLEN_IPV6_GLOBAL IPV6_MAX_BYTELEN +#define BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL (IPV6_MAX_BYTELEN * 2) + /* Additional/uncommon BGP attributes. * lazily allocated as and when a struct attr * requires it. diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 27d7e69782..b1fc7726f1 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -343,13 +343,13 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) char addrbuf[BUFSIZ]; /* Add MP case. */ - if (attr->extra->mp_nexthop_len == 16 - || attr->extra->mp_nexthop_len == 32) + if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL + || attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, addrbuf, BUFSIZ)); - if (attr->extra->mp_nexthop_len == 32) + if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, addrbuf, BUFSIZ)); diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index f6c091c3db..8ed928baf3 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -120,17 +120,17 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) { switch (ae1->mp_nexthop_len) { - case 4: - case 12: + case BGP_ATTR_NHLEN_IPV4: + case BGP_ATTR_NHLEN_VPNV4: compare = IPV4_ADDR_CMP (&ae1->mp_nexthop_global_in, &ae2->mp_nexthop_global_in); break; #ifdef HAVE_IPV6 - case 16: + case BGP_ATTR_NHLEN_IPV6_GLOBAL: compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); break; - case 32: + case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); if (!compare) @@ -145,7 +145,8 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) /* This can happen if one IPv6 peer sends you global and link-local * nexthops but another IPv6 peer only sends you global */ - else if (ae1->mp_nexthop_len == 16 || ae1->mp_nexthop_len == 32) + else if (ae1->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || + ae1->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 8095e6233e..8938cf7c0b 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -110,9 +110,9 @@ bgp_nexthop_onlink (afi_t afi, struct attr *attr) #ifdef HAVE_IPV6 else if (afi == AFI_IP6) { - if (attr->extra->mp_nexthop_len == 32) + if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) return 1; - else if (attr->extra->mp_nexthop_len == 16) + else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) { if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global)) return 1; diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index ceb231a6dd..26a52e5635 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -372,7 +372,7 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p) break; #ifdef HAVE_IPV6 case AFI_IP6: - if (ri->attr->extra->mp_nexthop_len != 16 + if (ri->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL || IN6_IS_ADDR_LINKLOCAL (&ri->attr->extra->mp_nexthop_global)) return -1; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index de140d46d5..7a5f01a3d1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1141,7 +1141,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, /* IPv6 global nexthop must be included. */ memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, IPV6_MAX_BYTELEN); - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } #endif /* HAVE_IPV6 */ } @@ -1154,16 +1154,16 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) { if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) - attr->extra->mp_nexthop_len=32; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; else - attr->extra->mp_nexthop_len=16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } /* Default nexthop_local treatment for non-RS-Clients */ else { /* Link-local address should not be transit to different peer. */ - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; /* Set link-local address for shared network peer. */ if (peer->shared_network @@ -1171,17 +1171,17 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, { memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, IPV6_MAX_BYTELEN); - attr->extra->mp_nexthop_len = 32; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } /* If bgpd act as BGP-4+ route-reflector, do not send link-local address.*/ if (reflect) - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; /* If BGP-4+ link-local nexthop is not link-local nexthop. */ if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } } @@ -1459,14 +1459,14 @@ subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, */ if (p->family == AF_INET6) { - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; if (!reflect) { if (peer->shared_network || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) && IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local))) - attr->extra->mp_nexthop_len = 32; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } /* Clear off link-local nexthop in source, if not needed. This may help @@ -1673,7 +1673,7 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, /* IPv6 global nexthop must be included. */ memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, IPV6_MAX_BYTELEN); - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } #endif /* HAVE_IPV6 */ } @@ -1688,9 +1688,9 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) { if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) - attre->mp_nexthop_len=32; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; else - attre->mp_nexthop_len=16; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } /* Default nexthop_local treatment for RS-Clients */ @@ -1701,9 +1701,9 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, (rsclient->ifindex == from->ifindex)) { if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) - attre->mp_nexthop_len=32; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; else - attre->mp_nexthop_len=16; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } /* Set link-local address for shared network peer. */ @@ -1712,11 +1712,11 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, { memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, IPV6_MAX_BYTELEN); - attre->mp_nexthop_len = 32; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } else - attre->mp_nexthop_len = 16; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } } @@ -1880,7 +1880,7 @@ subgroup_announce_check_rsclient (struct bgp_info *ri, /* IPv6 global nexthop must be included. */ memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, IPV6_MAX_BYTELEN); - attr->extra->mp_nexthop_len = 16; + attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } #endif /* HAVE_IPV6 */ } @@ -1895,9 +1895,9 @@ subgroup_announce_check_rsclient (struct bgp_info *ri, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) { if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) - attre->mp_nexthop_len=32; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; else - attre->mp_nexthop_len=16; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } /* Default nexthop_local treatment for RS-Clients */ @@ -1908,9 +1908,9 @@ subgroup_announce_check_rsclient (struct bgp_info *ri, (rsclient->ifindex == from->ifindex)) { if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) - attre->mp_nexthop_len=32; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; else - attre->mp_nexthop_len=16; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } /* Set link-local address for shared network peer. */ @@ -1919,11 +1919,11 @@ subgroup_announce_check_rsclient (struct bgp_info *ri, { memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, IPV6_MAX_BYTELEN); - attre->mp_nexthop_len = 32; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } else - attre->mp_nexthop_len = 16; + attre->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } } @@ -6378,7 +6378,7 @@ bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, { struct attr_extra *extra = bgp_attr_extra_get(&attr); extra->mp_nexthop_global = *nexthop6; - extra->mp_nexthop_len = 16; + extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } #endif @@ -6930,11 +6930,11 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, assert (attr->extra); char buf[BUFSIZ]; char buf1[BUFSIZ]; - if (attr->extra->mp_nexthop_len == 16) + if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) vty_out (vty, "%s", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf, BUFSIZ)); - else if (attr->extra->mp_nexthop_len == 32) + else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) vty_out (vty, "%s(%s)", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf, BUFSIZ), @@ -7304,7 +7304,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, #ifdef HAVE_IPV6 /* display nexthop local */ - if (attr->extra && attr->extra->mp_nexthop_len == 32) + if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { if (json_paths) { diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 09bbb01fe9..8be44e6595 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2091,7 +2091,7 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix, if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, rule)) return RMAP_MATCH; - if (bgp_info->attr->extra->mp_nexthop_len == 32 && + if (bgp_info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL && IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, rule)) return RMAP_MATCH; @@ -2194,7 +2194,7 @@ route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, /* Set nexthop length. */ if (bgp_info->attr->extra->mp_nexthop_len == 0) - bgp_info->attr->extra->mp_nexthop_len = 16; + bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_NEXTHOP_CHANGED); @@ -2260,8 +2260,8 @@ route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address; /* Set nexthop length. */ - if (bgp_info->attr->extra->mp_nexthop_len != 32) - bgp_info->attr->extra->mp_nexthop_len = 32; + if (bgp_info->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_NEXTHOP_CHANGED); @@ -2353,8 +2353,8 @@ route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix, /* The next hop value will be set as part of packet rewrite. */ /* Set nexthop length. */ - if (bgp_info->attr->extra->mp_nexthop_len != 32) - bgp_info->attr->extra->mp_nexthop_len = 32; + if (bgp_info->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } else { @@ -2362,7 +2362,7 @@ route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix, /* Set nexthop length. */ if (bgp_info->attr->extra->mp_nexthop_len == 0) - bgp_info->attr->extra->mp_nexthop_len = 16; + bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } } diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 764941a5f7..ff20776184 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -617,7 +617,7 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) /* IPv6 global nexthop must be included. */ memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, IPV6_MAX_BYTELEN); - ae->mp_nexthop_len = 16; + ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; /* If the peer is on shared nextwork and we have link-local nexthop set it. */ @@ -626,7 +626,7 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) { memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, IPV6_MAX_BYTELEN); - ae->mp_nexthop_len = 32; + ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } } #endif /* HAVE_IPV6 */ diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index ce2dc15612..59ca687cff 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -885,11 +885,11 @@ bgp_info_to_ipv6_nexthop (struct bgp_info *info) struct in6_addr *nexthop = NULL; /* Only global address nexthop exists. */ - if (info->attr->extra->mp_nexthop_len == 16) + if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) nexthop = &info->attr->extra->mp_nexthop_global; /* If both global and link-local address present. */ - if (info->attr->extra->mp_nexthop_len == 32) + if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { /* Workaround for Cisco's nexthop bug. */ if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->extra->mp_nexthop_global) @@ -1186,7 +1186,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, if (nexthop) { - if (info->attr->extra->mp_nexthop_len == 32) + if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) if (info->peer->nexthop.ifp) ifindex = info->peer->nexthop.ifp->ifindex; @@ -1224,7 +1224,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, if (nexthop == NULL) continue; - if (mpinfo->attr->extra->mp_nexthop_len == 32) + if (mpinfo->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) if (mpinfo->peer->nexthop.ifp) ifindex = mpinfo->peer->nexthop.ifp->ifindex; @@ -1391,11 +1391,11 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) nexthop = NULL; /* Only global address nexthop exists. */ - if (info->attr->extra->mp_nexthop_len == 16) + if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) nexthop = &info->attr->extra->mp_nexthop_global; /* If both global and link-local address present. */ - if (info->attr->extra->mp_nexthop_len == 32) + if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { nexthop = &info->attr->extra->mp_nexthop_local; if (info->peer->nexthop.ifp) -- 2.39.5