On Wed, Oct 05, 2016 at 01:57:47PM +0530, bscha...@redhat.com wrote: > From: Babu Shanmugam <bscha...@redhat.com> > > This patch adds support for marking qos on IP packets based on arbitrary > match criteria for a logical switch. > > Signed-off-by: Babu Shanmugam <bscha...@redhat.com> > Suggested-by: Mickey Spiegel <mickeys....@gmail.com> > Acked-by: Mickey Spiegel <mickeys....@gmail.com>
I figured out the problem I had with the test. It was a race due to lack of --wait on the ovn-nbctl calls. I added --wait in the right places and that fixed the problem. While I was at it, I decided to improve the test by making it also check with ovn-trace, since it's usually easier to understand failures from ovn-trace than from physical packet traces. I folded in the following and applied this to master. Thank you! --8<--------------------------cut here-------------------------->8-- diff --git a/NEWS b/NEWS index ee873d6..95cb2b2 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ Post-v2.6.0 --------------------- - OVN: * QoS is now implemented via egress shaping rather than ingress policing. + * DSCP marking is now supported, via the new northbound QoS table. - Fixed regression in table stats maintenance introduced in OVS 2.3.0, wherein the number of OpenFlow table hits and misses was not accurate. diff --git a/tests/ovn.at b/tests/ovn.at index d9f9683..948716b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -5367,9 +5367,7 @@ AT_SETUP([ovn -- DSCP marking check]) AT_KEYWORDS([ovn]) ovn_start -# Configure the Northbound database ovn-nbctl ls-add lsw0 - ovn-nbctl --wait=sb lsp-add lsw0 lp1 ovn-nbctl --wait=sb lsp-add lsw0 lp2 ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 @@ -5385,44 +5383,66 @@ ovn_attach n1 br-phys 192.168.0.1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=vif1-tx.pcap options:rxq_pcap=vif1-rx.pcap ofport-request=1 ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=vif2-tx.pcap options:rxq_pcap=vif2-rx.pcap ofport-request=2 -# Extracts the final flow from ofproto/trace output, -# removing the irrelevant MFF_LOG_CT_ZONE (reg13) value. -get_final_flow() { - sed -n "/Final flow:/s/reg13=[[^,]]*,//p" stdout +AT_CAPTURE_FILE([trace]) +ovn_trace () { + ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' +} + +# Extracts nw_tos from the final flow from ofproto/trace output and prints +# it on stdout. Prints "none" if no nw_tos was included. +get_final_nw_tos() { + if flow=$(grep '^Final flow:' stdout); then :; else + # The output didn't have a final flow. + return 99 + fi + + tos=$(echo "$flow" | sed -n 's/.*nw_tos=\([[0-9]]\{1,\}\).*/\1/p') + case $tos in + '') echo none ;; + *) echo $tos ;; + esac +} + +# check_tos TOS +# +# Checks that a packet from 1.1.1.1 to 1.1.1.2 gets its DSCP set to TOS. +check_tos() { + # First check with ovn-trace for logical flows. + echo "checking for tos $1" + (if test $1 != 0; then echo "ip.dscp = $1;"; fi; + echo 'output("lp2");') > expout + AT_CHECK_UNQUOTED([ovn_trace lsw0 'inport == "lp1" && eth.src == f0:00:00:00:00:01 && eth.dst == f0:00:00:00:00:02 && ip4.src == 1.1.1.1 && ip4.dst == 1.1.1.2'], [0], [expout]) + + # Then re-check with ofproto/trace for a physical packet. + AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2'], [0], [stdout-nolog]) + AT_CHECK_UNQUOTED([get_final_nw_tos], [0], [`expr $1 \* 4` +]) } # check at L2 -AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02' -generate], [0], [stdout]) -AT_CHECK([get_final_flow], [0],[Final flow: reg14=0x1,reg15=0x2,metadata=0x1,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x0000 +AT_CHECK([ovn_trace lsw0 'inport == "lp1" && eth.src == f0:00:00:00:00:01 && eth.dst == f0:00:00:00:00:02'], [0], [output("lp2"); +]) +AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02'], [0], [stdout-nolog]) +AT_CHECK([get_final_nw_tos], [0], [none ]) # check at L3 without dscp marking -AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2' -generate], [0], [stdout]) -AT_CHECK([get_final_flow], [0],[Final flow: ip,reg14=0x1,reg15=0x2,metadata=0x1,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=1.1.1.1,nw_dst=1.1.1.2,nw_proto=0,nw_tos=0,nw_ecn=0,nw_ttl=0 -]) +check_tos 0 # Mark DSCP with a valid value -qos_id=$(ovn-nbctl -- --id=@lp1-qos create QoS priority=100 action=dscp=48 match="inport\=\=\"lp1\"" direction="from-lport" -- set Logical_Switch lsw0 qos_rules=@lp1-qos) -AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2' -generate], [0], [stdout]) -AT_CHECK([get_final_flow], [0],[Final flow: ip,reg14=0x1,reg15=0x2,metadata=0x1,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=1.1.1.1,nw_dst=1.1.1.2,nw_proto=0,nw_tos=192,nw_ecn=0,nw_ttl=0 -]) +qos_id=$(ovn-nbctl --wait=hv -- --id=@lp1-qos create QoS priority=100 action=dscp=48 match="inport\=\=\"lp1\"" direction="from-lport" -- set Logical_Switch lsw0 qos_rules=@lp1-qos) +check_tos 48 # Update the DSCP marking -ovn-nbctl set QoS $qos_id action=dscp=63 -AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2' -generate], [0], [stdout]) -AT_CHECK([get_final_flow], [0],[Final flow: ip,reg14=0x1,reg15=0x2,metadata=0x1,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=1.1.1.1,nw_dst=1.1.1.2,nw_proto=0,nw_tos=252,nw_ecn=0,nw_ttl=0 -]) +ovn-nbctl --wait=hv set QoS $qos_id action=dscp=63 +check_tos 63 -ovn-nbctl set QoS $qos_id match="outport\=\=\"lp2\"" direction="to-lport" -AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2' -generate], [0], [stdout]) -AT_CHECK([get_final_flow], [0],[Final flow: ip,reg14=0x1,reg15=0x2,metadata=0x1,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=1.1.1.1,nw_dst=1.1.1.2,nw_proto=0,nw_tos=252,nw_ecn=0,nw_ttl=0 -]) +ovn-nbctl --wait=hv set QoS $qos_id match="outport\=\=\"lp2\"" direction="to-lport" +check_tos 63 # Disable DSCP marking -ovn-nbctl clear Logical_Switch lsw0 qos_rules -AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2' -generate], [0], [stdout]) -AT_CHECK([get_final_flow], [0],[Final flow: ip,reg14=0x1,reg15=0x2,metadata=0x1,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=1.1.1.1,nw_dst=1.1.1.2,nw_proto=0,nw_tos=0,nw_ecn=0,nw_ttl=0 -]) +ovn-nbctl --wait=hv clear Logical_Switch lsw0 qos_rules +check_tos 0 OVN_CLEANUP([hv]) AT_CLEANUP _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev