]> Pileus Git - ~andy/linux/commitdiff
ipv6: introduce ip6_dst_mtu_forward and protect forwarding path with it
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Thu, 9 Jan 2014 09:01:16 +0000 (10:01 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Jan 2014 19:22:54 +0000 (11:22 -0800)
In the IPv6 forwarding path we are only concerend about the outgoing
interface MTU, but also respect locked MTUs on routes. Tunnel provider
or IPSEC already have to recheck and if needed send PtB notifications
to the sending host in case the data does not fit into the packet with
added headers (we only know the final header sizes there, while also
using path MTU information).

The reason for this change is, that path MTU information can be injected
into the kernel via e.g. icmp_err protocol handler without verification
of local sockets. As such, this could cause the IPv6 forwarding path to
wrongfully emit Packet-too-Big errors and drop IPv6 packets.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>
Cc: John Heffner <johnwheffner@gmail.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_output.c

index d1de9560c4217925b19666d811bb17378e550a39..ef02b26ccf812e57e794e9b151746600bcb9a8f0 100644 (file)
@@ -321,6 +321,27 @@ static inline int ip6_forward_finish(struct sk_buff *skb)
        return dst_output(skb);
 }
 
+static unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
+{
+       unsigned int mtu;
+       struct inet6_dev *idev;
+
+       if (dst_metric_locked(dst, RTAX_MTU)) {
+               mtu = dst_metric_raw(dst, RTAX_MTU);
+               if (mtu)
+                       return mtu;
+       }
+
+       mtu = IPV6_MIN_MTU;
+       rcu_read_lock();
+       idev = __in6_dev_get(dst->dev);
+       if (idev)
+               mtu = idev->cnf.mtu6;
+       rcu_read_unlock();
+
+       return mtu;
+}
+
 int ip6_forward(struct sk_buff *skb)
 {
        struct dst_entry *dst = skb_dst(skb);
@@ -441,7 +462,7 @@ int ip6_forward(struct sk_buff *skb)
                }
        }
 
-       mtu = dst_mtu(dst);
+       mtu = ip6_dst_mtu_forward(dst);
        if (mtu < IPV6_MIN_MTU)
                mtu = IPV6_MIN_MTU;