]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: make if_subnet_delete a bit more strict
authorChristian Franke <chris@opensourcerouting.org>
Thu, 24 Jan 2013 14:04:44 +0000 (14:04 +0000)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 19 Sep 2013 15:51:16 +0000 (17:51 +0200)
Enhance if_subnet_delete so it will complain about improper use.
Also, fix one occurence of improper use where it was called for
IPv6 as well.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
zebra/connected.c
zebra/interface.c

index 05538c5d49144284b730af94d4d7eff443cc26fc..3db1271d01cfd71518d72bdc4d2ce3af84e3bdc7 100644 (file)
@@ -49,8 +49,9 @@ connected_withdraw (struct connected *ifc)
     {
       zebra_interface_address_delete_update (ifc->ifp, ifc);
 
-      if_subnet_delete (ifc->ifp, ifc);
-      
+      if (ifc->address->family == AF_INET)
+        if_subnet_delete (ifc->ifp, ifc);
+
       if (ifc->address->family == AF_INET)
         connected_down_ipv4 (ifc->ifp, ifc);
 #ifdef HAVE_IPV6
index 3578b79008358800be8d1e72a508cbc28ba46268..baa7ab6383ecc5ae2a9f201e582a5fc8c8912033 100644 (file)
@@ -161,11 +161,26 @@ if_subnet_delete (struct interface *ifp, struct connected *ifc)
   /* Get address derived subnet node. */
   rn = route_node_lookup (zebra_if->ipv4_subnets, ifc->address);
   if (! (rn && rn->info))
-    return -1;
+    {
+      zlog_warn("Trying to remove an address from an unknown subnet."
+                " (please report this bug)");
+      return -1;
+    }
   route_unlock_node (rn);
   
   /* Untie address from subnet's address list. */
   addr_list = rn->info;
+
+  /* Deleting an address that is not registered is a bug.
+   * In any case, we shouldn't decrement the lock counter if the address
+   * is unknown. */
+  if (!listnode_lookup(addr_list, ifc))
+    {
+      zlog_warn("Trying to remove an address from a subnet where it is not"
+                " currently registered. (please report this bug)");
+      return -1;
+    }
+
   listnode_delete (addr_list, ifc);
   route_unlock_node (rn);