diff options
author | Ole Troan <otroan@employees.org> | 2024-07-31 11:16:35 +0200 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2024-07-31 13:40:11 +0000 |
commit | 01ea72bc49d3514cdda49b1712c88c4dc01cab5d (patch) | |
tree | 6d1a44ed99860e536757c4ee3173be307d45aeb3 /src/vnet | |
parent | f726ebd174a0dc171c50c897e5fdd21841fc55f9 (diff) |
ip6: set buffer->error in ip6_input_check
When packets are dropped and this field is not set, then
trace shows the packet being dropped by the null-node instead
of the correct reason.
Type: fix
Change-Id: I3ed9186285d0db7fa6a1e5b739a28ee625968f30
Signed-off-by: Ole Troan <otroan@employees.org>
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/ip/ip6_input.h | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/vnet/ip/ip6_input.h b/src/vnet/ip/ip6_input.h index 49e37ec1808..809083137e3 100644 --- a/src/vnet/ip/ip6_input.h +++ b/src/vnet/ip/ip6_input.h @@ -53,11 +53,9 @@ typedef enum } ip6_input_next_t; always_inline void -ip6_input_check_x2 (vlib_main_t * vm, - vlib_node_runtime_t * error_node, - vlib_buffer_t * p0, vlib_buffer_t * p1, - ip6_header_t * ip0, ip6_header_t * ip1, - u32 * next0, u32 * next1) +ip6_input_check_x2 (vlib_main_t *vm, vlib_node_runtime_t *error_node, + vlib_buffer_t *p0, vlib_buffer_t *p1, ip6_header_t *ip0, + ip6_header_t *ip1, u32 *next0, u32 *next1) { u8 error0, error1; @@ -65,13 +63,15 @@ ip6_input_check_x2 (vlib_main_t * vm, /* Version != 6? Drop it. */ error0 = - (clib_net_to_host_u32 - (ip0->ip_version_traffic_class_and_flow_label) >> 28) != - 6 ? IP6_ERROR_VERSION : error0; + (clib_net_to_host_u32 (ip0->ip_version_traffic_class_and_flow_label) >> + 28) != 6 ? + IP6_ERROR_VERSION : + error0; error1 = - (clib_net_to_host_u32 - (ip1->ip_version_traffic_class_and_flow_label) >> 28) != - 6 ? IP6_ERROR_VERSION : error1; + (clib_net_to_host_u32 (ip1->ip_version_traffic_class_and_flow_label) >> + 28) != 6 ? + IP6_ERROR_VERSION : + error1; /* hop limit < 1? Drop it. for link-local broadcast packets, * like dhcpv6 packets from client has hop-limit 1, which should not @@ -81,18 +81,18 @@ ip6_input_check_x2 (vlib_main_t * vm, error1 = ip1->hop_limit < 1 ? IP6_ERROR_TIME_EXPIRED : error1; /* L2 length must be at least minimal IP header. */ - error0 = - p0->current_length < sizeof (ip0[0]) ? IP6_ERROR_TOO_SHORT : error0; - error1 = - p1->current_length < sizeof (ip1[0]) ? IP6_ERROR_TOO_SHORT : error1; + error0 = p0->current_length < sizeof (ip0[0]) ? IP6_ERROR_TOO_SHORT : error0; + error1 = p1->current_length < sizeof (ip1[0]) ? IP6_ERROR_TOO_SHORT : error1; if (PREDICT_FALSE (error0 != IP6_ERROR_NONE)) { + p0->error = error_node->errors[error0]; + if (error0 == IP6_ERROR_TIME_EXPIRED) { - icmp6_error_set_vnet_buffer (p0, ICMP6_time_exceeded, - ICMP6_time_exceeded_ttl_exceeded_in_transit, - 0); + icmp6_error_set_vnet_buffer ( + p0, ICMP6_time_exceeded, + ICMP6_time_exceeded_ttl_exceeded_in_transit, 0); *next0 = IP6_INPUT_NEXT_ICMP_ERROR; } else @@ -102,11 +102,13 @@ ip6_input_check_x2 (vlib_main_t * vm, } if (PREDICT_FALSE (error1 != IP6_ERROR_NONE)) { + p1->error = error_node->errors[error0]; + if (error1 == IP6_ERROR_TIME_EXPIRED) { - icmp6_error_set_vnet_buffer (p1, ICMP6_time_exceeded, - ICMP6_time_exceeded_ttl_exceeded_in_transit, - 0); + icmp6_error_set_vnet_buffer ( + p1, ICMP6_time_exceeded, + ICMP6_time_exceeded_ttl_exceeded_in_transit, 0); *next1 = IP6_INPUT_NEXT_ICMP_ERROR; } else @@ -117,9 +119,8 @@ ip6_input_check_x2 (vlib_main_t * vm, } always_inline void -ip6_input_check_x1 (vlib_main_t * vm, - vlib_node_runtime_t * error_node, - vlib_buffer_t * p0, ip6_header_t * ip0, u32 * next0) +ip6_input_check_x1 (vlib_main_t *vm, vlib_node_runtime_t *error_node, + vlib_buffer_t *p0, ip6_header_t *ip0, u32 *next0) { u8 error0; @@ -127,9 +128,10 @@ ip6_input_check_x1 (vlib_main_t * vm, /* Version != 6? Drop it. */ error0 = - (clib_net_to_host_u32 - (ip0->ip_version_traffic_class_and_flow_label) >> 28) != - 6 ? IP6_ERROR_VERSION : error0; + (clib_net_to_host_u32 (ip0->ip_version_traffic_class_and_flow_label) >> + 28) != 6 ? + IP6_ERROR_VERSION : + error0; /* hop limit < 1? Drop it. for link-local broadcast packets, * like dhcpv6 packets from client has hop-limit 1, which should not @@ -138,16 +140,16 @@ ip6_input_check_x1 (vlib_main_t * vm, error0 = ip0->hop_limit < 1 ? IP6_ERROR_TIME_EXPIRED : error0; /* L2 length must be at least minimal IP header. */ - error0 = - p0->current_length < sizeof (ip0[0]) ? IP6_ERROR_TOO_SHORT : error0; + error0 = p0->current_length < sizeof (ip0[0]) ? IP6_ERROR_TOO_SHORT : error0; if (PREDICT_FALSE (error0 != IP6_ERROR_NONE)) { + p0->error = error_node->errors[error0]; if (error0 == IP6_ERROR_TIME_EXPIRED) { - icmp6_error_set_vnet_buffer (p0, ICMP6_time_exceeded, - ICMP6_time_exceeded_ttl_exceeded_in_transit, - 0); + icmp6_error_set_vnet_buffer ( + p0, ICMP6_time_exceeded, + ICMP6_time_exceeded_ttl_exceeded_in_transit, 0); *next0 = IP6_INPUT_NEXT_ICMP_ERROR; } else |