All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/4] ip_gre: a bunch of fixes for erspan
@ 2017-10-01 14:00 Xin Long
  2017-10-01 14:00 ` [PATCH net 1/4] ip_gre: get key from session_id correctly in erspan_rcv Xin Long
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Xin Long @ 2017-10-01 14:00 UTC (permalink / raw)
  To: network dev; +Cc: davem, Dmitry Kozlov, William Tu

This patchset is to fix some issues that could cause 0 or low
performance, and even unexpected truncated packets on erspan.

Xin Long (4):
  ip_gre: get key from session_id correctly in erspan_rcv
  ip_gre: check packet length and mtu correctly in erspan_xmit
  ip_gre: set tunnel hlen properly in erspan_tunnel_init
  ip_gre: erspan device should keep dst

 net/ipv4/ip_gre.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net 1/4] ip_gre: get key from session_id correctly in erspan_rcv
  2017-10-01 14:00 [PATCH net 0/4] ip_gre: a bunch of fixes for erspan Xin Long
@ 2017-10-01 14:00 ` Xin Long
  2017-10-01 14:00 ` [PATCH net 2/4] ip_gre: check packet length and mtu correctly in erspan_xmit Xin Long
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2017-10-01 14:00 UTC (permalink / raw)
  To: network dev; +Cc: davem, Dmitry Kozlov, William Tu

erspan only uses the first 10 bits of session_id as the key to look
up the tunnel. But in erspan_rcv, it missed 'session_id & ID_MASK'
when getting the key from session_id.

If any other flag is also set in session_id in a packet, it would
fail to find the tunnel due to incorrect key in erspan_rcv.

This patch is to add 'session_id & ID_MASK' there and also remove
the unnecessary variable session_id.

Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/ip_gre.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 8b837f6..b25b1e5 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -259,7 +259,6 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	struct ip_tunnel *tunnel;
 	struct erspanhdr *ershdr;
 	const struct iphdr *iph;
-	__be32 session_id;
 	__be32 index;
 	int len;
 
@@ -275,8 +274,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	/* The original GRE header does not have key field,
 	 * Use ERSPAN 10-bit session ID as key.
 	 */
-	session_id = cpu_to_be32(ntohs(ershdr->session_id));
-	tpi->key = session_id;
+	tpi->key = cpu_to_be32(ntohs(ershdr->session_id) & ID_MASK);
 	index = ershdr->md.index;
 	tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex,
 				  tpi->flags | TUNNEL_KEY,
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 2/4] ip_gre: check packet length and mtu correctly in erspan_xmit
  2017-10-01 14:00 [PATCH net 0/4] ip_gre: a bunch of fixes for erspan Xin Long
  2017-10-01 14:00 ` [PATCH net 1/4] ip_gre: get key from session_id correctly in erspan_rcv Xin Long
@ 2017-10-01 14:00 ` Xin Long
  2017-10-01 14:00 ` [PATCH net 3/4] ip_gre: set tunnel hlen properly in erspan_tunnel_init Xin Long
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2017-10-01 14:00 UTC (permalink / raw)
  To: network dev; +Cc: davem, Dmitry Kozlov, William Tu

As a ARPHRD_ETHER device, skb->len in erspan_xmit is the length
of the whole ether packet. So before checking if a packet size
exceeds the mtu, skb->len should subtract dev->hard_header_len.

Otherwise, all packets with max size according to mtu would be
trimmed to be truncated packet.

Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/ip_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index b25b1e5..2a4ef9d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -731,7 +731,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 	if (skb_cow_head(skb, dev->needed_headroom))
 		goto free_skb;
 
-	if (skb->len > dev->mtu) {
+	if (skb->len - dev->hard_header_len > dev->mtu) {
 		pskb_trim(skb, dev->mtu);
 		truncate = true;
 	}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 3/4] ip_gre: set tunnel hlen properly in erspan_tunnel_init
  2017-10-01 14:00 [PATCH net 0/4] ip_gre: a bunch of fixes for erspan Xin Long
  2017-10-01 14:00 ` [PATCH net 1/4] ip_gre: get key from session_id correctly in erspan_rcv Xin Long
  2017-10-01 14:00 ` [PATCH net 2/4] ip_gre: check packet length and mtu correctly in erspan_xmit Xin Long
