mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
netfilter: nf_tables: Carry reset boolean in nft_obj_dump_ctx
[ Upstream commit a552339063d37b3b1133d9dfc31f851edafb27bb ] 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 <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Stable-dep-of: bd662c4218f9 ("netfilter: nf_tables: Add locking for NFT_MSG_GETOBJ_RESET requests") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
71b6d8d3a8
commit
d76c69c84e
@@ -7420,6 +7420,7 @@ struct nft_obj_dump_ctx {
|
|||||||
unsigned int s_idx;
|
unsigned int s_idx;
|
||||||
char *table;
|
char *table;
|
||||||
u32 type;
|
u32 type;
|
||||||
|
bool reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
@@ -7433,12 +7434,8 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
unsigned int entries = 0;
|
unsigned int entries = 0;
|
||||||
struct nft_object *obj;
|
struct nft_object *obj;
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
bool reset = false;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) == NFT_MSG_GETOBJ_RESET)
|
|
||||||
reset = true;
|
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
nft_net = nft_pernet(net);
|
nft_net = nft_pernet(net);
|
||||||
cb->seq = READ_ONCE(nft_net->base_seq);
|
cb->seq = READ_ONCE(nft_net->base_seq);
|
||||||
@@ -7465,7 +7462,7 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
NFT_MSG_NEWOBJ,
|
NFT_MSG_NEWOBJ,
|
||||||
NLM_F_MULTI | NLM_F_APPEND,
|
NLM_F_MULTI | NLM_F_APPEND,
|
||||||
table->family, table,
|
table->family, table,
|
||||||
obj, reset);
|
obj, ctx->reset);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -7474,7 +7471,7 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
cont:
|
cont:
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if (reset && entries)
|
if (ctx->reset && entries)
|
||||||
audit_log_obj_reset(table, nft_net->base_seq, entries);
|
audit_log_obj_reset(table, nft_net->base_seq, entries);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
break;
|
break;
|
||||||
@@ -7501,6 +7498,9 @@ static int nf_tables_dump_obj_start(struct netlink_callback *cb)
|
|||||||
if (nla[NFTA_OBJ_TYPE])
|
if (nla[NFTA_OBJ_TYPE])
|
||||||
ctx->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
|
ctx->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
|
||||||
|
|
||||||
|
if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) == NFT_MSG_GETOBJ_RESET)
|
||||||
|
ctx->reset = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user