tunnel: Treat in_key=0 the same as a missing in_key.
authorEthan Jackson <ethan@nicira.com>
Fri, 8 Feb 2013 02:39:24 +0000 (18:39 -0800)
committerEthan Jackson <ethan@nicira.com>
Fri, 8 Feb 2013 21:31:27 +0000 (13:31 -0800)
The documented behavior of ovs is that a missing key is the
same as a zero key.  However, the tunneling code actually treated
them differently.  This could cause problems with tunneling modes
such as vxlan which always have a key.  Specifically, a tunnel with
no key configured, would send have to send traffic with a key of
zero.  However, the same tunnel would drop incoming traffic with a
zero key because it was expecting there to be none at all.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto/tunnel.c

index d50cff8..5a4607e 100644 (file)
@@ -46,7 +46,6 @@ struct tnl_match {
     ovs_be32 ip_src;
     ovs_be32 ip_dst;
     uint32_t odp_port;
-    bool in_key_present;
     bool in_key_flow;
 };
 
@@ -95,7 +94,6 @@ tnl_port_add__(const struct ofport *ofport, uint32_t odp_port,
     tnl_port->match.in_key = cfg->in_key;
     tnl_port->match.ip_src = cfg->ip_src;
     tnl_port->match.ip_dst = cfg->ip_dst;
-    tnl_port->match.in_key_present = cfg->in_key_present;
     tnl_port->match.in_key_flow = cfg->in_key_flow;
     tnl_port->match.odp_port = odp_port;
 
@@ -185,7 +183,6 @@ tnl_port_receive(struct flow *flow)
     match.ip_src = flow->tunnel.ip_dst;
     match.ip_dst = flow->tunnel.ip_src;
     match.in_key = flow->tunnel.tun_id;
-    match.in_key_present = flow->tunnel.flags & FLOW_TNL_F_KEY;
 
     tnl_port = tnl_find(&match);
     if (!tnl_port) {
@@ -389,12 +386,10 @@ tnl_match_fmt(const struct tnl_match *match, struct ds *ds)
     ds_put_format(ds, IP_FMT"->"IP_FMT, IP_ARGS(match->ip_src),
                   IP_ARGS(match->ip_dst));
 
-    if (match->in_key_present) {
-        if (match->in_key_flow) {
-            ds_put_cstr(ds, ", key=flow");
-        } else {
-            ds_put_format(ds, ", key=%#"PRIx64, ntohll(match->in_key));
-        }
+    if (match->in_key_flow) {
+        ds_put_cstr(ds, ", key=flow");
+    } else {
+        ds_put_format(ds, ", key=%#"PRIx64, ntohll(match->in_key));
     }
 
     ds_put_format(ds, ", dp port=%"PRIu32, match->odp_port);