25 #define ESP_NODE "dpdk-esp-encrypt" 27 #define ESP_NODE "esp-encrypt" 32 #define foreach_ipsec_output_next \ 33 _(DROP, "error-drop") \ 34 _(ESP_ENCRYPT, ESP_NODE) 36 #define _(v, s) IPSEC_OUTPUT_NEXT_##v, 39 foreach_ipsec_output_next
42 } ipsec_output_next_t;
45 #define foreach_ipsec_output_error \ 46 _(RX_PKTS, "IPSec pkts received") \ 47 _(POLICY_DISCARD, "IPSec policy discard") \ 48 _(POLICY_NO_MATCH, "IPSec policy (no match)") \ 49 _(POLICY_PROTECT, "IPSec policy protect") \ 50 _(POLICY_BYPASS, "IPSec policy bypass") \ 51 _(ENCAPS_FAILED, "IPSec encapsulation failed") 56 #define _(sym,str) IPSEC_OUTPUT_ERROR_##sym, 57 foreach_ipsec_output_error
60 } ipsec_output_error_t;
62 static char *ipsec_output_error_strings[] = {
63 #define _(sym,string) string, 64 foreach_ipsec_output_error
74 } ipsec_output_trace_t;
78 format_ipsec_output_trace (
u8 * s, va_list * args)
82 ipsec_output_trace_t *t = va_arg (*args, ipsec_output_trace_t *);
86 s =
format (s,
"spd %u ", t->spd_id);
111 if (la < clib_net_to_host_u32 (p->
laddr.
start.ip4.as_u32))
114 if (la > clib_net_to_host_u32 (p->
laddr.
stop.ip4.as_u32))
117 if (ra < clib_net_to_host_u32 (p->
raddr.
start.ip4.as_u32))
120 if (ra > clib_net_to_host_u32 (p->
raddr.
stop.ip4.as_u32))
123 if (
PREDICT_FALSE ((pr != IP_PROTOCOL_TCP) && (pr != IP_PROTOCOL_UDP)))
126 if (lp < p->lport.start)
132 if (rp < p->rport.start)
176 if (
PREDICT_FALSE ((pr != IP_PROTOCOL_TCP) && (pr != IP_PROTOCOL_UDP)))
179 if (lp < p->lport.start)
185 if (rp < p->rport.start)
203 u32 *from, *to_next = 0;
204 u32 n_left_from, sw_if_index0, last_sw_if_index = (
u32) ~ 0;
205 u32 next_node_index = (
u32) ~ 0, last_next_node_index = (
u32) ~ 0;
209 u64 nc_protect = 0, nc_bypass = 0, nc_discard = 0, nc_nomatch = 0;
214 while (n_left_from > 0)
227 iph_offset =
vnet_buffer (b0)->ip.save_rewrite_length;
238 last_sw_if_index = sw_if_index0;
249 (
"packet received from %U port %u to %U port %u spd_id %u",
256 p0 = ipsec_output_ip6_policy_match (spd0,
273 clib_net_to_host_u16 (udp0->
dst_port));
274 clib_warning (
"sw_if_index0 %u spd_index0 %u spd_id %u",
275 sw_if_index0, spd_index0, spd0->
id);
278 p0 = ipsec_output_policy_match (spd0, ip0->
protocol,
291 if (p0->
policy == IPSEC_POLICY_ACTION_PROTECT)
309 else if (p0->
policy == IPSEC_POLICY_ACTION_BYPASS)
351 if (
PREDICT_FALSE ((last_next_node_index != next_node_index) || f == 0))
357 last_next_node_index = next_node_index;
369 ipsec_output_trace_t *tr =
372 tr->spd_id = spd0->
id;
378 IPSEC_OUTPUT_ERROR_POLICY_PROTECT, nc_protect);
380 IPSEC_OUTPUT_ERROR_POLICY_BYPASS, nc_bypass);
382 IPSEC_OUTPUT_ERROR_POLICY_DISCARD, nc_discard);
384 IPSEC_OUTPUT_ERROR_POLICY_NO_MATCH,
393 return ipsec_output_inline (vm, node, frame, 0);
398 .function = ipsec_output_ip4_node_fn,
399 .name =
"ipsec-output-ip4",
400 .vector_size =
sizeof (
u32),
401 .format_trace = format_ipsec_output_trace,
404 .n_errors =
ARRAY_LEN(ipsec_output_error_strings),
405 .error_strings = ipsec_output_error_strings,
407 .n_next_nodes = IPSEC_OUTPUT_N_NEXT,
409 #define _(s,n) [IPSEC_OUTPUT_NEXT_##s] = n, 410 foreach_ipsec_output_next
421 return ipsec_output_inline (vm, node, frame, 1);
426 .function = ipsec_output_ip6_node_fn,
427 .name =
"ipsec-output-ip6",
428 .vector_size =
sizeof (
u32),
429 .format_trace = format_ipsec_output_trace,
432 .n_errors =
ARRAY_LEN(ipsec_output_error_strings),
433 .error_strings = ipsec_output_error_strings,
435 .n_next_nodes = IPSEC_OUTPUT_N_NEXT,
437 #define _(s,n) [IPSEC_OUTPUT_NEXT_##s] = n, 438 foreach_ipsec_output_next
459 .vector_size =
sizeof (
u32),
461 .name =
"ipsec-output-ip4",
465 .vector_size =
sizeof (
u32),
467 .name =
"ipsec-output-ip6",
u64 packets
packet counter
sll srl srl sll sra u16x4 i
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static int ip4_header_bytes(ip4_header_t *i)
struct _vlib_node_registration vlib_node_registration_t
u32 * ipv4_outbound_policies
uword * spd_index_by_sw_if_index
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define clib_warning(format, args...)
ipsec_policy_t * policies
u32 error_drop_node_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline u32 get_next_output_feature_node_index(vlib_buffer_t *b, vlib_node_runtime_t *nr)
ip46_address_range_t laddr
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
vlib_node_registration_t ipsec_output_node
(constructor) VLIB_REGISTER_NODE (ipsec_output_node)
u32 esp_encrypt_node_index
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void * ip6_next_header(ip6_header_t *i)
ip46_address_range_t raddr
#define VLIB_BUFFER_IS_TRACED
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static uword ipsec_output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 * ipv6_outbound_policies
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
#define vec_foreach(var, vec)
Vector iterator.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.