Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert IPv4 mapped IPv6 stuff for 10.1 #16587

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions bgpd/bgp_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
afi = BGP_ATTR_MP_NEXTHOP_LEN_IP6(pi->attr) ? AFI_IP6
: AFI_IP;

/* Validation for the ipv4 mapped ipv6 nexthop. */
if (IS_MAPPED_IPV6(&pi->attr->mp_nexthop_global)) {
afi = AFI_IP;
}

/* This will return true if the global IPv6 NH is a link local
* addr */
if (make_prefix(afi, pi, &p) < 0)
Expand Down Expand Up @@ -1035,11 +1040,19 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
p->u.prefix4 = p_orig->u.prefix4;
p->prefixlen = p_orig->prefixlen;
} else {
if (p_orig->family == AF_EVPN)
p->u.prefix4 = pi->attr->mp_nexthop_global_in;
else
p->u.prefix4 = pi->attr->nexthop;
p->prefixlen = IPV4_MAX_BITLEN;
if (IS_MAPPED_IPV6(&pi->attr->mp_nexthop_global)) {
ipv4_mapped_ipv6_to_ipv4(
&pi->attr->mp_nexthop_global, &ipv4);
p->u.prefix4 = ipv4;
p->prefixlen = IPV4_MAX_BITLEN;
} else {
if (p_orig->family == AF_EVPN)
p->u.prefix4 =
pi->attr->mp_nexthop_global_in;
else
p->u.prefix4 = pi->attr->nexthop;
p->prefixlen = IPV4_MAX_BITLEN;
}
}
break;
case AFI_IP6:
Expand All @@ -1055,7 +1068,6 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
/* If we receive MP_REACH nexthop with ::(LL)
* or LL(LL), use LL address as nexthop cache.
*/
p->prefixlen = IPV6_MAX_BITLEN;
if (pi->attr &&
pi->attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
Expand All @@ -1070,22 +1082,15 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
pi->attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
if (CHECK_FLAG(pi->attr->nh_flags,
BGP_ATTR_NH_MP_PREFER_GLOBAL)) {
if (IS_MAPPED_IPV6(
&pi->attr->mp_nexthop_global)) {
ipv4_mapped_ipv6_to_ipv4(
&pi->attr->mp_nexthop_global,
&ipv4);
p->u.prefix4 = ipv4;
p->prefixlen = IPV4_MAX_BITLEN;
} else
p->u.prefix6 =
pi->attr->mp_nexthop_global;
} else
BGP_ATTR_NH_MP_PREFER_GLOBAL))
p->u.prefix6 =
pi->attr->mp_nexthop_global;
else
p->u.prefix6 =
pi->attr->mp_nexthop_local;
} else
p->u.prefix6 = pi->attr->mp_nexthop_global;
p->prefixlen = IPV6_MAX_BITLEN;
}
break;
default:
Expand Down
5 changes: 4 additions & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -9659,7 +9659,10 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
json_object_string_add(json_nexthop_ll, "scope",
"link-local");

if (!CHECK_FLAG(attr->nh_flags,
if ((IPV6_ADDR_CMP(&attr->mp_nexthop_global,
&attr->mp_nexthop_local) !=
0) &&
!CHECK_FLAG(attr->nh_flags,
BGP_ATTR_NH_MP_PREFER_GLOBAL))
json_object_boolean_true_add(
json_nexthop_ll, "used");
Expand Down
12 changes: 5 additions & 7 deletions bgpd/bgp_updgrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,11 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
gnh_modified = 1;
}

if (peer->nexthop.v4.s_addr != INADDR_ANY &&
(IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) ||
(IN6_IS_ADDR_LINKLOCAL(mod_v6nhg) &&
peer->connection->su.sa.sa_family == AF_INET6 &&
paf->afi == AFI_IP))) {
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg, peer->nexthop.v4);
gnh_modified = 1;
if (IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg)) {
if (peer->nexthop.v4.s_addr != INADDR_ANY) {
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg,
peer->nexthop.v4);
}
}

