| 518 | } |
| 519 | |
| 520 | int |
| 521 | trie_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); |
nothing calls this directly
no test coverage detected