datapath: Return EEXIST on overlapping new flow request
authorAndy Zhou <azhou@nicira.com>
Thu, 20 Jun 2013 23:36:04 +0000 (16:36 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 21 Jun 2013 00:43:42 +0000 (17:43 -0700)
Flow update still requires unmasked key to match. If not,
return EINVAL.

CC: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath/datapath.c

index 41899fa..9ee29a7 100644 (file)
@@ -1342,12 +1342,6 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                /* We found a matching flow. */
                struct sw_flow_actions *old_acts;
 
-               /* Make sure the it has the same unmasked key. */
-               if (!ovs_flow_cmp_unmasked_key(flow, &key, match.range.end)) {
-                       error = -EINVAL;
-                       goto err_unlock_ovs;
-               }
-
                /* Bail out if we're not allowed to modify an existing flow.
                 * We accept NLM_F_CREATE in place of the intended NLM_F_EXCL
                 * because Generic Netlink treats the latter as a dump
@@ -1359,6 +1353,11 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                    info->nlhdr->nlmsg_flags & (NLM_F_CREATE | NLM_F_EXCL))
                        goto err_unlock_ovs;
 
+               /* The unmasked key has to be the same for flow updates. */
+               error = -EINVAL;
+               if (!ovs_flow_cmp_unmasked_key(flow, &key, match.range.end))
+                       goto err_unlock_ovs;
+
                /* Update actions. */
                old_acts = ovsl_dereference(flow->sf_acts);
                rcu_assign_pointer(flow->sf_acts, acts);