]> Git Repo - linux.git/commitdiff
netlabel: Always remove the correct address selector
authorPaul Moore <[email protected]>
Tue, 21 Apr 2009 10:04:22 +0000 (10:04 +0000)
committerDavid S. Miller <[email protected]>
Wed, 22 Apr 2009 07:46:09 +0000 (00:46 -0700)
The NetLabel address selector mechanism has a problem where it can get
mistakenly remove the wrong selector when similar addresses are used.  The
problem is caused when multiple addresses are configured that have different
netmasks but the same address, e.g. 127.0.0.0/8 and 127.0.0.0/24.  This patch
fixes the problem.

Reported-by: Etienne Basset <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
Acked-by: James Morris <[email protected]>
Tested-by: Etienne Basset <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/netlabel/netlabel_addrlist.c

index 834c6eb7f484cfe9ccab1523ac4f8733d6c6dda8..c0519139679e4ccfc46bd065915a9486d2a83d10 100644 (file)
@@ -256,13 +256,11 @@ struct netlbl_af4list *netlbl_af4list_remove(__be32 addr, __be32 mask,
 {
        struct netlbl_af4list *entry;
 
-       entry = netlbl_af4list_search(addr, head);
-       if (entry != NULL && entry->addr == addr && entry->mask == mask) {
-               netlbl_af4list_remove_entry(entry);
-               return entry;
-       }
-
-       return NULL;
+       entry = netlbl_af4list_search_exact(addr, mask, head);
+       if (entry == NULL)
+               return NULL;
+       netlbl_af4list_remove_entry(entry);
+       return entry;
 }
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
@@ -299,15 +297,11 @@ struct netlbl_af6list *netlbl_af6list_remove(const struct in6_addr *addr,
 {
        struct netlbl_af6list *entry;
 
-       entry = netlbl_af6list_search(addr, head);
-       if (entry != NULL &&
-           ipv6_addr_equal(&entry->addr, addr) &&
-           ipv6_addr_equal(&entry->mask, mask)) {
-               netlbl_af6list_remove_entry(entry);
-               return entry;
-       }
-
-       return NULL;
+       entry = netlbl_af6list_search_exact(addr, mask, head);
+       if (entry == NULL)
+               return NULL;
+       netlbl_af6list_remove_entry(entry);
+       return entry;
 }
 #endif /* IPv6 */
 
This page took 0.047346 seconds and 4 git commands to generate.