VPP-635: CLI Memory leak with invalid parameter
In the CLI parsing, below is a common pattern:
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "x"))
x = 1;
:
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
}
unformat_free (line_input);
The 'else' returns if an unknown string is encountered. There a memory
leak because the 'unformat_free(line_input)' is not called. There is a
large number of instances of this pattern.
Replaced the previous pattern with:
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "x"))
x = 1;
:
else
{
error = clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
goto done:
}
}
/* ...Remaining code... */
done:
unformat_free (line_input);
return error;
}
In multiple files, 'unformat_free (line_input);' was never called, so
there was a memory leak whether an invalid string was entered or not.
Also, there were multiple instance where:
error = clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
used 'input' as the last parameter instead of 'line_input'. The result
is that output did not contain the substring in error, instead just an
empty string. Fixed all of those as well.
There are a lot of file, and very mind numbing work, so tried to keep
it to a pattern to avoid mistakes.
Change-Id: I8902f0c32a47dd7fb3bb3471a89818571702f1d2
Signed-off-by: Billy McFall <bmcfall@redhat.com>
Signed-off-by: Dave Barach <dave@barachs.net>
This commit is contained in:
committed by
Dave Barach
parent
2291a36008
commit
a9a20e7f69
@@ -288,6 +288,7 @@ static clib_error_t *
|
||||
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;
|
||||
@@ -322,13 +323,19 @@ static clib_error_t *
|
||||
{
|
||||
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))
|
||||
@@ -346,8 +353,12 @@ static clib_error_t *
|
||||
* 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);
|
||||
|
||||
+18
-7
@@ -949,6 +949,7 @@ ila_entry_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -986,19 +987,29 @@ ila_entry_command_fn (vlib_main_t * vm,
|
||||
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) =
|
||||
|
||||
+62
-37
@@ -28,13 +28,16 @@ lb_vip_command_fn (vlib_main_t * vm,
|
||||
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)
|
||||
{
|
||||
@@ -46,13 +49,13 @@ lb_vip_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -65,17 +68,25 @@ lb_vip_command_fn (vlib_main_t * vm,
|
||||
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) =
|
||||
@@ -96,16 +107,21 @@ lb_as_command_fn (vlib_main_t * vm,
|
||||
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)
|
||||
{
|
||||
@@ -114,15 +130,15 @@ lb_as_command_fn (vlib_main_t * vm,
|
||||
} 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();
|
||||
@@ -130,18 +146,21 @@ lb_as_command_fn (vlib_main_t * vm,
|
||||
|
||||
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) =
|
||||
@@ -163,6 +182,7 @@ lb_conf_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -181,19 +201,24 @@ lb_conf_command_fn (vlib_main_t * vm,
|
||||
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) =
|
||||
|
||||
+28
-14
@@ -192,6 +192,7 @@ sixrd_add_domain_command_fn (vlib_main_t *vm,
|
||||
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))
|
||||
@@ -205,19 +206,25 @@ sixrd_add_domain_command_fn (vlib_main_t *vm,
|
||||
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 *
|
||||
@@ -228,6 +235,7 @@ sixrd_del_domain_command_fn (vlib_main_t *vm,
|
||||
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))
|
||||
@@ -236,18 +244,24 @@ sixrd_del_domain_command_fn (vlib_main_t *vm,
|
||||
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 *
|
||||
|
||||
+96
-43
@@ -1705,6 +1705,7 @@ add_address_command_fn (vlib_main_t * vm,
|
||||
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))
|
||||
@@ -1721,19 +1722,27 @@ add_address_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
|
||||
@@ -1755,11 +1764,11 @@ add_address_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
}
|
||||
@@ -1767,7 +1776,10 @@ add_address_command_fn (vlib_main_t * vm,
|
||||
increment_v4_address (&this_addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
VLIB_CLI_COMMAND (add_address_command, static) = {
|
||||
@@ -1807,10 +1819,12 @@ snat_feature_command_fn (vlib_main_t * vm,
|
||||
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))
|
||||
{
|
||||
@@ -1830,6 +1844,8 @@ snat_feature_command_fn (vlib_main_t * vm,
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
vec_free (inside_sw_if_indices);
|
||||
vec_free (outside_sw_if_indices);
|
||||
|
||||
@@ -1923,13 +1939,18 @@ add_static_mapping_command_fn (vlib_main_t * vm,
|
||||
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);
|
||||
@@ -1937,22 +1958,27 @@ add_static_mapping_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1985,6 +2011,7 @@ set_workers_command_fn (vlib_main_t * vm,
|
||||
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))
|
||||
@@ -1995,13 +2022,18 @@ set_workers_command_fn (vlib_main_t * vm,
|
||||
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);
|
||||
|
||||
@@ -2010,17 +2042,20 @@ set_workers_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
}
|
||||
|
||||
/*?
|
||||
@@ -2047,6 +2082,7 @@ snat_ipfix_logging_enable_disable_command_fn (vlib_main_t * vm,
|
||||
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))
|
||||
@@ -2061,17 +2097,25 @@ snat_ipfix_logging_enable_disable_command_fn (vlib_main_t * vm,
|
||||
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;
|
||||
}
|
||||
|
||||
/*?
|
||||
@@ -2604,6 +2648,7 @@ snat_add_interface_address_command_fn (vlib_main_t * vm,
|
||||
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))
|
||||
@@ -2617,8 +2662,11 @@ snat_add_interface_address_command_fn (vlib_main_t * vm,
|
||||
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);
|
||||
@@ -2629,10 +2677,15 @@ snat_add_interface_address_command_fn (vlib_main_t * vm,
|
||||
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) = {
|
||||
|
||||
+54
-25
@@ -163,21 +163,31 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input,
|
||||
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);
|
||||
|
||||
@@ -185,7 +195,7 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (num_fq == 0)
|
||||
{
|
||||
vlib_cli_output (vm, "No frame queues exist\n");
|
||||
return error;
|
||||
goto done;
|
||||
}
|
||||
|
||||
// Allocate storage for trace if necessary
|
||||
@@ -204,6 +214,10 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input,
|
||||
memset (fqh, 0, sizeof (*fqh));
|
||||
fqm->vlib_frame_queues[fqix]->trace = enable;
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -432,28 +446,33 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input,
|
||||
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++)
|
||||
@@ -461,6 +480,9 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input,
|
||||
fqm->vlib_frame_queues[fqix]->nelts = nelts;
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -499,15 +521,19 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
|
||||
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);
|
||||
|
||||
@@ -515,7 +541,7 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (threshold == ~(u32) 0)
|
||||
{
|
||||
vlib_cli_output (vm, "expecting threshold value\n");
|
||||
return error;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (threshold == 0)
|
||||
@@ -525,7 +551,7 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (num_fq == 0)
|
||||
{
|
||||
vlib_cli_output (vm, "No frame queues exist\n");
|
||||
return error;
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (fqix = 0; fqix < num_fq; fqix++)
|
||||
@@ -533,6 +559,9 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
|
||||
fqm->vlib_frame_queues[fqix]->vector_threshold = threshold;
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -372,6 +372,7 @@ cli_add_trace_buffer (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -384,8 +385,11 @@ cli_add_trace_buffer (vlib_main_t * vm,
|
||||
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* */
|
||||
@@ -403,7 +407,10 @@ cli_add_trace_buffer (vlib_main_t * vm,
|
||||
}));
|
||||
/* *INDENT-ON* */
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
+16
-6
@@ -2835,6 +2835,7 @@ unix_cli_set_terminal_pager (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -2852,13 +2853,17 @@ unix_cli_set_terminal_pager (vlib_main_t * vm,
|
||||
"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;
|
||||
}
|
||||
|
||||
/*?
|
||||
@@ -2886,6 +2891,7 @@ unix_cli_set_terminal_history (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -2901,8 +2907,11 @@ unix_cli_set_terminal_history (vlib_main_t * vm,
|
||||
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;
|
||||
@@ -2914,9 +2923,10 @@ unix_cli_set_terminal_history (vlib_main_t * vm,
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
@@ -49,6 +49,7 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
u8 *hw_addr_ptr = 0;
|
||||
u32 sw_if_index;
|
||||
int r;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -63,29 +64,47 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
(line_input, "hw-addr %U", unformat_ethernet_address, hwaddr))
|
||||
hw_addr_ptr = hwaddr;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
if (host_if_name == NULL)
|
||||
return clib_error_return (0, "missing host interface name");
|
||||
{
|
||||
error = clib_error_return (0, "missing host interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
r = af_packet_create_if (vm, host_if_name, hw_addr_ptr, &sw_if_index);
|
||||
vec_free (host_if_name);
|
||||
|
||||
if (r == VNET_API_ERROR_SYSCALL_ERROR_1)
|
||||
return clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
|
||||
{
|
||||
error = clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (r == VNET_API_ERROR_INVALID_INTERFACE)
|
||||
return clib_error_return (0, "Invalid interface name");
|
||||
{
|
||||
error = clib_error_return (0, "Invalid interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS)
|
||||
return clib_error_return (0, "Interface elready exists");
|
||||
{
|
||||
error = clib_error_return (0, "Interface elready exists");
|
||||
goto done;
|
||||
}
|
||||
|
||||
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
|
||||
sw_if_index);
|
||||
return 0;
|
||||
|
||||
done:
|
||||
vec_free (host_if_name);
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
@@ -124,6 +143,7 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
{
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
u8 *host_if_name = NULL;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -134,18 +154,26 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (unformat (line_input, "name %s", &host_if_name))
|
||||
;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
if (host_if_name == NULL)
|
||||
return clib_error_return (0, "missing host interface name");
|
||||
{
|
||||
error = clib_error_return (0, "missing host interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
af_packet_delete_if (vm, host_if_name);
|
||||
vec_free (host_if_name);
|
||||
|
||||
return 0;
|
||||
done:
|
||||
vec_free (host_if_name);
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
+206
-84
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,7 @@ lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
{
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
u16 detail = 0;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
@@ -120,15 +121,19 @@ lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (unformat (line_input, "verbose"))
|
||||
detail = 1;
|
||||
else
|
||||
return clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
|
||||
dpdk_ipsec_show_mapping (vm, detail);
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
@@ -37,6 +37,7 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
u8 is_pipe = 0;
|
||||
u8 is_master = 0;
|
||||
u32 sw_if_index = ~0;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -57,30 +58,48 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
else if (unformat (line_input, "slave"))
|
||||
is_master = 0;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
if (host_if_name == NULL)
|
||||
return clib_error_return (0, "missing host interface name");
|
||||
{
|
||||
error = clib_error_return (0, "missing host interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
r =
|
||||
netmap_create_if (vm, host_if_name, hw_addr_ptr, is_pipe, is_master,
|
||||
&sw_if_index);
|
||||
|
||||
if (r == VNET_API_ERROR_SYSCALL_ERROR_1)
|
||||
return clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
|
||||
{
|
||||
error = clib_error_return (0, "%s (errno %d)", strerror (errno), errno);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (r == VNET_API_ERROR_INVALID_INTERFACE)
|
||||
return clib_error_return (0, "Invalid interface name");
|
||||
{
|
||||
error = clib_error_return (0, "Invalid interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS)
|
||||
return clib_error_return (0, "Interface already exists");
|
||||
{
|
||||
error = clib_error_return (0, "Interface already exists");
|
||||
goto done;
|
||||
}
|
||||
|
||||
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
|
||||
sw_if_index);
|
||||
return 0;
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
@@ -144,6 +163,7 @@ netmap_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
{
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
u8 *host_if_name = NULL;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -154,17 +174,25 @@ netmap_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (unformat (line_input, "name %s", &host_if_name))
|
||||
;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
if (host_if_name == NULL)
|
||||
return clib_error_return (0, "missing host interface name");
|
||||
{
|
||||
error = clib_error_return (0, "missing host interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
netmap_delete_if (vm, host_if_name);
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
@@ -2682,6 +2682,7 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
|
||||
u32 custom_dev_instance = ~0;
|
||||
u8 hwaddr[6];
|
||||
u8 *hw = NULL;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -2704,10 +2705,12 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
|
||||
renumber = 1;
|
||||
}
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
|
||||
@@ -2716,14 +2719,18 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
|
||||
is_server, &sw_if_index, feature_mask,
|
||||
renumber, custom_dev_instance, hw)))
|
||||
{
|
||||
vec_free (sock_filename);
|
||||
return clib_error_return (0, "vhost_user_create_if returned %d", rv);
|
||||
error = clib_error_return (0, "vhost_user_create_if returned %d", rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
vec_free (sock_filename);
|
||||
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
|
||||
sw_if_index);
|
||||
return 0;
|
||||
|
||||
done:
|
||||
vec_free (sock_filename);
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
clib_error_t *
|
||||
@@ -2734,6 +2741,7 @@ vhost_user_delete_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
u32 sw_if_index = ~0;
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -2751,15 +2759,25 @@ vhost_user_delete_command_fn (vlib_main_t * vm,
|
||||
vnet_get_sup_hw_interface (vnm, sw_if_index);
|
||||
if (hwif == NULL ||
|
||||
vhost_user_dev_class.index != hwif->dev_class_index)
|
||||
return clib_error_return (0, "Not a vhost interface");
|
||||
{
|
||||
error = clib_error_return (0, "Not a vhost interface");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
vhost_user_delete_if (vnm, vm, sw_if_index);
|
||||
return 0;
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -3286,6 +3304,7 @@ vhost_thread_command_fn (vlib_main_t * vm,
|
||||
u32 sw_if_index;
|
||||
u8 del = 0;
|
||||
int rv;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -3295,9 +3314,9 @@ vhost_thread_command_fn (vlib_main_t * vm,
|
||||
(line_input, "%U %d", unformat_vnet_sw_interface, vnet_get_main (),
|
||||
&sw_if_index, &worker_thread_index))
|
||||
{
|
||||
unformat_free (line_input);
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (unformat (line_input, "del"))
|
||||
@@ -3305,9 +3324,16 @@ vhost_thread_command_fn (vlib_main_t * vm,
|
||||
|
||||
if ((rv =
|
||||
vhost_user_thread_placement (sw_if_index, worker_thread_index, del)))
|
||||
return clib_error_return (0, "vhost_user_thread_placement returned %d",
|
||||
rv);
|
||||
return 0;
|
||||
{
|
||||
error = clib_error_return (0, "vhost_user_thread_placement returned %d",
|
||||
rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+25
-10
@@ -491,6 +491,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
|
||||
u32 num_m_args = 0;
|
||||
u8 is_add = 1;
|
||||
u32 sw_if_index;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (! unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -508,16 +509,24 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
|
||||
else if (unformat (line_input, "teb"))
|
||||
teb = 1;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
if (num_m_args < 2)
|
||||
return clib_error_return (0, "mandatory argument(s) missing");
|
||||
{
|
||||
error = clib_error_return (0, "mandatory argument(s) missing");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (memcmp (&src, &dst, sizeof(src)) == 0)
|
||||
return clib_error_return (0, "src and dst are identical");
|
||||
{
|
||||
error = clib_error_return (0, "src and dst are identical");
|
||||
goto done;
|
||||
}
|
||||
|
||||
memset (a, 0, sizeof (*a));
|
||||
a->outer_fib_id = outer_fib_id;
|
||||
@@ -536,15 +545,21 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
|
||||
vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
|
||||
break;
|
||||
case VNET_API_ERROR_INVALID_VALUE:
|
||||
return clib_error_return (0, "GRE tunnel already exists...");
|
||||
error = clib_error_return (0, "GRE tunnel already exists...");
|
||||
goto done;
|
||||
case VNET_API_ERROR_NO_SUCH_FIB:
|
||||
return clib_error_return (0, "outer fib ID %d doesn't exist\n",
|
||||
outer_fib_id);
|
||||
error = clib_error_return (0, "outer fib ID %d doesn't exist\n",
|
||||
outer_fib_id);
|
||||
goto done;
|
||||
default:
|
||||
return clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
|
||||
error = clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
|
||||
|
||||
@@ -399,6 +399,8 @@ set_ip_source_check (vlib_main_t * vm,
|
||||
vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index,
|
||||
is_del == 0, &config, sizeof (config));
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -531,7 +533,9 @@ ip_source_check_accept (vlib_main_t * vm,
|
||||
}
|
||||
|
||||
done:
|
||||
return (error);
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
+11
-4
@@ -143,8 +143,11 @@ thrash (vlib_main_t * vm,
|
||||
else if (unformat (line_input, "verbose"))
|
||||
verbose = 1;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +181,7 @@ thrash (vlib_main_t * vm,
|
||||
if (p == 0)
|
||||
{
|
||||
vlib_cli_output (vm, "Couldn't map fib id %d to fib index\n", table_id);
|
||||
return 0;
|
||||
goto done;
|
||||
}
|
||||
table_index = p[0];
|
||||
|
||||
@@ -294,7 +297,11 @@ thrash (vlib_main_t * vm,
|
||||
|
||||
pool_free (tm->route_pool);
|
||||
}
|
||||
return 0;
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
@@ -2923,7 +2923,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
|
||||
else if (unformat (line_input, "ra-lifetime"))
|
||||
{
|
||||
if (!unformat (line_input, "%d", &ra_lifetime))
|
||||
return (error = unformat_parse_error (line_input));
|
||||
{
|
||||
error = unformat_parse_error (line_input);
|
||||
goto done;
|
||||
}
|
||||
use_lifetime = 1;
|
||||
break;
|
||||
}
|
||||
@@ -2931,13 +2934,19 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
|
||||
{
|
||||
if (!unformat
|
||||
(line_input, "%d %d", &ra_initial_count, &ra_initial_interval))
|
||||
return (error = unformat_parse_error (line_input));
|
||||
{
|
||||
error = unformat_parse_error (line_input);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (unformat (line_input, "ra-interval"))
|
||||
{
|
||||
if (!unformat (line_input, "%d", &ra_max_interval))
|
||||
return (error = unformat_parse_error (line_input));
|
||||
{
|
||||
error = unformat_parse_error (line_input);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!unformat (line_input, "%d", &ra_min_interval))
|
||||
ra_min_interval = 0;
|
||||
@@ -2949,7 +2958,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
|
||||
break;
|
||||
}
|
||||
else
|
||||
return (unformat_parse_error (line_input));
|
||||
{
|
||||
error = unformat_parse_error (line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (add_radv_info)
|
||||
@@ -3006,7 +3018,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
|
||||
else if (unformat (line_input, "no-onlink"))
|
||||
no_onlink = 1;
|
||||
else
|
||||
return (unformat_parse_error (line_input));
|
||||
{
|
||||
error = unformat_parse_error (line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
ip6_neighbor_ra_prefix (vm, sw_if_index,
|
||||
@@ -3018,9 +3033,9 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input,
|
||||
off_link, no_autoconfig, no_onlink, is_no);
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
done:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
+23
-11
@@ -568,8 +568,6 @@ vnet_ip_route_cmd (vlib_main_t * vm,
|
||||
}
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
|
||||
if (vec_len (prefixs) == 0)
|
||||
{
|
||||
error =
|
||||
@@ -704,6 +702,7 @@ done:
|
||||
vec_free (dpos);
|
||||
vec_free (prefixs);
|
||||
vec_free (rpaths);
|
||||
unformat_free (line_input);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -872,8 +871,6 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
|
||||
}
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
|
||||
if (~0 == table_id)
|
||||
{
|
||||
/*
|
||||
@@ -970,6 +967,8 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
|
||||
(scount * gcount) / (timet[1] - timet[0]));
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1149,24 +1148,37 @@ probe_neighbor_address (vlib_main_t * vm,
|
||||
is_ip4 = 0;
|
||||
}
|
||||
else
|
||||
return clib_error_return (0, "unknown input '%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
|
||||
if (sw_if_index == ~0)
|
||||
return clib_error_return (0, "Interface required, not set.");
|
||||
{
|
||||
error = clib_error_return (0, "Interface required, not set.");
|
||||
goto done;
|
||||
}
|
||||
if (address_set == 0)
|
||||
return clib_error_return (0, "ip address required, not set.");
|
||||
{
|
||||
error = clib_error_return (0, "ip address required, not set.");
|
||||
goto done;
|
||||
}
|
||||
if (address_set > 1)
|
||||
return clib_error_return (0, "Multiple ip addresses not supported.");
|
||||
{
|
||||
error = clib_error_return (0, "Multiple ip addresses not supported.");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (is_ip4)
|
||||
error = ip4_probe_neighbor_wait (vm, &a4, sw_if_index, retry_count);
|
||||
else
|
||||
error = ip6_probe_neighbor_wait (vm, &a6, sw_if_index, retry_count);
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm,
|
||||
vnet_ipsec_gre_add_del_tunnel_args_t _a, *a = &_a;
|
||||
int rv;
|
||||
u32 sw_if_index;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -250,16 +251,24 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm,
|
||||
else if (unformat (line_input, "remote-sa %d", &rsa))
|
||||
num_m_args++;
|
||||
else
|
||||
return clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
unformat_free (line_input);
|
||||
|
||||
if (num_m_args < 4)
|
||||
return clib_error_return (0, "mandatory argument(s) missing");
|
||||
{
|
||||
error = clib_error_return (0, "mandatory argument(s) missing");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (memcmp (&src, &dst, sizeof (src)) == 0)
|
||||
return clib_error_return (0, "src and dst are identical");
|
||||
{
|
||||
error = clib_error_return (0, "src and dst are identical");
|
||||
goto done;
|
||||
}
|
||||
|
||||
memset (a, 0, sizeof (*a));
|
||||
a->is_add = is_add;
|
||||
@@ -277,14 +286,19 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm,
|
||||
vnet_get_main (), sw_if_index);
|
||||
break;
|
||||
case VNET_API_ERROR_INVALID_VALUE:
|
||||
return clib_error_return (0, "GRE tunnel already exists...");
|
||||
error = clib_error_return (0, "GRE tunnel already exists...");
|
||||
goto done;
|
||||
default:
|
||||
return clib_error_return (0,
|
||||
"vnet_ipsec_gre_add_del_tunnel returned %d",
|
||||
rv);
|
||||
error = clib_error_return (0,
|
||||
"vnet_ipsec_gre_add_del_tunnel returned %d",
|
||||
rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
+123
-56
File diff suppressed because it is too large
Load Diff
+20
-6
@@ -315,6 +315,7 @@ test_patch_command_fn (vlib_main_t * vm,
|
||||
int rx_set = 0;
|
||||
int tx_set = 0;
|
||||
int is_add = 1;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -335,10 +336,16 @@ test_patch_command_fn (vlib_main_t * vm,
|
||||
}
|
||||
|
||||
if (rx_set == 0)
|
||||
return clib_error_return (0, "rx interface not set");
|
||||
{
|
||||
error = clib_error_return (0, "rx interface not set");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (tx_set == 0)
|
||||
return clib_error_return (0, "tx interface not set");
|
||||
{
|
||||
error = clib_error_return (0, "tx interface not set");
|
||||
goto done;
|
||||
}
|
||||
|
||||
rv = vnet_l2_patch_add_del (rx_sw_if_index, tx_sw_if_index, is_add);
|
||||
|
||||
@@ -348,17 +355,24 @@ test_patch_command_fn (vlib_main_t * vm,
|
||||
break;
|
||||
|
||||
case VNET_API_ERROR_INVALID_SW_IF_INDEX:
|
||||
return clib_error_return (0, "rx interface not a physical port");
|
||||
error = clib_error_return (0, "rx interface not a physical port");
|
||||
goto done;
|
||||
|
||||
case VNET_API_ERROR_INVALID_SW_IF_INDEX_2:
|
||||
return clib_error_return (0, "tx interface not a physical port");
|
||||
error = clib_error_return (0, "tx interface not a physical port");
|
||||
goto done;
|
||||
|
||||
default:
|
||||
return clib_error_return
|
||||
error = clib_error_return
|
||||
(0, "WARNING: vnet_l2_patch_add_del returned %d", rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
+25
-9
@@ -409,6 +409,7 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
|
||||
u8 *rw = 0;
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
int rv;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -416,8 +417,11 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
|
||||
|
||||
if (!unformat (line_input, "%U",
|
||||
unformat_vnet_sw_interface, vnm, &l2_sw_if_index))
|
||||
return clib_error_return (0, "unknown input '%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
|
||||
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
@@ -436,7 +440,10 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
|
||||
}
|
||||
|
||||
if (next_node_index == ~0)
|
||||
return clib_error_return (0, "next node not specified");
|
||||
{
|
||||
error = clib_error_return (0, "next node not specified");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (tx_fib_id != ~0)
|
||||
{
|
||||
@@ -448,7 +455,11 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
|
||||
p = hash_get (ip4_main.fib_index_by_table_id, tx_fib_id);
|
||||
|
||||
if (p == 0)
|
||||
return clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id);
|
||||
{
|
||||
error =
|
||||
clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id);
|
||||
goto done;
|
||||
}
|
||||
|
||||
tx_fib_index = p[0];
|
||||
}
|
||||
@@ -463,16 +474,21 @@ set_l2_xcrw_command_fn (vlib_main_t * vm,
|
||||
break;
|
||||
|
||||
case VNET_API_ERROR_INVALID_SW_IF_INDEX:
|
||||
return clib_error_return (0, "%U not cross-connected",
|
||||
format_vnet_sw_if_index_name,
|
||||
vnm, l2_sw_if_index);
|
||||
error = clib_error_return (0, "%U not cross-connected",
|
||||
format_vnet_sw_if_index_name,
|
||||
vnm, l2_sw_if_index);
|
||||
goto done;
|
||||
|
||||
default:
|
||||
return clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv);
|
||||
error = clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
vec_free (rw);
|
||||
unformat_free (line_input);
|
||||
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
+28
-11
@@ -427,6 +427,7 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
|
||||
u32 sw_if_index;
|
||||
u32 encap_fib_id = ~0;
|
||||
u32 encap_fib_index = ~0;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -455,18 +456,22 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
|
||||
else if (unformat (line_input, "l2-sublayer-present"))
|
||||
l2_sublayer_present = 1;
|
||||
else
|
||||
return clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
|
||||
if (encap_fib_id != ~0)
|
||||
{
|
||||
uword *p;
|
||||
ip6_main_t *im = &ip6_main;
|
||||
if (!(p = hash_get (im->fib_index_by_table_id, encap_fib_id)))
|
||||
return clib_error_return (0, "No fib with id %d", encap_fib_id);
|
||||
{
|
||||
error = clib_error_return (0, "No fib with id %d", encap_fib_id);
|
||||
goto done;
|
||||
}
|
||||
encap_fib_index = p[0];
|
||||
}
|
||||
else
|
||||
@@ -475,9 +480,15 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
|
||||
}
|
||||
|
||||
if (our_address_set == 0)
|
||||
return clib_error_return (0, "our address not specified");
|
||||
{
|
||||
error = clib_error_return (0, "our address not specified");
|
||||
goto done;
|
||||
}
|
||||
if (client_address_set == 0)
|
||||
return clib_error_return (0, "client address not specified");
|
||||
{
|
||||
error = clib_error_return (0, "client address not specified");
|
||||
goto done;
|
||||
}
|
||||
|
||||
rv = create_l2tpv3_ipv6_tunnel (lm, &client_address, &our_address,
|
||||
local_session_id, remote_session_id,
|
||||
@@ -491,16 +502,22 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
|
||||
vnet_get_main (), sw_if_index);
|
||||
break;
|
||||
case VNET_API_ERROR_INVALID_VALUE:
|
||||
return clib_error_return (0, "session already exists...");
|
||||
error = clib_error_return (0, "session already exists...");
|
||||
goto done;
|
||||
|
||||
case VNET_API_ERROR_NO_SUCH_ENTRY:
|
||||
return clib_error_return (0, "session does not exist...");
|
||||
error = clib_error_return (0, "session does not exist...");
|
||||
goto done;
|
||||
|
||||
default:
|
||||
return clib_error_return (0, "l2tp_session_add_del returned %d", rv);
|
||||
error = clib_error_return (0, "l2tp_session_add_del returned %d", rv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
return 0;
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
+105
-36
File diff suppressed because it is too large
Load Diff
@@ -794,6 +794,7 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
u32 table_id, vni, bd_id;
|
||||
u8 vni_is_set = 0, vrf_is_set = 0, bd_index_is_set = 0;
|
||||
u8 nsh_iface = 0;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
if (vnet_lisp_gpe_enable_disable_status () == 0)
|
||||
{
|
||||
@@ -828,8 +829,9 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
}
|
||||
else
|
||||
{
|
||||
return clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
error = clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,7 +841,8 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
{
|
||||
if (~0 == lisp_gpe_add_nsh_iface (&lisp_gpe_main))
|
||||
{
|
||||
return clib_error_return (0, "NSH interface not created");
|
||||
error = clib_error_return (0, "NSH interface not created");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -850,21 +853,34 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
}
|
||||
|
||||
if (vrf_is_set && bd_index_is_set)
|
||||
return clib_error_return (0,
|
||||
"Cannot set both vrf and brdige domain index!");
|
||||
{
|
||||
error = clib_error_return
|
||||
(0, "Cannot set both vrf and brdige domain index!");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!vni_is_set)
|
||||
return clib_error_return (0, "vni must be set!");
|
||||
{
|
||||
error = clib_error_return (0, "vni must be set!");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!vrf_is_set && !bd_index_is_set)
|
||||
return clib_error_return (0, "vrf or bridge domain index must be set!");
|
||||
{
|
||||
error =
|
||||
clib_error_return (0, "vrf or bridge domain index must be set!");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (bd_index_is_set)
|
||||
{
|
||||
if (is_add)
|
||||
{
|
||||
if (~0 == lisp_gpe_tenant_l2_iface_add_or_lock (vni, bd_id))
|
||||
return clib_error_return (0, "L2 interface not created");
|
||||
{
|
||||
error = clib_error_return (0, "L2 interface not created");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else
|
||||
lisp_gpe_tenant_l2_iface_unlock (vni);
|
||||
@@ -874,13 +890,35 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
if (is_add)
|
||||
{
|
||||
if (~0 == lisp_gpe_tenant_l3_iface_add_or_lock (vni, table_id))
|
||||
return clib_error_return (0, "L3 interface not created");
|
||||
{
|
||||
error = clib_error_return (0, "L3 interface not created");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else
|
||||
lisp_gpe_tenant_l3_iface_unlock (vni);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
if (nsh_iface)
|
||||
{
|
||||
if (is_add)
|
||||
{
|
||||
if (~0 == lisp_gpe_add_nsh_iface (&lisp_gpe_main))
|
||||
{
|
||||
error = clib_error_return (0, "NSH interface not created");
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
lisp_gpe_del_nsh_iface (&lisp_gpe_main);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
@@ -218,6 +218,7 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
u8 is_en = 1;
|
||||
vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
@@ -231,12 +232,18 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm,
|
||||
is_en = 0;
|
||||
else
|
||||
{
|
||||
return clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
error = clib_error_return (0, "parse error: '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
a->is_en = is_en;
|
||||
return vnet_lisp_gpe_enable_disable (a);
|
||||
error = vnet_lisp_gpe_enable_disable (a);
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
+137
-49
File diff suppressed because it is too large
Load Diff
@@ -470,6 +470,8 @@ vnet_mpls_local_label (vlib_main_t * vm,
|
||||
}
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -535,6 +535,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
|
||||
fib_route_path_t rpath, *rpaths = NULL;
|
||||
mpls_label_t out_label = MPLS_LABEL_INVALID, *labels = NULL;
|
||||
u32 sw_if_index;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
memset(&rpath, 0, sizeof(rpath));
|
||||
|
||||
@@ -595,8 +596,11 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
|
||||
else if (unformat (line_input, "l2-only"))
|
||||
l2_only = 1;
|
||||
else
|
||||
return clib_error_return (0, "unknown input '%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "unknown input '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_del)
|
||||
@@ -606,17 +610,22 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
|
||||
else
|
||||
{
|
||||
if (0 == vec_len(labels))
|
||||
return clib_error_return (0, "No Output Labels '%U'",
|
||||
format_unformat_error, line_input);
|
||||
{
|
||||
error = clib_error_return (0, "No Output Labels '%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
|
||||
vec_add1(rpaths, rpath);
|
||||
vnet_mpls_tunnel_add(rpaths, labels, l2_only, &sw_if_index);
|
||||
}
|
||||
|
||||
done:
|
||||
vec_free(labels);
|
||||
vec_free(rpaths);
|
||||
unformat_free (line_input);
|
||||
|
||||
return (NULL);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*?
|
||||
|
||||
+29
-10
@@ -547,21 +547,30 @@ pg_capture_cmd_fn (vlib_main_t * vm,
|
||||
else
|
||||
{
|
||||
error = clib_error_create ("unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
return error;
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hi)
|
||||
return clib_error_return (0, "Please specify interface name");
|
||||
{
|
||||
error = clib_error_return (0, "Please specify interface name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (hi->dev_class_index != pg_dev_class.index)
|
||||
return clib_error_return (0, "Please specify packet-generator interface");
|
||||
{
|
||||
error =
|
||||
clib_error_return (0, "Please specify packet-generator interface");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!pcap_file_name && is_disable == 0)
|
||||
return clib_error_return (0, "Please specify pcap file name");
|
||||
{
|
||||
error = clib_error_return (0, "Please specify pcap file name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
unformat_free (line_input);
|
||||
|
||||
pg_capture_args_t _a, *a = &_a;
|
||||
|
||||
@@ -572,6 +581,10 @@ pg_capture_cmd_fn (vlib_main_t * vm,
|
||||
a->count = count;
|
||||
|
||||
error = pg_capture (a);
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -590,6 +603,7 @@ create_pg_if_cmd_fn (vlib_main_t * vm,
|
||||
pg_main_t *pg = &pg_main;
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
u32 if_id;
|
||||
clib_error_t *error = NULL;
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
@@ -600,14 +614,19 @@ create_pg_if_cmd_fn (vlib_main_t * vm,
|
||||
;
|
||||
|
||||
else
|
||||
return clib_error_create ("unknown input `%U'",
|
||||
format_unformat_error, input);
|
||||
{
|
||||
error = clib_error_create ("unknown input `%U'",
|
||||
format_unformat_error, line_input);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
pg_interface_add_or_get (pg, if_id);
|
||||
|
||||
done:
|
||||
unformat_free (line_input);
|
||||
|
||||
pg_interface_add_or_get (pg, if_id);
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user