ofproto: Add user-specifiable datapath description (OpenFlow 1.0)
authorJustin Pettit <jpettit@nicira.com>
Wed, 13 Jan 2010 07:01:25 +0000 (23:01 -0800)
committerJustin Pettit <jpettit@nicira.com>
Sat, 20 Feb 2010 10:22:27 +0000 (02:22 -0800)
In OpenFlow 1.0, a "dp_desc" character array was added to the ofp_desc_stats
structure that allows a human readable description of the datapath to be
provided.

NOTE: OVS at this point is not wire-compatible with OpenFlow 1.0 until
the final commit in this OpenFlow 1.0 set.

include/openflow/openflow.h
lib/ofp-print.c
ofproto/ofproto.c
ofproto/ofproto.h
utilities/ovs-openflowd.c

index 50fee6eeae8398f7c8fe10ad92b518cd56929370..4835b8a9968fba093fe63010abe0b45b0dcf0f6a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -725,8 +725,10 @@ struct ofp_desc_stats {
     char hw_desc[DESC_STR_LEN];        /* Hardware description. */
     char sw_desc[DESC_STR_LEN];        /* Software description. */
     char serial_num[SERIAL_NUM_LEN];   /* Serial number. */
+    char dp_desc[DESC_STR_LEN];        /* Human readable description of
+                                          the datapath. */
 };
