Jozsef Kadlecsik <kadlec@xxxxxxxxxxxxx> wrote: > > Any comments? > > Here is a simple reproducer. The idea is to show that keepalive packets > > in an idle tcp connection will be dropped (and the connection will time > > out) if conntrack hooks are de-registered and then re-registered. The > > reproducer has two files. client_server.py creates both ends of a tcp > > connection, bounces a few packets back and forth, and then blocks on a > > recv on the client side. The client's keepalive is configured to time > > out in 20 seconds. This connection should not time out. test is a bash > > script that creates a net namespace where it sets iptables rules for the > > connection, starts client_server.py, and then clears and restores the > > iptables rules (which causes conntrack hooks to be de-registered and > > re-registered). > > In my opinion an iptables restore should not cause conntrack hooks to be > de-registered and re-registered, because important TCP initialization > parameters cannot be "restored" later from the packets. Therefore the > proper fix would be to prevent it to happen. Otherwise your patch looks OK > to handle the case when conntrack is intentionally restarted. The repro clears all rules, waits 4 seconds, then restores the ruleset. using iptables-restore < FOO; sleep 4; iptables-restore < FOO will not result in any unregister ops. We could make kernel defer unregister via some work queue but i don't see what this would help/accomplish (and its questionable of how long it should wait). We could disallow unregister, but that seems silly (forces reboot...). I think the patch is fine.