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, 23 Jan 2010 02:08:05 +0000 (18:08 -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 50fee6e..4835b8a 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 60a2700..1443842 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.
@@ -927,6 +927,7 @@ ofp_desc_stats_reply(struct ds *string, const void *body, size_t len UNUSED,
     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 25804dc..335e6c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 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.
@@ -194,6 +194,7 @@ struct ofproto {
     char *hardware;             /* Hardware. */
     char *software;             /* Software version. */
     char *serial;               /* Serial number. */
+    char *dp_desc;              /* Datapath description. */
 
     /* Datapath. */
     struct dpif *dpif;
@@ -303,6 +304,7 @@ ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux,
     p->hardware = xstrdup("Reference Implementation");
     p->software = xstrdup(VERSION BUILDNR);
     p->serial = xstrdup("None");
+    p->dp_desc = xstrdup("None");
 
     /* Initialize datapath. */
     p->dpif = dpif;
@@ -403,7 +405,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);
@@ -421,6 +424,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
@@ -2378,6 +2385,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 50dd5d5..9ec2d05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 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.
@@ -52,7 +52,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 35f6f24..959ba2c 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.
@@ -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). */
@@ -176,7 +177,8 @@ main(int argc, char *argv[])
     if (s.mgmt_id) {
         ofproto_set_mgmt_id(ofproto, s.mgmt_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));
@@ -248,6 +250,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,
@@ -277,6 +280,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'},
@@ -318,6 +322,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;
@@ -372,6 +377,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;
@@ -568,6 +577,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"