MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_rib_get_nxt

Function rte_rib_get_nxt

dpdk/lib/rib/rte_rib.c:167–205  ·  view source on GitHub ↗

* Traverses on subtree and retrieves more specific routes * for a given in args ip/depth prefix * last = NULL means the first invocation */

Source from the content-addressed store, hash-verified

165 * last = NULL means the first invocation
166 */
167struct rte_rib_node *
168rte_rib_get_nxt(struct rte_rib *rib, uint32_t ip,
169 uint8_t depth, struct rte_rib_node *last, int flag)
170{
171 struct rte_rib_node *tmp, *prev = NULL;
172
173 if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
174 rte_errno = EINVAL;
175 return NULL;
176 }
177
178 if (last == NULL) {
179 tmp = rib->tree;
180 while ((tmp) && (tmp->depth < depth))
181 tmp = get_nxt_node(tmp, ip);
182 } else {
183 tmp = last;
184 while ((tmp->parent != NULL) && (is_right_node(tmp) ||
185 (tmp->parent->right == NULL))) {
186 tmp = tmp->parent;
187 if (is_valid_node(tmp) &&
188 (is_covered(tmp->ip, ip, depth) &&
189 (tmp->depth > depth)))
190 return tmp;
191 }
192 tmp = (tmp->parent) ? tmp->parent->right : NULL;
193 }
194 while (tmp) {
195 if (is_valid_node(tmp) &&
196 (is_covered(tmp->ip, ip, depth) &&
197 (tmp->depth > depth))) {
198 prev = tmp;
199 if (flag == RTE_RIB_GET_NXT_COVER)
200 return prev;
201 }
202 tmp = (tmp->left) ? tmp->left : tmp->right;
203 }
204 return prev;
205}
206
207void
208rte_rib_remove(struct rte_rib *rib, uint32_t ip, uint8_t depth)

Callers 4

modify_fibFunction · 0.85
dir24_8_modifyFunction · 0.85
rte_rib_freeFunction · 0.85
test_tree_traversalFunction · 0.85

Calls 4

get_nxt_nodeFunction · 0.70
is_right_nodeFunction · 0.70
is_valid_nodeFunction · 0.70
is_coveredFunction · 0.70

Tested by 1

test_tree_traversalFunction · 0.68