diff options
author | Neale Ranns <nranns@cisco.com> | 2019-05-21 06:54:54 -0700 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-06-04 10:32:46 +0000 |
commit | b538dd868665009f9a3737610177342f88e3ba80 (patch) | |
tree | 2e2a1964e56a70e7c2584668b8f32017311e834c /src/vnet/ip/punt_node.c | |
parent | 0c6ac791dde099346af1752aa92d0eb05fc2db11 (diff) |
Punt: specify packets by IP protocol Type
Change-Id: I0c2d6fccd95146e52bb88ca4a6e84554d5d6b2ed
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip/punt_node.c')
-rw-r--r-- | src/vnet/ip/punt_node.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/vnet/ip/punt_node.c b/src/vnet/ip/punt_node.c index 53c8199342b..67f97431c19 100644 --- a/src/vnet/ip/punt_node.c +++ b/src/vnet/ip/punt_node.c @@ -286,13 +286,29 @@ punt_socket_inline (vlib_main_t * vm, udp = (udp_header_t *) (ip + 1); } - u16 port = clib_net_to_host_u16 (udp->dst_port); - /* * Find registerered client * If no registered client, drop packet and count */ - c = punt_client_l4_get (af, port); + c = punt_client_l4_get (af, clib_net_to_host_u16 (udp->dst_port)); + } + else if (PUNT_TYPE_IP_PROTO == pt) + { + /* Reverse UDP Punt advance */ + ip_protocol_t proto; + + if (AF_IP4 == af) + { + ip4_header_t *ip = vlib_buffer_get_current (b); + proto = ip->protocol; + } + else + { + ip6_header_t *ip = vlib_buffer_get_current (b); + proto = ip->protocol; + } + + c = punt_client_ip_proto_get (af, proto); } else if (PUNT_TYPE_EXCEPTION == pt) { @@ -391,6 +407,22 @@ udp6_punt_socket (vlib_main_t * vm, } static uword +ip4_proto_punt_socket (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * from_frame) +{ + return punt_socket_inline (vm, node, from_frame, + PUNT_TYPE_IP_PROTO, AF_IP4); +} + +static uword +ip6_proto_punt_socket (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * from_frame) +{ + return punt_socket_inline (vm, node, from_frame, + PUNT_TYPE_IP_PROTO, AF_IP6); +} + +static uword exception_punt_socket (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame) { @@ -419,6 +451,25 @@ VLIB_REGISTER_NODE (udp6_punt_socket_node) = { .n_errors = PUNT_N_ERROR, .error_strings = punt_error_strings, }; +VLIB_REGISTER_NODE (ip4_proto_punt_socket_node) = { + .function = ip4_proto_punt_socket, + .name = "ip4-proto-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 (ip6_proto_punt_socket_node) = { + .function = ip6_proto_punt_socket, + .name = "ip6-proto-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, +}; VLIB_REGISTER_NODE (exception_punt_socket_node) = { .function = exception_punt_socket, .name = "exception-punt-socket", |