Skip to content

Commit 5913bea

Browse files
committed
netfilter: nfnetlink: pass down netns pointer to commit() and abort() callbacks
Adapt callsites to avoid recurrent lookup of the netns pointer. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 7b8002a commit 5913bea

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎include/linux/netfilter/nfnetlink.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ struct nfnetlink_subsystem {
2626
__u8 subsys_id; /* nfnetlink subsystem ID */
2727
__u8 cb_count; /* number of callbacks */
2828
const struct nfnl_callback *cb; /* callback for individual types */
29-
int (*commit)(struct sk_buff *skb);
30-
int (*abort)(struct sk_buff *skb);
29+
int (*commit)(struct net *net, struct sk_buff *skb);
30+
int (*abort)(struct net *net, struct sk_buff *skb);
3131
};
3232

3333
int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n);

‎net/netfilter/nf_tables_api.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3865,9 +3865,8 @@ static void nf_tables_commit_release(struct nft_trans *trans)
38653865
kfree(trans);
38663866
}
38673867

3868-
static int nf_tables_commit(struct sk_buff *skb)
3868+
static int nf_tables_commit(struct net *net, struct sk_buff *skb)
38693869
{
3870-
struct net *net = sock_net(skb->sk);
38713870
struct nft_trans *trans, *next;
38723871
struct nft_trans_elem *te;
38733872

@@ -4002,9 +4001,8 @@ static void nf_tables_abort_release(struct nft_trans *trans)
40024001
kfree(trans);
40034002
}
40044003

4005-
static int nf_tables_abort(struct sk_buff *skb)
4004+
static int nf_tables_abort(struct net *net, struct sk_buff *skb)
40064005
{
4007-
struct net *net = sock_net(skb->sk);
40084006
struct nft_trans *trans, *next;
40094007
struct nft_trans_elem *te;
40104008

‎net/netfilter/nfnetlink.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
425425
}
426426
done:
427427
if (status & NFNL_BATCH_REPLAY) {
428-
ss->abort(oskb);
428+
ss->abort(net, oskb);
429429
nfnl_err_reset(&err_list);
430430
nfnl_unlock(subsys_id);
431431
kfree_skb(skb);
432432
goto replay;
433433
} else if (status == NFNL_BATCH_DONE) {
434-
ss->commit(oskb);
434+
ss->commit(net, oskb);
435435
} else {
436-
ss->abort(oskb);
436+
ss->abort(net, oskb);
437437
}
438438

439439
nfnl_err_deliver(&err_list, oskb);

0 commit comments

Comments
 (0)