gre: Use needed_headroom
Now that we have dev->needed_headroom, we can use it instead of having a bogus dev->hard_header_len. This also allows us to include dev->hard_header_len in the MTU computation so that when we do have a meaningful hard_harder_len in future it is included automatically in figuring out the MTU. Incidentally, this fixes a bug where we ignored the needed_headroom field of the underlying device in calculating our own hard_header_len. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ec2a5652ea
commit
c95b819ad7
|
@ -637,7 +637,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
|
|
||||||
df = tiph->frag_off;
|
df = tiph->frag_off;
|
||||||
if (df)
|
if (df)
|
||||||
mtu = dst_mtu(&rt->u.dst) - tunnel->hlen;
|
mtu = dst_mtu(&rt->u.dst) - dev->hard_header_len - tunnel->hlen;
|
||||||
else
|
else
|
||||||
mtu = skb->dst ? dst_mtu(skb->dst) : dev->mtu;
|
mtu = skb->dst ? dst_mtu(skb->dst) : dev->mtu;
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ static void ipgre_tunnel_bind_dev(struct net_device *dev)
|
||||||
tunnel = netdev_priv(dev);
|
tunnel = netdev_priv(dev);
|
||||||
iph = &tunnel->parms.iph;
|
iph = &tunnel->parms.iph;
|
||||||
|
|
||||||
/* Guess output device to choose reasonable mtu and hard_header_len */
|
/* Guess output device to choose reasonable mtu and needed_headroom */
|
||||||
|
|
||||||
if (iph->daddr) {
|
if (iph->daddr) {
|
||||||
struct flowi fl = { .oif = tunnel->parms.link,
|
struct flowi fl = { .oif = tunnel->parms.link,
|
||||||
|
@ -806,7 +806,7 @@ static void ipgre_tunnel_bind_dev(struct net_device *dev)
|
||||||
tdev = __dev_get_by_index(dev_net(dev), tunnel->parms.link);
|
tdev = __dev_get_by_index(dev_net(dev), tunnel->parms.link);
|
||||||
|
|
||||||
if (tdev) {
|
if (tdev) {
|
||||||
hlen = tdev->hard_header_len;
|
hlen = tdev->hard_header_len + tdev->needed_headroom;
|
||||||
mtu = tdev->mtu;
|
mtu = tdev->mtu;
|
||||||
}
|
}
|
||||||
dev->iflink = tunnel->parms.link;
|
dev->iflink = tunnel->parms.link;
|
||||||
|
@ -820,8 +820,8 @@ static void ipgre_tunnel_bind_dev(struct net_device *dev)
|
||||||
if (tunnel->parms.o_flags&GRE_SEQ)
|
if (tunnel->parms.o_flags&GRE_SEQ)
|
||||||
addend += 4;
|
addend += 4;
|
||||||
}
|
}
|
||||||
dev->hard_header_len = hlen + addend;
|
dev->needed_headroom = addend + hlen;
|
||||||
dev->mtu = mtu - addend;
|
dev->mtu = mtu - dev->hard_header_len - addend;
|
||||||
tunnel->hlen = addend;
|
tunnel->hlen = addend;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -959,7 +959,8 @@ done:
|
||||||
static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu)
|
static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
{
|
{
|
||||||
struct ip_tunnel *tunnel = netdev_priv(dev);
|
struct ip_tunnel *tunnel = netdev_priv(dev);
|
||||||
if (new_mtu < 68 || new_mtu > 0xFFF8 - tunnel->hlen)
|
if (new_mtu < 68 ||
|
||||||
|
new_mtu > 0xFFF8 - dev->hard_header_len - tunnel->hlen)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
dev->mtu = new_mtu;
|
dev->mtu = new_mtu;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1085,7 +1086,7 @@ static void ipgre_tunnel_setup(struct net_device *dev)
|
||||||
dev->change_mtu = ipgre_tunnel_change_mtu;
|
dev->change_mtu = ipgre_tunnel_change_mtu;
|
||||||
|
|
||||||
dev->type = ARPHRD_IPGRE;
|
dev->type = ARPHRD_IPGRE;
|
||||||
dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
|
dev->needed_headroom = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
|
||||||
dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 4;
|
dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 4;
|
||||||
dev->flags = IFF_NOARP;
|
dev->flags = IFF_NOARP;
|
||||||
dev->iflink = 0;
|
dev->iflink = 0;
|
||||||
|
|
Loading…
Reference in New Issue