]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nftables: add nft_parse_register_store() and use it
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 16 May 2023 14:44:28 +0000 (16:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 11:44:07 +0000 (12:44 +0100)
ccfd9bff2f8eef9f49dde68581fa34e7995535e4 ]

This new function combines the netlink register attribute parser
and the store validation function.

This update requires to replace:

        enum nft_registers      dreg:8;

in many of the expression private areas otherwise compiler complains
with:

        error: cannot take address of bit-field ‘dreg’

when passing the register field as reference.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
22 files changed:
include/net/netfilter/nf_tables.h
include/net/netfilter/nf_tables_core.h
include/net/netfilter/nft_fib.h
include/net/netfilter/nft_meta.h
net/bridge/netfilter/nft_meta_bridge.c
net/netfilter/nf_tables_api.c
net/netfilter/nft_bitwise.c
net/netfilter/nft_byteorder.c
net/netfilter/nft_ct.c
net/netfilter/nft_exthdr.c
net/netfilter/nft_fib.c
net/netfilter/nft_hash.c
net/netfilter/nft_immediate.c
net/netfilter/nft_lookup.c
net/netfilter/nft_meta.c
net/netfilter/nft_numgen.c
net/netfilter/nft_osf.c
net/netfilter/nft_payload.c
net/netfilter/nft_rt.c
net/netfilter/nft_socket.c
net/netfilter/nft_tunnel.c
net/netfilter/nft_xfrm.c

index 78181f017681b038a8c2dead936d3f75900bc5f0..446f70132d827ccde27ed0b4ecb7967b308f58e8 100644 (file)
@@ -209,10 +209,10 @@ unsigned int nft_parse_register(const struct nlattr *attr);
 int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg);
 
 int nft_parse_register_load(const struct nlattr *attr, u8 *sreg, u32 len);
-int nft_validate_register_store(const struct nft_ctx *ctx,
-                               enum nft_registers reg,
-                               const struct nft_data *data,
-                               enum nft_data_types type, unsigned int len);
+int nft_parse_register_store(const struct nft_ctx *ctx,
+                            const struct nlattr *attr, u8 *dreg,
+                            const struct nft_data *data,
+                            enum nft_data_types type, unsigned int len);
 
 /**
  *     struct nft_userdata - user defined data associated with an object
index c57ecb9e157cd6ec4429a4eca0fa5df9f39315d5..6a3fd54c69c172da4795a78109f5fc87639266e7 100644 (file)
@@ -31,7 +31,7 @@ struct nft_cmp_fast_expr {
 
 struct nft_immediate_expr {
        struct nft_data         data;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      dlen;
 };
 
@@ -51,7 +51,7 @@ struct nft_payload {
        enum nft_payload_bases  base:8;
        u8                      offset;
        u8                      len;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
 };
 
 struct nft_payload_set {
index 628b6fa579cd889c681a1d68255d1ac106b17349..237f3757637e15c9d903855d902f57a214d1931c 100644 (file)
@@ -5,7 +5,7 @@
 #include <net/netfilter/nf_tables.h>
 
 struct nft_fib {
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      result;
        u32                     flags;
 };
index 946fa8c83798ed3902155077d8a39c7ee51c8887..2dce55c736f400ede2bb121e739be1718787b85d 100644 (file)
@@ -7,7 +7,7 @@
 struct nft_meta {
        enum nft_meta_keys      key:8;
        union {
-               enum nft_registers      dreg:8;
+               u8              dreg;
                u8              sreg;
        };
 };
index 7c9e92b2f806c8979d603e0624b72df141cc2900..0c28fa4647b73a04c0522c02dc3f4e4763519cf4 100644 (file)
@@ -87,9 +87,8 @@ static int nft_meta_bridge_get_init(const struct nft_ctx *ctx,
                return nft_meta_get_init(ctx, expr, tb);
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_META_DREG]);
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, len);
+       return nft_parse_register_store(ctx, tb[NFTA_META_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, len);
 }
 
 static struct nft_expr_type nft_meta_bridge_type;
index 26390fb986215bf7d72c94aa00191e1e63cec7c7..0ccbe8751085afec339b7ab866858b8b9dda64eb 100644 (file)
@@ -3839,6 +3839,12 @@ static int nf_tables_delset(struct net *net, struct sock *nlsk,
        return nft_delset(&ctx, set);
 }
 
+static int nft_validate_register_store(const struct nft_ctx *ctx,
+                                      enum nft_registers reg,
+                                      const struct nft_data *data,
+                                      enum nft_data_types type,
+                                      unsigned int len);
+
 static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx,
                                        struct nft_set *set,
                                        const struct nft_set_iter *iter,
@@ -7473,10 +7479,11 @@ EXPORT_SYMBOL_GPL(nft_parse_register_load);
  *     A value of NULL for the data means that its runtime gathered
  *     data.
  */
-int nft_validate_register_store(const struct nft_ctx *ctx,
-                               enum nft_registers reg,
-                               const struct nft_data *data,
-                               enum nft_data_types type, unsigned int len)
+static int nft_validate_register_store(const struct nft_ctx *ctx,
+                                      enum nft_registers reg,
+                                      const struct nft_data *data,
+                                      enum nft_data_types type,
+                                      unsigned int len)
 {
        int err;
 
@@ -7508,7 +7515,24 @@ int nft_validate_register_store(const struct nft_ctx *ctx,
                return 0;
        }
 }
-EXPORT_SYMBOL_GPL(nft_validate_register_store);
+
+int nft_parse_register_store(const struct nft_ctx *ctx,
+                            const struct nlattr *attr, u8 *dreg,
+                            const struct nft_data *data,
+                            enum nft_data_types type, unsigned int len)
+{
+       int err;
+       u32 reg;
+
+       reg = nft_parse_register(attr);
+       err = nft_validate_register_store(ctx, reg, data, type, len);
+       if (err < 0)
+               return err;
+
+       *dreg = reg;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(nft_parse_register_store);
 
 static const struct nla_policy nft_verdict_policy[NFTA_VERDICT_MAX + 1] = {
        [NFTA_VERDICT_CODE]     = { .type = NLA_U32 },
index 850c6b5713b43281a520262f3942a5113e260173..ccab2e66d754b0ea0e545bf05a010c8f21f1fbb3 100644 (file)
@@ -17,7 +17,7 @@
 
 struct nft_bitwise {
        u8                      sreg;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      len;
        struct nft_data         mask;
        struct nft_data         xor;
@@ -70,9 +70,9 @@ static int nft_bitwise_init(const struct nft_ctx *ctx,
        if (err < 0)
                return err;
 
-       priv->dreg = nft_parse_register(tb[NFTA_BITWISE_DREG]);
-       err = nft_validate_register_store(ctx, priv->dreg, NULL,
-                                         NFT_DATA_VALUE, priv->len);
+       err = nft_parse_register_store(ctx, tb[NFTA_BITWISE_DREG],
+                                      &priv->dreg, NULL, NFT_DATA_VALUE,
+                                      priv->len);
        if (err < 0)
                return err;
 
index 0960563cd5a19f873dbac184a3116ba8c259e8ba..9d5947ab8d4ef33531dd82fa42057d24273f1260 100644 (file)
@@ -17,7 +17,7 @@
 
 struct nft_byteorder {
        u8                      sreg;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        enum nft_byteorder_ops  op:8;
        u8                      len;
        u8                      size;
@@ -142,9 +142,9 @@ static int nft_byteorder_init(const struct nft_ctx *ctx,
        if (err < 0)
                return err;
 
-       priv->dreg = nft_parse_register(tb[NFTA_BYTEORDER_DREG]);
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, priv->len);
+       return nft_parse_register_store(ctx, tb[NFTA_BYTEORDER_DREG],
+                                       &priv->dreg, NULL, NFT_DATA_VALUE,
+                                       priv->len);
 }
 
 static int nft_byteorder_dump(struct sk_buff *skb, const struct nft_expr *expr)
index edc6b8ae06480ba78fc0e299dbf207e5e09b587d..7e269f7378cc045b1bbae5cfc44fd8601d2f876f 100644 (file)
@@ -27,7 +27,7 @@ struct nft_ct {
        enum nft_ct_keys        key:8;
        enum ip_conntrack_dir   dir:8;
        union {
-               enum nft_registers      dreg:8;
+               u8              dreg;
                u8              sreg;
        };
 };
@@ -498,9 +498,8 @@ static int nft_ct_get_init(const struct nft_ctx *ctx,
                }
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_CT_DREG]);
-       err = nft_validate_register_store(ctx, priv->dreg, NULL,
-                                         NFT_DATA_VALUE, len);
+       err = nft_parse_register_store(ctx, tb[NFTA_CT_DREG], &priv->dreg, NULL,
+                                      NFT_DATA_VALUE, len);
        if (err < 0)
                return err;
 
index f2b36b9c2b53c5d0e6a2f810e4aa87bb2d26c852..670dd146fb2b16be550ae2874aadb9cb4979f0bf 100644 (file)
@@ -19,7 +19,7 @@ struct nft_exthdr {
        u8                      offset;
        u8                      len;
        u8                      op;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      sreg;
        u8                      flags;
 };
@@ -353,12 +353,12 @@ static int nft_exthdr_init(const struct nft_ctx *ctx,
        priv->type   = nla_get_u8(tb[NFTA_EXTHDR_TYPE]);
        priv->offset = offset;
        priv->len    = len;
-       priv->dreg   = nft_parse_register(tb[NFTA_EXTHDR_DREG]);
        priv->flags  = flags;
        priv->op     = op;
 
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, priv->len);
+       return nft_parse_register_store(ctx, tb[NFTA_EXTHDR_DREG],
+                                       &priv->dreg, NULL, NFT_DATA_VALUE,
+                                       priv->len);
 }
 
 static int nft_exthdr_tcp_set_init(const struct nft_ctx *ctx,
index cfac0964f48db4e2d23b350904ab01c70553a339..d2777aff5943db0388f5555a774b530b8ef6207a 100644 (file)
@@ -86,7 +86,6 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
                return -EINVAL;
 
        priv->result = ntohl(nla_get_be32(tb[NFTA_FIB_RESULT]));
-       priv->dreg = nft_parse_register(tb[NFTA_FIB_DREG]);
 
        switch (priv->result) {
        case NFT_FIB_RESULT_OIF:
@@ -106,8 +105,8 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
                return -EINVAL;
        }
 
-       err = nft_validate_register_store(ctx, priv->dreg, NULL,
-                                         NFT_DATA_VALUE, len);
+       err = nft_parse_register_store(ctx, tb[NFTA_FIB_DREG], &priv->dreg,
+                                      NULL, NFT_DATA_VALUE, len);
        if (err < 0)
                return err;
 
index 3b01ad0a02dfe4c067d4ae09ab4c4426d5f7b397..2ff6c7759494bf74a62f70f4463a7184caf52efe 100644 (file)
@@ -15,7 +15,7 @@
 
 struct nft_jhash {
        u8                      sreg;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      len;
        bool                    autogen_seed:1;
        u32                     modulus;
@@ -38,7 +38,7 @@ static void nft_jhash_eval(const struct nft_expr *expr,
 }
 
 struct nft_symhash {
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u32                     modulus;
        u32                     offset;
 };
@@ -83,8 +83,6 @@ static int nft_jhash_init(const struct nft_ctx *ctx,
        if (tb[NFTA_HASH_OFFSET])
                priv->offset = ntohl(nla_get_be32(tb[NFTA_HASH_OFFSET]));
 
-       priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
-
        err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len);
        if (err < 0)
                return err;
@@ -111,8 +109,8 @@ static int nft_jhash_init(const struct nft_ctx *ctx,
                get_random_bytes(&priv->seed, sizeof(priv->seed));
        }
 
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, sizeof(u32));
+       return nft_parse_register_store(ctx, tb[NFTA_HASH_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, sizeof(u32));
 }
 
 static int nft_symhash_init(const struct nft_ctx *ctx,
@@ -128,8 +126,6 @@ static int nft_symhash_init(const struct nft_ctx *ctx,
        if (tb[NFTA_HASH_OFFSET])
                priv->offset = ntohl(nla_get_be32(tb[NFTA_HASH_OFFSET]));
 
-       priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
-
        priv->modulus = ntohl(nla_get_be32(tb[NFTA_HASH_MODULUS]));
        if (priv->modulus < 1)
                return -ERANGE;
@@ -137,8 +133,9 @@ static int nft_symhash_init(const struct nft_ctx *ctx,
        if (priv->offset + priv->modulus - 1 < priv->offset)
                return -EOVERFLOW;
 
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, sizeof(u32));
+       return nft_parse_register_store(ctx, tb[NFTA_HASH_DREG],
+                                       &priv->dreg, NULL, NFT_DATA_VALUE,
+                                       sizeof(u32));
 }
 
 static int nft_jhash_dump(struct sk_buff *skb,
index 98a8149be094b37c69fe3a5b73fda5062c4538c1..6a95d532eaecc7d91d5f10b6ed6fdb358a2709a0 100644 (file)
@@ -48,9 +48,9 @@ static int nft_immediate_init(const struct nft_ctx *ctx,
 
        priv->dlen = desc.len;
 
-       priv->dreg = nft_parse_register(tb[NFTA_IMMEDIATE_DREG]);
-       err = nft_validate_register_store(ctx, priv->dreg, &priv->data,
-                                         desc.type, desc.len);
+       err = nft_parse_register_store(ctx, tb[NFTA_IMMEDIATE_DREG],
+                                      &priv->dreg, &priv->data, desc.type,
+                                      desc.len);
        if (err < 0)
                goto err1;
 
index 349591dabb36a4b5ef0852e6ccb270f2b8667083..e0ffd463a13208cbbe91d605169b265643dab86a 100644 (file)
@@ -18,7 +18,7 @@
 struct nft_lookup {
        struct nft_set                  *set;
        u8                              sreg;
-       enum nft_registers              dreg:8;
+       u8                              dreg;
        bool                            invert;
        struct nft_set_binding          binding;
 };
@@ -97,9 +97,9 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
                if (!(set->flags & NFT_SET_MAP))
                        return -EINVAL;
 
-               priv->dreg = nft_parse_register(tb[NFTA_LOOKUP_DREG]);
-               err = nft_validate_register_store(ctx, priv->dreg, NULL,
-                                                 set->dtype, set->dlen);
+               err = nft_parse_register_store(ctx, tb[NFTA_LOOKUP_DREG],
+                                              &priv->dreg, NULL, set->dtype,
+                                              set->dlen);
                if (err < 0)
                        return err;
        } else if (set->flags & NFT_SET_MAP)
index 28761430d9ee4521315c17cec5382f9cf6c2faba..ec2798ff822e643deb66e863eb9c4900dea16d1c 100644 (file)
@@ -380,9 +380,8 @@ int nft_meta_get_init(const struct nft_ctx *ctx,
                return -EOPNOTSUPP;
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_META_DREG]);
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, len);
+       return nft_parse_register_store(ctx, tb[NFTA_META_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, len);
 }
 EXPORT_SYMBOL_GPL(nft_meta_get_init);
 
index 48edb9d5f01254d3786827d04ea10311d66f4484..7bbca252e7fc59f189e6c07811ba5ee34afbece4 100644 (file)
@@ -16,7 +16,7 @@
 static DEFINE_PER_CPU(struct rnd_state, nft_numgen_prandom_state);
 
 struct nft_ng_inc {
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u32                     modulus;
        atomic_t                counter;
        u32                     offset;
@@ -66,11 +66,10 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,
        if (priv->offset + priv->modulus - 1 < priv->offset)
                return -EOVERFLOW;
 
-       priv->dreg = nft_parse_register(tb[NFTA_NG_DREG]);
        atomic_set(&priv->counter, priv->modulus - 1);
 
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, sizeof(u32));
+       return nft_parse_register_store(ctx, tb[NFTA_NG_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, sizeof(u32));
 }
 
 static int nft_ng_dump(struct sk_buff *skb, enum nft_registers dreg,
@@ -100,7 +99,7 @@ static int nft_ng_inc_dump(struct sk_buff *skb, const struct nft_expr *expr)
 }
 
 struct nft_ng_random {
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u32                     modulus;
        u32                     offset;
 };
@@ -140,10 +139,8 @@ static int nft_ng_random_init(const struct nft_ctx *ctx,
 
        prandom_init_once(&nft_numgen_prandom_state);
 
-       priv->dreg = nft_parse_register(tb[NFTA_NG_DREG]);
-
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, sizeof(u32));
+       return nft_parse_register_store(ctx, tb[NFTA_NG_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, sizeof(u32));
 }
 
 static int nft_ng_random_dump(struct sk_buff *skb, const struct nft_expr *expr)
index d966a3aff1d33baaa018dd3aa4f86aaa8fe73805..b7c2bc01f8a27d347abf119176595340cd9d0baa 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/netfilter/nfnetlink_osf.h>
 
 struct nft_osf {
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      ttl;
        u32                     flags;
 };
@@ -83,9 +83,9 @@ static int nft_osf_init(const struct nft_ctx *ctx,
                priv->flags = flags;
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]);
-       err = nft_validate_register_store(ctx, priv->dreg, NULL,
-                                         NFT_DATA_VALUE, NFT_OSF_MAXGENRELEN);
+       err = nft_parse_register_store(ctx, tb[NFTA_OSF_DREG], &priv->dreg,
+                                      NULL, NFT_DATA_VALUE,
+                                      NFT_OSF_MAXGENRELEN);
        if (err < 0)
                return err;
 
index ce670c959a99e48ab973aa94adf01cafdfdfaaf2..54298fcd82f0e1b540cee1eb3d9cfc5df2512c0b 100644 (file)
@@ -135,10 +135,10 @@ static int nft_payload_init(const struct nft_ctx *ctx,
        priv->base   = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE]));
        priv->offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET]));
        priv->len    = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN]));
