Lines Matching refs:nh

95 static u8 *__mpls_nh_via(struct mpls_route *rt, struct mpls_nh *nh)  in __mpls_nh_via()  argument
97 return (u8 *)nh + rt->rt_via_offset; in __mpls_nh_via()
101 const struct mpls_nh *nh) in mpls_nh_via() argument
103 return __mpls_nh_via((struct mpls_route *)rt, (struct mpls_nh *)nh); in mpls_nh_via()
106 static unsigned int mpls_nh_header_size(const struct mpls_nh *nh) in mpls_nh_header_size() argument
109 return nh->nh_labels * sizeof(struct mpls_shim_hdr); in mpls_nh_header_size()
256 unsigned int nh_flags = READ_ONCE(nh->nh_flags); in mpls_select_multipath()
261 return nh; in mpls_select_multipath()
347 struct mpls_nh *nh; in mpls_forward() local
392 nh = mpls_select_multipath(rt, skb); in mpls_forward()
393 if (!nh) in mpls_forward()
412 out_dev = nh->nh_dev; in mpls_forward()
417 new_header_size = mpls_nh_header_size(nh); in mpls_forward()
446 for (i = nh->nh_labels - 1; i >= 0; i--) { in mpls_forward()
447 hdr[i] = mpls_entry_encode(nh->nh_label[i], in mpls_forward()
456 if (nh->nh_via_table == MPLS_NEIGH_TABLE_UNSPEC) in mpls_forward()
460 err = neigh_xmit(nh->nh_via_table, out_dev, in mpls_forward()
461 mpls_nh_via(rt, nh), skb); in mpls_forward()
648 struct mpls_nh *nh, int oif) in find_outdev() argument
653 switch (nh->nh_via_table) { in find_outdev()
655 dev = inet_fib_lookup_dev(net, mpls_nh_via(rt, nh)); in find_outdev()
658 dev = inet6_fib_lookup_dev(net, mpls_nh_via(rt, nh)); in find_outdev()
680 struct mpls_nh *nh, int oif) in mpls_nh_assign_dev() argument
685 dev = find_outdev(net, rt, nh, oif); in mpls_nh_assign_dev()
697 if ((nh->nh_via_table == NEIGH_LINK_TABLE) && in mpls_nh_assign_dev()
698 (dev->addr_len != nh->nh_via_alen)) in mpls_nh_assign_dev()
701 nh->nh_dev = dev; in mpls_nh_assign_dev()
704 nh->nh_flags |= RTNH_F_DEAD; in mpls_nh_assign_dev()
710 nh->nh_flags |= RTNH_F_LINKDOWN; in mpls_nh_assign_dev()
771 struct mpls_nh *nh = rt->rt_nh; in mpls_nh_build_from_cfg() local
775 if (!nh) in mpls_nh_build_from_cfg()
778 nh->nh_labels = cfg->rc_output_labels; in mpls_nh_build_from_cfg()
779 for (i = 0; i < nh->nh_labels; i++) in mpls_nh_build_from_cfg()
780 nh->nh_label[i] = cfg->rc_output_label[i]; in mpls_nh_build_from_cfg()
782 nh->nh_via_table = cfg->rc_via_table; in mpls_nh_build_from_cfg()
783 memcpy(__mpls_nh_via(rt, nh), cfg->rc_via, cfg->rc_via_alen); in mpls_nh_build_from_cfg()
784 nh->nh_via_alen = cfg->rc_via_alen; in mpls_nh_build_from_cfg()
786 err = mpls_nh_assign_dev(net, rt, nh, cfg->rc_ifindex); in mpls_nh_build_from_cfg()
790 if (nh->nh_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN)) in mpls_nh_build_from_cfg()
800 struct mpls_nh *nh, int oif, struct nlattr *via, in mpls_nh_build() argument
806 if (!nh) in mpls_nh_build()
810 err = nla_get_labels(newdst, max_labels, &nh->nh_labels, in mpls_nh_build()
811 nh->nh_label, extack); in mpls_nh_build()
817 err = nla_get_via(via, &nh->nh_via_alen, &nh->nh_via_table, in mpls_nh_build()
818 __mpls_nh_via(rt, nh), extack); in mpls_nh_build()
822 nh->nh_via_table = MPLS_NEIGH_TABLE_UNSPEC; in mpls_nh_build()
825 err = mpls_nh_assign_dev(net, rt, nh, oif); in mpls_nh_build()
918 err = mpls_nh_build(cfg->rc_nlinfo.nl_net, rt, nh, in mpls_nh_build_multi()
924 if (nh->nh_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN)) in mpls_nh_build_multi()
1513 if (!nh->nh_dev || nh->nh_dev == dev) in mpls_ifdown()
1515 if (nh->nh_dev == dev) in mpls_ifdown()
1538 unsigned int nh_flags = nh->nh_flags; in mpls_ifdown()
1540 if (nh->nh_dev != dev) in mpls_ifdown()
1553 nh->nh_dev = NULL; in mpls_ifdown()
1555 if (nh->nh_flags != nh_flags) in mpls_ifdown()
1556 WRITE_ONCE(nh->nh_flags, nh_flags); in mpls_ifdown()
1587 unsigned int nh_flags = nh->nh_flags; in mpls_ifup()
1593 if (nh->nh_dev != dev) in mpls_ifup()
1597 WRITE_ONCE(nh->nh_flags, nh_flags); in mpls_ifup()
2018 const struct mpls_nh *nh = rt->rt_nh; in mpls_dump_route() local
2020 if (nh->nh_labels && in mpls_dump_route()
2021 nla_put_labels(skb, RTA_NEWDST, nh->nh_labels, in mpls_dump_route()
2022 nh->nh_label)) in mpls_dump_route()
2024 if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC && in mpls_dump_route()
2025 nla_put_via(skb, nh->nh_via_table, mpls_nh_via(rt, nh), in mpls_dump_route()
2026 nh->nh_via_alen)) in mpls_dump_route()
2028 dev = nh->nh_dev; in mpls_dump_route()
2031 if (nh->nh_flags & RTNH_F_LINKDOWN) in mpls_dump_route()
2033 if (nh->nh_flags & RTNH_F_DEAD) in mpls_dump_route()
2046 dev = nh->nh_dev; in mpls_dump_route()
2055 if (nh->nh_flags & RTNH_F_LINKDOWN) { in mpls_dump_route()
2059 if (nh->nh_flags & RTNH_F_DEAD) { in mpls_dump_route()
2064 if (nh->nh_labels && nla_put_labels(skb, RTA_NEWDST, in mpls_dump_route()
2065 nh->nh_labels, in mpls_dump_route()
2066 nh->nh_label)) in mpls_dump_route()
2068 if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC && in mpls_dump_route()
2069 nla_put_via(skb, nh->nh_via_table, in mpls_dump_route()
2070 mpls_nh_via(rt, nh), in mpls_dump_route()
2071 nh->nh_via_alen)) in mpls_dump_route()
2158 struct mpls_nh *nh = rt->rt_nh; in mpls_rt_uses_dev() local
2160 if (nh->nh_dev == dev) in mpls_rt_uses_dev()
2164 if (nh->nh_dev == dev) in mpls_rt_uses_dev()
2239 struct mpls_nh *nh = rt->rt_nh; in lfib_nlmsg_size() local
2241 if (nh->nh_dev) in lfib_nlmsg_size()
2243 if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC) /* RTA_VIA */ in lfib_nlmsg_size()
2244 payload += nla_total_size(2 + nh->nh_via_alen); in lfib_nlmsg_size()
2245 if (nh->nh_labels) /* RTA_NEWDST */ in lfib_nlmsg_size()
2246 payload += nla_total_size(nh->nh_labels * 4); in lfib_nlmsg_size()
2252 if (!nh->nh_dev) in lfib_nlmsg_size()
2256 if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC) in lfib_nlmsg_size()
2257 nhsize += nla_total_size(2 + nh->nh_via_alen); in lfib_nlmsg_size()
2258 if (nh->nh_labels) in lfib_nlmsg_size()
2259 nhsize += nla_total_size(nh->nh_labels * 4); in lfib_nlmsg_size()
2368 struct mpls_nh *nh; in mpls_getroute() local
2458 nh = mpls_select_multipath(rt, skb); in mpls_getroute()
2459 if (!nh) { in mpls_getroute()
2489 if (nh->nh_labels && in mpls_getroute()
2490 nla_put_labels(skb, RTA_NEWDST, nh->nh_labels, in mpls_getroute()
2491 nh->nh_label)) in mpls_getroute()
2494 if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC && in mpls_getroute()
2495 nla_put_via(skb, nh->nh_via_table, mpls_nh_via(rt, nh), in mpls_getroute()
2496 nh->nh_via_alen)) in mpls_getroute()
2498 dev = nh->nh_dev; in mpls_getroute()