From 84361d615deb53e559d4a43b1450339c8836f667 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Fri, 18 Mar 2016 19:53:15 +0000 Subject: [PATCH] quagga: delete interface from default table when moved to vrf All daemons changed to flag an interface that has been moved to a vrf as DELETED instead of INTERNAL. When they were flagged as IFINDEX_INTERNAL, ospf, rip, and isis would re-install them in the default assuming that they were being "pre-defined" before the kernel definitions. Ticket: CM-9265 Signed-off-by: Don Slice Reviewed-by: Donald Sharp --- bgpd/bgp_zebra.c | 2 +- isisd/isis_circuit.c | 3 +++ isisd/isis_zebra.c | 2 +- lib/if.h | 1 + ospf6d/ospf6_zebra.c | 2 +- ospfd/ospf_vty.c | 3 +++ ospfd/ospf_zebra.c | 2 +- ripd/rip_interface.c | 5 ++++- ripngd/ripng_interface.c | 2 +- 9 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index a00cc9f67e..878c755f8c 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -319,7 +319,7 @@ bgp_interface_delete (int command, struct zclient *zclient, if (! ifp) /* This may happen if we've just unregistered for a VRF. */ return 0; - ifp->ifindex = IFINDEX_INTERNAL; + ifp->ifindex = IFINDEX_DELETED; if (BGP_DEBUG (zebra, ZEBRA)) zlog_debug("Rx Intf del VRF %u IF %s", vrf_id, ifp->name); diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index ca8f964845..d1eaa8a17c 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -958,6 +958,9 @@ isis_interface_config_write (struct vty *vty) for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) { + if (ifp->ifindex == IFINDEX_DELETED) + continue; + /* IF name */ vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); write++; diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index e02de129ac..d8bfafbe54 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -116,7 +116,7 @@ isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length, in case there is configuration info attached to it. */ if_delete_retain(ifp); - ifp->ifindex = IFINDEX_INTERNAL; + ifp->ifindex = IFINDEX_DELETED; return 0; } diff --git a/lib/if.h b/lib/if.h index a411e709f2..a8e674765f 100644 --- a/lib/if.h +++ b/lib/if.h @@ -84,6 +84,7 @@ struct interface deleted interfaces). */ unsigned int ifindex; #define IFINDEX_INTERNAL 0 +#define IFINDEX_DELETED UINT_MAX /* Zebra internal interface status */ u_char status; diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index e81e216c5a..9c738233b4 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -128,7 +128,7 @@ ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length, ospf6_interface_if_del (ifp); #endif /*0*/ - ifp->ifindex = IFINDEX_INTERNAL; + ifp->ifindex = IFINDEX_DELETED; return 0; } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 9122a219df..8cdf6e9d68 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -9285,6 +9285,9 @@ config_write_interface (struct vty *vty) if (memcmp (ifp->name, "VLINK", 5) == 0) continue; + if (ifp->ifindex == IFINDEX_DELETED) + continue; + vty_out (vty, "!%s", VTY_NEWLINE); vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index f79d75d476..725bdeb4ca 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -148,7 +148,7 @@ ospf_interface_delete (int command, struct zclient *zclient, if (rn->info) ospf_if_free ((struct ospf_interface *) rn->info); - ifp->ifindex = IFINDEX_INTERNAL; + ifp->ifindex = IFINDEX_DELETED; return 0; } diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index c9fc40e815..c269ae07bc 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -492,7 +492,7 @@ rip_interface_delete (int command, struct zclient *zclient, /* To support pseudo interface do not free interface structure. */ /* if_delete(ifp); */ - ifp->ifindex = IFINDEX_INTERNAL; + ifp->ifindex = IFINDEX_DELETED; return 0; } @@ -1928,6 +1928,9 @@ rip_interface_config_write (struct vty *vty) { struct rip_interface *ri; + if (ifp->ifindex == IFINDEX_DELETED) + continue; + ri = ifp->info; /* Do not display the interface if there is no diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 3b3c377c81..ca7f02ef59 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -320,7 +320,7 @@ ripng_interface_delete (int command, struct zclient *zclient, /* To support pseudo interface do not free interface structure. */ /* if_delete(ifp); */ - ifp->ifindex = IFINDEX_INTERNAL; + ifp->ifindex = IFINDEX_DELETED; return 0; } -- 2.39.5