Skip to content

Commit aca3001

Browse files
Liping Zhangummakynes
authored andcommitted
netfilter: nfnetlink_acct: report overquota to the right netns
We should report the over quota message to the right net namespace instead of the init netns. Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 2497b84 commit aca3001

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎include/linux/netfilter/nfnetlink_acct.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ struct nf_acct;
1515
struct nf_acct *nfnl_acct_find_get(struct net *net, const char *filter_name);
1616
void nfnl_acct_put(struct nf_acct *acct);
1717
void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct);
18-
extern int nfnl_acct_overquota(const struct sk_buff *skb,
19-
struct nf_acct *nfacct);
18+
int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb,
19+
struct nf_acct *nfacct);
2020
#endif /* _NFNL_ACCT_H */

‎net/netfilter/nfnetlink_acct.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct)
443443
}
444444
EXPORT_SYMBOL_GPL(nfnl_acct_update);
445445

446-
static void nfnl_overquota_report(struct nf_acct *nfacct)
446+
static void nfnl_overquota_report(struct net *net, struct nf_acct *nfacct)
447447
{
448448
int ret;
449449
struct sk_buff *skb;
@@ -458,11 +458,12 @@ static void nfnl_overquota_report(struct nf_acct *nfacct)
458458
kfree_skb(skb);
459459
return;
460460
}
461-
netlink_broadcast(init_net.nfnl, skb, 0, NFNLGRP_ACCT_QUOTA,
461+
netlink_broadcast(net->nfnl, skb, 0, NFNLGRP_ACCT_QUOTA,
462462
GFP_ATOMIC);
463463
}
464464

465-
int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct)
465+
int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb,
466+
struct nf_acct *nfacct)
466467
{
467468
u64 now;
468469
u64 *quota;
@@ -480,7 +481,7 @@ int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct)
480481

481482
if (now >= *quota &&
482483
!test_and_set_bit(NFACCT_OVERQUOTA_BIT, &nfacct->flags)) {
483-
nfnl_overquota_report(nfacct);
484+
nfnl_overquota_report(net, nfacct);
484485
}
485486

486487
return ret;

‎net/netfilter/xt_nfacct.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par)
2626

2727
nfnl_acct_update(skb, info->nfacct);
2828

29-
overquota = nfnl_acct_overquota(skb, info->nfacct);
29+
overquota = nfnl_acct_overquota(par->net, skb, info->nfacct);
3030

3131
return overquota == NFACCT_UNDERQUOTA ? false : true;
3232
}

0 commit comments

Comments
 (0)