DPDK  19.11.14
Data Structures | Enumerations | Functions
rte_rib.h File Reference
#include <stdlib.h>
#include <stdint.h>
#include <rte_compat.h>

Go to the source code of this file.

Data Structures

struct  rte_rib_conf
 

Enumerations

enum  { RTE_RIB_GET_NXT_ALL, RTE_RIB_GET_NXT_COVER }
 

Functions

static uint32_t rte_rib_depth_to_mask (uint8_t depth)
 
__rte_experimental struct rte_rib_node * rte_rib_lookup (struct rte_rib *rib, uint32_t ip)
 
__rte_experimental struct rte_rib_node * rte_rib_lookup_parent (struct rte_rib_node *ent)
 
__rte_experimental struct rte_rib_node * rte_rib_lookup_exact (struct rte_rib *rib, uint32_t ip, uint8_t depth)
 
__rte_experimental struct rte_rib_node * rte_rib_get_nxt (struct rte_rib *rib, uint32_t ip, uint8_t depth, struct rte_rib_node *last, int flag)
 
__rte_experimental void rte_rib_remove (struct rte_rib *rib, uint32_t ip, uint8_t depth)
 
__rte_experimental struct rte_rib_node * rte_rib_insert (struct rte_rib *rib, uint32_t ip, uint8_t depth)
 
__rte_experimental int rte_rib_get_ip (struct rte_rib_node *node, uint32_t *ip)
 
__rte_experimental int rte_rib_get_depth (struct rte_rib_node *node, uint8_t *depth)
 
__rte_experimental void * rte_rib_get_ext (struct rte_rib_node *node)
 
__rte_experimental int rte_rib_get_nh (struct rte_rib_node *node, uint64_t *nh)
 
__rte_experimental int rte_rib_set_nh (struct rte_rib_node *node, uint64_t nh)
 
__rte_experimental struct rte_rib * rte_rib_create (const char *name, int socket_id, struct rte_rib_conf *conf)
 
__rte_experimental struct rte_rib * rte_rib_find_existing (const char *name)
 
__rte_experimental void rte_rib_free (struct rte_rib *rib)
 

Detailed Description

RTE RIB library.

Warning
EXPERIMENTAL: All functions in this file may be changed or removed without prior notice.

Level compressed tree implementation for IPv4 Longest Prefix Match

Definition in file rte_rib.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

rte_rib_get_nxt() flags

Enumerator
RTE_RIB_GET_NXT_ALL 

flag to get all subroutes in a RIB tree

RTE_RIB_GET_NXT_COVER 

flag to get first matched subroutes in a RIB tree

Definition at line 33 of file rte_rib.h.

Function Documentation

◆ rte_rib_depth_to_mask()

static uint32_t rte_rib_depth_to_mask ( uint8_t  depth)
inlinestatic

Get an IPv4 mask from prefix length It is caller responsibility to make sure depth is not bigger than 32

Parameters
depthprefix length
Returns
IPv4 mask

Definition at line 65 of file rte_rib.h.

◆ rte_rib_lookup()

__rte_experimental struct rte_rib_node* rte_rib_lookup ( struct rte_rib *  rib,
uint32_t  ip 
)

Lookup an IP into the RIB structure

Parameters
ribRIB object handle
ipIP to be looked up in the RIB
Returns
pointer to struct rte_rib_node on success NULL otherwise

◆ rte_rib_lookup_parent()

__rte_experimental struct rte_rib_node* rte_rib_lookup_parent ( struct rte_rib_node *  ent)

Lookup less specific route into the RIB structure

Parameters
entPointer to struct rte_rib_node that represents target route
Returns
pointer to struct rte_rib_node that represents less specific route on success NULL otherwise

◆ rte_rib_lookup_exact()

__rte_experimental struct rte_rib_node* rte_rib_lookup_exact ( struct rte_rib *  rib,
uint32_t  ip,
uint8_t  depth 
)

Lookup prefix into the RIB structure

Parameters
ribRIB object handle
ipnet to be looked up in the RIB
depthprefix length
Returns
pointer to struct rte_rib_node on success NULL otherwise

◆ rte_rib_get_nxt()

__rte_experimental struct rte_rib_node* rte_rib_get_nxt ( struct rte_rib *  rib,
uint32_t  ip,
uint8_t  depth,
struct rte_rib_node *  last,
int  flag 
)

Retrieve next more specific prefix from the RIB that is covered by ip/depth supernet in an ascending order

Parameters
ribRIB object handle
ipnet address of supernet prefix that covers returned more specific prefixes
depthsupernet prefix length
lastpointer to the last returned prefix to get next prefix or NULL to get first more specific prefix
flag-RTE_RIB_GET_NXT_ALL get all prefixes from subtrie -RTE_RIB_GET_NXT_COVER get only first more specific prefix even if it have more specifics
Returns
pointer to the next more specific prefix NULL if there is no prefixes left

◆ rte_rib_remove()

__rte_experimental void rte_rib_remove ( struct rte_rib *  rib,
uint32_t  ip,
uint8_t  depth 
)

Remove prefix from the RIB

Parameters
ribRIB object handle
ipnet to be removed from the RIB
depthprefix length

◆ rte_rib_insert()

__rte_experimental struct rte_rib_node* rte_rib_insert ( struct rte_rib *  rib,
uint32_t  ip,
uint8_t  depth 
)

Insert prefix into the RIB

Parameters
ribRIB object handle
ipnet to be inserted to the RIB
depthprefix length
Returns
pointer to new rte_rib_node on success NULL otherwise

◆ rte_rib_get_ip()

__rte_experimental int rte_rib_get_ip ( struct rte_rib_node *  node,
uint32_t *  ip 
)

Get an ip from rte_rib_node

Parameters
nodepointer to the rib node
ippointer to the ip to save
Returns
0 on success. -1 on failure with rte_errno indicating reason for failure.

◆ rte_rib_get_depth()

__rte_experimental int rte_rib_get_depth ( struct rte_rib_node *  node,
uint8_t *  depth 
)

Get a depth from rte_rib_node

Parameters
nodepointer to the rib node
depthpointer to the depth to save
Returns
0 on success. -1 on failure with rte_errno indicating reason for failure.

◆ rte_rib_get_ext()

__rte_experimental void* rte_rib_get_ext ( struct rte_rib_node *  node)

Get ext field from the rib node It is caller responsibility to make sure there are necessary space for the ext field inside rib node.

Parameters
nodepointer to the rib node
Returns
pointer to the ext

◆ rte_rib_get_nh()

__rte_experimental int rte_rib_get_nh ( struct rte_rib_node *  node,
uint64_t *  nh 
)

Get nexthop from the rib node

Parameters
nodepointer to the rib node
nhpointer to the nexthop to save
Returns
0 on success. -1 on failure with rte_errno indicating reason for failure.

◆ rte_rib_set_nh()

__rte_experimental int rte_rib_set_nh ( struct rte_rib_node *  node,
uint64_t  nh 
)

Set nexthop into the rib node

Parameters
nodepointer to the rib node
nhnexthop value to set to the rib node
Returns
0 on success. -1 on failure with rte_errno indicating reason for failure.

◆ rte_rib_create()

__rte_experimental struct rte_rib* rte_rib_create ( const char *  name,
int  socket_id,
struct rte_rib_conf conf 
)

Create RIB

Parameters
nameRIB name
socket_idNUMA socket ID for RIB table memory allocation
confStructure containing the configuration
Returns
Handle to RIB object on success NULL otherwise with rte_errno indicating reason for failure.

◆ rte_rib_find_existing()

__rte_experimental struct rte_rib* rte_rib_find_existing ( const char *  name)

Find an existing RIB object and return a pointer to it.

Parameters
nameName of the rib object as passed to rte_rib_create()
Returns
Pointer to RIB object on success NULL otherwise with rte_errno indicating reason for failure.

◆ rte_rib_free()

__rte_experimental void rte_rib_free ( struct rte_rib *  rib)

Free an RIB object.

Parameters
ribRIB object handle
Returns
None