summaryrefslogtreecommitdiffstats
BranchCommit messageAuthorAge
mastervppapigen: fix f-string in crccheckerOle Troan2 days
stable/2410build: fix dpdk mellanox driver build settingDave Wallace6 days
stable/2406prom: test_prom fixMatus Fabian3 months
stable/2402build: update octeon-roc checksum to updated versionDave Wallace3 months
stable/2310sr: use correct reply to sr_policy_add_v2Vratko Polak6 months
stable/2306vpp-swan: fix configuration of policiesGabriel Oginski13 months
stable/2302vlib: reset stop_timer_handle on expired processesMatthew Smith13 months
stable/2210nat: fix nat44 vrf handlersDaniel Béreš19 months
stable/2206misc: VPP 22.06.1 Release NotesDave Wallace21 months
stable/2106ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/2101ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/2009ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/2005ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/2001ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/1904ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/1908ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/2110ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/2202ipsec: fix AES CBC IV generation (CVE-2022-46397)Benoît Ganne21 months
stable/1901vlib: address vlib_error_t scaling issueSteven Luong5 years
stable/1807Clean up multi-thread barrier-sync hold-down timerDave Barach5 years
stable/1810mp_safe SW_INTERFACE_DUMP, SW_INTERFACE_DETAILS, SW_INTERFACE_TAG_ADD_DEL,Steven Luong5 years
stable/1804fix packets redirect ineffective on af-packet interfacechenxiang6 years
stable/1801fix issue with missing sample_main in sample pluginDamjan Marion6 years
stable/1710l2-flood: fix restore vnet buffer's flags in the replication routineSteve Shin7 years
stable/1707Add replicate DPO header to export list for VPPSBNeale Ranns7 years
stable/1704VPP debug image with worker threads hit assert on adding IP route with traffi...Neale Ranns7 years
stable/1701Fix pretty-printing in "api trace custom-dump" (VPP-683)Andrew Yourtchenko7 years
stable/1609Vhost: Add thread sync while receiving vhost messagePierre Pfister8 years
stable/1606Fix generate-deb-changelog to handle YY.MM releaseEd Warnicke8 years
stable/testWhitespace probe for CIEd Warnicke8 years
 
TagDownloadAuthorAge
v24.10-rc2commit 466b350538...Andrew Yourtchenko12 days
v24.10-rc1commit b91e15387d...Andrew Yourtchenko5 weeks
v25.02-rc0commit 8f989630b0...Andrew Yourtchenko5 weeks
v24.06commit 6e8b350a01...Andrew Yourtchenko4 months
v24.06-rc2commit 55457075d9...Andrew Yourtchenko5 months
v24.06-rc1commit b3304b2b76...Andrew Yourtchenko5 months
v24.10-rc0commit 71e0902454...Andrew Yourtchenko5 months
v24.02commit 455960759b...Andrew Yourtchenko8 months
v24.02-rc2commit 8cbf84dce0...Andrew Yourtchenko8 months
v24.02-rc1commit 3a56e86a73...Andrew Yourtchenko9 months
v24.06-rc0commit 6fb2b3dc72...Andrew Yourtchenko9 months
v23.10commit 7c4027fa5e...Andrew Yourtchenko12 months
v23.10-rc2commit 015a6f7f17...Andrew Yourtchenko13 months
v23.10-rc1commit 14df6fc1ea...Andrew Yourtchenko13 months
v24.02-rc0commit 7419bede7a...Andrew Yourtchenko13 months
v23.06commit 493b8990d1...Andrew Yourtchenko16 months
v23.06-rc2commit 5e6bc730ef...Andrew Yourtchenko16 months
v23.06-rc1commit b60a6477eb...Andrew Yourtchenko17 months
v23.10-rc0commit a7dd04d73b...Andrew Yourtchenko17 months
v23.02commit 5516fc0f3b...Andrew Yourtchenko20 months
v22.10.1commit 57302fe52f...Dave Wallace21 months
v22.06.1commit 1513b381d8...Dave Wallace21 months
v23.02-rc2commit be1b844214...Andrew Yourtchenko21 months
v23.02-rc1commit 42b5a8767c...Andrew Yourtchenko21 months
v23.06-rc0commit 2ebb95228f...Andrew Yourtchenko21 months
v22.10commit 07e0c05e69...Andrew Yourtchenko2 years
v22.10-rc2commit 61bae8a54d...Andrew Yourtchenko2 years
v22.10-rc1commit f845abb5dd...Andrew Yourtchenko2 years
v23.02-rc0commit a2a7a4031b...Andrew Yourtchenko2 years
v22.06commit 0d352a97c5...Andrew Yourtchenko2 years
v22.06-rc2commit ea4bcec987...Andrew Yourtchenko2 years
v22.06-rc1commit 211fa4748c...Andrew Yourtchenko2 years
v22.10-rc0commit e0301eeb7b...Andrew Yourtchenko2 years
v22.02commit 7911f29c51...Andrew Yourtchenko3 years
v22.02-rc2commit 9d2db2eb2e...Andrew Yourtchenko3 years
v22.02-rc1commit 93e5bea2d3...Andrew Yourtchenko3 years
v22.06-rc0commit 017a676654...Andrew Yourtchenko3 years
v21.10.1commit 0385458a56...Andrew Yourtchenko3 years
v21.10commit 0e0384cde9...Andrew Yourtchenko3 years
v21.10-rc2commit c1931b2f09...Andrew Yourtchenko3 years
v21.10-rc1commit fd9d936b3c...Andrew Yourtchenko3 years
v22.02-rc0commit 192c55f2e7...Andrew Yourtchenko3 years
v21.01.1commit 54f8aff02a...Andrew Yourtchenko3 years
v21.06commit fc83f8cc67...Andrew Yourtchenko3 years
v21.06-rc2commit 8b297dbceb...Andrew Yourtchenko3 years
v21.06-rc1commit e82d59f381...Andrew Yourtchenko3 years
v21.10-rc0commit 91d6a94845...Andrew Yourtchenko3 years
v21.01commit 3d2d96e554...Andrew Yourtchenko4 years
v21.01-rc2commit 15db851d93...Andrew Yourtchenko4 years
v21.01-rc1commit 9dab7b9416...Andrew Yourtchenko4 years
v21.06-rc0commit 7742d5b355...Andrew Yourtchenko4 years
v20.09commit 072def4738...Andrew Yourtchenko4 years
v20.09-rc2commit a87deb77da...Andrew Yourtchenko4 years
v20.09-rc1commit fb6d768419...Andrew Yourtchenko4 years
v21.01-rc0commit 0b31630ce7...Andrew Yourtchenko4 years
v19.08.3commit 37e99c22df...Andrew Yourtchenko4 years
v20.05.1commit b1500e9fff...Andrew Yourtchenko4 years
v20.05commit ab572152d9...Andrew Yourtchenko4 years
v20.05-rc2commit 63f9e7cc0e...Andrew Yourtchenko4 years
v20.05-rc1commit b8e9009400...Andrew Yourtchenko4 years
v20.09-rc0commit b163bbb748...Andrew Yourtchenko4 years
v19.08.2commit ec9ce338f0...Andrew Yourtchenko4 years
v20.01commit fce396738f...Andrew Yourtchenko5 years
v20.01-rc2commit 29acfa2ad5...Andrew Yourtchenko5 years
v20.01-rc1commit c7fe31cfff...Andrew Yourtchenko5 years
v20.05-rc0commit 8ad070e102...Andrew Yourtchenko5 years
v19.04.4-rc0commit dfec10d137...Dave Wallace5 years
v19.04.3commit bdb89b9897...Dave Wallace5 years
v19.08.1commit f4dcae4164...Andrew Yourtchenko5 years
v19.08commit 1c586de48c...Andrew Yourtchenko5 years
v19.08-rc2commit 2f51729bb3...Andrew Yourtchenko5 years
v19.08-rc1commit 23526f78a8...Andrew Yourtchenko5 years
v20.01-rc0commit e41fd65381...Andrew Yourtchenko5 years
v19.04.2commit d95a226047...Dave Wallace5 years
v19.01.3commit bef25c30a1...Andrew Yourtchenko5 years
v19.04.2-rc0commit e4a0f9fdc0...Dave Wallace5 years
v19.01.3-rc0commit 6af8243814...Dave Wallace5 years
v19.04.1commit 1662c9cd23...Dave Wallace5 years
v19.01.2commit fa63602fcb...Andrew Yourtchenko5 years
v19.01.2-rc0commit 67a3e2d130...Dave Wallace5 years
v19.04.1-rc0commit 873b9ed405...Dave Wallace5 years
v19.04commit 3d18a191aa...Dave Wallace6 years
v19.04-rc2commit 0d7332e43f...Dave Wallace6 years
v19.08-rc0commit 40fd1f3dfd...Dave Wallace6 years
v19.04-rc1commit e29b8228a2...Dave Wallace6 years
v19.01.1commit cbd68cb711...Dave Wallace6 years
v19.01commit 67d9475ae3...Andrew Yourtchenko6 years
v19.01-rc2commit 0cb68778ec...Andrew Yourtchenko6 years
v19.01-rc1commit 3e2bc759f4...Damjan Marion6 years
v19.04-rc0commit ef080e1f9b...Andrew Yourtchenko6 years
v18.10commit 3a9a6f72d1...Marco Varlese6 years
v18.10-rc2commit b3aff922ff...Marco Varlese6 years
v19.01-rc0commit 4f611176e9...Marco Varlese6 years
v18.10-rc1commit 90395743d3...Marco Varlese6 years
v18.07.1commit 55fbdb9941...Ed Warnicke6 years
v18.07commit db6d6b3058...Ed Warnicke6 years
v18.07-rc2commit c16a23c596...Ed Warnicke6 years
v18.10-rc0commit 0e6f4d6af4...Ed Warnicke6 years
v18.07-rc0commit 3e21eba4d2...Ed Warnicke6 years
v18.07-rc1commit e400a6d1a5...Ed Warnicke6 years
v18.01.2commit 540b31ac8f...Dave Wallace6 years
v18.04commit ac2b7363f4...Chris Luke7 years
v18.04-rc2commit 18744ee680...Chris Luke7 years
v18.04-rc1commit 7ace56b9d8...Chris Luke7 years
v18.01.1commit f13bac295d...Dave Wallace7 years
v18.01commit 9d21268d0a...Dave Wallace7 years
v18.01-rc2commit bbdfeaebf2...Dave Wallace7 years
v18.01-rc1commit 8c2bacde4f...Dave Wallace7 years
v18.04-rc0commit a3a6ec63d3...Dave Wallace7 years
v17.10commit 116af2170e...Florin Coras7 years
v17.10-rc2commit cf6c343710...Florin Coras7 years
v18.01-rc0commit 75a17ecddc...Florin Coras7 years
v17.10-rc1commit 7ea28045aa...Florin Coras7 years
v17.07.01commit 839fa732c1...Neale Ranns7 years
v17.07commit f4f635e7c0...Neale Ranns7 years
v17.07-rc2commit 01d2b4b13a...Neale Ranns7 years
v17.10-rc0commit cdc74273df...Neale Ranns7 years
v17.07-rc1commit ea89b8cf66...Neale Ranns7 years
v17.04.2commit fc69a97116...Ole Troan7 years
v17.04.1commit 7d68ec6134...Ole Troan7 years
v17.04commit 511ee63cbb...Ole Troan8 years
v17.04-rc2commit 92bcecfdcc...Ole Troan8 years
v17.07-rc0commit 87edd671d7...Ole Troan8 years
v17.04-rc1commit cb92fc6edc...Ole Troan8 years
v17.01.1commit 8099e90346...Damjan Marion8 years
v17.01commit cd111b2228...Damjan Marion8 years
v17.01-rc2commit 235c64f067...Damjan Marion8 years
v17.04-rc0commit 2e70d8b31d...Damjan Marion8 years
v17.01-rc1commit 436b319354...Damjan Marion8 years
v17.01-rc0commit 931be3aca2...Ed Warnicke8 years
v16.09commit 21bc8624f5...Keith Burns (alagalah)8 years
v16.09-rc2commit 08377f8ff7...Keith Burns (alagalah)8 years
v16.12-rc0commit 694265d4f1...Dave Barach8 years
v16.09-rc1commit dbc6e3f0bb...Dave Barach8 years
v16.06commit 693f4358de...Ed Warnicke8 years
v16.06-rc3commit cf6511560e...Dave Barach8 years
v16.06-rc2commit b98a3a87a9...Dave Barach8 years
v16.09-rc0commit 862623da6e...Ed Warnicke8 years
v16.06-rc1commit 826d4f7b1f...Ed Warnicke8 years
v1.0.0commit cb9cadad57...Ed Warnicke9 years
/span> /* *INDENT-OFF* */ VLIB_REGISTER_NODE (udp4_punt_socket_node) = { .function = udp4_punt_socket, .name = "ip4-udp-punt-socket", .format_trace = format_udp_punt_trace, .flags = VLIB_NODE_FLAG_IS_DROP, /* Takes a vector of packets. */ .vector_size = sizeof (u32), .n_errors = PUNT_N_ERROR, .error_strings = punt_error_strings, }; VLIB_REGISTER_NODE (udp6_punt_socket_node) = { .function = udp6_punt_socket, .name = "ip6-udp-punt-socket", .format_trace = format_udp_punt_trace, .flags = VLIB_NODE_FLAG_IS_DROP, .vector_size = sizeof (u32), .n_errors = PUNT_N_ERROR, .error_strings = punt_error_strings, }; /* *INDENT-ON* */ typedef struct { enum punt_action_e action; u32 sw_if_index; } punt_trace_t; static u8 * format_punt_trace (u8 * s, va_list * va) { CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *); CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *); vnet_main_t *vnm = vnet_get_main (); punt_trace_t *t = va_arg (*va, punt_trace_t *); s = format (s, "%U Action: %d", format_vnet_sw_if_index_name, vnm, t->sw_if_index, t->action); return s; } static uword punt_socket_rx_fd (vlib_main_t * vm, vlib_node_runtime_t * node, u32 fd) { const uword buffer_size = VLIB_BUFFER_DATA_SIZE; u32 n_trace = vlib_get_trace_count (vm, node); u32 next = node->cached_next_index; u32 n_left_to_next, next_index; u32 *to_next; u32 error = PUNT_ERROR_NONE; vlib_get_next_frame (vm, node, next, to_next, n_left_to_next); /* $$$$ Only dealing with one buffer at the time for now */ u32 bi; vlib_buffer_t *b; punt_packetdesc_t packetdesc; ssize_t size; struct iovec io[2]; if (vlib_buffer_alloc (vm, &bi, 1) != 1) { error = PUNT_ERROR_NOBUFFER; goto error; } b = vlib_get_buffer (vm, bi); io[0].iov_base = &packetdesc; io[0].iov_len = sizeof (packetdesc); io[1].iov_base = b->data; io[1].iov_len = buffer_size; size = readv (fd, io, 2); /* We need at least the packet descriptor plus a header */ if (size <= (int) (sizeof (packetdesc) + sizeof (ip4_header_t))) { vlib_buffer_free (vm, &bi, 1); error = PUNT_ERROR_READV; goto error; } b->flags = VNET_BUFFER_F_LOCALLY_ORIGINATED; b->current_length = size - sizeof (packetdesc); VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b); switch (packetdesc.action) { case PUNT_L2: vnet_buffer (b)->sw_if_index[VLIB_TX] = packetdesc.sw_if_index; next_index = PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT; break; case PUNT_IP4_ROUTED: vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index; vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0; next_index = PUNT_SOCKET_RX_NEXT_IP4_LOOKUP; break; case PUNT_IP6_ROUTED: vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index; vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0; next_index = PUNT_SOCKET_RX_NEXT_IP6_LOOKUP; break; default: error = PUNT_ERROR_ACTION; vlib_buffer_free (vm, &bi, 1); goto error; } if (PREDICT_FALSE (n_trace > 0)) { punt_trace_t *t; vlib_trace_buffer (vm, node, next_index, b, 1 /* follow_chain */ ); vlib_set_trace_count (vm, node, --n_trace); t = vlib_add_trace (vm, node, b, sizeof (*t)); t->sw_if_index = packetdesc.sw_if_index; t->action = packetdesc.action; } to_next[0] = bi; to_next++; n_left_to_next--; vlib_validate_buffer_enqueue_x1 (vm, node, next, to_next, n_left_to_next, bi, next_index); vlib_put_next_frame (vm, node, next, n_left_to_next); return 1; error: vlib_node_increment_counter (vm, punt_socket_rx_node.index, error, 1); return 0; } static uword punt_socket_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { punt_main_t *pm = &punt_main; u32 total_count = 0; int i; for (i = 0; i < vec_len (pm->ready_fds); i++) { total_count += punt_socket_rx_fd (vm, node, pm->ready_fds[i]); vec_del1 (pm->ready_fds, i); } return total_count; } /* *INDENT-OFF* */ VLIB_REGISTER_NODE (punt_socket_rx_node, static) = { .function = punt_socket_rx, .name = "punt-socket-rx", .type = VLIB_NODE_TYPE_INPUT, .state = VLIB_NODE_STATE_INTERRUPT, .vector_size = 1, .n_errors = PUNT_N_ERROR, .error_strings = punt_error_strings, .n_next_nodes = PUNT_SOCKET_RX_N_NEXT, .next_nodes = { [PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT] = "interface-output", [PUNT_SOCKET_RX_NEXT_IP4_LOOKUP] = "ip4-lookup", [PUNT_SOCKET_RX_NEXT_IP6_LOOKUP] = "ip6-lookup", }, .format_trace = format_punt_trace, }; /* *INDENT-ON* */ static clib_error_t * punt_socket_read_ready (clib_file_t * uf) { vlib_main_t *vm = vlib_get_main (); punt_main_t *pm = &punt_main; /** Schedule the rx node */ vlib_node_set_interrupt_pending (vm, punt_socket_rx_node.index); vec_add1 (pm->ready_fds, uf->file_descriptor); return 0; } clib_error_t * vnet_punt_socket_add (vlib_main_t * vm, u32 header_version, bool is_ip4, u8 protocol, u16 port, char *client_pathname) { punt_main_t *pm = &punt_main; if (!pm->is_configured) return clib_error_return (0, "socket is not configured"); if (header_version != PUNT_PACKETDESC_VERSION) return clib_error_return (0, "Invalid packet descriptor version"); /* For now we only support UDP punt */ if (protocol != IP_PROTOCOL_UDP) return clib_error_return (0, "only UDP protocol (%d) is supported, got %d", IP_PROTOCOL_UDP, protocol); if (port == (u16) ~ 0) return clib_error_return (0, "UDP port number required"); /* Register client */ if (punt_socket_register (is_ip4, protocol, port, client_pathname) < 0) return clib_error_return (0, "Punt socket: Invalid client path: %s", client_pathname); u32 node_index = is_ip4 ? udp4_punt_socket_node.index : udp6_punt_socket_node.index; udp_register_dst_port (vm, port, node_index, is_ip4); return 0; } clib_error_t * vnet_punt_socket_del (vlib_main_t * vm, bool is_ip4, u8 l4_protocol, u16 port) { punt_main_t *pm = &punt_main; if (!pm->is_configured) return clib_error_return (0, "socket is not configured"); punt_socket_unregister (is_ip4, l4_protocol, port); udp_unregister_dst_port (vm, port, is_ip4); return 0; } /** * @brief Request IP traffic punt to the local TCP/IP stack. * * @em Note * - UDP and TCP are the only protocols supported in the current implementation * * @param vm vlib_main_t corresponding to the current thread * @param ipv IP protcol version. * 4 - IPv4, 6 - IPv6, ~0 for both IPv6 and IPv4 * @param protocol 8-bits L4 protocol value * UDP is 17 * TCP is 1 * @param port 16-bits L4 (TCP/IP) port number when applicable (UDP only) * * @returns 0 on success, non-zero value otherwise */ clib_error_t * vnet_punt_add_del (vlib_main_t * vm, u8 ipv, u8 protocol, u16 port, bool is_add) { /* 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), 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); if (port == (u16) ~ 0) { if ((ipv == 4) || (ipv == (u8) ~ 0)) { if (protocol == IP_PROTOCOL_UDP) 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)) { if (protocol == IP_PROTOCOL_UDP) 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; } else if (is_add) { 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); if (ipv == 6 || ipv == (u8) ~ 0) udp_register_dst_port (vm, port, udp6_punt_node.index, 0); return 0; } else return clib_error_return (0, "punt delete is not supported yet"); } static clib_error_t * punt_cli (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { u32 port = ~0; bool is_add = true; u32 protocol = ~0; clib_error_t *error = NULL; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "del")) is_add = false; else if (unformat (input, "all")) ; else if (unformat (input, "%d", &port)) ; else if (unformat (input, "udp")) protocol = IP_PROTOCOL_UDP; else if (unformat (input, "tcp")) protocol = IP_PROTOCOL_TCP; else { error = clib_error_return (0, "parse error: '%U'", format_unformat_error, input); goto done; } } /* punt both IPv6 and IPv4 when used in CLI */ error = vnet_punt_add_del (vm, ~0, protocol, port, is_add); if (error) { clib_error_report (error); goto done; } done: return error; } /*? * The set of '<em>set punt</em>' commands allows specific IP traffic to * be punted to the host TCP/IP stack * * @em Note * - UDP is the only protocol supported in the current implementation * - All TCP traffic is currently punted to the host by default * * @cliexpar * @parblock * Example of how to request NTP traffic to be punted * @cliexcmd{set punt udp 125} * * Example of how to request all 'unknown' UDP traffic to be punted * @cliexcmd{set punt udp all} * * Example of how to stop all 'unknown' UDP traffic to be punted * @cliexcmd{set punt udp del all} * @endparblock ?*/ /* *INDENT-OFF* */ VLIB_CLI_COMMAND (punt_command, static) = { .path = "set punt", .short_help = "set punt [udp|tcp] [del] <all | port-num1 [port-num2 ...]>", .function = punt_cli, }; /* *INDENT-ON* */ static clib_error_t * punt_socket_register_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { bool is_ipv4 = true; u32 protocol = ~0; u32 port = ~0; u8 *socket_name = 0; clib_error_t *error = NULL; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "ipv4")) ; else if (unformat (input, "ipv6")) is_ipv4 = false; else if (unformat (input, "udp")) protocol = IP_PROTOCOL_UDP; else if (unformat (input, "tcp")) protocol = IP_PROTOCOL_TCP; else if (unformat (input, "%d", &port)) ; else if (unformat (input, "socket %s", &socket_name)) ; else { error = clib_error_return (0, "parse error: '%U'", format_unformat_error, input); goto done; } } error = vnet_punt_socket_add (vm, 1, is_ipv4, protocol, port, (char *) socket_name); if (error) { goto done; } done: return error; } /*? * * @cliexpar * @cliexcmd{punt socket register} ?*/ /* *INDENT-OFF* */ VLIB_CLI_COMMAND (punt_socket_register_command, static) = { .path = "punt socket register", .function = punt_socket_register_cmd, .short_help = "punt socket register [ipv4|ipv6] [udp|tcp]> <all | port-num1 [port-num2 ...]> <socket>", .is_mp_safe = 1, }; /* *INDENT-ON* */ static clib_error_t * punt_socket_deregister_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { bool is_ipv4 = true; u32 protocol = ~0; u32 port = ~0; clib_error_t *error = NULL; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "ipv4")) ; else if (unformat (input, "ipv6")) is_ipv4 = false; else if (unformat (input, "udp")) protocol = IP_PROTOCOL_UDP; else if (unformat (input, "tcp")) protocol = IP_PROTOCOL_TCP; else if (unformat (input, "%d", &port)) ; else { error = clib_error_return (0, "parse error: '%U'", format_unformat_error, input); goto done; } } error = vnet_punt_socket_del (vm, is_ipv4, protocol, port); if (error) { goto done; } done: return error; } /*? * * @cliexpar * @cliexcmd{punt socket register} ?*/ /* *INDENT-OFF* */ VLIB_CLI_COMMAND (punt_socket_deregister_command, static) = { .path = "punt socket deregister", .function = punt_socket_deregister_cmd, .short_help = "punt socket deregister [ipv4|ipv6] [udp|tcp]> <all | port-num1 [port-num2 ...]>", .is_mp_safe = 1, }; /* *INDENT-ON* */ punt_socket_detail_t * punt_socket_entries (u8 ipv) { punt_main_t *pm = &punt_main; punt_client_t *pc; punt_socket_detail_t *ps = 0; bool is_valid; punt_client_t *v = !ipv ? pm->clients_by_dst_port4 : pm->clients_by_dst_port6; vec_foreach (pc, v) { if (pc && pc->port != 0) { is_valid = false; if (pc->protocol == IP_PROTOCOL_UDP) { is_valid = udp_is_valid_dst_port (pc->port, !ipv); } if (is_valid) { punt_socket_detail_t detail = { .ipv = ipv, .l4_protocol = pc->protocol, .l4_port = pc->port }; memcpy (detail.pathname, pc->caddr.sun_path, sizeof (pc->caddr.sun_path)); vec_add1 (ps, detail); } } } return ps; } u8 * format_punt_socket (u8 * s, va_list * args) { punt_client_t *clients = va_arg (*args, punt_client_t *); u8 *is_ipv6 = va_arg (*args, u8 *); punt_client_t *pc; bool is_valid; vec_foreach (pc, clients) { if (pc && pc->port != 0) { is_valid = false; if (pc->protocol == IP_PROTOCOL_UDP) { is_valid = udp_is_valid_dst_port (pc->port, !(*is_ipv6)); } if (is_valid) { s = format (s, " punt %s port %d to socket %s \n", (pc->protocol == IP_PROTOCOL_UDP) ? "UDP" : "TCP", pc->port, pc->caddr.sun_path); } } } return (s); } static clib_error_t * punt_socket_show_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { u8 is_ipv6; punt_main_t *pm = &punt_main; clib_error_t *error = NULL; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "ipv4")) is_ipv6 = 0; else if (unformat (input, "ipv6")) is_ipv6 = 1; else { error = clib_error_return (0, "parse error: '%U'", format_unformat_error, input); goto done; } } punt_client_t *v = is_ipv6 ? pm->clients_by_dst_port6 : pm->clients_by_dst_port4; vlib_cli_output (vm, "%U", format_punt_socket, v, &is_ipv6); done: return (error); } /*? * * @cliexpar * @cliexcmd{show punt socket ipv4} ?*/ /* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_punt_socket_registration_command, static) = { .path = "show punt socket registrations", .function = punt_socket_show_cmd, .short_help = "show punt socket registrations [ipv4|ipv6]", .is_mp_safe = 1, }; /* *INDENT-ON* */ clib_error_t * punt_init (vlib_main_t * vm) { punt_main_t *pm = &punt_main; pm->clients_by_dst_port6 = sparse_vec_new (sizeof (pm->clients_by_dst_port6[0]), BITS (((udp_header_t *) 0)->dst_port)); pm->clients_by_dst_port4 = sparse_vec_new (sizeof (pm->clients_by_dst_port4[0]), BITS (((udp_header_t *) 0)->dst_port)); pm->is_configured = false; pm->interface_output_node = vlib_get_node_by_name (vm, (u8 *) "interface-output"); return 0; } VLIB_INIT_FUNCTION (punt_init); static clib_error_t * punt_config (vlib_main_t * vm, unformat_input_t * input) { punt_main_t *pm = &punt_main; char *socket_path = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "socket %s", &socket_path)) strncpy (pm->sun_path, socket_path, UNIX_PATH_MAX - 1); else return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); } if (socket_path == 0) return 0; /* UNIX domain socket */ struct sockaddr_un addr; if ((pm->socket_fd = socket (AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0)) == -1) { return clib_error_return (0, "socket error"); } clib_memset (&addr, 0, sizeof (addr)); addr.sun_family = AF_UNIX; if (*socket_path == '\0') { *addr.sun_path = '\0'; strncpy (addr.sun_path + 1, socket_path + 1, sizeof (addr.sun_path) - 2); } else { strncpy (addr.sun_path, socket_path, sizeof (addr.sun_path) - 1); unlink (socket_path); } if (bind (pm->socket_fd, (struct sockaddr *) &addr, sizeof (addr)) == -1) { return clib_error_return (0, "bind error"); } /* Register socket */ clib_file_main_t *fm = &file_main; 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; return 0; } VLIB_CONFIG_FUNCTION (punt_config, "punt"); /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */