Lines Matching full:nh

55 get_rtm_type(const struct nhop_object *nh)  in get_rtm_type()  argument
57 int nh_flags = nh->nh_flags; in get_rtm_type()
68 nl_get_rtm_protocol(const struct nhop_object *nh) in nl_get_rtm_protocol() argument
71 if (NH_IS_NHGRP(nh)) { in nl_get_rtm_protocol()
72 const struct nhgrp_object *nhg = (const struct nhgrp_object *)nh; in nl_get_rtm_protocol()
76 nh = nhg->nhops[0]; in nl_get_rtm_protocol()
79 uint8_t origin = nhop_get_origin(nh); in nl_get_rtm_protocol()
83 int rt_flags = nhop_get_rtflags(nh); in nl_get_rtm_protocol()
124 dump_rc_nhop_gw(struct nl_writer *nw, const struct nhop_object *nh) in dump_rc_nhop_gw() argument
130 switch (nhop_get_neigh_family(nh)) { in dump_rc_nhop_gw()
135 nlattr_add(nw, NL_RTA_GATEWAY, 4, &nh->gw4_sa.sin_addr); in dump_rc_nhop_gw()
139 upper_family = nhop_get_upper_family(nh); in dump_rc_nhop_gw()
141 struct in6_addr gw6 = nh->gw6_sa.sin6_addr; in dump_rc_nhop_gw()
147 struct in6_addr gw6 = nh->gw6_sa.sin6_addr; in dump_rc_nhop_gw()
162 dump_rc_nhop_mtu(struct nl_writer *nw, const struct nhop_object *nh) in dump_rc_nhop_mtu() argument
174 *((uint32_t *)(nla + 1)) = nh->nh_mtu; in dump_rc_nhop_mtu()
184 uint32_t base_rtflags = nhop_get_rtflags(wn[0].nh); in dump_rc_nhg()
201 rtnh->rtnh_ifindex = if_getindex(wn[i].nh->nh_ifp); in dump_rc_nhg()
203 dump_rc_nhop_gw(nw, wn[i].nh); in dump_rc_nhg()
204 uint32_t rtflags = nhop_get_rtflags(wn[i].nh); in dump_rc_nhg()
208 dump_rc_nhop_mtu(nw, wn[i].nh); in dump_rc_nhg()
229 const struct nhop_object *nh = rnd->rnd_nhop; in dump_rc_nhop() local
230 uint32_t rtflags = nhop_get_rtflags(nh); in dump_rc_nhop()
240 if (nh->nh_flags & NHF_GATEWAY) in dump_rc_nhop()
241 dump_rc_nhop_gw(nw, nh); in dump_rc_nhop()
243 uint32_t uidx = nhop_get_uidx(nh); in dump_rc_nhop()
246 nlattr_add_u32(nw, NL_RTA_KNH_ID, nhop_get_idx(nh)); in dump_rc_nhop()
250 dump_rc_nhop_mtu(nw, nh); in dump_rc_nhop()
251 uint32_t nh_expire = nhop_get_expire(nh); in dump_rc_nhop()
256 nlattr_add_u32(nw, NL_RTA_OIF, if_getindex(nh->nh_ifp)); in dump_rc_nhop()
712 finalize_nhop(struct nhop_object *nh, const struct sockaddr *dst, int *perror) in finalize_nhop() argument
718 if (nh->gw_sa.sa_family == 0) { in finalize_nhop()
722 if (nh->nh_ifp != NULL) in finalize_nhop()
723 nhop_set_direct_gw(nh, nh->nh_ifp); in finalize_nhop()
732 if (nh->nh_ifp == NULL) { in finalize_nhop()
733 uint32_t fibnum = nhop_get_fibnum(nh); in finalize_nhop()
736 if (nh->nh_flags & NHF_GATEWAY) in finalize_nhop()
738 else if (nh->nh_flags & NHF_HOST) in finalize_nhop()
741 struct ifaddr *ifa = ifa_ifwithroute(flags, dst, &nh->gw_sa, fibnum); in finalize_nhop()
747 nhop_set_transmit_ifp(nh, ifa->ifa_ifp); in finalize_nhop()
751 if (nh->nh_ifa == NULL) { in finalize_nhop()
752 const struct sockaddr *gw_sa = &nh->gw_sa; in finalize_nhop()
764 struct ifaddr *ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp); in finalize_nhop()
767 gw_sa = &nh->gw_sa; in finalize_nhop()
768 ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp); in finalize_nhop()
775 nhop_set_src(nh, ifa); in finalize_nhop()
778 return (nhop_get_nhop(nh, perror)); in finalize_nhop()
826 struct nhop_object *nh = nhop_alloc(attrs->rta_table, attrs->rtm_family); in create_nexthop_one() local
827 if (nh == NULL) in create_nexthop_one()
830 error = nl_set_nexthop_gw(nh, mpnh->gw, mpnh->ifp, npt); in create_nexthop_one()
832 nhop_free(nh); in create_nexthop_one()
836 nhop_set_transmit_ifp(nh, mpnh->ifp); in create_nexthop_one()
837 nhop_set_pxtype_flag(nh, get_pxflag(attrs)); in create_nexthop_one()
838 nhop_set_rtflags(nh, attrs->rta_rtflags); in create_nexthop_one()
840 nhop_set_origin(nh, attrs->rtm_protocol); in create_nexthop_one()
842 *pnh = finalize_nhop(nh, attrs->rta_dst, &error); in create_nexthop_one()
852 struct nhop_object *nh = NULL; in create_nexthop_from_attrs() local
864 error = create_nexthop_one(attrs, mpnh, npt, &wn[i].nh); in create_nexthop_from_attrs()
867 nhop_free(wn[j].nh); in create_nexthop_from_attrs()
873 struct rib_head *rh = nhop_get_rh(wn[0].nh); in create_nexthop_from_attrs()
884 nhop_free(wn[i].nh); in create_nexthop_from_attrs()
894 nh = nhop_alloc(attrs->rta_table, attrs->rtm_family); in create_nexthop_from_attrs()
895 if (nh == NULL) { in create_nexthop_from_attrs()
900 *perror = nl_set_nexthop_gw(nh, attrs->rta_gw, attrs->rta_oif, npt); in create_nexthop_from_attrs()
902 nhop_free(nh); in create_nexthop_from_attrs()
907 nhop_set_transmit_ifp(nh, attrs->rta_oif); in create_nexthop_from_attrs()
909 nhop_set_mtu(nh, attrs->rtax_mtu, true); in create_nexthop_from_attrs()
911 nhop_set_broadcast(nh, true); in create_nexthop_from_attrs()
913 nhop_set_origin(nh, attrs->rtm_protocol); in create_nexthop_from_attrs()
914 nhop_set_pxtype_flag(nh, get_pxflag(attrs)); in create_nexthop_from_attrs()
915 nhop_set_rtflags(nh, attrs->rta_rtflags); in create_nexthop_from_attrs()
921 nhop_set_blackhole(nh, RTF_BLACKHOLE); in create_nexthop_from_attrs()
925 nhop_set_blackhole(nh, RTF_REJECT); in create_nexthop_from_attrs()
930 nh = finalize_nhop(nh, attrs->rta_dst, perror); in create_nexthop_from_attrs()
933 return (nh); in create_nexthop_from_attrs()
941 struct nhop_object *nh = NULL; in rtnl_handle_newroute() local
966 nh = nl_find_nhop(attrs.rta_table, attrs.rtm_family, attrs.rta_nh_id, in rtnl_handle_newroute()
971 nh = create_nexthop_from_attrs(&attrs, npt, &error); in rtnl_handle_newroute()
978 if (!NH_IS_NHGRP(nh) && attrs.rta_weight == 0) in rtnl_handle_newroute()
980 struct route_nhop_data rnd = { .rnd_nhop = nh, .rnd_weight = attrs.rta_weight }; in rtnl_handle_newroute()
991 path_match_func(const struct rtentry *rt, const struct nhop_object *nh, void *_data) in path_match_func() argument
995 if ((attrs->rta_gw != NULL) && !rib_match_gw(rt, nh, attrs->rta_gw)) in path_match_func()
998 if ((attrs->rta_oif != NULL) && (attrs->rta_oif != nh->nh_ifp)) in path_match_func()