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

Function trie_modify

dpdk/lib/fib/trie.c:520–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520int
521trie_modify(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
522 uint8_t depth, uint64_t next_hop, int op)
523{
524 struct rte_trie_tbl *dp;
525 struct rte_rib6 *rib;
526 struct rte_rib6_node *tmp = NULL;
527 struct rte_rib6_node *node;
528 struct rte_rib6_node *parent;
529 uint8_t ip_masked[RTE_FIB6_IPV6_ADDR_SIZE];
530 int i, ret = 0;
531 uint64_t par_nh, node_nh;
532 uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
533
534 if ((fib == NULL) || (ip == NULL) || (depth > RTE_FIB6_MAXDEPTH))
535 return -EINVAL;
536
537 dp = rte_fib6_get_dp(fib);
538 RTE_ASSERT(dp);
539 rib = rte_fib6_get_rib(fib);
540 RTE_ASSERT(rib);
541
542 for (i = 0; i < RTE_FIB6_IPV6_ADDR_SIZE; i++)
543 ip_masked[i] = ip[i] & get_msk_part(depth, i);
544
545 if (depth > 24) {
546 tmp = rte_rib6_get_nxt(rib, ip_masked,
547 RTE_ALIGN_FLOOR(depth, 8), NULL,
548 RTE_RIB6_GET_NXT_COVER);
549 if (tmp == NULL) {
550 tmp = rte_rib6_lookup(rib, ip);
551 if (tmp != NULL) {
552 rte_rib6_get_depth(tmp, &tmp_depth);
553 parent_depth = RTE_MAX(tmp_depth, 24);
554 }
555 depth_diff = RTE_ALIGN_CEIL(depth, 8) -
556 RTE_ALIGN_CEIL(parent_depth, 8);
557 depth_diff = depth_diff >> 3;
558 }
559 }
560 node = rte_rib6_lookup_exact(rib, ip_masked, depth);
561 switch (op) {
562 case RTE_FIB6_ADD:
563 if (node != NULL) {
564 rte_rib6_get_nh(node, &node_nh);
565 if (node_nh == next_hop)
566 return 0;
567 ret = modify_dp(dp, rib, ip_masked, depth, next_hop);
568 if (ret == 0)
569 rte_rib6_set_nh(node, next_hop);
570 return 0;
571 }
572
573 if ((depth > 24) && (dp->rsvd_tbl8s >=
574 dp->number_tbl8s - depth_diff))
575 return -ENOSPC;
576
577 node = rte_rib6_insert(rib, ip_masked, depth);

Callers

nothing calls this directly

Calls 13

rte_fib6_get_dpFunction · 0.85
rte_fib6_get_ribFunction · 0.85
get_msk_partFunction · 0.85
rte_rib6_get_nxtFunction · 0.85
rte_rib6_lookupFunction · 0.85
rte_rib6_get_depthFunction · 0.85
rte_rib6_lookup_exactFunction · 0.85
rte_rib6_get_nhFunction · 0.85
modify_dpFunction · 0.85
rte_rib6_set_nhFunction · 0.85
rte_rib6_insertFunction · 0.85
rte_rib6_lookup_parentFunction · 0.85

Tested by

no test coverage detected