Clean-up related to supporting priorities...mostly suggestions from Ben.
authorJustin Pettit <jpettit@nicira.com>
Sat, 26 Apr 2008 21:27:32 +0000 (14:27 -0700)
committerJustin Pettit <jpettit@nicira.com>
Sat, 26 Apr 2008 21:27:32 +0000 (14:27 -0700)
include/openflow.h
switch/table-linear.c
utilities/dpctl.c

index 836c03a43e620a8b793663baad3a9096ce5eca83..5c1a6e2d349a11073e614d28df94c15cb72791fd 100644 (file)
@@ -329,6 +329,9 @@ struct ofp_match {
 /* Value used in "max_idle" to indicate that the entry is permanent */
 #define OFP_FLOW_PERMANENT 0
 
+/* By default, choose a priority in the middle */
+#define OFP_DEFAULT_PRIORITY 0x8000
+
 /* Flow setup and teardown (controller -> datapath). */
 struct ofp_flow_mod {
     struct ofp_header header;
index 6da93a239152de960267e0bf918fe0eaac8b514a..dc1f7e70141b21a4c811b7c04b58f7453f283475 100644 (file)
@@ -87,10 +87,8 @@ static int table_linear_insert(struct sw_table *swt, struct sw_flow *flow)
     tl->n_flows++;
 
     /* Insert the entry immediately in front of where we're pointing. */
-    if (f)
-        list_push_back(&f->node, &flow->node);
-    else
-        list_push_back(&tl->flows, &flow->node);
+    list_push_back(&f->node, &flow->node);
+
     return 1;
 }
 
index c3fe8cd6c08310a8e5099cbad0617f355e1cb99a..4b3e03af70e1c8be05b519bdf0d980357baf9573 100644 (file)
@@ -487,6 +487,9 @@ str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
     if (table_idx) {
         *table_idx = 0xff;
     }
+    if (priority) {
+        *priority = OFP_DEFAULT_PRIORITY;
+    }
     memset(match, 0, sizeof *match);
     wildcards = OFPFW_ALL;
     for (name = strtok(string, "="), value = strtok(NULL, " \t\n");
@@ -589,7 +592,7 @@ static void do_add_flows(int argc, char *argv[])
     while (fgets(line, sizeof line, file)) {
         struct buffer *buffer;
         struct ofp_flow_mod *ofm;
-        uint16_t priority=0;
+        uint16_t priority;
         size_t size;
 
         char *comment;
@@ -608,12 +611,13 @@ static void do_add_flows(int argc, char *argv[])
         /* Parse and send. */
         size = sizeof *ofm + sizeof ofm->actions[0];
         ofm = alloc_openflow_buffer(size, OFPT_FLOW_MOD, &buffer);
+        str_to_flow(line, &ofm->match, &ofm->actions[0], NULL, &priority);
         ofm->command = htons(OFPFC_ADD);
         ofm->max_idle = htons(50);
         ofm->buffer_id = htonl(UINT32_MAX);
         ofm->group_id = htonl(0);
-        str_to_flow(line, &ofm->match, &ofm->actions[0], NULL, &priority);
         ofm->priority = htons(priority);
+        ofm->reserved = htonl(0);
 
         send_openflow_buffer(vconn, buffer);
     }
@@ -635,10 +639,11 @@ static void do_del_flows(int argc, char *argv[])
     size = sizeof *ofm;
     ofm = alloc_openflow_buffer(size, OFPT_FLOW_MOD, &buffer);
     ofm->command = htons(OFPFC_DELETE);
-    ofm->max_idle = 0;
+    ofm->max_idle = htons(0);
     ofm->buffer_id = htonl(UINT32_MAX);
-    ofm->group_id = 0;
-    ofm->priority = 0;
+    ofm->group_id = htonl(0);
+    ofm->priority = htons(0);
+    ofm->reserved = htonl(0);
     str_to_flow(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL, NULL);
 
     send_openflow_buffer(vconn, buffer);