|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
25 #define foreach_ipsec_output_error \
26 _(RX_PKTS, "IPSec pkts received") \
27 _(POLICY_DISCARD, "IPSec policy discard") \
28 _(POLICY_NO_MATCH, "IPSec policy (no match)") \
29 _(POLICY_PROTECT, "IPSec policy protect") \
30 _(POLICY_BYPASS, "IPSec policy bypass") \
31 _(ENCAPS_FAILED, "IPSec encapsulation failed")
35 #define _(sym,str) IPSEC_OUTPUT_ERROR_##sym,
42 #define _(sym,string) string,
83 if (ra < clib_net_to_host_u32 (p->
raddr.
start.ip4.as_u32))
86 if (ra > clib_net_to_host_u32 (p->
raddr.
stop.ip4.as_u32))
89 if (la < clib_net_to_host_u32 (p->
laddr.
start.ip4.as_u32))
92 if (la > clib_net_to_host_u32 (p->
laddr.
stop.ip4.as_u32))
96 ((pr != IP_PROTOCOL_TCP) && (pr != IP_PROTOCOL_UDP)
97 && (pr != IP_PROTOCOL_SCTP)))
100 if (lp < p->lport.start)
106 if (rp < p->rport.start)
121 if ((memcmp (
a->as_u64, la->as_u64, 2 * sizeof (
u64)) >= 0) &&
122 (memcmp (
a->as_u64, ua->as_u64, 2 * sizeof (
u64)) <= 0))
130 ip6_address_t * ra,
u16 lp,
u16 rp,
u8 pr)
152 ((pr != IP_PROTOCOL_TCP) && (pr != IP_PROTOCOL_UDP)
153 && (pr != IP_PROTOCOL_SCTP)))
156 if (lp < p->lport.start)
162 if (rp < p->rport.start)
182 u32 next_node_index = (
u32) ~ 0, last_next_node_index = (
u32) ~ 0;
187 u64 nc_protect = 0, nc_bypass = 0, nc_discard = 0, nc_nomatch = 0;
215 iph_offset =
vnet_buffer (b0)->ip.save_rewrite_length;
226 last_sw_if_index = sw_if_index0;
237 (
"packet received from %U port %u to %U port %u spd_id %u",
260 clib_net_to_host_u16 (udp0->
dst_port));
261 clib_warning (
"sw_if_index0 %u spd_index0 %u spd_id %u",
262 sw_if_index0, spd_index0, spd0->
id);
275 tcp0 = (
void *) udp0;
279 pi0 = p0 -
im->policies;
291 bytes0 = clib_net_to_host_u16 (ip0->
length);
294 if (p0->
policy == IPSEC_POLICY_ACTION_PROTECT)
301 next_node_index =
im->esp6_encrypt_node_index;
303 next_node_index =
im->esp4_encrypt_node_index;
305 next_node_index =
im->ah6_encrypt_node_index;
307 next_node_index =
im->ah4_encrypt_node_index;
323 VNET_BUFFER_OFFLOAD_F_TCP_CKSUM))
326 vm, b0, ip6_0, &bogus);
329 VNET_BUFFER_OFFLOAD_F_UDP_CKSUM))
332 vm, b0, ip6_0, &bogus);
338 VNET_BUFFER_OFFLOAD_F_IP_CKSUM))
343 VNET_BUFFER_OFFLOAD_F_TCP_CKSUM))
349 VNET_BUFFER_OFFLOAD_F_UDP_CKSUM))
358 else if (p0->
policy == IPSEC_POLICY_ACTION_BYPASS)
366 next_node_index =
im->error_drop_node_index;
375 next_node_index =
im->error_drop_node_index;
381 if (
PREDICT_FALSE ((last_next_node_index != next_node_index) ||
f == 0))
387 last_next_node_index = next_node_index;
415 IPSEC_OUTPUT_ERROR_POLICY_PROTECT, nc_protect);
417 IPSEC_OUTPUT_ERROR_POLICY_BYPASS, nc_bypass);
419 IPSEC_OUTPUT_ERROR_POLICY_DISCARD, nc_discard);
421 IPSEC_OUTPUT_ERROR_POLICY_NO_MATCH,
435 .name =
"ipsec4-output-feature",
436 .vector_size =
sizeof (
u32),
445 #define _(s,n) [IPSEC_OUTPUT_NEXT_##s] = n,
460 .name =
"ipsec6-output-feature",
461 .vector_size =
sizeof (
u32),
470 #define _(s,n) [IPSEC_OUTPUT_NEXT_##s] = n,
static u8 * format_ipsec_output_trace(u8 *s, va_list *args)
vnet_interface_main_t * im
ipsec_protocol_t protocol
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
ip46_address_range_t raddr
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#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)
struct _tcp_header tcp_header_t
@ VLIB_NODE_TYPE_INTERNAL
vlib_main_t vlib_node_runtime_t * node
vlib_node_registration_t ipsec6_output_node
(constructor) VLIB_REGISTER_NODE (ipsec6_output_node)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
static void * ip6_next_header(ip6_header_t *i)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static ipsec_policy_t * ipsec6_output_policy_match(ipsec_spd_t *spd, ip6_address_t *la, ip6_address_t *ra, u16 lp, u16 rp, u8 pr)
u32 id
the User's ID for this policy
#define CLIB_PREFETCH(addr, size, type)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define VLIB_NODE_FN(node)
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
#define VLIB_NODE_FLAG_TRACE
static_always_inline void vnet_buffer_offload_flags_clear(vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
static void vlib_prefetch_combined_counter(const vlib_combined_counter_main_t *cm, u32 thread_index, u32 index)
Pre-fetch a per-thread combined counter for the given object index.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
sll srl srl sll sra u16x4 i
static char * ipsec_output_error_strings[]
#define ALWAYS_ASSERT(truth)
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
static ipsec_policy_t * ipsec_output_policy_match(ipsec_spd_t *spd, u8 pr, u32 la, u32 ra, u16 lp, u16 rp)
description fragment has unexpected format
vlib_combined_counter_main_t ipsec_spd_policy_counters
Policy packet & bytes counters.
static uword ip6_addr_match_range(ip6_address_t *a, ip6_address_t *la, ip6_address_t *ua)
#define vec_foreach(var, vec)
Vector iterator.
A Secruity Policy Database.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define foreach_ipsec_output_error
ip46_address_range_t laddr
#define foreach_ipsec_output_next
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u16 ip4_header_checksum(ip4_header_t *i)
#define clib_warning(format, args...)
u32 * policies[IPSEC_SPD_POLICY_N_TYPES]
vectors for each of the policy types
static int ip4_header_bytes(const ip4_header_t *i)
ipsec_policy_action_t policy
static uword ipsec_output_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ipv6)
vlib_node_registration_t ipsec4_output_node
(constructor) VLIB_REGISTER_NODE (ipsec4_output_node)
vl_api_fib_path_type_t type
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
#define vlib_prefetch_buffer_data(b, type)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)