-OFP_ASSERT(sizeof(struct ofp_desc_stats) == 800);
+OFP_ASSERT(sizeof(struct ofp_desc_stats) == 1056);
 
 /* Body for ofp_stats_request of type OFPST_FLOW. */
 struct ofp_flow_stats_request {
index 04bfe2f1d0fb10cea40e18c46780ffa83f23cd6e..19058b45b21061af1f612efff2ab1d39e58ff160 100644 (file)
@@ -927,6 +927,7 @@ ofp_desc_stats_reply(struct ds *string, const void *body,
     ds_put_format(string, "Hardware: %s\n", ods->hw_desc);
     ds_put_format(string, "Software: %s\n", ods->sw_desc);
     ds_put_format(string, "Serial Num: %s\n", ods->serial_num);
+    ds_put_format(string, "DP Description: %s\n", ods->dp_desc);
 }
 
 static void
index f22c2070c4acb2dc02ac29a50e8c9ec40d5e6e55..14a425db2999b056f5a2dc291aadea41699bc5c4 100644 (file)
@@ -189,6 +189,7 @@ struct ofproto {
     char *hardware;             /* Hardware. */
     char *software;             /* Software version. */
     char *serial;               /* Serial number. */
+    char *dp_desc;              /* Datapath description. */
 
     /* Datapath. */
     struct dpif *dpif;
@@ -300,6 +301,7 @@ ofproto_create(const char *datapath, const char *datapath_type,
     p->hardware = xstrdup("Reference Implementation");
     p->software = xstrdup(VERSION BUILDNR);
     p->serial = xstrdup("None");
+    p->dp_desc = xstrdup("None");
 
     /* Initialize datapath. */
     p->dpif = dpif;
@@ -387,7 +389,8 @@ ofproto_set_max_backoff(struct ofproto *p, int max_backoff)
 void
 ofproto_set_desc(struct ofproto *p,
                  const char *manufacturer, const char *hardware,
-                 const char *software, const char *serial)
+                 const char *software, const char *serial,
+                 const char *dp_desc)
 {
     if (manufacturer) {
         free(p->manufacturer);
@@ -405,6 +408,10 @@ ofproto_set_desc(struct ofproto *p,
         free(p->serial);
         p->serial = xstrdup(serial);
     }
+    if (dp_desc) {
+        free(p->dp_desc);
+        p->dp_desc = xstrdup(dp_desc);
+    }
 }
 
 int
@@ -2385,6 +2392,7 @@ handle_desc_stats_request(struct ofproto *p, struct ofconn *ofconn,
     strncpy(ods->hw_desc, p->hardware, sizeof ods->hw_desc);
     strncpy(ods->sw_desc, p->software, sizeof ods->sw_desc);
     strncpy(ods->serial_num, p->serial, sizeof ods->serial_num);
+    strncpy(ods->dp_desc, p->dp_desc, sizeof ods->dp_desc);
     queue_tx(msg, ofconn, ofconn->reply_counter);
 
     return 0;
index a94c8b59b303dc2214c9823beb0a80c67b9f4159..668cdffb6edf8c2f059f85f5184d75e03c67079b 100644 (file)
@@ -67,7 +67,8 @@ void ofproto_set_probe_interval(struct ofproto *, int probe_interval);
 void ofproto_set_max_backoff(struct ofproto *, int max_backoff);
 void ofproto_set_desc(struct ofproto *,
                       const char *manufacturer, const char *hardware,
-                      const char *software, const char *serial);
+                      const char *software, const char *serial,
+                      const char *dp_desc);
 int ofproto_set_in_band(struct ofproto *, bool in_band);
 int ofproto_set_discovery(struct ofproto *, bool discovery,
                           const char *accept_controller_re,
index 1b8e7ebdffcfb37fffcb412b36fc2e3ec9d12f67..011be3797127887c681fec9a8210295e0affe9b8 100644 (file)
@@ -71,6 +71,7 @@ struct ofsettings {
     const char *hw_desc;        /* Hardware. */
     const char *sw_desc;        /* Software version. */
     const char *serial_desc;    /* Serial number. */
+    const char *dp_desc;        /* Serial number. */
 
     /* Related vconns and network devices. */
     const char *controller_name; /* Controller (if not discovery mode). */
@@ -171,7 +172,8 @@ main(int argc, char *argv[])
     if (s.datapath_id) {
         ofproto_set_datapath_id(ofproto, s.datapath_id);
     }
-    ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc, s.serial_desc);
+    ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc,
+                     s.serial_desc, s.dp_desc);
     if (!s.listeners.n) {
         svec_add_nocopy(&s.listeners, xasprintf("punix:%s/%s.mgmt",
                                               ovs_rundir, s.dp_name));
@@ -242,6 +244,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         OPT_HARDWARE,
         OPT_SOFTWARE,
         OPT_SERIAL,
+        OPT_DP_DESC,
         OPT_ACCEPT_VCONN,
         OPT_NO_RESOLV_CONF,
         OPT_BR_NAME,
@@ -269,6 +272,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         {"hardware", required_argument, 0, OPT_HARDWARE},
         {"software", required_argument, 0, OPT_SOFTWARE},
         {"serial", required_argument, 0, OPT_SERIAL},
+        {"dp_desc", required_argument, 0, OPT_DP_DESC},
         {"accept-vconn", required_argument, 0, OPT_ACCEPT_VCONN},
         {"no-resolv-conf", no_argument, 0, OPT_NO_RESOLV_CONF},
         {"config",      required_argument, 0, 'F'},
@@ -307,6 +311,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
     s->hw_desc = NULL;
     s->sw_desc = NULL;
     s->serial_desc = NULL;
+    s->dp_desc = NULL;
     svec_init(&s->listeners);
     svec_init(&s->snoops);
     s->fail_mode = FAIL_OPEN;
@@ -353,6 +358,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
             s->serial_desc = optarg;
             break;
 
+        case OPT_DP_DESC:
+            s->dp_desc = optarg;
+            break;
+
         case OPT_ACCEPT_VCONN:
             s->accept_controller_re = optarg;
             break;
@@ -526,6 +535,7 @@ usage(void)
            "  --hardware=HW           Identify hardware as HW\n"
            "  --software=SW           Identify software as SW\n"
            "  --serial=SERIAL         Identify serial number as SERIAL\n"
+           "  --dp_desc=DP_DESC       Identify dp description as DP_DESC\n"
            "\nController discovery options:\n"
            "  --accept-vconn=REGEX    accept matching discovered controllers\n"
            "  --no-resolv-conf        do not update /etc/resolv.conf\n"