Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: provide nft_ctx in object init function

this is needed by the upcoming ct helper object type --
we'd like to be able use the table family (ip, ip6, inet) to figure
out which helper has to be requested.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
84fba055 c1183db8

+10 -6
+2 -1
include/net/netfilter/nf_tables.h
··· 1017 1017 unsigned int maxattr; 1018 1018 struct module *owner; 1019 1019 const struct nla_policy *policy; 1020 - int (*init)(const struct nlattr * const tb[], 1020 + int (*init)(const struct nft_ctx *ctx, 1021 + const struct nlattr *const tb[], 1021 1022 struct nft_object *obj); 1022 1023 void (*destroy)(struct nft_object *obj); 1023 1024 int (*dump)(struct sk_buff *skb,
+4 -3
net/netfilter/nf_tables_api.c
··· 4095 4095 [NFTA_OBJ_DATA] = { .type = NLA_NESTED }, 4096 4096 }; 4097 4097 4098 - static struct nft_object *nft_obj_init(const struct nft_object_type *type, 4098 + static struct nft_object *nft_obj_init(const struct nft_ctx *ctx, 4099 + const struct nft_object_type *type, 4099 4100 const struct nlattr *attr) 4100 4101 { 4101 4102 struct nlattr *tb[type->maxattr + 1]; ··· 4116 4115 if (obj == NULL) 4117 4116 goto err1; 4118 4117 4119 - err = type->init((const struct nlattr * const *)tb, obj); 4118 + err = type->init(ctx, (const struct nlattr * const *)tb, obj); 4120 4119 if (err < 0) 4121 4120 goto err2; 4122 4121 ··· 4224 4223 if (IS_ERR(type)) 4225 4224 return PTR_ERR(type); 4226 4225 4227 - obj = nft_obj_init(type, nla[NFTA_OBJ_DATA]); 4226 + obj = nft_obj_init(&ctx, type, nla[NFTA_OBJ_DATA]); 4228 4227 if (IS_ERR(obj)) { 4229 4228 err = PTR_ERR(obj); 4230 4229 goto err1;
+2 -1
net/netfilter/nft_counter.c
··· 82 82 return 0; 83 83 } 84 84 85 - static int nft_counter_obj_init(const struct nlattr * const tb[], 85 + static int nft_counter_obj_init(const struct nft_ctx *ctx, 86 + const struct nlattr * const tb[], 86 87 struct nft_object *obj) 87 88 { 88 89 struct nft_counter_percpu_priv *priv = nft_obj_data(obj);
+2 -1
net/netfilter/nft_quota.c
··· 99 99 return 0; 100 100 } 101 101 102 - static int nft_quota_obj_init(const struct nlattr * const tb[], 102 + static int nft_quota_obj_init(const struct nft_ctx *ctx, 103 + const struct nlattr * const tb[], 103 104 struct nft_object *obj) 104 105 { 105 106 struct nft_quota *priv = nft_obj_data(obj);