From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 828D95A0268; Thu, 16 Feb 2023 20:03:51 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH v2] conf: Fix typo and logic in conf_ports() check for port binding Date: Thu, 16 Feb 2023 20:03:51 +0100 Message-Id: <20230216190351.2370015-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: WUH5NPSZ42MOV4DKEWTRHVJIY3P4L242 X-Message-ID-Hash: WUH5NPSZ42MOV4DKEWTRHVJIY3P4L242 X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Ouch, I accidentally pushed the previous change without running the tests: - we need to check, in conf_ports(), that udp_sock_init() managed to bind at least a port, not the opposite - for -T and -U, we have no way to know if we'll manage to bind the port later, so never report an error for those Fixes: 3d0de2c1d727 ("conf, tcp, udp: Exit if we fail to bind sockets for all given ports") Signed-off-by: Stefano Brivio --- v2: Add the special case for -T and -U conf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 5426c9b..4dc0660 100644 --- a/conf.c +++ b/conf.c @@ -306,6 +306,9 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, } else if (optname == 'u') { if (!udp_sock_init(c, 0, af, addr, ifname, i)) bound_one = true; + } else { + /* No way to check in advance for -T and -U */ + bound_one = true; } } @@ -356,8 +359,11 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, if (!tcp_sock_init(c, af, addr, ifname, i)) bound_one = true; } else if (optname == 'u') { - if (udp_sock_init(c, 0, af, addr, ifname, i)) + if (!udp_sock_init(c, 0, af, addr, ifname, i)) bound_one = true; + } else { + /* No way to check in advance for -T and -U */ + bound_one = true; } } } while ((p = next_chunk(p, ','))); -- 2.35.1