From e3432ee978b4fd740aa4db785742a28a573e2cde Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 17 Oct 2012 13:29:34 -0700 Subject: [PATCH] ofp-util: Again allow OpenFlow port 0 in commands and actions. 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 anyhow.) Reported-by: Gurucharan Shetty Signed-off-by: Ben Pfaff --- 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 d841cb32..30077c02 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 419a1cd4..34255da2 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 81858275..f800da17 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -11,6 +11,7 @@ udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1 cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src +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=192.168.0.3,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:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00 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 ]]) AT_CLEANUP -- 2.30.2