From: vivek Date: Thu, 12 May 2016 23:51:43 +0000 (-0700) Subject: BGP: Set advertisement interval when triggering IPv6 RAs X-Git-Tag: frr-2.0-rc1~920 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=5c81b96acaf5e08e1a323c31dafd764ad82a0503;p=mirror%2Ffrr.git BGP: Set advertisement interval when triggering IPv6 RAs This change extends the earlier change which added the ability in BGP to trigger IPv6 Router Advertisements when an unnumbered neighbor is configured. In addition to triggering the RAs, the advertisement interval is also set to 10 seconds. This is needed to handle the scenario where the peer may start later. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Ticket: CM-10896 Reviewed By: CCR-4693 Testing Done: Manual, bgp-min, bgp-smoke --- diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 377a6e08a6..457f865bea 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -2012,6 +2012,8 @@ bgp_zebra_instance_deregister (struct bgp *bgp) void bgp_zebra_initiate_radv (struct bgp *bgp, struct peer *peer) { + int ra_interval = BGP_UNNUM_DEFAULT_RA_INTERVAL; + /* Don't try to initiate if we're not connected to Zebra */ if (zclient->sock < 0) return; @@ -2019,7 +2021,7 @@ bgp_zebra_initiate_radv (struct bgp *bgp, struct peer *peer) if (BGP_DEBUG (zebra, ZEBRA)) zlog_debug("%u: Initiating RA for peer %s", bgp->vrf_id, peer->host); - zclient_send_interface_radv_req (zclient, bgp->vrf_id, peer->ifp, 1); + zclient_send_interface_radv_req (zclient, bgp->vrf_id, peer->ifp, 1, ra_interval); } void @@ -2032,7 +2034,7 @@ bgp_zebra_terminate_radv (struct bgp *bgp, struct peer *peer) if (BGP_DEBUG (zebra, ZEBRA)) zlog_debug("%u: Terminating RA for peer %s", bgp->vrf_id, peer->host); - zclient_send_interface_radv_req (zclient, bgp->vrf_id, peer->ifp, 0); + zclient_send_interface_radv_req (zclient, bgp->vrf_id, peer->ifp, 0, 0); } /* BGP has established connection with Zebra. */ diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index d15a58ecd4..20f23e73cb 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -32,6 +32,9 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define BGP_MAX_HOSTNAME 64 /* Linux max, is larger than most other sys */ +/* Default interval for IPv6 RAs when triggered by BGP unnumbered neighbor. */ +#define BGP_UNNUM_DEFAULT_RA_INTERVAL 10 + struct update_subgroup; struct bpacket; diff --git a/lib/zclient.c b/lib/zclient.c index d1e9a96546..35a5b9e857 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -484,7 +484,7 @@ zclient_send_dereg_requests (struct zclient *zclient, vrf_id_t vrf_id) /* Send request to zebra daemon to start or stop RA. */ void zclient_send_interface_radv_req (struct zclient *zclient, vrf_id_t vrf_id, - struct interface *ifp, int enable) + struct interface *ifp, int enable, int ra_interval) { struct stream *s; @@ -506,6 +506,7 @@ zclient_send_interface_radv_req (struct zclient *zclient, vrf_id_t vrf_id, zclient_create_header (s, ZEBRA_INTERFACE_DISABLE_RADV, vrf_id); stream_putl (s, ifp->ifindex); + stream_putl (s, ra_interval); stream_putw_at (s, 0, stream_get_endp (s)); diff --git a/lib/zclient.h b/lib/zclient.h index 726f254a2a..ad82a21f3f 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -176,7 +176,7 @@ extern void zclient_send_reg_requests (struct zclient *, vrf_id_t); extern void zclient_send_dereg_requests (struct zclient *, vrf_id_t); extern void zclient_send_interface_radv_req (struct zclient *zclient, vrf_id_t vrf_id, - struct interface *ifp, int enable); + struct interface *ifp, int enable, int ra_interval); /* Send redistribute command to zebra daemon. Do not update zclient state. */ extern int zebra_redistribute_send (int command, struct zclient *, afi_t, int type, u_short instance, vrf_id_t vrf_id); diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 003459dd5f..d4d48988c7 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -799,7 +799,8 @@ ipv6_nd_suppress_ra_set (struct interface *ifp, ipv6_nd_suppress_ra_status statu * Handle client (BGP) message to enable or disable IPv6 RA on an interface. * Note that while the client could request RA on an interface on which the * operator has not enabled RA, RA won't be disabled upon client request - * if the operator has explicitly enabled RA. + * if the operator has explicitly enabled RA. The enable request can also + * specify a RA interval (in seconds). */ void zebra_interface_radv_set (struct zserv *client, int sock, u_short length, @@ -809,16 +810,18 @@ zebra_interface_radv_set (struct zserv *client, int sock, u_short length, unsigned int ifindex; struct interface *ifp; struct zebra_if *zif; + int ra_interval; s = client->ibuf; - /* Get interface index. */ + /* Get interface index and RA interval. */ ifindex = stream_getl (s); + ra_interval = stream_getl (s); if (IS_ZEBRA_DEBUG_EVENT) - zlog_debug("%u: IF %u RA %s from client %s", + zlog_debug("%u: IF %u RA %s from client %s, interval %ds", zvrf->vrf_id, ifindex, enable ? "enable" : "disable", - zebra_route_string(client->proto)); + zebra_route_string(client->proto), ra_interval); /* Locate interface and check VRF match. */ ifp = if_lookup_by_index_per_ns (zebra_ns_lookup (NS_DEFAULT), ifindex); @@ -839,11 +842,19 @@ zebra_interface_radv_set (struct zserv *client, int sock, u_short length, zif = ifp->info; if (enable) - ipv6_nd_suppress_ra_set (ifp, RA_ENABLE); + { + ipv6_nd_suppress_ra_set (ifp, RA_ENABLE); + if (ra_interval && + (ra_interval * 1000) < zif->rtadv.MaxRtrAdvInterval) + zif->rtadv.MaxRtrAdvInterval = ra_interval * 1000; + } else { if (!zif->rtadv.configured) - ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS); + { + zif->rtadv.MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL; + ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS); + } } }