1 AT_BANNER([flow classifier unit tests])
8 [many-rules-in-one-list],
9 [versioned many-rules-in-one-list],
10 [many-rules-in-one-table],
11 [versioned many-rules-in-one-table],
12 [many-rules-in-two-tables],
13 [versioned many-rules-in-two-tables],
14 [many-rules-in-five-tables],
15 [versioned many-rules-in-five-tables]],
16 [AT_SETUP([flow classifier - m4_bpatsubst(testname, [-], [ ])])
17 AT_CHECK([ovstest test-classifier m4_bpatsubst(testname, [versioned], [--versioned])], [0], [], [])
20 AT_BANNER([miniflow unit tests])
26 [AT_SETUP([miniflow - m4_bpatsubst(testname, [-], [ ])])
27 AT_CHECK([ovstest test-classifier testname], [0], [], [])
30 AT_BANNER([flow classifier lookup segmentation])
31 AT_SETUP([flow classifier - lookup segmentation])
33 ADD_OF_PORTS([br0], [1], [2], [3])
34 AT_DATA([flows.txt], [dnl
35 table=0 in_port=1 priority=16,tcp,nw_dst=10.1.0.0/255.255.0.0,action=output(3)
36 table=0 in_port=1 priority=32,tcp,nw_dst=10.1.2.15,action=output(2)
37 table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=80,action=drop
38 table=0 in_port=1 priority=0,ip,action=drop
39 table=0 in_port=2 priority=16,tcp,nw_dst=192.168.0.0/255.255.0.0,action=output(1)
40 table=0 in_port=2 priority=0,ip,action=drop
41 table=0 in_port=3 priority=16,tcp,nw_src=10.1.0.0/255.255.0.0,action=output(1)
42 table=0 in_port=3 priority=0,ip,action=drop
44 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
45 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=2,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
46 AT_CHECK([tail -2 stdout], [0],
47 [Megaflow: recirc_id=0,tcp,in_port=2,nw_dst=192.168.0.0/16,nw_frag=no
50 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=11.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
51 AT_CHECK([tail -2 stdout], [0],
52 [Megaflow: recirc_id=0,ip,in_port=1,nw_dst=1.0.0.0/1.0.0.0,nw_frag=no
53 Datapath actions: drop
55 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
56 AT_CHECK([tail -2 stdout], [0],
57 [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_dst=80
58 Datapath actions: drop
60 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=79'], [0], [stdout])
61 AT_CHECK([tail -2 stdout], [0],
62 [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_dst=0x1/0x1
68 AT_BANNER([flow classifier prefix lookup])
69 AT_SETUP([flow classifier - prefix lookup])
71 ADD_OF_PORTS([br0], [1], [2], [3])
72 AT_CHECK([ovs-vsctl set Bridge br0 flow_tables:0=@N1 -- --id=@N1 create Flow_Table name=t0], [0], [ignore], [])
73 AT_DATA([flows.txt], [dnl
74 table=0 in_port=1 priority=16,tcp,nw_dst=10.1.0.0/255.255.0.0,action=output(3)
75 table=0 in_port=1 priority=32,tcp,nw_dst=10.1.2.0/255.255.255.0,tp_src=79,action=output(2)
76 table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=80,action=drop
77 table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=8080,action=output(2)
78 table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=192,action=output(2)
79 table=0 in_port=1 priority=0,ip,action=drop
80 table=0 in_port=2 priority=16,tcp,nw_dst=192.168.0.0/255.255.0.0,action=output(1)
81 table=0 in_port=2 priority=0,ip,action=drop
82 table=0 in_port=3 priority=16,tcp,nw_src=10.1.0.0/255.255.0.0,action=output(1)
83 table=0 in_port=3 priority=0,ip,action=drop
85 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
87 # nw_dst and nw_src should be on by default
88 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
89 AT_CHECK([tail -2 stdout], [0],
90 [Megaflow: recirc_id=0,ip,in_port=1,nw_dst=192.168.0.0/16,nw_frag=no
91 Datapath actions: drop
94 AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=ipv6_label], [0])
95 AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=nw_dst,nw_src,tun_dst,tun_src], [1], [],
96 [ovs-vsctl: nw_dst,nw_src,tun_dst,tun_src: 4 value(s) specified but the maximum number is 3
98 AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=nw_dst,nw_dst], [1], [],
99 [ovs-vsctl: nw_dst,nw_dst: set contains duplicate value
102 AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=nw_dst], [0])
103 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
104 AT_CHECK([tail -2 stdout], [0],
105 [Megaflow: recirc_id=0,ip,in_port=1,nw_dst=192.168.0.0/16,nw_frag=no
106 Datapath actions: drop
108 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=2,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
109 AT_CHECK([tail -2 stdout], [0],
110 [Megaflow: recirc_id=0,tcp,in_port=2,nw_dst=192.168.0.0/16,nw_frag=no
113 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout])
114 AT_CHECK([tail -2 stdout], [0],
115 [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_dst=80
116 Datapath actions: drop
118 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=79'], [0], [stdout])
119 AT_CHECK([tail -2 stdout], [0],
120 [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_src=0x0/0x1,tp_dst=0x40/0xfff0
123 AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=none], [0])
124 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.3.16,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=79'], [0], [stdout])
125 AT_CHECK([tail -2 stdout], [0],
126 [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.3.16,nw_frag=no
129 OVS_VSWITCHD_STOP(["/'prefixes' with incompatible field: ipv6_label/d"])
132 AT_BANNER([conjunctive match])
134 AT_SETUP([single conjunctive match])
136 ADD_OF_PORTS([br0], 1, 2, 3, 4, 5)
137 AT_DATA([flows.txt], [dnl
139 priority=100,ip,ip_src=10.0.0.1,actions=conjunction(1,1/2)
140 priority=100,ip,ip_src=10.0.0.4,actions=conjunction(1,1/2)
141 priority=100,ip,ip_src=10.0.0.6,actions=conjunction(1,1/2)
142 priority=100,ip,ip_src=10.0.0.7,actions=conjunction(1,1/2)
143 priority=100,ip,ip_dst=10.0.0.2,actions=conjunction(1,2/2)
144 priority=100,ip,ip_dst=10.0.0.5,actions=conjunction(1,2/2)
145 priority=100,ip,ip_dst=10.0.0.7,actions=conjunction(1,2/2)
146 priority=100,ip,ip_dst=10.0.0.8,actions=conjunction(1,2/2)
147 priority=100,ip,ip_src=10.0.0.1,ip_dst=10.0.0.4,actions=4
148 priority=100,ip,ip_src=10.0.0.3,ip_dst=10.0.0.5,actions=5
152 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
153 for src in 0 1 2 3 4 5 6 7; do
154 for dst in 0 1 2 3 4 5 6 7; do
155 if test $src$dst = 14; then
157 elif test $src$dst = 35; then
161 case $src in [[1467]]) case $dst in [[2578]]) out=3 ;; esac ;; esac
163 AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_type=0x0800,nw_src=10.0.0.$src,nw_dst=10.0.0.$dst"], [0], [stdout])
164 AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $out
171 AT_SETUP([multiple conjunctive match])
173 ADD_OF_PORTS([br0], 1, 2, 3, 4, 5)
174 AT_DATA([flows.txt], [dnl
179 priority=5,ip,ip_src=20.0.0.0/8,actions=conjunction(1,1/2),conjunction(2,1/2)
180 priority=5,ip,ip_src=10.1.0.0/16,actions=conjunction(1,1/2),conjunction(3,2/3)
181 priority=5,ip,ip_src=10.2.0.0/16,actions=conjunction(1,1/2),conjunction(2,1/2)
182 priority=5,ip,ip_src=10.1.3.0/24,actions=conjunction(1,1/2),conjunction(3,2/3)
183 priority=5,ip,ip_src=10.1.4.5/32,actions=conjunction(1,1/2),conjunction(2,1/2)
185 priority=5,ip,ip_dst=20.0.0.0/8,actions=conjunction(1,2/2)
186 priority=5,ip,ip_dst=10.1.0.0/16,actions=conjunction(1,2/2)
187 priority=5,ip,ip_dst=10.2.0.0/16,actions=conjunction(1,2/2)
188 priority=5,ip,ip_dst=10.1.3.0/24,actions=conjunction(1,2/2)
189 priority=5,ip,ip_dst=10.1.4.5/32,actions=conjunction(1,2/2)
190 priority=5,ip,ip_dst=30.0.0.0/8,actions=conjunction(2,2/2),conjunction(3,1/3)
191 priority=5,ip,ip_dst=40.5.0.0/16,actions=conjunction(2,2/2),conjunction(3,1/3)
193 priority=5,tcp,tcp_dst=80,actions=conjunction(3,3/3)
194 priority=5,tcp,tcp_dst=443,actions=conjunction(3,3/3)
196 priority=5,tcp,tcp_src=80,actions=conjunction(3,3/3)
197 priority=5,tcp,tcp_src=443,actions=conjunction(3,3/3)
201 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
220 for c0 in '1 80' '2 443' '3 8080'; do
221 for d0 in '1 80' '2 443' '3 8080'; do
222 set $a0; a=$1 ip_src=$2
223 set $b0; b=$1 ip_dst=$2
224 set $c0; c=$1 tcp_src=$2
225 set $d0; d=$1 tcp_dst=$2
227 [[12345]][[12345]]??) out=1 ;;
228 [[135]][[67]]??) out=2 ;;
229 [[24]][[67]][[12]]? | [[24]][[67]]?[[12]]) out=3 ;;
232 AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=5,dl_type=0x0800,nw_proto=6,nw_src=$ip_src,nw_dst=$ip_dst,tcp_src=$tcp_src,tcp_dst=$tcp_dst"], [0], [stdout])
233 AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $out
242 # In conjunctive match, we can find some soft matches that turn out not to be a
243 # real match. Usually, that's the end of the road--there is no real match.
244 # But if there is a flow identical to one of the flows that was a soft match,
245 # except with a lower priority, then we have to try again with that lower
246 # priority flow. This test checks this special case.
247 AT_SETUP([conjunctive match priority fallback])
249 ADD_OF_PORTS([br0], 1, 2, 3, 4, 5, 6, 7)
250 AT_DATA([flows.txt], [dnl
254 priority=5,ip,ip_src=10.0.0.1,actions=conjunction(1,1/2)
255 priority=5,ip,ip_src=10.0.0.2,actions=conjunction(1,1/2)
256 priority=5,ip,ip_dst=10.0.0.1,actions=conjunction(1,2/2)
257 priority=5,ip,ip_dst=10.0.0.2,actions=conjunction(1,2/2)
258 priority=5,ip,ip_dst=10.0.0.3,actions=conjunction(1,2/2)
260 priority=4,ip,ip_src=10.0.0.3,ip_dst=10.0.0.2,actions=2
262 priority=3,ip,ip_src=10.0.0.1,actions=conjunction(3,1/2)
263 priority=3,ip,ip_src=10.0.0.3,actions=conjunction(3,1/2)
264 priority=3,ip,ip_dst=10.0.0.2,actions=conjunction(3,2/2)
265 priority=3,ip,ip_dst=10.0.0.3,actions=conjunction(3,2/2)
266 priority=3,ip,ip_dst=10.0.0.4,actions=conjunction(3,2/2)
268 priority=2,ip,ip_dst=10.0.0.1,actions=4
270 priority=1,ip,ip_src=10.0.0.1,ip_dst=10.0.0.5,actions=5
274 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
275 for src in 0 1 2 3; do
276 for dst in 0 1 2 3 4 5; do
278 [[12]][[123]]) out=1 ;;
280 [[13]][[234]]) out=3 ;;
285 AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=7,dl_type=0x0800,nw_src=10.0.0.$src,nw_dst=10.0.0.$dst"], [0], [stdout])
286 AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $out