ovs-openflowd: Remove documentation for obsolete --mgmt-id option.
[openvswitch] / utilities / ovs-openflowd.c
index e0cfdc957bca741cf1ceaed93e90cc16347085b0..4e3f3809bb16dcbb000066dda50f2cb241090db5 100644 (file)
@@ -62,7 +62,8 @@ struct ofsettings {
 
     /* Datapath. */
     uint64_t datapath_id;       /* Datapath ID. */
-    const char *dp_name;        /* Name of local datapath. */
+    char *dp_name;              /* Name of local datapath. */
+    char *dp_type;              /* Type of local datapath. */
     struct svec ports;          /* Set of ports to add to datapath (if any). */
 
     /* Description strings. */
@@ -70,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;        /* Datapath description. */
 
     /* Related vconns and network devices. */
     const char *controller_name; /* Controller (if not discovery mode). */
@@ -93,9 +95,6 @@ struct ofsettings {
     /* Spanning tree protocol. */
     bool enable_stp;
 
-    /* Management. */
-    uint64_t mgmt_id;           /* Management ID. */
-
     /* NetFlow. */
     struct svec netflow;        /* NetFlow targets. */
 };
@@ -110,6 +109,7 @@ main(int argc, char *argv[])
     struct ofproto *ofproto;
     struct ofsettings s;
     int error;
+    struct dpif *dpif;
     struct netflow_options nf_options;
 
     proctitle_init(argc, argv);
@@ -131,28 +131,32 @@ main(int argc, char *argv[])
     VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
     VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
 
-    /* Create the datapath and add ports to it, if requested by the user. */
+    error = dpif_create_and_open(s.dp_name, s.dp_type, &dpif);
+    if (error) {
+        ovs_fatal(error, "could not create datapath");
+    }
+
+    /* Add ports to the datapath if requested by the user. */
     if (s.ports.n) {
-        struct dpif *dpif;
         const char *port;
         size_t i;
-
-        error = dpif_create_and_open(s.dp_name, &dpif);
-        if (error) {
-            ovs_fatal(error, "could not create datapath");
-        }
+        struct netdev *netdev;
 
         SVEC_FOR_EACH (i, port, &s.ports) {
+            error = netdev_open_default(port, &netdev);
+            if (error) {
+                ovs_fatal(error, "failed to open %s as a device", port);
+            }
+
             error = dpif_port_add(dpif, port, 0, NULL);
             if (error) {
                 ovs_fatal(error, "failed to add %s as a port", port);
             }
         }
-        dpif_close(dpif);
     }
 
     /* Start OpenFlow processing. */
-    error = ofproto_create(s.dp_name, NULL, NULL, &ofproto);
+    error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto);
     if (error) {
         ovs_fatal(error, "could not initialize openflow switch");
     }
@@ -168,10 +172,8 @@ main(int argc, char *argv[])
     if (s.datapath_id) {
         ofproto_set_datapath_id(ofproto, s.datapath_id);
     }
-    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));
@@ -226,6 +228,8 @@ main(int argc, char *argv[])
         poll_block();
     }
 
+    dpif_close(dpif);
+
     return 0;
 }
 \f
@@ -236,10 +240,11 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
 {
     enum {
         OPT_DATAPATH_ID = UCHAR_MAX + 1,
-        OPT_MANUFACTURER,
-        OPT_HARDWARE,
-        OPT_SOFTWARE,
-        OPT_SERIAL,
+        OPT_MFR_DESC,
+        OPT_HW_DESC,
+        OPT_SW_DESC,
+        OPT_SERIAL_DESC,
+        OPT_DP_DESC,
         OPT_ACCEPT_VCONN,
         OPT_NO_RESOLV_CONF,
         OPT_BR_NAME,
@@ -256,17 +261,17 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         OPT_OUT_OF_BAND,
         OPT_IN_BAND,
         OPT_NETFLOW,
-        OPT_MGMT_ID,
         OPT_PORTS,
         VLOG_OPTION_ENUMS,
         LEAK_CHECKER_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"datapath-id", required_argument, 0, OPT_DATAPATH_ID},
-        {"manufacturer", required_argument, 0, OPT_MANUFACTURER},
-        {"hardware", required_argument, 0, OPT_HARDWARE},
-        {"software", required_argument, 0, OPT_SOFTWARE},
-        {"serial", required_argument, 0, OPT_SERIAL},
+        {"mfr-desc", required_argument, 0, OPT_MFR_DESC},
+        {"hw-desc", required_argument, 0, OPT_HW_DESC},
+        {"sw-desc", required_argument, 0, OPT_SW_DESC},
+        {"serial-desc", required_argument, 0, OPT_SERIAL_DESC},
+        {"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'},
@@ -284,7 +289,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         {"out-of-band", no_argument, 0, OPT_OUT_OF_BAND},
         {"in-band",     no_argument, 0, OPT_IN_BAND},
         {"netflow",     required_argument, 0, OPT_NETFLOW},
-        {"mgmt-id",     required_argument, 0, OPT_MGMT_ID},
         {"ports",       required_argument, 0, OPT_PORTS},
         {"verbose",     optional_argument, 0, 'v'},
         {"help",        no_argument, 0, 'h'},
@@ -306,6 +310,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;
@@ -319,7 +324,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
     s->enable_stp = false;
     s->in_band = true;
     svec_init(&s->netflow);
-    s->mgmt_id = 0;
     svec_init(&s->ports);
     for (;;) {
         int c;
@@ -333,26 +337,30 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         case OPT_DATAPATH_ID:
             if (!dpid_from_string(optarg, &s->datapath_id)) {
                 ovs_fatal(0, "argument to --datapath-id must be "
-                          "exactly 12 hex digits and may not be all-zero");
+                          "exactly 16 hex digits and may not be all-zero");
             }
             break;
 
-        case OPT_MANUFACTURER:
+        case OPT_MFR_DESC:
             s->mfr_desc = optarg;
             break;
 
-        case OPT_HARDWARE:
+        case OPT_HW_DESC:
             s->hw_desc = optarg;
             break;
 
-        case OPT_SOFTWARE:
+        case OPT_SW_DESC:
             s->sw_desc = optarg;
             break;
 
-        case OPT_SERIAL:
+        case OPT_SERIAL_DESC:
             s->serial_desc = optarg;
             break;
 
+        case OPT_DP_DESC:
+            s->dp_desc = optarg;
+            break;
+
         case OPT_ACCEPT_VCONN:
             s->accept_controller_re = optarg;
             break;
@@ -437,18 +445,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
             svec_add(&s->netflow, optarg);
             break;
 
-        case OPT_MGMT_ID:
-            if (strlen(optarg) != 12
-                || strspn(optarg, "0123456789abcdefABCDEF") != 12) {
-                ovs_fatal(0, "argument to --mgmt-id must be "
-                          "exactly 12 hex digits");
-            }
-            s->mgmt_id = strtoll(optarg, NULL, 16);
-            if (!s->mgmt_id) {
-                ovs_fatal(0, "argument to --mgmt-id must be nonzero");
-            }
-            break;
-
         case 'l':
             svec_add(&s->listeners, optarg);
             break;
@@ -499,7 +495,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
     }
 
     /* Local and remote vconns. */
-    s->dp_name = argv[0];
+    dp_parse_name(argv[0], &s->dp_name, &s->dp_type);
+
     s->controller_name = argc > 1 ? xstrdup(argv[1]) : NULL;
 
     /* Set accept_controller_regex. */
@@ -532,13 +529,12 @@ 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"
-           "  --mgmt-id=ID            Use ID as the management ID\n"
-           "                          (ID must consist of 12 hex digits)\n"
-           "  --manufacturer=MFR      Identify manufacturer as MFR\n"
-           "  --hardware=HW           Identify hardware as HW\n"
-           "  --software=SW           Identify software as SW\n"
-           "  --serial=SERIAL         Identify serial number as SERIAL\n"
+           "                          (ID must consist of 16 hex digits)\n"
+           "  --mfr-desc=MFR          Identify manufacturer as MFR\n"
+           "  --hw-desc=HW            Identify hardware as HW\n"
+           "  --sw-desc=SW            Identify software as SW\n"
+           "  --serial-desc=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"