VPP-1100 Fix loop in "set punt tcp/udp command" 16/9816/3
authorSwarup Nayak <swarupnpvt@gmail.com>
Wed, 13 Dec 2017 07:57:23 +0000 (13:27 +0530)
committerFlorin Coras <florin.coras@gmail.com>
Thu, 14 Dec 2017 20:33:58 +0000 (20:33 +0000)
Change-Id: I23081ea25a8d40d8ebe1fcb6efe4143e9c5a0fc6
Signed-off-by: Swarup Nayak <swarupnpvt@gmail.com>
src/vnet/ip/punt.c

index db3ea33..568350c 100644 (file)
@@ -739,7 +739,7 @@ punt_cli (vlib_main_t * vm,
   u32 port;
   bool is_add = true;
   u32 protocol = ~0;
-  clib_error_t *error;
+  clib_error_t *error = NULL;
 
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
@@ -750,22 +750,34 @@ punt_cli (vlib_main_t * vm,
          /* punt both IPv6 and IPv4 when used in CLI */
          error = vnet_punt_add_del (vm, ~0, protocol, ~0, is_add);
          if (error)
-           clib_error_report (error);
+           {
+             clib_error_report (error);
+             goto done;
+           }
        }
       else if (unformat (input, "%d", &port))
        {
          /* punt both IPv6 and IPv4 when used in CLI */
          error = vnet_punt_add_del (vm, ~0, protocol, port, is_add);
          if (error)
-           clib_error_report (error);
+           {
+             clib_error_report (error);
+             goto done;
+           }
        }
       else if (unformat (input, "udp"))
        protocol = IP_PROTOCOL_UDP;
       else if (unformat (input, "tcp"))
        protocol = IP_PROTOCOL_TCP;
+      else
+       {
+         error = clib_error_return (0, "parse error: '%U'",
+                                    format_unformat_error, input);
+         goto done;
+       }
     }
-
-  return 0;
+done:
+  return error;
 }
 
 /*?