FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
adj.h File Reference
+ Include dependency graph for adj.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...
 

Macros

#define IP4_LOOKUP_NEXT_NODES
 
#define IP6_LOOKUP_NEXT_NODES
 
#define ADJ_ATTR_NAMES
 
#define FOR_EACH_ADJ_ATTR(_attr)
 

Typedefs

typedef void(* adj_midchain_fixup_t) (vlib_main_t *vm, struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)
 A function type for post-rewrite fixups on midchain adjacency. More...
 
typedef enum adj_attr_t_ adj_attr_t
 Flags on an IP adjacency. More...
 
typedef enum adj_flags_t_ adj_flags_t
 Flags on an IP adjacency. More...
 
typedef struct ip_adjacency_t_ ip_adjacency_t
 IP unicast adjacency. More...
 

Enumerations

enum  ip_lookup_next_t {
  IP_LOOKUP_NEXT_DROP, IP_LOOKUP_NEXT_PUNT, IP_LOOKUP_NEXT_LOCAL, IP_LOOKUP_NEXT_ARP,
  IP_LOOKUP_NEXT_GLEAN, IP_LOOKUP_NEXT_REWRITE, IP_LOOKUP_NEXT_MIDCHAIN, IP_LOOKUP_NEXT_ICMP_ERROR,
  IP_LOOKUP_NEXT_MCAST, IP_LOOKUP_NEXT_BCAST, IP_LOOKUP_NEXT_MCAST_MIDCHAIN, IP_LOOKUP_N_NEXT
}
 An adjacency is a representation of an attached L3 peer. 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  adj_attr_t_ { ADJ_ATTR_SYNC_WALK_ACTIVE = 0, ADJ_ATTR_MIDCHAIN_NO_COUNT, ADJ_ATTR_MIDCHAIN_IP_STACK, ADJ_ATTR_MIDCHAIN_LOOPED }
 Flags on an IP adjacency. More...
 
enum  adj_flags_t_ {
  ADJ_FLAG_NONE = 0, ADJ_FLAG_SYNC_WALK_ACTIVE = (1 << ADJ_ATTR_SYNC_WALK_ACTIVE), ADJ_FLAG_MIDCHAIN_NO_COUNT = (1 << ADJ_ATTR_MIDCHAIN_NO_COUNT), ADJ_FLAG_MIDCHAIN_IP_STACK = (1 << ADJ_ATTR_MIDCHAIN_IP_STACK),
  ADJ_FLAG_MIDCHAIN_LOOPED = (1 << ADJ_ATTR_MIDCHAIN_LOOPED)
}
 Flags on an IP adjacency. More...
 

Functions

u8format_adj_flags (u8 *s, va_list *args)
 Format adjacency flags. More...
 
 STATIC_ASSERT ((STRUCT_OFFSET_OF(ip_adjacency_t, cacheline0)==0), "IP adjacency cacheline 0 is not offset")
 
 STATIC_ASSERT ((STRUCT_OFFSET_OF(ip_adjacency_t, cacheline1)==CLIB_CACHE_LINE_BYTES), "IP adjacency cacheline 1 is more than one cacheline size offset")
 
void adj_lock (adj_index_t adj_index)
 Take a reference counting lock on the adjacency. More...
 
void adj_unlock (adj_index_t adj_index)
 Release a reference counting lock on the adjacency. More...
 
u32 adj_child_add (adj_index_t adj_index, fib_node_type_t type, fib_node_index_t child_index)
 Add a child dependent to an adjacency. More...
 
void adj_child_remove (adj_index_t adj_index, u32 sibling_index)
 Remove a child dependent. More...
 
void adj_walk (u32 sw_if_index, adj_walk_cb_t cb, void *ctx)
 Walk the Adjacencies on a given interface. More...
 
vnet_link_t adj_get_link_type (adj_index_t ai)
 Return the link type of the adjacency. More...
 
u32 adj_get_sw_if_index (adj_index_t ai)
 Return the sw interface index of the adjacency. More...
 
int adj_is_up (adj_index_t ai)
 Return true if the adjacency is 'UP', i.e. More...
 
const u8adj_get_rewrite (adj_index_t ai)
 Return the link type of the adjacency. More...
 
void adj_feature_update (u32 sw_if_index, u8 arc_index, u8 is_enable)
 Notify the adjacency subsystem that the features settings for an interface have changed. More...
 
int adj_recursive_loop_detect (adj_index_t ai, fib_node_index_t **entry_indicies)
 descend the FIB graph looking for loops More...
 
