FD.io VPP  v18.01-8-g0eacf49
Vector Packet Processing
map.h File Reference
+ Include dependency graph for map.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  map_domain_t
 
union  map_ip4_reass_key_t
 
struct  map_ip4_reass_t
 
union  map_ip6_reass_key_t
 
struct  map_ip6_fragment_t
 
struct  map_ip6_reass_t
 
struct  map_main_pre_resolved_t_
 A pre-resolved next-hop. More...
 
struct  map_main_t
 
struct  map_trace_t
 

Macros

#define MAP_SKIP_IP6_LOOKUP   1
 
#define MAP_IP4_REASS_LIFETIME_DEFAULT   (100) /* ms */
 IP4 reassembly logic: One virtually reassembled flow requires a map_ip4_reass_t structure in order to keep the first-fragment port number and, optionally, cache out of sequence packets. More...
 
#define MAP_IP4_REASS_HT_RATIO_DEFAULT   (1.0)
 
#define MAP_IP4_REASS_POOL_SIZE_DEFAULT   1024
 
#define MAP_IP4_REASS_BUFFERS_DEFAULT   2048
 
#define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY   5
 
#define MAP_IP6_REASS_LIFETIME_DEFAULT   (100) /* ms */
 
#define MAP_IP6_REASS_HT_RATIO_DEFAULT   (1.0)
 
#define MAP_IP6_REASS_POOL_SIZE_DEFAULT   1024
 
#define MAP_IP6_REASS_BUFFERS_DEFAULT   2048
 
#define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY   5
 
#define MAP_IP6_REASS_COUNT_BYTES
 
#define MAP_IP4_REASS_COUNT_BYTES
 
#define MAP_REASS_INDEX_NONE   ((u16)0xffff)
 
#define foreach_map_error
 
#define map_ip4_reass_lock()   while (__sync_lock_test_and_set(map_main.ip4_reass_lock, 1)) {}
 
#define map_ip4_reass_unlock()   do {CLIB_MEMORY_BARRIER(); *map_main.ip4_reass_lock = 0;} while(0)
 
#define map_ip6_reass_lock()   while (__sync_lock_test_and_set(map_main.ip6_reass_lock, 1)) {}
 
#define map_ip6_reass_unlock()   do {CLIB_MEMORY_BARRIER(); *map_main.ip6_reass_lock = 0;} while(0)
 
#define MAP_IP4_REASS_CONF_HT_RATIO_MAX   100
 
#define MAP_IP4_REASS_CONF_POOL_SIZE_MAX   (0xfeff)
 
#define MAP_IP4_REASS_CONF_LIFETIME_MAX   0xffff
 
#define MAP_IP4_REASS_CONF_BUFFERS_MAX   (0xffffffff)
 
#define MAP_IP6_REASS_CONF_HT_RATIO_MAX   100
 
#define MAP_IP6_REASS_CONF_POOL_SIZE_MAX   (0xfeff)
 
#define MAP_IP6_REASS_CONF_LIFETIME_MAX   0xffff
 
#define MAP_IP6_REASS_CONF_BUFFERS_MAX   (0xffffffff)
 
#define u8_ptr_add(ptr, index)   (((u8 *)ptr) + index)
 
#define u16_net_add(u, val)   clib_host_to_net_u16(clib_net_to_host_u16(u) + (val))
 

Typedefs

typedef struct map_main_pre_resolved_t_ map_main_pre_resolved_t
 A pre-resolved next-hop. More...
 

Enumerations

enum  map_domain_flags_e { MAP_DOMAIN_PREFIX = 1 << 0, MAP_DOMAIN_TRANSLATION = 1 << 1 }
 
enum  map_domain_counter_t { MAP_DOMAIN_IPV4_FRAGMENT = 0, MAP_DOMAIN_COUNTER_RX = 0, MAP_DOMAIN_COUNTER_TX, MAP_N_DOMAIN_COUNTER }
 
enum  map_error_t { MAP_N_ERROR }
 

Functions

int map_create_domain (ip4_address_t *ip4_prefix, u8 ip4_prefix_len, ip6_address_t *ip6_prefix, u8 ip6_prefix_len, ip6_address_t *ip6_src, u8 ip6_src_len, u8 ea_bits_len, u8 psid_offset, u8 psid_length, u32 *map_domain_index, u16 mtu, u8 flags)
 
int map_delete_domain (u32 map_domain_index)
 
int map_add_del_psid (u32 map_domain_index, u16 psid, ip6_address_t *tep, u8 is_add)
 
u8format_map_trace (u8 *s, va_list *args)
 
 STATIC_ASSERT ((sizeof(map_domain_t)<=CLIB_CACHE_LINE_BYTES),"MAP domain fits in one cacheline")
 
u64 map_error_counter_get (u32 node_index, map_error_t map_error)
 
static_always_inline u64 map_get_pfx (map_domain_t *d, u32 addr, u16 port)
 
static_always_inline u64 map_get_pfx_net (map_domain_t *d, u32 addr, u16 port)
 
static_always_inline u64 map_get_sfx (map_domain_t *d, u32 addr, u16 port)
 
static_always_inline u64 map_get_sfx_net (map_domain_t *d, u32 addr, u16 port)
 
static_always_inline u32 map_get_ip4 (ip6_address_t *addr)
 
static_always_inline map_domain_tip4_map_get_domain (u32 mdi)
 
static_always_inline map_domain_tip6_map_get_domain (u32 mdi, ip4_address_t *addr, u32 *map_domain_index, u8 *error)
 
map_ip4_reass_tmap_ip4_reass_get (u32 src, u32 dst, u16 fragment_id, u8 protocol, u32 **pi_to_drop)
 
void map_ip4_reass_free (map_ip4_reass_t *r, u32 **pi_to_drop)
 
static_always_inline void map_ip4_reass_get_fragments (map_ip4_reass_t *r, u32 **pi)
 
int map_ip4_reass_add_fragment (map_ip4_reass_t *r, u32 pi)
 
map_ip6_reass_tmap_ip6_reass_get (ip6_address_t *src, ip6_address_t *dst, u32 fragment_id, u8 protocol, u32 **pi_to_drop)
 
void map_ip6_reass_free (map_ip6_reass_t *r, u32 **pi_to_drop)
 
int map_ip6_reass_add_fragment (map_ip6_reass_t *r, u32 pi, u16 data_offset, u16 next_data_offset, u8 *data_start, u16 data_len)
 
void map_ip4_drop_pi (u32 pi)
 
