]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, zebra: Allow for interface deletion when kernel event happens
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 18 Sep 2019 17:42:46 +0000 (13:42 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 19 Sep 2019 17:34:06 +0000 (13:34 -0400)
When zebra gets a callback from the kernel that an interface has
actually been deleted *and* the end users has not configured
the interface, then allow for deletion of the interface from zebra.

This is especially important in a docker environment where containers
and their veth interfaces are treated as ephermeal.  FRR can quickly
have an inordinate amount of interfaces sitting around that are
not in the kernel and we have no way to clean them up either.

My expectation is that this will cause a second order crashes
in upper level protocols, but I am not sure how to catch these
and fix them now ( suggestions welcome ).  There are too many
use patterns and order based events that I cannot know for certain
that we are going to see any at all, until someone sees this problem
as a crash :(  I do not recommend that this be put in the current
stabilization branch and allow this to soak in master for some time
first.

Testing:

sharpd@donna ~/frr4> sudo ip link add vethdj type veth peer name vethjd
sharpd@donna ~/frr4> sudo ip link add vethaa type veth peer name vethab
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          down    default
vethab          down    default
vethdj          down    default
vethjd          down    default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo ip link set vethaa up
sharpd@donna ~/frr4> sudo ip link set vethab up
sharpd@donna ~/frr4> sudo ip link del vethdj
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          up      default
vethab          up      default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo ip link del vethaa
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo ip link add vethaa type veth peer name vethab
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          down    default
vethab          down    default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo vtysh -c "show run"
Building configuration...

Current configuration:
!
frr version 7.2-dev
frr defaults datacenter
hostname donna.cumulusnetworks.com
log stdout
no ipv6 forwarding
!
ip route 192.168.3.0/24 192.168.209.1
ip route 192.168.4.0/24 blackhole
ip route 192.168.5.0/24 192.168.209.1
ip route 192.168.6.0/24 192.168.209.1
ip route 192.168.7.0/24 99.99.99.99 nexthop-vrf EVA
ip route 192.168.8.0/24 192.168.209.1
ip route 4.5.6.7/32 12.13.14.15
!
interface dummy1
 ip address 12.13.14.15/32
!
interface vethaa
 description FROO
!
line vty
!
end
sharpd@donna ~/frr4> sudo ip link del vethaa
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          down    default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo vtysh -c "show run"
Building configuration...

Current configuration:
!
frr version 7.2-dev
frr defaults datacenter
hostname donna.cumulusnetworks.com
log stdout
no ipv6 forwarding
!
ip route 192.168.3.0/24 192.168.209.1
ip route 192.168.4.0/24 blackhole
ip route 192.168.5.0/24 192.168.209.1
ip route 192.168.6.0/24 192.168.209.1
ip route 192.168.7.0/24 99.99.99.99 nexthop-vrf EVA
ip route 192.168.8.0/24 192.168.209.1
ip route 4.5.6.7/32 12.13.14.15
!
interface dummy1
 ip address 12.13.14.15/32
!
interface vethaa
 description FROO
!
line vty
!
end

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/if.c
lib/if.h
zebra/interface.c

index 1e34ff4b847c47a899b91409fbb9aa5caaebec98..371c6bef876ac604e05c3af9ea7c20ae8846b5c2 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -1423,6 +1423,8 @@ static int lib_interface_create(enum nb_event event,
 #else
                ifp = if_get_by_name(ifname, vrf->vrf_id);
 #endif /* SUNOS_5 */
+
+               ifp->configured = true;
                nb_running_set_entry(dnode, ifp);
                break;
        }
@@ -1450,6 +1452,8 @@ static int lib_interface_destroy(enum nb_event event,
                break;
        case NB_EV_APPLY:
                ifp = nb_running_unset_entry(dnode);
+
+               ifp->configured = false;
                if_delete(ifp);
                break;
        }
index e3ec278f9fbae0cc99d59aceef25c746f27cabd8..ee99fad2e16b68339edb48baa198d724980d25df 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -293,6 +293,12 @@ struct interface {
        struct route_node *node;
        vrf_id_t vrf_id;
 
+       /*
+        * Has the end users entered `interface XXXX` from the cli in some
+        * fashion?
+        */
+       bool configured;
+
        QOBJ_FIELDS
 };
 
index 6486c01430c39bc02c1c8e8538053903c4064558..d21ab25fed450135120fd3a505cf24bf56713cc6 100644 (file)
@@ -767,6 +767,13 @@ void if_delete_update(struct interface *ifp)
                memset(&zif->brslave_info, 0,
                       sizeof(struct zebra_l2info_brslave));
        }
+
+       if (!ifp->configured) {
+               if (IS_ZEBRA_DEBUG_KERNEL)
+                       zlog_debug("interface %s is being deleted from the system",
+                                  ifp->name);
+               if_delete(ifp);
+       }
 }
 
 /* VRF change for an interface */