Skip to content

Commit df0aab5

Browse files
authored
Merge pull request #17290 from opensourcerouting/16354-bp-8.4
(8.4 backport) bgpd: add `bgp ipv6-auto-ra` command
2 parents cf77ed9 + 4c8e4bc commit df0aab5

File tree

7 files changed

+63
-7
lines changed

7 files changed

+63
-7
lines changed

bgpd/bgp_nht.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,12 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
552552
* we receive from bgp. This is to allow us
553553
* to work with v4 routing over v6 nexthops
554554
*/
555-
if (peer && !peer->ifp
556-
&& CHECK_FLAG(peer->flags,
557-
PEER_FLAG_CAPABILITY_ENHE)
558-
&& nhr->prefix.family == AF_INET6
559-
&& nexthop->type != NEXTHOP_TYPE_BLACKHOLE) {
555+
if (peer && !peer->ifp &&
556+
CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE) &&
557+
!CHECK_FLAG(bnc->bgp->flags,
558+
BGP_FLAG_IPV6_NO_AUTO_RA) &&
559+
nhr->prefix.family == AF_INET6 &&
560+
nexthop->type != NEXTHOP_TYPE_BLACKHOLE) {
560561
struct interface *ifp;
561562

562563
ifp = if_lookup_by_index(nexthop->ifindex,
@@ -1293,6 +1294,9 @@ void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
12931294
return;
12941295

12951296
bgp = peer->bgp;
1297+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA))
1298+
return;
1299+
12961300
if (!sockunion2hostprefix(&peer->su, &p)) {
12971301
zlog_warn("%s: Unable to convert sockunion to prefix for %s",
12981302
__func__, peer->host);

bgpd/bgp_vty.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,6 +4528,27 @@ DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd,
45284528
return CMD_SUCCESS;
45294529
}
45304530

4531+
DEFPY (bgp_ipv6_auto_ra,
4532+
bgp_ipv6_auto_ra_cmd,
4533+
"[no] bgp ipv6-auto-ra",
4534+
NO_STR
4535+
BGP_STR
4536+
"Allow enabling IPv6 ND RA sending\n")
4537+
{
4538+
if (vty->node == CONFIG_NODE) {
4539+
struct listnode *node, *nnode;
4540+
struct bgp *bgp;
4541+
4542+
COND_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA, no);
4543+
for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
4544+
COND_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA, no);
4545+
} else {
4546+
VTY_DECLVAR_CONTEXT(bgp, bgp);
4547+
COND_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA, no);
4548+
}
4549+
return CMD_SUCCESS;
4550+
}
4551+
45314552
static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
45324553
int v6only,
45334554
const char *peer_group_name,
@@ -17508,6 +17529,9 @@ int bgp_config_write(struct vty *vty)
1750817529
if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL)
1750917530
vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2);
1751017531

17532+
if (CHECK_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA))
17533+
vty_out(vty, "no bgp ipv6-auto-ra\n");
17534+
1751117535
/* BGP configuration. */
1751217536
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
1751317537

@@ -17846,6 +17870,11 @@ int bgp_config_write(struct vty *vty)
1784617870
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN))
1784717871
vty_out(vty, " bgp shutdown\n");
1784817872

17873+
/* Automatic RA enabling by BGP */
17874+
if (!CHECK_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA))
17875+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA))
17876+
vty_out(vty, " no bgp ipv6-auto-ra\n");
17877+
1784917878
if (bgp->allow_martian)
1785017879
vty_out(vty, " bgp allow-martian-nexthop\n");
1785117880

@@ -18276,6 +18305,12 @@ void bgp_vty_init(void)
1827618305
install_element(BGP_NODE, &bgp_fast_convergence_cmd);
1827718306
install_element(BGP_NODE, &no_bgp_fast_convergence_cmd);
1827818307

18308+
/* global bgp ipv6-auto-ra command */
18309+
install_element(CONFIG_NODE, &bgp_ipv6_auto_ra_cmd);
18310+
18311+
/* bgp ipv6-auto-ra command */
18312+
install_element(BGP_NODE, &bgp_ipv6_auto_ra_cmd);
18313+
1827918314
/* global bgp update-delay command */
1828018315
install_element(CONFIG_NODE, &bgp_global_update_delay_cmd);
1828118316
install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd);

bgpd/bgp_zebra.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,9 @@ void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer)
21452145
{
21462146
uint32_t ra_interval = BGP_UNNUM_DEFAULT_RA_INTERVAL;
21472147

2148+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA))
2149+
return;
2150+
21482151
/* Don't try to initiate if we're not connected to Zebra */
21492152
if (zclient->sock < 0)
21502153
return;

bgpd/bgpd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,9 @@ int bgp_global_gr_init(struct bgp *bgp)
12401240
bgp->global_gr_present_state = GLOBAL_HELPER;
12411241
bgp->present_zebra_gr_state = ZEBRA_GR_DISABLE;
12421242

1243+
if (CHECK_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA))
1244+
SET_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA);
1245+
12431246
return BGP_GR_SUCCESS;
12441247
}
12451248

bgpd/bgpd.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ struct bgp_master {
169169
uint32_t flags;
170170
#define BM_FLAG_GRACEFUL_SHUTDOWN (1 << 0)
171171
#define BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA (1 << 1)
172+
#define BM_FLAG_IPV6_NO_AUTO_RA (1 << 8)
172173

173174
bool terminating; /* global flag that sigint terminate seen */
174175

@@ -495,7 +496,9 @@ struct bgp {
495496
/* Indicate Graceful Restart support for BGP NOTIFICATION messages */
496497
#define BGP_FLAG_GRACEFUL_NOTIFICATION (1 << 30)
497498
/* Send Hard Reset CEASE Notification for 'Administrative Reset' */
498-
#define BGP_FLAG_HARD_ADMIN_RESET (1 << 31)
499+
#define BGP_FLAG_HARD_ADMIN_RESET (1ULL << 31)
500+
/* Prohibit BGP from enabling IPv6 RA on interfaces */
501+
#define BGP_FLAG_IPV6_NO_AUTO_RA (1ULL << 40)
499502

500503
/* BGP default address-families.
501504
* New peers inherit enabled afi/safis from bgp instance.

doc/user/bgp.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,13 @@ IPv6 Support
11421142
address family is enabled by default for all new neighbors.
11431143

11441144

1145+
.. clicmd:: bgp ipv6-auto-ra
1146+
1147+
By default, bgpd can ask Zebra to enable sending IPv6 router advertisement
1148+
messages on interfaces. For example, this happens for unnumbered peers
1149+
support or when extended-nexthop capability is used. The ``no`` form of this
1150+
command disables such behaviour.
1151+
11451152
.. _bgp-route-aggregation:
11461153

11471154
Route Aggregation

doc/user/ipv6.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Router Advertisement
2525
.. clicmd:: ipv6 nd suppress-ra
2626

2727
Don't send router advertisement messages. The ``no`` form of this command
28-
enables sending RA messages.
28+
enables sending RA messages. Note that while being suppressed, RA messages
29+
might still be enabled by other daemons, such as bgpd or vrrpd.
2930

3031
.. clicmd:: ipv6 nd prefix ipv6prefix [valid-lifetime] [preferred-lifetime] [off-link] [no-autoconfig] [router-address]
3132

0 commit comments

Comments
 (0)