summaryrefslogtreecommitdiff
path: root/lib/learn.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-08-26 16:23:50 -0700
committerBen Pfaff <blp@nicira.com>2013-08-27 13:23:01 -0700
commit0fb88c18fb26dcbe353501d346ac03295d552b36 (patch)
tree00ac80cafd80d2e499b512b55ad0333990cc2779 /lib/learn.c
parent994c997345100f1868d8fbee508443475c556439 (diff)
downloadopenvswitch-0fb88c18fb26dcbe353501d346ac03295d552b36.tar.gz
ofp-util: Abstract flow_mod OFPFF_* flags.
The OFPFF_* flags used in flow_mods are just confusing enough that it seems worthwhile to try to abstract them out. In particular: * OFPFF_EMERG was introduced in OF1.0, deleted in OF1.1, and then its bit was reused for a different purpose in OF1.2. * OFPFF_RESET_COUNTS was introduced in OF1.2 but the semantics that it specifies are implied by "add" commands in earlier versions, so proper translation requires the OpenFlow version number and flow_mod command. This commit does the abstraction. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib/learn.c')
-rw-r--r--lib/learn.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/learn.c b/lib/learn.c
index 49d9efdba..68d95cbed 100644
--- a/lib/learn.c
+++ b/lib/learn.c
@@ -97,12 +97,23 @@ learn_from_openflow(const struct nx_action_learn *nal, struct ofpbuf *ofpacts)
learn->hard_timeout = ntohs(nal->hard_timeout);
learn->priority = ntohs(nal->priority);
learn->cookie = ntohll(nal->cookie);
- learn->flags = ntohs(nal->flags);
learn->table_id = nal->table_id;
learn->fin_idle_timeout = ntohs(nal->fin_idle_timeout);
learn->fin_hard_timeout = ntohs(nal->fin_hard_timeout);
- if (learn->flags & ~OFPFF_SEND_FLOW_REM || learn->table_id == 0xff) {
+ /* We only support "send-flow-removed" for now. */
+ switch (ntohs(nal->flags)) {
+ case 0:
+ learn->flags = 0;
+ break;
+ case OFPFF_SEND_FLOW_REM:
+ learn->flags = OFPUTIL_FF_SEND_FLOW_REM;
+ break;
+ default:
+ return OFPERR_OFPBAC_BAD_ARGUMENT;
+ }
+
+ if (learn->table_id == 0xff) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
}