netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 nf-next] netfilter: x_tables: speed up iptables-restore
@ 2017-10-10 21:39 Florian Westphal
  2017-10-10 21:39 ` [PATCH v2 nf-next 1/2] netfilter: x_tables: make xt_replace_table wait until old rules are not used anymore Florian Westphal
  2017-10-10 21:39 ` [PATCH v2 nf-next 2/2] netfilter: x_tables: don't use seqlock when fetching old counters Florian Westphal
  0 siblings, 2 replies; 5+ messages in thread
From: Florian Westphal @ 2017-10-10 21:39 UTC (permalink / raw)
  To: netdev, edumazet

iptables-restore can take quite a long time when sytem is busy,
in order of half a minute or more.
The main reason for this is the way ip(6)tables performs table
swap, or, more precisely, expensive sequence lock synchronizations
when reading counters.

When xt_replace_table assigns the new ruleset pointer, it does
not wait for other processors to finish with old ruleset.

Instead it relies on the counter sequence lock in get_counters()
to do this.

This works but this is very costly if system is busy as each counter
read operation can possibly be restarted indefinitely.

Instead, make xt_replace_table wait until all processors are
known to not use the old ruleset anymore.

This allows to read the old counters without any locking, no cpu is
using the ruleset anymore so counters can't change either.

 ipv4/netfilter/arp_tables.c |   22 ++++++++++++++++++++--
 ipv4/netfilter/ip_tables.c  |   23 +++++++++++++++++++++--
 ipv6/netfilter/ip6_tables.c |   22 ++++++++++++++++++++--
 netfilter/x_tables.c        |   15 ++++++++++++---
 4 files changed, 73 insertions(+), 9 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-11 13:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-10 21:39 [PATCH v2 nf-next] netfilter: x_tables: speed up iptables-restore Florian Westphal
2017-10-10 21:39 ` [PATCH v2 nf-next 1/2] netfilter: x_tables: make xt_replace_table wait until old rules are not used anymore Florian Westphal
2017-10-11 13:23   ` Eric Dumazet
2017-10-11 13:45     ` Florian Westphal
2017-10-10 21:39 ` [PATCH v2 nf-next 2/2] netfilter: x_tables: don't use seqlock when fetching old counters Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).