int map_ip4_reass_conf_ht_ratio (f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
 
int map_ip4_reass_conf_pool_size (u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
 
int map_ip4_reass_conf_lifetime (u16 lifetime_ms)
 
int map_ip4_reass_conf_buffers (u32 buffers)
 
void map_ip6_drop_pi (u32 pi)
 
int map_ip6_reass_conf_ht_ratio (f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
 
int map_ip6_reass_conf_pool_size (u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
 
int map_ip6_reass_conf_lifetime (u16 lifetime_ms)
 
int map_ip6_reass_conf_buffers (u32 buffers)
 
static_always_inline void ip4_map_t_embedded_address (map_domain_t *d, ip6_address_t *ip6, const ip4_address_t *ip4)
 
static_always_inline u32 ip6_map_t_embedded_address (map_domain_t *d, ip6_address_t *addr)
 
static void map_domain_counter_lock (map_main_t *mm)
 
static void map_domain_counter_unlock (map_main_t *mm)
 
static_always_inline void map_send_all_to_node (vlib_main_t *vm, u32 *pi_vector, vlib_node_runtime_t *node, vlib_error_t *error, u32 next)
 

Variables

map_main_pre_resolved_t pre_resolved [FIB_PROTOCOL_MAX]
 Pre-resolved next hops for v4 and v6. More...
 
map_main_t map_main
 
vlib_node_registration_t ip4_map_node
 (constructor) VLIB_REGISTER_NODE (ip4_map_node) More...
 
vlib_node_registration_t ip6_map_node
 (constructor) VLIB_REGISTER_NODE (ip6_map_node) More...
 
vlib_node_registration_t ip4_map_t_node
 (constructor) VLIB_REGISTER_NODE (ip4_map_t_node) More...
 
vlib_node_registration_t ip4_map_t_fragmented_node
 (constructor) VLIB_REGISTER_NODE (ip4_map_t_fragmented_node) More...
 
vlib_node_registration_t ip4_map_t_tcp_udp_node
 (constructor) VLIB_REGISTER_NODE (ip4_map_t_tcp_udp_node) More...
 
vlib_node_registration_t ip4_map_t_icmp_node
 (constructor) VLIB_REGISTER_NODE (ip4_map_t_icmp_node) More...
 
vlib_node_registration_t ip6_map_t_node
 (constructor) VLIB_REGISTER_NODE (ip6_map_t_node) More...
 
vlib_node_registration_t ip6_map_t_fragmented_node
 (constructor) VLIB_REGISTER_NODE (ip6_map_t_fragmented_node) More...
 
vlib_node_registration_t ip6_map_t_tcp_udp_node
 (constructor) VLIB_REGISTER_NODE (ip6_map_t_tcp_udp_node) More...
 
vlib_node_registration_t ip6_map_t_icmp_node
 (constructor) VLIB_REGISTER_NODE (ip6_map_t_icmp_node) More...
 

Macro Definition Documentation

#define foreach_map_error
Value:
/* Must be first. */ \
_(NONE, "valid MAP packets") \
_(BAD_PROTOCOL, "bad protocol") \
_(SEC_CHECK, "security check failed") \
_(ENCAP_SEC_CHECK, "encap security check failed") \
_(DECAP_SEC_CHECK, "decap security check failed") \
_(ICMP, "unable to translate ICMP") \
_(ICMP_RELAY, "unable to relay ICMP") \
_(UNKNOWN, "unknown") \
_(NO_BINDING, "no binding") \
_(NO_DOMAIN, "no domain") \
_(FRAGMENTED, "packet is a fragment") \
_(FRAGMENT_MEMORY, "could not cache fragment") \
_(FRAGMENT_MALFORMED, "fragment has unexpected format")\
_(FRAGMENT_DROPPED, "dropped cached fragment") \
_(MALFORMED, "malformed packet") \
_(DF_SET, "can't fragment, DF set")

Definition at line 299 of file map.h.

#define MAP_IP4_REASS_BUFFERS_DEFAULT   2048

Definition at line 59 of file map.h.

#define MAP_IP4_REASS_CONF_BUFFERS_MAX   (0xffffffff)

Definition at line 498 of file map.h.

#define MAP_IP4_REASS_CONF_HT_RATIO_MAX   100

Definition at line 492 of file map.h.

#define MAP_IP4_REASS_CONF_LIFETIME_MAX   0xffff

Definition at line 496 of file map.h.

#define MAP_IP4_REASS_CONF_POOL_SIZE_MAX   (0xfeff)

Definition at line 494 of file map.h.

#define MAP_IP4_REASS_COUNT_BYTES

Definition at line 71 of file map.h.

#define MAP_IP4_REASS_HT_RATIO_DEFAULT   (1.0)

Definition at line 57 of file map.h.

#define MAP_IP4_REASS_LIFETIME_DEFAULT   (100) /* ms */

IP4 reassembly logic: One virtually reassembled flow requires a map_ip4_reass_t structure in order to keep the first-fragment port number and, optionally, cache out of sequence packets.

There are up to MAP_IP4_REASS_MAX_REASSEMBLY such structures. When in use, those structures are stored in a hash table of MAP_IP4_REASS_BUCKETS buckets. When a new structure needs to be used, it is allocated from available ones. If there is no structure available, the oldest in use is selected and used if and only if it was first allocated more than MAP_IP4_REASS_LIFETIME seconds ago. In case no structure can be allocated, the fragment is dropped.

Definition at line 56 of file map.h.

#define map_ip4_reass_lock ( )    while (__sync_lock_test_and_set(map_main.ip4_reass_lock, 1)) {}

Definition at line 458 of file map.h.

#define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY   5

Definition at line 61 of file map.h.

#define MAP_IP4_REASS_POOL_SIZE_DEFAULT   1024

Definition at line 58 of file map.h.

#define map_ip4_reass_unlock ( )    do {CLIB_MEMORY_BARRIER(); *map_main.ip4_reass_lock = 0;} while(0)

Definition at line 459 of file map.h.

#define MAP_IP6_REASS_BUFFERS_DEFAULT   2048

Definition at line 66 of file map.h.

#define MAP_IP6_REASS_CONF_BUFFERS_MAX   (0xffffffff)

Definition at line 510 of file map.h.

#define MAP_IP6_REASS_CONF_HT_RATIO_MAX   100

Definition at line 504 of file map.h.

#define MAP_IP6_REASS_CONF_LIFETIME_MAX   0xffff

Definition at line 508 of file map.h.

#define MAP_IP6_REASS_CONF_POOL_SIZE_MAX   (0xfeff)

Definition at line 506 of file map.h.

#define MAP_IP6_REASS_COUNT_BYTES

Definition at line 70 of file map.h.

#define MAP_IP6_REASS_HT_RATIO_DEFAULT   (1.0)

Definition at line 64 of file map.h.

#define MAP_IP6_REASS_LIFETIME_DEFAULT   (100) /* ms */

Definition at line 63 of file map.h.

#define map_ip6_reass_lock ( )    while (__sync_lock_test_and_set(map_main.ip6_reass_lock, 1)) {}

Definition at line 481 of file map.h.

#define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY   5

Definition at line 68 of file map.h.

#define MAP_IP6_REASS_POOL_SIZE_DEFAULT   1024

Definition at line 65 of file map.h.

#define map_ip6_reass_unlock ( )    do {CLIB_MEMORY_BARRIER(); *map_main.ip6_reass_lock = 0;} while(0)

Definition at line 482 of file map.h.

#define MAP_REASS_INDEX_NONE   ((u16)0xffff)

Definition at line 107 of file map.h.

#define MAP_SKIP_IP6_LOOKUP   1

Definition at line 26 of file map.h.

#define u16_net_add (   u,
  val 
)    clib_host_to_net_u16(clib_net_to_host_u16(u) + (val))

Definition at line 514 of file map.h.

#define u8_ptr_add (   ptr,
  index 
)    (((u8 *)ptr) + index)

Definition at line 513 of file map.h.

Typedef Documentation

A pre-resolved next-hop.

Enumeration Type Documentation

Enumerator
MAP_DOMAIN_IPV4_FRAGMENT 
MAP_DOMAIN_COUNTER_RX 
MAP_DOMAIN_COUNTER_TX 
MAP_N_DOMAIN_COUNTER 

Definition at line 144 of file map.h.

Enumerator
MAP_DOMAIN_PREFIX 
MAP_DOMAIN_TRANSLATION 

Definition at line 38 of file map.h.

Enumerator
MAP_N_ERROR 

Definition at line 318 of file map.h.

Function Documentation

u8* format_map_trace ( u8 s,
va_list *  args 
)

Definition at line 1383 of file map.c.

+ Here is the call graph for this function:

static_always_inline map_domain_t* ip4_map_get_domain ( u32  mdi)

Definition at line 410 of file map.h.

+ Here is the caller graph for this function:

static_always_inline void ip4_map_t_embedded_address ( map_domain_t d,
ip6_address_t ip6,
const ip4_address_t ip4 
)

Definition at line 517 of file map.h.

+ Here is the caller graph for this function:

static_always_inline map_domain_t* ip6_map_get_domain ( u32  mdi,
ip4_address_t addr,
u32 map_domain_index,
u8 error 
)

Definition at line 423 of file map.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline u32 ip6_map_t_embedded_address ( map_domain_t d,
ip6_address_t addr 
)

Definition at line 527 of file map.h.

+ Here is the caller graph for this function:

int map_add_del_psid ( u32  map_domain_index,
u16  psid,
ip6_address_t tep,
u8  is_add 
)

Definition at line 264 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_create_domain ( ip4_address_t ip4_prefix,
u8  ip4_prefix_len,
ip6_address_t ip6_prefix,
u8  ip6_prefix_len,
ip6_address_t ip6_src,
u8  ip6_src_len,
u8  ea_bits_len,
u8  psid_offset,
u8  psid_length,
u32 map_domain_index,
u16  mtu,
u8  flags 
)

Definition at line 64 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_delete_domain ( u32  map_domain_index)

Definition at line 220 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void map_domain_counter_lock ( map_main_t mm)
inlinestatic

Definition at line 534 of file map.h.

+ Here is the caller graph for this function:

static void map_domain_counter_unlock ( map_main_t mm)
inlinestatic

Definition at line 541 of file map.h.

+ Here is the caller graph for this function:

u64 map_error_counter_get ( u32  node_index,
map_error_t  map_error 
)

Definition at line 1085 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline u32 map_get_ip4 ( ip6_address_t addr)

Definition at line 401 of file map.h.

+ Here is the caller graph for this function:

static_always_inline u64 map_get_pfx ( map_domain_t d,
u32  addr,
u16  port 
)

Definition at line 351 of file map.h.

+ Here is the caller graph for this function:

static_always_inline u64 map_get_pfx_net ( map_domain_t d,
u32  addr,
u16  port 
)

Definition at line 365 of file map.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline u64 map_get_sfx ( map_domain_t d,
u32  addr,
u16  port 
)

Definition at line 375 of file map.h.

+ Here is the caller graph for this function:

static_always_inline u64 map_get_sfx_net ( map_domain_t d,
u32  addr,
u16  port 
)

Definition at line 394 of file map.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void map_ip4_drop_pi ( u32  pi)

Definition at line 664 of file ip6_map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_ip4_reass_add_fragment ( map_ip4_reass_t r,
u32  pi 
)

Definition at line 1544 of file map.c.

+ Here is the caller graph for this function:

int map_ip4_reass_conf_buffers ( u32  buffers)

Definition at line 1874 of file map.c.

+ Here is the caller graph for this function:

int map_ip4_reass_conf_ht_ratio ( f32  ht_ratio,
u32 trashed_reass,
u32 dropped_packets 
)

Definition at line 1835 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_ip4_reass_conf_lifetime ( u16  lifetime_ms)

Definition at line 1867 of file map.c.

+ Here is the caller graph for this function:

int map_ip4_reass_conf_pool_size ( u16  pool_size,
u32 trashed_reass,
u32 dropped_packets 
)

Definition at line 1852 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void map_ip4_reass_free ( map_ip4_reass_t r,
u32 **  pi_to_drop 
)

Definition at line 1420 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

map_ip4_reass_t* map_ip4_reass_get ( u32  src,
u32  dst,
u16  fragment_id,
u8  protocol,
u32 **  pi_to_drop 
)

Definition at line 1463 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline void map_ip4_reass_get_fragments ( map_ip4_reass_t r,
u32 **  pi 
)

Definition at line 462 of file map.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void map_ip6_drop_pi ( u32  pi)

Definition at line 655 of file ip6_map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_ip6_reass_add_fragment ( map_ip6_reass_t r,
u32  pi,
u16  data_offset,
u16  next_data_offset,
u8 data_start,
u16  data_len 
)

Definition at line 1723 of file map.c.

+ Here is the caller graph for this function:

int map_ip6_reass_conf_buffers ( u32  buffers)

Definition at line 1957 of file map.c.

+ Here is the caller graph for this function:

int map_ip6_reass_conf_ht_ratio ( f32  ht_ratio,
u32 trashed_reass,
u32 dropped_packets 
)

Definition at line 1918 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_ip6_reass_conf_lifetime ( u16  lifetime_ms)

Definition at line 1950 of file map.c.

+ Here is the caller graph for this function:

int map_ip6_reass_conf_pool_size ( u16  pool_size,
u32 trashed_reass,
u32 dropped_packets 
)

Definition at line 1935 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void map_ip6_reass_free ( map_ip6_reass_t r,
u32 **  pi_to_drop 
)

Definition at line 1583 of file map.c.

+ Here is the caller graph for this function:

map_ip6_reass_t* map_ip6_reass_get ( ip6_address_t src,
ip6_address_t dst,
u32  fragment_id,
u8  protocol,
u32 **  pi_to_drop 
)

Definition at line 1635 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline void map_send_all_to_node ( vlib_main_t vm,
u32 pi_vector,
vlib_node_runtime_t node,
vlib_error_t error,
u32  next 
)

Definition at line 549 of file map.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

STATIC_ASSERT ( (sizeof(map_domain_t)<=CLIB_CACHE_LINE_BYTES ,
"MAP domain fits in one cacheline"   
)

Variable Documentation

(constructor) VLIB_REGISTER_NODE (ip4_map_node)

Definition at line 703 of file ip4_map.c.

vlib_node_registration_t ip4_map_t_fragmented_node

(constructor) VLIB_REGISTER_NODE (ip4_map_t_fragmented_node)

Definition at line 726 of file ip4_map_t.c.

vlib_node_registration_t ip4_map_t_icmp_node

(constructor) VLIB_REGISTER_NODE (ip4_map_t_icmp_node)

Definition at line 746 of file ip4_map_t.c.

vlib_node_registration_t ip4_map_t_node

(constructor) VLIB_REGISTER_NODE (ip4_map_t_node)

Definition at line 786 of file ip4_map_t.c.

vlib_node_registration_t ip4_map_t_tcp_udp_node

(constructor) VLIB_REGISTER_NODE (ip4_map_t_tcp_udp_node)

Definition at line 766 of file ip4_map_t.c.

(constructor) VLIB_REGISTER_NODE (ip6_map_node)

Definition at line 1180 of file ip6_map.c.

vlib_node_registration_t ip6_map_t_fragmented_node

(constructor) VLIB_REGISTER_NODE (ip6_map_t_fragmented_node)

Definition at line 953 of file ip6_map_t.c.

vlib_node_registration_t ip6_map_t_icmp_node

(constructor) VLIB_REGISTER_NODE (ip6_map_t_icmp_node)

Definition at line 973 of file ip6_map_t.c.

vlib_node_registration_t ip6_map_t_node

(constructor) VLIB_REGISTER_NODE (ip6_map_t_node)

Definition at line 1013 of file ip6_map_t.c.

vlib_node_registration_t ip6_map_t_tcp_udp_node

(constructor) VLIB_REGISTER_NODE (ip6_map_t_tcp_udp_node)

Definition at line 993 of file ip6_map_t.c.

map_main_t map_main

Definition at line 26 of file map.c.

Pre-resolved next hops for v4 and v6.

Why these are global and not per-domain is beyond me.

Pre-resolved next hops for v4 and v6.

Definition at line 312 of file map.c.