Commit 14f3ad6f authored by Ulrich Weber's avatar Ulrich Weber Committed by David S. Miller

ipv6: Use 1280 as min MTU for ipv6 forwarding

Clients will set their MTU to 1280 if they receive a
ICMPV6_PKT_TOOBIG message with an MTU less than 1280.

To allow encapsulating of packets over a 1280 link
we should always accept packets with a size of 1280
for forwarding even if the path has a lower MTU and
fragment the encapsulated packets afterwards.

In case a forwarded packet is not going to be encapsulated
a ICMPV6_PKT_TOOBIG msg will still be send by ip6_fragment()
with the correct MTU.
Signed-off-by: default avatarUlrich Weber <uweber@astaro.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fbf219f1
...@@ -402,6 +402,7 @@ int ip6_forward(struct sk_buff *skb) ...@@ -402,6 +402,7 @@ int ip6_forward(struct sk_buff *skb)
struct ipv6hdr *hdr = ipv6_hdr(skb); struct ipv6hdr *hdr = ipv6_hdr(skb);
struct inet6_skb_parm *opt = IP6CB(skb); struct inet6_skb_parm *opt = IP6CB(skb);
struct net *net = dev_net(dst->dev); struct net *net = dev_net(dst->dev);
u32 mtu;
if (net->ipv6.devconf_all->forwarding == 0) if (net->ipv6.devconf_all->forwarding == 0)
goto error; goto error;
...@@ -508,10 +509,14 @@ int ip6_forward(struct sk_buff *skb) ...@@ -508,10 +509,14 @@ int ip6_forward(struct sk_buff *skb)
} }
} }
if (skb->len > dst_mtu(dst)) { mtu = dst_mtu(dst);
if (mtu < IPV6_MIN_MTU)
mtu = IPV6_MIN_MTU;
if (skb->len > mtu) {
/* Again, force OUTPUT device used as source address */ /* Again, force OUTPUT device used as source address */
skb->dev = dst->dev; skb->dev = dst->dev;
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, dst_mtu(dst)); icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
IP6_INC_STATS_BH(net, IP6_INC_STATS_BH(net,
ip6_dst_idev(dst), IPSTATS_MIB_INTOOBIGERRORS); ip6_dst_idev(dst), IPSTATS_MIB_INTOOBIGERRORS);
IP6_INC_STATS_BH(net, IP6_INC_STATS_BH(net,
...@@ -621,8 +626,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) ...@@ -621,8 +626,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
mtu = ip6_skb_dst_mtu(skb); mtu = ip6_skb_dst_mtu(skb);
/* We must not fragment if the socket is set to force MTU discovery /* We must not fragment if the socket is set to force MTU discovery
* or if the skb it not generated by a local socket. (This last * or if the skb it not generated by a local socket.
* check should be redundant, but it's free.)
*/ */
if (!skb->local_df) { if (!skb->local_df) {
skb->dev = skb_dst(skb)->dev; skb->dev = skb_dst(skb)->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment