Skip to content

Commit d41bb33

Browse files
lxindavem330
authored andcommitted
ip6_tunnel: update mtu properly for ARPHRD_ETHER tunnel device in tx path
Now when updating mtu in tx path, it doesn't consider ARPHRD_ETHER tunnel device, like ip6gre_tap tunnel, for which it should also subtract ether header to get the correct mtu. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2d40557 commit d41bb33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv6/ip6_tunnel.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
10431043
struct dst_entry *dst = NULL, *ndst = NULL;
10441044
struct net_device *tdev;
10451045
int mtu;
1046+
unsigned int eth_hlen = t->dev->type == ARPHRD_ETHER ? ETH_HLEN : 0;
10461047
unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen;
10471048
unsigned int max_headroom = psh_hlen;
10481049
bool use_cache = false;
@@ -1124,7 +1125,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
11241125
t->parms.name);
11251126
goto tx_err_dst_release;
11261127
}
1127-
mtu = dst_mtu(dst) - psh_hlen - t->tun_hlen;
1128+
mtu = dst_mtu(dst) - eth_hlen - psh_hlen - t->tun_hlen;
11281129
if (encap_limit >= 0) {
11291130
max_headroom += 8;
11301131
mtu -= 8;
@@ -1133,7 +1134,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
11331134
mtu = IPV6_MIN_MTU;
11341135
if (skb_dst(skb) && !t->parms.collect_md)
11351136
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
1136-
if (skb->len - t->tun_hlen > mtu && !skb_is_gso(skb)) {
1137+
if (skb->len - t->tun_hlen - eth_hlen > mtu && !skb_is_gso(skb)) {
11371138
*pmtu = mtu;
11381139
err = -EMSGSIZE;
11391140
goto tx_err_dst_release;

0 commit comments

Comments
 (0)