]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: fix creation of base chains with hooknum and priority 0
authorPatrick McHardy <kaber@trash.net>
Tue, 6 Jul 2010 03:57:22 +0000 (05:57 +0200)
committerPatrick McHardy <kaber@trash.net>
Tue, 6 Jul 2010 03:57:22 +0000 (05:57 +0200)
Base chains with both a hook number and priority of zero are created
as regular chains. Fix by adding a BASECHAIN flag indicating that the
chain should be created as a base chain.

Signed-off-by: Patrick McHardy <kaber@trash.net>
include/rule.h
src/netlink.c
src/parser.y

index 9754307274ef5f51a859bb7e741e291d2f57f9b7..23171ffbe7dafc03be2907596f15296efab8372b 100644 (file)
@@ -78,11 +78,21 @@ extern void table_free(struct table *table);
 extern void table_add_hash(struct table *table);
 extern struct table *table_lookup(const struct handle *h);
 
+/**
+ * enum chain_flags - chain flags
+ *
+ * @CHAIN_F_BASECHAIN: chain is a base chain
+ */
+enum chain_flags {
+       CHAIN_F_BASECHAIN       = 0x1,
+};
+
 /**
  * struct chain - nftables chain
  *
  * @list:      list node in table list
  * @handle:    chain handle
+ * @flags:     chain flags
  * @hooknum:   hook number (base chains)
  * @priority:  hook priority (base chains)
  * @rules:     rules contained in the chain
@@ -90,6 +100,7 @@ extern struct table *table_lookup(const struct handle *h);
 struct chain {
        struct list_head        list;
        struct handle           handle;
+       uint32_t                flags;
        unsigned int            hooknum;
        unsigned int            priority;
        struct scope            scope;
index 54d92c426a90de82d176a0e10631d2d82661f47b..0427f4ac67f700baf9ed0a9dd81d7955554b731b 100644 (file)
@@ -422,7 +422,7 @@ int netlink_add_chain(struct netlink_ctx *ctx, const struct handle *h,
        int err;
 
        nlc = alloc_nft_chain(h);
-       if (chain != NULL && (chain->hooknum || chain->priority)) {
+       if (chain != NULL && chain->flags & CHAIN_F_BASECHAIN) {
                nfnl_nft_chain_set_hooknum(nlc, chain->hooknum);
                nfnl_nft_chain_set_priority(nlc, chain->priority);
        }
index f70b505dbdfcc96cca0808fee0ec32b6a94de841..8e3d3639a6e832e1e8bc87682eaf9b4e5b4b3007 100644 (file)
@@ -740,11 +740,13 @@ hook_spec         :       HOOK            HOOKNUM         NUM
                        {
                                $<chain>0->hooknum      = $2;
                                $<chain>0->priority     = $3;
+                               $<chain>0->flags        |= CHAIN_F_BASECHAIN;
                        }
                        |       HOOK            HOOKNUM         DASH    NUM
                        {
                                $<chain>0->hooknum      = $2;
                                $<chain>0->priority     = -$4;
+                               $<chain>0->flags        |= CHAIN_F_BASECHAIN;
                        }
                        ;