Lines Matching defs:nh
55 get_rtm_type(const struct nhop_object *nh)
57 int nh_flags = nh->nh_flags;
68 nl_get_rtm_protocol(const struct nhop_object *nh)
71 if (NH_IS_NHGRP(nh)) {
72 const struct nhgrp_object *nhg = (const struct nhgrp_object *)nh;
76 nh = nhg->nhops[0];
79 uint8_t origin = nhop_get_origin(nh);
83 int rt_flags = nhop_get_rtflags(nh);
124 dump_rc_nhop_gw(struct nl_writer *nw, const struct nhop_object *nh)
130 switch (nhop_get_neigh_family(nh)) {
135 nlattr_add(nw, NL_RTA_GATEWAY, 4, &nh->gw4_sa.sin_addr);
139 upper_family = nhop_get_upper_family(nh);
141 struct in6_addr gw6 = nh->gw6_sa.sin6_addr;
147 struct in6_addr gw6 = nh->gw6_sa.sin6_addr;
162 dump_rc_nhop_mtu(struct nl_writer *nw, const struct nhop_object *nh)
174 *((uint32_t *)(nla + 1)) = nh->nh_mtu;
184 uint32_t base_rtflags = nhop_get_rtflags(wn[0].nh);
201 rtnh->rtnh_ifindex = if_getindex(wn[i].nh->nh_ifp);
203 dump_rc_nhop_gw(nw, wn[i].nh);
204 uint32_t rtflags = nhop_get_rtflags(wn[i].nh);
208 dump_rc_nhop_mtu(nw, wn[i].nh);
229 const struct nhop_object *nh = rnd->rnd_nhop;
230 uint32_t rtflags = nhop_get_rtflags(nh);
240 if (nh->nh_flags & NHF_GATEWAY)
241 dump_rc_nhop_gw(nw, nh);
243 uint32_t uidx = nhop_get_uidx(nh);
246 nlattr_add_u32(nw, NL_RTA_KNH_ID, nhop_get_idx(nh));
250 dump_rc_nhop_mtu(nw, nh);
251 uint32_t nh_expire = nhop_get_expire(nh);
256 nlattr_add_u32(nw, NL_RTA_OIF, if_getindex(nh->nh_ifp));
700 finalize_nhop(struct nhop_object *nh, const struct sockaddr *dst, int *perror)
706 if (nh->gw_sa.sa_family == 0) {
710 if (nh->nh_ifp != NULL)
711 nhop_set_direct_gw(nh, nh->nh_ifp);
720 if (nh->nh_ifp == NULL) {
721 uint32_t fibnum = nhop_get_fibnum(nh);
724 if (nh->nh_flags & NHF_GATEWAY)
726 else if (nh->nh_flags & NHF_HOST)
729 struct ifaddr *ifa = ifa_ifwithroute(flags, dst, &nh->gw_sa, fibnum);
735 nhop_set_transmit_ifp(nh, ifa->ifa_ifp);
739 if (nh->nh_ifa == NULL) {
740 const struct sockaddr *gw_sa = &nh->gw_sa;
752 struct ifaddr *ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp);
755 gw_sa = &nh->gw_sa;
756 ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp);
763 nhop_set_src(nh, ifa);
766 return (nhop_get_nhop(nh, perror));
814 struct nhop_object *nh = nhop_alloc(attrs->rta_table, attrs->rtm_family);
815 if (nh == NULL)
818 error = nl_set_nexthop_gw(nh, mpnh->gw, mpnh->ifp, npt);
820 nhop_free(nh);
824 nhop_set_transmit_ifp(nh, mpnh->ifp);
825 nhop_set_pxtype_flag(nh, get_pxflag(attrs));
826 nhop_set_rtflags(nh, attrs->rta_rtflags);
828 nhop_set_origin(nh, attrs->rtm_protocol);
830 *pnh = finalize_nhop(nh, attrs->rta_dst, &error);
840 struct nhop_object *nh = NULL;
852 error = create_nexthop_one(attrs, mpnh, npt, &wn[i].nh);
855 nhop_free(wn[j].nh);
861 struct rib_head *rh = nhop_get_rh(wn[0].nh);
872 nhop_free(wn[i].nh);
882 nh = nhop_alloc(attrs->rta_table, attrs->rtm_family);
883 if (nh == NULL) {
888 *perror = nl_set_nexthop_gw(nh, attrs->rta_gw, attrs->rta_oif, npt);
890 nhop_free(nh);
895 nhop_set_transmit_ifp(nh, attrs->rta_oif);
897 nhop_set_mtu(nh, attrs->rtax_mtu, true);
899 nhop_set_broadcast(nh, true);
901 nhop_set_origin(nh, attrs->rtm_protocol);
902 nhop_set_pxtype_flag(nh, get_pxflag(attrs));
903 nhop_set_rtflags(nh, attrs->rta_rtflags);
909 nhop_set_blackhole(nh, RTF_BLACKHOLE);
913 nhop_set_blackhole(nh, RTF_REJECT);
918 nh = finalize_nhop(nh, attrs->rta_dst, perror);
921 return (nh);
929 struct nhop_object *nh = NULL;
954 nh = nl_find_nhop(attrs.rta_table, attrs.rtm_family, attrs.rta_nh_id,
959 nh = create_nexthop_from_attrs(&attrs, npt, &error);
966 if (!NH_IS_NHGRP(nh) && attrs.rta_weight == 0)
968 struct route_nhop_data rnd = { .rnd_nhop = nh, .rnd_weight = attrs.rta_weight };
979 path_match_func(const struct rtentry *rt, const struct nhop_object *nh, void *_data)
983 if ((attrs->rta_gw != NULL) && !rib_match_gw(rt, nh, attrs->rta_gw))
986 if ((attrs->rta_oif != NULL) && (attrs->rta_oif != nh->nh_ifp))