[PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

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

 



Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments,
'--concurrent' will not take effect sometimes; for a simple example,
ebtables -L --concurrent. This is becuase the handling of '--concurrent'
is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Signed-off-by: Firo Yang <firo.yang@xxxxxxxx>
---
 ebtables.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/ebtables.c b/ebtables.c
index f7dfccf..98f655b 100644
--- a/ebtables.c
+++ b/ebtables.c
@@ -98,6 +98,12 @@ static struct option ebt_original_options[] =
 
 static struct option *ebt_options = ebt_original_options;
 
+static struct option ebt_global_options[] =
+{
+        { "concurrent"     , no_argument      , 0, 13  },
+        { 0 }
+};
+
 /* Holds all the data */
 static struct ebt_u_replace *replace;
 
@@ -580,6 +586,17 @@ int do_command(int argc, char *argv[], int exec_style,
 	 * '-t'  ,'-M' and --atomic (if specified) have to come
 	 * before '-A' and the like */
 
+	while ((c = getopt_long(argc, argv, "", ebt_global_options, NULL)) != -1) {
+		switch (c) {
+		case 13 : /* concurrent */
+                        use_lockfd = 1;
+                        break;
+                default :
+                        continue;
+                }
+        }
+
+        optind = 1;
 	/* Getopt saves the day */
 	while ((c = getopt_long(argc, argv,
 	   "-A:D:C:I:N:E:X::L::Z::F::P:Vhi:o:j:c:p:s:d:t:M:", ebt_options, NULL)) != -1) {
@@ -1040,9 +1057,8 @@ big_iface_length:
 			replace->filename = (char *)malloc(strlen(optarg) + 1);
 			strcpy(replace->filename, optarg);
 			break;
-		case 13 : /* concurrent */
-			use_lockfd = 1;
-			break;
+		case 13 :
+			continue;
 		case 1 :
 			if (!strcmp(optarg, "!"))
 				ebt_check_inverse2(optarg);
-- 
2.30.2





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux