X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fpunt.c;h=d8c7d81a23a9fb475d4e66461d237a72c70b88da;hb=609e1210c6339376dd6cdd0f79195b436d5614d2;hp=568350cda82ea817103c5458f6a1cb2bc1078a28;hpb=1b708845633f7ddb816f81aed82f55fd9522fbcf;p=vpp.git diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c index 568350cda82..d8c7d81a23a 100644 --- a/src/vnet/ip/punt.c +++ b/src/vnet/ip/punt.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,8 @@ #include #define foreach_punt_next \ - _ (PUNT, "error-punt") + _ (PUNT4, "ip4-punt") \ + _ (PUNT6, "ip6-punt") typedef enum { @@ -58,6 +60,8 @@ enum punt_socket_rx_next_e PUNT_SOCKET_RX_N_NEXT }; +#define punt_next_punt(is_ip4) (is_ip4 ? PUNT_NEXT_PUNT4 : PUNT_NEXT_PUNT6) + vlib_node_registration_t udp4_punt_node; vlib_node_registration_t udp6_punt_node; vlib_node_registration_t udp4_punt_socket_node; @@ -104,7 +108,8 @@ udp46_punt_inline (vlib_main_t * vm, { u32 n_left_to_next; - vlib_get_next_frame (vm, node, PUNT_NEXT_PUNT, to_next, n_left_to_next); + vlib_get_next_frame (vm, node, punt_next_punt (is_ip4), to_next, + n_left_to_next); while (n_left_from > 0 && n_left_to_next > 0) { @@ -123,7 +128,7 @@ udp46_punt_inline (vlib_main_t * vm, b0->error = node->errors[PUNT_ERROR_UDP_PORT]; } - vlib_put_next_frame (vm, node, PUNT_NEXT_PUNT, n_left_to_next); + vlib_put_next_frame (vm, node, punt_next_punt (is_ip4), n_left_to_next); } return from_frame->n_vectors; @@ -265,7 +270,7 @@ punt_socket_register (bool is_ip4, u8 protocol, u16 port, punt_client_t *v = is_ip4 ? pm->clients_by_dst_port4 : pm->clients_by_dst_port6; - memset (&c, 0, sizeof (c)); + clib_memset (&c, 0, sizeof (c)); memcpy (c.caddr.sun_path, client_pathname, sizeof (c.caddr.sun_path)); c.caddr.sun_family = AF_UNIX; c.port = port; @@ -307,7 +312,7 @@ udp46_punt_socket_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, bool is_ip4) { - u32 *buffers = vlib_frame_args (frame); + u32 *buffers = vlib_frame_vector_args (frame); uword n_packets = frame->n_vectors; struct iovec *iovecs = 0; punt_main_t *pm = &punt_main; @@ -363,7 +368,7 @@ udp46_punt_socket_inline (vlib_main_t * vm, c = punt_client_get (is_ip4, port); udp_punt_trace_t *t; t = vlib_add_trace (vm, node, b, sizeof (t[0])); - clib_memcpy (&t->client, c, sizeof (t->client)); + clib_memcpy_fast (&t->client, c, sizeof (t->client)); } /* Re-set iovecs if present. */ @@ -396,7 +401,7 @@ udp46_punt_socket_inline (vlib_main_t * vm, } udp_punt_trace_t *t; t = vlib_add_trace (vm, node, b, sizeof (t[0])); - clib_memcpy (&t->client, c, sizeof (t->client)); + clib_memcpy_fast (&t->client, c, sizeof (t->client)); t->is_midchain = 1; } @@ -685,11 +690,13 @@ vnet_punt_add_del (vlib_main_t * vm, u8 ipv, u8 protocol, u16 port, bool is_add) { - /* For now we only support UDP punt */ - if (protocol != IP_PROTOCOL_UDP && protocol != IP_PROTOCOL_TCP) + /* For now we only support TCP, UDP and SCTP punt */ + if (protocol != IP_PROTOCOL_UDP && + protocol != IP_PROTOCOL_TCP && protocol != IP_PROTOCOL_SCTP) return clib_error_return (0, - "only UDP (%d) and TCP (%d) protocols are supported, got %d", - IP_PROTOCOL_UDP, IP_PROTOCOL_TCP, protocol); + "only UDP (%d), TCP (%d) and SCTP (%d) protocols are supported, got %d", + IP_PROTOCOL_UDP, IP_PROTOCOL_TCP, + IP_PROTOCOL_SCTP, protocol); if (ipv != (u8) ~ 0 && ipv != 4 && ipv != 6) return clib_error_return (0, "IP version must be 4 or 6, got %d", ipv); @@ -702,6 +709,8 @@ vnet_punt_add_del (vlib_main_t * vm, u8 ipv, u8 protocol, u16 port, udp_punt_unknown (vm, 1, is_add); else if (protocol == IP_PROTOCOL_TCP) tcp_punt_unknown (vm, 1, is_add); + else if (protocol == IP_PROTOCOL_SCTP) + sctp_punt_unknown (vm, 1, is_add); } if ((ipv == 6) || (ipv == (u8) ~ 0)) @@ -710,6 +719,8 @@ vnet_punt_add_del (vlib_main_t * vm, u8 ipv, u8 protocol, u16 port, udp_punt_unknown (vm, 0, is_add); else if (protocol == IP_PROTOCOL_TCP) tcp_punt_unknown (vm, 0, is_add); + else if (protocol == IP_PROTOCOL_SCTP) + sctp_punt_unknown (vm, 0, is_add); } return 0; @@ -717,8 +728,9 @@ vnet_punt_add_del (vlib_main_t * vm, u8 ipv, u8 protocol, u16 port, else if (is_add) { - if (protocol == IP_PROTOCOL_TCP) - return clib_error_return (0, "punt TCP ports is not supported yet"); + if (protocol == IP_PROTOCOL_TCP || protocol == IP_PROTOCOL_SCTP) + return clib_error_return (0, + "punt TCP/SCTP ports is not supported yet"); if (ipv == 4 || ipv == (u8) ~ 0) udp_register_dst_port (vm, port, udp4_punt_node.index, 1); @@ -854,7 +866,7 @@ punt_config (vlib_main_t * vm, unformat_input_t * input) return clib_error_return (0, "socket error"); } - memset (&addr, 0, sizeof (addr)); + clib_memset (&addr, 0, sizeof (addr)); addr.sun_family = AF_UNIX; if (*socket_path == '\0') { @@ -878,6 +890,7 @@ punt_config (vlib_main_t * vm, unformat_input_t * input) clib_file_t template = { 0 }; template.read_function = punt_socket_read_ready; template.file_descriptor = pm->socket_fd; + template.description = format (0, "%s", socket_path); pm->clib_file_index = clib_file_add (fm, &template); pm->is_configured = true;