netfilter: make xt_rateest hash table per net
Subsystems (3)
PATCH 1/1 netfilter: make xt_rateest hash table per net
As suggested by Eric, we need to make the xt_rateest hash table and its lock per netns to reduce lock contentions.
Cc Florian Westphal <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Pablo Neira Ayuso <[email protected]>
Signed-off-by Cong Wang <[email protected]>
--- include/net/netfilter/xt_rateest.h | 4 +- net/netfilter/xt_RATEEST.c | 91 +++++++++++++++++++++++++++----------- net/netfilter/xt_rateest.c | 10 ++--- 3 files changed, 72 insertions(+), 33 deletions(-)
include/net/netfilter/xt_rateest.h +2 -2
@@ -21,7 +21,7 @@ struct xt_rateest { struct net_rate_estimator __rcu *rate_est; }; -struct xt_rateest *xt_rateest_lookup (const char *name); -void xt_rateest_put (struct xt_rateest *est); +struct xt_rateest *xt_rateest_lookup (struct net *net,const char *name); +void xt_rateest_put (struct net *net,struct xt_rateest *est);#endif /* _XT_RATEEST_H */
net/netfilter/xt_RATEEST.c +65 -26
191 lines not on this page · raw message
net/netfilter/xt_rateest.c +5 -5
@@ -95,13 +95,13 @@ static int xt_rateest_mt_checkentry(const struct xt_mtchk_param *par) } ret = -ENOENT ; - est1 =xt_rateest_lookup (info->name1); + est1 =xt_rateest_lookup (par->net, info->name1);if (!est1) goto err1; est2 =NULL ;if (info->flags &XT_RATEEST_MATCH_REL ) { - est2 =xt_rateest_lookup (info->name2); + est2 =xt_rateest_lookup (par->net, info->name2);if (!est2) goto err2; }
@@ -111,7 +111,7 @@ static int xt_rateest_mt_checkentry(const struct xt_mtchk_param *par)return 0 ; err2: -xt_rateest_put (est1); +xt_rateest_put (par->net, est1); err1:return ret; }
@@ -120,9 +120,9 @@ static void xt_rateest_mt_destroy(const struct xt_mtdtor_param *par) {struct xt_rateest_match_info *info = par->matchinfo; -xt_rateest_put (info->est1); +xt_rateest_put (par->net, info->est1);if (info->est2) -xt_rateest_put (info->est2); +xt_rateest_put (par->net, info->est2); }static struct xt_match xt_rateest_mt_reg__read_mostly = {
Signature · 1 line
2.13.0
Quoted 8 lines · Cong Wang
As suggested by Eric, we need to make the
xt_rateesthash table and its lock per netns to reduce lock contentions.Cc Florian Westphal <[email protected]>Cc Eric Dumazet <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Signed-off-by Cong Wang <[email protected]>
Quoted 5 lines
--- include/net/netfilter/xt_rateest.h | 4 +- net/netfilter/xt_RATEEST.c | 91 +++++++++++++++++++++++++++----------- net/netfilter/xt_rateest.c | 10 ++--- 3 files changed, 72 insertions(+), 33 deletions(-)
Very nice, thanks !
Reviewed-by Eric Dumazet <[email protected]>
Although the main reason was to avoid name collisions between different netns.
Hash table is small enough that it can be allocated for each netns.
Quoted 15 lines · Eric Dumazet
Quoted 8 lines · Cong Wang
As suggested by Eric, we need to make the
xt_rateesthash table and its lock per netns to reduce lock contentions.Cc Florian Westphal <[email protected]>Cc Eric Dumazet <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Signed-off-by Cong Wang <[email protected]>Quoted 5 lines
--- include/net/netfilter/xt_rateest.h | 4 +- net/netfilter/xt_RATEEST.c | 91 +++++++++++++++++++++++++++----------- net/netfilter/xt_rateest.c | 10 ++--- 3 files changed, 72 insertions(+), 33 deletions(-)
Quoted 3 lines
Very nice, thanks !
Reviewed-by Eric Dumazet <[email protected]>
Applied, thanks!