1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef _NET_IP6_ROUTE_H 31da177e4SLinus Torvalds #define _NET_IP6_ROUTE_H 41da177e4SLinus Torvalds 5*949d6b40SJakub Kicinski #include <net/addrconf.h> 6*949d6b40SJakub Kicinski #include <net/flow.h> 7*949d6b40SJakub Kicinski #include <net/ip6_fib.h> 8*949d6b40SJakub Kicinski #include <net/sock.h> 9*949d6b40SJakub Kicinski #include <net/lwtunnel.h> 10*949d6b40SJakub Kicinski #include <linux/ip.h> 11*949d6b40SJakub Kicinski #include <linux/ipv6.h> 12*949d6b40SJakub Kicinski #include <linux/route.h> 13*949d6b40SJakub Kicinski #include <net/nexthop.h> 14*949d6b40SJakub Kicinski 1570ceb4f5SYOSHIFUJI Hideaki struct route_info { 1670ceb4f5SYOSHIFUJI Hideaki __u8 type; 1770ceb4f5SYOSHIFUJI Hideaki __u8 length; 1870ceb4f5SYOSHIFUJI Hideaki __u8 prefix_len; 1970ceb4f5SYOSHIFUJI Hideaki #if defined(__BIG_ENDIAN_BITFIELD) 2070ceb4f5SYOSHIFUJI Hideaki __u8 reserved_h:3, 2170ceb4f5SYOSHIFUJI Hideaki route_pref:2, 2270ceb4f5SYOSHIFUJI Hideaki reserved_l:3; 2370ceb4f5SYOSHIFUJI Hideaki #elif defined(__LITTLE_ENDIAN_BITFIELD) 2470ceb4f5SYOSHIFUJI Hideaki __u8 reserved_l:3, 2570ceb4f5SYOSHIFUJI Hideaki route_pref:2, 2670ceb4f5SYOSHIFUJI Hideaki reserved_h:3; 2770ceb4f5SYOSHIFUJI Hideaki #endif 28e69a4adcSAl Viro __be32 lifetime; 29207644f5SGustavo A. R. Silva __u8 prefix[]; /* 0,8 or 16 */ 3070ceb4f5SYOSHIFUJI Hideaki }; 3170ceb4f5SYOSHIFUJI Hideaki 327cbca67cSYOSHIFUJI Hideaki #define RT6_LOOKUP_F_IFACE 0x00000001 337cbca67cSYOSHIFUJI Hideaki #define RT6_LOOKUP_F_REACHABLE 0x00000002 347cbca67cSYOSHIFUJI Hideaki #define RT6_LOOKUP_F_HAS_SADDR 0x00000004 357cbca67cSYOSHIFUJI Hideaki #define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008 367cbca67cSYOSHIFUJI Hideaki #define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010 377cbca67cSYOSHIFUJI Hideaki #define RT6_LOOKUP_F_SRCPREF_COA 0x00000020 38d5d32e4bSDavid Ahern #define RT6_LOOKUP_F_IGNORE_LINKSTATE 0x00000040 390e09edccSWei Wang #define RT6_LOOKUP_F_DST_NOREF 0x00000080 4077d16f45SYOSHIFUJI Hideaki 4130f78d8eSEric Dumazet /* We do not (yet ?) support IPv6 jumbograms (RFC 2675) 4230f78d8eSEric Dumazet * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header 4330f78d8eSEric Dumazet */ 4430f78d8eSEric Dumazet #define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr)) 4530f78d8eSEric Dumazet 460c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 /* 470c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate 480c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 * between IPV6_ADDR_PREFERENCES socket option values 490c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 * IPV6_PREFER_SRC_TMP = 0x1 500c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 * IPV6_PREFER_SRC_PUBLIC = 0x2 510c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 * IPV6_PREFER_SRC_COA = 0x4 520c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 * and above RT6_LOOKUP_F_SRCPREF_xxx flags. 530c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 */ 540c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 static inline int rt6_srcprefs2flags(unsigned int srcprefs) 550c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 { 560c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 /* No need to bitmask because srcprefs have only 3 bits. */ 570c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 return srcprefs << 3; 580c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 } 590c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 600c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 static inline unsigned int rt6_flags2srcprefs(int flags) 610c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 { 620c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 return (flags >> 3) & 7; 630c9a2ac1SYOSHIFUJI Hideaki / 吉藤英明 } 641da177e4SLinus Torvalds 6560ea37f7SWang Yufen static inline bool rt6_need_strict(const struct in6_addr *daddr) 6660ea37f7SWang Yufen { 6760ea37f7SWang Yufen return ipv6_addr_type(daddr) & 6860ea37f7SWang Yufen (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); 6960ea37f7SWang Yufen } 70fbfe95a4SDavid S. Miller 71f88d8ea6SDavid Ahern /* fib entries using a nexthop object can not be coalesced into 72f88d8ea6SDavid Ahern * a multipath route 73f88d8ea6SDavid Ahern */ 7433bd5ac5SDavid Ahern static inline bool rt6_qualify_for_ecmp(const struct fib6_info *f6i) 7533bd5ac5SDavid Ahern { 76be659b8dSDavid Ahern /* the RTF_ADDRCONF flag filters out RA's */ 77f88d8ea6SDavid Ahern return !(f6i->fib6_flags & RTF_ADDRCONF) && !f6i->nh && 781cf844c7SDavid Ahern f6i->fib6_nh->fib_nh_gw_family; 7933bd5ac5SDavid Ahern } 8033bd5ac5SDavid Ahern 815c3a0fd7SJoe Perches void ip6_route_input(struct sk_buff *skb); 82d409b847SMahesh Bandewar struct dst_entry *ip6_route_input_lookup(struct net *net, 83d409b847SMahesh Bandewar struct net_device *dev, 84b75cc8f9SDavid Ahern struct flowi6 *fl6, 85b75cc8f9SDavid Ahern const struct sk_buff *skb, int flags); 861da177e4SLinus Torvalds 877d9e5f42SWei Wang struct dst_entry *ip6_route_output_flags_noref(struct net *net, 887d9e5f42SWei Wang const struct sock *sk, 897d9e5f42SWei Wang struct flowi6 *fl6, int flags); 907d9e5f42SWei Wang 916f21c96aSPaolo Abeni struct dst_entry *ip6_route_output_flags(struct net *net, const struct sock *sk, 926f21c96aSPaolo Abeni struct flowi6 *fl6, int flags); 936f21c96aSPaolo Abeni 946f21c96aSPaolo Abeni static inline struct dst_entry *ip6_route_output(struct net *net, 956f21c96aSPaolo Abeni const struct sock *sk, 966f21c96aSPaolo Abeni struct flowi6 *fl6) 976f21c96aSPaolo Abeni { 986f21c96aSPaolo Abeni return ip6_route_output_flags(net, sk, fl6, 0); 996f21c96aSPaolo Abeni } 1006f21c96aSPaolo Abeni 101d64a1f57SWei Wang /* Only conditionally release dst if flags indicates 102d64a1f57SWei Wang * !RT6_LOOKUP_F_DST_NOREF or dst is in uncached_list. 103d64a1f57SWei Wang */ 104d64a1f57SWei Wang static inline void ip6_rt_put_flags(struct rt6_info *rt, int flags) 105d64a1f57SWei Wang { 106d64a1f57SWei Wang if (!(flags & RT6_LOOKUP_F_DST_NOREF) || 107d64a1f57SWei Wang !list_empty(&rt->rt6i_uncached)) 108d64a1f57SWei Wang ip6_rt_put(rt); 109d64a1f57SWei Wang } 110d64a1f57SWei Wang 1115c3a0fd7SJoe Perches struct dst_entry *ip6_route_lookup(struct net *net, struct flowi6 *fl6, 112b75cc8f9SDavid Ahern const struct sk_buff *skb, int flags); 1139ff74384SDavid Ahern struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, 114b75cc8f9SDavid Ahern int ifindex, struct flowi6 *fl6, 115b75cc8f9SDavid Ahern const struct sk_buff *skb, int flags); 1161da177e4SLinus Torvalds 1172f460933SWANG Cong void ip6_route_init_special_entries(void); 1185c3a0fd7SJoe Perches int ip6_route_init(void); 1195c3a0fd7SJoe Perches void ip6_route_cleanup(void); 1201da177e4SLinus Torvalds 1217c1552daSChristoph Hellwig int ipv6_route_ioctl(struct net *net, unsigned int cmd, 1227c1552daSChristoph Hellwig struct in6_rtmsg *rtmsg); 1231da177e4SLinus Torvalds 124acb54e3cSDavid Ahern int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags, 125acb54e3cSDavid Ahern struct netlink_ext_ack *extack); 12693c2fb25SDavid Ahern int ip6_ins_rt(struct net *net, struct fib6_info *f6i); 12711dd74b3SRoopa Prabhu int ip6_del_rt(struct net *net, struct fib6_info *f6i, bool skip_notify); 1281da177e4SLinus Torvalds 12993c2fb25SDavid Ahern void rt6_flush_exceptions(struct fib6_info *f6i); 13093c2fb25SDavid Ahern void rt6_age_exceptions(struct fib6_info *f6i, struct fib6_gc_args *gc_args, 131c757faa8SWei Wang unsigned long now); 13235732d01SWei Wang 13393c2fb25SDavid Ahern static inline int ip6_route_get_saddr(struct net *net, struct fib6_info *f6i, 134a2e2ff56SDavid Ahern const struct in6_addr *daddr, 135a2e2ff56SDavid Ahern unsigned int prefs, 136a2e2ff56SDavid Ahern struct in6_addr *saddr) 137a2e2ff56SDavid Ahern { 138a2e2ff56SDavid Ahern int err = 0; 139a2e2ff56SDavid Ahern 1406fe74941SDavid Ahern if (f6i && f6i->fib6_prefsrc.plen) { 14193c2fb25SDavid Ahern *saddr = f6i->fib6_prefsrc.addr; 1426fe74941SDavid Ahern } else { 1436fe74941SDavid Ahern struct net_device *dev = f6i ? fib6_info_nh_dev(f6i) : NULL; 1446fe74941SDavid Ahern 1456fe74941SDavid Ahern err = ipv6_dev_get_saddr(net, dev, daddr, prefs, saddr); 1466fe74941SDavid Ahern } 147a2e2ff56SDavid Ahern 148a2e2ff56SDavid Ahern return err; 149a2e2ff56SDavid Ahern } 150c3968a85SDaniel Walter 1515c3a0fd7SJoe Perches struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr, 152b75cc8f9SDavid Ahern const struct in6_addr *saddr, int oif, 153b75cc8f9SDavid Ahern const struct sk_buff *skb, int flags); 154b4bac172SDavid Ahern u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6, 155b4bac172SDavid Ahern const struct sk_buff *skb, struct flow_keys *hkeys); 1561da177e4SLinus Torvalds 1575c3a0fd7SJoe Perches struct dst_entry *icmp6_dst_alloc(struct net_device *dev, struct flowi6 *fl6); 1583b00944cSYOSHIFUJI Hideaki 1595c3a0fd7SJoe Perches void fib6_force_start_gc(struct net *net); 1601da177e4SLinus Torvalds 161360a9887SDavid Ahern struct fib6_info *addrconf_f6i_alloc(struct net *net, struct inet6_dev *idev, 162acb54e3cSDavid Ahern const struct in6_addr *addr, bool anycast, 163acb54e3cSDavid Ahern gfp_t gfp_flags); 1641da177e4SLinus Torvalds 1659ab179d8SDavid Ahern struct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev, 1669ab179d8SDavid Ahern int flags); 1679ab179d8SDavid Ahern 1681da177e4SLinus Torvalds /* 1691da177e4SLinus Torvalds * support functions for ND 1701da177e4SLinus Torvalds * 1711da177e4SLinus Torvalds */ 1728d1c802bSDavid Ahern struct fib6_info *rt6_get_dflt_router(struct net *net, 173afb1d4b5SDavid Ahern const struct in6_addr *addr, 1741da177e4SLinus Torvalds struct net_device *dev); 1758d1c802bSDavid Ahern struct fib6_info *rt6_add_dflt_router(struct net *net, 176afb1d4b5SDavid Ahern const struct in6_addr *gwaddr, 1776b2e04bcSPraveen Chaudhary struct net_device *dev, unsigned int pref, 1786b2e04bcSPraveen Chaudhary u32 defrtr_usr_metric); 1791da177e4SLinus Torvalds 1805c3a0fd7SJoe Perches void rt6_purge_dflt_routers(struct net *net); 1811da177e4SLinus Torvalds 1825c3a0fd7SJoe Perches int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, 183b71d1d42SEric Dumazet const struct in6_addr *gwaddr); 18470ceb4f5SYOSHIFUJI Hideaki 1855c3a0fd7SJoe Perches void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, int oif, 186e2d118a1SLorenzo Colitti u32 mark, kuid_t uid); 1875c3a0fd7SJoe Perches void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu); 188e2d118a1SLorenzo Colitti void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark, 189e2d118a1SLorenzo Colitti kuid_t uid); 190d456336dSMaciej Żenczykowski void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif); 1915c3a0fd7SJoe Perches void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk); 1921da177e4SLinus Torvalds 1931da177e4SLinus Torvalds struct netlink_callback; 1941da177e4SLinus Torvalds 195fd2c3ef7SEric Dumazet struct rt6_rtnl_dump_arg { 1961b43af54SPatrick McHardy struct sk_buff *skb; 1971b43af54SPatrick McHardy struct netlink_callback *cb; 198191cd582SBrian Haley struct net *net; 1994724676dSDavid Ahern struct fib_dump_filter filter; 2001b43af54SPatrick McHardy }; 2011b43af54SPatrick McHardy 2021e47b483SStefano Brivio int rt6_dump_route(struct fib6_info *f6i, void *p_arg, unsigned int skip); 2035c3a0fd7SJoe Perches void rt6_mtu_change(struct net_device *dev, unsigned int mtu); 2045c3a0fd7SJoe Perches void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); 205be7a010dSDuan Jiong void rt6_clean_tohost(struct net *net, struct in6_addr *gateway); 206ecc5663cSDavid Ahern void rt6_sync_up(struct net_device *dev, unsigned char nh_flags); 2074c981e28SIdo Schimmel void rt6_disable_ip(struct net_device *dev, unsigned long event); 20827c6fa73SIdo Schimmel void rt6_sync_down_dev(struct net_device *dev, unsigned long event); 20993c2fb25SDavid Ahern void rt6_multipath_rebalance(struct fib6_info *f6i); 2101da177e4SLinus Torvalds 211510c321bSXin Long void rt6_uncached_list_add(struct rt6_info *rt); 212510c321bSXin Long void rt6_uncached_list_del(struct rt6_info *rt); 213510c321bSXin Long 2141b70d792SDavid Ahern static inline const struct rt6_info *skb_rt6_info(const struct sk_buff *skb) 2151b70d792SDavid Ahern { 2161b70d792SDavid Ahern const struct dst_entry *dst = skb_dst(skb); 2171b70d792SDavid Ahern const struct rt6_info *rt6 = NULL; 2181b70d792SDavid Ahern 2191b70d792SDavid Ahern if (dst) 2201b70d792SDavid Ahern rt6 = container_of(dst, struct rt6_info, dst); 2211b70d792SDavid Ahern 2221b70d792SDavid Ahern return rt6; 2231b70d792SDavid Ahern } 2241da177e4SLinus Torvalds 2251da177e4SLinus Torvalds /* 2261da177e4SLinus Torvalds * Store a destination cache entry in a socket 2271da177e4SLinus Torvalds */ 2286bd4f355SEric Dumazet static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, 229d3818c92SEric Dumazet const struct in6_addr *daddr, 230d3818c92SEric Dumazet const struct in6_addr *saddr) 2311da177e4SLinus Torvalds { 2321da177e4SLinus Torvalds struct ipv6_pinfo *np = inet6_sk(sk); 2331da177e4SLinus Torvalds 2346bd4f355SEric Dumazet np->dst_cookie = rt6_get_cookie((struct rt6_info *)dst); 235f83ef8c0SHerbert Xu sk_setup_caps(sk, dst); 2361da177e4SLinus Torvalds np->daddr_cache = daddr; 2378e1ef0a9SYOSHIFUJI Hideaki #ifdef CONFIG_IPV6_SUBTREES 2388e1ef0a9SYOSHIFUJI Hideaki np->saddr_cache = saddr; 2398e1ef0a9SYOSHIFUJI Hideaki #endif 2401da177e4SLinus Torvalds } 2411da177e4SLinus Torvalds 2427d6850f7SAlexey Kodanev void ip6_sk_dst_store_flow(struct sock *sk, struct dst_entry *dst, 2437d6850f7SAlexey Kodanev const struct flowi6 *fl6); 2447d6850f7SAlexey Kodanev 245a50feda5SEric Dumazet static inline bool ipv6_unicast_destination(const struct sk_buff *skb) 2461da177e4SLinus Torvalds { 247adf30907SEric Dumazet struct rt6_info *rt = (struct rt6_info *) skb_dst(skb); 2481da177e4SLinus Torvalds 2491da177e4SLinus Torvalds return rt->rt6i_flags & RTF_LOCAL; 2501da177e4SLinus Torvalds } 2511da177e4SLinus Torvalds 2522647a9b0SMartin KaFai Lau static inline bool ipv6_anycast_destination(const struct dst_entry *dst, 2532647a9b0SMartin KaFai Lau const struct in6_addr *daddr) 254509aba3bSFX Le Bail { 2552647a9b0SMartin KaFai Lau struct rt6_info *rt = (struct rt6_info *)dst; 256509aba3bSFX Le Bail 2572647a9b0SMartin KaFai Lau return rt->rt6i_flags & RTF_ANYCAST || 258ccdb2d17SVincent Bernat (rt->rt6i_dst.plen < 127 && 25903e2a984STim Stallard !(rt->rt6i_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) && 2602647a9b0SMartin KaFai Lau ipv6_addr_equal(&rt->rt6i_dst.addr, daddr)); 261509aba3bSFX Le Bail } 262509aba3bSFX Le Bail 2637d8c6e39SEric W. Biederman int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, 2647d8c6e39SEric W. Biederman int (*output)(struct net *, struct sock *, struct sk_buff *)); 265ad0081e4SDavid Stevens 2668d22679dSEric Dumazet static inline unsigned int ip6_skb_dst_mtu(const struct sk_buff *skb) 267ad0081e4SDavid Stevens { 2688d22679dSEric Dumazet const struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? 2698d22679dSEric Dumazet inet6_sk(skb->sk) : NULL; 2708d22679dSEric Dumazet const struct dst_entry *dst = skb_dst(skb); 27140391467SAntoine Tenart unsigned int mtu; 272fade5641SVadim Fedorenko 273fade5641SVadim Fedorenko if (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) { 2748d22679dSEric Dumazet mtu = READ_ONCE(dst->dev->mtu); 2758d22679dSEric Dumazet mtu -= lwtunnel_headroom(dst->lwtstate, mtu); 2768d22679dSEric Dumazet } else { 2778d22679dSEric Dumazet mtu = dst_mtu(dst); 2788d22679dSEric Dumazet } 279fade5641SVadim Fedorenko return mtu; 280ad0081e4SDavid Stevens } 281ad0081e4SDavid Stevens 28293b36cf3SHannes Frederic Sowa static inline bool ip6_sk_accept_pmtu(const struct sock *sk) 28393b36cf3SHannes Frederic Sowa { 2840b95227aSHannes Frederic Sowa return inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_INTERFACE && 2850b95227aSHannes Frederic Sowa inet6_sk(sk)->pmtudisc != IPV6_PMTUDISC_OMIT; 2860b95227aSHannes Frederic Sowa } 2870b95227aSHannes Frederic Sowa 28860ff7467SWANG Cong static inline bool ip6_sk_ignore_df(const struct sock *sk) 2890b95227aSHannes Frederic Sowa { 2900b95227aSHannes Frederic Sowa return inet6_sk(sk)->pmtudisc < IPV6_PMTUDISC_DO || 2910b95227aSHannes Frederic Sowa inet6_sk(sk)->pmtudisc == IPV6_PMTUDISC_OMIT; 29293b36cf3SHannes Frederic Sowa } 29393b36cf3SHannes Frederic Sowa 2949b1c1ef1SNicolas Dichtel static inline const struct in6_addr *rt6_nexthop(const struct rt6_info *rt, 2959b1c1ef1SNicolas Dichtel const struct in6_addr *daddr) 2969bb5a148SYOSHIFUJI Hideaki / 吉藤英明 { 2972647a9b0SMartin KaFai Lau if (rt->rt6i_flags & RTF_GATEWAY) 2989bb5a148SYOSHIFUJI Hideaki / 吉藤英明 return &rt->rt6i_gateway; 29945e4fd26SMartin KaFai Lau else if (unlikely(rt->rt6i_flags & RTF_CACHE)) 3002647a9b0SMartin KaFai Lau return &rt->rt6i_dst.addr; 3012647a9b0SMartin KaFai Lau else 3022647a9b0SMartin KaFai Lau return daddr; 3039bb5a148SYOSHIFUJI Hideaki / 吉藤英明 } 3049bb5a148SYOSHIFUJI Hideaki / 吉藤英明 3058d1c802bSDavid Ahern static inline bool rt6_duplicate_nexthop(struct fib6_info *a, struct fib6_info *b) 306f06b7549SDavid Ahern { 307f88d8ea6SDavid Ahern struct fib6_nh *nha, *nhb; 308ad1601aeSDavid Ahern 309f88d8ea6SDavid Ahern if (a->nh || b->nh) 310f88d8ea6SDavid Ahern return nexthop_cmp(a->nh, b->nh); 311f88d8ea6SDavid Ahern 312f88d8ea6SDavid Ahern nha = a->fib6_nh; 313f88d8ea6SDavid Ahern nhb = b->fib6_nh; 314ad1601aeSDavid Ahern return nha->fib_nh_dev == nhb->fib_nh_dev && 315ad1601aeSDavid Ahern ipv6_addr_equal(&nha->fib_nh_gw6, &nhb->fib_nh_gw6) && 316ad1601aeSDavid Ahern !lwtunnel_cmp_encap(nha->fib_nh_lws, nhb->fib_nh_lws); 317f06b7549SDavid Ahern } 3185e5d6fedSRoopa Prabhu 319427faee1SVadim Fedorenko static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dst, 320427faee1SVadim Fedorenko bool forwarding) 32107cb9623SFelix Fietkau { 32207cb9623SFelix Fietkau struct inet6_dev *idev; 32307cb9623SFelix Fietkau unsigned int mtu; 32407cb9623SFelix Fietkau 325427faee1SVadim Fedorenko if (!forwarding || dst_metric_locked(dst, RTAX_MTU)) { 32607cb9623SFelix Fietkau mtu = dst_metric_raw(dst, RTAX_MTU); 32707cb9623SFelix Fietkau if (mtu) 328fade5641SVadim Fedorenko goto out; 32907cb9623SFelix Fietkau } 33007cb9623SFelix Fietkau 33107cb9623SFelix Fietkau mtu = IPV6_MIN_MTU; 33207cb9623SFelix Fietkau rcu_read_lock(); 33307cb9623SFelix Fietkau idev = __in6_dev_get(dst->dev); 33407cb9623SFelix Fietkau if (idev) 33507cb9623SFelix Fietkau mtu = idev->cnf.mtu6; 33607cb9623SFelix Fietkau rcu_read_unlock(); 33707cb9623SFelix Fietkau 338fade5641SVadim Fedorenko out: 339fade5641SVadim Fedorenko return mtu - lwtunnel_headroom(dst->lwtstate, mtu); 34007cb9623SFelix Fietkau } 34107cb9623SFelix Fietkau 342b748f260SDavid Ahern u32 ip6_mtu_from_fib6(const struct fib6_result *res, 343b748f260SDavid Ahern const struct in6_addr *daddr, 344b748f260SDavid Ahern const struct in6_addr *saddr); 345901731b8SDavid Ahern 346f8a1b43bSDavid Ahern struct neighbour *ip6_neigh_lookup(const struct in6_addr *gw, 347f8a1b43bSDavid Ahern struct net_device *dev, struct sk_buff *skb, 348f8a1b43bSDavid Ahern const void *daddr); 3491da177e4SLinus Torvalds #endif 350