connmgr: Do not use OFPRR_METER_DELETE before OF1.4
authorSimon Horman <horms@verge.net.au>
Thu, 12 Jun 2014 05:30:47 +0000 (14:30 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 12 Jun 2014 18:22:05 +0000 (11:22 -0700)
OFPRR_METER_DELETE was introduced in OF1.4 however meters were introduced
in OF1.3.

Regardless of the OF version when flows are deleted cause flows to be
deleted handle_delete_meter() calls delete_flows__() with
OFPRR_METER_DELETE as the reason.

In order to avoid sending OFPRR_METER_DELETE to controllers connected
using OF1.3 map OFPRR_METER_DELETE to OFPRR_DELETE which exists in that
version.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-util.c

index 03fc978..9c32c5a 100644 (file)
@@ -3148,6 +3148,11 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
                             enum ofputil_protocol protocol)
 {
     struct ofpbuf *msg;
+    enum ofp_flow_removed_reason reason = fr->reason;
+
+    if (reason == OFPRR_METER_DELETE && !(protocol & OFPUTIL_P_OF14_UP)) {
+        reason = OFPRR_DELETE;
+    }
 
     switch (protocol) {
     case OFPUTIL_P_OF11_STD:
@@ -3164,7 +3169,7 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
         ofr = ofpbuf_put_zeros(msg, sizeof *ofr);
         ofr->cookie = fr->cookie;
         ofr->priority = htons(fr->priority);
-        ofr->reason = fr->reason;
+        ofr->reason = reason;
         ofr->table_id = fr->table_id;
         ofr->duration_sec = htonl(fr->duration_sec);
         ofr->duration_nsec = htonl(fr->duration_nsec);
@@ -3186,7 +3191,7 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
         ofputil_match_to_ofp10_match(&fr->match, &ofr->match);
         ofr->cookie = fr->cookie;
         ofr->priority = htons(fr->priority);
-        ofr->reason = fr->reason;
+        ofr->reason = reason;
         ofr->duration_sec = htonl(fr->duration_sec);
         ofr->duration_nsec = htonl(fr->duration_nsec);
         ofr->idle_timeout = htons(fr->idle_timeout);
@@ -3208,7 +3213,7 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
         nfr = ofpbuf_l3(msg);
         nfr->cookie = fr->cookie;
         nfr->priority = htons(fr->priority);
-        nfr->reason = fr->reason;
+        nfr->reason = reason;
         nfr->table_id = fr->table_id + 1;
         nfr->duration_sec = htonl(fr->duration_sec);
         nfr->duration_nsec = htonl(fr->duration_nsec);