netfilter: nf_tables: allow to change chain policy without hook if it exists
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Mar 2015 12:21:42 +0000 (13:21 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Mar 2015 12:48:04 +0000 (13:48 +0100)
If there's an existing base chain, we have to allow to change the
default policy without indicating the hook information.

However, if the chain doesn't exists, we have to enforce the presence of
the hook attribute.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 6ab777912237976ed72cdd34f18a7bea336f44ae..ac1a9528dbf2e4af0d33fec5667369d23ed179e4 100644 (file)
@@ -1225,7 +1225,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
 
        if (nla[NFTA_CHAIN_POLICY]) {
                if ((chain != NULL &&
-                   !(chain->flags & NFT_BASE_CHAIN)) ||
+                   !(chain->flags & NFT_BASE_CHAIN)))
+                       return -EOPNOTSUPP;
+
+               if (chain == NULL &&
                    nla[NFTA_CHAIN_HOOK] == NULL)
                        return -EOPNOTSUPP;