netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] ip6: Transmit tunneling fixes
@ 2016-05-10  0:12 Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 1/5] ip6_gre: Fix MTU setting Tom Herbert
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Tom Herbert @ 2016-05-10  0:12 UTC (permalink / raw)
  To: davem, netdev, alexander.duyck; +Cc: kernel-team

Several fixes suggested by Alexander.

Tested: Running netperf TCP_STREAM with gretap and keyid configured.
Visually verified that MTU is correctly being set. Did not test HW
offload (Alexander plese try)


Tom Herbert (5):
  ip6_gre: Fix MTU setting
  gre6: Fix flag translations
  ip6_gre: Set inner protocol correctly in __gre6_xmit
  ip6: Don't set transport header in IPv6 tunneling
  ip6_gre: Use correct flags for reading TUNNEL_SEQ

 net/ipv6/ip6_gre.c    | 55 ++++++++++++++++++++++++++-------------------------
 net/ipv6/ip6_tunnel.c |  2 --
 2 files changed, 28 insertions(+), 29 deletions(-)

-- 
2.8.0.rc2

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

* [PATCH net-next 1/5] ip6_gre: Fix MTU setting
  2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
@ 2016-05-10  0:12 ` Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 2/5] gre6: Fix flag translations Tom Herbert
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-05-10  0:12 UTC (permalink / raw)
  To: davem, netdev, alexander.duyck; +Cc: kernel-team

In ip6gre_tnl_link_config set t->tun_len and t->hlen correctly for the
configuration. For hard_header_len and mtu calculation include
IPv6 header and encapsulation overhead.

In ip6gre_tunnel_init_common set t->tun_len and t->hlen correctly for
the configuration. Revert to setting hard_header_len instead of
needed_headroom.

Tested:

./ip link add name tun8 type ip6gretap remote \
2401:db00:20:911a:face:0:27:0 local \
2401:db00:20:911a:face:0:25:0 ttl 225

Gives MTU of 1434. That is equal to 1500 - 40 - 14 - 4 - 8.

./ip link add name tun8 type ip6gretap remote \
2401:db00:20:911a:face:0:27:0 local \
2401:db00:20:911a:face:0:25:0 ttl 225 okey 123

Gives MTU of 1430. That is equal to 1500 - 40 - 14 - 4 - 8 - 4.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/ip6_gre.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 47b671a..6d0aa94 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -700,7 +700,7 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
 	struct net_device *dev = t->dev;
 	struct __ip6_tnl_parm *p = &t->parms;
 	struct flowi6 *fl6 = &t->fl.u.ip6;
-	int addend = sizeof(struct ipv6hdr) + 4;
+	int t_hlen;
 
 	if (dev->type != ARPHRD_ETHER) {
 		memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
@@ -727,16 +727,11 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
 	else
 		dev->flags &= ~IFF_POINTOPOINT;
 
-	/* Precalculate GRE options length */
-	if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) {
-		if (t->parms.o_flags&GRE_CSUM)
-			addend += 4;
-		if (t->parms.o_flags&GRE_KEY)
-			addend += 4;
-		if (t->parms.o_flags&GRE_SEQ)
-			addend += 4;
-	}
-	t->hlen = addend;
+	t->tun_hlen = gre_calc_hlen(t->parms.o_flags);
+
+	t->hlen = t->tun_hlen;
+
+	t_hlen = t->hlen + sizeof(struct ipv6hdr);
 
 	if (p->flags & IP6_TNL_F_CAP_XMIT) {
 		int strict = (ipv6_addr_type(&p->raddr) &
@@ -750,10 +745,11 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
 			return;
 
 		if (rt->dst.dev) {
-			dev->hard_header_len = rt->dst.dev->hard_header_len + addend;
+			dev->hard_header_len = rt->dst.dev->hard_header_len +
+					       t_hlen;
 
 			if (set_mtu) {
-				dev->mtu = rt->dst.dev->mtu - addend;
+				dev->mtu = rt->dst.dev->mtu - t_hlen;
 				if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
 					dev->mtu -= 8;
 				if (dev->type == ARPHRD_ETHER)
@@ -1027,11 +1023,12 @@ static int ip6gre_tunnel_init_common(struct net_device *dev)
 
 	tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags);
 
-	t_hlen = tunnel->hlen + sizeof(struct ipv6hdr);
+	tunnel->hlen = tunnel->tun_hlen;
 
-	dev->needed_headroom	= LL_MAX_HEADER + t_hlen + 4;
-	dev->mtu		= ETH_DATA_LEN - t_hlen - 4;
+	t_hlen = tunnel->hlen + sizeof(struct ipv6hdr);
 
+	dev->hard_header_len = LL_MAX_HEADER + t_hlen;
+	dev->mtu = ETH_DATA_LEN - t_hlen;
 	if (!(tunnel->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
 		dev->mtu -= 8;
 
-- 
2.8.0.rc2

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

* [PATCH net-next 2/5] gre6: Fix flag translations
  2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 1/5] ip6_gre: Fix MTU setting Tom Herbert
@ 2016-05-10  0:12 ` Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 3/5] ip6_gre: Set inner protocol correctly in __gre6_xmit Tom Herbert
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-05-10  0:12 UTC (permalink / raw)
  To: davem, netdev, alexander.duyck; +Cc: kernel-team

GRE for IPv6 does not properly translate for GRE flags to tunnel
flags and vice versa. This patch fixes that.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/ip6_gre.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 6d0aa94..509fb92 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -795,8 +795,8 @@ static void ip6gre_tnl_parm_from_user(struct __ip6_tnl_parm *p,
 	p->link = u->link;
 	p->i_key = u->i_key;
 	p->o_key = u->o_key;
-	p->i_flags = u->i_flags;
-	p->o_flags = u->o_flags;
+	p->i_flags = gre_flags_to_tnl_flags(u->i_flags);
+	p->o_flags = gre_flags_to_tnl_flags(u->o_flags);
 	memcpy(p->name, u->name, sizeof(u->name));
 }
 
@@ -813,8 +813,8 @@ static void ip6gre_tnl_parm_to_user(struct ip6_tnl_parm2 *u,
 	u->link = p->link;
 	u->i_key = p->i_key;
 	u->o_key = p->o_key;
-	u->i_flags = p->i_flags;
-	u->o_flags = p->o_flags;
+	u->i_flags = gre_tnl_flags_to_gre_flags(p->i_flags);
+	u->o_flags = gre_tnl_flags_to_gre_flags(p->o_flags);
 	memcpy(u->name, p->name, sizeof(u->name));
 }
 
@@ -1214,10 +1214,12 @@ static void ip6gre_netlink_parms(struct nlattr *data[],
 		parms->link = nla_get_u32(data[IFLA_GRE_LINK]);
 
 	if (data[IFLA_GRE_IFLAGS])
-		parms->i_flags = nla_get_be16(data[IFLA_GRE_IFLAGS]);
+		parms->i_flags = gre_flags_to_tnl_flags(
+				nla_get_be16(data[IFLA_GRE_IFLAGS]));
 
 	if (data[IFLA_GRE_OFLAGS])
-		parms->o_flags = nla_get_be16(data[IFLA_GRE_OFLAGS]);
+		parms->o_flags = gre_flags_to_tnl_flags(
+				nla_get_be16(data[IFLA_GRE_OFLAGS]));
 
 	if (data[IFLA_GRE_IKEY])
 		parms->i_key = nla_get_be32(data[IFLA_GRE_IKEY]);
@@ -1409,8 +1411,10 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	struct __ip6_tnl_parm *p = &t->parms;
 
 	if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
-	    nla_put_be16(skb, IFLA_GRE_IFLAGS, p->i_flags) ||
-	    nla_put_be16(skb, IFLA_GRE_OFLAGS, p->o_flags) ||
+	    nla_put_be16(skb, IFLA_GRE_IFLAGS,
+			 gre_tnl_flags_to_gre_flags(p->i_flags)) ||
+	    nla_put_be16(skb, IFLA_GRE_OFLAGS,
+			 gre_tnl_flags_to_gre_flags(p->o_flags)) ||
 	    nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
 	    nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
 	    nla_put_in6_addr(skb, IFLA_GRE_LOCAL, &p->laddr) ||
-- 
2.8.0.rc2

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

* [PATCH net-next 3/5] ip6_gre: Set inner protocol correctly in __gre6_xmit
  2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 1/5] ip6_gre: Fix MTU setting Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 2/5] gre6: Fix flag translations Tom Herbert
@ 2016-05-10  0:12 ` Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 4/5] ip6: Don't set transport header in IPv6 tunneling Tom Herbert
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-05-10  0:12 UTC (permalink / raw)
  To: davem, netdev, alexander.duyck; +Cc: kernel-team

Need to use adjusted protocol value for setting inner protocol.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/ip6_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 509fb92..ec209f4 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -519,7 +519,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
 	gre_build_header(skb, tunnel->tun_hlen, tunnel->parms.o_flags,
 			 protocol, tunnel->parms.o_key, htonl(tunnel->o_seqno));
 
-	skb_set_inner_protocol(skb, proto);
+	skb_set_inner_protocol(skb, protocol);
 
 	return ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,
 			    NEXTHDR_GRE);
-- 
2.8.0.rc2

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

* [PATCH net-next 4/5] ip6: Don't set transport header in IPv6 tunneling
  2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
                   ` (2 preceding siblings ...)
  2016-05-10  0:12 ` [PATCH net-next 3/5] ip6_gre: Set inner protocol correctly in __gre6_xmit Tom Herbert
@ 2016-05-10  0:12 ` Tom Herbert
  2016-05-10  0:12 ` [PATCH net-next 5/5] ip6_gre: Use correct flags for reading TUNNEL_SEQ Tom Herbert
  2016-05-10  3:30 ` [PATCH net-next 0/5] ip6: Transmit tunneling fixes Alexander Duyck
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-05-10  0:12 UTC (permalink / raw)
  To: davem, netdev, alexander.duyck; +Cc: kernel-team

We only need to reset network header here.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/ip6_tunnel.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index ade55af..50af706 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1114,8 +1114,6 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
 		dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr);
 	skb_dst_set(skb, dst);
 
-	skb->transport_header = skb->network_header;
-
 	if (encap_limit >= 0) {
 		init_tel_txopt(&opt, encap_limit);
 		ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
-- 
2.8.0.rc2

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

* [PATCH net-next 5/5] ip6_gre: Use correct flags for reading TUNNEL_SEQ
  2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
                   ` (3 preceding siblings ...)
  2016-05-10  0:12 ` [PATCH net-next 4/5] ip6: Don't set transport header in IPv6 tunneling Tom Herbert
@ 2016-05-10  0:12 ` Tom Herbert
  2016-05-10  3:30 ` [PATCH net-next 0/5] ip6: Transmit tunneling fixes Alexander Duyck
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-05-10  0:12 UTC (permalink / raw)
  To: davem, netdev, alexander.duyck; +Cc: kernel-team

Fix two spots where o_flags in a tunnel are being compared to GRE_SEQ
instead of TUNNEL_SEQ.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 net/ipv6/ip6_gre.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index ec209f4..ee62ec4 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -343,7 +343,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
 		goto failed_free;
 
 	/* Can use a lockless transmit, unless we generate output sequences */
-	if (!(nt->parms.o_flags & GRE_SEQ))
+	if (!(nt->parms.o_flags & TUNNEL_SEQ))
 		dev->features |= NETIF_F_LLTX;
 
 	dev_hold(dev);
@@ -1314,7 +1314,7 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
 	dev->features		|= GRE6_FEATURES;
 	dev->hw_features	|= GRE6_FEATURES;
 
-	if (!(nt->parms.o_flags & GRE_SEQ)) {
+	if (!(nt->parms.o_flags & TUNNEL_SEQ)) {
 		/* TCP segmentation offload is not supported when we
 		 * generate output sequences.
 		 */
-- 
2.8.0.rc2

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

* Re: [PATCH net-next 0/5] ip6: Transmit tunneling fixes
  2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
                   ` (4 preceding siblings ...)
  2016-05-10  0:12 ` [PATCH net-next 5/5] ip6_gre: Use correct flags for reading TUNNEL_SEQ Tom Herbert
@ 2016-05-10  3:30 ` Alexander Duyck
  2016-05-10  4:39   ` David Miller
  5 siblings, 1 reply; 8+ messages in thread
From: Alexander Duyck @ 2016-05-10  3:30 UTC (permalink / raw)
  To: Tom Herbert; +Cc: David Miller, Netdev, Kernel Team

On Mon, May 9, 2016 at 5:12 PM, Tom Herbert <tom@herbertland.com> wrote:
> Several fixes suggested by Alexander.
>
> Tested: Running netperf TCP_STREAM with gretap and keyid configured.
> Visually verified that MTU is correctly being set. Did not test HW
> offload (Alexander plese try)

This appears to have fixed the issues I saw.  I can confirm the MTU is
the same value that it was before the regression and I am able to
send/receive at around 17Gb/s.

Tested-by: Alexander Duyck <aduyck@mirantis.com>

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

* Re: [PATCH net-next 0/5] ip6: Transmit tunneling fixes
  2016-05-10  3:30 ` [PATCH net-next 0/5] ip6: Transmit tunneling fixes Alexander Duyck
@ 2016-05-10  4:39   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2016-05-10  4:39 UTC (permalink / raw)
  To: alexander.duyck; +Cc: tom, netdev, kernel-team

From: Alexander Duyck <alexander.duyck@gmail.com>
Date: Mon, 9 May 2016 20:30:46 -0700

> On Mon, May 9, 2016 at 5:12 PM, Tom Herbert <tom@herbertland.com> wrote:
>> Several fixes suggested by Alexander.
>>
>> Tested: Running netperf TCP_STREAM with gretap and keyid configured.
>> Visually verified that MTU is correctly being set. Did not test HW
>> offload (Alexander plese try)
> 
> This appears to have fixed the issues I saw.  I can confirm the MTU is
> the same value that it was before the regression and I am able to
> send/receive at around 17Gb/s.
> 
> Tested-by: Alexander Duyck <aduyck@mirantis.com>

Series applied, thanks everyone.

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

end of thread, other threads:[~2016-05-10  4:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-10  0:12 [PATCH net-next 0/5] ip6: Transmit tunneling fixes Tom Herbert
2016-05-10  0:12 ` [PATCH net-next 1/5] ip6_gre: Fix MTU setting Tom Herbert
2016-05-10  0:12 ` [PATCH net-next 2/5] gre6: Fix flag translations Tom Herbert
2016-05-10  0:12 ` [PATCH net-next 3/5] ip6_gre: Set inner protocol correctly in __gre6_xmit Tom Herbert
2016-05-10  0:12 ` [PATCH net-next 4/5] ip6: Don't set transport header in IPv6 tunneling Tom Herbert
2016-05-10  0:12 ` [PATCH net-next 5/5] ip6_gre: Use correct flags for reading TUNNEL_SEQ Tom Herbert
2016-05-10  3:30 ` [PATCH net-next 0/5] ip6: Transmit tunneling fixes Alexander Duyck
2016-05-10  4:39   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).