diff options
-rw-r--r-- | src/plugins/snort/daq_vpp.c | 5 | ||||
-rw-r--r-- | src/plugins/snort/snort_api.c | 21 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/plugins/snort/daq_vpp.c b/src/plugins/snort/daq_vpp.c index 386092a0382..6fc0bf5506a 100644 --- a/src/plugins/snort/daq_vpp.c +++ b/src/plugins/snort/daq_vpp.c @@ -10,6 +10,7 @@ #include <sys/socket.h> #include <sys/un.h> #include <sys/mman.h> +#include <sys/time.h> #include <errno.h> #include <sys/epoll.h> @@ -521,6 +522,7 @@ vpp_daq_msg_receive_one (VPP_Context_t *vc, VPPQueuePair *qp, { uint32_t n_recv, n_left; uint32_t head, next, mask = qp->queue_size - 1; + struct timeval tv; if (max_recv == 0) return 0; @@ -535,11 +537,14 @@ vpp_daq_msg_receive_one (VPP_Context_t *vc, VPPQueuePair *qp, n_left = n_recv = max_recv; } + gettimeofday (&tv, NULL); while (n_left--) { uint32_t desc_index = qp->enq_ring[next & mask]; daq_vpp_desc_t *d = qp->descs + desc_index; VPPDescData *dd = qp->desc_data + desc_index; + dd->pkthdr.ts.tv_sec = tv.tv_sec; + dd->pkthdr.ts.tv_usec = tv.tv_usec; dd->pkthdr.pktlen = d->length; dd->pkthdr.address_space_id = d->address_space_id; dd->msg.data = vc->bpools[d->buffer_pool].base + d->offset; 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); } |