summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorBilly McFall <bmcfall@redhat.com>2017-02-15 11:39:12 -0500
committerDave Barach <openvpp@barachs.net>2017-02-22 16:23:12 +0000
commita9a20e7f69f4a91a4d5267ab5ce14125bdc7d6c6 (patch)
tree58647f28d51d1cac3e7aa4e9ca94280192e6ec25 /src/vnet
parent2291a36008e197423a0f0414f6dcca4afa3ac4c1 (diff)
VPP-635: CLI Memory leak with invalid parameter
In the CLI parsing, below is a common pattern: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "x")) x = 1; : else return clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); } unformat_free (line_input); The 'else' returns if an unknown string is encountered. There a memory leak because the 'unformat_free(line_input)' is not called. There is a large number of instances of this pattern. Replaced the previous pattern with: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "x")) x = 1; : else { error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); goto done: } } /* ...Remaining code... */ done: unformat_free (line_input); return error; } In multiple files, 'unformat_free (line_input);' was never called, so there was a memory leak whether an invalid string was entered or not. Also, there were multiple instance where: error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); used 'input' as the last parameter instead of 'line_input'. The result is that output did not contain the substring in error, instead just an empty string. Fixed all of those as well. There are a lot of file, and very mind numbing work, so tried to keep it to a pattern to avoid mistakes. Change-Id: I8902f0c32a47dd7fb3bb3471a89818571702f1d2 Signed-off-by: Billy McFall <bmcfall@redhat.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/af_packet/cli.c56
-rw-r--r--src/vnet/devices/dpdk/cli.c290
-rw-r--r--src/vnet/devices/dpdk/ipsec/cli.c15
-rw-r--r--src/vnet/devices/netmap/cli.c54
-rw-r--r--src/vnet/devices/virtio/vhost-user.c62
-rw-r--r--src/vnet/gre/interface.c35
-rw-r--r--src/vnet/ip/ip4_source_check.c6
-rw-r--r--src/vnet/ip/ip4_test.c15
-rw-r--r--src/vnet/ip/ip6_neighbor.c27
-rw-r--r--src/vnet/ip/lookup.c34
-rw-r--r--src/vnet/ipsec-gre/interface.c34
-rw-r--r--src/vnet/ipsec/ipsec_cli.c177
-rw-r--r--src/vnet/l2/l2_patch.c26
-rw-r--r--src/vnet/l2/l2_xcrw.c34
-rw-r--r--src/vnet/l2tp/l2tp.c39
-rw-r--r--src/vnet/lisp-cp/lisp_cli.c139
-rw-r--r--src/vnet/lisp-gpe/interface.c58
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.c13
-rw-r--r--src/vnet/map/map.c186
-rw-r--r--src/vnet/mpls/mpls.c2
-rw-r--r--src/vnet/mpls/mpls_tunnel.c19
-rw-r--r--src/vnet/pg/cli.c39
-rw-r--r--src/vnet/policer/node_funcs.c19
-rw-r--r--src/vnet/policer/policer.c13
-rw-r--r--src/vnet/unix/tapcli.c57
-rw-r--r--src/vnet/vxlan-gpe/vxlan_gpe.c62
-rw-r--r--src/vnet/vxlan/vxlan.c81
27 files changed, 1163 insertions, 429 deletions
diff --git a/src/vnet/devices/af_packet/cli.c b/src/vnet/devices/af_packet/cli.c
index 6baa26e1720..d4aa7016aaa 100644
--- a/src/vnet/devices/af_packet/cli.c
+++ b/src/vnet/devices/af_packet/cli.c
@@ -49,6 +49,7 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
u8 *hw_addr_ptr = 0;
u32 sw_if_index;
int r;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -63,29 +64,47 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
(line_input, "hw-addr %U", unformat_ethernet_address, hwaddr))
hw_addr_ptr = hwaddr;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (host_if_name == NULL)
- return clib_error_return (0, "missing host interface name");
+ {
+ error = clib_error_return (0, "missing host interface name");
+ goto done;
+ }
r = af_packet_create_if (vm, host_if_name, hw_addr_ptr, &sw_if_index);
- vec_free (host_if_name);
if (r == VNET_API_ERROR_SYSCALL_ERROR_1)
- return clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
+ {
+ error = clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
+ goto done;
+ }
if (r == VNET_API_ERROR_INVALID_INTERFACE)
- return clib_error_return (0, "Invalid interface name");
+ {
+ error = clib_error_return (0, "Invalid interface name");
+ goto done;
+ }
if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS)
- return clib_error_return (0, "Interface elready exists");
+ {
+ error = clib_error_return (0, "Interface elready exists");
+ goto done;
+ }
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index);
- return 0;
+
+done:
+ vec_free (host_if_name);
+ unformat_free (line_input);
+
+ return error;
}
/*?
@@ -124,6 +143,7 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
unformat_input_t _line_input, *line_input = &_line_input;
u8 *host_if_name = NULL;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -134,18 +154,26 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (unformat (line_input, "name %s", &host_if_name))
;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (host_if_name == NULL)
- return clib_error_return (0, "missing host interface name");
+ {
+ error = clib_error_return (0, "missing host interface name");
+ goto done;
+ }
af_packet_delete_if (vm, host_if_name);
+
+done:
vec_free (host_if_name);
+ unformat_free (line_input);
- return 0;
+ return error;
}
/*?
diff --git a/src/vnet/devices/dpdk/cli.c b/src/vnet/devices/dpdk/cli.c
index d133cfd95db..1fc665aca41 100644
--- a/src/vnet/devices/dpdk/cli.c
+++ b/src/vnet/devices/dpdk/cli.c
@@ -398,7 +398,7 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
u32 hw_if_index = (u32) ~ 0;
u32 nb_rx_desc = (u32) ~ 0;
u32 nb_tx_desc = (u32) ~ 0;
- clib_error_t *rv;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -414,25 +414,37 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "rx %d", &nb_rx_desc))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify valid interface name");
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
- return clib_error_return (0, "number of descriptors can be set only for "
- "physical devices");
+ {
+ error =
+ clib_error_return (0,
+ "number of descriptors can be set only for "
+ "physical devices");
+ goto done;
+ }
if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
(nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
- return clib_error_return (0, "nothing changed");
+ {
+ error = clib_error_return (0, "nothing changed");
+ goto done;
+ }
if (nb_rx_desc != (u32) ~ 0)
xd->nb_rx_desc = nb_rx_desc;
@@ -440,9 +452,12 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
if (nb_tx_desc != (u32) ~ 0)
xd->nb_tx_desc = nb_tx_desc;
- rv = dpdk_port_setup (dm, xd);
+ error = dpdk_port_setup (dm, xd);
+
+done:
+ unformat_free (line_input);
- return rv;
+ return error;
}
/* *INDENT-OFF* */
@@ -523,6 +538,7 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
u32 queue = (u32) 0;
u32 cpu = (u32) ~ 0;
int i;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -538,18 +554,25 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "thread %d", &cpu))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify valid interface name");
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
if (cpu < dm->input_cpu_first_index ||
cpu >= (dm->input_cpu_first_index + dm->input_cpu_count))
- return clib_error_return (0, "please specify valid thread id");
+ {
+ error = clib_error_return (0, "please specify valid thread id");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -563,7 +586,7 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
queue == dq->queue_id)
{
if (cpu == i) /* nothing to do */
- return 0;
+ goto done;
vec_del1(dm->devices_by_cpu[i], dq - dm->devices_by_cpu[i]);
vec_add2(dm->devices_by_cpu[cpu], dq, 1);
@@ -586,13 +609,18 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index,
VLIB_NODE_STATE_POLLING);
- return 0;
+ goto done;
}
}
/* *INDENT-ON* */
}
- return clib_error_return (0, "not found");
+ error = clib_error_return (0, "not found");
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -653,6 +681,7 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
u32 hw_if_index = (u32) ~ 0;
u32 cpu = (u32) ~ 0;
int i;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -666,18 +695,22 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "thread %d", &cpu))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
return clib_error_return (0, "please specify valid interface name");
if (cpu < dm->hqos_cpu_first_index ||
cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
- return clib_error_return (0, "please specify valid thread id");
+ {
+ error = clib_error_return (0, "please specify valid thread id");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -689,7 +722,7 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index)
{
if (cpu == i) /* nothing to do */
- return 0;
+ goto done;
vec_del1 (dm->devices_by_hqos_cpu[i],
dq - dm->devices_by_hqos_cpu[i]);
@@ -703,12 +736,17 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
vec_sort_with_function (dm->devices_by_hqos_cpu[cpu],
dpdk_device_queue_sort);
- return 0;
+ goto done;
}
}
}
- return clib_error_return (0, "not found");
+ error = clib_error_return (0, "not found");
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -732,6 +770,7 @@ set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
u32 pipe_id = (u32) ~ 0;
u32 profile_id = (u32) ~ 0;
int rv;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -749,14 +788,18 @@ set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "profile %d", &profile_id))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify valid interface name");
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -765,9 +808,15 @@ set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id,
profile_id);
if (rv)
- return clib_error_return (0, "pipe configuration failed");
+ {
+ error = clib_error_return (0, "pipe configuration failed");
+ goto done;
+ }
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -797,6 +846,7 @@ set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
.tc_period = 10,
};
int rv;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -829,23 +879,33 @@ set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "period %d", &p.tc_period))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify valid interface name");
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p);
if (rv)
- return clib_error_return (0, "subport configuration failed");
+ {
+ error = clib_error_return (0, "subport configuration failed");
+ goto done;
+ }
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -872,6 +932,7 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
u32 queue = (u32) ~ 0;
u32 entry = (u32) ~ 0;
u32 val, i;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -889,20 +950,33 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "queue %d", &queue))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify valid interface name");
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
if (entry >= 64)
- return clib_error_return (0, "invalid entry");
+ {
+ error = clib_error_return (0, "invalid entry");
+ goto done;
+ }
if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
- return clib_error_return (0, "invalid traffic class");
+ {
+ error = clib_error_return (0, "invalid traffic class");
+ goto done;
+ }
if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
- return clib_error_return (0, "invalid traffic class");
+ {
+ error = clib_error_return (0, "invalid traffic class");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -911,7 +985,10 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
/* Should never happen, shut up Coverity warning */
if (p == 0)
- return clib_error_return (0, "no worker registrations?");
+ {
+ error = clib_error_return (0, "no worker registrations?");
+ goto done;
+ }
vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
int worker_thread_first = tr->first_index;
@@ -921,7 +998,10 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
for (i = 0; i < worker_thread_count; i++)
xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -939,6 +1019,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
unformat_input_t _line_input, *line_input = &_line_input;
vlib_thread_main_t *tm = vlib_get_thread_main ();
dpdk_main_t *dm = &dpdk_main;
+ clib_error_t *error = NULL;
/* Device specific data */
struct rte_eth_dev_info dev_info;
@@ -984,15 +1065,19 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "mask %llx", &mask))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
/* Get interface */
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify valid interface name");
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -1019,7 +1104,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
if (devconf->hqos_enabled == 0)
{
vlib_cli_output (vm, "HQoS disabled for this interface");
- return 0;
+ goto done;
}
n_subports_per_port = devconf->hqos.port.n_subports_per_port;
@@ -1028,27 +1113,39 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
/* Validate packet field configuration: id, offset and mask */
if (id >= 3)
- return clib_error_return (0, "invalid packet field id");
+ {
+ error = clib_error_return (0, "invalid packet field id");
+ goto done;
+ }
switch (id)
{
case 0:
if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0)
- return clib_error_return (0, "invalid subport ID mask "
- "(n_subports_per_port = %u)",
- n_subports_per_port);
+ {
+ error = clib_error_return (0, "invalid subport ID mask "
+ "(n_subports_per_port = %u)",
+ n_subports_per_port);
+ goto done;
+ }
break;
case 1:
if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0)
- return clib_error_return (0, "invalid pipe ID mask "
- "(n_pipes_per_subport = %u)",
- n_pipes_per_subport);
+ {
+ error = clib_error_return (0, "invalid pipe ID mask "
+ "(n_pipes_per_subport = %u)",
+ n_pipes_per_subport);
+ goto done;
+ }
break;
case 2:
default:
if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0)
- return clib_error_return (0, "invalid TC table index mask "
- "(TC table size = %u)", tctbl_size);
+ {
+ error = clib_error_return (0, "invalid TC table index mask "
+ "(TC table size = %u)", tctbl_size);
+ goto done;
+ }
}
/* Propagate packet field configuration to all workers */
@@ -1075,7 +1172,10 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
__builtin_ctzll (mask);
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -1106,6 +1206,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
dpdk_device_config_t *devconf = 0;
vlib_thread_registration_t *tr;
uword *p = 0;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -1117,14 +1218,18 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
&hw_if_index))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify interface name!!");
+ {
+ error = clib_error_return (0, "please specify interface name!!");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -1151,7 +1256,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
if (devconf->hqos_enabled == 0)
{
vlib_cli_output (vm, "HQoS disabled for this interface");
- return 0;
+ goto done;
}
/* Detect the set of worker threads */
@@ -1159,7 +1264,10 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
/* Should never happen, shut up Coverity warning */
if (p == 0)
- return clib_error_return (0, "no worker registrations?");
+ {
+ error = clib_error_return (0, "no worker registrations?");
+ goto done;
+ }
tr = (vlib_thread_registration_t *) p[0];
@@ -1284,7 +1392,10 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
}
#endif
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -1315,6 +1426,7 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
u32 qindex;
struct rte_sched_queue_stats stats;
u16 qlen;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -1339,14 +1451,18 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "please specify interface name!!");
+ {
+ error = clib_error_return (0, "please specify interface name!!");
+ goto done;
+ }
hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
@@ -1373,7 +1489,7 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
if (devconf->hqos_enabled == 0)
{
vlib_cli_output (vm, "HQoS disabled for this interface");
- return 0;
+ goto done;
}
/*
@@ -1386,7 +1502,10 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
if (rte_sched_queue_read_stats (xd->hqos_ht->hqos, qindex, &stats, &qlen) !=
0)
- return clib_error_return (0, "failed to read stats");
+ {
+ error = clib_error_return (0, "failed to read stats");
+ goto done;
+ }
vlib_cli_output (vm, "%=24s%=16s", "Stats Parameter", "Value");
vlib_cli_output (vm, "%=24s%=16d", "Packets", stats.n_pkts);
@@ -1399,7 +1518,10 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_output (vm, "%=24s%=16d", "Bytes dropped", stats.n_bytes_dropped);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/devices/dpdk/ipsec/cli.c b/src/vnet/devices/dpdk/ipsec/cli.c
index 93df4a641f1..f9d3a5d082e 100644
--- a/src/vnet/devices/dpdk/ipsec/cli.c
+++ b/src/vnet/devices/dpdk/ipsec/cli.c
@@ -111,6 +111,7 @@ lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input,
{
unformat_input_t _line_input, *line_input = &_line_input;
u16 detail = 0;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -120,15 +121,19 @@ lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input,
if (unformat (line_input, "verbose"))
detail = 1;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
dpdk_ipsec_show_mapping (vm, detail);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/devices/netmap/cli.c b/src/vnet/devices/netmap/cli.c
index 6157f27c77f..713632947a1 100644
--- a/src/vnet/devices/netmap/cli.c
+++ b/src/vnet/devices/netmap/cli.c
@@ -37,6 +37,7 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
u8 is_pipe = 0;
u8 is_master = 0;
u32 sw_if_index = ~0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -57,30 +58,48 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "slave"))
is_master = 0;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (host_if_name == NULL)
- return clib_error_return (0, "missing host interface name");
+ {
+ error = clib_error_return (0, "missing host interface name");
+ goto done;
+ }
r =
netmap_create_if (vm, host_if_name, hw_addr_ptr, is_pipe, is_master,
&sw_if_index);
if (r == VNET_API_ERROR_SYSCALL_ERROR_1)
- return clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
+ {
+ error = clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
+ goto done;
+ }
if (r == VNET_API_ERROR_INVALID_INTERFACE)
- return clib_error_return (0, "Invalid interface name");
+ {
+ error = clib_error_return (0, "Invalid interface name");
+ goto done;
+ }
if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS)
- return clib_error_return (0, "Interface already exists");
+ {
+ error = clib_error_return (0, "Interface already exists");
+ goto done;
+ }
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
@@ -144,6 +163,7 @@ netmap_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
unformat_input_t _line_input, *line_input = &_line_input;
u8 *host_if_name = NULL;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -154,17 +174,25 @@ netmap_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (unformat (line_input, "name %s", &host_if_name))
;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (host_if_name == NULL)
- return clib_error_return (0, "missing host interface name");
+ {
+ error = clib_error_return (0, "missing host interface name");
+ goto done;
+ }
netmap_delete_if (vm, host_if_name);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index 315daa77f62..c43f6e67789 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -2682,6 +2682,7 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
u32 custom_dev_instance = ~0;
u8 hwaddr[6];
u8 *hw = NULL;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -2704,10 +2705,12 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
renumber = 1;
}
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
vnet_main_t *vnm = vnet_get_main ();
@@ -2716,14 +2719,18 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
is_server, &sw_if_index, feature_mask,
renumber, custom_dev_instance, hw)))
{
- vec_free (sock_filename);
- return clib_error_return (0, "vhost_user_create_if returned %d", rv);
+ error = clib_error_return (0, "vhost_user_create_if returned %d", rv);
+ goto done;
}
- vec_free (sock_filename);
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index);
- return 0;
+
+done:
+ vec_free (sock_filename);
+ unformat_free (line_input);
+
+ return error;
}
clib_error_t *
@@ -2734,6 +2741,7 @@ vhost_user_delete_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
u32 sw_if_index = ~0;
vnet_main_t *vnm = vnet_get_main ();
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -2751,15 +2759,25 @@ vhost_user_delete_command_fn (vlib_main_t * vm,
vnet_get_sup_hw_interface (vnm, sw_if_index);
if (hwif == NULL ||
vhost_user_dev_class.index != hwif->dev_class_index)
- return clib_error_return (0, "Not a vhost interface");
+ {
+ error = clib_error_return (0, "Not a vhost interface");
+ goto done;
+ }
}
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
+
vhost_user_delete_if (vnm, vm, sw_if_index);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
int
@@ -3286,6 +3304,7 @@ vhost_thread_command_fn (vlib_main_t * vm,
u32 sw_if_index;
u8 del = 0;
int rv;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -3295,9 +3314,9 @@ vhost_thread_command_fn (vlib_main_t * vm,
(line_input, "%U %d", unformat_vnet_sw_interface, vnet_get_main (),
&sw_if_index, &worker_thread_index))
{
- unformat_free (line_input);
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
}
if (unformat (line_input, "del"))
@@ -3305,9 +3324,16 @@ vhost_thread_command_fn (vlib_main_t * vm,
if ((rv =
vhost_user_thread_placement (sw_if_index, worker_thread_index, del)))
- return clib_error_return (0, "vhost_user_thread_placement returned %d",
- rv);
- return 0;
+ {
+ error = clib_error_return (0, "vhost_user_thread_placement returned %d",
+ rv);
+ goto done;
+ }
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c
index d624587d8e9..d4476ac4682 100644
--- a/src/vnet/gre/interface.c
+++ b/src/vnet/gre/interface.c
@@ -491,6 +491,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
u32 num_m_args = 0;
u8 is_add = 1;
u32 sw_if_index;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (! unformat_user (input, unformat_line_input, line_input))
@@ -508,16 +509,24 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "teb"))
teb = 1;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args < 2)
- return clib_error_return (0, "mandatory argument(s) missing");
+ {
+ error = clib_error_return (0, "mandatory argument(s) missing");
+ goto done;
+ }
if (memcmp (&src, &dst, sizeof(src)) == 0)
- return clib_error_return (0, "src and dst are identical");
+ {
+ error = clib_error_return (0, "src and dst are identical");
+ goto done;
+ }
memset (a, 0, sizeof (*a));
a->outer_fib_id = outer_fib_id;
@@ -536,15 +545,21 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
break;
case VNET_API_ERROR_INVALID_VALUE:
- return clib_error_return (0, "GRE tunnel already exists...");
+ error = clib_error_return (0, "GRE tunnel already exists...");
+ goto done;
case VNET_API_ERROR_NO_SUCH_FIB:
- return clib_error_return (0, "outer fib ID %d doesn't exist\n",
- outer_fib_id);
+ error = clib_error_return (0, "outer fib ID %d doesn't exist\n",
+ outer_fib_id);
+ goto done;
default:
- return clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
+ error = clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
diff --git a/src/vnet/ip/ip4_source_check.c b/src/vnet/ip/ip4_source_check.c
index d461cc885d6..3af32f2e13b 100644
--- a/src/vnet/ip/ip4_source_check.c
+++ b/src/vnet/ip/ip4_source_check.c
@@ -399,6 +399,8 @@ set_ip_source_check (vlib_main_t * vm,
vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index,
is_del == 0, &config, sizeof (config));
done:
+ unformat_free (line_input);
+
return error;
}
@@ -531,7 +533,9 @@ ip_source_check_accept (vlib_main_t * vm,
}
done:
- return (error);
+ unformat_free (line_input);
+
+ return error;
}
/*?
diff --git a/src/vnet/ip/ip4_test.c b/src/vnet/ip/ip4_test.c
index 45d171130df..73dabfdc23a 100644
--- a/src/vnet/ip/ip4_test.c
+++ b/src/vnet/ip/ip4_test.c
@@ -143,8 +143,11 @@ thrash (vlib_main_t * vm,
else if (unformat (line_input, "verbose"))
verbose = 1;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
}
@@ -178,7 +181,7 @@ thrash (vlib_main_t * vm,
if (p == 0)
{
vlib_cli_output (vm, "Couldn't map fib id %d to fib index\n", table_id);
- return 0;
+ goto done;
}
table_index = p[0];
@@ -294,7 +297,11 @@ thrash (vlib_main_t * vm,
pool_free (tm->route_pool);
}
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index 7229591e683..6b53137ffb2 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -2923,7 +2923,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
else if (unformat (line_input, "ra-lifetime"))
{
if (!unformat (line_input, "%d", &ra_lifetime))
- return (error = unformat_parse_error (line_input));
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
use_lifetime = 1;
break;
}
@@ -2931,13 +2934,19 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
{
if (!unformat
(line_input, "%d %d", &ra_initial_count, &ra_initial_interval))
- return (error = unformat_parse_error (line_input));
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
break;
}
else if (unformat (line_input, "ra-interval"))
{
if (!unformat (line_input, "%d", &ra_max_interval))
- return (error = unformat_parse_error (line_input));
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
if (!unformat (line_input, "%d", &ra_min_interval))
ra_min_interval = 0;
@@ -2949,7 +2958,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
break;
}
else
- return (unformat_parse_error (line_input));
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
}
if (add_radv_info)
@@ -3006,7 +3018,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
else if (unformat (line_input, "no-onlink"))
no_onlink = 1;
else
- return (unformat_parse_error (line_input));
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
}
ip6_neighbor_ra_prefix (vm, sw_if_index,
@@ -3018,9 +3033,9 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
off_link, no_autoconfig, no_onlink, is_no);
}
+done:
unformat_free (line_input);
-done:
return error;
}
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 0ef0e7a6deb..807b87b6037 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -568,8 +568,6 @@ vnet_ip_route_cmd (vlib_main_t * vm,
}
}
- unformat_free (line_input);
-
if (vec_len (prefixs) == 0)
{
error =
@@ -704,6 +702,7 @@ done:
vec_free (dpos);
vec_free (prefixs);
vec_free (rpaths);
+ unformat_free (line_input);
return error;
}
@@ -872,8 +871,6 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
}
}
- unformat_free (line_input);
-
if (~0 == table_id)
{
/*
@@ -970,6 +967,8 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
(scount * gcount) / (timet[1] - timet[0]));
done:
+ unformat_free (line_input);
+
return error;
}
@@ -1149,24 +1148,37 @@ probe_neighbor_address (vlib_main_t * vm,
is_ip4 = 0;
}
else
- return clib_error_return (0, "unknown input '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (sw_if_index == ~0)
- return clib_error_return (0, "Interface required, not set.");
+ {
+ error = clib_error_return (0, "Interface required, not set.");
+ goto done;
+ }
if (address_set == 0)
- return clib_error_return (0, "ip address required, not set.");
+ {
+ error = clib_error_return (0, "ip address required, not set.");
+ goto done;
+ }
if (address_set > 1)
- return clib_error_return (0, "Multiple ip addresses not supported.");
+ {
+ error = clib_error_return (0, "Multiple ip addresses not supported.");
+ goto done;
+ }
if (is_ip4)
error = ip4_probe_neighbor_wait (vm, &a4, sw_if_index, retry_count);
else
error = ip6_probe_neighbor_wait (vm, &a6, sw_if_index, retry_count);
+done:
+ unformat_free (line_input);
+
return error;
}
diff --git a/src/vnet/ipsec-gre/interface.c b/src/vnet/ipsec-gre/interface.c
index 3b6e4ac261c..0772ce73df2 100644
--- a/src/vnet/ipsec-gre/interface.c
+++ b/src/vnet/ipsec-gre/interface.c
@@ -232,6 +232,7 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm,
vnet_ipsec_gre_add_del_tunnel_args_t _a, *a = &_a;
int rv;
u32 sw_if_index;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -250,16 +251,24 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "remote-sa %d", &rsa))
num_m_args++;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args < 4)
- return clib_error_return (0, "mandatory argument(s) missing");
+ {
+ error = clib_error_return (0, "mandatory argument(s) missing");
+ goto done;
+ }
if (memcmp (&src, &dst, sizeof (src)) == 0)
- return clib_error_return (0, "src and dst are identical");
+ {
+ error = clib_error_return (0, "src and dst are identical");
+ goto done;
+ }
memset (a, 0, sizeof (*a));
a->is_add = is_add;
@@ -277,14 +286,19 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm,
vnet_get_main (), sw_if_index);
break;
case VNET_API_ERROR_INVALID_VALUE:
- return clib_error_return (0, "GRE tunnel already exists...");
+ error = clib_error_return (0, "GRE tunnel already exists...");
+ goto done;
default:
- return clib_error_return (0,
- "vnet_ipsec_gre_add_del_tunnel returned %d",
- rv);
+ error = clib_error_return (0,
+ "vnet_ipsec_gre_add_del_tunnel returned %d",
+ rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/ipsec/ipsec_cli.c b/src/vnet/ipsec/ipsec_cli.c
index 3c1e26f22c0..0e034402b5c 100644
--- a/src/vnet/ipsec/ipsec_cli.c
+++ b/src/vnet/ipsec/ipsec_cli.c
@@ -32,6 +32,7 @@ set_interface_spd_command_fn (vlib_main_t * vm,
u32 sw_if_index = (u32) ~ 0;
u32 spd_id;
int is_add = 1;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -43,14 +44,18 @@ set_interface_spd_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "del"))
is_add = 0;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
-
- unformat_free (line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -72,7 +77,7 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm,
ipsec_sa_t sa;
int is_add = ~0;
u8 *ck = 0, *ik = 0;
- clib_error_t *err = 0;
+ clib_error_t *error = NULL;
memset (&sa, 0, sizeof (sa));
@@ -90,8 +95,11 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "esp"))
sa.protocol = IPSEC_PROTOCOL_ESP;
else if (unformat (line_input, "ah"))
- //sa.protocol = IPSEC_PROTOCOL_AH;
- return clib_error_return (0, "unsupported security protocol 'AH'");
+ {
+ //sa.protocol = IPSEC_PROTOCOL_AH;
+ error = clib_error_return (0, "unsupported security protocol 'AH'");
+ goto done;
+ }
else
if (unformat (line_input, "crypto-key %U", unformat_hex_string, &ck))
sa.crypto_key_len = vec_len (ck);
@@ -102,8 +110,12 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm,
{
if (sa.crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
sa.crypto_alg >= IPSEC_CRYPTO_N_ALG)
- return clib_error_return (0, "unsupported crypto-alg: '%U'",
- format_ipsec_crypto_alg, sa.crypto_alg);
+ {
+ error = clib_error_return (0, "unsupported crypto-alg: '%U'",
+ format_ipsec_crypto_alg,
+ sa.crypto_alg);
+ goto done;
+ }
}
else
if (unformat (line_input, "integ-key %U", unformat_hex_string, &ik))
@@ -113,8 +125,12 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm,
{
if (sa.integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
sa.integ_alg >= IPSEC_INTEG_N_ALG)
- return clib_error_return (0, "unsupported integ-alg: '%U'",
- format_ipsec_integ_alg, sa.integ_alg);
+ {
+ error = clib_error_return (0, "unsupported integ-alg: '%U'",
+ format_ipsec_integ_alg,
+ sa.integ_alg);
+ goto done;
+ }
}
else if (unformat (line_input, "tunnel-src %U",
unformat_ip4_address, &sa.tunnel_src_addr.ip4))
@@ -135,12 +151,13 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm,
sa.is_tunnel_ip6 = 1;
}
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (sa.crypto_key_len > sizeof (sa.crypto_key))
sa.crypto_key_len = sizeof (sa.crypto_key);
@@ -156,14 +173,17 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm,
if (is_add)
{
ASSERT (im->cb.check_support_cb);
- err = im->cb.check_support_cb (&sa);
- if (err)
- return err;
+ error = im->cb.check_support_cb (&sa);
+ if (error)
+ goto done;
}
ipsec_add_del_sa (vm, &sa, is_add);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -183,6 +203,7 @@ ipsec_spd_add_del_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
u32 spd_id = ~0;
int is_add = ~0;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -196,18 +217,25 @@ ipsec_spd_add_del_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "%u", &spd_id))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (spd_id == ~0)
- return clib_error_return (0, "please specify SPD ID");
+ {
+ error = clib_error_return (0, "please specify SPD ID");
+ goto done;
+ }
ipsec_add_del_spd (vm, spd_id, is_add);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -230,6 +258,7 @@ ipsec_policy_add_del_command_fn (vlib_main_t * vm,
int is_add = 0;
int is_ip_any = 1;
u32 tmp, tmp2;
+ clib_error_t *error = NULL;
memset (&p, 0, sizeof (p));
p.lport.stop = p.rport.stop = ~0;
@@ -262,7 +291,10 @@ ipsec_policy_add_del_command_fn (vlib_main_t * vm,
&p.policy))
{
if (p.policy == IPSEC_POLICY_ACTION_RESOLVE)
- return clib_error_return (0, "unsupported action: 'resolve'");
+ {
+ error = clib_error_return (0, "unsupported action: 'resolve'");
+ goto done;
+ }
}
else if (unformat (line_input, "sa %u", &p.sa_id))
;
@@ -300,19 +332,24 @@ ipsec_policy_add_del_command_fn (vlib_main_t * vm,
p.rport.stop = tmp2;
}
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
ipsec_add_del_policy (vm, &p, is_add);
if (is_ip_any)
{
p.is_ipv6 = 1;
ipsec_add_del_policy (vm, &p, is_add);
}
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -332,6 +369,7 @@ set_ipsec_sa_key_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
ipsec_sa_t sa;
u8 *ck = 0, *ik = 0;
+ clib_error_t *error = NULL;
memset (&sa, 0, sizeof (sa));
@@ -349,12 +387,13 @@ set_ipsec_sa_key_command_fn (vlib_main_t * vm,
if (unformat (line_input, "integ-key %U", unformat_hex_string, &ik))
sa.integ_key_len = vec_len (ik);
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (sa.crypto_key_len > sizeof (sa.crypto_key))
sa.crypto_key_len = sizeof (sa.crypto_key);
@@ -369,7 +408,10 @@ set_ipsec_sa_key_command_fn (vlib_main_t * vm,
ipsec_set_sa_key (vm, &sa);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -649,6 +691,7 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm,
ipsec_add_del_tunnel_args_t a;
int rv;
u32 num_m_args = 0;
+ clib_error_t *error = NULL;
memset (&a, 0, sizeof (a));
a.is_add = 1;
@@ -673,13 +716,18 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "del"))
a.is_add = 0;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args < 4)
- return clib_error_return (0, "mandatory argument(s) missing");
+ {
+ error = clib_error_return (0, "mandatory argument(s) missing");
+ goto done;
+ }
rv = ipsec_add_del_tunnel_if (&a);
@@ -689,16 +737,21 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_INVALID_VALUE:
if (a.is_add)
- return clib_error_return (0,
- "IPSec tunnel interface already exists...");
+ error = clib_error_return (0,
+ "IPSec tunnel interface already exists...");
else
- return clib_error_return (0, "IPSec tunnel interface not exists...");
+ error = clib_error_return (0, "IPSec tunnel interface not exists...");
+ goto done;
default:
- return clib_error_return (0, "ipsec_register_interface returned %d",
- rv);
+ error = clib_error_return (0, "ipsec_register_interface returned %d",
+ rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -720,6 +773,7 @@ set_interface_key_command_fn (vlib_main_t * vm,
u32 hw_if_index = (u32) ~ 0;
u32 alg;
u8 *key = 0;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -748,25 +802,38 @@ set_interface_key_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "%U", unformat_hex_string, &key))
;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (type == IPSEC_IF_SET_KEY_TYPE_NONE)
- return clib_error_return (0, "unknown key type");
+ {
+ error = clib_error_return (0, "unknown key type");
+ goto done;
+ }
if (alg > 0 && vec_len (key) == 0)
- return clib_error_return (0, "key is not specified");
+ {
+ error = clib_error_return (0, "key is not specified");
+ goto done;
+ }
if (hw_if_index == (u32) ~ 0)
- return clib_error_return (0, "interface not specified");
+ {
+ error = clib_error_return (0, "interface not specified");
+ goto done;
+ }
ipsec_set_interface_key (im->vnet_main, hw_if_index, type, alg, key);
+
+done:
vec_free (key);
+ unformat_free (line_input);
- return 0;
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/l2/l2_patch.c b/src/vnet/l2/l2_patch.c
index 5e4691f45c7..ff3d2f3a6af 100644
--- a/src/vnet/l2/l2_patch.c
+++ b/src/vnet/l2/l2_patch.c
@@ -315,6 +315,7 @@ test_patch_command_fn (vlib_main_t * vm,
int rx_set = 0;
int tx_set = 0;
int is_add = 1;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -335,10 +336,16 @@ test_patch_command_fn (vlib_main_t * vm,
}
if (rx_set == 0)
- return clib_error_return (0, "rx interface not set");
+ {
+ error = clib_error_return (0, "rx interface not set");
+ goto done;
+ }
if (tx_set == 0)
- return clib_error_return (0, "tx interface not set");
+ {
+ error = clib_error_return (0, "tx interface not set");
+ goto done;
+ }
rv = vnet_l2_patch_add_del (rx_sw_if_index, tx_sw_if_index, is_add);
@@ -348,17 +355,24 @@ test_patch_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_INVALID_SW_IF_INDEX:
- return clib_error_return (0, "rx interface not a physical port");
+ error = clib_error_return (0, "rx interface not a physical port");
+ goto done;
case VNET_API_ERROR_INVALID_SW_IF_INDEX_2:
- return clib_error_return (0, "tx interface not a physical port");
+ error = clib_error_return (0, "tx interface not a physical port");
+ goto done;
default:
- return clib_error_return
+ error = clib_error_return
(0, "WARNING: vnet_l2_patch_add_del returned %d", rv);
+ goto done;
}
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
diff --git a/src/vnet/l2/l2_xcrw.c b/src/vnet/l2/l2_xcrw.c
index 70610a853d3..d08a5d8f8e8 100644
--- a/src/vnet/l2/l2_xcrw.c
+++ b/src/vnet/l2/l2_xcrw.c
@@ -409,6 +409,7 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
u8 *rw = 0;
vnet_main_t *vnm = vnet_get_main ();
int rv;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
@@ -416,8 +417,11 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
if (!unformat (line_input, "%U",
unformat_vnet_sw_interface, vnm, &l2_sw_if_index))
- return clib_error_return (0, "unknown input '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -436,7 +440,10 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
}
if (next_node_index == ~0)
- return clib_error_return (0, "next node not specified");
+ {
+ error = clib_error_return (0, "next node not specified");
+ goto done;
+ }
if (tx_fib_id != ~0)
{
@@ -448,7 +455,11 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
p = hash_get (ip4_main.fib_index_by_table_id, tx_fib_id);
if (p == 0)
- return clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id);
+ {
+ error =
+ clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id);
+ goto done;
+ }
tx_fib_index = p[0];
}
@@ -463,16 +474,21 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_INVALID_SW_IF_INDEX:
- return clib_error_return (0, "%U not cross-connected",
- format_vnet_sw_if_index_name,
- vnm, l2_sw_if_index);
+ error = clib_error_return (0, "%U not cross-connected",
+ format_vnet_sw_if_index_name,
+ vnm, l2_sw_if_index);
+ goto done;
+
default:
- return clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv);
+ error = clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv);
+ goto done;
}
+done:
vec_free (rw);
+ unformat_free (line_input);
- return 0;
+ return error;
}
/*?
diff --git a/src/vnet/l2tp/l2tp.c b/src/vnet/l2tp/l2tp.c
index a4531dab85c..2d3233972a8 100644
--- a/src/vnet/l2tp/l2tp.c
+++ b/src/vnet/l2tp/l2tp.c
@@ -427,6 +427,7 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
u32 sw_if_index;
u32 encap_fib_id = ~0;
u32 encap_fib_index = ~0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -455,18 +456,22 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "l2-sublayer-present"))
l2_sublayer_present = 1;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (encap_fib_id != ~0)
{
uword *p;
ip6_main_t *im = &ip6_main;
if (!(p = hash_get (im->fib_index_by_table_id, encap_fib_id)))
- return clib_error_return (0, "No fib with id %d", encap_fib_id);
+ {
+ error = clib_error_return (0, "No fib with id %d", encap_fib_id);
+ goto done;
+ }
encap_fib_index = p[0];
}
else
@@ -475,9 +480,15 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
}
if (our_address_set == 0)
- return clib_error_return (0, "our address not specified");
+ {
+ error = clib_error_return (0, "our address not specified");
+ goto done;
+ }
if (client_address_set == 0)
- return clib_error_return (0, "client address not specified");
+ {
+ error = clib_error_return (0, "client address not specified");
+ goto done;
+ }
rv = create_l2tpv3_ipv6_tunnel (lm, &client_address, &our_address,
local_session_id, remote_session_id,
@@ -491,16 +502,22 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
vnet_get_main (), sw_if_index);
break;
case VNET_API_ERROR_INVALID_VALUE:
- return clib_error_return (0, "session already exists...");
+ error = clib_error_return (0, "session already exists...");
+ goto done;
case VNET_API_ERROR_NO_SUCH_ENTRY:
- return clib_error_return (0, "session does not exist...");
+ error = clib_error_return (0, "session does not exist...");
+ goto done;
default:
- return clib_error_return (0, "l2tp_session_add_del returned %d", rv);
+ error = clib_error_return (0, "l2tp_session_add_del returned %d", rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/lisp-cp/lisp_cli.c b/src/vnet/lisp-cp/lisp_cli.c
index 25d11c6127e..05df9fb6d2a 100644
--- a/src/vnet/lisp-cp/lisp_cli.c
+++ b/src/vnet/lisp-cp/lisp_cli.c
@@ -25,6 +25,7 @@ lisp_show_adjacencies_command_fn (vlib_main_t * vm,
vlib_cli_output (vm, "%s %40s\n", "leid", "reid");
unformat_input_t _line_input, *line_input = &_line_input;
u32 vni = ~0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -38,14 +39,14 @@ lisp_show_adjacencies_command_fn (vlib_main_t * vm,
{
vlib_cli_output (vm, "parse error: '%U'",
format_unformat_error, line_input);
- return 0;
+ goto done;
}
}
if (~0 == vni)
{
vlib_cli_output (vm, "error: no vni specified!");
- return 0;
+ goto done;
}
adjs = vnet_lisp_adjacencies_get_by_vni (vni);
@@ -57,7 +58,10 @@ lisp_show_adjacencies_command_fn (vlib_main_t * vm,
}
vec_free (adjs);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -77,6 +81,7 @@ lisp_add_del_map_server_command_fn (vlib_main_t * vm,
u8 is_add = 1, ip_set = 0;
ip_address_t ip;
unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -94,14 +99,14 @@ lisp_add_del_map_server_command_fn (vlib_main_t * vm,
{
vlib_cli_output (vm, "parse error: '%U'",
format_unformat_error, line_input);
- return 0;
+ goto done;
}
}
if (!ip_set)
{
vlib_cli_output (vm, "map-server ip address not set!");
- return 0;
+ goto done;
}
rv = vnet_lisp_add_del_map_server (&ip, is_add);
@@ -109,7 +114,10 @@ lisp_add_del_map_server_command_fn (vlib_main_t * vm,
vlib_cli_output (vm, "failed to %s map-server!",
is_add ? "add" : "delete");
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -191,7 +199,7 @@ lisp_add_del_local_eid_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (key && (0 == key_id))
{
vlib_cli_output (vm, "invalid key_id!");
- return 0;
+ goto done;;
}
gid_address_copy (&a->eid, &eid);
@@ -213,6 +221,8 @@ done:
vec_free (locator_set_name);
gid_address_free (&a->eid);
vec_free (a->key);
+ unformat_free (line_input);
+
return error;
}
@@ -233,6 +243,7 @@ lisp_eid_table_map_command_fn (vlib_main_t * vm,
u8 is_add = 1, is_l2 = 0;
u32 vni = 0, dp_id = 0;
unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -250,11 +261,16 @@ lisp_eid_table_map_command_fn (vlib_main_t * vm,
is_l2 = 1;
else
{
- return unformat_parse_error (line_input);
+ error = unformat_parse_error (line_input);
+ goto done;
}
}
vnet_lisp_eid_table_map (vni, dp_id, is_l2, is_add);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -479,7 +495,7 @@ lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input,
!= ip_prefix_version (leid_ippref)))
{
clib_warning ("remote and local EIDs are of different types!");
- return error;
+ goto done;
}
memset (a, 0, sizeof (a[0]));
@@ -512,6 +528,7 @@ lisp_map_request_mode_command_fn (vlib_main_t * vm,
{
unformat_input_t _i, *i = &_i;
map_request_mode_t mr_mode = _MR_MODE_MAX;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, i))
@@ -533,12 +550,15 @@ lisp_map_request_mode_command_fn (vlib_main_t * vm,
if (_MR_MODE_MAX == mr_mode)
{
clib_warning ("No LISP map request mode entered!");
- return 0;
+ goto done;
}
vnet_lisp_set_map_request_mode (mr_mode);
+
done:
- return 0;
+ unformat_free (i);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -630,7 +650,10 @@ lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "disable"))
is_add = 0;
else
- return clib_error_return (0, "parse error");
+ {
+ error = clib_error_return (0, "parse error");
+ goto done;
+ }
}
if (!locator_name_set)
@@ -648,6 +671,8 @@ lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm,
done:
if (locator_set_name)
vec_free (locator_set_name);
+ unformat_free (line_input);
+
return error;
}
@@ -771,6 +796,7 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm,
gid_address_t eid;
u8 print_all = 1;
u8 filter = 0;
+ clib_error_t *error = NULL;
memset (&eid, 0, sizeof (eid));
@@ -787,8 +813,11 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "remote"))
filter = 2;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
@@ -818,7 +847,7 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm,
{
mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
if ((u32) ~ 0 == mi)
- return 0;
+ goto done;
mapit = pool_elt_at_index (lcm->mapping_pool, mi);
locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool,
@@ -827,14 +856,17 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm,
if (filter && !((1 == filter && ls->local) ||
(2 == filter && !ls->local)))
{
- return 0;
+ goto done;
}
vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
lcm, mapit, ls);
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -853,6 +885,7 @@ lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
unformat_input_t _line_input, *line_input = &_line_input;
u8 is_enabled = 0;
u8 is_set = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -869,16 +902,24 @@ lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
is_set = 1;
else
{
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
}
}
if (!is_set)
- return clib_error_return (0, "state not set");
+ {
+ error = clib_error_return (0, "state not set");
+ goto done;
+ }
vnet_lisp_enable_disable (is_enabled);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -897,6 +938,7 @@ lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
u8 is_enabled = 0;
u8 is_set = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -915,18 +957,22 @@ lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
{
vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
line_input);
- return 0;
+ goto done;
}
}
if (!is_set)
{
vlib_cli_output (vm, "state not set!");
- return 0;
+ goto done;
}
vnet_lisp_map_register_enable_disable (is_enabled);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -945,6 +991,7 @@ lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
u8 is_enabled = 0;
u8 is_set = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -963,18 +1010,22 @@ lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
{
vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
line_input);
- return 0;
+ goto done;
}
}
if (!is_set)
{
vlib_cli_output (vm, "state not set!");
- return 0;
+ goto done;
}
vnet_lisp_rloc_probe_enable_disable (is_enabled);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -1022,6 +1073,7 @@ lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
uword *vni_table = 0;
u8 is_l2 = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -1040,14 +1092,17 @@ lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
is_l2 = 0;
}
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
if (!vni_table)
{
vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
- return 0;
+ goto done;
}
vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
@@ -1059,7 +1114,10 @@ lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
}));
/* *INDENT-ON* */
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
@@ -1131,6 +1189,8 @@ done:
vec_free (locators);
if (locator_set_name)
vec_free (locator_set_name);
+ unformat_free (line_input);
+
return error;
}
@@ -1205,6 +1265,8 @@ lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
done:
vec_free (locators);
vec_free (locator_set_name);
+ unformat_free (line_input);
+
return error;
}
@@ -1322,6 +1384,8 @@ lisp_add_del_map_resolver_command_fn (vlib_main_t * vm,
}
done:
+ unformat_free (line_input);
+
return error;
}
@@ -1372,11 +1436,11 @@ lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm,
is_add ? "add" : "delete");
}
+done:
vec_free (locator_set_name);
+ unformat_free (line_input);
-done:
return error;
-
}
/* *INDENT-OFF* */
@@ -1438,7 +1502,10 @@ lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "disable"))
is_add = 0;
else
- return clib_error_return (0, "parse error");
+ {
+ error = clib_error_return (0, "parse error");
+ goto done;
+ }
}
if (!ip_set)
@@ -1454,6 +1521,8 @@ lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm,
}
done:
+ unformat_free (line_input);
+
return error;
}
diff --git a/src/vnet/lisp-gpe/interface.c b/src/vnet/lisp-gpe/interface.c
index 2142e095119..19ac22e7a56 100644
--- a/src/vnet/lisp-gpe/interface.c
+++ b/src/vnet/lisp-gpe/interface.c
@@ -794,6 +794,7 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
u32 table_id, vni, bd_id;
u8 vni_is_set = 0, vrf_is_set = 0, bd_index_is_set = 0;
u8 nsh_iface = 0;
+ clib_error_t *error = NULL;
if (vnet_lisp_gpe_enable_disable_status () == 0)
{
@@ -828,8 +829,9 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
else
{
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
}
}
@@ -839,7 +841,8 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
if (~0 == lisp_gpe_add_nsh_iface (&lisp_gpe_main))
{
- return clib_error_return (0, "NSH interface not created");
+ error = clib_error_return (0, "NSH interface not created");
+ goto done;
}
}
else
@@ -850,21 +853,34 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
if (vrf_is_set && bd_index_is_set)
- return clib_error_return (0,
- "Cannot set both vrf and brdige domain index!");
+ {
+ error = clib_error_return
+ (0, "Cannot set both vrf and brdige domain index!");
+ goto done;
+ }
if (!vni_is_set)
- return clib_error_return (0, "vni must be set!");
+ {
+ error = clib_error_return (0, "vni must be set!");
+ goto done;
+ }
if (!vrf_is_set && !bd_index_is_set)
- return clib_error_return (0, "vrf or bridge domain index must be set!");
+ {
+ error =
+ clib_error_return (0, "vrf or bridge domain index must be set!");
+ goto done;
+ }
if (bd_index_is_set)
{
if (is_add)
{
if (~0 == lisp_gpe_tenant_l2_iface_add_or_lock (vni, bd_id))
- return clib_error_return (0, "L2 interface not created");
+ {
+ error = clib_error_return (0, "L2 interface not created");
+ goto done;
+ }
}
else
lisp_gpe_tenant_l2_iface_unlock (vni);
@@ -874,13 +890,35 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (is_add)
{
if (~0 == lisp_gpe_tenant_l3_iface_add_or_lock (vni, table_id))
- return clib_error_return (0, "L3 interface not created");
+ {
+ error = clib_error_return (0, "L3 interface not created");
+ goto done;
+ }
}
else
lisp_gpe_tenant_l3_iface_unlock (vni);
}
- return (NULL);
+ if (nsh_iface)
+ {
+ if (is_add)
+ {
+ if (~0 == lisp_gpe_add_nsh_iface (&lisp_gpe_main))
+ {
+ error = clib_error_return (0, "NSH interface not created");
+ goto done;
+ }
+ else
+ {
+ lisp_gpe_del_nsh_iface (&lisp_gpe_main);
+ }
+ }
+ }
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c
index 1f8afdaefb8..f2fbcbd5b2b 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.c
+++ b/src/vnet/lisp-gpe/lisp_gpe.c
@@ -218,6 +218,7 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
u8 is_en = 1;
vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -231,12 +232,18 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm,
is_en = 0;
else
{
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
}
}
a->is_en = is_en;
- return vnet_lisp_gpe_enable_disable (a);
+ error = vnet_lisp_gpe_enable_disable (a);
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/map/map.c b/src/vnet/map/map.c
index aeec6a946c9..a2d28118ff4 100644
--- a/src/vnet/map/map.c
+++ b/src/vnet/map/map.c
@@ -465,6 +465,8 @@ map_security_check_command_fn (vlib_main_t * vm,
{
unformat_input_t _line_input, *line_input = &_line_input;
map_main_t *mm = &map_main;
+ clib_error_t *error = NULL;
+
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -476,11 +478,17 @@ map_security_check_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "on"))
mm->sec_check = true;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+
+done:
unformat_free (line_input);
- return 0;
+
+ return error;
}
static clib_error_t *
@@ -490,6 +498,8 @@ map_security_check_frag_command_fn (vlib_main_t * vm,
{
unformat_input_t _line_input, *line_input = &_line_input;
map_main_t *mm = &map_main;
+ clib_error_t *error = NULL;
+
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -501,11 +511,17 @@ map_security_check_frag_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "on"))
mm->sec_check_frag = true;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+
+done:
unformat_free (line_input);
- return 0;
+
+ return error;
}
static clib_error_t *
@@ -523,6 +539,7 @@ map_add_domain_command_fn (vlib_main_t * vm,
u32 mtu = 0;
u8 flags = 0;
ip6_src_len = 128;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -559,20 +576,28 @@ map_add_domain_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "map-t"))
flags |= MAP_DOMAIN_TRANSLATION;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args < 3)
- return clib_error_return (0, "mandatory argument(s) missing");
+ {
+ error = clib_error_return (0, "mandatory argument(s) missing");
+ goto done;
+ }
map_create_domain (&ip4_prefix, ip4_prefix_len,
&ip6_prefix, ip6_prefix_len, &ip6_src, ip6_src_len,
ea_bits_len, psid_offset, psid_length, &map_domain_index,
mtu, flags);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
static clib_error_t *
@@ -582,6 +607,7 @@ map_del_domain_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
u32 num_m_args = 0;
u32 map_domain_index;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -592,17 +618,25 @@ map_del_domain_command_fn (vlib_main_t * vm,
if (unformat (line_input, "index %d", &map_domain_index))
num_m_args++;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args != 1)
- return clib_error_return (0, "mandatory argument(s) missing");
+ {
+ error = clib_error_return (0, "mandatory argument(s) missing");
+ goto done;
+ }
map_delete_domain (map_domain_index);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
static clib_error_t *
@@ -613,6 +647,7 @@ map_add_rule_command_fn (vlib_main_t * vm,
ip6_address_t tep;
u32 num_m_args = 0;
u32 psid = 0, map_domain_index;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -628,19 +663,29 @@ map_add_rule_command_fn (vlib_main_t * vm,
if (unformat (line_input, "ip6-dst %U", unformat_ip6_address, &tep))
num_m_args++;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args != 3)
- return clib_error_return (0, "mandatory argument(s) missing");
+ {
+ error = clib_error_return (0, "mandatory argument(s) missing");
+ goto done;
+ }
if (map_add_del_psid (map_domain_index, psid, &tep, 1) != 0)
{
- return clib_error_return (0, "Failing to add Mapping Rule");
+ error = clib_error_return (0, "Failing to add Mapping Rule");
+ goto done;
}
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
#if MAP_SKIP_IP6_LOOKUP
@@ -653,6 +698,7 @@ map_pre_resolve_command_fn (vlib_main_t * vm,
ip4_address_t ip4nh;
ip6_address_t ip6nh;
map_main_t *mm = &map_main;
+ clib_error_t *error = NULL;
memset (&ip4nh, 0, sizeof (ip4nh));
memset (&ip6nh, 0, sizeof (ip6nh));
@@ -669,14 +715,19 @@ map_pre_resolve_command_fn (vlib_main_t * vm,
if (unformat (line_input, "ip6-nh %U", unformat_ip6_address, &ip6nh))
mm->preresolve_ip6 = ip6nh;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
map_pre_resolve (&ip4nh, &ip6nh);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
#endif
@@ -688,6 +739,7 @@ map_icmp_relay_source_address_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
ip4_address_t icmp_src_address;
map_main_t *mm = &map_main;
+ clib_error_t *error = NULL;
mm->icmp4_src_address.as_u32 = 0;
@@ -701,12 +753,17 @@ map_icmp_relay_source_address_command_fn (vlib_main_t * vm,
(line_input, "%U", unformat_ip4_address, &icmp_src_address))
mm->icmp4_src_address = icmp_src_address;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+
+done:
unformat_free (line_input);
- return 0;
+ return error;
}
static clib_error_t *
@@ -717,6 +774,7 @@ map_icmp_unreachables_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
map_main_t *mm = &map_main;
int num_m_args = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -730,16 +788,21 @@ map_icmp_unreachables_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "off"))
mm->icmp6_enabled = false;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (num_m_args != 1)
- return clib_error_return (0, "mandatory argument(s) missing");
+ error = clib_error_return (0, "mandatory argument(s) missing");
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
static clib_error_t *
@@ -748,6 +811,7 @@ map_fragment_command_fn (vlib_main_t * vm,
{
unformat_input_t _line_input, *line_input = &_line_input;
map_main_t *mm = &map_main;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -760,12 +824,17 @@ map_fragment_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "outer"))
mm->frag_inner = false;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+
+done:
unformat_free (line_input);
- return 0;
+ return error;
}
static clib_error_t *
@@ -775,6 +844,7 @@ map_fragment_df_command_fn (vlib_main_t * vm,
{
unformat_input_t _line_input, *line_input = &_line_input;
map_main_t *mm = &map_main;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -787,12 +857,17 @@ map_fragment_df_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "off"))
mm->frag_ignore_df = false;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+
+done:
unformat_free (line_input);
- return 0;
+ return error;
}
static clib_error_t *
@@ -803,6 +878,7 @@ map_traffic_class_command_fn (vlib_main_t * vm,
unformat_input_t _line_input, *line_input = &_line_input;
map_main_t *mm = &map_main;
u32 tc = 0;
+ clib_error_t *error = NULL;
mm->tc_copy = false;
@@ -817,12 +893,17 @@ map_traffic_class_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "%x", &tc))
mm->tc = tc & 0xff;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+
+done:
unformat_free (line_input);
- return 0;
+ return error;
}
static u8 *
@@ -922,6 +1003,7 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input,
map_domain_t *d;
bool counters = false;
u32 map_domain_index = ~0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -934,10 +1016,12 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input,
else if (unformat (line_input, "index %d", &map_domain_index))
;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
if (pool_elts (mm->domains) == 0)
vlib_cli_output (vm, "No MAP domains are configured...");
@@ -952,15 +1036,19 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
if (pool_is_free_index (mm->domains, map_domain_index))
{
- return clib_error_return (0, "MAP domain does not exists %d",
- map_domain_index);
+ error = clib_error_return (0, "MAP domain does not exists %d",
+ map_domain_index);
+ goto done;
}
d = pool_elt_at_index (mm->domains, map_domain_index);
vlib_cli_output (vm, "%U", format_map_domain, d, counters);
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
static clib_error_t *
diff --git a/src/vnet/mpls/mpls.c b/src/vnet/mpls/mpls.c
index 0e610e175cc..7ae4aa00264 100644
--- a/src/vnet/mpls/mpls.c
+++ b/src/vnet/mpls/mpls.c
@@ -470,6 +470,8 @@ vnet_mpls_local_label (vlib_main_t * vm,
}
done:
+ unformat_free (line_input);
+
return error;
}
diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c
index 8d1e30a36fb..e488271dd41 100644
--- a/src/vnet/mpls/mpls_tunnel.c
+++ b/src/vnet/mpls/mpls_tunnel.c
@@ -535,6 +535,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
fib_route_path_t rpath, *rpaths = NULL;
mpls_label_t out_label = MPLS_LABEL_INVALID, *labels = NULL;
u32 sw_if_index;
+ clib_error_t *error = NULL;
memset(&rpath, 0, sizeof(rpath));
@@ -595,8 +596,11 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "l2-only"))
l2_only = 1;
else
- return clib_error_return (0, "unknown input '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
if (is_del)
@@ -606,17 +610,22 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
else
{
if (0 == vec_len(labels))
- return clib_error_return (0, "No Output Labels '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "No Output Labels '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
vec_add1(rpaths, rpath);
vnet_mpls_tunnel_add(rpaths, labels, l2_only, &sw_if_index);
}
+done:
vec_free(labels);
vec_free(rpaths);
+ unformat_free (line_input);
- return (NULL);
+ return error;
}
/*?
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index f5896b4326e..3c249a7b5f1 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -547,21 +547,30 @@ pg_capture_cmd_fn (vlib_main_t * vm,
else
{
error = clib_error_create ("unknown input `%U'",
- format_unformat_error, input);
- return error;
+ format_unformat_error, line_input);
+ goto done;
}
}
if (!hi)
- return clib_error_return (0, "Please specify interface name");
+ {
+ error = clib_error_return (0, "Please specify interface name");
+ goto done;
+ }
if (hi->dev_class_index != pg_dev_class.index)
- return clib_error_return (0, "Please specify packet-generator interface");
+ {
+ error =
+ clib_error_return (0, "Please specify packet-generator interface");
+ goto done;
+ }
if (!pcap_file_name && is_disable == 0)
- return clib_error_return (0, "Please specify pcap file name");
+ {
+ error = clib_error_return (0, "Please specify pcap file name");
+ goto done;
+ }
- unformat_free (line_input);
pg_capture_args_t _a, *a = &_a;
@@ -572,6 +581,10 @@ pg_capture_cmd_fn (vlib_main_t * vm,
a->count = count;
error = pg_capture (a);
+
+done:
+ unformat_free (line_input);
+
return error;
}
@@ -590,6 +603,7 @@ create_pg_if_cmd_fn (vlib_main_t * vm,
pg_main_t *pg = &pg_main;
unformat_input_t _line_input, *line_input = &_line_input;
u32 if_id;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -600,14 +614,19 @@ create_pg_if_cmd_fn (vlib_main_t * vm,
;
else
- return clib_error_create ("unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_create ("unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+ pg_interface_add_or_get (pg, if_id);
+
+done:
unformat_free (line_input);
- pg_interface_add_or_get (pg, if_id);
- return 0;
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/policer/node_funcs.c b/src/vnet/policer/node_funcs.c
index 1f4997ff669..457dd09fd12 100644
--- a/src/vnet/policer/node_funcs.c
+++ b/src/vnet/policer/node_funcs.c
@@ -447,6 +447,7 @@ test_policer_command_fn (vlib_main_t * vm,
int rx_set = 0;
int is_add = 1;
int is_show = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -468,7 +469,10 @@ test_policer_command_fn (vlib_main_t * vm,
}
if (rx_set == 0)
- return clib_error_return (0, "interface not set");
+ {
+ error = clib_error_return (0, "interface not set");
+ goto done;
+ }
if (is_show)
{
@@ -477,12 +481,13 @@ test_policer_command_fn (vlib_main_t * vm,
policer = pool_elt_at_index (pm->policers, pi);
vlib_cli_output (vm, "%U", format_policer_instance, policer);
- return 0;
+ goto done;
}
if (is_add && config_name == 0)
{
- return clib_error_return (0, "policer config name required");
+ error = clib_error_return (0, "policer config name required");
+ goto done;
}
rv = test_policer_add_del (rx_sw_if_index, config_name, is_add);
@@ -493,11 +498,15 @@ test_policer_command_fn (vlib_main_t * vm,
break;
default:
- return clib_error_return
+ error = clib_error_return
(0, "WARNING: vnet_vnet_policer_add_del returned %d", rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index 290a6af57e2..cd754e29be9 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -413,6 +413,7 @@ configure_policer_command_fn (vlib_main_t * vm,
u8 is_add = 1;
u8 *name = 0;
u32 pi;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -433,13 +434,19 @@ configure_policer_command_fn (vlib_main_t * vm,
foreach_config_param
#undef _
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+ error = policer_add_del (vm, name, &c, &pi, is_add);
+
+done:
unformat_free (line_input);
- return policer_add_del (vm, name, &c, &pi, is_add);
+ return error;
}
/* *INDENT-OFF* */
diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c
index 48e81b5070e..25c930c6bfe 100644
--- a/src/vnet/unix/tapcli.c
+++ b/src/vnet/unix/tapcli.c
@@ -1308,6 +1308,7 @@ tap_connect_command_fn (vlib_main_t * vm,
int ip6_address_set = 0;
u32 ip4_mask_width = 0;
u32 ip6_mask_width = 0;
+ clib_error_t *error = NULL;
if (tm->is_disabled)
return clib_error_return (0, "device disabled...");
@@ -1336,12 +1337,18 @@ tap_connect_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "%s", &intfc_name))
;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
if (intfc_name == 0)
- return clib_error_return (0, "interface name must be specified");
+ {
+ error = clib_error_return (0, "interface name must be specified");
+ goto done;
+ }
memset (ap, 0, sizeof (*ap));
@@ -1367,48 +1374,64 @@ tap_connect_command_fn (vlib_main_t * vm,
switch (rv)
{
case VNET_API_ERROR_SYSCALL_ERROR_1:
- return clib_error_return (0, "Couldn't open /dev/net/tun");
+ error = clib_error_return (0, "Couldn't open /dev/net/tun");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_2:
- return clib_error_return (0, "Error setting flags on '%s'", intfc_name);
-
+ error = clib_error_return (0, "Error setting flags on '%s'", intfc_name);
+ goto done;
+
case VNET_API_ERROR_SYSCALL_ERROR_3:
- return clib_error_return (0, "Couldn't open provisioning socket");
+ error = clib_error_return (0, "Couldn't open provisioning socket");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_4:
- return clib_error_return (0, "Couldn't get if_index");
+ error = clib_error_return (0, "Couldn't get if_index");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_5:
- return clib_error_return (0, "Couldn't bind provisioning socket");
+ error = clib_error_return (0, "Couldn't bind provisioning socket");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_6:
- return clib_error_return (0, "Couldn't set device non-blocking flag");
+ error = clib_error_return (0, "Couldn't set device non-blocking flag");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_7:
- return clib_error_return (0, "Couldn't set device MTU");
+ error = clib_error_return (0, "Couldn't set device MTU");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_8:
- return clib_error_return (0, "Couldn't get interface flags");
+ error = clib_error_return (0, "Couldn't get interface flags");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_9:
- return clib_error_return (0, "Couldn't set intfc admin state up");
+ error = clib_error_return (0, "Couldn't set intfc admin state up");
+ goto done;
case VNET_API_ERROR_SYSCALL_ERROR_10:
- return clib_error_return (0, "Couldn't set intfc address/mask");
+ error = clib_error_return (0, "Couldn't set intfc address/mask");
+ goto done;
case VNET_API_ERROR_INVALID_REGISTRATION:
- return clib_error_return (0, "Invalid registration");
+ error = clib_error_return (0, "Invalid registration");
+ goto done;
case 0:
break;
default:
- return clib_error_return (0, "Unknown error: %d", rv);
+ error = clib_error_return (0, "Unknown error: %d", rv);
+ goto done;
}
vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name,
vnet_get_main(), sw_if_index);
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (tap_connect_command, static) = {
diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.c b/src/vnet/vxlan-gpe/vxlan_gpe.c
index b97510c4ee3..2cba596f097 100644
--- a/src/vnet/vxlan-gpe/vxlan_gpe.c
+++ b/src/vnet/vxlan-gpe/vxlan_gpe.c
@@ -454,6 +454,7 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
u32 tmp;
vnet_vxlan_gpe_add_del_tunnel_args_t _a, * a = &_a;
u32 sw_if_index;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (! unformat_user (input, unformat_line_input, line_input))
@@ -494,7 +495,10 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
encap_fib_index = ip4_fib_index_from_table_id (tmp);
if (encap_fib_index == ~0)
- return clib_error_return (0, "nonexistent encap fib id %d", tmp);
+ {
+ error = clib_error_return (0, "nonexistent encap fib id %d", tmp);
+ goto done;
+ }
}
else if (unformat (line_input, "decap-vrf-id %d", &tmp))
{
@@ -504,7 +508,10 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
decap_fib_index = ip4_fib_index_from_table_id (tmp);
if (decap_fib_index == ~0)
- return clib_error_return (0, "nonexistent decap fib id %d", tmp);
+ {
+ error = clib_error_return (0, "nonexistent decap fib id %d", tmp);
+ goto done;
+ }
}
else if (unformat (line_input, "vni %d", &vni))
vni_set = 1;
@@ -517,27 +524,43 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
else if (unformat(line_input, "next-nsh"))
protocol = VXLAN_GPE_PROTOCOL_NSH;
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (local_set == 0)
- return clib_error_return (0, "tunnel local address not specified");
+ {
+ error = clib_error_return (0, "tunnel local address not specified");
+ goto done;
+ }
if (remote_set == 0)
- return clib_error_return (0, "tunnel remote address not specified");
+ {
+ error = clib_error_return (0, "tunnel remote address not specified");
+ goto done;
+ }
if (ipv4_set && ipv6_set)
- return clib_error_return (0, "both IPv4 and IPv6 addresses specified");
+ {
+ error = clib_error_return (0, "both IPv4 and IPv6 addresses specified");
+ goto done;
+ }
if ((ipv4_set && memcmp(&local.ip4, &remote.ip4, sizeof(local.ip4)) == 0) ||
(ipv6_set && memcmp(&local.ip6, &remote.ip6, sizeof(local.ip6)) == 0))
- return clib_error_return (0, "src and dst addresses are identical");
+ {
+ error = clib_error_return (0, "src and dst addresses are identical");
+ goto done;
+ }
if (vni_set == 0)
- return clib_error_return (0, "vni not specified");
+ {
+ error = clib_error_return (0, "vni not specified");
+ goto done;
+ }
memset (a, 0, sizeof (*a));
@@ -558,20 +581,27 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
break;
case VNET_API_ERROR_INVALID_DECAP_NEXT:
- return clib_error_return (0, "invalid decap-next...");
+ error = clib_error_return (0, "invalid decap-next...");
+ goto done;
case VNET_API_ERROR_TUNNEL_EXIST:
- return clib_error_return (0, "tunnel already exists...");
+ error = clib_error_return (0, "tunnel already exists...");
+ goto done;
case VNET_API_ERROR_NO_SUCH_ENTRY:
- return clib_error_return (0, "tunnel does not exist...");
+ error = clib_error_return (0, "tunnel does not exist...");
+ goto done;
default:
- return clib_error_return
+ error = clib_error_return
(0, "vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (create_vxlan_gpe_tunnel_command, static) = {
diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c
index 849fc25d874..eedc16f81d9 100644
--- a/src/vnet/vxlan/vxlan.c
+++ b/src/vnet/vxlan/vxlan.c
@@ -657,6 +657,7 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm,
int rv;
vnet_vxlan_add_del_tunnel_args_t _a, * a = &_a;
u32 tunnel_sw_if_index;
+ clib_error_t *error = NULL;
/* Cant "universally zero init" (={0}) due to GCC bug 53119 */
memset(&src, 0, sizeof src);
@@ -715,7 +716,10 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm,
{
encap_fib_index = fib_table_find (fib_ip_proto (ipv6_set), tmp);
if (encap_fib_index == ~0)
- return clib_error_return (0, "nonexistent encap-vrf-id %d", tmp);
+ {
+ error = clib_error_return (0, "nonexistent encap-vrf-id %d", tmp);
+ goto done;
+ }
}
else if (unformat (line_input, "decap-next %U", unformat_decap_next,
&decap_next_index, ipv4_set))
@@ -723,41 +727,72 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "vni %d", &vni))
{
if (vni >> 24)
- return clib_error_return (0, "vni %d out of range", vni);
+ {
+ error = clib_error_return (0, "vni %d out of range", vni);
+ goto done;
+ }
}
else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (src_set == 0)
- return clib_error_return (0, "tunnel src address not specified");
+ {
+ error = clib_error_return (0, "tunnel src address not specified");
+ goto done;
+ }
if (dst_set == 0)
- return clib_error_return (0, "tunnel dst address not specified");
+ {
+ error = clib_error_return (0, "tunnel dst address not specified");
+ goto done;
+ }
if (grp_set && !ip46_address_is_multicast(&dst))
- return clib_error_return (0, "tunnel group address not multicast");
+ {
+ error = clib_error_return (0, "tunnel group address not multicast");
+ goto done;
+ }
if (grp_set == 0 && ip46_address_is_multicast(&dst))
- return clib_error_return (0, "dst address must be unicast");
+ {
+ error = clib_error_return (0, "dst address must be unicast");
+ goto done;
+ }
if (grp_set && mcast_sw_if_index == ~0)
- return clib_error_return (0, "tunnel nonexistent multicast device");
+ {
+ error = clib_error_return (0, "tunnel nonexistent multicast device");
+ goto done;
+ }
if (ipv4_set && ipv6_set)
- return clib_error_return (0, "both IPv4 and IPv6 addresses specified");
+ {
+ error = clib_error_return (0, "both IPv4 and IPv6 addresses specified");
+ goto done;
+ }
if (ip46_address_cmp(&src, &dst) == 0)
- return clib_error_return (0, "src and dst addresses are identical");
+ {
+ error = clib_error_return (0, "src and dst addresses are identical");
+ goto done;
+ }
if (decap_next_index == ~0)
- return clib_error_return (0, "next node not found");
+ {
+ error = clib_error_return (0, "next node not found");
+ goto done;
+ }
if (vni == 0)
- return clib_error_return (0, "vni not specified");
+ {
+ error = clib_error_return (0, "vni not specified");
+ goto done;
+ }
memset (a, 0, sizeof (*a));
@@ -779,17 +814,23 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm,
break;
case VNET_API_ERROR_TUNNEL_EXIST:
- return clib_error_return (0, "tunnel already exists...");
+ error = clib_error_return (0, "tunnel already exists...");
+ goto done;
case VNET_API_ERROR_NO_SUCH_ENTRY:
- return clib_error_return (0, "tunnel does not exist...");
+ error = clib_error_return (0, "tunnel does not exist...");
+ goto done;
default:
- return clib_error_return
+ error = clib_error_return
(0, "vnet_vxlan_add_del_tunnel returned %d", rv);
+ goto done;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
@@ -912,6 +953,8 @@ set_ip_vxlan_bypass (u32 is_ip6,
vnet_int_vxlan_bypass_mode (sw_if_index, is_ip6, is_enable);
done:
+ unformat_free (line_input);
+
return error;
}