From: Ben Pfaff Date: Thu, 7 Nov 2013 00:12:34 +0000 (-0800) Subject: ofproto: Limit OVS-assigned port numbers to 32767 and below. X-Git-Tag: sliver-openvswitch-2.0.90-1~5^2~53 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=484c8355ded7682e2a722eb7da8782b9f9b576c5;p=sliver-openvswitch.git ofproto: Limit OVS-assigned port numbers to 32767 and below. A couple of controller vendors have mentioned to me that they would like to have some part of the OpenFlow port number space reserved for the controller to use. This commit reserves 32768 and up (roughly the upper half of the OF1.0 port range) to the controller. Bug #18753. Signed-off-by: Ben Pfaff --- diff --git a/NEWS b/NEWS index 43a20793a..1830e3e18 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Post-v2.0.0 defaults. - OpenFlow: * The OpenFlow 1.1+ "Write-Actions" instruction is now supported. + * OVS limits the OpenFlow port numbers it assigns to port 32767 and + below, leaving port numbers above that range free for assignment + by the controller. - ovs-vswitchd.conf.db.5 man page will contain graphviz/dot diagram only if graphviz package was installed at the build time. - Support for Linux kernels up to 3.11 diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 0c66a5969..d565b199b 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -2004,9 +2004,13 @@ alloc_ofp_port(struct ofproto *ofproto, const char *netdev_name) /* Search for a free OpenFlow port number. We try not to * immediately reuse them to prevent problems due to old - * flows. */ + * flows. + * + * We limit the automatically assigned port numbers to the lower half + * of the port range, to reserve the upper half for assignment by + * controllers. */ for (;;) { - if (++ofproto->alloc_port_no >= ofproto->max_ports) { + if (++ofproto->alloc_port_no >= MIN(ofproto->max_ports, 32768)) { ofproto->alloc_port_no = 1; } last_used_at = ofport_get_usage(ofproto, diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 52924ee71..d2fba341f 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1254,33 +1254,54 @@ address.

- -

OpenFlow port number for this interface. Unlike most columns, this - column's value should be set only by Open vSwitch itself. Other - clients should set this column to an empty set (the default) when - creating an .

-

Open vSwitch populates this column when the port number becomes - known. If the interface is successfully added, - will be set to a number between 1 and 65535 - (generally either in the range 1 to 65279, inclusive, or 65534, the - port number for the OpenFlow ``local port''). If the interface - cannot be added then Open vSwitch sets this column - to -1.

-

When is not set, Open vSwitch picks - an appropriate value for this column and then tries to keep the value - constant across restarts.

-
- - -

Requested OpenFlow port number for this interface. The port - number must be between 1 and 65279, inclusive. Some datapaths - cannot satisfy all requests for particular port numbers. When - this column is empty or the request cannot be fulfilled, the - system will choose a free port. The - column reports the assigned OpenFlow port number.

-

The port number must be requested in the same transaction - that creates the port.

-
+ +

+ When a client adds a new interface, Open vSwitch chooses an OpenFlow + port number for the new port. If the client that adds the port fills + in , then Open vSwitch tries to use its + value as the OpenFlow port number. Otherwise, or if the requested + port number is already in use or cannot be used for another reason, + Open vSwitch automatically assigns a free port number. Regardless of + how the port number was obtained, Open vSwitch then reports in the port number actually assigned. +

+ +

+ Open vSwitch limits the port numbers that it automatically assigns to + the range 1 through 32,767, inclusive. Controllers therefore have + free use of ports 32,768 and up. +

+ + +

+ OpenFlow port number for this interface. Open vSwitch sets this + column's value, so other clients should treat it as read-only. +

+

+ The OpenFlow ``local'' port (OFPP_LOCAL) is 65,534. + The other valid port numbers are in the range 1 to 65,279, + inclusive. Value -1 indicates an error adding the interface. +

+
+ + +

+ Requested OpenFlow port number for this interface. +

+ +

+ Open vSwitch currently assigns the OpenFlow port number for an + interface once, when the client first adds the interface. It does + not change the port number later if the client sets or changes or + clears . Therefore, to ensure that + takes effect, the client should set + it in the same database transaction that creates the interface. + (Future versions of Open vSwitch might honor changes to .) +

+
+