Skip to content

Commit 9363dc4

Browse files
aborreroummakynes
authored andcommitted
netfilter: nf_tables: store and dump set policy
We want to know in which cases the user explicitly sets the policy options. In that case, we also want to dump back the info. Signed-off-by: Arturo Borrero Gonzalez <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 34666d4 commit 9363dc4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ void nft_unregister_set(struct nft_set_ops *ops);
241241
* @dtype: data type (verdict or numeric type defined by userspace)
242242
* @size: maximum set size
243243
* @nelems: number of elements
244+
* @policy: set parameterization (see enum nft_set_policies)
244245
* @ops: set ops
245246
* @flags: set flags
246247
* @klen: key length
@@ -255,6 +256,7 @@ struct nft_set {
255256
u32 dtype;
256257
u32 size;
257258
u32 nelems;
259+
u16 policy;
258260
/* runtime data below here */
259261
const struct nft_set_ops *ops ____cacheline_aligned;
260262
u16 flags;

net/netfilter/nf_tables_api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,11 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
23442344
goto nla_put_failure;
23452345
}
23462346

2347+
if (set->policy != NFT_SET_POL_PERFORMANCE) {
2348+
if (nla_put_be32(skb, NFTA_SET_POLICY, htonl(set->policy)))
2349+
goto nla_put_failure;
2350+
}
2351+
23472352
desc = nla_nest_start(skb, NFTA_SET_DESC);
23482353
if (desc == NULL)
23492354
goto nla_put_failure;
@@ -2669,6 +2674,7 @@ static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb,
26692674
set->dlen = desc.dlen;
26702675
set->flags = flags;
26712676
set->size = desc.size;
2677+
set->policy = policy;
26722678

26732679
err = ops->init(set, &desc, nla);
26742680
if (err < 0)

0 commit comments

Comments
 (0)