aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/snort/snort_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/snort/snort_api.c')
-rw-r--r--src/plugins/snort/snort_api.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/snort/snort_api.c b/src/plugins/snort/snort_api.c
index 334a84b4341..adad0d8763f 100644
--- a/src/plugins/snort/snort_api.c
+++ b/src/plugins/snort/snort_api.c
@@ -80,10 +80,16 @@ vl_api_snort_interface_attach_t_handler (vl_api_snort_interface_attach_t *mp)
u8 snort_dir = mp->snort_dir;
int rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- instance = snort_get_instance_by_index (instance_index);
- if (instance)
- rv = snort_interface_enable_disable (
- vm, (char *) instance->name, sw_if_index, 1 /* is_enable */, snort_dir);
+ if (sw_if_index == INDEX_INVALID)
+ rv = VNET_API_ERROR_NO_MATCHING_INTERFACE;
+ else
+ {
+ instance = snort_get_instance_by_index (instance_index);
+ if (instance)
+ rv = snort_interface_enable_disable (vm, (char *) instance->name,
+ sw_if_index, 1 /* is_enable */,
+ snort_dir);
+ }
REPLY_MACRO (VL_API_SNORT_INTERFACE_ATTACH_REPLY);
}
@@ -346,10 +352,11 @@ vl_api_snort_interface_detach_t_handler (vl_api_snort_interface_detach_t *mp)
vlib_main_t *vm = vlib_get_main ();
vl_api_snort_interface_detach_reply_t *rmp;
u32 sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
- int rv;
+ int rv = VNET_API_ERROR_NO_MATCHING_INTERFACE;
- rv = snort_interface_enable_disable (vm, NULL, sw_if_index,
- 0 /* is_enable */, 0);
+ if (sw_if_index != INDEX_INVALID)
+ rv = snort_interface_enable_disable (vm, NULL, sw_if_index,
+ 0 /* is_enable */, SNORT_INOUT);
REPLY_MACRO (VL_API_SNORT_INTERFACE_DETACH_REPLY);
}