diff options
author | Christian Franke <chris@opensourcerouting.org> | 2013-01-24 14:04:44 +0000 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2013-09-19 17:51:16 +0200 |
commit | 9db047fcb1bedcf1a5a1962e49aa70f48f969b96 (patch) | |
tree | d09388f975d4201dc905cb00522e5d56b09a1cfe /zebra/interface.c | |
parent | 599da95527ec8e09cd3d890dc3addc6f2e791a0c (diff) |
zebra: make if_subnet_delete a bit more strict
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>
Diffstat (limited to 'zebra/interface.c')
-rw-r--r-- | zebra/interface.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index 3578b790..baa7ab63 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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); |