Skip to content

Commit c42d8bd

Browse files
committed
netfilter: nf_tables: pass hook list to flowtable event notifier
Update the flowtable netlink notifier to take the list of hooks as input. This allows to reuse this function in incremental flowtable hook updates. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 389a2cb commit c42d8bd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6523,7 +6523,8 @@ static int nf_tables_delflowtable(struct net *net, struct sock *nlsk,
65236523
static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
65246524
u32 portid, u32 seq, int event,
65256525
u32 flags, int family,
6526-
struct nft_flowtable *flowtable)
6526+
struct nft_flowtable *flowtable,
6527+
struct list_head *hook_list)
65276528
{
65286529
struct nlattr *nest, *nest_devs;
65296530
struct nfgenmsg *nfmsg;
@@ -6559,7 +6560,7 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
65596560
if (!nest_devs)
65606561
goto nla_put_failure;
65616562

6562-
list_for_each_entry_rcu(hook, &flowtable->hook_list, list) {
6563+
list_for_each_entry_rcu(hook, hook_list, list) {
65636564
if (nla_put_string(skb, NFTA_DEVICE_NAME, hook->ops.dev->name))
65646565
goto nla_put_failure;
65656566
}
@@ -6612,7 +6613,9 @@ static int nf_tables_dump_flowtable(struct sk_buff *skb,
66126613
cb->nlh->nlmsg_seq,
66136614
NFT_MSG_NEWFLOWTABLE,
66146615
NLM_F_MULTI | NLM_F_APPEND,
6615-
table->family, flowtable) < 0)
6616+
table->family,
6617+
flowtable,
6618+
&flowtable->hook_list) < 0)
66166619
goto done;
66176620

66186621
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
@@ -6709,7 +6712,7 @@ static int nf_tables_getflowtable(struct net *net, struct sock *nlsk,
67096712
err = nf_tables_fill_flowtable_info(skb2, net, NETLINK_CB(skb).portid,
67106713
nlh->nlmsg_seq,
67116714
NFT_MSG_NEWFLOWTABLE, 0, family,
6712-
flowtable);
6715+
flowtable, &flowtable->hook_list);
67136716
if (err < 0)
67146717
goto err;
67156718

@@ -6721,6 +6724,7 @@ static int nf_tables_getflowtable(struct net *net, struct sock *nlsk,
67216724

67226725
static void nf_tables_flowtable_notify(struct nft_ctx *ctx,
67236726
struct nft_flowtable *flowtable,
6727+
struct list_head *hook_list,
67246728
int event)
67256729
{
67266730
struct sk_buff *skb;
@@ -6736,7 +6740,7 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx,
67366740

67376741
err = nf_tables_fill_flowtable_info(skb, ctx->net, ctx->portid,
67386742
ctx->seq, event, 0,
6739-
ctx->family, flowtable);
6743+
ctx->family, flowtable, hook_list);
67406744
if (err < 0) {
67416745
kfree_skb(skb);
67426746
goto err;
@@ -7494,13 +7498,15 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
74947498
nft_clear(net, nft_trans_flowtable(trans));
74957499
nf_tables_flowtable_notify(&trans->ctx,
74967500
nft_trans_flowtable(trans),
7501+
&nft_trans_flowtable(trans)->hook_list,
74977502
NFT_MSG_NEWFLOWTABLE);
74987503
nft_trans_destroy(trans);
74997504
break;
75007505
case NFT_MSG_DELFLOWTABLE:
75017506
list_del_rcu(&nft_trans_flowtable(trans)->list);
75027507
nf_tables_flowtable_notify(&trans->ctx,
75037508
nft_trans_flowtable(trans),
7509+
&nft_trans_flowtable(trans)->hook_list,
75047510
NFT_MSG_DELFLOWTABLE);
75057511
nft_unregister_flowtable_net_hooks(net,
75067512
&nft_trans_flowtable(trans)->hook_list);

0 commit comments

Comments
 (0)