From dd49f1ee6230eaf608f3afa880ef0a6d2b84456e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 9 Jul 2025 15:52:33 +0200 Subject: [PATCH] BUG/MINOR: listener: really assign distinct IDs to shards A fix was made in 3.0 for the case where sharded listeners were using a same ID with commit 0db8b6034d ("BUG/MINOR: listener: always assign distinct IDs to shards"). However, the fix is incorrect. By checking the ID of temporary node instead of the kept one in bind_complete_thread_setup() it ends up never inserting the used nodes at this point, thus not reserving them. The side effect is that assigning too close IDs to subsequent listeners results in the same ID still being assigned twice since not reserved. Example: global nbthread 20 frontend foo bind :8000 shards by-thread id 10 bind :8010 shards by-thread id 20 The first one will start a series from 10 to 29 and the second one a series from 20 to 39. But 20 not being inserted when creating the shards, it will remain available for the post-parsing phase that assigns all unassigned IDs by filling holes, and two listeners will have ID 20. By checking the correct node, the problem disappears. The patch above was marked for backporting to 2.6, so this fix should be backported that far as well. --- src/listener.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/listener.c b/src/listener.c index 9d4232e8e..f6524d1ba 100644 --- a/src/listener.c +++ b/src/listener.c @@ -1856,7 +1856,7 @@ int bind_complete_thread_setup(struct bind_conf *bind_conf, int *err_code) new_li->luid = new_li->conf.id.key = tmp_li->luid; tmp_li->luid = 0; eb32_delete(&tmp_li->conf.id); - if (tmp_li->luid) + if (new_li->luid) eb32_insert(&fe->conf.used_listener_id, &new_li->conf.id); new_li = tmp_li; } @@ -1880,7 +1880,7 @@ int bind_complete_thread_setup(struct bind_conf *bind_conf, int *err_code) new_li->luid = new_li->conf.id.key = li->luid; li->luid = 0; eb32_delete(&li->conf.id); - if (li->luid) + if (new_li->luid) eb32_insert(&fe->conf.used_listener_id, &new_li->conf.id); } } -- 2.47.2