[ovs-dev] [PATCH 2/2] datapath: Fix Tunnel options ToS

Pravin B Shelar pshelar at nicira.com
Wed May 9 01:27:33 UTC 2012


Use DSCP bits from ToS set on tunnel.

Signed-off-by: Pravin B Shelar <pshelar at nicira.com>

Bug #8822
---
 datapath/tunnel.c    |   14 ++++++++------
 vswitchd/vswitch.xml |    3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index c2133bb..74d99d9 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -1002,12 +1002,15 @@ unlock:
 static struct rtable *__find_route(const struct tnl_mutable_config *mutable,
 				   u8 ipproto, u8 tos)
 {
+	/* Tunnel configuration keeps DSCP part of TOS bits, But Linux
+ 	 * router expect RT_TOS bits only. */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
 	struct flowi fl = { .nl_u = { .ip4_u = {
 					.daddr = mutable->key.daddr,
 					.saddr = mutable->key.saddr,
-					.tos = tos } },
-			    .proto = ipproto };
+					.tos   = RT_TOS(tos) } },
+					.proto = ipproto };
 	struct rtable *rt;
 
 	if (unlikely(ip_route_output_key(port_key_get_net(&mutable->key), &rt, &fl)))
@@ -1017,7 +1020,7 @@ static struct rtable *__find_route(const struct tnl_mutable_config *mutable,
 #else
 	struct flowi4 fl = { .daddr = mutable->key.daddr,
 			     .saddr = mutable->key.saddr,
-			     .flowi4_tos = tos,
+			     .flowi4_tos = RT_TOS(tos),
 			     .flowi4_proto = ipproto };
 
 	return ip_route_output_key(port_key_get_net(&mutable->key), &fl);
@@ -1032,7 +1035,6 @@ static struct rtable *find_route(struct vport *vport,
 	struct tnl_cache *cur_cache = rcu_dereference(tnl_vport->cache);
 
 	*cache = NULL;
-	tos = RT_TOS(tos);
 
 	if (likely(tos == mutable->tos &&
 	    check_cache_valid(cur_cache, mutable))) {
@@ -1040,7 +1042,6 @@ static struct rtable *find_route(struct vport *vport,
 		return cur_cache->rt;
 	} else {
 		struct rtable *rt;
-
 		rt = __find_route(mutable, tnl_vport->tnl_ops->ipproto, tos);
 		if (IS_ERR(rt))
 			return NULL;
@@ -1402,7 +1403,8 @@ static int tnl_set_config(struct net *net, struct nlattr *options,
 
 	if (a[OVS_TUNNEL_ATTR_TOS]) {
 		mutable->tos = nla_get_u8(a[OVS_TUNNEL_ATTR_TOS]);
-		if (mutable->tos != RT_TOS(mutable->tos))
+		/* Check if ECN bits are zero. */
+		if (!INET_ECN_is_not_ect(mutable->tos))
 			return -EINVAL;
 	}
 
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index b9b7b97..25d5fce 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -1258,7 +1258,8 @@
 
       <column name="options" key="tos">
         Optional.  The value of the ToS bits to be set on the encapsulating
-        packet.  It may also be the word <code>inherit</code>, in which case
+        packet.  ToS is interpreted as DSCP and ECN bits, ECN part must be
+        zero.  It may also be the word \fBinherit\fR, in which case
         the ToS will be copied from the inner packet if it is IPv4 or IPv6
         (otherwise it will be 0).  The ECN fields are always inherited.
         Default is 0.
-- 
1.7.10




More information about the dev mailing list