|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
34 #include <sys/socket.h>
154 "only UDP protocol (%d) is supported, got %d",
168 memcpy (
c->caddr.sun_path, client_pathname, sizeof (
c->caddr.sun_path));
169 c->caddr.sun_family = AF_UNIX;
170 c->reg.type = PUNT_TYPE_L4;
171 c->reg.punt.l4.port =
port;
173 c->reg.punt.l4.af =
af;
200 memcpy (
c->caddr.sun_path, client_pathname, sizeof (
c->caddr.sun_path));
201 c->caddr.sun_family = AF_UNIX;
202 c->reg.type = PUNT_TYPE_IP_PROTO;
203 c->reg.punt.ip_proto.protocol =
proto;
204 c->reg.punt.ip_proto.af =
af;
217 char *client_pathname)
230 memcpy (pc->
caddr.sun_path, client_pathname, sizeof (pc->
caddr.sun_path));
231 pc->
caddr.sun_family = AF_UNIX;
232 pc->
reg.
type = PUNT_TYPE_EXCEPTION;
303 "Punt socket: Invalid client path: %s",
314 case PUNT_TYPE_IP_PROTO:
319 case PUNT_TYPE_EXCEPTION:
342 case PUNT_TYPE_IP_PROTO:
345 case PUNT_TYPE_EXCEPTION:
375 "only UDP (%d) and TCP (%d) protocols are supported, got %d",
376 IP_PROTOCOL_UDP, IP_PROTOCOL_TCP,
protocol);
382 else if (
protocol == IP_PROTOCOL_TCP)
421 const char *node_name =
422 vnet_punt_reason_flag_is_IP6_PACKET (flag) ?
"ip6-punt" :
"ip4-punt";
431 "Punting registration not found...");
442 case PUNT_TYPE_EXCEPTION:
444 case PUNT_TYPE_IP_PROTO:
464 .protocol = IP_PROTOCOL_UDP,
467 .type = PUNT_TYPE_L4,
481 pr.
type = PUNT_TYPE_EXCEPTION;
539 .short_help =
"set punt [IPV4|ip6|ipv6] [UDP|tcp] [del] [ALL|<port-num>]",
558 .protocol = IP_PROTOCOL_UDP,
561 .type = PUNT_TYPE_L4,
582 else if (
unformat (input,
"socket %s", &socket_name))
586 pr.
type = PUNT_TYPE_EXCEPTION;
614 .path =
"punt socket register",
616 .short_help =
"punt socket register [IPV4|ipv6] [UDP|tcp] [ALL|<port-num>] socket <socket>",
634 .protocol = IP_PROTOCOL_UDP,
637 .type = PUNT_TYPE_L4,
660 pr.
type = PUNT_TYPE_EXCEPTION;
683 .path =
"punt socket deregister",
685 .short_help =
"punt socket deregister [IPV4|ipv6] [UDP|tcp] [ALL|<port-num>]",
704 cb (pool_elt_at_index(pm->punt_client_pool, pci), ctx);
709 case PUNT_TYPE_IP_PROTO:
716 cb (pool_elt_at_index(pm->punt_client_pool, pci), ctx);
721 case PUNT_TYPE_EXCEPTION:
746 s =
format (s,
"%U %U port %d",
751 case PUNT_TYPE_IP_PROTO:
756 case PUNT_TYPE_EXCEPTION:
762 s =
format (s,
" to socket %s \n", pc->
caddr.sun_path);
791 pt = PUNT_TYPE_EXCEPTION;
795 pt = PUNT_TYPE_IP_PROTO;
819 .path =
"show punt socket registrations",
821 .short_help =
"show punt socket registrations [l4|exception]",
852 #define _(pos, len, value, name, str) \
853 if (vnet_punt_reason_flag_is_##name (flag)) \
854 s = format (s, "%s ", str);
867 char *socket_path = 0;
871 if (
unformat (input,
"socket %s", &socket_path))
872 strncpy (pm->
sun_path, socket_path, UNIX_PATH_MAX - 1);
878 if (socket_path == 0)
882 struct sockaddr_un
addr;
883 if ((pm->
socket_fd = socket (AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0)) == -1)
889 addr.sun_family = AF_UNIX;
890 if (*socket_path ==
'\0')
892 *
addr.sun_path =
'\0';
893 strncpy (
addr.sun_path + 1, socket_path + 1,
894 sizeof (
addr.sun_path) - 2);
898 strncpy (
addr.sun_path, socket_path, sizeof (
addr.sun_path) - 1);
899 unlink (socket_path);
920 template.file_descriptor = pm->
socket_fd;
921 template.description =
format (0,
"punt socket %s", socket_path);
static clib_error_t * punt_socket_register_ip_proto(vlib_main_t *vm, ip_address_family_t af, ip_protocol_t proto, char *client_pathname)
enum vlib_punt_reason_t_ vlib_punt_reason_t
The 'syatem' defined punt reasons.
void udp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
void ip4_unregister_protocol(u32 protocolx)
clib_file_main_t file_main
#define hash_set(h, key, value)
static vlib_cli_command_t punt_command
(constructor) VLIB_CLI_COMMAND (punt_command)
static clib_error_t * punt_exception_add_del(vlib_punt_reason_t reason, bool is_add)
Request exception traffic punt.
vlib_node_registration_t udp4_punt_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_node)
u8 * format_vnet_punt_reason_flags(u8 *s, va_list *args)
static clib_error_t * punt_socket_unregister_exception(vlib_punt_reason_t reason)
A registration, by a client, to direct punted traffic to a given node.
static vlib_cli_command_t punt_socket_register_command
(constructor) VLIB_CLI_COMMAND (punt_socket_register_command)
punt_client_t * punt_client_pool
static u32 punt_client_ip_proto_db_remove(ip_address_family_t af, ip_protocol_t proto)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_node_t * interface_output_node
#define clib_error_return(e, args...)
clib_file_function_t * read_function
static void punt_client_exception_db_add(vlib_punt_reason_t reason, u32 pci)
#define hash_foreach(key_var, value_var, h, body)
static clib_error_t * punt_socket_register_exception(vlib_main_t *vm, vlib_punt_reason_t reason, char *client_pathname)
#define vlib_call_init_function(vm, x)
static clib_error_t * punt_init(vlib_main_t *vm)
static_always_inline punt_client_t * punt_client_exception_get(vlib_punt_reason_t reason)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static clib_error_t * punt_socket_unregister_ip_proto(ip_address_family_t af, ip_protocol_t proto)
void * clients_by_ip_proto
void ip4_register_protocol(u32 protocol, u32 node_index)
u32 vlib_punt_reason_get_flags(vlib_punt_reason_t pr)
int vlib_punt_register(vlib_punt_hdl_t client, vlib_punt_reason_t reason, const char *node_name)
Register a node to receive particular punted buffers.
static u32 punt_client_l4_db_remove(ip_address_family_t af, u16 port)
#define clib_error_report(e)
static clib_error_t * punt_socket_register_l4(vlib_main_t *vm, ip_address_family_t af, u8 protocol, u16 port, char *client_pathname)
static_always_inline u32 punt_client_l4_mk_key(ip_address_family_t af, u16 port)
char * vnet_punt_get_server_pathname(void)
#define pool_put_index(p, i)
Free pool element with given index.
clib_error_t * ip_punt_init(vlib_main_t *vm)
static_always_inline punt_client_t * punt_client_ip_proto_get(ip_address_family_t af, ip_protocol_t proto)
u32 * clients_by_exception
#define hash_unset(h, key)
static void punt_client_l4_db_add(ip_address_family_t af, u16 port, u32 index)
static vlib_cli_command_t show_punt_socket_registration_command
(constructor) VLIB_CLI_COMMAND (show_punt_socket_registration_command)
#define VLIB_CONFIG_FUNCTION(x, n,...)
static_always_inline punt_client_t * punt_client_l4_get(ip_address_family_t af, u16 port)
u8 * format_vlib_punt_reason(u8 *s, va_list *args)
Format a punt reason.
static clib_error_t * punt_config(vlib_main_t *vm, unformat_input_t *input)
static u8 * format_punt_client(u8 *s, va_list *args)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u8 * format_ip_address_family(u8 *s, va_list *args)
static clib_error_t * punt_socket_read_ready(clib_file_t *uf)
punt_exception_t exception
static u32 punt_client_exception_db_remove(vlib_punt_reason_t reason)
void * clients_by_l4_port
vlib_node_registration_t udp4_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_socket_node)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
walk_rc_t(* punt_client_walk_cb_t)(const punt_client_t *pc, void *ctx)
void punt_client_walk(punt_type_t pt, punt_client_walk_cb_t cb, void *ctx)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
clib_error_t * vnet_punt_socket_del(vlib_main_t *vm, const punt_reg_t *pr)
int vlib_punt_unregister(vlib_punt_hdl_t client, vlib_punt_reason_t reason, const char *node_name)
#define VLIB_CLI_COMMAND(x,...)
void tcp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
@ foreach_vnet_punt_reason_flag
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_node_registration_t punt_socket_rx_node
(constructor) VLIB_REGISTER_NODE (punt_socket_rx_node)
static_always_inline u32 punt_client_ip_proto_mk_key(ip_address_family_t af, ip_protocol_t proto)
static clib_error_t * punt_socket_unregister_l4(ip_address_family_t af, ip_protocol_t protocol, u16 port)
static clib_error_t * punt_socket_deregister_cmd(vlib_main_t *vm, unformat_input_t *input__, vlib_cli_command_t *cmd)
static void punt_client_ip_proto_db_add(ip_address_family_t af, ip_protocol_t proto, u32 index)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definitions for punt infrastructure.
clib_error_t * vnet_punt_add_del(vlib_main_t *vm, const punt_reg_t *pr, bool is_add)
uword unformat_punt_reason(unformat_input_t *input, va_list *args)
Unformat a punt reason.
description fragment has unexpected format
void ip6_unregister_protocol(u32 protocol)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
static clib_error_t * punt_l4_add_del(vlib_main_t *vm, ip_address_family_t af, ip_protocol_t protocol, u16 port, bool is_add)
Request IP L4 traffic punt to the local TCP/IP stack.
#define VLIB_INIT_FUNCTION(x)
vl_api_address_family_t af
vl_api_ip_proto_t protocol
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
static clib_error_t * punt_cli(vlib_main_t *vm, unformat_input_t *input__, vlib_cli_command_t *cmd)
char sun_path[sizeof(struct sockaddr_un)]
vlib_node_registration_t ip6_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip6_proto_punt_socket_node)
vlib_node_registration_t udp6_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_socket_node)
#define vec_foreach(var, vec)
Vector iterator.
#define PUNT_PACKETDESC_VERSION
vlib_punt_reason_t reason
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
enum punt_type_t_ punt_type_t
static clib_error_t * punt_socket_register_cmd(vlib_main_t *vm, unformat_input_t *input__, vlib_cli_command_t *cmd)
enum ip_protocol ip_protocol_t
clib_error_t * vnet_punt_socket_add(vlib_main_t *vm, u32 header_version, const punt_reg_t *pr, char *client_pathname)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vlib_main_t * vlib_get_main(void)
#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)
void ip6_register_protocol(u32 protocol, u32 node_index)
punt_thread_data_t * thread_data
static walk_rc_t punt_client_show_one(const punt_client_t *pc, void *ctx)
vlib_punt_hdl_t vlib_punt_client_register(const char *who)
Register a new clinet.
enum vnet_punt_reason_flag_t_ vnet_punt_reason_flag_t
static vlib_thread_main_t * vlib_get_thread_main()
static vlib_cli_command_t punt_socket_deregister_command
(constructor) VLIB_CLI_COMMAND (punt_socket_deregister_command)
enum walk_rc_t_ walk_rc_t
Walk return code.
static clib_error_t * punt_socket_show_cmd(vlib_main_t *vm, unformat_input_t *input__, vlib_cli_command_t *cmd)
vlib_node_registration_t ip4_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip4_proto_punt_socket_node)
enum ip_address_family_t_ ip_address_family_t