FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
main.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright(c) 2021 Cisco Systems, Inc.
3  */
4 
5 #include <vlib/vlib.h>
6 #include <vnet/plugin/plugin.h>
7 #include <vpp/app/version.h>
8 #include <snort/snort.h>
9 
10 #include <sys/eventfd.h>
11 
13 
14 VLIB_REGISTER_LOG_CLASS (snort_log, static) = {
15  .class_name = "snort",
16  .default_syslog_level = VLIB_LOG_LEVEL_DEBUG,
17 };
18 
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__)
21 
22 static void
24 {
26  snort_qpair_t *qp;
27  snort_main_t *sm = &snort_main;
29 
30  if (c->instance_index != ~0)
31  {
35  pool_elt_at_index (sm->instances, c->instance_index);
36  vec_foreach (qp, si->qpairs)
37  __atomic_store_n (&qp->ready, 1, __ATOMIC_RELEASE);
38 
39  si->client_index = ~0;
42  }
43 
44  clib_file_del (&file_main, uf);
45  clib_socket_close (&c->socket);
46  pool_put (sm->clients, c);
47 }
48 
49 static snort_instance_t *
51 {
52  snort_main_t *sm = &snort_main;
53  uword *p;
54  if ((p = hash_get_mem (sm->instance_by_name, name)) == 0)
55  return 0;
56 
57  return vec_elt_at_index (sm->instances, p[0]);
58  ;
59 }
60 
61 static clib_error_t *
63 {
65  snort_main_t *sm = &snort_main;
69  snort_qpair_t *qp;
71  clib_error_t *err;
72  daq_vpp_msg_t msg;
73  char *name;
74  u8 *base;
75 
76  log_debug ("fd_read_ready: client %u", uf->private_data);
77 
78  if ((err = clib_socket_recvmsg (&c->socket, &msg, sizeof (msg), 0, 0)))
79  {
80  log_err ("client recvmsg error: %U", format_clib_error, err);
82  clib_error_free (err);
83  return 0;
84  }
85 
86  if (msg.type != DAQ_VPP_MSG_TYPE_HELLO)
87  {
88  log_err ("unexpeced message recieved from client", 0);
90  return 0;
91  }
92 
94  name = msg.hello.inst_name;
95 
96  log_debug ("fd_read_ready: connect instance %s", name);
97 
98  if ((si = snort_get_instance_by_name (name)) == 0)
99  {
100  log_err ("unknown instance '%s' requested by client", name);
102  return 0;
103  }
104 
105  vec_foreach (qp, si->qpairs)
106  {
107  u32 ready = __atomic_load_n (&qp->ready, __ATOMIC_ACQUIRE);
108  if (!ready)
109  {
110  log_err ("instance '%s' is not ready to accept connections", name);
112  return 0;
113  }
114  }
115 
116  base = (u8 *) si->shm_base;
117 
118  if (si->client_index != ~0)
119  {
120  log_err ("client already connected to instance '%s'", name);
122  return 0;
123  }
124  si->client_index = uf->private_data;
125  c->instance_index = si->index;
126 
127  log_debug ("fd_read_ready: connect instance index %u", si->index);
128 
129  clib_fifo_add2 (c->msg_queue, e);
132  e->msg.config.num_qpairs = vec_len (si->qpairs);
133  e->msg.config.shm_size = si->shm_size;
134  e->fds[0] = si->shm_fd;
135  e->n_fds = 1;
136 
138  {
139  vlib_physmem_map_t *pm;
141  clib_fifo_add2 (c->msg_queue, e);
143  e->msg.bpool.size = pm->n_pages << pm->log2_page_size;
144  e->fds[0] = pm->fd;
145  e->n_fds = 1;
146  }
147 
148  vec_foreach (qp, si->qpairs)
149  {
150  clib_fifo_add2 (c->msg_queue, e);
153  e->msg.qpair.desc_table_offset = (u8 *) qp->descriptors - base;
154  e->msg.qpair.enq_ring_offset = (u8 *) qp->enq_ring - base;
155  e->msg.qpair.deq_ring_offset = (u8 *) qp->deq_ring - base;
156  e->msg.qpair.enq_head_offset = (u8 *) qp->enq_head - base;
157  e->msg.qpair.deq_head_offset = (u8 *) qp->deq_head - base;
158  e->fds[0] = qp->enq_fd;
159  e->fds[1] = qp->deq_fd;
160  e->n_fds = 2;
161  }
162 
164  return 0;
165 }
166 
167 static clib_error_t *
169 {
170  snort_main_t *sm = &snort_main;
173 
174  log_debug ("fd_write_ready: client %u", uf->private_data);
175  clib_fifo_sub2 (c->msg_queue, e);
176 
177  if (clib_fifo_elts (c->msg_queue) == 0)
179 
180  return clib_socket_sendmsg (&c->socket, &e->msg, sizeof (*e), e->fds,
181  e->n_fds);
182 }
183 
184 clib_error_t *
186 {
187  log_debug ("fd_error: client %u", uf->private_data);
188  return 0;
189 }
190 
191 static clib_error_t *
193 {
195  snort_main_t *sm = &snort_main;
198  u64 counter;
199 
200  if (read (uf->file_descriptor, &counter, sizeof (counter)) < 0)
201  return clib_error_return (0, "client closed socket");
202 
205  return 0;
206 }
207 
208 static clib_error_t *
210 {
211  snort_main_t *sm = &snort_main;
212  snort_client_t *c;
213  clib_socket_t *s;
214  clib_error_t *err = 0;
215  clib_file_t t = { 0 };
216 
217  pool_get_zero (sm->clients, c);
218  c->instance_index = ~0;
219  s = &c->socket;
220 
221  if ((err = clib_socket_accept (sm->listener, s)))
222  {
223  log_err ("%U", format_clib_error, err);
224  pool_put (sm->clients, c);
225  return err;
226  }
227 
231  t.file_descriptor = s->fd;
232  t.private_data = c - sm->clients;
233  t.description = format (0, "snort client");
234  c->file_index = clib_file_add (&file_main, &t);
235 
236  log_debug ("snort_conn_fd_accept_ready: client %u", t.private_data);
237  return 0;
238 }
239 
240 static clib_error_t *
242 {
243  snort_main_t *sm = &snort_main;
244  clib_error_t *err;
245  clib_file_t t = { 0 };
246  clib_socket_t *s;
247 
248  if (sm->listener)
249  return 0;
250 
251  s = clib_mem_alloc (sizeof (clib_socket_t));
252  clib_memset (s, 0, sizeof (clib_socket_t));
253  s->config = (char *) sm->socket_name;
256 
257  if ((err = clib_socket_init (s)))
258  {
259  clib_mem_free (s);
260  return err;
261  }
262 
264  t.file_descriptor = s->fd;
265  t.description = format (0, "snort listener %s", s->config);
266  log_debug ("%v", t.description);
267  clib_file_add (&file_main, &t);
268 
269  sm->listener = s;
270 
271  return 0;
272 }
273 
274 clib_error_t *
275 snort_instance_create (vlib_main_t *vm, char *name, u8 log2_queue_sz,
276  u8 drop_on_disconnect)
277 {
279  snort_main_t *sm = &snort_main;
281  clib_error_t *err = 0;
282  u32 index, i;
283  u8 *base = CLIB_MEM_VM_MAP_FAILED;
284  u32 size;
285  int fd = -1;
286  u32 qpair_mem_sz = 0;
287  u32 qsz = 1 << log2_queue_sz;
288  u8 align = CLIB_CACHE_LINE_BYTES;
289 
291  return clib_error_return (0, "instance already exists");
292 
293  /* descriptor table */
294  qpair_mem_sz += round_pow2 (qsz * sizeof (daq_vpp_desc_t), align);
295 
296  /* enq and deq ring */
297  qpair_mem_sz += 2 * round_pow2 (qsz * sizeof (u32), align);
298 
299  /* enq and deq head pointer */
300  qpair_mem_sz += 2 * round_pow2 (sizeof (u32), align);
301 
302  size =
303  round_pow2 (tm->n_vlib_mains * qpair_mem_sz, clib_mem_get_page_size ());
304  fd = clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT, "snort instance %s",
305  name);
306 
307  if (fd == -1)
308  {
309  err = clib_error_return (0, "memory fd failure: %U", format_clib_error,
311  goto done;
312  }
313 
314  if ((ftruncate (fd, size)) == -1)
315  {
316  err = clib_error_return (0, "ftruncate failure");
317  goto done;
318  }
319 
320  base = clib_mem_vm_map_shared (0, size, fd, 0, "snort instance %s", name);
321 
322  if (base == CLIB_MEM_VM_MAP_FAILED)
323  {
324  err = clib_error_return (0, "mmap failure");
325  goto done;
326  }
327 
328  pool_get_zero (sm->instances, si);
329  si->index = si - sm->instances;
330  si->client_index = ~0;
331  si->shm_base = base;
332  si->shm_fd = fd;
333  si->shm_size = size;
334  si->name = format (0, "%s%c", name, 0);
335  si->drop_on_disconnect = drop_on_disconnect;
336  index = si - sm->instances;
337  hash_set_mem (sm->instance_by_name, si->name, index);
338 
339  log_debug ("instnce '%s' createed with fd %d at %p, len %u", name, fd, base,
340  size);
341 
344  vec_validate_aligned (si->qpairs, tm->n_vlib_mains - 1,
346 
347  for (int i = 0; i < tm->n_vlib_mains; i++)
348  {
349  snort_qpair_t *qp = vec_elt_at_index (si->qpairs, i);
351  clib_file_t t = { 0 };
352 
353  qp->log2_queue_size = log2_queue_sz;
354  qp->descriptors = (void *) base;
355  base += round_pow2 (qsz * sizeof (daq_vpp_desc_t), align);
356  qp->enq_ring = (void *) base;
357  base += round_pow2 (qsz * sizeof (u32), align);
358  qp->deq_ring = (void *) base;
359  base += round_pow2 (qsz * sizeof (u32), align);
360  qp->enq_head = (void *) base;
361  base += round_pow2 (sizeof (u32), align);
362  qp->deq_head = (void *) base;
363  base += round_pow2 (sizeof (u32), align);
364  qp->enq_fd = eventfd (0, EFD_NONBLOCK);
365  qp->deq_fd = eventfd (0, EFD_NONBLOCK);
366  vec_validate_aligned (qp->buffer_indices, qsz - 1,
369  clib_memset_u32 (qp->buffer_indices, ~0, qsz);
370 
371  /* pre-populate freelist */
374 
375  /* listen on dequeue events */
377  t.file_descriptor = qp->deq_fd;
378  t.private_data = si->index;
379  t.description =
380  format (0, "snort dequeue for instance '%s' qpair %u", si->name, i);
382  qp->ready = 1;
385  }
386 
387  for (i = 0; i < vlib_get_n_threads (); i++)
389  VLIB_NODE_STATE_INTERRUPT);
390 
391 done:
392  if (err)
393  {
394  if (base != CLIB_MEM_VM_MAP_FAILED)
395  clib_mem_vm_unmap (base);
396  if (fd != -1)
397  close (fd);
398  }
399  return err;
400 }
401 
402 clib_error_t *
404  u32 sw_if_index, int is_enable)
405 {
406  snort_main_t *sm = &snort_main;
407  vnet_main_t *vnm = vnet_get_main ();
409  clib_error_t *err = 0;
410  u32 index;
411 
412  if (is_enable)
413  {
414  if ((si = snort_get_instance_by_name (instance_name)) == 0)
415  {
416  err = clib_error_return (0, "unknown instance '%s'", instance_name);
417  goto done;
418  }
419 
421 
423  if (index != ~0)
424  {
426  err = clib_error_return (0,
427  "interface %U already assgined to "
428  "instance '%s'",
430  sw_if_index, si->name);
431  goto done;
432  }
433 
435  vnet_feature_enable_disable ("ip4-unicast", "snort-enq", sw_if_index, 1,
436  &index, sizeof (index));
437  }
438  else
439  {
442  {
443  err =
445  "interface %U is not assigned to snort "
446  "instance!",
448  goto done;
449  }
452 
454  vnet_feature_enable_disable ("ip4-unicast", "snort-enq", sw_if_index, 0,
455  &index, sizeof (index));
456  }
457 
458 done:
459  if (err)
460  log_err ("%U", format_clib_error, err);
461  return 0;
462 }
463 
464 clib_error_t *
466 {
467  int i;
469  for (i = 0; i < vlib_get_n_threads (); i++)
471  mode);
472  return 0;
473 }
474 
475 static void
477 {
478  if (sm->socket_name)
479  return;
480 
481  if (!socket_name)
482  socket_name = (u8 *) DAQ_VPP_DEFAULT_SOCKET_FILE;
483 
484  sm->socket_name =
485  format (0, "%s/%s", vlib_unix_get_runtime_dir (), socket_name);
487 }
488 
489 static clib_error_t *
491 {
492  snort_main_t *sm = &snort_main;
493  sm->instance_by_name = hash_create_string (0, sizeof (uword));
494  vlib_buffer_pool_t *bp;
495 
497  {
498  vlib_physmem_map_t *pm =
501  }
502 
503  if (!sm->socket_name)
504  snort_set_default_socket (sm, 0);
505 
506  return snort_listener_init (vm);
507 }
508 
510 
512  .version = VPP_BUILD_VER,
513  .description = "Snort",
514 };
515 
516 VNET_FEATURE_INIT (snort_enq, static) = {
517  .arc_name = "ip4-unicast",
518  .node_name = "snort-enq",
519  .runs_before = VNET_FEATURES ("ip4-lookup"),
520 };
vlib_physmem_map_t::base
void * base
Definition: physmem.h:49
vlib.h
clib_file::file_descriptor
u32 file_descriptor
Definition: file.h:54
clib_file::write_function
clib_file_function_t * write_function
Definition: file.h:67
log_debug
#define log_debug(fmt,...)
Definition: main.c:19
CLIB_SOCKET_F_IS_SERVER
#define CLIB_SOCKET_F_IS_SERVER
Definition: socket.h:58
snort_init
static clib_error_t * snort_init(vlib_main_t *vm)
Definition: main.c:490
snort_qpair_t::freelist
u32 * freelist
Definition: snort.h:27
daq_vpp_msg_t::hello
daq_vpp_msg_hello_t hello
Definition: daq_vpp.h:55
file_main
clib_file_main_t file_main
Definition: main.c:63
clib_file_set_polling_thread
static void clib_file_set_polling_thread(clib_file_main_t *um, uword index, u32 thread_index)
Definition: file.h:127
snort_qpair_t::descriptors
daq_vpp_desc_t * descriptors
Definition: snort.h:17
vlib_physmem_map_t
Definition: physmem.h:45
daq_vpp_msg_qpair_t::enq_head_offset
uint32_t enq_head_offset
Definition: daq_vpp.h:44
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
snort_set_node_mode
clib_error_t * snort_set_node_mode(vlib_main_t *vm, u32 mode)
Definition: main.c:465
snort_per_thread_data_t
Definition: snort.h:64
snort_qpair_t::buffer_indices
u32 * buffer_indices
Definition: snort.h:25
snort_conn_fd_accept_ready
static clib_error_t * snort_conn_fd_accept_ready(clib_file_t *uf)
Definition: main.c:209
vlib_node_set_state
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:175
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
name
string name[64]
Definition: fib.api:25
snort_set_default_socket
static void snort_set_default_socket(snort_main_t *sm, u8 *socket_name)
Definition: main.c:476
daq_vpp_msg_t::bpool
daq_vpp_msg_bpool_t bpool
Definition: daq_vpp.h:57
clib_fifo_elts
static uword clib_fifo_elts(void *v)
Definition: fifo.h:66
clib_socket_recvmsg
static clib_error_t * clib_socket_recvmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:160
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
clib_mem_vm_map_shared
__clib_export void * clib_mem_vm_map_shared(void *base, uword size, int fd, uword offset, char *fmt,...)
Definition: mem.c:59
vlib_buffer_pool_t
Definition: buffer.h:450
clib_mem_vm_unmap
__clib_export int clib_mem_vm_unmap(void *base)
Definition: mem.c:478
vlib_buffer_pool_t::physmem_map_index
u32 physmem_map_index
Definition: buffer.h:458
hash_create_string
#define hash_create_string(elts, value_bytes)
Definition: hash.h:689
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
clib_file::read_function
clib_file_function_t * read_function
Definition: file.h:67
snort_main_t::socket_name
u8 * socket_name
Definition: snort.h:80
daq_vpp_msg_qpair_t::desc_table_offset
uint32_t desc_table_offset
Definition: daq_vpp.h:43
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
snort_deq_ready
static clib_error_t * snort_deq_ready(clib_file_t *uf)
Definition: main.c:192
snort_get_instance_by_name
static snort_instance_t * snort_get_instance_by_name(char *name)
Definition: main.c:50
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
snort_listener_init
static clib_error_t * snort_listener_init(vlib_main_t *vm)
Definition: main.c:241
clib_file::private_data
u64 private_data
Definition: file.h:64
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vlib_main_t::buffer_main
vlib_buffer_main_t * buffer_main
Definition: main.h:167
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
snort.h
daq_vpp_desc_t
Definition: daq_vpp.h:68
vlib_physmem_get_map
vlib_physmem_map_t * vlib_physmem_get_map(vlib_main_t *vm, u32 index)
Definition: physmem.c:86
clib_file::description
u8 * description
Definition: file.h:70
snort_deq_node
vlib_node_registration_t snort_deq_node
(constructor) VLIB_REGISTER_NODE (snort_deq_node)
Definition: dequeue.c:354
CLIB_MEM_VM_MAP_FAILED
#define CLIB_MEM_VM_MAP_FAILED
Definition: mem.h:54
snort_qpair_t::enq_ring
volatile u32 * enq_ring
Definition: snort.h:20
snort_qpair_t::enq_fd
int enq_fd
Definition: snort.h:23
vlib_physmem_map_t::log2_page_size
u32 log2_page_size
Definition: physmem.h:52
daq_vpp_msg_qpair_t::enq_ring_offset
uint32_t enq_ring_offset
Definition: daq_vpp.h:46
format_clib_error
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
clib_mem_vm_create_fd
__clib_export int clib_mem_vm_create_fd(clib_mem_page_sz_t log2_page_size, char *fmt,...)
Definition: mem.c:231
DAQ_VPP_MSG_TYPE_HELLO
@ DAQ_VPP_MSG_TYPE_HELLO
Definition: daq_vpp.h:17
snort_main_t::clients
snort_client_t * clients
Definition: snort.h:73
daq_vpp_msg_t::config
daq_vpp_msg_config_t config
Definition: daq_vpp.h:56
round_pow2
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:279
snort_per_thread_data_t::interrupts
void * interrupts
Definition: snort.h:67
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
vlib_physmem_map_t::fd
int fd
Definition: physmem.h:48
clib_memset_u32
static_always_inline void clib_memset_u32(void *p, u32 val, uword count)
Definition: string.h:349
snort_main_t
Definition: snort.h:70
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_physmem_map_t::n_pages
u32 n_pages
Definition: physmem.h:50
daq_vpp_msg_t::type
daq_vpp_msg_type_t type
Definition: daq_vpp.h:52
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
daq_vpp_msg_config_t::num_bpools
uint16_t num_bpools
Definition: daq_vpp.h:31
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
clib_socket_close
static clib_error_t * clib_socket_close(clib_socket_t *sock)
Definition: socket.h:177
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
clib_interrupt_resize
__clib_export void clib_interrupt_resize(void **data, uword n_int)
Definition: interrupt.c:38
clib_file
Definition: file.h:51
daq_vpp_msg_config_t::shm_size
uint32_t shm_size
Definition: daq_vpp.h:30
snort_main_t::instances
snort_instance_t * instances
Definition: snort.h:74
snort_client_msg_queue_elt::fds
int fds[2]
Definition: snort.h:52
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
snort_main_t::listener
clib_socket_t * listener
Definition: snort.h:72
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
daq_vpp_msg_t
Definition: daq_vpp.h:50
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
clib_interrupt_set
static_always_inline void clib_interrupt_set(void *in, int int_num)
Definition: interrupt.h:66
vlib_unix_get_runtime_dir
static char * vlib_unix_get_runtime_dir(void)
Definition: unix.h:151
clib_socket_sendmsg
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
Definition: socket.h:153
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
snort_freelist_init
static void snort_freelist_init(u32 *fl)
Definition: snort.h:107
snort_main_t::per_thread_data
snort_per_thread_data_t * per_thread_data
Definition: snort.h:78
clib_file_set_data_available_to_write
static uword clib_file_set_data_available_to_write(clib_file_main_t *um, u32 clib_file_index, uword is_available)
Definition: file.h:137
VLIB_REGISTER_LOG_CLASS
VLIB_REGISTER_LOG_CLASS(snort_log, static)
snort_qpair_t::deq_fd_file_index
u32 deq_fd_file_index
Definition: snort.h:24
daq_vpp_msg_bpool_t::size
uint32_t size
Definition: daq_vpp.h:37
snort_main_t::instance_by_sw_if_index
u32 * instance_by_sw_if_index
Definition: snort.h:76
snort_qpair_t::enq_head
volatile u32 * enq_head
Definition: snort.h:18
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
daq_vpp_msg_qpair_t::deq_head_offset
uint32_t deq_head_offset
Definition: daq_vpp.h:45
snort_instance_create
clib_error_t * snort_instance_create(vlib_main_t *vm, char *name, u8 log2_queue_sz, u8 drop_on_disconnect)
Definition: main.c:275
snort_client_disconnect
static void snort_client_disconnect(clib_file_t *uf)
Definition: main.c:23
plugin.h
snort_conn_fd_read_ready
static clib_error_t * snort_conn_fd_read_ready(clib_file_t *uf)
Definition: main.c:62
snort_main_t::input_mode
u32 input_mode
Definition: snort.h:79
snort_qpair_t::next_indices
u16 * next_indices
Definition: snort.h:26
snort_client_msg_queue_elt
Definition: snort.h:49
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
snort_client_msg_queue_elt::msg
daq_vpp_msg_t msg
Definition: snort.h:51
vnet_main_t
Definition: vnet.h:76
size
u32 size
Definition: vhost_user.h:125
snort_conn_fd_error
clib_error_t * snort_conn_fd_error(clib_file_t *uf)
Definition: main.c:185
index
u32 index
Definition: flow_types.api:221
vlib_buffer_main_t::buffer_pools
vlib_buffer_pool_t * buffer_pools
Definition: buffer.h:486
snort_instance_t
Definition: snort.h:37
u64
unsigned long u64
Definition: types.h:89
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:458
format
description fragment has unexpected format
Definition: map.api:433
snort_qpair_t
Definition: snort.h:13
clib_socket_init
__clib_export clib_error_t * clib_socket_init(clib_socket_t *s)
Definition: socket.c:403
clib_file_del
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
Definition: file.h:109
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
daq_vpp_msg_hello_t::inst_name
char inst_name[DAQ_VPP_INST_NAME_LEN]
Definition: daq_vpp.h:25
daq_vpp_msg_t::qpair
daq_vpp_msg_qpair_t qpair
Definition: daq_vpp.h:58
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
CLIB_MEM_PAGE_SZ_DEFAULT
@ CLIB_MEM_PAGE_SZ_DEFAULT
Definition: mem.h:60
vlib_thread_main_t
Definition: threads.h:243
vlib_node_set_interrupt_pending
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
Definition: node_funcs.h:249
snort_main_t::instance_by_name
uword * instance_by_name
Definition: snort.h:75
clib_fifo_add2
#define clib_fifo_add2(f, p)
Definition: fifo.h:200
CLIB_SOCKET_F_ALLOW_GROUP_WRITE
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
Definition: socket.h:62
si
vnet_sw_interface_t * si
Definition: interface_output.c:418
daq_vpp_msg_qpair_t::log2_queue_size
uint8_t log2_queue_size
Definition: daq_vpp.h:42
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
clib_mem_get_page_size
static_always_inline uword clib_mem_get_page_size(void)
Definition: mem.h:471
snort_qpair_t::deq_ring
volatile u32 * deq_ring
Definition: snort.h:21
vlib_get_main_by_index
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
Definition: global_funcs.h:29
snort_interface_enable_disable
clib_error_t * snort_interface_enable_disable(vlib_main_t *vm, char *instance_name, u32 sw_if_index, int is_enable)
Definition: main.c:403
DAQ_VPP_INST_NAME_LEN
#define DAQ_VPP_INST_NAME_LEN
Definition: daq_vpp.h:12
clib_file_add
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
snort_qpair_t::deq_fd
int deq_fd
Definition: snort.h:23
vnet_feature_enable_disable
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)
Definition: pnat_test_stubs.h:50
VNET_FEATURE_INIT
VNET_FEATURE_INIT(snort_enq, static)
snort_qpair_t::ready
u32 ready
Definition: snort.h:28
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vlib_get_n_threads
static u32 vlib_get_n_threads()
Definition: global_funcs.h:23
DAQ_VPP_DEFAULT_SOCKET_FILE
#define DAQ_VPP_DEFAULT_SOCKET_FILE
Definition: daq_vpp.h:10
daq_vpp_msg_config_t::num_qpairs
uint16_t num_qpairs
Definition: daq_vpp.h:32
log_err
#define log_err(fmt,...)
Definition: main.c:20
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
VNET_FEATURES
#define VNET_FEATURES(...)
Definition: feature.h:470
pool_get_zero
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
Definition: pool.h:258
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
snort_qpair_t::deq_head
volatile u32 * deq_head
Definition: snort.h:19
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vec_terminate_c_string
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1132
i
int i
Definition: flowhash_template.h:376
CLIB_SOCKET_F_PASSCRED
#define CLIB_SOCKET_F_PASSCRED
Definition: socket.h:64
snort_client_t
Definition: snort.h:56
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
snort_main_t::buffer_pool_base_addrs
u8 ** buffer_pool_base_addrs
Definition: snort.h:77
DAQ_VPP_MSG_TYPE_BPOOL
@ DAQ_VPP_MSG_TYPE_BPOOL
Definition: daq_vpp.h:19
clib_file::error_function
clib_file_function_t * error_function
Definition: file.h:67
clib_socket_t
struct _socket_t clib_socket_t
snort_qpair_t::log2_queue_size
u8 log2_queue_size
Definition: snort.h:16
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
clib_fifo_sub2
#define clib_fifo_sub2(f, p)
Definition: fifo.h:232
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
clib_mem_get_last_error
static_always_inline clib_error_t * clib_mem_get_last_error(void)
Definition: mem.h:567
snort_conn_fd_write_ready
static clib_error_t * snort_conn_fd_write_ready(clib_file_t *uf)
Definition: main.c:168
daq_vpp_msg_qpair_t::deq_ring_offset
uint32_t deq_ring_offset
Definition: daq_vpp.h:47
snort_client_msg_queue_elt::n_fds
int n_fds
Definition: snort.h:53
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:256
snort_main
snort_main_t snort_main
Definition: main.c:12
CLIB_SOCKET_F_SEQPACKET
#define CLIB_SOCKET_F_SEQPACKET
Definition: socket.h:63
DAQ_VPP_MSG_TYPE_QPAIR
@ DAQ_VPP_MSG_TYPE_QPAIR
Definition: daq_vpp.h:20
clib_socket_accept
__clib_export clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
Definition: socket.c:593
DAQ_VPP_MSG_TYPE_CONFIG
@ DAQ_VPP_MSG_TYPE_CONFIG
Definition: daq_vpp.h:18