Skip to content

Commit c79c314

Browse files
committed
Merge branch 'erspan-fixes'
Xin Long says: ==================== ip_gre: a bunch of fixes for erspan This patchset is to fix some issues that could cause 0 or low performance, and even unexpected truncated packets on erspan. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents aad0621 + c84bed4 commit c79c314

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/ipv4/ip_gre.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
259259
struct ip_tunnel *tunnel;
260260
struct erspanhdr *ershdr;
261261
const struct iphdr *iph;
262-
__be32 session_id;
263262
__be32 index;
264263
int len;
265264

@@ -275,8 +274,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
275274
/* The original GRE header does not have key field,
276275
* Use ERSPAN 10-bit session ID as key.
277276
*/
278-
session_id = cpu_to_be32(ntohs(ershdr->session_id));
279-
tpi->key = session_id;
277+
tpi->key = cpu_to_be32(ntohs(ershdr->session_id) & ID_MASK);
280278
index = ershdr->md.index;
281279
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex,
282280
tpi->flags | TUNNEL_KEY,
@@ -733,7 +731,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
733731
if (skb_cow_head(skb, dev->needed_headroom))
734732
goto free_skb;
735733

736-
if (skb->len > dev->mtu) {
734+
if (skb->len - dev->hard_header_len > dev->mtu) {
737735
pskb_trim(skb, dev->mtu);
738736
truncate = true;
739737
}
@@ -1247,13 +1245,16 @@ static int erspan_tunnel_init(struct net_device *dev)
12471245

12481246
tunnel->tun_hlen = 8;
12491247
tunnel->parms.iph.protocol = IPPROTO_GRE;
1250-
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);
12511251

12521252
dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
12531253
dev->mtu = ETH_DATA_LEN - t_hlen - 4;
12541254
dev->features |= GRE_FEATURES;
12551255
dev->hw_features |= GRE_FEATURES;
12561256
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
1257+
netif_keep_dst(dev);
12571258

12581259
return ip_tunnel_init(dev);
12591260
}

0 commit comments

Comments
 (0)