[ovs-dev] [OpenFlow 0.9 7/7] ofproto: Use 64-bit datapath id and management id (OpenFlow 0.9)

Justin Pettit jpettit at nicira.com
Thu Nov 19 08:00:41 UTC 2009


The length of a datapath was changed from 48 bits to 64 bits in OpenFlow
0.9.  For parity, we increased the management id size to match.

NOTE: This is the final commit in the OpenFlow 0.9 set.  Starting with
this commit, OVS is OpenFlow 0.9-compliant.
---
 include/openflow/openflow.h     |    5 +++--
 lib/cfg.c                       |    4 ++--
 lib/learning-switch.c           |   24 ++++++++++++------------
 lib/ofp-print.c                 |    2 +-
 ofproto/ofproto.c               |    4 ++--
 ofproto/status.c                |    2 +-
 utilities/ovs-openflowd.8.in    |    4 ++--
 utilities/ovs-openflowd.c       |   16 ++++++++--------
 vswitchd/ovs-vswitchd.conf.5.in |   11 ++++++-----
 9 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h
index f32fdfa..a94fa79 100644
--- a/include/openflow/openflow.h
+++ b/include/openflow/openflow.h
@@ -229,8 +229,9 @@ OFP_ASSERT(sizeof(struct ofp_phy_port) == 48);
 /* Switch features. */
 struct ofp_switch_features {
     struct ofp_header header;
-    uint64_t datapath_id;   /* Datapath unique ID.  Only the lower 48-bits
-                               are meaningful. */
+    uint64_t datapath_id;   /* Datapath unique ID.  The lower 48-bits are for 
+                               a MAC address, while the upper 16-bits are
+                               implementer-defined. */
 
     uint32_t n_buffers;     /* Max packets buffered at once. */
 
diff --git a/lib/cfg.c b/lib/cfg.c
index d0170b6..ed36a88 100644
--- a/lib/cfg.c
+++ b/lib/cfg.c
@@ -834,7 +834,7 @@ cfg_get_mac(int idx, const char *key_, ...)
 
 /* Returns the value numbered 'idx' of 'key', parsed as an datapath ID.
  * Returns 0 if 'idx' is greater than or equal to cfg_count(key) or if the
- * value 'idx' of 'key' is not a valid datapath ID consisting of exactly 12
+ * value 'idx' of 'key' is not a valid datapath ID consisting of exactly 16
  * hexadecimal digits.  */
 uint64_t
 cfg_get_dpid(int idx, const char *key_, ...)
@@ -1134,7 +1134,7 @@ parse_mac(const char *s, uint8_t mac[6])
 static bool
 parse_dpid(const char *s, uint64_t *dpid)
 {
-    if (strlen(s) == 12 && strspn(s, "0123456789abcdefABCDEF") == 12) {
+    if (strlen(s) == 16 && strspn(s, "0123456789abcdefABCDEF") == 16) {
         *dpid = strtoll(s, NULL, 16);
         return true;
     } else {
diff --git a/lib/learning-switch.c b/lib/learning-switch.c
index 9c60e2e..9db0e8b 100644
--- a/lib/learning-switch.c
+++ b/lib/learning-switch.c
@@ -151,7 +151,7 @@ lswitch_run(struct lswitch *sw, struct rconn *rconn)
     /* If we're waiting for more replies, keeping waiting for up to 10 s. */
     if (sw->last_reply != LLONG_MIN) {
         if (now - sw->last_reply > 10000) {
-            VLOG_ERR_RL(&rl, "%012llx: No more flow stat replies last 10 s",
+            VLOG_ERR_RL(&rl, "%016llx: No more flow stat replies last 10 s",
                         sw->datapath_id);
             sw->last_reply = LLONG_MIN;
             sw->last_query = LLONG_MIN;
@@ -164,7 +164,7 @@ lswitch_run(struct lswitch *sw, struct rconn *rconn)
     /* If we're waiting for any reply at all, keep waiting for up to 10 s. */
     if (sw->last_query != LLONG_MIN) {
         if (now - sw->last_query > 10000) {
-            VLOG_ERR_RL(&rl, "%012llx: No flow stat replies in last 10 s",
+            VLOG_ERR_RL(&rl, "%016llx: No flow stat replies in last 10 s",
                         sw->datapath_id);
             sw->last_query = LLONG_MIN;
             schedule_query(sw, 0);
@@ -184,7 +184,7 @@ lswitch_run(struct lswitch *sw, struct rconn *rconn)
             struct ofpbuf *b;
             int error;
 
-            VLOG_DBG("%012llx: Sending flow stats request to implement STP",
+            VLOG_DBG("%016llx: Sending flow stats request to implement STP",
                      sw->datapath_id);
 
             sw->last_query = now;
@@ -203,7 +203,7 @@ lswitch_run(struct lswitch *sw, struct rconn *rconn)
 
             error = rconn_send(rconn, b, NULL);
             if (error) {
-                VLOG_WARN_RL(&rl, "%012llx: sending flow stats request "
+                VLOG_WARN_RL(&rl, "%016llx: sending flow stats request "
                              "failed: %s", sw->datapath_id, strerror(error));
                 ofpbuf_delete(b);
                 schedule_query(sw, 1000);
@@ -298,7 +298,7 @@ lswitch_process_packet(struct lswitch *sw, struct rconn *rconn,
     for (p = processors; p < &processors[n_processors]; p++) {
         if (oh->type == p->type) {
             if (msg->size < p->min_size) {
-                VLOG_WARN_RL(&rl, "%012llx: %s: too short (%zu bytes) for "
+                VLOG_WARN_RL(&rl, "%016llx: %s: too short (%zu bytes) for "
                              "type %"PRIu8" (min %zu)", sw->datapath_id,
                              rconn_get_name(rconn), msg->size, oh->type,
                              p->min_size);
@@ -312,7 +312,7 @@ lswitch_process_packet(struct lswitch *sw, struct rconn *rconn,
     }
     if (VLOG_IS_DBG_ENABLED()) {
         char *p = ofp_to_string(msg->data, msg->size, 2);
-        VLOG_DBG_RL(&rl, "%012llx: OpenFlow packet ignored: %s",
+        VLOG_DBG_RL(&rl, "%016llx: OpenFlow packet ignored: %s",
                     sw->datapath_id, p);
         free(p);
     }
@@ -345,10 +345,10 @@ queue_tx(struct lswitch *sw, struct rconn *rconn, struct ofpbuf *b)
     int retval = rconn_send_with_limit(rconn, b, sw->queued, 10);
     if (retval && retval != ENOTCONN) {
         if (retval == EAGAIN) {
-            VLOG_INFO_RL(&rl, "%012llx: %s: tx queue overflow",
+            VLOG_INFO_RL(&rl, "%016llx: %s: tx queue overflow",
                          sw->datapath_id, rconn_get_name(rconn));
         } else {
-            VLOG_WARN_RL(&rl, "%012llx: %s: send: %s",
+            VLOG_WARN_RL(&rl, "%016llx: %s: send: %s",
                          sw->datapath_id, rconn_get_name(rconn),
                          strerror(retval));
         }
@@ -403,7 +403,7 @@ process_packet_in(struct lswitch *sw, struct rconn *rconn, void *opi_)
 
     if (may_learn(sw, in_port) && sw->ml) {
         if (mac_learning_learn(sw->ml, flow.dl_src, 0, in_port)) {
-            VLOG_DBG_RL(&rl, "%012llx: learned that "ETH_ADDR_FMT" is on "
+            VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
                         "port %"PRIu16, sw->datapath_id,
                         ETH_ADDR_ARGS(flow.dl_src), in_port);
         }
@@ -578,12 +578,12 @@ process_flow_stats(struct lswitch *sw, struct rconn *rconn,
         for (a = ofs->actions; (char *) a < end; a += len / 8) {
             len = ntohs(a->len);
             if (len > end - (char *) a) {
-                VLOG_DBG_RL(&rl, "%012llx: action exceeds available space "
+                VLOG_DBG_RL(&rl, "%016llx: action exceeds available space "
                             "(%zu > %td)",
                             sw->datapath_id, len, end - (char *) a);
                 break;
             } else if (len % 8) {
-                VLOG_DBG_RL(&rl, "%012llx: action length (%zu) not multiple "
+                VLOG_DBG_RL(&rl, "%016llx: action length (%zu) not multiple "
                             "of 8 bytes", sw->datapath_id, len);
                 break;
             }
@@ -629,7 +629,7 @@ process_stats_reply(struct lswitch *sw, struct rconn *rconn, void *osr_)
         process_flow_stats(sw, rconn, fs);
     }
     if (!(osr->flags & htons(OFPSF_REPLY_MORE))) {
-        VLOG_DBG("%012llx: Deleted %d of %d received flows to "
+        VLOG_DBG("%016llx: Deleted %d of %d received flows to "
                  "implement STP, %d because of no-recv, %d because of "
                  "no-send", sw->datapath_id,
                  sw->n_no_recv + sw->n_no_send, sw->n_flows,
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 55bb3e4..ba017f7 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -552,7 +552,7 @@ ofp_print_switch_features(struct ds *string, const void *oh, size_t len,
     int n_ports;
     int i;
 
-    ds_put_format(string, " ver:0x%x, dpid:%"PRIx64"\n", 
+    ds_put_format(string, " ver:0x%x, dpid:%016"PRIx64"\n", 
             osf->header.version, ntohll(osf->datapath_id));
     ds_put_format(string, "n_tables:%d, n_buffers:%d\n", osf->n_tables,
             ntohl(osf->n_buffers));
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index bcffc42..25804dc 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -360,7 +360,7 @@ ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux,
 
     /* Pick final datapath ID. */
     p->datapath_id = pick_datapath_id(p);
-    VLOG_INFO("using datapath ID %012"PRIx64, p->datapath_id);
+    VLOG_INFO("using datapath ID %016"PRIx64, p->datapath_id);
 
     *ofprotop = p;
     return 0;
@@ -372,7 +372,7 @@ ofproto_set_datapath_id(struct ofproto *p, uint64_t datapath_id)
     uint64_t old_dpid = p->datapath_id;
     p->datapath_id = datapath_id ? datapath_id : pick_datapath_id(p);
     if (p->datapath_id != old_dpid) {
-        VLOG_INFO("datapath ID changed to %012"PRIx64, p->datapath_id);
+        VLOG_INFO("datapath ID changed to %016"PRIx64, p->datapath_id);
         rconn_reconnect(p->controller->rconn);
     }
 }
diff --git a/ofproto/status.c b/ofproto/status.c
index b2cb935..dacd520 100644
--- a/ofproto/status.c
+++ b/ofproto/status.c
@@ -137,7 +137,7 @@ config_status_cb(struct status_reply *sr, void *ofproto_)
 
     datapath_id = ofproto_get_datapath_id(ofproto);
     if (datapath_id) {
-        status_reply_put(sr, "datapath-id=%"PRIx64, datapath_id);
+        status_reply_put(sr, "datapath-id=%016"PRIx64, datapath_id);
     }
 
     mgmt_id = ofproto_get_mgmt_id(ofproto);
diff --git a/utilities/ovs-openflowd.8.in b/utilities/ovs-openflowd.8.in
index 312e7f7..d4fff8d 100644
--- a/utilities/ovs-openflowd.8.in
+++ b/utilities/ovs-openflowd.8.in
@@ -210,13 +210,13 @@ When controller discovery is not performed, this option has no effect.
 .SS "Networking Options"
 .TP
 \fB--datapath-id=\fIdpid\fR
-Sets \fIdpid\fR, which must consist of exactly 12 hexadecimal digits,
+Sets \fIdpid\fR, which must consist of exactly 16 hexadecimal digits,
 as the datapath ID that the switch will use to identify itself to the
 OpenFlow controller.
 
 If this option is omitted, the default datapath ID is taken from the
 Ethernet address of the datapath's local port (which is typically
-randomly generated).
+randomly generated) in the lower 48 bits and zeros in the upper 16.
 
 .TP
 \fB--mgmt-id=\fImgmtid\fR
diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c
index d6b2c51..6d5a91f 100644
--- a/utilities/ovs-openflowd.c
+++ b/utilities/ovs-openflowd.c
@@ -321,10 +321,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
 
         switch (c) {
         case OPT_DATAPATH_ID:
-            if (strlen(optarg) != 12
-                || strspn(optarg, "0123456789abcdefABCDEF") != 12) {
+            if (strlen(optarg) != 16
+                || strspn(optarg, "0123456789abcdefABCDEF") != 16) {
                 ovs_fatal(0, "argument to --datapath-id must be "
-                          "exactly 12 hex digits");
+                          "exactly 16 hex digits");
             }
             s->datapath_id = strtoll(optarg, NULL, 16);
             if (!s->datapath_id) {
@@ -443,10 +443,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
             break;
 
         case OPT_MGMT_ID:
-            if (strlen(optarg) != 12
-                || strspn(optarg, "0123456789abcdefABCDEF") != 12) {
+            if (strlen(optarg) != 16
+                || strspn(optarg, "0123456789abcdefABCDEF") != 16) {
                 ovs_fatal(0, "argument to --mgmt-id must be "
-                          "exactly 12 hex digits");
+                          "exactly 16 hex digits");
             }
             s->mgmt_id = strtoll(optarg, NULL, 16);
             if (!s->mgmt_id) {
@@ -533,9 +533,9 @@ usage(void)
     vconn_usage(true, true, true);
     printf("\nOpenFlow options:\n"
            "  -d, --datapath-id=ID    Use ID as the OpenFlow switch ID\n"
-           "                          (ID must consist of 12 hex digits)\n"
+           "                          (ID must consist of 16 hex digits)\n"
            "  --mgmt-id=ID            Use ID as the management ID\n"
-           "                          (ID must consist of 12 hex digits)\n"
+           "                          (ID must consist of 16 hex digits)\n"
            "  --manufacturer=MFR      Identify manufacturer as MFR\n"
            "  --hardware=HW           Identify hardware as HW\n"
            "  --software=SW           Identify software as SW\n"
diff --git a/vswitchd/ovs-vswitchd.conf.5.in b/vswitchd/ovs-vswitchd.conf.5.in
index c416678..1b900d5 100644
--- a/vswitchd/ovs-vswitchd.conf.5.in
+++ b/vswitchd/ovs-vswitchd.conf.5.in
@@ -488,7 +488,7 @@ the connection has been broken and attempts to reconnect.  The default
 and minimum values are both 5 seconds.
 
 A management id may be specified with the \fBmgmt.id\fR key.  It takes
-an id in the form of exactly 12 hexadecimal digits.  If one is not
+an id in the form of exactly 16 hexadecimal digits.  If one is not
 specified, a random id is generated each time \fBovs\-vswitchd\fR is started.
 .fi
 .RE
@@ -561,10 +561,11 @@ The Unix domain server socket named \fIfile\fR.
 .PP
 The datapath ID used by the bridge to identify itself to the remote
 controller may be specified as \fBbridge.\fIname\fB.datapath-id\fR,
-in the form of exactly 12 hexadecimal digits.  If the datapath ID
-is not specified, then it defaults to the bridge's MAC address (see
-\fBBridge Configuration\fR, above, for information on how the bridge's
-MAC address is chosen).
+in the form of exactly 16 hexadecimal digits.  If the datapath ID
+is not specified, then it defaults to the bridge's MAC address in
+the lower 48 bits (see \fBBridge Configuration\fR, above, for information 
+on how the bridge's MAC address is chosen) and zeros in the upper 16
+bits.
 .ST "Local Port Network Configuration"
 When an external controller is configured, but controller discovery is
 not in use, the following additional settings are honored:
-- 
1.6.4





More information about the dev mailing list