From: Stefano Brivio <sbrivio@redhat.com>
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 [thread overview]
Message-ID: <20230216190351.2370015-1-sbrivio@redhat.com> (raw)
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 <sbrivio@redhat.com>
---
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, ',')));
--
@@ -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
reply other threads:[~2023-02-16 19:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230216190351.2370015-1-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).