diff options
author | Ben Pfaff <blp@nicira.com> | 2009-06-17 14:26:19 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2009-07-06 09:07:24 -0700 |
commit | 9ee3ae3e0d89fcd67d04d8a890734a5fbee218a5 (patch) | |
tree | c63f27762bbe6c996c45f0a97dcc1a486383066d /utilities | |
parent | 2f8c6cfb506aad3b9b498917878e65149c3b67b2 (diff) | |
download | openvswitch-9ee3ae3e0d89fcd67d04d8a890734a5fbee218a5.tar.gz |
datapath: Make the datapath responsible for choosing port numbers.
Soon we will allow for multiple datapath implementations. By allowing
the datapath to choose the port numbers, we possibly simplify some datapath
implementations, and the datapath's clients don't have to guess (or to
check) what port numbers are free, so this seems like a better way to go.
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/ovs-dpctl.8.in | 5 | ||||
-rw-r--r-- | utilities/ovs-dpctl.c | 41 |
2 files changed, 2 insertions, 44 deletions
diff --git a/utilities/ovs-dpctl.8.in b/utilities/ovs-dpctl.8.in index c43d4ffa0..0a1d67029 100644 --- a/utilities/ovs-dpctl.8.in +++ b/utilities/ovs-dpctl.8.in @@ -70,11 +70,6 @@ A \fInetdev\fR may be followed by a comma-separated list of options. The following options are currently supported: .RS -.IP "\fBport=\fIportno\fR" -Specifies \fIportno\fR (a number between 1 and 255) as the port number -at which \fInetdev\fR will be attached. By default, \fBadd\-if\fR -automatically selects the lowest available port number. - .IP "\fBinternal\fR" Instead of attaching an existing \fInetdev\fR, creates an internal port (analogous to the local port) with that name. diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index 9f45b3add..270281832 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -243,29 +243,6 @@ query_ports(struct dpif *dpif, struct odp_port **ports, size_t *n_ports) qsort(*ports, *n_ports, sizeof **ports, compare_ports); } -static uint16_t -get_free_port(struct dpif *dpif) -{ - struct odp_port *ports; - size_t n_ports; - int port_no; - - query_ports(dpif, &ports, &n_ports); - for (port_no = 0; port_no <= UINT16_MAX; port_no++) { - size_t i; - for (i = 0; i < n_ports; i++) { - if (ports[i].port == port_no) { - goto next_portno; - } - } - free(ports); - return port_no; - - next_portno: ; - } - ovs_fatal(0, "no free datapath ports"); -} - static void do_add_if(int argc UNUSED, char *argv[]) { @@ -277,7 +254,6 @@ do_add_if(int argc UNUSED, char *argv[]) for (i = 2; i < argc; i++) { char *save_ptr = NULL; char *devname, *suboptions; - int port = -1; int flags = 0; int error; @@ -290,11 +266,9 @@ do_add_if(int argc UNUSED, char *argv[]) suboptions = strtok_r(NULL, "", &save_ptr); if (suboptions) { enum { - AP_PORT, AP_INTERNAL }; static char *options[] = { - "port", "internal" }; @@ -302,13 +276,6 @@ do_add_if(int argc UNUSED, char *argv[]) char *value; switch (getsubopt(&suboptions, options, &value)) { - case AP_PORT: - if (!value) { - ovs_error(0, "'port' suboption requires a value"); - } - port = atoi(value); - break; - case AP_INTERNAL: flags |= ODP_PORT_INTERNAL; break; @@ -319,14 +286,10 @@ do_add_if(int argc UNUSED, char *argv[]) } } } - if (port < 0) { - port = get_free_port(dpif); - } - error = dpif_port_add(dpif, devname, port, flags); + error = dpif_port_add(dpif, devname, flags, NULL); if (error) { - ovs_error(error, "adding %s as port %"PRIu16" of %s failed", - devname, port, argv[1]); + ovs_error(error, "adding %s to %s failed", devname, argv[1]); failure = true; } else if (if_up(devname)) { failure = true; |