[PATCH ipvsadm 2/5] ipvsadm: fix ambiguous usage error message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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;
+			ce->svc.netmask = 128;
+		} else
+			fail(2, "-6 used without -f\n");
+	}
+
 	if (ce->cmd == CMD_TIMEOUT) {
 		char *optarg1, *optarg2;
 
-- 
2.45.2





[Index of Archives]     [Linux Filesystem Devel]     [Linux NFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [X.Org]

  Powered by Linux