[ovs-dev] [PATCH] datapath: Fix zero key tunnels.

Pravin B Shelar pshelar at nicira.com
Wed Oct 24 01:42:32 UTC 2012


Datapath tunneling check for flag OVS_FLOW_TNL_F_KEY is failing,
causing it to drop packet. This only happens on tunnels with
zero key as vswitchd does not generate set-tunnel action. Set
tunnel action sets this flags for given action. To fix this issue
the check is dropped.

Bug #13666

Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
---
 datapath/actions.c      |    1 -
 datapath/vport-capwap.c |   24 ++++++------------------
 datapath/vport-gre.c    |   25 ++++++-------------------
 3 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/datapath/actions.c b/datapath/actions.c
index 972f7a2..4649c05 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -357,7 +357,6 @@ static int execute_set_action(struct sk_buff *skb,
 		}
 
 		OVS_CB(skb)->tun_key->tun_id = nla_get_be64(nested_attr);
-		OVS_CB(skb)->tun_key->tun_flags |= OVS_FLOW_TNL_F_KEY;
 		break;
 
 	case OVS_KEY_ATTR_IPV4_TUNNEL:
diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c
index 8a63416..39aec42 100644
--- a/datapath/vport-capwap.c
+++ b/datapath/vport-capwap.c
@@ -155,7 +155,7 @@ static struct inet_frags frag_state = {
 	.secret_interval = CAPWAP_FRAG_SECRET_INTERVAL,
 };
 
-static int get_capwap_param(const struct tnl_mutable_config *mutable,
+static void get_capwap_param(const struct tnl_mutable_config *mutable,
 			const struct ovs_key_ipv4_tunnel *tun_key,
 			u32 *flags,  __be64 *out_key)
 {
@@ -169,18 +169,12 @@ static int get_capwap_param(const struct tnl_mutable_config *mutable,
 		*out_key = tun_key->tun_id;
 	} else {
 		*flags = mutable->flags;
-		if (mutable->flags & TNL_F_OUT_KEY_ACTION) {
-			if (likely(tun_key->tun_flags & OVS_FLOW_TNL_F_KEY)) {
-				*out_key = tun_key->tun_id;
-			} else {
-				*out_key = 0;
-				return -EINVAL;
-			}
-		} else
+		if (mutable->flags & TNL_F_OUT_KEY_ACTION)
+			*out_key = tun_key->tun_id;
+		else
 			*out_key = mutable->out_key;
 
 	}
-	return 0;
 }
 
 static int capwap_hdr_len(const struct tnl_mutable_config *mutable,
@@ -189,11 +183,8 @@ static int capwap_hdr_len(const struct tnl_mutable_config *mutable,
 	int size = CAPWAP_MIN_HLEN;
 	u32 flags;
 	__be64 out_key;
-	int err;
 
-	err = get_capwap_param(mutable, tun_key, &flags, &out_key);
-	if (err)
-		return err;
+	get_capwap_param(mutable, tun_key, &flags, &out_key);
 
 	/* CAPWAP has no checksums. */
 	if (flags & TNL_F_CSUM)
@@ -259,10 +250,7 @@ static struct sk_buff *capwap_update_header(const struct vport *vport,
 	u32 flags;
 	__be64 out_key;
 
-	if (get_capwap_param(mutable, tun_key, &flags, &out_key)) {
-		kfree_skb(skb);
-		return NULL;
-	}
+	get_capwap_param(mutable, tun_key, &flags, &out_key);
 
 	if (flags & TNL_F_OUT_KEY_ACTION) {
 		/* first field in WSI is key */
diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index a25da02..d02d4ec 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -45,7 +45,7 @@ struct gre_base_hdr {
 	__be16 protocol;
 };
 
-static int get_gre_param(const struct tnl_mutable_config *mutable,
+static void get_gre_param(const struct tnl_mutable_config *mutable,
 			const struct ovs_key_ipv4_tunnel *tun_key,
 			u32 *flags, u32 *tunnel_type, __be64 *out_key)
 {
@@ -61,18 +61,12 @@ static int get_gre_param(const struct tnl_mutable_config *mutable,
 	} else {
 		*flags = mutable->flags;
 		*tunnel_type = mutable->key.tunnel_type;
-		if (mutable->flags & TNL_F_OUT_KEY_ACTION) {
-			if (likely(tun_key->tun_flags & OVS_FLOW_TNL_F_KEY)) {
-				*out_key = tun_key->tun_id;
-			} else {
-				*out_key = 0;
-				return -EINVAL;
-			}
-		} else
+		if (mutable->flags & TNL_F_OUT_KEY_ACTION)
+			*out_key = tun_key->tun_id;
+		else
 			*out_key = mutable->out_key;
 
 	}
-	return 0;
 }
 
 static int gre_hdr_len(const struct tnl_mutable_config *mutable,
@@ -82,12 +76,8 @@ static int gre_hdr_len(const struct tnl_mutable_config *mutable,
 	u32 flags;
 	u32 tunnel_type;
 	__be64 out_key;
-	int err;
-
-	err = get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key);
-	if (err)
-		return err;
 
+	get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key);
 	len = GRE_HEADER_SECTION;
 
 	if (flags & TNL_F_CSUM)
@@ -177,10 +167,7 @@ static struct sk_buff *gre_update_header(const struct vport *vport,
 	__be32 *options = (__be32 *)(skb_network_header(skb) + tunnel_hlen
 					       - GRE_HEADER_SECTION);
 
-	if (get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key)) {
-		kfree_skb(skb);
-		return NULL;
-	}
+	get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key);
 
 	/* Work backwards over the options so the checksum is last. */
 	if (flags & TNL_F_OUT_KEY_ACTION) {
-- 
1.7.10




More information about the dev mailing list