Skip to content

Commit 4e9ceee

Browse files
committed
bgpd: add bgp ipv6-auto-ra command
Introduce a command to stop bgpd from enabling IPv6 router advertisement messages sending on interfaces. Signed-off-by: Mikhail Sokolovskiy <[email protected]>
1 parent 66de921 commit 4e9ceee

File tree

7 files changed

+62
-6
lines changed

7 files changed

+62
-6
lines changed

bgpd/bgp_nht.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,12 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
642642
* we receive from bgp. This is to allow us
643643
* to work with v4 routing over v6 nexthops
644644
*/
645-
if (peer && !peer->ifp
646-
&& CHECK_FLAG(peer->flags,
647-
PEER_FLAG_CAPABILITY_ENHE)
648-
&& nhr->prefix.family == AF_INET6
649-
&& nexthop->type != NEXTHOP_TYPE_BLACKHOLE) {
645+
if (peer && !peer->ifp &&
646+
CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE) &&
647+
!CHECK_FLAG(bnc->bgp->flags,
648+
BGP_FLAG_IPV6_NO_AUTO_RA) &&
649+
nhr->prefix.family == AF_INET6 &&
650+
nexthop->type != NEXTHOP_TYPE_BLACKHOLE) {
650651
struct interface *ifp;
651652

652653
ifp = if_lookup_by_index(nexthop->ifindex,
@@ -1515,6 +1516,10 @@ void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
15151516
return;
15161517

15171518
bgp = peer->bgp;
1519+
1520+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA))
1521+
return;
1522+
15181523
if (!sockunion2hostprefix(&peer->connection->su, &p)) {
15191524
zlog_warn("%s: Unable to convert sockunion to prefix for %s",
15201525
__func__, peer->host);

bgpd/bgp_vty.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5038,6 +5038,27 @@ DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd,
50385038
return CMD_SUCCESS;
50395039
}
50405040

5041+
DEFPY (bgp_ipv6_auto_ra,
5042+
bgp_ipv6_auto_ra_cmd,
5043+
"[no] bgp ipv6-auto-ra",
5044+
NO_STR
5045+
BGP_STR
5046+
"Allow enabling IPv6 ND RA sending\n")
5047+
{
5048+
if (vty->node == CONFIG_NODE) {
5049+
struct listnode *node, *nnode;
5050+
struct bgp *bgp;
5051+
5052+
COND_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA, no);
5053+
for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
5054+
COND_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA, no);
5055+
} else {
5056+
VTY_DECLVAR_CONTEXT(bgp, bgp);
5057+
COND_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA, no);
5058+
}
5059+
return CMD_SUCCESS;
5060+
}
5061+
50415062
static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
50425063
int v6only,
50435064
const char *peer_group_name,
@@ -19385,6 +19406,9 @@ int bgp_config_write(struct vty *vty)
1938519406
if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA))
1938619407
vty_out(vty, "bgp send-extra-data zebra\n");
1938719408

19409+
if (CHECK_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA))
19410+
vty_out(vty, "no bgp ipv6-auto-ra\n");
19411+
1938819412
/* DSCP value for outgoing packets in BGP connections */
1938919413
if (bm->ip_tos != IPTOS_PREC_INTERNETCONTROL)
1939019414
vty_out(vty, "bgp session-dscp %u\n", bm->ip_tos >> 2);
@@ -19801,6 +19825,11 @@ int bgp_config_write(struct vty *vty)
1980119825
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN))
1980219826
vty_out(vty, " bgp shutdown\n");
1980319827

19828+
/* Automatic RA enabling by BGP */
19829+
if (!CHECK_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA))
19830+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA))
19831+
vty_out(vty, " no bgp ipv6-auto-ra\n");
19832+
1980419833
if (bgp->allow_martian)
1980519834
vty_out(vty, " bgp allow-martian-nexthop\n");
1980619835

@@ -20341,6 +20370,12 @@ void bgp_vty_init(void)
2034120370
install_element(BGP_NODE, &bgp_fast_convergence_cmd);
2034220371
install_element(BGP_NODE, &no_bgp_fast_convergence_cmd);
2034320372

20373+
/* global bgp ipv6-auto-ra command */
20374+
install_element(CONFIG_NODE, &bgp_ipv6_auto_ra_cmd);
20375+
20376+
/* bgp ipv6-auto-ra command */
20377+
install_element(BGP_NODE, &bgp_ipv6_auto_ra_cmd);
20378+
2034420379
/* global bgp update-delay command */
2034520380
install_element(CONFIG_NODE, &bgp_global_update_delay_cmd);
2034620381
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
@@ -2338,6 +2338,9 @@ void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer)
23382338
{
23392339
uint32_t ra_interval = BGP_UNNUM_DEFAULT_RA_INTERVAL;
23402340

2341+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA))
2342+
return;
2343+
23412344
/* Don't try to initiate if we're not connected to Zebra */
23422345
if (zclient->sock < 0)
23432346
return;

bgpd/bgpd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,8 @@ int bgp_global_gr_init(struct bgp *bgp)
14121412
bgp->rib_stale_time = bm->rib_stale_time;
14131413
if (CHECK_FLAG(bm->flags, BM_FLAG_GR_PRESERVE_FWD))
14141414
SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD);
1415+
if (CHECK_FLAG(bm->flags, BM_FLAG_IPV6_NO_AUTO_RA))
1416+
SET_FLAG(bgp->flags, BGP_FLAG_IPV6_NO_AUTO_RA);
14151417

14161418
bgp->present_zebra_gr_state = ZEBRA_GR_DISABLE;
14171419

bgpd/bgpd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ struct bgp_master {
171171
#define BM_FLAG_GR_PRESERVE_FWD (1 << 5)
172172
#define BM_FLAG_GRACEFUL_RESTART (1 << 6)
173173
#define BM_FLAG_GR_COMPLETE (1 << 7)
174+
#define BM_FLAG_IPV6_NO_AUTO_RA (1 << 8)
174175

175176
#define BM_FLAG_GR_CONFIGURED (BM_FLAG_GR_RESTARTER | BM_FLAG_GR_DISABLED)
176177

@@ -551,6 +552,8 @@ struct bgp {
551552
#define BGP_FLAG_ENFORCE_FIRST_AS (1ULL << 36)
552553
#define BGP_FLAG_DYNAMIC_CAPABILITY (1ULL << 37)
553554
#define BGP_FLAG_VNI_DOWN (1ULL << 38)
555+
/* Prohibit BGP from enabling IPv6 RA on interfaces */
556+
#define BGP_FLAG_IPV6_NO_AUTO_RA (1ULL << 39)
554557

555558
/* BGP default address-families.
556559
* 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
@@ -1282,6 +1282,13 @@ IPv6 Support
12821282
address family is enabled by default for all new neighbors.
12831283

12841284

1285+
.. clicmd:: bgp ipv6-auto-ra
1286+
1287+
By default, bgpd can ask Zebra to enable sending IPv6 router advertisement
1288+
messages on interfaces. For example, this happens for unnumbered peers
1289+
support or when extended-nexthop capability is used. The ``no`` form of this
1290+
command disables such behaviour.
1291+
12851292
.. _bgp-route-aggregation:
12861293

12871294
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)