From: Jeremy Sowden <azazel@debian.org>
To: Julian Anastasov <ja@ssi.bg>
Cc: LVS Devel <lvs-devel@vger.kernel.org>
Subject: Re: [PATCH ipvsadm 2/5] ipvsadm: fix ambiguous usage error message
Date: Sun, 12 Jan 2025 21:57:01 +0000 [thread overview]
Message-ID: <20250112215701.GA2068886@celephais.dreamlands> (raw)
In-Reply-To: <67c5c2f3-5a47-b636-96f5-f088019170d7@ssi.bg>
[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]
On 2025-01-12, at 23:18:43 +0200, Julian Anastasov wrote:
> On Sun, 12 Jan 2025, Jeremy Sowden wrote:
> > If `-6` is used without `-f`, the usage error message is "-6 used before -f",
> > which can be misconstrued as warning that both options were used but in the
> > wrong order.
> >
> > Change the option-parsing to allow `-6` to appear before `-f` and the error-
> > message in the case that `-6` was used without `-f`.
> >
> > Link: http://bugs.debian.org/610596
> > Signed-off-by: Jeremy Sowden <azazel@debian.org>
> > ---
> > ipvsadm.c | 17 ++++++++++-------
> > 1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/ipvsadm.c b/ipvsadm.c
> > index 42f31a20e596..889128017bd1 100644
> > --- a/ipvsadm.c
> > +++ b/ipvsadm.c
> > @@ -523,7 +523,7 @@ static int
> > parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
> > unsigned long long *options, unsigned int *format)
> > {
> > - int c, parse;
> > + int c, parse, ipv6 = 0;
> > poptContext context;
> > char *optarg = NULL, sched_flags_arg[128];
> > struct poptOption options_table[] = {
> > @@ -829,12 +829,7 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
> > *format |= FMT_EXACT;
> > break;
> > case '6':
> > - if (ce->svc.fwmark) {
> > - ce->svc.af = AF_INET6;
> > - ce->svc.netmask = 128;
> > - } else {
> > - fail(2, "-6 used before -f\n");
> > - }
> > + ipv6 = 1;
> > break;
> > case 'o':
> > set_option(options, OPTC_ONEPACKET);
> > @@ -935,6 +930,14 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
> > return -1;
> > }
> >
> > + if (ipv6) {
> > + if (ce->svc.fwmark) {
> > + ce->svc.af = AF_INET6;
>
> As ce->svc.af is set later after all options are processed,
> the -M option will always see AF_INET in ce->svc.af ...
>
> > + ce->svc.netmask = 128;
>
> Now we override the value from -M, so we can not do
> this here.
Ah, right. Thanks. The simplest thing, then, would be just to reword
the error message to something like:
fail(2, "-6 must follow -f\n");
Will respin.
J.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 931 bytes --]
next prev parent reply other threads:[~2025-01-12 21:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 20:03 [PATCH ipvsadm 0/5] Debian package fixes Jeremy Sowden
2025-01-12 20:03 ` [PATCH ipvsadm 1/5] ipvsadm: increase maximum weight value Jeremy Sowden
2025-01-12 20:03 ` [PATCH ipvsadm 2/5] ipvsadm: fix ambiguous usage error message Jeremy Sowden
2025-01-12 21:18 ` Julian Anastasov
2025-01-12 21:57 ` Jeremy Sowden [this message]
2025-01-12 20:03 ` [PATCH ipvsadm 3/5] Use variable for pkg-config in Makefiles Jeremy Sowden
2025-01-12 20:03 ` [PATCH ipvsadm 4/5] Support environmental and command-line `*FLAGS` variable " Jeremy Sowden
2025-01-12 20:03 ` [PATCH ipvsadm 5/5] Make sure libipvs.a is built before ipvsadm Jeremy Sowden
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=20250112215701.GA2068886@celephais.dreamlands \
--to=azazel@debian.org \
--cc=ja@ssi.bg \
--cc=lvs-devel@vger.kernel.org \
/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.
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 NNTP newsgroup(s).