]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ofp-actions: Store cookie in network byte order in struct ofpact_learn.
authorBen Pfaff <blp@nicira.com>
Thu, 5 Jun 2014 22:27:31 +0000 (15:27 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 6 Jun 2014 20:54:47 +0000 (13:54 -0700)
Most other code in Open vSwitch that works with flow cookies keeps them
in network byte order.  Using network byte order in struct ofpact_learn,
also, reduces the number of byte order conversions needed across the
source tree.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
lib/learn.c
lib/ofp-actions.h

index ef9fab9937c328421d766e86eaf0692b7dc1f3b6..90991b16576b7656452f1b4b44a682348c76b9e7 100644 (file)
@@ -96,7 +96,7 @@ learn_from_openflow(const struct nx_action_learn *nal, struct ofpbuf *ofpacts)
     learn->idle_timeout = ntohs(nal->idle_timeout);
     learn->hard_timeout = ntohs(nal->hard_timeout);
     learn->priority = ntohs(nal->priority);
-    learn->cookie = ntohll(nal->cookie);
+    learn->cookie = nal->cookie;
     learn->table_id = nal->table_id;
     learn->fin_idle_timeout = ntohs(nal->fin_idle_timeout);
     learn->fin_hard_timeout = ntohs(nal->fin_hard_timeout);
@@ -262,7 +262,7 @@ learn_to_nxast(const struct ofpact_learn *learn, struct ofpbuf *openflow)
     nal->fin_idle_timeout = htons(learn->fin_idle_timeout);
     nal->fin_hard_timeout = htons(learn->fin_hard_timeout);
     nal->priority = htons(learn->priority);
-    nal->cookie = htonll(learn->cookie);
+    nal->cookie = learn->cookie;
     nal->flags = htons(learn->flags);
     nal->table_id = learn->table_id;
 
@@ -313,7 +313,7 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
     fm->priority = learn->priority;
     fm->cookie = htonll(0);
     fm->cookie_mask = htonll(0);
-    fm->new_cookie = htonll(learn->cookie);
+    fm->new_cookie = learn->cookie;
     fm->modify_cookie = fm->new_cookie != OVS_BE64_MAX;
     fm->table_id = learn->table_id;
     fm->command = OFPFC_MODIFY_STRICT;
@@ -579,7 +579,7 @@ learn_parse__(char *orig, char *arg, struct ofpbuf *ofpacts)
         } else if (!strcmp(name, "fin_hard_timeout")) {
             learn->fin_hard_timeout = atoi(value);
         } else if (!strcmp(name, "cookie")) {
-            learn->cookie = strtoull(value, NULL, 0);
+            learn->cookie = htonll(strtoull(value, NULL, 0));
         } else if (!strcmp(name, "send_flow_rem")) {
             learn->flags |= OFPFF_SEND_FLOW_REM;
         } else {
@@ -659,7 +659,7 @@ learn_format(const struct ofpact_learn *learn, struct ds *s)
         ds_put_cstr(s, ",send_flow_rem");
     }
     if (learn->cookie != 0) {
-        ds_put_format(s, ",cookie=%#"PRIx64, learn->cookie);
+        ds_put_format(s, ",cookie=%#"PRIx64, ntohll(learn->cookie));
     }
 
     for (spec = learn->specs; spec < &learn->specs[learn->n_specs]; spec++) {
index be1a0aa7e03c47ad98ab244d3850bd9de1744b6d..86522ab4d4d064b623a99e0365e003c79864a6b8 100644 (file)
@@ -481,7 +481,7 @@ struct ofpact_learn {
     uint16_t hard_timeout;      /* Max time before discarding (seconds). */
     uint16_t priority;          /* Priority level of flow entry. */
     uint8_t table_id;           /* Table to insert flow entry. */
-    uint64_t cookie;            /* Cookie for new flow. */
+    ovs_be64 cookie;            /* Cookie for new flow. */
     enum ofputil_flow_mod_flags flags;
     uint16_t fin_idle_timeout;  /* Idle timeout after FIN, if nonzero. */
     uint16_t fin_hard_timeout;  /* Hard timeout after FIN, if nonzero. */