]> git.proxmox.com Git - ovs.git/blame - tests/ovn.at
INSTALL.DPDK-ADVANCED: Fix number and indentation in jumbo frames
[ovs.git] / tests / ovn.at
CommitLineData
49d7c759
BP
1# OVN_CHECK_PACKETS([PCAP], [EXPECTED])
2#
3# This compares packets read from PCAP, in pcap format, to those read
4# from EXPECTED, which is a text file containing packets as hex
5# strings, one per line. If PCAP contains fewer packets than
6# EXPECTED, it waits up to 10 seconds for more packets to appear.
7#
8# The implementation is an m4 macro that is mostly implemented in
9# terms of a shell function. This reduces the size of the generated
10# testsuite file since the shell function is only emitted once even
11# when this macro is invoked many times.
12m4_divert_text([PREPARE_TESTS],
13 [ovn_check_packets__ () {
14 echo
15 echo "checking packets in $1 against $2:"
16 rcv_pcap=$1
17 rcv_text=`echo "$rcv_pcap.packets" | sed 's/\.pcap//'`
18 exp_text=$2
19 exp_n=`wc -l < "$exp_text"`
20 ovs_wait_cond () {
e4543cfe 21 $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text
49d7c759
BP
22 rcv_n=`wc -l < "$rcv_text"`
23 test $rcv_n -ge $exp_n
24 }
25 ovs_wait || echo "expected $exp_n packets, only received $rcv_n"
26
e4543cfe 27 sort $exp_text > expout
49d7c759
BP
28 }
29])
30m4_define([OVN_CHECK_PACKETS],
31 [ovn_check_packets__ "$1" "$2"
32 AT_CHECK([sort $rcv_text], [0], [expout])])
33
f295c17b 34AT_BANNER([OVN components])
10b1662b
BP
35
36AT_SETUP([ovn -- lexer])
37dnl For lines without =>, input and expected output are identical.
38dnl For lines with =>, input precedes => and expected output follows =>.
39AT_DATA([test-cases.txt], [dnl
40foo bar baz quuxquuxquux _abcd_ a.b.c.d a123_.456
41"abc\u0020def" => "abc def"
42" => error("Input ends inside quoted string.")dnl "
43
2c5cbb15
RB
44$foo $bar $baz $quuxquuxquux $_abcd_ $a.b.c.d $a123_.456
45$1 => error("`$' must be followed by a valid identifier.") 1
46
10b1662b
BP
47a/*b*/c => a c
48a//b c => a
49a/**/b => a b
50a/*/b => a error("`/*' without matching `*/'.")
51a/*/**/b => a b
52a/b => a error("`/' is only valid as part of `//' or `/*'.") b
53
540 1 12345 18446744073709551615
5518446744073709551616 => error("Decimal constants must be less than 2**64.")
569999999999999999999999 => error("Decimal constants must be less than 2**64.")
5701 => error("Decimal constants must not have leading zeros.")
58
590/0
600/1
611/0 => error("Value contains unmasked 1-bits.")
621/1
63128/384
641/3
651/ => error("Integer constant expected.")
66
671/0x123 => error("Value and mask have incompatible formats.")
68
690x1234
700x01234 => 0x1234
710x0 => 0
720x000 => 0
730xfedcba9876543210
740XFEDCBA9876543210 => 0xfedcba9876543210
750xfedcba9876543210fedcba9876543210
10b1662b
BP
760x0000fedcba9876543210fedcba9876543210 => 0xfedcba9876543210fedcba9876543210
770x => error("Hex digits expected following 0x.")
780X => error("Hex digits expected following 0X.")
790x0/0x0 => 0/0
800x0/0x1 => 0/0x1
810x1/0x0 => error("Value contains unmasked 1-bits.")
820xffff/0x1ffff
830x. => error("Invalid syntax in hexadecimal constant.")
84
85192.168.128.1 1.2.3.4 255.255.255.255 0.0.0.0
86256.1.2.3 => error("Invalid numeric constant.")
87192.168.0.0/16
88192.168.0.0/255.255.0.0 => 192.168.0.0/16
89192.168.0.0/255.255.255.0 => 192.168.0.0/24
90192.168.0.0/255.255.0.255
91192.168.0.0/255.0.0.0 => error("Value contains unmasked 1-bits.")
92192.168.0.0/32
93192.168.0.0/255.255.255.255 => 192.168.0.0/32
52c0fc39 941.2.3.4:5 => 1.2.3.4 : 5
10b1662b
BP
95
96::
97::1
98ff00::1234 => ff00::1234
992001:db8:85a3::8a2e:370:7334
1002001:db8:85a3:0:0:8a2e:370:7334 => 2001:db8:85a3::8a2e:370:7334
1012001:0db8:85a3:0000:0000:8a2e:0370:7334 => 2001:db8:85a3::8a2e:370:7334
102::ffff:192.0.2.128
103::ffff:c000:0280 => ::ffff:192.0.2.128
104::1/::1
105::1/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff => ::1/128
106::1/128
107ff00::/8
108ff00::/ff00:: => ff00::/8
109
11001:23:45:67:ab:cd
11101:23:45:67:AB:CD => 01:23:45:67:ab:cd
112fe:dc:ba:98:76:54
113FE:DC:ba:98:76:54 => fe:dc:ba:98:76:54
11401:00:00:00:00:00/01:00:00:00:00:00
115ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff
116fe:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff
117ff:ff:ff:ff:ff:ff/fe:ff:ff:ff:ff:ff => error("Value contains unmasked 1-bits.")
118fe:x => error("Invalid numeric constant.")
11900:01:02:03:04:x => error("Invalid numeric constant.")
120
a20c96c6 121# Test that operators are tokenized as expected, even without white space.
52c0fc39 122(){}[[]]==!=<<=>>=!&&||..,;=<->--: => ( ) { } [[ ]] == != < <= > >= ! && || .. , ; = <-> -- :
10b1662b
BP
123& => error("`&' is only valid as part of `&&'.")
124| => error("`|' is only valid as part of `||'.")
56091efe 125- => error("`-' is only valid as part of `--'.")
10b1662b
BP
126
127^ => error("Invalid character `^' in input.")
128])
129AT_CAPTURE_FILE([input.txt])
130sed 's/ =>.*//' test-cases.txt > input.txt
131sed 's/.* => //' test-cases.txt > expout
132AT_CHECK([ovstest test-ovn lex < input.txt], [0], [expout])
133AT_CLEANUP
e0840f11 134
7700eea0
BP
135dnl The OVN expression parser needs to know what fields overlap with one
136dnl another. This test therefore verifies that all the smaller registers
137dnl are defined as terms of subfields of the larger ones.
138dnl
139dnl When we add or remove registers this test needs to be updated, of course.
140AT_SETUP([ovn -- registers])
141AT_CHECK([ovstest test-ovn dump-symtab | grep reg | sort], [0],
142[[reg0 = xxreg0[96..127]
143reg1 = xxreg0[64..95]
144reg2 = xxreg0[32..63]
145reg3 = xxreg0[0..31]
146reg4 = xxreg1[96..127]
147reg5 = xxreg1[64..95]
148reg6 = xxreg1[32..63]
149reg7 = xxreg1[0..31]
150reg8 = xreg4[32..63]
151reg9 = xreg4[0..31]
152xreg0 = xxreg0[64..127]
153xreg1 = xxreg0[0..63]
154xreg2 = xxreg1[64..127]
155xreg3 = xxreg1[0..63]
156xreg4 = OXM_OF_PKT_REG4
157xxreg0 = NXM_NX_XXREG0
158xxreg1 = NXM_NX_XXREG1
159]])
160AT_CLEANUP
161
2277b860
BP
162dnl Check that the OVN conntrack field definitions are correct.
163AT_SETUP([ovn -- conntrack fields])
164AT_CHECK([ovstest test-ovn dump-symtab | grep ^ct | sort], [0],
165[[ct.est = ct_state[1]
166ct.inv = ct_state[4]
167ct.new = ct_state[0]
168ct.rel = ct_state[2]
169ct.rpl = ct_state[3]
170ct.trk = ct_state[5]
171ct_label = NXM_NX_CT_LABEL
172ct_mark = NXM_NX_CT_MARK
173ct_state = NXM_NX_CT_STATE
174]])
175AT_CLEANUP
176
e0840f11
BP
177AT_SETUP([ovn -- expression parser])
178dnl For lines without =>, input and expected output are identical.
179dnl For lines with =>, input precedes => and expected output follows =>.
180AT_DATA([test-cases.txt], [[
181eth.type == 0x800
182eth.type==0x800 => eth.type == 0x800
183eth.type[0..15] == 0x800 => eth.type == 0x800
184
185vlan.present
186vlan.present == 1 => vlan.present
187!(vlan.present == 0) => vlan.present
188!(vlan.present != 1) => vlan.present
189!vlan.present
190vlan.present == 0 => !vlan.present
191vlan.present != 1 => !vlan.present
192!(vlan.present == 1) => !vlan.present
193!(vlan.present != 0) => !vlan.present
194
195eth.dst[0]
196eth.dst[0] == 1 => eth.dst[0]
197eth.dst[0] != 0 => eth.dst[0]
198!(eth.dst[0] == 0) => eth.dst[0]
199!(eth.dst[0] != 1) => eth.dst[0]
200
201!eth.dst[0]
202eth.dst[0] == 0 => !eth.dst[0]
203eth.dst[0] != 1 => !eth.dst[0]
204!(eth.dst[0] == 1) => !eth.dst[0]
205!(eth.dst[0] != 0) => !eth.dst[0]
206
207vlan.tci[12..15] == 0x3
208vlan.tci == 0x3000/0xf000 => vlan.tci[12..15] == 0x3
209vlan.tci[12..15] != 0x3
210vlan.tci != 0x3000/0xf000 => vlan.tci[12..15] != 0x3
211
212!vlan.pcp => vlan.pcp == 0
213!(vlan.pcp) => vlan.pcp == 0
214vlan.pcp == 0x4
215vlan.pcp != 0x4
216vlan.pcp > 0x4
217vlan.pcp >= 0x4
218vlan.pcp < 0x4
219vlan.pcp <= 0x4
220!(vlan.pcp != 0x4) => vlan.pcp == 0x4
221!(vlan.pcp == 0x4) => vlan.pcp != 0x4
222!(vlan.pcp <= 0x4) => vlan.pcp > 0x4
223!(vlan.pcp < 0x4) => vlan.pcp >= 0x4
224!(vlan.pcp >= 0x4) => vlan.pcp < 0x4
225!(vlan.pcp > 0x4) => vlan.pcp <= 0x4
2260x4 == vlan.pcp => vlan.pcp == 0x4
2270x4 != vlan.pcp => vlan.pcp != 0x4
2280x4 < vlan.pcp => vlan.pcp > 0x4
2290x4 <= vlan.pcp => vlan.pcp >= 0x4
2300x4 > vlan.pcp => vlan.pcp < 0x4
2310x4 >= vlan.pcp => vlan.pcp <= 0x4
232!(0x4 != vlan.pcp) => vlan.pcp == 0x4
233!(0x4 == vlan.pcp) => vlan.pcp != 0x4
234!(0x4 >= vlan.pcp) => vlan.pcp > 0x4
235!(0x4 > vlan.pcp) => vlan.pcp >= 0x4
236!(0x4 <= vlan.pcp) => vlan.pcp < 0x4
237!(0x4 < vlan.pcp) => vlan.pcp <= 0x4
238
2391 < vlan.pcp < 4 => vlan.pcp > 0x1 && vlan.pcp < 0x4
2401 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4
2411 < vlan.pcp <= 4 => vlan.pcp > 0x1 && vlan.pcp <= 0x4
2421 <= vlan.pcp < 4 => vlan.pcp >= 0x1 && vlan.pcp < 0x4
2431 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4
2444 > vlan.pcp > 1 => vlan.pcp < 0x4 && vlan.pcp > 0x1
2454 >= vlan.pcp > 1 => vlan.pcp <= 0x4 && vlan.pcp > 0x1
2464 > vlan.pcp >= 1 => vlan.pcp < 0x4 && vlan.pcp >= 0x1
2474 >= vlan.pcp >= 1 => vlan.pcp <= 0x4 && vlan.pcp >= 0x1
248!(1 < vlan.pcp < 4) => vlan.pcp <= 0x1 || vlan.pcp >= 0x4
249!(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4
250!(1 < vlan.pcp <= 4) => vlan.pcp <= 0x1 || vlan.pcp > 0x4
251!(1 <= vlan.pcp < 4) => vlan.pcp < 0x1 || vlan.pcp >= 0x4
252!(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4
253!(4 > vlan.pcp > 1) => vlan.pcp >= 0x4 || vlan.pcp <= 0x1
254!(4 >= vlan.pcp > 1) => vlan.pcp > 0x4 || vlan.pcp <= 0x1
255!(4 > vlan.pcp >= 1) => vlan.pcp >= 0x4 || vlan.pcp < 0x1
256!(4 >= vlan.pcp >= 1) => vlan.pcp > 0x4 || vlan.pcp < 0x1
257
258vlan.pcp == {1, 2, 3, 4} => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4
259vlan.pcp == 1 || ((vlan.pcp == 2 || vlan.pcp == 3) || vlan.pcp == 4) => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4
260
261vlan.pcp != {1, 2, 3, 4} => vlan.pcp != 0x1 && vlan.pcp != 0x2 && vlan.pcp != 0x3 && vlan.pcp != 0x4
262vlan.pcp == 1 && ((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && vlan.pcp == 0x2 && vlan.pcp == 0x3 && vlan.pcp == 0x4
263
264vlan.pcp == 1 && !((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3 || vlan.pcp != 0x4)
265vlan.pcp == 1 && (!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3) && vlan.pcp == 0x4
266vlan.pcp == 1 && !(!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && ((vlan.pcp == 0x2 && vlan.pcp == 0x3) || vlan.pcp != 0x4)
267
268ip4.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
269ip6.src == ::1 => ip6.src == 0x1
270
271ip4.src == 1.2.3.4 => ip4.src == 0x1020304
272ip4.src == ::1.2.3.4/::ffff:ffff => ip4.src == 0x1020304
273ip6.src == ::1 => ip6.src == 0x1
274
2751
2760
277!1 => 0
278!0 => 1
279
280inport == "eth0"
281!(inport != "eth0") => inport == "eth0"
282
3b7cb7e1
BP
283ip4.src == "eth0" => Integer field ip4.src is not compatible with string constant.
284inport == 1 => String field inport is not compatible with integer constant.
76da94b5 285ip4.src = 1.2.3.4 => Syntax error at `=' expecting relational operator.
e0840f11
BP
286
287ip4.src > {1, 2, 3} => Only == and != operators may be used with value sets.
288eth.type > 0x800 => Only == and != operators may be used with nominal field eth.type.
289vlan.present > 0 => Only == and != operators may be used with Boolean field vlan.present.
290
291inport != "eth0" => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account).
292!(inport == "eth0") => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account).
293eth.type != 0x800 => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account).
294!(eth.type == 0x800) => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account).
76da94b5 295inport = "eth0" => Syntax error at `=' expecting relational operator.
e0840f11
BP
296
297123 == 123 => Syntax error at `123' expecting field name.
298
2c5cbb15
RB
299$name => Syntax error at `$name' expecting address set name.
300
e0840f11
BP
301123 == xyzzy => Syntax error at `xyzzy' expecting field name.
302xyzzy == 1 => Syntax error at `xyzzy' expecting field name.
303
304inport[1] == 1 => Cannot select subfield of string field inport.
305
306eth.type[] == 1 => Syntax error at `@:>@' expecting small integer.
307eth.type[::1] == 1 => Syntax error at `::1' expecting small integer.
308eth.type[18446744073709551615] == 1 => Syntax error at `18446744073709551615' expecting small integer.
309
310eth.type[5!] => Syntax error at `!' expecting `@:>@'.
311
312eth.type[5..1] => Invalid bit range 5 to 1.
313
314eth.type[12..16] => Cannot select bits 12 to 16 of 16-bit field eth.type.
315
316eth.type[10] == 1 => Cannot select subfield of nominal field eth.type.
317
318eth.type => Explicit `!= 0' is required for inequality test of multibit field against 0.
319
320!(!(vlan.pcp)) => Explicit `!= 0' is required for inequality test of multibit field against 0.
321
322123 => Syntax error at end of input expecting relational operator.
323
324123 x => Syntax error at `x' expecting relational operator.
325
326{1, "eth0"} => Syntax error at `"eth0"' expecting integer.
327
328eth.type == xyzzy => Syntax error at `xyzzy' expecting constant.
329
330(1 x) => Syntax error at `x' expecting `)'.
331
332!0x800 != eth.type => Missing parentheses around operand of !.
333
334eth.type == 0x800 || eth.type == 0x86dd && ip.proto == 17 => && and || must be parenthesized when used together.
335
336eth.dst == {} => Syntax error at `}' expecting constant.
337
338eth.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).
339
3b7cb7e1 340ip4.src == ::1 => 128-bit constant is not compatible with 32-bit field ip4.src.
e0840f11
BP
341
3421 == eth.type == 2 => Range expressions must have the form `x < field < y' or `x > field > y', with each `<' optionally replaced by `<=' or `>' by `>=').
8b34ccda
JS
343
344eth.dst[40] x => Extra tokens at end of input.
ea382567
RB
345
346ip4.src == {1.2.3.4, $set1, $unknownset} => Syntax error at `$unknownset' expecting address set name.
347eth.src == {$set3, badmac, 00:00:00:00:00:01} => Syntax error at `badmac' expecting constant.
e0840f11
BP
348]])
349sed 's/ =>.*//' test-cases.txt > input.txt
350sed 's/.* => //' test-cases.txt > expout
351AT_CHECK([ovstest test-ovn parse-expr < input.txt], [0], [expout])
352AT_CLEANUP
353
354AT_SETUP([ovn -- expression annotation])
355dnl Input precedes =>, expected output follows =>.
356AT_DATA([test-cases.txt], [[
357ip4.src == 1.2.3.4 => ip4.src == 0x1020304 && eth.type == 0x800
358ip4.src != 1.2.3.4 => ip4.src != 0x1020304 && eth.type == 0x800
359ip.proto == 123 => ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)
360ip.proto == {123, 234} => (ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)) || (ip.proto == 0xea && (eth.type == 0x800 || eth.type == 0x86dd))
361ip4.src == 1.2.3.4 && ip4.dst == 5.6.7.8 => ip4.src == 0x1020304 && eth.type == 0x800 && ip4.dst == 0x5060708 && eth.type == 0x800
362
363ip => eth.type == 0x800 || eth.type == 0x86dd
364ip == 1 => eth.type == 0x800 || eth.type == 0x86dd
365ip[0] == 1 => eth.type == 0x800 || eth.type == 0x86dd
366ip > 0 => Only == and != operators may be used with nominal field ip.
367!ip => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'.
368ip == 0 => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'.
369
370vlan.present => vlan.tci[12]
371!vlan.present => !vlan.tci[12]
372
373!vlan.pcp => vlan.tci[13..15] == 0 && vlan.tci[12]
374vlan.pcp == 1 && vlan.vid == 2 => vlan.tci[13..15] == 0x1 && vlan.tci[12] && vlan.tci[0..11] == 0x2 && vlan.tci[12]
7700eea0 375!reg0 && !reg1 && !reg2 && !reg3 => xxreg0[96..127] == 0 && xxreg0[64..95] == 0 && xxreg0[32..63] == 0 && xxreg0[0..31] == 0
e0840f11
BP
376
377ip.first_frag => ip.frag[0] && (eth.type == 0x800 || eth.type == 0x86dd) && (!ip.frag[1] || (eth.type != 0x800 && eth.type != 0x86dd))
378!ip.first_frag => !ip.frag[0] || (eth.type != 0x800 && eth.type != 0x86dd) || (ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd))
379ip.later_frag => ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd)
380
381bad_prereq != 0 => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name.
382self_recurse != 0 => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'.
383mutual_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'.
384mutual_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'.
385]])
386sed 's/ =>.*//' test-cases.txt > input.txt
387sed 's/.* => //' test-cases.txt > expout
388AT_CHECK([ovstest test-ovn annotate-expr < input.txt], [0], [expout])
389AT_CLEANUP
390
9d4aecca 391AT_SETUP([ovn -- 1-term expression conversion])
e0840f11 392AT_CHECK([ovstest test-ovn exhaustive --operation=convert 1], [0],
9d4aecca 393 [Tested converting all 1-terminal expressions with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars.
e0840f11
BP
394])
395AT_CLEANUP
396
9d4aecca 397AT_SETUP([ovn -- 2-term expression conversion])
e0840f11 398AT_CHECK([ovstest test-ovn exhaustive --operation=convert 2], [0],
9d4aecca 399 [Tested converting 570 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars.
e0840f11
BP
400])
401AT_CLEANUP
402
9d4aecca 403AT_SETUP([ovn -- 3-term expression conversion])
e0840f11 404AT_CHECK([ovstest test-ovn exhaustive --operation=convert --bits=2 3], [0],
9d4aecca 405 [Tested converting 62418 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars.
e0840f11
BP
406])
407AT_CLEANUP
408
9d4aecca
BP
409AT_SETUP([ovn -- 3-term numeric expression simplification])
410AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=2 --svars=0 3], [0],
411 [Tested simplifying 477138 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=.
e0840f11
BP
412])
413AT_CLEANUP
414
9d4aecca
BP
415AT_SETUP([ovn -- 4-term string expression simplification])
416AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=0 --svars=4 4], [0],
417 [Tested simplifying 21978 expressions of 4 terminals with 4 string vars.
e0840f11
BP
418])
419AT_CLEANUP
420
9d4aecca
BP
421AT_SETUP([ovn -- 3-term mixed expression simplification])
422AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=1 --svars=1 3], [0],
423 [Tested simplifying 124410 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars.
e0840f11
BP
424])
425AT_CLEANUP
426
9d4aecca
BP
427AT_SETUP([ovn -- 4-term numeric expression normalization])
428AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 4], [0],
429 [Tested normalizing 1207162 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=.
e0840f11
BP
430])
431AT_CLEANUP
432
9d4aecca
BP
433AT_SETUP([ovn -- 4-term string expression normalization])
434AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 4], [0],
435 [Tested normalizing 11242 expressions of 4 terminals with 3 string vars.
436])
437AT_CLEANUP
438
439AT_SETUP([ovn -- 4-term mixed expression normalization])
440AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --bits=1 --svars=2 4], [0],
441 [Tested normalizing 128282 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars.
442])
443AT_CLEANUP
444
445AT_SETUP([ovn -- 5-term numeric expression normalization])
446AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 --relops='==' 5], [0],
447 [Tested normalizing 368550 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==.
448])
449AT_CLEANUP
450
451AT_SETUP([ovn -- 5-term string expression normalization])
452AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 --relops='==' 5], [0],
453 [Tested normalizing 368550 expressions of 5 terminals with 3 string vars.
454])
455AT_CLEANUP
456
457AT_SETUP([ovn -- 5-term mixed expression normalization])
458AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --svars=1 --bits=1 --relops='==' 5], [0],
459 [Tested normalizing 116550 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars.
460])
461AT_CLEANUP
462
463AT_SETUP([ovn -- 4-term numeric expressions to flows])
464AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=2 --svars=0 --bits=2 --relops='==' 4], [0],
465 [Tested converting to flows 128282 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==.
466])
467AT_CLEANUP
468
469AT_SETUP([ovn -- 4-term string expressions to flows])
470AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=0 --svars=4 4], [0],
471 [Tested converting to flows 21978 expressions of 4 terminals with 4 string vars.
472])
473AT_CLEANUP
474
475AT_SETUP([ovn -- 4-term mixed expressions to flows])
476AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=1 --bits=2 --svars=1 --relops='==' 4], [0],
477 [Tested converting to flows 37994 expressions of 4 terminals with 1 numeric vars (each 2 bits) in terms of operators == and 1 string vars.
478])
479AT_CLEANUP
480
481AT_SETUP([ovn -- 3-term numeric expressions to flows])
482AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=3 --svars=0 --bits=3 --relops='==' 3], [0],
483 [Tested converting to flows 38394 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==.
e0840f11
BP
484])
485AT_CLEANUP
f386a8a7
BP
486
487AT_SETUP([ovn -- converting expressions to flows -- string fields])
488expr_to_flow () {
489 echo "$1" | ovstest test-ovn expr-to-flows | sort
490}
cc5e28d8 491AT_CHECK([expr_to_flow 'inport == "eth0"'], [0], [reg14=0x5
f386a8a7 492])
cc5e28d8 493AT_CHECK([expr_to_flow 'inport == "eth1"'], [0], [reg14=0x6
f386a8a7
BP
494])
495AT_CHECK([expr_to_flow 'inport == "eth2"'], [0], [(no flows)
496])
497AT_CHECK([expr_to_flow 'inport == "eth0" && ip'], [0], [dnl
cc5e28d8
JP
498ip,reg14=0x5
499ipv6,reg14=0x5
f386a8a7
BP
500])
501AT_CHECK([expr_to_flow 'inport == "eth1" && ip'], [0], [dnl
cc5e28d8
JP
502ip,reg14=0x6
503ipv6,reg14=0x6
f386a8a7
BP
504])
505AT_CHECK([expr_to_flow 'inport == "eth2" && ip'], [0], [(no flows)
506])
507AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2", "LOCAL"}'], [0],
cc5e28d8
JP
508[reg14=0x5
509reg14=0x6
510reg14=0xfffe
f386a8a7
BP
511])
512AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2"} && ip'], [0], [dnl
cc5e28d8
JP
513ip,reg14=0x5
514ip,reg14=0x6
515ipv6,reg14=0x5
516ipv6,reg14=0x6
f386a8a7 517])
9d4aecca
BP
518AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl
519(no flows)
520])
f386a8a7 521AT_CLEANUP
3b7cb7e1 522
2c5cbb15
RB
523AT_SETUP([ovn -- converting expressions to flows -- address sets])
524expr_to_flow () {
525 echo "$1" | ovstest test-ovn expr-to-flows | sort
526}
527AT_CHECK([expr_to_flow 'ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3}'], [0], [dnl
528ip,nw_src=10.0.0.1
529ip,nw_src=10.0.0.2
530ip,nw_src=10.0.0.3
531])
532AT_CHECK([expr_to_flow 'ip4.src == $set1'], [0], [dnl
533ip,nw_src=10.0.0.1
534ip,nw_src=10.0.0.2
535ip,nw_src=10.0.0.3
536])
537AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set1}'], [0], [dnl
538ip,nw_src=1.2.3.4
539ip,nw_src=10.0.0.1
540ip,nw_src=10.0.0.2
541ip,nw_src=10.0.0.3
542])
543AT_CHECK([expr_to_flow 'ip4.src == {1.2.0.0/20, 5.5.5.0/24, $set1}'], [0], [dnl
544ip,nw_src=1.2.0.0/20
545ip,nw_src=10.0.0.1
546ip,nw_src=10.0.0.2
547ip,nw_src=10.0.0.3
548ip,nw_src=5.5.5.0/24
549])
550AT_CHECK([expr_to_flow 'ip6.src == {::1, ::2, ::3}'], [0], [dnl
551ipv6,ipv6_src=::1
552ipv6,ipv6_src=::2
553ipv6,ipv6_src=::3
554])
555AT_CHECK([expr_to_flow 'ip6.src == {::1, $set2, ::4}'], [0], [dnl
556ipv6,ipv6_src=::1
557ipv6,ipv6_src=::2
558ipv6,ipv6_src=::3
559ipv6,ipv6_src=::4
560])
561AT_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
562dl_src=00:00:00:00:00:01
563dl_src=00:00:00:00:00:02
564dl_src=00:00:00:00:00:03
565])
566AT_CHECK([expr_to_flow 'eth.src == {$set3}'], [0], [dnl
567dl_src=00:00:00:00:00:01
568dl_src=00:00:00:00:00:02
569dl_src=00:00:00:00:00:03
570])
ea382567
RB
571AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, $set3, ba:be:be:ef:de:ad, $set3}'], [0], [dnl
572dl_src=00:00:00:00:00:01
573dl_src=00:00:00:00:00:02
574dl_src=00:00:00:00:00:03
575dl_src=ba:be:be:ef:de:ad
576])
2c5cbb15
RB
577AT_CLEANUP
578
3b7cb7e1
BP
579AT_SETUP([ovn -- action parsing])
580dnl Text before => is input, text after => is expected output.
581AT_DATA([test-cases.txt], [[
5f822129 582# drop
3b7cb7e1 583drop; => actions=drop, prereqs=1
5f822129
BP
584drop; next; => Syntax error at `next' expecting end of input.
585next; drop; => Syntax error at `drop' expecting action.
586
587# output
588output; => actions=resubmit(,64), prereqs=1
589
590# next
558ec83d
BP
591next; => actions=resubmit(,27), prereqs=1
592next(0); => actions=resubmit(,16), prereqs=1
593next(15); => actions=resubmit(,31), prereqs=1
5f822129
BP
594
595next(); => Syntax error at `)' expecting small integer.
596next(10; => Syntax error at `;' expecting `)'.
597next(16); => "next" argument must be in range 0 to 15.
598
599# Loading a constant value.
3b7cb7e1
BP
600tcp.dst=80; => actions=set_field:80->tcp_dst, prereqs=ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd)
601eth.dst[40] = 1; => actions=set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dst, prereqs=1
602vlan.pcp = 2; => actions=set_field:0x4000/0xe000->vlan_tci, prereqs=vlan.tci[12]
603vlan.tci[13..15] = 2; => actions=set_field:0x4000/0xe000->vlan_tci, prereqs=1
bf143492 604inport = ""; => actions=set_field:0->reg14, prereqs=1
47f3b59b 605ip.ttl = 4; => actions=set_field:4->nw_ttl, prereqs=eth.type == 0x800 || eth.type == 0x86dd
cc5e28d8 606outport="eth0"; next; outport="LOCAL"; next; => actions=set_field:0x5->reg15,resubmit(,27),set_field:0xfffe->reg15,resubmit(,27), prereqs=1
558ec83d 607
3b7cb7e1
BP
608inport[1] = 1; => Cannot select subfield of string field inport.
609ip.proto[1] = 1; => Cannot select subfield of nominal field ip.proto.
8fb72d29 610eth.dst[40] == 1; => Syntax error at `==' expecting `=' or `<->'.
ce57ea75 611ip = 1; => Predicate symbol ip used where lvalue required.
3b7cb7e1
BP
612ip.proto = 6; => Field ip.proto is not modifiable.
613inport = {"a", "b"}; => Assignments require a single value.
614inport = {}; => Syntax error at `}' expecting constant.
615bad_prereq = 123; => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name.
616self_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'.
ce57ea75 617vlan.present = 0; => Predicate symbol vlan.present used where lvalue required.
5f822129
BP
618
619# Moving one field into another.
7700eea0
BP
620reg0 = reg1; => actions=move:NXM_NX_XXREG0[64..95]->NXM_NX_XXREG0[96..127], prereqs=1
621vlan.pcp = reg0[0..2]; => actions=move:NXM_NX_XXREG0[96..98]->NXM_OF_VLAN_TCI[13..15], prereqs=vlan.tci[12]
622reg0[10] = vlan.pcp[1]; => actions=move:NXM_OF_VLAN_TCI[14]->NXM_NX_XXREG0[106], prereqs=vlan.tci[12]
cc5e28d8 623outport = inport; => actions=move:NXM_NX_REG14[]->NXM_NX_REG15[], prereqs=1
5f822129 624
ce57ea75 625reg0[0] = vlan.present; => Predicate symbol vlan.present used where lvalue required.
5ee054fb
BP
626reg0 = reg1[0..10]; => Can't assign 11-bit value to 32-bit destination.
627inport = reg0; => Can't assign integer field (reg0) to string field (inport).
628inport = big_string; => String fields inport and big_string are incompatible for assignment.
629ip.proto = reg0[0..7]; => Field ip.proto is not modifiable.
5f822129
BP
630
631# Exchanging fields.
7700eea0
BP
632reg0 <-> reg1; => actions=push:NXM_NX_XXREG0[64..95],push:NXM_NX_XXREG0[96..127],pop:NXM_NX_XXREG0[64..95],pop:NXM_NX_XXREG0[96..127], prereqs=1
633vlan.pcp <-> reg0[0..2]; => actions=push:NXM_NX_XXREG0[96..98],push:NXM_OF_VLAN_TCI[13..15],pop:NXM_NX_XXREG0[96..98],pop:NXM_OF_VLAN_TCI[13..15], prereqs=vlan.tci[12]
634reg0[10] <-> vlan.pcp[1]; => actions=push:NXM_OF_VLAN_TCI[14],push:NXM_NX_XXREG0[106],pop:NXM_OF_VLAN_TCI[14],pop:NXM_NX_XXREG0[106], prereqs=vlan.tci[12]
cc5e28d8 635outport <-> inport; => actions=push:NXM_NX_REG14[],push:NXM_NX_REG15[],pop:NXM_NX_REG14[],pop:NXM_NX_REG15[], prereqs=1
5f822129 636
ce57ea75 637reg0[0] <-> vlan.present; => Predicate symbol vlan.present used where lvalue required.
a20c96c6
BP
638reg0 <-> reg1[0..10]; => Can't exchange 32-bit field with 11-bit field.
639inport <-> reg0; => Can't exchange string field (inport) with integer field (reg0).
640inport <-> big_string; => String fields inport and big_string are incompatible for exchange.
641ip.proto <-> reg0[0..7]; => Field ip.proto is not modifiable.
642reg0[0..7] <-> ip.proto; => Field ip.proto is not modifiable.
5f822129
BP
643
644# TTL decrement.
645ip.ttl--; => actions=dec_ttl, prereqs=ip
47f3b59b 646ip.ttl => Syntax error at end of input expecting `--'.
5f822129 647
467085fd 648# load balancing.
cc5e28d8 649ct_lb; => actions=ct(table=27,zone=NXM_NX_REG13[0..15],nat), prereqs=ip
467085fd
GS
650ct_lb(); => Syntax error at `)' expecting IPv4 address.
651ct_lb(192.168.1.2:80, 192.168.1.3:80); => actions=group:1, prereqs=ip
652ct_lb(192.168.1.2, 192.168.1.3, ); => actions=group:2, prereqs=ip
653ct_lb(192.168.1.2:); => Syntax error at `)' expecting port number.
654ct_lb(192.168.1.2:123456); => Syntax error at `123456' expecting port number.
655ct_lb(foo); => Syntax error at `foo' expecting IPv4 address.
656
5f822129 657# conntrack
cc5e28d8
JP
658ct_next; => actions=ct(table=27,zone=NXM_NX_REG13[0..15]), prereqs=ip
659ct_commit; => actions=ct(commit,zone=NXM_NX_REG13[0..15]), prereqs=ip
660ct_commit(); => actions=ct(commit,zone=NXM_NX_REG13[0..15]), prereqs=ip
661ct_commit(ct_mark=1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark)), prereqs=ip
662ct_commit(ct_mark=1/1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_mark)), prereqs=ip
663ct_commit(ct_label=1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_label)), prereqs=ip
664ct_commit(ct_label=1/1); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_label)), prereqs=ip
354b8f27
NS
665ct_commit(ct_label=0x01020304050607080910111213141516); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1020304050607080910111213141516->ct_label)), prereqs=ip
666ct_commit(ct_label=0x181716151413121110090807060504030201); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x16151413121110090807060504030201->ct_label)), prereqs=ip
667ct_commit(ct_label=0x01000000000000000000000000000000/0x01000000000000000000000000000000); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1000000000000000000000000000000/0x1000000000000000000000000000000->ct_label)), prereqs=ip
668ct_commit(ct_label=18446744073709551615); => actions=ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0xffffffffffffffff->ct_label)), prereqs=ip
669ct_commit(ct_label=18446744073709551616); => Decimal constants must be less than 2**64.
cc5e28d8 670ct_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
5f822129 671
de297547 672# dnat
cc5e28d8
JP
673ct_dnat; => actions=ct(table=27,zone=NXM_NX_REG11[0..15],nat), prereqs=ip
674ct_dnat(192.168.1.2); => actions=ct(commit,table=27,zone=NXM_NX_REG11[0..15],nat(dst=192.168.1.2)), prereqs=ip
de297547
GS
675ct_dnat(192.168.1.2, 192.168.1.3); => Syntax error at `,' expecting `)'.
676ct_dnat(foo); => Syntax error at `foo' invalid ip.
677ct_dnat(foo, bar); => Syntax error at `foo' invalid ip.
678ct_dnat(); => Syntax error at `)' invalid ip.
679
680# snat
cc5e28d8
JP
681ct_snat; => actions=ct(zone=NXM_NX_REG12[0..15],nat), prereqs=ip
682ct_snat(192.168.1.2); => actions=ct(commit,table=27,zone=NXM_NX_REG12[0..15],nat(src=192.168.1.2)), prereqs=ip
de297547
GS
683ct_snat(192.168.1.2, 192.168.1.3); => Syntax error at `,' expecting `)'.
684ct_snat(foo); => Syntax error at `foo' invalid ip.
685ct_snat(foo, bar); => Syntax error at `foo' invalid ip.
686ct_snat(); => Syntax error at `)' invalid ip.
687
688
6335d074
BP
689# arp
690arp { 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
691
0bac7164
BP
692# get_arp
693get_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
7700eea0 694get_arp(inport, reg0); => actions=push:NXM_NX_REG15[],push:NXM_NX_REG0[],push:NXM_NX_XXREG0[96..127],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
0bac7164
BP
695get_arp; => Syntax error at `;' expecting `('.
696get_arp(); => Syntax error at `)' expecting field name.
697get_arp(inport); => Syntax error at `)' expecting `,'.
698get_arp(inport ip4.dst); => Syntax error at `ip4.dst' expecting `,'.
699get_arp(inport, ip4.dst; => Syntax error at `;' expecting `)'.
700get_arp(inport, eth.dst); => Cannot use 48-bit field eth.dst[0..47] where 32-bit field is required.
701get_arp(inport, outport); => Cannot use string field outport where numeric field is required.
702get_arp(reg0, ip4.dst); => Cannot use numeric field reg0 where string field is required.
703
704# put_arp
705put_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
706
42814145 707# put_dhcp_opts
7700eea0
BP
708reg1[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.00.01.de.10.00.00.00.40.01.02.03.04.03.04.0a.00.00.01,pause), prereqs=1
709reg2[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.00.01.de.10.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
42814145
NS
710# offerip=10.0.0.4 --> 0a.00.00.04
711# router=10.0.0.1 --> 03.04.0a.00.00.01
712# netmask=255.255.255.0 --> 01.04.ff.ff.ff.00
713# mtu=1400 --> 1a.02.05.78
714# ip_forward_enable-1 --> 13.01.01
715# default_ttl=121 --> 17.01.79
716# dns_server={8.8.8.8,7.7.7.7} --> 06.08.08.08.08.08.07.07.07.07
717# classless_static_route= --> 79.14
718# {30.0.0.0/24,10.0.0.4 --> 18.1e.00.00.0a.00.00.04
719# 40.0.0.0/16,10.0.0.6 --> 10.28.00.0a.00.00.06
720# 0.0.0.0/0,10.0.0.1} --> 00.0a.00.00.01
721# ethernet_encap=1 --> 24.01.01
722# router_discovery=0 --> 1f.01.00
7700eea0 723reg0[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.00.01.de.10.00.00.00.6f.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
42814145
NS
724reg1[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.
725reg1[0] = put_dhcp_opts(); => Syntax error at `)'.
726reg1[0] = put_dhcp_opts(x = 1.2.3.4, router = 10.0.0.1); => Syntax error at `x' expecting offerip option.
727reg1[0] = put_dhcp_opts(offerip=1.2.3.4, "hi"); => Syntax error at `"hi"'.
728reg1[0] = put_dhcp_opts(offerip=1.2.3.4, xyzzy); => Syntax error at `xyzzy' expecting DHCP option name.
729reg1[0] = put_dhcp_opts(offerip="xyzzy"); => DHCP option offerip requires numeric value.
730reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain=1.2.3.4); => DHCP option domain requires string value.
731
f8a8db39 732# nd_na
bf143492 733nd_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.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00), prereqs=nd_ns
e75451fe 734
c34a87b6
JP
735# get_nd
736get_nd(outport, ip6.dst); => actions=push:NXM_NX_XXREG0[],push:NXM_NX_IPV6_DST[],pop:NXM_NX_XXREG0[],set_field:00:00:00:00:00:00->eth_dst,resubmit(,65),pop:NXM_NX_XXREG0[], prereqs=eth.type == 0x86dd
737get_nd(inport, xxreg0); => actions=push:NXM_NX_REG15[],push:NXM_NX_REG14[],pop:NXM_NX_REG15[],set_field:00:00:00:00:00:00->eth_dst,resubmit(,65),pop:NXM_NX_REG15[], prereqs=1
738get_nd; => Syntax error at `;' expecting `('.
739get_nd(); => Syntax error at `)' expecting field name.
740get_nd(inport); => Syntax error at `)' expecting `,'.
741get_nd(inport ip6.dst); => Syntax error at `ip6.dst' expecting `,'.
742get_nd(inport, ip6.dst; => Syntax error at `;' expecting `)'.
743get_nd(inport, eth.dst); => Cannot use 48-bit field eth.dst[0..47] where 128-bit field is required.
744get_nd(inport, outport); => Cannot use string field outport where numeric field is required.
745get_nd(xxreg0, ip6.dst); => Cannot use numeric field xxreg0 where string field is required.
746
747# put_nd
748put_nd(inport, nd.target, nd.sll); => actions=push:NXM_NX_XXREG0[],push:NXM_OF_ETH_SRC[],push:NXM_NX_ND_SLL[],push:NXM_NX_ND_TARGET[],pop:NXM_NX_XXREG0[],pop:NXM_OF_ETH_SRC[],controller(userdata=00.00.00.04.00.00.00.00),pop:NXM_OF_ETH_SRC[],pop:NXM_NX_XXREG0[], prereqs=((icmp6.type == 0x87 && eth.type == 0x86dd && ip.proto == 0x3a && (eth.type == 0x800 || eth.type == 0x86dd)) || (icmp6.type == 0x88 && eth.type == 0x86dd && ip.proto == 0x3a && (eth.type == 0x800 || eth.type == 0x86dd))) && icmp6.code == 0 && eth.type == 0x86dd && ip.proto == 0x3a && (eth.type == 0x800 || eth.type == 0x86dd) && ip.ttl == 0xff && (eth.type == 0x800 || eth.type == 0x86dd) && icmp6.type == 0x87 && eth.type == 0x86dd && ip.proto == 0x3a && (eth.type == 0x800 || eth.type == 0x86dd) && icmp6.code == 0 && eth.type == 0x86dd && ip.proto == 0x3a && (eth.type == 0x800 || eth.type == 0x86dd) && ip.ttl == 0xff && (eth.type == 0x800 || eth.type == 0x86dd)
749
5f822129
BP
750# Contradictionary prerequisites (allowed but not useful):
751ip4.src = ip6.src[0..31]; => actions=move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[], prereqs=eth.type == 0x800 && eth.type == 0x86dd
752ip4.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
753
754## Miscellaneous negative tests.
755; => Syntax error at `;'.
756xyzzy; => Syntax error at `xyzzy' expecting action.
757next; 123; => Syntax error at `123'.
758next; xyzzy; => Syntax error at `xyzzy' expecting action.
759next => Syntax error at end of input expecting ';'.
3b7cb7e1
BP
760]])
761sed 's/ =>.*//' test-cases.txt > input.txt
762sed 's/.* => //' test-cases.txt > expout
763AT_CHECK([ovstest test-ovn parse-actions < input.txt], [0], [expout])
764AT_CLEANUP
f295c17b
BP
765
766AT_BANNER([OVN end-to-end tests])
767
9975d7be
BP
768# 3 hypervisors, one logical switch, 3 logical ports per hypervisor
769AT_SETUP([ovn -- 3 HVs, 1 LS, 3 lports/HV])
57d143eb 770AT_KEYWORDS([ovnarp])
f295c17b
BP
771AT_SKIP_IF([test $HAVE_PYTHON = no])
772ovn_start
773
774# Create hypervisors hv[123].
9975d7be 775# Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3.
f295c17b
BP
776# Add all of the vifs to a single logical switch lsw0.
777# Turn on port security on all the vifs except vif[123]1.
778# Make vif13, vif2[23], vif3[123] destinations for unknown MACs.
779# Add some ACLs for Ethertypes 1234, 1235, 1236.
ea46a4e9 780ovn-nbctl ls-add lsw0
f295c17b
BP
781net_add n1
782for i in 1 2 3; do
783 sim_add hv$i
784 as hv$i
785 ovs-vsctl add-br br-phys
786 ovn_attach n1 br-phys 192.168.0.$i
787
788 for j in 1 2 3; do
789 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
31ed1192 790 ovn-nbctl lsp-add lsw0 lp$i$j
4d5c43d5 791 if test $j = 1; then
31ed1192 792 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown
f295c17b 793 else
7dc88496
NS
794 if test $j = 3; then
795 ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j"
796 else
797 ip_addrs="192.168.0.$i$j"
798 fi
31ed1192
JP
799 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs"
800 ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j
f295c17b
BP
801 fi
802 done
803done
804ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop
805ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop
806ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop
ea382567
RB
807ovn-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\"
808ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop
f295c17b
BP
809
810# Pre-populate the hypervisors' ARP tables so that we don't lose any
811# packets for ARP resolution (native tunneling doesn't queue packets
812# for ARP resolution).
813ovn_populate_arp
814
815# Allow some time for ovn-northd and ovn-controller to catch up.
816# XXX This should be more systematic.
817sleep 1
611099dc 818
57d143eb
HZ
819# Given the name of a logical port, prints the name of the hypervisor
820# on which it is located.
821vif_to_hv() {
822 echo hv${1%?}
823}
824
f295c17b
BP
825# test_packet INPORT DST SRC ETHTYPE OUTPORT...
826#
827# This shell function causes a packet to be received on INPORT. The packet's
828# content has Ethernet destination DST and source SRC (each exactly 12 hex
829# digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
830# more) list the VIFs on which the packet should be received. INPORT and the
31ed1192 831# OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11.
f295c17b
BP
832for i in 1 2 3; do
833 for j in 1 2 3; do
834 : > $i$j.expected
835 done
836done
837test_packet() {
838 local inport=$1 packet=$2$3$4; shift; shift; shift; shift
57d143eb 839 hv=`vif_to_hv $inport`
f295c17b
BP
840 vif=vif$inport
841 as $hv ovs-appctl netdev-dummy/receive $vif $packet
842 for outport; do
e4543cfe 843 echo $packet >> $outport.expected
f295c17b
BP
844 done
845}
846
57d143eb
HZ
847# test_arp INPORT SHA SPA TPA [REPLY_HA]
848#
849# Causes a packet to be received on INPORT. The packet is an ARP
850# request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then
851# it should be the hardware address of the target to expect to receive in an
852# ARP reply; otherwise no reply is expected.
853#
31ed1192 854# INPORT is an logical switch port number, e.g. 11 for vif11.
57d143eb
HZ
855# SHA and REPLY_HA are each 12 hex digits.
856# SPA and TPA are each 8 hex digits.
857test_arp() {
858 local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5
859 local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa}
860 hv=`vif_to_hv $inport`
861 as $hv ovs-appctl netdev-dummy/receive vif$inport $request
862
92f9822b 863 if test X$reply_ha = X; then
57d143eb
HZ
864 # Expect to receive the broadcast ARP on the other logical switch ports
865 # if no reply is expected.
866 local i j
867 for i in 1 2 3; do
868 for j in 1 2 3; do
869 if test $i$j != $inport; then
870 echo $request >> $i$j.expected
871 fi
872 done
873 done
874 else
875 # Expect to receive the reply, if any.
876 local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa}
877 echo $reply >> $inport.expected
878 fi
879}
880
881ip_to_hex() {
882 printf "%02x%02x%02x%02x" "$@"
883}
884
f295c17b
BP
885# Send packets between all pairs of source and destination ports:
886#
31ed1192
JP
887# 1. Unicast packets are delivered to exactly one logical switch port
888# (except that packets destined to their input ports are dropped).
f295c17b 889#
31ed1192
JP
890# 2. Broadcast and multicast are delivered to all logical switch ports
891# except the input port.
f295c17b 892#
ea46a4e9 893# 3. When port security is turned on, the switch drops packets from the wrong
f295c17b
BP
894# MAC address.
895#
ea46a4e9 896# 4. The switch drops all packets with a VLAN tag.
f295c17b 897#
ea46a4e9 898# 5. The switch drops all packets with a multicast source address. (This only
f295c17b
BP
899# affects behavior when port security is turned off, since otherwise port
900# security would drop the packet anyway.)
901#
ea46a4e9 902# 6. The switch delivers packets with an unknown destination to logical
31ed1192
JP
903# switch ports with "unknown" among their MAC addresses (and port
904# security disabled).
f295c17b 905#
ea46a4e9 906# 7. The switch drops unicast packets that violate an ACL.
f295c17b 907#
ea46a4e9 908# 8. The switch drops multicast and broadcast packets that violate an ACL.
57d143eb
HZ
909#
910# 9. ARP requests to known IPs are responded directly.
911#
912# 10. No response to ARP requests for unknown IPs.
f295c17b
BP
913for is in 1 2 3; do
914 for js in 1 2 3; do
915 s=$is$js
916 bcast=
4d5c43d5
JP
917 unknown=
918 bacl2=
919 bacl3=
f295c17b
BP
920 for id in 1 2 3; do
921 for jd in 1 2 3; do
922 d=$id$jd
923
924 if test $d != $s; then unicast=$d; else unicast=; fi
925 test_packet $s f000000000$d f000000000$s $s$d $unicast #1
926
927 if test $d != $s && test $js = 1; then
4d5c43d5
JP
928 impersonate=$d
929 else
930 impersonate=
931 fi
f295c17b
BP
932 test_packet $s f000000000$d f00000000055 55$d $impersonate #3
933
4d5c43d5
JP
934 if test $d != $s && test $s != 11; then acl2=$d; else acl2=; fi
935 if test $d != $s && test $d != 33; then acl3=$d; else acl3=; fi
e137131a 936 if test $d = $s || (test $js = 1 && test $d = 33); then
ea382567
RB
937 # Source of 11, 21, or 31 and dest of 33 should be dropped
938 # due to the 4th ACL that uses address_set(set1).
939 acl4=
940 else
941 acl4=$d
942 fi
f295c17b
BP
943 test_packet $s f000000000$d f000000000$s 1234 #7, acl1
944 test_packet $s f000000000$d f000000000$s 1235 $acl2 #7, acl2
945 test_packet $s f000000000$d f000000000$s 1236 $acl3 #7, acl3
ea382567 946 test_packet $s f000000000$d f000000000$s 1237 $acl4 #7, acl4
f295c17b
BP
947
948 test_packet $s f000000000$d f00000000055 810000091234 #4
949 test_packet $s f000000000$d 0100000000$s $s$d #5
950
4d5c43d5
JP
951 if test $d != $s && test $jd = 1; then
952 unknown="$unknown $d"
953 fi
f295c17b
BP
954 bcast="$bcast $unicast"
955 bacl2="$bacl2 $acl2"
956 bacl3="$bacl3 $acl3"
57d143eb
HZ
957
958 sip=`ip_to_hex 192 168 0 $i$j`
959 tip=`ip_to_hex 192 168 0 $id$jd`
960 tip_unknown=`ip_to_hex 11 11 11 11`
961 test_arp $s f000000000$s $sip $tip f000000000$d #9
962 test_arp $s f000000000$s $sip $tip_unknown #10
7dc88496
NS
963
964 if test $jd = 3; then
31ed1192 965 # lsp[123]3 has an additional ip 192.169.0.[123]3.
7dc88496
NS
966 tip=`ip_to_hex 192 169 0 $id$jd`
967 test_arp $s f000000000$s $sip $tip f000000000$d #9
968 fi
f295c17b
BP
969 done
970 done
971
4d5c43d5 972 # Broadcast and multicast.
f295c17b
BP
973 test_packet $s ffffffffffff f000000000$s ${s}ff $bcast #2
974 test_packet $s 010000000000 f000000000$s ${s}ff $bcast #2
4d5c43d5 975 if test $js = 1; then
f295c17b
BP
976 bcast_impersonate=$bcast
977 else
4d5c43d5
JP
978 bcast_impersonate=
979 fi
f295c17b
BP
980 test_packet $s 010000000000 f00000000044 44ff $bcast_impersonate #3
981
982 test_packet $s f0000000ffff f000000000$s ${s}66 $unknown #6
983
984 test_packet $s ffffffffffff f000000000$s 1234 #8, acl1
985 test_packet $s ffffffffffff f000000000$s 1235 $bacl2 #8, acl2
986 test_packet $s ffffffffffff f000000000$s 1236 $bacl3 #8, acl3
987 test_packet $s 010000000000 f000000000$s 1234 #8, acl1
988 test_packet $s 010000000000 f000000000$s 1235 $bacl2 #8, acl2
989 test_packet $s 010000000000 f000000000$s 1236 $bacl3 #8, acl3
990 done
991done
992
7dc88496
NS
993# set address for lp13 with invalid characters.
994# lp13 should be configured with only 192.168.0.13.
31ed1192 995ovn-nbctl lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13"
3b8cd0ea
BP
996
997# Allow some time for ovn-northd and ovn-controller to catch up.
998# XXX This should be more systematic.
999sleep 1
1000
7dc88496
NS
1001sip=`ip_to_hex 192 168 0 11`
1002tip=`ip_to_hex 192 168 0 13`
1003test_arp 11 f00000000011 $sip $tip f00000000013
1004
1005tip=`ip_to_hex 192 169 0 13`
1006#arp request for 192.169.0.13 should be flooded
1007test_arp 11 f00000000011 $sip $tip
1008
91125642 1009# dump information and flows with counters
bb0c41d3
RM
1010ovn-sbctl dump-flows -- list multicast_group
1011
1012echo "------ hv1 dump ------"
1013as hv1 ovs-vsctl show
1014as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1015
1016echo "------ hv2 dump ------"
1017as hv2 ovs-vsctl show
1018as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1019
1020echo "------ hv3 dump ------"
1021as hv3 ovs-vsctl show
1022as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int
49d7c759 1023
f295c17b
BP
1024# Now check the packets actually received against the ones expected.
1025for i in 1 2 3; do
1026 for j in 1 2 3; do
49d7c759 1027 OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected])
f295c17b
BP
1028 done
1029done
fcde56f5 1030
7a8f15e0 1031OVN_CLEANUP([hv1],[hv2],[hv3])
d9c8c57c 1032
f295c17b 1033AT_CLEANUP
eb6b08eb 1034
7277bc83
RB
1035# 2 hypervisors, 4 logical ports per HV
1036# 2 locally attached networks (one flat, one vlan tagged over same device)
1037# 2 ports per HV on each network
e90aeb57 1038AT_SETUP([ovn -- 2 HVs, 4 lports/HV, localnet ports])
d79fc5f4
RB
1039AT_KEYWORDS([ovn-localnet])
1040AT_SKIP_IF([test $HAVE_PYTHON = no])
1041ovn_start
1042
ea46a4e9
JP
1043# In this test cases we create 3 switches, all connected to same
1044# physical network (through br-phys on each HV). Each switch has
0ee7f7f1
HZ
1045# VIF ports across 2 HVs. Each HV has 5 VIF ports. The first digit
1046# of VIF port name indicates the hypervisor it is bound to, e.g.
1047# lp23 means VIF 3 on hv2.
1048#
ea46a4e9 1049# Each switch's VLAN tag and their logical switch ports are:
0ee7f7f1
HZ
1050# - ls1:
1051# - untagged
ea46a4e9 1052# - ports: lp11, lp12, lp21, lp22
0ee7f7f1
HZ
1053#
1054# - ls2:
1055# - tagged with VLAN 101
ea46a4e9 1056# - ports: lp13, lp14, lp23, lp24
0ee7f7f1
HZ
1057# - ls3:
1058# - untagged
ea46a4e9 1059# - ports: lp15, lp25
0ee7f7f1 1060#
ea46a4e9 1061# Note: a localnet port is created for each switch to connect to
0ee7f7f1
HZ
1062# physical network.
1063
1064for i in 1 2 3; do
ea46a4e9
JP
1065 ls_name=ls$i
1066 ovn-nbctl ls-add $ls_name
0ee7f7f1
HZ
1067 ln_port_name=ln$i
1068 if test $i -eq 2; then
ea46a4e9 1069 ovn-nbctl lsp-add $ls_name $ln_port_name "" 101
0ee7f7f1 1070 else
ea46a4e9 1071 ovn-nbctl lsp-add $ls_name $ln_port_name
0ee7f7f1 1072 fi
31ed1192
JP
1073 ovn-nbctl lsp-set-addresses $ln_port_name unknown
1074 ovn-nbctl lsp-set-type $ln_port_name localnet
1075 ovn-nbctl lsp-set-options $ln_port_name network_name=phys
0ee7f7f1 1076done
d79fc5f4
RB
1077
1078net_add n1
1079for i in 1 2; do
1080 sim_add hv$i
1081 as hv$i
1082 ovs-vsctl add-br br-phys
1083 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
1084 ovn_attach n1 br-phys 192.168.0.$i
1085
0ee7f7f1 1086 for j in 1 2 3 4 5; do
d79fc5f4
RB
1087 ovs-vsctl add-port br-int vif$i$j -- \
1088 set Interface vif$i$j external-ids:iface-id=lp$i$j \
1089 options:tx_pcap=hv$i/vif$i$j-tx.pcap \
1090 options:rxq_pcap=hv$i/vif$i$j-rx.pcap \
1091 ofport-request=$i$j
1092
31ed1192 1093 lsp_name=lp$i$j
7277bc83 1094 if test $j -le 2; then
ea46a4e9 1095 ls_name=ls1
0ee7f7f1 1096 elif test $j -le 4; then
ea46a4e9 1097 ls_name=ls2
d79fc5f4 1098 else
ea46a4e9 1099 ls_name=ls3
d79fc5f4 1100 fi
d79fc5f4 1101
ea46a4e9 1102 ovn-nbctl lsp-add $ls_name $lsp_name
31ed1192
JP
1103 ovn-nbctl lsp-set-addresses $lsp_name f0:00:00:00:00:$i$j
1104 ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$j
d79fc5f4 1105
31ed1192 1106 OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup])
d79fc5f4
RB
1107 done
1108done
1109
1110ovn_populate_arp
1111
1112# XXX This is now the 3rd copy of these functions in this file ...
1113
1114# Given the name of a logical port, prints the name of the hypervisor
1115# on which it is located.
1116vif_to_hv() {
1117 echo hv${1%?}
1118}
1119#
1120# test_packet INPORT DST SRC ETHTYPE OUTPORT...
1121#
1122# This shell function causes a packet to be received on INPORT. The packet's
1123# content has Ethernet destination DST and source SRC (each exactly 12 hex
1124# digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1125# more) list the VIFs on which the packet should be received. INPORT and the
31ed1192 1126# OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11.
d79fc5f4 1127for i in 1 2; do
0ee7f7f1 1128 for j in 1 2 3 4 5; do
d79fc5f4
RB
1129 : > $i$j.expected
1130 done
1131done
1132test_packet() {
1133 local inport=$1 src=$2 dst=$3 eth=$4; shift; shift; shift; shift
1134 local packet=${src}${dst}${eth}
1135 hv=`vif_to_hv $inport`
1136 vif=vif$inport
1137 as $hv ovs-appctl netdev-dummy/receive $vif $packet
1138 for outport; do
e4543cfe 1139 echo $packet >> $outport.expected
d79fc5f4
RB
1140 done
1141}
1142
7277bc83
RB
1143# lp11 and lp21 are on the same network (phys, untagged)
1144# and on different hypervisors
d79fc5f4
RB
1145test_packet 11 f00000000021 f00000000011 1121 21
1146test_packet 21 f00000000011 f00000000021 2111 11
1147
7277bc83
RB
1148# lp11 and lp12 are on the same network (phys, untagged)
1149# and on the same hypervisor
e90aeb57
RB
1150test_packet 11 f00000000012 f00000000011 1112 12
1151test_packet 12 f00000000011 f00000000012 1211 11
7277bc83
RB
1152
1153# lp13 and lp23 are on the same network (phys, VLAN 101)
1154# and on different hypervisors
1155test_packet 13 f00000000023 f00000000013 1323 23
1156test_packet 23 f00000000013 f00000000023 2313 13
1157
1158# lp13 and lp14 are on the same network (phys, VLAN 101)
1159# and on the same hypervisor
e90aeb57
RB
1160test_packet 13 f00000000014 f00000000013 1314 14
1161test_packet 14 f00000000013 f00000000014 1413 13
d79fc5f4 1162
0ee7f7f1 1163# lp11 and lp15 are on the same network (phys, untagged),
ea46a4e9 1164# same hypervisor, and on different switches
0ee7f7f1
HZ
1165test_packet 11 f00000000015 f00000000011 1115 15
1166test_packet 15 f00000000011 f00000000015 1511 11
1167
1168# lp11 and lp25 are on the same network (phys, untagged),
ea46a4e9 1169# different hypervisors, and on different switches
0ee7f7f1
HZ
1170test_packet 11 f00000000025 f00000000011 1125 25
1171test_packet 25 f00000000011 f00000000025 2511 11
1172
d79fc5f4 1173# Ports that should not be able to communicate
7277bc83
RB
1174test_packet 11 f00000000013 f00000000011 1113
1175test_packet 11 f00000000023 f00000000011 1123
1176test_packet 21 f00000000013 f00000000021 2113
1177test_packet 21 f00000000023 f00000000021 2123
1178test_packet 13 f00000000011 f00000000013 1311
1179test_packet 13 f00000000021 f00000000013 1321
1180test_packet 23 f00000000011 f00000000023 2311
1181test_packet 23 f00000000021 f00000000023 2321
d79fc5f4 1182
d79fc5f4
RB
1183# Dump a bunch of info helpful for debugging if there's a failure.
1184
1185echo "------ OVN dump ------"
1186ovn-nbctl show
1187ovn-sbctl show
1188
1189echo "------ hv1 dump ------"
1190as hv1 ovs-vsctl show
1191as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1192
1193echo "------ hv2 dump ------"
1194as hv2 ovs-vsctl show
1195as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1196
1197# Now check the packets actually received against the ones expected.
1198for i in 1 2; do
0ee7f7f1 1199 for j in 1 2 3 4 5; do
49d7c759 1200 OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected])
d79fc5f4
RB
1201 done
1202done
1203
7a8f15e0 1204OVN_CLEANUP([hv1],[hv2])
d9c8c57c 1205
d79fc5f4
RB
1206AT_CLEANUP
1207
91125642
FF
1208AT_SETUP([ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS])
1209AT_KEYWORDS([vtep])
eb6b08eb
JP
1210AT_SKIP_IF([test $HAVE_PYTHON = no])
1211ovn_start
1212
1213# Configure the Northbound database
ea46a4e9 1214ovn-nbctl ls-add lsw0
eb6b08eb 1215
31ed1192
JP
1216ovn-nbctl lsp-add lsw0 lp1
1217ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01
eb6b08eb 1218
31ed1192
JP
1219ovn-nbctl lsp-add lsw0 lp2
1220ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02
eb6b08eb 1221
31ed1192
JP
1222ovn-nbctl lsp-add lsw0 lp-vtep
1223ovn-nbctl lsp-set-type lp-vtep vtep
1224ovn-nbctl lsp-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0
1225ovn-nbctl lsp-set-addresses lp-vtep unknown
eb6b08eb
JP
1226
1227net_add n1 # Network to connect hv1, hv2, and vtep
1228net_add n2 # Network to connect vtep and hv3
1229
1230# Create hypervisor hv1 connected to n1
1231sim_add hv1
1232as hv1
1233ovs-vsctl add-br br-phys
1234ovn_attach n1 br-phys 192.168.0.1
1235ovs-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
1236
1237# Create hypervisor hv2 connected to n1
1238sim_add hv2
1239as hv2
1240ovs-vsctl add-br br-phys
1241ovn_attach n1 br-phys 192.168.0.2
1242ovs-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
1243
1244
1245# Start the vtep emulator with a leg in both networks
1246sim_add vtep
1247as vtep
1248
1249ovsdb-tool create "$ovs_base"/vtep/vtep.db "$abs_top_srcdir"/vtep/vtep.ovsschema || return 1
1250ovs-appctl -t ovsdb-server ovsdb-server/add-db "$ovs_base"/vtep/vtep.db
1251
1252ovs-vsctl add-br br-phys
1253net_attach n1 br-phys
1254
1255mac=`ovs-vsctl get Interface br-phys mac_in_use | sed s/\"//g`
1256arp_table="$arp_table $sandbox,br-phys,192.168.0.3,$mac"
1257ovs-appctl netdev-dummy/ip4addr br-phys 192.168.0.3/24 >/dev/null || return 1
1258ovs-appctl ovs/route/add 192.168.0.3/24 br-phys >/dev/null || return 1
1259
1260ovs-vsctl add-br br-vtep
1261net_attach n2 br-vtep
1262
1263vtep-ctl add-ps br-vtep
1264vtep-ctl set Physical_Switch br-vtep tunnel_ips=192.168.0.3
1265vtep-ctl add-ls lsw0
1266
1267start_daemon ovs-vtep br-vtep
1268start_daemon ovn-controller-vtep --vtep-db=unix:"$ovs_base"/vtep/db.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock
1269
1270sleep 1
1271
1272vtep-ctl bind-ls br-vtep br-vtep_n2 0 lsw0
1273
475f0a2c
DB
1274OVS_WAIT_UNTIL([test -n "`as vtep vtep-ctl get-replication-mode lsw0 |
1275 grep -- source`"])
1276# It takes more time for the update to be processed by ovs-vtep.
eb6b08eb
JP
1277sleep 1
1278
1279# Add hv3 on the other side of the vtep
1280sim_add hv3
1281as hv3
1282ovs-vsctl add-br br-phys
1283net_attach n2 br-phys
1284
1285ovs-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
1286
1287# Pre-populate the hypervisors' ARP tables so that we don't lose any
1288# packets for ARP resolution (native tunneling doesn't queue packets
1289# for ARP resolution).
1290ovn_populate_arp
1291
1292# Allow some time for ovn-northd and ovn-controller to catch up.
1293# XXX This should be more systematic.
1294sleep 1
6977df72 1295
eb6b08eb
JP
1296# test_packet INPORT DST SRC ETHTYPE OUTPORT...
1297#
1298# This shell function causes a packet to be received on INPORT. The packet's
1299# content has Ethernet destination DST and source SRC (each exactly 12 hex
1300# digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1301# more) list the VIFs on which the packet should be received. INPORT and the
31ed1192 1302# OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1.
eb6b08eb
JP
1303for i in 1 2 3; do
1304 : > $i.expected
1305done
1306test_packet() {
1307 local inport=$1 packet=$2$3$4; shift; shift; shift; shift
1308 #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'`
1309 hv=hv$inport
1310 vif=vif$inport
1311 as $hv ovs-appctl netdev-dummy/receive $vif $packet
1312 for outport; do
e4543cfe 1313 echo $packet >> $outport.expected
eb6b08eb
JP
1314 done
1315}
1316
1317# Send packets between all pairs of source and destination ports:
1318#
31ed1192
JP
1319# 1. Unicast packets are delivered to exactly one logical switch port
1320# (except that packets destined to their input ports are dropped).
eb6b08eb 1321#
31ed1192
JP
1322# 2. Broadcast and multicast are delivered to all logical switch ports
1323# except the input port.
eb6b08eb 1324#
ea46a4e9 1325# 3. The switch delivers packets with an unknown destination to logical
31ed1192
JP
1326# switch ports with "unknown" among their MAC addresses (and port
1327# security disabled).
eb6b08eb
JP
1328for s in 1 2 3; do
1329 bcast=
1330 unknown=
1331 for d in 1 2 3; do
1332 if test $d != $s; then unicast=$d; else unicast=; fi
1333 test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1
1334
1335 # The vtep (vif3) is the only one configured for "unknown"
1336 if test $d != $s && test $d = 3; then
1337 unknown="$unknown $d"
1338 fi
1339 bcast="$bcast $unicast"
1340 done
1341
1342 # Broadcast and multicast.
46ed1382
DB
1343 test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2
1344 test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #2
eb6b08eb
JP
1345
1346 test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #3
1347done
1348
bb0c41d3
RM
1349# dump information with counters
1350echo "------ OVN dump ------"
1351ovn-nbctl show
1352ovn-sbctl show
1353
1354echo "------ hv1 dump ------"
1355as hv1 ovs-vsctl show
6195e2e7 1356as hv1 ovs-ofctl -O OpenFlow13 show br-int
bb0c41d3
RM
1357as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1358
1359echo "------ hv2 dump ------"
1360as hv2 ovs-vsctl show
6195e2e7 1361as hv2 ovs-ofctl -O OpenFlow13 show br-int
bb0c41d3
RM
1362as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1363
1364echo "------ hv3 dump ------"
1365as hv3 ovs-vsctl show
6754e92d
FF
1366# note: hv3 has no logical port bind, thus it should not have br-int
1367AT_CHECK([as hv3 ovs-ofctl -O OpenFlow13 show br-int], [1], [],
1368[ovs-ofctl: br-int is not a bridge or a socket
1369])
bb0c41d3 1370
eb6b08eb
JP
1371# Now check the packets actually received against the ones expected.
1372for i in 1 2 3; do
49d7c759 1373 OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected])
eb6b08eb 1374done
fcde56f5
LR
1375
1376# Gracefully terminate daemons
7a8f15e0
LR
1377OVN_CLEANUP([hv1],[hv2],[vtep])
1378OVN_CLEANUP_VSWITCH([hv3])
d9c8c57c 1379
eb6b08eb 1380AT_CLEANUP
9975d7be 1381
184bc3ca
RB
1382# Similar test to "hardware GW"
1383AT_SETUP([ovn -- 3 HVs, 1 VIFs/HV, 1 software GW, 1 LS])
1384AT_SKIP_IF([test $HAVE_PYTHON = no])
1385ovn_start
1386
1387# Configure the Northbound database
1388ovn-nbctl ls-add lsw0
1389
1390ovn-nbctl lsp-add lsw0 lp1
1391ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01
1392
1393ovn-nbctl lsp-add lsw0 lp2
1394ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02
1395
1396ovn-nbctl lsp-add lsw0 lp-gw
1397ovn-nbctl lsp-set-type lp-gw l2gateway
62b87eab 1398ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw
184bc3ca
RB
1399ovn-nbctl lsp-set-addresses lp-gw unknown
1400
1401net_add n1 # Network to connect hv1, hv2, and gw
1402net_add n2 # Network to connect gw and hv3
1403
1404# Create hypervisor hv1 connected to n1
1405sim_add hv1
1406as hv1
1407ovs-vsctl add-br br-phys
1408ovn_attach n1 br-phys 192.168.0.1
1409ovs-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
1410
1411# Create hypervisor hv2 connected to n1
1412sim_add hv2
1413as hv2
1414ovs-vsctl add-br br-phys
1415ovn_attach n1 br-phys 192.168.0.2
1416ovs-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
1417
1418# Create hypervisor hv_gw connected to n1 and n2
1419# connect br-phys bridge to n1; connect hv-gw bridge to n2
1420sim_add hv_gw
1421as hv_gw
1422ovs-vsctl add-br br-phys
1423ovn_attach n1 br-phys 192.168.0.3
1424ovs-vsctl add-br br-phys2
1425net_attach n2 br-phys2
1426ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2"
1427
184bc3ca
RB
1428# Add hv3 on the other side of the GW
1429sim_add hv3
1430as hv3
1431ovs-vsctl add-br br-phys
1432net_attach n2 br-phys
1433ovs-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
1434
1435
1436# Pre-populate the hypervisors' ARP tables so that we don't lose any
1437# packets for ARP resolution (native tunneling doesn't queue packets
1438# for ARP resolution).
1439ovn_populate_arp
1440
1441# Allow some time for ovn-northd and ovn-controller to catch up.
1442# XXX This should be more systematic.
1443sleep 1
1444
1445# test_packet INPORT DST SRC ETHTYPE OUTPORT...
1446#
1447# This shell function causes a packet to be received on INPORT. The packet's
1448# content has Ethernet destination DST and source SRC (each exactly 12 hex
1449# digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1450# more) list the VIFs on which the packet should be received. INPORT and the
1451# OUTPORTs are specified as lport numbers, e.g. 1 for vif1.
184bc3ca
RB
1452for i in 1 2 3; do
1453 : > $i.expected
1454done
1455test_packet() {
1456 local inport=$1 packet=$2$3$4; shift; shift; shift; shift
1457 #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'`
1458 hv=hv$inport
1459 vif=vif$inport
1460 as $hv ovs-appctl netdev-dummy/receive $vif $packet
1461 for outport; do
e4543cfe 1462 echo $packet >> $outport.expected
184bc3ca
RB
1463 done
1464}
1465
1466# Send packets between all pairs of source and destination ports:
1467#
1468# 1. Unicast packets are delivered to exactly one lport (except that packets
1469# destined to their input ports are dropped).
1470#
1471# 2. Broadcast and multicast are delivered to all lports except the input port.
1472#
1473# 3. The lswitch delivers packets with an unknown destination to lports with
1474# "unknown" among their MAC addresses (and port security disabled).
1475for s in 1 2 3 ; do
1476 bcast=
1477 unknown=
1478 for d in 1 2 3 ; do
1479 if test $d != $s; then unicast=$d; else unicast=; fi
1480 test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1
1481
1482 # The vtep (vif3) is the only one configured for "unknown"
1483 if test $d != $s && test $d = 3; then
1484 unknown="$unknown $d"
1485 fi
1486 bcast="$bcast $unicast"
1487 done
1488
1489 test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2
1490 test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #3
1491 test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #4
1492done
1493
184bc3ca
RB
1494echo "------ ovn-nbctl show ------"
1495ovn-nbctl show
1496echo "------ ovn-sbctl show ------"
1497ovn-sbctl show
1498
1499echo "------ hv1 ------"
1500as hv1 ovs-vsctl show
1501echo "------ hv1 br-int ------"
1502as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
1503echo "------ hv1 br-phys ------"
1504as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-phys
1505
1506echo "------ hv2 ------"
1507as hv2 ovs-vsctl show
1508echo "------ hv2 br-int ------"
1509as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
1510echo "------ hv2 br-phys ------"
1511as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-phys
1512
1513echo "------ hv_gw ------"
1514as hv_gw ovs-vsctl show
1515echo "------ hv_gw br-phys ------"
1516as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys
1517echo "------ hv_gw br-phys2 ------"
1518as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys2
1519
1520echo "------ hv3 ------"
1521as hv3 ovs-vsctl show
1522echo "------ hv3 br-phys ------"
1523as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-phys
1524
1525# Now check the packets actually received against the ones expected.
1526for i in 1 2 3; do
49d7c759 1527 OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected])
184bc3ca
RB
1528done
1529AT_CLEANUP
1530
9975d7be
BP
1531# 3 hypervisors, 3 logical switches with 3 logical ports each, 1 logical router
1532AT_SETUP([ovn -- 3 HVs, 3 LS, 3 lports/LS, 1 LR])
1533AT_SKIP_IF([test $HAVE_PYTHON = no])
1534ovn_start
1535
1536# Logical network:
1537#
1538# Three logical switches ls1, ls2, ls3.
86e98048
BP
1539# One logical router lr0 connected to ls[123],
1540# with nine subnets, three per logical switch:
1541#
1542# lrp11 on ls1 for subnet 192.168.11.0/24
1543# lrp12 on ls1 for subnet 192.168.12.0/24
1544# lrp13 on ls1 for subnet 192.168.13.0/24
1545# ...
1546# lrp33 on ls3 for subnet 192.168.33.0/24
1547#
1548# 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two
1549# digits are the subnet and the last digit distinguishes the VIF.
9975d7be 1550for i in 1 2 3; do
ea46a4e9 1551 ovn-nbctl ls-add ls$i
9975d7be 1552 for j in 1 2 3; do
86e98048 1553 for k in 1 2 3; do
31ed1192
JP
1554 # Add "unknown" to MAC addresses for lp?11, so packets for
1555 # MAC-IP bindings discovered via ARP later have somewhere to go.
1556 if test $j$k = 11; then unknown=unknown; else unknown=; fi
1557
1558 ovn-nbctl \
1559 -- lsp-add ls$i lp$i$j$k \
1560 -- lsp-set-addresses lp$i$j$k "f0:00:00:00:0$i:$j$k \
1561 192.168.$i$j.$k" $unknown
86e98048
BP
1562 done
1563 done
1564done
1565
fa2a27b2 1566ovn-nbctl lr-add lr0
86e98048
BP
1567for i in 1 2 3; do
1568 for j in 1 2 3; do
bf44c2cd 1569 ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24
269ecccc 1570 ovn-nbctl \
31ed1192 1571 -- lsp-add ls$i lrp$i$j-attachment \
269ecccc 1572 -- set Logical_Switch_Port lrp$i$j-attachment type=router \
00007447 1573 options:router-port=lrp$i$j \
86e98048 1574 addresses='"00:00:00:00:ff:'$i$j'"'
9975d7be
BP
1575 done
1576done
1577
80f408f4 1578ovn-nbctl set Logical_Switch_Port lrp33-attachment \
57d143eb
HZ
1579 addresses='"00:00:00:00:ff:33 192.168.33.254"'
1580
9975d7be
BP
1581# Physical network:
1582#
1583# Three hypervisors hv[123].
86e98048
BP
1584# lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3.
1585# lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3.
1586# lp?3[123] all on hv3.
1587
9975d7be
BP
1588
1589# Given the name of a logical port, prints the name of the hypervisor
1590# on which it is located.
1591vif_to_hv() {
1592 case $1 in dnl (
86e98048
BP
1593 ?11) echo 1 ;; dnl (
1594 ?12 | ?21 | ?22) echo 2 ;; dnl (
1595 ?13 | ?23 | ?3?) echo 3 ;;
9975d7be
BP
1596 esac
1597}
1598
86e98048
BP
1599# Given the name of a logical port, prints the name of its logical router
1600# port, e.g. "vif_to_lrp 123" yields 12.
1601vif_to_lrp() {
1602 echo ${1%?}
1603}
1604
1605# Given the name of a logical port, prints the name of its logical
1606# switch, e.g. "vif_to_ls 123" yields 1.
e3393e3f 1607vif_to_ls() {
86e98048 1608 echo ${1%??}
e3393e3f
BP
1609}
1610
9975d7be
BP
1611net_add n1
1612for i in 1 2 3; do
1613 sim_add hv$i
1614 as hv$i
1615 ovs-vsctl add-br br-phys
1616 ovn_attach n1 br-phys 192.168.0.$i
1617done
1618for i in 1 2 3; do
1619 for j in 1 2 3; do
86e98048 1620 for k in 1 2 3; do
269ecccc
JP
1621 hv=`vif_to_hv $i$j$k`
1622 as hv$hv ovs-vsctl \
1623 -- add-port br-int vif$i$j$k \
1624 -- set Interface vif$i$j$k \
1625 external-ids:iface-id=lp$i$j$k \
1626 options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \
1627 options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \
1628 ofport-request=$i$j$k
86e98048 1629 done
9975d7be
BP
1630 done
1631done
1632
1633# Pre-populate the hypervisors' ARP tables so that we don't lose any
1634# packets for ARP resolution (native tunneling doesn't queue packets
1635# for ARP resolution).
1636ovn_populate_arp
1637
1638# Allow some time for ovn-northd and ovn-controller to catch up.
1639# XXX This should be more systematic.
1640sleep 1
1641
e3393e3f 1642# test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT...
9975d7be
BP
1643#
1644# This shell function causes a packet to be received on INPORT. The packet's
1645# content has Ethernet destination DST and source SRC (each exactly 12 hex
1646# digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or
1647# more) list the VIFs on which the packet should be received. INPORT and the
31ed1192 1648# OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123.
9975d7be
BP
1649for i in 1 2 3; do
1650 for j in 1 2 3; do
86e98048
BP
1651 for k in 1 2 3; do
1652 : > $i$j$k.expected
269ecccc 1653 done
9975d7be
BP
1654 done
1655done
e3393e3f 1656test_ip() {
9975d7be
BP
1657 # This packet has bad checksums but logical L3 routing doesn't check.
1658 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
ba43992e 1659 local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
9975d7be
BP
1660 shift; shift; shift; shift; shift
1661 hv=hv`vif_to_hv $inport`
1662 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
1663 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
86e98048
BP
1664 in_ls=`vif_to_ls $inport`
1665 in_lrp=`vif_to_lrp $inport`
9975d7be 1666 for outport; do
269ecccc 1667 out_ls=`vif_to_ls $outport`
86e98048 1668 if test $in_ls = $out_ls; then
9975d7be
BP
1669 # Ports on the same logical switch receive exactly the same packet.
1670 echo $packet
1671 else
1672 # Routing decrements TTL and updates source and dest MAC
1673 # (and checksum).
269ecccc 1674 out_lrp=`vif_to_lrp $outport`
86e98048 1675 echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000
e4543cfe 1676 fi >> $outport.expected
9975d7be
BP
1677 done
1678}
1679
e3393e3f 1680as hv1 ovs-vsctl --columns=name,ofport list interface
0bac7164
BP
1681as hv1 ovn-sbctl list port_binding
1682as hv1 ovn-sbctl list datapath_binding
9975d7be
BP
1683as hv1 ovn-sbctl dump-flows
1684as hv1 ovs-ofctl dump-flows br-int
1685
e3393e3f 1686# Send IP packets between all pairs of source and destination ports:
9975d7be 1687#
31ed1192
JP
1688# 1. Unicast IP packets are delivered to exactly one logical switch port
1689# (except that packets destined to their input ports are dropped).
9975d7be 1690#
31ed1192
JP
1691# 2. Broadcast IP packets are delivered to all logical switch ports
1692# except the input port.
86e98048
BP
1693ip_to_hex() {
1694 printf "%02x%02x%02x%02x" "$@"
1695}
9975d7be 1696for is in 1 2 3; do
269ecccc
JP
1697 for js in 1 2 3; do
1698 for ks in 1 2 3; do
1699 bcast=
1700 s=$is$js$ks
1701 smac=f00000000$s
1702 sip=`ip_to_hex 192 168 $is$js $ks`
1703 for id in 1 2 3; do
1704 for jd in 1 2 3; do
1705 for kd in 1 2 3; do
1706 d=$id$jd$kd
1707 dip=`ip_to_hex 192 168 $id$jd $kd`
1708 if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi
1709 if test $d != $s; then unicast=$d; else unicast=; fi
1710
1711 test_ip $s $smac $dmac $sip $dip $unicast #1
1712
1713 if test $id = $is && test $d != $s; then bcast="$bcast $d"; fi
1714 done
1715 done
9975d7be 1716 done
269ecccc
JP
1717 test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2
1718 done
1719 done
e3393e3f
BP
1720done
1721
0bac7164
BP
1722# 3. Send an IP packet from every logical port to every other subnet,
1723# to an IP address that does not have a static IP-MAC binding.
1724# This should generate a broadcast ARP request for the destination
1725# IP address in the destination subnet.
1726for is in 1 2 3; do
269ecccc
JP
1727 for js in 1 2 3; do
1728 for ks in 1 2 3; do
1729 s=$is$js$ks
1730 smac=f00000000$s
1731 sip=`ip_to_hex 192 168 $is$js $ks`
1732 for id in 1 2 3; do
1733 for jd in 1 2 3; do
1734 if test $is$js = $id$jd; then
1735 continue
1736 fi
1737
1738 # Send the packet.
1739 dmac=00000000ff$is$js
1740 # Calculate a 4th octet for the destination that is
1741 # unique per $s, avoids the .1 .2 .3 and .254 IP addresses
1742 # that have static MAC bindings, and fits in the range
1743 # 0-255.
1744 o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10`
1745 dip=`ip_to_hex 192 168 $id$jd $o4`
1746 test_ip $s $smac $dmac $sip $dip
1747
1748 # Every LP on the destination subnet's lswitch should
1749 # receive the ARP request.
1750 lrmac=00000000ff$id$jd
1751 lrip=`ip_to_hex 192 168 $id$jd 254`
1752 arp=ffffffffffff${lrmac}08060001080006040001${lrmac}${lrip}000000000000${dip}
1753 for jd2 in 1 2 3; do
1754 for kd in 1 2 3; do
e4543cfe 1755 echo $arp >> $id$jd2$kd.expected
0bac7164 1756 done
269ecccc 1757 done
0bac7164 1758 done
269ecccc 1759 done
0bac7164 1760 done
269ecccc 1761 done
0bac7164
BP
1762done
1763
e3393e3f
BP
1764# test_arp INPORT SHA SPA TPA [REPLY_HA]
1765#
1766# Causes a packet to be received on INPORT. The packet is an ARP
1767# request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then
1768# it should be the hardware address of the target to expect to receive in an
1769# ARP reply; otherwise no reply is expected.
1770#
31ed1192 1771# INPORT is an logical switch port number, e.g. 11 for vif11.
e3393e3f
BP
1772# SHA and REPLY_HA are each 12 hex digits.
1773# SPA and TPA are each 8 hex digits.
1774test_arp() {
1775 local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5
1776 local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa}
1777 hv=hv`vif_to_hv $inport`
1778 as $hv ovs-appctl netdev-dummy/receive vif$inport $request
1779 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request
1780
57d143eb 1781 # Expect to receive the broadcast ARP on the other logical switch ports if
ea46a4e9 1782 # IP address is not configured to the switch patch port.
e3393e3f 1783 local i=`vif_to_ls $inport`
86e98048 1784 local j k
e3393e3f 1785 for j in 1 2 3; do
86e98048 1786 for k in 1 2 3; do
ea46a4e9 1787 # 192.168.33.254 is configured to the switch patch port for lrp33,
57d143eb
HZ
1788 # so no ARP flooding expected for it.
1789 if test $i$j$k != $inport && test $tpa != `ip_to_hex 192 168 33 254`; then
86e98048
BP
1790 echo $request >> $i$j$k.expected
1791 fi
1792 done
e3393e3f
BP
1793 done
1794
1795 # Expect to receive the reply, if any.
1796 if test X$reply_ha != X; then
86e98048
BP
1797 lrp=`vif_to_lrp $inport`
1798 local reply=${sha}00000000ff${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa}
e3393e3f
BP
1799 echo $reply >> $inport.expected
1800 fi
1801}
1802
1803# Test router replies to ARP requests from all source ports:
1804#
0bac7164 1805# 4. Router replies to query for its MAC address from port's own IP address.
e3393e3f 1806#
0bac7164 1807# 5. Router replies to query for its MAC address from any random IP address
e3393e3f
BP
1808# in its subnet.
1809#
0bac7164 1810# 6. Router replies to query for its MAC address from another subnet.
e3393e3f 1811#
0bac7164 1812# 7. No reply to query for IP address other than router IP.
e3393e3f 1813for i in 1 2 3; do
269ecccc
JP
1814 for j in 1 2 3; do
1815 for k in 1 2 3; do
1816 smac=f00000000$i$j$k # Source MAC
1817 sip=`ip_to_hex 192 168 $i$j $k` # Source IP
1818 rip=`ip_to_hex 192 168 $i$j 254` # Router IP
1819 rmac=00000000ff$i$j # Router MAC
1820 otherip=`ip_to_hex 192 168 $i$j 55` # Some other IP in subnet
1821 test_arp $i$j$k $smac $sip $rip $rmac #4
1822 test_arp $i$j$k $smac $otherip $rip $rmac #5
1823 test_arp $i$j$k $smac 0a123456 $rip $rmac #6
1824 test_arp $i$j$k $smac $sip $otherip #7
0bac7164 1825 done
269ecccc 1826 done
0bac7164
BP
1827done
1828
1829# Allow some time for packet forwarding.
1830# XXX This can be improved.
1831sleep 1
1832
1833# 8. Generate an ARP reply for each of the IP addresses ARPed for
1834# earlier as #3.
1835#
1836# Here, the $s is the VIF that originated the ARP request and $d is
1837# the VIF that sends the ARP reply, which is somewhat backward but
1838# it means that $s and $d are the same as #3.
1839: > mac_bindings.expected
1840for is in 1 2 3; do
269ecccc
JP
1841 for js in 1 2 3; do
1842 for ks in 1 2 3; do
1843 s=$is$js$ks
1844 for id in 1 2 3; do
1845 for jd in 1 2 3; do
1846 if test $is$js = $id$jd; then
1847 continue
1848 fi
1849
1850 kd=1
1851 d=$id$jd$kd
1852
1853 o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10`
1854 host_ip=`ip_to_hex 192 168 $id$jd $o4`
1855 host_mac=8000000000$o4
1856
1857 lrmac=00000000ff$id$jd
1858 lrip=`ip_to_hex 192 168 $id$jd 254`
1859
1860 arp=${lrmac}${host_mac}08060001080006040002${host_mac}${host_ip}${lrmac}${lrip}
1861
1862 echo
1863 echo
1864 echo
1865 hv=hv`vif_to_hv $d`
1866 as $hv ovs-appctl netdev-dummy/receive vif$d $arp
1867 #as $hv ovs-appctl ofproto/trace br-int in_port=$d $arp
1868 #as $hv ovs-ofctl dump-flows br-int table=19
1869
1870 host_ip_pretty=192.168.$id$jd.$o4
1871 host_mac_pretty=80:00:00:00:00:$o4
1872 echo lrp$id$jd,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected
86e98048 1873 done
269ecccc 1874 done
9975d7be 1875 done
269ecccc 1876 done
9975d7be 1877done
0bac7164 1878
9975d7be
BP
1879# Allow some time for packet forwarding.
1880# XXX This can be improved.
1881sleep 1
1882
0bac7164
BP
1883# 9. Send an IP packet from every logical port to every other subnet. These
1884# are the same packets already sent as #3, but now the destinations' IP-MAC
1885# bindings have been discovered via ARP, so instead of provoking an ARP
1886# request, these packets now get routed to their destinations (which don't
1887# have static MAC bindings, so they go to the port we've designated as
1888# accepting "unknown" MACs.)
1889for is in 1 2 3; do
269ecccc
JP
1890 for js in 1 2 3; do
1891 for ks in 1 2 3; do
1892 s=$is$js$ks
1893 smac=f00000000$s
1894 sip=`ip_to_hex 192 168 $is$js $ks`
1895 for id in 1 2 3; do
1896 for jd in 1 2 3; do
1897 if test $is$js = $id$jd; then
1898 continue
1899 fi
1900
1901 # Send the packet.
1902 dmac=00000000ff$is$js
1903 # Calculate a 4th octet for the destination that is
1904 # unique per $s, avoids the .1 .2 .3 and .254 IP addresses
1905 # that have static MAC bindings, and fits in the range
1906 # 0-255.
1907 o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10`
1908 dip=`ip_to_hex 192 168 $id$jd $o4`
1909 test_ip $s $smac $dmac $sip $dip
1910
1911 # Expect the packet egress.
1912 host_mac=8000000000$o4
1913 outport=${id}11
1914 out_lrp=$id$jd
e4543cfe 1915 echo ${host_mac}00000000ff${out_lrp}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 >> $outport.expected
0bac7164 1916 done
269ecccc 1917 done
0bac7164 1918 done
269ecccc 1919 done
0bac7164
BP
1920done
1921
0bac7164
BP
1922ovn-sbctl -f csv -d bare --no-heading \
1923 -- --columns=logical_port,ip,mac list mac_binding > mac_bindings
1924
9975d7be
BP
1925# Now check the packets actually received against the ones expected.
1926for i in 1 2 3; do
1927 for j in 1 2 3; do
86e98048 1928 for k in 1 2 3; do
49d7c759
BP
1929 OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap],
1930 [$i$j$k.expected])
86e98048 1931 done
9975d7be
BP
1932 done
1933done
fcde56f5 1934
0bac7164
BP
1935# Check the MAC bindings against those expected.
1936AT_CHECK_UNQUOTED([sort < mac_bindings], [0], [`sort < mac_bindings.expected`
1937])
1938
fcde56f5 1939# Gracefully terminate daemons
7a8f15e0 1940OVN_CLEANUP([hv1], [hv2], [hv3])
eff49a56 1941
9975d7be 1942AT_CLEANUP
685f4dfe
NS
1943
1944# 3 hypervisors, one logical switch, 3 logical ports per hypervisor
1945AT_SETUP([ovn -- portsecurity : 3 HVs, 1 LS, 3 lports/HV])
1946AT_KEYWORDS([portsecurity])
1947AT_SKIP_IF([test $HAVE_PYTHON = no])
1948ovn_start
1949
1950# Create hypervisors hv[123].
1951# Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3.
1952# Add all of the vifs to a single logical switch lsw0.
1953# Turn off port security on vifs vif[123]1
1954# Turn on l2 port security on vifs vif[123]2
1955# Turn of l2 and l3 port security on vifs vif[123]3
1956# Make vif13, vif2[23], vif3[123] destinations for unknown MACs.
ea46a4e9 1957ovn-nbctl ls-add lsw0
685f4dfe
NS
1958net_add n1
1959for i in 1 2 3; do
1960 sim_add hv$i
1961 as hv$i
1962 ovs-vsctl add-br br-phys
1963 ovn_attach n1 br-phys 192.168.0.$i
1964
1965 for j in 1 2 3; do
1966 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
31ed1192 1967 ovn-nbctl lsp-add lsw0 lp$i$j
685f4dfe 1968 if test $j = 1; then
31ed1192 1969 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown
685f4dfe 1970 elif test $j = 2; then
31ed1192
JP
1971 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j"
1972 ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j
685f4dfe
NS
1973 else
1974 extra_addr="f0:00:00:00:0$i:$i$j fe80::ea2a:eaff:fe28:$i$j"
31ed1192
JP
1975 ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr"
1976 ovn-nbctl lsp-set-port-security lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr"
685f4dfe
NS
1977 fi
1978 done
1979done
1980
685f4dfe
NS
1981# Pre-populate the hypervisors' ARP tables so that we don't lose any
1982# packets for ARP resolution (native tunneling doesn't queue packets
1983# for ARP resolution).
1984ovn_populate_arp
1985
1986# Allow some time for ovn-northd and ovn-controller to catch up.
1987# XXX This should be more systematic.
1988sleep 1
685f4dfe
NS
1989
1990# Given the name of a logical port, prints the name of the hypervisor
1991# on which it is located.
1992vif_to_hv() {
1993 echo hv${1%?}
1994}
1995
685f4dfe
NS
1996for i in 1 2 3; do
1997 for j in 1 2 3; do
1998 : > $i$j.expected
1999 done
2000done
2001
2002# test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT...
2003#
2004# This shell function causes an ip packet to be received on INPORT.
2005# The packet's content has Ethernet destination DST and source SRC
2006# (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits).
2007# The OUTPORTs (zero or more) list the VIFs on which the packet should
31ed1192
JP
2008# be received. INPORT and the OUTPORTs are specified as logical switch
2009# port numbers, e.g. 11 for vif11.
685f4dfe
NS
2010test_ip() {
2011 # This packet has bad checksums but logical L3 routing doesn't check.
2012 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
efe179e0 2013 local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
685f4dfe
NS
2014 shift; shift; shift; shift; shift
2015 hv=`vif_to_hv $inport`
2016 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
2017 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
2018 for outport; do
e4543cfe 2019 echo $packet >> $outport.expected
685f4dfe
NS
2020 done
2021}
2022
2023# test_arp INPORT SHA SPA TPA DROP [REPLY_HA]
2024#
2025# Causes a packet to be received on INPORT. The packet is an ARP
2026# request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then
2027# it should be the hardware address of the target to expect to receive in an
2028# ARP reply; otherwise no reply is expected.
2029#
31ed1192 2030# INPORT is an logical switch port number, e.g. 11 for vif11.
685f4dfe
NS
2031# SHA and REPLY_HA are each 12 hex digits.
2032# SPA and TPA are each 8 hex digits.
2033test_arp() {
2034 local inport=$1 smac=$2 sha=$3 spa=$4 tpa=$5 drop=$6 reply_ha=$7
2035 local request=ffffffffffff${smac}08060001080006040001${sha}${spa}ffffffffffff${tpa}
2036 hv=`vif_to_hv $inport`
2037 as $hv ovs-appctl netdev-dummy/receive vif$inport $request
2038 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request
2039 if test $drop != 1; then
e137131a 2040 if test X$reply_ha = X; then
685f4dfe
NS
2041 # Expect to receive the broadcast ARP on the other logical switch ports
2042 # if no reply is expected.
2043 local i j
2044 for i in 1 2 3; do
2045 for j in 1 2 3; do
2046 if test $i$j != $inport; then
2047 echo $request >> $i$j.expected
2048 fi
2049 done
2050 done
2051 else
2052 # Expect to receive the reply, if any.
2053 local reply=${smac}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa}
2054 echo $reply >> $inport.expected
2055 fi
2056 fi
2057}
2058
2059# test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT...
2060# This function is similar to test_ip() except that it sends
2061# ipv6 packet
2062test_ipv6() {
2063 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5
2064 local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}0000000000000000
2065 shift; shift; shift; shift; shift
2066 hv=`vif_to_hv $inport`
2067 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
2068 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
2069 for outport; do
e4543cfe 2070 echo $packet >> $outport.expected
685f4dfe
NS
2071 done
2072}
2073
9e687b23
DL
2074# test_icmpv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT...
2075# This function is similar to test_ipv6() except it specifies the ICMPv6 type
2076# of the test packet
2077test_icmpv6() {
2078 local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6
2079 local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}${icmp_type}00000000000000
2080 shift; shift; shift; shift; shift; shift
2081 hv=`vif_to_hv $inport`
2082 as $hv ovs-appctl netdev-dummy/receive vif$inport $packet
2083 #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet
2084 for outport; do
e4543cfe 2085 echo $packet >> $outport.expected
9e687b23
DL
2086 done
2087}
2088
685f4dfe
NS
2089ip_to_hex() {
2090 printf "%02x%02x%02x%02x" "$@"
2091}
2092
2093# no port security
2094sip=`ip_to_hex 192 168 0 12`
2095tip=`ip_to_hex 192 168 0 13`
2096# the arp packet should be allowed even if lp[123]1 is
2097# not configured with mac f00000000023 and ip 192.168.0.12
2098for i in 1 2 3; do
2099 test_arp ${i}1 f00000000023 f00000000023 $sip $tip 0 f00000000013
2100 for j in 1 2 3; do
2101 if test $i != $j; then
2102 test_ip ${i}1 f000000000${i}1 f000000000${j}1 $sip $tip ${j}1
2103 fi
2104 done
2105done
2106
2107# l2 port security
2108sip=`ip_to_hex 192 168 0 12`
2109tip=`ip_to_hex 192 168 0 13`
2110
2111# arp packet should be allowed since lp22 is configured with
2112# mac f00000000022
2113test_arp 22 f00000000022 f00000000022 $sip $tip 0 f00000000013
2114
2115# arp packet should not be allowed since lp32 is not configured with
2116# mac f00000000021
2117test_arp 32 f00000000021 f00000000021 $sip $tip 1
2118
2119# arp packet with sha set to f00000000021 should not be allowed
2120# for lp12
2121test_arp 12 f00000000012 f00000000021 $sip $tip 1
2122
2123# ip packets should be allowed and received since lp[123]2 do not
2124# have l3 port security
2125sip=`ip_to_hex 192 168 0 55`
2126tip=`ip_to_hex 192 168 0 66`
2127for i in 1 2 3; do
2128 for j in 1 2 3; do
2129 if test $i != $j; then
2130 test_ip ${i}2 f000000000${i}2 f000000000${j}2 $sip $tip ${j}2
2131 fi
2132 done
2133done
2134
2135# ipv6 packets should be received by lp[123]2
2136# lp[123]1 can send ipv6 traffic as there is no port security
2137sip=fe800000000000000000000000000000
2138tip=ff020000000000000000000000000000
2139
2140for i in 1 2 3; do
2141 test_ipv6 ${i}1 f000000000${i}1 f000000000${i}2 $sip $tip ${i}2
2142done
2143
2144
2145# l2 and l3 port security
2146sip=`ip_to_hex 192 168 0 13`
2147tip=`ip_to_hex 192 168 0 22`
2148# arp packet should be allowed since lp13 is configured with
2149# f00000000013 and 192.168.0.13
2150test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022
2151
2152# the arp packet should be dropped because lp23 is not configured
2153# with mac f00000000022
2154sip=`ip_to_hex 192 168 0 13`
2155tip=`ip_to_hex 192 168 0 22`
2156test_arp 23 f00000000022 f00000000022 $sip $tip 1
2157
2158# the arp packet should be dropped because lp33 is not configured
2159# with ip 192.168.0.55
2160spa=`ip_to_hex 192 168 0 55`
2161tpa=`ip_to_hex 192 168 0 22`
2162test_arp 33 f00000000031 f00000000031 $spa $tpa 1
2163
2164# ip packets should not be received by lp[123]3 since
2165# l3 port security is enabled
2166sip=`ip_to_hex 192 168 0 55`
2167tip=`ip_to_hex 192 168 0 66`
2168for i in 1 2 3; do
2169 for j in 1 2 3; do
2170 test_ip ${i}2 f000000000${i}2 f000000000${j}3 $sip $tip
2171 done
2172done
2173
2174# ipv6 packets should be dropped for lp[123]3 since
2175# it is configured with only ipv4 address
2176sip=fe800000000000000000000000000000
2177tip=ff020000000000000000000000000000
2178
2179for i in 1 2 3; do
2180 test_ipv6 ${i}3 f000000000${i}3 f00000000022 $sip $tip
2181done
2182
2183# ipv6 packets should not be received by lp[123]3 with mac f000000000$[123]3
2184# lp[123]1 can send ipv6 traffic as there is no port security
2185for i in 1 2 3; do
2186 test_ipv6 ${i}1 f000000000${i}1 f000000000${i}3 $sip $tip
2187done
2188
2189# lp13 has extra port security with mac f0000000113 and ipv6 addr
2190# fe80::ea2a:eaff:fe28:0012
2191
2192# ipv4 packet should be dropped for lp13 with mac f0000000113
2193sip=`ip_to_hex 192 168 0 13`
2194tip=`ip_to_hex 192 168 0 23`
2195test_ip 13 f00000000113 f00000000023 $sip $tip
2196
2197# ipv6 packet should be received by lp[123]3 with mac f0000000{i}{i}3
2198# and ip6.dst as fe80::ea2a:eaff:fe28:0{i}{i}3.
2199# lp11 can send ipv6 traffic as there is no port security
2200sip=ee800000000000000000000000000000
2201for i in 1 2 3; do
2202 tip=fe80000000000000ea2aeafffe2800{i}3
2203 test_ipv6 11 f00000000011 f000000000{i}${i}3 $sip $tip {i}3
2204done
2205
2206
2207# ipv6 packet should not be received by lp33 with mac f0000000333
2208# and ip6.dst as fe80::ea2a:eaff:fe28:0023 as it is
2209# configured with fe80::ea2a:eaff:fe28:0033
2210# lp11 can send ipv6 traffic as there is no port security
2211
2212sip=ee800000000000000000000000000000
2213tip=fe80000000000000ea2aeafffe280023
2214test_ipv6 11 f00000000011 f00000000333 $sip $tip
2215
2216# ipv6 packet should be allowed for lp[123]3 with mac f0000000{i}{i}3
2217# and ip6.src fe80::ea2a:eaff:fe28:0{i}{i}3 and ip6.src ::.
2218# and should be dropped for any other ip6.src
2219# lp21 can receive ipv6 traffic as there is no port security
2220
2221tip=ee800000000000000000000000000000
2222for i in 1 2 3; do
2223 sip=fe80000000000000ea2aeafffe2800${i}3
2224 test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 21
2225
9e687b23 2226 # Test ICMPv6 MLD reports (v1 and v2) and NS for DAD
685f4dfe 2227 sip=00000000000000000000000000000000
9e687b23
DL
2228 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 83 21
2229 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 8f 21
2230 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff0200000000000000ea2aeafffe2800 87 21
2231 # Traffic to non-multicast traffic should be dropped
2232 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 83
2233 # Traffic of other ICMPv6 types should be dropped
2234 test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 80
685f4dfe
NS
2235
2236 # should be dropped
2237 sip=ae80000000000000ea2aeafffe2800aa
2238 test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip
2239done
2240
31ed1192
JP
2241# configure lsp13 to send and received IPv4 packets with an address range
2242ovn-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"
7d9d86ad 2243
8ff5a966
NS
2244sleep 2
2245
7d9d86ad
NS
2246sip=`ip_to_hex 10 0 0 13`
2247tip=`ip_to_hex 192 168 0 22`
31ed1192 2248# arp packet with inner ip 10.0.0.13 should be allowed for lsp13
7d9d86ad
NS
2249test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022
2250
2251sip=`ip_to_hex 10 0 0 14`
2252tip=`ip_to_hex 192 168 0 23`
31ed1192 2253# IPv4 packet from lsp13 with src ip 10.0.0.14 destined to lsp23
7d9d86ad
NS
2254# with dst ip 192.168.0.23 should be allowed
2255test_ip 13 f00000000013 f00000000023 $sip $tip 23
2256
2257sip=`ip_to_hex 192 168 0 33`
2258tip=`ip_to_hex 10 0 0 15`
31ed1192
JP
2259# IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2260# with dst ip 10.0.0.15 should be received by lsp13
7d9d86ad
NS
2261test_ip 33 f00000000033 f00000000013 $sip $tip 13
2262
2263sip=`ip_to_hex 192 168 0 33`
2264tip=`ip_to_hex 20 0 0 4`
31ed1192
JP
2265# IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2266# with dst ip 20.0.0.4 should be received by lsp13
7d9d86ad
NS
2267test_ip 33 f00000000033 f00000000013 $sip $tip 13
2268
2269sip=`ip_to_hex 192 168 0 33`
2270tip=`ip_to_hex 20 0 0 5`
31ed1192
JP
2271# IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2272# with dst ip 20.0.0.5 should not be received by lsp13
7d9d86ad
NS
2273test_ip 33 f00000000033 f00000000013 $sip $tip
2274
2275sip=`ip_to_hex 192 168 0 33`
2276tip=`ip_to_hex 20 0 0 255`
31ed1192
JP
2277# IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2278# with dst ip 20.0.0.255 should be received by lsp13
7d9d86ad
NS
2279test_ip 33 f00000000033 f00000000013 $sip $tip 13
2280
2281sip=`ip_to_hex 192 168 0 33`
2282tip=`ip_to_hex 192 168 0 255`
31ed1192
JP
2283# IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2284# with dst ip 192.168.0.255 should not be received by lsp13
7d9d86ad
NS
2285test_ip 33 f00000000033 f00000000013 $sip $tip
2286
2287sip=`ip_to_hex 192 168 0 33`
2288tip=`ip_to_hex 224 0 0 4`
31ed1192
JP
2289# IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13
2290# with dst ip 224.0.0.4 should be received by lsp13
7d9d86ad 2291test_ip 33 f00000000033 f00000000013 $sip $tip 13
685f4dfe 2292
bb0c41d3
RM
2293#dump information including flow counters
2294ovn-nbctl show
2295ovn-sbctl dump-flows -- list multicast_group
2296
2297echo "------ hv1 dump ------"
2298as hv1 ovs-vsctl show
6195e2e7 2299as hv1 ovs-ofctl -O OpenFlow13 show br-int
bb0c41d3
RM
2300as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
2301
2302echo "------ hv2 dump ------"
2303as hv2 ovs-vsctl show
6195e2e7 2304as hv2 ovs-ofctl -O OpenFlow13 show br-int
bb0c41d3
RM
2305as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int
2306
2307echo "------ hv3 dump ------"
2308as hv3 ovs-vsctl show
6195e2e7 2309as hv3 ovs-ofctl -O OpenFlow13 show br-int
bb0c41d3
RM
2310as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int
2311
685f4dfe
NS
2312# Now check the packets actually received against the ones expected.
2313for i in 1 2 3; do
2314 for j in 1 2 3; do
49d7c759 2315 OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected])
685f4dfe
NS
2316 done
2317done
2318
7a8f15e0 2319OVN_CLEANUP([hv1],[hv2],[hv3])
d9c8c57c 2320
685f4dfe 2321AT_CLEANUP
509afdc3
GS
2322
2323AT_SETUP([ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs])
2324AT_KEYWORDS([ovnpeer])
2325AT_SKIP_IF([test $HAVE_PYTHON = no])
2326ovn_start
2327
2328# Logical network:
2329# Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24
2330# network. R1 has a switchs ls1 (191.168.1.0/24) connected to it.
2331# R2 has ls2 (172.16.1.0/24) connected to it.
2332
fa2a27b2
JP
2333ovn-nbctl lr-add R1
2334ovn-nbctl lr-add R2
509afdc3 2335
ea46a4e9
JP
2336ovn-nbctl ls-add ls1
2337ovn-nbctl ls-add ls2
509afdc3
GS
2338
2339# Connect ls1 to R1
bf44c2cd 2340ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24
509afdc3 2341
31ed1192 2342ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
31114af7 2343 options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
509afdc3
GS
2344
2345# Connect ls2 to R2
bf44c2cd 2346ovn-nbctl lrp-add R2 ls2 00:00:00:01:02:04 172.16.1.1/24
509afdc3 2347
31ed1192 2348ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
31114af7 2349 options:router-port=ls2 addresses=\"00:00:00:01:02:04\"
509afdc3
GS
2350
2351# Connect R1 to R2
4685e523
JP
2352ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1
2353ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2
509afdc3 2354
6d9ecfa9
JP
2355ovn-nbctl lr-route-add R1 "0.0.0.0/0" 20.0.0.2
2356ovn-nbctl lr-route-add R2 "0.0.0.0/0" 20.0.0.1
509afdc3
GS
2357
2358# Create logical port ls1-lp1 in ls1
31ed1192
JP
2359ovn-nbctl lsp-add ls1 ls1-lp1 \
2360-- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
509afdc3
GS
2361
2362# Create logical port ls2-lp1 in ls2
31ed1192
JP
2363ovn-nbctl lsp-add ls2 ls2-lp1 \
2364-- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
509afdc3
GS
2365
2366# Create two hypervisor and create OVS ports corresponding to logical ports.
2367net_add n1
2368
2369sim_add hv1
2370as hv1
2371ovs-vsctl add-br br-phys
2372ovn_attach n1 br-phys 192.168.0.1
2373ovs-vsctl -- add-port br-int hv1-vif1 -- \
2374 set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \
2375 options:tx_pcap=hv1/vif1-tx.pcap \
2376 options:rxq_pcap=hv1/vif1-rx.pcap \
2377 ofport-request=1
2378
2379sim_add hv2
2380as hv2
2381ovs-vsctl add-br br-phys
2382ovn_attach n1 br-phys 192.168.0.2
2383ovs-vsctl -- add-port br-int hv2-vif1 -- \
2384 set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \
2385 options:tx_pcap=hv2/vif1-tx.pcap \
2386 options:rxq_pcap=hv2/vif1-rx.pcap \
2387 ofport-request=1
2388
2389
2390# Pre-populate the hypervisors' ARP tables so that we don't lose any
2391# packets for ARP resolution (native tunneling doesn't queue packets
2392# for ARP resolution).
2393ovn_populate_arp
2394
2395# Allow some time for ovn-northd and ovn-controller to catch up.
2396# XXX This should be more systematic.
2397sleep 1
2398
2399# Send ip packets between the two ports.
2400ip_to_hex() {
2401 printf "%02x%02x%02x%02x" "$@"
2402}
509afdc3
GS
2403
2404# Packet to send.
2405src_mac="f00000010203"
2406dst_mac="000000010203"
2407src_ip=`ip_to_hex 192 168 1 2`
2408dst_ip=`ip_to_hex 172 16 1 2`
2409packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2410as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2411
2412
2413echo "---------NB dump-----"
2414ovn-nbctl show
2415echo "---------------------"
2416ovn-nbctl list logical_router
2417echo "---------------------"
2418ovn-nbctl list logical_router_port
2419echo "---------------------"
2420
2421echo "---------SB dump-----"
2422ovn-sbctl list datapath_binding
2423echo "---------------------"
2424ovn-sbctl list port_binding
2425echo "---------------------"
2426
2427echo "------ hv1 dump ----------"
8dab1022 2428as hv1 ovs-ofctl show br-int
509afdc3
GS
2429as hv1 ovs-ofctl dump-flows br-int
2430echo "------ hv2 dump ----------"
8dab1022 2431as hv2 ovs-ofctl show br-int
509afdc3
GS
2432as hv2 ovs-ofctl dump-flows br-int
2433
2434# Packet to Expect
2435src_mac="000000010204"
2436dst_mac="f00000010204"
49d7c759 2437echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected
509afdc3 2438
49d7c759 2439OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
509afdc3 2440
7a8f15e0 2441OVN_CLEANUP([hv1],[hv2])
509afdc3
GS
2442
2443AT_CLEANUP
5412db30
J
2444
2445
4685e523
JP
2446AT_SETUP([ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR])
2447AT_KEYWORDS([router-admin-state])
2448AT_SKIP_IF([test $HAVE_PYTHON = no])
2449ovn_start
2450
2451# Logical network:
2452# One LR - R1 has switch ls1 with two subnets attached to it (191.168.1.0/24
2453# and 172.16.1.0/24) connected to it.
2454
2455ovn-nbctl lr-add R1
2456
2457ovn-nbctl ls-add ls1
2458
2459# Connect ls1 to R1
bf44c2cd 2460ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 172.16.1.1/24
4685e523
JP
2461ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
2462 options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
2463
2464# Create logical port ls1-lp1 in ls1
2465ovn-nbctl lsp-add ls1 ls1-lp1 \
2466 -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
2467
2468# Create logical port ls1-lp2 in ls1
2469ovn-nbctl lsp-add ls1 ls1-lp2 \
2470 -- lsp-set-addresses ls1-lp2 "f0:00:00:01:02:04 172.16.1.2"
2471
2472# Create one hypervisor and create OVS ports corresponding to logical ports.
2473net_add n1
2474
2475sim_add hv1
2476as hv1
2477ovs-vsctl add-br br-phys
2478ovn_attach n1 br-phys 192.168.0.1
2479ovs-vsctl -- add-port br-int vif1 -- \
2480 set interface vif1 external-ids:iface-id=ls1-lp1 \
2481 options:tx_pcap=hv1/vif1-tx.pcap \
2482 options:rxq_pcap=hv1/vif1-rx.pcap \
2483 ofport-request=1
2484
2485ovs-vsctl -- add-port br-int vif2 -- \
2486 set interface vif2 external-ids:iface-id=ls1-lp2 \
2487 options:tx_pcap=hv1/vif2-tx.pcap \
2488 options:rxq_pcap=hv1/vif2-rx.pcap \
2489 ofport-request=1
2490
2491
2492# Allow some time for ovn-northd and ovn-controller to catch up.
2493# XXX This should be more systematic.
2494sleep 1
2495
2496# Send ip packets between the two ports.
2497ip_to_hex() {
2498 printf "%02x%02x%02x%02x" "$@"
2499}
4685e523
JP
2500
2501# Packet to send.
2502src_mac="f00000010203"
2503dst_mac="000000010203"
2504src_ip=`ip_to_hex 192 168 1 2`
2505dst_ip=`ip_to_hex 172 16 1 2`
2506packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2507as hv1 ovs-appctl netdev-dummy/receive vif1 $packet
2508
2509
2510echo "---------NB dump-----"
2511ovn-nbctl show
2512echo "---------------------"
2513ovn-nbctl list logical_router
2514echo "---------------------"
2515ovn-nbctl list logical_router_port
2516echo "---------------------"
2517
2518echo "---------SB dump-----"
2519ovn-sbctl list datapath_binding
2520echo "---------------------"
2521ovn-sbctl list logical_flow
2522echo "---------------------"
2523
2524echo "------ hv1 dump ----------"
2525as hv1 ovs-ofctl dump-flows br-int
2526
2527
2528#Disable router R1
2529ovn-nbctl set Logical_Router R1 enabled=false
2530
3b8cd0ea
BP
2531# Allow some time for ovn-northd and ovn-controller to catch up.
2532# XXX This should be more systematic.
2533sleep 1
2534
4685e523
JP
2535echo "---------SB dump-----"
2536ovn-sbctl list datapath_binding
2537echo "---------------------"
2538ovn-sbctl list logical_flow
2539echo "---------------------"
2540
2541echo "------ hv1 dump ----------"
2542as hv1 ovs-ofctl dump-flows br-int
2543
2544as hv1 ovs-appctl netdev-dummy/receive vif1 $packet
2545
2546# Packet to Expect
2547expect_src_mac="000000010203"
2548expect_dst_mac="f00000010204"
49d7c759 2549echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected
4685e523 2550
49d7c759 2551OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected])
4685e523
JP
2552
2553
2554as hv1
2555OVS_APP_EXIT_AND_WAIT([ovn-controller])
2556OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
2557OVS_APP_EXIT_AND_WAIT([ovsdb-server])
2558
2559as ovn-sb
2560OVS_APP_EXIT_AND_WAIT([ovsdb-server])
2561
2562as ovn-nb
2563OVS_APP_EXIT_AND_WAIT([ovsdb-server])
2564
2565as northd
2566OVS_APP_EXIT_AND_WAIT([ovn-northd])
2567
2568as main
2569OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
2570OVS_APP_EXIT_AND_WAIT([ovsdb-server])
2571
2572AT_CLEANUP
2573
2574
2575AT_SETUP([ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR])
5412db30
J
2576AT_KEYWORDS([router-admin-state])
2577AT_SKIP_IF([test $HAVE_PYTHON = no])
2578ovn_start
2579
2580# Logical network:
2581# One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
2582# and has switch ls2 (172.16.1.0/24) connected to it.
2583
fa2a27b2 2584ovn-nbctl lr-add R1
5412db30 2585
ea46a4e9
JP
2586ovn-nbctl ls-add ls1
2587ovn-nbctl ls-add ls2
5412db30
J
2588
2589# Connect ls1 to R1
bf44c2cd 2590ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24
31ed1192 2591ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
31114af7 2592 options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
5412db30
J
2593
2594# Connect ls2 to R1
bf44c2cd 2595ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24
31ed1192 2596ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
31114af7 2597 options:router-port=ls2 addresses=\"00:00:00:01:02:04\"
5412db30
J
2598
2599# Create logical port ls1-lp1 in ls1
31ed1192
JP
2600ovn-nbctl lsp-add ls1 ls1-lp1 \
2601-- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
5412db30
J
2602
2603# Create logical port ls2-lp1 in ls2
31ed1192
JP
2604ovn-nbctl lsp-add ls2 ls2-lp1 \
2605-- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
5412db30
J
2606
2607# Create one hypervisor and create OVS ports corresponding to logical ports.
2608net_add n1
2609
2610sim_add hv1
2611as hv1
2612ovs-vsctl add-br br-phys
2613ovn_attach n1 br-phys 192.168.0.1
2614ovs-vsctl -- add-port br-int vif1 -- \
2615 set interface vif1 external-ids:iface-id=ls1-lp1 \
2616 options:tx_pcap=hv1/vif1-tx.pcap \
2617 options:rxq_pcap=hv1/vif1-rx.pcap \
2618 ofport-request=1
2619
2620ovs-vsctl -- add-port br-int vif2 -- \
2621 set interface vif2 external-ids:iface-id=ls2-lp1 \
2622 options:tx_pcap=hv1/vif2-tx.pcap \
2623 options:rxq_pcap=hv1/vif2-rx.pcap \
2624 ofport-request=1
2625
2626
2627# Allow some time for ovn-northd and ovn-controller to catch up.
2628# XXX This should be more systematic.
2629sleep 1
2630
2631# Send ip packets between the two ports.
2632ip_to_hex() {
2633 printf "%02x%02x%02x%02x" "$@"
2634}
5412db30
J
2635
2636# Packet to send.
2637src_mac="f00000010203"
2638dst_mac="000000010203"
2639src_ip=`ip_to_hex 192 168 1 2`
2640dst_ip=`ip_to_hex 172 16 1 2`
2641packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2642as hv1 ovs-appctl netdev-dummy/receive vif1 $packet
2643
2644
2645echo "---------NB dump-----"
2646ovn-nbctl show
2647echo "---------------------"
2648ovn-nbctl list logical_router
2649echo "---------------------"
2650ovn-nbctl list logical_router_port
2651echo "---------------------"
2652
2653echo "---------SB dump-----"
2654ovn-sbctl list datapath_binding
2655echo "---------------------"
2656ovn-sbctl list logical_flow
2657echo "---------------------"
2658
2659echo "------ hv1 dump ----------"
2660as hv1 ovs-ofctl dump-flows br-int
2661
5412db30
J
2662#Disable router R1
2663ovn-nbctl set Logical_Router R1 enabled=false
2664
2665echo "---------SB dump-----"
2666ovn-sbctl list datapath_binding
2667echo "---------------------"
2668ovn-sbctl list logical_flow
2669echo "---------------------"
2670
2671echo "------ hv1 dump ----------"
2672as hv1 ovs-ofctl dump-flows br-int
2673
a1361a6e
LR
2674# Allow some time for the disabling of logical router R1 to propagate.
2675# XXX This should be more systematic.
2676sleep 1
2677
5412db30
J
2678as hv1 ovs-appctl netdev-dummy/receive vif1 $packet
2679
2680# Packet to Expect
2681expect_src_mac="000000010204"
2682expect_dst_mac="f00000010204"
49d7c759 2683echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected
5412db30 2684
49d7c759 2685OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected])
5412db30 2686
7a8f15e0 2687OVN_CLEANUP([hv1])
5412db30
J
2688
2689AT_CLEANUP
2690
28dc3fe9
SR
2691AT_SETUP([ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes])
2692AT_KEYWORDS([ovnstaticroutespeer])
2693AT_SKIP_IF([test $HAVE_PYTHON = no])
2694ovn_start
2695
2696# Logical network:
2697# Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24
2698# network. R1 has switchess foo (192.168.1.0/24)
2699# connected to it.
2700# R2 has alice (172.16.1.0/24) and bob (172.16.2.0/24) connected to it.
2701
fa2a27b2
JP
2702ovn-nbctl lr-add R1
2703ovn-nbctl lr-add R2
28dc3fe9 2704
ea46a4e9
JP
2705ovn-nbctl ls-add foo
2706ovn-nbctl ls-add alice
2707ovn-nbctl ls-add bob
28dc3fe9
SR
2708
2709# Connect foo to R1
bf44c2cd 2710ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24
31ed1192 2711ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \
31114af7 2712 options:router-port=foo addresses=\"00:00:00:01:02:03\"
28dc3fe9
SR
2713
2714# Connect alice to R2
bf44c2cd 2715ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24
31ed1192 2716ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \
80f408f4 2717 type=router options:router-port=alice addresses=\"00:00:00:01:02:04\"
28dc3fe9
SR
2718
2719# Connect bob to R2
bf44c2cd 2720ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24
31ed1192 2721ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob type=router \
31114af7 2722 options:router-port=bob addresses=\"00:00:00:01:02:05\"
28dc3fe9
SR
2723
2724# Connect R1 to R2
4685e523
JP
2725ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1
2726ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2
28dc3fe9
SR
2727
2728#install static routes
e48ccf3c
JP
2729ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2
2730ovn-nbctl lr-route-add R2 172.16.2.0/24 20.0.0.2 R1_R2
2731ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1
28dc3fe9
SR
2732
2733# Create logical port foo1 in foo
31ed1192
JP
2734ovn-nbctl lsp-add foo foo1 \
2735-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
28dc3fe9
SR
2736
2737# Create logical port alice1 in alice
31ed1192
JP
2738ovn-nbctl lsp-add alice alice1 \
2739-- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2"
28dc3fe9
SR
2740
2741# Create logical port bob1 in bob
31ed1192
JP
2742ovn-nbctl lsp-add bob bob1 \
2743-- lsp-set-addresses bob1 "f0:00:00:01:02:05 172.16.2.2"
28dc3fe9
SR
2744
2745# Create two hypervisor and create OVS ports corresponding to logical ports.
2746net_add n1
2747
2748sim_add hv1
2749as hv1
2750ovs-vsctl add-br br-phys
2751ovn_attach n1 br-phys 192.168.0.1
2752ovs-vsctl -- add-port br-int hv1-vif1 -- \
2753 set interface hv1-vif1 external-ids:iface-id=foo1 \
2754 options:tx_pcap=hv1/vif1-tx.pcap \
2755 options:rxq_pcap=hv1/vif1-rx.pcap \
2756 ofport-request=1
2757
2758ovs-vsctl -- add-port br-int hv1-vif2 -- \
2759 set interface hv1-vif2 external-ids:iface-id=alice1 \
2760 options:tx_pcap=hv1/vif2-tx.pcap \
2761 options:rxq_pcap=hv1/vif2-rx.pcap \
2762 ofport-request=2
2763
2764sim_add hv2
2765as hv2
2766ovs-vsctl add-br br-phys
2767ovn_attach n1 br-phys 192.168.0.2
2768ovs-vsctl -- add-port br-int hv2-vif1 -- \
2769 set interface hv2-vif1 external-ids:iface-id=bob1 \
2770 options:tx_pcap=hv2/vif1-tx.pcap \
2771 options:rxq_pcap=hv2/vif1-rx.pcap \
2772 ofport-request=1
2773
2774
2775# Pre-populate the hypervisors' ARP tables so that we don't lose any
2776# packets for ARP resolution (native tunneling doesn't queue packets
2777# for ARP resolution).
2778ovn_populate_arp
2779
2780# Allow some time for ovn-northd and ovn-controller to catch up.
2781# XXX This should be more systematic.
2782sleep 1
2783
2784ip_to_hex() {
2785 printf "%02x%02x%02x%02x" "$@"
2786}
28dc3fe9
SR
2787
2788# Send ip packets between foo1 and alice1
2789src_mac="f00000010203"
2790dst_mac="000000010203"
2791src_ip=`ip_to_hex 192 168 1 2`
2792dst_ip=`ip_to_hex 172 16 1 2`
2793packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2794as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2795
2796# Send ip packets between foo1 and bob1
2797src_mac="f00000010203"
2798dst_mac="000000010203"
2799src_ip=`ip_to_hex 192 168 1 2`
2800dst_ip=`ip_to_hex 172 16 2 2`
2801packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
2802as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
2803
2804echo "---------NB dump-----"
2805ovn-nbctl show
2806echo "---------------------"
2807ovn-nbctl list logical_router
2808echo "---------------------"
2809ovn-nbctl list logical_router_port
2810echo "---------------------"
2811
2812echo "---------SB dump-----"
2813ovn-sbctl list datapath_binding
2814echo "---------------------"
2815ovn-sbctl list port_binding
2816echo "---------------------"
2817
2818echo "------ hv1 dump ----------"
2819as hv1 ovs-ofctl dump-flows br-int
2820echo "------ hv2 dump ----------"
2821as hv2 ovs-ofctl dump-flows br-int
2822
2823# Packet to Expect at bob1
2824src_mac="000000010205"
2825dst_mac="f00000010205"
2826src_ip=`ip_to_hex 192 168 1 2`
2827dst_ip=`ip_to_hex 172 16 2 2`
49d7c759 2828echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected
28dc3fe9 2829
49d7c759 2830OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
28dc3fe9
SR
2831
2832# Packet to Expect at alice1
2833src_mac="000000010204"
2834dst_mac="f00000010204"
2835src_ip=`ip_to_hex 192 168 1 2`
2836dst_ip=`ip_to_hex 172 16 1 2`
49d7c759 2837echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected
28dc3fe9 2838
49d7c759 2839OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected])
28dc3fe9 2840
7a8f15e0 2841OVN_CLEANUP([hv1],[hv2])
28dc3fe9
SR
2842
2843AT_CLEANUP
5412db30 2844
0ee8aaf6
RR
2845AT_SETUP([ovn -- send gratuitous arp on localnet])
2846AT_KEYWORDS([ovn])
d08dbed7 2847AT_SKIP_IF([test $HAVE_PYTHON = no])
0ee8aaf6 2848ovn_start
ea46a4e9 2849ovn-nbctl ls-add lsw0
0ee8aaf6
RR
2850net_add n1
2851sim_add hv
2852as hv
2853ovs-vsctl \
2854 -- add-br br-phys \
2855 -- add-br br-eth0
2856
2857ovn_attach n1 br-phys 192.168.0.1
2858
2859AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0])
2860AT_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])
2861
2862# Create a vif.
31ed1192
JP
2863AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1])
2864AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.2"])
2865AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"])
0ee8aaf6
RR
2866
2867# Create a localnet port.
31ed1192
JP
2868AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port])
2869AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown])
2870AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet])
2871AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1])
0ee8aaf6
RR
2872
2873AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1])
2874
2875# Wait for packet to be received.
49d7c759
BP
2876echo "fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" > expected
2877OVN_CHECK_PACKETS([hv/snoopvif-tx.pcap], [expected])
0ee8aaf6
RR
2878
2879# Delete the localnet ports.
2880AT_CHECK([ovs-vsctl del-port localvif1])
31ed1192 2881AT_CHECK([ovn-nbctl lsp-del ln_port])
0ee8aaf6 2882
7a8f15e0 2883OVN_CLEANUP([hv])
0ee8aaf6
RR
2884
2885AT_CLEANUP
75cf9d2b
GS
2886
2887AT_SETUP([ovn -- 2 HVs, 3 LRs connected via LS, static routes])
2888AT_KEYWORDS([ovnstaticroutes])
2889AT_SKIP_IF([test $HAVE_PYTHON = no])
2890ovn_start
2891
2892# Logical network:
2893# Three LRs - R1, R2 and R3 that are connected to each other via LS "join"
2894# in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24)
2895# connected to it. R2 has alice (172.16.1.0/24) and R3 has bob (10.32.1.0/24)
2896# connected to it.
2897
fa2a27b2
JP
2898ovn-nbctl lr-add R1
2899ovn-nbctl lr-add R2
2900ovn-nbctl lr-add R3
75cf9d2b 2901
ea46a4e9
JP
2902ovn-nbctl ls-add foo
2903ovn-nbctl ls-add alice
2904ovn-nbctl ls-add bob
2905ovn-nbctl ls-add join
75cf9d2b
GS
2906
2907# Connect foo to R1
31114af7 2908ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
31ed1192 2909ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \
31114af7 2910 options:router-port=foo addresses=\"00:00:01:01:02:03\"
75cf9d2b
GS
2911
2912# Connect alice to R2
31114af7 2913ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
31ed1192 2914ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \
80f408f4 2915 type=router options:router-port=alice addresses=\"00:00:02:01:02:03\"
75cf9d2b
GS
2916
2917# Connect bob to R3
31114af7 2918ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24
31ed1192 2919ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \
80f408f4 2920 type=router options:router-port=bob addresses=\"00:00:03:01:02:03\"
75cf9d2b
GS
2921
2922# Connect R1 to join
31114af7 2923ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24
31ed1192 2924ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \
80f408f4 2925 type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"'
75cf9d2b
GS
2926
2927# Connect R2 to join
31114af7 2928ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
31ed1192 2929ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \
80f408f4 2930 type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"'
75cf9d2b
GS
2931
2932# Connect R3 to join
31114af7 2933ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24
31ed1192 2934ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \
80f408f4 2935 type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"'
75cf9d2b
GS
2936
2937#install static routes
e48ccf3c
JP
2938ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2
2939ovn-nbctl lr-route-add R1 10.32.1.0/24 20.0.0.3
75cf9d2b 2940
e48ccf3c
JP
2941ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1
2942ovn-nbctl lr-route-add R2 10.32.1.0/24 20.0.0.3
75cf9d2b 2943
e48ccf3c
JP
2944ovn-nbctl lr-route-add R3 192.168.1.0/24 20.0.0.1
2945ovn-nbctl lr-route-add R3 172.16.1.0/24 20.0.0.2
75cf9d2b
GS
2946
2947# Create logical port foo1 in foo
31ed1192
JP
2948ovn-nbctl lsp-add foo foo1 \
2949-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
75cf9d2b
GS
2950
2951# Create logical port alice1 in alice
31ed1192
JP
2952ovn-nbctl lsp-add alice alice1 \
2953-- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2"
75cf9d2b
GS
2954
2955# Create logical port bob1 in bob
31ed1192
JP
2956ovn-nbctl lsp-add bob bob1 \
2957-- lsp-set-addresses bob1 "f0:00:00:01:02:05 10.32.1.2"
75cf9d2b
GS
2958
2959# Create two hypervisor and create OVS ports corresponding to logical ports.
2960net_add n1
2961
2962sim_add hv1
2963as hv1
2964ovs-vsctl add-br br-phys
2965ovn_attach n1 br-phys 192.168.0.1
2966ovs-vsctl -- add-port br-int hv1-vif1 -- \
2967 set interface hv1-vif1 external-ids:iface-id=foo1 \
2968 options:tx_pcap=hv1/vif1-tx.pcap \
2969 options:rxq_pcap=hv1/vif1-rx.pcap \
2970 ofport-request=1
2971
2972ovs-vsctl -- add-port br-int hv1-vif2 -- \
2973 set interface hv1-vif2 external-ids:iface-id=alice1 \
2974 options:tx_pcap=hv1/vif2-tx.pcap \
2975 options:rxq_pcap=hv1/vif2-rx.pcap \
2976 ofport-request=2
2977
2978sim_add hv2
2979as hv2
2980ovs-vsctl add-br br-phys
2981ovn_attach n1 br-phys 192.168.0.2
2982ovs-vsctl -- add-port br-int hv2-vif1 -- \
2983 set interface hv2-vif1 external-ids:iface-id=bob1 \
2984 options:tx_pcap=hv2/vif1-tx.pcap \
2985 options:rxq_pcap=hv2/vif1-rx.pcap \
2986 ofport-request=1
2987
2988
2989# Pre-populate the hypervisors' ARP tables so that we don't lose any
2990# packets for ARP resolution (native tunneling doesn't queue packets
2991# for ARP resolution).
2992ovn_populate_arp
2993
2994# Allow some time for ovn-northd and ovn-controller to catch up.
2995# XXX This should be more systematic.
2996sleep 1
2997
2998ip_to_hex() {
2999 printf "%02x%02x%02x%02x" "$@"
3000}
75cf9d2b
GS
3001
3002# Send ip packets between foo1 and alice1
3003src_mac="f00000010203"
3004dst_mac="000001010203"
3005src_ip=`ip_to_hex 192 168 1 2`
3006dst_ip=`ip_to_hex 172 16 1 2`
3007packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
3008as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
3009as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet
3010
3011# Send ip packets between foo1 and bob1
3012src_mac="f00000010203"
3013dst_mac="000001010203"
3014src_ip=`ip_to_hex 192 168 1 2`
3015dst_ip=`ip_to_hex 10 32 1 2`
3016packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
3017as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
3018
3019echo "---------NB dump-----"
3020ovn-nbctl show
3021echo "---------------------"
3022ovn-nbctl list logical_router
3023echo "---------------------"
3024ovn-nbctl list logical_router_port
3025echo "---------------------"
3026
3027echo "---------SB dump-----"
3028ovn-sbctl list datapath_binding
3029echo "---------------------"
3030ovn-sbctl list port_binding
3031echo "---------------------"
3032ovn-sbctl dump-flows
3033echo "---------------------"
3034
3035echo "------ hv1 dump ----------"
3036as hv1 ovs-ofctl show br-int
3037as hv1 ovs-ofctl dump-flows br-int
3038echo "------ hv2 dump ----------"
3039as hv2 ovs-ofctl show br-int
3040as hv2 ovs-ofctl dump-flows br-int
3041echo "----------------------------"
3042
3043# Packet to Expect at bob1
3044src_mac="000003010203"
3045dst_mac="f00000010205"
3046src_ip=`ip_to_hex 192 168 1 2`
3047dst_ip=`ip_to_hex 10 32 1 2`
49d7c759 3048echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected
75cf9d2b 3049
49d7c759 3050OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
75cf9d2b
GS
3051
3052# Packet to Expect at alice1
3053src_mac="000002010203"
3054dst_mac="f00000010204"
3055src_ip=`ip_to_hex 192 168 1 2`
3056dst_ip=`ip_to_hex 172 16 1 2`
49d7c759 3057echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected
75cf9d2b 3058
49d7c759 3059OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected])
75cf9d2b 3060
7a8f15e0 3061OVN_CLEANUP([hv1],[hv2])
75cf9d2b
GS
3062
3063AT_CLEANUP
c1645003 3064
281977f7
NS
3065AT_SETUP([ovn -- dhcpv4 : 1 HV, 2 LS, 2 LSPs/LS])
3066AT_KEYWORDS([dhcpv4])
3067AT_SKIP_IF([test $HAVE_PYTHON = no])
3068ovn_start
3069
3070ovn-nbctl ls-add ls1
3071
3072ovn-nbctl lsp-add ls1 ls1-lp1 \
3073-- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4"
3074
3075ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4"
3076
3077ovn-nbctl lsp-add ls1 ls1-lp2 \
3078-- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4"
3079
3080ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4"
3081
3082ovn-nbctl ls-add ls2
3083ovn-nbctl lsp-add ls2 ls2-lp1 \
3084-- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4"
3085ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4"
3086ovn-nbctl lsp-add ls2 ls2-lp2 \
3087-- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 30.0.0.7"
3088ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 30.0.0.7"
3089
3090ovn-nbctl -- --id=@d1 create DHCP_Options cidr=10.0.0.0/24 \
3091options="\"server_id\"=\"10.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:01\" \
3092\"lease_time\"=\"3600\" \"router\"=\"10.0.0.1\"" \
3093-- add Logical_Switch_Port ls1-lp1 dhcpv4_options @d1 \
3094-- add Logical_Switch_Port ls1-lp2 dhcpv4_options @d1
3095
3096ovn-nbctl -- --id=@d2 create DHCP_Options cidr=30.0.0.0/24 \
3097options="\"server_id\"=\"30.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:02\" \
3098\"lease_time\"=\"3600\"" -- add Logical_Switch_Port ls2-lp2 dhcpv4_options @d2
3099
3100net_add n1
3101sim_add hv1
3102
3103as hv1
3104ovs-vsctl add-br br-phys
3105ovn_attach n1 br-phys 192.168.0.1
3106ovs-vsctl -- add-port br-int hv1-vif1 -- \
3107 set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \
3108 options:tx_pcap=hv1/vif1-tx.pcap \
3109 options:rxq_pcap=hv1/vif1-rx.pcap \
3110 ofport-request=1
3111
3112ovs-vsctl -- add-port br-int hv1-vif2 -- \
3113 set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \
3114 options:tx_pcap=hv1/vif2-tx.pcap \
3115 options:rxq_pcap=hv1/vif2-rx.pcap \
3116 ofport-request=2
3117
3118ovs-vsctl -- add-port br-int hv1-vif3 -- \
3119 set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \
3120 options:tx_pcap=hv1/vif3-tx.pcap \
3121 options:rxq_pcap=hv1/vif3-rx.pcap \
3122 ofport-request=3
3123
3124ovs-vsctl -- add-port br-int hv1-vif4 -- \
3125 set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \
3126 options:tx_pcap=hv1/vif4-tx.pcap \
3127 options:rxq_pcap=hv1/vif4-rx.pcap \
3128 ofport-request=4
3129
3130ovn_populate_arp
3131
3132sleep 2
3133
3134as hv1 ovs-vsctl show
3135
281977f7
NS
3136# This shell function sends a DHCP request packet
3137# test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ...
3138test_dhcp() {
3139 local inport=$1 src_mac=$2 dhcp_type=$3 offer_ip=$4
3140 local request=ffffffffffff${src_mac}080045100110000000008011000000000000ffffffff
3141 # udp header and dhcp header
3142 request+=0044004300fc0000
3143 request+=010106006359aa760000000000000000000000000000000000000000${src_mac}
3144 # client hardware padding
3145 request+=00000000000000000000
3146 # server hostname
3147 request+=0000000000000000000000000000000000000000000000000000000000000000
3148 request+=0000000000000000000000000000000000000000000000000000000000000000
3149 # boot file name
3150 request+=0000000000000000000000000000000000000000000000000000000000000000
3151 request+=0000000000000000000000000000000000000000000000000000000000000000
3152 request+=0000000000000000000000000000000000000000000000000000000000000000
3153 request+=0000000000000000000000000000000000000000000000000000000000000000
3154 # dhcp magic cookie
3155 request+=63825363
3156 # dhcp message type
3157 request+=3501${dhcp_type}ff
3158
3159 if test $offer_ip != 0; then
3160 local srv_mac=$5 srv_ip=$6 expected_dhcp_opts=$7
3161 # total IP length will be the IP length of the request packet
3162 # (which is 272 in our case) + 8 (padding bytes) + (expected_dhcp_opts / 2)
3163 ip_len=`expr 280 + ${#expected_dhcp_opts} / 2`
3164 udp_len=`expr $ip_len - 20`
3165 printf -v ip_len "%x" $ip_len
3166 printf -v udp_len "%x" $udp_len
3167 # $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len
3168 local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip}
3169 # udp header and dhcp header.
3170 # $udp_len var will be in 3 digits. So adding a '0' before $udp_len
3171 reply+=004300440${udp_len}0000020106006359aa760000000000000000
3172 # your ip address
3173 reply+=${offer_ip}
3174 # next server ip address, relay agent ip address, client mac address
3175 reply+=0000000000000000${src_mac}
3176 # client hardware padding
3177 reply+=00000000000000000000
3178 # server hostname
3179 reply+=0000000000000000000000000000000000000000000000000000000000000000
3180 reply+=0000000000000000000000000000000000000000000000000000000000000000
3181 # boot file name
3182 reply+=0000000000000000000000000000000000000000000000000000000000000000
3183 reply+=0000000000000000000000000000000000000000000000000000000000000000
3184 reply+=0000000000000000000000000000000000000000000000000000000000000000
3185 reply+=0000000000000000000000000000000000000000000000000000000000000000
3186 # dhcp magic cookie
3187 reply+=63825363
3188 # dhcp message type
3189 local dhcp_reply_type=02
3190 if test $dhcp_type = 03; then
3191 dhcp_reply_type=05
3192 fi
3193 reply+=3501${dhcp_reply_type}${expected_dhcp_opts}00000000ff00000000
3194 echo $reply >> $inport.expected
3195 else
3196 shift; shift; shift; shift;
3197 for outport; do
e4543cfe 3198 echo $request >> $outport.expected
281977f7
NS
3199 done
3200 fi
3201 as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request
3202}
3203
3204reset_pcap_file() {
3205 local iface=$1
3206 local pcap_file=$2
3207 ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \
3208options:rxq_pcap=dummy-rx.pcap
3209 rm -f ${pcap_file}*.pcap
3210 ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \
3211options:rxq_pcap=${pcap_file}-rx.pcap
3212}
3213
3214ip_to_hex() {
3215 printf "%02x%02x%02x%02x" "$@"
3216}
3217
3218AT_CAPTURE_FILE([ofctl_monitor0.log])
3219as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \
3220--pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log
3221
3222echo "---------NB dump-----"
3223ovn-nbctl show
3224echo "---------------------"
3225echo "---------SB dump-----"
3226ovn-sbctl list datapath_binding
3227echo "---------------------"
3228ovn-sbctl list logical_flow
3229echo "---------------------"
3230
3231echo "---------------------"
3232ovn-sbctl dump-flows
3233echo "---------------------"
3234
3235echo "------ hv1 dump ----------"
3236as hv1 ovs-ofctl dump-flows br-int
3237
3238# Send DHCPDISCOVER.
3239offer_ip=`ip_to_hex 10 0 0 4`
3240server_ip=`ip_to_hex 10 0 0 1`
3241expected_dhcp_opts=0104ffffff0003040a00000136040a000001330400000e10
3242test_dhcp 1 f00000000001 01 $offer_ip ff1000000001 $server_ip $expected_dhcp_opts
3243
3244# NXT_RESUMEs should be 1.
3245OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
3246
3247$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets
3248cat 1.expected | cut -c -48 > expout
3249AT_CHECK([cat 1.packets | cut -c -48], [0], [expout])
3250# Skipping the IPv4 checksum.
3251cat 1.expected | cut -c 53- > expout
3252AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout])
3253
3254# ovs-ofctl also resumes the packets and this causes other ports to receive
3255# the DHCP request packet. So reset the pcap files so that its easier to test.
3256reset_pcap_file hv1-vif1 hv1/vif1
3257reset_pcap_file hv1-vif2 hv1/vif2
3258rm -f 1.expected
3259rm -f 2.expected
3260
3261# Send DHCPREQUEST.
3262offer_ip=`ip_to_hex 10 0 0 6`
3263server_ip=`ip_to_hex 10 0 0 1`
3264expected_dhcp_opts=0104ffffff0003040a00000136040a000001330400000e10
3265test_dhcp 2 f00000000002 03 $offer_ip ff1000000001 $server_ip $expected_dhcp_opts
3266
3267# NXT_RESUMEs should be 2.
3268OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
3269
3270$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets
3271cat 2.expected | cut -c -48 > expout
3272AT_CHECK([cat 2.packets | cut -c -48], [0], [expout])
3273# Skipping the IPv4 checksum.
3274cat 2.expected | cut -c 53- > expout
3275AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout])
3276
3277reset_pcap_file hv1-vif1 hv1/vif1
3278reset_pcap_file hv1-vif2 hv1/vif2
3279rm -f 1.expected
3280rm -f 2.expected
3281
3282# Send Invalid DHCPv4 packet on ls1-lp2. It should be received by ovn-controller
3283# but should be resumed without the reply.
3284# ls1-lp1 (vif1-tx.pcap) should receive the DHCPv4 request packet twice,
3285# one from ovn-controller and the other from "ovs-ofctl resume."
3286offer_ip=0
3287test_dhcp 2 f00000000002 08 $offer_ip 1 1
3288
3289# NXT_RESUMEs should be 3.
3290OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
3291
3292# vif1-tx.pcap should have received the DHCPv4 (invalid) request packet
49d7c759 3293OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected])
281977f7
NS
3294
3295reset_pcap_file hv1-vif1 hv1/vif1
3296reset_pcap_file hv1-vif2 hv1/vif2
3297rm -f 1.expected
3298rm -f 2.expected
3299
3300# Send DHCPv4 packet on ls2-lp1. It doesn't have any DHCPv4 options defined.
3301# ls2-lp2 (vif4-tx.pcap) should receive the DHCPv4 request packet once.
3302
3303test_dhcp 3 f00000000003 01 0 4
3304
3305# Send DHCPv4 packet on ls2-lp2. "router" DHCPv4 option is not defined for
3306# this lport.
3307test_dhcp 4 f00000000004 01 0 3
3308
3309# NXT_RESUMEs should be 3.
3310OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
3311
49d7c759
BP
3312OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected])
3313OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [4.expected])
281977f7
NS
3314
3315as hv1
3316OVS_APP_EXIT_AND_WAIT([ovn-controller])
3317OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
3318OVS_APP_EXIT_AND_WAIT([ovsdb-server])
3319
3320as ovn-sb
3321OVS_APP_EXIT_AND_WAIT([ovsdb-server])
3322
3323as ovn-nb
3324OVS_APP_EXIT_AND_WAIT([ovsdb-server])
3325
3326as northd
3327OVS_APP_EXIT_AND_WAIT([ovn-northd])
3328
3329as main
3330OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
3331OVS_APP_EXIT_AND_WAIT([ovsdb-server])
3332
3333AT_CLEANUP
3334
c1645003
GS
3335AT_SETUP([ovn -- 2 HVs, 2 LRs connected via LS, gateway router])
3336AT_KEYWORDS([ovngatewayrouter])
3337AT_SKIP_IF([test $HAVE_PYTHON = no])
3338ovn_start
3339
3340# Logical network:
3341# Two LRs - R1 and R2 that are connected to each other via LS "join"
3342# in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24)
3343# connected to it. R2 has alice (172.16.1.0/24) connected to it.
3344# R2 is a gateway router.
3345
3346
3347
3348# Create two hypervisor and create OVS ports corresponding to logical ports.
3349net_add n1
3350
3351sim_add hv1
3352as hv1
3353ovs-vsctl add-br br-phys
3354ovn_attach n1 br-phys 192.168.0.1
3355ovs-vsctl -- add-port br-int hv1-vif1 -- \
3356 set interface hv1-vif1 external-ids:iface-id=foo1 \
3357 options:tx_pcap=hv1/vif1-tx.pcap \
3358 options:rxq_pcap=hv1/vif1-rx.pcap \
3359 ofport-request=1
3360
3361
3362sim_add hv2
3363as hv2
3364ovs-vsctl add-br br-phys
3365ovn_attach n1 br-phys 192.168.0.2
3366ovs-vsctl -- add-port br-int hv2-vif1 -- \
3367 set interface hv2-vif1 external-ids:iface-id=alice1 \
3368 options:tx_pcap=hv2/vif1-tx.pcap \
3369 options:rxq_pcap=hv2/vif1-rx.pcap \
3370 ofport-request=1
3371
3372# Pre-populate the hypervisors' ARP tables so that we don't lose any
3373# packets for ARP resolution (native tunneling doesn't queue packets
3374# for ARP resolution).
3375ovn_populate_arp
3376
3377ovn-nbctl create Logical_Router name=R1
3378ovn-nbctl create Logical_Router name=R2 options:chassis="hv2"
3379
ea46a4e9
JP
3380ovn-nbctl ls-add foo
3381ovn-nbctl ls-add alice
3382ovn-nbctl ls-add join
c1645003
GS
3383
3384# Connect foo to R1
31114af7 3385ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
31ed1192 3386ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \
80f408f4 3387 type=router options:router-port=foo addresses=\"00:00:01:01:02:03\"
c1645003
GS
3388
3389# Connect alice to R2
31114af7 3390ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
31ed1192 3391ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \
80f408f4 3392 type=router options:router-port=alice addresses=\"00:00:02:01:02:03\"
c1645003
GS
3393
3394# Connect R1 to join
31114af7 3395ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24
31ed1192 3396ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \
80f408f4 3397 type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"'
c1645003
GS
3398
3399# Connect R2 to join
31114af7 3400ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
31ed1192 3401ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \
80f408f4 3402 type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"'
c1645003
GS
3403
3404
3405#install static routes
3406ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
3407ip_prefix=172.16.1.0/24 nexthop=20.0.0.2 -- add Logical_Router \
3408R1 static_routes @lrt
3409
3410ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
3411ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \
3412R2 static_routes @lrt
3413
3414# Create logical port foo1 in foo
31ed1192
JP
3415ovn-nbctl lsp-add foo foo1 \
3416-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
c1645003
GS
3417
3418# Create logical port alice1 in alice
31ed1192
JP
3419ovn-nbctl lsp-add alice alice1 \
3420-- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2"
c1645003
GS
3421
3422
3423# Allow some time for ovn-northd and ovn-controller to catch up.
3424# XXX This should be more systematic.
3425sleep 2
3426
3427ip_to_hex() {
3428 printf "%02x%02x%02x%02x" "$@"
3429}
c1645003
GS
3430
3431# Send ip packets between foo1 and alice1
3432src_mac="f00000010203"
3433dst_mac="000001010203"
3434src_ip=`ip_to_hex 192 168 1 2`
3435dst_ip=`ip_to_hex 172 16 1 2`
3436packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
3437
3438echo "---------NB dump-----"
3439ovn-nbctl show
3440echo "---------------------"
3441ovn-nbctl list logical_router
3442echo "---------------------"
3443ovn-nbctl list logical_router_port
3444echo "---------------------"
3445
3446echo "---------SB dump-----"
3447ovn-sbctl list datapath_binding
3448echo "---------------------"
3449ovn-sbctl list port_binding
3450echo "---------------------"
3451ovn-sbctl dump-flows
3452echo "---------------------"
3453ovn-sbctl list chassis
3454ovn-sbctl list encap
3455echo "---------------------"
3456
c1645003
GS
3457# Packet to Expect at alice1
3458src_mac="000002010203"
3459dst_mac="f00000010204"
3460src_ip=`ip_to_hex 192 168 1 2`
3461dst_ip=`ip_to_hex 172 16 1 2`
3462expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000
3463
3464
3465as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
3466as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet
3467
ab39371d
RM
3468echo "------ hv1 dump after packet 1 ----------"
3469as hv1 ovs-ofctl show br-int
3470as hv1 ovs-ofctl dump-flows br-int
3471echo "------ hv2 dump after packet 1 ----------"
3472as hv2 ovs-ofctl show br-int
3473as hv2 ovs-ofctl dump-flows br-int
3474echo "----------------------------"
3475
49d7c759
BP
3476echo $expected > expected
3477OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
c1645003 3478
34114cf8
GS
3479# Delete the router and re-create it. Things should work as before.
3480ovn-nbctl lr-del R2
3481ovn-nbctl create Logical_Router name=R2 options:chassis="hv2"
3482# Connect alice to R2
3483ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
3484# Connect R2 to join
3485ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
3486
3487ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
3488ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \
3489R2 static_routes @lrt
3490
3491# Wait for ovn-controller to catch up.
3492sleep 1
3493
3494# Send the packet again.
3495as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
ab39371d
RM
3496
3497echo "------ hv1 dump after packet 2 ----------"
3498as hv1 ovs-ofctl show br-int
3499as hv1 ovs-ofctl dump-flows br-int
3500echo "------ hv2 dump after packet 2 ----------"
3501as hv2 ovs-ofctl show br-int
3502as hv2 ovs-ofctl dump-flows br-int
3503echo "----------------------------"
3504
49d7c759
BP
3505echo $expected >> expected
3506OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
34114cf8 3507
7a8f15e0 3508OVN_CLEANUP([hv1],[hv2])
c1645003
GS
3509
3510AT_CLEANUP
bb3c4568
FF
3511
3512AT_SETUP([ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR])
3513AT_KEYWORDS([router-icmp-reply])
3514AT_SKIP_IF([test $HAVE_PYTHON = no])
3515ovn_start
3516
3517# Logical network:
3518# One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
3519# and has switch ls2 (172.16.1.0/24) connected to it.
3520
fa2a27b2 3521ovn-nbctl lr-add R1
bb3c4568 3522
ea46a4e9
JP
3523ovn-nbctl ls-add ls1
3524ovn-nbctl ls-add ls2
bb3c4568
FF
3525
3526# Connect ls1 to R1
31114af7 3527ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24
31ed1192 3528ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \
80f408f4 3529 type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\"
bb3c4568
FF
3530
3531# Connect ls2 to R1
31114af7 3532ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24
31ed1192 3533ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \
80f408f4 3534 type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\"
bb3c4568
FF
3535
3536# Create logical port ls1-lp1 in ls1
31ed1192
JP
3537ovn-nbctl lsp-add ls1 ls1-lp1 \
3538-- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2"
bb3c4568
FF
3539
3540# Create logical port ls2-lp1 in ls2
31ed1192
JP
3541ovn-nbctl lsp-add ls2 ls2-lp1 \
3542-- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2"
bb3c4568
FF
3543
3544# Create one hypervisor and create OVS ports corresponding to logical ports.
3545net_add n1
3546
3547sim_add hv1
3548as hv1
3549ovs-vsctl add-br br-phys
3550ovn_attach n1 br-phys 192.168.0.1
3551ovs-vsctl -- add-port br-int vif1 -- \
3552 set interface vif1 external-ids:iface-id=ls1-lp1 \
3553 options:tx_pcap=hv1/vif1-tx.pcap \
3554 options:rxq_pcap=hv1/vif1-rx.pcap \
3555 ofport-request=1
3556
3557ovs-vsctl -- add-port br-int vif2 -- \
3558 set interface vif2 external-ids:iface-id=ls2-lp1 \
3559 options:tx_pcap=hv1/vif2-tx.pcap \
3560 options:rxq_pcap=hv1/vif2-rx.pcap \
3561 ofport-request=1
3562
3563
3564# Allow some time for ovn-northd and ovn-controller to catch up.
3565# XXX This should be more systematic.
3566sleep 1
3567
3568
3569ip_to_hex() {
3570 printf "%02x%02x%02x%02x" "$@"
3571}
bb3c4568
FF
3572for i in 1 2; do
3573 : > vif$i.expected
3574done
3575# test_ipv4_icmp_request INPORT ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM ICMP_CHKSUM [EXP_IP_CHKSUM EXP_ICMP_CHKSUM]
3576#
3577# Causes a packet to be received on INPORT. The packet is an ICMPv4
3578# request with ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHSUM and
3579# ICMP_CHKSUM as specified. If EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are
3580# provided, then it should be the ip and icmp checksums of the packet
3581# responded; otherwise, no reply is expected.
3582# In the absence of an ip checksum calculation helpers, this relies
3583# on the caller to provide the checksums for the ip and icmp headers.
3584# XXX This should be more systematic.
3585#
3586# INPORT is an lport number, e.g. 11 for vif11.
3587# ETH_SRC and ETH_DST are each 12 hex digits.
3588# IPV4_SRC and IPV4_DST are each 8 hex digits.
3589# IP_CHSUM and ICMP_CHKSUM are each 4 hex digits.
3590# EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits.
3591test_ipv4_icmp_request() {
3592 local inport=$1 eth_src=$2 eth_dst=$3 ipv4_src=$4 ipv4_dst=$5 ip_chksum=$6 icmp_chksum=$7
3593 local exp_ip_chksum=$8 exp_icmp_chksum=$9
3594 shift; shift; shift; shift; shift; shift; shift
3595 shift; shift
3596
3597 # Use ttl to exercise section 4.2.2.9 of RFC1812
3598 local ip_ttl=01
3599 local icmp_id=5fbf
3600 local icmp_seq=0001
3601 local icmp_data=$(seq 1 56 | xargs printf "%02x")
3602 local icmp_type_code_request=0800
3603 local icmp_payload=${icmp_type_code_request}${icmp_chksum}${icmp_id}${icmp_seq}${icmp_data}
3604 local packet=${eth_dst}${eth_src}08004500005400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${icmp_payload}
3605
3606 as hv1 ovs-appctl netdev-dummy/receive vif$inport $packet
3607 if test X$exp_icmp_chksum != X; then
3608 # Expect to receive the reply, if any. In same port where packet was sent.
3609 # Note: src and dst fields are expected to be reversed.
3610 local icmp_type_code_response=0000
3611 local reply_icmp_ttl=fe
3612 local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_id}${icmp_seq}${icmp_data}
3613 local reply=${eth_src}${eth_dst}08004500005400004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload}
3614 echo $reply >> vif$inport.expected
3615 fi
3616}
3617
3618# Send ping packet to router's ip addresses, from each of the 2 logical ports.
3619rtr_l1_ip=$(ip_to_hex 192 168 1 1)
3620rtr_l2_ip=$(ip_to_hex 172 16 1 1)
3621l1_ip=$(ip_to_hex 192 168 1 2)
3622l2_ip=$(ip_to_hex 172 16 1 2)
3623
3624# Ping router ip address that is on same subnet as the logical port
3625test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l1_ip 0000 8510 02ff 8d10
3626test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l2_ip 0000 8510 02ff 8d10
3627
3628# Ping router ip address that is on the other side of the logical ports
3629test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l2_ip 0000 8510 02ff 8d10
3630test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l1_ip 0000 8510 02ff 8d10
3631
3632echo "---------NB dump-----"
3633ovn-nbctl show
3634echo "---------------------"
3635ovn-nbctl list logical_router
3636echo "---------------------"
3637ovn-nbctl list logical_router_port
3638echo "---------------------"
3639
3640echo "---------SB dump-----"
3641ovn-sbctl list datapath_binding
3642echo "---------------------"
3643ovn-sbctl list logical_flow
3644echo "---------------------"
3645
3646echo "------ hv1 dump ----------"
3647as hv1 ovs-ofctl dump-flows br-int
3648
3649# Now check the packets actually received against the ones expected.
3650for inport in 1 2; do
49d7c759 3651 OVN_CHECK_PACKETS([hv1/vif${inport}-tx.pcap], [vif$inport.expected])
bb3c4568
FF
3652done
3653
7a8f15e0 3654OVN_CLEANUP([hv1])
bb3c4568
FF
3655
3656AT_CLEANUP
94f79fcb
RB
3657
3658# 1 hypervisor, 1 port
3659# make sure that the port state is properly set to up and back down
3660# when created and deleted.
3661AT_SETUP([ovn -- port state up and down])
3662AT_KEYWORDS([ovn])
3663ovn_start
3664
3665ovn-nbctl ls-add ls1
3666ovn-nbctl lsp-add ls1 lp1
3667ovn-nbctl lsp-set-addresses lp1 unknown
3668
3669net_add n1
3670sim_add hv1
3671as hv1 ovs-vsctl add-br br-phys
3672as hv1 ovn_attach n1 br-phys 192.168.0.1
3673
3674as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1
3675OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup])
3676
3677as hv1 ovs-vsctl del-port br-int vif1
3678OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown])
3679
7a8f15e0 3680OVN_CLEANUP([hv1])
94f79fcb 3681
94f79fcb 3682AT_CLEANUP
e75451fe 3683
f8a8db39
JP
3684AT_SETUP([ovn -- nd_na ])
3685AT_KEYWORDS([ovn-nd_na])
e75451fe
ZKL
3686AT_SKIP_IF([test $HAVE_PYTHON = no])
3687ovn_start
3688
3689#TODO: since patch port for IPv6 logical router port is not ready not,
3690# so we are not going to test vifs on different lswitches cases. Try
3691# to update for that once relevant stuff implemented.
3692
3693# In this test cases we create 1 lswitch, it has 2 VIF ports attached
3694# with. NS packet we test, from one VIF for another VIF, will be replied
3695# by local ovn-controller, but not by target VIF.
3696
3697# Create hypervisors and logical switch lsw0.
3698ovn-nbctl ls-add lsw0
3699net_add n1
3700sim_add hv1
3701as hv1
3702ovs-vsctl add-br br-phys
3703ovn_attach n1 br-phys 192.168.0.2
3704
3705# Add vif1 to hv1 and lsw0, turn on l2 port security on vif1.
3706ovs-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
3707ovn-nbctl lsp-add lsw0 lp1
3708ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598"
3709ovn-nbctl lsp-set-port-security lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598"
3710
3711# Add vif2 to hv1 and lsw0, turn on l2 port security on vif2.
3712ovs-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
3713ovn-nbctl lsp-add lsw0 lp2
3714ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae"
3715ovn-nbctl lsp-set-port-security lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae"
3716
3717# Add ACL rule for ICMPv6 on lsw0
3718ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related
3719ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related
3720ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related
3721
3722# Allow some time for ovn-northd and ovn-controller to catch up.
3723# XXX This should be more systematic.
3724sleep 1
3725
3726# Given the name of a logical port, prints the name of the hypervisor
3727# on which it is located.
3728vif_to_hv() {
3729 echo hv1${1%?}
3730}
e75451fe
ZKL
3731for i in 1 2; do
3732 : > $i.expected
3733done
3734
3735# Complete Neighbor Solicitation packet and Neighbor Advertisement packet
3736# vif1 -> NS -> vif2. vif1 <- NA <- ovn-controller.
3737# vif2 will not receive NS packet, since ovn-controller will reply for it.
3738ns_packet=3333ffa1f9aefa163e94059886dd6000000000203afffd81ce49a9480000f8163efffe940598fd81ce49a9480000f8163efffea1f9ae8700e01160000000fd81ce49a9480000f8163efffea1f9ae0101fa163e940598
3739na_packet=fa163e940598fa163ea1f9ae86dd6000000000203afffd81ce49a9480000f8163efffea1f9aefd81ce49a9480000f8163efffe9405988800e9ed60000000fd81ce49a9480000f8163efffea1f9ae0201fa163ea1f9ae
3740
3741as hv1 ovs-appctl netdev-dummy/receive vif1 $ns_packet
e4543cfe 3742echo $na_packet >> 1.expected
e75451fe 3743
e75451fe
ZKL
3744echo "------ hv1 dump ------"
3745as hv1 ovs-vsctl show
3746as hv1 ovs-ofctl -O OpenFlow13 show br-int
3747as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int
3748
3749for i in 1 2; do
49d7c759 3750 OVN_CHECK_PACKETS([hv1/vif$i-tx.pcap], [$i.expected])
e75451fe
ZKL
3751done
3752
7a8f15e0 3753OVN_CLEANUP([hv1])
e75451fe
ZKL
3754
3755AT_CLEANUP
7417d147
RM
3756
3757AT_SETUP([ovn -- address sets modification/removal smoke test])
3758AT_KEYWORDS([ovn-addr])
3759ovn_start
3760
3761net_add n1
3762
3763sim_add hv1
3764as hv1
3765ovs-vsctl add-br br-phys
3766ovn_attach n1 br-phys 192.168.0.1
3767
3768row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"`
3769ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\"
3770ovn-nbctl destroy Address_Set $row
3771
3772sleep 1
3773
3774# A bug previously existed in the address set support code
3775# that caused ovn-controller to crash after an address set
3776# was updated and then removed. This test case ensures
3777# that ovn-controller is at least still running after
3778# creating, updating, and deleting an address set.
3779AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore])
3780
3781OVN_CLEANUP([hv1])
3782
3783AT_CLEANUP
8639f9be
ND
3784
3785AT_SETUP([ovn -- ipam])
3786AT_KEYWORDS([ovnipam])
3787AT_SKIP_IF([test $HAVE_PYTHON = no])
3788ovn_start
3789
3790# Add a port to a switch that does not have a subnet set, then set the
3791# subnet which should result in an address being allocated for the port.
3792ovn-nbctl ls-add sw0
3793ovn-nbctl lsp-add sw0 p0 -- lsp-set-addresses p0 dynamic
3794ovn-nbctl add Logical-Switch sw0 other_config subnet=192.168.1.0/24
3795AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0],
3796 ["0a:00:00:00:00:01 192.168.1.2"
3797])
3798
3799# Add 9 more ports to sw0, addresses should all be unique.
3800for n in `seq 1 9`; do
3801 ovn-nbctl lsp-add sw0 "p$n" -- lsp-set-addresses "p$n" dynamic
3802done
3803AT_CHECK([ovn-nbctl get Logical-Switch-Port p1 dynamic_addresses], [0],
3804 ["0a:00:00:00:00:02 192.168.1.3"
3805])
3806AT_CHECK([ovn-nbctl get Logical-Switch-Port p2 dynamic_addresses], [0],
3807 ["0a:00:00:00:00:03 192.168.1.4"
3808])
3809AT_CHECK([ovn-nbctl get Logical-Switch-Port p3 dynamic_addresses], [0],
3810 ["0a:00:00:00:00:04 192.168.1.5"
3811])
3812AT_CHECK([ovn-nbctl get Logical-Switch-Port p4 dynamic_addresses], [0],
3813 ["0a:00:00:00:00:05 192.168.1.6"
3814])
3815AT_CHECK([ovn-nbctl get Logical-Switch-Port p5 dynamic_addresses], [0],
3816 ["0a:00:00:00:00:06 192.168.1.7"
3817])
3818AT_CHECK([ovn-nbctl get Logical-Switch-Port p6 dynamic_addresses], [0],
3819 ["0a:00:00:00:00:07 192.168.1.8"
3820])
3821AT_CHECK([ovn-nbctl get Logical-Switch-Port p7 dynamic_addresses], [0],
3822 ["0a:00:00:00:00:08 192.168.1.9"
3823])
3824AT_CHECK([ovn-nbctl get Logical-Switch-Port p8 dynamic_addresses], [0],
3825 ["0a:00:00:00:00:09 192.168.1.10"
3826])
3827AT_CHECK([ovn-nbctl get Logical-Switch-Port p9 dynamic_addresses], [0],
3828 ["0a:00:00:00:00:0a 192.168.1.11"
3829])
3830
3831# Trying similar tests with a second switch. MAC addresses should be unique
3832# across both switches but IP's only need to be unique within the same switch.
3833ovn-nbctl ls-add sw1
3834ovn-nbctl lsp-add sw1 p10 -- lsp-set-addresses p10 dynamic
3835ovn-nbctl add Logical-Switch sw1 other_config subnet=192.168.1.0/24
3836AT_CHECK([ovn-nbctl get Logical-Switch-Port p10 dynamic_addresses], [0],
3837 ["0a:00:00:00:00:0b 192.168.1.2"
3838])
3839
3840for n in `seq 11 19`; do
3841 ovn-nbctl lsp-add sw1 "p$n" -- lsp-set-addresses "p$n" dynamic
3842done
3843AT_CHECK([ovn-nbctl get Logical-Switch-Port p11 dynamic_addresses], [0],
3844 ["0a:00:00:00:00:0c 192.168.1.3"
3845])
3846AT_CHECK([ovn-nbctl get Logical-Switch-Port p12 dynamic_addresses], [0],
3847 ["0a:00:00:00:00:0d 192.168.1.4"
3848])
3849AT_CHECK([ovn-nbctl get Logical-Switch-Port p13 dynamic_addresses], [0],
3850 ["0a:00:00:00:00:0e 192.168.1.5"
3851])
3852AT_CHECK([ovn-nbctl get Logical-Switch-Port p14 dynamic_addresses], [0],
3853 ["0a:00:00:00:00:0f 192.168.1.6"
3854])
3855AT_CHECK([ovn-nbctl get Logical-Switch-Port p15 dynamic_addresses], [0],
3856 ["0a:00:00:00:00:10 192.168.1.7"
3857])
3858AT_CHECK([ovn-nbctl get Logical-Switch-Port p16 dynamic_addresses], [0],
3859 ["0a:00:00:00:00:11 192.168.1.8"
3860])
3861AT_CHECK([ovn-nbctl get Logical-Switch-Port p17 dynamic_addresses], [0],
3862 ["0a:00:00:00:00:12 192.168.1.9"
3863])
3864AT_CHECK([ovn-nbctl get Logical-Switch-Port p18 dynamic_addresses], [0],
3865 ["0a:00:00:00:00:13 192.168.1.10"
3866])
3867AT_CHECK([ovn-nbctl get Logical-Switch-Port p19 dynamic_addresses], [0],
3868 ["0a:00:00:00:00:14 192.168.1.11"
3869])
3870
3871# Change a port's address to test for multiple ip's for a single address entry
3872# and addresses set by the user.
3873ovn-nbctl lsp-set-addresses p0 "0a:00:00:00:00:15 192.168.1.12 192.168.1.14"
3874ovn-nbctl lsp-add sw0 p20 -- lsp-set-addresses p20 dynamic
3875AT_CHECK([ovn-nbctl get Logical-Switch-Port p20 dynamic_addresses], [0],
3876 ["0a:00:00:00:00:16 192.168.1.13"
3877])
3878
3879# Test for logical router port address management.
3880ovn-nbctl create Logical_Router name=R1
3881ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw0 \
3882network="192.168.1.1/24" mac=\"0a:00:00:00:00:17\" \
3883-- add Logical_Router R1 ports @lrp -- lsp-add sw0 rp-sw0 \
3884-- set Logical_Switch_Port rp-sw0 type=router options:router-port=sw0
3885ovn-nbctl lsp-add sw0 p21 -- lsp-set-addresses p21 dynamic
3886AT_CHECK([ovn-nbctl get Logical-Switch-Port p21 dynamic_addresses], [0],
3887 ["0a:00:00:00:00:18 192.168.1.15"
3888])
3889
3890# Test for address reuse after logical port is deleted.
3891ovn-nbctl lsp-del p0
3892ovn-nbctl lsp-add sw0 p23 -- lsp-set-addresses p23 dynamic
3893AT_CHECK([ovn-nbctl get Logical-Switch-Port p23 dynamic_addresses], [0],
3894 ["0a:00:00:00:00:19 192.168.1.2"
3895])
3896
3897# Test for multiple addresses to one logical port.
3898ovn-nbctl lsp-add sw0 p25 -- lsp-set-addresses p25 \
3899"0a:00:00:00:00:1a 192.168.1.12" "0a:00:00:00:00:1b 192.168.1.14"
3900ovn-nbctl lsp-add sw0 p26 -- lsp-set-addresses p26 dynamic
3901AT_CHECK([ovn-nbctl get Logical-Switch-Port p26 dynamic_addresses], [0],
3902 ["0a:00:00:00:00:1c 192.168.1.16"
3903])
3904
3905# Test for exhausting subnet address space.
3906ovn-nbctl ls-add sw2 -- add Logical-Switch sw2 other_config subnet=172.16.1.0/30
3907ovn-nbctl lsp-add sw2 p27 -- lsp-set-addresses p27 dynamic
3908AT_CHECK([ovn-nbctl get Logical-Switch-Port p27 dynamic_addresses], [0],
3909 ["0a:00:00:00:00:1d 172.16.1.2"
3910])
3911
3912ovn-nbctl lsp-add sw2 p28 -- lsp-set-addresses p28 dynamic
3913AT_CHECK([ovn-nbctl get Logical-Switch-Port p28 dynamic_addresses], [0],
3914 [[[]]
3915])
3916
3917# Test that address management does not add duplicate MAC for lsp/lrp peers.
3918ovn-nbctl create Logical_Router name=R2
3919ovn-nbctl ls-add sw3
3920ovn-nbctl lsp-add sw3 p29 -- lsp-set-addresses p29 \
3921"0a:00:00:00:00:1e"
3922ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw3 \
3923network="192.168.2.1/24" mac=\"0a:00:00:00:00:1f\" \
3924-- add Logical_Router R2 ports @lrp -- lsp-add sw3 rp-sw3 \
3925-- set Logical_Switch_Port rp-sw3 type=router options:router-port=sw3
3926ovn-nbctl lsp-add sw0 p30 -- lsp-set-addresses p30 dynamic
3927AT_CHECK([ovn-nbctl get Logical-Switch-Port p30 dynamic_addresses], [0],
3928 ["0a:00:00:00:00:20 192.168.1.17"
3929])
3930
3931as ovn-sb
3932OVS_APP_EXIT_AND_WAIT([ovsdb-server])
3933
3934as ovn-nb
3935OVS_APP_EXIT_AND_WAIT([ovsdb-server])
3936
3937as northd
3938OVS_APP_EXIT_AND_WAIT([ovn-northd])
3939
3940AT_CLEANUP
3941
3942AT_SETUP([ovn -- ipam connectivity])
3943AT_KEYWORDS([ovnipamconnectivity])
3944AT_SKIP_IF([test $HAVE_PYTHON = no])
3945ovn_start
3946
3947ovn-nbctl lr-add R1
3948
3949# Test for a ping using dynamically allocated addresses.
3950ovn-nbctl ls-add foo -- add Logical_Switch foo other_config subnet=192.168.1.0/24
3951ovn-nbctl ls-add alice -- add Logical_Switch alice other_config subnet=192.168.2.0/24
3952
3953# Connect foo to R1
3954ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24
3955ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \
3956 options:router-port=foo addresses=\"00:00:00:01:02:03\"
3957
3958# Connect alice to R1
3959ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 192.168.2.1/24
3960ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice type=router \
3961 options:router-port=alice addresses=\"00:00:00:01:02:04\"
3962
3963# Create logical port foo1 in foo
3964ovn-nbctl lsp-add foo foo1 \
3965-- lsp-set-addresses foo1 "dynamic"
3966AT_CHECK([ovn-nbctl get Logical-Switch-Port foo1 dynamic_addresses], [0],
3967 ["0a:00:00:00:00:01 192.168.1.2"
3968])
3969
3970# Create logical port alice1 in alice
3971ovn-nbctl lsp-add alice alice1 \
3972-- lsp-set-addresses alice1 "dynamic"
3973AT_CHECK([ovn-nbctl get Logical-Switch-Port alice1 dynamic_addresses], [0],
3974 ["0a:00:00:00:00:02 192.168.2.2"
3975])
3976
3977# Create logical port foo2 in foo
3978ovn-nbctl lsp-add foo foo2 \
3979-- lsp-set-addresses foo2 "dynamic"
3980AT_CHECK([ovn-nbctl get Logical-Switch-Port foo2 dynamic_addresses], [0],
3981 ["0a:00:00:00:00:03 192.168.1.3"
3982])
3983
3984# Create a hypervisor and create OVS ports corresponding to logical ports.
3985net_add n1
3986
3987sim_add hv1
3988as hv1
3989ovs-vsctl add-br br-phys
3990ovn_attach n1 br-phys 192.168.0.1
3991ovs-vsctl -- add-port br-int hv1-vif1 -- \
3992 set interface hv1-vif1 external-ids:iface-id=foo1 \
3993 options:tx_pcap=hv1/vif1-tx.pcap \
3994 options:rxq_pcap=hv1/vif1-rx.pcap \
3995 ofport-request=1
3996
3997ovs-vsctl -- add-port br-int hv1-vif2 -- \
3998 set interface hv1-vif2 external-ids:iface-id=foo2 \
3999 options:tx_pcap=hv1/vif2-tx.pcap \
4000 options:rxq_pcap=hv1/vif2-rx.pcap \
4001 ofport-request=2
4002
4003ovs-vsctl -- add-port br-int hv1-vif3 -- \
4004 set interface hv1-vif3 external-ids:iface-id=alice1 \
4005 options:tx_pcap=hv1/vif3-tx.pcap \
4006 options:rxq_pcap=hv1/vif3-rx.pcap \
4007 ofport-request=3
4008
4009# Allow some time for ovn-northd and ovn-controller to catch up.
4010# XXX This should be more systematic.
4011sleep 1
4012
4013ip_to_hex() {
4014 printf "%02x%02x%02x%02x" "$@"
4015}
8639f9be
ND
4016
4017# Send ip packets between foo1 and foo2
4018src_mac="0a0000000001"
4019dst_mac="0a0000000003"
4020src_ip=`ip_to_hex 192 168 1 2`
4021dst_ip=`ip_to_hex 192 168 1 3`
4022packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
4023as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
4024
4025# Send ip packets between foo1 and alice1
4026src_mac="0a0000000001"
4027dst_mac="000000010203"
4028src_ip=`ip_to_hex 192 168 1 2`
4029dst_ip=`ip_to_hex 192 168 2 2`
4030packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
4031as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
4032
4033echo "---------NB dump-----"
4034ovn-nbctl show
4035echo "---------------------"
4036ovn-nbctl list logical_router
4037echo "---------------------"
4038ovn-nbctl list logical_router_port
4039echo "---------------------"
4040
4041echo "---------SB dump-----"
4042ovn-sbctl list datapath_binding
4043echo "---------------------"
4044ovn-sbctl list port_binding
4045echo "---------------------"
4046
4047echo "------ hv1 dump ----------"
4048as hv1 ovs-ofctl dump-flows br-int
4049
4050# Packet to Expect at foo2
4051src_mac="0a0000000001"
4052dst_mac="0a0000000003"
4053src_ip=`ip_to_hex 192 168 1 2`
4054dst_ip=`ip_to_hex 192 168 1 3`
4055expected=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000
4056
e4543cfe
DDP
4057$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets
4058echo $expected > expout
8639f9be
ND
4059AT_CHECK([cat received1.packets], [0], [expout])
4060
4061# Packet to Expect at alice1
4062src_mac="000000010204"
4063dst_mac="0a0000000002"
4064src_ip=`ip_to_hex 192 168 1 2`
4065dst_ip=`ip_to_hex 192 168 2 2`
4066expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000
4067
e4543cfe
DDP
4068$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets
4069echo $expected > expout
8639f9be
ND
4070AT_CHECK([cat received2.packets], [0], [expout])
4071
4072OVN_CLEANUP([hv1])
4073
4074AT_CLEANUP