18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _NET_IP6_ROUTE_H 38c2ecf20Sopenharmony_ci#define _NET_IP6_ROUTE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_cistruct route_info { 68c2ecf20Sopenharmony_ci __u8 type; 78c2ecf20Sopenharmony_ci __u8 length; 88c2ecf20Sopenharmony_ci __u8 prefix_len; 98c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN_BITFIELD) 108c2ecf20Sopenharmony_ci __u8 reserved_h:3, 118c2ecf20Sopenharmony_ci route_pref:2, 128c2ecf20Sopenharmony_ci reserved_l:3; 138c2ecf20Sopenharmony_ci#elif defined(__LITTLE_ENDIAN_BITFIELD) 148c2ecf20Sopenharmony_ci __u8 reserved_l:3, 158c2ecf20Sopenharmony_ci route_pref:2, 168c2ecf20Sopenharmony_ci reserved_h:3; 178c2ecf20Sopenharmony_ci#endif 188c2ecf20Sopenharmony_ci __be32 lifetime; 198c2ecf20Sopenharmony_ci __u8 prefix[]; /* 0,8 or 16 */ 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <net/addrconf.h> 238c2ecf20Sopenharmony_ci#include <net/flow.h> 248c2ecf20Sopenharmony_ci#include <net/ip6_fib.h> 258c2ecf20Sopenharmony_ci#include <net/sock.h> 268c2ecf20Sopenharmony_ci#include <net/lwtunnel.h> 278c2ecf20Sopenharmony_ci#include <linux/ip.h> 288c2ecf20Sopenharmony_ci#include <linux/ipv6.h> 298c2ecf20Sopenharmony_ci#include <linux/route.h> 308c2ecf20Sopenharmony_ci#include <net/nexthop.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_IFACE 0x00000001 338c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_REACHABLE 0x00000002 348c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_HAS_SADDR 0x00000004 358c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008 368c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010 378c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_SRCPREF_COA 0x00000020 388c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_IGNORE_LINKSTATE 0x00000040 398c2ecf20Sopenharmony_ci#define RT6_LOOKUP_F_DST_NOREF 0x00000080 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* We do not (yet ?) support IPv6 jumbograms (RFC 2675) 428c2ecf20Sopenharmony_ci * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci#define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr)) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* 478c2ecf20Sopenharmony_ci * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate 488c2ecf20Sopenharmony_ci * between IPV6_ADDR_PREFERENCES socket option values 498c2ecf20Sopenharmony_ci * IPV6_PREFER_SRC_TMP = 0x1 508c2ecf20Sopenharmony_ci * IPV6_PREFER_SRC_PUBLIC = 0x2 518c2ecf20Sopenharmony_ci * IPV6_PREFER_SRC_COA = 0x4 528c2ecf20Sopenharmony_ci * and above RT6_LOOKUP_F_SRCPREF_xxx flags. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_cistatic inline int rt6_srcprefs2flags(unsigned int srcprefs) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci /* No need to bitmask because srcprefs have only 3 bits. */ 578c2ecf20Sopenharmony_ci return srcprefs << 3; 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline unsigned int rt6_flags2srcprefs(int flags) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci return (flags >> 3) & 7; 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic inline bool rt6_need_strict(const struct in6_addr *daddr) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci return ipv6_addr_type(daddr) & 688c2ecf20Sopenharmony_ci (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* fib entries using a nexthop object can not be coalesced into 728c2ecf20Sopenharmony_ci * a multipath route 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_cistatic inline bool rt6_qualify_for_ecmp(const struct fib6_info *f6i) 758c2ecf20Sopenharmony_ci{ 768c2ecf20Sopenharmony_ci /* the RTF_ADDRCONF flag filters out RA's */ 778c2ecf20Sopenharmony_ci return !(f6i->fib6_flags & RTF_ADDRCONF) && !f6i->nh && 788c2ecf20Sopenharmony_ci f6i->fib6_nh->fib_nh_gw_family; 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_civoid ip6_route_input(struct sk_buff *skb); 828c2ecf20Sopenharmony_cistruct dst_entry *ip6_route_input_lookup(struct net *net, 838c2ecf20Sopenharmony_ci struct net_device *dev, 848c2ecf20Sopenharmony_ci struct flowi6 *fl6, 858c2ecf20Sopenharmony_ci const struct sk_buff *skb, int flags); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistruct dst_entry *ip6_route_output_flags_noref(struct net *net, 888c2ecf20Sopenharmony_ci const struct sock *sk, 898c2ecf20Sopenharmony_ci struct flowi6 *fl6, int flags); 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistruct dst_entry *ip6_route_output_flags(struct net *net, const struct sock *sk, 928c2ecf20Sopenharmony_ci struct flowi6 *fl6, int flags); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic inline struct dst_entry *ip6_route_output(struct net *net, 958c2ecf20Sopenharmony_ci const struct sock *sk, 968c2ecf20Sopenharmony_ci struct flowi6 *fl6) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci return ip6_route_output_flags(net, sk, fl6, 0); 998c2ecf20Sopenharmony_ci} 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* Only conditionally release dst if flags indicates 1028c2ecf20Sopenharmony_ci * !RT6_LOOKUP_F_DST_NOREF or dst is in uncached_list. 1038c2ecf20Sopenharmony_ci */ 1048c2ecf20Sopenharmony_cistatic inline void ip6_rt_put_flags(struct rt6_info *rt, int flags) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci if (!(flags & RT6_LOOKUP_F_DST_NOREF) || 1078c2ecf20Sopenharmony_ci !list_empty(&rt->rt6i_uncached)) 1088c2ecf20Sopenharmony_ci ip6_rt_put(rt); 1098c2ecf20Sopenharmony_ci} 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistruct dst_entry *ip6_route_lookup(struct net *net, struct flowi6 *fl6, 1128c2ecf20Sopenharmony_ci const struct sk_buff *skb, int flags); 1138c2ecf20Sopenharmony_cistruct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, 1148c2ecf20Sopenharmony_ci int ifindex, struct flowi6 *fl6, 1158c2ecf20Sopenharmony_ci const struct sk_buff *skb, int flags); 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_civoid ip6_route_init_special_entries(void); 1188c2ecf20Sopenharmony_ciint ip6_route_init(void); 1198c2ecf20Sopenharmony_civoid ip6_route_cleanup(void); 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciint ipv6_route_ioctl(struct net *net, unsigned int cmd, 1228c2ecf20Sopenharmony_ci struct in6_rtmsg *rtmsg); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ciint ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags, 1258c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 1268c2ecf20Sopenharmony_ciint ip6_ins_rt(struct net *net, struct fib6_info *f6i); 1278c2ecf20Sopenharmony_ciint ip6_del_rt(struct net *net, struct fib6_info *f6i, bool skip_notify); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_civoid rt6_flush_exceptions(struct fib6_info *f6i); 1308c2ecf20Sopenharmony_civoid rt6_age_exceptions(struct fib6_info *f6i, struct fib6_gc_args *gc_args, 1318c2ecf20Sopenharmony_ci unsigned long now); 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic inline int ip6_route_get_saddr(struct net *net, struct fib6_info *f6i, 1348c2ecf20Sopenharmony_ci const struct in6_addr *daddr, 1358c2ecf20Sopenharmony_ci unsigned int prefs, 1368c2ecf20Sopenharmony_ci struct in6_addr *saddr) 1378c2ecf20Sopenharmony_ci{ 1388c2ecf20Sopenharmony_ci int err = 0; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci if (f6i && f6i->fib6_prefsrc.plen) { 1418c2ecf20Sopenharmony_ci *saddr = f6i->fib6_prefsrc.addr; 1428c2ecf20Sopenharmony_ci } else { 1438c2ecf20Sopenharmony_ci struct net_device *dev = f6i ? fib6_info_nh_dev(f6i) : NULL; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci err = ipv6_dev_get_saddr(net, dev, daddr, prefs, saddr); 1468c2ecf20Sopenharmony_ci } 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci return err; 1498c2ecf20Sopenharmony_ci} 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistruct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr, 1528c2ecf20Sopenharmony_ci const struct in6_addr *saddr, int oif, 1538c2ecf20Sopenharmony_ci const struct sk_buff *skb, int flags); 1548c2ecf20Sopenharmony_ciu32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6, 1558c2ecf20Sopenharmony_ci const struct sk_buff *skb, struct flow_keys *hkeys); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistruct dst_entry *icmp6_dst_alloc(struct net_device *dev, struct flowi6 *fl6); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_civoid fib6_force_start_gc(struct net *net); 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistruct fib6_info *addrconf_f6i_alloc(struct net *net, struct inet6_dev *idev, 1628c2ecf20Sopenharmony_ci const struct in6_addr *addr, bool anycast, 1638c2ecf20Sopenharmony_ci gfp_t gfp_flags); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_cistruct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev, 1668c2ecf20Sopenharmony_ci int flags); 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci/* 1698c2ecf20Sopenharmony_ci * support functions for ND 1708c2ecf20Sopenharmony_ci * 1718c2ecf20Sopenharmony_ci */ 1728c2ecf20Sopenharmony_cistruct fib6_info *rt6_get_dflt_router(struct net *net, 1738c2ecf20Sopenharmony_ci const struct in6_addr *addr, 1748c2ecf20Sopenharmony_ci struct net_device *dev); 1758c2ecf20Sopenharmony_cistruct fib6_info *rt6_add_dflt_router(struct net *net, 1768c2ecf20Sopenharmony_ci const struct in6_addr *gwaddr, 1778c2ecf20Sopenharmony_ci struct net_device *dev, unsigned int pref); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_civoid rt6_purge_dflt_routers(struct net *net); 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ciint rt6_route_rcv(struct net_device *dev, u8 *opt, int len, 1828c2ecf20Sopenharmony_ci const struct in6_addr *gwaddr); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_civoid ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, int oif, 1858c2ecf20Sopenharmony_ci u32 mark, kuid_t uid); 1868c2ecf20Sopenharmony_civoid ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu); 1878c2ecf20Sopenharmony_civoid ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark, 1888c2ecf20Sopenharmony_ci kuid_t uid); 1898c2ecf20Sopenharmony_civoid ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif); 1908c2ecf20Sopenharmony_civoid ip6_sk_redirect(struct sk_buff *skb, struct sock *sk); 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_cistruct netlink_callback; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistruct rt6_rtnl_dump_arg { 1958c2ecf20Sopenharmony_ci struct sk_buff *skb; 1968c2ecf20Sopenharmony_ci struct netlink_callback *cb; 1978c2ecf20Sopenharmony_ci struct net *net; 1988c2ecf20Sopenharmony_ci struct fib_dump_filter filter; 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ciint rt6_dump_route(struct fib6_info *f6i, void *p_arg, unsigned int skip); 2028c2ecf20Sopenharmony_civoid rt6_mtu_change(struct net_device *dev, unsigned int mtu); 2038c2ecf20Sopenharmony_civoid rt6_remove_prefsrc(struct inet6_ifaddr *ifp); 2048c2ecf20Sopenharmony_civoid rt6_clean_tohost(struct net *net, struct in6_addr *gateway); 2058c2ecf20Sopenharmony_civoid rt6_sync_up(struct net_device *dev, unsigned char nh_flags); 2068c2ecf20Sopenharmony_civoid rt6_disable_ip(struct net_device *dev, unsigned long event); 2078c2ecf20Sopenharmony_civoid rt6_sync_down_dev(struct net_device *dev, unsigned long event); 2088c2ecf20Sopenharmony_civoid rt6_multipath_rebalance(struct fib6_info *f6i); 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_civoid rt6_uncached_list_add(struct rt6_info *rt); 2118c2ecf20Sopenharmony_civoid rt6_uncached_list_del(struct rt6_info *rt); 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_cistatic inline const struct rt6_info *skb_rt6_info(const struct sk_buff *skb) 2148c2ecf20Sopenharmony_ci{ 2158c2ecf20Sopenharmony_ci const struct dst_entry *dst = skb_dst(skb); 2168c2ecf20Sopenharmony_ci const struct rt6_info *rt6 = NULL; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci if (dst) 2198c2ecf20Sopenharmony_ci rt6 = container_of(dst, struct rt6_info, dst); 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci return rt6; 2228c2ecf20Sopenharmony_ci} 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci/* 2258c2ecf20Sopenharmony_ci * Store a destination cache entry in a socket 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_cistatic inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, 2288c2ecf20Sopenharmony_ci const struct in6_addr *daddr, 2298c2ecf20Sopenharmony_ci const struct in6_addr *saddr) 2308c2ecf20Sopenharmony_ci{ 2318c2ecf20Sopenharmony_ci struct ipv6_pinfo *np = inet6_sk(sk); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci np->dst_cookie = rt6_get_cookie((struct rt6_info *)dst); 2348c2ecf20Sopenharmony_ci sk_setup_caps(sk, dst); 2358c2ecf20Sopenharmony_ci np->daddr_cache = daddr; 2368c2ecf20Sopenharmony_ci#ifdef CONFIG_IPV6_SUBTREES 2378c2ecf20Sopenharmony_ci np->saddr_cache = saddr; 2388c2ecf20Sopenharmony_ci#endif 2398c2ecf20Sopenharmony_ci} 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_civoid ip6_sk_dst_store_flow(struct sock *sk, struct dst_entry *dst, 2428c2ecf20Sopenharmony_ci const struct flowi6 *fl6); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_cistatic inline bool ipv6_unicast_destination(const struct sk_buff *skb) 2458c2ecf20Sopenharmony_ci{ 2468c2ecf20Sopenharmony_ci struct rt6_info *rt = (struct rt6_info *) skb_dst(skb); 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci return rt->rt6i_flags & RTF_LOCAL; 2498c2ecf20Sopenharmony_ci} 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_cistatic inline bool ipv6_anycast_destination(const struct dst_entry *dst, 2528c2ecf20Sopenharmony_ci const struct in6_addr *daddr) 2538c2ecf20Sopenharmony_ci{ 2548c2ecf20Sopenharmony_ci struct rt6_info *rt = (struct rt6_info *)dst; 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci return rt->rt6i_flags & RTF_ANYCAST || 2578c2ecf20Sopenharmony_ci (rt->rt6i_dst.plen < 127 && 2588c2ecf20Sopenharmony_ci !(rt->rt6i_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) && 2598c2ecf20Sopenharmony_ci ipv6_addr_equal(&rt->rt6i_dst.addr, daddr)); 2608c2ecf20Sopenharmony_ci} 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ciint ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, 2638c2ecf20Sopenharmony_ci int (*output)(struct net *, struct sock *, struct sk_buff *)); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_cistatic inline unsigned int ip6_skb_dst_mtu(struct sk_buff *skb) 2668c2ecf20Sopenharmony_ci{ 2678c2ecf20Sopenharmony_ci unsigned int mtu; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? 2708c2ecf20Sopenharmony_ci inet6_sk(skb->sk) : NULL; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci if (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) { 2738c2ecf20Sopenharmony_ci mtu = READ_ONCE(skb_dst(skb)->dev->mtu); 2748c2ecf20Sopenharmony_ci mtu -= lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu); 2758c2ecf20Sopenharmony_ci } else 2768c2ecf20Sopenharmony_ci mtu = dst_mtu(skb_dst(skb)); 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci return mtu; 2798c2ecf20Sopenharmony_ci} 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_cistatic inline bool ip6_sk_accept_pmtu(const struct sock *sk) 2828c2ecf20Sopenharmony_ci{ 2838c2ecf20Sopenharmony_ci return inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_INTERFACE && 2848c2ecf20Sopenharmony_ci inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_OMIT; 2858c2ecf20Sopenharmony_ci} 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_cistatic inline bool ip6_sk_ignore_df(const struct sock *sk) 2888c2ecf20Sopenharmony_ci{ 2898c2ecf20Sopenharmony_ci return inet6_sk(sk)->pmtudisc < IPV6_PMTUDISC_DO || 2908c2ecf20Sopenharmony_ci inet6_sk(sk)->pmtudisc == IPV6_PMTUDISC_OMIT; 2918c2ecf20Sopenharmony_ci} 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_cistatic inline const struct in6_addr *rt6_nexthop(const struct rt6_info *rt, 2948c2ecf20Sopenharmony_ci const struct in6_addr *daddr) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci if (rt->rt6i_flags & RTF_GATEWAY) 2978c2ecf20Sopenharmony_ci return &rt->rt6i_gateway; 2988c2ecf20Sopenharmony_ci else if (unlikely(rt->rt6i_flags & RTF_CACHE)) 2998c2ecf20Sopenharmony_ci return &rt->rt6i_dst.addr; 3008c2ecf20Sopenharmony_ci else 3018c2ecf20Sopenharmony_ci return daddr; 3028c2ecf20Sopenharmony_ci} 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cistatic inline bool rt6_duplicate_nexthop(struct fib6_info *a, struct fib6_info *b) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci struct fib6_nh *nha, *nhb; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci if (a->nh || b->nh) 3098c2ecf20Sopenharmony_ci return nexthop_cmp(a->nh, b->nh); 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci nha = a->fib6_nh; 3128c2ecf20Sopenharmony_ci nhb = b->fib6_nh; 3138c2ecf20Sopenharmony_ci return nha->fib_nh_dev == nhb->fib_nh_dev && 3148c2ecf20Sopenharmony_ci ipv6_addr_equal(&nha->fib_nh_gw6, &nhb->fib_nh_gw6) && 3158c2ecf20Sopenharmony_ci !lwtunnel_cmp_encap(nha->fib_nh_lws, nhb->fib_nh_lws); 3168c2ecf20Sopenharmony_ci} 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_cistatic inline unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst) 3198c2ecf20Sopenharmony_ci{ 3208c2ecf20Sopenharmony_ci struct inet6_dev *idev; 3218c2ecf20Sopenharmony_ci unsigned int mtu; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci if (dst_metric_locked(dst, RTAX_MTU)) { 3248c2ecf20Sopenharmony_ci mtu = dst_metric_raw(dst, RTAX_MTU); 3258c2ecf20Sopenharmony_ci if (mtu) 3268c2ecf20Sopenharmony_ci goto out; 3278c2ecf20Sopenharmony_ci } 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci mtu = IPV6_MIN_MTU; 3308c2ecf20Sopenharmony_ci rcu_read_lock(); 3318c2ecf20Sopenharmony_ci idev = __in6_dev_get(dst->dev); 3328c2ecf20Sopenharmony_ci if (idev) 3338c2ecf20Sopenharmony_ci mtu = idev->cnf.mtu6; 3348c2ecf20Sopenharmony_ci rcu_read_unlock(); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ciout: 3378c2ecf20Sopenharmony_ci return mtu - lwtunnel_headroom(dst->lwtstate, mtu); 3388c2ecf20Sopenharmony_ci} 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ciu32 ip6_mtu_from_fib6(const struct fib6_result *res, 3418c2ecf20Sopenharmony_ci const struct in6_addr *daddr, 3428c2ecf20Sopenharmony_ci const struct in6_addr *saddr); 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_cistruct neighbour *ip6_neigh_lookup(const struct in6_addr *gw, 3458c2ecf20Sopenharmony_ci struct net_device *dev, struct sk_buff *skb, 3468c2ecf20Sopenharmony_ci const void *daddr); 3478c2ecf20Sopenharmony_ci#endif 348