49 #ifndef included_ip_lookup_h 50 #define included_ip_lookup_h 110 #define IP4_LOOKUP_NEXT_NODES { \ 111 [IP_LOOKUP_NEXT_MISS] = "ip4-miss", \ 112 [IP_LOOKUP_NEXT_DROP] = "ip4-drop", \ 113 [IP_LOOKUP_NEXT_PUNT] = "ip4-punt", \ 114 [IP_LOOKUP_NEXT_LOCAL] = "ip4-local", \ 115 [IP_LOOKUP_NEXT_ARP] = "ip4-arp", \ 116 [IP_LOOKUP_NEXT_REWRITE] = "ip4-rewrite-transit", \ 117 [IP_LOOKUP_NEXT_CLASSIFY] = "ip4-classify", \ 118 [IP_LOOKUP_NEXT_MAP] = "ip4-map", \ 119 [IP_LOOKUP_NEXT_MAP_T] = "ip4-map-t", \ 120 [IP_LOOKUP_NEXT_INDIRECT] = "ip4-indirect", \ 121 [IP_LOOKUP_NEXT_ICMP_ERROR] = "ip4-icmp-error", \ 124 #define IP6_LOOKUP_NEXT_NODES { \ 125 [IP_LOOKUP_NEXT_MISS] = "ip6-miss", \ 126 [IP_LOOKUP_NEXT_DROP] = "ip6-drop", \ 127 [IP_LOOKUP_NEXT_PUNT] = "ip6-punt", \ 128 [IP_LOOKUP_NEXT_LOCAL] = "ip6-local", \ 129 [IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor", \ 130 [IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite", \ 131 [IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify", \ 132 [IP_LOOKUP_NEXT_MAP] = "ip6-map", \ 133 [IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t", \ 134 [IP_LOOKUP_NEXT_INDIRECT] = "ip6-indirect", \ 135 [IP_LOOKUP_NEXT_ICMP_ERROR] = "ip6-icmp-error", \ 136 [IP6_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop", \ 137 [IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop", \ 138 [IP6_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop", \ 142 #define IP_FLOW_HASH_SRC_ADDR (1<<0) 143 #define IP_FLOW_HASH_DST_ADDR (1<<1) 144 #define IP_FLOW_HASH_PROTO (1<<2) 145 #define IP_FLOW_HASH_SRC_PORT (1<<3) 146 #define IP_FLOW_HASH_DST_PORT (1<<4) 147 #define IP_FLOW_HASH_REVERSE_SRC_DST (1<<5) 150 #define IP_FLOW_HASH_DEFAULT (0x1F) 152 #define foreach_flow_hash_bit \ 153 _(src, IP_FLOW_HASH_SRC_ADDR) \ 154 _(dst, IP_FLOW_HASH_DST_ADDR) \ 155 _(sport, IP_FLOW_HASH_SRC_PORT) \ 156 _(dport, IP_FLOW_HASH_DST_PORT) \ 157 _(proto, IP_FLOW_HASH_PROTO) \ 158 _(reverse, IP_FLOW_HASH_REVERSE_SRC_DST) 160 #define IP_ADJACENCY_OPAQUE_SZ 16 180 ip_lookup_next_t lookup_next_index : 16;
202 ip46_address_t next_hop;
229 uword signature = 0xfeedfaceULL;
252 if (memcmp (&a1->rewrite_header, &a2->rewrite_header,
293 } normalized_next_hops, unnormalized_next_hops;
314 u8 rewrite_string[64 - 1*
sizeof(
u32) - 1*
sizeof(
u8)];
434 #define IP_LOOKUP_MISS_ADJ_INDEX 0 492 #define ip_prefetch_adjacency(lm,adj_index,type) \ 494 ip_adjacency_t * _adj = (lm)->adjacency_heap + (adj_index); \ 495 CLIB_PREFETCH (_adj, sizeof (_adj[0]), type); \ 511 #define VNET_IP_REGISTER_ADJACENCY(ip,x,...) \ 512 __VA_ARGS__ ip_adj_register_t ip##adj_##x; \ 513 static void __vnet_##ip##_register_adjacency_##x (void) \ 514 __attribute__((__constructor__)) ; \ 515 static void __vnet_##ip##_register_adjacency_##x (void) \ 517 ip_lookup_main_t *lm = &ip##_main.lookup_main; \ 518 ip##adj_##x.next = lm->registered_adjacencies; \ 519 lm->registered_adjacencies = &ip##adj_##x; \ 521 __VA_ARGS__ ip_adj_register_t ip##adj_##x 523 #define VNET_IP4_REGISTER_ADJACENCY(x,...) \ 524 VNET_IP_REGISTER_ADJACENCY(ip4, x, __VA_ARGS__) 526 #define VNET_IP6_REGISTER_ADJACENCY(x,...) \ 527 VNET_IP_REGISTER_ADJACENCY(ip6, x, __VA_ARGS__) 551 u32 * adj_index_result);
580 u32 old_mp_adj_index,
581 u32 next_hop_adj_index,
583 u32 * new_mp_adj_index);
608 u32 if_address_index;
615 if_address_index = (if_address_index == ~0 ?
622 #define foreach_ip_interface_address(lm,a,sw_if_index,loop,body) \ 624 vnet_main_t *_vnm = vnet_get_main(); \ 625 u32 _sw_if_index = sw_if_index; \ 626 vnet_sw_interface_t *_swif; \ 627 _swif = vnet_get_sw_interface (_vnm, _sw_if_index); \ 632 if (loop && _swif->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED) \ 633 _sw_if_index = _swif->unnumbered_sw_if_index; \ 635 (vec_len((lm)->if_address_pool_index_by_sw_if_index) \ 637 ? vec_elt ((lm)->if_address_pool_index_by_sw_if_index, \ 638 (_sw_if_index)) : (u32)~0; \ 639 ip_interface_address_t * _a; \ 642 _a = pool_elt_at_index ((lm)->if_address_pool, _ia); \ 643 _ia = _a->next_this_sw_interface; \ uword * multipath_adjacency_by_next_hops
Hash table mapping normalized next hops and weights to multipath adjacency index. ...
static void ip_call_add_del_adjacency_callbacks(ip_lookup_main_t *lm, u32 adj_index, u32 is_del)
uword * adjacency_by_id_vector
format_function_t * format_fib_result
ip_lookup_next_t
Common (IP4/IP6) next index stored in adjacency.
static ip_interface_address_t * ip_interface_address_for_packet(ip_lookup_main_t *lm, vlib_buffer_t *b, u32 sw_if_index)
char * node_name
Name of the node for this registered adjacency.
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
sll srl srl sll sra u16x4 i
u32 * config_index_by_sw_if_index
ip_add_del_adjacency_callback_t * add_del_adjacency_callbacks
ip_adjacency_t * adjacency_heap
Adjacency heap.
u16 saved_lookup_next_index
Highest possible perf subgraph arc interposition, e.g.
ip_multicast_rewrite_t * rewrite_heap
clib_error_t * ip_interface_address_add_del(ip_lookup_main_t *lm, u32 sw_if_index, void *address, u32 address_length, u32 is_del, u32 *result_index)
ip_interface_address_t * if_address_pool
Pool of addresses that are assigned to interfaces.
#define STRUCT_MARK_PTR(v, f)
u16 n_adj
Number of adjecencies in block.
format_function_t * fn
Formatting function for the adjacency.
ip_lookup_next_t lookup_next_index
static int ip_adjacency_is_multipath(ip_lookup_main_t *lm, u32 adj_index)
u32 miss_adj_index
Adjacency index for routing table misses, local punts, and drops.
ip_config_main_t rx_config_mains[VNET_N_CAST]
rx/tx interface/feature configuration.
void ip_update_adjacency(ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *copy_adj)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u32 share_count
Number of FIB entries sharing this adjacency.
u32 special_adjacency_format_function_index
Special format function for this adjacency.
#define STRUCT_MARK(mark)
u32 * next_index
When the adjacency is registered, the ip-lookup next index will be written where this pointer points...
#define STRUCT_OFFSET_OF(t, f)
static int vnet_ip_adjacency_share_compare(ip_adjacency_t *a1, ip_adjacency_t *a2)
void(* ip_add_del_adjacency_callback_t)(struct ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *adj, u32 is_del)
u32 neighbor_probe_adj_index
mhash_t address_to_if_address_index
Hash table mapping address to index in interface address pool.
This structure is used to dynamically register a custom adjacency for ip lookup.
Adjacency to drop this packet.
u32 next_adj_with_signature
Use this adjacency instead.
This packets needs to go to ICMP error.
u32 vnet_register_special_adjacency_format_function(ip_lookup_main_t *lm, format_function_t *fp)
Hop-by-hop header handling.
u32 * adjacency_remap_table
uword * adj_index_by_signature
Adjacency by signature hash.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Adjacency to punt this packet.
This packet is for one of our own IP addresses.
#define VLIB_BUFFER_PRE_DATA_SIZE
int ip_register_adjacency(vlib_main_t *vm, u8 is_ip4, ip_adj_register_t *reg)
static uword vnet_ip_adjacency_signature(ip_adjacency_t *adj)
struct ip_lookup_main_t ip_lookup_main_t
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u32 * classify_table_index_by_sw_if_index
First table index to use for this interface, ~0 => none.
This packet needs to go to MAP - RFC7596, RFC7597.
struct ip_adj_register_struct * next
u8 local_next_by_ip_protocol[256]
Table mapping ip protocol to ip[46]-local node next index.
This packet needs to be classified.
u32 ip_multipath_adjacency_add_del_next_hop(ip_lookup_main_t *lm, u32 is_del, u32 old_mp_adj_index, u32 next_hop_adj_index, u32 next_hop_weight, u32 *new_mp_adj_index)
ip_adj_register_t * registered_adjacencies
Registered adjacencies.
static ip_interface_address_t * ip_get_interface_address(ip_lookup_main_t *lm, void *addr_fib)
static uword * mhash_get(mhash_t *h, void *key)
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *adj, u32 n_adj, u32 *adj_index_result)
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
vlib_combined_counter_main_t adjacency_counters
Adjacency packet/byte counters indexed by adjacency index.
u8 builtin_protocol_by_ip_protocol[256]
IP_BUILTIN_PROTOCOL_{TCP,UDP,ICMP,OTHER} by protocol in IP header.
u32 * if_address_pool_index_by_sw_if_index
Head of doubly linked list of interface addresses for each software interface.
static void ip_register_add_del_adjacency_callback(ip_lookup_main_t *lm, ip_add_del_adjacency_callback_t cb)
ip_multipath_next_hop_t * next_hop_hash_lookup_key
Temporary vectors for looking up next hops in hash.
i32 ** adjacency_id_vector
uword hash_memory(void *p, word n_bytes, uword state)
#define vec_elt(v, i)
Get vector value at index i.
ip_config_main_t tx_config_main
#define vnet_declare_rewrite(total_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
format_function_t ** special_adjacency_format_functions
Special adjacency format functions.
void ip_multipath_adjacency_free(ip_lookup_main_t *lm, ip_multipath_adjacency_t *a)
u32 heap_handle
Handle for this adjacency in adjacency heap.
u32 is_ip6
1 for ip6; 0 for ip4.
Packet does not match any route in table.
#define IP_ADJACENCY_OPAQUE_SZ
static void * mhash_key_to_mem(mhash_t *h, uword key)
A collection of combined counters.
ip_multipath_next_hop_t * next_hop_heap
Heap of (next hop, weight) blocks.
ip_multipath_adjacency_t * multipath_adjacencies
Indexed by heap_handle from ip_adjacency_t.
This packets needs to go to indirect next hop.
This packet is to be rewritten and forwarded to the next processing node.
u32 if_address_index
Interface address index for this local/arp adjacency.
i16 explicit_fib_index
Force re-lookup in a different FIB.
ip_multipath_next_hop_t * next_hop_hash_lookup_key_normalized
void ip_lookup_init(ip_lookup_main_t *lm, u32 ip_lookup_node_index)
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
This packet needs to go to MAP with Translation - RFC7599.
vlib buffer structure definition and a few select access methods.
vnet_config_main_t config_main
void ip_del_adjacency(ip_lookup_main_t *lm, u32 adj_index)
f64 multipath_next_hop_error_tolerance
If average error per adjacency is less than this threshold adjacency block size is accepted...
u32 fib_result_n_bytes
Number of bytes in a fib result.
ip_multicast_rewrite_string_t * rewrite_strings
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
u32 next_this_sw_interface
format_function_t * format_address_and_length
Either format_ip4_address_and_length or format_ip6_address_and_length.
struct ip_adj_register_struct ip_adj_register_t
This structure is used to dynamically register a custom adjacency for ip lookup.
u32 prev_this_sw_interface
u16 lookup_next_index_as_int