* Creates new multipath group based on existing group/nhop in @rnd_orig and * to-be-added nhop @wn_add. * Returns 0 on success and stores result in @rnd_new. */
| 641 | * Returns 0 on success and stores result in @rnd_new. |
| 642 | */ |
| 643 | int |
| 644 | nhgrp_get_addition_group(struct rib_head *rh, struct route_nhop_data *rnd_orig, |
| 645 | struct route_nhop_data *rnd_add, struct route_nhop_data *rnd_new) |
| 646 | { |
| 647 | struct nh_control *ctl = rh->nh_control; |
| 648 | struct nhgrp_priv *nhg_priv; |
| 649 | struct weightened_nhop wn[2] = {}; |
| 650 | int error; |
| 651 | |
| 652 | if (rnd_orig->rnd_nhop == NULL) { |
| 653 | /* No paths to add to, just reference current nhop */ |
| 654 | *rnd_new = *rnd_add; |
| 655 | if (nhop_try_ref_object(rnd_new->rnd_nhop) == 0) |
| 656 | return (EAGAIN); |
| 657 | return (0); |
| 658 | } |
| 659 | |
| 660 | wn[0].nh = rnd_add->rnd_nhop; |
| 661 | wn[0].weight = rnd_add->rnd_weight; |
| 662 | |
| 663 | if (!NH_IS_NHGRP(rnd_orig->rnd_nhop)) { |
| 664 | /* Simple merge of 2 non-multipath nexthops */ |
| 665 | wn[1].nh = rnd_orig->rnd_nhop; |
| 666 | wn[1].weight = rnd_orig->rnd_weight; |
| 667 | nhg_priv = get_nhgrp(ctl, wn, 2, &error); |
| 668 | } else { |
| 669 | /* Get new nhop group with @rt->rt_nhop as an additional nhop */ |
| 670 | nhg_priv = append_nhops(ctl, rnd_orig->rnd_nhgrp, &wn[0], 1, |
| 671 | &error); |
| 672 | } |
| 673 | |
| 674 | if (nhg_priv == NULL) |
| 675 | return (error); |
| 676 | rnd_new->rnd_nhgrp = nhg_priv->nhg; |
| 677 | rnd_new->rnd_weight = 0; |
| 678 | |
| 679 | return (0); |
| 680 | } |
| 681 | |
| 682 | /* |
| 683 | * Returns pointer to array of nexthops with weights for |
no test coverage detected