Skip to content

Commit 5b57569

Browse files
authored
Merge pull request #17073 from louis-6wind/fix-ipv6-ll-nexthop-reflector
bgpd, tests: don't send local nexthop from rr client
2 parents 24296c6 + c4a8263 commit 5b57569

File tree

3 files changed

+23
-96
lines changed

3 files changed

+23
-96
lines changed

bgpd/bgp_route.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
21482148
struct attr *piattr;
21492149
route_map_result_t ret;
21502150
int transparent;
2151-
int reflect;
2151+
int ibgp_to_ibgp;
21522152
afi_t afi;
21532153
safi_t safi;
21542154
int samepeer_safe = 0; /* for synthetic mplsvpns routes */
@@ -2357,14 +2357,14 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
23572357
}
23582358
}
23592359

2360-
/* Route-Reflect check. */
2360+
/* iBGP to iBGP check. */
23612361
if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
2362-
reflect = 1;
2362+
ibgp_to_ibgp = 1;
23632363
else
2364-
reflect = 0;
2364+
ibgp_to_ibgp = 0;
23652365

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

24112411
/* If originator-id is not set and the route is to be reflected,
24122412
set the originator id */
2413-
if (reflect
2414-
&& (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
2413+
if (ibgp_to_ibgp && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
24152414
IPV4_ADDR_COPY(&(attr->originator_id), &(from->remote_id));
24162415
SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
24172416
}
@@ -2444,7 +2443,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
24442443
* announced to an EBGP peer (and they have the same attributes barring
24452444
* their nexthop).
24462445
*/
2447-
if (reflect)
2446+
if (ibgp_to_ibgp)
24482447
SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED);
24492448

24502449
#define NEXTHOP_IS_V6 \
@@ -2472,7 +2471,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
24722471
*/
24732472
if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_local))
24742473
global_and_ll = true;
2475-
} else if (!reflect && !transparent &&
2474+
} else if (!ibgp_to_ibgp && !transparent &&
2475+
!CHECK_FLAG(from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT) &&
24762476
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_local) && peer->shared_network &&
24772477
(from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))
24782478
global_and_ll = true;
@@ -2694,9 +2694,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
26942694
PEER_FLAG_NEXTHOP_SELF)
26952695
|| CHECK_FLAG(peer->af_flags[afi][safi],
26962696
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
2697-
if (!reflect
2698-
|| CHECK_FLAG(peer->af_flags[afi][safi],
2699-
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
2697+
if (!ibgp_to_ibgp ||
2698+
CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) {
27002699
subgroup_announce_reset_nhop(
27012700
(peer_cap_enhe(peer, afi, safi)
27022701
? AF_INET6

tests/topotests/bgp_nexthop_ipv6/r4/show_bgp_ipv6_step2.json

+6-42
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
"ip": "fd00:0:2::1",
1010
"hostname": "rr",
1111
"afi": "ipv6",
12-
"scope": "global"
13-
},
14-
{
15-
"ip": "link-local:rr:eth-sw",
16-
"hostname": "rr",
17-
"afi": "ipv6",
18-
"scope": "link-local",
12+
"scope": "global",
1913
"used": true
2014
}
2115
]
@@ -28,13 +22,7 @@
2822
"ip": "fd00:0:2::2",
2923
"hostname": "rr",
3024
"afi": "ipv6",
31-
"scope": "global"
32-
},
33-
{
34-
"ip": "link-local:rr:eth-sw",
35-
"hostname": "rr",
36-
"afi": "ipv6",
37-
"scope": "link-local",
25+
"scope": "global",
3826
"used": true
3927
}
4028
]
@@ -47,13 +35,7 @@
4735
"ip": "fd00:0:2::3",
4836
"hostname": "rr",
4937
"afi": "ipv6",
50-
"scope": "global"
51-
},
52-
{
53-
"ip": "link-local:rr:eth-sw",
54-
"hostname": "rr",
55-
"afi": "ipv6",
56-
"scope": "link-local",
38+
"scope": "global",
5739
"used": true
5840
}
5941
]
@@ -117,13 +99,7 @@
11799
"ip": "fd00:0:2::1",
118100
"hostname": "rr",
119101
"afi": "ipv6",
120-
"scope": "global"
121-
},
122-
{
123-
"ip": "link-local:rr:eth-sw",
124-
"hostname": "rr",
125-
"afi": "ipv6",
126-
"scope": "link-local",
102+
"scope": "global",
127103
"used": true
128104
}
129105
]
@@ -136,13 +112,7 @@
136112
"ip": "fd00:0:2::2",
137113
"hostname": "rr",
138114
"afi": "ipv6",
139-
"scope": "global"
140-
},
141-
{
142-
"ip": "link-local:rr:eth-sw",
143-
"hostname": "rr",
144-
"afi": "ipv6",
145-
"scope": "link-local",
115+
"scope": "global",
146116
"used": true
147117
}
148118
]
@@ -155,13 +125,7 @@
155125
"ip": "fd00:0:2::3",
156126
"hostname": "rr",
157127
"afi": "ipv6",
158-
"scope": "global"
159-
},
160-
{
161-
"ip": "link-local:rr:eth-sw",
162-
"hostname": "rr",
163-
"afi": "ipv6",
164-
"scope": "link-local",
128+
"scope": "global",
165129
"used": true
166130
}
167131
]

tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step2.json

+6-42
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
"ip": "fd00:0:3::9",
1010
"hostname": "rr",
1111
"afi": "ipv6",
12-
"scope": "global"
13-
},
14-
{
15-
"ip": "link-local:rr:eth-r5",
16-
"hostname": "rr",
17-
"afi": "ipv6",
18-
"scope": "link-local",
12+
"scope": "global",
1913
"used": true
2014
}
2115
]
@@ -28,13 +22,7 @@
2822
"ip": "fd00:0:3::9",
2923
"hostname": "rr",
3024
"afi": "ipv6",
31-
"scope": "global"
32-
},
33-
{
34-
"ip": "link-local:rr:eth-r5",
35-
"hostname": "rr",
36-
"afi": "ipv6",
37-
"scope": "link-local",
25+
"scope": "global",
3826
"used": true
3927
}
4028
]
@@ -47,13 +35,7 @@
4735
"ip": "fd00:0:3::9",
4836
"hostname": "rr",
4937
"afi": "ipv6",
50-
"scope": "global"
51-
},
52-
{
53-
"ip": "link-local:rr:eth-r5",
54-
"hostname": "rr",
55-
"afi": "ipv6",
56-
"scope": "link-local",
38+
"scope": "global",
5739
"used": true
5840
}
5941
]
@@ -117,13 +99,7 @@
11799
"ip": "fd00:0:3::9",
118100
"hostname": "rr",
119101
"afi": "ipv6",
120-
"scope": "global"
121-
},
122-
{
123-
"ip": "link-local:rr:eth-r5",
124-
"hostname": "rr",
125-
"afi": "ipv6",
126-
"scope": "link-local",
102+
"scope": "global",
127103
"used": true
128104
}
129105
]
@@ -136,13 +112,7 @@
136112
"ip": "fd00:0:3::9",
137113
"hostname": "rr",
138114
"afi": "ipv6",
139-
"scope": "global"
140-
},
141-
{
142-
"ip": "link-local:rr:eth-r5",
143-
"hostname": "rr",
144-
"afi": "ipv6",
145-
"scope": "link-local",
115+
"scope": "global",
146116
"used": true
147117
}
148118
]
@@ -155,13 +125,7 @@
155125
"ip": "fd00:0:3::9",
156126
"hostname": "rr",
157127
"afi": "ipv6",
158-
"scope": "global"
159-
},
160-
{
161-
"ip": "link-local:rr:eth-r5",
162-
"hostname": "rr",
163-
"afi": "ipv6",
164-
"scope": "link-local",
128+
"scope": "global",
165129
"used": true
166130
}
167131
]

0 commit comments

Comments
 (0)