Skip to content

Commit c122fda

Browse files
lxindavem330
authored andcommitted
ip_gre: set tunnel hlen properly in erspan_tunnel_init
According to __gre_tunnel_init, tunnel->hlen should be set as the headers' length between inner packet and outer iphdr. It would be used especially to calculate a proper mtu when updating mtu in tnl_update_pmtu. Now without setting it, a bigger mtu value than expected would be updated, which hurts performance a lot. This patch is to fix it by setting tunnel->hlen with: tunnel->tun_hlen + tunnel->encap_hlen + sizeof(struct erspanhdr) Fixes: 84e54fe ("gre: introduce native tunnel support for ERSPAN") Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5513d08 commit c122fda

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/ipv4/ip_gre.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,9 @@ static int erspan_tunnel_init(struct net_device *dev)
12451245

12461246
tunnel->tun_hlen = 8;
12471247
tunnel->parms.iph.protocol = IPPROTO_GRE;
1248-
t_hlen = tunnel->hlen + sizeof(struct iphdr) + sizeof(struct erspanhdr);
1248+
tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen +
1249+
sizeof(struct erspanhdr);
1250+
t_hlen = tunnel->hlen + sizeof(struct iphdr);
12491251

12501252
dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
12511253
dev->mtu = ETH_DATA_LEN - t_hlen - 4;

0 commit comments

Comments
 (0)