Skip to content

Commit

Permalink
Merge pull request FRRouting#17073 from louis-6wind/fix-ipv6-ll-nexth…
Browse files Browse the repository at this point in the history
…op-reflector

bgpd, tests: don't send local nexthop from rr client
  • Loading branch information
riw777 authored Oct 15, 2024
2 parents 24296c6 + c4a8263 commit 5b57569
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 96 deletions.
23 changes: 11 additions & 12 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
struct attr *piattr;
route_map_result_t ret;
int transparent;
int reflect;
int ibgp_to_ibgp;
afi_t afi;
safi_t safi;
int samepeer_safe = 0; /* for synthetic mplsvpns routes */
Expand Down Expand Up @@ -2357,14 +2357,14 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
}
}

/* Route-Reflect check. */
/* iBGP to iBGP check. */
if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
reflect = 1;
ibgp_to_ibgp = 1;
else
reflect = 0;
ibgp_to_ibgp = 0;

/* IBGP reflection check. */
if (reflect && !samepeer_safe) {
if (ibgp_to_ibgp && !samepeer_safe) {
/* A route from a Client peer. */
if (CHECK_FLAG(from->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT)) {
Expand Down Expand Up @@ -2410,8 +2410,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,

/* If originator-id is not set and the route is to be reflected,
set the originator id */
if (reflect
&& (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
if (ibgp_to_ibgp && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
IPV4_ADDR_COPY(&(attr->originator_id), &(from->remote_id));
SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
}
Expand Down Expand Up @@ -2444,7 +2443,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* announced to an EBGP peer (and they have the same attributes barring
* their nexthop).
*/
if (reflect)
if (ibgp_to_ibgp)
SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED);

#define NEXTHOP_IS_V6 \
Expand Down Expand Up @@ -2472,7 +2471,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
*/
if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_local))
global_and_ll = true;
} else if (!reflect && !transparent &&
} else if (!ibgp_to_ibgp && !transparent &&
!CHECK_FLAG(from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT) &&
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_local) && peer->shared_network &&
(from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))
global_and_ll = true;
Expand Down Expand Up @@ -2694,9 +2694,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
PEER_FLAG_NEXTHOP_SELF)
|| CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
if (!reflect
|| CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
if (!ibgp_to_ibgp ||
CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) {
subgroup_announce_reset_nhop(
(peer_cap_enhe(peer, afi, safi)
? AF_INET6
Expand Down
48 changes: 6 additions & 42 deletions tests/topotests/bgp_nexthop_ipv6/r4/show_bgp_ipv6_step2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
"ip": "fd00:0:2::1",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -28,13 +22,7 @@
"ip": "fd00:0:2::2",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -47,13 +35,7 @@
"ip": "fd00:0:2::3",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand Down Expand Up @@ -117,13 +99,7 @@
"ip": "fd00:0:2::1",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -136,13 +112,7 @@
"ip": "fd00:0:2::2",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -155,13 +125,7 @@
"ip": "fd00:0:2::3",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand Down
48 changes: 6 additions & 42 deletions tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -28,13 +22,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -47,13 +35,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand Down Expand Up @@ -117,13 +99,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -136,13 +112,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand All @@ -155,13 +125,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand Down

0 comments on commit 5b57569

Please sign in to comment.