[ovs-dev] [PATCH 09/18] connmgr: Use version of underlying rconn

Simon Horman horms at verge.net.au
Fri Oct 26 02:35:57 UTC 2012


Signed-off-by: Simon Horman <horms at verge.net.au>
---
 lib/ofp-util.c    |   14 ++++++++++++--
 lib/ofp-util.h    |    2 ++
 ofproto/connmgr.c |    9 ++++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index bf453e2..3c85185 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -624,9 +624,10 @@ ofputil_protocol_to_ofp_version(enum ofputil_protocol protocol)
         return OFP10_VERSION;
     case OFPUTIL_P_OF12:
         return OFP12_VERSION;
+    case OFPUTIL_P_NONE:
+    default:
+        NOT_REACHED();
     }
-
-    NOT_REACHED();
 }
 
 /* Returns true if 'protocol' is a single OFPUTIL_P_* value, false
@@ -662,6 +663,7 @@ ofputil_protocol_set_tid(enum ofputil_protocol protocol, bool enable)
     case OFPUTIL_P_OF12:
         return OFPUTIL_P_OF12;
 
+    case OFPUTIL_P_NONE:
     default:
         NOT_REACHED();
     }
@@ -696,6 +698,7 @@ ofputil_protocol_set_base(enum ofputil_protocol cur,
     case OFPUTIL_P_OF12:
         return ofputil_protocol_set_tid(OFPUTIL_P_OF12, tid);
 
+    case OFPUTIL_P_NONE:
     default:
         NOT_REACHED();
     }
@@ -726,6 +729,9 @@ ofputil_protocol_to_string(enum ofputil_protocol protocol)
 
     case OFPUTIL_P_OF12:
         return "OpenFlow12";
+
+    case OFPUTIL_P_NONE:
+        NOT_REACHED();
     }
 
     /* Check abbreviations. */
@@ -1284,6 +1290,7 @@ ofputil_encode_set_protocol(enum ofputil_protocol current,
 
         case OFPUTIL_P_OF10_TID:
         case OFPUTIL_P_NXM_TID:
+        case OFPUTIL_P_NONE:
             NOT_REACHED();
         }
     }
@@ -1625,6 +1632,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
         break;
     }
 
+    case OFPUTIL_P_NONE:
     default:
         NOT_REACHED();
     }
@@ -1829,6 +1837,7 @@ ofputil_encode_flow_stats_request(const struct ofputil_flow_stats_request *fsr,
         break;
     }
 
+    case OFPUTIL_P_NONE:
     default:
         NOT_REACHED();
     }
@@ -2323,6 +2332,7 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
         break;
     }
 
+    case OFPUTIL_P_NONE:
     default:
         NOT_REACHED();
     }
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 87fe25d..1c3b92a 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -58,6 +58,8 @@ int ofputil_netmask_to_wcbits(ovs_be32 netmask);
  * to implement set union and intersection.
  */
 enum ofputil_protocol {
+    OFPUTIL_P_NONE     = 0,
+
     /* OpenFlow 1.0-based protocols. */
     OFPUTIL_P_OF10     = 1 << 0, /* OpenFlow 1.0 flow format. */
     OFPUTIL_P_OF10_TID = 1 << 1, /* OF1.0 + flow_mod_table_id extension. */
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index d64c7b4..e6fd400 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1036,7 +1036,7 @@ ofconn_flush(struct ofconn *ofconn)
     int i;
 
     ofconn->role = NX_ROLE_OTHER;
-    ofconn->protocol = OFPUTIL_P_OF10;
+    ofconn->protocol = OFPUTIL_P_NONE;
     ofconn->packet_in_format = NXPIF_OPENFLOW10;
 
     /* Disassociate 'ofconn' from all of the ofopgroups that it initiated that
@@ -1183,6 +1183,13 @@ ofconn_run(struct ofconn *ofconn,
             of_msg = (ofconn->blocked
                       ? ofconn->blocked
                       : rconn_recv(ofconn->rconn));
+            if (ofconn_get_protocol(ofconn) == OFPUTIL_P_NONE) {
+                int version = rconn_get_version(ofconn->rconn);
+                if (version > 0) {
+                    ofconn_set_protocol(ofconn,
+                                ofputil_protocol_from_ofp_version(version));
+                }
+            }
             if (!of_msg) {
                 break;
             }
-- 
1.7.10.4




More information about the dev mailing list