---
name: "rte_rib_get_nxt"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_rib.h"
---

# rte\_rib\_get\_nxt(3)

Part of [rte\_rib.h(3)](/rte_rib.h/3.md).

## NAME

rte\_rib.h

## SYNOPSIS

`#include <stdlib.h>`\
 `#include <stdint.h>`\

### 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)\
 struct rte\_rib\_node \* **rte\_rib\_lookup** (struct rte\_rib \*rib, uint32\_t ip)\
 struct rte\_rib\_node \* **rte\_rib\_lookup\_parent** (struct rte\_rib\_node \*ent)\
 struct rte\_rib\_node \* **rte\_rib\_lookup\_exact** (struct rte\_rib \*rib, uint32\_t ip, uint8\_t depth)\
 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)\
 void **rte\_rib\_remove** (struct rte\_rib \*rib, uint32\_t ip, uint8\_t depth)\
 struct rte\_rib\_node \* **rte\_rib\_insert** (struct rte\_rib \*rib, uint32\_t ip, uint8\_t depth)\
 int **rte\_rib\_get\_ip** (const struct rte\_rib\_node \*node, uint32\_t \*ip)\
 int **rte\_rib\_get\_depth** (const struct rte\_rib\_node \*node, uint8\_t \*depth)\
 void \* **rte\_rib\_get\_ext** (struct rte\_rib\_node \*node)\
 int **rte\_rib\_get\_nh** (const struct rte\_rib\_node \*node, uint64\_t \*nh)\
 int **rte\_rib\_set\_nh** (struct rte\_rib\_node \*node, uint64\_t nh)\
 struct rte\_rib \* **rte\_rib\_create** (const char \*name, int socket\_id, const struct **rte\_rib\_conf** \*conf)\
 struct rte\_rib \* **rte\_rib\_find\_existing** (const char \*name)\
 void **rte\_rib\_free** (struct rte\_rib \*rib)\

## Detailed Description

RTE RIB library.

Level compressed tree implementation for IPv4 Longest Prefix Match

Definition in file **rte\_rib.h**.

## Enumeration Type Documentation

### 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* **28** *of file* **rte\_rib.h***.*

## Function Documentation

### static uint32\_t rte\_rib\_depth\_to\_mask (uint8\_t depth)` [inline]`, ` [static]`

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

**Parameters**

*depth prefix length*

**Returns**

*IPv4 mask*

*Definition at line* **60** *of file* **rte\_rib.h***.*

### struct rte\_rib\_node \* rte\_rib\_lookup (struct rte\_rib \* rib, uint32\_t ip)

*Lookup an IP into the RIB structure*

**Parameters**

*rib RIB object handle* \
 *ip IP to be looked up in the RIB*

**Returns**

*pointer to struct rte\_rib\_node on success NULL otherwise*

### struct rte\_rib\_node \* rte\_rib\_lookup\_parent (struct rte\_rib\_node \* ent)

*Lookup less specific route into the RIB structure*

**Parameters**

*ent Pointer 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*

### 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**

*rib RIB object handle* \
 *ip net to be looked up in the RIB* \
 *depth prefix length*

**Returns**

*pointer to struct rte\_rib\_node on success NULL otherwise*

### 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**

*rib RIB object handle* \
 *ip net address of supernet prefix that covers returned more specific prefixes* \
 *depth supernet prefix length* \
 *last pointer 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*

### void rte\_rib\_remove (struct rte\_rib \* rib, uint32\_t ip, uint8\_t depth)

*Remove prefix from the RIB*

**Parameters**

*rib RIB object handle* \
 *ip net to be removed from the RIB* \
 *depth prefix length*

### struct rte\_rib\_node \* rte\_rib\_insert (struct rte\_rib \* rib, uint32\_t ip, uint8\_t depth)

*Insert prefix into the RIB*

**Parameters**

*rib RIB object handle* \
 *ip net to be inserted to the RIB* \
 *depth prefix length*

**Returns**

*pointer to new rte\_rib\_node on success NULL otherwise*

### int rte\_rib\_get\_ip (const struct rte\_rib\_node \* node, uint32\_t \* ip)

*Get an ip from rte\_rib\_node*

**Parameters**

*node pointer to the rib node* \
 *ip pointer to the ip to save*

**Returns**

*0 on success. -1 on failure with rte\_errno indicating reason for failure.*

### int rte\_rib\_get\_depth (const struct rte\_rib\_node \* node, uint8\_t \* depth)

*Get a depth from rte\_rib\_node*

**Parameters**

*node pointer to the rib node* \
 *depth pointer to the depth to save*

**Returns**

*0 on success. -1 on failure with rte\_errno indicating reason for failure.*

### 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**

*node pointer to the rib node*

**Returns**

*pointer to the ext*

### int rte\_rib\_get\_nh (const struct rte\_rib\_node \* node, uint64\_t \* nh)

*Get nexthop from the rib node*

**Parameters**

*node pointer to the rib node* \
 *nh pointer to the nexthop to save*

**Returns**

*0 on success. -1 on failure with rte\_errno indicating reason for failure.*

### int rte\_rib\_set\_nh (struct rte\_rib\_node \* node, uint64\_t nh)

*Set nexthop into the rib node*

**Parameters**

*node pointer to the rib node* \
 *nh nexthop value to set to the rib node*

**Returns**

*0 on success. -1 on failure with rte\_errno indicating reason for failure.*

### struct rte\_rib \* rte\_rib\_create (const char \* name, int socket\_id, const struct rte\_rib\_conf \* conf)

*Create RIB*

**Parameters**

*name RIB name* \
 *socket\_id NUMA socket ID for RIB table memory allocation* \
 *conf Structure containing the configuration*

**Returns**

*Handle to RIB object on success NULL otherwise with rte\_errno indicating reason for failure.*

### struct rte\_rib \* rte\_rib\_find\_existing (const char \* name)

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

**Parameters**

*name Name 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.*

### void rte\_rib\_free (struct rte\_rib \* rib)

*Free an RIB object.*

**Parameters**

*rib RIB object handle created with* **rte\_rib\_create()***. If rib is NULL, no operation is performed.*

## Author

*Generated automatically by Doxygen for DPDK from the source code.*
