2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00
ovs/tests/dpif-netdev.at

2514 lines
116 KiB
Plaintext
Raw Normal View History

AT_BANNER([dpif-netdev])
m4_divert_push([PREPARE_TESTS])
[
# Strips out uninteresting parts of flow output, as well as parts
# that vary from one run to another (e.g., timing and bond actions).
strip_timers () {
sed '
s/duration:[0-9\.][0-9\.]*/duration:0.0/
s/used:[0-9\.][0-9\.]*/used:0.0/
'
}
strip_xout () {
sed '
s/mega_ufid:[-0-9a-f]* //
s/ufid:[-0-9a-f]* //
s/used:[0-9\.][0-9\.]*/used:0.0/
s/actions:.*/actions: <del>/
s/packets:[0-9]*/packets:0/
s/bytes:[0-9]*/bytes:0/
' | sort
}
strip_xout_keep_actions () {
sed '
s/mega_ufid:[-0-9a-f]* //
s/ufid:[-0-9a-f]* //
s/used:[0-9\.][0-9\.]*/used:0.0/
s/packets:[0-9]*/packets:0/
s/bytes:[0-9]*/bytes:0/
' | sort
}
filter_flow_install () {
grep 'flow_add' | sed 's/.*flow_add: //' | sort | uniq
}
filter_hw_flow_install () {
grep 'netdev_dummy.*flow put\[create\]' | sed 's/.*|DBG|//' | sort | uniq
}
filter_hw_flow_del () {
grep 'netdev_dummy.*flow del' | sed 's/.*|DBG|//' | sort | uniq
}
filter_hw_packet_netdev_dummy () {
grep 'netdev_dummy.*: packet:.*with mark' | sed 's/.*|DBG|//' | sort | uniq
}
filter_flow_dump () {
grep 'flow_dump ' | sed '
s/.*flow_dump //
s/used:[0-9\.][0-9\.]*/used:0.0/
' | sort | uniq
}
strip_metadata () {
sed 's/metadata=0x[0-9a-f]*/metadata=0x0/'
}
]
m4_divert_pop([PREPARE_TESTS])
AT_SETUP([dpif-netdev - netdev-dummy/receive])
# Create br0 with interfaces p0
OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1 -- ])
AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
AT_CHECK([ovs-ofctl add-flow br0 action=normal])
ovs-appctl time/stop
ovs-appctl time/warp 5000
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:01,dst=50:54:00:00:02:00),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)'])
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:01,dst=50:54:00:00:02:00),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)
])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:06:00),eth_type(0x0800),ipv4(src=10.0.0.5,dst=10.0.0.6,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)' --len 1024])
OVS_WAIT_UNTIL([test `grep -c "miss upcall" ovs-vswitchd.log` -ge 2])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:06:00),eth_type(0x0800),ipv4(src=10.0.0.5,dst=10.0.0.6,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)
])
OVS_VSWITCHD_STOP
AT_CLEANUP
m4_define([DPIF_NETDEV_DUMMY_IFACE],
[AT_SETUP([dpif-netdev - $1 interface])
# Create br0 with interfaces p1 and p7
# and br1 with interfaces p2 and p8
# with p1 and p2 connected via unix domain socket
OVS_VSWITCHD_START(
[add-port br0 p1 -- set interface p1 type=$1 options:pstream=punix:$OVS_RUNDIR/p0.sock ofport_request=1 -- \
add-port br0 p7 -- set interface p7 ofport_request=7 type=$1 -- \
add-br br1 -- \
set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
fail-mode=secure -- \
add-port br1 p2 -- set interface p2 type=$1 options:stream=unix:$OVS_RUNDIR/p0.sock ofport_request=2 -- \
add-port br1 p8 -- set interface p8 ofport_request=8 type=$1 --], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,8,8,8,8"], [])])
AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
AT_CHECK([ovs-ofctl add-flow br0 action=normal])
AT_CHECK([ovs-ofctl add-flow br1 action=normal])
ovs-appctl time/stop
ovs-appctl time/warp 5000
AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
ovs-appctl time/warp 100
sleep 1 # wait for forwarders process packets
AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(frag=no), actions: <del>
recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
recirc_id(0),in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
recirc_id(0),in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(frag=no), actions: <del>
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_DUMMY_IFACE([dummy])
DPIF_NETDEV_DUMMY_IFACE([dummy-pmd])
m4_define([DPIF_NETDEV_MISS_FLOW_INSTALL],
[AT_SETUP([dpif-netdev - miss upcall key matches flow_install - $1])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set interface p1 type=$1 options:pstream=punix:$OVS_RUNDIR/p0.sock \
-- set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
AT_CHECK([ovs-ofctl add-flow br0 action=normal])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
ovs-appctl ofproto/trace 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
])
AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
])
# Now, the same again without megaflows.
AT_CHECK([ovs-appctl upcall/disable-megaflows], [0], [megaflows disabled
])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
OVS_WAIT_UNTIL([test `grep -c "miss upcall" ovs-vswitchd.log` -ge 2])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
])
AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(-new-est-rel-rpl-inv-trk-snat-dnat),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0), actions: <del>
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_MISS_FLOW_INSTALL([dummy])
DPIF_NETDEV_MISS_FLOW_INSTALL([dummy-pmd])
m4_define([DPIF_NETDEV_FLOW_PUT_MODIFY],
[AT_SETUP([dpif-netdev - datapath flow modification - $1])
OVS_VSWITCHD_START(
[add-port br0 p1 -- set interface p1 type=$1 ofport_request=1 options:pstream=punix:$OVS_RUNDIR/p1.sock -- \
add-port br0 p2 -- set interface p2 type=$1 ofport_request=2 options:pstream=punix:$OVS_RUNDIR/p2.sock -- \
set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg])
# Add a flow that directs some packets received on p1 to p2 and the
# rest back out p1.
AT_CHECK([ovs-ofctl del-flows br0])
AT_CHECK([ovs-ofctl add-flow br0 priority=1,ip,in_port=1,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,actions=output:2])
AT_CHECK([ovs-ofctl add-flow br0 priority=0,in_port=1,actions=IN_PORT])
# Inject a packet of the form that should go to p2.
packet="in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no))"
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no))
])
ovs-appctl revalidator/wait
# Dump the datapath flow to see that it goes to p2 ("actions:2").
AT_CHECK([ovs-appctl dpif/dump-flows br0], [0], [dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5/0x0),encap(eth_type(0x0800),ipv4(frag=no)), packets:0, bytes:0, used:never, actions:2
])
# Delete the flows, then add new flows that would not match the same
# packet as before.
AT_CHECK([ovs-ofctl del-flows br0])
AT_CHECK([ovs-ofctl add-flow br0 priority=1,in_port=1,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,dl_type=0x0801,actions=output:2])
AT_CHECK([ovs-ofctl add-flow br0 priority=0,in_port=1,actions=IN_PORT])
# Wait for flow revalidation
ovs-appctl revalidator/wait
# Inject the same packet again.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64])
ovs-appctl revalidator/wait
# Dump the datapath flow to see that it goes to p1 ("actions:IN_PORT").
AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5/0x0),encap(eth_type(0x0800),ipv4(frag=no)), packets:1, bytes:64, used:0.0s, actions:1
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_FLOW_PUT_MODIFY([dummy])
DPIF_NETDEV_FLOW_PUT_MODIFY([dummy-pmd])
m4_define([DPIF_NETDEV_MISS_FLOW_DUMP],
[AT_SETUP([dpif-netdev - miss upcall key matches flow_dump - $1])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set interface p1 type=$1 options:pstream=punix:$OVS_RUNDIR/p0.sock \
-- set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
AT_CHECK([ovs-appctl upcall/disable-ufid], [0], [Datapath dumping tersely using UFID disabled
], [])
AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
AT_CHECK([ovs-appctl vlog/disable-rate-limit dpif])
AT_CHECK([ovs-ofctl add-flow br0 action=normal])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
])
ovs-appctl revalidator/wait
AT_CHECK([filter_flow_dump < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),dp_hash(0/0),skb_priority(0/0),in_port(1),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:0, bytes:0, used:never, actions: <del>
])
# Now, the same again without megaflows.
AT_CHECK([ovs-appctl upcall/disable-megaflows], [0], [megaflows disabled
])
AT_CHECK([ovs-appctl upcall/disable-ufid], [0], [Datapath dumping tersely using UFID disabled
], [])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
OVS_WAIT_UNTIL([test `grep -c "miss upcall" ovs-vswitchd.log` -ge 2])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
])
ovs-appctl revalidator/wait
AT_CHECK([filter_flow_dump < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0/0xff),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions: <del>
recirc_id(0),dp_hash(0/0),skb_priority(0/0),in_port(1),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:0, bytes:0, used:never, actions: <del>
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_MISS_FLOW_DUMP([dummy])
DPIF_NETDEV_MISS_FLOW_DUMP([dummy-pmd])
AT_SETUP([dpif-netdev - meters])
# Create br0 with interfaces p1 and p7
# and br1 with interfaces p2 and p8
# with p1 and p2 connected via unix domain socket
OVS_VSWITCHD_START(
[add-port br0 p1 -- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock ofport_request=1 -- \
add-port br0 p7 -- set interface p7 ofport_request=7 type=dummy -- \
add-br br1 -- \
set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
fail-mode=secure -- \
add-port br1 p2 -- set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock ofport_request=2 -- \
add-port br1 p8 -- set interface p8 ofport_request=8 type=dummy --])
AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
AT_CHECK([ovs-ofctl -O OpenFlow13 add-meter br0 'meter=1 pktps burst stats bands=type=drop rate=1 burst_size=1'])
AT_CHECK([ovs-ofctl -O OpenFlow13 add-meter br0 'meter=2 kbps burst stats bands=type=drop rate=1 burst_size=2'])
AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 'in_port=1 action=meter:1,7'])
AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 'in_port=7 action=meter:2,1'])
AT_CHECK([ovs-ofctl add-flow br1 'in_port=2 action=8'])
AT_CHECK([ovs-ofctl add-flow br1 'in_port=8 action=2'])
ovs-appctl time/stop
AT_CHECK([ovs-ofctl -O OpenFlow13 dump-meters br0], [0], [dnl
OFPST_METER_CONFIG reply (OF1.3) (xid=0x2):
meter=1 pktps burst stats bands=
type=drop rate=1 burst_size=1
meter=2 kbps burst stats bands=
type=drop rate=1 burst_size=2
])
ovs-appctl time/warp 5000
for i in `seq 1 7`; do
AT_CHECK(
[ovs-appctl netdev-dummy/receive p7 \
'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
done
for i in `seq 1 5`; do
AT_CHECK(
[ovs-appctl netdev-dummy/receive p8 \
'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
done
sleep 1 # wait for forwarders process packets
# Meter 1 is measuring packets, allowing one packet per second with
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
# bursts of one packet, so 4 out of 5 packets should hit the drop band.
# Meter 2 is measuring kbps, with burst size 2 (== 2000 bits). 4 packets
# (240 bytes == 1920 bits) pass, but the last three packets should hit the
# drop band. There should be 80 bits remaining for the next packets.
AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl
OFPST_METER reply (OF1.3) (xid=0x2):
meter:1 flow_count:1 packet_in_count:5 byte_in_count:300 duration:0.0s bands:
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
0: packet_count:4 byte_count:240
meter:2 flow_count:1 packet_in_count:7 byte_in_count:420 duration:0.0s bands:
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
0: packet_count:3 byte_count:180
])
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
# Advance time by 870 ms
ovs-appctl time/warp 870
for i in `seq 1 5`; do
AT_CHECK(
[ovs-appctl netdev-dummy/receive p7 \
'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
AT_CHECK(
[ovs-appctl netdev-dummy/receive p8 \
'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
done
sleep 1 # wait for forwarders process packets
# Meter 1 is measuring packets, allowing one packet per second with
# bursts of one packet, so all 5 of the new packets should hit the drop
# band.
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
# Meter 2 is measuring kbps, with burst size 2 (== 2000 bits). After 870ms
# there should be space for 80 + 870 = 950 bits, so one new 60 byte (480 bit)
# packet should pass, remaining 4 should hit the drop band. There should be
# 470 bits left.
AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl
OFPST_METER reply (OF1.3) (xid=0x2):
meter:1 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands:
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
0: packet_count:9 byte_count:540
meter:2 flow_count:1 packet_in_count:12 byte_in_count:720 duration:0.0s bands:
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
0: packet_count:7 byte_count:420
])
# Advance time by 10 ms
ovs-appctl time/warp 10
for i in `seq 1 5`; do
AT_CHECK(
[ovs-appctl netdev-dummy/receive p7 \
'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
done
sleep 1 # wait for forwarders process packets
# Meter 1 should remain the same as we didn't send anything that should hit it.
# Meter 2 is measuring kbps, with burst size 2 (== 2000 bits). After 10ms
# there should be space for 470 + 10 = 480 bits, so one new 60 byte (480 bit)
# packet should pass, remaining 4 should hit the drop band.
AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl
OFPST_METER reply (OF1.3) (xid=0x2):
meter:1 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands:
0: packet_count:9 byte_count:540
meter:2 flow_count:1 packet_in_count:17 byte_in_count:1020 duration:0.0s bands:
0: packet_count:11 byte_count:660
])
userspace: Improved packet drop statistics. Currently OVS maintains explicit packet drop/error counters only on port level. Packets that are dropped as part of normal OpenFlow processing are counted in flow stats of “drop” flows or as table misses in table stats. These can only be interpreted by controllers that know the semantics of the configured OpenFlow pipeline. Without that knowledge, it is impossible for an OVS user to obtain e.g. the total number of packets dropped due to OpenFlow rules. Furthermore, there are numerous other reasons for which packets can be dropped by OVS slow path that are not related to the OpenFlow pipeline. The generated datapath flow entries include a drop action to avoid further expensive upcalls to the slow path, but subsequent packets dropped by the datapath are not accounted anywhere. Finally, the datapath itself drops packets in certain error situations. Also, these drops are today not accounted for.This makes it difficult for OVS users to monitor packet drop in an OVS instance and to alert a management system in case of a unexpected increase of such drops. Also OVS trouble-shooters face difficulties in analysing packet drops. With this patch we implement following changes to address the issues mentioned above. 1. Identify and account all the silent packet drop scenarios 2. Display these drops in ovs-appctl coverage/show Co-authored-by: Rohith Basavaraja <rohith.basavaraja@gmail.com> Co-authored-by: Keshav Gupta <keshugupta1@gmail.com> Signed-off-by: Anju Thomas <anju.thomas@ericsson.com> Signed-off-by: Rohith Basavaraja <rohith.basavaraja@gmail.com> Signed-off-by: Keshav Gupta <keshugupta1@gmail.com> Acked-by: Eelco Chaudron <echaudro@redhat.com Acked-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2019-12-18 05:48:12 +01:00
ovs-appctl time/warp 5000
AT_CHECK([
ovs-appctl coverage/read-counter datapath_drop_meter
], [0], [dnl
dpif-netdev: Remove meter rate from the bucket size calculation. Implementation of meters supposed to be a classic token bucket with 2 typical parameters: rate and burst size. Burst size in this schema is the maximum number of bytes/packets that could pass without being rate limited. Recent changes to userspace datapath made meter implementation to be in line with the kernel one, and this uncovered several issues. The main problem is that maximum bucket size for unknown reason accounts not only burst size, but also the numerical value of rate. This creates a lot of confusion around behavior of meters. For example, if rate is configured as 1000 pps and burst size set to 1, this should mean that meter will tolerate bursts of 1 packet at most, i.e. not a single packet above the rate should pass the meter. However, current implementation calculates maximum bucket size as (rate + burst size), so the effective bucket size will be 1001. This means that first 1000 packets will not be rate limited and average rate might be twice as high as the configured rate. This also makes it practically impossible to configure meter that will have burst size lower than the rate, which might be a desirable configuration if the rate is high. Inability to configure low values of a burst size and overall inability for a user to predict what will be a maximum and average rate from the configured parameters of a meter without looking at the OVS and kernel code might be also classified as a security issue, because drop meters are frequently used as a way of protection from DoS attacks. This change removes rate from the calculation of a bucket size, making it in line with the classic token bucket algorithm and essentially making the rate and burst tolerance being predictable from a users' perspective. Same change will be proposed for the kernel implementation. Unit tests changed back to their correct version and enhanced. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
2021-04-21 15:48:16 +02:00
20
userspace: Improved packet drop statistics. Currently OVS maintains explicit packet drop/error counters only on port level. Packets that are dropped as part of normal OpenFlow processing are counted in flow stats of “drop” flows or as table misses in table stats. These can only be interpreted by controllers that know the semantics of the configured OpenFlow pipeline. Without that knowledge, it is impossible for an OVS user to obtain e.g. the total number of packets dropped due to OpenFlow rules. Furthermore, there are numerous other reasons for which packets can be dropped by OVS slow path that are not related to the OpenFlow pipeline. The generated datapath flow entries include a drop action to avoid further expensive upcalls to the slow path, but subsequent packets dropped by the datapath are not accounted anywhere. Finally, the datapath itself drops packets in certain error situations. Also, these drops are today not accounted for.This makes it difficult for OVS users to monitor packet drop in an OVS instance and to alert a management system in case of a unexpected increase of such drops. Also OVS trouble-shooters face difficulties in analysing packet drops. With this patch we implement following changes to address the issues mentioned above. 1. Identify and account all the silent packet drop scenarios 2. Display these drops in ovs-appctl coverage/show Co-authored-by: Rohith Basavaraja <rohith.basavaraja@gmail.com> Co-authored-by: Keshav Gupta <keshugupta1@gmail.com> Signed-off-by: Anju Thomas <anju.thomas@ericsson.com> Signed-off-by: Rohith Basavaraja <rohith.basavaraja@gmail.com> Signed-off-by: Keshav Gupta <keshugupta1@gmail.com> Acked-by: Eelco Chaudron <echaudro@redhat.com Acked-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2019-12-18 05:48:12 +01:00
])
AT_CHECK([cat ovs-vswitchd.log | filter_flow_install | strip_xout_keep_actions], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:meter(0),7
recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:8
recirc_id(0),in_port(7),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:meter(1),1
recirc_id(0),in_port(8),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:2
])
AT_CHECK([ovs-ofctl -O OpenFlow13 del-meters br0])
OVS_VSWITCHD_STOP
AT_CLEANUP
m4_define([DPIF_NETDEV_FLOW_HW_OFFLOAD],
[AT_SETUP([dpif-netdev - partial hw offload - $1])
OVS_VSWITCHD_START(
[add-port br0 p1 -- \
set interface p1 type=$1 ofport_request=1 options:pstream=punix:$OVS_RUNDIR/p1.sock options:ifindex=1100 -- \
set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg netdev_dummy:file:dbg])
AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
OVS_WAIT_UNTIL([grep "netdev: Flow API Enabled" ovs-vswitchd.log])
AT_CHECK([ovs-ofctl del-flows br0])
AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=IN_PORT])
packet="packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no)"
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no)
])
# Check that flow successfully offloaded.
OVS_WAIT_UNTIL([grep "succeed to add netdev flow" ovs-vswitchd.log])
AT_CHECK([filter_hw_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
p1: flow put[[create]]: flow match: recirc_id=0,eth,ip,in_port=1,vlan_tci=0x0000/0x1fff,nw_frag=no, mark: 1
])
# Check that datapath flow installed successfully.
AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions: <del>
])
# Inject the same packet again.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
# Check for succesfull packet matching with installed offloaded flow.
AT_CHECK([filter_hw_packet_netdev_dummy < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: packet: ip,vlan_tci=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_proto=0,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no matches with flow: recirc_id=0,eth,ip,vlan_tci=0x0000/0x1fff,nw_frag=no with mark: 1
])
ovs-appctl revalidator/wait
# Dump the datapath flow to see that actions was executed for a packet.
AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:1, bytes:64, used:0.0s, actions:1
])
# Wait for datapath flow expiration.
ovs-appctl time/stop
ovs-appctl time/warp 15000
ovs-appctl revalidator/wait
# Check that flow successfully deleted from HW.
OVS_WAIT_UNTIL([grep "succeed to delete netdev flow" ovs-vswitchd.log])
AT_CHECK([filter_hw_flow_del < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: flow del: mark: 1
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_FLOW_HW_OFFLOAD([dummy])
DPIF_NETDEV_FLOW_HW_OFFLOAD([dummy-pmd])
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
m4_define([DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS],
[AT_SETUP([dpif-netdev - partial hw offload with packet modifications - $1])
OVS_VSWITCHD_START(
[add-port br0 p1 -- \
set interface p1 type=$1 ofport_request=1 options:pcap=p1.pcap options:ifindex=1101 -- \
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg netdev_dummy:file:dbg])
AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
OVS_WAIT_UNTIL([grep "netdev: Flow API Enabled" ovs-vswitchd.log])
AT_CHECK([ovs-ofctl del-flows br0])
# Setting flow to modify ipv4 src address and udp dst port to be sure that
# offloaded packets has correctly initialized l3/l4 offsets.
AT_CHECK([ovs-ofctl add-flow br0 in_port=1,udp,actions=mod_nw_src:192.168.0.7,mod_tp_dst:3773,output:IN_PORT])
packet="packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=17,ttl=64,frag=no),udp(src=81,dst=82))"
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),dnl
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=17,tos=0,ttl=64,frag=no),udp(src=81,dst=82))
])
# Check that flow successfully offloaded.
OVS_WAIT_UNTIL([grep "succeed to add netdev flow" ovs-vswitchd.log])
AT_CHECK([filter_hw_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
p1: flow put[[create]]: flow match: recirc_id=0,eth,udp,in_port=1,dl_vlan=99,nw_src=127.0.0.1,nw_frag=no,tp_dst=82, mark: 1
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
])
# Check that datapath flow installed successfully.
AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x8100),vlan(vid=99,pcp=7/0x0),encap(eth_type(0x0800),ipv4(src=127.0.0.1,proto=17,frag=no),udp(dst=82)), actions: <del>
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
])
# Inject the same packet again.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
# Check for succesfull packet matching with installed offloaded flow.
AT_CHECK([filter_hw_packet_netdev_dummy < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: packet: udp,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=81,tp_dst=82 dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
matches with flow: recirc_id=0,eth,udp,dl_vlan=99,nw_src=127.0.0.1,nw_frag=no,tp_dst=82 with mark: 1
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
])
ovs-appctl revalidator/wait
# Dump the datapath flow to see that actions was executed for a packet.
AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
dpif-netdev: Forwarding optimization for flows with a simple match. There are cases where users might want simple forwarding or drop rules for all packets received from a specific port, e.g :: "in_port=1,actions=2" "in_port=2,actions=IN_PORT" "in_port=3,vlan_tci=0x1234/0x1fff,actions=drop" "in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3" There are also cases where complex OpenFlow rules can be simplified down to datapath flows with very simple match criteria. In theory, for very simple forwarding, OVS doesn't need to parse packets at all in order to follow these rules. "Simple match" lookup optimization is intended to speed up packet forwarding in these cases. Design: Due to various implementation constraints userspace datapath has following flow fields always in exact match (i.e. it's required to match at least these fields of a packet even if the OF rule doesn't need that): - recirc_id - in_port - packet_type - dl_type - vlan_tci (CFI + VID) - in most cases - nw_frag - for ip packets Not all of these fields are related to packet itself. We already know the current 'recirc_id' and the 'in_port' before starting the packet processing. It also seems safe to assume that we're working with Ethernet packets. So, for the simple OF rule we need to match only on 'dl_type', 'vlan_tci' and 'nw_frag'. 'in_port', 'dl_type', 'nw_frag' and 13 bits of 'vlan_tci' can be combined in a single 64bit integer (mark) that can be used as a hash in hash map. We are using only VID and CFI form the 'vlan_tci', flows that need to match on PCP will not qualify for the optimization. Workaround for matching on non-existence of vlan updated to match on CFI and VID only in order to qualify for the optimization. CFI is always set by OVS if vlan is present in a packet, so there is no need to match on PCP in this case. 'nw_frag' takes 2 bits of PCP inside the simple match mark. New per-PMD flow table 'simple_match_table' introduced to store simple match flows only. 'dp_netdev_flow_add' adds flow to the usual 'flow_table' and to the 'simple_match_table' if the flow meets following constraints: - 'recirc_id' in flow match is 0. - 'packet_type' in flow match is Ethernet. - Flow wildcards contains only minimal set of non-wildcarded fields (listed above). If the number of flows for current 'in_port' in a regular 'flow_table' equals number of flows for current 'in_port' in a 'simple_match_table', we may use simple match optimization, because all the flows we have are simple match flows. This means that we only need to parse 'dl_type', 'vlan_tci' and 'nw_frag' to perform packet matching. Now we make the unique flow mark from the 'in_port', 'dl_type', 'nw_frag' and 'vlan_tci' and looking for it in the 'simple_match_table'. On successful lookup we don't need to run full 'miniflow_extract()'. Unsuccessful lookup technically means that we have no suitable flow in the datapath and upcall will be required. So, in this case EMC and SMC lookups are disabled. We may optimize this path in the future by bypassing the dpcls lookup too. Performance improvement of this solution on a 'simple match' flows should be comparable with partial HW offloading, because it parses same packet fields and uses similar flow lookup scheme. However, unlike partial HW offloading, it works for all port types including virtual ones. Performance results when compared to EMC: Test setup: virtio-user OVS virtio-user Testpmd1 ------------> pmd1 ------------> Testpmd2 (txonly) x<------ pmd2 <------------ (mac swap) Single stream of 64byte packets. Actions: in_port=vhost0,actions=vhost1 in_port=vhost1,actions=vhost0 Stats collected from pmd1 and pmd2, so there are 2 scenarios: Virt-to-Virt : Testpmd1 ------> pmd1 ------> Testpmd2. Virt-to-NoCopy : Testpmd2 ------> pmd2 --->x Testpmd1. Here the packet sent from pmd2 to Testpmd1 is always dropped, because the virtqueue is full since Testpmd1 is in txonly mode and doesn't receive any packets. This should be closer to the performance of a VM-to-Phy scenario. Test performed on machine with Intel Xeon CPU E5-2690 v4 @ 2.60GHz. Table below represents improvement in throughput when compared to EMC. +----------------+------------------------+------------------------+ | | Default (-g -O2) | "-Ofast -march=native" | | Scenario +------------+-----------+------------+-----------+ | | GCC | Clang | GCC | Clang | +----------------+------------+-----------+------------+-----------+ | Virt-to-Virt | +18.9% | +25.5% | +10.8% | +16.7% | | Virt-to-NoCopy | +24.3% | +33.7% | +14.9% | +22.0% | +----------------+------------+-----------+------------+-----------+ For Phy-to-Phy case performance improvement should be even higher, but it's not the main use-case for this functionality. Performance difference for the non-simple flows is within a margin of error. Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-08-09 14:57:52 +02:00
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x8100),vlan(vid=99,pcp=7/0x0),encap(eth_type(0x0800),ipv4(src=127.0.0.1,proto=17,frag=no),udp(dst=82)), dnl
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
packets:1, bytes:64, used:0.0s, actions:set(ipv4(src=192.168.0.7)),set(udp(dst=3773)),1
])
# Wait for datapath flow expiration.
ovs-appctl time/stop
ovs-appctl time/warp 15000
ovs-appctl revalidator/wait
# Check that flow successfully deleted from HW.
OVS_WAIT_UNTIL([grep "succeed to delete netdev flow" ovs-vswitchd.log])
AT_CHECK([filter_hw_flow_del < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: flow del: mark: 1
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
])
# Check that ip address and udp port were correctly modified in output packets.
AT_CHECK([ovs-ofctl parse-pcap p1.pcap], [0], [dnl
udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=81,tp_dst=82
udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=192.168.0.7,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=81,tp_dst=3773
udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=81,tp_dst=82
udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=192.168.0.7,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=81,tp_dst=3773
flow: Fix crash on vlan packets with partial offloading. parse_tcp_flags() does not care about vlan tags in a packet thus not able to parse them. As a result, if partial offloading is enabled in userspace datapath vlan packets are not parsed, i.e. has no initialized offsets. This causes OVS crash on any attempt to access/modify packet header fields. For example, having the flow with following actions: in_port=1,ip,actions=mod_nw_src:192.168.0.7,output:IN_PORT will lead to OVS crash on vlan packet handling: Process terminating with default action of signal 11 (SIGSEGV) Invalid read of size 4 at 0x785657: get_16aligned_be32 (unaligned.h:249) by 0x785657: odp_set_ipv4 (odp-execute.c:82) by 0x785657: odp_execute_masked_set_action (odp-execute.c:527) by 0x785657: odp_execute_actions (odp-execute.c:894) by 0x74CDA9: dp_netdev_execute_actions (dpif-netdev.c:7355) by 0x74CDA9: packet_batch_per_flow_execute (dpif-netdev.c:6339) by 0x74CDA9: dp_netdev_input__ (dpif-netdev.c:6845) by 0x74DB6E: dp_netdev_input (dpif-netdev.c:6854) by 0x74DB6E: dp_netdev_process_rxq_port (dpif-netdev.c:4287) by 0x74E863: dpif_netdev_run (dpif-netdev.c:5264) by 0x703F57: type_run (ofproto-dpif.c:370) by 0x6EC8B8: ofproto_type_run (ofproto.c:1760) by 0x6DA52B: bridge_run__ (bridge.c:3188) by 0x6E083F: bridge_run (bridge.c:3252) by 0x1642E4: main (ovs-vswitchd.c:127) Address 0xc is not stack'd, malloc'd or (recently) free'd Fix that by properly parsing vlan tags first. Function 'parse_dl_type' transformed for that purpose as it had no users anyway. Added unit test for packet modification with partial offloading that triggers above crash. Fixes: aab96ec4d81e ("dpif-netdev: retrieve flow directly from the flow mark") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
2019-10-23 22:26:52 +02:00
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS([dummy])
DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS([dummy-pmd])
m4_define([DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS_VID_ARP],
[AT_SETUP([dpif-netdev - partial hw offload with arp vlan id packet modifications - $1])
OVS_VSWITCHD_START(
[add-port br0 p1 -- \
set interface p1 type=$1 ofport_request=1 options:pcap=p1.pcap options:ifindex=1102 -- \
set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure], [], [],
[m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg netdev_dummy:file:dbg])
AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
OVS_WAIT_UNTIL([grep "netdev: Flow API Enabled" ovs-vswitchd.log])
AT_CHECK([ovs-ofctl del-flows br0])
# Setting flow to modify vlan id with arp packet to be sure that
# offloaded packets has correctly initialized l3 offset.
AT_CHECK([ovs-ofctl add-flow br0 in_port=1,arp,dl_vlan=99,actions=mod_vlan_vid=11,output:IN_PORT])
packet="packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0806),arp(sip=127.0.0.1,tip=127.0.0.1,op=1,sha=00:0b:0c:0d:0e:0f,tha=00:00:00:00:00:00))"
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
recirc_id(0),dp_hash(0),skb_priority(0),in_port(1),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),dnl
packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0806),arp(sip=127.0.0.1,tip=127.0.0.1,op=1,sha=00:0b:0c:0d:0e:0f,tha=00:00:00:00:00:00))
])
# Check that flow successfully offloaded.
OVS_WAIT_UNTIL([grep "succeed to add netdev flow" ovs-vswitchd.log])
AT_CHECK([filter_hw_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: flow put[[create]]: flow match: recirc_id=0,eth,arp,in_port=1,dl_vlan=99,dl_vlan_pcp=7, mark: 1
])
# Check that datapath flow installed successfully.
AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0806)), actions: <del>
])
# Inject the same packet again.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
# Check for succesfull packet matching with installed offloaded flow.
AT_CHECK([filter_hw_packet_netdev_dummy < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: packet: arp,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,arp_spa=127.0.0.1,arp_tpa=127.0.0.1,arp_op=1,arp_sha=00:0b:0c:0d:0e:0f,arp_tha=00:00:00:00:00:00 dnl
matches with flow: recirc_id=0,eth,arp,dl_vlan=99,dl_vlan_pcp=7 with mark: 1
])
ovs-appctl revalidator/wait
# Dump the datapath flow to see that actions was executed for a packet.
AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0806)), dnl
packets:1, bytes:64, used:0.0s, actions:pop_vlan,push_vlan(vid=11,pcp=7),1
])
# Wait for datapath flow expiration.
ovs-appctl time/stop
ovs-appctl time/warp 15000
ovs-appctl revalidator/wait
# Check that flow successfully deleted from HW.
OVS_WAIT_UNTIL([grep "succeed to delete netdev flow" ovs-vswitchd.log])
AT_CHECK([filter_hw_flow_del < ovs-vswitchd.log | strip_xout], [0], [dnl
p1: flow del: mark: 1
])
# Check that VLAN ID was correctly modified in output packets.
AT_CHECK([ovs-ofctl parse-pcap p1.pcap], [0], [dnl
arp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,arp_spa=127.0.0.1,arp_tpa=127.0.0.1,arp_op=1,arp_sha=00:0b:0c:0d:0e:0f,arp_tha=00:00:00:00:00:00
arp,in_port=ANY,dl_vlan=11,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,arp_spa=127.0.0.1,arp_tpa=127.0.0.1,arp_op=1,arp_sha=00:0b:0c:0d:0e:0f,arp_tha=00:00:00:00:00:00
arp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,arp_spa=127.0.0.1,arp_tpa=127.0.0.1,arp_op=1,arp_sha=00:0b:0c:0d:0e:0f,arp_tha=00:00:00:00:00:00
arp,in_port=ANY,dl_vlan=11,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,arp_spa=127.0.0.1,arp_tpa=127.0.0.1,arp_op=1,arp_sha=00:0b:0c:0d:0e:0f,arp_tha=00:00:00:00:00:00
])
OVS_VSWITCHD_STOP
AT_CLEANUP])
DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS_VID_ARP([dummy])
DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS_VID_ARP([dummy-pmd])
AT_SETUP([dpif-netdev - check dpctl/add-flow in_port exact match])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock \
-- set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure])
AT_CHECK([ovs-appctl dpctl/add-flow "eth(),eth_type(0x0800),ipv4()" "3"], [2],
[], [dnl
ovs-vswitchd: updating flow table (Invalid argument)
ovs-appctl: ovs-vswitchd: server returned an error
])
OVS_WAIT_UNTIL([grep "flow: in_port is not an exact match" ovs-vswitchd.log])
OVS_VSWITCHD_STOP(["/flow: in_port is not an exact match/d
/failed to put/d"])
AT_CLEANUP
dpif-netdev: Use unmasked key when adding datapath flows. The datapath supports installing wider flows, and OVS relies on this behavior. For example if ipv4(src=1.1.1.1/192.0.0.0, dst=1.1.1.2/192.0.0.0) exists, a wider flow (smaller mask) of ipv4(src=192.1.1.1/128.0.0.0,dst=192.1.1.2/128.0.0.0) is allowed to be added. However, if we try to add a wildcard rule, the installation fails: # ovs-appctl dpctl/add-flow system@myDP "in_port(1),eth_type(0x0800), \ ipv4(src=1.1.1.1/192.0.0.0,dst=1.1.1.2/192.0.0.0,frag=no)" 2 # ovs-appctl dpctl/add-flow system@myDP "in_port(1),eth_type(0x0800), \ ipv4(src=192.1.1.1/0.0.0.0,dst=49.1.1.2/0.0.0.0,frag=no)" 2 ovs-vswitchd: updating flow table (File exists) The reason is that the key used to determine if the flow is already present in the system uses the original key ANDed with the mask. This results in the IP address not being part of the (miniflow) key, i.e., being substituted with an all-zero value. When doing the actual lookup, this results in the key wrongfully matching the first flow, and therefore the flow does not get installed. The solution is to use the unmasked key for the existence check, the same way this is handled in the "slow" dpif_flow_put() case. OVS relies on the fact that overlapping flows can exist if one is a superset of the other. Note that this is only true when the same set of actions is applied. This is due to how the revalidator process works. During revalidation, OVS removes too generic flows from the datapath to avoid incorrect matches but allows too narrow flows to stay in the datapath to avoid the data plane disruption and also to avoid constant flow deletions if the datapath ignores wildcards on certain fields/bits. See flow_wildcards_has_extra() check in the revalidate_ukey__() function. The problem here is that we have a too narrow flow installed, and now OpenFlow rules got changed, so the actual flow should be more generic. Revalidators will not remove the narrow flow, and we will eventually get an upcall on the packet that doesn't match the narrow flow, but we will not be able to install a more generic flow because after masking with the new wider mask, the key matches on the narrow flow, so we get EEXIST. Fixes: beb75a40fdc2 ("userspace: Switching of L3 packets in L2 pipeline") Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-11-28 09:53:30 +01:00
AT_SETUP([dpif-netdev - check dpctl/add-flow wider ip match])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock \
-- set bridge br0 datapath-type=dummy])
AT_CHECK([ovs-appctl revalidator/pause])
AT_CHECK([ovs-appctl dpctl/add-flow "in_port(1),eth_type(0x0800),ipv4(src=0.0.0.0/192.0.0.0,dst=0.0.0.0/192.0.0.0,frag=no)" "3"])
AT_CHECK([ovs-appctl dpctl/add-flow "in_port(1),eth_type(0x0800),ipv4(src=192.1.1.1/0.0.0.0,dst=49.1.1.1/0.0.0.0,frag=no)" "3"])
AT_CHECK([ovs-appctl revalidator/resume])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([dpif-netdev - check tx packet checksum offloading])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock \
-- set bridge br0 datapath-type=dummy \
other-config:datapath-id=1234 fail-mode=secure])
AT_CHECK([ovs-vsctl get interface p1 status | sed -n 's/^{\(.*\).*}$/\1/p'], [0], [dnl
tx_geneve_tso_offload="false", tx_gre_tso_offload="false", tx_ip_csum_offload="false", tx_out_ip_csum_offload="false", tx_out_udp_csum_offload="false", tx_sctp_csum_offload="false", tx_tcp_csum_offload="false", tx_tcp_seg_offload="false", tx_udp_csum_offload="false", tx_vxlan_tso_offload="false"
], [])
AT_CHECK([ovs-vsctl get interface br0 status | sed -n 's/^{\(.*\).*}$/\1/p'], [0], [dnl
tx_geneve_tso_offload="false", tx_gre_tso_offload="false", tx_ip_csum_offload="false", tx_out_ip_csum_offload="false", tx_out_udp_csum_offload="false", tx_sctp_csum_offload="false", tx_tcp_csum_offload="false", tx_tcp_seg_offload="false", tx_udp_csum_offload="false", tx_vxlan_tso_offload="false"
], [])
OVS_VSWITCHD_STOP
AT_CLEANUP
# SEND_UDP_PKTS([p_name], [p_ofport])
#
# Sends 128 packets to port 'p_name' with different UDP destination ports.
m4_define([SEND_UDP_PKTS],
[
for i in `seq 1 128`; do
pkt="in_port($2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:01:00),eth_type(0x0800),ipv4(src=10.0.1.1,dst=10.0.0.1,proto=17),udp(src=1000,dst=$i)"
ovs-appctl netdev-dummy/receive $1 $pkt --len 256
done
]
)
AT_SETUP([dpif-netdev - tx packet steering])
OVS_VSWITCHD_START(
[add-port br0 p1 -- set Interface p1 type=dummy-pmd ofport_request=1], [], [], [--dummy-numa 0])
dnl 'thread' mode, packets are expected to be transmitted on a single
dnl queue since there is only one PMD thread.
AT_CHECK([ovs-vsctl add-port br0 p2 -- set Interface p2 type=dummy-pmd ofport_request=2 options:n_txq=2 other_config:tx-steering=thread])
AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=output:2])
AT_CHECK([SEND_UDP_PKTS([p1], [1])])
OVS_WAIT_UNTIL([test `ovs-vsctl get Interface p2 statistics:tx_packets` -eq 128])
AT_CHECK([ovs-vsctl get Interface p2 statistics], [], [stdout])
AT_CHECK([test `ovs-vsctl get Interface p2 statistics:tx_q0_packets` -eq 0 -a dnl
`ovs-vsctl get Interface p2 statistics:tx_q1_packets` -eq 128 || dnl
test `ovs-vsctl get Interface p2 statistics:tx_q0_packets` -eq 128 -a dnl
`ovs-vsctl get Interface p2 statistics:tx_q1_packets` -eq 0])
AT_CHECK([ovs-vsctl del-port p2])
dnl 'hash' mode, packets are expected to be transmitted on both
dnl queues, based on their hash value.
AT_CHECK([ovs-vsctl add-port br0 p2 -- set Interface p2 type=dummy-pmd ofport_request=2 options:n_txq=2 other_config:tx-steering=hash])
AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=output:2])
AT_CHECK([SEND_UDP_PKTS([p1], [1])])
OVS_WAIT_UNTIL([test `ovs-vsctl get Interface p2 statistics:tx_packets` -eq 128])
AT_CHECK([ovs-vsctl get Interface p2 statistics], [], [stdout])
AT_CHECK([test `ovs-vsctl get Interface p2 statistics:tx_q0_packets` -gt 0 -a dnl
`ovs-vsctl get Interface p2 statistics:tx_q1_packets` -gt 0])
AT_CHECK([ovs-vsctl del-port p2])
dnl 'hash' mode with hw-offload enabled, packets are expected to be transmitted on both
dnl queues, based on their hash value.
AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
AT_CHECK([ovs-vsctl add-port br0 p2 -- set Interface p2 type=dummy-pmd ofport_request=2 options:n_txq=2 other_config:tx-steering=hash])
AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=output:2])
AT_CHECK([SEND_UDP_PKTS([p1], [1])])
OVS_WAIT_UNTIL([test `ovs-vsctl get Interface p2 statistics:tx_packets` -eq 128])
AT_CHECK([ovs-vsctl get Interface p2 statistics], [], [stdout])
AT_CHECK([test `ovs-vsctl get Interface p2 statistics:tx_q0_packets` -gt 0 -a dnl
`ovs-vsctl get Interface p2 statistics:tx_q1_packets` -gt 0])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - ip csum offload])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Modify the ip_dst addr to force changing the IP csum.
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,actions=mod_nw_dst:192.168.1.1,output:p2])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
tcp,ip_src=192.168.123.2,ip_dst=192.168.123.1,ip_frag=no,\
tcp_src=54392,tcp_dst=5201,tcp_flags=ack"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
dnl Checks for good packet (Tx offloads disabled).
flow_expected=$(echo "${flow_s}" | sed 's/192.168.123.1/192.168.1.1/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads disabled).
bad_frame=$(ovs-ofctl compose-packet --bare --bad-csum "${flow_s}")
bad_expected=$(ovs-ofctl compose-packet --bare --bad-csum "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
dnl In this case, datapath will fix the csum as it trusts the Rx status.
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Checks for good packet (Tx offloads enabled).
AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_tx_csum=true])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads enabled).
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
dnl In this case, datapath will fix the csum as it trusts the Rx status.
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Special case, to check if Tx offload did happen in the driver.
AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_tx_csum_disabled=true])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
dnl The bad IP checksum is left untouched but the IP address and the TCP.
dnl checksum got updated.
first_part_bad=$(echo $bad_frame | sed -ne "s/^\(.*\)c0a87b02c0a87b01.*$/\1/p")
second_part_good=$(echo $good_expected | sed -ne "s/^.*\(c0a87b02c0a80101.*$\)/\1/p")
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${first_part_bad}${second_part_good}
])
AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_tx_csum_disabled=false])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Test with IP optional fields in a valid packet. Note that neither this
dnl packet nor the following one contain a correct checksum. OVS is
dnl expected to replace this dummy checksum with a valid one if possible.
m4_define([OPT_PKT], m4_join([],
dnl eth(dst=aa:aa:aa:aa:aa:aa,src=bb:bb:bb:bb:bb:bb,type=0x0800)
[aaaaaaaaaaaabbbbbbbbbbbb0800],
dnl ipv4(dst=10.0.0.2,src=10.0.0.1,proto=1,len=60,tot_len=68,csum=0xeeee)
[4f000044abab00004001eeee0a0000010a000002],
dnl IPv4 Opt: type 7 (Record Route) len 39 + type 0 (EOL).
[07270c010203040a000003000000000000000000],
[0000000000000000000000000000000000000000],
dnl icmp(type=8,code=0), csum 0x3e2f incorrect, should be 0x412f.
[08003e2fb6d00000]))
dnl IP header indicates optional fields but doesn't contain any.
m4_define([MICROGRAM], m4_join([],
dnl eth(dst=aa:aa:aa:aa:aa:aa,src=bb:bb:bb:bb:bb:bb,type=0x0800)
[aaaaaaaaaaaabbbbbbbbbbbb0800],
dnl ipv4(dst=10.0.0.2,src=10.0.0.1,proto=1,len=60,tot_len=68,csum=0xeeee)
[4f000044abab00004001eeee0a0000010a000002]))
AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_tx_csum=true])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 OPT_PKT])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 MICROGRAM])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
dnl Build the expected modified packets. The first packet has a valid IPv4
dnl checksum and modified destination IP address. The second packet isn't
dnl expected to change.
AT_CHECK([echo "OPT_PKT" | sed -e "s/0a000002/c0a80101/" -e "s/eeee/dd2e/" > expout])
AT_CHECK([echo "MICROGRAM" >> expout])
AT_CHECK([tail -n 2 p2.pcap.txt], [0], [expout])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - tcp csum offload])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Modify the tcp_dst port to force changing the TCP csum.
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,tcp,actions=mod_tp_dst:2222,output:p2])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
tcp,ip_src=192.168.123.2,ip_dst=192.168.123.1,ip_frag=no,\
tcp_src=54392,tcp_dst=5201,tcp_flags=ack"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
dnl Checks for good packet (Tx offloads disabled).
flow_expected=$(echo "${flow_s}" | sed 's/5201/2222/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads disabled).
bad_frame=$(echo $good_frame | sed -e "s/6b72/dead/")
dnl 0x6b72 + (5201-2222) == 0x7715
dnl 0xdead + (5201-2222) == 0xea50
bad_expected=$(echo $good_expected | sed -e "s/7715/ea50/")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for good packet (Tx offloads enabled).
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum=true])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads enabled).
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Special case, to check if Tx offload did happen in the driver.
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=true])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
dnl The bad TCP checksum is left untouched.
bad_updated=$(echo $good_expected | sed -e "s/7715/dead/")
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_updated}
])
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=false])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - tcp csum offload (simple match)])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,actions=output:p2])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
tcp,ip_src=192.168.123.2,ip_dst=192.168.123.1,ip_frag=no,\
tcp_src=54392,tcp_dst=5201,tcp_flags=ack"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
bad_frame=$(echo $good_frame | sed -e "s/6b72/dead/")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_frame}
])
dnl First packet, no simple matching.
AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | grep 'simple match hits'], [0], [dnl
simple match hits: 0
])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_frame}
])
AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | grep 'simple match hits'], [0], [dnl
simple match hits: 1
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_frame}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | grep 'simple match hits'], [0], [dnl
simple match hits: 2
])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_frame}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | grep 'simple match hits'], [0], [dnl
simple match hits: 3
])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_frame}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | grep 'simple match hits'], [0], [dnl
simple match hits: 4
])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - udp csum offload])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Modify the udp_dst port to force changing the UDP csum.
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,udp,actions=mod_tp_dst:2222,output:p2])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
udp,ip_src=192.168.123.2,ip_dst=192.168.123.1,ip_frag=no,\
udp_src=54392,udp_dst=5201"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
dnl Checks for good packet (Tx offloads disabled).
flow_expected=$(echo "${flow_s}" | sed 's/5201/2222/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads disabled).
bad_frame=$(echo $good_frame | sed -e "s/bb3b/dead/")
dnl 0xbb3b + (5201-2222) == 0xc6de
dnl 0xdead + (5201-2222) == 0xea50
bad_expected=$(echo $good_expected | sed -e "s/c6de/ea50/")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for good packet (Tx offloads enabled).
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum=true])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads enabled).
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Special case, to check if Tx offload did happen in the driver.
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=true])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
dnl The bad UDP checksum is left untouched.
bad_updated=$(echo $good_expected | sed -e "s/c6de/dead/")
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_updated}
])
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=false])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - IPv6 tcp csum offload])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Modify the tcp_dst port to force changing the TCP csum.
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,tcp6,actions=mod_tp_dst:2222,output:p2])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
tcp6,ipv6_src=fe80::2,ipv6_dst=fe80::1,\
tcp_src=54392,tcp_dst=5201,tcp_flags=ack"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
dnl Checks for good packet (Tx offloads disabled).
flow_expected=$(echo "${flow_s}" | sed 's/5201/2222/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads disabled).
bad_frame=$(echo $good_frame | sed -e "s/e5c2/dead/")
dnl 0xe5c2 + (5201-2222) == 0xf165
dnl 0xdead + (5201-2222) == 0xea50
bad_expected=$(echo $good_expected | sed -e "s/f165/ea50/")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for good packet (Tx offloads enabled).
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum=true])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads enabled).
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Special case, to check if Tx offload did happen in the driver.
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=true])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
dnl The bad TCP checksum is left untouched.
bad_updated=$(echo $good_expected | sed -e "s/f165/dead/")
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_updated}
])
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=false])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - IPv6 udp csum offload])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Modify the udp_dst port to force changing the UDP csum.
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,udp6,actions=mod_tp_dst:2222,output:p2])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
udp6,ipv6_src=fe80::2,ipv6_dst=fe80::1,\
udp_src=54392,udp_dst=5201"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
dnl Checks for good packet (Tx offloads disabled).
flow_expected=$(echo "${flow_s}" | sed 's/5201/2222/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads disabled).
bad_frame=$(echo $good_frame | sed -e "s/358c/dead/")
dnl 0x358c + (5201-2222) == 0x412f
dnl 0xdead + (5201-2222) == 0xea50
bad_expected=$(echo $good_expected | sed -e "s/412f/ea50/")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for good packet (Tx offloads enabled).
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum=true])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads enabled).
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_bad=false])
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_partial=false])
dnl Special case, to check if Tx offload did happen in the driver.
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=true])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=true])
dnl The bad UDP checksum is left untouched.
bad_updated=$(echo $good_expected | sed -e "s/412f/dead/")
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${bad_updated}
])
AT_CHECK([ovs-vsctl set Interface p2 options:ol_l4_tx_csum_disabled=false])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_l4_rx_csum_set_good=false])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - conntrack])
OVS_VSWITCHD_START(
[add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy --])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Modify the ip_dst addr to force changing the IP csum.
AT_CHECK([ovs-ofctl add-flow br1 'in_port=p1,ip,ct_state=-trk,actions=ct(commit,nat(dst=192.168.1.1),table=0),p2'])
flow_s="\
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,\
tcp,ip_src=192.168.123.2,ip_dst=192.168.123.1,ip_frag=no,\
tcp_src=54392,tcp_dst=5201,tcp_flags=ack"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s}")
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [0
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [0
])
dnl Checks for good packet (Tx offloads disabled).
flow_expected=$(echo "${flow_s}" | sed 's/192.168.123.1/192.168.1.1/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [1
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [0
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [1
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [0
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [1
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [1
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads disabled).
bad_frame=$(ovs-ofctl compose-packet --bare --bad-csum "${flow_s}")
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [2
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [2
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [2
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [2
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
dnl In this case, datapath will fix the csum as it trusts the Rx status.
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [2
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [3
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Checks for good packet (Tx offloads enabled).
AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_tx_csum=true])
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [3
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [3
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [3
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [3
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [3
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [4
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${good_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [3
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [4
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Checks for bad packet (Tx offloads enabled).
dnl No Rx flag.
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [4
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [5
])
dnl Flag as Rx good.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [4
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [5
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
dnl In this case, datapath will fix the csum as it trusts the Rx status.
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
dnl Flag as Rx bad.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [4
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [6
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_bad=false])
dp-packet: Rework IP checksum offloads. As the packet traverses through OVS, offloading Tx flags must be carefully evaluated and updated which results in a bit of complexity because of a separate "outer" Tx offloading flag coming from DPDK API, and a "normal"/"inner" Tx offloading flag. On the other hand, the DPDK mbuf API specifies 4 status when it comes to IP checksums: - RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum - RTE_MBUF_F_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong - RTE_MBUF_F_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid - RTE_MBUF_F_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet data, but the integrity of the IP header is verified. This patch changes OVS API so that OVS code only tracks the status of the checksum of the "current" L3 header and let the Tx flags aspect to the netdev-* implementations. With this API, the flow extraction can be cleaned up. During packet processing, OVS can simply look for the IP checksum validity (either good, or partial) before changing some IP header, and then mark the checksum as partial. In the conntrack case, when natting packets, the checksum status of the inner part (ICMP error case) must be forced temporarily as unknown to force checksum resolution. When tunneling comes into play, IP checksums status is bit-shifted for future considerations in the processing if, for example, the tunnel header gets decapsulated again, or in the netdev-* implementations that support tunnel offloading. Finally, netdev-* implementations only need to care about packets in partial status: a good checksum does not need touching, a bad checksum has been updated by kept as bad by OVS, an unknown checksum is either an IPv6 or if it was an IPv4, OVS updated it too (keeping it good or bad accordingly). Rename current API for consistency with dp_packet_(inner_)?ip_checksum_. Signed-off-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-17 09:20:57 +02:00
dnl Flag as Rx partial.
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=true])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${bad_frame}])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_checked], [0], [4
])
AT_CHECK([ovs-appctl coverage/read-counter conntrack_l3csum_err], [0], [6
])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
dnl In this case, datapath will fix the csum as it trusts the Rx status.
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_partial=false])
dnl Special case, check natted ICMP (for traffic flagged good).
icmp_frame="0a8f393fe0738abf7e2f05840800450000440001000040010364c0a87b02c0a87b010303746c0000000045000028000100004006037bc0a87b01c0a87b021451d4780000000000000000500220002fc40000"
icmp_expected="0a8f393fe0738abf7e2f05840800450000440001000040017d64c0a87b02c0a801010303fa6b00000000450000280001000040067d7bc0a80101c0a87b021451d478000000000000000050022000a9c40000"
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=true])
AT_CHECK([ovs-ofctl add-flow br1 'in_port=p1,icmp,ct_state=-trk,actions=ct(commit,nat(dst=192.168.1.1)),p2'])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 ${icmp_frame}])
AT_CHECK([ovs-pcap p2.pcap > p2.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${icmp_expected}
])
AT_CHECK([ovs-vsctl set Interface p1 options:ol_ip_rx_csum_set_good=false])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - tso])
OVS_VSWITCHD_START(
[set Open_vSwitch . other_config:userspace-tso-enable=true -- \
add-br br1 -- set bridge br1 datapath-type=dummy -- \
add-port br1 p1 -- \
set Interface p1 type=dummy -- \
add-port br1 p2 -- \
set Interface p2 type=dummy])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl Simple passthrough rule.
AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,actions=output:p2])
flow_s="in_port(1),eth(src=8a:bf:7e:2f:05:84,dst=0a:8f:39:4f:e0:73),eth_type(0x0800), \
ipv4(src=192.168.123.2,dst=192.168.123.1,proto=6,tos=1,ttl=64,frag=no), \
tcp(src=54392,dst=5201),tcp_flags(ack)"
flow_s_v6="in_port(1),eth(src=8a:bf:7e:2f:05:84,dst=0a:8f:39:4f:e0:73),eth_type(0x86dd), \
ipv6(src=2001:cafe::88,dst=2001:cafe::92,proto=6), \
tcp(src=54392,dst=5201),tcp_flags(ack)"
dnl Send from tso to no-tso.
AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap -- \
set Interface p1 options:ol_tso_segsz=500])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s}" --len 2054])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s_v6}" --len 2074])
dnl Send from tso to tso.
AT_CHECK([ovs-vsctl set Interface p2 options:ol_tso_segsz=500])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s}" --len 2054])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s_v6}" --len 2074])
dnl Check that first we have:
dnl - 4x IPv4 500 byte payloads
dnl - 4x IPv6 500 byte payloads
dnl - one IPv4 2000 byte payload, and
dnl - one IPv6 2000 byte payload
zero500=$(printf '0%.0s' $(seq 1000))
AT_CHECK_UNQUOTED([ovs-pcap p2.pcap], [0], [dnl
[0a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02c0a87b01]dnl
[d47814510000000000000000501000004dc20000${zero500}]
[0a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02c0a87b01]dnl
[d4781451000001f400000000501000004bce0000${zero500}]
[0a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02c0a87b01]dnl
[d4781451000003e8000000005010000049da0000${zero500}]
[0a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02c0a87b01]dnl
[d4781451000005dc000000005010000047e60000${zero500}]
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000]dnl
[882001cafe000000000000000000000092d4781451000000000000000050100000edfd0000]dnl
[${zero500}]
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000]dnl
[882001cafe000000000000000000000092d4781451000001f40000000050100000ec090000]dnl
[${zero500}]
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000]dnl
[882001cafe000000000000000000000092d4781451000003e80000000050100000ea150000]dnl
[${zero500}]
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000]dnl
[882001cafe000000000000000000000092d4781451000005dc0000000050100000e8210000]dnl
[${zero500}]
[0a8f394fe0738abf7e2f05840800450107f8000000004006fbaac0a87b02c0a87b01]dnl
[d478145100000000000000005010000047e60000${zero500}${zero500}${zero500}${zero500}]
[0a8f394fe0738abf7e2f058486dd6000000007e406002001cafe0000000000000000000000]dnl
[882001cafe000000000000000000000092d4781451000000000000000050100000e8210000]dnl
[${zero500}${zero500}${zero500}${zero500}]
])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([userspace offload - tunnel tso fallback])
OVS_VSWITCHD_START([set Open_vSwitch . other_config:userspace-tso-enable=true \
-- add-br br1 -- set bridge br1 datapath-type=dummy \
other-config:hwaddr=aa:55:aa:55:00:03 \
-- add-port br1 p1 -- set Interface p1 type=dummy \
ofport_request=1])
AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy \
-- add-port int-br t1 -- set Interface t1 type=vxlan \
options:remote_ip=1.1.2.92 options:key=123 \
options:csum=true ofport_request=2 \
-- add-port int-br t2 -- set Interface t2 type=geneve \
options:remote_ip=1.1.2.92 options:key=123 \
options:csum=true ofport_request=3 \
-- add-port int-br t3 -- set Interface t3 type=vxlan \
options:remote_ip=2001:cafe::93 options:key=123 \
options:csum=true ofport_request=4 \
-- add-port int-br t4 -- set Interface t4 type=geneve \
options:remote_ip=2001:cafe::93 options:key=123 \
options:csum=true ofport_request=5 \
-- add-port int-br t5 -- set Interface t5 type=gre \
options:remote_ip=2001:cafe::93 options:key=123 \
options:csum=true ofport_request=6 \
-- add-port int-br t6 -- set Interface t6 type=gre \
options:remote_ip=1.1.2.92 options:key=123 \
options:csum=false ofport_request=7], [0])
AT_CHECK([ovs-appctl vlog/set netdev_dummy:file:dbg])
dnl The final tunnel intentionally has checksum turned off to exercise a
dnl different code path, there is no GRE checksum offload anyways.
m4_define([IPV4_TSO], [m4_join([,],
[eth(src=8a:bf:7e:2f:05:84,dst=0a:8f:39:4f:e0:73),eth_type(0x0800)],
[ipv4(src=192.168.123.2,dst=192.168.123.1,proto=6,tos=1,ttl=64,frag=no)],
[tcp(src=54392,dst=5201),tcp_flags(ack)])])
m4_define([IPV6_TSO], [m4_join([,],
[eth(src=8a:bf:7e:2f:05:84,dst=0a:8f:39:4f:e0:73),eth_type(0x86dd)],
[ipv6(src=2001:cafe::88,dst=2001:cafe::92,proto=6)],
[tcp(src=54392,dst=5201),tcp_flags(ack)])])
dnl Setup dummy interface tunnel connectivity.
AT_CHECK([ovs-appctl netdev-dummy/ip4addr br1 1.1.2.88/24], [0], [OK
])
AT_CHECK([ovs-appctl netdev-dummy/ip6addr br1 2001:cafe::88/24], [0], [OK
])
AT_CHECK([ovs-appctl tnl/neigh/set br1 1.1.2.92 aa:bb:cc:00:00:01], [0], [OK
])
AT_CHECK([ovs-appctl tnl/neigh/set br1 2001:cafe::93 aa:bb:cc:00:00:06], [0],
[OK
])
AT_CHECK([ovs-appctl tnl/egress_port_range 57363 57363], [0], [OK
])
AT_CHECK([ovs-ofctl add-flow br1 action=normal])
AT_CHECK([ovs-ofctl add-flow int-br action=normal])
dnl Configure the TX interface to segment.
AT_CHECK([ovs-vsctl set Interface p1 options:tx_pcap=p1.pcap -- \
set Interface int-br options:ol_tso_segsz=500])
AT_CHECK([ovs-appctl netdev-dummy/receive int-br "IPV4_TSO" \
--len 2054])
AT_CHECK([ovs-appctl netdev-dummy/receive int-br "IPV6_TSO" \
--len 2074])
dnl Check that first we have the following packets:
dnl - IPv4 VXLAN tunnel with IPv4 payload
dnl - IPv4 VXLAN tunnel with IPv6 payload
dnl - IPv6 VXLAN tunnel with IPv4 payload
dnl - IPv6 VXLAN tunnel with IPv6 payload
dnl - IPv4 Geneve tunnel with IPv4 payload
dnl - IPv4 Geneve tunnel with IPv6 payload
dnl - IPv6 Geneve tunnel with IPv4 payload
dnl - IPv6 Geneve tunnel with IPv6 payload
dnl - IPv6 Geneve tunnel with IPv4 payload
dnl - IPv6 Geneve tunnel with IPv6 payload
dnl - IPv4 GRE tunnel with IPv4 payload
dnl - IPv4 GRE tunnel with IPv6 payload
dnl - IPv6 GRE tunnel with IPv4 payload
dnl - IPv6 GRE tunnel with IPv6 payload
dnl These are sorted since OVS may send payloads to the tunnels in any order.
zero400=$(printf '0%.0s' $(seq 800))
zero100=$(printf '0%.0s' $(seq 200))
AT_CHECK_UNQUOTED([ovs-pcap p1.pcap | sort], [0], [dnl
[aabbcc000001aa55aa55000308004500025a00004000402f31c0010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe000000000000000000000092d4781451]dnl
[000000000000000050100000edfd0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500025a00014000402f31bf010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe000000000000000000000092d4781451]dnl
[000001f40000000050100000ec090000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500025a00024000402f31be010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe000000000000000000000092d4781451]dnl
[000003e80000000050100000ea150000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500025a00034000402f31bd010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe000000000000000000000092d4781451]dnl
[000005dc0000000050100000e8210000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200004000401131d6010102580101025ce01312b5024e5f360800000000007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000000000000000050100000edfd0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200004000401131d6010102580101025ce01317c1024efcd10000655800007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000000000000000050100000edfd0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200014000401131d5010102580101025ce01312b5024e5f360800000000007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000001f40000000050100000ec090000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200014000401131d5010102580101025ce01317c1024efcd10000655800007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000001f40000000050100000ec090000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200024000401131d4010102580101025ce01312b5024e5f360800000000007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000003e80000000050100000ea150000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200024000401131d4010102580101025ce01317c1024efcd10000655800007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000003e80000000050100000ea150000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200034000401131d3010102580101025ce01312b5024e5f360800000000007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000005dc0000000050100000e8210000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004500026200034000401131d3010102580101025ce01317c1024efcd10000655800007b00]dnl
[0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000092d4781451000005dc0000000050100000e8210000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024600004000402f31d3010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058408004501021c0000000040060187c0a87b02c0a87b01d47814510000000000000000501000004dc20000]dnl
[${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024600014000402f31d2010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058408004501021c0001000040060186c0a87b02c0a87b01d4781451000001f400000000501000004bce0000]dnl
[${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024600024000402f31d1010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058408004501021c0002000040060185c0a87b02c0a87b01d4781451000003e8000000005010000049da0000]dnl
[${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024600034000402f31d0010102580101025c200065580000007b0a8f394fe0738abf]dnl
[7e2f058408004501021c0003000040060184c0a87b02c0a87b01d4781451000005dc000000005010000047e60000]dnl
[${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00004000401131e9010102580101025ce01312b5023abd990800000000007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02c0a87b01d4781451000000000000000050100000]dnl
[4dc20000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00004000401131e9010102580101025ce01317c1023a5b350000655800007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02c0a87b01d4781451000000000000000050100000]dnl
[4dc20000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00014000401131e8010102580101025ce01312b5023abd990800000000007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02c0a87b01d4781451000001f40000000050100000]dnl
[4bce0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00014000401131e8010102580101025ce01317c1023a5b350000655800007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02c0a87b01d4781451000001f40000000050100000]dnl
[4bce0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00024000401131e7010102580101025ce01312b5023abd990800000000007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02c0a87b01d4781451000003e80000000050100000]dnl
[49da0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00024000401131e7010102580101025ce01317c1023a5b350000655800007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02c0a87b01d4781451000003e80000000050100000]dnl
[49da0000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00034000401131e6010102580101025ce01312b5023abd990800000000007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02c0a87b01d4781451000005dc0000000050100000]dnl
[47e60000${zero100}${zero400}]
[aabbcc000001aa55aa55000308004501024e00034000401131e6010102580101025ce01317c1023a5b350000655800007b00]dnl
[0a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02c0a87b01d4781451000005dc0000000050100000]dnl
[47e60000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60000000024a2f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a0006558da8e00000000007b0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000]dnl
[000000882001cafe000000000000000000000092d4781451000005dc0000000050100000e8210000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60000000024a2f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a0006558dc8200000000007b0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000]dnl
[000000882001cafe000000000000000000000092d4781451000003e80000000050100000ea150000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60000000024a2f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a0006558de7600000000007b0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000]dnl
[000000882001cafe000000000000000000000092d4781451000001f40000000050100000ec090000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60000000024a2f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a0006558e06a00000000007b0a8f394fe0738abf7e2f058486dd60000000020806002001cafe0000000000000000]dnl
[000000882001cafe000000000000000000000092d4781451000000000000000050100000edfd0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5024e8ed10800000000007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000000000000000050100000edfd0000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5024e8ed10800000000007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000001f40000000050100000ec090000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5024e8ed10800000000007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000003e80000000050100000ea150000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5024e8ed10800000000007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000005dc0000000050100000e8210000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1024e2c6d0000655800007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000000000000000050100000edfd0000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1024e2c6d0000655800007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000001f40000000050100000ec090000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1024e2c6d0000655800007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000003e80000000050100000ea150000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd60000000024e11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1024e2c6d0000655800007b000a8f394fe0738abf7e2f058486dd60000000020806002001cafe00000000]dnl
[00000000000000882001cafe000000000000000000000092d4781451000005dc0000000050100000e8210000${zero100}]dnl
[${zero400}]
[aabbcc000006aa55aa55000386dd6010000002362f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a00065583a4e00000000007b0a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02c0a87b01]dnl
[d4781451000005dc000000005010000047e60000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd6010000002362f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a00065583c4300000000007b0a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02c0a87b01]dnl
[d4781451000003e8000000005010000049da0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd6010000002362f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a00065583e3800000000007b0a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02c0a87b01]dnl
[d4781451000001f400000000501000004bce0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd6010000002362f402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093a0006558402d00000000007b0a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02c0a87b01]dnl
[d47814510000000000000000501000004dc20000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5023aed340800000000007b000a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02]dnl
[c0a87b01d47814510000000000000000501000004dc20000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5023aed340800000000007b000a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02]dnl
[c0a87b01d4781451000001f400000000501000004bce0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5023aed340800000000007b000a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02]dnl
[c0a87b01d4781451000003e8000000005010000049da0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01312b5023aed340800000000007b000a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02]dnl
[c0a87b01d4781451000005dc000000005010000047e60000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1023a8ad00000655800007b000a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02]dnl
[c0a87b01d47814510000000000000000501000004dc20000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1023a8ad00000655800007b000a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02]dnl
[c0a87b01d4781451000001f400000000501000004bce0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1023a8ad00000655800007b000a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02]dnl
[c0a87b01d4781451000003e8000000005010000049da0000${zero100}${zero400}]
[aabbcc000006aa55aa55000386dd60100000023a11402001cafe0000000000000000000000882001cafe0000000000000000]dnl
[00000093e01317c1023a8ad00000655800007b000a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02]dnl
[c0a87b01d4781451000005dc000000005010000047e60000${zero100}${zero400}]
])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([dpif-netdev - revalidators handle dp modification fail correctly])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set interface p1 type=dummy \
-- set bridge br0 datapath-type=dummy \
-- add-port br0 p2 \
-- set interface p2 type=dummy --
])
AT_CHECK([ovs-ofctl add-flow br0 'table=0,in_port=p1,actions=p2'])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'ipv4(src=10.0.0.1,dst=10.0.0.2),tcp(src=1,dst=2)'])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'ipv4(src=10.0.0.1,dst=10.0.0.2),tcp(src=1,dst=2)'])
AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/.*thread://' | strip_xout_keep_actions ], [0], [
recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:0.0s, actions:2
])
dnl Wait for the dp flow to enter OPERATIONAL state.
AT_CHECK([ovs-appctl revalidator/wait])
AT_CHECK([ovs-appctl revalidator/pause])
dnl Delete all dp flows, so flow modification will fail.
AT_CHECK([ovs-appctl dpctl/del-flows])
AT_CHECK([ovs-appctl revalidator/resume])
dnl Replace OpenFlow rules, trigger revalidation and wait for it to complete.
AT_CHECK([echo 'table=0,in_port=p1,ip actions=ct(commit)' | ovs-ofctl --bundle replace-flows br0 -])
AT_CHECK([ovs-appctl revalidator/wait])
dnl Inconsistent ukey should be deleted.
AT_CHECK([ovs-appctl upcall/show | grep keys | grep -q -v 0], [1])
dnl Check the log for the flow modification error.
AT_CHECK([grep -q -E ".*failed to put.*$" ovs-vswitchd.log])
dnl Remove warning logs to let test suite pass.
OVS_VSWITCHD_STOP(["dnl
/.*failed to put.*$/d
/.*failed to flow_del.*$/d"])
AT_CLEANUP
AT_SETUP([dpif-netdev - MFEX Autovalidator])
AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], [])
AT_SKIP_IF([! $PYTHON3 $srcdir/genpkts.py 2000 > packets])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set Interface p1 type=dummy-pmd], [], [], [--dummy-numa="0,0,0,0,1,1,1,1"])
AT_SKIP_IF([! ovs-appctl dpif-netdev/miniflow-parser-get | sed 1,4d | grep "True"], [], [dnl
])
AT_CHECK([ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512], [0], [dnl
DPIF implementation set to dpif_avx512.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set autovalidator], [0], [dnl
Miniflow extract implementation set to autovalidator.
])
cat packets | while read line; do
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $line], [0], [ignore])
done
OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP 'rx_packets=\s*\K\d+'` -ge 16000])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([dpif-netdev - MFEX Autovalidator Fuzzy])
AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], [])
AT_SKIP_IF([! $PYTHON3 $srcdir/genpkts.py 2000 fuzzy > packets])
OVS_VSWITCHD_START(
[add-port br0 p1 \
-- set Interface p1 type=dummy-pmd], [], [], [--dummy-numa="0,0,0,0,1,1,1,1"])
AT_SKIP_IF([! ovs-appctl dpif-netdev/miniflow-parser-get | sed 1,4d | grep "True"], [], [dnl
])
AT_CHECK([ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512], [0], [dnl
DPIF implementation set to dpif_avx512.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set autovalidator], [0], [dnl
Miniflow extract implementation set to autovalidator.
])
cat packets | while read line; do
AT_CHECK([ovs-appctl netdev-dummy/receive p1 $line], [0], [ignore])
done
OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP 'rx_packets=\s*\K\d+'` -ge 16000])
OVS_VSWITCHD_STOP(["dnl
/upcall: datapath reached the dynamic limit of .* flows./d"])
AT_CLEANUP
AT_SETUP([dpif-netdev - MFEX Configuration])
OVS_VSWITCHD_START(
[set Open_vSwitch . other_config:pmd-cpu-mask=0x1 \
-- add-port br0 p1 \
-- set Interface p1 type=dummy-pmd], [], [], [--dummy-numa="0,0,0,0,1,1,1,1"])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set scalar 1], [2],
[], [dnl
Error: unknown argument 1.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 6 study 300 xyz], [2],
[], [dnl
Error: invalid study_pkt_cnt value: xyz.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set scalar abcd], [2],
[], [dnl
Error: unknown argument abcd.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 scalar abcd], [2],
[], [dnl
Error: unknown argument abcd.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd], [2],
[], [dnl
Error: -pmd option requires a thread id argument.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set tudy abcd], [2],
[], [dnl
Error: unknown argument abcd.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 7 study abcd], [2],
[], [dnl
Error: invalid study_pkt_cnt value: abcd.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 study], [0], [dnl
Miniflow extract implementation set to study, on pmd thread 0, studying 128 packets.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 study 512], [0], [dnl
Miniflow extract implementation set to study, on pmd thread 0, studying 512 packets.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set study 512], [0], [dnl
Miniflow extract implementation set to study, studying 512 packets.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set study], [0], [dnl
Miniflow extract implementation set to study, studying 128 packets.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 autovalidator], [0], [dnl
Miniflow extract implementation set to autovalidator, on pmd thread 0.
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd zero study], [2],
[], [dnl
Error: miniflow extract parser not changed, PMD thread passed is not valid: 'zero'. Pass a valid pmd thread ID.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 1], [2],
[], [dnl
Error: no miniflow extract name provided. Output of miniflow-parser-get shows implementation list.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 1 superstudy], [2],
[], [dnl
Error: unknown miniflow extract implementation superstudy.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set superstudy], [2],
[], [dnl
Error: unknown miniflow extract implementation superstudy.
ovs-appctl: ovs-vswitchd: server returned an error
])
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 1 study -pmd], [2],
[], [dnl
Error: invalid study_pkt_cnt value: -pmd.
ovs-appctl: ovs-vswitchd: server returned an error
])
OVS_VSWITCHD_STOP(["dnl
/Error: unknown argument 1./d
/Error: invalid study_pkt_cnt value: xyz./d
/Error: unknown argument abcd./d
/Error: -pmd option requires a thread id argument./d
/Error: invalid study_pkt_cnt value: abcd./d
/Error: miniflow extract parser not changed, PMD thread passed is not valid: 'zero'. Pass a valid pmd thread ID./d
/Error: no miniflow extract name provided. Output of miniflow-parser-get shows implementation list./d
/Error: unknown miniflow extract implementation superstudy./d
/Error: invalid study_pkt_cnt value: -pmd./d"])
AT_CLEANUP
AT_SETUP([datapath - Actions Autovalidator Checksum])
OVS_VSWITCHD_START(add-port br0 p0 -- set Interface p0 type=dummy \
-- add-port br0 p1 -- set Interface p1 type=dummy)
AT_CHECK([ovs-appctl odp-execute/action-impl-set autovalidator], [0], [dnl
Action implementation set to autovalidator.
])
dnl Add flows to trigger checksum calculation.
AT_DATA([flows.txt], [dnl
in_port=p0,ip,actions=mod_nw_src=10.1.1.1,p1
in_port=p0,ipv6,actions=set_field:fc00::100->ipv6_src,p1
])
AT_CHECK([ovs-ofctl del-flows br0])
AT_CHECK([ovs-ofctl -Oopenflow13 add-flows br0 flows.txt])
AT_CHECK([ovs-vsctl set Interface p1 options:pcap=p1.pcap])
dnl IPv4 packet with values that will trigger carry-over addition for checksum.
flow_s_v4="
eth_src=47:42:86:08:17:50,eth_dst=3e:55:b5:9e:3a:fb,dl_type=0x0800,
nw_src=229.167.36.90,nw_dst=130.161.64.186,nw_proto=6,nw_ttl=64,nw_frag=no,
tp_src=54392,tp_dst=5201,tcp_flags=ack"
good_frame=$(ovs-ofctl compose-packet --bare "${flow_s_v4}")
AT_CHECK([ovs-appctl netdev-dummy/receive p0 ${good_frame}])
dnl Checksum should change to 0xAC33 with ip_src changed to 10.1.1.1
dnl by the datapath while processing the packet.
flow_expected=$(echo "${flow_s_v4}" | sed 's/229.167.36.90/10.1.1.1/g')
good_expected=$(ovs-ofctl compose-packet --bare "${flow_expected}")
AT_CHECK([ovs-pcap p1.pcap > p1.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p1.pcap.txt], [0], [${good_expected}
])
dnl Repeat similar test for IPv6.
flow_s_v6="
eth_src=8a:bf:7e:2f:05:84,eth_dst=0a:8f:39:4f:e0:73,dl_type=0x86dd,
ipv6_src=2f8a:2076:3926:9e7:2d47:4bc9:9c7:17f3,
ipv6_dst=7287:10dd:2fb9:41d5:3eb2:2c7a:11b0:6258,
ipv6_label=0x51ac,nw_proto=6,nw_ttl=142,nw_frag=no,
tp_src=20405,tp_dst=20662,tcp_flags=ack"
good_frame_v6=$(ovs-ofctl compose-packet --bare "${flow_s_v6}")
AT_CHECK([ovs-appctl netdev-dummy/receive p0 ${good_frame_v6}])
dnl Checksum should change to 0x59FD with ipv6_src changed to fc00::100
dnl by the datapath while processing the packet.
flow_expected_v6=$(echo "${flow_s_v6}" | \
sed 's/2f8a:2076:3926:9e7:2d47:4bc9:9c7:17f3/fc00::100/g')
good_expected_v6=$(ovs-ofctl compose-packet --bare "${flow_expected_v6}")
AT_CHECK([ovs-pcap p1.pcap > p1.pcap.txt 2>&1])
AT_CHECK_UNQUOTED([tail -n 1 p1.pcap.txt], [0], [${good_expected_v6}
])
OVS_VSWITCHD_STOP
AT_CLEANUP