Greetings dev,
I have whipped up a quick little utility (find below), that I've done a
bit of debugging with and it seems to have made working with dump-flows
from ovs-ofctl a little easier to use.
If you think it's worthwhile to add to the repository, I'll submit it
formally. We were using it while debugging some strange packet
forwarding in openshift.
-Aaron
===================================== 8< =====================================
#!/bin/sh
# Copyright (C) 2017 Red Hat, Inc
# Licensed under the terms of the Apache 2.0 License
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
OFCTL=$(which ovs-ofctl 2>/dev/null)
if [ ! -x "$OFCTL" ]; then
echo "Unable to find ovs-ofctl. Please check that it is installed."
exit 1
fi
dump_flows () {
$OFCTL dump-flows $*
}
replace_ports () {
PORTS=$($OFCTL dump-ports-desc $*)
for PORT in $(echo $PORTS | egrep -o '[0-9]+\([a-zA-Z0-9]+\):' | sort
-k1,1nr); do
PORT_ID=$(echo $PORT | egrep -o ^\([0-9]+\))
PORT_NAME=$(echo $PORT | egrep -o "\([a-zA-Z0-9]+\):" | tr -d '():')
echo "$PORT | $PORT_ID | $PORT_NAME |
s@output:$PORT_ID@output:$PORT_NAME" >> ports.txt
REPLACE="$REPLACE -e s@in_port=$PORT_ID@in_port=$PORT_NAME@g"
REPLACE="$REPLACE -e s@output:$PORT_ID@output:$PORT_NAME@g"
done
sed $REPLACE
}
FORMAT_STRING="%-3s %-6s %-45s %-25s"
if [ "$1" == "--dump-format" ]; then
shift
FORMAT_STRING="$1"
shift
fi
FORMAT_STRING=\"${FORMAT_STRING}\\n\"
dump_flows $* | \
grep -v OFPST_FLOW | \
sed -r \
-e '/priority=/bx ; s@, n_bytes=([0-9]+)@, n_bytes=\1, priority=0, @g ; :x
s@priority=([0-9]+) actions=@priority=\1 * actions=@g ; s@^ cookie=0x[0-9]+,
duration=[0-9.s]+, table=([0-9]+), n_packets=[0-9]+, n_bytes=[0-9]+,
(priority=([0-9]+),? ?)?(.*)$@\1 \3 \4@g' \
-e 's@priority=@@' \
-e 's@,\sactions=@* actions=@' | \
replace_ports $* | \
sort -k1,1n -k2,2nr | \
awk "{ printf $FORMAT_STRING, \$1, \$2, \$3, \$4, \$5 }"
===================================== 8< =====================================
Example Output:
[root@openshift-node-1 /]# ./ovs-dump-flows -O OpenFlow13 br0
0 400 ip,in_port=tun0,nw_src=10.129.0.1 actions=goto_table:30
0 301
ct_zone=1,ip,in_port=vxlan0,nw_src=10.128.0.0/14,nw_dst=10.129.0.0/23
actions=goto_table:25
0 301
ct_zone=1,ip,in_port=vxlan0,nw_src=10.129.0.0/23,nw_dst=10.128.0.0/14
actions=goto_table:25
0 300
ct_mark=0x1,ip,in_port=tun0,nw_src=10.129.0.0/23,nw_dst=10.128.0.0/14
actions=goto_table:25
0 300 ct_zone=0,ip
actions=ct(table=0,zone=1)
0 250 ip,in_port=tun0,nw_dst=224.0.0.0/4 actions=drop
0 200 arp,in_port=tun0,arp_spa=10.129.0.1,arp_tpa=10.128.0.0/14
actions=goto_table:30
0 200 arp,in_port=vxlan0,arp_spa=10.128.0.0/14,arp_tpa=10.129.0.0/23
actions=move:NXM_NX_TUN_ID[0..31]->NXM_NX_REG0[],goto_table:10
0 200 ip,in_port=tun0 actions=goto_table:30
0 200 ip,in_port=vxlan0,nw_src=10.128.0.0/14,nw_dst=10.129.0.0/23
actions=move:NXM_NX_TUN_ID[0..31]->NXM_NX_REG0[],goto_table:10
0 200 ip,in_port=vxlan0,nw_src=10.128.0.0/14,nw_dst=224.0.0.0/4
actions=move:NXM_NX_TUN_ID[0..31]->NXM_NX_REG0[],goto_table:10
0 150 in_port=tun0 actions=drop
0 150 in_port=vxlan0 actions=drop
0 100 arp actions=goto_table:20
0 100 ip actions=goto_table:20
0 0 * actions=drop
10 100 tun_src=172.17.0.2 actions=goto_table:30
10 100 tun_src=172.17.0.4 actions=goto_table:30
10 0 * actions=drop
20 100
arp,in_port=veth9611029c,arp_spa=10.129.0.4,arp_sha=52:70:c1:d0:72:24
actions=load:0->NXM_NX_REG0[],goto_table:21
20 100 ip,in_port=veth9611029c,nw_src=10.129.0.4
actions=load:0->NXM_NX_REG0[],goto_table:21
20 0 * actions=drop
21 0 * actions=goto_table:30
25 100 ip,nw_src=10.129.0.4
actions=load:0->NXM_NX_REG0[],goto_table:30
25 0 * actions=drop
30 300 arp,arp_tpa=10.129.0.1 actions=output:tun0
30 300 ct_state=+rpl,ct_mark=0x1,ip,nw_dst=10.129.0.0/23
actions=output:tun0
30 300 ip,nw_dst=10.129.0.1 actions=output:tun0
30 200 arp,arp_tpa=10.129.0.0/23 actions=goto_table:40
30 200 ip,nw_dst=10.129.0.0/23 actions=goto_table:70
30 100 arp,arp_tpa=10.128.0.0/14 actions=goto_table:50
30 100 ip,nw_dst=10.128.0.0/14 actions=goto_table:90
30 100 ip,nw_dst=172.30.0.0/16 actions=output:tun0
30 50 ip,in_port=vxlan0,nw_dst=224.0.0.0/4
actions=goto_table:120
30 25 ip,nw_dst=224.0.0.0/4
actions=goto_table:110
30 0 arp actions=drop
30 0 ip
actions=goto_table:100
40 100 arp,arp_tpa=10.129.0.4
actions=output:veth9611029c
40 0 * actions=drop
50 100 arp,arp_tpa=10.128.0.0/23
actions=move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],set_field:172.17.0.2->tun_dst,output:vxlan0
50 100 arp,arp_tpa=10.130.0.0/23
actions=move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],set_field:172.17.0.4->tun_dst,output:vxlan0
50 0 * actions=drop
70 100 ip,nw_dst=10.129.0.4
actions=load:0->NXM_NX_REG1[],load:0x6->NXM_NX_REG2[],goto_table:80
70 0 * actions=drop
80 300 ip,nw_src=10.129.0.1
actions=output:NXM_NX_REG2[]
80 200 reg0=0
actions=output:NXM_NX_REG2[]
80 200 reg1=0
actions=output:NXM_NX_REG2[]
80 0 * actions=drop
90 100 ip,nw_dst=10.128.0.0/23
actions=move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],set_field:172.17.0.2->tun_dst,output:vxlan0
90 100 ip,nw_dst=10.130.0.0/23
actions=move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],set_field:172.17.0.4->tun_dst,output:vxlan0
90 0 * actions=drop
100 0 * actions=output:tun0
110 0 * actions=drop
111 100 *
actions=move:NXM_NX_REG0[]->NXM_NX_TUN_ID[0..31],set_field:172.17.0.2->tun_dst,output:vxlan0,set_field:172.17.0.4->tun_dst,output:vxlan0,goto_table:120
120 0 * actions=drop
253 0 *
actions=note:03.01.00.00.00.00
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev