1 AT_BANNER([OVN components])
3 AT_SETUP([ovn -- lexer])
4 dnl For lines without =>, input and expected output are identical.
5 dnl For lines with =>, input precedes => and expected output follows =>.
6 AT_DATA([test-cases.txt], [dnl
7 foo bar baz quuxquuxquux _abcd_ a.b.c.d a123_.456
8 "abc\u0020def" => "abc def"
9 " => error("Input ends inside quoted string.")dnl "
11 $foo $bar $baz $quuxquuxquux $_abcd_ $a.b.c.d $a123_.456
12 $1 => error("`$' must be followed by a valid identifier.") 1
17 a/*/b => a error("`/*' without matching `*/'.")
19 a/b => a error("`/' is only valid as part of `//' or `/*'.") b
21 0 1 12345 18446744073709551615
22 18446744073709551616 => error("Decimal constants must be less than 2**64.")
23 9999999999999999999999 => error("Decimal constants must be less than 2**64.")
24 01 => error("Decimal constants must not have leading zeros.")
28 1/0 => error("Value contains unmasked 1-bits.")
32 1/ => error("Integer constant expected.")
34 1/0x123 => error("Value and mask have incompatible formats.")
41 0XFEDCBA9876543210 => 0xfedcba9876543210
42 0xfedcba9876543210fedcba9876543210
43 0x0000fedcba9876543210fedcba9876543210 => 0xfedcba9876543210fedcba9876543210
44 0x => error("Hex digits expected following 0x.")
45 0X => error("Hex digits expected following 0X.")
48 0x1/0x0 => error("Value contains unmasked 1-bits.")
50 0x. => error("Invalid syntax in hexadecimal constant.")
52 192.168.128.1 1.2.3.4 255.255.255.255 0.0.0.0
53 256.1.2.3 => error("Invalid numeric constant.")
55 192.168.0.0/255.255.0.0 => 192.168.0.0/16
56 192.168.0.0/255.255.255.0 => 192.168.0.0/24
57 192.168.0.0/255.255.0.255
58 192.168.0.0/255.0.0.0 => error("Value contains unmasked 1-bits.")
60 192.168.0.0/255.255.255.255 => 192.168.0.0/32
61 1.2.3.4:5 => 1.2.3.4 : 5
65 ff00::1234 => ff00::1234
66 2001:db8:85a3::8a2e:370:7334
67 2001:db8:85a3:0:0:8a2e:370:7334 => 2001:db8:85a3::8a2e:370:7334
68 2001:0db8:85a3:0000:0000:8a2e:0370:7334 => 2001:db8:85a3::8a2e:370:7334
70 ::ffff:c000:0280 => ::ffff:192.0.2.128
72 ::1/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff => ::1/128
75 ff00::/ff00:: => ff00::/8
78 01:23:45:67:AB:CD => 01:23:45:67:ab:cd
80 FE:DC:ba:98:76:54 => fe:dc:ba:98:76:54
81 01:00:00:00:00:00/01:00:00:00:00:00
82 ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff
83 fe:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff
84 ff:ff:ff:ff:ff:ff/fe:ff:ff:ff:ff:ff => error("Value contains unmasked 1-bits.")
85 fe:x => error("Invalid numeric constant.")
86 00:01:02:03:04:x => error("Invalid numeric constant.")
88 # Test that operators are tokenized as expected, even without white space.
89 (){}[[]]==!=<<=>>=!&&||..,;=<->--: => ( ) { } [[ ]] == != < <= > >= ! && || .. , ; = <-> -- :
90 & => error("`&' is only valid as part of `&&'.")
91 | => error("`|' is only valid as part of `||'.")
92 - => error("`-' is only valid as part of `--'.")
94 ^ => error("Invalid character `^' in input.")
96 AT_CAPTURE_FILE([input.txt])
97 sed 's/ =>.*//' test-cases.txt > input.txt
98 sed 's/.* => //' test-cases.txt > expout
99 AT_CHECK([ovstest test-ovn lex < input.txt], [0], [expout])
102 AT_SETUP([ovn -- expression parser])
103 dnl For lines without =>, input and expected output are identical.
104 dnl For lines with =>, input precedes => and expected output follows =>.
105 AT_DATA([test-cases.txt], [[
107 eth.type==0x800 => eth.type == 0x800
108 eth.type[0..15] == 0x800 => eth.type == 0x800
111 vlan.present == 1 => vlan.present
112 !(vlan.present == 0) => vlan.present
113 !(vlan.present != 1) => vlan.present
115 vlan.present == 0 => !vlan.present
116 vlan.present != 1 => !vlan.present
117 !(vlan.present == 1) => !vlan.present
118 !(vlan.present != 0) => !vlan.present
121 eth.dst[0] == 1 => eth.dst[0]
122 eth.dst[0] != 0 => eth.dst[0]
123 !(eth.dst[0] == 0) => eth.dst[0]
124 !(eth.dst[0] != 1) => eth.dst[0]
127 eth.dst[0] == 0 => !eth.dst[0]
128 eth.dst[0] != 1 => !eth.dst[0]
129 !(eth.dst[0] == 1) => !eth.dst[0]
130 !(eth.dst[0] != 0) => !eth.dst[0]
132 vlan.tci[12..15] == 0x3
133 vlan.tci == 0x3000/0xf000 => vlan.tci[12..15] == 0x3
134 vlan.tci[12..15] != 0x3
135 vlan.tci != 0x3000/0xf000 => vlan.tci[12..15] != 0x3
137 !vlan.pcp => vlan.pcp == 0
138 !(vlan.pcp) => vlan.pcp == 0
145 !(vlan.pcp != 0x4) => vlan.pcp == 0x4
146 !(vlan.pcp == 0x4) => vlan.pcp != 0x4
147 !(vlan.pcp <= 0x4) => vlan.pcp > 0x4
148 !(vlan.pcp < 0x4) => vlan.pcp >= 0x4
149 !(vlan.pcp >= 0x4) => vlan.pcp < 0x4
150 !(vlan.pcp > 0x4) => vlan.pcp <= 0x4
151 0x4 == vlan.pcp => vlan.pcp == 0x4
152 0x4 != vlan.pcp => vlan.pcp != 0x4
153 0x4 < vlan.pcp => vlan.pcp > 0x4
154 0x4 <= vlan.pcp => vlan.pcp >= 0x4
155 0x4 > vlan.pcp => vlan.pcp < 0x4
156 0x4 >= vlan.pcp => vlan.pcp <= 0x4
157 !(0x4 != vlan.pcp) => vlan.pcp == 0x4
158 !(0x4 == vlan.pcp) => vlan.pcp != 0x4
159 !(0x4 >= vlan.pcp) => vlan.pcp > 0x4
160 !(0x4 > vlan.pcp) => vlan.pcp >= 0x4
161 !(0x4 <= vlan.pcp) => vlan.pcp < 0x4
162 !(0x4 < vlan.pcp) => vlan.pcp <= 0x4
164 1 < vlan.pcp < 4 => vlan.pcp > 0x1 && vlan.pcp < 0x4
165 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4
166 1 < vlan.pcp <= 4 => vlan.pcp > 0x1 && vlan.pcp <= 0x4
167 1 <= vlan.pcp < 4 => vlan.pcp >= 0x1 && vlan.pcp < 0x4
168 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4
169 4 > vlan.pcp > 1 => vlan.pcp < 0x4 && vlan.pcp > 0x1
170 4 >= vlan.pcp > 1 => vlan.pcp <= 0x4 && vlan.pcp > 0x1
171 4 > vlan.pcp >= 1 => vlan.pcp < 0x4 && vlan.pcp >= 0x1
172 4 >= vlan.pcp >= 1 => vlan.pcp <= 0x4 && vlan.pcp >= 0x1
173 !(1 < vlan.pcp < 4) => vlan.pcp <= 0x1 || vlan.pcp >= 0x4
174 !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4
175 !(1 < vlan.pcp <= 4) => vlan.pcp <= 0x1 || vlan.pcp > 0x4
176 !(1 <= vlan.pcp < 4) => vlan.pcp < 0x1 || vlan.pcp >= 0x4
177 !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4
178 !(4 > vlan.pcp > 1) => vlan.pcp >= 0x4 || vlan.pcp <= 0x1
179 !(4 >= vlan.pcp > 1) => vlan.pcp > 0x4 || vlan.pcp <= 0x1
180 !(4 > vlan.pcp >= 1) => vlan.pcp >= 0x4 || vlan.pcp < 0x1
181 !(4 >= vlan.pcp >= 1) => vlan.pcp > 0x4 || vlan.pcp < 0x1
183 vlan.pcp == {1, 2, 3, 4} => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4
184 vlan.pcp == 1 || ((vlan.pcp == 2 || vlan.pcp == 3) || vlan.pcp == 4) => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4
186 vlan.pcp != {1, 2, 3, 4} => vlan.pcp != 0x1 && vlan.pcp != 0x2 && vlan.pcp != 0x3 && vlan.pcp != 0x4
187 vlan.pcp == 1 && ((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && vlan.pcp == 0x2 && vlan.pcp == 0x3 && vlan.pcp == 0x4
189 vlan.pcp == 1 && !((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3 || vlan.pcp != 0x4)
190 vlan.pcp == 1 && (!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3) && vlan.pcp == 0x4
191 vlan.pcp == 1 && !(!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && ((vlan.pcp == 0x2 && vlan.pcp == 0x3) || vlan.pcp != 0x4)
193 ip4.src == {10.0.0.0/8, 192.168.0.0/16, 172.16.20.0/24, 8.8.8.8} => ip4.src[24..31] == 0xa || ip4.src[16..31] == 0xc0a8 || ip4.src[8..31] == 0xac1014 || ip4.src == 0x8080808
194 ip6.src == ::1 => ip6.src == 0x1
196 ip4.src == 1.2.3.4 => ip4.src == 0x1020304
197 ip4.src == ::1.2.3.4/::ffff:ffff => ip4.src == 0x1020304
198 ip6.src == ::1 => ip6.src == 0x1
206 !(inport != "eth0") => inport == "eth0"
208 ip4.src == "eth0" => Integer field ip4.src is not compatible with string constant.
209 inport == 1 => String field inport is not compatible with integer constant.
211 ip4.src > {1, 2, 3} => Only == and != operators may be used with value sets.
212 eth.type > 0x800 => Only == and != operators may be used with nominal field eth.type.
213 vlan.present > 0 => Only == and != operators may be used with Boolean field vlan.present.
215 inport != "eth0" => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account).
216 !(inport == "eth0") => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account).
217 eth.type != 0x800 => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account).
218 !(eth.type == 0x800) => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account).
220 123 == 123 => Syntax error at `123' expecting field name.
222 $name => Syntax error at `$name' expecting address set name.
224 123 == xyzzy => Syntax error at `xyzzy' expecting field name.
225 xyzzy == 1 => Syntax error at `xyzzy' expecting field name.
227 inport[1] == 1 => Cannot select subfield of string field inport.
229 eth.type[] == 1 => Syntax error at `@:>@' expecting small integer.
230 eth.type[::1] == 1 => Syntax error at `::1' expecting small integer.
231 eth.type[18446744073709551615] == 1 => Syntax error at `18446744073709551615' expecting small integer.
233 eth.type[5!] => Syntax error at `!' expecting `@:>@'.
235 eth.type[5..1] => Invalid bit range 5 to 1.
237 eth.type[12..16] => Cannot select bits 12 to 16 of 16-bit field eth.type.
239 eth.type[10] == 1 => Cannot select subfield of nominal field eth.type.
241 eth.type => Explicit `!= 0' is required for inequality test of multibit field against 0.
243 !(!(vlan.pcp)) => Explicit `!= 0' is required for inequality test of multibit field against 0.
245 123 => Syntax error at end of input expecting relational operator.
247 123 x => Syntax error at `x' expecting relational operator.
249 {1, "eth0"} => Syntax error at `"eth0"' expecting integer.
251 eth.type == xyzzy => Syntax error at `xyzzy' expecting constant.
253 (1 x) => Syntax error at `x' expecting `)'.
255 !0x800 != eth.type => Missing parentheses around operand of !.
257 eth.type == 0x800 || eth.type == 0x86dd && ip.proto == 17 => && and || must be parenthesized when used together.
259 eth.dst == {} => Syntax error at `}' expecting constant.
261 eth.src > 00:00:00:00:11:11/00:00:00:00:ff:ff => Only == and != operators may be used with masked constants. Consider using subfields instead (e.g. eth.src[0..15] > 0x1111 in place of eth.src > 00:00:00:00:11:11/00:00:00:00:ff:ff).
263 ip4.src == ::1 => 128-bit constant is not compatible with 32-bit field ip4.src.
265 1 == eth.type == 2 => Range expressions must have the form `x < field < y' or `x > field > y', with each `<' optionally replaced by `<=' or `>' by `>=').
267 eth.dst[40] x => Extra tokens at end of input.
269 ip4.src == {1.2.3.4, $set1, $unknownset} => Syntax error at `$unknownset' expecting address set name.
270 eth.src == {$set3, badmac, 00:00:00:00:00:01} => Syntax error at `badmac' expecting constant.
272 sed 's/ =>.*//' test-cases.txt > input.txt
273 sed 's/.* => //' test-cases.txt > expout
274 AT_CHECK([ovstest test-ovn parse-expr < input.txt], [0], [expout])
277 AT_SETUP([ovn -- expression annotation])
278 dnl Input precedes =>, expected output follows =>.
279 AT_DATA([test-cases.txt], [[
280 ip4.src == 1.2.3.4 => ip4.src == 0x1020304 && eth.type == 0x800
281 ip4.src != 1.2.3.4 => ip4.src != 0x1020304 && eth.type == 0x800
282 ip.proto == 123 => ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)
283 ip.proto == {123, 234} => (ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)) || (ip.proto == 0xea && (eth.type == 0x800 || eth.type == 0x86dd))
284 ip4.src == 1.2.3.4 && ip4.dst == 5.6.7.8 => ip4.src == 0x1020304 && eth.type == 0x800 && ip4.dst == 0x5060708 && eth.type == 0x800
286 ip => eth.type == 0x800 || eth.type == 0x86dd
287 ip == 1 => eth.type == 0x800 || eth.type == 0x86dd
288 ip[0] == 1 => eth.type == 0x800 || eth.type == 0x86dd
289 ip > 0 => Only == and != operators may be used with nominal field ip.
290 !ip => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'.
291 ip == 0 => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'.
293 vlan.present => vlan.tci[12]
294 !vlan.present => !vlan.tci[12]
296 !vlan.pcp => vlan.tci[13..15] == 0 && vlan.tci[12]
297 vlan.pcp == 1 && vlan.vid == 2 => vlan.tci[13..15] == 0x1 && vlan.tci[12] && vlan.tci[0..11] == 0x2 && vlan.tci[12]
298 !reg0 && !reg1 && !reg2 && !reg3 => xreg0[32..63] == 0 && xreg0[0..31] == 0 && xreg1[32..63] == 0 && xreg1[0..31] == 0
300 ip.first_frag => ip.frag[0] && (eth.type == 0x800 || eth.type == 0x86dd) && (!ip.frag[1] || (eth.type != 0x800 && eth.type != 0x86dd))
301 !ip.first_frag => !ip.frag[0] || (eth.type != 0x800 && eth.type != 0x86dd) || (ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd))
302 ip.later_frag => ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd)
304 bad_prereq != 0 => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name.
305 self_recurse != 0 => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'.
306 mutual_recurse_1 != 0 => Error parsing expression `mutual_recurse_2 != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `mutual_recurse_1 != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `mutual_recurse_1'.
307 mutual_recurse_2 != 0 => Error parsing expression `mutual_recurse_1 != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `mutual_recurse_2 != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `mutual_recurse_2'.
309 sed 's/ =>.*//' test-cases.txt > input.txt
310 sed 's/.* => //' test-cases.txt > expout
311 AT_CHECK([ovstest test-ovn annotate-expr < input.txt], [0], [expout])
314 AT_SETUP([ovn -- 1-term expression conversion])
315 AT_CHECK([ovstest test-ovn exhaustive --operation=convert 1], [0],
316 [Tested converting all 1-terminal expressions with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars.
320 AT_SETUP([ovn -- 2-term expression conversion])
321 AT_CHECK([ovstest test-ovn exhaustive --operation=convert 2], [0],
322 [Tested converting 570 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars.
326 AT_SETUP([ovn -- 3-term expression conversion])
327 AT_CHECK([ovstest test-ovn exhaustive --operation=convert --bits=2 3], [0],
328 [Tested converting 62418 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars.
332 AT_SETUP([ovn -- 3-term numeric expression simplification])
333 AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=2 --svars=0 3], [0],
334 [Tested simplifying 477138 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=.
338 AT_SETUP([ovn -- 4-term string expression simplification])
339 AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=0 --svars=4 4], [0],
340 [Tested simplifying 21978 expressions of 4 terminals with 4 string vars.
344 AT_SETUP([ovn -- 3-term mixed expression simplification])
345 AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=1 --svars=1 3], [0],
346 [Tested simplifying 124410 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars.
350 AT_SETUP([ovn -- 4-term numeric expression normalization])
351 AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 4], [0],
352 [Tested normalizing 1207162 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=.
356 AT_SETUP([ovn -- 4-term string expression normalization])
357 AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 4], [0],
358 [Tested normalizing 11242 expressions of 4 terminals with 3 string vars.
362 AT_SETUP([ovn -- 4-term mixed expression normalization])
363 AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --bits=1 --svars=2 4], [0],
364 [Tested normalizing 128282 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars.
368 AT_SETUP([ovn -- 5-term numeric expression normalization])
369 AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 --relops='==' 5], [0],
370 [Tested normalizing 368550 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==.
374 AT_SETUP([ovn -- 5-term string expression normalization])
375 AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 --relops='==' 5], [0],
376 [Tested normalizing 368550 expressions of 5 terminals with 3 string vars.
380 AT_SETUP([ovn -- 5-term mixed expression normalization])
381 AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --svars=1 --bits=1 --relops='==' 5], [0],
382 [Tested normalizing 116550 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars.
386 AT_SETUP([ovn -- 4-term numeric expressions to flows])
387 AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=2 --svars=0 --bits=2 --relops='==' 4], [0],
388 [Tested converting to flows 128282 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==.
392 AT_SETUP([ovn -- 4-term string expressions to flows])
393 AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=0 --svars=4 4], [0],
394 [Tested converting to flows 21978 expressions of 4 terminals with 4 string vars.
398 AT_SETUP([ovn -- 4-term mixed expressions to flows])
399 AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=1 --bits=2 --svars=1 --relops='==' 4], [0],
400 [Tested converting to flows 37994 expressions of 4 terminals with 1 numeric vars (each 2 bits) in terms of operators == and 1 string vars.
404 AT_SETUP([ovn -- 3-term numeric expressions to flows])
405 AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=3 --svars=0 --bits=3 --relops='==' 3], [0],
406 [Tested converting to flows 38394 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==.
410 AT_SETUP([ovn -- converting expressions to flows -- string fields])
412 echo "$1" | ovstest test-ovn expr-to-flows | sort
414 AT_CHECK([expr_to_flow 'inport == "eth0"'], [0], [reg14=0x5
416 AT_CHECK([expr_to_flow 'inport == "eth1"'], [0], [reg14=0x6
418 AT_CHECK([expr_to_flow 'inport == "eth2"'], [0], [(no flows)
420 AT_CHECK([expr_to_flow 'inport == "eth0" && ip'], [0], [dnl
424 AT_CHECK([expr_to_flow 'inport == "eth1" && ip'], [0], [dnl
428 AT_CHECK([expr_to_flow 'inport == "eth2" && ip'], [0], [(no flows)
430 AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2", "LOCAL"}'], [0],
435 AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2"} && ip'], [0], [dnl
441 AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl
446 AT_SETUP([ovn -- converting expressions to flows -- address sets])
448 echo "$1" | ovstest test-ovn expr-to-flows | sort
450 AT_CHECK([expr_to_flow 'ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3}'], [0], [dnl
455 AT_CHECK([expr_to_flow 'ip4.src == $set1'], [0], [dnl
460 AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set1}'], [0], [dnl
466 AT_CHECK([expr_to_flow 'ip4.src == {1.2.0.0/20, 5.5.5.0/24, $set1}'], [0], [dnl
473 AT_CHECK([expr_to_flow 'ip6.src == {::1, ::2, ::3}'], [0], [dnl
478 AT_CHECK([expr_to_flow 'ip6.src == {::1, $set2, ::4}'], [0], [dnl
484 AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, 00:00:00:00:00:02, 00:00:00:00:00:03}'], [0], [dnl
485 dl_src=00:00:00:00:00:01
486 dl_src=00:00:00:00:00:02
487 dl_src=00:00:00:00:00:03
489 AT_CHECK([expr_to_flow 'eth.src == {$set3}'], [0], [dnl
490 dl_src=00:00:00:00:00:01
491 dl_src=00:00:00:00:00:02
492 dl_src=00:00:00:00:00:03
494 AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, $set3, ba:be:be:ef:de:ad, $set3}'], [0], [dnl
495 dl_src=00:00:00:00:00:01
496 dl_src=00:00:00:00:00:02
497 dl_src=00:00:00:00:00:03
498 dl_src=ba:be:be:ef:de:ad
502 AT_SETUP([ovn -- action parsing])
503 dnl Text before => is input, text after => is expected output.
504 AT_DATA([test-cases.txt], [[
506 drop; => actions=drop, prereqs=1
507 drop; next; => Syntax error at `next' expecting end of input.
508 next; drop; => Syntax error at `drop' expecting action.
511 output; => actions=resubmit(,64), prereqs=1
514 next; => actions=resubmit(,27), prereqs=1
515 next(0); => actions=resubmit(,16), prereqs=1
516 next(15); => actions=resubmit(,31), prereqs=1
518 next(); => Syntax error at `)' expecting small integer.
519 next(10; => Syntax error at `;' expecting `)'.
520 next(16); => "next" argument must be in range 0 to 15.
522 # Loading a constant value.
523 tcp.dst=80; => actions=set_field:80->tcp_dst, prereqs=ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd)
524 eth.dst[40] = 1; => actions=set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dst, prereqs=1
525 vlan.pcp = 2; => actions=set_field:0x4000/0xe000->vlan_tci, prereqs=vlan.tci[12]
526 vlan.tci[13..15] = 2; => actions=set_field:0x4000/0xe000->vlan_tci, prereqs=1
527 inport = ""; => actions=set_field:0->reg14,set_field:0->in_port, prereqs=1
528 ip.ttl = 4; => actions=set_field:4->nw_ttl, prereqs=eth.type == 0x800 || eth.type == 0x86dd
529 outport="eth0"; next; outport="LOCAL"; next; => actions=set_field:0x5->reg15,resubmit(,27),set_field:0xfffe->reg15,resubmit(,27), prereqs=1
531 inport[1] = 1; => Cannot select subfield of string field inport.
532 ip.proto[1] = 1; => Cannot select subfield of nominal field ip.proto.
533 eth.dst[40] == 1; => Syntax error at `==' expecting `=' or `<->'.
534 ip = 1; => Predicate symbol ip used where lvalue required.
535 ip.proto = 6; => Field ip.proto is not modifiable.
536 inport = {"a", "b"}; => Assignments require a single value.
537 inport = {}; => Syntax error at `}' expecting constant.
538 bad_prereq = 123; => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name.
539 self_recurse = 123; => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'.
540 vlan.present = 0; => Predicate symbol vlan.present used where lvalue required.
542 # Moving one field into another.
543 reg0 = reg1; => actions=move:OXM_OF_PKT_REG0[0..31]->OXM_OF_PKT_REG0[32..63], prereqs=1
544 vlan.pcp = reg0[0..2]; => actions=move:OXM_OF_PKT_REG0[32..34]->NXM_OF_VLAN_TCI[13..15], prereqs=vlan.tci[12]
545 reg0[10] = vlan.pcp[1]; => actions=move:NXM_OF_VLAN_TCI[14]->OXM_OF_PKT_REG0[42], prereqs=vlan.tci[12]
546 outport = inport; => actions=move:NXM_NX_REG14[]->NXM_NX_REG15[], prereqs=1
548 reg0[0] = vlan.present; => Predicate symbol vlan.present used where lvalue required.
549 reg0 = reg1[0..10]; => Can't assign 11-bit value to 32-bit destination.
550 inport = reg0; => Can't assign integer field (reg0) to string field (inport).
551 inport = big_string; => String fields inport and big_string are incompatible for assignment.
552 ip.proto = reg0[0..7]; => Field ip.proto is not modifiable.
555 reg0 <-> reg1; => actions=push:OXM_OF_PKT_REG0[0..31],push:OXM_OF_PKT_REG0[32..63],pop:OXM_OF_PKT_REG0[0..31],pop:OXM_OF_PKT_REG0[32..63], prereqs=1
556 vlan.pcp <-> reg0[0..2]; => actions=push:OXM_OF_PKT_REG0[32..34],push:NXM_OF_VLAN_TCI[13..15],pop:OXM_OF_PKT_REG0[32..34],pop:NXM_OF_VLAN_TCI[13..15], prereqs=vlan.tci[12]
557 reg0[10] <-> vlan.pcp[1]; => actions=push:NXM_OF_VLAN_TCI[14],push:OXM_OF_PKT_REG0[42],pop:NXM_OF_VLAN_TCI[14],pop:OXM_OF_PKT_REG0[42], prereqs=vlan.tci[12]
558 outport <-> inport; => actions=push:NXM_NX_REG14[],push:NXM_NX_REG15[],pop:NXM_NX_REG14[],pop:NXM_NX_REG15[], prereqs=1
560 reg0[0] <-> vlan.present; => Predicate symbol vlan.present used where lvalue required.
561 reg0 <-> reg1[0..10]; => Can't exchange 32-bit field with 11-bit field.
562 inport <-> reg0; => Can't exchange string field (inport) with integer field (reg0).
563 inport <-> big_string; => String fields inport and big_string are incompatible for exchange.
564 ip.proto <-> reg0[0..7]; => Field ip.proto is not modifiable.
565 reg0[0..7] <-> ip.proto; => Field ip.proto is not modifiable.
568 ip.ttl--; => actions=dec_ttl, prereqs=ip
569 ip.ttl => Syntax error at end of input expecting `--'.
572 ct_lb; => actions=ct(table=27,zone=NXM_NX_REG13[0..15],nat), prereqs=ip
573 ct_lb(); => Syntax error at `)' expecting IPv4 address.
574 ct_lb(192.168.1.2:80, 192.168.1.3:80); => actions=group:1, prereqs=ip
575 ct_lb(192.168.1.2, 192.168.1.3, ); => actions=group:2, prereqs=ip
576 ct_lb(192.168.1.2:); => Syntax error at `)' expecting port number.
577 ct_lb(192.168.1.2:123456); => Syntax error at `123456' expecting port number.
578 ct_lb(foo); => Syntax error at `foo' expecting IPv4 address.
581 ct_next; => actions=ct(table=27,zone=NXM_NX_REG13[0..15]), prereqs=ip
582 ct_commit; => actions=ct(commit,zone=NXM_NX_REG13[0..15]), prereqs=ip
583 ct_commit(); => actions=ct(commit,zone=NXM_NX_REG13[0..15]), prereqs=ip
584 ct_commit(ct_mark=1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark)), prereqs=ip
585 ct_commit(ct_mark=1/1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_mark)), prereqs=ip
586 ct_commit(ct_label=1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_label)), prereqs=ip
587 ct_commit(ct_label=1/1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_label)), prereqs=ip
588 ct_commit(ct_mark=1, ct_label=2); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark,set_field:0x2->ct_label)), prereqs=ip
591 ct_dnat; => actions=ct(table=27,zone=NXM_NX_REG11[0..15],nat), prereqs=ip
592 ct_dnat(192.168.1.2); => actions=ct(commit,table=27,zone=NXM_NX_REG11[0..15],nat(dst=192.168.1.2)), prereqs=ip
593 ct_dnat(192.168.1.2, 192.168.1.3); => Syntax error at `,' expecting `)'.
594 ct_dnat(foo); => Syntax error at `foo' invalid ip.
595 ct_dnat(foo, bar); => Syntax error at `foo' invalid ip.
596 ct_dnat(); => Syntax error at `)' invalid ip.
599 ct_snat; => actions=ct(zone=NXM_NX_REG12[0..15],nat), prereqs=ip
600 ct_snat(192.168.1.2); => actions=ct(commit,table=27,zone=NXM_NX_REG12[0..15],nat(src=192.168.1.2)), prereqs=ip
601 ct_snat(192.168.1.2, 192.168.1.3); => Syntax error at `,' expecting `)'.
602 ct_snat(foo); => Syntax error at `foo' invalid ip.
603 ct_snat(foo, bar); => Syntax error at `foo' invalid ip.
604 ct_snat(); => Syntax error at `)' invalid ip.
608 arp { eth.dst = ff:ff:ff:ff:ff:ff; output; }; => actions=controller(userdata=00.00.00.00.00.00.00.00.00.19.00.10.80.00.06.06.ff.ff.ff.ff.ff.ff.00.00.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00), prereqs=ip4
611 get_arp(outport, ip4.dst); => actions=push:NXM_NX_REG0[],push:NXM_OF_IP_DST[],pop:NXM_NX_REG0[],set_field:00:00:00:00:00:00->eth_dst,resubmit(,65),pop:NXM_NX_REG0[], prereqs=eth.type == 0x800
612 get_arp(inport, reg0); => actions=push:NXM_NX_REG15[],push:NXM_NX_REG0[],push:OXM_OF_PKT_REG0[32..63],push:NXM_NX_REG14[],pop:NXM_NX_REG15[],pop:NXM_NX_REG0[],set_field:00:00:00:00:00:00->eth_dst,resubmit(,65),pop:NXM_NX_REG0[],pop:NXM_NX_REG15[], prereqs=1
613 get_arp; => Syntax error at `;' expecting `('.
614 get_arp(); => Syntax error at `)' expecting field name.
615 get_arp(inport); => Syntax error at `)' expecting `,'.
616 get_arp(inport ip4.dst); => Syntax error at `ip4.dst' expecting `,'.
617 get_arp(inport, ip4.dst; => Syntax error at `;' expecting `)'.
618 get_arp(inport, eth.dst); => Cannot use 48-bit field eth.dst[0..47] where 32-bit field is required.
619 get_arp(inport, outport); => Cannot use string field outport where numeric field is required.
620 get_arp(reg0, ip4.dst); => Cannot use numeric field reg0 where string field is required.
623 put_arp(inport, arp.spa, arp.sha); => actions=push:NXM_NX_REG0[],push:NXM_OF_ETH_SRC[],push:NXM_NX_ARP_SHA[],push:NXM_OF_ARP_SPA[],pop:NXM_NX_REG0[],pop:NXM_OF_ETH_SRC[],controller(userdata=00.00.00.01.00.00.00.00),pop:NXM_OF_ETH_SRC[],pop:NXM_NX_REG0[], prereqs=eth.type == 0x806 && eth.type == 0x806
626 reg1[0] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); => actions=controller(userdata=00.00.00.02.00.00.00.00.80.01.00.08.00.00.00.00.01.02.03.04.03.04.0a.00.00.01,pause), prereqs=1
627 reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,mtu=1400,domain="ovn.org"); => actions=controller(userdata=00.00.00.02.00.00.00.00.80.01.02.08.00.00.00.25.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.fe.00.1a.02.05.78.0f.07.6f.76.6e.2e.6f.72.67,pause), prereqs=1
628 # offerip=10.0.0.4 --> 0a.00.00.04
629 # router=10.0.0.1 --> 03.04.0a.00.00.01
630 # netmask=255.255.255.0 --> 01.04.ff.ff.ff.00
631 # mtu=1400 --> 1a.02.05.78
632 # ip_forward_enable-1 --> 13.01.01
633 # default_ttl=121 --> 17.01.79
634 # dns_server={8.8.8.8,7.7.7.7} --> 06.08.08.08.08.08.07.07.07.07
635 # classless_static_route= --> 79.14
636 # {30.0.0.0/24,10.0.0.4 --> 18.1e.00.00.0a.00.00.04
637 # 40.0.0.0/16,10.0.0.6 --> 10.28.00.0a.00.00.06
638 # 0.0.0.0/0,10.0.0.1} --> 00.0a.00.00.01
639 # ethernet_encap=1 --> 24.01.01
640 # router_discovery=0 --> 1f.01.00
641 reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0); => actions=controller(userdata=00.00.00.02.00.00.00.00.80.01.00.08.00.00.00.2f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00,pause), prereqs=1
642 reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); => Cannot use 2-bit field reg1[0..1] where 1-bit field is required.
643 reg1[0] = put_dhcp_opts(); => Syntax error at `)'.
644 reg1[0] = put_dhcp_opts(x = 1.2.3.4, router = 10.0.0.1); => Syntax error at `x' expecting offerip option.
645 reg1[0] = put_dhcp_opts(offerip=1.2.3.4, "hi"); => Syntax error at `"hi"'.
646 reg1[0] = put_dhcp_opts(offerip=1.2.3.4, xyzzy); => Syntax error at `xyzzy' expecting DHCP option name.
647 reg1[0] = put_dhcp_opts(offerip="xyzzy"); => DHCP option offerip requires numeric value.
648 reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain=1.2.3.4); => DHCP option domain requires string value.
651 na { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; /* Allow sending out inport. */ output; }; => actions=controller(userdata=00.00.00.03.00.00.00.00.00.19.00.10.80.00.08.06.12.34.56.78.9a.bc.00.00.00.19.00.10.80.00.42.06.12.34.56.78.9a.bc.00.00.ff.ff.00.18.00.00.23.20.00.06.00.20.00.00.00.00.00.01.1c.04.00.01.1e.04.00.19.00.10.00.01.1c.04.00.00.00.00.00.00.00.00.00.19.00.10.00.00.00.02.00.00.00.00.00.00.00.00.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00), prereqs=nd
653 # Contradictionary prerequisites (allowed but not useful):
654 ip4.src = ip6.src[0..31]; => actions=move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[], prereqs=eth.type == 0x800 && eth.type == 0x86dd
655 ip4.src <-> ip6.src[0..31]; => actions=push:NXM_NX_IPV6_SRC[0..31],push:NXM_OF_IP_SRC[],pop:NXM_NX_IPV6_SRC[0..31],pop:NXM_OF_IP_SRC[], prereqs=eth.type == 0x800 && eth.type == 0x86dd
657 ## Miscellaneous negative tests.
658 ; => Syntax error at `;'.
659 xyzzy; => Syntax error at `xyzzy' expecting action.
660 next; 123; => Syntax error at `123'.
661 next; xyzzy; => Syntax error at `xyzzy' expecting action.
662 next => Syntax error at end of input expecting ';'.
664 sed 's/ =>.*//' test-cases.txt > input.txt
665 sed 's/.* => //' test-cases.txt > expout
666 AT_CHECK([ovstest test-ovn parse-actions < input.txt], [0], [expout])
669 AT_BANNER([OVN end-to-end tests])
671 # 3 hypervisors, one logical switch, 3 logical ports per hypervisor
672 AT_SETUP([ovn -- 3 HVs, 1 LS, 3 lports/HV])
673 AT_KEYWORDS([ovnarp])
674 AT_SKIP_IF([test $HAVE_PYTHON = no])
677 # Create hypervisors hv[123].
678 # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3.
679 # Add all of the vifs to a single logical switch lsw0.
680 # Turn on port security on all the vifs except vif[123]1.
681 # Make vif13, vif2[23], vif3[123] destinations for unknown MACs.
682 # Add some ACLs for Ethertypes 1234, 1235, 1236.
683 ovn-nbctl ls-add lsw0
688 ovs-vsctl add-br br-phys
689 ovn_attach n1 br-phys 192.168.0.$i
692 ovs-vsctl add-port br-int vif$i$j -- set Interface vif$i$j external-ids:iface-id=lp$i$j options:tx_pcap=hv$i/vif$i$j-tx.pcap options:rxq_pcap=hv$i/vif$i$j-rx.pcap ofport-request=$i$j
693 ovn-nbctl lsp-add lsw0 lp$i$j
695 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown
698 ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j"
700 ip_addrs="192.168.0.$i$j"
702 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs"
703 ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j
707 ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop
708 ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop
709 ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop
710 ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:11\",\"f0:00:00:00:00:21\",\"f0:00:00:00:00:31\"
711 ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop
713 # Pre-populate the hypervisors' ARP tables so that we don't lose any
714 # packets for ARP resolution (native tunneling doesn't queue packets
715 # for ARP resolution).
718 # Allow some time for ovn-northd and ovn-controller to catch up.
719 # XXX This should be more systematic.
722 # Given the name of a logical port, prints the name of the hypervisor
723 # on which it is located.
728 # test_packet INPORT DST SRC ETHTYPE OUTPORT...
730 # This shell function causes a packet to be received on INPORT. The packet's
731 # content has Ethernet destination DST and source SRC (each exactly 12 hex
732 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
733 # more) list the VIFs on which the packet should be received. INPORT and the
734 # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11.
736 sed 's/\(00\)\{1,\}$//'
744 local inport=$1 packet=$2$3$4; shift; shift; shift; shift
745 hv=`vif_to_hv $inport`
747 as $hv ovs-appctl netdev-dummy/receive $vif $packet
749 echo $packet | trim_zeros >> $outport.expected
753 # test_arp INPORT SHA SPA TPA [REPLY_HA]
755 # Causes a packet to be received on INPORT. The packet is an ARP
756 # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then
757 # it should be the hardware address of the target to expect to receive in an
758 # ARP reply; otherwise no reply is expected.
760 # INPORT is an logical switch port number, e.g. 11 for vif11.
761 # SHA and REPLY_HA are each 12 hex digits.
762 # SPA and TPA are each 8 hex digits.
764 local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5
765 local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa}
766 hv=`vif_to_hv $inport`
767 as $hv ovs-appctl netdev-dummy/receive vif$inport $request
769 if test X$reply_ha = X; then
770 # Expect to receive the broadcast ARP on the other logical switch ports
771 # if no reply is expected.
775 if test $i$j != $inport; then
776 echo $request >> $i$j.expected
781 # Expect to receive the reply, if any.
782 local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa}
783 echo $reply >> $inport.expected
788 printf "%02x%02x%02x%02x" "$@"
791 # Send packets between all pairs of source and destination ports:
793 # 1. Unicast packets are delivered to exactly one logical switch port
794 # (except that packets destined to their input ports are dropped).
796 # 2. Broadcast and multicast are delivered to all logical switch ports
797 # except the input port.
799 # 3. When port security is turned on, the switch drops packets from the wrong
802 # 4. The switch drops all packets with a VLAN tag.
804 # 5. The switch drops all packets with a multicast source address. (This only
805 # affects behavior when port security is turned off, since otherwise port
806 # security would drop the packet anyway.)
808 # 6. The switch delivers packets with an unknown destination to logical
809 # switch ports with "unknown" among their MAC addresses (and port
810 # security disabled).
812 # 7. The switch drops unicast packets that violate an ACL.
814 # 8. The switch drops multicast and broadcast packets that violate an ACL.
816 # 9. ARP requests to known IPs are responded directly.
818 # 10. No response to ARP requests for unknown IPs.
830 if test $d != $s; then unicast=$d; else unicast=; fi
831 test_packet $s f000000000$d f000000000$s $s$d $unicast #1
833 if test $d != $s && test $js = 1; then
838 test_packet $s f000000000$d f00000000055 55$d $impersonate #3
840 if test $d != $s && test $s != 11; then acl2=$d; else acl2=; fi
841 if test $d != $s && test $d != 33; then acl3=$d; else acl3=; fi
842 if test $d = $s || (test $js = 1 && test $d = 33); then
843 # Source of 11, 21, or 31 and dest of 33 should be dropped
844 # due to the 4th ACL that uses address_set(set1).
849 test_packet $s f000000000$d f000000000$s 1234 #7, acl1
850 test_packet $s f000000000$d f000000000$s 1235 $acl2 #7, acl2
851 test_packet $s f000000000$d f000000000$s 1236 $acl3 #7, acl3
852 test_packet $s f000000000$d f000000000$s 1237 $acl4 #7, acl4
854 test_packet $s f000000000$d f00000000055 810000091234 #4
855 test_packet $s f000000000$d 0100000000$s $s$d #5
857 if test $d != $s && test $jd = 1; then
858 unknown="$unknown $d"
860 bcast="$bcast $unicast"
864 sip=`ip_to_hex 192 168 0 $i$j`
865 tip=`ip_to_hex 192 168 0 $id$jd`
866 tip_unknown=`ip_to_hex 11 11 11 11`
867 test_arp $s f000000000$s $sip $tip f000000000$d #9
868 test_arp $s f000000000$s $sip $tip_unknown #10
870 if test $jd = 3; then
871 # lsp[123]3 has an additional ip 192.169.0.[123]3.
872 tip=`ip_to_hex 192 169 0 $id$jd`
873 test_arp $s f000000000$s $sip $tip f000000000$d #9
878 # Broadcast and multicast.
879 test_packet $s ffffffffffff f000000000$s ${s}ff $bcast #2
880 test_packet $s 010000000000 f000000000$s ${s}ff $bcast #2
881 if test $js = 1; then
882 bcast_impersonate=$bcast
886 test_packet $s 010000000000 f00000000044 44ff $bcast_impersonate #3
888 test_packet $s f0000000ffff f000000000$s ${s}66 $unknown #6
890 test_packet $s ffffffffffff f000000000$s 1234 #8, acl1
891 test_packet $s ffffffffffff f000000000$s 1235 $bacl2 #8, acl2
892 test_packet $s ffffffffffff f000000000$s 1236 $bacl3 #8, acl3
893 test_packet $s 010000000000 f000000000$s 1234 #8, acl1
894 test_packet $s 010000000000 f000000000$s 1235 $bacl2 #8, acl2
895 test_packet $s 010000000000 f000000000$s 1236 $bacl3 #8, acl3
899 # set address for lp13 with invalid characters.
900 # lp13 should be configured with only 192.168.0.13.
901 ovn-nbctl lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13"
902 sip=`ip_to_hex 192 168 0 11`
903 tip=`ip_to_hex 192 168 0 13`
904 test_arp 11 f00000000011 $sip $tip f00000000013
906 tip=`ip_to_hex 192 169 0 13`
907 #arp request for 192.169.0.13 should be flooded
908 test_arp 11 f00000000011 $sip $tip
910 # Allow some time for packet forwarding.
911 # XXX This can be improved.
914 # dump information and flows with counters
915 ovn-sbctl dump-flows -- list multicast_group
917 echo "------ hv1 dump ------"
918 as hv1 ovs-vsctl show
919 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
921 echo "------ hv2 dump ------"
922 as hv2 ovs-vsctl show
923 as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
925 echo "------ hv3 dump ------"
926 as hv3 ovs-vsctl show
927 as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int
928 # Now check the packets actually received against the ones expected.
931 file=hv$i/vif$i$j-tx.pcap
933 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i$j.packets
934 sort $i$j.expected > expout
935 AT_CHECK([sort $i$j.packets], [0], [expout])
940 OVN_CLEANUP([hv1],[hv2],[hv3])
944 # 2 hypervisors, 4 logical ports per HV
945 # 2 locally attached networks (one flat, one vlan tagged over same device)
946 # 2 ports per HV on each network
947 AT_SETUP([ovn -- 2 HVs, 4 lports/HV, localnet ports])
948 AT_KEYWORDS([ovn-localnet])
949 AT_SKIP_IF([test $HAVE_PYTHON = no])
952 # In this test cases we create 3 switches, all connected to same
953 # physical network (through br-phys on each HV). Each switch has
954 # VIF ports across 2 HVs. Each HV has 5 VIF ports. The first digit
955 # of VIF port name indicates the hypervisor it is bound to, e.g.
956 # lp23 means VIF 3 on hv2.
958 # Each switch's VLAN tag and their logical switch ports are:
961 # - ports: lp11, lp12, lp21, lp22
964 # - tagged with VLAN 101
965 # - ports: lp13, lp14, lp23, lp24
968 # - ports: lp15, lp25
970 # Note: a localnet port is created for each switch to connect to
975 ovn-nbctl ls-add $ls_name
977 if test $i -eq 2; then
978 ovn-nbctl lsp-add $ls_name $ln_port_name "" 101
980 ovn-nbctl lsp-add $ls_name $ln_port_name
982 ovn-nbctl lsp-set-addresses $ln_port_name unknown
983 ovn-nbctl lsp-set-type $ln_port_name localnet
984 ovn-nbctl lsp-set-options $ln_port_name network_name=phys
991 ovs-vsctl add-br br-phys
992 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
993 ovn_attach n1 br-phys 192.168.0.$i
995 for j in 1 2 3 4 5; do
996 ovs-vsctl add-port br-int vif$i$j -- \
997 set Interface vif$i$j external-ids:iface-id=lp$i$j \
998 options:tx_pcap=hv$i/vif$i$j-tx.pcap \
999 options:rxq_pcap=hv$i/vif$i$j-rx.pcap \
1003 if test $j -le 2; then
1005 elif test $j -le 4; then
1011 ovn-nbctl lsp-add $ls_name $lsp_name
1012 ovn-nbctl lsp-set-addresses $lsp_name f0:00:00:00:00:$i$j
1013 ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$j
1015 OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup])
1021 # XXX This is now the 3rd copy of these functions in this file ...
1023 # Given the name of a logical port, prints the name of the hypervisor
1024 # on which it is located.
1029 # test_packet INPORT DST SRC ETHTYPE OUTPORT...
1031 # This shell function causes a packet to be received on INPORT. The packet's
1032 # content has Ethernet destination DST and source SRC (each exactly 12 hex
1033 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1034 # more) list the VIFs on which the packet should be received. INPORT and the
1035 # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11.
1037 sed 's/\(00\)\{1,\}$//'
1040 for j in 1 2 3 4 5; do
1045 local inport=$1 src=$2 dst=$3 eth=$4; shift; shift; shift; shift
1046 local packet=${src}${dst}${eth}
1047 hv=`vif_to_hv $inport`
1049 as $hv ovs-appctl netdev-dummy/receive $vif $packet
1051 echo $packet | trim_zeros >> $outport.expected
1055 # lp11 and lp21 are on the same network (phys, untagged)
1056 # and on different hypervisors
1057 test_packet 11 f00000000021 f00000000011 1121 21
1058 test_packet 21 f00000000011 f00000000021 2111 11
1060 # lp11 and lp12 are on the same network (phys, untagged)
1061 # and on the same hypervisor
1062 test_packet 11 f00000000012 f00000000011 1112 12
1063 test_packet 12 f00000000011 f00000000012 1211 11
1065 # lp13 and lp23 are on the same network (phys, VLAN 101)
1066 # and on different hypervisors
1067 test_packet 13 f00000000023 f00000000013 1323 23
1068 test_packet 23 f00000000013 f00000000023 2313 13
1070 # lp13 and lp14 are on the same network (phys, VLAN 101)
1071 # and on the same hypervisor
1072 test_packet 13 f00000000014 f00000000013 1314 14
1073 test_packet 14 f00000000013 f00000000014 1413 13
1075 # lp11 and lp15 are on the same network (phys, untagged),
1076 # same hypervisor, and on different switches
1077 test_packet 11 f00000000015 f00000000011 1115 15
1078 test_packet 15 f00000000011 f00000000015 1511 11
1080 # lp11 and lp25 are on the same network (phys, untagged),
1081 # different hypervisors, and on different switches
1082 test_packet 11 f00000000025 f00000000011 1125 25
1083 test_packet 25 f00000000011 f00000000025 2511 11
1085 # Ports that should not be able to communicate
1086 test_packet 11 f00000000013 f00000000011 1113
1087 test_packet 11 f00000000023 f00000000011 1123
1088 test_packet 21 f00000000013 f00000000021 2113
1089 test_packet 21 f00000000023 f00000000021 2123
1090 test_packet 13 f00000000011 f00000000013 1311
1091 test_packet 13 f00000000021 f00000000013 1321
1092 test_packet 23 f00000000011 f00000000023 2311
1093 test_packet 23 f00000000021 f00000000023 2321
1095 # Allow some time for packet forwarding.
1096 # XXX This can be improved.
1099 # Dump a bunch of info helpful for debugging if there's a failure.
1101 echo "------ OVN dump ------"
1105 echo "------ hv1 dump ------"
1106 as hv1 ovs-vsctl show
1107 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1109 echo "------ hv2 dump ------"
1110 as hv2 ovs-vsctl show
1111 as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1113 # Now check the packets actually received against the ones expected.
1115 for j in 1 2 3 4 5; do
1116 file=hv$i/vif$i$j-tx.pcap
1118 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i$j.packets
1119 sort $i$j.expected > expout
1120 AT_CHECK([sort $i$j.packets], [0], [expout])
1125 OVN_CLEANUP([hv1],[hv2])
1129 AT_SETUP([ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS])
1131 AT_SKIP_IF([test $HAVE_PYTHON = no])
1134 # Configure the Northbound database
1135 ovn-nbctl ls-add lsw0
1137 ovn-nbctl lsp-add lsw0 lp1
1138 ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01
1140 ovn-nbctl lsp-add lsw0 lp2
1141 ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02
1143 ovn-nbctl lsp-add lsw0 lp-vtep
1144 ovn-nbctl lsp-set-type lp-vtep vtep
1145 ovn-nbctl lsp-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0
1146 ovn-nbctl lsp-set-addresses lp-vtep unknown
1148 net_add n1 # Network to connect hv1, hv2, and vtep
1149 net_add n2 # Network to connect vtep and hv3
1151 # Create hypervisor hv1 connected to n1
1154 ovs-vsctl add-br br-phys
1155 ovn_attach n1 br-phys 192.168.0.1
1156 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=hv1/vif1-tx.pcap options:rxq_pcap=hv1/vif1-rx.pcap ofport-request=1
1158 # Create hypervisor hv2 connected to n1
1161 ovs-vsctl add-br br-phys
1162 ovn_attach n1 br-phys 192.168.0.2
1163 ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=hv2/vif2-tx.pcap options:rxq_pcap=hv2/vif2-rx.pcap ofport-request=1
1166 # Start the vtep emulator with a leg in both networks
1170 ovsdb-tool create "$ovs_base"/vtep/vtep.db "$abs_top_srcdir"/vtep/vtep.ovsschema || return 1
1171 ovs-appctl -t ovsdb-server ovsdb-server/add-db "$ovs_base"/vtep/vtep.db
1173 ovs-vsctl add-br br-phys
1174 net_attach n1 br-phys
1176 mac=`ovs-vsctl get Interface br-phys mac_in_use | sed s/\"//g`
1177 arp_table="$arp_table $sandbox,br-phys,192.168.0.3,$mac"
1178 ovs-appctl netdev-dummy/ip4addr br-phys 192.168.0.3/24 >/dev/null || return 1
1179 ovs-appctl ovs/route/add 192.168.0.3/24 br-phys >/dev/null || return 1
1181 ovs-vsctl add-br br-vtep
1182 net_attach n2 br-vtep
1184 vtep-ctl add-ps br-vtep
1185 vtep-ctl set Physical_Switch br-vtep tunnel_ips=192.168.0.3
1186 vtep-ctl add-ls lsw0
1188 start_daemon ovs-vtep br-vtep
1189 start_daemon ovn-controller-vtep --vtep-db=unix:"$ovs_base"/vtep/db.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock
1193 vtep-ctl bind-ls br-vtep br-vtep_n2 0 lsw0
1197 # Add hv3 on the other side of the vtep
1200 ovs-vsctl add-br br-phys
1201 net_attach n2 br-phys
1203 ovs-vsctl add-port br-phys vif3 -- set Interface vif3 options:tx_pcap=hv3/vif3-tx.pcap options:rxq_pcap=hv3/vif3-rx.pcap ofport-request=1
1205 # Pre-populate the hypervisors' ARP tables so that we don't lose any
1206 # packets for ARP resolution (native tunneling doesn't queue packets
1207 # for ARP resolution).
1210 # Allow some time for ovn-northd and ovn-controller to catch up.
1211 # XXX This should be more systematic.
1214 # test_packet INPORT DST SRC ETHTYPE OUTPORT...
1216 # This shell function causes a packet to be received on INPORT. The packet's
1217 # content has Ethernet destination DST and source SRC (each exactly 12 hex
1218 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1219 # more) list the VIFs on which the packet should be received. INPORT and the
1220 # OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1.
1222 sed 's/\(00\)\{1,\}$//'
1228 local inport=$1 packet=$2$3$4; shift; shift; shift; shift
1229 #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'`
1232 as $hv ovs-appctl netdev-dummy/receive $vif $packet
1234 echo $packet | trim_zeros >> $outport.expected
1238 # Send packets between all pairs of source and destination ports:
1240 # 1. Unicast packets are delivered to exactly one logical switch port
1241 # (except that packets destined to their input ports are dropped).
1243 # 2. Broadcast and multicast are delivered to all logical switch ports
1244 # except the input port.
1246 # 3. The switch delivers packets with an unknown destination to logical
1247 # switch ports with "unknown" among their MAC addresses (and port
1248 # security disabled).
1253 if test $d != $s; then unicast=$d; else unicast=; fi
1254 test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1
1256 # The vtep (vif3) is the only one configured for "unknown"
1257 if test $d != $s && test $d = 3; then
1258 unknown="$unknown $d"
1260 bcast="$bcast $unicast"
1263 # Broadcast and multicast.
1264 test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2
1265 test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #2
1267 test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #3
1270 # Allow some time for packet forwarding.
1271 # XXX This can be improved.
1274 # dump information with counters
1275 echo "------ OVN dump ------"
1279 echo "------ hv1 dump ------"
1280 as hv1 ovs-vsctl show
1281 as hv1 ovs-ofctl -O OpenFlow13 show br-int
1282 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1284 echo "------ hv2 dump ------"
1285 as hv2 ovs-vsctl show
1286 as hv2 ovs-ofctl -O OpenFlow13 show br-int
1287 as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1289 echo "------ hv3 dump ------"
1290 as hv3 ovs-vsctl show
1291 # note: hv3 has no logical port bind, thus it should not have br-int
1292 AT_CHECK([as hv3 ovs-ofctl -O OpenFlow13 show br-int], [1], [],
1293 [ovs-ofctl: br-int is not a bridge or a socket
1296 # Now check the packets actually received against the ones expected.
1298 file=hv$i/vif$i-tx.pcap
1300 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i.packets
1301 sort $i.expected > expout
1302 AT_CHECK([sort $i.packets], [0], [expout])
1306 # Gracefully terminate daemons
1307 OVN_CLEANUP([hv1],[hv2],[vtep])
1308 OVN_CLEANUP_VSWITCH([hv3])
1312 # Similar test to "hardware GW"
1313 AT_SETUP([ovn -- 3 HVs, 1 VIFs/HV, 1 software GW, 1 LS])
1314 AT_SKIP_IF([test $HAVE_PYTHON = no])
1317 # Configure the Northbound database
1318 ovn-nbctl ls-add lsw0
1320 ovn-nbctl lsp-add lsw0 lp1
1321 ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01
1323 ovn-nbctl lsp-add lsw0 lp2
1324 ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02
1326 ovn-nbctl lsp-add lsw0 lp-gw
1327 ovn-nbctl lsp-set-type lp-gw l2gateway
1328 ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw
1329 ovn-nbctl lsp-set-addresses lp-gw unknown
1331 net_add n1 # Network to connect hv1, hv2, and gw
1332 net_add n2 # Network to connect gw and hv3
1334 # Create hypervisor hv1 connected to n1
1337 ovs-vsctl add-br br-phys
1338 ovn_attach n1 br-phys 192.168.0.1
1339 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=hv1/vif1-tx.pcap options:rxq_pcap=hv1/vif1-rx.pcap ofport-request=1
1341 # Create hypervisor hv2 connected to n1
1344 ovs-vsctl add-br br-phys
1345 ovn_attach n1 br-phys 192.168.0.2
1346 ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=hv2/vif2-tx.pcap options:rxq_pcap=hv2/vif2-rx.pcap ofport-request=1
1348 # Create hypervisor hv_gw connected to n1 and n2
1349 # connect br-phys bridge to n1; connect hv-gw bridge to n2
1352 ovs-vsctl add-br br-phys
1353 ovn_attach n1 br-phys 192.168.0.3
1354 ovs-vsctl add-br br-phys2
1355 net_attach n2 br-phys2
1356 ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2"
1358 # Add hv3 on the other side of the GW
1361 ovs-vsctl add-br br-phys
1362 net_attach n2 br-phys
1363 ovs-vsctl add-port br-phys vif3 -- set Interface vif3 options:tx_pcap=hv3/vif3-tx.pcap options:rxq_pcap=hv3/vif3-rx.pcap ofport-request=1
1366 # Pre-populate the hypervisors' ARP tables so that we don't lose any
1367 # packets for ARP resolution (native tunneling doesn't queue packets
1368 # for ARP resolution).
1371 # Allow some time for ovn-northd and ovn-controller to catch up.
1372 # XXX This should be more systematic.
1375 # test_packet INPORT DST SRC ETHTYPE OUTPORT...
1377 # This shell function causes a packet to be received on INPORT. The packet's
1378 # content has Ethernet destination DST and source SRC (each exactly 12 hex
1379 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1380 # more) list the VIFs on which the packet should be received. INPORT and the
1381 # OUTPORTs are specified as lport numbers, e.g. 1 for vif1.
1383 sed 's/\(00\)\{1,\}$//'
1389 local inport=$1 packet=$2$3$4; shift; shift; shift; shift
1390 #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'`
1393 as $hv ovs-appctl netdev-dummy/receive $vif $packet
1395 echo $packet | trim_zeros >> $outport.expected
1399 # Send packets between all pairs of source and destination ports:
1401 # 1. Unicast packets are delivered to exactly one lport (except that packets
1402 # destined to their input ports are dropped).
1404 # 2. Broadcast and multicast are delivered to all lports except the input port.
1406 # 3. The lswitch delivers packets with an unknown destination to lports with
1407 # "unknown" among their MAC addresses (and port security disabled).
1412 if test $d != $s; then unicast=$d; else unicast=; fi
1413 test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1
1415 # The vtep (vif3) is the only one configured for "unknown"
1416 if test $d != $s && test $d = 3; then
1417 unknown="$unknown $d"
1419 bcast="$bcast $unicast"
1422 test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2
1423 test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #3
1424 test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #4
1427 # Allow some time for packet forwarding.
1428 # XXX This can be improved.
1431 echo "------ ovn-nbctl show ------"
1433 echo "------ ovn-sbctl show ------"
1436 echo "------ hv1 ------"
1437 as hv1 ovs-vsctl show
1438 echo "------ hv1 br-int ------"
1439 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1440 echo "------ hv1 br-phys ------"
1441 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-phys
1443 echo "------ hv2 ------"
1444 as hv2 ovs-vsctl show
1445 echo "------ hv2 br-int ------"
1446 as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1447 echo "------ hv2 br-phys ------"
1448 as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-phys
1450 echo "------ hv_gw ------"
1451 as hv_gw ovs-vsctl show
1452 echo "------ hv_gw br-phys ------"
1453 as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys
1454 echo "------ hv_gw br-phys2 ------"
1455 as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys2
1457 echo "------ hv3 ------"
1458 as hv3 ovs-vsctl show
1459 echo "------ hv3 br-phys ------"
1460 as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-phys
1462 # Now check the packets actually received against the ones expected.
1464 file=hv$i/vif$i-tx.pcap
1466 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i.packets
1467 sort $i.expected > expout
1468 AT_CHECK([sort $i.packets], [0], [expout])
1473 # 3 hypervisors, 3 logical switches with 3 logical ports each, 1 logical router
1474 AT_SETUP([ovn -- 3 HVs, 3 LS, 3 lports/LS, 1 LR])
1475 AT_SKIP_IF([test $HAVE_PYTHON = no])
1480 # Three logical switches ls1, ls2, ls3.
1481 # One logical router lr0 connected to ls[123],
1482 # with nine subnets, three per logical switch:
1484 # lrp11 on ls1 for subnet 192.168.11.0/24
1485 # lrp12 on ls1 for subnet 192.168.12.0/24
1486 # lrp13 on ls1 for subnet 192.168.13.0/24
1488 # lrp33 on ls3 for subnet 192.168.33.0/24
1490 # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two
1491 # digits are the subnet and the last digit distinguishes the VIF.
1493 ovn-nbctl ls-add ls$i
1496 # Add "unknown" to MAC addresses for lp?11, so packets for
1497 # MAC-IP bindings discovered via ARP later have somewhere to go.
1498 if test $j$k = 11; then unknown=unknown; else unknown=; fi
1501 -- lsp-add ls$i lp$i$j$k \
1502 -- lsp-set-addresses lp$i$j$k "f0:00:00:00:0$i:$j$k \
1503 192.168.$i$j.$k" $unknown
1508 ovn-nbctl lr-add lr0
1511 ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j \
1512 192.168.$i$j.254/24 lrp$i$j-attachment
1514 -- lsp-add ls$i lrp$i$j-attachment \
1515 -- set Logical_Switch_Port lrp$i$j-attachment type=router \
1516 options:router-port=lrp$i$j \
1517 addresses='"00:00:00:00:ff:'$i$j'"'
1521 ovn-nbctl set Logical_Switch_Port lrp33-attachment \
1522 addresses='"00:00:00:00:ff:33 192.168.33.254"'
1526 # Three hypervisors hv[123].
1527 # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3.
1528 # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3.
1529 # lp?3[123] all on hv3.
1532 # Given the name of a logical port, prints the name of the hypervisor
1533 # on which it is located.
1536 ?11) echo 1 ;; dnl (
1537 ?12 | ?21 | ?22) echo 2 ;; dnl (
1538 ?13 | ?23 | ?3?) echo 3 ;;
1542 # Given the name of a logical port, prints the name of its logical router
1543 # port, e.g. "vif_to_lrp 123" yields 12.
1548 # Given the name of a logical port, prints the name of its logical
1549 # switch, e.g. "vif_to_ls 123" yields 1.
1558 ovs-vsctl add-br br-phys
1559 ovn_attach n1 br-phys 192.168.0.$i
1564 hv=`vif_to_hv $i$j$k`
1565 as hv$hv ovs-vsctl \
1566 -- add-port br-int vif$i$j$k \
1567 -- set Interface vif$i$j$k \
1568 external-ids:iface-id=lp$i$j$k \
1569 options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \
1570 options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \
1571 ofport-request=$i$j$k
1576 # Pre-populate the hypervisors' ARP tables so that we don't lose any
1577 # packets for ARP resolution (native tunneling doesn't queue packets
1578 # for ARP resolution).
1581 # Allow some time for ovn-northd and ovn-controller to catch up.
1582 # XXX This should be more systematic.
1585 # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT...
1587 # This shell function causes a packet to be received on INPORT. The packet's
1588 # content has Ethernet destination DST and source SRC (each exactly 12 hex
1589 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1590 # more) list the VIFs on which the packet should be received. INPORT and the
1591 # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123.
1593 sed 's/\(00\)\{1,\}$//'
1603 # This packet has bad checksums but logical L3 routing doesn't check.
1604 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
1605 local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
1606 shift; shift; shift; shift; shift
1607 hv=hv`vif_to_hv $inport`
1608 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
1609 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
1610 in_ls=`vif_to_ls $inport`
1611 in_lrp=`vif_to_lrp $inport`
1613 out_ls=`vif_to_ls $outport`
1614 if test $in_ls = $out_ls; then
1615 # Ports on the same logical switch receive exactly the same packet.
1618 # Routing decrements TTL and updates source and dest MAC
1620 out_lrp=`vif_to_lrp $outport`
1621 echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000
1622 fi | trim_zeros >> $outport.expected
1626 as hv1 ovs-vsctl --columns=name,ofport list interface
1627 as hv1 ovn-sbctl list port_binding
1628 as hv1 ovn-sbctl list datapath_binding
1629 as hv1 ovn-sbctl dump-flows
1630 as hv1 ovs-ofctl dump-flows br-int
1632 # Send IP packets between all pairs of source and destination ports:
1634 # 1. Unicast IP packets are delivered to exactly one logical switch port
1635 # (except that packets destined to their input ports are dropped).
1637 # 2. Broadcast IP packets are delivered to all logical switch ports
1638 # except the input port.
1640 printf "%02x%02x%02x%02x" "$@"
1648 sip=`ip_to_hex 192 168 $is$js $ks`
1653 dip=`ip_to_hex 192 168 $id$jd $kd`
1654 if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi
1655 if test $d != $s; then unicast=$d; else unicast=; fi
1657 test_ip $s $smac $dmac $sip $dip $unicast #1
1659 if test $id = $is && test $d != $s; then bcast="$bcast $d"; fi
1663 test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2
1668 # 3. Send an IP packet from every logical port to every other subnet,
1669 # to an IP address that does not have a static IP-MAC binding.
1670 # This should generate a broadcast ARP request for the destination
1671 # IP address in the destination subnet.
1677 sip=`ip_to_hex 192 168 $is$js $ks`
1680 if test $is$js = $id$jd; then
1685 dmac=00000000ff$is$js
1686 # Calculate a 4th octet for the destination that is
1687 # unique per $s, avoids the .1 .2 .3 and .254 IP addresses
1688 # that have static MAC bindings, and fits in the range
1690 o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10`
1691 dip=`ip_to_hex 192 168 $id$jd $o4`
1692 test_ip $s $smac $dmac $sip $dip
1694 # Every LP on the destination subnet's lswitch should
1695 # receive the ARP request.
1696 lrmac=00000000ff$id$jd
1697 lrip=`ip_to_hex 192 168 $id$jd 254`
1698 arp=ffffffffffff${lrmac}08060001080006040001${lrmac}${lrip}000000000000${dip}
1699 for jd2 in 1 2 3; do
1701 echo $arp | trim_zeros >> $id$jd2$kd.expected
1710 # test_arp INPORT SHA SPA TPA [REPLY_HA]
1712 # Causes a packet to be received on INPORT. The packet is an ARP
1713 # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then
1714 # it should be the hardware address of the target to expect to receive in an
1715 # ARP reply; otherwise no reply is expected.
1717 # INPORT is an logical switch port number, e.g. 11 for vif11.
1718 # SHA and REPLY_HA are each 12 hex digits.
1719 # SPA and TPA are each 8 hex digits.
1721 local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5
1722 local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa}
1723 hv=hv`vif_to_hv $inport`
1724 as $hv ovs-appctl netdev-dummy/receive vif$inport $request
1725 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request
1727 # Expect to receive the broadcast ARP on the other logical switch ports if
1728 # IP address is not configured to the switch patch port.
1729 local i=`vif_to_ls $inport`
1733 # 192.168.33.254 is configured to the switch patch port for lrp33,
1734 # so no ARP flooding expected for it.
1735 if test $i$j$k != $inport && test $tpa != `ip_to_hex 192 168 33 254`; then
1736 echo $request >> $i$j$k.expected
1741 # Expect to receive the reply, if any.
1742 if test X$reply_ha != X; then
1743 lrp=`vif_to_lrp $inport`
1744 local reply=${sha}00000000ff${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa}
1745 echo $reply >> $inport.expected
1749 # Test router replies to ARP requests from all source ports:
1751 # 4. Router replies to query for its MAC address from port's own IP address.
1753 # 5. Router replies to query for its MAC address from any random IP address
1756 # 6. Router replies to query for its MAC address from another subnet.
1758 # 7. No reply to query for IP address other than router IP.
1762 smac=f00000000$i$j$k # Source MAC
1763 sip=`ip_to_hex 192 168 $i$j $k` # Source IP
1764 rip=`ip_to_hex 192 168 $i$j 254` # Router IP
1765 rmac=00000000ff$i$j # Router MAC
1766 otherip=`ip_to_hex 192 168 $i$j 55` # Some other IP in subnet
1767 test_arp $i$j$k $smac $sip $rip $rmac #4
1768 test_arp $i$j$k $smac $otherip $rip $rmac #5
1769 test_arp $i$j$k $smac 0a123456 $rip $rmac #6
1770 test_arp $i$j$k $smac $sip $otherip #7
1775 # Allow some time for packet forwarding.
1776 # XXX This can be improved.
1779 # 8. Generate an ARP reply for each of the IP addresses ARPed for
1782 # Here, the $s is the VIF that originated the ARP request and $d is
1783 # the VIF that sends the ARP reply, which is somewhat backward but
1784 # it means that $s and $d are the same as #3.
1785 : > mac_bindings.expected
1792 if test $is$js = $id$jd; then
1799 o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10`
1800 host_ip=`ip_to_hex 192 168 $id$jd $o4`
1801 host_mac=8000000000$o4
1803 lrmac=00000000ff$id$jd
1804 lrip=`ip_to_hex 192 168 $id$jd 254`
1806 arp=${lrmac}${host_mac}08060001080006040002${host_mac}${host_ip}${lrmac}${lrip}
1812 as $hv ovs-appctl netdev-dummy/receive vif$d $arp
1813 #as $hv ovs-appctl ofproto/trace br-int in_port=$d $arp
1814 #as $hv ovs-ofctl dump-flows br-int table=19
1816 host_ip_pretty=192.168.$id$jd.$o4
1817 host_mac_pretty=80:00:00:00:00:$o4
1818 echo lrp$id$jd,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected
1825 # Allow some time for packet forwarding.
1826 # XXX This can be improved.
1829 # 9. Send an IP packet from every logical port to every other subnet. These
1830 # are the same packets already sent as #3, but now the destinations' IP-MAC
1831 # bindings have been discovered via ARP, so instead of provoking an ARP
1832 # request, these packets now get routed to their destinations (which don't
1833 # have static MAC bindings, so they go to the port we've designated as
1834 # accepting "unknown" MACs.)
1840 sip=`ip_to_hex 192 168 $is$js $ks`
1843 if test $is$js = $id$jd; then
1848 dmac=00000000ff$is$js
1849 # Calculate a 4th octet for the destination that is
1850 # unique per $s, avoids the .1 .2 .3 and .254 IP addresses
1851 # that have static MAC bindings, and fits in the range
1853 o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10`
1854 dip=`ip_to_hex 192 168 $id$jd $o4`
1855 test_ip $s $smac $dmac $sip $dip
1857 # Expect the packet egress.
1858 host_mac=8000000000$o4
1861 echo ${host_mac}00000000ff${out_lrp}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 | trim_zeros >> $outport.expected
1868 # Allow some time for packet forwarding.
1869 # XXX This can be improved.
1872 ovn-sbctl -f csv -d bare --no-heading \
1873 -- --columns=logical_port,ip,mac list mac_binding > mac_bindings
1875 # Now check the packets actually received against the ones expected.
1879 file=hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap
1881 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i$j$k.packets
1882 sort $i$j$k.expected > expout
1883 AT_CHECK([sort $i$j$k.packets], [0], [expout])
1889 # Check the MAC bindings against those expected.
1890 AT_CHECK_UNQUOTED([sort < mac_bindings], [0], [`sort < mac_bindings.expected`
1893 # Gracefully terminate daemons
1894 OVN_CLEANUP([hv1], [hv2], [hv3])
1898 # 3 hypervisors, one logical switch, 3 logical ports per hypervisor
1899 AT_SETUP([ovn -- portsecurity : 3 HVs, 1 LS, 3 lports/HV])
1900 AT_KEYWORDS([portsecurity])
1901 AT_SKIP_IF([test $HAVE_PYTHON = no])
1904 # Create hypervisors hv[123].
1905 # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3.
1906 # Add all of the vifs to a single logical switch lsw0.
1907 # Turn off port security on vifs vif[123]1
1908 # Turn on l2 port security on vifs vif[123]2
1909 # Turn of l2 and l3 port security on vifs vif[123]3
1910 # Make vif13, vif2[23], vif3[123] destinations for unknown MACs.
1911 ovn-nbctl ls-add lsw0
1916 ovs-vsctl add-br br-phys
1917 ovn_attach n1 br-phys 192.168.0.$i
1920 ovs-vsctl add-port br-int vif$i$j -- set Interface vif$i$j external-ids:iface-id=lp$i$j options:tx_pcap=hv$i/vif$i$j-tx.pcap options:rxq_pcap=hv$i/vif$i$j-rx.pcap ofport-request=$i$j
1921 ovn-nbctl lsp-add lsw0 lp$i$j
1922 if test $j = 1; then
1923 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown
1924 elif test $j = 2; then
1925 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j"
1926 ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j
1928 extra_addr="f0:00:00:00:0$i:$i$j fe80::ea2a:eaff:fe28:$i$j"
1929 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr"
1930 ovn-nbctl lsp-set-port-security lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr"
1935 # Pre-populate the hypervisors' ARP tables so that we don't lose any
1936 # packets for ARP resolution (native tunneling doesn't queue packets
1937 # for ARP resolution).
1940 # Allow some time for ovn-northd and ovn-controller to catch up.
1941 # XXX This should be more systematic.
1944 # Given the name of a logical port, prints the name of the hypervisor
1945 # on which it is located.
1952 sed 's/\(00\)\{1,\}$//'
1960 # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT...
1962 # This shell function causes an ip packet to be received on INPORT.
1963 # The packet's content has Ethernet destination DST and source SRC
1964 # (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits).
1965 # The OUTPORTs (zero or more) list the VIFs on which the packet should
1966 # be received. INPORT and the OUTPORTs are specified as logical switch
1967 # port numbers, e.g. 11 for vif11.
1969 # This packet has bad checksums but logical L3 routing doesn't check.
1970 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
1971 local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}003511110008
1972 shift; shift; shift; shift; shift
1973 hv=`vif_to_hv $inport`
1974 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
1975 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
1977 echo $packet | trim_zeros >> $outport.expected
1981 # test_arp INPORT SHA SPA TPA DROP [REPLY_HA]
1983 # Causes a packet to be received on INPORT. The packet is an ARP
1984 # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then
1985 # it should be the hardware address of the target to expect to receive in an
1986 # ARP reply; otherwise no reply is expected.
1988 # INPORT is an logical switch port number, e.g. 11 for vif11.
1989 # SHA and REPLY_HA are each 12 hex digits.
1990 # SPA and TPA are each 8 hex digits.
1992 local inport=$1 smac=$2 sha=$3 spa=$4 tpa=$5 drop=$6 reply_ha=$7
1993 local request=ffffffffffff${smac}08060001080006040001${sha}${spa}ffffffffffff${tpa}
1994 hv=`vif_to_hv $inport`
1995 as $hv ovs-appctl netdev-dummy/receive vif$inport $request
1996 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request
1997 if test $drop != 1; then
1998 if test X$reply_ha = X; then
1999 # Expect to receive the broadcast ARP on the other logical switch ports
2000 # if no reply is expected.
2004 if test $i$j != $inport; then
2005 echo $request >> $i$j.expected
2010 # Expect to receive the reply, if any.
2011 local reply=${smac}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa}
2012 echo $reply >> $inport.expected
2017 # test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT...
2018 # This function is similar to test_ip() except that it sends
2021 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
2022 local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}0000000000000000
2023 shift; shift; shift; shift; shift
2024 hv=`vif_to_hv $inport`
2025 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
2026 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
2028 echo $packet | trim_zeros >> $outport.expected
2032 # test_icmpv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT...
2033 # This function is similar to test_ipv6() except it specifies the ICMPv6 type
2034 # of the test packet
2036 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6
2037 local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}${icmp_type}00000000000000
2038 shift; shift; shift; shift; shift; shift
2039 hv=`vif_to_hv $inport`
2040 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
2041 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
2043 echo $packet | trim_zeros >> $outport.expected
2048 printf "%02x%02x%02x%02x" "$@"
2052 sip=`ip_to_hex 192 168 0 12`
2053 tip=`ip_to_hex 192 168 0 13`
2054 # the arp packet should be allowed even if lp[123]1 is
2055 # not configured with mac f00000000023 and ip 192.168.0.12
2057 test_arp ${i}1 f00000000023 f00000000023 $sip $tip 0 f00000000013
2059 if test $i != $j; then
2060 test_ip ${i}1 f000000000${i}1 f000000000${j}1 $sip $tip ${j}1
2066 sip=`ip_to_hex 192 168 0 12`
2067 tip=`ip_to_hex 192 168 0 13`
2069 # arp packet should be allowed since lp22 is configured with
2071 test_arp 22 f00000000022 f00000000022 $sip $tip 0 f00000000013
2073 # arp packet should not be allowed since lp32 is not configured with
2075 test_arp 32 f00000000021 f00000000021 $sip $tip 1
2077 # arp packet with sha set to f00000000021 should not be allowed
2079 test_arp 12 f00000000012 f00000000021 $sip $tip 1
2081 # ip packets should be allowed and received since lp[123]2 do not
2082 # have l3 port security
2083 sip=`ip_to_hex 192 168 0 55`
2084 tip=`ip_to_hex 192 168 0 66`
2087 if test $i != $j; then
2088 test_ip ${i}2 f000000000${i}2 f000000000${j}2 $sip $tip ${j}2
2093 # ipv6 packets should be received by lp[123]2
2094 # lp[123]1 can send ipv6 traffic as there is no port security
2095 sip=fe800000000000000000000000000000
2096 tip=ff020000000000000000000000000000
2099 test_ipv6 ${i}1 f000000000${i}1 f000000000${i}2 $sip $tip ${i}2
2103 # l2 and l3 port security
2104 sip=`ip_to_hex 192 168 0 13`
2105 tip=`ip_to_hex 192 168 0 22`
2106 # arp packet should be allowed since lp13 is configured with
2107 # f00000000013 and 192.168.0.13
2108 test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022
2110 # the arp packet should be dropped because lp23 is not configured
2111 # with mac f00000000022
2112 sip=`ip_to_hex 192 168 0 13`
2113 tip=`ip_to_hex 192 168 0 22`
2114 test_arp 23 f00000000022 f00000000022 $sip $tip 1
2116 # the arp packet should be dropped because lp33 is not configured
2117 # with ip 192.168.0.55
2118 spa=`ip_to_hex 192 168 0 55`
2119 tpa=`ip_to_hex 192 168 0 22`
2120 test_arp 33 f00000000031 f00000000031 $spa $tpa 1
2122 # ip packets should not be received by lp[123]3 since
2123 # l3 port security is enabled
2124 sip=`ip_to_hex 192 168 0 55`
2125 tip=`ip_to_hex 192 168 0 66`
2128 test_ip ${i}2 f000000000${i}2 f000000000${j}3 $sip $tip
2132 # ipv6 packets should be dropped for lp[123]3 since
2133 # it is configured with only ipv4 address
2134 sip=fe800000000000000000000000000000
2135 tip=ff020000000000000000000000000000
2138 test_ipv6 ${i}3 f000000000${i}3 f00000000022 $sip $tip
2141 # ipv6 packets should not be received by lp[123]3 with mac f000000000$[123]3
2142 # lp[123]1 can send ipv6 traffic as there is no port security
2144 test_ipv6 ${i}1 f000000000${i}1 f000000000${i}3 $sip $tip
2147 # lp13 has extra port security with mac f0000000113 and ipv6 addr
2148 # fe80::ea2a:eaff:fe28:0012
2150 # ipv4 packet should be dropped for lp13 with mac f0000000113
2151 sip=`ip_to_hex 192 168 0 13`
2152 tip=`ip_to_hex 192 168 0 23`
2153 test_ip 13 f00000000113 f00000000023 $sip $tip
2155 # ipv6 packet should be received by lp[123]3 with mac f0000000{i}{i}3
2156 # and ip6.dst as fe80::ea2a:eaff:fe28:0{i}{i}3.
2157 # lp11 can send ipv6 traffic as there is no port security
2158 sip=ee800000000000000000000000000000
2160 tip=fe80000000000000ea2aeafffe2800{i}3
2161 test_ipv6 11 f00000000011 f000000000{i}${i}3 $sip $tip {i}3
2165 # ipv6 packet should not be received by lp33 with mac f0000000333
2166 # and ip6.dst as fe80::ea2a:eaff:fe28:0023 as it is
2167 # configured with fe80::ea2a:eaff:fe28:0033
2168 # lp11 can send ipv6 traffic as there is no port security
2170 sip=ee800000000000000000000000000000
2171 tip=fe80000000000000ea2aeafffe280023
2172 test_ipv6 11 f00000000011 f00000000333 $sip $tip
2174 # ipv6 packet should be allowed for lp[123]3 with mac f0000000{i}{i}3
2175 # and ip6.src fe80::ea2a:eaff:fe28:0{i}{i}3 and ip6.src ::.
2176 # and should be dropped for any other ip6.src
2177 # lp21 can receive ipv6 traffic as there is no port security
2179 tip=ee800000000000000000000000000000
2181 sip=fe80000000000000ea2aeafffe2800${i}3
2182 test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 21
2184 # Test ICMPv6 MLD reports (v1 and v2) and NS for DAD
2185 sip=00000000000000000000000000000000
2186 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 83 21
2187 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 8f 21
2188 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff0200000000000000ea2aeafffe2800 87 21
2189 # Traffic to non-multicast traffic should be dropped
2190 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 83
2191 # Traffic of other ICMPv6 types should be dropped
2192 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 80
2195 sip=ae80000000000000ea2aeafffe2800aa
2196 test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip
2199 # configure lsp13 to send and received IPv4 packets with an address range
2200 ovn-nbctl lsp-set-port-security lp13 "f0:00:00:00:00:13 192.168.0.13 20.0.0.4/24 10.0.0.0/24"
2204 sip=`ip_to_hex 10 0 0 13`
2205 tip=`ip_to_hex 192 168 0 22`
2206 # arp packet with inner ip 10.0.0.13 should be allowed for lsp13
2207 test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022
2209 sip=`ip_to_hex 10 0 0 14`
2210 tip=`ip_to_hex 192 168 0 23`
2211 # IPv4 packet from lsp13 with src ip 10.0.0.14 destined to lsp23
2212 # with dst ip 192.168.0.23 should be allowed
2213 test_ip 13 f00000000013 f00000000023 $sip $tip 23
2215 sip=`ip_to_hex 192 168 0 33`
2216 tip=`ip_to_hex 10 0 0 15`
2217 # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2218 # with dst ip 10.0.0.15 should be received by lsp13
2219 test_ip 33 f00000000033 f00000000013 $sip $tip 13
2221 sip=`ip_to_hex 192 168 0 33`
2222 tip=`ip_to_hex 20 0 0 4`
2223 # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2224 # with dst ip 20.0.0.4 should be received by lsp13
2225 test_ip 33 f00000000033 f00000000013 $sip $tip 13
2227 sip=`ip_to_hex 192 168 0 33`
2228 tip=`ip_to_hex 20 0 0 5`
2229 # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2230 # with dst ip 20.0.0.5 should not be received by lsp13
2231 test_ip 33 f00000000033 f00000000013 $sip $tip
2233 sip=`ip_to_hex 192 168 0 33`
2234 tip=`ip_to_hex 20 0 0 255`
2235 # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2236 # with dst ip 20.0.0.255 should be received by lsp13
2237 test_ip 33 f00000000033 f00000000013 $sip $tip 13
2239 sip=`ip_to_hex 192 168 0 33`
2240 tip=`ip_to_hex 192 168 0 255`
2241 # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2242 # with dst ip 192.168.0.255 should not be received by lsp13
2243 test_ip 33 f00000000033 f00000000013 $sip $tip
2245 sip=`ip_to_hex 192 168 0 33`
2246 tip=`ip_to_hex 224 0 0 4`
2247 # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2248 # with dst ip 224.0.0.4 should be received by lsp13
2249 test_ip 33 f00000000033 f00000000013 $sip $tip 13
2251 # Allow some time for packet forwarding.
2253 # XXX This can be improved.
2256 #dump information including flow counters
2258 ovn-sbctl dump-flows -- list multicast_group
2260 echo "------ hv1 dump ------"
2261 as hv1 ovs-vsctl show
2262 as hv1 ovs-ofctl -O OpenFlow13 show br-int
2263 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
2265 echo "------ hv2 dump ------"
2266 as hv2 ovs-vsctl show
2267 as hv2 ovs-ofctl -O OpenFlow13 show br-int
2268 as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
2270 echo "------ hv3 dump ------"
2271 as hv3 ovs-vsctl show
2272 as hv3 ovs-ofctl -O OpenFlow13 show br-int
2273 as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int
2275 # Now check the packets actually received against the ones expected.
2278 file=hv$i/vif$i$j-tx.pcap
2280 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i$j.packets
2281 sort $i$j.expected > expout
2282 AT_CHECK([sort $i$j.packets], [0], [expout])
2287 OVN_CLEANUP([hv1],[hv2],[hv3])
2291 AT_SETUP([ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs])
2292 AT_KEYWORDS([ovnpeer])
2293 AT_SKIP_IF([test $HAVE_PYTHON = no])
2297 # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24
2298 # network. R1 has a switchs ls1 (191.168.1.0/24) connected to it.
2299 # R2 has ls2 (172.16.1.0/24) connected to it.
2304 ovn-nbctl ls-add ls1
2305 ovn-nbctl ls-add ls2
2308 ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 rp-ls1
2310 ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
2311 options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
2314 ovn-nbctl lrp-add R2 ls2 00:00:00:01:02:04 172.16.1.1/24 rp-ls2
2316 ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
2317 options:router-port=ls2 addresses=\"00:00:00:01:02:04\"
2320 ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 R2_R1
2321 ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 R1_R2
2323 ovn-nbctl set Logical_Router R1 default_gw="20.0.0.2"
2324 ovn-nbctl set Logical_Router R2 default_gw="20.0.0.1"
2326 # Create logical port ls1-lp1 in ls1
2327 ovn-nbctl lsp-add ls1 ls1-lp1 \
2328 -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
2330 # Create logical port ls2-lp1 in ls2
2331 ovn-nbctl lsp-add ls2 ls2-lp1 \
2332 -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
2334 # Create two hypervisor and create OVS ports corresponding to logical ports.
2339 ovs-vsctl add-br br-phys
2340 ovn_attach n1 br-phys 192.168.0.1
2341 ovs-vsctl -- add-port br-int hv1-vif1 -- \
2342 set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \
2343 options:tx_pcap=hv1/vif1-tx.pcap \
2344 options:rxq_pcap=hv1/vif1-rx.pcap \
2349 ovs-vsctl add-br br-phys
2350 ovn_attach n1 br-phys 192.168.0.2
2351 ovs-vsctl -- add-port br-int hv2-vif1 -- \
2352 set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \
2353 options:tx_pcap=hv2/vif1-tx.pcap \
2354 options:rxq_pcap=hv2/vif1-rx.pcap \
2358 # Pre-populate the hypervisors' ARP tables so that we don't lose any
2359 # packets for ARP resolution (native tunneling doesn't queue packets
2360 # for ARP resolution).
2363 # Allow some time for ovn-northd and ovn-controller to catch up.
2364 # XXX This should be more systematic.
2367 # Send ip packets between the two ports.
2369 printf "%02x%02x%02x%02x" "$@"
2372 sed 's/\(00\)\{1,\}$//'
2376 src_mac="f00000010203"
2377 dst_mac="000000010203"
2378 src_ip=`ip_to_hex 192 168 1 2`
2379 dst_ip=`ip_to_hex 172 16 1 2`
2380 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2381 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2384 echo "---------NB dump-----"
2386 echo "---------------------"
2387 ovn-nbctl list logical_router
2388 echo "---------------------"
2389 ovn-nbctl list logical_router_port
2390 echo "---------------------"
2392 echo "---------SB dump-----"
2393 ovn-sbctl list datapath_binding
2394 echo "---------------------"
2395 ovn-sbctl list port_binding
2396 echo "---------------------"
2398 echo "------ hv1 dump ----------"
2399 as hv1 ovs-ofctl show br-int
2400 as hv1 ovs-ofctl dump-flows br-int
2401 echo "------ hv2 dump ----------"
2402 as hv2 ovs-ofctl show br-int
2403 as hv2 ovs-ofctl dump-flows br-int
2406 src_mac="000000010204"
2407 dst_mac="f00000010204"
2408 expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
2410 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/vif1-tx.pcap | trim_zeros > received.packets
2411 echo $expected | trim_zeros > expout
2412 AT_CHECK([cat received.packets], [0], [expout])
2414 OVN_CLEANUP([hv1],[hv2])
2419 AT_SETUP([ovn -- 1 HVs, 2 LSs, 1 lport/LS, 1 LR])
2420 AT_KEYWORDS([router-admin-state])
2421 AT_SKIP_IF([test $HAVE_PYTHON = no])
2425 # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
2426 # and has switch ls2 (172.16.1.0/24) connected to it.
2430 ovn-nbctl ls-add ls1
2431 ovn-nbctl ls-add ls2
2434 ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 rp-ls1
2435 ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
2436 options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
2439 ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24 rp-ls2
2440 ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
2441 options:router-port=ls2 addresses=\"00:00:00:01:02:04\"
2443 # Create logical port ls1-lp1 in ls1
2444 ovn-nbctl lsp-add ls1 ls1-lp1 \
2445 -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
2447 # Create logical port ls2-lp1 in ls2
2448 ovn-nbctl lsp-add ls2 ls2-lp1 \
2449 -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
2451 # Create one hypervisor and create OVS ports corresponding to logical ports.
2456 ovs-vsctl add-br br-phys
2457 ovn_attach n1 br-phys 192.168.0.1
2458 ovs-vsctl -- add-port br-int vif1 -- \
2459 set interface vif1 external-ids:iface-id=ls1-lp1 \
2460 options:tx_pcap=hv1/vif1-tx.pcap \
2461 options:rxq_pcap=hv1/vif1-rx.pcap \
2464 ovs-vsctl -- add-port br-int vif2 -- \
2465 set interface vif2 external-ids:iface-id=ls2-lp1 \
2466 options:tx_pcap=hv1/vif2-tx.pcap \
2467 options:rxq_pcap=hv1/vif2-rx.pcap \
2471 # Allow some time for ovn-northd and ovn-controller to catch up.
2472 # XXX This should be more systematic.
2475 # Send ip packets between the two ports.
2477 printf "%02x%02x%02x%02x" "$@"
2480 sed 's/\(00\)\{1,\}$//'
2484 src_mac="f00000010203"
2485 dst_mac="000000010203"
2486 src_ip=`ip_to_hex 192 168 1 2`
2487 dst_ip=`ip_to_hex 172 16 1 2`
2488 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2489 as hv1 ovs-appctl netdev-dummy/receive vif1 $packet
2492 echo "---------NB dump-----"
2494 echo "---------------------"
2495 ovn-nbctl list logical_router
2496 echo "---------------------"
2497 ovn-nbctl list logical_router_port
2498 echo "---------------------"
2500 echo "---------SB dump-----"
2501 ovn-sbctl list datapath_binding
2502 echo "---------------------"
2503 ovn-sbctl list logical_flow
2504 echo "---------------------"
2506 echo "------ hv1 dump ----------"
2507 as hv1 ovs-ofctl dump-flows br-int
2511 ovn-nbctl set Logical_Router R1 enabled=false
2513 echo "---------SB dump-----"
2514 ovn-sbctl list datapath_binding
2515 echo "---------------------"
2516 ovn-sbctl list logical_flow
2517 echo "---------------------"
2519 echo "------ hv1 dump ----------"
2520 as hv1 ovs-ofctl dump-flows br-int
2522 # Allow some time for the disabling of logical router R1 to propagate.
2523 # XXX This should be more systematic.
2526 as hv1 ovs-appctl netdev-dummy/receive vif1 $packet
2529 expect_src_mac="000000010204"
2530 expect_dst_mac="f00000010204"
2531 expected=${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000
2533 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > received.packets
2534 echo $expected | trim_zeros > expout
2535 AT_CHECK([cat received.packets], [0], [expout])
2542 AT_SETUP([ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes])
2543 AT_KEYWORDS([ovnstaticroutespeer])
2544 AT_SKIP_IF([test $HAVE_PYTHON = no])
2548 # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24
2549 # network. R1 has switchess foo (192.168.1.0/24)
2551 # R2 has alice (172.16.1.0/24) and bob (172.16.2.0/24) connected to it.
2556 ovn-nbctl ls-add foo
2557 ovn-nbctl ls-add alice
2558 ovn-nbctl ls-add bob
2561 ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 rp-foo
2562 ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \
2563 options:router-port=foo addresses=\"00:00:00:01:02:03\"
2565 # Connect alice to R2
2566 ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24 rp-alice
2567 ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \
2568 type=router options:router-port=alice addresses=\"00:00:00:01:02:04\"
2571 ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24 rp-bob
2572 ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob type=router \
2573 options:router-port=bob addresses=\"00:00:00:01:02:05\"
2576 ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 R2_R1
2577 ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 R1_R2
2579 #install static routes
2580 ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2
2581 ovn-nbctl lr-route-add R2 172.16.2.0/24 20.0.0.2 R1_R2
2582 ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1
2584 # Create logical port foo1 in foo
2585 ovn-nbctl lsp-add foo foo1 \
2586 -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
2588 # Create logical port alice1 in alice
2589 ovn-nbctl lsp-add alice alice1 \
2590 -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2"
2592 # Create logical port bob1 in bob
2593 ovn-nbctl lsp-add bob bob1 \
2594 -- lsp-set-addresses bob1 "f0:00:00:01:02:05 172.16.2.2"
2596 # Create two hypervisor and create OVS ports corresponding to logical ports.
2601 ovs-vsctl add-br br-phys
2602 ovn_attach n1 br-phys 192.168.0.1
2603 ovs-vsctl -- add-port br-int hv1-vif1 -- \
2604 set interface hv1-vif1 external-ids:iface-id=foo1 \
2605 options:tx_pcap=hv1/vif1-tx.pcap \
2606 options:rxq_pcap=hv1/vif1-rx.pcap \
2609 ovs-vsctl -- add-port br-int hv1-vif2 -- \
2610 set interface hv1-vif2 external-ids:iface-id=alice1 \
2611 options:tx_pcap=hv1/vif2-tx.pcap \
2612 options:rxq_pcap=hv1/vif2-rx.pcap \
2617 ovs-vsctl add-br br-phys
2618 ovn_attach n1 br-phys 192.168.0.2
2619 ovs-vsctl -- add-port br-int hv2-vif1 -- \
2620 set interface hv2-vif1 external-ids:iface-id=bob1 \
2621 options:tx_pcap=hv2/vif1-tx.pcap \
2622 options:rxq_pcap=hv2/vif1-rx.pcap \
2626 # Pre-populate the hypervisors' ARP tables so that we don't lose any
2627 # packets for ARP resolution (native tunneling doesn't queue packets
2628 # for ARP resolution).
2631 # Allow some time for ovn-northd and ovn-controller to catch up.
2632 # XXX This should be more systematic.
2636 printf "%02x%02x%02x%02x" "$@"
2639 sed 's/\(00\)\{1,\}$//'
2642 # Send ip packets between foo1 and alice1
2643 src_mac="f00000010203"
2644 dst_mac="000000010203"
2645 src_ip=`ip_to_hex 192 168 1 2`
2646 dst_ip=`ip_to_hex 172 16 1 2`
2647 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2648 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2650 # Send ip packets between foo1 and bob1
2651 src_mac="f00000010203"
2652 dst_mac="000000010203"
2653 src_ip=`ip_to_hex 192 168 1 2`
2654 dst_ip=`ip_to_hex 172 16 2 2`
2655 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2656 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2658 echo "---------NB dump-----"
2660 echo "---------------------"
2661 ovn-nbctl list logical_router
2662 echo "---------------------"
2663 ovn-nbctl list logical_router_port
2664 echo "---------------------"
2666 echo "---------SB dump-----"
2667 ovn-sbctl list datapath_binding
2668 echo "---------------------"
2669 ovn-sbctl list port_binding
2670 echo "---------------------"
2672 echo "------ hv1 dump ----------"
2673 as hv1 ovs-ofctl dump-flows br-int
2674 echo "------ hv2 dump ----------"
2675 as hv2 ovs-ofctl dump-flows br-int
2677 # Packet to Expect at bob1
2678 src_mac="000000010205"
2679 dst_mac="f00000010205"
2680 src_ip=`ip_to_hex 192 168 1 2`
2681 dst_ip=`ip_to_hex 172 16 2 2`
2682 expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
2684 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/vif1-tx.pcap | trim_zeros > received.packets
2685 echo $expected | trim_zeros > expout
2686 AT_CHECK([cat received.packets], [0], [expout])
2688 # Packet to Expect at alice1
2689 src_mac="000000010204"
2690 dst_mac="f00000010204"
2691 src_ip=`ip_to_hex 192 168 1 2`
2692 dst_ip=`ip_to_hex 172 16 1 2`
2693 expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
2695 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > received1.packets
2696 echo $expected | trim_zeros > expout
2697 AT_CHECK([cat received1.packets], [0], [expout])
2699 OVN_CLEANUP([hv1],[hv2])
2703 AT_SETUP([ovn -- send gratuitous arp on localnet])
2705 AT_SKIP_IF([test $HAVE_PYTHON = no])
2707 ovn-nbctl ls-add lsw0
2715 ovn_attach n1 br-phys 192.168.0.1
2717 AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0])
2718 AT_CHECK([ovs-vsctl add-port br-eth0 snoopvif -- set Interface snoopvif options:tx_pcap=hv/snoopvif-tx.pcap options:rxq_pcap=hv/snoopvif-rx.pcap])
2721 AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1])
2722 AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.2"])
2723 AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"])
2725 # Create a localnet port.
2726 AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port])
2727 AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown])
2728 AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet])
2729 AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1])
2731 AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1])
2733 # Wait for packet to be received.
2734 OVS_WAIT_UNTIL([test `wc -c < "hv/snoopvif-tx.pcap"` -ge 50])
2736 sed 's/\(00\)\{1,\}$//'
2738 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv/snoopvif-tx.pcap | trim_zeros > packets
2739 expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102"
2740 echo $expected > expout
2741 AT_CHECK([sort packets], [0], [expout])
2744 # Delete the localnet ports.
2745 AT_CHECK([ovs-vsctl del-port localvif1])
2746 AT_CHECK([ovn-nbctl lsp-del ln_port])
2752 AT_SETUP([ovn -- 2 HVs, 3 LRs connected via LS, static routes])
2753 AT_KEYWORDS([ovnstaticroutes])
2754 AT_SKIP_IF([test $HAVE_PYTHON = no])
2758 # Three LRs - R1, R2 and R3 that are connected to each other via LS "join"
2759 # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24)
2760 # connected to it. R2 has alice (172.16.1.0/24) and R3 has bob (10.32.1.0/24)
2767 ovn-nbctl ls-add foo
2768 ovn-nbctl ls-add alice
2769 ovn-nbctl ls-add bob
2770 ovn-nbctl ls-add join
2773 ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
2774 ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \
2775 options:router-port=foo addresses=\"00:00:01:01:02:03\"
2777 # Connect alice to R2
2778 ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
2779 ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \
2780 type=router options:router-port=alice addresses=\"00:00:02:01:02:03\"
2783 ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24
2784 ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \
2785 type=router options:router-port=bob addresses=\"00:00:03:01:02:03\"
2787 # Connect R1 to join
2788 ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24
2789 ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \
2790 type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"'
2792 # Connect R2 to join
2793 ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
2794 ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \
2795 type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"'
2797 # Connect R3 to join
2798 ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24
2799 ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \
2800 type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"'
2802 #install static routes
2803 ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2
2804 ovn-nbctl lr-route-add R1 10.32.1.0/24 20.0.0.3
2806 ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1
2807 ovn-nbctl lr-route-add R2 10.32.1.0/24 20.0.0.3
2809 ovn-nbctl lr-route-add R3 192.168.1.0/24 20.0.0.1
2810 ovn-nbctl lr-route-add R3 172.16.1.0/24 20.0.0.2
2812 # Create logical port foo1 in foo
2813 ovn-nbctl lsp-add foo foo1 \
2814 -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
2816 # Create logical port alice1 in alice
2817 ovn-nbctl lsp-add alice alice1 \
2818 -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2"
2820 # Create logical port bob1 in bob
2821 ovn-nbctl lsp-add bob bob1 \
2822 -- lsp-set-addresses bob1 "f0:00:00:01:02:05 10.32.1.2"
2824 # Create two hypervisor and create OVS ports corresponding to logical ports.
2829 ovs-vsctl add-br br-phys
2830 ovn_attach n1 br-phys 192.168.0.1
2831 ovs-vsctl -- add-port br-int hv1-vif1 -- \
2832 set interface hv1-vif1 external-ids:iface-id=foo1 \
2833 options:tx_pcap=hv1/vif1-tx.pcap \
2834 options:rxq_pcap=hv1/vif1-rx.pcap \
2837 ovs-vsctl -- add-port br-int hv1-vif2 -- \
2838 set interface hv1-vif2 external-ids:iface-id=alice1 \
2839 options:tx_pcap=hv1/vif2-tx.pcap \
2840 options:rxq_pcap=hv1/vif2-rx.pcap \
2845 ovs-vsctl add-br br-phys
2846 ovn_attach n1 br-phys 192.168.0.2
2847 ovs-vsctl -- add-port br-int hv2-vif1 -- \
2848 set interface hv2-vif1 external-ids:iface-id=bob1 \
2849 options:tx_pcap=hv2/vif1-tx.pcap \
2850 options:rxq_pcap=hv2/vif1-rx.pcap \
2854 # Pre-populate the hypervisors' ARP tables so that we don't lose any
2855 # packets for ARP resolution (native tunneling doesn't queue packets
2856 # for ARP resolution).
2859 # Allow some time for ovn-northd and ovn-controller to catch up.
2860 # XXX This should be more systematic.
2864 printf "%02x%02x%02x%02x" "$@"
2867 sed 's/\(00\)\{1,\}$//'
2870 # Send ip packets between foo1 and alice1
2871 src_mac="f00000010203"
2872 dst_mac="000001010203"
2873 src_ip=`ip_to_hex 192 168 1 2`
2874 dst_ip=`ip_to_hex 172 16 1 2`
2875 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2876 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2877 as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet
2879 # Send ip packets between foo1 and bob1
2880 src_mac="f00000010203"
2881 dst_mac="000001010203"
2882 src_ip=`ip_to_hex 192 168 1 2`
2883 dst_ip=`ip_to_hex 10 32 1 2`
2884 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2885 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2887 echo "---------NB dump-----"
2889 echo "---------------------"
2890 ovn-nbctl list logical_router
2891 echo "---------------------"
2892 ovn-nbctl list logical_router_port
2893 echo "---------------------"
2895 echo "---------SB dump-----"
2896 ovn-sbctl list datapath_binding
2897 echo "---------------------"
2898 ovn-sbctl list port_binding
2899 echo "---------------------"
2900 ovn-sbctl dump-flows
2901 echo "---------------------"
2903 echo "------ hv1 dump ----------"
2904 as hv1 ovs-ofctl show br-int
2905 as hv1 ovs-ofctl dump-flows br-int
2906 echo "------ hv2 dump ----------"
2907 as hv2 ovs-ofctl show br-int
2908 as hv2 ovs-ofctl dump-flows br-int
2909 echo "----------------------------"
2911 # Packet to Expect at bob1
2912 src_mac="000003010203"
2913 dst_mac="f00000010205"
2914 src_ip=`ip_to_hex 192 168 1 2`
2915 dst_ip=`ip_to_hex 10 32 1 2`
2916 expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
2918 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/vif1-tx.pcap | trim_zeros > received.packets
2919 echo $expected | trim_zeros > expout
2920 AT_CHECK([cat received.packets], [0], [expout])
2922 # Packet to Expect at alice1
2923 src_mac="000002010203"
2924 dst_mac="f00000010204"
2925 src_ip=`ip_to_hex 192 168 1 2`
2926 dst_ip=`ip_to_hex 172 16 1 2`
2927 expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
2929 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > received1.packets
2930 echo $expected | trim_zeros > expout
2931 AT_CHECK([cat received1.packets], [0], [expout])
2933 OVN_CLEANUP([hv1],[hv2])
2937 AT_SETUP([ovn -- 2 HVs, 2 LRs connected via LS, gateway router])
2938 AT_KEYWORDS([ovngatewayrouter])
2939 AT_SKIP_IF([test $HAVE_PYTHON = no])
2943 # Two LRs - R1 and R2 that are connected to each other via LS "join"
2944 # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24)
2945 # connected to it. R2 has alice (172.16.1.0/24) connected to it.
2946 # R2 is a gateway router.
2950 # Create two hypervisor and create OVS ports corresponding to logical ports.
2955 ovs-vsctl add-br br-phys
2956 ovn_attach n1 br-phys 192.168.0.1
2957 ovs-vsctl -- add-port br-int hv1-vif1 -- \
2958 set interface hv1-vif1 external-ids:iface-id=foo1 \
2959 options:tx_pcap=hv1/vif1-tx.pcap \
2960 options:rxq_pcap=hv1/vif1-rx.pcap \
2966 ovs-vsctl add-br br-phys
2967 ovn_attach n1 br-phys 192.168.0.2
2968 ovs-vsctl -- add-port br-int hv2-vif1 -- \
2969 set interface hv2-vif1 external-ids:iface-id=alice1 \
2970 options:tx_pcap=hv2/vif1-tx.pcap \
2971 options:rxq_pcap=hv2/vif1-rx.pcap \
2974 # Pre-populate the hypervisors' ARP tables so that we don't lose any
2975 # packets for ARP resolution (native tunneling doesn't queue packets
2976 # for ARP resolution).
2979 ovn-nbctl create Logical_Router name=R1
2980 ovn-nbctl create Logical_Router name=R2 options:chassis="hv2"
2982 ovn-nbctl ls-add foo
2983 ovn-nbctl ls-add alice
2984 ovn-nbctl ls-add join
2987 ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
2988 ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \
2989 type=router options:router-port=foo addresses=\"00:00:01:01:02:03\"
2991 # Connect alice to R2
2992 ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
2993 ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \
2994 type=router options:router-port=alice addresses=\"00:00:02:01:02:03\"
2996 # Connect R1 to join
2997 ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24
2998 ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \
2999 type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"'
3001 # Connect R2 to join
3002 ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
3003 ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \
3004 type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"'
3007 #install static routes
3008 ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
3009 ip_prefix=172.16.1.0/24 nexthop=20.0.0.2 -- add Logical_Router \
3010 R1 static_routes @lrt
3012 ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
3013 ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \
3014 R2 static_routes @lrt
3016 # Create logical port foo1 in foo
3017 ovn-nbctl lsp-add foo foo1 \
3018 -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
3020 # Create logical port alice1 in alice
3021 ovn-nbctl lsp-add alice alice1 \
3022 -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2"
3025 # Allow some time for ovn-northd and ovn-controller to catch up.
3026 # XXX This should be more systematic.
3030 printf "%02x%02x%02x%02x" "$@"
3033 sed 's/\(00\)\{1,\}$//'
3036 # Send ip packets between foo1 and alice1
3037 src_mac="f00000010203"
3038 dst_mac="000001010203"
3039 src_ip=`ip_to_hex 192 168 1 2`
3040 dst_ip=`ip_to_hex 172 16 1 2`
3041 packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
3043 echo "---------NB dump-----"
3045 echo "---------------------"
3046 ovn-nbctl list logical_router
3047 echo "---------------------"
3048 ovn-nbctl list logical_router_port
3049 echo "---------------------"
3051 echo "---------SB dump-----"
3052 ovn-sbctl list datapath_binding
3053 echo "---------------------"
3054 ovn-sbctl list port_binding
3055 echo "---------------------"
3056 ovn-sbctl dump-flows
3057 echo "---------------------"
3058 ovn-sbctl list chassis
3059 ovn-sbctl list encap
3060 echo "---------------------"
3062 echo "------ hv1 dump ----------"
3063 as hv1 ovs-ofctl show br-int
3064 as hv1 ovs-ofctl dump-flows br-int
3065 echo "------ hv2 dump ----------"
3066 as hv2 ovs-ofctl show br-int
3067 as hv2 ovs-ofctl dump-flows br-int
3068 echo "----------------------------"
3070 # Packet to Expect at alice1
3071 src_mac="000002010203"
3072 dst_mac="f00000010204"
3073 src_ip=`ip_to_hex 192 168 1 2`
3074 dst_ip=`ip_to_hex 172 16 1 2`
3075 expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
3078 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
3079 as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet
3081 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/vif1-tx.pcap | trim_zeros > received1.packets
3082 echo $expected | trim_zeros > expout
3083 AT_CHECK([cat received1.packets], [0], [expout])
3085 # Delete the router and re-create it. Things should work as before.
3087 ovn-nbctl create Logical_Router name=R2 options:chassis="hv2"
3088 # Connect alice to R2
3089 ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
3090 # Connect R2 to join
3091 ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
3093 ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
3094 ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \
3095 R2 static_routes @lrt
3097 # Wait for ovn-controller to catch up.
3100 # Send the packet again.
3101 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
3102 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/vif1-tx.pcap | trim_zeros > received1.packets
3103 echo $expected | trim_zeros >> expout
3104 AT_CHECK([cat received1.packets], [0], [expout])
3106 OVN_CLEANUP([hv1],[hv2])
3110 AT_SETUP([ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR])
3111 AT_KEYWORDS([router-icmp-reply])
3112 AT_SKIP_IF([test $HAVE_PYTHON = no])
3116 # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
3117 # and has switch ls2 (172.16.1.0/24) connected to it.
3121 ovn-nbctl ls-add ls1
3122 ovn-nbctl ls-add ls2
3125 ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24
3126 ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \
3127 type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\"
3130 ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24
3131 ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \
3132 type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\"
3134 # Create logical port ls1-lp1 in ls1
3135 ovn-nbctl lsp-add ls1 ls1-lp1 \
3136 -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2"
3138 # Create logical port ls2-lp1 in ls2
3139 ovn-nbctl lsp-add ls2 ls2-lp1 \
3140 -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2"
3142 # Create one hypervisor and create OVS ports corresponding to logical ports.
3147 ovs-vsctl add-br br-phys
3148 ovn_attach n1 br-phys 192.168.0.1
3149 ovs-vsctl -- add-port br-int vif1 -- \
3150 set interface vif1 external-ids:iface-id=ls1-lp1 \
3151 options:tx_pcap=hv1/vif1-tx.pcap \
3152 options:rxq_pcap=hv1/vif1-rx.pcap \
3155 ovs-vsctl -- add-port br-int vif2 -- \
3156 set interface vif2 external-ids:iface-id=ls2-lp1 \
3157 options:tx_pcap=hv1/vif2-tx.pcap \
3158 options:rxq_pcap=hv1/vif2-rx.pcap \
3162 # Allow some time for ovn-northd and ovn-controller to catch up.
3163 # XXX This should be more systematic.
3168 printf "%02x%02x%02x%02x" "$@"
3171 sed 's/\(00\)\{1,\}$//'
3176 # test_ipv4_icmp_request INPORT ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM ICMP_CHKSUM [EXP_IP_CHKSUM EXP_ICMP_CHKSUM]
3178 # Causes a packet to be received on INPORT. The packet is an ICMPv4
3179 # request with ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHSUM and
3180 # ICMP_CHKSUM as specified. If EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are
3181 # provided, then it should be the ip and icmp checksums of the packet
3182 # responded; otherwise, no reply is expected.
3183 # In the absence of an ip checksum calculation helpers, this relies
3184 # on the caller to provide the checksums for the ip and icmp headers.
3185 # XXX This should be more systematic.
3187 # INPORT is an lport number, e.g. 11 for vif11.
3188 # ETH_SRC and ETH_DST are each 12 hex digits.
3189 # IPV4_SRC and IPV4_DST are each 8 hex digits.
3190 # IP_CHSUM and ICMP_CHKSUM are each 4 hex digits.
3191 # EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits.
3192 test_ipv4_icmp_request() {
3193 local inport=$1 eth_src=$2 eth_dst=$3 ipv4_src=$4 ipv4_dst=$5 ip_chksum=$6 icmp_chksum=$7
3194 local exp_ip_chksum=$8 exp_icmp_chksum=$9
3195 shift; shift; shift; shift; shift; shift; shift
3198 # Use ttl to exercise section 4.2.2.9 of RFC1812
3202 local icmp_data=$(seq 1 56 | xargs printf "%02x")
3203 local icmp_type_code_request=0800
3204 local icmp_payload=${icmp_type_code_request}${icmp_chksum}${icmp_id}${icmp_seq}${icmp_data}
3205 local packet=${eth_dst}${eth_src}08004500005400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${icmp_payload}
3207 as hv1 ovs-appctl netdev-dummy/receive vif$inport $packet
3208 if test X$exp_icmp_chksum != X; then
3209 # Expect to receive the reply, if any. In same port where packet was sent.
3210 # Note: src and dst fields are expected to be reversed.
3211 local icmp_type_code_response=0000
3212 local reply_icmp_ttl=fe
3213 local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_id}${icmp_seq}${icmp_data}
3214 local reply=${eth_src}${eth_dst}08004500005400004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload}
3215 echo $reply >> vif$inport.expected
3219 # Send ping packet to router's ip addresses, from each of the 2 logical ports.
3220 rtr_l1_ip=$(ip_to_hex 192 168 1 1)
3221 rtr_l2_ip=$(ip_to_hex 172 16 1 1)
3222 l1_ip=$(ip_to_hex 192 168 1 2)
3223 l2_ip=$(ip_to_hex 172 16 1 2)
3225 # Ping router ip address that is on same subnet as the logical port
3226 test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l1_ip 0000 8510 02ff 8d10
3227 test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l2_ip 0000 8510 02ff 8d10
3229 # Ping router ip address that is on the other side of the logical ports
3230 test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l2_ip 0000 8510 02ff 8d10
3231 test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l1_ip 0000 8510 02ff 8d10
3233 echo "---------NB dump-----"
3235 echo "---------------------"
3236 ovn-nbctl list logical_router
3237 echo "---------------------"
3238 ovn-nbctl list logical_router_port
3239 echo "---------------------"
3241 echo "---------SB dump-----"
3242 ovn-sbctl list datapath_binding
3243 echo "---------------------"
3244 ovn-sbctl list logical_flow
3245 echo "---------------------"
3247 echo "------ hv1 dump ----------"
3248 as hv1 ovs-ofctl dump-flows br-int
3250 # Now check the packets actually received against the ones expected.
3251 for inport in 1 2; do
3252 file=hv1/vif${inport}-tx.pcap
3254 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > received.packets
3255 cat vif$inport.expected | trim_zeros > expout
3256 AT_CHECK([cat received.packets], [0], [expout])
3263 # 1 hypervisor, 1 port
3264 # make sure that the port state is properly set to up and back down
3265 # when created and deleted.
3266 AT_SETUP([ovn -- port state up and down])
3270 ovn-nbctl ls-add ls1
3271 ovn-nbctl lsp-add ls1 lp1
3272 ovn-nbctl lsp-set-addresses lp1 unknown
3276 as hv1 ovs-vsctl add-br br-phys
3277 as hv1 ovn_attach n1 br-phys 192.168.0.1
3279 as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1
3280 OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup])
3282 as hv1 ovs-vsctl del-port br-int vif1
3283 OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown])
3289 AT_SETUP([ovn -- nd ])
3290 AT_KEYWORDS([ovn-nd])
3291 AT_SKIP_IF([test $HAVE_PYTHON = no])
3294 #TODO: since patch port for IPv6 logical router port is not ready not,
3295 # so we are not going to test vifs on different lswitches cases. Try
3296 # to update for that once relevant stuff implemented.
3298 # In this test cases we create 1 lswitch, it has 2 VIF ports attached
3299 # with. NS packet we test, from one VIF for another VIF, will be replied
3300 # by local ovn-controller, but not by target VIF.
3302 # Create hypervisors and logical switch lsw0.
3303 ovn-nbctl ls-add lsw0
3307 ovs-vsctl add-br br-phys
3308 ovn_attach n1 br-phys 192.168.0.2
3310 # Add vif1 to hv1 and lsw0, turn on l2 port security on vif1.
3311 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=hv1/vif1-tx.pcap options:rxq_pcap=hv1/vif1-rx.pcap ofport-request=1
3312 ovn-nbctl lsp-add lsw0 lp1
3313 ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598"
3314 ovn-nbctl lsp-set-port-security lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598"
3316 # Add vif2 to hv1 and lsw0, turn on l2 port security on vif2.
3317 ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=hv1/vif2-tx.pcap options:rxq_pcap=hv1/vif2-rx.pcap ofport-request=2
3318 ovn-nbctl lsp-add lsw0 lp2
3319 ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae"
3320 ovn-nbctl lsp-set-port-security lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae"
3322 # Add ACL rule for ICMPv6 on lsw0
3323 ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related
3324 ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related
3325 ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related
3327 # Allow some time for ovn-northd and ovn-controller to catch up.
3328 # XXX This should be more systematic.
3331 # Given the name of a logical port, prints the name of the hypervisor
3332 # on which it is located.
3337 sed 's/\(00\)\{1,\}$//'
3343 # Complete Neighbor Solicitation packet and Neighbor Advertisement packet
3344 # vif1 -> NS -> vif2. vif1 <- NA <- ovn-controller.
3345 # vif2 will not receive NS packet, since ovn-controller will reply for it.
3346 ns_packet=3333ffa1f9aefa163e94059886dd6000000000203afffd81ce49a9480000f8163efffe940598fd81ce49a9480000f8163efffea1f9ae8700e01160000000fd81ce49a9480000f8163efffea1f9ae0101fa163e940598
3347 na_packet=fa163e940598fa163ea1f9ae86dd6000000000203afffd81ce49a9480000f8163efffea1f9aefd81ce49a9480000f8163efffe9405988800e9ed60000000fd81ce49a9480000f8163efffea1f9ae0201fa163ea1f9ae
3349 as hv1 ovs-appctl netdev-dummy/receive vif1 $ns_packet
3350 echo $na_packet | trim_zeros >> 1.expected
3354 echo "------ hv1 dump ------"
3355 as hv1 ovs-vsctl show
3356 as hv1 ovs-ofctl -O OpenFlow13 show br-int
3357 as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
3360 file=hv1/vif$i-tx.pcap
3362 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $file | trim_zeros > $i.packets
3363 cat $i.expected > expout
3364 AT_CHECK([cat $i.packets], [0], [expout])
3371 AT_SETUP([ovn -- address sets modification/removal smoke test])
3372 AT_KEYWORDS([ovn-addr])
3379 ovs-vsctl add-br br-phys
3380 ovn_attach n1 br-phys 192.168.0.1
3382 row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"`
3383 ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\"
3384 ovn-nbctl destroy Address_Set $row
3388 # A bug previously existed in the address set support code
3389 # that caused ovn-controller to crash after an address set
3390 # was updated and then removed. This test case ensures
3391 # that ovn-controller is at least still running after
3392 # creating, updating, and deleting an address set.
3393 AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore])