/*
- * 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.
/* Datapath. */
uint64_t datapath_id; /* Datapath ID. */
const char *dp_name; /* Name of local datapath. */
+ struct svec ports; /* Set of ports to add to datapath (if any). */
/* Description strings. */
const char *mfr_desc; /* Manufacturer. */
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). */
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. */
+ 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");
+ }
+
+ SVEC_FOR_EACH (i, port, &s.ports) {
+ 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);
if (error) {
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));
OPT_HARDWARE,
OPT_SOFTWARE,
OPT_SERIAL,
+ OPT_DP_DESC,
OPT_ACCEPT_VCONN,
OPT_NO_RESOLV_CONF,
OPT_BR_NAME,
OPT_COMMAND_DIR,
OPT_NETFLOW,
OPT_MGMT_ID,
+ OPT_PORTS,
VLOG_OPTION_ENUMS,
LEAK_CHECKER_OPTION_ENUMS
};
{"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'},
{"command-dir", required_argument, 0, OPT_COMMAND_DIR},
{"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'},
{"version", no_argument, 0, 'V'},
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;
s->command_dir = NULL;
svec_init(&s->netflow);
s->mgmt_id = 0;
+ svec_init(&s->ports);
for (;;) {
int c;
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) {
s->serial_desc = optarg;
break;
+ case OPT_DP_DESC:
+ s->dp_desc = optarg;
+ break;
+
case OPT_ACCEPT_VCONN:
s->accept_controller_re = optarg;
break;
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) {
svec_add(&s->snoops, optarg);
break;
+ case OPT_PORTS:
+ svec_split(&s->ports, optarg, ",");
+ break;
+
case 'h':
usage();
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"
" --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"