diff options
Diffstat (limited to 'zebra/connected.c')
-rw-r--r-- | zebra/connected.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/zebra/connected.c b/zebra/connected.c index ad3e9607..80cb8cbc 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -36,23 +36,31 @@ #include "zebra/interface.h" #include "zebra/connected.h" extern struct zebra_t zebrad; + /* withdraw a connected address */ static void connected_withdraw (struct connected *ifc) { + if (! ifc) return; /* Update interface address information to protocol daemon. */ if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) { + int count; + zebra_interface_address_delete_update (ifc->ifp, ifc); - if_subnet_delete (ifc->ifp, ifc); + count = if_subnet_delete (ifc->ifp, ifc); if (ifc->address->family == AF_INET) + { connected_down_ipv4 (ifc->ifp, ifc); + if (count == 0) + rib_flush_interface (AFI_IP, ifc->ifp); + } #ifdef HAVE_IPV6 else connected_down_ipv6 (ifc->ifp, ifc); @@ -86,7 +94,7 @@ connected_announce (struct interface *ifp, struct connected *ifc) zebra_interface_address_add_update (ifp, ifc); - if (if_is_up(ifp)) + if (if_is_operative(ifp)) { if (ifc->address->family == AF_INET) connected_up_ipv4 (ifp, ifc); @@ -174,6 +182,7 @@ void connected_up_ipv4 (struct interface *ifp, struct connected *ifc) { struct prefix_ipv4 p; + struct in_addr src = ((struct prefix_ipv4 *) ifc->address)->prefix; if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) return; @@ -188,14 +197,15 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc) if (prefix_ipv4_any (&p)) return; - rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex, - RT_TABLE_MAIN, ifp->metric, 0); + rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, &src, + ifp->ifindex, RT_TABLE_MAIN, ifp->metric, 0, + RT_SCOPE_LINK, RTPROT_KERNEL); rib_update (); } /* Add connected IPv4 route to the interface. */ -void +struct connected * connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, u_char prefixlen, struct in_addr *broad, const char *label) @@ -270,10 +280,10 @@ connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); /* nothing to do? */ - if ((ifc = connected_implicit_withdraw (ifp, ifc)) == NULL) - return; - + ifc = connected_implicit_withdraw (ifp, ifc); connected_announce (ifp, ifc); + + return ifc; } void @@ -318,6 +328,8 @@ connected_delete_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, return; connected_withdraw (ifc); + + rib_update(); } #ifdef HAVE_IPV6 @@ -347,7 +359,7 @@ connected_up_ipv6 (struct interface *ifp, struct connected *ifc) } /* Add connected IPv6 route to the interface. */ -void +struct connected * connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *addr, u_char prefixlen, struct in6_addr *broad, const char *label) @@ -394,10 +406,10 @@ connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *addr, if (label) ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); - if ((ifc = connected_implicit_withdraw (ifp, ifc)) == NULL) - return; - + ifc = connected_implicit_withdraw (ifp, ifc); connected_announce (ifp, ifc); + + return ifc; } void @@ -437,5 +449,7 @@ connected_delete_ipv6 (struct interface *ifp, struct in6_addr *address, return; connected_withdraw (ifc); + + rib_update(); } #endif /* HAVE_IPV6 */ |