21 u32 dst_address_u32,
u32 dst_address_length,
39 hash = _hash_set3 (hash, dst_address_u32,
79 u32 dst_address, dst_address_length, adj_index, old_adj_index;
108 dst_address_length, adj_index);
113 if (old_adj_index == adj_index
123 is_del ? old_adj_index : adj_index,
128 && old_adj_index != ~0
129 && old_adj_index != adj_index)
147 u32 address_length : 6;
154 ip4_route_t * routes = 0, * r;
164 x.address_length =
i;
168 x.address.data_u32 = p->
key;
176 memset (&a, 0,
sizeof (a));
209 ip_prefix_t * src_prefix,
u32 table_id,
225 memset(&src, 0,
sizeof(src));
240 memset(&dst_adj, 0,
sizeof(dst_adj));
243 dst_adj.rewrite_header.sw_if_index = src_fib - lgm->
ip4_src_fibs;
248 memset(&a, 0,
sizeof(a));
271 clib_warning(
"Trying to delete inexistent dst route for %U. Aborting",
281 memset(&a, 0,
sizeof(a));
297 dst_adjp->rewrite_header.sw_if_index);
308 memset(&a, 0,
sizeof(a));
325 ip_prefix_t * src_prefix,
u32 table_id)
338 memset(&src, 0,
sizeof(src));
356 BVT(clib_bihash_kv) kv, value;
361 for (i = 0; i < len; i++)
366 ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
368 mask = &fib->
fib_masks[dst_address_length];
372 kv.key[2] = dst_address_length;
389 int dst_address_length = 128 - i;
390 vec_add1 (fib->prefix_lengths_in_search_order, dst_address_length);
402 u32 dst_address_length, adj_index;
404 u32 old_adj_index = ~0;
405 BVT(clib_bihash_kv) kv, value;
434 128 - dst_address_length, 0);
444 128 - dst_address_length, 1);
448 kv.key[0] = dst_address.
as_u64[0];
449 kv.key[1] = dst_address.
as_u64[1];
450 kv.key[2] = dst_address_length;
453 old_adj_index = value.value;
463 kv.value = adj_index;
469 if (old_adj_index == adj_index
480 && old_adj_index != ~0
481 && old_adj_index != adj_index)
498 for (j = 0; j < i0; j++)
522 ip_prefix_t * src_prefix,
u32 table_id,
538 memset(&src, 0,
sizeof(src));
541 adj_index =
ip6_get_route (lgm->
im6, table_id, 0, &dst, dst_address_length);
551 memset(src_fib, 0,
sizeof(src_fib[0]));
554 memset(&dst_adj, 0,
sizeof(dst_adj));
557 dst_adj.rewrite_header.sw_if_index = src_fib - lgm->
ip6_src_fibs;
562 memset(&a, 0,
sizeof(a));
585 clib_warning(
"Trying to delete inexistent dst route for %U. Aborting",
595 memset(&a, 0,
sizeof(a));
611 dst_adjp->rewrite_header.sw_if_index);
623 memset(&a, 0,
sizeof(a));
640 ip_prefix_t * src_prefix,
u32 table_id)
653 memset(&src, 0,
sizeof(src));
656 adj_index =
ip6_get_route (lgm->
im6, table_id, 0, &dst, dst_address_length);
667 ip_prefix_t * src_prefix,
u32 table_id,
680 ip_prefix_t * src_prefix,
u32 table_id)
686 return (adj_index == 0) ? 0 : adj_index[0];
716 u32 * src_adj_index1)
749 u32 n_left_from, next_index, * from, * to_next;
757 while (n_left_from > 0)
763 while (n_left_from >= 4 && n_left_to_next >= 2)
768 u32 dst_adj_index0, src_adj_index0, src_fib_index0, dst_adj_index1,
769 src_adj_index1, src_fib_index1;
773 next0 = next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
811 src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
812 src_fib_index1 = dst_adj1->rewrite_header.sw_if_index;
816 && src_fib_index1 != (
u32) ~0))
820 &src_adj_index0, &src_adj_index1);
833 src_adj0->rewrite_header.sw_if_index;
835 src_adj1->rewrite_header.sw_if_index;
839 if (src_fib_index0 != (
u32) ~0)
847 src_adj0->rewrite_header.sw_if_index;
849 if (src_fib_index1 != (
u32) ~0)
857 src_adj1->rewrite_header.sw_if_index;
862 n_left_to_next, bi0, bi1, next0,
866 while (n_left_from > 0 && n_left_to_next > 0)
870 u32 bi0, dst_adj_index0, src_adj_index0, src_fib_index0;
871 u32 next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
887 src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
901 src_adj0->rewrite_header.sw_if_index;
905 n_left_to_next, bi0, next0);
914 .name =
"lgpe-ip4-lookup",
915 .vector_size =
sizeof (
u32),
921 #define _(sym,str) [LGPE_IP4_LOOKUP_NEXT_##sym] = str, 933 BVT(clib_bihash_kv) kv, value;
938 for (i = 0; i < len; i++)
943 ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
945 mask = &fib->
fib_masks[dst_address_length];
949 kv.key[2] = dst_address_length;
963 u32 n_left_from, next_index, * from, * to_next;
971 while (n_left_from > 0)
977 while (n_left_from >= 4 && n_left_to_next >= 2)
982 u32 dst_adj_index0, src_adj_index0, src_fib_index0, dst_adj_index1,
983 src_adj_index1, src_fib_index1;
987 next0 = next1 = LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
1009 n_left_to_next -= 2;
1025 src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
1026 src_fib_index1 = dst_adj1->rewrite_header.sw_if_index;
1030 && src_fib_index1 != (
u32) ~0))
1049 src_adj0->rewrite_header.sw_if_index;
1051 src_adj1->rewrite_header.sw_if_index;
1055 if (src_fib_index0 != (
u32) ~0)
1063 src_adj0->rewrite_header.sw_if_index;
1065 if (src_fib_index1 != (
u32) ~0)
1073 src_adj1->rewrite_header.sw_if_index;
1078 n_left_to_next, bi0, bi1, next0,
1082 while (n_left_from > 0 && n_left_to_next > 0)
1086 u32 bi0, dst_adj_index0, src_adj_index0, src_fib_index0;
1087 u32 next0 = LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
1095 n_left_to_next -= 1;
1103 src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
1118 src_adj0->rewrite_header.sw_if_index;
1122 n_left_to_next, bi0, next0);
1131 .name =
"lgpe-ip6-lookup",
1132 .vector_size =
sizeof (
u32),
1138 #define _(sym,str) [LGPE_IP6_LOOKUP_NEXT_##sym] = str,
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
always_inline uword round_pow2(uword x, uword pow2)
always_inline ip4_fib_mtrie_leaf_t ip4_fib_mtrie_lookup_step(ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t current_leaf, ip4_address_t *dst_address, u32 dst_address_byte_index)
sll srl srl sll sra u16x4 i
u32 ip4_lookup_next_lgpe_ip4_lookup
always_inline uword clib_bitmap_count_set_bits(uword *ai)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
ip_lookup_next_t lookup_next_index
always_inline u32 ip4_fib_mtrie_leaf_get_adj_index(ip4_fib_mtrie_leaf_t n)
always_inline void ip4_src_fib_lookup_two(lisp_gpe_main_t *lgm, u32 src_fib_index0, u32 src_fib_index1, ip4_address_t *addr0, ip4_address_t *addr1, u32 *src_adj_index0, u32 *src_adj_index1)
always_inline hash_t * hash_header(void *v)
#define ip_prefix_len(_a)
i32 dst_address_length_refcounts[129]
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *copy_adj, u32 n_adj, u32 *adj_index_return)
always_inline uword max_log2(uword x)
ip6_address_t fib_masks[129]
#define vec_bytes(v)
Number of data bytes in vector.
int BV() clib_bihash_add_del(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*add_v, int is_add)
#define ip_prefix_version(_a)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define IP4_FIB_MTRIE_LEAF_EMPTY
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static u8 ip4_fib_is_empty(ip4_fib_t *fib)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define IP6_FIB_DEFAULT_HASH_NUM_BUCKETS
void ip4_fib_mtrie_add_del_route(ip4_fib_t *fib, ip4_address_t dst_address, u32 dst_address_length, u32 adj_index, u32 is_del)
static int ip6_sd_fib_add_del_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id, ip_adjacency_t *add_adj, u8 is_add)
static int ip4_sd_fib_add_del_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id, ip_adjacency_t *add_adj, u8 is_add)
void BV() clib_bihash_init(BVT(clib_bihash)*h, char *name, u32 nbuckets, uword memory_size)
#define clib_warning(format, args...)
u32 table_index_or_table_id
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
void ip6_add_del_route(ip6_main_t *im, ip6_add_del_route_args_t *args)
void ip_del_adjacency(ip_lookup_main_t *lm, u32 adj_index)
ip6_src_fib_t * ip6_src_fibs
ip4_src_fib_t * ip4_src_fibs
int BV() clib_bihash_search(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*search_key, BVT(clib_bihash_kv)*valuep)
ip6_address_t dst_address
#define clib_bitmap_foreach(i, ai, body)
#define pool_elt_at_index(p, i)
always_inline uword lgpe_ip4_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
u8 * prefix_lengths_in_search_order
typedef CLIB_PACKED(struct ip4_route{ip4_address_t address;u32 address_length:6;u32 index:26;})
void * ip4_get_route(ip4_main_t *im, u32 fib_index_or_table_id, u32 flags, u8 *address, u32 address_length)
#define IP6_FIB_DEFAULT_HASH_MEMORY_SIZE
u32 ip6_lookup_next_lgpe_ip6_lookup
always_inline uword * clib_bitmap_set(uword *ai, uword i, uword value)
always_inline void hash_set_flags(void *v, uword flags)
u32 ip6_get_route(ip6_main_t *im, u32 fib_index_or_table_id, u32 flags, ip6_address_t *address, u32 address_length)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
static void * ip4_sd_fib_get_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
static void ip6_src_fib_init(ip6_src_fib_t *fib)
static void * ip4_sd_get_src_route(lisp_gpe_main_t *lgm, u32 src_fib_index, ip4_address_t *src, u32 address_length)
#define IP6_ROUTE_FLAG_KEEP_OLD_ADJACENCY
void ip4_mtrie_init(ip4_fib_mtrie_t *m)
#define CLIB_PREFETCH(addr, size, type)
int ip_sd_fib_add_del_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id, ip_adjacency_t *add_adj, u8 is_add)
u32 ip_sd_fib_get_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id)
static void ip4_fib_init_adj_index_by_dst_address(ip_lookup_main_t *lm, ip4_fib_t *fib, u32 address_length)
static u32 ip6_src_fib_lookup(lisp_gpe_main_t *lgm, u32 src_fib_index, ip6_address_t *src)
#define IP6_ROUTE_FLAG_DEL
lisp_gpe_main_t lisp_gpe_main
#define IP4_ROUTE_FLAG_DEL
always_inline uword hash_elts(void *v)
#define foreach_lgpe_ip4_lookup_next
#define hash_create(elts, value_bytes)
uword * non_empty_dst_address_length_bitmap
#define IP4_FIB_MTRIE_LEAF_ROOT
ip4_address_t dst_address
#define IP4_ROUTE_FLAG_ADD
static void ip4_sd_fib_add_del_src_route(lisp_gpe_main_t *lgm, ip4_add_del_route_args_t *a)
#define foreach_lgpe_ip6_lookup_next
static int BV() clib_bihash_search_inline_2(BVT(clib_bihash)*h, BVT(clib_bihash_kv)*search_key, BVT(clib_bihash_kv)*valuep)
always_inline ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
static void compute_prefix_lengths_in_search_order(ip6_src_fib_t *fib)
always_inline uword lgpe_ip6_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static void ip6_sd_fib_add_del_src_route(lisp_gpe_main_t *lgm, ip6_add_del_route_args_t *a)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
#define IP4_ROUTE_FLAG_FIB_INDEX
always_inline uword hash_value_bytes(hash_t *h)
u32 table_index_or_table_id
#define IP4_ROUTE_FLAG_KEEP_OLD_ADJACENCY
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
#define IP4_ROUTE_FLAG_TABLE_ID
#define IP6_ROUTE_FLAG_ADD
#define vec_foreach(var, vec)
Vector iterator.
u32 lookup_table_nbuckets
always_inline void ip6_address_mask(ip6_address_t *a, ip6_address_t *mask)
uword * adj_index_by_dst_address[33]
#define IP6_ROUTE_FLAG_TABLE_ID
always_inline uword pow2_mask(uword x)
void ip4_add_del_route(ip4_main_t *im, ip4_add_del_route_args_t *args)
always_inline void vlib_smp_unsafe_warning(void)
always_inline void ip4_src_fib_lookup_one(lisp_gpe_main_t *lgm, u32 src_fib_index0, ip4_address_t *addr0, u32 *src_adj_index0)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
#define HASH_FLAG_NO_AUTO_SHRINK
static u32 ip6_sd_get_src_route(lisp_gpe_main_t *lgm, u32 src_fib_index, ip6_address_t *src, u32 address_length)
static void ip4_sd_fib_set_adj_index(lisp_gpe_main_t *lgm, ip4_fib_t *fib, u32 flags, u32 dst_address_u32, u32 dst_address_length, u32 adj_index)
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u32 ip6_sd_fib_get_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id)
ip4_fib_mtrie_leaf_t default_leaf