[ovs-dev] [PATCH] dpif-netdev: Make "packet-out" with in_port=OFPP_CONTROLLER work again.

Ben Pfaff blp at nicira.com
Tue Jul 9 16:23:29 UTC 2013


Commit 4e022ec09e14 (Create specific types for ofp and odp port) broke
OpenFlow OFPP_PACKET_OUT requests that use in_port=OFPP_CONTROLLER.  This
commit fixes the problem and adds a regression test.

CC: Alex Wang <alexw at nicira.com>
Reported-by: YAMAMOTO Takashi <yamamoto at valinux.co.jp>
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/dpif-netdev.c |    5 ++++-
 tests/ofproto.at  |    7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f8f1f88..f7e3b1f 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -694,6 +694,8 @@ static int
 dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
                               struct flow *flow)
 {
+    odp_port_t in_port;
+
     if (odp_flow_key_to_flow(key, key_len, flow) != ODP_FIT_PERFECT) {
         /* This should not happen: it indicates that odp_flow_key_from_flow()
          * and odp_flow_key_to_flow() disagree on the acceptable form of a
@@ -713,7 +715,8 @@ dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
         return EINVAL;
     }
 
-    if (!is_valid_port_number(flow->in_port.odp_port)) {
+    in_port = flow->in_port.odp_port;
+    if (!is_valid_port_number(in_port) && in_port != ODPP_NONE) {
         return EINVAL;
     }
 
diff --git a/tests/ofproto.at b/tests/ofproto.at
index df98863..e2e6f1b 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -1487,6 +1487,7 @@ dnl controllers despite the spec) as meaning a packet that was generated
 dnl by the controller.
 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1])
 
 # Start a monitor listening for packet-ins.
 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
@@ -1496,13 +1497,15 @@ ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
 AT_CAPTURE_FILE([monitor.log])
 
 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
-AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
-AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
+AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
+AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
 
 # Stop the monitor and check its output.
 ovs-appctl -t ovs-ofctl ofctl/barrier
 ovs-appctl -t ovs-ofctl exit
 
+ovs-ofctl dump-ports br0
+
 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
 metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
-- 
1.7.2.5




More information about the dev mailing list