All of lore.kernel.org
 help / color / mirror / Atom feed
* [Q] The usage of xt_recseq.
@ 2024-08-13 14:01 Sebastian Andrzej Siewior
  2024-08-13 14:37 ` [netfilter-core] " Florian Westphal
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-08-13 14:01 UTC (permalink / raw)
  To: netfilter-devel, coreteam
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Eric Dumazet,
	Thomas Gleixner

xt_recseq is per-CPU sequence counter which is not entirely using the
seqcount API.
The writer side of the sequence counter is updating the packet and byte
counter (64bit) while processing a packet. The reader simply retrieves
the two counter.
Based on the code, the writer side can be recursive which is probably
why the "regular" write side isn't used or maybe because there is no
"lock".
The seqcount is per-CPU and disabling BH is used as the "lock". On
PREEMPT_RT code in local_bh_disable()ed section is preemptible and this
means that a seqcount reader with higher priority can preempt the writer
which leads to a deadlock. 

While trying to trigger the writer side, I managed only to trigger a
single reader and only while using iptables-legacy/ arptables-legacy
commands. The nft did not trigger it. So it is legacy code only.

Would it work to convert the counters to u64_stats_sync? On 32bit
there would be a seqcount_t with preemption disabling during the
update which means the xt_write_recseq_begin()/ xt_write_recseq_end()
has to be limited the counter update only. On 64bit architectures there
would be just the update. This means that number of packets and bytes
might be "off" (the one got updated, the other not "yet") but I don't
think that this is a problem here.

I could send a RFC patch if there is nothing obvious I overlooked ;)

Sebastian

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

end of thread, other threads:[~2024-08-14 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 14:01 [Q] The usage of xt_recseq Sebastian Andrzej Siewior
2024-08-13 14:37 ` [netfilter-core] " Florian Westphal
2024-08-13 15:28   ` Sebastian Andrzej Siewior
2024-08-13 18:32     ` Florian Westphal
2024-08-14  7:13       ` Sebastian Andrzej Siewior
2024-08-14 15:09         ` Florian Westphal
2024-08-14 15:22           ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.