From: Ben Pfaff Date: Thu, 5 Jun 2014 22:27:31 +0000 (-0700) Subject: ofp-actions: Store cookie in network byte order in struct ofpact_learn. X-Git-Tag: v2.12.3~8824 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=80771642ad7d3627eb691775e7ed6f7d0b29e237;p=mirror_ovs.git ofp-actions: Store cookie in network byte order in struct ofpact_learn. 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 Acked-by: Thomas Graf --- diff --git a/lib/learn.c b/lib/learn.c index ef9fab993..90991b165 100644 --- a/lib/learn.c +++ b/lib/learn.c @@ -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++) { diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h index be1a0aa7e..86522ab4d 100644 --- a/lib/ofp-actions.h +++ b/lib/ofp-actions.h @@ -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. */