-       priv->dreg   = nft_parse_register(tb[NFTA_PAYLOAD_DREG]);
 
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, priv->len);
+       return nft_parse_register_store(ctx, tb[NFTA_PAYLOAD_DREG],
+                                       &priv->dreg, NULL, NFT_DATA_VALUE,
+                                       priv->len);
 }
 
 static int nft_payload_dump(struct sk_buff *skb, const struct nft_expr *expr)
index 7cfcb0e2f7ee1a5e3a72f930653f038e51d59a6f..bcd01a63e38f1bdb423cc9be816d3612beb533e6 100644 (file)
@@ -15,7 +15,7 @@
 
 struct nft_rt {
        enum nft_rt_keys        key:8;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
 };
 
 static u16 get_tcpmss(const struct nft_pktinfo *pkt, const struct dst_entry *skbdst)
@@ -141,9 +141,8 @@ static int nft_rt_get_init(const struct nft_ctx *ctx,
                return -EOPNOTSUPP;
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_RT_DREG]);
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, len);
+       return nft_parse_register_store(ctx, tb[NFTA_RT_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_rt_get_dump(struct sk_buff *skb,
index 4026ec38526f69e4902c6ad3a38e8e6983ce3b42..7e4f7063f4811d83b065cbba34fe5504917db2bf 100644 (file)
@@ -10,7 +10,7 @@
 struct nft_socket {
        enum nft_socket_keys            key:8;
        union {
-               enum nft_registers      dreg:8;
+               u8                      dreg;
        };
 };
 
@@ -119,9 +119,8 @@ static int nft_socket_init(const struct nft_ctx *ctx,
                return -EOPNOTSUPP;
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_SOCKET_DREG]);
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, len);
+       return nft_parse_register_store(ctx, tb[NFTA_SOCKET_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_socket_dump(struct sk_buff *skb,
index 4e850c81ad8d88294008e696e5d9960b9e312f0f..b2070f9f98ffa805c95c1da96cc30d2058c1018f 100644 (file)
@@ -14,7 +14,7 @@
 
 struct nft_tunnel {
        enum nft_tunnel_keys    key:8;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        enum nft_tunnel_mode    mode:8;
 };
 
@@ -92,8 +92,6 @@ static int nft_tunnel_get_init(const struct nft_ctx *ctx,
                return -EOPNOTSUPP;
        }
 
-       priv->dreg = nft_parse_register(tb[NFTA_TUNNEL_DREG]);
-
        if (tb[NFTA_TUNNEL_MODE]) {
                priv->mode = ntohl(nla_get_be32(tb[NFTA_TUNNEL_MODE]));
                if (priv->mode > NFT_TUNNEL_MODE_MAX)
@@ -102,8 +100,8 @@ static int nft_tunnel_get_init(const struct nft_ctx *ctx,
                priv->mode = NFT_TUNNEL_MODE_NONE;
        }
 
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, len);
+       return nft_parse_register_store(ctx, tb[NFTA_TUNNEL_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, len);
 }
 
 static int nft_tunnel_get_dump(struct sk_buff *skb,
index 06d5cabf1d7c4f3adbbe6a8d5a76d597277e1af4..cbbbc4ecad3aed11b584db94f6bc6543ce09fe34 100644 (file)
@@ -24,7 +24,7 @@ static const struct nla_policy nft_xfrm_policy[NFTA_XFRM_MAX + 1] = {
 
 struct nft_xfrm {
        enum nft_xfrm_keys      key:8;
-       enum nft_registers      dreg:8;
+       u8                      dreg;
        u8                      dir;
        u8                      spnum;
 };
@@ -86,9 +86,8 @@ static int nft_xfrm_get_init(const struct nft_ctx *ctx,
 
        priv->spnum = spnum;
 
-       priv->dreg = nft_parse_register(tb[NFTA_XFRM_DREG]);
-       return nft_validate_register_store(ctx, priv->dreg, NULL,
-                                          NFT_DATA_VALUE, len);
+       return nft_parse_register_store(ctx, tb[NFTA_XFRM_DREG], &priv->dreg,
+                                       NULL, NFT_DATA_VALUE, len);
 }
 
 /* Return true if key asks for daddr/saddr and current