Re: [PATCH ipvsadm 2/5] ipvsadm: fix ambiguous usage error message
Jeremy Sowden <[email protected]>
| Newsgroups | org.kernel.vger.lvs-devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> > > --- > > 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.
signature.asc
(application/pgp-signature, 931 B)
-----BEGIN PGP SIGNATURE----- wsG7BAABCgBvBYJnhDqhCRAphqwKvfEEDUcUAAAAAAAeACBzYWx0QG5vdGF0aW9u cy5zZXF1b2lhLXBncC5vcmedD+sr+WF5N5eqoSnqSNxExzxcRQ6W+tcWi2Ozxck0 JxYhBGwdtFNj70A3vVbVFymGrAq98QQNAABHjg/6Ajr4VHW07kh4ImecBHXhzl1G Mby/mhuek3jpp0KEB6USpnmm3OPvnaQA6Rx9iX23fWUn9ms0L0u/XL/vTyF5eepN km7RryObP6prsZFfUnLGhdjRlRKZ53/mvyOOg1eWdYUuQaBGYL1FWoaXitXHLnic YoyvylQuF1LCKNuLpjqAt3cyHTOsjwbqkBstOxqaYq6hv5r8/b/088Wn5VHF/EJJ vXpXranAT5Bx5R5tmdt7ILbIHQmWAk85wqX/BESihPj0ecPWUOF1F+JKj/GvrPvk Zpkkc08PNDwbRf6Ys5ao5xOmWExod0RcgkEuMUGYhWkfvGYEEGyl0PdQu8+fF6QV alGTHd1zvYZasTf+QsKQR0yljFMeop/ZZv0OEbbT2aycHneSaGtLgVKcqBxNHjLJ JcgBS44h88KeDLu7I6Xmgsw1GTRjNlUnpwhr6QmhNrc+AZTYaVcqu+3IQMKAiUAE VjFjwD3/g7hi6oHgtxylB7y4cBZsMSIibkRNrJQWhVjgs6Rnih2P0HJuBkRbeJ93 /wFSK2iXGXCclQxPV4LkYeu3yU0M9B2w+NXPLbahCUko6AheQjv1SvxrJPKP93hM stHMOotUiZNI9ny6BTxiho0kvU4Y7S771DCut2V3xK7xElRAcOV1X+chtBcjYCtw fA24DeE15aES2sdUlc8= =ldEv -----END PGP SIGNATURE-----