]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovn-controller: Fix match crieria for dynamic mac binding flows
authorChandra S Vejendla <csvejend@us.ibm.com>
Fri, 9 Sep 2016 04:31:54 +0000 (23:31 -0500)
committerBen Pfaff <blp@ovn.org>
Fri, 9 Sep 2016 15:38:39 +0000 (08:38 -0700)
match struct is not initialized before adding flows for each entry in
mac_bindings table.  The matches for IPv4 and IPv6 entries don't have
exactly the same form (IPv4 uses reg0, IPv6 uses xxreg0), so reusing
a match structure can cause problems.

Signed-off-by: Chandra Sekhar Vejendla <csvejend@us.ibm.com>
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
Co-authored-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ovn/controller/lflow.c

index efac5b3b7b73b66feb531466d281040c6c48f8ec..041462612448c469b906eaf72347a808a3a60195 100644 (file)
@@ -343,8 +343,6 @@ put_load(const uint8_t *data, size_t len,
 static void
 consider_neighbor_flow(const struct lport_index *lports,
                        const struct sbrec_mac_binding *b,
-                       struct ofpbuf *ofpacts_p,
-                       struct match *match_p,
                        struct hmap *flow_table)
 {
     const struct sbrec_port_binding *pb
@@ -360,7 +358,7 @@ consider_neighbor_flow(const struct lport_index *lports,
         return;
     }
 
-
+    struct match match = MATCH_CATCHALL_INITIALIZER;
     if (strchr(b->ip, '.')) {
         ovs_be32 ip;
         if (!ip_parse(b->ip, &ip)) {
@@ -368,7 +366,7 @@ consider_neighbor_flow(const struct lport_index *lports,
             VLOG_WARN_RL(&rl, "bad 'ip' %s", b->ip);
             return;
         }
-        match_set_reg(match_p, 0, ntohl(ip));
+        match_set_reg(&match, 0, ntohl(ip));
     } else {
         struct in6_addr ip6;
         if (!ipv6_parse(b->ip, &ip6)) {
@@ -378,16 +376,17 @@ consider_neighbor_flow(const struct lport_index *lports,
         }
         ovs_be128 value;
         memcpy(&value, &ip6, sizeof(value));
-        match_set_xxreg(match_p, 0, ntoh128(value));
+        match_set_xxreg(&match, 0, ntoh128(value));
     }
 
-    match_set_metadata(match_p, htonll(pb->datapath->tunnel_key));
-    match_set_reg(match_p, MFF_LOG_OUTPORT - MFF_REG0, pb->tunnel_key);
-
-    ofpbuf_clear(ofpacts_p);
-    put_load(mac.ea, sizeof mac.ea, MFF_ETH_DST, 0, 48, ofpacts_p);
+    match_set_metadata(&match, htonll(pb->datapath->tunnel_key));
+    match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, pb->tunnel_key);
 
-    ofctrl_add_flow(flow_table, OFTABLE_MAC_BINDING, 100, match_p, ofpacts_p);
+    uint64_t stub[1024 / 8];
+    struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(stub);
+    put_load(mac.ea, sizeof mac.ea, MFF_ETH_DST, 0, 48, &ofpacts);
+    ofctrl_add_flow(flow_table, OFTABLE_MAC_BINDING, 100, &match, &ofpacts);
+    ofpbuf_uninit(&ofpacts);
 }
 
 /* Adds an OpenFlow flow to flow tables for each MAC binding in the OVN
@@ -398,17 +397,10 @@ add_neighbor_flows(struct controller_ctx *ctx,
                    const struct lport_index *lports,
                    struct hmap *flow_table)
 {
-    struct ofpbuf ofpacts;
-    struct match match;
-    match_init_catchall(&match);
-    ofpbuf_init(&ofpacts, 0);
-
     const struct sbrec_mac_binding *b;
     SBREC_MAC_BINDING_FOR_EACH (b, ctx->ovnsb_idl) {
-        consider_neighbor_flow(lports, b, &ofpacts, &match, flow_table);
+        consider_neighbor_flow(lports, b, flow_table);
     }
-
-    ofpbuf_uninit(&ofpacts);
 }
 \f
 /* Translates logical flows in the Logical_Flow table in the OVN_SB database