From: Ben Pfaff Date: Tue, 9 Jul 2013 16:23:02 +0000 (-0700) Subject: dpif-netdev: Make "packet-out" with in_port=OFPP_CONTROLLER work again. X-Git-Tag: sliver-openvswitch-2.0.90-1~36^2~52 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=586ddea56b4dc74f45a6b0eec7e20f503a0d2c76;p=sliver-openvswitch.git dpif-netdev: Make "packet-out" with in_port=OFPP_CONTROLLER work again. 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 Reported-by: YAMAMOTO Takashi Signed-off-by: Ben Pfaff --- diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index f8f1f881e..f7e3b1ff1 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 df988637f..e2e6f1b0f 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