src/dpdk/lib/librte_rib/rte_rib.c
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)
{
	struct rte_rib_node *tmp, *prev = NULL;

	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
		rte_errno = EINVAL;
		return NULL;
	}

	if (last == NULL) {
		tmp = rib->tree;
		while ((tmp) && (tmp->depth < depth))
			tmp = get_nxt_node(tmp, ip);
	} else {
		tmp = last;
		while ((tmp->parent != NULL) && (is_right_node(tmp) ||
				(tmp->parent->right == NULL))) {
			tmp = tmp->parent;
			if (is_valid_node(tmp) &&
					(is_covered(tmp->ip, ip, depth) &&
					(tmp->depth > depth)))
				return tmp;
		}
		tmp = (tmp->parent) ? tmp->parent->right : NULL;
	}
	while (tmp) {
		if (is_valid_node(tmp) &&
				(is_covered(tmp->ip, ip, depth) &&
				(tmp->depth > depth))) {
			prev = tmp;
			if (flag == RTE_RIB_GET_NXT_COVER)
				return prev;
		}
		tmp = (tmp->left) ? tmp->left : tmp->right;
	}
	return prev;
}
/*
 *  Traverses on subtree and retrieves more specific routes
 *  for a given in args ip/depth prefix
 *  last = NULL means the first invocation
 */
Traverses on subtree and retrieves more specific routes
for a given in args ip/depth prefix
last = NULL means the first invocation
Traverses on subtree and retrieves more specific routes for a given in args ip / depth prefix last = NULL means the first invocation
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)
{
	struct rte_rib_node *tmp, *prev = NULL;
	if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
		rte_errno = EINVAL;
		return NULL;
	}
	if (last == NULL) {
		tmp = rib->tree;
		while ((tmp) && (tmp->depth < depth))
			tmp = get_nxt_node(tmp, ip);
	} else {
		tmp = last;
		while ((tmp->parent != NULL) && (is_right_node(tmp) ||
				(tmp->parent->right == NULL))) {
			tmp = tmp->parent;
			if (is_valid_node(tmp) &&
					(is_covered(tmp->ip, ip, depth) &&
					(tmp->depth > depth)))
				return tmp;
		}
		tmp = (tmp->parent) ? tmp->parent->right : NULL;
	}
	while (tmp) {
		if (is_valid_node(tmp) &&
				(is_covered(tmp->ip, ip, depth) &&
				(tmp->depth > depth))) {
			prev = tmp;
			if (flag == RTE_RIB_GET_NXT_COVER)
				return prev;
		}
		tmp = (tmp->left) ? tmp->left : tmp->right;
	}
	return prev;
}
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 ) { struct rte_rib_node * tmp , * prev = NULL ; if ( ( rib == NULL ) || ( depth > RIB_MAXDEPTH ) ) { rte_errno = EINVAL ; return NULL ; } if ( last == NULL ) { tmp = rib -> tree ; while ( ( tmp ) && ( tmp -> depth < depth ) ) tmp = get_nxt_node ( tmp , ip ) ; } else { tmp = last ; while ( ( tmp -> parent != NULL ) && ( is_right_node ( tmp ) || ( tmp -> parent -> right == NULL ) ) ) { tmp = tmp -> parent ; if ( is_valid_node ( tmp ) && ( is_covered ( tmp -> ip , ip , depth ) && ( tmp -> depth > depth ) ) ) return tmp ; } tmp = ( tmp -> parent ) ? tmp -> parent -> right : NULL ; } while ( tmp ) { if ( is_valid_node ( tmp ) && ( is_covered ( tmp -> ip , ip , depth ) && ( tmp -> depth > depth ) ) ) { prev = tmp ; if ( flag == RTE_RIB_GET_NXT_COVER ) return prev ; } tmp = ( tmp -> left ) ? tmp -> left : tmp -> right ; } return prev ; }
Traverses on subtree and retrieves more specific routes
  for a given in args ip/depth prefix
  last = NULL means the first invocation
Traverses on subtree and retrieves more specific routes for a given in args ip / depth prefix last = NULL means the first invocation