32 #include <sys/socket.h> 38 #define punt_error(n,s) PUNT_ERROR_##n, 44 #define foreach_punt_next \ 45 _ (PUNT4, "ip4-punt") \ 50 #define _(s,n) PUNT_NEXT_##s, 64 #define punt_next_punt(is_ip4) (is_ip4 ? PUNT_NEXT_PUNT4 : PUNT_NEXT_PUNT6) 81 u32 n_left_from, *from, *to_next;
93 while (n_left_from > 0)
100 while (n_left_from > 0 && n_left_to_next > 0)
124 #define punt_error(n,s) s, 187 .name =
"ip4-udp-punt",
189 .vector_size =
sizeof (
u32),
196 #define _(s,n) [PUNT_NEXT_##s] = n, 203 .name =
"ip6-udp-punt",
205 .vector_size =
sizeof (
u32),
212 #define _(s,n) [PUNT_NEXT_##s] = n, 262 for (i = 0; i < n_packets; i++)
272 if (PUNT_TYPE_L4 == pt)
297 else if (PUNT_TYPE_IP_PROTO == pt)
315 else if (PUNT_TYPE_EXCEPTION == pt)
325 PUNT_ERROR_SOCKET_TX_ERROR, 1);
329 struct sockaddr_un *caddr = &c->
caddr;
338 iov->iov_base = &packetdesc;
339 iov->iov_len =
sizeof (packetdesc);
376 while (b->
flags & VLIB_BUFFER_NEXT_PRESENT);
379 struct msghdr msg = {
381 .msg_namelen =
sizeof (*caddr),
386 if (sendmsg (pm->
socket_fd, &msg, 0) < (ssize_t) l)
388 PUNT_ERROR_SOCKET_TX_ERROR, 1);
418 PUNT_TYPE_IP_PROTO,
AF_IP4);
426 PUNT_TYPE_IP_PROTO,
AF_IP6);
434 PUNT_TYPE_EXCEPTION,
AF_IP4);
441 .name =
"ip4-udp-punt-socket",
445 .vector_size =
sizeof (
u32),
451 .name =
"ip6-udp-punt-socket",
454 .vector_size =
sizeof (
u32),
460 .name =
"ip4-proto-punt-socket",
464 .vector_size =
sizeof (
u32),
470 .name =
"ip6-proto-punt-socket",
473 .vector_size =
sizeof (
u32),
479 .name =
"exception-punt-socket",
482 .vector_size =
sizeof (
u32),
512 u32 n_left_to_next, next_index;
527 error = PUNT_ERROR_NOBUFFER;
532 io[0].iov_base = &packetdesc;
533 io[0].iov_len =
sizeof (packetdesc);
534 io[1].iov_base = b->
data;
535 io[1].iov_len = buffer_size;
537 size = readv (fd, io, 2);
539 if (size <= (
int) (
sizeof (packetdesc) +
sizeof (
ip4_header_t)))
542 error = PUNT_ERROR_READV;
546 b->
flags = VNET_BUFFER_F_LOCALLY_ORIGINATED;
551 switch (packetdesc.
action)
571 error = PUNT_ERROR_ACTION;
623 .name =
"punt-socket-rx",
626 .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 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
description fragment has unexpected format
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.
static __clib_warn_unused_result int vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
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)