|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
44 return format (s,
"SRv6-AD-Flow-localsid: localsid_index %d",
58 return format (s,
"SRv6-AD-Flow-rewrite: cache is empty");
72 #define foreach_srv6_ad_flow_rewrite_counter \
73 _ (PROCESSED, "srv6-ad-flow rewritten packets") \
74 _ (NO_RW, "(Error) No header for rewriting.")
78 #define _(sym, str) SRV6_AD_FLOW_REWRITE_COUNTER_##sym,
85 #define _(sym, string) string,
160 clib_bihash_add_del_40_8 (&ls->
ftable, &kv, 0);
177 f64 entry_timeout_time;
180 if (~0 != oldest_index)
186 if (
now >= entry_timeout_time)
225 u64 entry_timeout_time;
230 if (
ctx->now >= entry_timeout_time)
245 ip6_ext_header_t *first_hdr,
246 u8 first_hdr_type,
u8 expected_hdr_type,
247 u32 *encap_length,
u8 **found_hdr)
251 *found_hdr = (
void *) first_hdr;
255 u8 ext_hdr_type = first_hdr_type;
256 ip6_ext_header_t *ext_hdr = first_hdr;
270 *encap_length += ext_hdr_length;
271 ext_hdr_type = ext_hdr->next_hdr;
273 while (ext_hdr_type != expected_hdr_type &&
ip6_ext_hdr (ext_hdr_type))
282 *encap_length += ext_hdr_length;
283 ext_hdr_type = ext_hdr->next_hdr;
286 if (ext_hdr_type != expected_hdr_type)
310 ip6_address_t *new_dst;
313 clib_bihash_40_8_t *
h = &ls_mem->
ftable;
322 IP_PROTOCOL_IPV6_ROUTE, &encap_length,
327 srh->segments_left == 0))
331 *cnt_idx = ls_mem->
index;
336 srh->segments_left -= 1;
337 new_dst = (ip6_address_t *) (srh->segments) + srh->segments_left;
338 ip->dst_address.as_u64[0] = new_dst->as_u64[0];
339 ip->dst_address.as_u64[1] = new_dst->as_u64[1];
347 IP_PROTOCOL_IPV6, &encap_length, (
u8 **) &ulh);
355 *cnt_idx = ls_mem->
index;
367 ulh->protocol == IP_PROTOCOL_TCP))
374 kv.
key[0] = ulh->src_address.as_u64[0];
375 kv.
key[1] = ulh->src_address.as_u64[1];
376 kv.
key[2] = ulh->dst_address.as_u64[0];
377 kv.
key[3] = ulh->dst_address.as_u64[1];
381 if (!clib_bihash_search_40_8 (
h, &kv, &
value))
395 *cnt_idx = ls_mem->
index;
402 e->
key.
s_addr.ip6.as_u64[0] = ulh->src_address.as_u64[0];
403 e->
key.
s_addr.ip6.as_u64[1] = ulh->src_address.as_u64[1];
404 e->
key.
d_addr.ip6.as_u64[0] = ulh->dst_address.as_u64[0];
405 e->
key.
d_addr.ip6.as_u64[1] = ulh->dst_address.as_u64[1];
414 clib_bihash_add_or_overwrite_stale_40_8 (
h, &kv,
448 ip6_address_t *new_dst;
451 clib_bihash_40_8_t *
h = &ls_mem->
ftable;
460 IP_PROTOCOL_IPV6_ROUTE, &encap_length,
465 srh->segments_left == 0))
469 *cnt_idx = ls_mem->
index;
474 srh->segments_left -= 1;
475 new_dst = (ip6_address_t *) (srh->segments) + srh->segments_left;
476 ip->dst_address.as_u64[0] = new_dst->as_u64[0];
477 ip->dst_address.as_u64[1] = new_dst->as_u64[1];
485 IP_PROTOCOL_IP_IN_IP, &encap_length, (
u8 **) &ulh);
493 *cnt_idx = ls_mem->
index;
505 ulh->protocol == IP_PROTOCOL_TCP))
512 kv.
key[0] = *((
u64 *) &ulh->address_pair);
519 if (!clib_bihash_search_40_8 (
h, &kv, &
value))
533 *cnt_idx = ls_mem->
index;
550 clib_bihash_add_or_overwrite_stale_40_8 (
h, &kv,
650 n_left_to_next, bi0, next0);
655 return frame->n_vectors;
660 .name =
"srv6-ad-flow-localsid",
661 .vector_size =
sizeof (
u32),
730 b0->
error =
node->errors[SRV6_AD_FLOW_REWRITE_COUNTER_NO_RW];
739 ip0_encap->
protocol == IP_PROTOCOL_TCP))
753 if (clib_bihash_search_40_8 (&ls0_mem->
ftable, &kv0, &value0) <
758 b0->
error =
node->errors[SRV6_AD_FLOW_REWRITE_COUNTER_NO_RW];
779 ip0_encap->checksum + clib_host_to_net_u16 (0x0100);
780 checksum0 += checksum0 >= 0xffff;
781 ip0_encap->checksum = checksum0;
785 clib_net_to_host_u16 (ip0_encap->length);
804 sizeof tr->
src.as_u8);
806 sizeof tr->
dst.as_u8);
819 n_left_to_next, bi0, next0);
829 SRV6_AD_FLOW_REWRITE_COUNTER_PROCESSED,
832 return frame->n_vectors;
837 .name =
"srv6-ad4-flow-rewrite",
838 .vector_size =
sizeof (
u32),
903 b0->
error =
node->errors[SRV6_AD_FLOW_REWRITE_COUNTER_NO_RW];
912 if (
PREDICT_TRUE (ip0_encap->protocol == IP_PROTOCOL_UDP ||
913 ip0_encap->protocol == IP_PROTOCOL_TCP))
920 kv0.
key[0] = ip0_encap->src_address.as_u64[0];
921 kv0.
key[1] = ip0_encap->src_address.as_u64[1];
922 kv0.
key[2] = ip0_encap->dst_address.as_u64[0];
923 kv0.
key[3] = ip0_encap->dst_address.as_u64[1];
927 if (clib_bihash_search_40_8 (&ls0_mem->
ftable, &kv0, &value0))
931 b0->
error =
node->errors[SRV6_AD_FLOW_REWRITE_COUNTER_NO_RW];
950 ip0_encap->hop_limit -= 1;
954 clib_net_to_host_u16 (ip0_encap->payload_length);
973 sizeof tr->
src.as_u8);
975 sizeof tr->
dst.as_u8);
988 n_left_to_next, bi0, next0);
998 SRV6_AD_FLOW_REWRITE_COUNTER_PROCESSED,
1001 return frame->n_vectors;
1006 .name =
"srv6-ad6-flow-rewrite",
1007 .vector_size =
sizeof (
u32),
int ad_flow_is_idle_entry_cb(clib_bihash_kv_40_8_t *kv, void *arg)
static u32 clib_dlist_remove_head(dlist_elt_t *pool, u32 head_index)
static_always_inline int end_ad_flow_walk_expect_first_hdr(vlib_main_t *vm, vlib_buffer_t *b, ip6_ext_header_t *first_hdr, u8 first_hdr_type, u8 expected_hdr_type, u32 *encap_length, u8 **found_hdr)
Function doing SRH processing for AD behavior.
vlib_combined_counter_main_t sr_ls_valid_counters
vl_api_ip_port_and_mask_t dst_port
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
nat44_ei_hairpin_src_next_t next_index
srv6_ad_flow_entry_t * cache
Cache table.
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.
@ VLIB_NODE_TYPE_INTERNAL
void * plugin_mem
Memory to be used by the plugin callback functions.
#define ip6_ext_header_len(p)
vlib_main_t vlib_node_runtime_t * node
vlib_node_registration_t srv6_ad_flow_localsid_node
(constructor) VLIB_REGISTER_NODE (srv6_ad_flow_localsid_node)
static u32 ad_flow_value_get_session_index(clib_bihash_kv_40_8_t *value)
static char * srv6_ad_flow_rewrite_counter_strings[]
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
@ SRV6_AD_FLOW_LOCALSID_NEXT_ERROR
@ SRV6_AD_FLOW_LOCALSID_NEXT_PUNT
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
#define pool_put_index(p, i)
Free pool element with given index.
static_always_inline int ad_flow_lru_insert(srv6_ad_flow_localsid_t *ls, srv6_ad_flow_entry_t *e, f64 now)
vlib_combined_counter_main_t rw_valid_counters
Valid rewrite counters.
@ SRV6_AD_FLOW_REWRITE_N_NEXT
@ SRV6_AD_FLOW_LOCALSID_NEXT_REWRITE6
u32 * sw_iface_localsid6
Retrieve local SID from iface.
static void ad_flow_entry_delete(srv6_ad_flow_localsid_t *ls, srv6_ad_flow_entry_t *e, int lru_delete)
static uword srv6_ad4_flow_rewrite_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Graph node for applying a SR policy into an IPv6 packet.
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static void ad_flow_entry_update_lru(srv6_ad_flow_localsid_t *ls, srv6_ad_flow_entry_t *e)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vlib_combined_counter_main_t sr_ls_invalid_counters
vlib_error_t error
Error code for buffers to be enqueued to error handler.
clib_bihash_40_8_t ftable
Flow table.
#define VLIB_NODE_FLAG_TRACE
@ SRV6_AD_FLOW_REWRITE_N_COUNTERS
static u8 * format_srv6_ad_flow_rewrite_trace(u8 *s, va_list *args)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static int vlib_object_within_buffer_data(vlib_main_t *vm, vlib_buffer_t *b, void *obj, size_t len)
#define static_always_inline
static_always_inline int ad_flow_lru_free_one(srv6_ad_flow_localsid_t *ls, f64 now)
#define SRV6_AD_CACHE_TIMEOUT
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
srv6_ad_flow_main_t srv6_ad_flow_main
vl_api_ip_port_and_mask_t src_port
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
static_always_inline void end_ad_flow_processing_v4(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip, srv6_ad_flow_localsid_t *ls_mem, u32 *next, vlib_combined_counter_main_t **cnt, u32 *cnt_idx, f64 now)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
u32 nh_adj
Adjacency index for out.
srv6_ad_flow_localsid_next_t
#define foreach_srv6_ad_flow_rewrite_counter
struct _vlib_node_registration vlib_node_registration_t
ip6_sr_localsid_t * localsids
vlib_combined_counter_main_t sid_bypass_counters
Packets/bytes bypassing NF.
static u8 * format_srv6_ad_flow_localsid_trace(u8 *s, va_list *args)
struct srv6_ad_flow_entry_t::@134 key
@ SRV6_AD_FLOW_REWRITE_NEXT_LOOKUP
Segment Routing main datastructure.
vlib_combined_counter_main_t sid_punt_counters
Packets/bytes punted.
#define vec_free(V)
Free vector's memory (no header).
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
static uword srv6_ad6_flow_rewrite_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Graph node for applying a SR policy into an IPv6 packet.
@ SRV6_AD_FLOW_LOCALSID_N_NEXT
description fragment has unexpected format
A collection of combined counters.
u32 * sw_iface_localsid4
Retrieve local SID from iface.
vlib_put_next_frame(vm, node, next_index, 0)
static uword srv6_ad_flow_localsid_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
SRv6 AD Localsid graph node.
#define VLIB_BUFFER_PRE_DATA_SIZE
static u8 ip6_ext_hdr(u8 nexthdr)
vlib_combined_counter_main_t sid_cache_full_counters
#define ROUTING_HEADER_TYPE_SR
static_always_inline srv6_ad_flow_entry_t * ad_flow_entry_alloc(srv6_ad_flow_localsid_t *ls, f64 now)
static uword pool_elts(void *v)
Number of active elements in a pool.
@ SRV6_AD_FLOW_REWRITE_NEXT_ERROR
vlib_combined_counter_main_t rw_invalid_counters
Invalid rewrite counters.
static_always_inline void end_ad_flow_processing_v6(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip, srv6_ad_flow_localsid_t *ls_mem, u32 *next, vlib_combined_counter_main_t **cnt, u32 *cnt_idx, f64 now)
Function doing SRH processing for per-flow AD behavior (IPv6 inner traffic)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vlib_node_registration_t srv6_ad6_flow_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_ad6_flow_rewrite_node)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void clib_dlist_addtail(dlist_elt_t *pool, u32 head_index, u32 new_index)
static void clib_dlist_addhead(dlist_elt_t *pool, u32 head_index, u32 new_index)
static f64 vlib_time_now(vlib_main_t *vm)
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
vlib_node_registration_t srv6_ad4_flow_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_ad4_flow_rewrite_node)
vl_api_interface_index_t sw_if_index
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
@ SRV6_AD_FLOW_LOCALSID_NEXT_REWRITE4
vl_api_fib_path_type_t type
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
@ SRV6_AD_FLOW_LOCALSID_NEXT_BYPASS
srv6_ad_flow_rewrite_counters
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,...)
srv6_ad_flow_rewrite_next_t