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

Function nhgrp_get_addition_group

freebsd/net/route/nhgrp_ctl.c:643–680  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

641 * Returns 0 on success and stores result in @rnd_new.
642 */
643int
644nhgrp_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

Callers 1

add_route_mpathFunction · 0.85

Calls 3

nhop_try_ref_objectFunction · 0.85
get_nhgrpFunction · 0.85
append_nhopsFunction · 0.85

Tested by

no test coverage detected