From: Vijayabhaskar Katamreddy Date: Wed, 15 Nov 2017 21:50:26 +0000 (-0800) Subject: Fix icmp/udp/tcp punt/drop paths X-Git-Tag: v18.04-rc0~35 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=ce07412a54f06900b377a7f4966f6a26e19b8f2b;p=vpp.git Fix icmp/udp/tcp punt/drop paths Send packets to ip4/6_punt/drop nodes instead of error-drop/punt nodes dbarach: clean up an annoying checkstyle issue: indent 2.2.10 (OpenSUSE version) and indent 2.2.11 (Ubuntu / CentOS versions) had an artistic disagreement about ip_frag.c. Change-Id: I660bee28a064af9c6c70371363081e941d1c3a94 Signed-off-by: Vijayabhaskar Katamreddy Signed-off-by: Dave Barach --- diff --git a/src/vnet/ip/icmp4.c b/src/vnet/ip/icmp4.c index bbeab32b6a5..1fe01e48500 100644 --- a/src/vnet/ip/icmp4.c +++ b/src/vnet/ip/icmp4.c @@ -219,7 +219,7 @@ VLIB_REGISTER_NODE (ip4_icmp_input_node,static) = { .n_next_nodes = 1, .next_nodes = { - [ICMP_INPUT_NEXT_ERROR] = "error-punt", + [ICMP_INPUT_NEXT_ERROR] = "ip4-punt", }, }; /* *INDENT-ON* */ @@ -592,7 +592,7 @@ VLIB_REGISTER_NODE (ip4_icmp_error_node) = { .n_next_nodes = IP4_ICMP_ERROR_N_NEXT, .next_nodes = { - [IP4_ICMP_ERROR_NEXT_DROP] = "error-drop", + [IP4_ICMP_ERROR_NEXT_DROP] = "ip4-drop", [IP4_ICMP_ERROR_NEXT_LOOKUP] = "ip4-lookup", }, diff --git a/src/vnet/ip/icmp6.c b/src/vnet/ip/icmp6.c index 70696d0c6cb..ab871b3a969 100644 --- a/src/vnet/ip/icmp6.c +++ b/src/vnet/ip/icmp6.c @@ -250,7 +250,7 @@ VLIB_REGISTER_NODE (ip6_icmp_input_node) = { .n_next_nodes = 1, .next_nodes = { - [ICMP_INPUT_NEXT_DROP] = "error-drop", + [ICMP_INPUT_NEXT_DROP] = "ip6-drop", }, }; /* *INDENT-ON* */ @@ -663,7 +663,7 @@ VLIB_REGISTER_NODE (ip6_icmp_error_node) = { .n_next_nodes = IP6_ICMP_ERROR_N_NEXT, .next_nodes = { - [IP6_ICMP_ERROR_NEXT_DROP] = "error-drop", + [IP6_ICMP_ERROR_NEXT_DROP] = "ip6-drop", [IP6_ICMP_ERROR_NEXT_LOOKUP] = "ip6-lookup", }, diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 2f3f340264f..9c5775792b0 100755 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -2727,7 +2727,7 @@ ip4_rewrite_inline (vlib_main_t * vm, Next Indices: - adj->rewrite_header.next_index - or @c error-drop + or @c ip4-drop */ static uword ip4_rewrite (vlib_main_t * vm, @@ -2779,7 +2779,7 @@ VLIB_REGISTER_NODE (ip4_rewrite_node) = { .n_next_nodes = 2, .next_nodes = { - [IP4_REWRITE_NEXT_DROP] = "error-drop", + [IP4_REWRITE_NEXT_DROP] = "ip4-drop", [IP4_REWRITE_NEXT_ICMP_ERROR] = "ip4-icmp-error", }, }; diff --git a/src/vnet/ip/ip4_source_and_port_range_check.c b/src/vnet/ip/ip4_source_and_port_range_check.c index d1f18dd6b26..06e6e7c6b63 100644 --- a/src/vnet/ip/ip4_source_and_port_range_check.c +++ b/src/vnet/ip/ip4_source_and_port_range_check.c @@ -593,7 +593,7 @@ VLIB_REGISTER_NODE (ip4_source_port_and_range_check_rx) = { .n_next_nodes = IP4_SOURCE_AND_PORT_RANGE_CHECK_N_NEXT, .next_nodes = { - [IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP] = "error-drop", + [IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP] = "ip4-drop", }, .format_buffer = format_ip4_header, @@ -612,7 +612,7 @@ VLIB_REGISTER_NODE (ip4_source_port_and_range_check_tx) = { .n_next_nodes = IP4_SOURCE_AND_PORT_RANGE_CHECK_N_NEXT, .next_nodes = { - [IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP] = "error-drop", + [IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP] = "ip4-drop", }, .format_buffer = format_ip4_header, @@ -777,7 +777,7 @@ set_ip_source_and_port_range_check_fn (vlib_main_t * vm, * Example of graph node before range checking is enabled: * @cliexstart{show vlib graph ip4-source-and-port-range-check-tx} * Name Next Previous - * ip4-source-and-port-range- error-drop [0] + * ip4-source-and-port-range- ip4-drop [0] * @cliexend * * Example of how to enable range checking on TX: @@ -786,7 +786,7 @@ set_ip_source_and_port_range_check_fn (vlib_main_t * vm, * Example of graph node after range checking is enabled: * @cliexstart{show vlib graph ip4-source-and-port-range-check-tx} * Name Next Previous - * ip4-source-and-port-range- error-drop [0] ip4-rewrite + * ip4-source-and-port-range- ip4-drop [0] ip4-rewrite * interface-output [1] * @cliexend * diff --git a/src/vnet/ip/ip4_source_check.c b/src/vnet/ip/ip4_source_check.c index 17a1cb1bdd6..25c51275920 100644 --- a/src/vnet/ip/ip4_source_check.c +++ b/src/vnet/ip/ip4_source_check.c @@ -309,7 +309,7 @@ VLIB_REGISTER_NODE (ip4_check_source_reachable_via_any) = { .n_next_nodes = IP4_SOURCE_CHECK_N_NEXT, .next_nodes = { - [IP4_SOURCE_CHECK_NEXT_DROP] = "error-drop", + [IP4_SOURCE_CHECK_NEXT_DROP] = "ip4-drop", }, .format_buffer = format_ip4_header, @@ -328,7 +328,7 @@ VLIB_REGISTER_NODE (ip4_check_source_reachable_via_rx) = { .n_next_nodes = IP4_SOURCE_CHECK_N_NEXT, .next_nodes = { - [IP4_SOURCE_CHECK_NEXT_DROP] = "error-drop", + [IP4_SOURCE_CHECK_NEXT_DROP] = "ip4-drop", }, .format_buffer = format_ip4_header, @@ -405,7 +405,7 @@ done: * Example of graph node before range checking is enabled: * @cliexstart{show vlib graph ip4-source-check-via-rx} * Name Next Previous - * ip4-source-check-via-rx error-drop [0] + * ip4-source-check-via-rx ip4-drop [0] * @cliexend * * Example of how to enable unicast source checking on an interface: @@ -414,7 +414,7 @@ done: * Example of graph node after range checking is enabled: * @cliexstart{show vlib graph ip4-source-check-via-rx} * Name Next Previous - * ip4-source-check-via-rx error-drop [0] ip4-input-no-checksum + * ip4-source-check-via-rx ip4-drop [0] ip4-input-no-checksum * ip4-source-and-port-range- ip4-input * @cliexend * diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index 67fedc949ac..29cd3ca8239 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -1902,7 +1902,7 @@ VLIB_REGISTER_NODE (ip6_discover_neighbor_node) = .n_next_nodes = IP6_DISCOVER_NEIGHBOR_N_NEXT, .next_nodes = { - [IP6_DISCOVER_NEIGHBOR_NEXT_DROP] = "error-drop", + [IP6_DISCOVER_NEIGHBOR_NEXT_DROP] = "ip6-drop", [IP6_DISCOVER_NEIGHBOR_NEXT_REPLY_TX] = "interface-output", }, }; @@ -1920,7 +1920,7 @@ VLIB_REGISTER_NODE (ip6_glean_node) = .n_next_nodes = IP6_DISCOVER_NEIGHBOR_N_NEXT, .next_nodes = { - [IP6_DISCOVER_NEIGHBOR_NEXT_DROP] = "error-drop", + [IP6_DISCOVER_NEIGHBOR_NEXT_DROP] = "ip6-drop", [IP6_DISCOVER_NEIGHBOR_NEXT_REPLY_TX] = "interface-output", }, }; @@ -2432,7 +2432,7 @@ VLIB_REGISTER_NODE (ip6_rewrite_node) = .n_next_nodes = 2, .next_nodes = { - [IP6_REWRITE_NEXT_DROP] = "error-drop", + [IP6_REWRITE_NEXT_DROP] = "ip6-drop", [IP6_REWRITE_NEXT_ICMP_ERROR] = "ip6-icmp-error", }, }; diff --git a/src/vnet/ip/ip6_hop_by_hop.c b/src/vnet/ip/ip6_hop_by_hop.c index 14fbb392e19..90a4d21d3a6 100644 --- a/src/vnet/ip/ip6_hop_by_hop.c +++ b/src/vnet/ip/ip6_hop_by_hop.c @@ -46,7 +46,7 @@ ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main; #define foreach_ip6_hbyh_ioam_input_next \ _(IP6_REWRITE, "ip6-rewrite") \ _(IP6_LOOKUP, "ip6-lookup") \ - _(DROP, "error-drop") + _(DROP, "ip6-drop") typedef enum { diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c index d549ac37625..82b402ff263 100644 --- a/src/vnet/ip/ip6_neighbor.c +++ b/src/vnet/ip/ip6_neighbor.c @@ -2435,7 +2435,7 @@ VLIB_REGISTER_NODE (ip6_icmp_router_solicitation_node,static) = .n_next_nodes = ICMP6_ROUTER_SOLICITATION_N_NEXT, .next_nodes = { - [ICMP6_ROUTER_SOLICITATION_NEXT_DROP] = "error-drop", + [ICMP6_ROUTER_SOLICITATION_NEXT_DROP] = "ip6-drop", [ICMP6_ROUTER_SOLICITATION_NEXT_REPLY_RW] = "ip6-rewrite-mcast", [ICMP6_ROUTER_SOLICITATION_NEXT_REPLY_TX] = "interface-output", }, @@ -2628,7 +2628,7 @@ VLIB_REGISTER_NODE (ip6_icmp_router_advertisement_node,static) = .n_next_nodes = 1, .next_nodes = { - [0] = "error-drop", + [0] = "ip6-drop", }, }; /* *INDENT-ON* */ @@ -2671,7 +2671,7 @@ VLIB_REGISTER_NODE (ip6_icmp_neighbor_solicitation_node,static) = .n_next_nodes = ICMP6_NEIGHBOR_SOLICITATION_N_NEXT, .next_nodes = { - [ICMP6_NEIGHBOR_SOLICITATION_NEXT_DROP] = "error-drop", + [ICMP6_NEIGHBOR_SOLICITATION_NEXT_DROP] = "ip6-drop", [ICMP6_NEIGHBOR_SOLICITATION_NEXT_REPLY] = "interface-output", }, }; @@ -2689,7 +2689,7 @@ VLIB_REGISTER_NODE (ip6_icmp_neighbor_advertisement_node,static) = .n_next_nodes = 1, .next_nodes = { - [0] = "error-drop", + [0] = "ip6-drop", }, }; /* *INDENT-ON* */ diff --git a/src/vnet/ip/ip_frag.c b/src/vnet/ip/ip_frag.c index ca062bfd5e8..2af697e96b6 100644 --- a/src/vnet/ip/ip_frag.c +++ b/src/vnet/ip/ip_frag.c @@ -90,8 +90,8 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 pi, u32 ** buffer, ip_frag_id = ip4->fragment_id; ip_frag_offset = ip4_get_fragment_offset (ip4); more = - ! !(ip4->flags_and_fragment_offset & - clib_host_to_net_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS)); + !(!(ip4->flags_and_fragment_offset & + clib_host_to_net_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS))); } else { @@ -239,10 +239,12 @@ ip4_frag (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) next0 = IP4_FRAG_NEXT_ICMP_ERROR; } else - next0 = - (error0 == - IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)-> - ip_frag.next_index : IP4_FRAG_NEXT_DROP; + { + /* *INDENT-OFF* */ + next0 = (error0 == IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)-> + ip_frag.next_index : IP4_FRAG_NEXT_DROP; + /* *INDENT-ON* */ + } if (error0 == IP_FRAG_ERROR_NONE) { @@ -482,10 +484,11 @@ ip6_frag (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) tr->next = vnet_buffer (p0)->ip_frag.next_index; } - next0 = - (error0 == - IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)-> + /* *INDENT-OFF* */ + next0 = (error0 == IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)-> ip_frag.next_index : IP6_FRAG_NEXT_DROP; + /* *INDENT-ON* */ + frag_sent += vec_len (buffer); small_packets += (vec_len (buffer) == 1); @@ -547,7 +550,7 @@ VLIB_REGISTER_NODE (ip4_frag_node) = { [IP4_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup", [IP4_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup", [IP4_FRAG_NEXT_ICMP_ERROR] = "ip4-icmp-error", - [IP4_FRAG_NEXT_DROP] = "error-drop" + [IP4_FRAG_NEXT_DROP] = "ip4-drop" }, }; /* *INDENT-ON* */ @@ -567,7 +570,7 @@ VLIB_REGISTER_NODE (ip6_frag_node) = { .next_nodes = { [IP6_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup", [IP6_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup", - [IP6_FRAG_NEXT_DROP] = "error-drop" + [IP6_FRAG_NEXT_DROP] = "ip6-drop" }, }; /* *INDENT-ON* */ diff --git a/src/vnet/ip/ip_input_acl.c b/src/vnet/ip/ip_input_acl.c index 4d365a4437f..3c54fe8be2c 100644 --- a/src/vnet/ip/ip_input_acl.c +++ b/src/vnet/ip/ip_input_acl.c @@ -402,7 +402,7 @@ VLIB_REGISTER_NODE (ip4_inacl_node) = { .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, .next_nodes = { - [ACL_NEXT_INDEX_DENY] = "error-drop", + [ACL_NEXT_INDEX_DENY] = "ip4-drop", }, }; /* *INDENT-ON* */ @@ -427,7 +427,7 @@ VLIB_REGISTER_NODE (ip6_inacl_node) = { .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, .next_nodes = { - [ACL_NEXT_INDEX_DENY] = "error-drop", + [ACL_NEXT_INDEX_DENY] = "ip6-drop", }, }; /* *INDENT-ON* */ diff --git a/src/vnet/ip/ping.c b/src/vnet/ip/ping.c index f438ce96060..a142754bdf7 100755 --- a/src/vnet/ip/ping.c +++ b/src/vnet/ip/ping.c @@ -155,8 +155,8 @@ VLIB_REGISTER_NODE (ip6_icmp_echo_reply_node, static) = .format_trace = format_icmp_echo_trace, .n_next_nodes = ICMP6_ECHO_REPLY_N_NEXT, .next_nodes = { - [ICMP6_ECHO_REPLY_NEXT_DROP] = "error-drop", - [ICMP6_ECHO_REPLY_NEXT_PUNT] = "error-punt", + [ICMP6_ECHO_REPLY_NEXT_DROP] = "ip6-drop", + [ICMP6_ECHO_REPLY_NEXT_PUNT] = "ip6-punt", }, }; /* *INDENT-ON* */ @@ -213,8 +213,8 @@ VLIB_REGISTER_NODE (ip4_icmp_echo_reply_node, static) = .format_trace = format_icmp_echo_trace, .n_next_nodes = ICMP4_ECHO_REPLY_N_NEXT, .next_nodes = { - [ICMP4_ECHO_REPLY_NEXT_DROP] = "error-drop", - [ICMP4_ECHO_REPLY_NEXT_PUNT] = "error-punt", + [ICMP4_ECHO_REPLY_NEXT_DROP] = "ip4-drop", + [ICMP4_ECHO_REPLY_NEXT_PUNT] = "ip4-punt", }, }; /* *INDENT-ON* */ diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c index 568350cda82..b417427288c 100644 --- a/src/vnet/ip/punt.c +++ b/src/vnet/ip/punt.c @@ -40,7 +40,8 @@ #include #define foreach_punt_next \ - _ (PUNT, "error-punt") + _ (PUNT4, "ip4-punt") \ + _ (PUNT6, "ip6-punt") typedef enum { @@ -58,6 +59,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 +107,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 +127,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; diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index 702a94f3a98..b0ea24ff8ef 100644 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -27,7 +27,8 @@ static char *tcp_error_strings[] = { /* All TCP nodes have the same outgoing arcs */ #define foreach_tcp_state_next \ - _ (DROP, "error-drop") \ + _ (DROP4, "ip4-drop") \ + _ (DROP6, "ip6-drop") \ _ (TCP4_OUTPUT, "tcp4-output") \ _ (TCP6_OUTPUT, "tcp6-output") @@ -75,6 +76,9 @@ typedef enum _tcp_state_next #define tcp_next_output(is_ip4) (is_ip4 ? TCP_NEXT_TCP4_OUTPUT \ : TCP_NEXT_TCP6_OUTPUT) +#define tcp_next_drop(is_ip4) (is_ip4 ? TCP_NEXT_DROP4 \ + : TCP_NEXT_DROP6) + vlib_node_registration_t tcp4_established_node; vlib_node_registration_t tcp6_established_node; @@ -1554,7 +1558,7 @@ tcp_segment_rcv (tcp_main_t * tm, tcp_connection_t * tc, vlib_buffer_t * b, if (seq_lt (vnet_buffer (b)->tcp.seq_number, tc->rcv_nxt)) { error = TCP_ERROR_SEGMENT_OLD; - *next0 = TCP_NEXT_DROP; + *next0 = tcp_next_drop (tc->c_is_ip4); /* Completely in the past (possible retransmit) */ if (seq_leq (vnet_buffer (b)->tcp.seq_end, tc->rcv_nxt)) @@ -1707,7 +1711,7 @@ tcp46_established_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t *b0; tcp_header_t *th0 = 0; tcp_connection_t *tc0; - u32 next0 = TCP_ESTABLISHED_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED; + u32 next0 = tcp_next_drop (is_ip4), error0 = TCP_ERROR_ENQUEUED; bi0 = from[0]; to_next[0] = bi0; @@ -1967,7 +1971,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node, tcp_header_t *tcp0 = 0; tcp_connection_t *tc0; tcp_connection_t *new_tc0; - u32 next0 = TCP_SYN_SENT_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED; + u32 next0 = tcp_next_drop (is_ip4), error0 = TCP_ERROR_ENQUEUED; bi0 = from[0]; to_next[0] = bi0; @@ -2294,7 +2298,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t *b0; tcp_header_t *tcp0 = 0; tcp_connection_t *tc0; - u32 next0 = TCP_RCV_PROCESS_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED; + u32 next0 = tcp_next_drop (is_ip4), error0 = TCP_ERROR_ENQUEUED; u8 is_fin0; bi0 = from[0]; @@ -2690,7 +2694,7 @@ tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node, ip4_header_t *ip40; ip6_header_t *ip60; tcp_connection_t *child0; - u32 error0 = TCP_ERROR_SYNS_RCVD, next0 = TCP_LISTEN_NEXT_DROP; + u32 error0 = TCP_ERROR_SYNS_RCVD, next0 = tcp_next_drop (is_ip4); bi0 = from[0]; to_next[0] = bi0; @@ -2895,22 +2899,22 @@ typedef enum _tcp_input_next } tcp_input_next_t; #define foreach_tcp4_input_next \ - _ (DROP, "error-drop") \ + _ (DROP, "ip4-drop") \ _ (LISTEN, "tcp4-listen") \ _ (RCV_PROCESS, "tcp4-rcv-process") \ _ (SYN_SENT, "tcp4-syn-sent") \ _ (ESTABLISHED, "tcp4-established") \ _ (RESET, "tcp4-reset") \ - _ (PUNT, "error-punt") + _ (PUNT, "ip4-punt") #define foreach_tcp6_input_next \ - _ (DROP, "error-drop") \ + _ (DROP, "ip6-drop") \ _ (LISTEN, "tcp6-listen") \ _ (RCV_PROCESS, "tcp6-rcv-process") \ _ (SYN_SENT, "tcp6-syn-sent") \ _ (ESTABLISHED, "tcp6-established") \ _ (RESET, "tcp6-reset") \ - _ (PUNT, "error-punt") + _ (PUNT, "ip6-punt") #define filter_flags (TCP_FLAG_SYN|TCP_FLAG_ACK|TCP_FLAG_RST|TCP_FLAG_FIN) diff --git a/src/vnet/udp/udp_local.c b/src/vnet/udp/udp_local.c index ce9bb029788..f0d95304f13 100644 --- a/src/vnet/udp/udp_local.c +++ b/src/vnet/udp/udp_local.c @@ -24,8 +24,10 @@ udp_main_t udp_main; #define foreach_udp_local_next \ - _ (PUNT, "error-punt") \ - _ (DROP, "error-drop") \ + _ (PUNT4, "ip4-punt") \ + _ (PUNT6, "ip6-punt") \ + _ (DROP4, "ip4-drop") \ + _ (DROP6, "ip6-drop") \ _ (ICMP4_ERROR, "ip4-icmp-error") \ _ (ICMP6_ERROR, "ip6-icmp-error") @@ -37,6 +39,9 @@ typedef enum UDP_LOCAL_N_NEXT, } udp_local_next_t; +#define udp_local_next_drop(is_ip4) ((is_ip4) ? UDP_LOCAL_NEXT_DROP4 : UDP_LOCAL_NEXT_DROP6) +#define udp_local_next_punt(is_ip4) ((is_ip4) ? UDP_LOCAL_NEXT_PUNT4 : UDP_LOCAL_NEXT_PUNT6) + typedef struct { u16 src_port; @@ -132,7 +137,7 @@ udp46_local_inline (vlib_main_t * vm, if (PREDICT_FALSE (b0->current_length < advance0 + sizeof (*h0))) { error0 = UDP_ERROR_LENGTH_ERROR; - next0 = UDP_LOCAL_NEXT_DROP; + next0 = udp_local_next_drop (is_ip4); } else { @@ -143,14 +148,14 @@ udp46_local_inline (vlib_main_t * vm, vlib_buffer_length_in_chain (vm, b0))) { error0 = UDP_ERROR_LENGTH_ERROR; - next0 = UDP_LOCAL_NEXT_DROP; + next0 = udp_local_next_drop (is_ip4); } } if (PREDICT_FALSE (b1->current_length < advance1 + sizeof (*h1))) { error1 = UDP_ERROR_LENGTH_ERROR; - next1 = UDP_LOCAL_NEXT_DROP; + next1 = udp_local_next_drop (is_ip4); } else { @@ -161,7 +166,7 @@ udp46_local_inline (vlib_main_t * vm, vlib_buffer_length_in_chain (vm, b1))) { error1 = UDP_ERROR_LENGTH_ERROR; - next1 = UDP_LOCAL_NEXT_DROP; + next1 = udp_local_next_drop (is_ip4); } } @@ -187,7 +192,7 @@ udp46_local_inline (vlib_main_t * vm, if (PREDICT_FALSE (punt_unknown)) { b0->error = node->errors[UDP_ERROR_PUNT]; - next0 = UDP_LOCAL_NEXT_PUNT; + next0 = udp_local_next_punt (is_ip4); } else if (is_ip4) { @@ -224,7 +229,7 @@ udp46_local_inline (vlib_main_t * vm, if (PREDICT_FALSE (punt_unknown)) { b1->error = node->errors[UDP_ERROR_PUNT]; - next1 = UDP_LOCAL_NEXT_PUNT; + next1 = udp_local_next_punt (is_ip4); } else if (is_ip4) { @@ -308,7 +313,7 @@ udp46_local_inline (vlib_main_t * vm, if (PREDICT_FALSE (b0->current_length < advance0 + sizeof (*h0))) { b0->error = node->errors[UDP_ERROR_LENGTH_ERROR]; - next0 = UDP_LOCAL_NEXT_DROP; + next0 = udp_local_next_drop (is_ip4); goto trace_x1; } @@ -333,7 +338,7 @@ udp46_local_inline (vlib_main_t * vm, if (PREDICT_FALSE (punt_unknown)) { b0->error = node->errors[UDP_ERROR_PUNT]; - next0 = UDP_LOCAL_NEXT_PUNT; + next0 = udp_local_next_punt (is_ip4); } else if (is_ip4) { @@ -364,7 +369,7 @@ udp46_local_inline (vlib_main_t * vm, else { b0->error = node->errors[UDP_ERROR_LENGTH_ERROR]; - next0 = UDP_LOCAL_NEXT_DROP; + next0 = udp_local_next_drop (is_ip4); } trace_x1: