]>
Commit | Line | Data |
---|---|---|
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. | |
12 | m4_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 () { | |
abb37b6b FF |
21 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text |
22 | rcv_n=`wc -l < "$rcv_text"` | |
23 | test $rcv_n -ge $exp_n | |
49d7c759 BP |
24 | } |
25 | ovs_wait || echo "expected $exp_n packets, only received $rcv_n" | |
26 | ||
e4543cfe | 27 | sort $exp_text > expout |
49d7c759 BP |
28 | } |
29 | ]) | |
30 | m4_define([OVN_CHECK_PACKETS], | |
31 | [ovn_check_packets__ "$1" "$2" | |
32 | AT_CHECK([sort $rcv_text], [0], [expout])]) | |
33 | ||
f295c17b | 34 | AT_BANNER([OVN components]) |
10b1662b BP |
35 | |
36 | AT_SETUP([ovn -- lexer]) | |
37 | dnl For lines without =>, input and expected output are identical. | |
38 | dnl For lines with =>, input precedes => and expected output follows =>. | |
39 | AT_DATA([test-cases.txt], [dnl | |
40 | foo 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 |
47 | a/*b*/c => a c |
48 | a//b c => a | |
49 | a/**/b => a b | |
50 | a/*/b => a error("`/*' without matching `*/'.") | |
51 | a/*/**/b => a b | |
52 | a/b => a error("`/' is only valid as part of `//' or `/*'.") b | |
53 | ||
54 | 0 1 12345 18446744073709551615 | |
55 | 18446744073709551616 => error("Decimal constants must be less than 2**64.") | |
56 | 9999999999999999999999 => error("Decimal constants must be less than 2**64.") | |
57 | 01 => error("Decimal constants must not have leading zeros.") | |
58 | ||
59 | 0/0 | |
60 | 0/1 | |
61 | 1/0 => error("Value contains unmasked 1-bits.") | |
62 | 1/1 | |
63 | 128/384 | |
64 | 1/3 | |
65 | 1/ => error("Integer constant expected.") | |
66 | ||
67 | 1/0x123 => error("Value and mask have incompatible formats.") | |
68 | ||
69 | 0x1234 | |
70 | 0x01234 => 0x1234 | |
71 | 0x0 => 0 | |
72 | 0x000 => 0 | |
73 | 0xfedcba9876543210 | |
74 | 0XFEDCBA9876543210 => 0xfedcba9876543210 | |
75 | 0xfedcba9876543210fedcba9876543210 | |
10b1662b BP |
76 | 0x0000fedcba9876543210fedcba9876543210 => 0xfedcba9876543210fedcba9876543210 |
77 | 0x => error("Hex digits expected following 0x.") | |
78 | 0X => error("Hex digits expected following 0X.") | |
79 | 0x0/0x0 => 0/0 | |
80 | 0x0/0x1 => 0/0x1 | |
81 | 0x1/0x0 => error("Value contains unmasked 1-bits.") | |
82 | 0xffff/0x1ffff | |
83 | 0x. => error("Invalid syntax in hexadecimal constant.") | |
84 | ||
85 | 192.168.128.1 1.2.3.4 255.255.255.255 0.0.0.0 | |
86 | 256.1.2.3 => error("Invalid numeric constant.") | |
87 | 192.168.0.0/16 | |
88 | 192.168.0.0/255.255.0.0 => 192.168.0.0/16 | |
89 | 192.168.0.0/255.255.255.0 => 192.168.0.0/24 | |
90 | 192.168.0.0/255.255.0.255 | |
91 | 192.168.0.0/255.0.0.0 => error("Value contains unmasked 1-bits.") | |
92 | 192.168.0.0/32 | |
93 | 192.168.0.0/255.255.255.255 => 192.168.0.0/32 | |
52c0fc39 | 94 | 1.2.3.4:5 => 1.2.3.4 : 5 |
10b1662b BP |
95 | |
96 | :: | |
97 | ::1 | |
98 | ff00::1234 => ff00::1234 | |
99 | 2001:db8:85a3::8a2e:370:7334 | |
100 | 2001:db8:85a3:0:0:8a2e:370:7334 => 2001:db8:85a3::8a2e:370:7334 | |
101 | 2001: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 | |
107 | ff00::/8 | |
108 | ff00::/ff00:: => ff00::/8 | |
109 | ||
110 | 01:23:45:67:ab:cd | |
111 | 01:23:45:67:AB:CD => 01:23:45:67:ab:cd | |
112 | fe:dc:ba:98:76:54 | |
113 | FE:DC:ba:98:76:54 => fe:dc:ba:98:76:54 | |
114 | 01:00:00:00:00:00/01:00:00:00:00:00 | |
115 | ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff | |
116 | fe:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff | |
117 | ff:ff:ff:ff:ff:ff/fe:ff:ff:ff:ff:ff => error("Value contains unmasked 1-bits.") | |
118 | fe:x => error("Invalid numeric constant.") | |
119 | 00: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 | ]) | |
129 | AT_CAPTURE_FILE([input.txt]) | |
130 | sed 's/ =>.*//' test-cases.txt > input.txt | |
131 | sed 's/.* => //' test-cases.txt > expout | |
132 | AT_CHECK([ovstest test-ovn lex < input.txt], [0], [expout]) | |
133 | AT_CLEANUP | |
e0840f11 | 134 | |
7700eea0 BP |
135 | dnl The OVN expression parser needs to know what fields overlap with one |
136 | dnl another. This test therefore verifies that all the smaller registers | |
137 | dnl are defined as terms of subfields of the larger ones. | |
138 | dnl | |
139 | dnl When we add or remove registers this test needs to be updated, of course. | |
140 | AT_SETUP([ovn -- registers]) | |
141 | AT_CHECK([ovstest test-ovn dump-symtab | grep reg | sort], [0], | |
142 | [[reg0 = xxreg0[96..127] | |
143 | reg1 = xxreg0[64..95] | |
144 | reg2 = xxreg0[32..63] | |
145 | reg3 = xxreg0[0..31] | |
146 | reg4 = xxreg1[96..127] | |
147 | reg5 = xxreg1[64..95] | |
148 | reg6 = xxreg1[32..63] | |
149 | reg7 = xxreg1[0..31] | |
150 | reg8 = xreg4[32..63] | |
151 | reg9 = xreg4[0..31] | |
152 | xreg0 = xxreg0[64..127] | |
153 | xreg1 = xxreg0[0..63] | |
154 | xreg2 = xxreg1[64..127] | |
155 | xreg3 = xxreg1[0..63] | |
156 | xreg4 = OXM_OF_PKT_REG4 | |
157 | xxreg0 = NXM_NX_XXREG0 | |
158 | xxreg1 = NXM_NX_XXREG1 | |
159 | ]]) | |
160 | AT_CLEANUP | |
161 | ||
2277b860 BP |
162 | dnl Check that the OVN conntrack field definitions are correct. |
163 | AT_SETUP([ovn -- conntrack fields]) | |
164 | AT_CHECK([ovstest test-ovn dump-symtab | grep ^ct | sort], [0], | |
165 | [[ct.est = ct_state[1] | |
166 | ct.inv = ct_state[4] | |
167 | ct.new = ct_state[0] | |
168 | ct.rel = ct_state[2] | |
169 | ct.rpl = ct_state[3] | |
170 | ct.trk = ct_state[5] | |
171 | ct_label = NXM_NX_CT_LABEL | |
172 | ct_mark = NXM_NX_CT_MARK | |
173 | ct_state = NXM_NX_CT_STATE | |
174 | ]]) | |
175 | AT_CLEANUP | |
176 | ||
e0840f11 BP |
177 | AT_SETUP([ovn -- expression parser]) |
178 | dnl For lines without =>, input and expected output are identical. | |
179 | dnl For lines with =>, input precedes => and expected output follows =>. | |
180 | AT_DATA([test-cases.txt], [[ | |
181 | eth.type == 0x800 | |
182 | eth.type==0x800 => eth.type == 0x800 | |
183 | eth.type[0..15] == 0x800 => eth.type == 0x800 | |
184 | ||
185 | vlan.present | |
186 | vlan.present == 1 => vlan.present | |
187 | !(vlan.present == 0) => vlan.present | |
188 | !(vlan.present != 1) => vlan.present | |
189 | !vlan.present | |
190 | vlan.present == 0 => !vlan.present | |
191 | vlan.present != 1 => !vlan.present | |
192 | !(vlan.present == 1) => !vlan.present | |
193 | !(vlan.present != 0) => !vlan.present | |
194 | ||
195 | eth.dst[0] | |
196 | eth.dst[0] == 1 => eth.dst[0] | |
197 | eth.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] | |
202 | eth.dst[0] == 0 => !eth.dst[0] | |
203 | eth.dst[0] != 1 => !eth.dst[0] | |
204 | !(eth.dst[0] == 1) => !eth.dst[0] | |
205 | !(eth.dst[0] != 0) => !eth.dst[0] | |
206 | ||
207 | vlan.tci[12..15] == 0x3 | |
208 | vlan.tci == 0x3000/0xf000 => vlan.tci[12..15] == 0x3 | |
209 | vlan.tci[12..15] != 0x3 | |
210 | vlan.tci != 0x3000/0xf000 => vlan.tci[12..15] != 0x3 | |
211 | ||
212 | !vlan.pcp => vlan.pcp == 0 | |
213 | !(vlan.pcp) => vlan.pcp == 0 | |
214 | vlan.pcp == 0x4 | |
215 | vlan.pcp != 0x4 | |
216 | vlan.pcp > 0x4 | |
217 | vlan.pcp >= 0x4 | |
218 | vlan.pcp < 0x4 | |
219 | vlan.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 | |
226 | 0x4 == vlan.pcp => vlan.pcp == 0x4 | |
227 | 0x4 != vlan.pcp => vlan.pcp != 0x4 | |
228 | 0x4 < vlan.pcp => vlan.pcp > 0x4 | |
229 | 0x4 <= vlan.pcp => vlan.pcp >= 0x4 | |
230 | 0x4 > vlan.pcp => vlan.pcp < 0x4 | |
231 | 0x4 >= 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 | ||
239 | 1 < vlan.pcp < 4 => vlan.pcp > 0x1 && vlan.pcp < 0x4 | |
240 | 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4 | |
241 | 1 < vlan.pcp <= 4 => vlan.pcp > 0x1 && vlan.pcp <= 0x4 | |
242 | 1 <= vlan.pcp < 4 => vlan.pcp >= 0x1 && vlan.pcp < 0x4 | |
243 | 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4 | |
244 | 4 > vlan.pcp > 1 => vlan.pcp < 0x4 && vlan.pcp > 0x1 | |
245 | 4 >= vlan.pcp > 1 => vlan.pcp <= 0x4 && vlan.pcp > 0x1 | |
246 | 4 > vlan.pcp >= 1 => vlan.pcp < 0x4 && vlan.pcp >= 0x1 | |
247 | 4 >= 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 | ||
258 | vlan.pcp == {1, 2, 3, 4} => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4 | |
259 | vlan.pcp == 1 || ((vlan.pcp == 2 || vlan.pcp == 3) || vlan.pcp == 4) => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4 | |
260 | ||
261 | vlan.pcp != {1, 2, 3, 4} => vlan.pcp != 0x1 && vlan.pcp != 0x2 && vlan.pcp != 0x3 && vlan.pcp != 0x4 | |
262 | vlan.pcp == 1 && ((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && vlan.pcp == 0x2 && vlan.pcp == 0x3 && vlan.pcp == 0x4 | |
263 | ||
264 | vlan.pcp == 1 && !((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3 || vlan.pcp != 0x4) | |
265 | vlan.pcp == 1 && (!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3) && vlan.pcp == 0x4 | |
266 | vlan.pcp == 1 && !(!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && ((vlan.pcp == 0x2 && vlan.pcp == 0x3) || vlan.pcp != 0x4) | |
267 | ||
268 | ip4.src == {10.0.0.0/8, 192.168.0.0/16, 172.16.20.0/24, 8.8.8.8} => ip4.src[24..31] == 0xa || ip4.src[16..31] == 0xc0a8 || ip4.src[8..31] == 0xac1014 || ip4.src == 0x8080808 | |
269 | ip6.src == ::1 => ip6.src == 0x1 | |
270 | ||
271 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 | |
272 | ip4.src == ::1.2.3.4/::ffff:ffff => ip4.src == 0x1020304 | |
273 | ip6.src == ::1 => ip6.src == 0x1 | |
274 | ||
275 | 1 | |
276 | 0 | |
277 | !1 => 0 | |
278 | !0 => 1 | |
279 | ||
280 | inport == "eth0" | |
281 | !(inport != "eth0") => inport == "eth0" | |
282 | ||
3b7cb7e1 BP |
283 | ip4.src == "eth0" => Integer field ip4.src is not compatible with string constant. |
284 | inport == 1 => String field inport is not compatible with integer constant. | |
76da94b5 | 285 | ip4.src = 1.2.3.4 => Syntax error at `=' expecting relational operator. |
e0840f11 BP |
286 | |
287 | ip4.src > {1, 2, 3} => Only == and != operators may be used with value sets. | |
288 | eth.type > 0x800 => Only == and != operators may be used with nominal field eth.type. | |
289 | vlan.present > 0 => Only == and != operators may be used with Boolean field vlan.present. | |
290 | ||
291 | inport != "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). | |
293 | eth.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 | 295 | inport = "eth0" => Syntax error at `=' expecting relational operator. |
e0840f11 BP |
296 | |
297 | 123 == 123 => Syntax error at `123' expecting field name. | |
298 | ||
2c5cbb15 RB |
299 | $name => Syntax error at `$name' expecting address set name. |
300 | ||
e0840f11 BP |
301 | 123 == xyzzy => Syntax error at `xyzzy' expecting field name. |
302 | xyzzy == 1 => Syntax error at `xyzzy' expecting field name. | |
303 | ||
304 | inport[1] == 1 => Cannot select subfield of string field inport. | |
305 | ||
306 | eth.type[] == 1 => Syntax error at `@:>@' expecting small integer. | |
307 | eth.type[::1] == 1 => Syntax error at `::1' expecting small integer. | |
308 | eth.type[18446744073709551615] == 1 => Syntax error at `18446744073709551615' expecting small integer. | |
309 | ||
310 | eth.type[5!] => Syntax error at `!' expecting `@:>@'. | |
311 | ||
312 | eth.type[5..1] => Invalid bit range 5 to 1. | |
313 | ||
314 | eth.type[12..16] => Cannot select bits 12 to 16 of 16-bit field eth.type. | |
315 | ||
316 | eth.type[10] == 1 => Cannot select subfield of nominal field eth.type. | |
317 | ||
318 | eth.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 | ||
322 | 123 => Syntax error at end of input expecting relational operator. | |
323 | ||
324 | 123 x => Syntax error at `x' expecting relational operator. | |
325 | ||
326 | {1, "eth0"} => Syntax error at `"eth0"' expecting integer. | |
327 | ||
328 | eth.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 | ||
334 | eth.type == 0x800 || eth.type == 0x86dd && ip.proto == 17 => && and || must be parenthesized when used together. | |
335 | ||
336 | eth.dst == {} => Syntax error at `}' expecting constant. | |
337 | ||
338 | eth.src > 00:00:00:00:11:11/00:00:00:00:ff:ff => Only == and != operators may be used with masked constants. Consider using subfields instead (e.g. eth.src[0..15] > 0x1111 in place of eth.src > 00:00:00:00:11:11/00:00:00:00:ff:ff). | |
339 | ||
3b7cb7e1 | 340 | ip4.src == ::1 => 128-bit constant is not compatible with 32-bit field ip4.src. |
e0840f11 BP |
341 | |
342 | 1 == eth.type == 2 => Range expressions must have the form `x < field < y' or `x > field > y', with each `<' optionally replaced by `<=' or `>' by `>='). | |
8b34ccda | 343 | |
9aef3c1b | 344 | eth.dst[40] x => Syntax error at `x' expecting end of input. |
ea382567 RB |
345 | |
346 | ip4.src == {1.2.3.4, $set1, $unknownset} => Syntax error at `$unknownset' expecting address set name. | |
347 | eth.src == {$set3, badmac, 00:00:00:00:00:01} => Syntax error at `badmac' expecting constant. | |
e0840f11 BP |
348 | ]]) |
349 | sed 's/ =>.*//' test-cases.txt > input.txt | |
350 | sed 's/.* => //' test-cases.txt > expout | |
351 | AT_CHECK([ovstest test-ovn parse-expr < input.txt], [0], [expout]) | |
352 | AT_CLEANUP | |
353 | ||
354 | AT_SETUP([ovn -- expression annotation]) | |
355 | dnl Input precedes =>, expected output follows =>. | |
356 | AT_DATA([test-cases.txt], [[ | |
357 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 && eth.type == 0x800 | |
358 | ip4.src != 1.2.3.4 => ip4.src != 0x1020304 && eth.type == 0x800 | |
359 | ip.proto == 123 => ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd) | |
360 | ip.proto == {123, 234} => (ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)) || (ip.proto == 0xea && (eth.type == 0x800 || eth.type == 0x86dd)) | |
361 | ip4.src == 1.2.3.4 && ip4.dst == 5.6.7.8 => ip4.src == 0x1020304 && eth.type == 0x800 && ip4.dst == 0x5060708 && eth.type == 0x800 | |
362 | ||
363 | ip => eth.type == 0x800 || eth.type == 0x86dd | |
364 | ip == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
365 | ip[0] == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
366 | ip > 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'. | |
368 | ip == 0 => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
369 | ||
370 | vlan.present => vlan.tci[12] | |
371 | !vlan.present => !vlan.tci[12] | |
372 | ||
373 | !vlan.pcp => vlan.tci[13..15] == 0 && vlan.tci[12] | |
374 | vlan.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 | |
377 | ip.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)) | |
379 | ip.later_frag => ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd) | |
380 | ||
381 | bad_prereq != 0 => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
382 | self_recurse != 0 => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'. | |
383 | mutual_recurse_1 != 0 => Error parsing expression `mutual_recurse_2 != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `mutual_recurse_1 != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `mutual_recurse_1'. | |
384 | mutual_recurse_2 != 0 => Error parsing expression `mutual_recurse_1 != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `mutual_recurse_2 != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `mutual_recurse_2'. | |
385 | ]]) | |
386 | sed 's/ =>.*//' test-cases.txt > input.txt | |
387 | sed 's/.* => //' test-cases.txt > expout | |
388 | AT_CHECK([ovstest test-ovn annotate-expr < input.txt], [0], [expout]) | |
389 | AT_CLEANUP | |
390 | ||
9d4aecca | 391 | AT_SETUP([ovn -- 1-term expression conversion]) |
e0840f11 | 392 | AT_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 | ]) |
395 | AT_CLEANUP | |
396 | ||
9d4aecca | 397 | AT_SETUP([ovn -- 2-term expression conversion]) |
e0840f11 | 398 | AT_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 | ]) |
401 | AT_CLEANUP | |
402 | ||
9d4aecca | 403 | AT_SETUP([ovn -- 3-term expression conversion]) |
e0840f11 | 404 | AT_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 | ]) |
407 | AT_CLEANUP | |
408 | ||
9d4aecca BP |
409 | AT_SETUP([ovn -- 3-term numeric expression simplification]) |
410 | AT_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 | ]) |
413 | AT_CLEANUP | |
414 | ||
9d4aecca BP |
415 | AT_SETUP([ovn -- 4-term string expression simplification]) |
416 | AT_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 | ]) |
419 | AT_CLEANUP | |
420 | ||
9d4aecca BP |
421 | AT_SETUP([ovn -- 3-term mixed expression simplification]) |
422 | AT_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 | ]) |
425 | AT_CLEANUP | |
426 | ||
9d4aecca BP |
427 | AT_SETUP([ovn -- 4-term numeric expression normalization]) |
428 | AT_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 | ]) |
431 | AT_CLEANUP | |
432 | ||
9d4aecca BP |
433 | AT_SETUP([ovn -- 4-term string expression normalization]) |
434 | AT_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 | ]) | |
437 | AT_CLEANUP | |
438 | ||
439 | AT_SETUP([ovn -- 4-term mixed expression normalization]) | |
440 | AT_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 | ]) | |
443 | AT_CLEANUP | |
444 | ||
445 | AT_SETUP([ovn -- 5-term numeric expression normalization]) | |
446 | AT_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 | ]) | |
449 | AT_CLEANUP | |
450 | ||
451 | AT_SETUP([ovn -- 5-term string expression normalization]) | |
452 | AT_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 | ]) | |
455 | AT_CLEANUP | |
456 | ||
457 | AT_SETUP([ovn -- 5-term mixed expression normalization]) | |
458 | AT_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 | ]) | |
461 | AT_CLEANUP | |
462 | ||
463 | AT_SETUP([ovn -- 4-term numeric expressions to flows]) | |
464 | AT_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 | ]) | |
467 | AT_CLEANUP | |
468 | ||
469 | AT_SETUP([ovn -- 4-term string expressions to flows]) | |
470 | AT_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 | ]) | |
473 | AT_CLEANUP | |
474 | ||
475 | AT_SETUP([ovn -- 4-term mixed expressions to flows]) | |
476 | AT_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 | ]) | |
479 | AT_CLEANUP | |
480 | ||
481 | AT_SETUP([ovn -- 3-term numeric expressions to flows]) | |
482 | AT_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 | ]) |
485 | AT_CLEANUP | |
f386a8a7 BP |
486 | |
487 | AT_SETUP([ovn -- converting expressions to flows -- string fields]) | |
488 | expr_to_flow () { | |
489 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
490 | } | |
cc5e28d8 | 491 | AT_CHECK([expr_to_flow 'inport == "eth0"'], [0], [reg14=0x5 |
f386a8a7 | 492 | ]) |
cc5e28d8 | 493 | AT_CHECK([expr_to_flow 'inport == "eth1"'], [0], [reg14=0x6 |
f386a8a7 BP |
494 | ]) |
495 | AT_CHECK([expr_to_flow 'inport == "eth2"'], [0], [(no flows) | |
496 | ]) | |
497 | AT_CHECK([expr_to_flow 'inport == "eth0" && ip'], [0], [dnl | |
cc5e28d8 JP |
498 | ip,reg14=0x5 |
499 | ipv6,reg14=0x5 | |
f386a8a7 BP |
500 | ]) |
501 | AT_CHECK([expr_to_flow 'inport == "eth1" && ip'], [0], [dnl | |
cc5e28d8 JP |
502 | ip,reg14=0x6 |
503 | ipv6,reg14=0x6 | |
f386a8a7 BP |
504 | ]) |
505 | AT_CHECK([expr_to_flow 'inport == "eth2" && ip'], [0], [(no flows) | |
506 | ]) | |
507 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2", "LOCAL"}'], [0], | |
cc5e28d8 JP |
508 | [reg14=0x5 |
509 | reg14=0x6 | |
510 | reg14=0xfffe | |
f386a8a7 BP |
511 | ]) |
512 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2"} && ip'], [0], [dnl | |
cc5e28d8 JP |
513 | ip,reg14=0x5 |
514 | ip,reg14=0x6 | |
515 | ipv6,reg14=0x5 | |
516 | ipv6,reg14=0x6 | |
f386a8a7 | 517 | ]) |
9d4aecca BP |
518 | AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl |
519 | (no flows) | |
520 | ]) | |
f386a8a7 | 521 | AT_CLEANUP |
3b7cb7e1 | 522 | |
2c5cbb15 RB |
523 | AT_SETUP([ovn -- converting expressions to flows -- address sets]) |
524 | expr_to_flow () { | |
525 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
526 | } | |
527 | AT_CHECK([expr_to_flow 'ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3}'], [0], [dnl | |
528 | ip,nw_src=10.0.0.1 | |
529 | ip,nw_src=10.0.0.2 | |
530 | ip,nw_src=10.0.0.3 | |
531 | ]) | |
532 | AT_CHECK([expr_to_flow 'ip4.src == $set1'], [0], [dnl | |
533 | ip,nw_src=10.0.0.1 | |
534 | ip,nw_src=10.0.0.2 | |
535 | ip,nw_src=10.0.0.3 | |
536 | ]) | |
537 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set1}'], [0], [dnl | |
538 | ip,nw_src=1.2.3.4 | |
539 | ip,nw_src=10.0.0.1 | |
540 | ip,nw_src=10.0.0.2 | |
541 | ip,nw_src=10.0.0.3 | |
542 | ]) | |
543 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.0.0/20, 5.5.5.0/24, $set1}'], [0], [dnl | |
544 | ip,nw_src=1.2.0.0/20 | |
545 | ip,nw_src=10.0.0.1 | |
546 | ip,nw_src=10.0.0.2 | |
547 | ip,nw_src=10.0.0.3 | |
548 | ip,nw_src=5.5.5.0/24 | |
549 | ]) | |
550 | AT_CHECK([expr_to_flow 'ip6.src == {::1, ::2, ::3}'], [0], [dnl | |
551 | ipv6,ipv6_src=::1 | |
552 | ipv6,ipv6_src=::2 | |
553 | ipv6,ipv6_src=::3 | |
554 | ]) | |
555 | AT_CHECK([expr_to_flow 'ip6.src == {::1, $set2, ::4}'], [0], [dnl | |
556 | ipv6,ipv6_src=::1 | |
557 | ipv6,ipv6_src=::2 | |
558 | ipv6,ipv6_src=::3 | |
559 | ipv6,ipv6_src=::4 | |
560 | ]) | |
561 | AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, 00:00:00:00:00:02, 00:00:00:00:00:03}'], [0], [dnl | |
562 | dl_src=00:00:00:00:00:01 | |
563 | dl_src=00:00:00:00:00:02 | |
564 | dl_src=00:00:00:00:00:03 | |
565 | ]) | |
566 | AT_CHECK([expr_to_flow 'eth.src == {$set3}'], [0], [dnl | |
567 | dl_src=00:00:00:00:00:01 | |
568 | dl_src=00:00:00:00:00:02 | |
569 | dl_src=00:00:00:00:00:03 | |
570 | ]) | |
ea382567 RB |
571 | AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, $set3, ba:be:be:ef:de:ad, $set3}'], [0], [dnl |
572 | dl_src=00:00:00:00:00:01 | |
573 | dl_src=00:00:00:00:00:02 | |
574 | dl_src=00:00:00:00:00:03 | |
575 | dl_src=ba:be:be:ef:de:ad | |
576 | ]) | |
2c5cbb15 RB |
577 | AT_CLEANUP |
578 | ||
3b7cb7e1 | 579 | AT_SETUP([ovn -- action parsing]) |
d5a76da4 BP |
580 | dnl Unindented text is input (a set of OVN logical actions). |
581 | dnl Indented text is expected output. | |
582 | AT_DATA([test-cases.txt], | |
583 | [[# drop | |
584 | drop; | |
585 | encodes as drop | |
586 | drop; next; | |
587 | Syntax error at `next' expecting end of input. | |
588 | next; drop; | |
589 | Syntax error at `drop' expecting action. | |
5f822129 BP |
590 | |
591 | # output | |
d5a76da4 BP |
592 | output; |
593 | encodes as resubmit(,64) | |
5f822129 BP |
594 | |
595 | # next | |
d5a76da4 BP |
596 | next; |
597 | formats as next(11); | |
598 | encodes as resubmit(,27) | |
599 | next(11); | |
600 | encodes as resubmit(,27) | |
601 | next(0); | |
602 | encodes as resubmit(,16) | |
603 | next(15); | |
604 | encodes as resubmit(,31) | |
605 | ||
606 | next(); | |
607 | Syntax error at `)' expecting small integer. | |
608 | next(10; | |
609 | Syntax error at `;' expecting `)'. | |
610 | next(16); | |
611 | "next" argument must be in range 0 to 15. | |
5f822129 BP |
612 | |
613 | # Loading a constant value. | |
d5a76da4 BP |
614 | tcp.dst=80; |
615 | formats as tcp.dst = 80; | |
616 | encodes as set_field:80->tcp_dst | |
617 | has prereqs ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
618 | eth.dst[40] = 1; | |
619 | encodes as set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dst | |
620 | vlan.pcp = 2; | |
621 | encodes as set_field:0x4000/0xe000->vlan_tci | |
622 | has prereqs vlan.tci[12] | |
623 | vlan.tci[13..15] = 2; | |
624 | encodes as set_field:0x4000/0xe000->vlan_tci | |
625 | inport = ""; | |
626 | encodes as set_field:0->reg14 | |
627 | ip.ttl=4; | |
628 | formats as ip.ttl = 4; | |
629 | encodes as set_field:4->nw_ttl | |
630 | has prereqs eth.type == 0x800 || eth.type == 0x86dd | |
631 | outport="eth0"; next; outport="LOCAL"; next; | |
632 | formats as outport = "eth0"; next(11); outport = "LOCAL"; next(11); | |
633 | encodes as set_field:0x5->reg15,resubmit(,27),set_field:0xfffe->reg15,resubmit(,27) | |
634 | ||
635 | inport[1] = 1; | |
636 | Cannot select subfield of string field inport. | |
637 | ip.proto[1] = 1; | |
638 | Cannot select subfield of nominal field ip.proto. | |
639 | eth.dst[40] == 1; | |
640 | Syntax error at `==' expecting `=' or `<->'. | |
641 | ip = 1; | |
642 | Predicate symbol ip used where lvalue required. | |
643 | ip.proto = 6; | |
644 | Field ip.proto is not modifiable. | |
645 | inport = {"a", "b"}; | |
646 | Syntax error at `{' expecting constant. | |
647 | inport = {}; | |
648 | Syntax error at `{' expecting constant. | |
649 | bad_prereq = 123; | |
650 | Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
651 | self_recurse = 123; | |
652 | 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'. | |
653 | vlan.present = 0; | |
654 | Predicate symbol vlan.present used where lvalue required. | |
5f822129 BP |
655 | |
656 | # Moving one field into another. | |
d5a76da4 BP |
657 | reg0=reg1; |
658 | formats as reg0 = reg1; | |
659 | encodes as move:NXM_NX_XXREG0[64..95]->NXM_NX_XXREG0[96..127] | |
660 | vlan.pcp = reg0[0..2]; | |
661 | encodes as move:NXM_NX_XXREG0[96..98]->NXM_OF_VLAN_TCI[13..15] | |
662 | has prereqs vlan.tci[12] | |
663 | reg0[10] = vlan.pcp[1]; | |
664 | encodes as move:NXM_OF_VLAN_TCI[14]->NXM_NX_XXREG0[106] | |
665 | has prereqs vlan.tci[12] | |
666 | outport = inport; | |
667 | encodes as move:NXM_NX_REG14[]->NXM_NX_REG15[] | |
668 | ||
669 | reg0[0] = vlan.present; | |
670 | Predicate symbol vlan.present used where lvalue required. | |
671 | reg0 = reg1[0..10]; | |
672 | Can't assign 11-bit value to 32-bit destination. | |
673 | inport = reg0; | |
674 | Can't assign integer field (reg0) to string field (inport). | |
675 | inport = big_string; | |
676 | String fields inport and big_string are incompatible for assignment. | |
677 | ip.proto = reg0[0..7]; | |
678 | Field ip.proto is not modifiable. | |
5f822129 BP |
679 | |
680 | # Exchanging fields. | |
d5a76da4 BP |
681 | reg0 <-> reg1; |
682 | encodes as push:NXM_NX_XXREG0[64..95],push:NXM_NX_XXREG0[96..127],pop:NXM_NX_XXREG0[64..95],pop:NXM_NX_XXREG0[96..127] | |
683 | vlan.pcp <-> reg0[0..2]; | |
684 | encodes as 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] | |
685 | has prereqs vlan.tci[12] | |
686 | reg0[10] <-> vlan.pcp[1]; | |
687 | encodes as push:NXM_OF_VLAN_TCI[14],push:NXM_NX_XXREG0[106],pop:NXM_OF_VLAN_TCI[14],pop:NXM_NX_XXREG0[106] | |
688 | has prereqs vlan.tci[12] | |
689 | outport <-> inport; | |
690 | encodes as push:NXM_NX_REG14[],push:NXM_NX_REG15[],pop:NXM_NX_REG14[],pop:NXM_NX_REG15[] | |
691 | ||
692 | reg0[0] <-> vlan.present; | |
693 | Predicate symbol vlan.present used where lvalue required. | |
694 | reg0 <-> reg1[0..10]; | |
695 | Can't exchange 32-bit field with 11-bit field. | |
696 | inport <-> reg0; | |
697 | Can't exchange string field (inport) with integer field (reg0). | |
698 | inport <-> big_string; | |
699 | String fields inport and big_string are incompatible for exchange. | |
700 | ip.proto <-> reg0[0..7]; | |
701 | Field ip.proto is not modifiable. | |
702 | reg0[0..7] <-> ip.proto; | |
703 | Field ip.proto is not modifiable. | |
5f822129 BP |
704 | |
705 | # TTL decrement. | |
d5a76da4 BP |
706 | ip.ttl--; |
707 | encodes as dec_ttl | |
708 | has prereqs ip | |
709 | ip.ttl | |
710 | Syntax error at end of input expecting `--'. | |
5f822129 | 711 | |
467085fd | 712 | # load balancing. |
d5a76da4 BP |
713 | ct_lb; |
714 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15],nat) | |
715 | has prereqs ip | |
716 | ct_lb(); | |
717 | formats as ct_lb; | |
718 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15],nat) | |
719 | has prereqs ip | |
720 | ct_lb(192.168.1.2:80, 192.168.1.3:80); | |
721 | encodes as group:1 | |
722 | has prereqs ip | |
723 | ct_lb(192.168.1.2, 192.168.1.3, ); | |
724 | formats as ct_lb(192.168.1.2, 192.168.1.3); | |
725 | encodes as group:2 | |
726 | has prereqs ip | |
727 | ||
728 | ct_lb(192.168.1.2:); | |
729 | Syntax error at `)' expecting port number. | |
730 | ct_lb(192.168.1.2:123456); | |
731 | Syntax error at `123456' expecting port number. | |
732 | ct_lb(foo); | |
733 | Syntax error at `foo' expecting IPv4 address. | |
734 | ||
735 | # ct_next | |
736 | ct_next; | |
737 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15]) | |
738 | has prereqs ip | |
739 | ||
740 | # ct_commit | |
741 | ct_commit; | |
742 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
743 | has prereqs ip | |
744 | ct_commit(); | |
745 | formats as ct_commit; | |
746 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
747 | has prereqs ip | |
748 | ct_commit(ct_mark=1); | |
749 | formats as ct_commit(ct_mark=0x1); | |
750 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark)) | |
751 | has prereqs ip | |
752 | ct_commit(ct_mark=1/1); | |
753 | formats as ct_commit(ct_mark=0x1/0x1); | |
754 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_mark)) | |
755 | has prereqs ip | |
756 | ct_commit(ct_label=1); | |
757 | formats as ct_commit(ct_label=0x1); | |
758 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_label)) | |
759 | has prereqs ip | |
760 | ct_commit(ct_label=1/1); | |
761 | formats as ct_commit(ct_label=0x1/0x1); | |
762 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_label)) | |
763 | has prereqs ip | |
764 | ct_commit(ct_mark=1, ct_label=2); | |
765 | formats as ct_commit(ct_mark=0x1, ct_label=0x2); | |
766 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark,set_field:0x2->ct_label)) | |
767 | has prereqs ip | |
768 | ||
769 | ct_commit(ct_label=0x01020304050607080910111213141516); | |
770 | formats as ct_commit(ct_label=0x1020304050607080910111213141516); | |
771 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1020304050607080910111213141516->ct_label)) | |
772 | has prereqs ip | |
773 | ct_commit(ct_label=0x181716151413121110090807060504030201); | |
774 | formats as ct_commit(ct_label=0x16151413121110090807060504030201); | |
775 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x16151413121110090807060504030201->ct_label)) | |
776 | has prereqs ip | |
777 | ct_commit(ct_label=0x1000000000000000000000000000000/0x1000000000000000000000000000000); | |
778 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1000000000000000000000000000000/0x1000000000000000000000000000000->ct_label)) | |
779 | has prereqs ip | |
780 | ct_commit(ct_label=18446744073709551615); | |
781 | formats as ct_commit(ct_label=0xffffffffffffffff); | |
782 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0xffffffffffffffff->ct_label)) | |
783 | has prereqs ip | |
784 | ct_commit(ct_label=18446744073709551616); | |
785 | Decimal constants must be less than 2**64. | |
786 | ||
787 | # ct_dnat | |
788 | ct_dnat; | |
789 | encodes as ct(table=27,zone=NXM_NX_REG11[0..15],nat) | |
790 | has prereqs ip | |
791 | ct_dnat(192.168.1.2); | |
792 | encodes as ct(commit,table=27,zone=NXM_NX_REG11[0..15],nat(dst=192.168.1.2)) | |
793 | has prereqs ip | |
794 | ||
795 | ct_dnat(192.168.1.2, 192.168.1.3); | |
796 | Syntax error at `,' expecting `)'. | |
797 | ct_dnat(foo); | |
798 | Syntax error at `foo' expecting IPv4 address. | |
799 | ct_dnat(foo, bar); | |
800 | Syntax error at `foo' expecting IPv4 address. | |
801 | ct_dnat(); | |
802 | Syntax error at `)' expecting IPv4 address. | |
803 | ||
804 | # ct_snat | |
805 | ct_snat; | |
806 | encodes as ct(zone=NXM_NX_REG12[0..15],nat) | |
807 | has prereqs ip | |
808 | ct_snat(192.168.1.2); | |
809 | encodes as ct(commit,table=27,zone=NXM_NX_REG12[0..15],nat(src=192.168.1.2)) | |
810 | has prereqs ip | |
811 | ||
812 | ct_snat(192.168.1.2, 192.168.1.3); | |
813 | Syntax error at `,' expecting `)'. | |
814 | ct_snat(foo); | |
815 | Syntax error at `foo' expecting IPv4 address. | |
816 | ct_snat(foo, bar); | |
817 | Syntax error at `foo' expecting IPv4 address. | |
818 | ct_snat(); | |
819 | Syntax error at `)' expecting IPv4 address. | |
de297547 | 820 | |
6335d074 | 821 | # arp |
d5a76da4 BP |
822 | arp { eth.dst = ff:ff:ff:ff:ff:ff; output; }; |
823 | encodes as 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) | |
824 | has prereqs ip4 | |
6335d074 | 825 | |
0bac7164 | 826 | # get_arp |
d5a76da4 BP |
827 | get_arp(outport, ip4.dst); |
828 | encodes as 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[] | |
829 | has prereqs eth.type == 0x800 | |
830 | get_arp(inport, reg0); | |
831 | encodes as 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[] | |
832 | ||
833 | get_arp; | |
834 | Syntax error at `;' expecting `('. | |
835 | get_arp(); | |
836 | Syntax error at `)' expecting field name. | |
837 | get_arp(inport); | |
838 | Syntax error at `)' expecting `,'. | |
839 | get_arp(inport ip4.dst); | |
840 | Syntax error at `ip4.dst' expecting `,'. | |
841 | get_arp(inport, ip4.dst; | |
842 | Syntax error at `;' expecting `)'. | |
843 | get_arp(inport, eth.dst); | |
844 | Cannot use 48-bit field eth.dst[0..47] where 32-bit field is required. | |
845 | get_arp(inport, outport); | |
846 | Cannot use string field outport where numeric field is required. | |
847 | get_arp(reg0, ip4.dst); | |
848 | Cannot use numeric field reg0 where string field is required. | |
0bac7164 BP |
849 | |
850 | # put_arp | |
d5a76da4 BP |
851 | put_arp(inport, arp.spa, arp.sha); |
852 | encodes as 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[] | |
853 | has prereqs eth.type == 0x806 && eth.type == 0x806 | |
0bac7164 | 854 | |
42814145 | 855 | # put_dhcp_opts |
d5a76da4 BP |
856 | reg1[0] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); |
857 | encodes as 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) | |
858 | reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,mtu=1400,domain="ovn.org"); | |
859 | formats as reg2[5] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.254.0, mtu = 1400, domain = "ovn.org"); | |
860 | encodes as 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) | |
861 | reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0); | |
862 | formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0); | |
863 | encodes as 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) | |
864 | ||
865 | reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); | |
866 | Cannot use 2-bit field reg1[0..1] where 1-bit field is required. | |
867 | reg1[0] = put_dhcp_opts(); | |
868 | put_dhcp_opts requires offerip to be specified. | |
869 | reg1[0] = put_dhcp_opts(x = 1.2.3.4, router = 10.0.0.1); | |
870 | Syntax error at `x' expecting DHCPv4 option name. | |
871 | reg1[0] = put_dhcp_opts(router = 10.0.0.1); | |
872 | put_dhcp_opts requires offerip to be specified. | |
873 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, "hi"); | |
874 | Syntax error at `"hi"'. | |
875 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, xyzzy); | |
876 | Syntax error at `xyzzy' expecting DHCPv4 option name. | |
877 | reg1[0] = put_dhcp_opts(offerip="xyzzy"); | |
878 | DHCPv4 option offerip requires numeric value. | |
879 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain=1.2.3.4); | |
880 | DHCPv4 option domain requires string value. | |
42814145 | 881 | |
f8a8db39 | 882 | # nd_na |
d5a76da4 BP |
883 | nd_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; }; |
884 | formats as nd_na { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; output; }; | |
885 | encodes as 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) | |
886 | has prereqs nd_ns | |
e75451fe | 887 | |
c34a87b6 | 888 | # get_nd |
d5a76da4 BP |
889 | get_nd(outport, ip6.dst); |
890 | encodes as 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[] | |
891 | has prereqs eth.type == 0x86dd | |
892 | get_nd(inport, xxreg0); | |
893 | encodes as 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[] | |
894 | get_nd; | |
895 | Syntax error at `;' expecting `('. | |
896 | get_nd(); | |
897 | Syntax error at `)' expecting field name. | |
898 | get_nd(inport); | |
899 | Syntax error at `)' expecting `,'. | |
900 | get_nd(inport ip6.dst); | |
901 | Syntax error at `ip6.dst' expecting `,'. | |
902 | get_nd(inport, ip6.dst; | |
903 | Syntax error at `;' expecting `)'. | |
904 | get_nd(inport, eth.dst); | |
905 | Cannot use 48-bit field eth.dst[0..47] where 128-bit field is required. | |
906 | get_nd(inport, outport); | |
907 | Cannot use string field outport where numeric field is required. | |
908 | get_nd(xxreg0, ip6.dst); | |
909 | Cannot use numeric field xxreg0 where string field is required. | |
c34a87b6 JP |
910 | |
911 | # put_nd | |
d5a76da4 BP |
912 | put_nd(inport, nd.target, nd.sll); |
913 | encodes as 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[] | |
914 | has 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) | |
c34a87b6 | 915 | |
01cfdb2f | 916 | # put_dhcpv6_opts |
d5a76da4 BP |
917 | reg1[0] = put_dhcpv6_opts(ia_addr = ae70::4, server_id = 00:00:00:00:10:02); |
918 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.05.00.10.00.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.04.02.00.06.00.00.00.00.00.10.02,pause) | |
919 | reg1[0] = put_dhcpv6_opts(); | |
920 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40,pause) | |
921 | reg1[0] = put_dhcpv6_opts(dns_server={ae70::1,ae70::2}); | |
922 | formats as reg1[0] = put_dhcpv6_opts(dns_server = {ae70::1, ae70::2}); | |
923 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.17.00.20.00.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.01.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.02,pause) | |
924 | reg1[0] = put_dhcpv6_opts(domain_search = "ovn.org"); | |
925 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.18.00.07.00.6f.76.6e.2e.6f.72.67,pause) | |
926 | reg1[0] = put_dhcpv6_opts(x = 1.2.3.4); | |
927 | Syntax error at `x' expecting DHCPv6 option name. | |
928 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, "hi"); | |
929 | Syntax error at `"hi"'. | |
930 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, xyzzy); | |
931 | Syntax error at `xyzzy' expecting DHCPv6 option name. | |
932 | reg1[0] = put_dhcpv6_opts(ia_addr="ae70::4"); | |
933 | DHCPv6 option ia_addr requires numeric value. | |
934 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, domain_search=ae70::1); | |
935 | DHCPv6 option domain_search requires string value. | |
01cfdb2f | 936 | |
5f822129 | 937 | # Contradictionary prerequisites (allowed but not useful): |
d5a76da4 BP |
938 | ip4.src = ip6.src[0..31]; |
939 | encodes as move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[] | |
940 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
941 | ip4.src <-> ip6.src[0..31]; | |
942 | encodes as push:NXM_NX_IPV6_SRC[0..31],push:NXM_OF_IP_SRC[],pop:NXM_NX_IPV6_SRC[0..31],pop:NXM_OF_IP_SRC[] | |
943 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
944 | ||
945 | # Miscellaneous negative tests. | |
946 | ; | |
947 | Syntax error at `;'. | |
948 | xyzzy; | |
949 | Syntax error at `xyzzy' expecting action. | |
950 | next; 123; | |
951 | Syntax error at `123'. | |
952 | next; xyzzy; | |
953 | Syntax error at `xyzzy' expecting action. | |
954 | next | |
9aef3c1b | 955 | Syntax error at end of input expecting `;'. |
3b7cb7e1 | 956 | ]]) |
d5a76da4 BP |
957 | sed '/^[[ ]]/d' test-cases.txt > input.txt |
958 | cp test-cases.txt expout | |
3b7cb7e1 BP |
959 | AT_CHECK([ovstest test-ovn parse-actions < input.txt], [0], [expout]) |
960 | AT_CLEANUP | |
f295c17b BP |
961 | |
962 | AT_BANNER([OVN end-to-end tests]) | |
963 | ||
9975d7be BP |
964 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor |
965 | AT_SETUP([ovn -- 3 HVs, 1 LS, 3 lports/HV]) | |
57d143eb | 966 | AT_KEYWORDS([ovnarp]) |
f295c17b BP |
967 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
968 | ovn_start | |
969 | ||
970 | # Create hypervisors hv[123]. | |
9975d7be | 971 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. |
f295c17b BP |
972 | # Add all of the vifs to a single logical switch lsw0. |
973 | # Turn on port security on all the vifs except vif[123]1. | |
974 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
975 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
ea46a4e9 | 976 | ovn-nbctl ls-add lsw0 |
f295c17b BP |
977 | net_add n1 |
978 | for i in 1 2 3; do | |
979 | sim_add hv$i | |
980 | as hv$i | |
981 | ovs-vsctl add-br br-phys | |
982 | ovn_attach n1 br-phys 192.168.0.$i | |
983 | ||
984 | for j in 1 2 3; do | |
985 | 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 | 986 | ovn-nbctl lsp-add lsw0 lp$i$j |
4d5c43d5 | 987 | if test $j = 1; then |
31ed1192 | 988 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
f295c17b | 989 | else |
7dc88496 NS |
990 | if test $j = 3; then |
991 | ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j" | |
992 | else | |
993 | ip_addrs="192.168.0.$i$j" | |
994 | fi | |
31ed1192 JP |
995 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs" |
996 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
f295c17b BP |
997 | fi |
998 | done | |
999 | done | |
1000 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1001 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop | |
1002 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop | |
ea382567 RB |
1003 | ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:11\",\"f0:00:00:00:00:21\",\"f0:00:00:00:00:31\" |
1004 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop | |
f295c17b BP |
1005 | |
1006 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1007 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1008 | # for ARP resolution). | |
1009 | ovn_populate_arp | |
1010 | ||
1011 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1012 | # XXX This should be more systematic. | |
1013 | sleep 1 | |
611099dc | 1014 | |
57d143eb HZ |
1015 | # Given the name of a logical port, prints the name of the hypervisor |
1016 | # on which it is located. | |
1017 | vif_to_hv() { | |
1018 | echo hv${1%?} | |
1019 | } | |
1020 | ||
f295c17b BP |
1021 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1022 | # | |
1023 | # This shell function causes a packet to be received on INPORT. The packet's | |
1024 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1025 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1026 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1027 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. |
f295c17b BP |
1028 | for i in 1 2 3; do |
1029 | for j in 1 2 3; do | |
1030 | : > $i$j.expected | |
1031 | done | |
1032 | done | |
1033 | test_packet() { | |
1034 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
57d143eb | 1035 | hv=`vif_to_hv $inport` |
f295c17b BP |
1036 | vif=vif$inport |
1037 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1038 | for outport; do | |
e4543cfe | 1039 | echo $packet >> $outport.expected |
f295c17b BP |
1040 | done |
1041 | } | |
1042 | ||
57d143eb HZ |
1043 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
1044 | # | |
1045 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1046 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1047 | # it should be the hardware address of the target to expect to receive in an | |
1048 | # ARP reply; otherwise no reply is expected. | |
1049 | # | |
31ed1192 | 1050 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
57d143eb HZ |
1051 | # SHA and REPLY_HA are each 12 hex digits. |
1052 | # SPA and TPA are each 8 hex digits. | |
1053 | test_arp() { | |
1054 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1055 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
1056 | hv=`vif_to_hv $inport` | |
1057 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
1058 | ||
92f9822b | 1059 | if test X$reply_ha = X; then |
57d143eb HZ |
1060 | # Expect to receive the broadcast ARP on the other logical switch ports |
1061 | # if no reply is expected. | |
1062 | local i j | |
1063 | for i in 1 2 3; do | |
1064 | for j in 1 2 3; do | |
1065 | if test $i$j != $inport; then | |
1066 | echo $request >> $i$j.expected | |
1067 | fi | |
1068 | done | |
1069 | done | |
1070 | else | |
1071 | # Expect to receive the reply, if any. | |
1072 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
1073 | echo $reply >> $inport.expected | |
1074 | fi | |
1075 | } | |
1076 | ||
1077 | ip_to_hex() { | |
1078 | printf "%02x%02x%02x%02x" "$@" | |
1079 | } | |
1080 | ||
f295c17b BP |
1081 | # Send packets between all pairs of source and destination ports: |
1082 | # | |
31ed1192 JP |
1083 | # 1. Unicast packets are delivered to exactly one logical switch port |
1084 | # (except that packets destined to their input ports are dropped). | |
f295c17b | 1085 | # |
31ed1192 JP |
1086 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1087 | # except the input port. | |
f295c17b | 1088 | # |
ea46a4e9 | 1089 | # 3. When port security is turned on, the switch drops packets from the wrong |
f295c17b BP |
1090 | # MAC address. |
1091 | # | |
ea46a4e9 | 1092 | # 4. The switch drops all packets with a VLAN tag. |
f295c17b | 1093 | # |
ea46a4e9 | 1094 | # 5. The switch drops all packets with a multicast source address. (This only |
f295c17b BP |
1095 | # affects behavior when port security is turned off, since otherwise port |
1096 | # security would drop the packet anyway.) | |
1097 | # | |
ea46a4e9 | 1098 | # 6. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1099 | # switch ports with "unknown" among their MAC addresses (and port |
1100 | # security disabled). | |
f295c17b | 1101 | # |
ea46a4e9 | 1102 | # 7. The switch drops unicast packets that violate an ACL. |
f295c17b | 1103 | # |
ea46a4e9 | 1104 | # 8. The switch drops multicast and broadcast packets that violate an ACL. |
57d143eb HZ |
1105 | # |
1106 | # 9. ARP requests to known IPs are responded directly. | |
1107 | # | |
1108 | # 10. No response to ARP requests for unknown IPs. | |
4acd1e87 | 1109 | |
f295c17b BP |
1110 | for is in 1 2 3; do |
1111 | for js in 1 2 3; do | |
1112 | s=$is$js | |
1113 | bcast= | |
4d5c43d5 JP |
1114 | unknown= |
1115 | bacl2= | |
1116 | bacl3= | |
f295c17b BP |
1117 | for id in 1 2 3; do |
1118 | for jd in 1 2 3; do | |
1119 | d=$id$jd | |
1120 | ||
1121 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1122 | test_packet $s f000000000$d f000000000$s $s$d $unicast #1 | |
1123 | ||
1124 | if test $d != $s && test $js = 1; then | |
4d5c43d5 JP |
1125 | impersonate=$d |
1126 | else | |
1127 | impersonate= | |
1128 | fi | |
f295c17b BP |
1129 | test_packet $s f000000000$d f00000000055 55$d $impersonate #3 |
1130 | ||
4d5c43d5 JP |
1131 | if test $d != $s && test $s != 11; then acl2=$d; else acl2=; fi |
1132 | if test $d != $s && test $d != 33; then acl3=$d; else acl3=; fi | |
e137131a | 1133 | if test $d = $s || (test $js = 1 && test $d = 33); then |
ea382567 RB |
1134 | # Source of 11, 21, or 31 and dest of 33 should be dropped |
1135 | # due to the 4th ACL that uses address_set(set1). | |
1136 | acl4= | |
1137 | else | |
1138 | acl4=$d | |
1139 | fi | |
f295c17b BP |
1140 | test_packet $s f000000000$d f000000000$s 1234 #7, acl1 |
1141 | test_packet $s f000000000$d f000000000$s 1235 $acl2 #7, acl2 | |
1142 | test_packet $s f000000000$d f000000000$s 1236 $acl3 #7, acl3 | |
ea382567 | 1143 | test_packet $s f000000000$d f000000000$s 1237 $acl4 #7, acl4 |
f295c17b BP |
1144 | |
1145 | test_packet $s f000000000$d f00000000055 810000091234 #4 | |
1146 | test_packet $s f000000000$d 0100000000$s $s$d #5 | |
1147 | ||
4d5c43d5 JP |
1148 | if test $d != $s && test $jd = 1; then |
1149 | unknown="$unknown $d" | |
1150 | fi | |
f295c17b BP |
1151 | bcast="$bcast $unicast" |
1152 | bacl2="$bacl2 $acl2" | |
1153 | bacl3="$bacl3 $acl3" | |
57d143eb HZ |
1154 | |
1155 | sip=`ip_to_hex 192 168 0 $i$j` | |
1156 | tip=`ip_to_hex 192 168 0 $id$jd` | |
1157 | tip_unknown=`ip_to_hex 11 11 11 11` | |
1158 | test_arp $s f000000000$s $sip $tip f000000000$d #9 | |
1159 | test_arp $s f000000000$s $sip $tip_unknown #10 | |
7dc88496 NS |
1160 | |
1161 | if test $jd = 3; then | |
31ed1192 | 1162 | # lsp[123]3 has an additional ip 192.169.0.[123]3. |
7dc88496 NS |
1163 | tip=`ip_to_hex 192 169 0 $id$jd` |
1164 | test_arp $s f000000000$s $sip $tip f000000000$d #9 | |
1165 | fi | |
f295c17b BP |
1166 | done |
1167 | done | |
1168 | ||
4d5c43d5 | 1169 | # Broadcast and multicast. |
f295c17b BP |
1170 | test_packet $s ffffffffffff f000000000$s ${s}ff $bcast #2 |
1171 | test_packet $s 010000000000 f000000000$s ${s}ff $bcast #2 | |
4d5c43d5 | 1172 | if test $js = 1; then |
f295c17b BP |
1173 | bcast_impersonate=$bcast |
1174 | else | |
4d5c43d5 JP |
1175 | bcast_impersonate= |
1176 | fi | |
f295c17b BP |
1177 | test_packet $s 010000000000 f00000000044 44ff $bcast_impersonate #3 |
1178 | ||
1179 | test_packet $s f0000000ffff f000000000$s ${s}66 $unknown #6 | |
1180 | ||
1181 | test_packet $s ffffffffffff f000000000$s 1234 #8, acl1 | |
1182 | test_packet $s ffffffffffff f000000000$s 1235 $bacl2 #8, acl2 | |
1183 | test_packet $s ffffffffffff f000000000$s 1236 $bacl3 #8, acl3 | |
1184 | test_packet $s 010000000000 f000000000$s 1234 #8, acl1 | |
1185 | test_packet $s 010000000000 f000000000$s 1235 $bacl2 #8, acl2 | |
1186 | test_packet $s 010000000000 f000000000$s 1236 $bacl3 #8, acl3 | |
1187 | done | |
1188 | done | |
1189 | ||
7dc88496 NS |
1190 | # set address for lp13 with invalid characters. |
1191 | # lp13 should be configured with only 192.168.0.13. | |
31ed1192 | 1192 | ovn-nbctl lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13" |
3b8cd0ea BP |
1193 | |
1194 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1195 | # XXX This should be more systematic. | |
1196 | sleep 1 | |
1197 | ||
7dc88496 NS |
1198 | sip=`ip_to_hex 192 168 0 11` |
1199 | tip=`ip_to_hex 192 168 0 13` | |
1200 | test_arp 11 f00000000011 $sip $tip f00000000013 | |
1201 | ||
1202 | tip=`ip_to_hex 192 169 0 13` | |
1203 | #arp request for 192.169.0.13 should be flooded | |
1204 | test_arp 11 f00000000011 $sip $tip | |
1205 | ||
91125642 | 1206 | # dump information and flows with counters |
bb0c41d3 RM |
1207 | ovn-sbctl dump-flows -- list multicast_group |
1208 | ||
1209 | echo "------ hv1 dump ------" | |
1210 | as hv1 ovs-vsctl show | |
1211 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1212 | ||
1213 | echo "------ hv2 dump ------" | |
1214 | as hv2 ovs-vsctl show | |
1215 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1216 | ||
1217 | echo "------ hv3 dump ------" | |
1218 | as hv3 ovs-vsctl show | |
1219 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
49d7c759 | 1220 | |
f295c17b BP |
1221 | # Now check the packets actually received against the ones expected. |
1222 | for i in 1 2 3; do | |
1223 | for j in 1 2 3; do | |
49d7c759 | 1224 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
f295c17b BP |
1225 | done |
1226 | done | |
fcde56f5 | 1227 | |
7a8f15e0 | 1228 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 1229 | |
f295c17b | 1230 | AT_CLEANUP |
eb6b08eb | 1231 | |
4acd1e87 BP |
1232 | AT_SETUP([ovn -- trace 1 LS, 3 LSPs]) |
1233 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1234 | ovn_start | |
1235 | ||
1236 | # Create a logical switch and some logical ports. | |
1237 | # Turn on port security on all lports except ls1. | |
1238 | # Make ls1 a destination for unknown MACs. | |
1239 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
1240 | ovn-nbctl ls-add lsw0 | |
1241 | ovn-sbctl chassis-add hv0 geneve 127.0.0.1 | |
1242 | for i in 1 2 3; do | |
1243 | ovn-nbctl lsp-add lsw0 lp$i | |
1244 | ovn-sbctl lsp-bind lp$i hv0 | |
1245 | if test $i = 1; then | |
abb37b6b | 1246 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:0$i 192.168.0.$i" unknown |
4acd1e87 | 1247 | else |
abb37b6b FF |
1248 | if test $i = 3; then |
1249 | ip_addrs="192.168.0.$i fe80::ea2a:eaff:fe28:$i/64 192.169.0.$i" | |
1250 | else | |
1251 | ip_addrs="192.168.0.$i" | |
1252 | fi | |
1253 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:$i $ip_addrs" | |
1254 | ovn-nbctl lsp-set-port-security lp$i f0:00:00:00:00:$i | |
4acd1e87 BP |
1255 | fi |
1256 | done | |
1257 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1258 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp1"' drop | |
1259 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp3"' drop | |
1260 | ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:01\",\"f0:00:00:00:00:02\" | |
1261 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp3"' drop | |
1262 | ||
1263 | ovn-nbctl --wait=sb sync | |
1264 | on_exit 'kill `cat ovn-trace.pid`' | |
1265 | ovn-trace --detach --pidfile --no-chdir | |
1266 | ||
1267 | # test_packet INPORT DST SRC [-vlan] [-eth TYPE] OUTPORT... | |
1268 | # | |
1269 | # This shell function causes a packet to be received on INPORT. The packet's | |
1270 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1271 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1272 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1273 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. | |
1274 | test_packet() { | |
1275 | local inport=$1 eth_dst=$2 eth_src=$3; shift; shift; shift | |
1276 | uflow="inport==\"lp$inport\" && eth.dst==$eth_dst && eth.src==$eth_src" | |
1277 | while :; do | |
abb37b6b FF |
1278 | case $1 in # ( |
1279 | -vlan) uflow="$uflow && vlan.vid == 1234"; shift ;; # ( | |
1280 | -eth) uflow="$uflow && eth.type == 0x$2"; shift; shift ;; # ( | |
1281 | *) break ;; | |
1282 | esac | |
4acd1e87 BP |
1283 | done |
1284 | for outport; do | |
abb37b6b | 1285 | echo "output(\"lp$outport\");" |
4acd1e87 BP |
1286 | done > expout |
1287 | ||
1288 | AT_CAPTURE_FILE([trace]) | |
1289 | AT_CHECK([ovs-appctl -t ovn-trace trace --all lsw0 "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
1290 | } | |
1291 | ||
1292 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
1293 | # | |
1294 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1295 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1296 | # it should be the hardware address of the target to expect to receive in an | |
1297 | # ARP reply; otherwise no reply is expected. | |
1298 | # | |
1299 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
1300 | # SHA and REPLY_HA are each 12 hex digits. | |
1301 | # SPA and TPA are each 8 hex digits. | |
1302 | test_arp() { | |
1303 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1304 | ||
1305 | local request="inport == \"lp$inport\" | |
1306 | && eth.dst == ff:ff:ff:ff:ff:ff && eth.src == $sha | |
1307 | && arp.op == 1 && arp.sha == $sha && arp.spa == $spa | |
abb37b6b | 1308 | && arp.tha == ff:ff:ff:ff:ff:ff && arp.tpa == $tpa" |
4acd1e87 BP |
1309 | |
1310 | if test -z "$reply_ha"; then | |
1311 | reply= | |
abb37b6b FF |
1312 | local i |
1313 | for i in 1 2 3; do | |
1314 | if test $i != $inport; then | |
1315 | reply="${reply}output(\"lp$i\"); | |
4acd1e87 | 1316 | " |
abb37b6b FF |
1317 | fi |
1318 | done | |
4acd1e87 BP |
1319 | else |
1320 | reply="\ | |
1321 | eth.dst = $sha; | |
1322 | eth.src = $reply_ha; | |
1323 | arp.op = 2; | |
1324 | arp.tha = $sha; | |
1325 | arp.sha = $reply_ha; | |
1326 | arp.tpa = $spa; | |
1327 | arp.spa = $tpa; | |
1328 | output(\"lp$inport\"); | |
1329 | " | |
1330 | fi | |
1331 | ||
1332 | AT_CAPTURE_FILE([trace]) | |
1333 | AT_CHECK_UNQUOTED([ovs-appctl -t ovn-trace trace --all lsw0 "$request" | tee trace | sed '1,/Minimal trace/d'], [0], [$reply]) | |
1334 | } | |
1335 | ||
1336 | # Send packets between all pairs of source and destination ports: | |
1337 | # | |
1338 | # 1. Unicast packets are delivered to exactly one logical switch port | |
1339 | # (except that packets destined to their input ports are dropped). | |
1340 | # | |
1341 | # 2. Broadcast and multicast are delivered to all logical switch ports | |
1342 | # except the input port. | |
1343 | # | |
1344 | # 3. When port security is turned on, the switch drops packets from the wrong | |
1345 | # MAC address. | |
1346 | # | |
1347 | # 4. The switch drops all packets with a VLAN tag. | |
1348 | # | |
1349 | # 5. The switch drops all packets with a multicast source address. (This only | |
1350 | # affects behavior when port security is turned off, since otherwise port | |
1351 | # security would drop the packet anyway.) | |
1352 | # | |
1353 | # 6. The switch delivers packets with an unknown destination to logical | |
1354 | # switch ports with "unknown" among their MAC addresses (and port | |
1355 | # security disabled). | |
1356 | # | |
1357 | # 7. The switch drops unicast packets that violate an ACL. | |
1358 | # | |
1359 | # 8. The switch drops multicast and broadcast packets that violate an ACL. | |
1360 | # | |
1361 | # 9. ARP requests to known IPs are responded directly. | |
1362 | # | |
1363 | # 10. No response to ARP requests for unknown IPs. | |
1364 | ||
1365 | for s in 1 2 3; do | |
1366 | bcast= | |
1367 | unknown= | |
1368 | bacl2= | |
1369 | bacl3= | |
1370 | for d in 1 2 3; do | |
abb37b6b FF |
1371 | echo |
1372 | echo "lp$s -> lp$d" | |
1373 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1374 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s $unicast #1 | |
1375 | ||
1376 | if test $d != $s && test $s = 1; then | |
1377 | impersonate=$d | |
1378 | else | |
1379 | impersonate= | |
1380 | fi | |
1381 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 $impersonate #3 | |
1382 | ||
1383 | if test $d != $s && test $s != 1; then acl2=$d; else acl2=; fi | |
1384 | if test $d != $s && test $d != 3; then acl3=$d; else acl3=; fi | |
1385 | if test $d = $s || ( (test $s = 1 || test $s = 2) && test $d = 3); then | |
1386 | # Source of 1 or 2 and dest of 3 should be dropped | |
1387 | # due to the 4th ACL that uses address_set(set1). | |
1388 | acl4= | |
1389 | else | |
1390 | acl4=$d | |
1391 | fi | |
1392 | ||
1393 | #7, acl1 to acl4: | |
1394 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1234 | |
1395 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1235 $acl2 | |
1396 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1236 $acl3 | |
1397 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1237 $acl4 | |
1398 | ||
1399 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 -vlan #4 | |
1400 | test_packet $s f0:00:00:00:00:0$d 01:00:00:00:00:0$s #5 | |
1401 | ||
1402 | if test $d != $s && test $d = 1; then | |
1403 | unknown="$unknown $d" | |
1404 | fi | |
1405 | bcast="$bcast $unicast" | |
1406 | bacl2="$bacl2 $acl2" | |
1407 | bacl3="$bacl3 $acl3" | |
1408 | ||
1409 | sip=192.168.0.$s | |
1410 | tip=192.168.0.$d | |
1411 | tip_unknown=11.11.11.11 | |
1412 | test_arp $s f0:00:00:00:00:0$s $sip $tip f0:00:00:00:00:0$d #9 | |
1413 | test_arp $s f0:00:00:00:00:0$s $sip $tip_unknown #10 | |
1414 | ||
1415 | if test $d = 3; then | |
1416 | # lp3 has an additional ip 192.169.0.[123]3. | |
1417 | tip=192.169.0.$d | |
1418 | test_arp $s f0:00:00:00:00:0$s $sip $tip f0:00:00:00:00:0$d #9 | |
1419 | fi | |
4acd1e87 BP |
1420 | done |
1421 | ||
1422 | # Broadcast and multicast. | |
1423 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s $bcast #2 | |
1424 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s $bcast #2 | |
1425 | if test $s = 1; then | |
abb37b6b | 1426 | bcast_impersonate=$bcast |
4acd1e87 | 1427 | else |
abb37b6b | 1428 | bcast_impersonate= |
4acd1e87 BP |
1429 | fi |
1430 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:44 $bcast_impersonate #3 | |
1431 | ||
1432 | test_packet $s f0:00:00:00:ff:ff f0:00:00:00:00:0$s $unknown #6 | |
1433 | ||
1434 | #8, acl1 to acl3: | |
1435 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1234 | |
1436 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
1437 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
1438 | ||
1439 | #8, acl1 to acl3: | |
1440 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1234 | |
1441 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
1442 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
1443 | done | |
1444 | ||
1445 | AT_CLEANUP | |
1446 | ||
7277bc83 RB |
1447 | # 2 hypervisors, 4 logical ports per HV |
1448 | # 2 locally attached networks (one flat, one vlan tagged over same device) | |
1449 | # 2 ports per HV on each network | |
e90aeb57 | 1450 | AT_SETUP([ovn -- 2 HVs, 4 lports/HV, localnet ports]) |
d79fc5f4 RB |
1451 | AT_KEYWORDS([ovn-localnet]) |
1452 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1453 | ovn_start | |
1454 | ||
ea46a4e9 JP |
1455 | # In this test cases we create 3 switches, all connected to same |
1456 | # physical network (through br-phys on each HV). Each switch has | |
0ee7f7f1 HZ |
1457 | # VIF ports across 2 HVs. Each HV has 5 VIF ports. The first digit |
1458 | # of VIF port name indicates the hypervisor it is bound to, e.g. | |
1459 | # lp23 means VIF 3 on hv2. | |
1460 | # | |
ea46a4e9 | 1461 | # Each switch's VLAN tag and their logical switch ports are: |
0ee7f7f1 HZ |
1462 | # - ls1: |
1463 | # - untagged | |
ea46a4e9 | 1464 | # - ports: lp11, lp12, lp21, lp22 |
0ee7f7f1 HZ |
1465 | # |
1466 | # - ls2: | |
1467 | # - tagged with VLAN 101 | |
ea46a4e9 | 1468 | # - ports: lp13, lp14, lp23, lp24 |
0ee7f7f1 HZ |
1469 | # - ls3: |
1470 | # - untagged | |
ea46a4e9 | 1471 | # - ports: lp15, lp25 |
0ee7f7f1 | 1472 | # |
ea46a4e9 | 1473 | # Note: a localnet port is created for each switch to connect to |
0ee7f7f1 HZ |
1474 | # physical network. |
1475 | ||
1476 | for i in 1 2 3; do | |
ea46a4e9 JP |
1477 | ls_name=ls$i |
1478 | ovn-nbctl ls-add $ls_name | |
0ee7f7f1 HZ |
1479 | ln_port_name=ln$i |
1480 | if test $i -eq 2; then | |
ea46a4e9 | 1481 | ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 |
0ee7f7f1 | 1482 | else |
ea46a4e9 | 1483 | ovn-nbctl lsp-add $ls_name $ln_port_name |
0ee7f7f1 | 1484 | fi |
31ed1192 JP |
1485 | ovn-nbctl lsp-set-addresses $ln_port_name unknown |
1486 | ovn-nbctl lsp-set-type $ln_port_name localnet | |
1487 | ovn-nbctl lsp-set-options $ln_port_name network_name=phys | |
0ee7f7f1 | 1488 | done |
d79fc5f4 RB |
1489 | |
1490 | net_add n1 | |
1491 | for i in 1 2; do | |
1492 | sim_add hv$i | |
1493 | as hv$i | |
1494 | ovs-vsctl add-br br-phys | |
1495 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
1496 | ovn_attach n1 br-phys 192.168.0.$i | |
1497 | ||
0ee7f7f1 | 1498 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
1499 | ovs-vsctl add-port br-int vif$i$j -- \ |
1500 | set Interface vif$i$j external-ids:iface-id=lp$i$j \ | |
1501 | options:tx_pcap=hv$i/vif$i$j-tx.pcap \ | |
1502 | options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ | |
1503 | ofport-request=$i$j | |
1504 | ||
31ed1192 | 1505 | lsp_name=lp$i$j |
7277bc83 | 1506 | if test $j -le 2; then |
ea46a4e9 | 1507 | ls_name=ls1 |
0ee7f7f1 | 1508 | elif test $j -le 4; then |
ea46a4e9 | 1509 | ls_name=ls2 |
d79fc5f4 | 1510 | else |
ea46a4e9 | 1511 | ls_name=ls3 |
d79fc5f4 | 1512 | fi |
d79fc5f4 | 1513 | |
ea46a4e9 | 1514 | ovn-nbctl lsp-add $ls_name $lsp_name |
31ed1192 JP |
1515 | ovn-nbctl lsp-set-addresses $lsp_name f0:00:00:00:00:$i$j |
1516 | ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$j | |
d79fc5f4 | 1517 | |
31ed1192 | 1518 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) |
d79fc5f4 RB |
1519 | done |
1520 | done | |
1521 | ||
1522 | ovn_populate_arp | |
1523 | ||
1524 | # XXX This is now the 3rd copy of these functions in this file ... | |
1525 | ||
1526 | # Given the name of a logical port, prints the name of the hypervisor | |
1527 | # on which it is located. | |
1528 | vif_to_hv() { | |
1529 | echo hv${1%?} | |
1530 | } | |
1531 | # | |
1532 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... | |
1533 | # | |
1534 | # This shell function causes a packet to be received on INPORT. The packet's | |
1535 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1536 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1537 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1538 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. |
d79fc5f4 | 1539 | for i in 1 2; do |
0ee7f7f1 | 1540 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
1541 | : > $i$j.expected |
1542 | done | |
1543 | done | |
1544 | test_packet() { | |
1545 | local inport=$1 src=$2 dst=$3 eth=$4; shift; shift; shift; shift | |
1546 | local packet=${src}${dst}${eth} | |
1547 | hv=`vif_to_hv $inport` | |
1548 | vif=vif$inport | |
1549 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1550 | for outport; do | |
e4543cfe | 1551 | echo $packet >> $outport.expected |
d79fc5f4 RB |
1552 | done |
1553 | } | |
1554 | ||
7277bc83 RB |
1555 | # lp11 and lp21 are on the same network (phys, untagged) |
1556 | # and on different hypervisors | |
d79fc5f4 RB |
1557 | test_packet 11 f00000000021 f00000000011 1121 21 |
1558 | test_packet 21 f00000000011 f00000000021 2111 11 | |
1559 | ||
7277bc83 RB |
1560 | # lp11 and lp12 are on the same network (phys, untagged) |
1561 | # and on the same hypervisor | |
e90aeb57 RB |
1562 | test_packet 11 f00000000012 f00000000011 1112 12 |
1563 | test_packet 12 f00000000011 f00000000012 1211 11 | |
7277bc83 RB |
1564 | |
1565 | # lp13 and lp23 are on the same network (phys, VLAN 101) | |
1566 | # and on different hypervisors | |
1567 | test_packet 13 f00000000023 f00000000013 1323 23 | |
1568 | test_packet 23 f00000000013 f00000000023 2313 13 | |
1569 | ||
1570 | # lp13 and lp14 are on the same network (phys, VLAN 101) | |
1571 | # and on the same hypervisor | |
e90aeb57 RB |
1572 | test_packet 13 f00000000014 f00000000013 1314 14 |
1573 | test_packet 14 f00000000013 f00000000014 1413 13 | |
d79fc5f4 | 1574 | |
0ee7f7f1 | 1575 | # lp11 and lp15 are on the same network (phys, untagged), |
ea46a4e9 | 1576 | # same hypervisor, and on different switches |
0ee7f7f1 HZ |
1577 | test_packet 11 f00000000015 f00000000011 1115 15 |
1578 | test_packet 15 f00000000011 f00000000015 1511 11 | |
1579 | ||
1580 | # lp11 and lp25 are on the same network (phys, untagged), | |
ea46a4e9 | 1581 | # different hypervisors, and on different switches |
0ee7f7f1 HZ |
1582 | test_packet 11 f00000000025 f00000000011 1125 25 |
1583 | test_packet 25 f00000000011 f00000000025 2511 11 | |
1584 | ||
d79fc5f4 | 1585 | # Ports that should not be able to communicate |
7277bc83 RB |
1586 | test_packet 11 f00000000013 f00000000011 1113 |
1587 | test_packet 11 f00000000023 f00000000011 1123 | |
1588 | test_packet 21 f00000000013 f00000000021 2113 | |
1589 | test_packet 21 f00000000023 f00000000021 2123 | |
1590 | test_packet 13 f00000000011 f00000000013 1311 | |
1591 | test_packet 13 f00000000021 f00000000013 1321 | |
1592 | test_packet 23 f00000000011 f00000000023 2311 | |
1593 | test_packet 23 f00000000021 f00000000023 2321 | |
d79fc5f4 | 1594 | |
d79fc5f4 RB |
1595 | # Dump a bunch of info helpful for debugging if there's a failure. |
1596 | ||
1597 | echo "------ OVN dump ------" | |
1598 | ovn-nbctl show | |
1599 | ovn-sbctl show | |
1600 | ||
1601 | echo "------ hv1 dump ------" | |
1602 | as hv1 ovs-vsctl show | |
1603 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1604 | ||
1605 | echo "------ hv2 dump ------" | |
1606 | as hv2 ovs-vsctl show | |
1607 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1608 | ||
1609 | # Now check the packets actually received against the ones expected. | |
1610 | for i in 1 2; do | |
0ee7f7f1 | 1611 | for j in 1 2 3 4 5; do |
49d7c759 | 1612 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
d79fc5f4 RB |
1613 | done |
1614 | done | |
1615 | ||
7a8f15e0 | 1616 | OVN_CLEANUP([hv1],[hv2]) |
d9c8c57c | 1617 | |
d79fc5f4 RB |
1618 | AT_CLEANUP |
1619 | ||
91125642 FF |
1620 | AT_SETUP([ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS]) |
1621 | AT_KEYWORDS([vtep]) | |
eb6b08eb JP |
1622 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1623 | ovn_start | |
1624 | ||
1625 | # Configure the Northbound database | |
ea46a4e9 | 1626 | ovn-nbctl ls-add lsw0 |
eb6b08eb | 1627 | |
31ed1192 JP |
1628 | ovn-nbctl lsp-add lsw0 lp1 |
1629 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
eb6b08eb | 1630 | |
31ed1192 JP |
1631 | ovn-nbctl lsp-add lsw0 lp2 |
1632 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
eb6b08eb | 1633 | |
31ed1192 JP |
1634 | ovn-nbctl lsp-add lsw0 lp-vtep |
1635 | ovn-nbctl lsp-set-type lp-vtep vtep | |
1636 | ovn-nbctl lsp-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0 | |
1637 | ovn-nbctl lsp-set-addresses lp-vtep unknown | |
eb6b08eb JP |
1638 | |
1639 | net_add n1 # Network to connect hv1, hv2, and vtep | |
1640 | net_add n2 # Network to connect vtep and hv3 | |
1641 | ||
1642 | # Create hypervisor hv1 connected to n1 | |
1643 | sim_add hv1 | |
1644 | as hv1 | |
1645 | ovs-vsctl add-br br-phys | |
1646 | ovn_attach n1 br-phys 192.168.0.1 | |
1647 | ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=hv1/vif1-tx.pcap options:rxq_pcap=hv1/vif1-rx.pcap ofport-request=1 | |
1648 | ||
1649 | # Create hypervisor hv2 connected to n1 | |
1650 | sim_add hv2 | |
1651 | as hv2 | |
1652 | ovs-vsctl add-br br-phys | |
1653 | ovn_attach n1 br-phys 192.168.0.2 | |
1654 | ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=hv2/vif2-tx.pcap options:rxq_pcap=hv2/vif2-rx.pcap ofport-request=1 | |
1655 | ||
1656 | ||
1657 | # Start the vtep emulator with a leg in both networks | |
1658 | sim_add vtep | |
1659 | as vtep | |
1660 | ||
1661 | ovsdb-tool create "$ovs_base"/vtep/vtep.db "$abs_top_srcdir"/vtep/vtep.ovsschema || return 1 | |
1662 | ovs-appctl -t ovsdb-server ovsdb-server/add-db "$ovs_base"/vtep/vtep.db | |
1663 | ||
1664 | ovs-vsctl add-br br-phys | |
1665 | net_attach n1 br-phys | |
1666 | ||
1667 | mac=`ovs-vsctl get Interface br-phys mac_in_use | sed s/\"//g` | |
1668 | arp_table="$arp_table $sandbox,br-phys,192.168.0.3,$mac" | |
1669 | ovs-appctl netdev-dummy/ip4addr br-phys 192.168.0.3/24 >/dev/null || return 1 | |
1670 | ovs-appctl ovs/route/add 192.168.0.3/24 br-phys >/dev/null || return 1 | |
1671 | ||
1672 | ovs-vsctl add-br br-vtep | |
1673 | net_attach n2 br-vtep | |
1674 | ||
1675 | vtep-ctl add-ps br-vtep | |
1676 | vtep-ctl set Physical_Switch br-vtep tunnel_ips=192.168.0.3 | |
1677 | vtep-ctl add-ls lsw0 | |
1678 | ||
1679 | start_daemon ovs-vtep br-vtep | |
1680 | start_daemon ovn-controller-vtep --vtep-db=unix:"$ovs_base"/vtep/db.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
1681 | ||
1682 | sleep 1 | |
1683 | ||
1684 | vtep-ctl bind-ls br-vtep br-vtep_n2 0 lsw0 | |
1685 | ||
475f0a2c DB |
1686 | OVS_WAIT_UNTIL([test -n "`as vtep vtep-ctl get-replication-mode lsw0 | |
1687 | grep -- source`"]) | |
1688 | # It takes more time for the update to be processed by ovs-vtep. | |
eb6b08eb JP |
1689 | sleep 1 |
1690 | ||
1691 | # Add hv3 on the other side of the vtep | |
1692 | sim_add hv3 | |
1693 | as hv3 | |
1694 | ovs-vsctl add-br br-phys | |
1695 | net_attach n2 br-phys | |
1696 | ||
1697 | ovs-vsctl add-port br-phys vif3 -- set Interface vif3 options:tx_pcap=hv3/vif3-tx.pcap options:rxq_pcap=hv3/vif3-rx.pcap ofport-request=1 | |
1698 | ||
1699 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1700 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1701 | # for ARP resolution). | |
1702 | ovn_populate_arp | |
1703 | ||
1704 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1705 | # XXX This should be more systematic. | |
1706 | sleep 1 | |
6977df72 | 1707 | |
eb6b08eb JP |
1708 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1709 | # | |
1710 | # This shell function causes a packet to be received on INPORT. The packet's | |
1711 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1712 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1713 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1714 | # OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1. |
eb6b08eb JP |
1715 | for i in 1 2 3; do |
1716 | : > $i.expected | |
1717 | done | |
1718 | test_packet() { | |
1719 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
1720 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
1721 | hv=hv$inport | |
1722 | vif=vif$inport | |
1723 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1724 | for outport; do | |
e4543cfe | 1725 | echo $packet >> $outport.expected |
eb6b08eb JP |
1726 | done |
1727 | } | |
1728 | ||
1729 | # Send packets between all pairs of source and destination ports: | |
1730 | # | |
31ed1192 JP |
1731 | # 1. Unicast packets are delivered to exactly one logical switch port |
1732 | # (except that packets destined to their input ports are dropped). | |
eb6b08eb | 1733 | # |
31ed1192 JP |
1734 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1735 | # except the input port. | |
eb6b08eb | 1736 | # |
ea46a4e9 | 1737 | # 3. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1738 | # switch ports with "unknown" among their MAC addresses (and port |
1739 | # security disabled). | |
eb6b08eb JP |
1740 | for s in 1 2 3; do |
1741 | bcast= | |
1742 | unknown= | |
1743 | for d in 1 2 3; do | |
1744 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1745 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
1746 | ||
1747 | # The vtep (vif3) is the only one configured for "unknown" | |
1748 | if test $d != $s && test $d = 3; then | |
1749 | unknown="$unknown $d" | |
1750 | fi | |
1751 | bcast="$bcast $unicast" | |
1752 | done | |
1753 | ||
1754 | # Broadcast and multicast. | |
46ed1382 DB |
1755 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 |
1756 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #2 | |
eb6b08eb JP |
1757 | |
1758 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #3 | |
1759 | done | |
1760 | ||
bb0c41d3 RM |
1761 | # dump information with counters |
1762 | echo "------ OVN dump ------" | |
1763 | ovn-nbctl show | |
1764 | ovn-sbctl show | |
1765 | ||
1766 | echo "------ hv1 dump ------" | |
1767 | as hv1 ovs-vsctl show | |
6195e2e7 | 1768 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
1769 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
1770 | ||
1771 | echo "------ hv2 dump ------" | |
1772 | as hv2 ovs-vsctl show | |
6195e2e7 | 1773 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
1774 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
1775 | ||
1776 | echo "------ hv3 dump ------" | |
1777 | as hv3 ovs-vsctl show | |
6754e92d FF |
1778 | # note: hv3 has no logical port bind, thus it should not have br-int |
1779 | AT_CHECK([as hv3 ovs-ofctl -O OpenFlow13 show br-int], [1], [], | |
1780 | [ovs-ofctl: br-int is not a bridge or a socket | |
1781 | ]) | |
bb0c41d3 | 1782 | |
eb6b08eb JP |
1783 | # Now check the packets actually received against the ones expected. |
1784 | for i in 1 2 3; do | |
49d7c759 | 1785 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
eb6b08eb | 1786 | done |
fcde56f5 LR |
1787 | |
1788 | # Gracefully terminate daemons | |
7a8f15e0 LR |
1789 | OVN_CLEANUP([hv1],[hv2],[vtep]) |
1790 | OVN_CLEANUP_VSWITCH([hv3]) | |
d9c8c57c | 1791 | |
eb6b08eb | 1792 | AT_CLEANUP |
9975d7be | 1793 | |
184bc3ca RB |
1794 | # Similar test to "hardware GW" |
1795 | AT_SETUP([ovn -- 3 HVs, 1 VIFs/HV, 1 software GW, 1 LS]) | |
1796 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1797 | ovn_start | |
1798 | ||
1799 | # Configure the Northbound database | |
1800 | ovn-nbctl ls-add lsw0 | |
1801 | ||
1802 | ovn-nbctl lsp-add lsw0 lp1 | |
1803 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
1804 | ||
1805 | ovn-nbctl lsp-add lsw0 lp2 | |
1806 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
1807 | ||
1808 | ovn-nbctl lsp-add lsw0 lp-gw | |
1809 | ovn-nbctl lsp-set-type lp-gw l2gateway | |
62b87eab | 1810 | ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw |
184bc3ca RB |
1811 | ovn-nbctl lsp-set-addresses lp-gw unknown |
1812 | ||
1813 | net_add n1 # Network to connect hv1, hv2, and gw | |
1814 | net_add n2 # Network to connect gw and hv3 | |
1815 | ||
1816 | # Create hypervisor hv1 connected to n1 | |
1817 | sim_add hv1 | |
1818 | as hv1 | |
1819 | ovs-vsctl add-br br-phys | |
1820 | ovn_attach n1 br-phys 192.168.0.1 | |
1821 | ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=hv1/vif1-tx.pcap options:rxq_pcap=hv1/vif1-rx.pcap ofport-request=1 | |
1822 | ||
1823 | # Create hypervisor hv2 connected to n1 | |
1824 | sim_add hv2 | |
1825 | as hv2 | |
1826 | ovs-vsctl add-br br-phys | |
1827 | ovn_attach n1 br-phys 192.168.0.2 | |
1828 | ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=hv2/vif2-tx.pcap options:rxq_pcap=hv2/vif2-rx.pcap ofport-request=1 | |
1829 | ||
1830 | # Create hypervisor hv_gw connected to n1 and n2 | |
1831 | # connect br-phys bridge to n1; connect hv-gw bridge to n2 | |
1832 | sim_add hv_gw | |
1833 | as hv_gw | |
1834 | ovs-vsctl add-br br-phys | |
1835 | ovn_attach n1 br-phys 192.168.0.3 | |
1836 | ovs-vsctl add-br br-phys2 | |
1837 | net_attach n2 br-phys2 | |
1838 | ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2" | |
1839 | ||
184bc3ca RB |
1840 | # Add hv3 on the other side of the GW |
1841 | sim_add hv3 | |
1842 | as hv3 | |
1843 | ovs-vsctl add-br br-phys | |
1844 | net_attach n2 br-phys | |
1845 | ovs-vsctl add-port br-phys vif3 -- set Interface vif3 options:tx_pcap=hv3/vif3-tx.pcap options:rxq_pcap=hv3/vif3-rx.pcap ofport-request=1 | |
1846 | ||
1847 | ||
1848 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1849 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1850 | # for ARP resolution). | |
1851 | ovn_populate_arp | |
1852 | ||
1853 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1854 | # XXX This should be more systematic. | |
1855 | sleep 1 | |
1856 | ||
1857 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... | |
1858 | # | |
1859 | # This shell function causes a packet to be received on INPORT. The packet's | |
1860 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1861 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1862 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1863 | # OUTPORTs are specified as lport numbers, e.g. 1 for vif1. | |
184bc3ca RB |
1864 | for i in 1 2 3; do |
1865 | : > $i.expected | |
1866 | done | |
1867 | test_packet() { | |
1868 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
1869 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
1870 | hv=hv$inport | |
1871 | vif=vif$inport | |
1872 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1873 | for outport; do | |
e4543cfe | 1874 | echo $packet >> $outport.expected |
184bc3ca RB |
1875 | done |
1876 | } | |
1877 | ||
1878 | # Send packets between all pairs of source and destination ports: | |
1879 | # | |
1880 | # 1. Unicast packets are delivered to exactly one lport (except that packets | |
1881 | # destined to their input ports are dropped). | |
1882 | # | |
1883 | # 2. Broadcast and multicast are delivered to all lports except the input port. | |
1884 | # | |
1885 | # 3. The lswitch delivers packets with an unknown destination to lports with | |
1886 | # "unknown" among their MAC addresses (and port security disabled). | |
1887 | for s in 1 2 3 ; do | |
1888 | bcast= | |
1889 | unknown= | |
1890 | for d in 1 2 3 ; do | |
1891 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1892 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
1893 | ||
1894 | # The vtep (vif3) is the only one configured for "unknown" | |
1895 | if test $d != $s && test $d = 3; then | |
1896 | unknown="$unknown $d" | |
1897 | fi | |
1898 | bcast="$bcast $unicast" | |
1899 | done | |
1900 | ||
1901 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 | |
1902 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #3 | |
1903 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #4 | |
1904 | done | |
1905 | ||
184bc3ca RB |
1906 | echo "------ ovn-nbctl show ------" |
1907 | ovn-nbctl show | |
1908 | echo "------ ovn-sbctl show ------" | |
1909 | ovn-sbctl show | |
1910 | ||
1911 | echo "------ hv1 ------" | |
1912 | as hv1 ovs-vsctl show | |
1913 | echo "------ hv1 br-int ------" | |
1914 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1915 | echo "------ hv1 br-phys ------" | |
1916 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
1917 | ||
1918 | echo "------ hv2 ------" | |
1919 | as hv2 ovs-vsctl show | |
1920 | echo "------ hv2 br-int ------" | |
1921 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1922 | echo "------ hv2 br-phys ------" | |
1923 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
1924 | ||
1925 | echo "------ hv_gw ------" | |
1926 | as hv_gw ovs-vsctl show | |
1927 | echo "------ hv_gw br-phys ------" | |
1928 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
1929 | echo "------ hv_gw br-phys2 ------" | |
1930 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys2 | |
1931 | ||
1932 | echo "------ hv3 ------" | |
1933 | as hv3 ovs-vsctl show | |
1934 | echo "------ hv3 br-phys ------" | |
1935 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
1936 | ||
1937 | # Now check the packets actually received against the ones expected. | |
1938 | for i in 1 2 3; do | |
49d7c759 | 1939 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
184bc3ca RB |
1940 | done |
1941 | AT_CLEANUP | |
1942 | ||
9975d7be BP |
1943 | # 3 hypervisors, 3 logical switches with 3 logical ports each, 1 logical router |
1944 | AT_SETUP([ovn -- 3 HVs, 3 LS, 3 lports/LS, 1 LR]) | |
1945 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1946 | ovn_start | |
1947 | ||
1948 | # Logical network: | |
1949 | # | |
1950 | # Three logical switches ls1, ls2, ls3. | |
86e98048 BP |
1951 | # One logical router lr0 connected to ls[123], |
1952 | # with nine subnets, three per logical switch: | |
1953 | # | |
1954 | # lrp11 on ls1 for subnet 192.168.11.0/24 | |
1955 | # lrp12 on ls1 for subnet 192.168.12.0/24 | |
1956 | # lrp13 on ls1 for subnet 192.168.13.0/24 | |
1957 | # ... | |
1958 | # lrp33 on ls3 for subnet 192.168.33.0/24 | |
1959 | # | |
1960 | # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two | |
1961 | # digits are the subnet and the last digit distinguishes the VIF. | |
9975d7be | 1962 | for i in 1 2 3; do |
ea46a4e9 | 1963 | ovn-nbctl ls-add ls$i |
9975d7be | 1964 | for j in 1 2 3; do |
86e98048 | 1965 | for k in 1 2 3; do |
31ed1192 JP |
1966 | # Add "unknown" to MAC addresses for lp?11, so packets for |
1967 | # MAC-IP bindings discovered via ARP later have somewhere to go. | |
1968 | if test $j$k = 11; then unknown=unknown; else unknown=; fi | |
1969 | ||
1970 | ovn-nbctl \ | |
1971 | -- lsp-add ls$i lp$i$j$k \ | |
1972 | -- lsp-set-addresses lp$i$j$k "f0:00:00:00:0$i:$j$k \ | |
1973 | 192.168.$i$j.$k" $unknown | |
86e98048 BP |
1974 | done |
1975 | done | |
1976 | done | |
1977 | ||
fa2a27b2 | 1978 | ovn-nbctl lr-add lr0 |
86e98048 BP |
1979 | for i in 1 2 3; do |
1980 | for j in 1 2 3; do | |
bf44c2cd | 1981 | ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24 |
269ecccc | 1982 | ovn-nbctl \ |
31ed1192 | 1983 | -- lsp-add ls$i lrp$i$j-attachment \ |
269ecccc | 1984 | -- set Logical_Switch_Port lrp$i$j-attachment type=router \ |
00007447 | 1985 | options:router-port=lrp$i$j \ |
86e98048 | 1986 | addresses='"00:00:00:00:ff:'$i$j'"' |
9975d7be BP |
1987 | done |
1988 | done | |
1989 | ||
80f408f4 | 1990 | ovn-nbctl set Logical_Switch_Port lrp33-attachment \ |
57d143eb HZ |
1991 | addresses='"00:00:00:00:ff:33 192.168.33.254"' |
1992 | ||
9975d7be BP |
1993 | # Physical network: |
1994 | # | |
1995 | # Three hypervisors hv[123]. | |
86e98048 BP |
1996 | # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3. |
1997 | # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3. | |
1998 | # lp?3[123] all on hv3. | |
1999 | ||
9975d7be BP |
2000 | |
2001 | # Given the name of a logical port, prints the name of the hypervisor | |
2002 | # on which it is located. | |
2003 | vif_to_hv() { | |
2004 | case $1 in dnl ( | |
86e98048 BP |
2005 | ?11) echo 1 ;; dnl ( |
2006 | ?12 | ?21 | ?22) echo 2 ;; dnl ( | |
2007 | ?13 | ?23 | ?3?) echo 3 ;; | |
9975d7be BP |
2008 | esac |
2009 | } | |
2010 | ||
86e98048 BP |
2011 | # Given the name of a logical port, prints the name of its logical router |
2012 | # port, e.g. "vif_to_lrp 123" yields 12. | |
2013 | vif_to_lrp() { | |
2014 | echo ${1%?} | |
2015 | } | |
2016 | ||
2017 | # Given the name of a logical port, prints the name of its logical | |
2018 | # switch, e.g. "vif_to_ls 123" yields 1. | |
e3393e3f | 2019 | vif_to_ls() { |
86e98048 | 2020 | echo ${1%??} |
e3393e3f BP |
2021 | } |
2022 | ||
9975d7be BP |
2023 | net_add n1 |
2024 | for i in 1 2 3; do | |
2025 | sim_add hv$i | |
2026 | as hv$i | |
2027 | ovs-vsctl add-br br-phys | |
2028 | ovn_attach n1 br-phys 192.168.0.$i | |
2029 | done | |
2030 | for i in 1 2 3; do | |
2031 | for j in 1 2 3; do | |
86e98048 | 2032 | for k in 1 2 3; do |
269ecccc JP |
2033 | hv=`vif_to_hv $i$j$k` |
2034 | as hv$hv ovs-vsctl \ | |
2035 | -- add-port br-int vif$i$j$k \ | |
2036 | -- set Interface vif$i$j$k \ | |
2037 | external-ids:iface-id=lp$i$j$k \ | |
2038 | options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \ | |
2039 | options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \ | |
2040 | ofport-request=$i$j$k | |
86e98048 | 2041 | done |
9975d7be BP |
2042 | done |
2043 | done | |
2044 | ||
2045 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2046 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2047 | # for ARP resolution). | |
2048 | ovn_populate_arp | |
2049 | ||
2050 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2051 | # XXX This should be more systematic. | |
2052 | sleep 1 | |
2053 | ||
e3393e3f | 2054 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... |
9975d7be BP |
2055 | # |
2056 | # This shell function causes a packet to be received on INPORT. The packet's | |
2057 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2058 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2059 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 2060 | # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123. |
9975d7be BP |
2061 | for i in 1 2 3; do |
2062 | for j in 1 2 3; do | |
86e98048 BP |
2063 | for k in 1 2 3; do |
2064 | : > $i$j$k.expected | |
269ecccc | 2065 | done |
9975d7be BP |
2066 | done |
2067 | done | |
e3393e3f | 2068 | test_ip() { |
9975d7be BP |
2069 | # This packet has bad checksums but logical L3 routing doesn't check. |
2070 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
ba43992e | 2071 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
9975d7be BP |
2072 | shift; shift; shift; shift; shift |
2073 | hv=hv`vif_to_hv $inport` | |
2074 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2075 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
86e98048 BP |
2076 | in_ls=`vif_to_ls $inport` |
2077 | in_lrp=`vif_to_lrp $inport` | |
9975d7be | 2078 | for outport; do |
269ecccc | 2079 | out_ls=`vif_to_ls $outport` |
86e98048 | 2080 | if test $in_ls = $out_ls; then |
9975d7be BP |
2081 | # Ports on the same logical switch receive exactly the same packet. |
2082 | echo $packet | |
2083 | else | |
2084 | # Routing decrements TTL and updates source and dest MAC | |
2085 | # (and checksum). | |
269ecccc | 2086 | out_lrp=`vif_to_lrp $outport` |
86e98048 | 2087 | echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 |
e4543cfe | 2088 | fi >> $outport.expected |
9975d7be BP |
2089 | done |
2090 | } | |
2091 | ||
e3393e3f | 2092 | as hv1 ovs-vsctl --columns=name,ofport list interface |
0bac7164 BP |
2093 | as hv1 ovn-sbctl list port_binding |
2094 | as hv1 ovn-sbctl list datapath_binding | |
9975d7be BP |
2095 | as hv1 ovn-sbctl dump-flows |
2096 | as hv1 ovs-ofctl dump-flows br-int | |
2097 | ||
e3393e3f | 2098 | # Send IP packets between all pairs of source and destination ports: |
9975d7be | 2099 | # |
31ed1192 JP |
2100 | # 1. Unicast IP packets are delivered to exactly one logical switch port |
2101 | # (except that packets destined to their input ports are dropped). | |
9975d7be | 2102 | # |
31ed1192 JP |
2103 | # 2. Broadcast IP packets are delivered to all logical switch ports |
2104 | # except the input port. | |
86e98048 BP |
2105 | ip_to_hex() { |
2106 | printf "%02x%02x%02x%02x" "$@" | |
2107 | } | |
9975d7be | 2108 | for is in 1 2 3; do |
269ecccc JP |
2109 | for js in 1 2 3; do |
2110 | for ks in 1 2 3; do | |
2111 | bcast= | |
2112 | s=$is$js$ks | |
2113 | smac=f00000000$s | |
2114 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2115 | for id in 1 2 3; do | |
2116 | for jd in 1 2 3; do | |
2117 | for kd in 1 2 3; do | |
2118 | d=$id$jd$kd | |
2119 | dip=`ip_to_hex 192 168 $id$jd $kd` | |
2120 | if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi | |
2121 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2122 | ||
2123 | test_ip $s $smac $dmac $sip $dip $unicast #1 | |
2124 | ||
2125 | if test $id = $is && test $d != $s; then bcast="$bcast $d"; fi | |
2126 | done | |
2127 | done | |
9975d7be | 2128 | done |
269ecccc JP |
2129 | test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2 |
2130 | done | |
2131 | done | |
e3393e3f BP |
2132 | done |
2133 | ||
0bac7164 BP |
2134 | # 3. Send an IP packet from every logical port to every other subnet, |
2135 | # to an IP address that does not have a static IP-MAC binding. | |
2136 | # This should generate a broadcast ARP request for the destination | |
2137 | # IP address in the destination subnet. | |
2138 | for is in 1 2 3; do | |
269ecccc JP |
2139 | for js in 1 2 3; do |
2140 | for ks in 1 2 3; do | |
2141 | s=$is$js$ks | |
2142 | smac=f00000000$s | |
2143 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2144 | for id in 1 2 3; do | |
2145 | for jd in 1 2 3; do | |
2146 | if test $is$js = $id$jd; then | |
2147 | continue | |
2148 | fi | |
2149 | ||
2150 | # Send the packet. | |
2151 | dmac=00000000ff$is$js | |
2152 | # Calculate a 4th octet for the destination that is | |
2153 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2154 | # that have static MAC bindings, and fits in the range | |
2155 | # 0-255. | |
2156 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2157 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2158 | test_ip $s $smac $dmac $sip $dip | |
2159 | ||
2160 | # Every LP on the destination subnet's lswitch should | |
2161 | # receive the ARP request. | |
2162 | lrmac=00000000ff$id$jd | |
2163 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2164 | arp=ffffffffffff${lrmac}08060001080006040001${lrmac}${lrip}000000000000${dip} | |
2165 | for jd2 in 1 2 3; do | |
2166 | for kd in 1 2 3; do | |
e4543cfe | 2167 | echo $arp >> $id$jd2$kd.expected |
0bac7164 | 2168 | done |
269ecccc | 2169 | done |
0bac7164 | 2170 | done |
269ecccc | 2171 | done |
0bac7164 | 2172 | done |
269ecccc | 2173 | done |
0bac7164 BP |
2174 | done |
2175 | ||
e3393e3f BP |
2176 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
2177 | # | |
2178 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2179 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2180 | # it should be the hardware address of the target to expect to receive in an | |
2181 | # ARP reply; otherwise no reply is expected. | |
2182 | # | |
31ed1192 | 2183 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
e3393e3f BP |
2184 | # SHA and REPLY_HA are each 12 hex digits. |
2185 | # SPA and TPA are each 8 hex digits. | |
2186 | test_arp() { | |
2187 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
2188 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2189 | hv=hv`vif_to_hv $inport` | |
2190 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2191 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request | |
2192 | ||
57d143eb | 2193 | # Expect to receive the broadcast ARP on the other logical switch ports if |
ea46a4e9 | 2194 | # IP address is not configured to the switch patch port. |
e3393e3f | 2195 | local i=`vif_to_ls $inport` |
86e98048 | 2196 | local j k |
e3393e3f | 2197 | for j in 1 2 3; do |
86e98048 | 2198 | for k in 1 2 3; do |
ea46a4e9 | 2199 | # 192.168.33.254 is configured to the switch patch port for lrp33, |
57d143eb HZ |
2200 | # so no ARP flooding expected for it. |
2201 | if test $i$j$k != $inport && test $tpa != `ip_to_hex 192 168 33 254`; then | |
86e98048 BP |
2202 | echo $request >> $i$j$k.expected |
2203 | fi | |
2204 | done | |
e3393e3f BP |
2205 | done |
2206 | ||
2207 | # Expect to receive the reply, if any. | |
2208 | if test X$reply_ha != X; then | |
86e98048 BP |
2209 | lrp=`vif_to_lrp $inport` |
2210 | local reply=${sha}00000000ff${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
e3393e3f BP |
2211 | echo $reply >> $inport.expected |
2212 | fi | |
2213 | } | |
2214 | ||
2215 | # Test router replies to ARP requests from all source ports: | |
2216 | # | |
0bac7164 | 2217 | # 4. Router replies to query for its MAC address from port's own IP address. |
e3393e3f | 2218 | # |
0bac7164 | 2219 | # 5. Router replies to query for its MAC address from any random IP address |
e3393e3f BP |
2220 | # in its subnet. |
2221 | # | |
0bac7164 | 2222 | # 6. Router replies to query for its MAC address from another subnet. |
e3393e3f | 2223 | # |
0bac7164 | 2224 | # 7. No reply to query for IP address other than router IP. |
e3393e3f | 2225 | for i in 1 2 3; do |
269ecccc JP |
2226 | for j in 1 2 3; do |
2227 | for k in 1 2 3; do | |
2228 | smac=f00000000$i$j$k # Source MAC | |
2229 | sip=`ip_to_hex 192 168 $i$j $k` # Source IP | |
2230 | rip=`ip_to_hex 192 168 $i$j 254` # Router IP | |
2231 | rmac=00000000ff$i$j # Router MAC | |
2232 | otherip=`ip_to_hex 192 168 $i$j 55` # Some other IP in subnet | |
2233 | test_arp $i$j$k $smac $sip $rip $rmac #4 | |
2234 | test_arp $i$j$k $smac $otherip $rip $rmac #5 | |
2235 | test_arp $i$j$k $smac 0a123456 $rip $rmac #6 | |
2236 | test_arp $i$j$k $smac $sip $otherip #7 | |
0bac7164 | 2237 | done |
269ecccc | 2238 | done |
0bac7164 BP |
2239 | done |
2240 | ||
2241 | # Allow some time for packet forwarding. | |
2242 | # XXX This can be improved. | |
2243 | sleep 1 | |
2244 | ||
2245 | # 8. Generate an ARP reply for each of the IP addresses ARPed for | |
2246 | # earlier as #3. | |
2247 | # | |
2248 | # Here, the $s is the VIF that originated the ARP request and $d is | |
2249 | # the VIF that sends the ARP reply, which is somewhat backward but | |
2250 | # it means that $s and $d are the same as #3. | |
2251 | : > mac_bindings.expected | |
2252 | for is in 1 2 3; do | |
269ecccc JP |
2253 | for js in 1 2 3; do |
2254 | for ks in 1 2 3; do | |
2255 | s=$is$js$ks | |
2256 | for id in 1 2 3; do | |
2257 | for jd in 1 2 3; do | |
2258 | if test $is$js = $id$jd; then | |
2259 | continue | |
2260 | fi | |
2261 | ||
2262 | kd=1 | |
2263 | d=$id$jd$kd | |
2264 | ||
2265 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2266 | host_ip=`ip_to_hex 192 168 $id$jd $o4` | |
2267 | host_mac=8000000000$o4 | |
2268 | ||
2269 | lrmac=00000000ff$id$jd | |
2270 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2271 | ||
2272 | arp=${lrmac}${host_mac}08060001080006040002${host_mac}${host_ip}${lrmac}${lrip} | |
2273 | ||
2274 | echo | |
2275 | echo | |
2276 | echo | |
2277 | hv=hv`vif_to_hv $d` | |
2278 | as $hv ovs-appctl netdev-dummy/receive vif$d $arp | |
2279 | #as $hv ovs-appctl ofproto/trace br-int in_port=$d $arp | |
2280 | #as $hv ovs-ofctl dump-flows br-int table=19 | |
2281 | ||
2282 | host_ip_pretty=192.168.$id$jd.$o4 | |
2283 | host_mac_pretty=80:00:00:00:00:$o4 | |
2284 | echo lrp$id$jd,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected | |
86e98048 | 2285 | done |
269ecccc | 2286 | done |
9975d7be | 2287 | done |
269ecccc | 2288 | done |
9975d7be | 2289 | done |
0bac7164 | 2290 | |
9975d7be BP |
2291 | # Allow some time for packet forwarding. |
2292 | # XXX This can be improved. | |
2293 | sleep 1 | |
2294 | ||
0bac7164 BP |
2295 | # 9. Send an IP packet from every logical port to every other subnet. These |
2296 | # are the same packets already sent as #3, but now the destinations' IP-MAC | |
2297 | # bindings have been discovered via ARP, so instead of provoking an ARP | |
2298 | # request, these packets now get routed to their destinations (which don't | |
2299 | # have static MAC bindings, so they go to the port we've designated as | |
2300 | # accepting "unknown" MACs.) | |
2301 | for is in 1 2 3; do | |
269ecccc JP |
2302 | for js in 1 2 3; do |
2303 | for ks in 1 2 3; do | |
2304 | s=$is$js$ks | |
2305 | smac=f00000000$s | |
2306 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2307 | for id in 1 2 3; do | |
2308 | for jd in 1 2 3; do | |
2309 | if test $is$js = $id$jd; then | |
2310 | continue | |
2311 | fi | |
2312 | ||
2313 | # Send the packet. | |
2314 | dmac=00000000ff$is$js | |
2315 | # Calculate a 4th octet for the destination that is | |
2316 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2317 | # that have static MAC bindings, and fits in the range | |
2318 | # 0-255. | |
2319 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2320 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2321 | test_ip $s $smac $dmac $sip $dip | |
2322 | ||
2323 | # Expect the packet egress. | |
2324 | host_mac=8000000000$o4 | |
2325 | outport=${id}11 | |
2326 | out_lrp=$id$jd | |
e4543cfe | 2327 | echo ${host_mac}00000000ff${out_lrp}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 >> $outport.expected |
0bac7164 | 2328 | done |
269ecccc | 2329 | done |
0bac7164 | 2330 | done |
269ecccc | 2331 | done |
0bac7164 BP |
2332 | done |
2333 | ||
0bac7164 BP |
2334 | ovn-sbctl -f csv -d bare --no-heading \ |
2335 | -- --columns=logical_port,ip,mac list mac_binding > mac_bindings | |
2336 | ||
9975d7be BP |
2337 | # Now check the packets actually received against the ones expected. |
2338 | for i in 1 2 3; do | |
2339 | for j in 1 2 3; do | |
86e98048 | 2340 | for k in 1 2 3; do |
abb37b6b FF |
2341 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap], |
2342 | [$i$j$k.expected]) | |
86e98048 | 2343 | done |
9975d7be BP |
2344 | done |
2345 | done | |
fcde56f5 | 2346 | |
0bac7164 BP |
2347 | # Check the MAC bindings against those expected. |
2348 | AT_CHECK_UNQUOTED([sort < mac_bindings], [0], [`sort < mac_bindings.expected` | |
2349 | ]) | |
2350 | ||
fcde56f5 | 2351 | # Gracefully terminate daemons |
7a8f15e0 | 2352 | OVN_CLEANUP([hv1], [hv2], [hv3]) |
eff49a56 | 2353 | |
9975d7be | 2354 | AT_CLEANUP |
685f4dfe NS |
2355 | |
2356 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor | |
2357 | AT_SETUP([ovn -- portsecurity : 3 HVs, 1 LS, 3 lports/HV]) | |
2358 | AT_KEYWORDS([portsecurity]) | |
2359 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2360 | ovn_start | |
2361 | ||
2362 | # Create hypervisors hv[123]. | |
2363 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. | |
2364 | # Add all of the vifs to a single logical switch lsw0. | |
2365 | # Turn off port security on vifs vif[123]1 | |
2366 | # Turn on l2 port security on vifs vif[123]2 | |
2367 | # Turn of l2 and l3 port security on vifs vif[123]3 | |
2368 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
ea46a4e9 | 2369 | ovn-nbctl ls-add lsw0 |
685f4dfe NS |
2370 | net_add n1 |
2371 | for i in 1 2 3; do | |
2372 | sim_add hv$i | |
2373 | as hv$i | |
2374 | ovs-vsctl add-br br-phys | |
2375 | ovn_attach n1 br-phys 192.168.0.$i | |
2376 | ||
2377 | for j in 1 2 3; do | |
2378 | 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 | 2379 | ovn-nbctl lsp-add lsw0 lp$i$j |
685f4dfe | 2380 | if test $j = 1; then |
31ed1192 | 2381 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
685f4dfe | 2382 | elif test $j = 2; then |
31ed1192 JP |
2383 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" |
2384 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
685f4dfe NS |
2385 | else |
2386 | extra_addr="f0:00:00:00:0$i:$i$j fe80::ea2a:eaff:fe28:$i$j" | |
31ed1192 JP |
2387 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr" |
2388 | 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 |
2389 | fi |
2390 | done | |
2391 | done | |
2392 | ||
685f4dfe NS |
2393 | # Pre-populate the hypervisors' ARP tables so that we don't lose any |
2394 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2395 | # for ARP resolution). | |
2396 | ovn_populate_arp | |
2397 | ||
2398 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2399 | # XXX This should be more systematic. | |
2400 | sleep 1 | |
685f4dfe NS |
2401 | |
2402 | # Given the name of a logical port, prints the name of the hypervisor | |
2403 | # on which it is located. | |
2404 | vif_to_hv() { | |
2405 | echo hv${1%?} | |
2406 | } | |
2407 | ||
685f4dfe NS |
2408 | for i in 1 2 3; do |
2409 | for j in 1 2 3; do | |
2410 | : > $i$j.expected | |
2411 | done | |
2412 | done | |
2413 | ||
2414 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
2415 | # | |
2416 | # This shell function causes an ip packet to be received on INPORT. | |
2417 | # The packet's content has Ethernet destination DST and source SRC | |
2418 | # (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits). | |
2419 | # The OUTPORTs (zero or more) list the VIFs on which the packet should | |
31ed1192 JP |
2420 | # be received. INPORT and the OUTPORTs are specified as logical switch |
2421 | # port numbers, e.g. 11 for vif11. | |
685f4dfe NS |
2422 | test_ip() { |
2423 | # This packet has bad checksums but logical L3 routing doesn't check. | |
2424 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
efe179e0 | 2425 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
685f4dfe NS |
2426 | shift; shift; shift; shift; shift |
2427 | hv=`vif_to_hv $inport` | |
2428 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2429 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2430 | for outport; do | |
e4543cfe | 2431 | echo $packet >> $outport.expected |
685f4dfe NS |
2432 | done |
2433 | } | |
2434 | ||
2435 | # test_arp INPORT SHA SPA TPA DROP [REPLY_HA] | |
2436 | # | |
2437 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2438 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2439 | # it should be the hardware address of the target to expect to receive in an | |
2440 | # ARP reply; otherwise no reply is expected. | |
2441 | # | |
31ed1192 | 2442 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
685f4dfe NS |
2443 | # SHA and REPLY_HA are each 12 hex digits. |
2444 | # SPA and TPA are each 8 hex digits. | |
2445 | test_arp() { | |
2446 | local inport=$1 smac=$2 sha=$3 spa=$4 tpa=$5 drop=$6 reply_ha=$7 | |
2447 | local request=ffffffffffff${smac}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2448 | hv=`vif_to_hv $inport` | |
2449 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2450 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request | |
2451 | if test $drop != 1; then | |
e137131a | 2452 | if test X$reply_ha = X; then |
685f4dfe NS |
2453 | # Expect to receive the broadcast ARP on the other logical switch ports |
2454 | # if no reply is expected. | |
2455 | local i j | |
2456 | for i in 1 2 3; do | |
2457 | for j in 1 2 3; do | |
2458 | if test $i$j != $inport; then | |
2459 | echo $request >> $i$j.expected | |
2460 | fi | |
2461 | done | |
2462 | done | |
2463 | else | |
2464 | # Expect to receive the reply, if any. | |
2465 | local reply=${smac}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
2466 | echo $reply >> $inport.expected | |
2467 | fi | |
2468 | fi | |
2469 | } | |
2470 | ||
2471 | # test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
2472 | # This function is similar to test_ip() except that it sends | |
2473 | # ipv6 packet | |
2474 | test_ipv6() { | |
2475 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
2476 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}0000000000000000 | |
2477 | shift; shift; shift; shift; shift | |
2478 | hv=`vif_to_hv $inport` | |
2479 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2480 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2481 | for outport; do | |
e4543cfe | 2482 | echo $packet >> $outport.expected |
685f4dfe NS |
2483 | done |
2484 | } | |
2485 | ||
9e687b23 DL |
2486 | # test_icmpv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT... |
2487 | # This function is similar to test_ipv6() except it specifies the ICMPv6 type | |
2488 | # of the test packet | |
2489 | test_icmpv6() { | |
2490 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6 | |
2491 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}${icmp_type}00000000000000 | |
2492 | shift; shift; shift; shift; shift; shift | |
2493 | hv=`vif_to_hv $inport` | |
2494 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2495 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2496 | for outport; do | |
e4543cfe | 2497 | echo $packet >> $outport.expected |
9e687b23 DL |
2498 | done |
2499 | } | |
2500 | ||
685f4dfe NS |
2501 | ip_to_hex() { |
2502 | printf "%02x%02x%02x%02x" "$@" | |
2503 | } | |
2504 | ||
2505 | # no port security | |
2506 | sip=`ip_to_hex 192 168 0 12` | |
2507 | tip=`ip_to_hex 192 168 0 13` | |
2508 | # the arp packet should be allowed even if lp[123]1 is | |
2509 | # not configured with mac f00000000023 and ip 192.168.0.12 | |
2510 | for i in 1 2 3; do | |
2511 | test_arp ${i}1 f00000000023 f00000000023 $sip $tip 0 f00000000013 | |
2512 | for j in 1 2 3; do | |
2513 | if test $i != $j; then | |
2514 | test_ip ${i}1 f000000000${i}1 f000000000${j}1 $sip $tip ${j}1 | |
2515 | fi | |
2516 | done | |
2517 | done | |
2518 | ||
2519 | # l2 port security | |
2520 | sip=`ip_to_hex 192 168 0 12` | |
2521 | tip=`ip_to_hex 192 168 0 13` | |
2522 | ||
2523 | # arp packet should be allowed since lp22 is configured with | |
2524 | # mac f00000000022 | |
2525 | test_arp 22 f00000000022 f00000000022 $sip $tip 0 f00000000013 | |
2526 | ||
2527 | # arp packet should not be allowed since lp32 is not configured with | |
2528 | # mac f00000000021 | |
2529 | test_arp 32 f00000000021 f00000000021 $sip $tip 1 | |
2530 | ||
2531 | # arp packet with sha set to f00000000021 should not be allowed | |
2532 | # for lp12 | |
2533 | test_arp 12 f00000000012 f00000000021 $sip $tip 1 | |
2534 | ||
2535 | # ip packets should be allowed and received since lp[123]2 do not | |
2536 | # have l3 port security | |
2537 | sip=`ip_to_hex 192 168 0 55` | |
2538 | tip=`ip_to_hex 192 168 0 66` | |
2539 | for i in 1 2 3; do | |
2540 | for j in 1 2 3; do | |
2541 | if test $i != $j; then | |
2542 | test_ip ${i}2 f000000000${i}2 f000000000${j}2 $sip $tip ${j}2 | |
2543 | fi | |
2544 | done | |
2545 | done | |
2546 | ||
2547 | # ipv6 packets should be received by lp[123]2 | |
2548 | # lp[123]1 can send ipv6 traffic as there is no port security | |
2549 | sip=fe800000000000000000000000000000 | |
2550 | tip=ff020000000000000000000000000000 | |
2551 | ||
2552 | for i in 1 2 3; do | |
2553 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}2 $sip $tip ${i}2 | |
2554 | done | |
2555 | ||
2556 | ||
2557 | # l2 and l3 port security | |
2558 | sip=`ip_to_hex 192 168 0 13` | |
2559 | tip=`ip_to_hex 192 168 0 22` | |
2560 | # arp packet should be allowed since lp13 is configured with | |
2561 | # f00000000013 and 192.168.0.13 | |
2562 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 | |
2563 | ||
2564 | # the arp packet should be dropped because lp23 is not configured | |
2565 | # with mac f00000000022 | |
2566 | sip=`ip_to_hex 192 168 0 13` | |
2567 | tip=`ip_to_hex 192 168 0 22` | |
2568 | test_arp 23 f00000000022 f00000000022 $sip $tip 1 | |
2569 | ||
2570 | # the arp packet should be dropped because lp33 is not configured | |
2571 | # with ip 192.168.0.55 | |
2572 | spa=`ip_to_hex 192 168 0 55` | |
2573 | tpa=`ip_to_hex 192 168 0 22` | |
2574 | test_arp 33 f00000000031 f00000000031 $spa $tpa 1 | |
2575 | ||
2576 | # ip packets should not be received by lp[123]3 since | |
2577 | # l3 port security is enabled | |
2578 | sip=`ip_to_hex 192 168 0 55` | |
2579 | tip=`ip_to_hex 192 168 0 66` | |
2580 | for i in 1 2 3; do | |
2581 | for j in 1 2 3; do | |
2582 | test_ip ${i}2 f000000000${i}2 f000000000${j}3 $sip $tip | |
2583 | done | |
2584 | done | |
2585 | ||
2586 | # ipv6 packets should be dropped for lp[123]3 since | |
2587 | # it is configured with only ipv4 address | |
2588 | sip=fe800000000000000000000000000000 | |
2589 | tip=ff020000000000000000000000000000 | |
2590 | ||
2591 | for i in 1 2 3; do | |
2592 | test_ipv6 ${i}3 f000000000${i}3 f00000000022 $sip $tip | |
2593 | done | |
2594 | ||
2595 | # ipv6 packets should not be received by lp[123]3 with mac f000000000$[123]3 | |
2596 | # lp[123]1 can send ipv6 traffic as there is no port security | |
2597 | for i in 1 2 3; do | |
2598 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}3 $sip $tip | |
2599 | done | |
2600 | ||
2601 | # lp13 has extra port security with mac f0000000113 and ipv6 addr | |
2602 | # fe80::ea2a:eaff:fe28:0012 | |
2603 | ||
2604 | # ipv4 packet should be dropped for lp13 with mac f0000000113 | |
2605 | sip=`ip_to_hex 192 168 0 13` | |
2606 | tip=`ip_to_hex 192 168 0 23` | |
2607 | test_ip 13 f00000000113 f00000000023 $sip $tip | |
2608 | ||
2609 | # ipv6 packet should be received by lp[123]3 with mac f0000000{i}{i}3 | |
2610 | # and ip6.dst as fe80::ea2a:eaff:fe28:0{i}{i}3. | |
2611 | # lp11 can send ipv6 traffic as there is no port security | |
2612 | sip=ee800000000000000000000000000000 | |
2613 | for i in 1 2 3; do | |
2614 | tip=fe80000000000000ea2aeafffe2800{i}3 | |
2615 | test_ipv6 11 f00000000011 f000000000{i}${i}3 $sip $tip {i}3 | |
2616 | done | |
2617 | ||
2618 | ||
2619 | # ipv6 packet should not be received by lp33 with mac f0000000333 | |
2620 | # and ip6.dst as fe80::ea2a:eaff:fe28:0023 as it is | |
2621 | # configured with fe80::ea2a:eaff:fe28:0033 | |
2622 | # lp11 can send ipv6 traffic as there is no port security | |
2623 | ||
2624 | sip=ee800000000000000000000000000000 | |
2625 | tip=fe80000000000000ea2aeafffe280023 | |
2626 | test_ipv6 11 f00000000011 f00000000333 $sip $tip | |
2627 | ||
2628 | # ipv6 packet should be allowed for lp[123]3 with mac f0000000{i}{i}3 | |
2629 | # and ip6.src fe80::ea2a:eaff:fe28:0{i}{i}3 and ip6.src ::. | |
2630 | # and should be dropped for any other ip6.src | |
2631 | # lp21 can receive ipv6 traffic as there is no port security | |
2632 | ||
2633 | tip=ee800000000000000000000000000000 | |
2634 | for i in 1 2 3; do | |
2635 | sip=fe80000000000000ea2aeafffe2800${i}3 | |
2636 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 21 | |
2637 | ||
9e687b23 | 2638 | # Test ICMPv6 MLD reports (v1 and v2) and NS for DAD |
685f4dfe | 2639 | sip=00000000000000000000000000000000 |
9e687b23 DL |
2640 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 83 21 |
2641 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 8f 21 | |
2642 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff0200000000000000ea2aeafffe2800 87 21 | |
2643 | # Traffic to non-multicast traffic should be dropped | |
2644 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 83 | |
2645 | # Traffic of other ICMPv6 types should be dropped | |
2646 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 80 | |
685f4dfe NS |
2647 | |
2648 | # should be dropped | |
2649 | sip=ae80000000000000ea2aeafffe2800aa | |
2650 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip | |
2651 | done | |
2652 | ||
31ed1192 JP |
2653 | # configure lsp13 to send and received IPv4 packets with an address range |
2654 | ovn-nbctl lsp-set-port-security lp13 "f0:00:00:00:00:13 192.168.0.13 20.0.0.4/24 10.0.0.0/24" | |
7d9d86ad | 2655 | |
8ff5a966 NS |
2656 | sleep 2 |
2657 | ||
7d9d86ad NS |
2658 | sip=`ip_to_hex 10 0 0 13` |
2659 | tip=`ip_to_hex 192 168 0 22` | |
31ed1192 | 2660 | # arp packet with inner ip 10.0.0.13 should be allowed for lsp13 |
7d9d86ad NS |
2661 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 |
2662 | ||
2663 | sip=`ip_to_hex 10 0 0 14` | |
2664 | tip=`ip_to_hex 192 168 0 23` | |
31ed1192 | 2665 | # IPv4 packet from lsp13 with src ip 10.0.0.14 destined to lsp23 |
7d9d86ad NS |
2666 | # with dst ip 192.168.0.23 should be allowed |
2667 | test_ip 13 f00000000013 f00000000023 $sip $tip 23 | |
2668 | ||
2669 | sip=`ip_to_hex 192 168 0 33` | |
2670 | tip=`ip_to_hex 10 0 0 15` | |
31ed1192 JP |
2671 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2672 | # with dst ip 10.0.0.15 should be received by lsp13 | |
7d9d86ad NS |
2673 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2674 | ||
2675 | sip=`ip_to_hex 192 168 0 33` | |
2676 | tip=`ip_to_hex 20 0 0 4` | |
31ed1192 JP |
2677 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2678 | # with dst ip 20.0.0.4 should be received by lsp13 | |
7d9d86ad NS |
2679 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2680 | ||
2681 | sip=`ip_to_hex 192 168 0 33` | |
2682 | tip=`ip_to_hex 20 0 0 5` | |
31ed1192 JP |
2683 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2684 | # with dst ip 20.0.0.5 should not be received by lsp13 | |
7d9d86ad NS |
2685 | test_ip 33 f00000000033 f00000000013 $sip $tip |
2686 | ||
2687 | sip=`ip_to_hex 192 168 0 33` | |
2688 | tip=`ip_to_hex 20 0 0 255` | |
31ed1192 JP |
2689 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2690 | # with dst ip 20.0.0.255 should be received by lsp13 | |
7d9d86ad NS |
2691 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2692 | ||
2693 | sip=`ip_to_hex 192 168 0 33` | |
2694 | tip=`ip_to_hex 192 168 0 255` | |
31ed1192 JP |
2695 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2696 | # with dst ip 192.168.0.255 should not be received by lsp13 | |
7d9d86ad NS |
2697 | test_ip 33 f00000000033 f00000000013 $sip $tip |
2698 | ||
2699 | sip=`ip_to_hex 192 168 0 33` | |
2700 | tip=`ip_to_hex 224 0 0 4` | |
31ed1192 JP |
2701 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2702 | # with dst ip 224.0.0.4 should be received by lsp13 | |
7d9d86ad | 2703 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
685f4dfe | 2704 | |
bb0c41d3 RM |
2705 | #dump information including flow counters |
2706 | ovn-nbctl show | |
2707 | ovn-sbctl dump-flows -- list multicast_group | |
2708 | ||
2709 | echo "------ hv1 dump ------" | |
2710 | as hv1 ovs-vsctl show | |
6195e2e7 | 2711 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2712 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2713 | ||
2714 | echo "------ hv2 dump ------" | |
2715 | as hv2 ovs-vsctl show | |
6195e2e7 | 2716 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2717 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2718 | ||
2719 | echo "------ hv3 dump ------" | |
2720 | as hv3 ovs-vsctl show | |
6195e2e7 | 2721 | as hv3 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2722 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2723 | ||
685f4dfe NS |
2724 | # Now check the packets actually received against the ones expected. |
2725 | for i in 1 2 3; do | |
2726 | for j in 1 2 3; do | |
49d7c759 | 2727 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
685f4dfe NS |
2728 | done |
2729 | done | |
2730 | ||
7a8f15e0 | 2731 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 2732 | |
685f4dfe | 2733 | AT_CLEANUP |
509afdc3 GS |
2734 | |
2735 | AT_SETUP([ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs]) | |
2736 | AT_KEYWORDS([ovnpeer]) | |
2737 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2738 | ovn_start | |
2739 | ||
2740 | # Logical network: | |
2741 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
2742 | # network. R1 has a switchs ls1 (191.168.1.0/24) connected to it. | |
2743 | # R2 has ls2 (172.16.1.0/24) connected to it. | |
2744 | ||
fa2a27b2 JP |
2745 | ovn-nbctl lr-add R1 |
2746 | ovn-nbctl lr-add R2 | |
509afdc3 | 2747 | |
ea46a4e9 JP |
2748 | ovn-nbctl ls-add ls1 |
2749 | ovn-nbctl ls-add ls2 | |
509afdc3 GS |
2750 | |
2751 | # Connect ls1 to R1 | |
bf44c2cd | 2752 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 |
509afdc3 | 2753 | |
31ed1192 | 2754 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
31114af7 | 2755 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" |
509afdc3 GS |
2756 | |
2757 | # Connect ls2 to R2 | |
bf44c2cd | 2758 | ovn-nbctl lrp-add R2 ls2 00:00:00:01:02:04 172.16.1.1/24 |
509afdc3 | 2759 | |
31ed1192 | 2760 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
31114af7 | 2761 | options:router-port=ls2 addresses=\"00:00:00:01:02:04\" |
509afdc3 GS |
2762 | |
2763 | # Connect R1 to R2 | |
4685e523 JP |
2764 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
2765 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
509afdc3 | 2766 | |
6d9ecfa9 JP |
2767 | ovn-nbctl lr-route-add R1 "0.0.0.0/0" 20.0.0.2 |
2768 | ovn-nbctl lr-route-add R2 "0.0.0.0/0" 20.0.0.1 | |
509afdc3 GS |
2769 | |
2770 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
2771 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
2772 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
509afdc3 GS |
2773 | |
2774 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
2775 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
2776 | -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2" | |
509afdc3 GS |
2777 | |
2778 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
2779 | net_add n1 | |
2780 | ||
2781 | sim_add hv1 | |
2782 | as hv1 | |
2783 | ovs-vsctl add-br br-phys | |
2784 | ovn_attach n1 br-phys 192.168.0.1 | |
2785 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
2786 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
2787 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
2788 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
2789 | ofport-request=1 | |
2790 | ||
2791 | sim_add hv2 | |
2792 | as hv2 | |
2793 | ovs-vsctl add-br br-phys | |
2794 | ovn_attach n1 br-phys 192.168.0.2 | |
2795 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
2796 | set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \ | |
2797 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
2798 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
2799 | ofport-request=1 | |
2800 | ||
2801 | ||
2802 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2803 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2804 | # for ARP resolution). | |
2805 | ovn_populate_arp | |
2806 | ||
2807 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2808 | # XXX This should be more systematic. | |
2809 | sleep 1 | |
2810 | ||
2811 | # Send ip packets between the two ports. | |
2812 | ip_to_hex() { | |
2813 | printf "%02x%02x%02x%02x" "$@" | |
2814 | } | |
509afdc3 GS |
2815 | |
2816 | # Packet to send. | |
2817 | src_mac="f00000010203" | |
2818 | dst_mac="000000010203" | |
2819 | src_ip=`ip_to_hex 192 168 1 2` | |
2820 | dst_ip=`ip_to_hex 172 16 1 2` | |
2821 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
2822 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
2823 | ||
2824 | ||
2825 | echo "---------NB dump-----" | |
2826 | ovn-nbctl show | |
2827 | echo "---------------------" | |
2828 | ovn-nbctl list logical_router | |
2829 | echo "---------------------" | |
2830 | ovn-nbctl list logical_router_port | |
2831 | echo "---------------------" | |
2832 | ||
2833 | echo "---------SB dump-----" | |
2834 | ovn-sbctl list datapath_binding | |
2835 | echo "---------------------" | |
2836 | ovn-sbctl list port_binding | |
2837 | echo "---------------------" | |
2838 | ||
2839 | echo "------ hv1 dump ----------" | |
8dab1022 | 2840 | as hv1 ovs-ofctl show br-int |
509afdc3 GS |
2841 | as hv1 ovs-ofctl dump-flows br-int |
2842 | echo "------ hv2 dump ----------" | |
8dab1022 | 2843 | as hv2 ovs-ofctl show br-int |
509afdc3 GS |
2844 | as hv2 ovs-ofctl dump-flows br-int |
2845 | ||
2846 | # Packet to Expect | |
2847 | src_mac="000000010204" | |
2848 | dst_mac="f00000010204" | |
49d7c759 | 2849 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
509afdc3 | 2850 | |
49d7c759 | 2851 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
509afdc3 | 2852 | |
7a8f15e0 | 2853 | OVN_CLEANUP([hv1],[hv2]) |
509afdc3 GS |
2854 | |
2855 | AT_CLEANUP | |
5412db30 J |
2856 | |
2857 | ||
4685e523 JP |
2858 | AT_SETUP([ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR]) |
2859 | AT_KEYWORDS([router-admin-state]) | |
2860 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2861 | ovn_start | |
2862 | ||
2863 | # Logical network: | |
2864 | # One LR - R1 has switch ls1 with two subnets attached to it (191.168.1.0/24 | |
2865 | # and 172.16.1.0/24) connected to it. | |
2866 | ||
2867 | ovn-nbctl lr-add R1 | |
2868 | ||
2869 | ovn-nbctl ls-add ls1 | |
2870 | ||
2871 | # Connect ls1 to R1 | |
bf44c2cd | 2872 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 172.16.1.1/24 |
4685e523 JP |
2873 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
2874 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" | |
2875 | ||
2876 | # Create logical port ls1-lp1 in ls1 | |
2877 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
2878 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
2879 | ||
2880 | # Create logical port ls1-lp2 in ls1 | |
2881 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
2882 | -- lsp-set-addresses ls1-lp2 "f0:00:00:01:02:04 172.16.1.2" | |
2883 | ||
2884 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
2885 | net_add n1 | |
2886 | ||
2887 | sim_add hv1 | |
2888 | as hv1 | |
2889 | ovs-vsctl add-br br-phys | |
2890 | ovn_attach n1 br-phys 192.168.0.1 | |
2891 | ovs-vsctl -- add-port br-int vif1 -- \ | |
2892 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
2893 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
2894 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
2895 | ofport-request=1 | |
2896 | ||
2897 | ovs-vsctl -- add-port br-int vif2 -- \ | |
2898 | set interface vif2 external-ids:iface-id=ls1-lp2 \ | |
2899 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
2900 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
2901 | ofport-request=1 | |
2902 | ||
2903 | ||
2904 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2905 | # XXX This should be more systematic. | |
2906 | sleep 1 | |
2907 | ||
2908 | # Send ip packets between the two ports. | |
2909 | ip_to_hex() { | |
2910 | printf "%02x%02x%02x%02x" "$@" | |
2911 | } | |
4685e523 JP |
2912 | |
2913 | # Packet to send. | |
2914 | src_mac="f00000010203" | |
2915 | dst_mac="000000010203" | |
2916 | src_ip=`ip_to_hex 192 168 1 2` | |
2917 | dst_ip=`ip_to_hex 172 16 1 2` | |
2918 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
2919 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
2920 | ||
2921 | ||
2922 | echo "---------NB dump-----" | |
2923 | ovn-nbctl show | |
2924 | echo "---------------------" | |
2925 | ovn-nbctl list logical_router | |
2926 | echo "---------------------" | |
2927 | ovn-nbctl list logical_router_port | |
2928 | echo "---------------------" | |
2929 | ||
2930 | echo "---------SB dump-----" | |
2931 | ovn-sbctl list datapath_binding | |
2932 | echo "---------------------" | |
2933 | ovn-sbctl list logical_flow | |
2934 | echo "---------------------" | |
2935 | ||
2936 | echo "------ hv1 dump ----------" | |
2937 | as hv1 ovs-ofctl dump-flows br-int | |
2938 | ||
2939 | ||
2940 | #Disable router R1 | |
2941 | ovn-nbctl set Logical_Router R1 enabled=false | |
2942 | ||
3b8cd0ea BP |
2943 | # Allow some time for ovn-northd and ovn-controller to catch up. |
2944 | # XXX This should be more systematic. | |
2945 | sleep 1 | |
2946 | ||
4685e523 JP |
2947 | echo "---------SB dump-----" |
2948 | ovn-sbctl list datapath_binding | |
2949 | echo "---------------------" | |
2950 | ovn-sbctl list logical_flow | |
2951 | echo "---------------------" | |
2952 | ||
2953 | echo "------ hv1 dump ----------" | |
2954 | as hv1 ovs-ofctl dump-flows br-int | |
2955 | ||
2956 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
2957 | ||
2958 | # Packet to Expect | |
2959 | expect_src_mac="000000010203" | |
2960 | expect_dst_mac="f00000010204" | |
49d7c759 | 2961 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
4685e523 | 2962 | |
49d7c759 | 2963 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
4685e523 JP |
2964 | |
2965 | ||
2966 | as hv1 | |
2967 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
2968 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
2969 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
2970 | ||
2971 | as ovn-sb | |
2972 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
2973 | ||
2974 | as ovn-nb | |
2975 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
2976 | ||
2977 | as northd | |
2978 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
2979 | ||
2980 | as main | |
2981 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
2982 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
2983 | ||
2984 | AT_CLEANUP | |
2985 | ||
2986 | ||
2987 | AT_SETUP([ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR]) | |
5412db30 J |
2988 | AT_KEYWORDS([router-admin-state]) |
2989 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2990 | ovn_start | |
2991 | ||
2992 | # Logical network: | |
2993 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
2994 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
2995 | ||
fa2a27b2 | 2996 | ovn-nbctl lr-add R1 |
5412db30 | 2997 | |
ea46a4e9 JP |
2998 | ovn-nbctl ls-add ls1 |
2999 | ovn-nbctl ls-add ls2 | |
5412db30 J |
3000 | |
3001 | # Connect ls1 to R1 | |
bf44c2cd | 3002 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3003 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
31114af7 | 3004 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" |
5412db30 J |
3005 | |
3006 | # Connect ls2 to R1 | |
bf44c2cd | 3007 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3008 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
31114af7 | 3009 | options:router-port=ls2 addresses=\"00:00:00:01:02:04\" |
5412db30 J |
3010 | |
3011 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
3012 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3013 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
5412db30 J |
3014 | |
3015 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
3016 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3017 | -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2" | |
5412db30 J |
3018 | |
3019 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3020 | net_add n1 | |
3021 | ||
3022 | sim_add hv1 | |
3023 | as hv1 | |
3024 | ovs-vsctl add-br br-phys | |
3025 | ovn_attach n1 br-phys 192.168.0.1 | |
3026 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3027 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3028 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3029 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3030 | ofport-request=1 | |
3031 | ||
3032 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3033 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
3034 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3035 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3036 | ofport-request=1 | |
3037 | ||
3038 | ||
3039 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3040 | # XXX This should be more systematic. | |
3041 | sleep 1 | |
3042 | ||
3043 | # Send ip packets between the two ports. | |
3044 | ip_to_hex() { | |
3045 | printf "%02x%02x%02x%02x" "$@" | |
3046 | } | |
5412db30 J |
3047 | |
3048 | # Packet to send. | |
3049 | src_mac="f00000010203" | |
3050 | dst_mac="000000010203" | |
3051 | src_ip=`ip_to_hex 192 168 1 2` | |
3052 | dst_ip=`ip_to_hex 172 16 1 2` | |
3053 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3054 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3055 | ||
3056 | ||
3057 | echo "---------NB dump-----" | |
3058 | ovn-nbctl show | |
3059 | echo "---------------------" | |
3060 | ovn-nbctl list logical_router | |
3061 | echo "---------------------" | |
3062 | ovn-nbctl list logical_router_port | |
3063 | echo "---------------------" | |
3064 | ||
3065 | echo "---------SB dump-----" | |
3066 | ovn-sbctl list datapath_binding | |
3067 | echo "---------------------" | |
3068 | ovn-sbctl list logical_flow | |
3069 | echo "---------------------" | |
3070 | ||
3071 | echo "------ hv1 dump ----------" | |
3072 | as hv1 ovs-ofctl dump-flows br-int | |
3073 | ||
5412db30 J |
3074 | #Disable router R1 |
3075 | ovn-nbctl set Logical_Router R1 enabled=false | |
3076 | ||
3077 | echo "---------SB dump-----" | |
3078 | ovn-sbctl list datapath_binding | |
3079 | echo "---------------------" | |
3080 | ovn-sbctl list logical_flow | |
3081 | echo "---------------------" | |
3082 | ||
3083 | echo "------ hv1 dump ----------" | |
3084 | as hv1 ovs-ofctl dump-flows br-int | |
3085 | ||
a1361a6e LR |
3086 | # Allow some time for the disabling of logical router R1 to propagate. |
3087 | # XXX This should be more systematic. | |
3088 | sleep 1 | |
3089 | ||
5412db30 J |
3090 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet |
3091 | ||
3092 | # Packet to Expect | |
3093 | expect_src_mac="000000010204" | |
3094 | expect_dst_mac="f00000010204" | |
49d7c759 | 3095 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
5412db30 | 3096 | |
49d7c759 | 3097 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
5412db30 | 3098 | |
7a8f15e0 | 3099 | OVN_CLEANUP([hv1]) |
5412db30 J |
3100 | |
3101 | AT_CLEANUP | |
3102 | ||
28dc3fe9 SR |
3103 | AT_SETUP([ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes]) |
3104 | AT_KEYWORDS([ovnstaticroutespeer]) | |
3105 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3106 | ovn_start | |
3107 | ||
3108 | # Logical network: | |
3109 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
3110 | # network. R1 has switchess foo (192.168.1.0/24) | |
3111 | # connected to it. | |
3112 | # R2 has alice (172.16.1.0/24) and bob (172.16.2.0/24) connected to it. | |
3113 | ||
fa2a27b2 JP |
3114 | ovn-nbctl lr-add R1 |
3115 | ovn-nbctl lr-add R2 | |
28dc3fe9 | 3116 | |
ea46a4e9 JP |
3117 | ovn-nbctl ls-add foo |
3118 | ovn-nbctl ls-add alice | |
3119 | ovn-nbctl ls-add bob | |
28dc3fe9 SR |
3120 | |
3121 | # Connect foo to R1 | |
bf44c2cd | 3122 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3123 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 3124 | options:router-port=foo addresses=\"00:00:00:01:02:03\" |
28dc3fe9 SR |
3125 | |
3126 | # Connect alice to R2 | |
bf44c2cd | 3127 | ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3128 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 3129 | type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" |
28dc3fe9 SR |
3130 | |
3131 | # Connect bob to R2 | |
bf44c2cd | 3132 | ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24 |
31ed1192 | 3133 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob type=router \ |
31114af7 | 3134 | options:router-port=bob addresses=\"00:00:00:01:02:05\" |
28dc3fe9 SR |
3135 | |
3136 | # Connect R1 to R2 | |
4685e523 JP |
3137 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
3138 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
28dc3fe9 SR |
3139 | |
3140 | #install static routes | |
e48ccf3c JP |
3141 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
3142 | ovn-nbctl lr-route-add R2 172.16.2.0/24 20.0.0.2 R1_R2 | |
3143 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 | |
28dc3fe9 SR |
3144 | |
3145 | # Create logical port foo1 in foo | |
31ed1192 JP |
3146 | ovn-nbctl lsp-add foo foo1 \ |
3147 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
28dc3fe9 SR |
3148 | |
3149 | # Create logical port alice1 in alice | |
31ed1192 JP |
3150 | ovn-nbctl lsp-add alice alice1 \ |
3151 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
28dc3fe9 SR |
3152 | |
3153 | # Create logical port bob1 in bob | |
31ed1192 JP |
3154 | ovn-nbctl lsp-add bob bob1 \ |
3155 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 172.16.2.2" | |
28dc3fe9 SR |
3156 | |
3157 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3158 | net_add n1 | |
3159 | ||
3160 | sim_add hv1 | |
3161 | as hv1 | |
3162 | ovs-vsctl add-br br-phys | |
3163 | ovn_attach n1 br-phys 192.168.0.1 | |
3164 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3165 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3166 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3167 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3168 | ofport-request=1 | |
3169 | ||
3170 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3171 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
3172 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3173 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3174 | ofport-request=2 | |
3175 | ||
3176 | sim_add hv2 | |
3177 | as hv2 | |
3178 | ovs-vsctl add-br br-phys | |
3179 | ovn_attach n1 br-phys 192.168.0.2 | |
3180 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3181 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
3182 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3183 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3184 | ofport-request=1 | |
3185 | ||
3186 | ||
3187 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3188 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3189 | # for ARP resolution). | |
3190 | ovn_populate_arp | |
3191 | ||
3192 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3193 | # XXX This should be more systematic. | |
3194 | sleep 1 | |
3195 | ||
3196 | ip_to_hex() { | |
3197 | printf "%02x%02x%02x%02x" "$@" | |
3198 | } | |
28dc3fe9 SR |
3199 | |
3200 | # Send ip packets between foo1 and alice1 | |
3201 | src_mac="f00000010203" | |
3202 | dst_mac="000000010203" | |
3203 | src_ip=`ip_to_hex 192 168 1 2` | |
3204 | dst_ip=`ip_to_hex 172 16 1 2` | |
3205 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3206 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3207 | ||
3208 | # Send ip packets between foo1 and bob1 | |
3209 | src_mac="f00000010203" | |
3210 | dst_mac="000000010203" | |
3211 | src_ip=`ip_to_hex 192 168 1 2` | |
3212 | dst_ip=`ip_to_hex 172 16 2 2` | |
3213 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3214 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3215 | ||
3216 | echo "---------NB dump-----" | |
3217 | ovn-nbctl show | |
3218 | echo "---------------------" | |
3219 | ovn-nbctl list logical_router | |
3220 | echo "---------------------" | |
3221 | ovn-nbctl list logical_router_port | |
3222 | echo "---------------------" | |
3223 | ||
3224 | echo "---------SB dump-----" | |
3225 | ovn-sbctl list datapath_binding | |
3226 | echo "---------------------" | |
3227 | ovn-sbctl list port_binding | |
3228 | echo "---------------------" | |
3229 | ||
3230 | echo "------ hv1 dump ----------" | |
3231 | as hv1 ovs-ofctl dump-flows br-int | |
3232 | echo "------ hv2 dump ----------" | |
3233 | as hv2 ovs-ofctl dump-flows br-int | |
3234 | ||
3235 | # Packet to Expect at bob1 | |
3236 | src_mac="000000010205" | |
3237 | dst_mac="f00000010205" | |
3238 | src_ip=`ip_to_hex 192 168 1 2` | |
3239 | dst_ip=`ip_to_hex 172 16 2 2` | |
49d7c759 | 3240 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 3241 | |
49d7c759 | 3242 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
28dc3fe9 SR |
3243 | |
3244 | # Packet to Expect at alice1 | |
3245 | src_mac="000000010204" | |
3246 | dst_mac="f00000010204" | |
3247 | src_ip=`ip_to_hex 192 168 1 2` | |
3248 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 3249 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 3250 | |
49d7c759 | 3251 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
28dc3fe9 | 3252 | |
7a8f15e0 | 3253 | OVN_CLEANUP([hv1],[hv2]) |
28dc3fe9 SR |
3254 | |
3255 | AT_CLEANUP | |
5412db30 | 3256 | |
0ee8aaf6 RR |
3257 | AT_SETUP([ovn -- send gratuitous arp on localnet]) |
3258 | AT_KEYWORDS([ovn]) | |
d08dbed7 | 3259 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
0ee8aaf6 | 3260 | ovn_start |
ea46a4e9 | 3261 | ovn-nbctl ls-add lsw0 |
0ee8aaf6 RR |
3262 | net_add n1 |
3263 | sim_add hv | |
3264 | as hv | |
3265 | ovs-vsctl \ | |
3266 | -- add-br br-phys \ | |
3267 | -- add-br br-eth0 | |
3268 | ||
3269 | ovn_attach n1 br-phys 192.168.0.1 | |
3270 | ||
3271 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
3272 | AT_CHECK([ovs-vsctl add-port br-eth0 snoopvif -- set Interface snoopvif options:tx_pcap=hv/snoopvif-tx.pcap options:rxq_pcap=hv/snoopvif-rx.pcap]) | |
3273 | ||
3274 | # Create a vif. | |
31ed1192 JP |
3275 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) |
3276 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.2"]) | |
3277 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
0ee8aaf6 RR |
3278 | |
3279 | # Create a localnet port. | |
31ed1192 JP |
3280 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) |
3281 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
3282 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
3283 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
0ee8aaf6 RR |
3284 | |
3285 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
3286 | ||
3287 | # Wait for packet to be received. | |
49d7c759 BP |
3288 | echo "fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" > expected |
3289 | OVN_CHECK_PACKETS([hv/snoopvif-tx.pcap], [expected]) | |
0ee8aaf6 RR |
3290 | |
3291 | # Delete the localnet ports. | |
3292 | AT_CHECK([ovs-vsctl del-port localvif1]) | |
31ed1192 | 3293 | AT_CHECK([ovn-nbctl lsp-del ln_port]) |
0ee8aaf6 | 3294 | |
7a8f15e0 | 3295 | OVN_CLEANUP([hv]) |
0ee8aaf6 RR |
3296 | |
3297 | AT_CLEANUP | |
75cf9d2b GS |
3298 | |
3299 | AT_SETUP([ovn -- 2 HVs, 3 LRs connected via LS, static routes]) | |
3300 | AT_KEYWORDS([ovnstaticroutes]) | |
3301 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3302 | ovn_start | |
3303 | ||
3304 | # Logical network: | |
3305 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
3306 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
3307 | # connected to it. R2 has alice (172.16.1.0/24) and R3 has bob (10.32.1.0/24) | |
3308 | # connected to it. | |
3309 | ||
fa2a27b2 JP |
3310 | ovn-nbctl lr-add R1 |
3311 | ovn-nbctl lr-add R2 | |
3312 | ovn-nbctl lr-add R3 | |
75cf9d2b | 3313 | |
ea46a4e9 JP |
3314 | ovn-nbctl ls-add foo |
3315 | ovn-nbctl ls-add alice | |
3316 | ovn-nbctl ls-add bob | |
3317 | ovn-nbctl ls-add join | |
75cf9d2b GS |
3318 | |
3319 | # Connect foo to R1 | |
31114af7 | 3320 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 3321 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 3322 | options:router-port=foo addresses=\"00:00:01:01:02:03\" |
75cf9d2b GS |
3323 | |
3324 | # Connect alice to R2 | |
31114af7 | 3325 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 3326 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 3327 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
75cf9d2b GS |
3328 | |
3329 | # Connect bob to R3 | |
31114af7 | 3330 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24 |
31ed1192 | 3331 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ |
80f408f4 | 3332 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" |
75cf9d2b GS |
3333 | |
3334 | # Connect R1 to join | |
31114af7 | 3335 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 3336 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 3337 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
75cf9d2b GS |
3338 | |
3339 | # Connect R2 to join | |
31114af7 | 3340 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 3341 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 3342 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
75cf9d2b GS |
3343 | |
3344 | # Connect R3 to join | |
31114af7 | 3345 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 |
31ed1192 | 3346 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ |
80f408f4 | 3347 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' |
75cf9d2b GS |
3348 | |
3349 | #install static routes | |
e48ccf3c JP |
3350 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
3351 | ovn-nbctl lr-route-add R1 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 3352 | |
e48ccf3c JP |
3353 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 |
3354 | ovn-nbctl lr-route-add R2 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 3355 | |
e48ccf3c JP |
3356 | ovn-nbctl lr-route-add R3 192.168.1.0/24 20.0.0.1 |
3357 | ovn-nbctl lr-route-add R3 172.16.1.0/24 20.0.0.2 | |
75cf9d2b GS |
3358 | |
3359 | # Create logical port foo1 in foo | |
31ed1192 JP |
3360 | ovn-nbctl lsp-add foo foo1 \ |
3361 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
75cf9d2b GS |
3362 | |
3363 | # Create logical port alice1 in alice | |
31ed1192 JP |
3364 | ovn-nbctl lsp-add alice alice1 \ |
3365 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
75cf9d2b GS |
3366 | |
3367 | # Create logical port bob1 in bob | |
31ed1192 JP |
3368 | ovn-nbctl lsp-add bob bob1 \ |
3369 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 10.32.1.2" | |
75cf9d2b GS |
3370 | |
3371 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3372 | net_add n1 | |
3373 | ||
3374 | sim_add hv1 | |
3375 | as hv1 | |
3376 | ovs-vsctl add-br br-phys | |
3377 | ovn_attach n1 br-phys 192.168.0.1 | |
3378 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3379 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3380 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3381 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3382 | ofport-request=1 | |
3383 | ||
3384 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3385 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
3386 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3387 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3388 | ofport-request=2 | |
3389 | ||
3390 | sim_add hv2 | |
3391 | as hv2 | |
3392 | ovs-vsctl add-br br-phys | |
3393 | ovn_attach n1 br-phys 192.168.0.2 | |
3394 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3395 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
3396 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3397 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3398 | ofport-request=1 | |
3399 | ||
3400 | ||
3401 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3402 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3403 | # for ARP resolution). | |
3404 | ovn_populate_arp | |
3405 | ||
3406 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3407 | # XXX This should be more systematic. | |
3408 | sleep 1 | |
3409 | ||
3410 | ip_to_hex() { | |
3411 | printf "%02x%02x%02x%02x" "$@" | |
3412 | } | |
75cf9d2b GS |
3413 | |
3414 | # Send ip packets between foo1 and alice1 | |
3415 | src_mac="f00000010203" | |
3416 | dst_mac="000001010203" | |
3417 | src_ip=`ip_to_hex 192 168 1 2` | |
3418 | dst_ip=`ip_to_hex 172 16 1 2` | |
3419 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3420 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3421 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
3422 | ||
3423 | # Send ip packets between foo1 and bob1 | |
3424 | src_mac="f00000010203" | |
3425 | dst_mac="000001010203" | |
3426 | src_ip=`ip_to_hex 192 168 1 2` | |
3427 | dst_ip=`ip_to_hex 10 32 1 2` | |
3428 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3429 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3430 | ||
3431 | echo "---------NB dump-----" | |
3432 | ovn-nbctl show | |
3433 | echo "---------------------" | |
3434 | ovn-nbctl list logical_router | |
3435 | echo "---------------------" | |
3436 | ovn-nbctl list logical_router_port | |
3437 | echo "---------------------" | |
3438 | ||
3439 | echo "---------SB dump-----" | |
3440 | ovn-sbctl list datapath_binding | |
3441 | echo "---------------------" | |
3442 | ovn-sbctl list port_binding | |
3443 | echo "---------------------" | |
3444 | ovn-sbctl dump-flows | |
3445 | echo "---------------------" | |
3446 | ||
3447 | echo "------ hv1 dump ----------" | |
3448 | as hv1 ovs-ofctl show br-int | |
3449 | as hv1 ovs-ofctl dump-flows br-int | |
3450 | echo "------ hv2 dump ----------" | |
3451 | as hv2 ovs-ofctl show br-int | |
3452 | as hv2 ovs-ofctl dump-flows br-int | |
3453 | echo "----------------------------" | |
3454 | ||
3455 | # Packet to Expect at bob1 | |
3456 | src_mac="000003010203" | |
3457 | dst_mac="f00000010205" | |
3458 | src_ip=`ip_to_hex 192 168 1 2` | |
3459 | dst_ip=`ip_to_hex 10 32 1 2` | |
49d7c759 | 3460 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 3461 | |
49d7c759 | 3462 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
75cf9d2b GS |
3463 | |
3464 | # Packet to Expect at alice1 | |
3465 | src_mac="000002010203" | |
3466 | dst_mac="f00000010204" | |
3467 | src_ip=`ip_to_hex 192 168 1 2` | |
3468 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 3469 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 3470 | |
49d7c759 | 3471 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
75cf9d2b | 3472 | |
7a8f15e0 | 3473 | OVN_CLEANUP([hv1],[hv2]) |
75cf9d2b GS |
3474 | |
3475 | AT_CLEANUP | |
c1645003 | 3476 | |
281977f7 NS |
3477 | AT_SETUP([ovn -- dhcpv4 : 1 HV, 2 LS, 2 LSPs/LS]) |
3478 | AT_KEYWORDS([dhcpv4]) | |
3479 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3480 | ovn_start | |
3481 | ||
3482 | ovn-nbctl ls-add ls1 | |
3483 | ||
3484 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3485 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
3486 | ||
3487 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
3488 | ||
3489 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3490 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
3491 | ||
3492 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
3493 | ||
3494 | ovn-nbctl ls-add ls2 | |
3495 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
3496 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
3497 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
3498 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
3499 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
3500 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
3501 | ||
3502 | ovn-nbctl -- --id=@d1 create DHCP_Options cidr=10.0.0.0/24 \ | |
3503 | options="\"server_id\"=\"10.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:01\" \ | |
3504 | \"lease_time\"=\"3600\" \"router\"=\"10.0.0.1\"" \ | |
3505 | -- add Logical_Switch_Port ls1-lp1 dhcpv4_options @d1 \ | |
3506 | -- add Logical_Switch_Port ls1-lp2 dhcpv4_options @d1 | |
3507 | ||
3508 | ovn-nbctl -- --id=@d2 create DHCP_Options cidr=30.0.0.0/24 \ | |
3509 | options="\"server_id\"=\"30.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:02\" \ | |
3510 | \"lease_time\"=\"3600\"" -- add Logical_Switch_Port ls2-lp2 dhcpv4_options @d2 | |
3511 | ||
3512 | net_add n1 | |
3513 | sim_add hv1 | |
3514 | ||
3515 | as hv1 | |
3516 | ovs-vsctl add-br br-phys | |
3517 | ovn_attach n1 br-phys 192.168.0.1 | |
3518 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3519 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
3520 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3521 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3522 | ofport-request=1 | |
3523 | ||
3524 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3525 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
3526 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3527 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3528 | ofport-request=2 | |
3529 | ||
3530 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
3531 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
3532 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
3533 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
3534 | ofport-request=3 | |
3535 | ||
3536 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
3537 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
3538 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
3539 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
3540 | ofport-request=4 | |
3541 | ||
3542 | ovn_populate_arp | |
3543 | ||
3544 | sleep 2 | |
3545 | ||
3546 | as hv1 ovs-vsctl show | |
3547 | ||
281977f7 NS |
3548 | # This shell function sends a DHCP request packet |
3549 | # test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ... | |
3550 | test_dhcp() { | |
3551 | local inport=$1 src_mac=$2 dhcp_type=$3 offer_ip=$4 | |
3552 | local request=ffffffffffff${src_mac}080045100110000000008011000000000000ffffffff | |
3553 | # udp header and dhcp header | |
3554 | request+=0044004300fc0000 | |
3555 | request+=010106006359aa760000000000000000000000000000000000000000${src_mac} | |
3556 | # client hardware padding | |
3557 | request+=00000000000000000000 | |
3558 | # server hostname | |
3559 | request+=0000000000000000000000000000000000000000000000000000000000000000 | |
3560 | request+=0000000000000000000000000000000000000000000000000000000000000000 | |
3561 | # boot file name | |
3562 | request+=0000000000000000000000000000000000000000000000000000000000000000 | |
3563 | request+=0000000000000000000000000000000000000000000000000000000000000000 | |
3564 | request+=0000000000000000000000000000000000000000000000000000000000000000 | |
3565 | request+=0000000000000000000000000000000000000000000000000000000000000000 | |
3566 | # dhcp magic cookie | |
3567 | request+=63825363 | |
3568 | # dhcp message type | |
3569 | request+=3501${dhcp_type}ff | |
3570 | ||
3571 | if test $offer_ip != 0; then | |
3572 | local srv_mac=$5 srv_ip=$6 expected_dhcp_opts=$7 | |
3573 | # total IP length will be the IP length of the request packet | |
3574 | # (which is 272 in our case) + 8 (padding bytes) + (expected_dhcp_opts / 2) | |
3575 | ip_len=`expr 280 + ${#expected_dhcp_opts} / 2` | |
3576 | udp_len=`expr $ip_len - 20` | |
3577 | printf -v ip_len "%x" $ip_len | |
3578 | printf -v udp_len "%x" $udp_len | |
3579 | # $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len | |
3580 | local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip} | |
3581 | # udp header and dhcp header. | |
3582 | # $udp_len var will be in 3 digits. So adding a '0' before $udp_len | |
3583 | reply+=004300440${udp_len}0000020106006359aa760000000000000000 | |
3584 | # your ip address | |
3585 | reply+=${offer_ip} | |
3586 | # next server ip address, relay agent ip address, client mac address | |
3587 | reply+=0000000000000000${src_mac} | |
3588 | # client hardware padding | |
3589 | reply+=00000000000000000000 | |
3590 | # server hostname | |
3591 | reply+=0000000000000000000000000000000000000000000000000000000000000000 | |
3592 | reply+=0000000000000000000000000000000000000000000000000000000000000000 | |
3593 | # boot file name | |
3594 | reply+=0000000000000000000000000000000000000000000000000000000000000000 | |
3595 | reply+=0000000000000000000000000000000000000000000000000000000000000000 | |
3596 | reply+=0000000000000000000000000000000000000000000000000000000000000000 | |
3597 | reply+=0000000000000000000000000000000000000000000000000000000000000000 | |
3598 | # dhcp magic cookie | |
3599 | reply+=63825363 | |
3600 | # dhcp message type | |
3601 | local dhcp_reply_type=02 | |
3602 | if test $dhcp_type = 03; then | |
3603 | dhcp_reply_type=05 | |
3604 | fi | |
3605 | reply+=3501${dhcp_reply_type}${expected_dhcp_opts}00000000ff00000000 | |
3606 | echo $reply >> $inport.expected | |
3607 | else | |
3608 | shift; shift; shift; shift; | |
3609 | for outport; do | |
e4543cfe | 3610 | echo $request >> $outport.expected |
281977f7 NS |
3611 | done |
3612 | fi | |
3613 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
3614 | } | |
3615 | ||
3616 | reset_pcap_file() { | |
3617 | local iface=$1 | |
3618 | local pcap_file=$2 | |
3619 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
3620 | options:rxq_pcap=dummy-rx.pcap | |
3621 | rm -f ${pcap_file}*.pcap | |
3622 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
3623 | options:rxq_pcap=${pcap_file}-rx.pcap | |
3624 | } | |
3625 | ||
3626 | ip_to_hex() { | |
3627 | printf "%02x%02x%02x%02x" "$@" | |
3628 | } | |
3629 | ||
3630 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
3631 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
3632 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
3633 | ||
3634 | echo "---------NB dump-----" | |
3635 | ovn-nbctl show | |
3636 | echo "---------------------" | |
3637 | echo "---------SB dump-----" | |
3638 | ovn-sbctl list datapath_binding | |
3639 | echo "---------------------" | |
3640 | ovn-sbctl list logical_flow | |
3641 | echo "---------------------" | |
3642 | ||
3643 | echo "---------------------" | |
3644 | ovn-sbctl dump-flows | |
3645 | echo "---------------------" | |
3646 | ||
3647 | echo "------ hv1 dump ----------" | |
3648 | as hv1 ovs-ofctl dump-flows br-int | |
3649 | ||
3650 | # Send DHCPDISCOVER. | |
3651 | offer_ip=`ip_to_hex 10 0 0 4` | |
3652 | server_ip=`ip_to_hex 10 0 0 1` | |
3653 | expected_dhcp_opts=0104ffffff0003040a00000136040a000001330400000e10 | |
3654 | test_dhcp 1 f00000000001 01 $offer_ip ff1000000001 $server_ip $expected_dhcp_opts | |
3655 | ||
3656 | # NXT_RESUMEs should be 1. | |
3657 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3658 | ||
3659 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
3660 | cat 1.expected | cut -c -48 > expout | |
3661 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
3662 | # Skipping the IPv4 checksum. | |
3663 | cat 1.expected | cut -c 53- > expout | |
3664 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
3665 | ||
3666 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
3667 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
3668 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3669 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3670 | rm -f 1.expected | |
3671 | rm -f 2.expected | |
3672 | ||
3673 | # Send DHCPREQUEST. | |
3674 | offer_ip=`ip_to_hex 10 0 0 6` | |
3675 | server_ip=`ip_to_hex 10 0 0 1` | |
3676 | expected_dhcp_opts=0104ffffff0003040a00000136040a000001330400000e10 | |
3677 | test_dhcp 2 f00000000002 03 $offer_ip ff1000000001 $server_ip $expected_dhcp_opts | |
3678 | ||
3679 | # NXT_RESUMEs should be 2. | |
3680 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3681 | ||
3682 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
3683 | cat 2.expected | cut -c -48 > expout | |
3684 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
3685 | # Skipping the IPv4 checksum. | |
3686 | cat 2.expected | cut -c 53- > expout | |
3687 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
3688 | ||
3689 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3690 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3691 | rm -f 1.expected | |
3692 | rm -f 2.expected | |
3693 | ||
3694 | # Send Invalid DHCPv4 packet on ls1-lp2. It should be received by ovn-controller | |
3695 | # but should be resumed without the reply. | |
3696 | # ls1-lp1 (vif1-tx.pcap) should receive the DHCPv4 request packet twice, | |
3697 | # one from ovn-controller and the other from "ovs-ofctl resume." | |
3698 | offer_ip=0 | |
3699 | test_dhcp 2 f00000000002 08 $offer_ip 1 1 | |
3700 | ||
3701 | # NXT_RESUMEs should be 3. | |
3702 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3703 | ||
3704 | # vif1-tx.pcap should have received the DHCPv4 (invalid) request packet | |
49d7c759 | 3705 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected]) |
281977f7 NS |
3706 | |
3707 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3708 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3709 | rm -f 1.expected | |
3710 | rm -f 2.expected | |
3711 | ||
3712 | # Send DHCPv4 packet on ls2-lp1. It doesn't have any DHCPv4 options defined. | |
3713 | # ls2-lp2 (vif4-tx.pcap) should receive the DHCPv4 request packet once. | |
3714 | ||
3715 | test_dhcp 3 f00000000003 01 0 4 | |
3716 | ||
3717 | # Send DHCPv4 packet on ls2-lp2. "router" DHCPv4 option is not defined for | |
3718 | # this lport. | |
3719 | test_dhcp 4 f00000000004 01 0 3 | |
3720 | ||
3721 | # NXT_RESUMEs should be 3. | |
3722 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3723 | ||
49d7c759 BP |
3724 | OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected]) |
3725 | OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [4.expected]) | |
281977f7 NS |
3726 | |
3727 | as hv1 | |
33ac3c83 NS |
3728 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) |
3729 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3730 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3731 | ||
3732 | as ovn-sb | |
3733 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3734 | ||
3735 | as ovn-nb | |
3736 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3737 | ||
3738 | as northd | |
3739 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
3740 | ||
3741 | as main | |
3742 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3743 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3744 | ||
3745 | AT_CLEANUP | |
3746 | ||
3747 | AT_SETUP([ovn -- dhcpv6 : 1 HV, 2 LS, 2 LSPs/LS]) | |
3748 | AT_KEYWORDS([dhcpv6]) | |
3749 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3750 | ovn_start | |
3751 | ||
3752 | ovn-nbctl ls-add ls1 | |
3753 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3754 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
3755 | ||
3756 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
3757 | ||
3758 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3759 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
3760 | ||
3761 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
3762 | ||
3763 | ovn-nbctl -- --id=@d1 create DHCP_Options cidr="ae70\:\:/64" \ | |
3764 | options="\"server_id\"=\"00:00:00:10:00:01\"" \ | |
3765 | -- add Logical_Switch_Port ls1-lp1 dhcpv6_options @d1 \ | |
3766 | -- add Logical_Switch_Port ls1-lp2 dhcpv6_options @d1 | |
3767 | ||
3768 | ovn-nbctl ls-add ls2 | |
3769 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
3770 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
3771 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
3772 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
3773 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
3774 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
3775 | ||
3776 | net_add n1 | |
3777 | sim_add hv1 | |
3778 | ||
3779 | as hv1 | |
3780 | ovs-vsctl add-br br-phys | |
3781 | ovn_attach n1 br-phys 192.168.0.1 | |
3782 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3783 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
3784 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3785 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3786 | ofport-request=1 | |
3787 | ||
3788 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3789 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
3790 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3791 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3792 | ofport-request=2 | |
3793 | ||
3794 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
3795 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
3796 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
3797 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
3798 | ofport-request=3 | |
3799 | ||
3800 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
3801 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
3802 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
3803 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
3804 | ofport-request=4 | |
3805 | ||
3806 | ovn_populate_arp | |
3807 | ||
3808 | sleep 2 | |
3809 | ||
3810 | trim_zeros() { | |
3811 | sed 's/\(00\)\{1,\}$//' | |
3812 | } | |
3813 | ||
3814 | # This shell function sends a DHCPv6 request packet | |
3815 | # test_dhcp INPORT SRC_MAC DHCPv6_MSG_TYPE OUTPORT... | |
3816 | # The OUTPORTs (zero or more) list the VIFs on which the original DHCP | |
3817 | # packet should be received twice (one from ovn-controller and the other | |
3818 | # from the "ovs-ofctl monitor br-int resume" | |
3819 | test_dhcpv6() { | |
3820 | local inport=$1 src_mac=$2 src_lla=$3 msg_code=$4 offer_ip=$5 | |
3821 | local request=ffffffffffff${src_mac}86dd00000000002a1101${src_lla} | |
3822 | # dst ip ff02::1:2 | |
3823 | request+=ff020000000000000000000000010002 | |
3824 | # udp header and dhcpv6 header | |
3825 | request+=02220223002affff${msg_code}010203 | |
3826 | # Client identifier | |
3827 | request+=0001000a00030001${src_mac} | |
3828 | # IA-NA (Identity Association for Non Temporary Address) | |
3829 | request+=0003000c0102030400000e1000001518 | |
3830 | shift; shift; shift; shift; shift; | |
3831 | if test $offer_ip != 0; then | |
3832 | local server_mac=000000100001 | |
3833 | local server_lla=fe80000000000000020000fffe100001 | |
3834 | local reply_code=07 | |
3835 | if test $msg_code = 01; then | |
3836 | reply_code=02 | |
3837 | fi | |
3838 | local reply=${src_mac}${server_mac}86dd0000000000541101${server_lla}${src_lla} | |
3839 | # udp header and dhcpv6 header | |
3840 | reply+=022302220054ffff${reply_code}010203 | |
3841 | # Client identifier | |
3842 | reply+=0001000a00030001${src_mac} | |
3843 | # IA-NA | |
3844 | reply+=0003002801020304ffffffffffffffff00050018${offer_ip}ffffffffffffffff | |
3845 | # Server identifier | |
3846 | reply+=0002000a00030001${server_mac} | |
3847 | echo $reply | trim_zeros >> $inport.expected | |
3848 | else | |
3849 | for outport; do | |
3850 | echo $request | trim_zeros >> $outport.expected | |
3851 | done | |
3852 | fi | |
3853 | ||
3854 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
3855 | } | |
3856 | ||
3857 | reset_pcap_file() { | |
3858 | local iface=$1 | |
3859 | local pcap_file=$2 | |
3860 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
3861 | options:rxq_pcap=dummy-rx.pcap | |
3862 | rm -f ${pcap_file}*.pcap | |
3863 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
3864 | options:rxq_pcap=${pcap_file}-rx.pcap | |
3865 | } | |
3866 | ||
3867 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
3868 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
3869 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
3870 | ||
3871 | echo "---------NB dump-----" | |
3872 | ovn-nbctl show | |
3873 | echo "---------------------" | |
3874 | echo "---------SB dump-----" | |
3875 | ovn-sbctl list datapath_binding | |
3876 | echo "---------------------" | |
3877 | ovn-sbctl list logical_flow | |
3878 | echo "---------------------" | |
3879 | ||
3880 | echo "---------------------" | |
3881 | ovn-sbctl dump-flows | |
3882 | echo "---------------------" | |
3883 | ||
3884 | echo "------ hv1 dump ----------" | |
3885 | as hv1 ovs-ofctl dump-flows br-int | |
3886 | ||
3887 | src_mac=f00000000001 | |
3888 | src_lla=fe80000000000000f20000fffe000001 | |
3889 | offer_ip=ae700000000000000000000000000004 | |
3890 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
3891 | ||
3892 | # NXT_RESUMEs should be 1. | |
3893 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3894 | ||
3895 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
3896 | # cat 1.expected | trim_zeros > expout | |
3897 | cat 1.expected | cut -c -120 > expout | |
3898 | AT_CHECK([cat 1.packets | cut -c -120], [0], [expout]) | |
3899 | # Skipping the UDP checksum | |
3900 | cat 1.expected | cut -c 125- > expout | |
3901 | AT_CHECK([cat 1.packets | cut -c 125-], [0], [expout]) | |
3902 | ||
3903 | rm 1.expected | |
3904 | ||
3905 | # Send invalid packet on ls1-lp2. ovn-controller should resume the packet | |
3906 | # without any modifications and the packet should be received by ls1-lp1. | |
3907 | # ls1-lp1 will receive the packet twice, one from the ovn-controller after the | |
3908 | # resume and the other from ovs-ofctl monitor resume. | |
3909 | ||
3910 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3911 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3912 | ||
3913 | src_mac=f00000000002 | |
3914 | src_lla=fe80000000000000f20000fffe000002 | |
3915 | offer_ip=ae700000000000000000000000000005 | |
3916 | # Set invalid msg_type | |
3917 | ||
3918 | test_dhcpv6 2 $src_mac $src_lla 10 0 1 1 | |
3919 | ||
3920 | # NXT_RESUMEs should be 2. | |
3921 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3922 | ||
3923 | # vif2-tx.pcap should not have received the DHCPv6 reply packet | |
3924 | rm 2.packets | |
3925 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > 2.packets | |
3926 | AT_CHECK([cat 2.packets], [0], []) | |
3927 | ||
3928 | # vif1-tx.pcap should have received the DHCPv6 (invalid) request packet | |
3929 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
3930 | cat 1.expected > expout | |
3931 | AT_CHECK([cat 1.packets], [0], [expout]) | |
3932 | ||
3933 | # Send DHCPv6 packet on ls2-lp1. native DHCPv6 is disabled on this port. | |
3934 | # There should be no DHCPv6 reply from ovn-controller and the request packet | |
3935 | # should be received by ls2-lp2. | |
3936 | ||
3937 | src_mac=f00000000003 | |
3938 | src_lla=fe80000000000000f20000fffe000003 | |
3939 | test_dhcpv6 3 $src_mac $src_lla 01 0 4 | |
3940 | ||
3941 | # NXT_RESUMEs should be 2 only. | |
3942 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3943 | ||
3944 | # vif3-tx.pcap should not have received the DHCPv6 reply packet | |
3945 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap | trim_zeros > 3.packets | |
3946 | AT_CHECK([cat 3.packets], [0], []) | |
3947 | ||
3948 | # vif4-tx.pcap should have received the DHCPv6 request packet | |
3949 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif4-tx.pcap | trim_zeros > 4.packets | |
3950 | cat 4.expected > expout | |
3951 | AT_CHECK([cat 4.packets], [0], [expout]) | |
3952 | ||
3953 | as hv1 | |
281977f7 NS |
3954 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) |
3955 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3956 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3957 | ||
3958 | as ovn-sb | |
3959 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3960 | ||
3961 | as ovn-nb | |
3962 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3963 | ||
3964 | as northd | |
3965 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
3966 | ||
3967 | as main | |
3968 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3969 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3970 | ||
3971 | AT_CLEANUP | |
3972 | ||
c1645003 GS |
3973 | AT_SETUP([ovn -- 2 HVs, 2 LRs connected via LS, gateway router]) |
3974 | AT_KEYWORDS([ovngatewayrouter]) | |
3975 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3976 | ovn_start | |
3977 | ||
3978 | # Logical network: | |
3979 | # Two LRs - R1 and R2 that are connected to each other via LS "join" | |
3980 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
3981 | # connected to it. R2 has alice (172.16.1.0/24) connected to it. | |
3982 | # R2 is a gateway router. | |
3983 | ||
3984 | ||
3985 | ||
3986 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3987 | net_add n1 | |
3988 | ||
3989 | sim_add hv1 | |
3990 | as hv1 | |
3991 | ovs-vsctl add-br br-phys | |
3992 | ovn_attach n1 br-phys 192.168.0.1 | |
3993 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3994 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3995 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3996 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3997 | ofport-request=1 | |
3998 | ||
3999 | ||
4000 | sim_add hv2 | |
4001 | as hv2 | |
4002 | ovs-vsctl add-br br-phys | |
4003 | ovn_attach n1 br-phys 192.168.0.2 | |
4004 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
4005 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
4006 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
4007 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
4008 | ofport-request=1 | |
4009 | ||
4010 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
4011 | # packets for ARP resolution (native tunneling doesn't queue packets | |
4012 | # for ARP resolution). | |
4013 | ovn_populate_arp | |
4014 | ||
4015 | ovn-nbctl create Logical_Router name=R1 | |
4016 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
4017 | ||
ea46a4e9 JP |
4018 | ovn-nbctl ls-add foo |
4019 | ovn-nbctl ls-add alice | |
4020 | ovn-nbctl ls-add join | |
c1645003 GS |
4021 | |
4022 | # Connect foo to R1 | |
31114af7 | 4023 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 4024 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ |
80f408f4 | 4025 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" |
c1645003 GS |
4026 | |
4027 | # Connect alice to R2 | |
31114af7 | 4028 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 4029 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 4030 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
c1645003 GS |
4031 | |
4032 | # Connect R1 to join | |
31114af7 | 4033 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 4034 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 4035 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
c1645003 GS |
4036 | |
4037 | # Connect R2 to join | |
31114af7 | 4038 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 4039 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 4040 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
c1645003 GS |
4041 | |
4042 | ||
4043 | #install static routes | |
4044 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4045 | ip_prefix=172.16.1.0/24 nexthop=20.0.0.2 -- add Logical_Router \ | |
4046 | R1 static_routes @lrt | |
4047 | ||
4048 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4049 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
4050 | R2 static_routes @lrt | |
4051 | ||
4052 | # Create logical port foo1 in foo | |
31ed1192 JP |
4053 | ovn-nbctl lsp-add foo foo1 \ |
4054 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
c1645003 GS |
4055 | |
4056 | # Create logical port alice1 in alice | |
31ed1192 JP |
4057 | ovn-nbctl lsp-add alice alice1 \ |
4058 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
c1645003 GS |
4059 | |
4060 | ||
4061 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4062 | # XXX This should be more systematic. | |
4063 | sleep 2 | |
4064 | ||
4065 | ip_to_hex() { | |
4066 | printf "%02x%02x%02x%02x" "$@" | |
4067 | } | |
c1645003 GS |
4068 | |
4069 | # Send ip packets between foo1 and alice1 | |
4070 | src_mac="f00000010203" | |
4071 | dst_mac="000001010203" | |
4072 | src_ip=`ip_to_hex 192 168 1 2` | |
4073 | dst_ip=`ip_to_hex 172 16 1 2` | |
4074 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4075 | ||
4076 | echo "---------NB dump-----" | |
4077 | ovn-nbctl show | |
4078 | echo "---------------------" | |
4079 | ovn-nbctl list logical_router | |
4080 | echo "---------------------" | |
4081 | ovn-nbctl list logical_router_port | |
4082 | echo "---------------------" | |
4083 | ||
4084 | echo "---------SB dump-----" | |
4085 | ovn-sbctl list datapath_binding | |
4086 | echo "---------------------" | |
4087 | ovn-sbctl list port_binding | |
4088 | echo "---------------------" | |
4089 | ovn-sbctl dump-flows | |
4090 | echo "---------------------" | |
4091 | ovn-sbctl list chassis | |
4092 | ovn-sbctl list encap | |
4093 | echo "---------------------" | |
4094 | ||
c1645003 GS |
4095 | # Packet to Expect at alice1 |
4096 | src_mac="000002010203" | |
4097 | dst_mac="f00000010204" | |
4098 | src_ip=`ip_to_hex 192 168 1 2` | |
4099 | dst_ip=`ip_to_hex 172 16 1 2` | |
4100 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
4101 | ||
4102 | ||
4103 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4104 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
4105 | ||
ab39371d RM |
4106 | echo "------ hv1 dump after packet 1 ----------" |
4107 | as hv1 ovs-ofctl show br-int | |
4108 | as hv1 ovs-ofctl dump-flows br-int | |
4109 | echo "------ hv2 dump after packet 1 ----------" | |
4110 | as hv2 ovs-ofctl show br-int | |
4111 | as hv2 ovs-ofctl dump-flows br-int | |
4112 | echo "----------------------------" | |
4113 | ||
49d7c759 BP |
4114 | echo $expected > expected |
4115 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
c1645003 | 4116 | |
34114cf8 GS |
4117 | # Delete the router and re-create it. Things should work as before. |
4118 | ovn-nbctl lr-del R2 | |
4119 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
4120 | # Connect alice to R2 | |
4121 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
4122 | # Connect R2 to join | |
4123 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
4124 | ||
4125 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4126 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
4127 | R2 static_routes @lrt | |
4128 | ||
4129 | # Wait for ovn-controller to catch up. | |
4130 | sleep 1 | |
4131 | ||
4132 | # Send the packet again. | |
4133 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
ab39371d RM |
4134 | |
4135 | echo "------ hv1 dump after packet 2 ----------" | |
4136 | as hv1 ovs-ofctl show br-int | |
4137 | as hv1 ovs-ofctl dump-flows br-int | |
4138 | echo "------ hv2 dump after packet 2 ----------" | |
4139 | as hv2 ovs-ofctl show br-int | |
4140 | as hv2 ovs-ofctl dump-flows br-int | |
4141 | echo "----------------------------" | |
4142 | ||
49d7c759 BP |
4143 | echo $expected >> expected |
4144 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
34114cf8 | 4145 | |
7a8f15e0 | 4146 | OVN_CLEANUP([hv1],[hv2]) |
c1645003 GS |
4147 | |
4148 | AT_CLEANUP | |
bb3c4568 FF |
4149 | |
4150 | AT_SETUP([ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR]) | |
4151 | AT_KEYWORDS([router-icmp-reply]) | |
4152 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4153 | ovn_start | |
4154 | ||
4155 | # Logical network: | |
4156 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
4157 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
4158 | ||
fa2a27b2 | 4159 | ovn-nbctl lr-add R1 |
bb3c4568 | 4160 | |
ea46a4e9 JP |
4161 | ovn-nbctl ls-add ls1 |
4162 | ovn-nbctl ls-add ls2 | |
bb3c4568 FF |
4163 | |
4164 | # Connect ls1 to R1 | |
31114af7 | 4165 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24 |
31ed1192 | 4166 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \ |
80f408f4 | 4167 | type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\" |
bb3c4568 FF |
4168 | |
4169 | # Connect ls2 to R1 | |
31114af7 | 4170 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24 |
31ed1192 | 4171 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \ |
80f408f4 | 4172 | type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\" |
bb3c4568 FF |
4173 | |
4174 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
4175 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
4176 | -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2" | |
bb3c4568 FF |
4177 | |
4178 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
4179 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
4180 | -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2" | |
bb3c4568 FF |
4181 | |
4182 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
4183 | net_add n1 | |
4184 | ||
4185 | sim_add hv1 | |
4186 | as hv1 | |
4187 | ovs-vsctl add-br br-phys | |
4188 | ovn_attach n1 br-phys 192.168.0.1 | |
4189 | ovs-vsctl -- add-port br-int vif1 -- \ | |
4190 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
4191 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4192 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4193 | ofport-request=1 | |
4194 | ||
4195 | ovs-vsctl -- add-port br-int vif2 -- \ | |
4196 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
4197 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4198 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4199 | ofport-request=1 | |
4200 | ||
4201 | ||
4202 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4203 | # XXX This should be more systematic. | |
4204 | sleep 1 | |
4205 | ||
4206 | ||
4207 | ip_to_hex() { | |
4208 | printf "%02x%02x%02x%02x" "$@" | |
4209 | } | |
bb3c4568 FF |
4210 | for i in 1 2; do |
4211 | : > vif$i.expected | |
4212 | done | |
4213 | # test_ipv4_icmp_request INPORT ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM ICMP_CHKSUM [EXP_IP_CHKSUM EXP_ICMP_CHKSUM] | |
4214 | # | |
4215 | # Causes a packet to be received on INPORT. The packet is an ICMPv4 | |
4216 | # request with ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHSUM and | |
4217 | # ICMP_CHKSUM as specified. If EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are | |
4218 | # provided, then it should be the ip and icmp checksums of the packet | |
4219 | # responded; otherwise, no reply is expected. | |
4220 | # In the absence of an ip checksum calculation helpers, this relies | |
4221 | # on the caller to provide the checksums for the ip and icmp headers. | |
4222 | # XXX This should be more systematic. | |
4223 | # | |
4224 | # INPORT is an lport number, e.g. 11 for vif11. | |
4225 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
4226 | # IPV4_SRC and IPV4_DST are each 8 hex digits. | |
4227 | # IP_CHSUM and ICMP_CHKSUM are each 4 hex digits. | |
4228 | # EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits. | |
4229 | test_ipv4_icmp_request() { | |
4230 | local inport=$1 eth_src=$2 eth_dst=$3 ipv4_src=$4 ipv4_dst=$5 ip_chksum=$6 icmp_chksum=$7 | |
4231 | local exp_ip_chksum=$8 exp_icmp_chksum=$9 | |
4232 | shift; shift; shift; shift; shift; shift; shift | |
4233 | shift; shift | |
4234 | ||
4235 | # Use ttl to exercise section 4.2.2.9 of RFC1812 | |
4236 | local ip_ttl=01 | |
4237 | local icmp_id=5fbf | |
4238 | local icmp_seq=0001 | |
4239 | local icmp_data=$(seq 1 56 | xargs printf "%02x") | |
4240 | local icmp_type_code_request=0800 | |
4241 | local icmp_payload=${icmp_type_code_request}${icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
4242 | local packet=${eth_dst}${eth_src}08004500005400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${icmp_payload} | |
4243 | ||
4244 | as hv1 ovs-appctl netdev-dummy/receive vif$inport $packet | |
4245 | if test X$exp_icmp_chksum != X; then | |
4246 | # Expect to receive the reply, if any. In same port where packet was sent. | |
4247 | # Note: src and dst fields are expected to be reversed. | |
4248 | local icmp_type_code_response=0000 | |
4249 | local reply_icmp_ttl=fe | |
4250 | local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
4251 | local reply=${eth_src}${eth_dst}08004500005400004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload} | |
4252 | echo $reply >> vif$inport.expected | |
4253 | fi | |
4254 | } | |
4255 | ||
4256 | # Send ping packet to router's ip addresses, from each of the 2 logical ports. | |
4257 | rtr_l1_ip=$(ip_to_hex 192 168 1 1) | |
4258 | rtr_l2_ip=$(ip_to_hex 172 16 1 1) | |
4259 | l1_ip=$(ip_to_hex 192 168 1 2) | |
4260 | l2_ip=$(ip_to_hex 172 16 1 2) | |
4261 | ||
4262 | # Ping router ip address that is on same subnet as the logical port | |
4263 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
4264 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
4265 | ||
4266 | # Ping router ip address that is on the other side of the logical ports | |
4267 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
4268 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
4269 | ||
4270 | echo "---------NB dump-----" | |
4271 | ovn-nbctl show | |
4272 | echo "---------------------" | |
4273 | ovn-nbctl list logical_router | |
4274 | echo "---------------------" | |
4275 | ovn-nbctl list logical_router_port | |
4276 | echo "---------------------" | |
4277 | ||
4278 | echo "---------SB dump-----" | |
4279 | ovn-sbctl list datapath_binding | |
4280 | echo "---------------------" | |
4281 | ovn-sbctl list logical_flow | |
4282 | echo "---------------------" | |
4283 | ||
4284 | echo "------ hv1 dump ----------" | |
4285 | as hv1 ovs-ofctl dump-flows br-int | |
4286 | ||
4287 | # Now check the packets actually received against the ones expected. | |
4288 | for inport in 1 2; do | |
49d7c759 | 4289 | OVN_CHECK_PACKETS([hv1/vif${inport}-tx.pcap], [vif$inport.expected]) |
bb3c4568 FF |
4290 | done |
4291 | ||
7a8f15e0 | 4292 | OVN_CLEANUP([hv1]) |
bb3c4568 FF |
4293 | |
4294 | AT_CLEANUP | |
94f79fcb RB |
4295 | |
4296 | # 1 hypervisor, 1 port | |
4297 | # make sure that the port state is properly set to up and back down | |
4298 | # when created and deleted. | |
4299 | AT_SETUP([ovn -- port state up and down]) | |
4300 | AT_KEYWORDS([ovn]) | |
4301 | ovn_start | |
4302 | ||
4303 | ovn-nbctl ls-add ls1 | |
4304 | ovn-nbctl lsp-add ls1 lp1 | |
4305 | ovn-nbctl lsp-set-addresses lp1 unknown | |
4306 | ||
4307 | net_add n1 | |
4308 | sim_add hv1 | |
4309 | as hv1 ovs-vsctl add-br br-phys | |
4310 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
4311 | ||
4312 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
4313 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
4314 | ||
4315 | as hv1 ovs-vsctl del-port br-int vif1 | |
4316 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
4317 | ||
7a8f15e0 | 4318 | OVN_CLEANUP([hv1]) |
94f79fcb | 4319 | |
94f79fcb | 4320 | AT_CLEANUP |
e75451fe | 4321 | |
f8a8db39 JP |
4322 | AT_SETUP([ovn -- nd_na ]) |
4323 | AT_KEYWORDS([ovn-nd_na]) | |
e75451fe ZKL |
4324 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4325 | ovn_start | |
4326 | ||
4327 | #TODO: since patch port for IPv6 logical router port is not ready not, | |
4328 | # so we are not going to test vifs on different lswitches cases. Try | |
4329 | # to update for that once relevant stuff implemented. | |
4330 | ||
4331 | # In this test cases we create 1 lswitch, it has 2 VIF ports attached | |
4332 | # with. NS packet we test, from one VIF for another VIF, will be replied | |
4333 | # by local ovn-controller, but not by target VIF. | |
4334 | ||
4335 | # Create hypervisors and logical switch lsw0. | |
4336 | ovn-nbctl ls-add lsw0 | |
4337 | net_add n1 | |
4338 | sim_add hv1 | |
4339 | as hv1 | |
4340 | ovs-vsctl add-br br-phys | |
4341 | ovn_attach n1 br-phys 192.168.0.2 | |
4342 | ||
4343 | # Add vif1 to hv1 and lsw0, turn on l2 port security on vif1. | |
4344 | ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=hv1/vif1-tx.pcap options:rxq_pcap=hv1/vif1-rx.pcap ofport-request=1 | |
4345 | ovn-nbctl lsp-add lsw0 lp1 | |
4346 | ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598" | |
4347 | ovn-nbctl lsp-set-port-security lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598" | |
4348 | ||
4349 | # Add vif2 to hv1 and lsw0, turn on l2 port security on vif2. | |
4350 | ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=hv1/vif2-tx.pcap options:rxq_pcap=hv1/vif2-rx.pcap ofport-request=2 | |
4351 | ovn-nbctl lsp-add lsw0 lp2 | |
4352 | ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae" | |
4353 | ovn-nbctl lsp-set-port-security lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae" | |
4354 | ||
4355 | # Add ACL rule for ICMPv6 on lsw0 | |
4356 | ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related | |
4357 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related | |
4358 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related | |
4359 | ||
4360 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4361 | # XXX This should be more systematic. | |
4362 | sleep 1 | |
4363 | ||
4364 | # Given the name of a logical port, prints the name of the hypervisor | |
4365 | # on which it is located. | |
4366 | vif_to_hv() { | |
4367 | echo hv1${1%?} | |
4368 | } | |
e75451fe ZKL |
4369 | for i in 1 2; do |
4370 | : > $i.expected | |
4371 | done | |
4372 | ||
4373 | # Complete Neighbor Solicitation packet and Neighbor Advertisement packet | |
4374 | # vif1 -> NS -> vif2. vif1 <- NA <- ovn-controller. | |
4375 | # vif2 will not receive NS packet, since ovn-controller will reply for it. | |
4376 | ns_packet=3333ffa1f9aefa163e94059886dd6000000000203afffd81ce49a9480000f8163efffe940598fd81ce49a9480000f8163efffea1f9ae8700e01160000000fd81ce49a9480000f8163efffea1f9ae0101fa163e940598 | |
4377 | na_packet=fa163e940598fa163ea1f9ae86dd6000000000203afffd81ce49a9480000f8163efffea1f9aefd81ce49a9480000f8163efffe9405988800e9ed60000000fd81ce49a9480000f8163efffea1f9ae0201fa163ea1f9ae | |
4378 | ||
4379 | as hv1 ovs-appctl netdev-dummy/receive vif1 $ns_packet | |
e4543cfe | 4380 | echo $na_packet >> 1.expected |
e75451fe | 4381 | |
e75451fe ZKL |
4382 | echo "------ hv1 dump ------" |
4383 | as hv1 ovs-vsctl show | |
4384 | as hv1 ovs-ofctl -O OpenFlow13 show br-int | |
4385 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
4386 | ||
4387 | for i in 1 2; do | |
49d7c759 | 4388 | OVN_CHECK_PACKETS([hv1/vif$i-tx.pcap], [$i.expected]) |
e75451fe ZKL |
4389 | done |
4390 | ||
7a8f15e0 | 4391 | OVN_CLEANUP([hv1]) |
e75451fe ZKL |
4392 | |
4393 | AT_CLEANUP | |
7417d147 RM |
4394 | |
4395 | AT_SETUP([ovn -- address sets modification/removal smoke test]) | |
4396 | AT_KEYWORDS([ovn-addr]) | |
4397 | ovn_start | |
4398 | ||
4399 | net_add n1 | |
4400 | ||
4401 | sim_add hv1 | |
4402 | as hv1 | |
4403 | ovs-vsctl add-br br-phys | |
4404 | ovn_attach n1 br-phys 192.168.0.1 | |
4405 | ||
4406 | row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"` | |
4407 | ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\" | |
4408 | ovn-nbctl destroy Address_Set $row | |
4409 | ||
4410 | sleep 1 | |
4411 | ||
4412 | # A bug previously existed in the address set support code | |
4413 | # that caused ovn-controller to crash after an address set | |
4414 | # was updated and then removed. This test case ensures | |
4415 | # that ovn-controller is at least still running after | |
4416 | # creating, updating, and deleting an address set. | |
4417 | AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore]) | |
4418 | ||
4419 | OVN_CLEANUP([hv1]) | |
4420 | ||
4421 | AT_CLEANUP | |
8639f9be ND |
4422 | |
4423 | AT_SETUP([ovn -- ipam]) | |
4424 | AT_KEYWORDS([ovnipam]) | |
4425 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4426 | ovn_start | |
4427 | ||
4428 | # Add a port to a switch that does not have a subnet set, then set the | |
4429 | # subnet which should result in an address being allocated for the port. | |
4430 | ovn-nbctl ls-add sw0 | |
4431 | ovn-nbctl lsp-add sw0 p0 -- lsp-set-addresses p0 dynamic | |
4432 | ovn-nbctl add Logical-Switch sw0 other_config subnet=192.168.1.0/24 | |
4433 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0], | |
4434 | ["0a:00:00:00:00:01 192.168.1.2" | |
4435 | ]) | |
4436 | ||
4437 | # Add 9 more ports to sw0, addresses should all be unique. | |
4438 | for n in `seq 1 9`; do | |
4439 | ovn-nbctl lsp-add sw0 "p$n" -- lsp-set-addresses "p$n" dynamic | |
4440 | done | |
4441 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p1 dynamic_addresses], [0], | |
4442 | ["0a:00:00:00:00:02 192.168.1.3" | |
4443 | ]) | |
4444 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p2 dynamic_addresses], [0], | |
4445 | ["0a:00:00:00:00:03 192.168.1.4" | |
4446 | ]) | |
4447 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p3 dynamic_addresses], [0], | |
4448 | ["0a:00:00:00:00:04 192.168.1.5" | |
4449 | ]) | |
4450 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p4 dynamic_addresses], [0], | |
4451 | ["0a:00:00:00:00:05 192.168.1.6" | |
4452 | ]) | |
4453 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p5 dynamic_addresses], [0], | |
4454 | ["0a:00:00:00:00:06 192.168.1.7" | |
4455 | ]) | |
4456 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p6 dynamic_addresses], [0], | |
4457 | ["0a:00:00:00:00:07 192.168.1.8" | |
4458 | ]) | |
4459 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p7 dynamic_addresses], [0], | |
4460 | ["0a:00:00:00:00:08 192.168.1.9" | |
4461 | ]) | |
4462 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p8 dynamic_addresses], [0], | |
4463 | ["0a:00:00:00:00:09 192.168.1.10" | |
4464 | ]) | |
4465 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p9 dynamic_addresses], [0], | |
4466 | ["0a:00:00:00:00:0a 192.168.1.11" | |
4467 | ]) | |
4468 | ||
4469 | # Trying similar tests with a second switch. MAC addresses should be unique | |
4470 | # across both switches but IP's only need to be unique within the same switch. | |
4471 | ovn-nbctl ls-add sw1 | |
4472 | ovn-nbctl lsp-add sw1 p10 -- lsp-set-addresses p10 dynamic | |
4473 | ovn-nbctl add Logical-Switch sw1 other_config subnet=192.168.1.0/24 | |
4474 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p10 dynamic_addresses], [0], | |
4475 | ["0a:00:00:00:00:0b 192.168.1.2" | |
4476 | ]) | |
4477 | ||
4478 | for n in `seq 11 19`; do | |
4479 | ovn-nbctl lsp-add sw1 "p$n" -- lsp-set-addresses "p$n" dynamic | |
4480 | done | |
4481 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p11 dynamic_addresses], [0], | |
4482 | ["0a:00:00:00:00:0c 192.168.1.3" | |
4483 | ]) | |
4484 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p12 dynamic_addresses], [0], | |
4485 | ["0a:00:00:00:00:0d 192.168.1.4" | |
4486 | ]) | |
4487 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p13 dynamic_addresses], [0], | |
4488 | ["0a:00:00:00:00:0e 192.168.1.5" | |
4489 | ]) | |
4490 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p14 dynamic_addresses], [0], | |
4491 | ["0a:00:00:00:00:0f 192.168.1.6" | |
4492 | ]) | |
4493 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p15 dynamic_addresses], [0], | |
4494 | ["0a:00:00:00:00:10 192.168.1.7" | |
4495 | ]) | |
4496 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p16 dynamic_addresses], [0], | |
4497 | ["0a:00:00:00:00:11 192.168.1.8" | |
4498 | ]) | |
4499 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p17 dynamic_addresses], [0], | |
4500 | ["0a:00:00:00:00:12 192.168.1.9" | |
4501 | ]) | |
4502 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p18 dynamic_addresses], [0], | |
4503 | ["0a:00:00:00:00:13 192.168.1.10" | |
4504 | ]) | |
4505 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p19 dynamic_addresses], [0], | |
4506 | ["0a:00:00:00:00:14 192.168.1.11" | |
4507 | ]) | |
4508 | ||
4509 | # Change a port's address to test for multiple ip's for a single address entry | |
4510 | # and addresses set by the user. | |
4511 | ovn-nbctl lsp-set-addresses p0 "0a:00:00:00:00:15 192.168.1.12 192.168.1.14" | |
4512 | ovn-nbctl lsp-add sw0 p20 -- lsp-set-addresses p20 dynamic | |
4513 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p20 dynamic_addresses], [0], | |
4514 | ["0a:00:00:00:00:16 192.168.1.13" | |
4515 | ]) | |
4516 | ||
4517 | # Test for logical router port address management. | |
4518 | ovn-nbctl create Logical_Router name=R1 | |
4519 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw0 \ | |
4520 | network="192.168.1.1/24" mac=\"0a:00:00:00:00:17\" \ | |
4521 | -- add Logical_Router R1 ports @lrp -- lsp-add sw0 rp-sw0 \ | |
4522 | -- set Logical_Switch_Port rp-sw0 type=router options:router-port=sw0 | |
4523 | ovn-nbctl lsp-add sw0 p21 -- lsp-set-addresses p21 dynamic | |
4524 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p21 dynamic_addresses], [0], | |
4525 | ["0a:00:00:00:00:18 192.168.1.15" | |
4526 | ]) | |
4527 | ||
4528 | # Test for address reuse after logical port is deleted. | |
4529 | ovn-nbctl lsp-del p0 | |
4530 | ovn-nbctl lsp-add sw0 p23 -- lsp-set-addresses p23 dynamic | |
4531 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p23 dynamic_addresses], [0], | |
4532 | ["0a:00:00:00:00:19 192.168.1.2" | |
4533 | ]) | |
4534 | ||
4535 | # Test for multiple addresses to one logical port. | |
4536 | ovn-nbctl lsp-add sw0 p25 -- lsp-set-addresses p25 \ | |
4537 | "0a:00:00:00:00:1a 192.168.1.12" "0a:00:00:00:00:1b 192.168.1.14" | |
4538 | ovn-nbctl lsp-add sw0 p26 -- lsp-set-addresses p26 dynamic | |
4539 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p26 dynamic_addresses], [0], | |
4540 | ["0a:00:00:00:00:1c 192.168.1.16" | |
4541 | ]) | |
4542 | ||
4543 | # Test for exhausting subnet address space. | |
4544 | ovn-nbctl ls-add sw2 -- add Logical-Switch sw2 other_config subnet=172.16.1.0/30 | |
4545 | ovn-nbctl lsp-add sw2 p27 -- lsp-set-addresses p27 dynamic | |
4546 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p27 dynamic_addresses], [0], | |
4547 | ["0a:00:00:00:00:1d 172.16.1.2" | |
4548 | ]) | |
4549 | ||
4550 | ovn-nbctl lsp-add sw2 p28 -- lsp-set-addresses p28 dynamic | |
4551 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p28 dynamic_addresses], [0], | |
4552 | [[[]] | |
4553 | ]) | |
4554 | ||
4555 | # Test that address management does not add duplicate MAC for lsp/lrp peers. | |
4556 | ovn-nbctl create Logical_Router name=R2 | |
4557 | ovn-nbctl ls-add sw3 | |
4558 | ovn-nbctl lsp-add sw3 p29 -- lsp-set-addresses p29 \ | |
4559 | "0a:00:00:00:00:1e" | |
4560 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw3 \ | |
4561 | network="192.168.2.1/24" mac=\"0a:00:00:00:00:1f\" \ | |
4562 | -- add Logical_Router R2 ports @lrp -- lsp-add sw3 rp-sw3 \ | |
4563 | -- set Logical_Switch_Port rp-sw3 type=router options:router-port=sw3 | |
4564 | ovn-nbctl lsp-add sw0 p30 -- lsp-set-addresses p30 dynamic | |
4565 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p30 dynamic_addresses], [0], | |
4566 | ["0a:00:00:00:00:20 192.168.1.17" | |
4567 | ]) | |
4568 | ||
4569 | as ovn-sb | |
4570 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4571 | ||
4572 | as ovn-nb | |
4573 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4574 | ||
4575 | as northd | |
4576 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
4577 | ||
4578 | AT_CLEANUP | |
4579 | ||
4580 | AT_SETUP([ovn -- ipam connectivity]) | |
4581 | AT_KEYWORDS([ovnipamconnectivity]) | |
4582 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4583 | ovn_start | |
4584 | ||
4585 | ovn-nbctl lr-add R1 | |
4586 | ||
4587 | # Test for a ping using dynamically allocated addresses. | |
4588 | ovn-nbctl ls-add foo -- add Logical_Switch foo other_config subnet=192.168.1.0/24 | |
4589 | ovn-nbctl ls-add alice -- add Logical_Switch alice other_config subnet=192.168.2.0/24 | |
4590 | ||
4591 | # Connect foo to R1 | |
4592 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
4593 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
4594 | options:router-port=foo addresses=\"00:00:00:01:02:03\" | |
4595 | ||
4596 | # Connect alice to R1 | |
4597 | ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 192.168.2.1/24 | |
4598 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice type=router \ | |
4599 | options:router-port=alice addresses=\"00:00:00:01:02:04\" | |
4600 | ||
4601 | # Create logical port foo1 in foo | |
4602 | ovn-nbctl lsp-add foo foo1 \ | |
4603 | -- lsp-set-addresses foo1 "dynamic" | |
4604 | AT_CHECK([ovn-nbctl get Logical-Switch-Port foo1 dynamic_addresses], [0], | |
4605 | ["0a:00:00:00:00:01 192.168.1.2" | |
4606 | ]) | |
4607 | ||
4608 | # Create logical port alice1 in alice | |
4609 | ovn-nbctl lsp-add alice alice1 \ | |
4610 | -- lsp-set-addresses alice1 "dynamic" | |
4611 | AT_CHECK([ovn-nbctl get Logical-Switch-Port alice1 dynamic_addresses], [0], | |
4612 | ["0a:00:00:00:00:02 192.168.2.2" | |
4613 | ]) | |
4614 | ||
4615 | # Create logical port foo2 in foo | |
4616 | ovn-nbctl lsp-add foo foo2 \ | |
4617 | -- lsp-set-addresses foo2 "dynamic" | |
4618 | AT_CHECK([ovn-nbctl get Logical-Switch-Port foo2 dynamic_addresses], [0], | |
4619 | ["0a:00:00:00:00:03 192.168.1.3" | |
4620 | ]) | |
4621 | ||
4622 | # Create a hypervisor and create OVS ports corresponding to logical ports. | |
4623 | net_add n1 | |
4624 | ||
4625 | sim_add hv1 | |
4626 | as hv1 | |
4627 | ovs-vsctl add-br br-phys | |
4628 | ovn_attach n1 br-phys 192.168.0.1 | |
4629 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4630 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
4631 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4632 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4633 | ofport-request=1 | |
4634 | ||
4635 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4636 | set interface hv1-vif2 external-ids:iface-id=foo2 \ | |
4637 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4638 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4639 | ofport-request=2 | |
4640 | ||
4641 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
4642 | set interface hv1-vif3 external-ids:iface-id=alice1 \ | |
4643 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
4644 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
4645 | ofport-request=3 | |
4646 | ||
4647 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4648 | # XXX This should be more systematic. | |
4649 | sleep 1 | |
4650 | ||
4651 | ip_to_hex() { | |
4652 | printf "%02x%02x%02x%02x" "$@" | |
4653 | } | |
8639f9be ND |
4654 | |
4655 | # Send ip packets between foo1 and foo2 | |
4656 | src_mac="0a0000000001" | |
4657 | dst_mac="0a0000000003" | |
4658 | src_ip=`ip_to_hex 192 168 1 2` | |
4659 | dst_ip=`ip_to_hex 192 168 1 3` | |
4660 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4661 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4662 | ||
4663 | # Send ip packets between foo1 and alice1 | |
4664 | src_mac="0a0000000001" | |
4665 | dst_mac="000000010203" | |
4666 | src_ip=`ip_to_hex 192 168 1 2` | |
4667 | dst_ip=`ip_to_hex 192 168 2 2` | |
4668 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4669 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4670 | ||
4671 | echo "---------NB dump-----" | |
4672 | ovn-nbctl show | |
4673 | echo "---------------------" | |
4674 | ovn-nbctl list logical_router | |
4675 | echo "---------------------" | |
4676 | ovn-nbctl list logical_router_port | |
4677 | echo "---------------------" | |
4678 | ||
4679 | echo "---------SB dump-----" | |
4680 | ovn-sbctl list datapath_binding | |
4681 | echo "---------------------" | |
4682 | ovn-sbctl list port_binding | |
4683 | echo "---------------------" | |
4684 | ||
4685 | echo "------ hv1 dump ----------" | |
4686 | as hv1 ovs-ofctl dump-flows br-int | |
4687 | ||
4688 | # Packet to Expect at foo2 | |
4689 | src_mac="0a0000000001" | |
4690 | dst_mac="0a0000000003" | |
4691 | src_ip=`ip_to_hex 192 168 1 2` | |
4692 | dst_ip=`ip_to_hex 192 168 1 3` | |
4693 | expected=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4694 | ||
e4543cfe DDP |
4695 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets |
4696 | echo $expected > expout | |
8639f9be ND |
4697 | AT_CHECK([cat received1.packets], [0], [expout]) |
4698 | ||
4699 | # Packet to Expect at alice1 | |
4700 | src_mac="000000010204" | |
4701 | dst_mac="0a0000000002" | |
4702 | src_ip=`ip_to_hex 192 168 1 2` | |
4703 | dst_ip=`ip_to_hex 192 168 2 2` | |
4704 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
4705 | ||
e4543cfe DDP |
4706 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets |
4707 | echo $expected > expout | |
8639f9be ND |
4708 | AT_CHECK([cat received2.packets], [0], [expout]) |
4709 | ||
4710 | OVN_CLEANUP([hv1]) | |
4711 | ||
4712 | AT_CLEANUP | |
f5792c3f NS |
4713 | |
4714 | AT_SETUP([ovn -- ovs-vswitchd restart]) | |
4715 | AT_KEYWORDS([vswitchd restart]) | |
4716 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4717 | ovn_start | |
4718 | ||
4719 | ovn-nbctl ls-add ls1 | |
4720 | ||
4721 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
4722 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
4723 | ||
4724 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
4725 | ||
4726 | net_add n1 | |
4727 | sim_add hv1 | |
4728 | ||
4729 | as hv1 | |
4730 | ovs-vsctl add-br br-phys | |
4731 | ovn_attach n1 br-phys 192.168.0.1 | |
4732 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4733 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
4734 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4735 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4736 | ofport-request=1 | |
4737 | ||
4738 | ovn_populate_arp | |
4739 | sleep 2 | |
4740 | ||
4741 | as hv1 ovs-vsctl show | |
4742 | ||
4743 | echo "---------------------" | |
4744 | ovn-sbctl dump-flows | |
4745 | echo "---------------------" | |
4746 | ||
4747 | echo "------ hv1 dump ----------" | |
4748 | as hv1 ovs-ofctl dump-flows br-int | |
4749 | total_flows=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
4750 | ||
4751 | echo "Total flows before vswitchd restart = " $total_flows | |
4752 | ||
4753 | # Code taken from ovs-save utility | |
4754 | save_flows () { | |
4755 | echo "ovs-ofctl add-flows br-int - << EOF" > restore_flows.sh | |
4756 | as hv1 ovs-ofctl dump-flows "br-int" | sed -e '/NXST_FLOW/d' \ | |
4757 | -e 's/\(idle\|hard\)_age=[^,]*,//g' >> restore_flows.sh | |
4758 | echo "EOF" >> restore_flows.sh | |
4759 | } | |
4760 | ||
4761 | restart_vswitchd () { | |
4762 | restore_flows=$1 | |
4763 | ||
4764 | if test $restore_flows = true; then | |
4765 | save_flows | |
4766 | fi | |
4767 | ||
4768 | as hv1 | |
4769 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4770 | ||
4771 | if test $restore_flows = true; then | |
4772 | as hv1 | |
4773 | ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="true" | |
4774 | fi | |
4775 | ||
4776 | as hv1 | |
4777 | start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl | |
4778 | ovs-ofctl dump-flows br-int | |
4779 | ||
4780 | if test $restore_flows = true; then | |
4781 | sh ./restore_flows.sh | |
4782 | echo "Flows after restore" | |
4783 | as hv1 | |
4784 | ovs-ofctl dump-flows br-int | |
4785 | ovs-vsctl --no-wait --if-exists remove open_vswitch . other_config \ | |
4786 | flow-restore-wait="true" | |
4787 | fi | |
4788 | } | |
4789 | ||
4790 | # Save the flows, restart vswitchd and restore the flows | |
4791 | restart_vswitchd true | |
4792 | OVS_WAIT_UNTIL([ | |
4793 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
4794 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
4795 | test "${total_flows}" = "${total_flows_after_restart}" | |
4796 | ]) | |
4797 | ||
4798 | # Restart vswitchd without restoring | |
4799 | restart_vswitchd false | |
4800 | OVS_WAIT_UNTIL([ | |
4801 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
4802 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
4803 | test "${total_flows}" = "${total_flows_after_restart}" | |
4804 | ]) | |
4805 | ||
4806 | OVN_CLEANUP([hv1]) | |
4807 | AT_CLEANUP | |
47021598 CSV |
4808 | |
4809 | AT_SETUP([ovn -- send arp for nexthop]) | |
4810 | AT_KEYWORDS([ovn]) | |
4811 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4812 | ovn_start | |
4813 | ||
4814 | # Topology: Two LSs - ls1 and ls2 are connected via router r0 | |
4815 | ||
4816 | # Create logical switches | |
4817 | ovn-nbctl ls-add ls1 | |
4818 | ovn-nbctl ls-add ls2 | |
4819 | ||
4820 | # Create router | |
4821 | ovn-nbctl create Logical_Router name=lr0 | |
4822 | ||
4823 | # Add router ls1p1 port to gateway router | |
4824 | ovn-nbctl lrp-add lr0 lrp-ls1lp1 f0:00:00:00:00:01 192.168.0.1/24 | |
4825 | ovn-nbctl lsp-add ls1 ls1lp1 -- set Logical_Switch_Port ls1lp1 \ | |
4826 | type=router options:router-port=lrp-ls1lp1 \ | |
4827 | addresses='"f0:00:00:00:00:01 192.168.0.1"' | |
4828 | ||
4829 | # Add router ls2p2 port to gateway router | |
4830 | ovn-nbctl lrp-add lr0 lrp-ls2lp1 f0:00:00:00:00:02 192.168.1.1/24 | |
4831 | ovn-nbctl lsp-add ls2 ls2lp1 -- set Logical_Switch_Port ls2lp1 \ | |
4832 | type=router options:router-port=lrp-ls2lp1 \ | |
4833 | addresses='"f0:00:00:00:00:02 192.168.1.1"' | |
4834 | ||
4835 | # Set default gateway (nexthop) to 192.168.1.254 | |
4836 | ovn-nbctl lr-route-add lr0 "0.0.0.0/0" 192.168.1.254 lrp-ls2lp1 | |
4837 | ||
4838 | # Create logical port ls1lp2 in ls1 | |
4839 | ovn-nbctl lsp-add ls1 ls1lp2 \ | |
4840 | -- lsp-set-addresses ls1lp2 "f0:00:00:00:00:03 192.168.0.2" | |
4841 | ||
4842 | # Create logical port ls2lp2 in ls2 | |
4843 | ovn-nbctl lsp-add ls2 ls2lp2 \ | |
4844 | -- lsp-set-addresses ls2lp2 "f0:00:00:00:00:04 192.168.1.10" | |
4845 | ||
4846 | net_add n1 | |
4847 | sim_add hv1 | |
4848 | as hv1 | |
4849 | ovs-vsctl add-br br-phys | |
4850 | ovn_attach n1 br-phys 192.168.0.1 | |
4851 | ovs-vsctl -- add-port br-int hv1-ls1lp2 -- \ | |
4852 | set interface hv1-ls1lp2 external-ids:iface-id=ls1lp2 \ | |
4853 | options:tx_pcap=hv1/ls1lp2-tx.pcap \ | |
4854 | options:rxq_pcap=hv1/ls1lp2-rx.pcap \ | |
4855 | ofport-request=1 | |
4856 | ovs-vsctl -- add-port br-int hv1-ls2lp2 -- \ | |
4857 | set interface hv1-ls2lp2 external-ids:iface-id=ls2lp2 \ | |
4858 | options:tx_pcap=hv1/ls2lp2-tx.pcap \ | |
4859 | options:rxq_pcap=hv1/ls2lp2-rx.pcap \ | |
4860 | ofport-request=2 | |
4861 | ||
4862 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4863 | # XXX This should be more systematic. | |
4864 | sleep 1 | |
4865 | ||
4866 | echo "---------NB dump-----" | |
4867 | ovn-nbctl show | |
4868 | echo "---------------------" | |
4869 | ovn-nbctl list logical_router | |
4870 | echo "---------------------" | |
4871 | ovn-nbctl list logical_router_port | |
4872 | echo "---------------------" | |
4873 | ||
4874 | echo "---------SB dump-----" | |
4875 | ovn-sbctl list datapath_binding | |
4876 | echo "---------------------" | |
4877 | ovn-sbctl list port_binding | |
4878 | echo "---------------------" | |
4879 | ovn-sbctl dump-flows | |
4880 | echo "---------------------" | |
4881 | ovn-sbctl list chassis | |
4882 | ovn-sbctl list encap | |
4883 | echo "---------------------" | |
4884 | ||
4885 | echo "------Flows dump-----" | |
4886 | as hv1 | |
4887 | ovs-ofctl dump-flows | |
4888 | echo "---------------------" | |
4889 | ||
4890 | ip_to_hex() { | |
4891 | printf "%02x%02x%02x%02x" "$@" | |
4892 | } | |
4893 | ||
4894 | src_mac="f00000000003" | |
4895 | dst_mac="f00000000001" | |
4896 | src_ip=`ip_to_hex 192 168 0 2` | |
4897 | dst_ip=`ip_to_hex 8 8 8 8` | |
4898 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4899 | ||
4900 | # Send IP packet destined to 8.8.8.8 from lsp1lp2 | |
4901 | as hv1 ovs-appctl netdev-dummy/receive hv1-ls1lp2 $packet | |
4902 | ||
4903 | trim_zeros() { | |
4904 | sed 's/\(00\)\{1,\}$//' | |
4905 | } | |
4906 | ||
4907 | # ARP packet should be received with Target IP Address set to 192.168.1.254 and | |
4908 | # not 8.8.8.8 | |
4909 | ||
4910 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ls2lp2-tx.pcap | trim_zeros > packets | |
4911 | expected="fffffffffffff0000000000208060001080006040001f00000000002c0a80101000000000000c0a801fe" | |
4912 | echo $expected > expout | |
4913 | AT_CHECK([cat packets], [0], [expout]) | |
4914 | cat packets | |
4915 | ||
4916 | OVN_CLEANUP([hv1]) | |
4917 | ||
4918 | AT_CLEANUP | |
8439c2eb CSV |
4919 | |
4920 | AT_SETUP([ovn -- send gratuitous arp for nat ips in localnet]) | |
4921 | AT_KEYWORDS([ovn]) | |
4922 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4923 | ovn_start | |
4924 | # Create logical switch | |
4925 | ovn-nbctl ls-add ls0 | |
4926 | # Create gateway router | |
4927 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
4928 | # Add router port to gateway router | |
4929 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 | |
4930 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
4931 | type=router options:router-port=lrp0-rp addresses='"f0:00:00:00:00:01"' | |
4932 | # Add nat-address option | |
4933 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="f0:00:00:00:00:01 192.168.0.2" | |
4934 | ||
4935 | net_add n1 | |
4936 | sim_add hv1 | |
4937 | as hv1 | |
4938 | ovs-vsctl \ | |
4939 | -- add-br br-phys \ | |
4940 | -- add-br br-eth0 | |
4941 | ||
4942 | ovn_attach n1 br-phys 192.168.0.1 | |
4943 | ||
4944 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
4945 | AT_CHECK([ovs-vsctl add-port br-eth0 snoopvif -- set Interface snoopvif options:tx_pcap=hv1/snoopvif-tx.pcap options:rxq_pcap=hv1/snoopvif-rx.pcap]) | |
4946 | ||
4947 | # Create a localnet port. | |
4948 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
4949 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
4950 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
4951 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
4952 | ||
4953 | ||
4954 | # Wait for packet to be received. | |
4955 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) | |
4956 | trim_zeros() { | |
4957 | sed 's/\(00\)\{1,\}$//' | |
4958 | } | |
4959 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
4960 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
4961 | echo $expected > expout | |
4962 | AT_CHECK([sort packets], [0], [expout]) | |
4963 | cat packets | |
4964 | ||
4965 | OVN_CLEANUP([hv1]) | |
4966 | ||
4967 | AT_CLEANUP | |
6e31816f CSV |
4968 | |
4969 | AT_SETUP([ovn -- delete mac bindings]) | |
4970 | AT_KEYWORDS([ovn]) | |
4971 | ovn_start | |
4972 | net_add n1 | |
4973 | sim_add hv1 | |
4974 | as hv1 | |
4975 | ovs-vsctl -- add-br br-phys | |
4976 | ovn_attach n1 br-phys 192.168.0.1 | |
4977 | # Create logical switch ls0 | |
4978 | ovn-nbctl ls-add ls0 | |
4979 | # Create ports lp0, lp1 in ls0 | |
4980 | ovn-nbctl lsp-add ls0 lp0 | |
4981 | ovn-nbctl lsp-add ls0 lp1 | |
4982 | ovn-nbctl lsp-set-addresses lp0 "f0:00:00:00:00:01 192.168.0.1" | |
4983 | ovn-nbctl lsp-set-addresses lp1 "f0:00:00:00:00:02 192.168.0.2" | |
4984 | dp_uuid=`ovn-sbctl find datapath | grep uuid | cut -f2 -d ":" | cut -f2 -d " "` | |
4985 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp0 mac="mac1" | |
4986 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp1 mac="mac2" | |
4987 | ovn-sbctl find MAC_Binding | |
4988 | #Delete port lp0 | |
4989 | ovn-nbctl lsp-del lp0 | |
4990 | ovn-sbctl find MAC_Binding | |
4991 | AT_CHECK([ovn-sbctl find MAC_Binding logical_port=lp0], [0], []) | |
4992 | #Delete ls0. This will verify that the mac_bindings are cleaned up when a | |
4993 | #datapath is deleted without explicitly removing the the logical ports | |
4994 | ovn-nbctl ls-del ls0 | |
4995 | ovn-sbctl find MAC_Binding | |
4996 | AT_CHECK([ovn-sbctl find MAC_Binding], [0], []) | |
4997 | ||
4998 | OVN_CLEANUP([hv1]) | |
4999 | ||
5000 | AT_CLEANUP |