vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, * line_input = &_line_input;
+ clib_error_t *error = 0;
ip4_address_t src, dst;
u8 is_add = 1;
u8 src_set = 0;
{
encap_fib_index = fib_index_from_fib_id (tmp);
if (encap_fib_index == ~0)
- return clib_error_return (0, \"nonexistent encap fib id %d\", tmp);
+ {
+ unformat_free (line_input);
+ return clib_error_return (0, \"nonexistent encap fib id %d\", tmp);
+ }
}
else if (unformat (line_input, \"decap-vrf-id %d\", &tmp))
{
decap_fib_index = fib_index_from_fib_id (tmp);
if (decap_fib_index == ~0)
- return clib_error_return (0, \"nonexistent decap fib id %d\", tmp);
+ {
+ unformat_free (line_input);
+ return clib_error_return (0, \"nonexistent decap fib id %d\", tmp);
+ }
}
else if (unformat (line_input, \"decap-next %U\", unformat_decap_next,
&decap_next_index))
* in the " ENCAP_STACK " header
*/
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);
+ unformat_free (line_input);
+ return error;
+ }
}
unformat_free (line_input);
ila_add_del_entry_args_t args = { 0 };
u8 next_hop_set = 0;
int ret;
+ clib_error_t *error = 0;
args.type = ILA_TYPE_IID;
args.csum_mode = ILA_CSUM_MODE_NO_ACTION;
else if (unformat (line_input, "del"))
args.is_del = 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 (!next_hop_set)
- return clib_error_return (0, "Specified a next hop");
+ {
+ error = clib_error_return (0, "Specified a next hop");
+ goto done;
+ }
if ((ret = ila_add_del_entry (&args)))
- return clib_error_return (0, "ila_add_del_entry returned error %d", ret);
+ {
+ error = clib_error_return (0, "ila_add_del_entry returned error %d", ret);
+ goto done;
+ }
- return NULL;
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (ila_entry_command, static) =
int ret;
u32 gre4 = 0;
lb_vip_type_t type;
+ clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
- if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen))
- return clib_error_return (0, "invalid vip prefix: '%U'",
- format_unformat_error, line_input);
+ if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen)) {
+ error = clib_error_return (0, "invalid vip prefix: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
gre4 = 1;
else if (unformat(line_input, "encap gre6"))
gre4 = 0;
- else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ else {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
if (ip46_prefix_is_ip4(&prefix, plen)) {
type = (gre4)?LB_VIP_TYPE_IP4_GRE4:LB_VIP_TYPE_IP4_GRE6;
u32 index;
if (!del) {
if ((ret = lb_vip_add(&prefix, plen, type, new_len, &index))) {
- return clib_error_return (0, "lb_vip_add error %d", ret);
+ error = clib_error_return (0, "lb_vip_add error %d", ret);
+ goto done;
} else {
vlib_cli_output(vm, "lb_vip_add ok %d", index);
}
} else {
- if ((ret = lb_vip_find_index(&prefix, plen, &index)))
- return clib_error_return (0, "lb_vip_find_index error %d", ret);
- else if ((ret = lb_vip_del(index)))
- return clib_error_return (0, "lb_vip_del error %d", ret);
+ if ((ret = lb_vip_find_index(&prefix, plen, &index))) {
+ error = clib_error_return (0, "lb_vip_find_index error %d", ret);
+ goto done;
+ } else if ((ret = lb_vip_del(index))) {
+ error = clib_error_return (0, "lb_vip_del error %d", ret);
+ goto done;
+ }
}
- return NULL;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (lb_vip_command, static) =
u32 vip_index;
u8 del = 0;
int ret;
+ clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
- if (!unformat(line_input, "%U", unformat_ip46_prefix, &vip_prefix, &vip_plen, IP46_TYPE_ANY))
- return clib_error_return (0, "invalid as address: '%U'",
- format_unformat_error, line_input);
+ if (!unformat(line_input, "%U", unformat_ip46_prefix, &vip_prefix, &vip_plen, IP46_TYPE_ANY)) {
+ error = clib_error_return (0, "invalid as address: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
- if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, &vip_index)))
- return clib_error_return (0, "lb_vip_find_index error %d", ret);
+ if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, &vip_index))) {
+ error = clib_error_return (0, "lb_vip_find_index error %d", ret);
+ goto done;
+ }
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
} else if (unformat(line_input, "del")) {
del = 1;
} else {
- vec_free(as_array);
- 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 (!vec_len(as_array)) {
- vec_free(as_array);
- return clib_error_return (0, "No AS address provided");
+ error = clib_error_return (0, "No AS address provided");
+ goto done;
}
lb_garbage_collection();
if (del) {
if ((ret = lb_vip_del_ass(vip_index, as_array, vec_len(as_array)))) {
- vec_free(as_array);
- return clib_error_return (0, "lb_vip_del_ass error %d", ret);
+ error = clib_error_return (0, "lb_vip_del_ass error %d", ret);
+ goto done;
}
} else {
if ((ret = lb_vip_add_ass(vip_index, as_array, vec_len(as_array)))) {
- vec_free(as_array);
- return clib_error_return (0, "lb_vip_add_ass error %d", ret);
+ error = clib_error_return (0, "lb_vip_add_ass error %d", ret);
+ goto done;
}
}
+done:
+ unformat_free (line_input);
vec_free(as_array);
- return 0;
+
+ return error;
}
VLIB_CLI_COMMAND (lb_as_command, static) =
u32 per_cpu_sticky_buckets_log2 = 0;
u32 flow_timeout = lbm->flow_timeout;
int ret;
+ clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
per_cpu_sticky_buckets = 1 << per_cpu_sticky_buckets_log2;
} else if (unformat(line_input, "timeout %d", &flow_timeout))
;
- else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
+ else {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
- unformat_free (line_input);
-
lb_garbage_collection();
- if ((ret = lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout)))
- return clib_error_return (0, "lb_conf error %d", ret);
+ if ((ret = lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout))) {
+ error = clib_error_return (0, "lb_conf error %d", ret);
+ goto done;
+ }
- return NULL;
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (lb_conf_command, static) =
u32 num_m_args = 0;
/* Optional arguments */
u32 mtu = 0;
+ clib_error_t *error = 0;
/* Get a line of input. */
if (!unformat_user(input, unformat_line_input, line_input))
num_m_args++;
else if (unformat(line_input, "mtu %d", &mtu))
num_m_args++;
- else
- return clib_error_return(0, "unknown input `%U'",
- format_unformat_error, input);
+ else {
+ 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");
+ if (num_m_args < 3) {
+ error = clib_error_return(0, "mandatory argument(s) missing");
+ goto done;
+ }
sixrd_create_domain(&ip6_prefix, ip6_prefix_len, &ip4_prefix, ip4_prefix_len,
&ip4_src, &sixrd_domain_index, mtu);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
static clib_error_t *
unformat_input_t _line_input, *line_input = &_line_input;
u32 num_m_args = 0;
u32 sixrd_domain_index;
+ clib_error_t *error = 0;
/* Get a line of input. */
if (! unformat_user(input, unformat_line_input, line_input))
while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) {
if (unformat(line_input, "index %d", &sixrd_domain_index))
num_m_args++;
- else
- return clib_error_return(0, "unknown input `%U'",
- format_unformat_error, input);
+ else {
+ 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");
+ if (num_m_args != 1) {
+ error = clib_error_return(0, "mandatory argument(s) missing");
+ goto done;
+ }
sixrd_delete_domain(sixrd_domain_index);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
static u8 *
int i, count;
int is_add = 1;
int rv = 0;
+ clib_error_t *error = 0;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
else if (unformat (line_input, "del"))
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 (sm->static_mapping_only)
- return clib_error_return (0, "static mapping only mode");
+ {
+ error = clib_error_return (0, "static mapping only mode");
+ goto done;
+ }
start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
if (end_host_order < start_host_order)
- return clib_error_return (0, "end address less than start address");
+ {
+ error = clib_error_return (0, "end address less than start address");
+ goto done;
+ }
count = (end_host_order - start_host_order) + 1;
switch (rv)
{
case VNET_API_ERROR_NO_SUCH_ENTRY:
- return clib_error_return (0, "S-NAT address not exist.");
- break;
+ error = clib_error_return (0, "S-NAT address not exist.");
+ goto done;
case VNET_API_ERROR_UNSPECIFIED:
- return clib_error_return (0, "S-NAT address used in static mapping.");
- break;
+ error = clib_error_return (0, "S-NAT address used in static mapping.");
+ goto done;
default:
break;
}
increment_v4_address (&this_addr);
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (add_address_command, static) = {
else if (unformat (line_input, "del"))
is_del = 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 (vec_len (inside_sw_if_indices))
{
}
}
+done:
+ unformat_free (line_input);
vec_free (inside_sw_if_indices);
vec_free (outside_sw_if_indices);
else if (unformat (line_input, "del"))
is_add = 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 (!addr_only && !proto_set)
- return clib_error_return (0, "missing protocol");
+ {
+ error = clib_error_return (0, "missing protocol");
+ goto done;
+ }
rv = snat_add_static_mapping(l_addr, e_addr, (u16) l_port, (u16) e_port,
vrf_id, addr_only, sw_if_index, proto, is_add);
switch (rv)
{
case VNET_API_ERROR_INVALID_VALUE:
- return clib_error_return (0, "External port already in use.");
- break;
+ error = clib_error_return (0, "External port already in use.");
+ goto done;
case VNET_API_ERROR_NO_SUCH_ENTRY:
if (is_add)
- return clib_error_return (0, "External addres must be allocated.");
+ error = clib_error_return (0, "External addres must be allocated.");
else
- return clib_error_return (0, "Mapping not exist.");
- break;
+ error = clib_error_return (0, "Mapping not exist.");
+ goto done;
case VNET_API_ERROR_NO_SUCH_FIB:
- return clib_error_return (0, "No such VRF id.");
+ error = clib_error_return (0, "No such VRF id.");
+ goto done;
case VNET_API_ERROR_VALUE_EXIST:
- return clib_error_return (0, "Mapping already exist.");
+ error = clib_error_return (0, "Mapping already exist.");
+ goto done;
default:
break;
}
+done:
+ unformat_free (line_input);
+
return error;
}
unformat_input_t _line_input, *line_input = &_line_input;
uword *bitmap = 0;
int rv = 0;
+ clib_error_t *error = 0;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
if (unformat (line_input, "%U", unformat_bitmap_list, &bitmap))
;
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 (bitmap == 0)
- return clib_error_return (0, "List of workers must be specified.");
+ {
+ error = clib_error_return (0, "List of workers must be specified.");
+ goto done;
+ }
rv = snat_set_workers(bitmap);
switch (rv)
{
case VNET_API_ERROR_INVALID_WORKER:
- return clib_error_return (0, "Invalid worker(s).");
- break;
+ error = clib_error_return (0, "Invalid worker(s).");
+ goto done;
case VNET_API_ERROR_FEATURE_DISABLED:
- return clib_error_return (0,
+ error = clib_error_return (0,
"Supported only if 2 or more workes available.");
- break;
+ goto done;
default:
break;
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
u32 src_port = 0;
u8 enable = 1;
int rv = 0;
+ clib_error_t *error = 0;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
else if (unformat (line_input, "disable"))
enable = 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);
rv = snat_ipfix_logging_enable_disable (enable, domain_id, (u16) src_port);
if (rv)
- return clib_error_return (0, "ipfix logging enable failed");
+ {
+ error = clib_error_return (0, "ipfix logging enable failed");
+ goto done;
+ }
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
u32 sw_if_index;
int rv;
int is_del = 0;
+ clib_error_t *error = 0;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
else if (unformat (line_input, "del"))
is_del = 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;
+ }
}
rv = snat_add_interface_address (sm, sw_if_index, is_del);
break;
default:
- return clib_error_return (0, "snat_add_interface_address returned %d",
- rv);
+ error = clib_error_return (0, "snat_add_interface_address returned %d",
+ rv);
+ goto done;
}
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
VLIB_CLI_COMMAND (snat_add_interface_address_command, static) = {
else if (unformat (line_input, "index %u", &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 (enable > 1)
- return clib_error_return (0, "expecting on or off");
+ {
+ error = clib_error_return (0, "expecting on or off");
+ goto done;
+ }
if (vec_len (tm->frame_queue_mains) == 0)
- return clib_error_return (0, "no worker handoffs exist");
+ {
+ error = clib_error_return (0, "no worker handoffs exist");
+ goto done;
+ }
if (index > vec_len (tm->frame_queue_mains) - 1)
- return clib_error_return (0,
- "expecting valid worker handoff queue index");
+ {
+ error = clib_error_return (0,
+ "expecting valid worker handoff queue index");
+ goto done;
+ }
fqm = vec_elt_at_index (tm->frame_queue_mains, index);
if (num_fq == 0)
{
vlib_cli_output (vm, "No frame queues exist\n");
- return error;
+ goto done;
}
// Allocate storage for trace if necessary
memset (fqh, 0, sizeof (*fqh));
fqm->vlib_frame_queues[fqix]->trace = enable;
}
+
+done:
+ unformat_free (line_input);
+
return error;
}
else if (unformat (line_input, "index %u", &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 (index > vec_len (tm->frame_queue_mains) - 1)
- return clib_error_return (0,
- "expecting valid worker handoff queue index");
+ {
+ error = clib_error_return (0,
+ "expecting valid worker handoff queue index");
+ goto done;
+ }
fqm = vec_elt_at_index (tm->frame_queue_mains, index);
if ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32))
{
- return clib_error_return (0, "expecting 4,8,16,32");
+ error = clib_error_return (0, "expecting 4,8,16,32");
+ goto done;
}
num_fq = vec_len (fqm->vlib_frame_queues);
if (num_fq == 0)
{
vlib_cli_output (vm, "No frame queues exist\n");
- return error;
+ goto done;
}
for (fqix = 0; fqix < num_fq; fqix++)
fqm->vlib_frame_queues[fqix]->nelts = nelts;
}
+done:
+ unformat_free (line_input);
+
return error;
}
else if (unformat (line_input, "index %u", &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 (index > vec_len (tm->frame_queue_mains) - 1)
- return clib_error_return (0,
- "expecting valid worker handoff queue index");
+ {
+ error = clib_error_return (0,
+ "expecting valid worker handoff queue index");
+ goto done;
+ }
fqm = vec_elt_at_index (tm->frame_queue_mains, index);
if (threshold == ~(u32) 0)
{
vlib_cli_output (vm, "expecting threshold value\n");
- return error;
+ goto done;
}
if (threshold == 0)
if (num_fq == 0)
{
vlib_cli_output (vm, "No frame queues exist\n");
- return error;
+ goto done;
}
for (fqix = 0; fqix < num_fq; fqix++)
fqm->vlib_frame_queues[fqix]->vector_threshold = threshold;
}
+done:
+ unformat_free (line_input);
+
return error;
}
vlib_trace_node_t *tn;
u32 node_index, add;
u8 verbose = 0;
+ clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
else if (unformat (line_input, "verbose"))
verbose = 1;
else
- return clib_error_create ("expected NODE COUNT, got `%U'",
- format_unformat_error, line_input);
+ {
+ error = clib_error_create ("expected NODE COUNT, got `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
/* *INDENT-OFF* */
}));
/* *INDENT-ON* */
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
unix_cli_main_t *cm = &unix_cli_main;
unix_cli_file_t *cf;
unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
"Pager limit set to %u lines; note, this is global.\n",
um->cli_pager_buffer_limit);
else
- return clib_error_return (0, "unknown parameter: `%U`",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown parameter: `%U`",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
+done:
unformat_free (line_input);
- return 0;
+ return error;
}
/*?
unix_cli_file_t *cf;
unformat_input_t _line_input, *line_input = &_line_input;
u32 limit;
+ clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
else if (unformat (line_input, "limit %u", &cf->history_limit))
;
else
- return clib_error_return (0, "unknown parameter: `%U`",
- format_unformat_error, line_input);
+ {
+ error = clib_error_return (0, "unknown parameter: `%U`",
+ format_unformat_error, line_input);
+ goto done;
+ }
/* If we reduced history size, or turned it off, purge the history */
limit = cf->has_history ? cf->history_limit : 0;
}
}
+done:
unformat_free (line_input);
- return 0;
+ return error;
}
/*?
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))
(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;
}
/*?
{
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))
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;
}
/*?
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;
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;
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* */
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;
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);
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);
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* */
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;
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);
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]);
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* */
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;
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);
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* */
.tc_period = 10,
};
int rv;
+ clib_error_t *error = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
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* */
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;
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);
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;
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* */
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;
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);
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;
/* 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 */
__builtin_ctzll (mask);
}
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
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;
&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);
if (devconf->hqos_enabled == 0)
{
vlib_cli_output (vm, "HQoS disabled for this interface");
- return 0;
+ goto done;
}
/* Detect the set of worker threads */
/* 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];
}
#endif
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
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;
;
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);
if (devconf->hqos_enabled == 0)
{
vlib_cli_output (vm, "HQoS disabled for this interface");
- return 0;
+ goto done;
}
/*
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);
vlib_cli_output (vm, "%=24s%=16d", "Bytes dropped", stats.n_bytes_dropped);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
{
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;
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* */
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))
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;
}
/*?
{
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))
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;
}
/*?
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))
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 ();
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 *
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))
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
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))
(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"))
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;
}
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))
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;
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) = {
vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index,
is_del == 0, &config, sizeof (config));
done:
+ unformat_free (line_input);
+
return error;
}
}
done:
- return (error);
+ unformat_free (line_input);
+
+ return error;
}
/*?
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;
+ }
}
}
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];
pool_free (tm->route_pool);
}
- return 0;
+
+done:
+ unformat_free (line_input);
+
+ return error;
}
/*?
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;
}
{
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;
break;
}
else
- return (unformat_parse_error (line_input));
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
}
if (add_radv_info)
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,
off_link, no_autoconfig, no_onlink, is_no);
}
+done:
unformat_free (line_input);
-done:
return error;
}
}
}
- unformat_free (line_input);
-
if (vec_len (prefixs) == 0)
{
error =
vec_free (dpos);
vec_free (prefixs);
vec_free (rpaths);
+ unformat_free (line_input);
return error;
}
}
}
- unformat_free (line_input);
-
if (~0 == table_id)
{
/*
(scount * gcount) / (timet[1] - timet[0]));
done:
+ unformat_free (line_input);
+
return error;
}
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;
}
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))
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;
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* */
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;
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* */
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));
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);
{
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))
{
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))
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);
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* */
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;
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* */
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;
&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))
;
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* */
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));
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);
ipsec_set_sa_key (vm, &sa);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
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;
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);
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* */
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;
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* */
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))
}
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);
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;
}
/*?
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))
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)
{
}
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)
{
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];
}
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;
}
/*?
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))
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
}
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,
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* */
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))
{
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);
}
vec_free (adjs);
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
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))
{
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);
vlib_cli_output (vm, "failed to %s map-server!",
is_add ? "add" : "delete");
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
if (key && (0 == key_id))
{
vlib_cli_output (vm, "invalid key_id!");
- return 0;
+ goto done;;
}
gid_address_copy (&a->eid, &eid);
vec_free (locator_set_name);
gid_address_free (&a->eid);
vec_free (a->key);
+ unformat_free (line_input);
+
return error;
}
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))
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* */
!= 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]));
{
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))
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* */
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)
done:
if (locator_set_name)
vec_free (locator_set_name);
+ unformat_free (line_input);
+
return error;
}
gid_address_t eid;
u8 print_all = 1;
u8 filter = 0;
+ clib_error_t *error = NULL;
memset (&eid, 0, sizeof (eid));
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",
{
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,
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* */
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))
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* */
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))
{
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* */
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))
{
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* */
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))
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");
}));
/* *INDENT-ON* */
- return 0;
+done:
+ unformat_free (line_input);
+
+ return error;
}
/* *INDENT-OFF* */
vec_free (locators);
if (locator_set_name)
vec_free (locator_set_name);
+ unformat_free (line_input);
+
return error;
}
done:
vec_free (locators);
vec_free (locator_set_name);
+ unformat_free (line_input);
+
return error;
}
}
done:
+ unformat_free (line_input);
+
return error;
}
is_add ? "add" : "delete");
}
+done:
vec_free (locator_set_name);
+ unformat_free (line_input);
-done:
return error;
-
}
/* *INDENT-OFF* */
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)
}
done:
+ unformat_free (line_input);
+
return error;
}
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)
{
}
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 (~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
}
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);
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* */
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))
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* */
{
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;
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 *
{
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;
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 *
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))
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 *
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))
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 *
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))
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
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));
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
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;
(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 *
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))
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 *
{
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))
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 *
{
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))
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 *
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;
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 *
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))
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...");
{
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 *
}
done:
+ unformat_free (line_input);
+
return error;
}
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));
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)
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;
}
/*?
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;
a->count = count;
error = pg_capture (a);
+
+done:
+ unformat_free (line_input);
+
return error;
}
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;
;
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* */
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))
}
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)
{
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);
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* */
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))
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* */
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...");
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));
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) = {
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))
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))
{
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;
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));
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) = {
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);
{
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))
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));
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;
}
/*?
vnet_int_vxlan_bypass_mode (sw_if_index, is_ip6, is_enable);
done:
+ unformat_free (line_input);
+
return error;
}
u32 local_session_id = 1, remote_session_id = 1;
int our_address_set = 0, client_address_set = 0;
int l2_sublayer_present = 0;
+ clib_error_t *error = NULL;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
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);
+ unformat_free (line_input);
+ return error;
+ }
}
unformat_free (line_input);
mac_addr_t *mac_addrs = 0;
u32 sw_if_index;
u32 i;
+ clib_error_t *error = NULL;
next_hops = NULL;
rpaths = NULL;
if (!unformat (line_input, "%U %U",
unformat_ip4_address, &prefix.fp_addr.ip4,
unformat_vnet_sw_interface, vnm, &sw_if_index))
- goto barf;
+ {
+ 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)
{
}
else
{
- barf:
- 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 (vec_len (mac_addrs) == 0 || vec_len (mac_addrs) != vec_len (next_hops))
- goto barf;
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
/* Create / delete special interface route /32's */
&prefix,
FIB_SOURCE_CLI, FIB_ENTRY_FLAG_NONE, rpaths);
+done:
vec_free (mac_addrs);
vec_free (next_hops);
+ unformat_free (line_input);
- return 0;
+ return error;
}
/* *INDENT-OFF* */