]> git.dujemihanovic.xyz Git - linux.git/commitdiff
net: ipv6: introduce ip6_dst_mtu_maybe_forward
authorVadim Fedorenko <vfedorenko@novek.ru>
Tue, 20 Jul 2021 20:06:27 +0000 (23:06 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Jul 2021 15:22:02 +0000 (08:22 -0700)
Replace ip6_dst_mtu_forward with ip6_dst_mtu_maybe_forward and
reuse this code in ip6_mtu. Actually these two functions were
almost duplicates, this change will simplify the maintaince of
mtu calculation code.

Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip6_route.h
net/ipv6/ip6_output.c
net/ipv6/route.c
net/netfilter/nf_flow_table_core.c

index 625a38ccb5d9458f89c7cec3a698775ce864d6cb..820eae3ea95ffbd555672fe9601ea355fe95e0a4 100644 (file)
@@ -316,12 +316,13 @@ static inline bool rt6_duplicate_nexthop(struct fib6_info *a, struct fib6_info *
               !lwtunnel_cmp_encap(nha->fib_nh_lws, nhb->fib_nh_lws);
 }
 
-static inline unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
+static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dst,
+                                                    bool forwarding)
 {
        struct inet6_dev *idev;
        unsigned int mtu;
 
-       if (dst_metric_locked(dst, RTAX_MTU)) {
+       if (!forwarding || dst_metric_locked(dst, RTAX_MTU)) {
                mtu = dst_metric_raw(dst, RTAX_MTU);
                if (mtu)
                        goto out;
index 01bea76e3891c2ee8667ee83fdbff5b26fe8a23f..f6bc7828a48050c59893e6406b92afd33b282988 100644 (file)
@@ -607,7 +607,7 @@ int ip6_forward(struct sk_buff *skb)
                }
        }
 
-       mtu = ip6_dst_mtu_forward(dst);
+       mtu = ip6_dst_mtu_maybe_forward(dst, true);
        if (mtu < IPV6_MIN_MTU)
                mtu = IPV6_MIN_MTU;
 
index 5f7286acca338327b107849c8a25acecf6e80509..21d5d0b4cde53aecaf80a590dffaf8f60829ebfe 100644 (file)
@@ -3201,25 +3201,7 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)
 
 INDIRECT_CALLABLE_SCOPE unsigned int ip6_mtu(const struct dst_entry *dst)
 {
-       struct inet6_dev *idev;
-       unsigned int mtu;
-
-       mtu = dst_metric_raw(dst, RTAX_MTU);
-       if (mtu)
-               goto out;
-
-       mtu = IPV6_MIN_MTU;
-
-       rcu_read_lock();
-       idev = __in6_dev_get(dst->dev);
-       if (idev)
-               mtu = idev->cnf.mtu6;
-       rcu_read_unlock();
-
-out:
-       mtu = min_t(unsigned int, mtu, IP6_MAX_MTU);
-
-       return mtu - lwtunnel_headroom(dst->lwtstate, mtu);
+       return ip6_dst_mtu_maybe_forward(dst, false);
 }
 EXPORT_INDIRECT_CALLABLE(ip6_mtu);
 
index 1e50908b1b7e1d97a3fa1accd5043446fdaa7514..8fe024a0ae46c71692552d736361cd2ace4a9266 100644 (file)
@@ -99,7 +99,7 @@ static int flow_offload_fill_route(struct flow_offload *flow,
                flow_tuple->mtu = ip_dst_mtu_maybe_forward(dst, true);
                break;
        case NFPROTO_IPV6:
-               flow_tuple->mtu = ip6_dst_mtu_forward(dst);
+               flow_tuple->mtu = ip6_dst_mtu_maybe_forward(dst, true);
                break;
        }