@ 2017-10-01 14:00 ` Xin Long
  2017-10-01 14:00 ` [PATCH net 4/4] ip_gre: erspan device should keep dst Xin Long
  2017-10-02  5:32 ` [PATCH net 0/4] ip_gre: a bunch of fixes for erspan David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2017-10-01 14:00 UTC (permalink / raw)
  To: network dev; +Cc: davem, Dmitry Kozlov, William Tu

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: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/ip_gre.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 2a4ef9d..fad0bb1 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1245,7 +1245,9 @@ static int erspan_tunnel_init(struct net_device *dev)
 
 	tunnel->tun_hlen = 8;
 	tunnel->parms.iph.protocol = IPPROTO_GRE;
-	t_hlen = tunnel->hlen + sizeof(struct iphdr) + sizeof(struct erspanhdr);
+	tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen +
+		       sizeof(struct erspanhdr);
+	t_hlen = tunnel->hlen + sizeof(struct iphdr);
 
 	dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
 	dev->mtu = ETH_DATA_LEN - t_hlen - 4;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 4/4] ip_gre: erspan device should keep dst
  2017-10-01 14:00 [PATCH net 0/4] ip_gre: a bunch of fixes for erspan Xin Long
                   ` (2 preceding siblings ...)
  2017-10-01 14:00 ` [PATCH net 3/4] ip_gre: set tunnel hlen properly in erspan_tunnel_init Xin Long
@ 2017-10-01 14:00 ` Xin Long
  2017-10-02  5:32 ` [PATCH net 0/4] ip_gre: a bunch of fixes for erspan David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2017-10-01 14:00 UTC (permalink / raw)
  To: network dev; +Cc: davem, Dmitry Kozlov, William Tu

The patch 'ip_gre: ipgre_tap device should keep dst' fixed
the issue ipgre_tap dev mtu couldn't be updated in tx path.

The same fix is needed for erspan as well.

Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/ip_gre.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index fad0bb1..467e44d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1254,6 +1254,7 @@ static int erspan_tunnel_init(struct net_device *dev)
 	dev->features		|= GRE_FEATURES;
 	dev->hw_features	|= GRE_FEATURES;
 	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE;
+	netif_keep_dst(dev);
 
 	return ip_tunnel_init(dev);
 }
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 0/4] ip_gre: a bunch of fixes for erspan
  2017-10-01 14:00 [PATCH net 0/4] ip_gre: a bunch of fixes for erspan Xin Long
                   ` (3 preceding siblings ...)
  2017-10-01 14:00 ` [PATCH net 4/4] ip_gre: erspan device should keep dst Xin Long
@ 2017-10-02  5:32 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-02  5:32 UTC (permalink / raw)
  To: lucien.xin; +Cc: netdev, xeb, u9012063

From: Xin Long <lucien.xin@gmail.com>
Date: Sun,  1 Oct 2017 22:00:52 +0800

> This patchset is to fix some issues that could cause 0 or low
> performance, and even unexpected truncated packets on erspan.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-02  5:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-01 14:00 [PATCH net 0/4] ip_gre: a bunch of fixes for erspan Xin Long
2017-10-01 14:00 ` [PATCH net 1/4] ip_gre: get key from session_id correctly in erspan_rcv Xin Long
2017-10-01 14:00 ` [PATCH net 2/4] ip_gre: check packet length and mtu correctly in erspan_xmit Xin Long
2017-10-01 14:00 ` [PATCH net 3/4] ip_gre: set tunnel hlen properly in erspan_tunnel_init Xin Long
2017-10-01 14:00 ` [PATCH net 4/4] ip_gre: erspan device should keep dst Xin Long
2017-10-02  5:32 ` [PATCH net 0/4] ip_gre: a bunch of fixes for erspan David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.