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

Function dir24_8_modify

dpdk/lib/fib/dir24_8.c:411–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411int
412dir24_8_modify(struct rte_fib *fib, uint32_t ip, uint8_t depth,
413 uint64_t next_hop, int op)
414{
415 struct dir24_8_tbl *dp;
416 struct rte_rib *rib;
417 struct rte_rib_node *tmp = NULL;
418 struct rte_rib_node *node;
419 struct rte_rib_node *parent;
420 int ret = 0;
421 uint64_t par_nh, node_nh;
422
423 if ((fib == NULL) || (depth > RTE_FIB_MAXDEPTH))
424 return -EINVAL;
425
426 dp = rte_fib_get_dp(fib);
427 rib = rte_fib_get_rib(fib);
428 RTE_ASSERT((dp != NULL) && (rib != NULL));
429
430 if (next_hop > get_max_nh(dp->nh_sz))
431 return -EINVAL;
432
433 ip &= rte_rib_depth_to_mask(depth);
434
435 node = rte_rib_lookup_exact(rib, ip, depth);
436 switch (op) {
437 case RTE_FIB_ADD:
438 if (node != NULL) {
439 rte_rib_get_nh(node, &node_nh);
440 if (node_nh == next_hop)
441 return 0;
442 ret = modify_fib(dp, rib, ip, depth, next_hop);
443 if (ret == 0)
444 rte_rib_set_nh(node, next_hop);
445 return 0;
446 }
447 if (depth > 24) {
448 tmp = rte_rib_get_nxt(rib, ip, 24, NULL,
449 RTE_RIB_GET_NXT_COVER);
450 if ((tmp == NULL) &&
451 (dp->rsvd_tbl8s >= dp->number_tbl8s))
452 return -ENOSPC;
453
454 }
455 node = rte_rib_insert(rib, ip, depth);
456 if (node == NULL)
457 return -rte_errno;
458 rte_rib_set_nh(node, next_hop);
459 parent = rte_rib_lookup_parent(node);
460 if (parent != NULL) {
461 rte_rib_get_nh(parent, &par_nh);
462 if (par_nh == next_hop)
463 return 0;
464 }
465 ret = modify_fib(dp, rib, ip, depth, next_hop);
466 if (ret != 0) {
467 rte_rib_remove(rib, ip, depth);
468 return ret;

Callers

nothing calls this directly

Calls 12

rte_fib_get_dpFunction · 0.85
rte_fib_get_ribFunction · 0.85
rte_rib_depth_to_maskFunction · 0.85
rte_rib_lookup_exactFunction · 0.85
rte_rib_get_nhFunction · 0.85
modify_fibFunction · 0.85
rte_rib_set_nhFunction · 0.85
rte_rib_get_nxtFunction · 0.85
rte_rib_insertFunction · 0.85
rte_rib_lookup_parentFunction · 0.85
rte_rib_removeFunction · 0.85
get_max_nhFunction · 0.70

Tested by

no test coverage detected