summaryrefslogtreecommitdiffstats
path: root/src/plugins/snat/snat_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/snat/snat_api.c')
-rw-r--r--src/plugins/snat/snat_api.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/plugins/snat/snat_api.c b/src/plugins/snat/snat_api.c
index 383df39958b..aa0b59ac4a0 100644
--- a/src/plugins/snat/snat_api.c
+++ b/src/plugins/snat/snat_api.c
@@ -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;