netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John W. Linville" <linville@tuxdriver.com>
To: netdev@vger.kernel.org
Cc: Dave Miller <davem@davemloft.net>,
	Pravin B Shelar <pshelar@nicira.com>,
	Jesse Gross <jesse@nicira.com>, Jiri Benc <jbenc@redhat.com>,
	"John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH 2/2] geneve: handle ipv6 priority like ipv4 tos
Date: Tue, 20 Oct 2015 11:11:06 -0400	[thread overview]
Message-ID: <1445353866-32710-2-git-send-email-linville@tuxdriver.com> (raw)
In-Reply-To: <1445353866-32710-1-git-send-email-linville@tuxdriver.com>

Other callers of udp_tunnel6_xmit_skb just pass 0 for the prio
argument.  Jesse Gross <jesse@nicira.com> suggested that prio is really
the same as IPv4's tos and should be handled the same, so this is my
interpretation of that suggestion.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Reported-by: Jesse Gross <jesse@nicira.com>
---
 drivers/net/geneve.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 217b472ab9e7..cef71bdda13d 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -748,6 +748,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
 	struct geneve_dev *geneve = netdev_priv(dev);
 	struct geneve_sock *gs6 = geneve->sock6;
 	struct dst_entry *dst = NULL;
+	__u8 prio;
 
 	memset(fl6, 0, sizeof(*fl6));
 	fl6->flowi6_mark = skb->mark;
@@ -756,7 +757,16 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
 	if (info) {
 		fl6->daddr = info->key.u.ipv6.dst;
 		fl6->saddr = info->key.u.ipv6.src;
+		fl6->flowi6_tos = RT_TOS(info->key.tos);
 	} else {
+		prio = geneve->tos;
+		if (prio == 1) {
+			const struct iphdr *iip = ip_hdr(skb);
+
+			prio = ip_tunnel_get_dsfield(iip, skb);
+		}
+
+		fl6->flowi6_tos = RT_TOS(prio);
 		fl6->daddr = geneve->remote.sin6.sin6_addr;
 	}
 
@@ -876,8 +886,9 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
 	struct geneve_dev *geneve = netdev_priv(dev);
 	struct geneve_sock *gs6 = geneve->sock6;
 	struct dst_entry *dst = NULL;
+	const struct iphdr *iip; /* interior IP header */
 	struct flowi6 fl6;
-	__u8 ttl;
+	__u8 prio, ttl;
 	__be16 sport;
 	bool udp_csum;
 	int err;
@@ -906,6 +917,8 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
 	sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
 	skb_reset_mac_header(skb);
 
+	iip = ip_hdr(skb);
+
 	if (info) {
 		const struct ip_tunnel_key *key = &info->key;
 		u8 *opts = NULL;
@@ -922,6 +935,7 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
 		if (unlikely(err))
 			goto err;
 
+		prio = ip_tunnel_ecn_encap(key->tos, iip, skb);
 		ttl = key->ttl;
 	} else {
 		udp_csum = false;
@@ -930,13 +944,14 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
 		if (unlikely(err))
 			goto err;
 
+		prio = ip_tunnel_ecn_encap(fl6.flowi6_tos, iip, skb);
 		ttl = geneve->ttl;
 		if (!ttl && ipv6_addr_is_multicast(&fl6.daddr))
 			ttl = 1;
 		ttl = ttl ? : ip6_dst_hoplimit(dst);
 	}
 	err = udp_tunnel6_xmit_skb(dst, gs6->sock->sk, skb, dev,
-				   &fl6.saddr, &fl6.daddr, 0, ttl,
+				   &fl6.saddr, &fl6.daddr, prio, ttl,
 				   sport, geneve->dst_port, !udp_csum);
 
 	iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
-- 
2.4.3

  reply	other threads:[~2015-10-20 15:15 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24 18:34 [RFT] geneve: implement support for IPv6-based tunnels John W. Linville
2015-09-24 18:39 ` [PATCH iproute2] geneve: add support for IPv6 link partners John W. Linville
2015-11-24  0:23   ` Stephen Hemminger
2015-09-25 12:08 ` [RFT] geneve: implement support for IPv6-based tunnels Jiri Benc
2015-09-28 19:20   ` John W. Linville
2015-09-29 16:10     ` Jiri Benc
2015-09-30 17:04 ` [RFT v2] " John W. Linville
2015-09-30 18:07   ` kbuild test robot
2015-09-30 18:34   ` [RFT v3] " John W. Linville
2015-10-01  1:55     ` kbuild test robot
2015-10-01 15:38     ` Jiri Benc
2015-10-01 16:26     ` Jesse Gross
2015-10-01 20:03       ` John W. Linville
2015-10-01 21:07         ` Jesse Gross
2015-10-20 15:11     ` [PATCH v4 1/2] " John W. Linville
2015-10-20 15:11       ` John W. Linville [this message]
2015-10-21  5:13         ` [PATCH 2/2] geneve: handle ipv6 priority like ipv4 tos Jesse Gross
2015-10-20 22:55       ` [PATCH v4 1/2] geneve: implement support for IPv6-based tunnels kbuild test robot
2015-10-21  1:52       ` YOSHIFUJI Hideaki/吉藤英明
2015-10-21 18:58         ` John W. Linville
2015-10-21  5:06       ` Jesse Gross
2015-10-22 19:45       ` [PATCH v5 " John W. Linville
2015-10-22 19:45         ` [PATCH v5 2/2] geneve: handle ipv6 priority like ipv4 tos John W. Linville
2015-10-23  4:48         ` [PATCH v5 1/2] geneve: implement support for IPv6-based tunnels YOSHIFUJI Hideaki
2015-10-23 13:38           ` John W. Linville
2015-10-23 14:40         ` [PATCH v6 " John W. Linville
2015-10-23 14:40           ` [PATCH v6 2/2] geneve: handle ipv6 priority like ipv4 tos John W. Linville
2015-10-26  4:08           ` [PATCH v6 1/2] geneve: implement support for IPv6-based tunnels Jesse Gross
2015-10-26 21:01           ` [PATCH v7 1/3] " John W. Linville
2015-10-26 21:01             ` [PATCH v7 2/3] geneve: handle ipv6 priority like ipv4 tos John W. Linville
2015-10-30  3:11               ` David Miller
2015-10-26 21:01             ` [PATCH v7 3/3] geneve: add IPv6 bits to geneve_fill_metadata_dst John W. Linville
2015-10-27 12:48               ` Sergei Shtylyov
2015-10-27 13:49               ` [PATCH v8 " John W. Linville
2015-10-27 14:24                 ` Jesse Gross
2015-10-30  3:12                 ` David Miller
2015-10-30  3:11             ` [PATCH v7 1/3] geneve: implement support for IPv6-based tunnels David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445353866-32710-2-git-send-email-linville@tuxdriver.com \
    --to=linville@tuxdriver.com \
    --cc=davem@davemloft.net \
    --cc=jbenc@redhat.com \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).