Treat flows without any wildcards as maximum priority.
authorBen Pfaff <blp@nicira.com>
Wed, 7 May 2008 22:21:30 +0000 (15:21 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 7 May 2008 22:23:45 +0000 (15:23 -0700)
Otherwise, we give the table implementations the opportunity to screw up
by distinguishing between two flows without wildcards but with apparently
different priorities that are required to be treated as the same priority.

datapath/forward.c
switch/datapath.c

index 929703fbbc4a48aea06e8f6914a9fbe2d9b0cab6..2c5410eaddc4a7ea8d5e42e6b9f3debbf772d0a7 100644 (file)
@@ -373,7 +373,7 @@ add_flow(struct sw_chain *chain, const struct ofp_flow_mod *ofm)
        /* Fill out flow. */
        flow_extract_match(&flow->key, &ofm->match);
        flow->max_idle = ntohs(ofm->max_idle);
-       flow->priority = ntohs(ofm->priority);
+       flow->priority = flow->key.wildcards ? ntohs(ofm->priority) : -1;
        flow->timeout = jiffies + flow->max_idle * HZ;
        flow->n_actions = n_acts;
        flow->init_time = jiffies;
@@ -424,8 +424,10 @@ recv_flow(struct sw_chain *chain, const struct sender *sender, const void *msg)
                return chain_delete(chain, &key, 0, 0) ? 0 : -ESRCH;
        } else if (command == OFPFC_DELETE_STRICT) {
                struct sw_flow_key key;
+               uint16_t priority;
                flow_extract_match(&key, &ofm->match);
-               return chain_delete(chain, &key, ntohs(ofm->priority), 1) ? 0 : -ESRCH;
+               priority = key.wildcards ? ntohs(ofm->priority) : -1;
+               return chain_delete(chain, &key, priority, 1) ? 0 : -ESRCH;
        } else {
                return -ENOTSUPP;
        }
index e02f418d5c97b720a153fec4ad59be4a17f6f646..5e51ca3c08d51317739e6ccb41ac5fed472b56e1 100644 (file)
@@ -1071,7 +1071,7 @@ add_flow(struct datapath *dp, const struct ofp_flow_mod *ofm)
     /* Fill out flow. */
     flow_extract_match(&flow->key, &ofm->match);
     flow->max_idle = ntohs(ofm->max_idle);
-    flow->priority = ntohs(ofm->priority);
+    flow->priority = flow->key.wildcards ? ntohs(ofm->priority) : -1;
     flow->timeout = time(0) + flow->max_idle; /* FIXME */
     flow->n_actions = n_acts;
     flow->created = time(0);    /* FIXME */
@@ -1122,9 +1122,10 @@ recv_flow(struct datapath *dp, const struct sender *sender UNUSED,
         return chain_delete(dp->chain, &key, 0, 0) ? 0 : -ESRCH;
     } else if (command == OFPFC_DELETE_STRICT) {
         struct sw_flow_key key;
+        uint16_t priority;
         flow_extract_match(&key, &ofm->match);
-        return chain_delete(dp->chain, &key, 
-                    ntohs(ofm->priority), 1) ? 0 : -ESRCH;
+        priority = key.wildcards ? ntohs(ofm->priority) : -1;
+        return chain_delete(dp->chain, &key, priority, 1) ? 0 : -ESRCH;
     } else {
         return -ENODEV;
     }