Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Classes | Macros | Typedefs | Enumerations | Functions | Variables
face.h File Reference
#include <vnet/fib/fib_node.h>
#include <vnet/vnet.h>
#include <vlib/vlib.h>
#include <vnet/ip/ip46_address.h>
#include <vnet/dpo/dpo.h>
#include <vnet/adj/adj_types.h>
#include <vppinfra/bihash_8_8.h>
#include <vnet/adj/adj_midchain.h>
#include "../error.h"
Include dependency graph for face.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hicn_face_vft_s
 Definition of the virtual functin table for an hICN FACE DPO. More...
 
struct  hicn_input_faces_s_
 

Macros

#define HICN_FACE_FLAGS_DEFAULT   0x00
 
#define HICN_FACE_FLAGS_FACE   0x01
 
#define HICN_FACE_FLAGS_IFACE   0x02
 
#define HICN_FACE_FLAGS_APPFACE_PROD   0x04 /* Currently only IP face can be appface */
 
#define HICN_FACE_FLAGS_APPFACE_CONS   0x08 /* Currently only IP face can be appface */
 
#define HICN_FACE_FLAGS_DELETED   0x10
 
#define HICN_FACE_NULL   (hicn_face_id_t) ~0
 
#define HICN_FACE_FLAGS_APPFACE_PROD_BIT   2
 
#define HICN_FACE_FLAGS_APPFACE_CONS_BIT   3
 
#define HICN_BUFFER_FLAGS_DEFAULT   0x00
 
#define HICN_BUFFER_FLAGS_FACE_IS_APP   0x01
 
#define foreach_hicn_face_counter
 
#define _(a, b, c)   HICN_FACE_COUNTERS_##a = (b),
 
#define get_face_counter_string(ctrxno)   (char *) (HICN_FACE_CTRX_STRING[ctrxno])
 

Typedefs

typedef u8 hicn_face_flags_t
 
typedef index_t hicn_face_id_t
 
typedef struct hicn_face_vft_s hicn_face_vft_t
 Definition of the virtual functin table for an hICN FACE DPO.
 
typedef hicn_face_id_t * hicn_face_vec_t
 
typedef struct hicn_input_faces_s_ hicn_face_input_faces_t
 

Enumerations

enum  hicn_face_counters_t { HICN_N_COUNTER }
 

Functions

struct __attribute__ ((packed)) hicn_face_s
 Structure representing a face. It containes the fields shared among all the types of faces as well it leaves some space for storing additional information specific to each type. More...
 
 STATIC_ASSERT ((1<< HICN_FACE_FLAGS_APPFACE_PROD_BIT)==HICN_FACE_FLAGS_APPFACE_PROD, "HICN_FACE_FLAGS_APPFACE_PROD_BIT and " "HICN_FACE_FLAGS_APPFACE_PROD must correspond")
 
 STATIC_ASSERT ((1<< HICN_FACE_FLAGS_APPFACE_CONS_BIT)==HICN_FACE_FLAGS_APPFACE_CONS, "HICN_FACE_FLAGS_APPFACE_CONS_BIT and " "HICN_FACE_FLAGS_APPFACE_CONS must correspond")
 
 STATIC_ASSERT ((HICN_FACE_FLAGS_APPFACE_PROD >> HICN_FACE_FLAGS_APPFACE_PROD_BIT)==HICN_BUFFER_FLAGS_FACE_IS_APP, "hicn buffer app flag does not correspond to HICN_FACE_FLAGS_APPFACE_PROD")
 
 STATIC_ASSERT ((HICN_FACE_FLAGS_APPFACE_CONS >> HICN_FACE_FLAGS_APPFACE_CONS_BIT)==HICN_BUFFER_FLAGS_FACE_IS_APP, "hicn buffer app flag does not correspond to HICN_FACE_FLAGS_APPFACE_PROD")
 
always_inline hicn_face_id_t hicn_dpoi_get_index (hicn_face_t *face_dpoi)
 Return the face id from the face object. More...
 
always_inline hicn_face_t * hicn_dpoi_get_from_idx_safe (hicn_face_id_t dpoi_index)
 Return the face object from the face id. This method is robust to invalid face id. More...
 
always_inline hicn_face_t * hicn_dpoi_get_from_idx (hicn_face_id_t dpoi_index)
 Return the face from the face id. Face id must be valid. More...
 
always_inline int hicn_dpoi_idx_is_valid (hicn_face_id_t face_id)
 Return true if the face id belongs to an existing face.
 
always_inline void hicn_face_lock_with_id (hicn_face_id_t face_id)
 Add a lock to the face dpo. More...
 
always_inline void hicn_face_unlock_with_id (hicn_face_id_t face_id)
 Remove a lock to the face dpo. Deallocate the face id locks == 0. More...
 
always_inline void hicn_face_lock (dpo_id_t *dpo)
 Add a lock to the face through its dpo. More...
 
always_inline void hicn_face_unlock (dpo_id_t *dpo)
 Remove a lock to the face through its dpo. Deallocate the face id locks == 0. More...
 
void hicn_face_module_init (vlib_main_t *vm)
 Init the internal structures of the face module. More...
 
u8 * format_hicn_face (u8 *s, va_list *args)
 
u8 * format_hicn_face_all (u8 *s, int n,...)
 Format all the existing faces. More...
 
int hicn_face_del (hicn_face_id_t face_id)
 Delete a face. More...
 
always_inline void hicn_face_get_key (const ip46_address_t *addr, u32 sw_if, const dpo_id_t *dpo, hicn_face_key_t *key)
 Create the key object for the mhash. Fill in the key object with the expected values. More...
 
always_inline hicn_face_t * hicn_face_get (const ip46_address_t *addr, u32 sw_if, mhash_t *hashtb, index_t adj_index)
 Get the face obj from the nat address. Does not add any lock. More...
 
always_inline hicn_face_t * hicn_face_get_with_dpo (const ip46_address_t *addr, u32 sw_if, const dpo_id_t *dpo, mhash_t *hashtb)
 Get the face obj from the nat address and the dpo. Does not add any lock. More...
 
always_inline hicn_face_input_faces_thicn_face_get_vec (const ip46_address_t *addr, mhash_t *hashtb)
 Get the vector of faces from the ip v4 address. Does not add any lock. More...
 
int hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, hicn_face_id_t *pfaceid, u8 is_app_prod)
 Create a new face ip. API for other modules (e.g., routing) More...
 
always_inline void hicn_iface_add (ip46_address_t *nat_address, int sw_if, hicn_face_id_t *pfaceid, dpo_proto_t proto, u32 adj_index)
 Create a new incomplete face ip. (Meant to be used by the data plane) More...
 
always_inline int hicn_face_ip4_lock (hicn_face_id_t *face_id, u32 *in_faces_vec_id, u8 *hicnb_flags, const ip4_address_t *nat_addr)
 Retrieve a vector of faces from the ip4 local address and returns its index. More...
 
always_inline int hicn_face_ip6_lock (hicn_face_id_t *face_id, u32 *in_faces_vec_id, u8 *hicnb_flags, const ip6_address_t *nat_addr)
 Retrieve a face from the ip6 local address and returns its dpo. This method adds a lock on the face state. More...
 
always_inline void hicn_iface_ip4_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, const ip4_address_t *nat_addr, u32 sw_if, u32 adj_index, u32 node_index)
 Retrieve, or create if it doesn't exist, a face from the ip6 local address and returns its dpo. This method adds a lock on the face state. More...
 
always_inline void hicn_iface_ip6_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, const ip6_address_t *nat_addr, u32 sw_if, u32 adj_index, u32 node_index)
 Retrieve, or create if it doesn't exist, a face from the ip6 local address and returns its dpo. This method adds a lock on the face state. More...
 

Variables

 hicn_face_t
 
hicn_face_t * hicn_dpoi_face_pool
 
mhash_t hicn_face_hashtb
 
const char * HICN_FACE_CTRX_STRING []
 
dpo_id_t * face_dpo_vec
 
hicn_face_vft_tface_vft_vec
 
char ** face_type_names_vec
 
u8 pl_index
 
dpo_type_t first_type
 
vlib_combined_counter_main_t * counters
 
hicn_face_vec_thicn_vec_pool
 
mhash_t hicn_face_vec_hashtb
 
 hicn_face_key_t
 

Detailed Description

This file implements a general face type. The purpose of a face is to carry the needed information to forward interest and data packets to the next node in the network. There are two type of faces: complete faces (in short faces), and incomplete faces (in short ifaces).

A face that does not contain the indication of the adjacency is an incomplete face (iface), otherwise it is considered to be complete. Ifaces are used to forward data back to the previous hICN hop from which we received an interest, while faces are used to forward interest packets to the next hicn node. Faces and ifaces are created at two different points in time. Faces are created when a route is added, while ifaces are created when an interest is received. In details, faces and ifaces carry the following information:

We maintain two hash tables to retrieve faces and ifaces. In particular one hash table which index faces and ifaces for nat_address, sw_if and dpo. This is used to retrieve existing faces or ifaces when an interest is received and when an new face is created. A second hash table that indexes vectors of faces for nat_address and sw_if. This is used to retrieve a list of possible incoming faces when a data is received.

Macro Definition Documentation

◆ foreach_hicn_face_counter

#define foreach_hicn_face_counter
Value:
_ (INTEREST_RX, 0, "Interest rx") \
_ (INTEREST_TX, 1, "Interest tx") \
_ (DATA_RX, 2, "Data rx") \
_ (DATA_TX, 3, "Data tx")

Typedef Documentation

◆ hicn_face_vec_t

typedef hicn_face_id_t* hicn_face_vec_t

@bried vector of faces used to collect faces having the same local address

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed)  )

Structure representing a face. It containes the fields shared among all the types of faces as well it leaves some space for storing additional information specific to each type.

Key definition for the mhash table. An face is uniquely identified by ip address, the interface id and a dpo pointing to the next node in the vlib graph. The ip address can correspond to the remote ip address of the next hicn hop, or to the local address of the receiving interface. The former is used to retrieve the incoming face when an interest is received, the latter when the arring packet is a data. If the face is a regular face In case of iface, the following structure can be filled in different ways:

  • dpo equal to DPO_INVALID when the iface is a regular hICN iface
  • in case of udp_tunnel dpo = { .dpoi_index = tunnel_id, .dpoi_type = DPO_FIRST, //We don't need the type, we leave it invalid .dpoi_proto = DPO_PROTO_IP4 or DPO_PROTO_IP6, .dpoi_next_node = HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP or HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP or HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP or HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP }

◆ format_hicn_face_all()

u8* format_hicn_face_all ( u8 *  s,
int  n,
  ... 
)

Format all the existing faces.

Parameters
sPointer to a previous string. If null it will be initialize
nNumber of input parameters
Returns
String with the faces formatted

◆ hicn_dpoi_get_from_idx()

always_inline hicn_face_t* hicn_dpoi_get_from_idx ( hicn_face_id_t  dpoi_index)

Return the face from the face id. Face id must be valid.

Parameters
dpoi_indexFace identifier
Returns
Pointer to the face

◆ hicn_dpoi_get_from_idx_safe()

always_inline hicn_face_t* hicn_dpoi_get_from_idx_safe ( hicn_face_id_t  dpoi_index)

Return the face object from the face id. This method is robust to invalid face id.

Parameters
dpoi_indexFace identifier
Returns
Pointer to the face or NULL

◆ hicn_dpoi_get_index()

always_inline hicn_face_id_t hicn_dpoi_get_index ( hicn_face_t *  face_dpoi)

Return the face id from the face object.

Parameters
Pointerto the face state
Returns
face id

◆ hicn_face_add()

int hicn_face_add ( const dpo_id_t *  dpo_nh,
ip46_address_t nat_address,
int  sw_if,
hicn_face_id_t *  pfaceid,
u8  is_app_prod 
)

Create a new face ip. API for other modules (e.g., routing)

Parameters
dpo_nhdpo contained in the face that points to the next node in the vlib graph
nat_addrnat ip v4 or v6 address of the face
sw_ifinterface associated to the face
pfaceidPointer to return the face id
is_app_prodif HICN_FACE_FLAGS_APPFACE_PROD the face is a local application face, all other values are ignored
Returns
HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally reachable ip address, otherwise HICN_ERROR_NONE

◆ hicn_face_del()

int hicn_face_del ( hicn_face_id_t  face_id)

Delete a face.

Parameters
face_idId of the face to delete
Returns
HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE

◆ hicn_face_get()

always_inline hicn_face_t* hicn_face_get ( const ip46_address_t addr,
u32  sw_if,
mhash_t *  hashtb,
index_t  adj_index 
)

Get the face obj from the nat address. Does not add any lock.

Parameters
addrIp v4 address used to create the key for the hash table.
sw_ifSoftware interface id used to create the key for the hash table.
hashtbHash table (remote or local) where to perform the lookup.
Returns
Pointer to the face.

◆ hicn_face_get_key()

always_inline void hicn_face_get_key ( const ip46_address_t addr,
u32  sw_if,
const dpo_id_t *  dpo,
hicn_face_key_t *  key 
)

Create the key object for the mhash. Fill in the key object with the expected values.

Parameters
addrnat address of the face
sw_ifinterface associated to the face
keyPointer to an allocated hicn_face_ip_key_t object

◆ hicn_face_get_vec()

always_inline hicn_face_input_faces_t* hicn_face_get_vec ( const ip46_address_t addr,
mhash_t *  hashtb 
)

Get the vector of faces from the ip v4 address. Does not add any lock.

Parameters
addrIp v4 address used to create the key for the hash table.
sw_ifSoftware interface id used to create the key for the hash table.
hashtbHash table (remote or local) where to perform the lookup.
Returns
Pointer to the face.

◆ hicn_face_get_with_dpo()

always_inline hicn_face_t* hicn_face_get_with_dpo ( const ip46_address_t addr,
u32  sw_if,
const dpo_id_t *  dpo,
mhash_t *  hashtb 
)

Get the face obj from the nat address and the dpo. Does not add any lock.

Parameters
addrIp v4 address used to create the key for the hash table.
sw_ifSoftware interface id used to create the key for the hash table.
hashtbHash table (remote or local) where to perform the lookup.
Returns
Pointer to the face.

◆ hicn_face_ip4_lock()

always_inline int hicn_face_ip4_lock ( hicn_face_id_t *  face_id,
u32 *  in_faces_vec_id,
u8 *  hicnb_flags,
const ip4_address_t nat_addr 
)

Retrieve a vector of faces from the ip4 local address and returns its index.

Parameters
vecResult of the lookup. If no face exists for the local address vec = NULL
hicnb_flagsFlags that indicate whether the face is an application face or not
local_addrIp v4 nat address of the face
sw_ifsoftware interface id of the face
Returns
HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.

◆ hicn_face_ip6_lock()

always_inline int hicn_face_ip6_lock ( hicn_face_id_t *  face_id,
u32 *  in_faces_vec_id,
u8 *  hicnb_flags,
const ip6_address_t nat_addr 
)

Retrieve a face from the ip6 local address and returns its dpo. This method adds a lock on the face state.

Parameters
dpoResult of the lookup. If the face doesn't exist dpo = NULL
hicnb_flagsFlags that indicate whether the face is an application face or not
nat_addrIp v6 nat address of the face
sw_ifsoftware interface id of the face
Returns
HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.

◆ hicn_face_lock()

always_inline void hicn_face_lock ( dpo_id_t *  dpo)

Add a lock to the face through its dpo.

Parameters
dpoPointer to the face dpo

◆ hicn_face_lock_with_id()

always_inline void hicn_face_lock_with_id ( hicn_face_id_t  face_id)

Add a lock to the face dpo.

Parameters
dpoPointer to the face dpo

◆ hicn_face_module_init()

void hicn_face_module_init ( vlib_main_t *  vm)

Init the internal structures of the face module.

Must be called before processing any packet

◆ hicn_face_unlock()

always_inline void hicn_face_unlock ( dpo_id_t *  dpo)

Remove a lock to the face through its dpo. Deallocate the face id locks == 0.

Parameters
dpoPointer to the face dpo

◆ hicn_face_unlock_with_id()

always_inline void hicn_face_unlock_with_id ( hicn_face_id_t  face_id)

Remove a lock to the face dpo. Deallocate the face id locks == 0.

Parameters
dpoPointer to the face dpo

◆ hicn_iface_add()

always_inline void hicn_iface_add ( ip46_address_t nat_address,
int  sw_if,
hicn_face_id_t *  pfaceid,
dpo_proto_t  proto,
u32  adj_index 
)

Create a new incomplete face ip. (Meant to be used by the data plane)

Parameters
local_addrLocal ip v4 or v6 address of the face
remote_addrRemote ip v4 or v6 address of the face
sw_ifinterface associated to the face
pfaceidPointer to return the face id
Returns
HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally reachable ip address, otherwise HICN_ERROR_NONE

◆ hicn_iface_ip4_add_and_lock()

always_inline void hicn_iface_ip4_add_and_lock ( hicn_face_id_t *  index,
u8 *  hicnb_flags,
const ip4_address_t nat_addr,
u32  sw_if,
u32  adj_index,
u32  node_index 
)

Retrieve, or create if it doesn't exist, a face from the ip6 local address and returns its dpo. This method adds a lock on the face state.

Parameters
dpoResult of the lookup
hicnb_flagsFlags that indicate whether the face is an application face or not
nat_addrIp v4 remote address of the face
sw_ifsoftware interface id of the face
node_indexvlib edge index to use in the packet processing

◆ hicn_iface_ip6_add_and_lock()

always_inline void hicn_iface_ip6_add_and_lock ( hicn_face_id_t *  index,
u8 *  hicnb_flags,
const ip6_address_t nat_addr,
u32  sw_if,
u32  adj_index,
u32  node_index 
)

Retrieve, or create if it doesn't exist, a face from the ip6 local address and returns its dpo. This method adds a lock on the face state.

Parameters
dpoResult of the lookup
hicnb_flagsFlags that indicate whether the face is an application face or not
nat_addrIp v6 remote address of the face
sw_ifsoftware interface id of the face
node_indexvlib edge index to use in the packet processing

Variable Documentation

◆ hicn_face_vec_hashtb

mhash_t hicn_face_vec_hashtb

Hash tables that indexes a face by remote address. For fast lookup when an interest arrives.

◆ hicn_vec_pool

hicn_face_vec_t* hicn_vec_pool

Pool containing the vector of possible incoming faces.