if (IS_MAPPED_IPV6(&peer->nexthop.v6_global)) {
Expand Down
150 changes: 60 additions & 90 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,11 @@ static int bgp_ifp_down(struct interface *ifp)

static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
{
struct connected *ifc, *connected;
struct connected *ifc;
struct bgp *bgp;
struct peer *peer;
struct prefix *addr;
struct listnode *node, *nnode;
bool v6_ll_in_nh_global;
afi_t afi;
safi_t safi;

Expand All @@ -326,70 +325,56 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
if (!bgp)
return 0;

if (!if_is_operative(ifc->ifp))
return 0;

bgp_connected_add(bgp, ifc);
if (if_is_operative(ifc->ifp)) {
bgp_connected_add(bgp, ifc);

/* If we have learnt of any neighbors on this interface,
* check to kick off any BGP interface-based neighbors,
* but only if this is a link-local address.
*/
if (IN6_IS_ADDR_LINKLOCAL(&ifc->address->u.prefix6) &&
!list_isempty(ifc->ifp->nbr_connected))
bgp_start_interface_nbrs(bgp, ifc->ifp);
else if (ifc->address->family == AF_INET6 &&
!IN6_IS_ADDR_LINKLOCAL(&ifc->address->u.prefix6)) {
addr = ifc->address;
/* If we have learnt of any neighbors on this interface,
* check to kick off any BGP interface-based neighbors,
* but only if this is a link-local address.
*/
if (IN6_IS_ADDR_LINKLOCAL(&ifc->address->u.prefix6)
&& !list_isempty(ifc->ifp->nbr_connected))
bgp_start_interface_nbrs(bgp, ifc->ifp);
else {
addr = ifc->address;

for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
v6_ll_in_nh_global = false;

if (IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global)) {
frr_each (if_connected, ifc->ifp->connected,
connected) {
if (connected->address->family !=
AF_INET6)
continue;
if (!IPV6_ADDR_SAME(&connected->address
->u.prefix6,
&peer->nexthop
.v6_global))
continue;
/* peer->nexthop.v6_global contains a link-local address
* that needs to be replaced by the global address.
*/
v6_ll_in_nh_global = true;
break;
}
}
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
if (addr->family == AF_INET)
continue;

/*
* If the Peer's interface name matches the
* interface name for which BGP received the
* update and if the received interface address
* is a globalV6 and if the peer is currently
* using a v4-mapped-v6 addr or a link local
* address, then copy the Rxed global v6 addr
* into peer's v6_global and send updates out
* with new nexthop addr.
*/
if (v6_ll_in_nh_global ||
(peer->conf_if &&
strcmp(peer->conf_if, ifc->ifp->name) == 0 &&
(IS_MAPPED_IPV6(&peer->nexthop.v6_global) ||
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global)))) {
if (bgp_debug_zebra(ifc->address)) {
zlog_debug("Update peer %pBP's current intf global addr from %pI6 to %pI6 and send updates",
peer,
&peer->nexthop.v6_global,
&addr->u.prefix6);
/*
* If the Peer's interface name matches the
* interface name for which BGP received the
* update and if the received interface address
* is a globalV6 and if the peer is currently
* using a v4-mapped-v6 addr or a link local
* address, then copy the Rxed global v6 addr
* into peer's v6_global and send updates out
* with new nexthop addr.
*/
if ((peer->conf_if &&
(strcmp(peer->conf_if, ifc->ifp->name) ==
0)) &&
!IN6_IS_ADDR_LINKLOCAL(&addr->u.prefix6) &&
((IS_MAPPED_IPV6(
&peer->nexthop.v6_global)) ||
IN6_IS_ADDR_LINKLOCAL(
&peer->nexthop.v6_global))) {

if (bgp_debug_zebra(ifc->address)) {
zlog_debug(
"Update peer %pBP's current intf addr %pI6 and send updates",
peer,
&peer->nexthop
.v6_global);
}
memcpy(&peer->nexthop.v6_global,
&addr->u.prefix6,
IPV6_MAX_BYTELEN);
FOREACH_AFI_SAFI (afi, safi)
bgp_announce_route(peer, afi,
safi, true);
}
memcpy(&peer->nexthop.v6_global,
&addr->u.prefix6, IPV6_MAX_BYTELEN);
FOREACH_AFI_SAFI (afi, safi)
bgp_announce_route(peer, afi, safi,
true);
}
}
}
Expand All @@ -400,14 +385,10 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
{
struct listnode *node, *nnode;
struct connected *ifc, *connected;
struct connected *ifc;
struct peer *peer;
struct bgp *bgp;
struct prefix *addr;
struct in6_addr *v6_global = NULL;
struct in6_addr *v6_local = NULL;
afi_t afi;
safi_t safi;

bgp = bgp_lookup_by_vrf_id(vrf_id);

Expand All @@ -426,18 +407,7 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)

addr = ifc->address;

if (bgp && addr->family == AF_INET6 &&
!IN6_IS_ADDR_LINKLOCAL(&addr->u.prefix6)) {
/* find another IPv6 global if possible and find the IPv6 link-local */
frr_each (if_connected, ifc->ifp->connected, connected) {
if (connected->address->family != AF_INET6)
continue;
if (IN6_IS_ADDR_LINKLOCAL(&connected->address->u.prefix6))
v6_local = &connected->address->u.prefix6;
else
v6_global = &connected->address->u.prefix6;
}

if (bgp) {
/*
* When we are using the v6 global as part of the peering
* nexthops and we are removing it, then we need to
Expand All @@ -446,17 +416,17 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
* we do not want the peering to bounce.
*/
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
if (IPV6_ADDR_SAME(&peer->nexthop.v6_global,
&addr->u.prefix6)) {
if (v6_global)
IPV6_ADDR_COPY(&peer->nexthop.v6_global,
v6_global);
else if (v6_local)
IPV6_ADDR_COPY(&peer->nexthop.v6_global,
v6_local);
else
memset(&peer->nexthop.v6_global, 0,
IPV6_MAX_BYTELEN);
afi_t afi;
safi_t safi;

if (addr->family == AF_INET)
continue;

if (!IN6_IS_ADDR_LINKLOCAL(&addr->u.prefix6)
&& memcmp(&peer->nexthop.v6_global,
&addr->u.prefix6, 16)
== 0) {
memset(&peer->nexthop.v6_global, 0, 16);
FOREACH_AFI_SAFI (afi, safi)
bgp_announce_route(peer, afi, safi,
true);
Expand Down
Empty file.
4 changes: 0 additions & 4 deletions tests/topotests/bgp_6vpe_ebgp_topo1/h1/zebra.conf

This file was deleted.

8 changes: 0 additions & 8 deletions tests/topotests/bgp_6vpe_ebgp_topo1/h2/zebra.conf

This file was deleted.

13 changes: 0 additions & 13 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/bgp_summary.json

This file was deleted.

Loading
Loading