Skip to content

Commit a552339

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: nf_tables: Carry reset boolean in nft_obj_dump_ctx
Relieve the dump callback from having to inspect nlmsg_type upon each call, just do it once at start of the dump. Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 5a893b9 commit a552339

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7685,6 +7685,7 @@ struct nft_obj_dump_ctx {
76857685
unsigned int s_idx;
76867686
char *table;
76877687
u32 type;
7688+
bool reset;
76887689
};
76897690

76907691
static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
@@ -7698,12 +7699,8 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
76987699
unsigned int entries = 0;
76997700
struct nft_object *obj;
77007701
unsigned int idx = 0;
7701-
bool reset = false;
77027702
int rc = 0;
77037703

7704-
if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) == NFT_MSG_GETOBJ_RESET)
7705-
reset = true;
7706-
77077704
rcu_read_lock();
77087705
nft_net = nft_pernet(net);
77097706
cb->seq = READ_ONCE(nft_net->base_seq);
@@ -7730,7 +7727,7 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
77307727
NFT_MSG_NEWOBJ,
77317728
NLM_F_MULTI | NLM_F_APPEND,
77327729
table->family, table,
7733-
obj, reset);
7730+
obj, ctx->reset);
77347731
if (rc < 0)
77357732
break;
77367733

@@ -7739,7 +7736,7 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
77397736
cont:
77407737
idx++;
77417738
}
7742-
if (reset && entries)
7739+
if (ctx->reset && entries)
77437740
audit_log_obj_reset(table, nft_net->base_seq, entries);
77447741
if (rc < 0)
77457742
break;
@@ -7766,6 +7763,9 @@ static int nf_tables_dump_obj_start(struct netlink_callback *cb)
77667763
if (nla[NFTA_OBJ_TYPE])
77677764
ctx->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
77687765

7766+
if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) == NFT_MSG_GETOBJ_RESET)
7767+
ctx->reset = true;
7768+
77697769
return 0;
77707770
}
77717771

0 commit comments

Comments
 (0)