[ovs-dev] [PATCH 2/2] ofp-util: Again allow OpenFlow port 0 in commands and actions.

Ben Pfaff blp at nicira.com
Wed Oct 17 20:29:44 UTC 2012

Commit c6100d92142b (ovs-ofctl: Accept port keywords, OF1.1 port numbers,
reject port number 0.) intentionally prohibited using port 0, which is not
a valid OpenFlow port number, in OpenFlow commands and actions.  However,
since then we have discovered that the NVP controller uses port 0 in
"resubmit" actions and hence in flow matches as well.  This seems like a
valid enough use case; after all, the port number in a resubmit action is
really just an arbitrary number that need not (and preferably does not)
refer to an actual OpenFlow port.  Therefore, this commit restores the
ability to use port 0.

(Only functions that parse OpenFlow commands and actions from strings, not
those that interpret binary OpenFlow coming in on OpenFlow connections,
were affected by this prohibition, so this only comes up in corner cases

Reported-by: Gurucharan Shetty <gshetty at nicira.com>
Signed-off-by: Ben Pfaff <blp at nicira.com>
 NEWS               |    2 --
 lib/ofp-util.c     |    5 +----
 tests/ovs-ofctl.at |    2 ++
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index d841cb3..30077c0 100644
--- a/NEWS
+++ b/NEWS
@@ -15,8 +15,6 @@ post-v1.8.0
         also the recommended way to specify these ports, for compatibility
         with OpenFlow 1.1 and later (which use the OpenFlow 1.0 numbers
         for these ports for different purposes).
-      - Commands and actions that accept port numbers no longer accept port 0,
-        which is not a valid port number in OpenFlow 1.0 and later.
     - ovs-dpctl:
       - Support requesting the port number with the "port_no" option in
         the "add-if" command.
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 419a1cd..34255da 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -3562,10 +3562,7 @@ ofputil_port_from_string(const char *s, uint16_t *portp)
     *portp = 0;
     if (str_to_uint(s, 10, &port32)) {
-        if (port32 == 0) {
-            VLOG_WARN("port 0 is not a valid OpenFlow port number");
-            return false;
-        } else if (port32 < OFPP_MAX) {
+        if (port32 < OFPP_MAX) {
             *portp = port32;
             return true;
         } else if (port32 < OFPP_FIRST_RESV) {
diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at
index 8185827..f800da1 100644
--- a/tests/ovs-ofctl.at
+++ b/tests/ovs-ofctl.at
@@ -11,6 +11,7 @@ udp,nw_src=,tp_dst=53 actions=pop_queue,output:1
 cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
+in_port=0 actions=resubmit:0
 AT_CHECK([ovs-ofctl parse-flows flows.txt
@@ -26,6 +27,7 @@ OFPT_FLOW_MOD: ADD udp,nw_src=,tp_dst=53 actions=pop_queue,output:1
 OFPT_FLOW_MOD: ADD priority=60000 cookie:0x123456789abcdef hard:10 actions=CONTROLLER:65535
 OFPT_FLOW_MOD: ADD actions=note:,note:,note:
 OFPT_FLOW_MOD: ADD actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[0..63],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[64..127]
+OFPT_FLOW_MOD: ADD in_port=0 actions=resubmit:0

More information about the dev mailing list