Zebra: Restrict automatic RA enable to relevant interfaces

When enabling IPv6 Router Advertisements automatically based on the
presence of IPv6 address on an interface, do it only for relevant
interfaces.

Note: This needs a configure option for completion.

Ticket: CM-9358
Reviewed By: CCR-4116
Testing Done: Manual verification
This commit is contained in:
vivek 2016-02-18 18:47:32 -08:00
parent 048cb05418
commit 30a3822f2b
4 changed files with 43 additions and 14 deletions

View file

@ -68,8 +68,11 @@ connected_withdraw (struct connected *ifc)
UNSET_FLAG(ifc->conf, ZEBRA_IFC_QUEUED);
/* Enable RA suppression if there are no IPv6 addresses on this interface */
if (! ipv6_address_configured(ifc->ifp))
ipv6_nd_suppress_ra_set (ifc->ifp, RA_SUPPRESS);
if (interface_ipv6_auto_ra_allowed (ifc->ifp))
{
if (! ipv6_address_configured(ifc->ifp))
ipv6_nd_suppress_ra_set (ifc->ifp, RA_SUPPRESS);
}
if (!CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
{
@ -99,7 +102,10 @@ connected_announce (struct interface *ifp, struct connected *ifc)
if_subnet_add (ifp, ifc);
else if (ifc->address->family == AF_INET6)
ipv6_nd_suppress_ra_set (ifp, RA_ENABLE);
{
if (interface_ipv6_auto_ra_allowed (ifp))
ipv6_nd_suppress_ra_set (ifp, RA_ENABLE);
}
zebra_interface_address_add_update (ifp, ifc);

View file

@ -1871,7 +1871,9 @@ ipv6_address_install (struct vty *vty, struct interface *ifp,
/* Add to linked list. */
listnode_add (ifp->connected, ifc);
ipv6_nd_suppress_ra_set (ifp, RA_ENABLE);
/* Enable RA on this interface */
if (interface_ipv6_auto_ra_allowed (ifp))
ipv6_nd_suppress_ra_set (ifp, RA_ENABLE);
}
/* This address is configured from zebra. */
@ -1971,8 +1973,11 @@ ipv6_address_uninstall (struct vty *vty, struct interface *ifp,
}
/* Enable RA suppression if there are no IPv6 addresses on this interface */
if (! ipv6_address_configured(ifp))
ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS);
if (interface_ipv6_auto_ra_allowed (ifp))
{
if (! ipv6_address_configured(ifp))
ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS);
}
UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED);
/* This information will be propagated to the zclients when the

View file

@ -1221,8 +1221,6 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
char *name = NULL;
char *kind = NULL;
char *slave_kind = NULL;
struct connected *ifc;
struct listnode *node;
vrf_id_t vrf_id = ns_id;
@ -1295,9 +1293,11 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
{
if_down (ifp); //Ideally, we should have down/delete come from kernel
// if_delete_update (ifp); //Pending: see how best to make the old ifp unusable
for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
if (ifc->address->family == AF_INET6)
ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS);
if (interface_ipv6_auto_ra_allowed (ifp))
{
if (ipv6_address_configured (ifp))
ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS);
}
}
if (ifp == NULL || !CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) ||
@ -1309,9 +1309,11 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
{
if_update_vrf (ifp, name, strlen(name), vrf_id);
for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
if (ifc->address->family == AF_INET6)
ipv6_nd_suppress_ra_set (ifp, RA_ENABLE);
if (interface_ipv6_auto_ra_allowed (ifp))
{
if (ipv6_address_configured (ifp))
ipv6_nd_suppress_ra_set (ifp, RA_ENABLE);
}
}
set_ifindex(ifp, ifi->ifi_index);

View file

@ -110,4 +110,20 @@ extern void rtadv_terminate (struct zebra_vrf *);
extern void rtadv_cmd_init (void);
extern void ipv6_nd_suppress_ra_set (struct interface *ifp, ipv6_nd_suppress_ra_status status);
/* Can we turn on IPv6 RAs automatically on this interface? */
static inline int
interface_ipv6_auto_ra_allowed (struct interface *ifp)
{
#if defined (HAVE_RTADV)
if ((strncmp (ifp->name, "eth", strlen("eth")) == 0) ||
(strncmp (ifp->name, "lo", strlen("lo")) == 0) ||
(strncmp (ifp->name, "switch", strlen("switch")) == 0))
return 0;
return 1;
#else
return 0;
#endif
}
#endif /* _ZEBRA_RTADV_H */