[PATCH] fwd, conf: Roll back to old rules if switching to new ones fails
If fwd_listen_init() fails while switching to new forwarding rules
received from pesto, we currently close the old listening sockets,
report an error and keep the (partially bound) new rules. That leaves
pasta in a state the user didn't ask for.
Make fwd_listen_switch() return the result of fwd_listen_init(), and
call it a second time from conf_handler() on failure to switch back
to the old rules.
Don't reset the count of the old table after closing its sockets, so
that the old rules stay in c->fwd_pending and can be restored. The
pending tables are cleared by conf_handler() before receiving new
rules anyway.
Note that reporting the failure to the client is left for a later patch.
Link: https://archives.passt.top/passt-dev/20261025153025.600a4fe9@elisabeth/
Signed-off-by: Hayato Kiwata
On Fri, 30 Oct 2026 01:28:58 +0900
Hayato Kiwata
If fwd_listen_init() fails while switching to new forwarding rules received from pesto, we currently close the old listening sockets, report an error and keep the (partially bound) new rules. That leaves pasta in a state the user didn't ask for.
Make fwd_listen_switch() return the result of fwd_listen_init(), and call it a second time from conf_handler() on failure to switch back to the old rules.
Ah, right, brilliant! I didn't realise that it doesn't actually need any further change because the other rules are always in c->fwd_pending.
Don't reset the count of the old table after closing its sockets, so that the old rules stay in c->fwd_pending and can be restored. The pending tables are cleared by conf_handler() before receiving new rules anyway.
Note that reporting the failure to the client is left for a later patch.
Link: https://archives.passt.top/passt-dev/20261025153025.600a4fe9@elisabeth/ Signed-off-by: Hayato Kiwata
Applied, sorry for the delay. -- Stefano
On Wed, Nov 11, 2026 at 08:03:26AM +0100, Stefano Brivio wrote:
On Fri, 30 Oct 2026 01:28:58 +0900 Hayato Kiwata
wrote: If fwd_listen_init() fails while switching to new forwarding rules received from pesto, we currently close the old listening sockets, report an error and keep the (partially bound) new rules. That leaves pasta in a state the user didn't ask for.
Make fwd_listen_switch() return the result of fwd_listen_init(), and call it a second time from conf_handler() on failure to switch back to the old rules.
Ah, right, brilliant! I didn't realise that it doesn't actually need any further change because the other rules are always in c->fwd_pending.
Right, I made it that way on purpose to support this kind of revert. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson
participants (3)
-
David Gibson
-
Hayato Kiwata
-
Stefano Brivio