[ovs-dev] [PATCH 2/2] ovs-dpctl: Allow requesting the port number from "add-if" command.
Justin Pettit
jpettit at nicira.com
Sat Jul 28 18:54:10 UTC 2012
The datapath port number influences the OpenFlow port number in
ovs-vswitchd. The new "port_no" option for the "add-if" command allows
the user to request a specific datapath port number.
Feature #12642
Signed-off-by: Justin Pettit <jpettit at nicira.com>
---
NEWS | 3 +++
utilities/ovs-dpctl.8.in | 10 +++++++---
utilities/ovs-dpctl.c | 14 +++++++++++++-
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index 34fa0ea..bfa58df 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ post-v1.8.0
- OpenFlow:
- Allow bitwise masking for SHA and THA fields in ARP, SLL and TLL
fields in IPv6 neighbor discovery messages, and IPv6 flow label.
+ - ovs-dpctl
+ - Support requesting the port number with the "port_no" option in
+ the "add-if" command.
v1.8.0 - xx xxx xxxx
diff --git a/utilities/ovs-dpctl.8.in b/utilities/ovs-dpctl.8.in
index 40032bc..cdbf641 100644
--- a/utilities/ovs-dpctl.8.in
+++ b/utilities/ovs-dpctl.8.in
@@ -66,6 +66,10 @@ The following options are currently supported:
.RS
.IP "\fBtype=\fItype\fR"
Specifies the type of port to add. The default type is \fBsystem\fR.
+.IP "\fBport_no=\fIport\fR"
+Requests a specific port number within the datapath. If this option is
+not specified, or a value of zero is given, then one will be
+automatically assigned.
.IP "\fIkey\fB=\fIvalue\fR"
Adds an arbitrary key-value option to the port's configuration.
.RE
@@ -78,9 +82,9 @@ Reconfigures each \fIport\fR in \fIdp\fR as specified. An
\fIoption\fR of the form \fIkey\fB=\fIvalue\fR adds the specified
key-value option to the port or overrides an existing key's value. An
\fIoption\fR of the form \fIkey\fB=\fR, that is, without a value,
-deletes the key-value named \fIkey\fR. The type of a port cannot be
-changed, so \fBtype=\fItype\fR is only allowed if \fItype\fR is the
-port's existing type.
+deletes the key-value named \fIkey\fR. The type and port number of a
+port cannot be changed, so \fBtype\fR and \fBport_no\fR are only allowed if
+they match the existing configuration.
.TP
\fBdel\-if \fIdp netdev\fR...
Removes each \fInetdev\fR from the list of network devices datapath
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index 9b55026..320d49f 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -248,6 +248,7 @@ dpctl_add_if(int argc OVS_UNUSED, char *argv[])
char *save_ptr = NULL;
struct netdev *netdev = NULL;
struct smap args;
+ uint16_t port_no = 0;
char *option;
int error;
@@ -273,6 +274,8 @@ dpctl_add_if(int argc OVS_UNUSED, char *argv[])
if (!strcmp(key, "type")) {
type = value;
+ } else if (!strcmp(key, "port_no")) {
+ port_no = atoi(value);
} else if (!smap_add_once(&args, key, value)) {
ovs_error(0, "duplicate \"%s\" option", key);
}
@@ -290,7 +293,7 @@ dpctl_add_if(int argc OVS_UNUSED, char *argv[])
goto next;
}
- error = dpif_port_add(dpif, netdev, NULL);
+ error = dpif_port_add(dpif, netdev, &port_no);
if (error) {
ovs_error(error, "adding %s to %s failed", name, argv[1]);
goto next;
@@ -325,6 +328,7 @@ dpctl_set_if(int argc, char *argv[])
char *type = NULL;
const char *name;
struct smap args;
+ uint32_t port_no;
char *option;
int error;
@@ -342,6 +346,7 @@ dpctl_set_if(int argc, char *argv[])
goto next;
}
type = xstrdup(dpif_port.type);
+ port_no = dpif_port.port_no;
dpif_port_destroy(&dpif_port);
/* Retrieve its existing configuration. */
@@ -375,6 +380,13 @@ dpctl_set_if(int argc, char *argv[])
name, type, value);
failure = true;
}
+ } else if (!strcmp(key, "port_no")) {
+ if (port_no != atoi(value)) {
+ ovs_error(0, "%s: can't change port number from "
+ "%"PRIu32" to %d",
+ name, port_no, atoi(value));
+ failure = true;
+ }
} else if (value[0] == '\0') {
smap_remove(&args, key);
} else {
--
1.7.5.4
More information about the dev
mailing list