aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/punt.h
blob: 7a3e5da2da64d85178ad98935409f8be157eda0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * Copyright (c) 2018 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __PUNT_H__
#define __PUNT_H__

#include <vlib/vlib.h>

/**
 * The 'syatem' defined punt reasons.
 * Only add to this list reasons defined and used within the vlib subsystem.
 * To define new reasons in e.g. plgins, use punt_reason_alloc()
 */
typedef enum vlib_punt_reason_t_
{
  PUNT_N_REASONS,
} vlib_punt_reason_t;

/**
 * Walk each punt reason
 */
typedef int (*punt_reason_walk_cb_t) (vlib_punt_reason_t id,
				      const u8 * name, void *ctx);

extern void punt_reason_walk (punt_reason_walk_cb_t cb, void *cxt);

/**
 * @brief Format a punt reason
 */
extern u8 *format_vlib_punt_reason (u8 * s, va_list * args);

/**
 * Typedef for a client handle
 */
typedef int vlib_punt_hdl_t;

/**
 * @brief Register a new clinet
 *
 * @param who - The name of the client
 *
 * @retrun the handle the punt infra allocated for this client that must
 *         be used when the client wishes to use the infra
 */
vlib_punt_hdl_t vlib_punt_client_register (const char *who);

/**
 * Allocate a new punt reason
 */
extern int vlib_punt_reason_alloc (vlib_punt_hdl_t client,
				   const char *reason_name,
				   vlib_punt_reason_t * reason);

/**
 * Validate that a punt reason is assigned
 */
extern int vlib_punt_reason_validate (vlib_punt_reason_t reason);

/**
 * @brief Register a node to receive particular punted buffers
 *
 * @paran client - The registered client registering for the packets
 * @param reason - The reason the packet was punted
 * @param node   - The node to which the punted packets will be sent
 */
extern int vlib_punt_register (vlib_punt_hdl_t client,
			       vlib_punt_reason_t reason, const char *node);
extern int vlib_punt_unregister (vlib_punt_hdl_t client,
				 vlib_punt_reason_t pr, const char *node);

/**
 * FOR USE IN THE DP ONLY
 *
 * Arc[s] to follow for each reason
 */
extern u16 **punt_dp_db;

/**
 * FOR USE IN THE DP ONLY
 *
 * Per-reason counters
 */
extern vlib_combined_counter_main_t punt_counters;

#endif

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
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 * be dropped. */ error0 = ip0->hop_limit < 1 ? IP6_ERROR_TIME_EXPIRED : error0; 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; if (PREDICT_FALSE (error0 != IP6_ERROR_NONE)) { if (error0 == IP6_ERROR_TIME_EXPIRED) { icmp6_error_set_vnet_buffer (p0, ICMP6_time_exceeded, ICMP6_time_exceeded_ttl_exceeded_in_transit, 0); *next0 = IP6_INPUT_NEXT_ICMP_ERROR; } else { *next0 = IP6_INPUT_NEXT_DROP; } } if (PREDICT_FALSE (error1 != IP6_ERROR_NONE)) { if (error1 == IP6_ERROR_TIME_EXPIRED) { icmp6_error_set_vnet_buffer (p1, ICMP6_time_exceeded, ICMP6_time_exceeded_ttl_exceeded_in_transit, 0); *next1 = IP6_INPUT_NEXT_ICMP_ERROR; } else { *next1 = IP6_INPUT_NEXT_DROP; } } } 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) { u8 error0; error0 = IP6_ERROR_NONE; /* Version != 6? Drop it. */ 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 * be dropped. */ 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; if (PREDICT_FALSE (error0 != IP6_ERROR_NONE)) { if (error0 == IP6_ERROR_TIME_EXPIRED) { icmp6_error_set_vnet_buffer (p0, ICMP6_time_exceeded, ICMP6_time_exceeded_ttl_exceeded_in_transit, 0); *next0 = IP6_INPUT_NEXT_ICMP_ERROR; } else { *next0 = IP6_INPUT_NEXT_DROP; } } } #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */