FD.io VPP  v16.09
Vector Packet Processing
lookup.h File Reference

Definitions for all things IP (v4|v6) unicast and multicast lookup related. More...

+ Include dependency graph for lookup.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ip_adjacency_t
 IP unicast adjacency. More...
 
struct  ip_multipath_next_hop_t
 
struct  ip_multipath_adjacency_t
 
struct  ip_multicast_rewrite_t
 
struct  ip_multicast_rewrite_string_t
 
struct  ip_multicast_lookup_main_t
 
struct  ip_interface_address_t
 
struct  ip_config_main_t
 
struct  ip_adj_register_struct
 This structure is used to dynamically register a custom adjacency for ip lookup. More...
 
struct  ip_lookup_main_t
 

Macros

#define IP4_LOOKUP_NEXT_NODES
 
#define IP6_LOOKUP_NEXT_NODES
 
#define IP_FLOW_HASH_SRC_ADDR   (1<<0)
 Flow hash configuration. More...
 
#define IP_FLOW_HASH_DST_ADDR   (1<<1)
 
#define IP_FLOW_HASH_PROTO   (1<<2)
 
#define IP_FLOW_HASH_SRC_PORT   (1<<3)
 
#define IP_FLOW_HASH_DST_PORT   (1<<4)
 
#define IP_FLOW_HASH_REVERSE_SRC_DST   (1<<5)
 
#define IP_FLOW_HASH_DEFAULT   (0x1F)
 Default: 5-tuple without the "reverse" bit. More...
 
#define foreach_flow_hash_bit
 
#define IP_ADJACENCY_OPAQUE_SZ   16
 
#define IP_LOOKUP_MISS_ADJ_INDEX   0
 Miss adjacency is always first in adjacency table. More...
 
#define ip_prefetch_adjacency(lm, adj_index, type)
 
#define VNET_IP_REGISTER_ADJACENCY(ip, x, ...)
 
#define VNET_IP4_REGISTER_ADJACENCY(x, ...)   VNET_IP_REGISTER_ADJACENCY(ip4, x, __VA_ARGS__)
 
#define VNET_IP6_REGISTER_ADJACENCY(x, ...)   VNET_IP_REGISTER_ADJACENCY(ip6, x, __VA_ARGS__)
 
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
 

Typedefs

typedef u32 ip_adjacency_index_t
 
typedef void(* ip_add_del_adjacency_callback_t) (struct ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *adj, u32 is_del)
 
typedef struct ip_adj_register_struct ip_adj_register_t
 This structure is used to dynamically register a custom adjacency for ip lookup. More...
 
typedef struct ip_lookup_main_t ip_lookup_main_t
 

Enumerations

enum  ip_lookup_next_t {
  IP_LOOKUP_NEXT_MISS, IP_LOOKUP_NEXT_DROP, IP_LOOKUP_NEXT_PUNT, IP_LOOKUP_NEXT_LOCAL,
  IP_LOOKUP_NEXT_ARP, IP_LOOKUP_NEXT_REWRITE, IP_LOOKUP_NEXT_CLASSIFY, IP_LOOKUP_NEXT_MAP,
  IP_LOOKUP_NEXT_MAP_T, IP_LOOKUP_NEXT_INDIRECT, IP_LOOKUP_NEXT_ICMP_ERROR, IP_LOOKUP_N_NEXT
}
 Common (IP4/IP6) next index stored in adjacency. More...
 
enum  ip4_lookup_next_t { IP4_LOOKUP_N_NEXT = IP_LOOKUP_N_NEXT }
 
enum  ip6_lookup_next_t { IP6_LOOKUP_NEXT_HOP_BY_HOP = IP_LOOKUP_N_NEXT, IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP, IP6_LOOKUP_NEXT_POP_HOP_BY_HOP, IP6_LOOKUP_N_NEXT }
 
enum  ip_local_next_t {
  IP_LOCAL_NEXT_DROP, IP_LOCAL_NEXT_PUNT, IP_LOCAL_NEXT_UDP_LOOKUP, IP_LOCAL_NEXT_ICMP,
  IP_LOCAL_N_NEXT
}
 

Functions

static uword vnet_ip_adjacency_signature (ip_adjacency_t *adj)
 
static int vnet_ip_adjacency_share_compare (ip_adjacency_t *a1, ip_adjacency_t *a2)
 
static ip_adjacency_tip_get_adjacency (ip_lookup_main_t *lm, u32 adj_index)
 
int ip_register_adjacency (vlib_main_t *vm, u8 is_ip4, ip_adj_register_t *reg)
 
static void ip_register_add_del_adjacency_callback (ip_lookup_main_t *lm, ip_add_del_adjacency_callback_t cb)
 
static void ip_call_add_del_adjacency_callbacks (ip_lookup_main_t *lm, u32 adj_index, u32 is_del)
 
ip_adjacency_tip_add_adjacency (ip_lookup_main_t *lm, ip_adjacency_t *adj, u32 n_adj, u32 *adj_index_result)
 
void ip_del_adjacency (ip_lookup_main_t *lm, u32 adj_index)
 
void ip_update_adjacency (ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *copy_adj)
 
static int ip_adjacency_is_multipath (ip_lookup_main_t *lm, u32 adj_index)
 
void ip_multipath_adjacency_free (ip_lookup_main_t *lm, ip_multipath_adjacency_t *a)
 
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)
 
clib_error_tip_interface_address_add_del (ip_lookup_main_t *lm, u32 sw_if_index, void *address, u32 address_length, u32 is_del, u32 *result_index)
 
static ip_interface_address_tip_get_interface_address (ip_lookup_main_t *lm, void *addr_fib)
 
static void * ip_interface_address_get_address (ip_lookup_main_t *lm, ip_interface_address_t *a)
 
static ip_interface_address_tip_interface_address_for_packet (ip_lookup_main_t *lm, vlib_buffer_t *b, u32 sw_if_index)
 
void ip_lookup_init (ip_lookup_main_t *lm, u32 ip_lookup_node_index)
 
u32 vnet_register_special_adjacency_format_function (ip_lookup_main_t *lm, format_function_t *fp)
 

Detailed Description

Definitions for all things IP (v4|v6) unicast and multicast lookup related.

  • Adjacency definitions and registration.
  • Callbacks on route add.
  • Callbacks on interface address change.

Definition in file lookup.h.

Macro Definition Documentation

#define foreach_flow_hash_bit
Value:
_(proto, IP_FLOW_HASH_PROTO) \
#define IP_FLOW_HASH_SRC_PORT
Definition: lookup.h:145
#define IP_FLOW_HASH_REVERSE_SRC_DST
Definition: lookup.h:147
#define IP_FLOW_HASH_DST_PORT
Definition: lookup.h:146
#define IP_FLOW_HASH_DST_ADDR
Definition: lookup.h:143
#define IP_FLOW_HASH_SRC_ADDR
Flow hash configuration.
Definition: lookup.h:142
#define IP_FLOW_HASH_PROTO
Definition: lookup.h:144

Definition at line 152 of file lookup.h.

#define foreach_ip_interface_address (   lm,
  a,
  sw_if_index,
  loop,
  body 
)
Value:
do { \
u32 _sw_if_index = sw_if_index; \
vnet_sw_interface_t *_swif; \
_swif = vnet_get_sw_interface (_vnm, _sw_if_index); \
\
/* \
* Loop => honor unnumbered interface addressing. \
*/ \
if (loop && _swif->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED) \
_sw_if_index = _swif->unnumbered_sw_if_index; \
u32 _ia = \
(vec_len((lm)->if_address_pool_index_by_sw_if_index) \
> (_sw_if_index)) \
? vec_elt ((lm)->if_address_pool_index_by_sw_if_index, \
(_sw_if_index)) : (u32)~0; \
ip_interface_address_t * _a; \
while (_ia != ~0) \
{ \
_a = pool_elt_at_index ((lm)->if_address_pool, _ia); \
_ia = _a->next_this_sw_interface; \
(a) = _a; \
body; \
} \
} while (0)
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:422
a
Definition: bitmap.h:516
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
unsigned int u32
Definition: types.h:88
#define vec_elt(v, i)
Get vector value at index i.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
struct vnet_main_t vnet_main_t

Definition at line 622 of file lookup.h.

#define IP4_LOOKUP_NEXT_NODES
Value:
{ \
[IP_LOOKUP_NEXT_MISS] = "ip4-miss", \
[IP_LOOKUP_NEXT_DROP] = "ip4-drop", \
[IP_LOOKUP_NEXT_PUNT] = "ip4-punt", \
[IP_LOOKUP_NEXT_LOCAL] = "ip4-local", \
[IP_LOOKUP_NEXT_ARP] = "ip4-arp", \
[IP_LOOKUP_NEXT_REWRITE] = "ip4-rewrite-transit", \
[IP_LOOKUP_NEXT_CLASSIFY] = "ip4-classify", \
[IP_LOOKUP_NEXT_MAP] = "ip4-map", \
[IP_LOOKUP_NEXT_MAP_T] = "ip4-map-t", \
[IP_LOOKUP_NEXT_INDIRECT] = "ip4-indirect", \
[IP_LOOKUP_NEXT_ICMP_ERROR] = "ip4-icmp-error", \
}
Adjacency to drop this packet.
Definition: lookup.h:63
This packets needs to go to ICMP error.
Definition: lookup.h:93
Adjacency to punt this packet.
Definition: lookup.h:65
This packet is for one of our own IP addresses.
Definition: lookup.h:68
This packet needs to go to MAP - RFC7596, RFC7597.
Definition: lookup.h:84
This packet needs to be classified.
Definition: lookup.h:81
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: lookup.h:73
Packet does not match any route in table.
Definition: lookup.h:60
This packets needs to go to indirect next hop.
Definition: lookup.h:90
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:78
This packet needs to go to MAP with Translation - RFC7599.
Definition: lookup.h:87

Definition at line 110 of file lookup.h.

#define IP6_LOOKUP_NEXT_NODES
Value:
{ \
[IP_LOOKUP_NEXT_MISS] = "ip6-miss", \
[IP_LOOKUP_NEXT_DROP] = "ip6-drop", \
[IP_LOOKUP_NEXT_PUNT] = "ip6-punt", \
[IP_LOOKUP_NEXT_LOCAL] = "ip6-local", \
[IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor", \
[IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite", \
[IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify", \
[IP_LOOKUP_NEXT_MAP] = "ip6-map", \
[IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t", \
[IP_LOOKUP_NEXT_INDIRECT] = "ip6-indirect", \
[IP_LOOKUP_NEXT_ICMP_ERROR] = "ip6-icmp-error", \
[IP6_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop", \
[IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop", \
[IP6_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop", \
}
Adjacency to drop this packet.
Definition: lookup.h:63
This packets needs to go to ICMP error.
Definition: lookup.h:93
Hop-by-hop header handling.
Definition: lookup.h:104
Adjacency to punt this packet.
Definition: lookup.h:65
This packet is for one of our own IP addresses.
Definition: lookup.h:68
This packet needs to go to MAP - RFC7596, RFC7597.
Definition: lookup.h:84
This packet needs to be classified.
Definition: lookup.h:81
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: lookup.h:73
Packet does not match any route in table.
Definition: lookup.h:60
This packets needs to go to indirect next hop.
Definition: lookup.h:90
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:78
This packet needs to go to MAP with Translation - RFC7599.
Definition: lookup.h:87

Definition at line 124 of file lookup.h.

#define IP_ADJACENCY_OPAQUE_SZ   16

Definition at line 160 of file lookup.h.

#define IP_FLOW_HASH_DEFAULT   (0x1F)

Default: 5-tuple without the "reverse" bit.

Definition at line 150 of file lookup.h.

#define IP_FLOW_HASH_DST_ADDR   (1<<1)

Definition at line 143 of file lookup.h.

#define IP_FLOW_HASH_DST_PORT   (1<<4)

Definition at line 146 of file lookup.h.

#define IP_FLOW_HASH_PROTO   (1<<2)

Definition at line 144 of file lookup.h.

#define IP_FLOW_HASH_REVERSE_SRC_DST   (1<<5)

Definition at line 147 of file lookup.h.

#define IP_FLOW_HASH_SRC_ADDR   (1<<0)

Flow hash configuration.

Definition at line 142 of file lookup.h.

#define IP_FLOW_HASH_SRC_PORT   (1<<3)

Definition at line 145 of file lookup.h.

#define IP_LOOKUP_MISS_ADJ_INDEX   0

Miss adjacency is always first in adjacency table.

Definition at line 434 of file lookup.h.

#define ip_prefetch_adjacency (   lm,
  adj_index,
  type 
)
Value:
do { \
ip_adjacency_t * _adj = (lm)->adjacency_heap + (adj_index); \
CLIB_PREFETCH (_adj, sizeof (_adj[0]), type); \
} while (0)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82

Definition at line 492 of file lookup.h.

#define VNET_IP4_REGISTER_ADJACENCY (   x,
  ... 
)    VNET_IP_REGISTER_ADJACENCY(ip4, x, __VA_ARGS__)

Definition at line 523 of file lookup.h.

#define VNET_IP6_REGISTER_ADJACENCY (   x,
  ... 
)    VNET_IP_REGISTER_ADJACENCY(ip6, x, __VA_ARGS__)

Definition at line 526 of file lookup.h.

#define VNET_IP_REGISTER_ADJACENCY (   ip,
  x,
  ... 
)
Value:
__VA_ARGS__ ip_adj_register_t ip##adj_##x; \
static void __vnet_##ip##_register_adjacency_##x (void) \
__attribute__((__constructor__)) ; \
static void __vnet_##ip##_register_adjacency_##x (void) \
{ \
ip_lookup_main_t *lm = &ip##_main.lookup_main; \
ip##adj_##x.next = lm->registered_adjacencies; \
lm->registered_adjacencies = &ip##adj_##x; \
} \
__VA_ARGS__ ip_adj_register_t ip##adj_##x
This structure is used to dynamically register a custom adjacency for ip lookup.
Definition: lookup.h:379
struct ip_lookup_main_t ip_lookup_main_t
ip_adj_register_t * registered_adjacencies
Registered adjacencies.
Definition: lookup.h:476

Definition at line 511 of file lookup.h.

Typedef Documentation

typedef void(* ip_add_del_adjacency_callback_t) (struct ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *adj, u32 is_del)

Definition at line 361 of file lookup.h.

This structure is used to dynamically register a custom adjacency for ip lookup.

Typically used with VNET_IP4_REGISTER_ADJACENCY or VNET_IP6_REGISTER_ADJACENCY macros.

Definition at line 259 of file lookup.h.

Enumeration Type Documentation

Enumerator
IP4_LOOKUP_N_NEXT 

Definition at line 98 of file lookup.h.

Enumerator
IP6_LOOKUP_NEXT_HOP_BY_HOP 

Hop-by-hop header handling.

IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP 
IP6_LOOKUP_NEXT_POP_HOP_BY_HOP 
IP6_LOOKUP_N_NEXT 

Definition at line 102 of file lookup.h.

Enumerator
IP_LOCAL_NEXT_DROP 
IP_LOCAL_NEXT_PUNT 
IP_LOCAL_NEXT_UDP_LOOKUP 
IP_LOCAL_NEXT_ICMP 
IP_LOCAL_N_NEXT 

Definition at line 351 of file lookup.h.

Common (IP4/IP6) next index stored in adjacency.

Enumerator
IP_LOOKUP_NEXT_MISS 

Packet does not match any route in table.

IP_LOOKUP_NEXT_DROP 

Adjacency to drop this packet.

IP_LOOKUP_NEXT_PUNT 

Adjacency to punt this packet.

IP_LOOKUP_NEXT_LOCAL 

This packet is for one of our own IP addresses.

IP_LOOKUP_NEXT_ARP 

This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string for this destination.

IP_LOOKUP_NEXT_REWRITE 

This packet is to be rewritten and forwarded to the next processing node.

This is typically the output interface but might be another node for further output processing.

IP_LOOKUP_NEXT_CLASSIFY 

This packet needs to be classified.

IP_LOOKUP_NEXT_MAP 

This packet needs to go to MAP - RFC7596, RFC7597.

IP_LOOKUP_NEXT_MAP_T 

This packet needs to go to MAP with Translation - RFC7599.

IP_LOOKUP_NEXT_INDIRECT 

This packets needs to go to indirect next hop.

IP_LOOKUP_NEXT_ICMP_ERROR 

This packets needs to go to ICMP error.

IP_LOOKUP_N_NEXT 

Definition at line 58 of file lookup.h.

Function Documentation

ip_adjacency_t* ip_add_adjacency ( ip_lookup_main_t lm,
ip_adjacency_t adj,
u32  n_adj,
u32 adj_index_result 
)

Definition at line 167 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int ip_adjacency_is_multipath ( ip_lookup_main_t lm,
u32  adj_index 
)
inlinestatic

Definition at line 560 of file lookup.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ip_call_add_del_adjacency_callbacks ( ip_lookup_main_t lm,
u32  adj_index,
u32  is_del 
)
inlinestatic

Definition at line 537 of file lookup.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ip_del_adjacency ( ip_lookup_main_t lm,
u32  adj_index 
)

Definition at line 314 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ip_adjacency_t* ip_get_adjacency ( ip_lookup_main_t lm,
u32  adj_index 
)
inlinestatic

Definition at line 480 of file lookup.h.

static ip_interface_address_t* ip_get_interface_address ( ip_lookup_main_t lm,
void *  addr_fib 
)
inlinestatic

Definition at line 594 of file lookup.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 764 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ip_interface_address_t* ip_interface_address_for_packet ( ip_lookup_main_t lm,
vlib_buffer_t b,
u32  sw_if_index 
)
inlinestatic

Definition at line 605 of file lookup.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* ip_interface_address_get_address ( ip_lookup_main_t lm,
ip_interface_address_t a 
)
inlinestatic

Definition at line 601 of file lookup.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ip_lookup_init ( ip_lookup_main_t lm,
u32  ip_lookup_node_index 
)

Definition at line 870 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 524 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ip_multipath_adjacency_free ( ip_lookup_main_t lm,
ip_multipath_adjacency_t a 
)

Definition at line 706 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ip_register_add_del_adjacency_callback ( ip_lookup_main_t lm,
ip_add_del_adjacency_callback_t  cb 
)
inlinestatic

Definition at line 530 of file lookup.h.

+ Here is the caller graph for this function:

int ip_register_adjacency ( vlib_main_t vm,
u8  is_ip4,
ip_adj_register_t reg 
)

Definition at line 137 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ip_update_adjacency ( ip_lookup_main_t lm,
u32  adj_index,
ip_adjacency_t copy_adj 
)

Definition at line 263 of file lookup.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int vnet_ip_adjacency_share_compare ( ip_adjacency_t a1,
ip_adjacency_t a2 
)
inlinestatic

Definition at line 245 of file lookup.h.

+ Here is the caller graph for this function:

static uword vnet_ip_adjacency_signature ( ip_adjacency_t adj)
inlinestatic

Definition at line 227 of file lookup.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 vnet_register_special_adjacency_format_function ( ip_lookup_main_t lm,
format_function_t fp 
)

Definition at line 1013 of file lookup.c.

+ Here is the caller graph for this function: