NAT64: change not supported multi threading behaviour
Disable CLI/API commands instead of error message on startup. Change-Id: I313ed6e2ea009f573afb5e08b0e85ed1f9091dc3 Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
@ -47,9 +47,11 @@ nat64_init (vlib_main_t * vm)
|
||||
clib_error_t *error = 0;
|
||||
vlib_thread_main_t *tm = vlib_get_thread_main ();
|
||||
|
||||
nm->is_disabled = 0;
|
||||
|
||||
if (tm->n_vlib_mains > 1)
|
||||
{
|
||||
error = clib_error_return (0, "multi thread not supported");
|
||||
nm->is_disabled = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -609,7 +611,7 @@ nat64_expire_walk_fn (vlib_main_t * vm, vlib_node_runtime_t * rt,
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
|
||||
while (1)
|
||||
while (!nm->is_disabled)
|
||||
{
|
||||
vlib_process_wait_for_event_or_clock (vm, 10.0);
|
||||
vlib_process_get_events (vm, NULL);
|
||||
|
@ -57,6 +57,8 @@ typedef struct
|
||||
u32 tcp_est_timeout;
|
||||
u32 tcp_incoming_syn_timeout;
|
||||
|
||||
u8 is_disabled;
|
||||
|
||||
snat_main_t *sm;
|
||||
} nat64_main_t;
|
||||
|
||||
|
@ -26,6 +26,7 @@ nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t * input,
|
||||
vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
ip4_address_t start_addr, end_addr, this_addr;
|
||||
u32 start_host_order, end_host_order;
|
||||
@ -34,6 +35,10 @@ nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
|
||||
u8 is_add = 1;
|
||||
clib_error_t *error = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
@ -124,6 +129,12 @@ nat64_show_pool_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t * input,
|
||||
vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
vlib_cli_output (vm, "NAT64 pool:");
|
||||
nat64_pool_addr_walk (nat64_cli_pool_walk, vm);
|
||||
|
||||
@ -135,6 +146,7 @@ nat64_interface_feature_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t *
|
||||
input, vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
clib_error_t *error = 0;
|
||||
@ -144,6 +156,10 @@ nat64_interface_feature_command_fn (vlib_main_t * vm,
|
||||
u8 is_add = 1;
|
||||
int i, rv;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
/* Get a line of input. */
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
@ -261,6 +277,12 @@ nat64_show_interfaces_command_fn (vlib_main_t * vm,
|
||||
unformat_input_t *
|
||||
input, vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
vlib_cli_output (vm, "NAT64 interfaces:");
|
||||
nat64_interfaces_walk (nat64_cli_interface_walk, vm);
|
||||
|
||||
@ -273,6 +295,7 @@ nat64_add_del_static_bib_command_fn (vlib_main_t *
|
||||
unformat_input_t
|
||||
* input, vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
clib_error_t *error = 0;
|
||||
u8 is_add = 1;
|
||||
@ -285,6 +308,10 @@ nat64_add_del_static_bib_command_fn (vlib_main_t *
|
||||
u8 p = 0;
|
||||
int rv;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
|
||||
@ -382,6 +409,10 @@ nat64_show_bib_command_fn (vlib_main_t * vm,
|
||||
clib_error_t *error = 0;
|
||||
snat_protocol_t proto = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
|
||||
@ -407,6 +438,7 @@ static clib_error_t *
|
||||
nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
unformat_input_t _line_input, *line_input = &_line_input;
|
||||
clib_error_t *error = 0;
|
||||
u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
|
||||
@ -415,6 +447,10 @@ nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
tcp_est = nat64_get_tcp_est_timeout ();
|
||||
tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout ();
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
|
||||
@ -490,6 +526,12 @@ static clib_error_t *
|
||||
nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
vlib_cli_command_t * cmd)
|
||||
{
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
vlib_cli_output (vm, "NAT64 session timeouts:");
|
||||
vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ());
|
||||
vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ());
|
||||
@ -553,6 +595,10 @@ nat64_show_st_command_fn (vlib_main_t * vm,
|
||||
clib_error_t *error = 0;
|
||||
snat_protocol_t proto = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return clib_error_return (0,
|
||||
"NAT64 disabled, multi thread not supported");
|
||||
|
||||
if (!unformat_user (input, unformat_line_input, line_input))
|
||||
return 0;
|
||||
|
||||
|
@ -725,7 +725,7 @@ snat_ip4_add_del_interface_address_cb (ip4_main_t * im,
|
||||
static clib_error_t * snat_init (vlib_main_t * vm)
|
||||
{
|
||||
snat_main_t * sm = &snat_main;
|
||||
clib_error_t * error = 0, * error_nat64 = 0;
|
||||
clib_error_t * error = 0;
|
||||
ip4_main_t * im = &ip4_main;
|
||||
ip_lookup_main_t * lm = &im->lookup_main;
|
||||
uword *p;
|
||||
@ -772,6 +772,8 @@ static clib_error_t * snat_init (vlib_main_t * vm)
|
||||
}
|
||||
|
||||
error = snat_api_init(vm, sm);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Set up the interface address add/del callback */
|
||||
cb4.function = snat_ip4_add_del_interface_address_cb;
|
||||
@ -782,9 +784,7 @@ static clib_error_t * snat_init (vlib_main_t * vm)
|
||||
/* Init IPFIX logging */
|
||||
snat_ipfix_logging_init(vm);
|
||||
|
||||
error_nat64 = nat64_init(vm);
|
||||
if (error_nat64)
|
||||
clib_warning("NAT64 init failed: %U", format_clib_error, error_nat64);
|
||||
error = nat64_init(vm);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -1210,6 +1210,7 @@ static void
|
||||
{
|
||||
vl_api_nat64_add_del_pool_addr_range_reply_t *rmp;
|
||||
snat_main_t *sm = &snat_main;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
int rv = 0;
|
||||
ip4_address_t this_addr;
|
||||
u32 start_host_order, end_host_order;
|
||||
@ -1217,6 +1218,12 @@ static void
|
||||
int i, count;
|
||||
u32 *tmp;
|
||||
|
||||
if (nm->is_disabled)
|
||||
{
|
||||
rv = VNET_API_ERROR_FEATURE_DISABLED;
|
||||
goto send_reply;
|
||||
}
|
||||
|
||||
tmp = (u32 *) mp->start_addr;
|
||||
start_host_order = clib_host_to_net_u32 (tmp[0]);
|
||||
tmp = (u32 *) mp->end_addr;
|
||||
@ -1291,6 +1298,10 @@ static void
|
||||
vl_api_nat64_pool_addr_dump_t_handler (vl_api_nat64_pool_addr_dump_t * mp)
|
||||
{
|
||||
unix_shared_memory_queue_t *q;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return;
|
||||
|
||||
q = vl_api_client_index_to_input_queue (mp->client_index);
|
||||
if (q == 0)
|
||||
@ -1320,9 +1331,16 @@ vl_api_nat64_add_del_interface_t_handler (vl_api_nat64_add_del_interface_t *
|
||||
mp)
|
||||
{
|
||||
snat_main_t *sm = &snat_main;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
vl_api_nat64_add_del_interface_reply_t *rmp;
|
||||
int rv = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
{
|
||||
rv = VNET_API_ERROR_FEATURE_DISABLED;
|
||||
goto send_reply;
|
||||
}
|
||||
|
||||
VALIDATE_SW_IF_INDEX (mp);
|
||||
|
||||
rv =
|
||||
@ -1331,6 +1349,7 @@ vl_api_nat64_add_del_interface_t_handler (vl_api_nat64_add_del_interface_t *
|
||||
|
||||
BAD_SW_IF_INDEX_LABEL;
|
||||
|
||||
send_reply:
|
||||
REPLY_MACRO (VL_API_NAT64_ADD_DEL_INTERFACE_REPLY);
|
||||
}
|
||||
|
||||
@ -1371,6 +1390,10 @@ static void
|
||||
vl_api_nat64_interface_dump_t_handler (vl_api_nat64_interface_dump_t * mp)
|
||||
{
|
||||
unix_shared_memory_queue_t *q;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return;
|
||||
|
||||
q = vl_api_client_index_to_input_queue (mp->client_index);
|
||||
if (q == 0)
|
||||
@ -1400,11 +1423,18 @@ static void
|
||||
(vl_api_nat64_add_del_static_bib_t * mp)
|
||||
{
|
||||
snat_main_t *sm = &snat_main;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
vl_api_nat64_add_del_static_bib_reply_t *rmp;
|
||||
ip6_address_t in_addr;
|
||||
ip4_address_t out_addr;
|
||||
int rv = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
{
|
||||
rv = VNET_API_ERROR_FEATURE_DISABLED;
|
||||
goto send_reply;
|
||||
}
|
||||
|
||||
memcpy (&in_addr.as_u8, mp->i_addr, 16);
|
||||
memcpy (&out_addr.as_u8, mp->o_addr, 4);
|
||||
|
||||
@ -1416,6 +1446,7 @@ static void
|
||||
clib_net_to_host_u32 (mp->vrf_id),
|
||||
mp->is_add);
|
||||
|
||||
send_reply:
|
||||
REPLY_MACRO (VL_API_NAT64_ADD_DEL_STATIC_BIB_REPLY);
|
||||
}
|
||||
|
||||
@ -1472,6 +1503,9 @@ vl_api_nat64_bib_dump_t_handler (vl_api_nat64_bib_dump_t * mp)
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
snat_protocol_t proto;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return;
|
||||
|
||||
q = vl_api_client_index_to_input_queue (mp->client_index);
|
||||
if (q == 0)
|
||||
return;
|
||||
@ -1500,9 +1534,16 @@ static void
|
||||
vl_api_nat64_set_timeouts_t_handler (vl_api_nat64_set_timeouts_t * mp)
|
||||
{
|
||||
snat_main_t *sm = &snat_main;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
vl_api_nat64_set_timeouts_reply_t *rmp;
|
||||
int rv = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
{
|
||||
rv = VNET_API_ERROR_FEATURE_DISABLED;
|
||||
goto send_reply;
|
||||
}
|
||||
|
||||
rv = nat64_set_icmp_timeout (ntohl (mp->icmp));
|
||||
if (rv)
|
||||
goto send_reply;
|
||||
@ -1536,9 +1577,13 @@ static void
|
||||
vl_api_nat64_get_timeouts_t_handler (vl_api_nat64_get_timeouts_t * mp)
|
||||
{
|
||||
snat_main_t *sm = &snat_main;
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
vl_api_nat64_get_timeouts_reply_t *rmp;
|
||||
int rv = 0;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
REPLY_MACRO2 (VL_API_NAT64_GET_TIMEOUTS_REPLY,
|
||||
({
|
||||
@ -1605,6 +1650,9 @@ vl_api_nat64_st_dump_t_handler (vl_api_nat64_st_dump_t * mp)
|
||||
nat64_main_t *nm = &nat64_main;
|
||||
snat_protocol_t proto;
|
||||
|
||||
if (nm->is_disabled)
|
||||
return;
|
||||
|
||||
q = vl_api_client_index_to_input_queue (mp->client_index);
|
||||
if (q == 0)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user