|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
7 #include <vpp/app/version.h>
10 #include <sys/eventfd.h>
15 .class_name =
"snort",
16 .default_syslog_level = VLIB_LOG_LEVEL_DEBUG,
19 #define log_debug(fmt, ...) vlib_log_debug (snort_log.class, fmt, __VA_ARGS__)
20 #define log_err(fmt, ...) vlib_log_err (snort_log.class, fmt, __VA_ARGS__)
30 if (
c->instance_index != ~0)
37 __atomic_store_n (&qp->
ready, 1, __ATOMIC_RELEASE);
39 si->client_index = ~0;
88 log_err (
"unexpeced message recieved from client", 0);
100 log_err (
"unknown instance '%s' requested by client",
name);
107 u32 ready = __atomic_load_n (&qp->
ready, __ATOMIC_ACQUIRE);
110 log_err (
"instance '%s' is not ready to accept connections",
name);
116 base = (
u8 *)
si->shm_base;
118 if (
si->client_index != ~0)
120 log_err (
"client already connected to instance '%s'",
name);
125 c->instance_index =
si->index;
127 log_debug (
"fd_read_ready: connect instance index %u",
si->index);
134 e->
fds[0] =
si->shm_fd;
218 c->instance_index = ~0;
276 u8 drop_on_disconnect)
286 u32 qpair_mem_sz = 0;
287 u32 qsz = 1 << log2_queue_sz;
314 if ((ftruncate (fd,
size)) == -1)
330 si->client_index = ~0;
335 si->drop_on_disconnect = drop_on_disconnect;
339 log_debug (
"instnce '%s' createed with fd %d at %p, len %u",
name, fd, base,
364 qp->
enq_fd = eventfd (0, EFD_NONBLOCK);
365 qp->
deq_fd = eventfd (0, EFD_NONBLOCK);
380 format (0,
"snort dequeue for instance '%s' qpair %u",
si->name,
i);
389 VLIB_NODE_STATE_INTERRUPT);
427 "interface %U already assgined to "
445 "interface %U is not assigned to snort "
512 .version = VPP_BUILD_VER,
513 .description =
"Snort",
517 .arc_name =
"ip4-unicast",
518 .node_name =
"snort-enq",
clib_file_function_t * write_function
#define log_debug(fmt,...)
#define CLIB_SOCKET_F_IS_SERVER
static clib_error_t * snort_init(vlib_main_t *vm)
daq_vpp_msg_hello_t hello
clib_file_main_t file_main
static void clib_file_set_polling_thread(clib_file_main_t *um, uword index, u32 thread_index)
daq_vpp_desc_t * descriptors
clib_error_t * snort_set_node_mode(vlib_main_t *vm, u32 mode)
static clib_error_t * snort_conn_fd_accept_ready(clib_file_t *uf)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void snort_set_default_socket(snort_main_t *sm, u8 *socket_name)
daq_vpp_msg_bpool_t bpool
static uword clib_fifo_elts(void *v)
static clib_error_t * clib_socket_recvmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
static void clib_mem_free(void *p)
__clib_export void * clib_mem_vm_map_shared(void *base, uword size, int fd, uword offset, char *fmt,...)
__clib_export int clib_mem_vm_unmap(void *base)
#define hash_create_string(elts, value_bytes)
#define clib_error_return(e, args...)
clib_file_function_t * read_function
uint32_t desc_table_offset
#define hash_set_mem(h, key, value)
static clib_error_t * snort_deq_ready(clib_file_t *uf)
static snort_instance_t * snort_get_instance_by_name(char *name)
vl_api_tunnel_mode_t mode
static clib_error_t * snort_listener_init(vlib_main_t *vm)
#define pool_put(P, E)
Free an object E in pool P.
vlib_buffer_main_t * buffer_main
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vlib_physmem_map_t * vlib_physmem_get_map(vlib_main_t *vm, u32 index)
vlib_node_registration_t snort_deq_node
(constructor) VLIB_REGISTER_NODE (snort_deq_node)
#define CLIB_MEM_VM_MAP_FAILED
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
__clib_export int clib_mem_vm_create_fd(clib_mem_page_sz_t log2_page_size, char *fmt,...)
daq_vpp_msg_config_t config
static uword round_pow2(uword x, uword pow2)
static_always_inline void clib_memset_u32(void *p, u32 val, uword count)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static clib_error_t * clib_socket_close(clib_socket_t *sock)
vnet_main_t * vnet_get_main(void)
__clib_export void clib_interrupt_resize(void **data, uword n_int)
snort_instance_t * instances
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
static_always_inline void clib_interrupt_set(void *in, int int_num)
static char * vlib_unix_get_runtime_dir(void)
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
static void snort_freelist_init(u32 *fl)
snort_per_thread_data_t * per_thread_data
static uword clib_file_set_data_available_to_write(clib_file_main_t *um, u32 clib_file_index, uword is_available)
VLIB_REGISTER_LOG_CLASS(snort_log, static)
u32 * instance_by_sw_if_index
#define CLIB_CACHE_LINE_BYTES
clib_error_t * snort_instance_create(vlib_main_t *vm, char *name, u8 log2_queue_sz, u8 drop_on_disconnect)
static void snort_client_disconnect(clib_file_t *uf)
static clib_error_t * snort_conn_fd_read_ready(clib_file_t *uf)
#define hash_get_mem(h, key)
clib_error_t * snort_conn_fd_error(clib_file_t *uf)
vlib_buffer_pool_t * buffer_pools
format_function_t format_vnet_sw_if_index_name
description fragment has unexpected format
__clib_export clib_error_t * clib_socket_init(clib_socket_t *s)
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
char inst_name[DAQ_VPP_INST_NAME_LEN]
daq_vpp_msg_qpair_t qpair
#define VLIB_INIT_FUNCTION(x)
@ CLIB_MEM_PAGE_SZ_DEFAULT
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
#define clib_fifo_add2(f, p)
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
#define vec_foreach(var, vec)
Vector iterator.
static_always_inline uword clib_mem_get_page_size(void)
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
clib_error_t * snort_interface_enable_disable(vlib_main_t *vm, char *instance_name, u32 sw_if_index, int is_enable)
#define DAQ_VPP_INST_NAME_LEN
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
VNET_FEATURE_INIT(snort_enq, static)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u32 vlib_get_n_threads()
#define DAQ_VPP_DEFAULT_SOCKET_FILE
static vlib_main_t * vlib_get_main(void)
#define VNET_FEATURES(...)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
#define CLIB_SOCKET_F_PASSCRED
#define clib_error_free(e)
u8 ** buffer_pool_base_addrs
clib_file_function_t * error_function
struct _socket_t clib_socket_t
static vlib_thread_main_t * vlib_get_thread_main()
#define clib_fifo_sub2(f, p)
vl_api_interface_index_t sw_if_index
static_always_inline clib_error_t * clib_mem_get_last_error(void)
static clib_error_t * snort_conn_fd_write_ready(clib_file_t *uf)
static void * clib_mem_alloc(uword size)
#define CLIB_SOCKET_F_SEQPACKET
__clib_export clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
@ DAQ_VPP_MSG_TYPE_CONFIG