From b3b052a483aa3bac9b9310d18227e861a9686643 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 30 Mar 2025 16:50:12 +0200 Subject: [PATCH] cluster: Close l2tp sockets before routes So another l2tpns on the same host can receive l2tp while we are quickly removing our routes. --- l2tpns.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/l2tpns.c b/l2tpns.c index 77b3333..e64210c 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -4029,6 +4029,23 @@ static void drop_routes(void) LOG(1, 0, 0, "Disabling receiving l2tp\n"); // Disable receiving l2tp trafic first since we don't forward to master any more disableif(tunidx); + + LOG(1, 0, 0, "Closing l2tp sockets\n"); + // Close l2tp sockets to let potential slave on the same host get it + for (i = 0; i < config->nbudpfd; i++) + { + close(udpfd[i]); + udpfd[i] = -1; + } + for (i = 1; i <= config->cluster_highest_tunnelid; i++) + { + if (tunn_local[i].l2tp_fd >= 0) + { + close(tunn_local[i].l2tp_fd); + tunn_local[i].l2tp_fd = -1; + } + } + LOG(1, 0, 0, "Dropping routes\n"); // Disable receiving Internet trafic for (i = 1; i <= config->cluster_highest_sessionid ; ++i)