35 #include <sys/socket.h> 41 #define punt_error(n,s) PUNT_ERROR_##n, 47 #define foreach_punt_next \ 48 _ (PUNT4, "ip4-punt") \ 53 #define _(s,n) PUNT_NEXT_##s, 67 #define punt_next_punt(is_ip4) (is_ip4 ? PUNT_NEXT_PUNT4 : PUNT_NEXT_PUNT6) 84 u32 n_left_from, *from, *to_next;
96 while (n_left_from > 0)
103 while (n_left_from > 0 && n_left_to_next > 0)
127 #define punt_error(n,s) s, 190 .name =
"ip4-udp-punt",
192 .vector_size =
sizeof (
u32),
199 #define _(s,n) [PUNT_NEXT_##s] = n, 206 .name =
"ip6-udp-punt",
208 .vector_size =
sizeof (
u32),
215 #define _(s,n) [PUNT_NEXT_##s] = n, 265 for (i = 0; i < n_packets; i++)
275 if (PUNT_TYPE_L4 == pt)
300 else if (PUNT_TYPE_IP_PROTO == pt)
318 else if (PUNT_TYPE_EXCEPTION == pt)
328 PUNT_ERROR_SOCKET_TX_ERROR, 1);
332 struct sockaddr_un *caddr = &c->
caddr;
341 iov->iov_base = &packetdesc;
342 iov->iov_len =
sizeof (packetdesc);
379 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT);
382 struct msghdr msg = {
384 .msg_namelen =
sizeof (*caddr),
389 if (sendmsg (pm->
socket_fd, &msg, 0) < (ssize_t) l)
391 PUNT_ERROR_SOCKET_TX_ERROR, 1);
421 PUNT_TYPE_IP_PROTO,
AF_IP4);
429 PUNT_TYPE_IP_PROTO,
AF_IP6);
437 PUNT_TYPE_EXCEPTION,
AF_IP4);
444 .name =
"ip4-udp-punt-socket",
448 .vector_size =
sizeof (
u32),
454 .name =
"ip6-udp-punt-socket",
457 .vector_size =
sizeof (
u32),
463 .name =
"ip4-proto-punt-socket",
467 .vector_size =
sizeof (
u32),
473 .name =
"ip6-proto-punt-socket",
476 .vector_size =
sizeof (
u32),
482 .name =
"exception-punt-socket",
485 .vector_size =
sizeof (
u32),
515 u32 n_left_to_next, next_index;
517 u32 error = PUNT_ERROR_NONE;
530 error = PUNT_ERROR_NOBUFFER;
535 io[0].iov_base = &packetdesc;
536 io[0].iov_len =
sizeof (packetdesc);
537 io[1].iov_base = b->
data;
538 io[1].iov_len = buffer_size;
540 size = readv (fd, io, 2);
542 if (size <= (
int) (
sizeof (packetdesc) +
sizeof (
ip4_header_t)))
545 error = PUNT_ERROR_READV;
549 b->
flags = VNET_BUFFER_F_LOCALLY_ORIGINATED;
554 switch (packetdesc.
action)
574 error = PUNT_ERROR_ACTION;
624 .name =
"punt-socket-rx",
627 .state = VLIB_NODE_STATE_INTERRUPT,
vlib_node_registration_t udp6_punt_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_node)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
enum punt_type_t_ punt_type_t
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
static uword punt_socket_rx_fd(vlib_main_t *vm, vlib_node_runtime_t *node, u32 fd)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
#define punt_next_punt(is_ip4)
vnet_main_t * vnet_get_main(void)
vlib_node_registration_t udp4_punt_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_node)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define clib_memcpy_fast(a, b, c)
#define VLIB_NODE_FLAG_TRACE_SUPPORTED
static uword udp46_punt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip4)
IPv4/IPv6 UDP punt node main loop.
u16 current_length
Nbytes between current data and the end of this buffer.
vlib_node_registration_t ip4_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip4_proto_punt_socket_node)
static_always_inline punt_client_t * punt_client_l4_get(ip_address_family_t af, u16 port)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static_always_inline punt_client_t * punt_client_ip_proto_get(ip_address_family_t af, ip_protocol_t proto)
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
static uword punt_socket_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, punt_type_t pt, ip_address_family_t af)
format_function_t format_vnet_sw_if_index_name
enum punt_action_e action
punt_thread_data_t * thread_data
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
static uword ip4_proto_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static char * punt_error_strings[]
struct punt_trace_t_ punt_trace_t
static_always_inline punt_client_t * punt_client_exception_get(vlib_punt_reason_t reason)
static u8 * format_punt_trace(u8 *s, va_list *va)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
enum ip_protocol ip_protocol_t
vlib_node_registration_t punt_socket_rx_node
(constructor) VLIB_REGISTER_NODE (punt_socket_rx_node)
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
vlib_node_registration_t ip6_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip6_proto_punt_socket_node)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define vec_del1(v, i)
Delete the element at index I.
static u8 * format_udp_punt_trace(u8 *s, va_list *args)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
#define foreach_punt_next
sll srl srl sll sra u16x4 i
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_node_registration_t udp6_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_socket_node)
enum punt_action_e action
vlib_main_t vlib_node_runtime_t * node
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static uword udp4_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static uword ip6_proto_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
enum ip_address_family_t_ ip_address_family_t
vlib_node_registration_t exception_punt_socket_node
(constructor) VLIB_REGISTER_NODE (exception_punt_socket_node)
vl_api_mac_event_action_t action
static uword exception_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define VLIB_NODE_FLAG_IS_DROP
static uword punt_socket_rx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vlib_node_registration_t udp4_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_socket_node)
Definitions for punt infrastructure.
static uword udp6_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)