netdev-linux: "Down" tap devices before setting hw addr.
[openvswitch] / lib / ofp-util.c
index 6ff9df894b72564f15693982d00a38aef96250e3..d4c240dae664b9307b2099a951d94937dffe7775 100644 (file)
@@ -1201,15 +1201,25 @@ ofputil_encode_hello(uint32_t allowed_versions)
  * connection if the switch processes the returned message correctly.  (If
  * '*next != want' then the caller will have to iterate.)
  *
- * If 'current == want', returns NULL and stores 'current' in '*next'. */
+ * If 'current == want', or if it is not possible to transition from 'current'
+ * to 'want' (because, for example, 'current' and 'want' use different OpenFlow
+ * protocol versions), returns NULL and stores 'current' in '*next'. */
 struct ofpbuf *
 ofputil_encode_set_protocol(enum ofputil_protocol current,
                             enum ofputil_protocol want,
                             enum ofputil_protocol *next)
 {
+    enum ofp_version cur_version, want_version;
     enum ofputil_protocol cur_base, want_base;
     bool cur_tid, want_tid;
 
+    cur_version = ofputil_protocol_to_ofp_version(current);
+    want_version = ofputil_protocol_to_ofp_version(want);
+    if (cur_version != want_version) {
+        *next = current;
+        return NULL;
+    }
+
     cur_base = ofputil_protocol_to_base(current);
     want_base = ofputil_protocol_to_base(want);
     if (cur_base != want_base) {
@@ -1223,7 +1233,9 @@ ofputil_encode_set_protocol(enum ofputil_protocol current,
             return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW10);
 
         case OFPUTIL_P_OF12_OXM:
-            return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW12);
+            /* There's only one OpenFlow 1.2 protocol and we already verified
+             * above that we're not trying to change versions. */
+            NOT_REACHED();
 
         case OFPUTIL_P_OF10_STD_TID:
         case OFPUTIL_P_OF10_NXM_TID:
@@ -1273,9 +1285,6 @@ ofputil_nx_flow_format_to_protocol(enum nx_flow_format flow_format)
     case NXFF_NXM:
         return OFPUTIL_P_OF10_NXM;
 
-    case NXFF_OPENFLOW12:
-        return OFPUTIL_P_OF12_OXM;
-
     default:
         return 0;
     }
@@ -1298,8 +1307,6 @@ ofputil_nx_flow_format_to_string(enum nx_flow_format flow_format)
         return "openflow10";
     case NXFF_NXM:
         return "nxm";
-    case NXFF_OPENFLOW12:
-        return "openflow12";
     default:
         NOT_REACHED();
     }