static ip_adjacency_tadj_get (adj_index_t adj_index)
 Get a pointer to an adjacency object from its index. More...
 
static int adj_is_valid (adj_index_t adj_index)
 
static int adj_are_counters_enabled (void)
 Get the global configuration option for enabling per-adj counters. More...
 

Variables

const ip46_address_t ADJ_BCAST_ADDR
 The special broadcast address (to construct a broadcast adjacency. More...
 
ip_adjacency_tadj_pool
 The global adjacency pool. More...
 
vlib_combined_counter_main_t adjacency_counters
 Adjacency packet counters. More...
 
int adj_per_adj_counters
 Global Config for enabling per-adjacency counters This is configurable because it comes with a non-negligible performance cost. More...
 

Macro Definition Documentation

◆ ADJ_ATTR_NAMES

#define ADJ_ATTR_NAMES
Value:
{ \
[ADJ_ATTR_SYNC_WALK_ACTIVE] = "walk-active", \
[ADJ_ATTR_MIDCHAIN_NO_COUNT] = "midchain-no-count", \
[ADJ_ATTR_MIDCHAIN_IP_STACK] = "midchain-ip-stack", \
[ADJ_ATTR_MIDCHAIN_LOOPED] = "midchain-looped", \
}
Packets TX through the midchain do not increment the interface counters.
Definition: adj.h:174
When stacking midchains on a fib-entry extract the choice from the load-balance returned based on an ...
Definition: adj.h:179
Currently a sync walk is active.
Definition: adj.h:165
If the midchain were to stack on its FIB entry a loop would form.
Definition: adj.h:183

Definition at line 186 of file adj.h.

◆ FOR_EACH_ADJ_ATTR

#define FOR_EACH_ADJ_ATTR (   _attr)
Value:
_attr++)
Currently a sync walk is active.
Definition: adj.h:165
If the midchain were to stack on its FIB entry a loop would form.
Definition: adj.h:183

Definition at line 193 of file adj.h.

◆ IP4_LOOKUP_NEXT_NODES

#define IP4_LOOKUP_NEXT_NODES
Value:
{ \
[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_GLEAN] = "ip4-glean", \
[IP_LOOKUP_NEXT_REWRITE] = "ip4-rewrite", \
[IP_LOOKUP_NEXT_MCAST] = "ip4-rewrite-mcast", \
[IP_LOOKUP_NEXT_BCAST] = "ip4-rewrite-bcast", \
[IP_LOOKUP_NEXT_MIDCHAIN] = "ip4-midchain", \
[IP_LOOKUP_NEXT_MCAST_MIDCHAIN] = "ip4-mcast-midchain", \
[IP_LOOKUP_NEXT_ICMP_ERROR] = "ip4-icmp-error", \
}
Multicast Adjacency.
Definition: adj.h:82
Broadcasr Adjacency.
Definition: adj.h:85
This packet is to be rewritten and forwarded to the next processing node.
Definition: adj.h:73
Adjacency to punt this packet.
Definition: adj.h:55
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: adj.h:68
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Definition: adj.h:63
Adjacency to drop this packet.
Definition: adj.h:53
Multicast Midchain Adjacency.
Definition: adj.h:89
This packets follow a mid-chain adjacency.
Definition: adj.h:76
This packets needs to go to ICMP error.
Definition: adj.h:79
This packet is for one of our own IP addresses.
Definition: adj.h:58

Definition at line 108 of file adj.h.

◆ IP6_LOOKUP_NEXT_NODES

#define IP6_LOOKUP_NEXT_NODES
Value:
{ \
[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_GLEAN] = "ip6-glean", \
[IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite", \
[IP_LOOKUP_NEXT_BCAST] = "ip6-rewrite-bcast", \
[IP_LOOKUP_NEXT_MCAST] = "ip6-rewrite-mcast", \
[IP_LOOKUP_NEXT_MIDCHAIN] = "ip6-midchain", \
[IP_LOOKUP_NEXT_MCAST_MIDCHAIN] = "ip6-mcast-midchain", \
[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", \
}
Multicast Adjacency.
Definition: adj.h:82
Broadcasr Adjacency.
Definition: adj.h:85
This packet is to be rewritten and forwarded to the next processing node.
Definition: adj.h:73
Adjacency to punt this packet.
Definition: adj.h:55
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: adj.h:68
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Definition: adj.h:63
Adjacency to drop this packet.
Definition: adj.h:53
Multicast Midchain Adjacency.
Definition: adj.h:89
This packets follow a mid-chain adjacency.
Definition: adj.h:76
This packets needs to go to ICMP error.
Definition: adj.h:79
This packet is for one of our own IP addresses.
Definition: adj.h:58

Definition at line 122 of file adj.h.

Typedef Documentation

◆ adj_attr_t

typedef enum adj_attr_t_ adj_attr_t

Flags on an IP adjacency.

◆ adj_flags_t

typedef enum adj_flags_t_ adj_flags_t

Flags on an IP adjacency.

◆ adj_midchain_fixup_t

typedef void(* adj_midchain_fixup_t) (vlib_main_t *vm, struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)

A function type for post-rewrite fixups on midchain adjacency.

Definition at line 152 of file adj.h.

◆ ip_adjacency_t

IP unicast adjacency.

Note
cache aligned.

An adjacency is a representation of a peer on a particular link.

Enumeration Type Documentation

◆ adj_attr_t_

Flags on an IP adjacency.

Enumerator
ADJ_ATTR_SYNC_WALK_ACTIVE 

Currently a sync walk is active.

Used to prevent re-entrant walking

ADJ_ATTR_MIDCHAIN_NO_COUNT 

Packets TX through the midchain do not increment the interface counters.

This should be used when the adj is associated with an L2 interface and that L2 interface is in a bridege domain. In that case the packet will have traversed the interface's TX node, and hence have been counted, before it traverses ths midchain

ADJ_ATTR_MIDCHAIN_IP_STACK 

When stacking midchains on a fib-entry extract the choice from the load-balance returned based on an IP hash of the adj's rewrite.

ADJ_ATTR_MIDCHAIN_LOOPED 

If the midchain were to stack on its FIB entry a loop would form.

Definition at line 160 of file adj.h.

◆ adj_flags_t_

Flags on an IP adjacency.

Enumerator
ADJ_FLAG_NONE 
ADJ_FLAG_SYNC_WALK_ACTIVE 
ADJ_FLAG_MIDCHAIN_NO_COUNT 
ADJ_FLAG_MIDCHAIN_IP_STACK 
ADJ_FLAG_MIDCHAIN_LOOPED 

Definition at line 201 of file adj.h.

◆ ip4_lookup_next_t

Enumerator
IP4_LOOKUP_N_NEXT 

Definition at line 94 of file adj.h.

◆ ip6_lookup_next_t

Enumerator
IP6_LOOKUP_NEXT_HOP_BY_HOP 
IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP 
IP6_LOOKUP_NEXT_POP_HOP_BY_HOP 
IP6_LOOKUP_N_NEXT 

Definition at line 99 of file adj.h.

◆ ip_lookup_next_t

An adjacency is a representation of an attached L3 peer.

Adjacency Sub-types:

  • neighbour: a representation of an attached L3 peer. Key:{addr,interface,link/ether-type} SHARED
  • glean: used to drive ARP/ND for packets destined to a local sub-net. 'glean' mean use the packet's destination address as the target address in the ARP packet. UNSHARED. Only one per-interface.
  • midchain: a nighbour adj on a virtual/tunnel interface.

The API to create and update the adjacency is very sub-type specific. This is intentional as it encourages the user to carefully consider which adjacency sub-type they are really using, and hence assign it data in the appropriate sub-type space in the union of sub-types. This prevents the adj becoming a disorganised dumping group for 'my features needs a u16 somewhere' data. It is important to enforce this approach as space in the adjacency is a premium, as we need it to fit in 1 cache line.

the API is also based around an index to an ajdacency not a raw pointer. This is so the user doesn't suffer the same limp inducing firearm injuries that the author suffered as the adjacenices can realloc.Common (IP4/IP6) next index stored in adjacency.

Enumerator
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 "incomplete adjacency" and packets need to be passed to ARP to find rewrite string for this destination.

IP_LOOKUP_NEXT_GLEAN 

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_MIDCHAIN 

This packets follow a mid-chain adjacency.

IP_LOOKUP_NEXT_ICMP_ERROR 

This packets needs to go to ICMP error.

IP_LOOKUP_NEXT_MCAST 

Multicast Adjacency.

IP_LOOKUP_NEXT_BCAST 

Broadcasr Adjacency.

IP_LOOKUP_NEXT_MCAST_MIDCHAIN 

Multicast Midchain Adjacency.

An Adjacency for sending macst packets on a tunnel/virtual interface

IP_LOOKUP_N_NEXT 

Definition at line 50 of file adj.h.

Function Documentation

◆ adj_are_counters_enabled()

static int adj_are_counters_enabled ( void  )
inlinestatic

Get the global configuration option for enabling per-adj counters.

Definition at line 448 of file adj.h.

+ Here is the caller graph for this function:

◆ adj_child_add()

u32 adj_child_add ( adj_index_t  adj_index,
fib_node_type_t  type,
fib_node_index_t  child_index 
)

Add a child dependent to an adjacency.

The child will thus be informed via its registerd back-walk function when the adjacency state changes.

Definition at line 366 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_child_remove()

void adj_child_remove ( adj_index_t  adj_index,
u32  sibling_index 
)

Remove a child dependent.

Definition at line 383 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_feature_update()

void adj_feature_update ( u32  sw_if_index,
u8  arc_index,
u8  is_enable 
)

Notify the adjacency subsystem that the features settings for an interface have changed.

Definition at line 434 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_get()

static ip_adjacency_t* adj_get ( adj_index_t  adj_index)
inlinestatic

Get a pointer to an adjacency object from its index.

Definition at line 433 of file adj.h.

◆ adj_get_link_type()

vnet_link_t adj_get_link_type ( adj_index_t  ai)

Return the link type of the adjacency.

Definition at line 497 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_get_rewrite()

const u8* adj_get_rewrite ( adj_index_t  ai)

Return the link type of the adjacency.

Return the link type of the adjacency.

Definition at line 533 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_get_sw_if_index()

u32 adj_get_sw_if_index ( adj_index_t  ai)

Return the sw interface index of the adjacency.

Definition at line 510 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_is_up()

int adj_is_up ( adj_index_t  ai)

Return true if the adjacency is 'UP', i.e.

can be used for forwarding. 0 is down, !0 is up.

can be used for forwarding 0 is down, !0 is up.

Definition at line 524 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_is_valid()

static int adj_is_valid ( adj_index_t  adj_index)
inlinestatic

Definition at line 439 of file adj.h.

+ Here is the caller graph for this function:

◆ adj_lock()

void adj_lock ( adj_index_t  adj_index)

Take a reference counting lock on the adjacency.

Definition at line 330 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_recursive_loop_detect()

int adj_recursive_loop_detect ( adj_index_t  ai,
fib_node_index_t **  entry_indicies 
)

descend the FIB graph looking for loops

Parameters
aiThe adj index to traverse
entry_indicies)A pointer to a vector of FIB entries already visited.

Definition at line 223 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_unlock()

void adj_unlock ( adj_index_t  adj_index)

Release a reference counting lock on the adjacency.

Definition at line 347 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_walk()

void adj_walk ( u32  sw_if_index,
adj_walk_cb_t  cb,
void *  ctx 
)

Walk the Adjacencies on a given interface.

Definition at line 477 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_adj_flags()

u8* format_adj_flags ( u8 s,
va_list *  args 
)

Format adjacency flags.

Definition at line 127 of file adj.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STATIC_ASSERT() [1/2]

STATIC_ASSERT ( (STRUCT_OFFSET_OF(ip_adjacency_t, cacheline0)==0)  ,
"IP adjacency cacheline 0 is not offset  
)

◆ STATIC_ASSERT() [2/2]

STATIC_ASSERT ( (STRUCT_OFFSET_OF(ip_adjacency_t, cacheline1)==CLIB_CACHE_LINE_BYTES ,
"IP adjacency cacheline 1 is more than one cacheline size offset  
)

Variable Documentation

◆ ADJ_BCAST_ADDR

const ip46_address_t ADJ_BCAST_ADDR

The special broadcast address (to construct a broadcast adjacency.

Definition at line 41 of file adj.c.

◆ adj_per_adj_counters

int adj_per_adj_counters

Global Config for enabling per-adjacency counters This is configurable because it comes with a non-negligible performance cost.

Global Config for enabling per-adjacency counters This is configurable because it comes with a non-negligible performance cost.

By default these are disabled.

Definition at line 39 of file adj.c.

◆ adj_pool

ip_adjacency_t* adj_pool

The global adjacency pool.

Exposed for fast/inline data-plane access

Definition at line 33 of file adj.c.

◆ adjacency_counters

vlib_combined_counter_main_t adjacency_counters

Adjacency packet counters.

Definition at line 25 of file adj.c.