26 #define foreach_ipsec_output_next \ 27 _(DROP, "error-drop") \ 28 _(ESP_ENCRYPT, "esp-encrypt") 30 #define _(v, s) IPSEC_OUTPUT_NEXT_##v, 33 foreach_ipsec_output_next
36 } ipsec_output_next_t;
39 #define foreach_ipsec_output_error \ 40 _(RX_PKTS, "IPSec pkts received") \ 41 _(POLICY_DISCARD, "IPSec policy discard") \ 42 _(POLICY_NO_MATCH, "IPSec policy (no match)") \ 43 _(POLICY_PROTECT, "IPSec policy protect") \ 44 _(POLICY_BYPASS, "IPSec policy bypass") \ 45 _(ENCAPS_FAILED, "IPSec encapsulation failed") 49 #define _(sym,str) IPSEC_OUTPUT_ERROR_##sym, 50 foreach_ipsec_output_error
53 } ipsec_output_error_t;
55 static char * ipsec_output_error_strings[] = {
56 #define _(sym,string) string, 57 foreach_ipsec_output_error
65 } ipsec_output_trace_t;
68 static u8 * format_ipsec_output_trace (
u8 * s, va_list * args)
72 ipsec_output_trace_t * t = va_arg (*args, ipsec_output_trace_t *);
76 s =
format (s,
"spd %u ", t->spd_id);
89 count_trailing_zeros(next_feature,
vnet_buffer(b)->output_features.bitmap);
91 vnet_buffer(b)->output_features.bitmap &= ~(1 << next_feature);
107 if (la < clib_net_to_host_u32(p->
laddr.
start.ip4.as_u32))
110 if (la > clib_net_to_host_u32(p->
laddr.
stop.ip4.as_u32))
113 if (ra < clib_net_to_host_u32(p->
raddr.
start.ip4.as_u32))
116 if (ra > clib_net_to_host_u32(p->
raddr.
stop.ip4.as_u32))
119 if (
PREDICT_FALSE((pr != IP_PROTOCOL_TCP) && (pr != IP_PROTOCOL_UDP)))
122 if (lp < p->lport.start)
128 if (rp < p->rport.start)
171 if (
PREDICT_FALSE((pr != IP_PROTOCOL_TCP) && (pr != IP_PROTOCOL_UDP)))
174 if (lp < p->lport.start)
180 if (rp < p->rport.start)
199 u32 * from, * to_next = 0;
200 u32 n_left_from, sw_if_index0, last_sw_if_index = (
u32) ~0;
201 u32 next_node_index = (
u32)~0, last_next_node_index = (
u32) ~0;
205 u64 nc_protect = 0, nc_bypass = 0, nc_discard = 0, nc_nomatch = 0;
210 while (n_left_from > 0)
252 last_sw_if_index = sw_if_index0;
259 clib_warning(
"packet received from %U port %u to %U port %u spd_id %u",
261 clib_net_to_host_u16(udp0->
src_port),
263 clib_net_to_host_u16(udp0->
dst_port),
267 p0 = ipsec_output_ip6_policy_match(spd0,
270 clib_net_to_host_u16(udp0->
src_port),
271 clib_net_to_host_u16(udp0->
dst_port),
282 clib_net_to_host_u16(udp0->
dst_port));
284 sw_if_index0, spd_index0, spd0->
id);
287 p0 = ipsec_output_policy_match(spd0, ip0->
protocol,
290 clib_net_to_host_u16(udp0->
src_port),
291 clib_net_to_host_u16(udp0->
dst_port));
296 if (p0->
policy == IPSEC_POLICY_ACTION_PROTECT)
313 else if (p0->
policy == IPSEC_POLICY_ACTION_BYPASS)
354 if (
PREDICT_FALSE((last_next_node_index != next_node_index)))
360 last_next_node_index = next_node_index;
371 ipsec_output_trace_t *tr =
vlib_add_trace (vm, node, b0,
sizeof (*tr));
373 tr->spd_id = spd0->
id;
379 IPSEC_OUTPUT_ERROR_POLICY_PROTECT, nc_protect);
381 IPSEC_OUTPUT_ERROR_POLICY_BYPASS, nc_bypass);
383 IPSEC_OUTPUT_ERROR_POLICY_DISCARD, nc_discard);
385 IPSEC_OUTPUT_ERROR_POLICY_NO_MATCH, nc_nomatch);
391 .name =
"ipsec-output",
392 .vector_size =
sizeof (
u32),
393 .format_trace = format_ipsec_output_trace,
396 .n_errors =
ARRAY_LEN(ipsec_output_error_strings),
397 .error_strings = ipsec_output_error_strings,
399 .n_next_nodes = IPSEC_OUTPUT_N_NEXT,
401 #define _(s,n) [IPSEC_OUTPUT_NEXT_##s] = n, 403 foreach_ipsec_output_next
422 .vector_size =
sizeof (
u32),
424 .name =
"ipsec-output",
sll srl srl sll sra u16x4 i
#define INTF_OUTPUT_FEAT_DONE
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
struct _vlib_node_registration vlib_node_registration_t
u32 * ipv4_outbound_policies
always_inline void * ip6_next_header(ip6_header_t *i)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
uword * spd_index_by_sw_if_index
#define clib_warning(format, args...)
always_inline int ip4_header_bytes(ip4_header_t *i)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
ipsec_policy_t * policies
static_always_inline u32 get_next_output_feature_node_index(vnet_main_t *vnm, vlib_buffer_t *b)
u32 error_drop_node_index
#define pool_elt_at_index(p, i)
always_inline void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
ip46_address_range_t laddr
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
vlib_node_registration_t ipsec_output_node
(constructor) VLIB_REGISTER_NODE (ipsec_output_node)
u32 esp_encrypt_node_index
ip46_address_range_t raddr
#define VLIB_BUFFER_IS_TRACED
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static uword ipsec_output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 * ipv6_outbound_policies
#define foreach_intf_output_feat
#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.
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.