]>
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], | |
858c2f76 GS |
165 | [[ct.dnat = ct_state[7] |
166 | ct.est = ct_state[1] | |
2277b860 BP |
167 | ct.inv = ct_state[4] |
168 | ct.new = ct_state[0] | |
169 | ct.rel = ct_state[2] | |
170 | ct.rpl = ct_state[3] | |
858c2f76 | 171 | ct.snat = ct_state[6] |
2277b860 BP |
172 | ct.trk = ct_state[5] |
173 | ct_label = NXM_NX_CT_LABEL | |
b73db61d | 174 | ct_label.blocked = ct_label[0] |
2277b860 BP |
175 | ct_mark = NXM_NX_CT_MARK |
176 | ct_state = NXM_NX_CT_STATE | |
177 | ]]) | |
178 | AT_CLEANUP | |
179 | ||
42d36b58 AZ |
180 | AT_SETUP([ovn -- compsition]) |
181 | AT_CHECK([ovstest test-ovn composition 2], [0], [ignore]) | |
182 | AT_CLEANUP | |
183 | ||
e0840f11 BP |
184 | AT_SETUP([ovn -- expression parser]) |
185 | dnl For lines without =>, input and expected output are identical. | |
186 | dnl For lines with =>, input precedes => and expected output follows =>. | |
187 | AT_DATA([test-cases.txt], [[ | |
188 | eth.type == 0x800 | |
189 | eth.type==0x800 => eth.type == 0x800 | |
190 | eth.type[0..15] == 0x800 => eth.type == 0x800 | |
191 | ||
192 | vlan.present | |
193 | vlan.present == 1 => vlan.present | |
194 | !(vlan.present == 0) => vlan.present | |
195 | !(vlan.present != 1) => vlan.present | |
196 | !vlan.present | |
197 | vlan.present == 0 => !vlan.present | |
198 | vlan.present != 1 => !vlan.present | |
199 | !(vlan.present == 1) => !vlan.present | |
200 | !(vlan.present != 0) => !vlan.present | |
201 | ||
202 | eth.dst[0] | |
203 | eth.dst[0] == 1 => eth.dst[0] | |
204 | eth.dst[0] != 0 => eth.dst[0] | |
205 | !(eth.dst[0] == 0) => eth.dst[0] | |
206 | !(eth.dst[0] != 1) => eth.dst[0] | |
207 | ||
208 | !eth.dst[0] | |
209 | eth.dst[0] == 0 => !eth.dst[0] | |
210 | eth.dst[0] != 1 => !eth.dst[0] | |
211 | !(eth.dst[0] == 1) => !eth.dst[0] | |
212 | !(eth.dst[0] != 0) => !eth.dst[0] | |
213 | ||
214 | vlan.tci[12..15] == 0x3 | |
215 | vlan.tci == 0x3000/0xf000 => vlan.tci[12..15] == 0x3 | |
216 | vlan.tci[12..15] != 0x3 | |
217 | vlan.tci != 0x3000/0xf000 => vlan.tci[12..15] != 0x3 | |
218 | ||
219 | !vlan.pcp => vlan.pcp == 0 | |
220 | !(vlan.pcp) => vlan.pcp == 0 | |
221 | vlan.pcp == 0x4 | |
222 | vlan.pcp != 0x4 | |
223 | vlan.pcp > 0x4 | |
224 | vlan.pcp >= 0x4 | |
225 | vlan.pcp < 0x4 | |
226 | vlan.pcp <= 0x4 | |
227 | !(vlan.pcp != 0x4) => vlan.pcp == 0x4 | |
228 | !(vlan.pcp == 0x4) => vlan.pcp != 0x4 | |
229 | !(vlan.pcp <= 0x4) => vlan.pcp > 0x4 | |
230 | !(vlan.pcp < 0x4) => vlan.pcp >= 0x4 | |
231 | !(vlan.pcp >= 0x4) => vlan.pcp < 0x4 | |
232 | !(vlan.pcp > 0x4) => 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 | 0x4 >= vlan.pcp => vlan.pcp <= 0x4 | |
239 | !(0x4 != vlan.pcp) => vlan.pcp == 0x4 | |
240 | !(0x4 == vlan.pcp) => vlan.pcp != 0x4 | |
241 | !(0x4 >= vlan.pcp) => vlan.pcp > 0x4 | |
242 | !(0x4 > vlan.pcp) => vlan.pcp >= 0x4 | |
243 | !(0x4 <= vlan.pcp) => vlan.pcp < 0x4 | |
244 | !(0x4 < vlan.pcp) => vlan.pcp <= 0x4 | |
245 | ||
246 | 1 < vlan.pcp < 4 => vlan.pcp > 0x1 && vlan.pcp < 0x4 | |
247 | 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4 | |
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 | 4 > vlan.pcp > 1 => vlan.pcp < 0x4 && vlan.pcp > 0x1 | |
252 | 4 >= vlan.pcp > 1 => vlan.pcp <= 0x4 && vlan.pcp > 0x1 | |
253 | 4 > vlan.pcp >= 1 => vlan.pcp < 0x4 && vlan.pcp >= 0x1 | |
254 | 4 >= vlan.pcp >= 1 => vlan.pcp <= 0x4 && vlan.pcp >= 0x1 | |
255 | !(1 < vlan.pcp < 4) => vlan.pcp <= 0x1 || vlan.pcp >= 0x4 | |
256 | !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4 | |
257 | !(1 < vlan.pcp <= 4) => vlan.pcp <= 0x1 || vlan.pcp > 0x4 | |
258 | !(1 <= vlan.pcp < 4) => vlan.pcp < 0x1 || vlan.pcp >= 0x4 | |
259 | !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4 | |
260 | !(4 > vlan.pcp > 1) => vlan.pcp >= 0x4 || vlan.pcp <= 0x1 | |
261 | !(4 >= vlan.pcp > 1) => vlan.pcp > 0x4 || vlan.pcp <= 0x1 | |
262 | !(4 > vlan.pcp >= 1) => vlan.pcp >= 0x4 || vlan.pcp < 0x1 | |
263 | !(4 >= vlan.pcp >= 1) => vlan.pcp > 0x4 || vlan.pcp < 0x1 | |
264 | ||
265 | vlan.pcp == {1, 2, 3, 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 | vlan.pcp != {1, 2, 3, 4} => vlan.pcp != 0x1 && vlan.pcp != 0x2 && vlan.pcp != 0x3 && vlan.pcp != 0x4 | |
269 | vlan.pcp == 1 && ((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && vlan.pcp == 0x2 && vlan.pcp == 0x3 && vlan.pcp == 0x4 | |
270 | ||
271 | vlan.pcp == 1 && !((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3 || vlan.pcp != 0x4) | |
272 | vlan.pcp == 1 && (!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3) && vlan.pcp == 0x4 | |
273 | vlan.pcp == 1 && !(!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && ((vlan.pcp == 0x2 && vlan.pcp == 0x3) || vlan.pcp != 0x4) | |
274 | ||
275 | 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 | |
276 | ip6.src == ::1 => ip6.src == 0x1 | |
277 | ||
278 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 | |
279 | ip4.src == ::1.2.3.4/::ffff:ffff => ip4.src == 0x1020304 | |
280 | ip6.src == ::1 => ip6.src == 0x1 | |
281 | ||
282 | 1 | |
283 | 0 | |
284 | !1 => 0 | |
285 | !0 => 1 | |
286 | ||
287 | inport == "eth0" | |
288 | !(inport != "eth0") => inport == "eth0" | |
289 | ||
3b7cb7e1 BP |
290 | ip4.src == "eth0" => Integer field ip4.src is not compatible with string constant. |
291 | inport == 1 => String field inport is not compatible with integer constant. | |
76da94b5 | 292 | ip4.src = 1.2.3.4 => Syntax error at `=' expecting relational operator. |
e0840f11 BP |
293 | |
294 | ip4.src > {1, 2, 3} => Only == and != operators may be used with value sets. | |
295 | eth.type > 0x800 => Only == and != operators may be used with nominal field eth.type. | |
296 | vlan.present > 0 => Only == and != operators may be used with Boolean field vlan.present. | |
297 | ||
298 | inport != "eth0" => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account). | |
299 | !(inport == "eth0") => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account). | |
300 | eth.type != 0x800 => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account). | |
301 | !(eth.type == 0x800) => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account). | |
76da94b5 | 302 | inport = "eth0" => Syntax error at `=' expecting relational operator. |
e0840f11 BP |
303 | |
304 | 123 == 123 => Syntax error at `123' expecting field name. | |
305 | ||
2c5cbb15 RB |
306 | $name => Syntax error at `$name' expecting address set name. |
307 | ||
e0840f11 BP |
308 | 123 == xyzzy => Syntax error at `xyzzy' expecting field name. |
309 | xyzzy == 1 => Syntax error at `xyzzy' expecting field name. | |
310 | ||
311 | inport[1] == 1 => Cannot select subfield of string field inport. | |
312 | ||
313 | eth.type[] == 1 => Syntax error at `@:>@' expecting small integer. | |
314 | eth.type[::1] == 1 => Syntax error at `::1' expecting small integer. | |
315 | eth.type[18446744073709551615] == 1 => Syntax error at `18446744073709551615' expecting small integer. | |
316 | ||
317 | eth.type[5!] => Syntax error at `!' expecting `@:>@'. | |
318 | ||
319 | eth.type[5..1] => Invalid bit range 5 to 1. | |
320 | ||
321 | eth.type[12..16] => Cannot select bits 12 to 16 of 16-bit field eth.type. | |
322 | ||
323 | eth.type[10] == 1 => Cannot select subfield of nominal field eth.type. | |
324 | ||
325 | eth.type => Explicit `!= 0' is required for inequality test of multibit field against 0. | |
326 | ||
327 | !(!(vlan.pcp)) => Explicit `!= 0' is required for inequality test of multibit field against 0. | |
328 | ||
329 | 123 => Syntax error at end of input expecting relational operator. | |
330 | ||
331 | 123 x => Syntax error at `x' expecting relational operator. | |
332 | ||
333 | {1, "eth0"} => Syntax error at `"eth0"' expecting integer. | |
334 | ||
335 | eth.type == xyzzy => Syntax error at `xyzzy' expecting constant. | |
336 | ||
337 | (1 x) => Syntax error at `x' expecting `)'. | |
338 | ||
339 | !0x800 != eth.type => Missing parentheses around operand of !. | |
340 | ||
341 | eth.type == 0x800 || eth.type == 0x86dd && ip.proto == 17 => && and || must be parenthesized when used together. | |
342 | ||
343 | eth.dst == {} => Syntax error at `}' expecting constant. | |
344 | ||
345 | 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). | |
346 | ||
3b7cb7e1 | 347 | ip4.src == ::1 => 128-bit constant is not compatible with 32-bit field ip4.src. |
e0840f11 BP |
348 | |
349 | 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 | 350 | |
9aef3c1b | 351 | eth.dst[40] x => Syntax error at `x' expecting end of input. |
ea382567 RB |
352 | |
353 | ip4.src == {1.2.3.4, $set1, $unknownset} => Syntax error at `$unknownset' expecting address set name. | |
354 | eth.src == {$set3, badmac, 00:00:00:00:00:01} => Syntax error at `badmac' expecting constant. | |
e0840f11 BP |
355 | ]]) |
356 | sed 's/ =>.*//' test-cases.txt > input.txt | |
357 | sed 's/.* => //' test-cases.txt > expout | |
358 | AT_CHECK([ovstest test-ovn parse-expr < input.txt], [0], [expout]) | |
359 | AT_CLEANUP | |
360 | ||
361 | AT_SETUP([ovn -- expression annotation]) | |
362 | dnl Input precedes =>, expected output follows =>. | |
363 | AT_DATA([test-cases.txt], [[ | |
364 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 && eth.type == 0x800 | |
365 | ip4.src != 1.2.3.4 => ip4.src != 0x1020304 && eth.type == 0x800 | |
366 | ip.proto == 123 => ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd) | |
367 | ip.proto == {123, 234} => (ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)) || (ip.proto == 0xea && (eth.type == 0x800 || eth.type == 0x86dd)) | |
368 | ip4.src == 1.2.3.4 && ip4.dst == 5.6.7.8 => ip4.src == 0x1020304 && eth.type == 0x800 && ip4.dst == 0x5060708 && eth.type == 0x800 | |
369 | ||
370 | ip => eth.type == 0x800 || eth.type == 0x86dd | |
371 | ip == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
372 | ip[0] == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
373 | ip > 0 => Only == and != operators may be used with nominal field ip. | |
374 | !ip => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
375 | ip == 0 => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
376 | ||
377 | vlan.present => vlan.tci[12] | |
378 | !vlan.present => !vlan.tci[12] | |
379 | ||
380 | !vlan.pcp => vlan.tci[13..15] == 0 && vlan.tci[12] | |
381 | vlan.pcp == 1 && vlan.vid == 2 => vlan.tci[13..15] == 0x1 && vlan.tci[12] && vlan.tci[0..11] == 0x2 && vlan.tci[12] | |
7700eea0 | 382 | !reg0 && !reg1 && !reg2 && !reg3 => xxreg0[96..127] == 0 && xxreg0[64..95] == 0 && xxreg0[32..63] == 0 && xxreg0[0..31] == 0 |
e0840f11 BP |
383 | |
384 | ip.first_frag => ip.frag[0] && (eth.type == 0x800 || eth.type == 0x86dd) && (!ip.frag[1] || (eth.type != 0x800 && eth.type != 0x86dd)) | |
385 | !ip.first_frag => !ip.frag[0] || (eth.type != 0x800 && eth.type != 0x86dd) || (ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd)) | |
386 | ip.later_frag => ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd) | |
387 | ||
388 | bad_prereq != 0 => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
389 | self_recurse != 0 => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'. | |
390 | 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'. | |
391 | 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'. | |
392 | ]]) | |
393 | sed 's/ =>.*//' test-cases.txt > input.txt | |
394 | sed 's/.* => //' test-cases.txt > expout | |
395 | AT_CHECK([ovstest test-ovn annotate-expr < input.txt], [0], [expout]) | |
396 | AT_CLEANUP | |
397 | ||
9d4aecca | 398 | AT_SETUP([ovn -- 1-term expression conversion]) |
e0840f11 | 399 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert 1], [0], |
9d4aecca | 400 | [Tested converting all 1-terminal expressions with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
401 | ]) |
402 | AT_CLEANUP | |
403 | ||
9d4aecca | 404 | AT_SETUP([ovn -- 2-term expression conversion]) |
e0840f11 | 405 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert 2], [0], |
8c3caa2c | 406 | [Tested converting 578 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
407 | ]) |
408 | AT_CLEANUP | |
409 | ||
9d4aecca | 410 | AT_SETUP([ovn -- 3-term expression conversion]) |
e0840f11 | 411 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert --bits=2 3], [0], |
8c3caa2c | 412 | [Tested converting 67410 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
413 | ]) |
414 | AT_CLEANUP | |
415 | ||
9d4aecca BP |
416 | AT_SETUP([ovn -- 3-term numeric expression simplification]) |
417 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=2 --svars=0 3], [0], | |
8c3caa2c | 418 | [Tested simplifying 490770 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=. |
e0840f11 BP |
419 | ]) |
420 | AT_CLEANUP | |
421 | ||
9d4aecca BP |
422 | AT_SETUP([ovn -- 4-term string expression simplification]) |
423 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=0 --svars=4 4], [0], | |
424 | [Tested simplifying 21978 expressions of 4 terminals with 4 string vars. | |
e0840f11 BP |
425 | ]) |
426 | AT_CLEANUP | |
427 | ||
9d4aecca BP |
428 | AT_SETUP([ovn -- 3-term mixed expression simplification]) |
429 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=1 --svars=1 3], [0], | |
8c3caa2c | 430 | [Tested simplifying 127890 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars. |
e0840f11 BP |
431 | ]) |
432 | AT_CLEANUP | |
433 | ||
97ba1d55 BP |
434 | AT_SETUP([ovn -- simplification special cases]) |
435 | simplify() { | |
436 | echo "$1" | ovstest test-ovn simplify-expr | |
437 | } | |
438 | AT_CHECK([simplify 'eth.dst == 0/0'], [0], [1 | |
439 | ]) | |
a3d79068 BP |
440 | AT_CHECK([simplify 'eth.dst != 0/0'], [0], [0 |
441 | ]) | |
33f15d17 BP |
442 | AT_CHECK([simplify 'tcp.dst >= 0'], [0], |
443 | [ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
444 | ]) | |
445 | AT_CHECK([simplify 'tcp.dst <= 65535'], [0], | |
446 | [ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
447 | ]) | |
448 | AT_CHECK([simplify 'tcp.dst > 0'], [0], | |
449 | [[(tcp.dst[0] || tcp.dst[1] || tcp.dst[2] || tcp.dst[3] || tcp.dst[4] || tcp.dst[5] || tcp.dst[6] || tcp.dst[7] || tcp.dst[8] || tcp.dst[9] || tcp.dst[10] || tcp.dst[11] || tcp.dst[12] || tcp.dst[13] || tcp.dst[14] || tcp.dst[15]) && ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
450 | ]]) | |
451 | AT_CHECK([simplify 'tcp.dst < 65535'], [0], | |
452 | [[(!tcp.dst[0] || !tcp.dst[1] || !tcp.dst[2] || !tcp.dst[3] || !tcp.dst[4] || !tcp.dst[5] || !tcp.dst[6] || !tcp.dst[7] || !tcp.dst[8] || !tcp.dst[9] || !tcp.dst[10] || !tcp.dst[11] || !tcp.dst[12] || !tcp.dst[13] || !tcp.dst[14] || !tcp.dst[15]) && ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
453 | ]]) | |
97ba1d55 BP |
454 | AT_CLEANUP |
455 | ||
ba8d3816 MS |
456 | AT_SETUP([ovn -- is_chassis_resident simplification]) |
457 | simplify() { | |
458 | echo "$1" | ovstest test-ovn simplify-expr | |
459 | } | |
460 | AT_CHECK([simplify 'is_chassis_resident("eth1")'], [0], [1 | |
461 | ]) | |
462 | AT_CHECK([simplify 'is_chassis_resident("eth2")'], [0], [0 | |
463 | ]) | |
464 | AT_CHECK([simplify '!is_chassis_resident("eth1")'], [0], [0 | |
465 | ]) | |
466 | AT_CHECK([simplify '!is_chassis_resident("eth2")'], [0], [1 | |
467 | ]) | |
468 | AT_CLEANUP | |
469 | ||
9d4aecca BP |
470 | AT_SETUP([ovn -- 4-term numeric expression normalization]) |
471 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 4], [0], | |
8c3caa2c | 472 | [Tested normalizing 1874026 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=. |
e0840f11 BP |
473 | ]) |
474 | AT_CLEANUP | |
475 | ||
9d4aecca BP |
476 | AT_SETUP([ovn -- 4-term string expression normalization]) |
477 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 4], [0], | |
478 | [Tested normalizing 11242 expressions of 4 terminals with 3 string vars. | |
479 | ]) | |
480 | AT_CLEANUP | |
481 | ||
482 | AT_SETUP([ovn -- 4-term mixed expression normalization]) | |
483 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --bits=1 --svars=2 4], [0], | |
8c3caa2c | 484 | [Tested normalizing 175978 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars. |
9d4aecca BP |
485 | ]) |
486 | AT_CLEANUP | |
487 | ||
488 | AT_SETUP([ovn -- 5-term numeric expression normalization]) | |
489 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 --relops='==' 5], [0], | |
8c3caa2c | 490 | [Tested normalizing 1317600 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==. |
9d4aecca BP |
491 | ]) |
492 | AT_CLEANUP | |
493 | ||
494 | AT_SETUP([ovn -- 5-term string expression normalization]) | |
495 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 --relops='==' 5], [0], | |
496 | [Tested normalizing 368550 expressions of 5 terminals with 3 string vars. | |
497 | ]) | |
498 | AT_CLEANUP | |
499 | ||
500 | AT_SETUP([ovn -- 5-term mixed expression normalization]) | |
501 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --svars=1 --bits=1 --relops='==' 5], [0], | |
8c3caa2c | 502 | [Tested normalizing 216000 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars. |
9d4aecca BP |
503 | ]) |
504 | AT_CLEANUP | |
505 | ||
506 | AT_SETUP([ovn -- 4-term numeric expressions to flows]) | |
8c3caa2c | 507 | AT_KEYWORDS([expression]) |
9d4aecca | 508 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=2 --svars=0 --bits=2 --relops='==' 4], [0], |
8c3caa2c | 509 | [Tested converting to flows 175978 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==. |
9d4aecca BP |
510 | ]) |
511 | AT_CLEANUP | |
512 | ||
513 | AT_SETUP([ovn -- 4-term string expressions to flows]) | |
8c3caa2c | 514 | AT_KEYWORDS([expression]) |
9d4aecca BP |
515 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=0 --svars=4 4], [0], |
516 | [Tested converting to flows 21978 expressions of 4 terminals with 4 string vars. | |
517 | ]) | |
518 | AT_CLEANUP | |
519 | ||
520 | AT_SETUP([ovn -- 4-term mixed expressions to flows]) | |
8c3caa2c | 521 | AT_KEYWORDS([expression]) |
9d4aecca | 522 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=1 --bits=2 --svars=1 --relops='==' 4], [0], |
8c3caa2c | 523 | [Tested converting to flows 48312 expressions of 4 terminals with 1 numeric vars (each 2 bits) in terms of operators == and 1 string vars. |
9d4aecca BP |
524 | ]) |
525 | AT_CLEANUP | |
526 | ||
527 | AT_SETUP([ovn -- 3-term numeric expressions to flows]) | |
8c3caa2c | 528 | AT_KEYWORDS([expression]) |
9d4aecca | 529 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=3 --svars=0 --bits=3 --relops='==' 3], [0], |
8c3caa2c | 530 | [Tested converting to flows 41328 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==. |
e0840f11 BP |
531 | ]) |
532 | AT_CLEANUP | |
f386a8a7 BP |
533 | |
534 | AT_SETUP([ovn -- converting expressions to flows -- string fields]) | |
8c3caa2c | 535 | AT_KEYWORDS([expression]) |
f386a8a7 BP |
536 | expr_to_flow () { |
537 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
538 | } | |
cc5e28d8 | 539 | AT_CHECK([expr_to_flow 'inport == "eth0"'], [0], [reg14=0x5 |
f386a8a7 | 540 | ]) |
cc5e28d8 | 541 | AT_CHECK([expr_to_flow 'inport == "eth1"'], [0], [reg14=0x6 |
f386a8a7 BP |
542 | ]) |
543 | AT_CHECK([expr_to_flow 'inport == "eth2"'], [0], [(no flows) | |
544 | ]) | |
545 | AT_CHECK([expr_to_flow 'inport == "eth0" && ip'], [0], [dnl | |
cc5e28d8 JP |
546 | ip,reg14=0x5 |
547 | ipv6,reg14=0x5 | |
f386a8a7 BP |
548 | ]) |
549 | AT_CHECK([expr_to_flow 'inport == "eth1" && ip'], [0], [dnl | |
cc5e28d8 JP |
550 | ip,reg14=0x6 |
551 | ipv6,reg14=0x6 | |
f386a8a7 BP |
552 | ]) |
553 | AT_CHECK([expr_to_flow 'inport == "eth2" && ip'], [0], [(no flows) | |
554 | ]) | |
555 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2", "LOCAL"}'], [0], | |
cc5e28d8 JP |
556 | [reg14=0x5 |
557 | reg14=0x6 | |
558 | reg14=0xfffe | |
f386a8a7 BP |
559 | ]) |
560 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2"} && ip'], [0], [dnl | |
cc5e28d8 JP |
561 | ip,reg14=0x5 |
562 | ip,reg14=0x6 | |
563 | ipv6,reg14=0x5 | |
564 | ipv6,reg14=0x6 | |
f386a8a7 | 565 | ]) |
9d4aecca BP |
566 | AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl |
567 | (no flows) | |
568 | ]) | |
f386a8a7 | 569 | AT_CLEANUP |
3b7cb7e1 | 570 | |
2c5cbb15 | 571 | AT_SETUP([ovn -- converting expressions to flows -- address sets]) |
8c3caa2c | 572 | AT_KEYWORDS([expression]) |
2c5cbb15 RB |
573 | expr_to_flow () { |
574 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
575 | } | |
576 | AT_CHECK([expr_to_flow 'ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3}'], [0], [dnl | |
577 | ip,nw_src=10.0.0.1 | |
578 | ip,nw_src=10.0.0.2 | |
579 | ip,nw_src=10.0.0.3 | |
580 | ]) | |
581 | AT_CHECK([expr_to_flow 'ip4.src == $set1'], [0], [dnl | |
582 | ip,nw_src=10.0.0.1 | |
583 | ip,nw_src=10.0.0.2 | |
584 | ip,nw_src=10.0.0.3 | |
585 | ]) | |
586 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set1}'], [0], [dnl | |
587 | ip,nw_src=1.2.3.4 | |
588 | ip,nw_src=10.0.0.1 | |
589 | ip,nw_src=10.0.0.2 | |
590 | ip,nw_src=10.0.0.3 | |
591 | ]) | |
592 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.0.0/20, 5.5.5.0/24, $set1}'], [0], [dnl | |
593 | ip,nw_src=1.2.0.0/20 | |
594 | ip,nw_src=10.0.0.1 | |
595 | ip,nw_src=10.0.0.2 | |
596 | ip,nw_src=10.0.0.3 | |
597 | ip,nw_src=5.5.5.0/24 | |
598 | ]) | |
599 | AT_CHECK([expr_to_flow 'ip6.src == {::1, ::2, ::3}'], [0], [dnl | |
600 | ipv6,ipv6_src=::1 | |
601 | ipv6,ipv6_src=::2 | |
602 | ipv6,ipv6_src=::3 | |
603 | ]) | |
604 | AT_CHECK([expr_to_flow 'ip6.src == {::1, $set2, ::4}'], [0], [dnl | |
605 | ipv6,ipv6_src=::1 | |
606 | ipv6,ipv6_src=::2 | |
607 | ipv6,ipv6_src=::3 | |
608 | ipv6,ipv6_src=::4 | |
609 | ]) | |
610 | 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 | |
611 | dl_src=00:00:00:00:00:01 | |
612 | dl_src=00:00:00:00:00:02 | |
613 | dl_src=00:00:00:00:00:03 | |
614 | ]) | |
615 | AT_CHECK([expr_to_flow 'eth.src == {$set3}'], [0], [dnl | |
616 | dl_src=00:00:00:00:00:01 | |
617 | dl_src=00:00:00:00:00:02 | |
618 | dl_src=00:00:00:00:00:03 | |
619 | ]) | |
ea382567 RB |
620 | AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, $set3, ba:be:be:ef:de:ad, $set3}'], [0], [dnl |
621 | dl_src=00:00:00:00:00:01 | |
622 | dl_src=00:00:00:00:00:02 | |
623 | dl_src=00:00:00:00:00:03 | |
624 | dl_src=ba:be:be:ef:de:ad | |
625 | ]) | |
2c5cbb15 RB |
626 | AT_CLEANUP |
627 | ||
3b7cb7e1 | 628 | AT_SETUP([ovn -- action parsing]) |
d5a76da4 BP |
629 | dnl Unindented text is input (a set of OVN logical actions). |
630 | dnl Indented text is expected output. | |
631 | AT_DATA([test-cases.txt], | |
632 | [[# drop | |
633 | drop; | |
634 | encodes as drop | |
635 | drop; next; | |
636 | Syntax error at `next' expecting end of input. | |
637 | next; drop; | |
638 | Syntax error at `drop' expecting action. | |
5f822129 BP |
639 | |
640 | # output | |
d5a76da4 BP |
641 | output; |
642 | encodes as resubmit(,64) | |
5f822129 BP |
643 | |
644 | # next | |
d5a76da4 BP |
645 | next; |
646 | formats as next(11); | |
647 | encodes as resubmit(,27) | |
648 | next(11); | |
649 | encodes as resubmit(,27) | |
650 | next(0); | |
651 | encodes as resubmit(,16) | |
652 | next(15); | |
653 | encodes as resubmit(,31) | |
654 | ||
655 | next(); | |
656 | Syntax error at `)' expecting small integer. | |
657 | next(10; | |
658 | Syntax error at `;' expecting `)'. | |
659 | next(16); | |
660 | "next" argument must be in range 0 to 15. | |
5f822129 BP |
661 | |
662 | # Loading a constant value. | |
d5a76da4 BP |
663 | tcp.dst=80; |
664 | formats as tcp.dst = 80; | |
665 | encodes as set_field:80->tcp_dst | |
666 | has prereqs ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
667 | eth.dst[40] = 1; | |
668 | encodes as set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dst | |
669 | vlan.pcp = 2; | |
670 | encodes as set_field:0x4000/0xe000->vlan_tci | |
671 | has prereqs vlan.tci[12] | |
672 | vlan.tci[13..15] = 2; | |
673 | encodes as set_field:0x4000/0xe000->vlan_tci | |
674 | inport = ""; | |
675 | encodes as set_field:0->reg14 | |
676 | ip.ttl=4; | |
677 | formats as ip.ttl = 4; | |
678 | encodes as set_field:4->nw_ttl | |
679 | has prereqs eth.type == 0x800 || eth.type == 0x86dd | |
680 | outport="eth0"; next; outport="LOCAL"; next; | |
681 | formats as outport = "eth0"; next(11); outport = "LOCAL"; next(11); | |
682 | encodes as set_field:0x5->reg15,resubmit(,27),set_field:0xfffe->reg15,resubmit(,27) | |
683 | ||
684 | inport[1] = 1; | |
685 | Cannot select subfield of string field inport. | |
686 | ip.proto[1] = 1; | |
687 | Cannot select subfield of nominal field ip.proto. | |
688 | eth.dst[40] == 1; | |
689 | Syntax error at `==' expecting `=' or `<->'. | |
690 | ip = 1; | |
691 | Predicate symbol ip used where lvalue required. | |
692 | ip.proto = 6; | |
693 | Field ip.proto is not modifiable. | |
694 | inport = {"a", "b"}; | |
695 | Syntax error at `{' expecting constant. | |
696 | inport = {}; | |
697 | Syntax error at `{' expecting constant. | |
698 | bad_prereq = 123; | |
699 | Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
700 | self_recurse = 123; | |
701 | 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'. | |
702 | vlan.present = 0; | |
703 | Predicate symbol vlan.present used where lvalue required. | |
5f822129 BP |
704 | |
705 | # Moving one field into another. | |
d5a76da4 BP |
706 | reg0=reg1; |
707 | formats as reg0 = reg1; | |
708 | encodes as move:NXM_NX_XXREG0[64..95]->NXM_NX_XXREG0[96..127] | |
709 | vlan.pcp = reg0[0..2]; | |
710 | encodes as move:NXM_NX_XXREG0[96..98]->NXM_OF_VLAN_TCI[13..15] | |
711 | has prereqs vlan.tci[12] | |
712 | reg0[10] = vlan.pcp[1]; | |
713 | encodes as move:NXM_OF_VLAN_TCI[14]->NXM_NX_XXREG0[106] | |
714 | has prereqs vlan.tci[12] | |
715 | outport = inport; | |
716 | encodes as move:NXM_NX_REG14[]->NXM_NX_REG15[] | |
717 | ||
718 | reg0[0] = vlan.present; | |
719 | Predicate symbol vlan.present used where lvalue required. | |
720 | reg0 = reg1[0..10]; | |
721 | Can't assign 11-bit value to 32-bit destination. | |
722 | inport = reg0; | |
723 | Can't assign integer field (reg0) to string field (inport). | |
724 | inport = big_string; | |
725 | String fields inport and big_string are incompatible for assignment. | |
726 | ip.proto = reg0[0..7]; | |
727 | Field ip.proto is not modifiable. | |
5f822129 BP |
728 | |
729 | # Exchanging fields. | |
d5a76da4 BP |
730 | reg0 <-> reg1; |
731 | 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] | |
732 | vlan.pcp <-> reg0[0..2]; | |
733 | 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] | |
734 | has prereqs vlan.tci[12] | |
735 | reg0[10] <-> vlan.pcp[1]; | |
736 | encodes as push:NXM_OF_VLAN_TCI[14],push:NXM_NX_XXREG0[106],pop:NXM_OF_VLAN_TCI[14],pop:NXM_NX_XXREG0[106] | |
737 | has prereqs vlan.tci[12] | |
738 | outport <-> inport; | |
739 | encodes as push:NXM_NX_REG14[],push:NXM_NX_REG15[],pop:NXM_NX_REG14[],pop:NXM_NX_REG15[] | |
740 | ||
741 | reg0[0] <-> vlan.present; | |
742 | Predicate symbol vlan.present used where lvalue required. | |
743 | reg0 <-> reg1[0..10]; | |
744 | Can't exchange 32-bit field with 11-bit field. | |
745 | inport <-> reg0; | |
746 | Can't exchange string field (inport) with integer field (reg0). | |
747 | inport <-> big_string; | |
748 | String fields inport and big_string are incompatible for exchange. | |
749 | ip.proto <-> reg0[0..7]; | |
750 | Field ip.proto is not modifiable. | |
751 | reg0[0..7] <-> ip.proto; | |
752 | Field ip.proto is not modifiable. | |
5f822129 BP |
753 | |
754 | # TTL decrement. | |
d5a76da4 BP |
755 | ip.ttl--; |
756 | encodes as dec_ttl | |
757 | has prereqs ip | |
758 | ip.ttl | |
759 | Syntax error at end of input expecting `--'. | |
5f822129 | 760 | |
467085fd | 761 | # load balancing. |
d5a76da4 BP |
762 | ct_lb; |
763 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15],nat) | |
764 | has prereqs ip | |
765 | ct_lb(); | |
766 | formats as ct_lb; | |
767 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15],nat) | |
768 | has prereqs ip | |
769 | ct_lb(192.168.1.2:80, 192.168.1.3:80); | |
770 | encodes as group:1 | |
771 | has prereqs ip | |
772 | ct_lb(192.168.1.2, 192.168.1.3, ); | |
773 | formats as ct_lb(192.168.1.2, 192.168.1.3); | |
774 | encodes as group:2 | |
775 | has prereqs ip | |
776 | ||
777 | ct_lb(192.168.1.2:); | |
778 | Syntax error at `)' expecting port number. | |
779 | ct_lb(192.168.1.2:123456); | |
780 | Syntax error at `123456' expecting port number. | |
781 | ct_lb(foo); | |
782 | Syntax error at `foo' expecting IPv4 address. | |
783 | ||
784 | # ct_next | |
785 | ct_next; | |
786 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15]) | |
787 | has prereqs ip | |
788 | ||
789 | # ct_commit | |
790 | ct_commit; | |
791 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
792 | has prereqs ip | |
793 | ct_commit(); | |
794 | formats as ct_commit; | |
795 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
796 | has prereqs ip | |
797 | ct_commit(ct_mark=1); | |
798 | formats as ct_commit(ct_mark=0x1); | |
799 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark)) | |
800 | has prereqs ip | |
801 | ct_commit(ct_mark=1/1); | |
802 | formats as ct_commit(ct_mark=0x1/0x1); | |
803 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_mark)) | |
804 | has prereqs ip | |
805 | ct_commit(ct_label=1); | |
806 | formats as ct_commit(ct_label=0x1); | |
807 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_label)) | |
808 | has prereqs ip | |
809 | ct_commit(ct_label=1/1); | |
810 | formats as ct_commit(ct_label=0x1/0x1); | |
811 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_label)) | |
812 | has prereqs ip | |
813 | ct_commit(ct_mark=1, ct_label=2); | |
814 | formats as ct_commit(ct_mark=0x1, ct_label=0x2); | |
815 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark,set_field:0x2->ct_label)) | |
816 | has prereqs ip | |
817 | ||
818 | ct_commit(ct_label=0x01020304050607080910111213141516); | |
819 | formats as ct_commit(ct_label=0x1020304050607080910111213141516); | |
820 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1020304050607080910111213141516->ct_label)) | |
821 | has prereqs ip | |
822 | ct_commit(ct_label=0x181716151413121110090807060504030201); | |
823 | formats as ct_commit(ct_label=0x16151413121110090807060504030201); | |
824 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x16151413121110090807060504030201->ct_label)) | |
825 | has prereqs ip | |
826 | ct_commit(ct_label=0x1000000000000000000000000000000/0x1000000000000000000000000000000); | |
827 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1000000000000000000000000000000/0x1000000000000000000000000000000->ct_label)) | |
828 | has prereqs ip | |
829 | ct_commit(ct_label=18446744073709551615); | |
830 | formats as ct_commit(ct_label=0xffffffffffffffff); | |
831 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0xffffffffffffffff->ct_label)) | |
832 | has prereqs ip | |
833 | ct_commit(ct_label=18446744073709551616); | |
834 | Decimal constants must be less than 2**64. | |
835 | ||
836 | # ct_dnat | |
837 | ct_dnat; | |
838 | encodes as ct(table=27,zone=NXM_NX_REG11[0..15],nat) | |
839 | has prereqs ip | |
840 | ct_dnat(192.168.1.2); | |
841 | encodes as ct(commit,table=27,zone=NXM_NX_REG11[0..15],nat(dst=192.168.1.2)) | |
842 | has prereqs ip | |
843 | ||
844 | ct_dnat(192.168.1.2, 192.168.1.3); | |
845 | Syntax error at `,' expecting `)'. | |
846 | ct_dnat(foo); | |
847 | Syntax error at `foo' expecting IPv4 address. | |
848 | ct_dnat(foo, bar); | |
849 | Syntax error at `foo' expecting IPv4 address. | |
850 | ct_dnat(); | |
851 | Syntax error at `)' expecting IPv4 address. | |
852 | ||
853 | # ct_snat | |
854 | ct_snat; | |
855 | encodes as ct(zone=NXM_NX_REG12[0..15],nat) | |
856 | has prereqs ip | |
857 | ct_snat(192.168.1.2); | |
858 | encodes as ct(commit,table=27,zone=NXM_NX_REG12[0..15],nat(src=192.168.1.2)) | |
859 | has prereqs ip | |
860 | ||
861 | ct_snat(192.168.1.2, 192.168.1.3); | |
862 | Syntax error at `,' expecting `)'. | |
863 | ct_snat(foo); | |
864 | Syntax error at `foo' expecting IPv4 address. | |
865 | ct_snat(foo, bar); | |
866 | Syntax error at `foo' expecting IPv4 address. | |
867 | ct_snat(); | |
868 | Syntax error at `)' expecting IPv4 address. | |
de297547 | 869 | |
6335d074 | 870 | # arp |
8a41ad8e BP |
871 | arp { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; |
872 | 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),resubmit(,64) | |
d5a76da4 | 873 | has prereqs ip4 |
bac29564 BP |
874 | arp { }; |
875 | formats as arp { drop; }; | |
876 | encodes as controller(userdata=00.00.00.00.00.00.00.00) | |
877 | has prereqs ip4 | |
6335d074 | 878 | |
0bac7164 | 879 | # get_arp |
d5a76da4 BP |
880 | get_arp(outport, ip4.dst); |
881 | 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[] | |
882 | has prereqs eth.type == 0x800 | |
883 | get_arp(inport, reg0); | |
884 | 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[] | |
885 | ||
886 | get_arp; | |
887 | Syntax error at `;' expecting `('. | |
888 | get_arp(); | |
889 | Syntax error at `)' expecting field name. | |
890 | get_arp(inport); | |
891 | Syntax error at `)' expecting `,'. | |
892 | get_arp(inport ip4.dst); | |
893 | Syntax error at `ip4.dst' expecting `,'. | |
894 | get_arp(inport, ip4.dst; | |
895 | Syntax error at `;' expecting `)'. | |
896 | get_arp(inport, eth.dst); | |
897 | Cannot use 48-bit field eth.dst[0..47] where 32-bit field is required. | |
898 | get_arp(inport, outport); | |
899 | Cannot use string field outport where numeric field is required. | |
900 | get_arp(reg0, ip4.dst); | |
901 | Cannot use numeric field reg0 where string field is required. | |
0bac7164 BP |
902 | |
903 | # put_arp | |
d5a76da4 BP |
904 | put_arp(inport, arp.spa, arp.sha); |
905 | 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[] | |
906 | has prereqs eth.type == 0x806 && eth.type == 0x806 | |
0bac7164 | 907 | |
42814145 | 908 | # put_dhcp_opts |
d5a76da4 BP |
909 | reg1[0] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); |
910 | 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) | |
911 | 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"); | |
912 | 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"); | |
913 | 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) | |
914 | 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); | |
915 | 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); | |
916 | 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) | |
917 | ||
918 | reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); | |
919 | Cannot use 2-bit field reg1[0..1] where 1-bit field is required. | |
920 | reg1[0] = put_dhcp_opts(); | |
921 | put_dhcp_opts requires offerip to be specified. | |
922 | reg1[0] = put_dhcp_opts(x = 1.2.3.4, router = 10.0.0.1); | |
923 | Syntax error at `x' expecting DHCPv4 option name. | |
924 | reg1[0] = put_dhcp_opts(router = 10.0.0.1); | |
925 | put_dhcp_opts requires offerip to be specified. | |
926 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, "hi"); | |
927 | Syntax error at `"hi"'. | |
928 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, xyzzy); | |
929 | Syntax error at `xyzzy' expecting DHCPv4 option name. | |
930 | reg1[0] = put_dhcp_opts(offerip="xyzzy"); | |
931 | DHCPv4 option offerip requires numeric value. | |
932 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain=1.2.3.4); | |
933 | DHCPv4 option domain requires string value. | |
42814145 | 934 | |
f8a8db39 | 935 | # nd_na |
d5a76da4 BP |
936 | 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; }; |
937 | formats as nd_na { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; output; }; | |
938 | 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) | |
939 | has prereqs nd_ns | |
e75451fe | 940 | |
c34a87b6 | 941 | # get_nd |
d5a76da4 BP |
942 | get_nd(outport, ip6.dst); |
943 | 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[] | |
944 | has prereqs eth.type == 0x86dd | |
945 | get_nd(inport, xxreg0); | |
946 | 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[] | |
947 | get_nd; | |
948 | Syntax error at `;' expecting `('. | |
949 | get_nd(); | |
950 | Syntax error at `)' expecting field name. | |
951 | get_nd(inport); | |
952 | Syntax error at `)' expecting `,'. | |
953 | get_nd(inport ip6.dst); | |
954 | Syntax error at `ip6.dst' expecting `,'. | |
955 | get_nd(inport, ip6.dst; | |
956 | Syntax error at `;' expecting `)'. | |
957 | get_nd(inport, eth.dst); | |
958 | Cannot use 48-bit field eth.dst[0..47] where 128-bit field is required. | |
959 | get_nd(inport, outport); | |
960 | Cannot use string field outport where numeric field is required. | |
961 | get_nd(xxreg0, ip6.dst); | |
962 | Cannot use numeric field xxreg0 where string field is required. | |
c34a87b6 JP |
963 | |
964 | # put_nd | |
d5a76da4 BP |
965 | put_nd(inport, nd.target, nd.sll); |
966 | 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[] | |
967 | 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 | 968 | |
01cfdb2f | 969 | # put_dhcpv6_opts |
d5a76da4 | 970 | reg1[0] = put_dhcpv6_opts(ia_addr = ae70::4, server_id = 00:00:00:00:10:02); |
a55dacac | 971 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.05.00.10.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.04.00.02.00.06.00.00.00.00.10.02,pause) |
d5a76da4 BP |
972 | reg1[0] = put_dhcpv6_opts(); |
973 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40,pause) | |
974 | reg1[0] = put_dhcpv6_opts(dns_server={ae70::1,ae70::2}); | |
975 | formats as reg1[0] = put_dhcpv6_opts(dns_server = {ae70::1, ae70::2}); | |
a55dacac | 976 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.17.00.20.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) |
40df4566 ZKL |
977 | reg1[0] = put_dhcpv6_opts(server_id=12:34:56:78:9a:bc, dns_server={ae70::1,ae89::2}); |
978 | formats as reg1[0] = put_dhcpv6_opts(server_id = 12:34:56:78:9a:bc, dns_server = {ae70::1, ae89::2}); | |
a55dacac | 979 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.02.00.06.12.34.56.78.9a.bc.00.17.00.20.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.01.ae.89.00.00.00.00.00.00.00.00.00.00.00.00.00.02,pause) |
d5a76da4 | 980 | reg1[0] = put_dhcpv6_opts(domain_search = "ovn.org"); |
a55dacac | 981 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.18.00.07.6f.76.6e.2e.6f.72.67,pause) |
d5a76da4 BP |
982 | reg1[0] = put_dhcpv6_opts(x = 1.2.3.4); |
983 | Syntax error at `x' expecting DHCPv6 option name. | |
984 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, "hi"); | |
985 | Syntax error at `"hi"'. | |
986 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, xyzzy); | |
987 | Syntax error at `xyzzy' expecting DHCPv6 option name. | |
988 | reg1[0] = put_dhcpv6_opts(ia_addr="ae70::4"); | |
989 | DHCPv6 option ia_addr requires numeric value. | |
990 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, domain_search=ae70::1); | |
991 | DHCPv6 option domain_search requires string value. | |
01cfdb2f | 992 | |
a6095f81 BS |
993 | # set_queue |
994 | set_queue(0); | |
995 | encodes as set_queue:0 | |
996 | set_queue(61440); | |
997 | encodes as set_queue:61440 | |
998 | set_queue(65535); | |
999 | Queue ID 65535 for set_queue is not in valid range 0 to 61440. | |
1000 | ||
5f822129 | 1001 | # Contradictionary prerequisites (allowed but not useful): |
d5a76da4 BP |
1002 | ip4.src = ip6.src[0..31]; |
1003 | encodes as move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[] | |
1004 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
1005 | ip4.src <-> ip6.src[0..31]; | |
1006 | 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[] | |
1007 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
1008 | ||
1009 | # Miscellaneous negative tests. | |
1010 | ; | |
1011 | Syntax error at `;'. | |
1012 | xyzzy; | |
1013 | Syntax error at `xyzzy' expecting action. | |
1014 | next; 123; | |
1015 | Syntax error at `123'. | |
1016 | next; xyzzy; | |
1017 | Syntax error at `xyzzy' expecting action. | |
1018 | next | |
9aef3c1b | 1019 | Syntax error at end of input expecting `;'. |
3b7cb7e1 | 1020 | ]]) |
d5a76da4 BP |
1021 | sed '/^[[ ]]/d' test-cases.txt > input.txt |
1022 | cp test-cases.txt expout | |
3b7cb7e1 BP |
1023 | AT_CHECK([ovstest test-ovn parse-actions < input.txt], [0], [expout]) |
1024 | AT_CLEANUP | |
f295c17b BP |
1025 | |
1026 | AT_BANNER([OVN end-to-end tests]) | |
1027 | ||
9975d7be BP |
1028 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor |
1029 | AT_SETUP([ovn -- 3 HVs, 1 LS, 3 lports/HV]) | |
57d143eb | 1030 | AT_KEYWORDS([ovnarp]) |
f295c17b BP |
1031 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1032 | ovn_start | |
1033 | ||
1034 | # Create hypervisors hv[123]. | |
9975d7be | 1035 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. |
f295c17b BP |
1036 | # Add all of the vifs to a single logical switch lsw0. |
1037 | # Turn on port security on all the vifs except vif[123]1. | |
1038 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
1039 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
ea46a4e9 | 1040 | ovn-nbctl ls-add lsw0 |
f295c17b BP |
1041 | net_add n1 |
1042 | for i in 1 2 3; do | |
1043 | sim_add hv$i | |
1044 | as hv$i | |
1045 | ovs-vsctl add-br br-phys | |
1046 | ovn_attach n1 br-phys 192.168.0.$i | |
1047 | ||
1048 | for j in 1 2 3; do | |
1049 | 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 | 1050 | ovn-nbctl lsp-add lsw0 lp$i$j |
4d5c43d5 | 1051 | if test $j = 1; then |
31ed1192 | 1052 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
f295c17b | 1053 | else |
7dc88496 NS |
1054 | if test $j = 3; then |
1055 | ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j" | |
1056 | else | |
1057 | ip_addrs="192.168.0.$i$j" | |
1058 | fi | |
31ed1192 JP |
1059 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs" |
1060 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
f295c17b BP |
1061 | fi |
1062 | done | |
1063 | done | |
1064 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1065 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop | |
1066 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop | |
ea382567 RB |
1067 | 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\" |
1068 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop | |
f295c17b BP |
1069 | |
1070 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1071 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1072 | # for ARP resolution). | |
1073 | ovn_populate_arp | |
1074 | ||
1075 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1076 | # XXX This should be more systematic. | |
1077 | sleep 1 | |
611099dc | 1078 | |
fc6f9978 HZ |
1079 | # Make sure there is no attempt to adding duplicated flows by ovn-controller |
1080 | AT_FAIL_IF([test -n "`grep duplicate hv1/ovn-controller.log`"]) | |
1081 | AT_FAIL_IF([test -n "`grep duplicate hv2/ovn-controller.log`"]) | |
1082 | AT_FAIL_IF([test -n "`grep duplicate hv3/ovn-controller.log`"]) | |
1083 | ||
57d143eb HZ |
1084 | # Given the name of a logical port, prints the name of the hypervisor |
1085 | # on which it is located. | |
1086 | vif_to_hv() { | |
1087 | echo hv${1%?} | |
1088 | } | |
1089 | ||
f295c17b BP |
1090 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1091 | # | |
1092 | # This shell function causes a packet to be received on INPORT. The packet's | |
1093 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1094 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1095 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1096 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. |
f295c17b BP |
1097 | for i in 1 2 3; do |
1098 | for j in 1 2 3; do | |
1099 | : > $i$j.expected | |
1100 | done | |
1101 | done | |
1102 | test_packet() { | |
1103 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
57d143eb | 1104 | hv=`vif_to_hv $inport` |
f295c17b BP |
1105 | vif=vif$inport |
1106 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1107 | for outport; do | |
e4543cfe | 1108 | echo $packet >> $outport.expected |
f295c17b BP |
1109 | done |
1110 | } | |
1111 | ||
57d143eb HZ |
1112 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
1113 | # | |
1114 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1115 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1116 | # it should be the hardware address of the target to expect to receive in an | |
1117 | # ARP reply; otherwise no reply is expected. | |
1118 | # | |
31ed1192 | 1119 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
57d143eb HZ |
1120 | # SHA and REPLY_HA are each 12 hex digits. |
1121 | # SPA and TPA are each 8 hex digits. | |
1122 | test_arp() { | |
1123 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1124 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
1125 | hv=`vif_to_hv $inport` | |
1126 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
1127 | ||
92f9822b | 1128 | if test X$reply_ha = X; then |
57d143eb HZ |
1129 | # Expect to receive the broadcast ARP on the other logical switch ports |
1130 | # if no reply is expected. | |
1131 | local i j | |
1132 | for i in 1 2 3; do | |
1133 | for j in 1 2 3; do | |
1134 | if test $i$j != $inport; then | |
1135 | echo $request >> $i$j.expected | |
1136 | fi | |
1137 | done | |
1138 | done | |
1139 | else | |
1140 | # Expect to receive the reply, if any. | |
1141 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
1142 | echo $reply >> $inport.expected | |
1143 | fi | |
1144 | } | |
1145 | ||
1146 | ip_to_hex() { | |
1147 | printf "%02x%02x%02x%02x" "$@" | |
1148 | } | |
1149 | ||
f295c17b BP |
1150 | # Send packets between all pairs of source and destination ports: |
1151 | # | |
31ed1192 JP |
1152 | # 1. Unicast packets are delivered to exactly one logical switch port |
1153 | # (except that packets destined to their input ports are dropped). | |
f295c17b | 1154 | # |
31ed1192 JP |
1155 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1156 | # except the input port. | |
f295c17b | 1157 | # |
ea46a4e9 | 1158 | # 3. When port security is turned on, the switch drops packets from the wrong |
f295c17b BP |
1159 | # MAC address. |
1160 | # | |
ea46a4e9 | 1161 | # 4. The switch drops all packets with a VLAN tag. |
f295c17b | 1162 | # |
ea46a4e9 | 1163 | # 5. The switch drops all packets with a multicast source address. (This only |
f295c17b BP |
1164 | # affects behavior when port security is turned off, since otherwise port |
1165 | # security would drop the packet anyway.) | |
1166 | # | |
ea46a4e9 | 1167 | # 6. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1168 | # switch ports with "unknown" among their MAC addresses (and port |
1169 | # security disabled). | |
f295c17b | 1170 | # |
ea46a4e9 | 1171 | # 7. The switch drops unicast packets that violate an ACL. |
f295c17b | 1172 | # |
ea46a4e9 | 1173 | # 8. The switch drops multicast and broadcast packets that violate an ACL. |
57d143eb | 1174 | # |
9fcb6a18 BP |
1175 | # 9. OVN generates responses to ARP requests for known IPs, except for |
1176 | # requests from a port for the port's own IP. | |
57d143eb HZ |
1177 | # |
1178 | # 10. No response to ARP requests for unknown IPs. | |
4acd1e87 | 1179 | |
f295c17b BP |
1180 | for is in 1 2 3; do |
1181 | for js in 1 2 3; do | |
1182 | s=$is$js | |
1183 | bcast= | |
4d5c43d5 JP |
1184 | unknown= |
1185 | bacl2= | |
1186 | bacl3= | |
f295c17b BP |
1187 | for id in 1 2 3; do |
1188 | for jd in 1 2 3; do | |
1189 | d=$id$jd | |
1190 | ||
1191 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1192 | test_packet $s f000000000$d f000000000$s $s$d $unicast #1 | |
1193 | ||
1194 | if test $d != $s && test $js = 1; then | |
4d5c43d5 JP |
1195 | impersonate=$d |
1196 | else | |
1197 | impersonate= | |
1198 | fi | |
f295c17b BP |
1199 | test_packet $s f000000000$d f00000000055 55$d $impersonate #3 |
1200 | ||
4d5c43d5 JP |
1201 | if test $d != $s && test $s != 11; then acl2=$d; else acl2=; fi |
1202 | if test $d != $s && test $d != 33; then acl3=$d; else acl3=; fi | |
e137131a | 1203 | if test $d = $s || (test $js = 1 && test $d = 33); then |
ea382567 RB |
1204 | # Source of 11, 21, or 31 and dest of 33 should be dropped |
1205 | # due to the 4th ACL that uses address_set(set1). | |
1206 | acl4= | |
1207 | else | |
1208 | acl4=$d | |
1209 | fi | |
f295c17b BP |
1210 | test_packet $s f000000000$d f000000000$s 1234 #7, acl1 |
1211 | test_packet $s f000000000$d f000000000$s 1235 $acl2 #7, acl2 | |
1212 | test_packet $s f000000000$d f000000000$s 1236 $acl3 #7, acl3 | |
ea382567 | 1213 | test_packet $s f000000000$d f000000000$s 1237 $acl4 #7, acl4 |
f295c17b BP |
1214 | |
1215 | test_packet $s f000000000$d f00000000055 810000091234 #4 | |
1216 | test_packet $s f000000000$d 0100000000$s $s$d #5 | |
1217 | ||
4d5c43d5 JP |
1218 | if test $d != $s && test $jd = 1; then |
1219 | unknown="$unknown $d" | |
1220 | fi | |
f295c17b BP |
1221 | bcast="$bcast $unicast" |
1222 | bacl2="$bacl2 $acl2" | |
1223 | bacl3="$bacl3 $acl3" | |
57d143eb HZ |
1224 | |
1225 | sip=`ip_to_hex 192 168 0 $i$j` | |
1226 | tip=`ip_to_hex 192 168 0 $id$jd` | |
1227 | tip_unknown=`ip_to_hex 11 11 11 11` | |
9fcb6a18 BP |
1228 | if test $d != $s; then |
1229 | reply_ha=f000000000$d | |
1230 | else | |
1231 | reply_ha= | |
1232 | fi | |
1233 | test_arp $s f000000000$s $sip $tip $reply_ha #9 | |
57d143eb | 1234 | test_arp $s f000000000$s $sip $tip_unknown #10 |
7dc88496 NS |
1235 | |
1236 | if test $jd = 3; then | |
31ed1192 | 1237 | # lsp[123]3 has an additional ip 192.169.0.[123]3. |
7dc88496 | 1238 | tip=`ip_to_hex 192 169 0 $id$jd` |
9fcb6a18 | 1239 | test_arp $s f000000000$s $sip $tip $reply_ha #9 |
7dc88496 | 1240 | fi |
f295c17b BP |
1241 | done |
1242 | done | |
1243 | ||
4d5c43d5 | 1244 | # Broadcast and multicast. |
f295c17b BP |
1245 | test_packet $s ffffffffffff f000000000$s ${s}ff $bcast #2 |
1246 | test_packet $s 010000000000 f000000000$s ${s}ff $bcast #2 | |
4d5c43d5 | 1247 | if test $js = 1; then |
f295c17b BP |
1248 | bcast_impersonate=$bcast |
1249 | else | |
4d5c43d5 JP |
1250 | bcast_impersonate= |
1251 | fi | |
f295c17b BP |
1252 | test_packet $s 010000000000 f00000000044 44ff $bcast_impersonate #3 |
1253 | ||
1254 | test_packet $s f0000000ffff f000000000$s ${s}66 $unknown #6 | |
1255 | ||
1256 | test_packet $s ffffffffffff f000000000$s 1234 #8, acl1 | |
1257 | test_packet $s ffffffffffff f000000000$s 1235 $bacl2 #8, acl2 | |
1258 | test_packet $s ffffffffffff f000000000$s 1236 $bacl3 #8, acl3 | |
1259 | test_packet $s 010000000000 f000000000$s 1234 #8, acl1 | |
1260 | test_packet $s 010000000000 f000000000$s 1235 $bacl2 #8, acl2 | |
1261 | test_packet $s 010000000000 f000000000$s 1236 $bacl3 #8, acl3 | |
1262 | done | |
1263 | done | |
1264 | ||
7dc88496 NS |
1265 | # set address for lp13 with invalid characters. |
1266 | # lp13 should be configured with only 192.168.0.13. | |
31ed1192 | 1267 | ovn-nbctl lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13" |
3b8cd0ea BP |
1268 | |
1269 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1270 | # XXX This should be more systematic. | |
1271 | sleep 1 | |
1272 | ||
7dc88496 NS |
1273 | sip=`ip_to_hex 192 168 0 11` |
1274 | tip=`ip_to_hex 192 168 0 13` | |
1275 | test_arp 11 f00000000011 $sip $tip f00000000013 | |
1276 | ||
1277 | tip=`ip_to_hex 192 169 0 13` | |
1278 | #arp request for 192.169.0.13 should be flooded | |
1279 | test_arp 11 f00000000011 $sip $tip | |
1280 | ||
91125642 | 1281 | # dump information and flows with counters |
bb0c41d3 RM |
1282 | ovn-sbctl dump-flows -- list multicast_group |
1283 | ||
1284 | echo "------ hv1 dump ------" | |
1285 | as hv1 ovs-vsctl show | |
1286 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1287 | ||
1288 | echo "------ hv2 dump ------" | |
1289 | as hv2 ovs-vsctl show | |
1290 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1291 | ||
1292 | echo "------ hv3 dump ------" | |
1293 | as hv3 ovs-vsctl show | |
1294 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
49d7c759 | 1295 | |
f295c17b BP |
1296 | # Now check the packets actually received against the ones expected. |
1297 | for i in 1 2 3; do | |
1298 | for j in 1 2 3; do | |
49d7c759 | 1299 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
f295c17b BP |
1300 | done |
1301 | done | |
fcde56f5 | 1302 | |
7a8f15e0 | 1303 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 1304 | |
f295c17b | 1305 | AT_CLEANUP |
eb6b08eb | 1306 | |
4acd1e87 BP |
1307 | AT_SETUP([ovn -- trace 1 LS, 3 LSPs]) |
1308 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1309 | ovn_start | |
1310 | ||
1311 | # Create a logical switch and some logical ports. | |
1312 | # Turn on port security on all lports except ls1. | |
1313 | # Make ls1 a destination for unknown MACs. | |
1314 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
1315 | ovn-nbctl ls-add lsw0 | |
1316 | ovn-sbctl chassis-add hv0 geneve 127.0.0.1 | |
1317 | for i in 1 2 3; do | |
1318 | ovn-nbctl lsp-add lsw0 lp$i | |
7979c444 BP |
1319 | done |
1320 | ovn-nbctl --wait=sb sync | |
1321 | for i in 1 2 3; do | |
4acd1e87 BP |
1322 | ovn-sbctl lsp-bind lp$i hv0 |
1323 | if test $i = 1; then | |
abb37b6b | 1324 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:0$i 192.168.0.$i" unknown |
4acd1e87 | 1325 | else |
abb37b6b FF |
1326 | if test $i = 3; then |
1327 | ip_addrs="192.168.0.$i fe80::ea2a:eaff:fe28:$i/64 192.169.0.$i" | |
1328 | else | |
1329 | ip_addrs="192.168.0.$i" | |
1330 | fi | |
1331 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:$i $ip_addrs" | |
1332 | ovn-nbctl lsp-set-port-security lp$i f0:00:00:00:00:$i | |
4acd1e87 BP |
1333 | fi |
1334 | done | |
1335 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1336 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp1"' drop | |
1337 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp3"' drop | |
1338 | ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:01\",\"f0:00:00:00:00:02\" | |
1339 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp3"' drop | |
1340 | ||
1341 | ovn-nbctl --wait=sb sync | |
1342 | on_exit 'kill `cat ovn-trace.pid`' | |
1343 | ovn-trace --detach --pidfile --no-chdir | |
1344 | ||
1345 | # test_packet INPORT DST SRC [-vlan] [-eth TYPE] OUTPORT... | |
1346 | # | |
1347 | # This shell function causes a packet to be received on INPORT. The packet's | |
1348 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1349 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1350 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1351 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. | |
1352 | test_packet() { | |
1353 | local inport=$1 eth_dst=$2 eth_src=$3; shift; shift; shift | |
1354 | uflow="inport==\"lp$inport\" && eth.dst==$eth_dst && eth.src==$eth_src" | |
1355 | while :; do | |
abb37b6b FF |
1356 | case $1 in # ( |
1357 | -vlan) uflow="$uflow && vlan.vid == 1234"; shift ;; # ( | |
1358 | -eth) uflow="$uflow && eth.type == 0x$2"; shift; shift ;; # ( | |
1359 | *) break ;; | |
1360 | esac | |
4acd1e87 BP |
1361 | done |
1362 | for outport; do | |
abb37b6b | 1363 | echo "output(\"lp$outport\");" |
4acd1e87 BP |
1364 | done > expout |
1365 | ||
1366 | AT_CAPTURE_FILE([trace]) | |
1367 | AT_CHECK([ovs-appctl -t ovn-trace trace --all lsw0 "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
1368 | } | |
1369 | ||
1370 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
1371 | # | |
1372 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1373 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1374 | # it should be the hardware address of the target to expect to receive in an | |
1375 | # ARP reply; otherwise no reply is expected. | |
1376 | # | |
1377 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
1378 | # SHA and REPLY_HA are each 12 hex digits. | |
1379 | # SPA and TPA are each 8 hex digits. | |
1380 | test_arp() { | |
1381 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1382 | ||
1383 | local request="inport == \"lp$inport\" | |
1384 | && eth.dst == ff:ff:ff:ff:ff:ff && eth.src == $sha | |
1385 | && arp.op == 1 && arp.sha == $sha && arp.spa == $spa | |
abb37b6b | 1386 | && arp.tha == ff:ff:ff:ff:ff:ff && arp.tpa == $tpa" |
4acd1e87 BP |
1387 | |
1388 | if test -z "$reply_ha"; then | |
1389 | reply= | |
abb37b6b FF |
1390 | local i |
1391 | for i in 1 2 3; do | |
1392 | if test $i != $inport; then | |
1393 | reply="${reply}output(\"lp$i\"); | |
4acd1e87 | 1394 | " |
abb37b6b FF |
1395 | fi |
1396 | done | |
4acd1e87 BP |
1397 | else |
1398 | reply="\ | |
1399 | eth.dst = $sha; | |
1400 | eth.src = $reply_ha; | |
1401 | arp.op = 2; | |
1402 | arp.tha = $sha; | |
1403 | arp.sha = $reply_ha; | |
1404 | arp.tpa = $spa; | |
1405 | arp.spa = $tpa; | |
1406 | output(\"lp$inport\"); | |
1407 | " | |
1408 | fi | |
1409 | ||
1410 | AT_CAPTURE_FILE([trace]) | |
1411 | AT_CHECK_UNQUOTED([ovs-appctl -t ovn-trace trace --all lsw0 "$request" | tee trace | sed '1,/Minimal trace/d'], [0], [$reply]) | |
1412 | } | |
1413 | ||
1414 | # Send packets between all pairs of source and destination ports: | |
1415 | # | |
1416 | # 1. Unicast packets are delivered to exactly one logical switch port | |
1417 | # (except that packets destined to their input ports are dropped). | |
1418 | # | |
1419 | # 2. Broadcast and multicast are delivered to all logical switch ports | |
1420 | # except the input port. | |
1421 | # | |
1422 | # 3. When port security is turned on, the switch drops packets from the wrong | |
1423 | # MAC address. | |
1424 | # | |
1425 | # 4. The switch drops all packets with a VLAN tag. | |
1426 | # | |
1427 | # 5. The switch drops all packets with a multicast source address. (This only | |
1428 | # affects behavior when port security is turned off, since otherwise port | |
1429 | # security would drop the packet anyway.) | |
1430 | # | |
1431 | # 6. The switch delivers packets with an unknown destination to logical | |
1432 | # switch ports with "unknown" among their MAC addresses (and port | |
1433 | # security disabled). | |
1434 | # | |
1435 | # 7. The switch drops unicast packets that violate an ACL. | |
1436 | # | |
1437 | # 8. The switch drops multicast and broadcast packets that violate an ACL. | |
1438 | # | |
9fcb6a18 BP |
1439 | # 9. OVN generates responses to ARP requests for known IPs, except for |
1440 | # requests from a port for the port's own IP. | |
4acd1e87 BP |
1441 | # |
1442 | # 10. No response to ARP requests for unknown IPs. | |
1443 | ||
1444 | for s in 1 2 3; do | |
1445 | bcast= | |
1446 | unknown= | |
1447 | bacl2= | |
1448 | bacl3= | |
1449 | for d in 1 2 3; do | |
abb37b6b FF |
1450 | echo |
1451 | echo "lp$s -> lp$d" | |
1452 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1453 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s $unicast #1 | |
1454 | ||
1455 | if test $d != $s && test $s = 1; then | |
1456 | impersonate=$d | |
1457 | else | |
1458 | impersonate= | |
1459 | fi | |
1460 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 $impersonate #3 | |
1461 | ||
1462 | if test $d != $s && test $s != 1; then acl2=$d; else acl2=; fi | |
1463 | if test $d != $s && test $d != 3; then acl3=$d; else acl3=; fi | |
1464 | if test $d = $s || ( (test $s = 1 || test $s = 2) && test $d = 3); then | |
1465 | # Source of 1 or 2 and dest of 3 should be dropped | |
1466 | # due to the 4th ACL that uses address_set(set1). | |
1467 | acl4= | |
1468 | else | |
1469 | acl4=$d | |
1470 | fi | |
1471 | ||
1472 | #7, acl1 to acl4: | |
1473 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1234 | |
1474 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1235 $acl2 | |
1475 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1236 $acl3 | |
1476 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1237 $acl4 | |
1477 | ||
1478 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 -vlan #4 | |
1479 | test_packet $s f0:00:00:00:00:0$d 01:00:00:00:00:0$s #5 | |
1480 | ||
1481 | if test $d != $s && test $d = 1; then | |
1482 | unknown="$unknown $d" | |
1483 | fi | |
1484 | bcast="$bcast $unicast" | |
1485 | bacl2="$bacl2 $acl2" | |
1486 | bacl3="$bacl3 $acl3" | |
1487 | ||
1488 | sip=192.168.0.$s | |
1489 | tip=192.168.0.$d | |
1490 | tip_unknown=11.11.11.11 | |
9fcb6a18 BP |
1491 | if test $d != $s; then reply_ha=f0:00:00:00:00:0$d; else reply_ha=; fi |
1492 | test_arp $s f0:00:00:00:00:0$s $sip $tip $reply_ha #9 | |
abb37b6b FF |
1493 | test_arp $s f0:00:00:00:00:0$s $sip $tip_unknown #10 |
1494 | ||
1495 | if test $d = 3; then | |
1496 | # lp3 has an additional ip 192.169.0.[123]3. | |
1497 | tip=192.169.0.$d | |
9fcb6a18 | 1498 | test_arp $s f0:00:00:00:00:0$s $sip $tip $reply_ha #9 |
abb37b6b | 1499 | fi |
4acd1e87 BP |
1500 | done |
1501 | ||
1502 | # Broadcast and multicast. | |
1503 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s $bcast #2 | |
1504 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s $bcast #2 | |
1505 | if test $s = 1; then | |
abb37b6b | 1506 | bcast_impersonate=$bcast |
4acd1e87 | 1507 | else |
abb37b6b | 1508 | bcast_impersonate= |
4acd1e87 BP |
1509 | fi |
1510 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:44 $bcast_impersonate #3 | |
1511 | ||
1512 | test_packet $s f0:00:00:00:ff:ff f0:00:00:00:00:0$s $unknown #6 | |
1513 | ||
1514 | #8, acl1 to acl3: | |
1515 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1234 | |
1516 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
1517 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
1518 | ||
1519 | #8, acl1 to acl3: | |
1520 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1234 | |
1521 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
1522 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
1523 | done | |
1524 | ||
1525 | AT_CLEANUP | |
1526 | ||
7277bc83 RB |
1527 | # 2 hypervisors, 4 logical ports per HV |
1528 | # 2 locally attached networks (one flat, one vlan tagged over same device) | |
1529 | # 2 ports per HV on each network | |
e90aeb57 | 1530 | AT_SETUP([ovn -- 2 HVs, 4 lports/HV, localnet ports]) |
d79fc5f4 RB |
1531 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1532 | ovn_start | |
1533 | ||
ea46a4e9 JP |
1534 | # In this test cases we create 3 switches, all connected to same |
1535 | # physical network (through br-phys on each HV). Each switch has | |
0ee7f7f1 HZ |
1536 | # VIF ports across 2 HVs. Each HV has 5 VIF ports. The first digit |
1537 | # of VIF port name indicates the hypervisor it is bound to, e.g. | |
1538 | # lp23 means VIF 3 on hv2. | |
1539 | # | |
ea46a4e9 | 1540 | # Each switch's VLAN tag and their logical switch ports are: |
0ee7f7f1 HZ |
1541 | # - ls1: |
1542 | # - untagged | |
ea46a4e9 | 1543 | # - ports: lp11, lp12, lp21, lp22 |
0ee7f7f1 HZ |
1544 | # |
1545 | # - ls2: | |
1546 | # - tagged with VLAN 101 | |
ea46a4e9 | 1547 | # - ports: lp13, lp14, lp23, lp24 |
0ee7f7f1 HZ |
1548 | # - ls3: |
1549 | # - untagged | |
ea46a4e9 | 1550 | # - ports: lp15, lp25 |
0ee7f7f1 | 1551 | # |
ea46a4e9 | 1552 | # Note: a localnet port is created for each switch to connect to |
0ee7f7f1 HZ |
1553 | # physical network. |
1554 | ||
1555 | for i in 1 2 3; do | |
ea46a4e9 JP |
1556 | ls_name=ls$i |
1557 | ovn-nbctl ls-add $ls_name | |
0ee7f7f1 HZ |
1558 | ln_port_name=ln$i |
1559 | if test $i -eq 2; then | |
ea46a4e9 | 1560 | ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 |
0ee7f7f1 | 1561 | else |
ea46a4e9 | 1562 | ovn-nbctl lsp-add $ls_name $ln_port_name |
0ee7f7f1 | 1563 | fi |
31ed1192 JP |
1564 | ovn-nbctl lsp-set-addresses $ln_port_name unknown |
1565 | ovn-nbctl lsp-set-type $ln_port_name localnet | |
1566 | ovn-nbctl lsp-set-options $ln_port_name network_name=phys | |
0ee7f7f1 | 1567 | done |
d79fc5f4 | 1568 | |
69b72264 BP |
1569 | # lsp_to_ls LSP |
1570 | # | |
1571 | # Prints the name of the logical switch that contains LSP. | |
1572 | lsp_to_ls () { | |
1573 | case $1 in dnl ( | |
1574 | lp?[[12]]) echo ls1 ;; dnl ( | |
1575 | lp?[[34]]) echo ls2 ;; dnl ( | |
1576 | lp?5) echo ls3 ;; dnl ( | |
1577 | *) AT_FAIL_IF([:]) ;; | |
1578 | esac | |
1579 | } | |
1580 | ||
d79fc5f4 RB |
1581 | net_add n1 |
1582 | for i in 1 2; do | |
1583 | sim_add hv$i | |
1584 | as hv$i | |
1585 | ovs-vsctl add-br br-phys | |
1586 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
1587 | ovn_attach n1 br-phys 192.168.0.$i | |
1588 | ||
0ee7f7f1 | 1589 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
1590 | ovs-vsctl add-port br-int vif$i$j -- \ |
1591 | set Interface vif$i$j external-ids:iface-id=lp$i$j \ | |
1592 | options:tx_pcap=hv$i/vif$i$j-tx.pcap \ | |
1593 | options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ | |
1594 | ofport-request=$i$j | |
1595 | ||
31ed1192 | 1596 | lsp_name=lp$i$j |
69b72264 | 1597 | ls_name=$(lsp_to_ls $lsp_name) |
d79fc5f4 | 1598 | |
ea46a4e9 | 1599 | ovn-nbctl lsp-add $ls_name $lsp_name |
31ed1192 JP |
1600 | ovn-nbctl lsp-set-addresses $lsp_name f0:00:00:00:00:$i$j |
1601 | ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$j | |
d79fc5f4 | 1602 | |
31ed1192 | 1603 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) |
d79fc5f4 RB |
1604 | done |
1605 | done | |
69b72264 BP |
1606 | ovn-nbctl --wait=sb sync |
1607 | ovn-sbctl dump-flows | |
d79fc5f4 RB |
1608 | |
1609 | ovn_populate_arp | |
1610 | ||
1611 | # XXX This is now the 3rd copy of these functions in this file ... | |
1612 | ||
1613 | # Given the name of a logical port, prints the name of the hypervisor | |
1614 | # on which it is located. | |
1615 | vif_to_hv() { | |
1616 | echo hv${1%?} | |
1617 | } | |
1618 | # | |
69b72264 | 1619 | # test_packet INPORT DST SRC ETHTYPE EOUT LOUT |
d79fc5f4 RB |
1620 | # |
1621 | # This shell function causes a packet to be received on INPORT. The packet's | |
1622 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
69b72264 BP |
1623 | # digits) and Ethernet type ETHTYPE (4 hex digits). INPORT is specified as |
1624 | # logical switch port numbers, e.g. 11 for vif11. | |
1625 | # | |
1626 | # EOUT is the end-to-end output port, that is, where the packet will end up | |
1627 | # after possibly bouncing through one or more localnet ports. LOUT is the | |
1628 | # logical output port, which might be a localnet port, as seen by ovn-trace | |
1629 | # (which doesn't know what localnet ports are connected to and therefore can't | |
1630 | # figure out the end-to-end answer). | |
d79fc5f4 | 1631 | for i in 1 2; do |
0ee7f7f1 | 1632 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
1633 | : > $i$j.expected |
1634 | done | |
1635 | done | |
1636 | test_packet() { | |
69b72264 BP |
1637 | local inport=$1 dst=$2 src=$3 eth=$4 eout=$5 lout=$6 |
1638 | echo "$@" | |
1639 | ||
1640 | # First try tracing the packet. | |
1641 | uflow="inport==\"lp$inport\" && eth.dst==$dst && eth.src==$src && eth.type==0x$eth" | |
1642 | if test $lout != drop; then | |
1643 | echo "output(\"$lout\");" | |
1644 | fi > expout | |
1645 | AT_CAPTURE_FILE([trace]) | |
1646 | AT_CHECK([ovn-trace --all $(lsp_to_ls lp$inport) "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
1647 | ||
1648 | # Then actually send a packet, for an end-to-end test. | |
1649 | local packet=$(echo $dst$src | sed 's/://g')${eth} | |
d79fc5f4 RB |
1650 | hv=`vif_to_hv $inport` |
1651 | vif=vif$inport | |
1652 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
69b72264 BP |
1653 | if test $eout != drop; then |
1654 | echo $packet >> ${eout#lp}.expected | |
1655 | fi | |
d79fc5f4 RB |
1656 | } |
1657 | ||
7277bc83 RB |
1658 | # lp11 and lp21 are on the same network (phys, untagged) |
1659 | # and on different hypervisors | |
69b72264 BP |
1660 | test_packet 11 f0:00:00:00:00:21 f0:00:00:00:00:11 1121 lp21 lp21 |
1661 | test_packet 21 f0:00:00:00:00:11 f0:00:00:00:00:21 2111 lp11 lp11 | |
d79fc5f4 | 1662 | |
7277bc83 RB |
1663 | # lp11 and lp12 are on the same network (phys, untagged) |
1664 | # and on the same hypervisor | |
69b72264 BP |
1665 | test_packet 11 f0:00:00:00:00:12 f0:00:00:00:00:11 1112 lp12 lp12 |
1666 | test_packet 12 f0:00:00:00:00:11 f0:00:00:00:00:12 1211 lp11 lp11 | |
7277bc83 RB |
1667 | |
1668 | # lp13 and lp23 are on the same network (phys, VLAN 101) | |
1669 | # and on different hypervisors | |
69b72264 BP |
1670 | test_packet 13 f0:00:00:00:00:23 f0:00:00:00:00:13 1323 lp23 lp23 |
1671 | test_packet 23 f0:00:00:00:00:13 f0:00:00:00:00:23 2313 lp13 lp13 | |
7277bc83 RB |
1672 | |
1673 | # lp13 and lp14 are on the same network (phys, VLAN 101) | |
1674 | # and on the same hypervisor | |
69b72264 BP |
1675 | test_packet 13 f0:00:00:00:00:14 f0:00:00:00:00:13 1314 lp14 lp14 |
1676 | test_packet 14 f0:00:00:00:00:13 f0:00:00:00:00:14 1413 lp13 lp13 | |
d79fc5f4 | 1677 | |
0ee7f7f1 | 1678 | # lp11 and lp15 are on the same network (phys, untagged), |
ea46a4e9 | 1679 | # same hypervisor, and on different switches |
69b72264 BP |
1680 | test_packet 11 f0:00:00:00:00:15 f0:00:00:00:00:11 1115 lp15 ln1 |
1681 | test_packet 15 f0:00:00:00:00:11 f0:00:00:00:00:15 1511 lp11 ln3 | |
0ee7f7f1 HZ |
1682 | |
1683 | # lp11 and lp25 are on the same network (phys, untagged), | |
ea46a4e9 | 1684 | # different hypervisors, and on different switches |
69b72264 BP |
1685 | test_packet 11 f0:00:00:00:00:25 f0:00:00:00:00:11 1125 lp25 ln1 |
1686 | test_packet 25 f0:00:00:00:00:11 f0:00:00:00:00:25 2511 lp11 ln3 | |
0ee7f7f1 | 1687 | |
d79fc5f4 | 1688 | # Ports that should not be able to communicate |
69b72264 BP |
1689 | test_packet 11 f0:00:00:00:00:13 f0:00:00:00:00:11 1113 drop ln1 |
1690 | test_packet 11 f0:00:00:00:00:23 f0:00:00:00:00:11 1123 drop ln1 | |
1691 | test_packet 21 f0:00:00:00:00:13 f0:00:00:00:00:21 2113 drop ln1 | |
1692 | test_packet 21 f0:00:00:00:00:23 f0:00:00:00:00:21 2123 drop ln1 | |
1693 | test_packet 13 f0:00:00:00:00:11 f0:00:00:00:00:13 1311 drop ln2 | |
1694 | test_packet 13 f0:00:00:00:00:21 f0:00:00:00:00:13 1321 drop ln2 | |
1695 | test_packet 23 f0:00:00:00:00:11 f0:00:00:00:00:23 2311 drop ln2 | |
1696 | test_packet 23 f0:00:00:00:00:21 f0:00:00:00:00:23 2321 drop ln2 | |
d79fc5f4 | 1697 | |
d79fc5f4 RB |
1698 | # Dump a bunch of info helpful for debugging if there's a failure. |
1699 | ||
1700 | echo "------ OVN dump ------" | |
1701 | ovn-nbctl show | |
1702 | ovn-sbctl show | |
1703 | ||
1704 | echo "------ hv1 dump ------" | |
1705 | as hv1 ovs-vsctl show | |
1706 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1707 | ||
1708 | echo "------ hv2 dump ------" | |
1709 | as hv2 ovs-vsctl show | |
1710 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1711 | ||
1712 | # Now check the packets actually received against the ones expected. | |
1713 | for i in 1 2; do | |
0ee7f7f1 | 1714 | for j in 1 2 3 4 5; do |
49d7c759 | 1715 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
d79fc5f4 RB |
1716 | done |
1717 | done | |
1718 | ||
7a8f15e0 | 1719 | OVN_CLEANUP([hv1],[hv2]) |
d9c8c57c | 1720 | |
d79fc5f4 RB |
1721 | AT_CLEANUP |
1722 | ||
91125642 FF |
1723 | AT_SETUP([ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS]) |
1724 | AT_KEYWORDS([vtep]) | |
eb6b08eb JP |
1725 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1726 | ovn_start | |
1727 | ||
1728 | # Configure the Northbound database | |
ea46a4e9 | 1729 | ovn-nbctl ls-add lsw0 |
eb6b08eb | 1730 | |
31ed1192 JP |
1731 | ovn-nbctl lsp-add lsw0 lp1 |
1732 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
eb6b08eb | 1733 | |
31ed1192 JP |
1734 | ovn-nbctl lsp-add lsw0 lp2 |
1735 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
eb6b08eb | 1736 | |
31ed1192 JP |
1737 | ovn-nbctl lsp-add lsw0 lp-vtep |
1738 | ovn-nbctl lsp-set-type lp-vtep vtep | |
1739 | ovn-nbctl lsp-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0 | |
1740 | ovn-nbctl lsp-set-addresses lp-vtep unknown | |
eb6b08eb | 1741 | |
77adbb62 DB |
1742 | # lpr, lr and lrp1 are used for the ARP request handling test only. |
1743 | ovn-nbctl lsp-add lsw0 lpr | |
1744 | ovn-nbctl lr-add lr | |
1745 | ovn-nbctl lrp-add lr lrp1 f0:00:00:00:00:f1 192.168.1.1/24 | |
1746 | ovn-nbctl set Logical_Switch_Port lpr type=router \ | |
1747 | options:router-port=lrp1 \ | |
1748 | addresses='"f0:00:00:00:00:f1 192.168.1.1"' | |
1749 | ||
1750 | ||
eb6b08eb JP |
1751 | net_add n1 # Network to connect hv1, hv2, and vtep |
1752 | net_add n2 # Network to connect vtep and hv3 | |
1753 | ||
1754 | # Create hypervisor hv1 connected to n1 | |
1755 | sim_add hv1 | |
1756 | as hv1 | |
1757 | ovs-vsctl add-br br-phys | |
1758 | ovn_attach n1 br-phys 192.168.0.1 | |
1759 | 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 | |
1760 | ||
1761 | # Create hypervisor hv2 connected to n1 | |
1762 | sim_add hv2 | |
1763 | as hv2 | |
1764 | ovs-vsctl add-br br-phys | |
1765 | ovn_attach n1 br-phys 192.168.0.2 | |
1766 | 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 | |
1767 | ||
1768 | ||
1769 | # Start the vtep emulator with a leg in both networks | |
1770 | sim_add vtep | |
1771 | as vtep | |
1772 | ||
1773 | ovsdb-tool create "$ovs_base"/vtep/vtep.db "$abs_top_srcdir"/vtep/vtep.ovsschema || return 1 | |
1774 | ovs-appctl -t ovsdb-server ovsdb-server/add-db "$ovs_base"/vtep/vtep.db | |
1775 | ||
1776 | ovs-vsctl add-br br-phys | |
1777 | net_attach n1 br-phys | |
1778 | ||
1779 | mac=`ovs-vsctl get Interface br-phys mac_in_use | sed s/\"//g` | |
1780 | arp_table="$arp_table $sandbox,br-phys,192.168.0.3,$mac" | |
1781 | ovs-appctl netdev-dummy/ip4addr br-phys 192.168.0.3/24 >/dev/null || return 1 | |
1782 | ovs-appctl ovs/route/add 192.168.0.3/24 br-phys >/dev/null || return 1 | |
1783 | ||
1784 | ovs-vsctl add-br br-vtep | |
1785 | net_attach n2 br-vtep | |
1786 | ||
1787 | vtep-ctl add-ps br-vtep | |
1788 | vtep-ctl set Physical_Switch br-vtep tunnel_ips=192.168.0.3 | |
1789 | vtep-ctl add-ls lsw0 | |
1790 | ||
1791 | start_daemon ovs-vtep br-vtep | |
1792 | start_daemon ovn-controller-vtep --vtep-db=unix:"$ovs_base"/vtep/db.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
1793 | ||
8cdc4312 | 1794 | OVS_WAIT_UNTIL([vtep-ctl bind-ls br-vtep br-vtep_n2 0 lsw0]) |
eb6b08eb | 1795 | |
475f0a2c DB |
1796 | OVS_WAIT_UNTIL([test -n "`as vtep vtep-ctl get-replication-mode lsw0 | |
1797 | grep -- source`"]) | |
1798 | # It takes more time for the update to be processed by ovs-vtep. | |
eb6b08eb JP |
1799 | sleep 1 |
1800 | ||
1801 | # Add hv3 on the other side of the vtep | |
1802 | sim_add hv3 | |
1803 | as hv3 | |
1804 | ovs-vsctl add-br br-phys | |
1805 | net_attach n2 br-phys | |
1806 | ||
1807 | 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 | |
1808 | ||
1809 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1810 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1811 | # for ARP resolution). | |
1812 | ovn_populate_arp | |
1813 | ||
1814 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1815 | # XXX This should be more systematic. | |
1816 | sleep 1 | |
6977df72 | 1817 | |
eb6b08eb JP |
1818 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1819 | # | |
1820 | # This shell function causes a packet to be received on INPORT. The packet's | |
1821 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1822 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1823 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1824 | # OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1. |
eb6b08eb JP |
1825 | for i in 1 2 3; do |
1826 | : > $i.expected | |
1827 | done | |
1828 | test_packet() { | |
1829 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
1830 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
1831 | hv=hv$inport | |
1832 | vif=vif$inport | |
1833 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1834 | for outport; do | |
e4543cfe | 1835 | echo $packet >> $outport.expected |
eb6b08eb JP |
1836 | done |
1837 | } | |
1838 | ||
1839 | # Send packets between all pairs of source and destination ports: | |
1840 | # | |
31ed1192 JP |
1841 | # 1. Unicast packets are delivered to exactly one logical switch port |
1842 | # (except that packets destined to their input ports are dropped). | |
eb6b08eb | 1843 | # |
31ed1192 JP |
1844 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1845 | # except the input port. | |
eb6b08eb | 1846 | # |
ea46a4e9 | 1847 | # 3. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1848 | # switch ports with "unknown" among their MAC addresses (and port |
1849 | # security disabled). | |
eb6b08eb JP |
1850 | for s in 1 2 3; do |
1851 | bcast= | |
1852 | unknown= | |
1853 | for d in 1 2 3; do | |
1854 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1855 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
1856 | ||
1857 | # The vtep (vif3) is the only one configured for "unknown" | |
1858 | if test $d != $s && test $d = 3; then | |
1859 | unknown="$unknown $d" | |
1860 | fi | |
1861 | bcast="$bcast $unicast" | |
1862 | done | |
1863 | ||
1864 | # Broadcast and multicast. | |
46ed1382 DB |
1865 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 |
1866 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #2 | |
eb6b08eb JP |
1867 | |
1868 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #3 | |
1869 | done | |
1870 | ||
77adbb62 DB |
1871 | # ARP request should not be responded to by logical switch router |
1872 | # type arp responder on HV1 and HV2 and should reach directly to | |
1873 | # vif1 and vif2 | |
1874 | ip_to_hex() { | |
1875 | printf "%02x%02x%02x%02x" "$@" | |
1876 | } | |
1877 | sha=f00000000003 | |
1878 | spa=`ip_to_hex 192 168 1 2` | |
1879 | tpa=`ip_to_hex 192 168 1 1` | |
1880 | request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
1881 | as hv3 ovs-appctl netdev-dummy/receive vif3 $request | |
1882 | echo $request >> 1.expected | |
1883 | echo $request >> 2.expected | |
1884 | ||
bb0c41d3 RM |
1885 | # dump information with counters |
1886 | echo "------ OVN dump ------" | |
1887 | ovn-nbctl show | |
1888 | ovn-sbctl show | |
1889 | ||
77adbb62 DB |
1890 | echo "---------SB dump-----" |
1891 | ovn-sbctl list datapath_binding | |
1892 | echo "---------------------" | |
1893 | ovn-sbctl list port_binding | |
1894 | echo "---------------------" | |
1895 | ovn-sbctl dump-flows | |
1896 | ||
bb0c41d3 RM |
1897 | echo "------ hv1 dump ------" |
1898 | as hv1 ovs-vsctl show | |
6195e2e7 | 1899 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
1900 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
1901 | ||
1902 | echo "------ hv2 dump ------" | |
1903 | as hv2 ovs-vsctl show | |
6195e2e7 | 1904 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
1905 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
1906 | ||
1907 | echo "------ hv3 dump ------" | |
1908 | as hv3 ovs-vsctl show | |
6754e92d FF |
1909 | # note: hv3 has no logical port bind, thus it should not have br-int |
1910 | AT_CHECK([as hv3 ovs-ofctl -O OpenFlow13 show br-int], [1], [], | |
1911 | [ovs-ofctl: br-int is not a bridge or a socket | |
1912 | ]) | |
bb0c41d3 | 1913 | |
eb6b08eb JP |
1914 | # Now check the packets actually received against the ones expected. |
1915 | for i in 1 2 3; do | |
49d7c759 | 1916 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
eb6b08eb | 1917 | done |
fcde56f5 LR |
1918 | |
1919 | # Gracefully terminate daemons | |
7a8f15e0 LR |
1920 | OVN_CLEANUP([hv1],[hv2],[vtep]) |
1921 | OVN_CLEANUP_VSWITCH([hv3]) | |
d9c8c57c | 1922 | |
eb6b08eb | 1923 | AT_CLEANUP |
9975d7be | 1924 | |
184bc3ca RB |
1925 | # Similar test to "hardware GW" |
1926 | AT_SETUP([ovn -- 3 HVs, 1 VIFs/HV, 1 software GW, 1 LS]) | |
1927 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1928 | ovn_start | |
1929 | ||
1930 | # Configure the Northbound database | |
1931 | ovn-nbctl ls-add lsw0 | |
1932 | ||
1933 | ovn-nbctl lsp-add lsw0 lp1 | |
1934 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
1935 | ||
1936 | ovn-nbctl lsp-add lsw0 lp2 | |
1937 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
1938 | ||
1939 | ovn-nbctl lsp-add lsw0 lp-gw | |
1940 | ovn-nbctl lsp-set-type lp-gw l2gateway | |
62b87eab | 1941 | ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw |
184bc3ca RB |
1942 | ovn-nbctl lsp-set-addresses lp-gw unknown |
1943 | ||
1944 | net_add n1 # Network to connect hv1, hv2, and gw | |
1945 | net_add n2 # Network to connect gw and hv3 | |
1946 | ||
1947 | # Create hypervisor hv1 connected to n1 | |
1948 | sim_add hv1 | |
1949 | as hv1 | |
1950 | ovs-vsctl add-br br-phys | |
1951 | ovn_attach n1 br-phys 192.168.0.1 | |
1952 | 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 | |
1953 | ||
1954 | # Create hypervisor hv2 connected to n1 | |
1955 | sim_add hv2 | |
1956 | as hv2 | |
1957 | ovs-vsctl add-br br-phys | |
1958 | ovn_attach n1 br-phys 192.168.0.2 | |
1959 | 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 | |
1960 | ||
1961 | # Create hypervisor hv_gw connected to n1 and n2 | |
1962 | # connect br-phys bridge to n1; connect hv-gw bridge to n2 | |
1963 | sim_add hv_gw | |
1964 | as hv_gw | |
1965 | ovs-vsctl add-br br-phys | |
1966 | ovn_attach n1 br-phys 192.168.0.3 | |
1967 | ovs-vsctl add-br br-phys2 | |
1968 | net_attach n2 br-phys2 | |
1969 | ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2" | |
1970 | ||
184bc3ca RB |
1971 | # Add hv3 on the other side of the GW |
1972 | sim_add hv3 | |
1973 | as hv3 | |
1974 | ovs-vsctl add-br br-phys | |
1975 | net_attach n2 br-phys | |
1976 | 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 | |
1977 | ||
1978 | ||
1979 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1980 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1981 | # for ARP resolution). | |
1982 | ovn_populate_arp | |
1983 | ||
1984 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1985 | # XXX This should be more systematic. | |
1986 | sleep 1 | |
1987 | ||
1988 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... | |
1989 | # | |
1990 | # This shell function causes a packet to be received on INPORT. The packet's | |
1991 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1992 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1993 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1994 | # OUTPORTs are specified as lport numbers, e.g. 1 for vif1. | |
184bc3ca RB |
1995 | for i in 1 2 3; do |
1996 | : > $i.expected | |
1997 | done | |
1998 | test_packet() { | |
1999 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
2000 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
2001 | hv=hv$inport | |
2002 | vif=vif$inport | |
2003 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
2004 | for outport; do | |
e4543cfe | 2005 | echo $packet >> $outport.expected |
184bc3ca RB |
2006 | done |
2007 | } | |
2008 | ||
2009 | # Send packets between all pairs of source and destination ports: | |
2010 | # | |
2011 | # 1. Unicast packets are delivered to exactly one lport (except that packets | |
2012 | # destined to their input ports are dropped). | |
2013 | # | |
2014 | # 2. Broadcast and multicast are delivered to all lports except the input port. | |
2015 | # | |
2016 | # 3. The lswitch delivers packets with an unknown destination to lports with | |
2017 | # "unknown" among their MAC addresses (and port security disabled). | |
2018 | for s in 1 2 3 ; do | |
2019 | bcast= | |
2020 | unknown= | |
2021 | for d in 1 2 3 ; do | |
2022 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2023 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
2024 | ||
2025 | # The vtep (vif3) is the only one configured for "unknown" | |
2026 | if test $d != $s && test $d = 3; then | |
2027 | unknown="$unknown $d" | |
2028 | fi | |
2029 | bcast="$bcast $unicast" | |
2030 | done | |
2031 | ||
2032 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 | |
2033 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #3 | |
2034 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #4 | |
2035 | done | |
2036 | ||
184bc3ca RB |
2037 | echo "------ ovn-nbctl show ------" |
2038 | ovn-nbctl show | |
2039 | echo "------ ovn-sbctl show ------" | |
2040 | ovn-sbctl show | |
2041 | ||
2042 | echo "------ hv1 ------" | |
2043 | as hv1 ovs-vsctl show | |
2044 | echo "------ hv1 br-int ------" | |
2045 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2046 | echo "------ hv1 br-phys ------" | |
2047 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2048 | ||
2049 | echo "------ hv2 ------" | |
2050 | as hv2 ovs-vsctl show | |
2051 | echo "------ hv2 br-int ------" | |
2052 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2053 | echo "------ hv2 br-phys ------" | |
2054 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2055 | ||
2056 | echo "------ hv_gw ------" | |
2057 | as hv_gw ovs-vsctl show | |
2058 | echo "------ hv_gw br-phys ------" | |
2059 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2060 | echo "------ hv_gw br-phys2 ------" | |
2061 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys2 | |
2062 | ||
2063 | echo "------ hv3 ------" | |
2064 | as hv3 ovs-vsctl show | |
2065 | echo "------ hv3 br-phys ------" | |
2066 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2067 | ||
2068 | # Now check the packets actually received against the ones expected. | |
2069 | for i in 1 2 3; do | |
49d7c759 | 2070 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
184bc3ca RB |
2071 | done |
2072 | AT_CLEANUP | |
2073 | ||
9975d7be BP |
2074 | # 3 hypervisors, 3 logical switches with 3 logical ports each, 1 logical router |
2075 | AT_SETUP([ovn -- 3 HVs, 3 LS, 3 lports/LS, 1 LR]) | |
2076 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2077 | ovn_start | |
2078 | ||
2079 | # Logical network: | |
2080 | # | |
2081 | # Three logical switches ls1, ls2, ls3. | |
86e98048 BP |
2082 | # One logical router lr0 connected to ls[123], |
2083 | # with nine subnets, three per logical switch: | |
2084 | # | |
2085 | # lrp11 on ls1 for subnet 192.168.11.0/24 | |
2086 | # lrp12 on ls1 for subnet 192.168.12.0/24 | |
2087 | # lrp13 on ls1 for subnet 192.168.13.0/24 | |
2088 | # ... | |
2089 | # lrp33 on ls3 for subnet 192.168.33.0/24 | |
2090 | # | |
2091 | # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two | |
2092 | # digits are the subnet and the last digit distinguishes the VIF. | |
9975d7be | 2093 | for i in 1 2 3; do |
ea46a4e9 | 2094 | ovn-nbctl ls-add ls$i |
9975d7be | 2095 | for j in 1 2 3; do |
86e98048 | 2096 | for k in 1 2 3; do |
31ed1192 JP |
2097 | # Add "unknown" to MAC addresses for lp?11, so packets for |
2098 | # MAC-IP bindings discovered via ARP later have somewhere to go. | |
2099 | if test $j$k = 11; then unknown=unknown; else unknown=; fi | |
2100 | ||
2101 | ovn-nbctl \ | |
2102 | -- lsp-add ls$i lp$i$j$k \ | |
2103 | -- lsp-set-addresses lp$i$j$k "f0:00:00:00:0$i:$j$k \ | |
2104 | 192.168.$i$j.$k" $unknown | |
86e98048 BP |
2105 | done |
2106 | done | |
2107 | done | |
2108 | ||
fa2a27b2 | 2109 | ovn-nbctl lr-add lr0 |
86e98048 BP |
2110 | for i in 1 2 3; do |
2111 | for j in 1 2 3; do | |
bf44c2cd | 2112 | ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24 |
269ecccc | 2113 | ovn-nbctl \ |
31ed1192 | 2114 | -- lsp-add ls$i lrp$i$j-attachment \ |
269ecccc | 2115 | -- set Logical_Switch_Port lrp$i$j-attachment type=router \ |
00007447 | 2116 | options:router-port=lrp$i$j \ |
86e98048 | 2117 | addresses='"00:00:00:00:ff:'$i$j'"' |
9975d7be BP |
2118 | done |
2119 | done | |
2120 | ||
80f408f4 | 2121 | ovn-nbctl set Logical_Switch_Port lrp33-attachment \ |
57d143eb HZ |
2122 | addresses='"00:00:00:00:ff:33 192.168.33.254"' |
2123 | ||
9975d7be BP |
2124 | # Physical network: |
2125 | # | |
2126 | # Three hypervisors hv[123]. | |
86e98048 BP |
2127 | # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3. |
2128 | # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3. | |
2129 | # lp?3[123] all on hv3. | |
2130 | ||
9975d7be BP |
2131 | |
2132 | # Given the name of a logical port, prints the name of the hypervisor | |
2133 | # on which it is located. | |
2134 | vif_to_hv() { | |
2135 | case $1 in dnl ( | |
86e98048 BP |
2136 | ?11) echo 1 ;; dnl ( |
2137 | ?12 | ?21 | ?22) echo 2 ;; dnl ( | |
2138 | ?13 | ?23 | ?3?) echo 3 ;; | |
9975d7be BP |
2139 | esac |
2140 | } | |
2141 | ||
86e98048 BP |
2142 | # Given the name of a logical port, prints the name of its logical router |
2143 | # port, e.g. "vif_to_lrp 123" yields 12. | |
2144 | vif_to_lrp() { | |
2145 | echo ${1%?} | |
2146 | } | |
2147 | ||
2148 | # Given the name of a logical port, prints the name of its logical | |
2149 | # switch, e.g. "vif_to_ls 123" yields 1. | |
e3393e3f | 2150 | vif_to_ls() { |
86e98048 | 2151 | echo ${1%??} |
e3393e3f BP |
2152 | } |
2153 | ||
9975d7be BP |
2154 | net_add n1 |
2155 | for i in 1 2 3; do | |
2156 | sim_add hv$i | |
2157 | as hv$i | |
2158 | ovs-vsctl add-br br-phys | |
2159 | ovn_attach n1 br-phys 192.168.0.$i | |
2160 | done | |
2161 | for i in 1 2 3; do | |
2162 | for j in 1 2 3; do | |
86e98048 | 2163 | for k in 1 2 3; do |
269ecccc JP |
2164 | hv=`vif_to_hv $i$j$k` |
2165 | as hv$hv ovs-vsctl \ | |
2166 | -- add-port br-int vif$i$j$k \ | |
2167 | -- set Interface vif$i$j$k \ | |
2168 | external-ids:iface-id=lp$i$j$k \ | |
2169 | options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \ | |
2170 | options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \ | |
2171 | ofport-request=$i$j$k | |
86e98048 | 2172 | done |
9975d7be BP |
2173 | done |
2174 | done | |
2175 | ||
2176 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2177 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2178 | # for ARP resolution). | |
2179 | ovn_populate_arp | |
2180 | ||
2181 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2182 | # XXX This should be more systematic. | |
2183 | sleep 1 | |
2184 | ||
e3393e3f | 2185 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... |
9975d7be BP |
2186 | # |
2187 | # This shell function causes a packet to be received on INPORT. The packet's | |
2188 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2189 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2190 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 2191 | # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123. |
9975d7be BP |
2192 | for i in 1 2 3; do |
2193 | for j in 1 2 3; do | |
86e98048 BP |
2194 | for k in 1 2 3; do |
2195 | : > $i$j$k.expected | |
269ecccc | 2196 | done |
9975d7be BP |
2197 | done |
2198 | done | |
e3393e3f | 2199 | test_ip() { |
9975d7be BP |
2200 | # This packet has bad checksums but logical L3 routing doesn't check. |
2201 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
ba43992e | 2202 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
9975d7be BP |
2203 | shift; shift; shift; shift; shift |
2204 | hv=hv`vif_to_hv $inport` | |
2205 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2206 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
86e98048 BP |
2207 | in_ls=`vif_to_ls $inport` |
2208 | in_lrp=`vif_to_lrp $inport` | |
9975d7be | 2209 | for outport; do |
269ecccc | 2210 | out_ls=`vif_to_ls $outport` |
86e98048 | 2211 | if test $in_ls = $out_ls; then |
9975d7be BP |
2212 | # Ports on the same logical switch receive exactly the same packet. |
2213 | echo $packet | |
2214 | else | |
2215 | # Routing decrements TTL and updates source and dest MAC | |
2216 | # (and checksum). | |
269ecccc | 2217 | out_lrp=`vif_to_lrp $outport` |
86e98048 | 2218 | echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 |
e4543cfe | 2219 | fi >> $outport.expected |
9975d7be BP |
2220 | done |
2221 | } | |
2222 | ||
e3393e3f | 2223 | as hv1 ovs-vsctl --columns=name,ofport list interface |
0bac7164 BP |
2224 | as hv1 ovn-sbctl list port_binding |
2225 | as hv1 ovn-sbctl list datapath_binding | |
9975d7be BP |
2226 | as hv1 ovn-sbctl dump-flows |
2227 | as hv1 ovs-ofctl dump-flows br-int | |
2228 | ||
e3393e3f | 2229 | # Send IP packets between all pairs of source and destination ports: |
9975d7be | 2230 | # |
31ed1192 JP |
2231 | # 1. Unicast IP packets are delivered to exactly one logical switch port |
2232 | # (except that packets destined to their input ports are dropped). | |
9975d7be | 2233 | # |
31ed1192 JP |
2234 | # 2. Broadcast IP packets are delivered to all logical switch ports |
2235 | # except the input port. | |
86e98048 BP |
2236 | ip_to_hex() { |
2237 | printf "%02x%02x%02x%02x" "$@" | |
2238 | } | |
9975d7be | 2239 | for is in 1 2 3; do |
269ecccc JP |
2240 | for js in 1 2 3; do |
2241 | for ks in 1 2 3; do | |
2242 | bcast= | |
2243 | s=$is$js$ks | |
2244 | smac=f00000000$s | |
2245 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2246 | for id in 1 2 3; do | |
2247 | for jd in 1 2 3; do | |
2248 | for kd in 1 2 3; do | |
2249 | d=$id$jd$kd | |
2250 | dip=`ip_to_hex 192 168 $id$jd $kd` | |
2251 | if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi | |
2252 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2253 | ||
2254 | test_ip $s $smac $dmac $sip $dip $unicast #1 | |
2255 | ||
2256 | if test $id = $is && test $d != $s; then bcast="$bcast $d"; fi | |
2257 | done | |
2258 | done | |
9975d7be | 2259 | done |
269ecccc JP |
2260 | test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2 |
2261 | done | |
2262 | done | |
e3393e3f BP |
2263 | done |
2264 | ||
0bac7164 BP |
2265 | # 3. Send an IP packet from every logical port to every other subnet, |
2266 | # to an IP address that does not have a static IP-MAC binding. | |
2267 | # This should generate a broadcast ARP request for the destination | |
2268 | # IP address in the destination subnet. | |
2269 | for is in 1 2 3; do | |
269ecccc JP |
2270 | for js in 1 2 3; do |
2271 | for ks in 1 2 3; do | |
2272 | s=$is$js$ks | |
2273 | smac=f00000000$s | |
2274 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2275 | for id in 1 2 3; do | |
2276 | for jd in 1 2 3; do | |
2277 | if test $is$js = $id$jd; then | |
2278 | continue | |
2279 | fi | |
2280 | ||
2281 | # Send the packet. | |
2282 | dmac=00000000ff$is$js | |
2283 | # Calculate a 4th octet for the destination that is | |
2284 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2285 | # that have static MAC bindings, and fits in the range | |
2286 | # 0-255. | |
2287 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2288 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2289 | test_ip $s $smac $dmac $sip $dip | |
2290 | ||
2291 | # Every LP on the destination subnet's lswitch should | |
2292 | # receive the ARP request. | |
2293 | lrmac=00000000ff$id$jd | |
2294 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2295 | arp=ffffffffffff${lrmac}08060001080006040001${lrmac}${lrip}000000000000${dip} | |
2296 | for jd2 in 1 2 3; do | |
2297 | for kd in 1 2 3; do | |
e4543cfe | 2298 | echo $arp >> $id$jd2$kd.expected |
0bac7164 | 2299 | done |
269ecccc | 2300 | done |
0bac7164 | 2301 | done |
269ecccc | 2302 | done |
0bac7164 | 2303 | done |
269ecccc | 2304 | done |
0bac7164 BP |
2305 | done |
2306 | ||
e3393e3f BP |
2307 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
2308 | # | |
2309 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2310 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2311 | # it should be the hardware address of the target to expect to receive in an | |
2312 | # ARP reply; otherwise no reply is expected. | |
2313 | # | |
31ed1192 | 2314 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
e3393e3f BP |
2315 | # SHA and REPLY_HA are each 12 hex digits. |
2316 | # SPA and TPA are each 8 hex digits. | |
2317 | test_arp() { | |
2318 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
2319 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2320 | hv=hv`vif_to_hv $inport` | |
2321 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2d9b49dd | 2322 | as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request |
e3393e3f | 2323 | |
57d143eb | 2324 | # Expect to receive the broadcast ARP on the other logical switch ports if |
ea46a4e9 | 2325 | # IP address is not configured to the switch patch port. |
e3393e3f | 2326 | local i=`vif_to_ls $inport` |
86e98048 | 2327 | local j k |
e3393e3f | 2328 | for j in 1 2 3; do |
86e98048 | 2329 | for k in 1 2 3; do |
ea46a4e9 | 2330 | # 192.168.33.254 is configured to the switch patch port for lrp33, |
57d143eb HZ |
2331 | # so no ARP flooding expected for it. |
2332 | if test $i$j$k != $inport && test $tpa != `ip_to_hex 192 168 33 254`; then | |
86e98048 BP |
2333 | echo $request >> $i$j$k.expected |
2334 | fi | |
2335 | done | |
e3393e3f BP |
2336 | done |
2337 | ||
2338 | # Expect to receive the reply, if any. | |
2339 | if test X$reply_ha != X; then | |
86e98048 BP |
2340 | lrp=`vif_to_lrp $inport` |
2341 | local reply=${sha}00000000ff${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
e3393e3f BP |
2342 | echo $reply >> $inport.expected |
2343 | fi | |
2344 | } | |
2345 | ||
2346 | # Test router replies to ARP requests from all source ports: | |
2347 | # | |
0bac7164 | 2348 | # 4. Router replies to query for its MAC address from port's own IP address. |
e3393e3f | 2349 | # |
0bac7164 | 2350 | # 5. Router replies to query for its MAC address from any random IP address |
e3393e3f BP |
2351 | # in its subnet. |
2352 | # | |
0bac7164 | 2353 | # 6. Router replies to query for its MAC address from another subnet. |
e3393e3f | 2354 | # |
0bac7164 | 2355 | # 7. No reply to query for IP address other than router IP. |
e3393e3f | 2356 | for i in 1 2 3; do |
269ecccc JP |
2357 | for j in 1 2 3; do |
2358 | for k in 1 2 3; do | |
2359 | smac=f00000000$i$j$k # Source MAC | |
2360 | sip=`ip_to_hex 192 168 $i$j $k` # Source IP | |
2361 | rip=`ip_to_hex 192 168 $i$j 254` # Router IP | |
2362 | rmac=00000000ff$i$j # Router MAC | |
2363 | otherip=`ip_to_hex 192 168 $i$j 55` # Some other IP in subnet | |
2364 | test_arp $i$j$k $smac $sip $rip $rmac #4 | |
2365 | test_arp $i$j$k $smac $otherip $rip $rmac #5 | |
2366 | test_arp $i$j$k $smac 0a123456 $rip $rmac #6 | |
2367 | test_arp $i$j$k $smac $sip $otherip #7 | |
0bac7164 | 2368 | done |
269ecccc | 2369 | done |
0bac7164 BP |
2370 | done |
2371 | ||
2372 | # Allow some time for packet forwarding. | |
2373 | # XXX This can be improved. | |
2374 | sleep 1 | |
2375 | ||
2376 | # 8. Generate an ARP reply for each of the IP addresses ARPed for | |
2377 | # earlier as #3. | |
2378 | # | |
2379 | # Here, the $s is the VIF that originated the ARP request and $d is | |
2380 | # the VIF that sends the ARP reply, which is somewhat backward but | |
2381 | # it means that $s and $d are the same as #3. | |
2382 | : > mac_bindings.expected | |
2383 | for is in 1 2 3; do | |
269ecccc JP |
2384 | for js in 1 2 3; do |
2385 | for ks in 1 2 3; do | |
2386 | s=$is$js$ks | |
2387 | for id in 1 2 3; do | |
2388 | for jd in 1 2 3; do | |
2389 | if test $is$js = $id$jd; then | |
2390 | continue | |
2391 | fi | |
2392 | ||
2393 | kd=1 | |
2394 | d=$id$jd$kd | |
2395 | ||
2396 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2397 | host_ip=`ip_to_hex 192 168 $id$jd $o4` | |
2398 | host_mac=8000000000$o4 | |
2399 | ||
2400 | lrmac=00000000ff$id$jd | |
2401 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2402 | ||
2403 | arp=${lrmac}${host_mac}08060001080006040002${host_mac}${host_ip}${lrmac}${lrip} | |
2404 | ||
2405 | echo | |
2406 | echo | |
2407 | echo | |
2408 | hv=hv`vif_to_hv $d` | |
2409 | as $hv ovs-appctl netdev-dummy/receive vif$d $arp | |
2410 | #as $hv ovs-appctl ofproto/trace br-int in_port=$d $arp | |
2411 | #as $hv ovs-ofctl dump-flows br-int table=19 | |
2412 | ||
2413 | host_ip_pretty=192.168.$id$jd.$o4 | |
2414 | host_mac_pretty=80:00:00:00:00:$o4 | |
2415 | echo lrp$id$jd,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected | |
86e98048 | 2416 | done |
269ecccc | 2417 | done |
9975d7be | 2418 | done |
269ecccc | 2419 | done |
9975d7be | 2420 | done |
0bac7164 | 2421 | |
9975d7be BP |
2422 | # Allow some time for packet forwarding. |
2423 | # XXX This can be improved. | |
2424 | sleep 1 | |
2425 | ||
0bac7164 BP |
2426 | # 9. Send an IP packet from every logical port to every other subnet. These |
2427 | # are the same packets already sent as #3, but now the destinations' IP-MAC | |
2428 | # bindings have been discovered via ARP, so instead of provoking an ARP | |
2429 | # request, these packets now get routed to their destinations (which don't | |
2430 | # have static MAC bindings, so they go to the port we've designated as | |
2431 | # accepting "unknown" MACs.) | |
2432 | for is in 1 2 3; do | |
269ecccc JP |
2433 | for js in 1 2 3; do |
2434 | for ks in 1 2 3; do | |
2435 | s=$is$js$ks | |
2436 | smac=f00000000$s | |
2437 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2438 | for id in 1 2 3; do | |
2439 | for jd in 1 2 3; do | |
2440 | if test $is$js = $id$jd; then | |
2441 | continue | |
2442 | fi | |
2443 | ||
2444 | # Send the packet. | |
2445 | dmac=00000000ff$is$js | |
2446 | # Calculate a 4th octet for the destination that is | |
2447 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2448 | # that have static MAC bindings, and fits in the range | |
2449 | # 0-255. | |
2450 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2451 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2452 | test_ip $s $smac $dmac $sip $dip | |
2453 | ||
2454 | # Expect the packet egress. | |
2455 | host_mac=8000000000$o4 | |
2456 | outport=${id}11 | |
2457 | out_lrp=$id$jd | |
e4543cfe | 2458 | echo ${host_mac}00000000ff${out_lrp}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 >> $outport.expected |
0bac7164 | 2459 | done |
269ecccc | 2460 | done |
0bac7164 | 2461 | done |
269ecccc | 2462 | done |
0bac7164 BP |
2463 | done |
2464 | ||
0bac7164 BP |
2465 | ovn-sbctl -f csv -d bare --no-heading \ |
2466 | -- --columns=logical_port,ip,mac list mac_binding > mac_bindings | |
2467 | ||
9975d7be BP |
2468 | # Now check the packets actually received against the ones expected. |
2469 | for i in 1 2 3; do | |
2470 | for j in 1 2 3; do | |
86e98048 | 2471 | for k in 1 2 3; do |
abb37b6b FF |
2472 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap], |
2473 | [$i$j$k.expected]) | |
86e98048 | 2474 | done |
9975d7be BP |
2475 | done |
2476 | done | |
fcde56f5 | 2477 | |
0bac7164 BP |
2478 | # Check the MAC bindings against those expected. |
2479 | AT_CHECK_UNQUOTED([sort < mac_bindings], [0], [`sort < mac_bindings.expected` | |
2480 | ]) | |
2481 | ||
fcde56f5 | 2482 | # Gracefully terminate daemons |
7a8f15e0 | 2483 | OVN_CLEANUP([hv1], [hv2], [hv3]) |
eff49a56 | 2484 | |
9975d7be | 2485 | AT_CLEANUP |
685f4dfe NS |
2486 | |
2487 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor | |
2488 | AT_SETUP([ovn -- portsecurity : 3 HVs, 1 LS, 3 lports/HV]) | |
685f4dfe NS |
2489 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
2490 | ovn_start | |
2491 | ||
2492 | # Create hypervisors hv[123]. | |
2493 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. | |
2494 | # Add all of the vifs to a single logical switch lsw0. | |
2495 | # Turn off port security on vifs vif[123]1 | |
2496 | # Turn on l2 port security on vifs vif[123]2 | |
2497 | # Turn of l2 and l3 port security on vifs vif[123]3 | |
2498 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
ea46a4e9 | 2499 | ovn-nbctl ls-add lsw0 |
685f4dfe NS |
2500 | net_add n1 |
2501 | for i in 1 2 3; do | |
2502 | sim_add hv$i | |
2503 | as hv$i | |
2504 | ovs-vsctl add-br br-phys | |
2505 | ovn_attach n1 br-phys 192.168.0.$i | |
2506 | ||
2507 | for j in 1 2 3; do | |
2508 | 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 | 2509 | ovn-nbctl lsp-add lsw0 lp$i$j |
685f4dfe | 2510 | if test $j = 1; then |
31ed1192 | 2511 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
685f4dfe | 2512 | elif test $j = 2; then |
31ed1192 JP |
2513 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" |
2514 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
685f4dfe NS |
2515 | else |
2516 | extra_addr="f0:00:00:00:0$i:$i$j fe80::ea2a:eaff:fe28:$i$j" | |
31ed1192 JP |
2517 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr" |
2518 | 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 |
2519 | fi |
2520 | done | |
2521 | done | |
2522 | ||
685f4dfe NS |
2523 | # Pre-populate the hypervisors' ARP tables so that we don't lose any |
2524 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2525 | # for ARP resolution). | |
2526 | ovn_populate_arp | |
2527 | ||
2528 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2529 | # XXX This should be more systematic. | |
2530 | sleep 1 | |
685f4dfe NS |
2531 | |
2532 | # Given the name of a logical port, prints the name of the hypervisor | |
2533 | # on which it is located. | |
2534 | vif_to_hv() { | |
2535 | echo hv${1%?} | |
2536 | } | |
2537 | ||
685f4dfe NS |
2538 | for i in 1 2 3; do |
2539 | for j in 1 2 3; do | |
2540 | : > $i$j.expected | |
2541 | done | |
2542 | done | |
2543 | ||
2544 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
2545 | # | |
2546 | # This shell function causes an ip packet to be received on INPORT. | |
2547 | # The packet's content has Ethernet destination DST and source SRC | |
2548 | # (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits). | |
2549 | # The OUTPORTs (zero or more) list the VIFs on which the packet should | |
31ed1192 JP |
2550 | # be received. INPORT and the OUTPORTs are specified as logical switch |
2551 | # port numbers, e.g. 11 for vif11. | |
685f4dfe NS |
2552 | test_ip() { |
2553 | # This packet has bad checksums but logical L3 routing doesn't check. | |
2554 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
efe179e0 | 2555 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
685f4dfe NS |
2556 | shift; shift; shift; shift; shift |
2557 | hv=`vif_to_hv $inport` | |
2558 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2559 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2560 | for outport; do | |
e4543cfe | 2561 | echo $packet >> $outport.expected |
685f4dfe NS |
2562 | done |
2563 | } | |
2564 | ||
2565 | # test_arp INPORT SHA SPA TPA DROP [REPLY_HA] | |
2566 | # | |
2567 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2568 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2569 | # it should be the hardware address of the target to expect to receive in an | |
2570 | # ARP reply; otherwise no reply is expected. | |
2571 | # | |
31ed1192 | 2572 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
685f4dfe NS |
2573 | # SHA and REPLY_HA are each 12 hex digits. |
2574 | # SPA and TPA are each 8 hex digits. | |
2575 | test_arp() { | |
2576 | local inport=$1 smac=$2 sha=$3 spa=$4 tpa=$5 drop=$6 reply_ha=$7 | |
2577 | local request=ffffffffffff${smac}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2578 | hv=`vif_to_hv $inport` | |
2579 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2580 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request | |
2581 | if test $drop != 1; then | |
e137131a | 2582 | if test X$reply_ha = X; then |
685f4dfe NS |
2583 | # Expect to receive the broadcast ARP on the other logical switch ports |
2584 | # if no reply is expected. | |
2585 | local i j | |
2586 | for i in 1 2 3; do | |
2587 | for j in 1 2 3; do | |
2588 | if test $i$j != $inport; then | |
2589 | echo $request >> $i$j.expected | |
2590 | fi | |
2591 | done | |
2592 | done | |
2593 | else | |
2594 | # Expect to receive the reply, if any. | |
2595 | local reply=${smac}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
2596 | echo $reply >> $inport.expected | |
2597 | fi | |
2598 | fi | |
2599 | } | |
2600 | ||
2601 | # test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
2602 | # This function is similar to test_ip() except that it sends | |
2603 | # ipv6 packet | |
2604 | test_ipv6() { | |
2605 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
2606 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}0000000000000000 | |
2607 | shift; shift; shift; shift; shift | |
2608 | hv=`vif_to_hv $inport` | |
2609 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2610 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2611 | for outport; do | |
e4543cfe | 2612 | echo $packet >> $outport.expected |
685f4dfe NS |
2613 | done |
2614 | } | |
2615 | ||
9e687b23 DL |
2616 | # test_icmpv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT... |
2617 | # This function is similar to test_ipv6() except it specifies the ICMPv6 type | |
2618 | # of the test packet | |
2619 | test_icmpv6() { | |
2620 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6 | |
2621 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}${icmp_type}00000000000000 | |
2622 | shift; shift; shift; shift; shift; shift | |
2623 | hv=`vif_to_hv $inport` | |
2624 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2625 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2626 | for outport; do | |
e4543cfe | 2627 | echo $packet >> $outport.expected |
9e687b23 DL |
2628 | done |
2629 | } | |
2630 | ||
685f4dfe NS |
2631 | ip_to_hex() { |
2632 | printf "%02x%02x%02x%02x" "$@" | |
2633 | } | |
2634 | ||
2635 | # no port security | |
2636 | sip=`ip_to_hex 192 168 0 12` | |
2637 | tip=`ip_to_hex 192 168 0 13` | |
2638 | # the arp packet should be allowed even if lp[123]1 is | |
2639 | # not configured with mac f00000000023 and ip 192.168.0.12 | |
2640 | for i in 1 2 3; do | |
2641 | test_arp ${i}1 f00000000023 f00000000023 $sip $tip 0 f00000000013 | |
2642 | for j in 1 2 3; do | |
2643 | if test $i != $j; then | |
2644 | test_ip ${i}1 f000000000${i}1 f000000000${j}1 $sip $tip ${j}1 | |
2645 | fi | |
2646 | done | |
2647 | done | |
2648 | ||
2649 | # l2 port security | |
2650 | sip=`ip_to_hex 192 168 0 12` | |
2651 | tip=`ip_to_hex 192 168 0 13` | |
2652 | ||
2653 | # arp packet should be allowed since lp22 is configured with | |
2654 | # mac f00000000022 | |
2655 | test_arp 22 f00000000022 f00000000022 $sip $tip 0 f00000000013 | |
2656 | ||
2657 | # arp packet should not be allowed since lp32 is not configured with | |
2658 | # mac f00000000021 | |
2659 | test_arp 32 f00000000021 f00000000021 $sip $tip 1 | |
2660 | ||
2661 | # arp packet with sha set to f00000000021 should not be allowed | |
2662 | # for lp12 | |
2663 | test_arp 12 f00000000012 f00000000021 $sip $tip 1 | |
2664 | ||
2665 | # ip packets should be allowed and received since lp[123]2 do not | |
2666 | # have l3 port security | |
2667 | sip=`ip_to_hex 192 168 0 55` | |
2668 | tip=`ip_to_hex 192 168 0 66` | |
2669 | for i in 1 2 3; do | |
2670 | for j in 1 2 3; do | |
2671 | if test $i != $j; then | |
2672 | test_ip ${i}2 f000000000${i}2 f000000000${j}2 $sip $tip ${j}2 | |
2673 | fi | |
2674 | done | |
2675 | done | |
2676 | ||
2677 | # ipv6 packets should be received by lp[123]2 | |
2678 | # lp[123]1 can send ipv6 traffic as there is no port security | |
2679 | sip=fe800000000000000000000000000000 | |
2680 | tip=ff020000000000000000000000000000 | |
2681 | ||
2682 | for i in 1 2 3; do | |
2683 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}2 $sip $tip ${i}2 | |
2684 | done | |
2685 | ||
2686 | ||
2687 | # l2 and l3 port security | |
2688 | sip=`ip_to_hex 192 168 0 13` | |
2689 | tip=`ip_to_hex 192 168 0 22` | |
2690 | # arp packet should be allowed since lp13 is configured with | |
2691 | # f00000000013 and 192.168.0.13 | |
2692 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 | |
2693 | ||
2694 | # the arp packet should be dropped because lp23 is not configured | |
2695 | # with mac f00000000022 | |
2696 | sip=`ip_to_hex 192 168 0 13` | |
2697 | tip=`ip_to_hex 192 168 0 22` | |
2698 | test_arp 23 f00000000022 f00000000022 $sip $tip 1 | |
2699 | ||
2700 | # the arp packet should be dropped because lp33 is not configured | |
2701 | # with ip 192.168.0.55 | |
2702 | spa=`ip_to_hex 192 168 0 55` | |
2703 | tpa=`ip_to_hex 192 168 0 22` | |
2704 | test_arp 33 f00000000031 f00000000031 $spa $tpa 1 | |
2705 | ||
2706 | # ip packets should not be received by lp[123]3 since | |
2707 | # l3 port security is enabled | |
2708 | sip=`ip_to_hex 192 168 0 55` | |
2709 | tip=`ip_to_hex 192 168 0 66` | |
2710 | for i in 1 2 3; do | |
2711 | for j in 1 2 3; do | |
2712 | test_ip ${i}2 f000000000${i}2 f000000000${j}3 $sip $tip | |
2713 | done | |
2714 | done | |
2715 | ||
2716 | # ipv6 packets should be dropped for lp[123]3 since | |
2717 | # it is configured with only ipv4 address | |
2718 | sip=fe800000000000000000000000000000 | |
2719 | tip=ff020000000000000000000000000000 | |
2720 | ||
2721 | for i in 1 2 3; do | |
2722 | test_ipv6 ${i}3 f000000000${i}3 f00000000022 $sip $tip | |
2723 | done | |
2724 | ||
2725 | # ipv6 packets should not be received by lp[123]3 with mac f000000000$[123]3 | |
2726 | # lp[123]1 can send ipv6 traffic as there is no port security | |
2727 | for i in 1 2 3; do | |
2728 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}3 $sip $tip | |
2729 | done | |
2730 | ||
2731 | # lp13 has extra port security with mac f0000000113 and ipv6 addr | |
2732 | # fe80::ea2a:eaff:fe28:0012 | |
2733 | ||
2734 | # ipv4 packet should be dropped for lp13 with mac f0000000113 | |
2735 | sip=`ip_to_hex 192 168 0 13` | |
2736 | tip=`ip_to_hex 192 168 0 23` | |
2737 | test_ip 13 f00000000113 f00000000023 $sip $tip | |
2738 | ||
6d53e8a9 BP |
2739 | # ipv6 packet should be received by lp[123]3 with mac f00000000${i}${i}3 |
2740 | # and ip6.dst as fe80::ea2a:eaff:fe28:0${i}${i}3. | |
685f4dfe NS |
2741 | # lp11 can send ipv6 traffic as there is no port security |
2742 | sip=ee800000000000000000000000000000 | |
2743 | for i in 1 2 3; do | |
6d53e8a9 BP |
2744 | tip=fe80000000000000ea2aeafffe2800${i}3 |
2745 | test_ipv6 11 f00000000011 f00000000${i}${i}3 $sip $tip ${i}3 | |
685f4dfe NS |
2746 | done |
2747 | ||
2748 | ||
2749 | # ipv6 packet should not be received by lp33 with mac f0000000333 | |
2750 | # and ip6.dst as fe80::ea2a:eaff:fe28:0023 as it is | |
2751 | # configured with fe80::ea2a:eaff:fe28:0033 | |
2752 | # lp11 can send ipv6 traffic as there is no port security | |
2753 | ||
2754 | sip=ee800000000000000000000000000000 | |
2755 | tip=fe80000000000000ea2aeafffe280023 | |
2756 | test_ipv6 11 f00000000011 f00000000333 $sip $tip | |
2757 | ||
6d53e8a9 BP |
2758 | # ipv6 packet should be allowed for lp[123]3 with mac f0000000${i}${i}3 |
2759 | # and ip6.src fe80::ea2a:eaff:fe28:0${i}${i}3 and ip6.src ::. | |
685f4dfe NS |
2760 | # and should be dropped for any other ip6.src |
2761 | # lp21 can receive ipv6 traffic as there is no port security | |
2762 | ||
2763 | tip=ee800000000000000000000000000000 | |
2764 | for i in 1 2 3; do | |
2765 | sip=fe80000000000000ea2aeafffe2800${i}3 | |
2766 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 21 | |
2767 | ||
9e687b23 | 2768 | # Test ICMPv6 MLD reports (v1 and v2) and NS for DAD |
685f4dfe | 2769 | sip=00000000000000000000000000000000 |
9e687b23 DL |
2770 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 83 21 |
2771 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 8f 21 | |
2772 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff0200000000000000ea2aeafffe2800 87 21 | |
2773 | # Traffic to non-multicast traffic should be dropped | |
2774 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 83 | |
2775 | # Traffic of other ICMPv6 types should be dropped | |
2776 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 80 | |
685f4dfe NS |
2777 | |
2778 | # should be dropped | |
2779 | sip=ae80000000000000ea2aeafffe2800aa | |
2780 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip | |
2781 | done | |
2782 | ||
31ed1192 JP |
2783 | # configure lsp13 to send and received IPv4 packets with an address range |
2784 | 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 | 2785 | |
8ff5a966 NS |
2786 | sleep 2 |
2787 | ||
7d9d86ad NS |
2788 | sip=`ip_to_hex 10 0 0 13` |
2789 | tip=`ip_to_hex 192 168 0 22` | |
31ed1192 | 2790 | # arp packet with inner ip 10.0.0.13 should be allowed for lsp13 |
7d9d86ad NS |
2791 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 |
2792 | ||
2793 | sip=`ip_to_hex 10 0 0 14` | |
2794 | tip=`ip_to_hex 192 168 0 23` | |
31ed1192 | 2795 | # IPv4 packet from lsp13 with src ip 10.0.0.14 destined to lsp23 |
7d9d86ad NS |
2796 | # with dst ip 192.168.0.23 should be allowed |
2797 | test_ip 13 f00000000013 f00000000023 $sip $tip 23 | |
2798 | ||
2799 | sip=`ip_to_hex 192 168 0 33` | |
2800 | tip=`ip_to_hex 10 0 0 15` | |
31ed1192 JP |
2801 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2802 | # with dst ip 10.0.0.15 should be received by lsp13 | |
7d9d86ad NS |
2803 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2804 | ||
2805 | sip=`ip_to_hex 192 168 0 33` | |
2806 | tip=`ip_to_hex 20 0 0 4` | |
31ed1192 JP |
2807 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2808 | # with dst ip 20.0.0.4 should be received by lsp13 | |
7d9d86ad NS |
2809 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2810 | ||
2811 | sip=`ip_to_hex 192 168 0 33` | |
2812 | tip=`ip_to_hex 20 0 0 5` | |
31ed1192 JP |
2813 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2814 | # with dst ip 20.0.0.5 should not be received by lsp13 | |
7d9d86ad NS |
2815 | test_ip 33 f00000000033 f00000000013 $sip $tip |
2816 | ||
2817 | sip=`ip_to_hex 192 168 0 33` | |
2818 | tip=`ip_to_hex 20 0 0 255` | |
31ed1192 JP |
2819 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2820 | # with dst ip 20.0.0.255 should be received by lsp13 | |
7d9d86ad NS |
2821 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2822 | ||
2823 | sip=`ip_to_hex 192 168 0 33` | |
2824 | tip=`ip_to_hex 192 168 0 255` | |
31ed1192 JP |
2825 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2826 | # with dst ip 192.168.0.255 should not be received by lsp13 | |
7d9d86ad NS |
2827 | test_ip 33 f00000000033 f00000000013 $sip $tip |
2828 | ||
2829 | sip=`ip_to_hex 192 168 0 33` | |
2830 | tip=`ip_to_hex 224 0 0 4` | |
31ed1192 JP |
2831 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2832 | # with dst ip 224.0.0.4 should be received by lsp13 | |
7d9d86ad | 2833 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
685f4dfe | 2834 | |
bb0c41d3 RM |
2835 | #dump information including flow counters |
2836 | ovn-nbctl show | |
2837 | ovn-sbctl dump-flows -- list multicast_group | |
2838 | ||
2839 | echo "------ hv1 dump ------" | |
2840 | as hv1 ovs-vsctl show | |
6195e2e7 | 2841 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2842 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2843 | ||
2844 | echo "------ hv2 dump ------" | |
2845 | as hv2 ovs-vsctl show | |
6195e2e7 | 2846 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2847 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2848 | ||
2849 | echo "------ hv3 dump ------" | |
2850 | as hv3 ovs-vsctl show | |
6195e2e7 | 2851 | as hv3 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2852 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2853 | ||
685f4dfe NS |
2854 | # Now check the packets actually received against the ones expected. |
2855 | for i in 1 2 3; do | |
2856 | for j in 1 2 3; do | |
49d7c759 | 2857 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
685f4dfe NS |
2858 | done |
2859 | done | |
2860 | ||
7a8f15e0 | 2861 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 2862 | |
685f4dfe | 2863 | AT_CLEANUP |
509afdc3 GS |
2864 | |
2865 | AT_SETUP([ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs]) | |
509afdc3 GS |
2866 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
2867 | ovn_start | |
2868 | ||
2869 | # Logical network: | |
2870 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
2871 | # network. R1 has a switchs ls1 (191.168.1.0/24) connected to it. | |
2872 | # R2 has ls2 (172.16.1.0/24) connected to it. | |
2873 | ||
3c1ae70a JP |
2874 | ls1_lp1_mac="f0:00:00:01:02:03" |
2875 | rp_ls1_mac="00:00:00:01:02:03" | |
2876 | rp_ls2_mac="00:00:00:01:02:04" | |
2877 | ls2_lp1_mac="f0:00:00:01:02:04" | |
2878 | ||
2879 | ls1_lp1_ip="192.168.1.2" | |
2880 | ls2_lp1_ip="172.16.1.2" | |
2881 | ||
fa2a27b2 JP |
2882 | ovn-nbctl lr-add R1 |
2883 | ovn-nbctl lr-add R2 | |
509afdc3 | 2884 | |
ea46a4e9 JP |
2885 | ovn-nbctl ls-add ls1 |
2886 | ovn-nbctl ls-add ls2 | |
509afdc3 GS |
2887 | |
2888 | # Connect ls1 to R1 | |
3c1ae70a | 2889 | ovn-nbctl lrp-add R1 ls1 $rp_ls1_mac 192.168.1.1/24 |
509afdc3 | 2890 | |
31ed1192 | 2891 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
3c1ae70a | 2892 | options:router-port=ls1 addresses=\"$rp_ls1_mac\" |
509afdc3 GS |
2893 | |
2894 | # Connect ls2 to R2 | |
3c1ae70a | 2895 | ovn-nbctl lrp-add R2 ls2 $rp_ls2_mac 172.16.1.1/24 |
509afdc3 | 2896 | |
31ed1192 | 2897 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
3c1ae70a | 2898 | options:router-port=ls2 addresses=\"$rp_ls2_mac\" |
509afdc3 GS |
2899 | |
2900 | # Connect R1 to R2 | |
4685e523 JP |
2901 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
2902 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
509afdc3 | 2903 | |
6d9ecfa9 JP |
2904 | ovn-nbctl lr-route-add R1 "0.0.0.0/0" 20.0.0.2 |
2905 | ovn-nbctl lr-route-add R2 "0.0.0.0/0" 20.0.0.1 | |
509afdc3 GS |
2906 | |
2907 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 | 2908 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3c1ae70a | 2909 | -- lsp-set-addresses ls1-lp1 "$ls1_lp1_mac $ls1_lp1_ip" |
509afdc3 GS |
2910 | |
2911 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 | 2912 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3c1ae70a | 2913 | -- lsp-set-addresses ls2-lp1 "$ls2_lp1_mac $ls2_lp1_ip" |
509afdc3 GS |
2914 | |
2915 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
2916 | net_add n1 | |
2917 | ||
2918 | sim_add hv1 | |
2919 | as hv1 | |
2920 | ovs-vsctl add-br br-phys | |
2921 | ovn_attach n1 br-phys 192.168.0.1 | |
2922 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
2923 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
2924 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
2925 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
2926 | ofport-request=1 | |
2927 | ||
2928 | sim_add hv2 | |
2929 | as hv2 | |
2930 | ovs-vsctl add-br br-phys | |
2931 | ovn_attach n1 br-phys 192.168.0.2 | |
2932 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
2933 | set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \ | |
2934 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
2935 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
2936 | ofport-request=1 | |
2937 | ||
2938 | ||
2939 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2940 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2941 | # for ARP resolution). | |
2942 | ovn_populate_arp | |
2943 | ||
2944 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2945 | # XXX This should be more systematic. | |
2946 | sleep 1 | |
2947 | ||
509afdc3 | 2948 | # Packet to send. |
3c1ae70a JP |
2949 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_lp1_mac && eth.dst==$rp_ls1_mac && |
2950 | ip4 && ip.ttl==64 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
2951 | udp && udp.src==53 && udp.dst==4369" | |
2952 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
509afdc3 GS |
2953 | |
2954 | ||
2955 | echo "---------NB dump-----" | |
2956 | ovn-nbctl show | |
2957 | echo "---------------------" | |
2958 | ovn-nbctl list logical_router | |
2959 | echo "---------------------" | |
2960 | ovn-nbctl list logical_router_port | |
2961 | echo "---------------------" | |
2962 | ||
2963 | echo "---------SB dump-----" | |
2964 | ovn-sbctl list datapath_binding | |
2965 | echo "---------------------" | |
2966 | ovn-sbctl list port_binding | |
2967 | echo "---------------------" | |
2968 | ||
2969 | echo "------ hv1 dump ----------" | |
8dab1022 | 2970 | as hv1 ovs-ofctl show br-int |
509afdc3 GS |
2971 | as hv1 ovs-ofctl dump-flows br-int |
2972 | echo "------ hv2 dump ----------" | |
8dab1022 | 2973 | as hv2 ovs-ofctl show br-int |
509afdc3 GS |
2974 | as hv2 ovs-ofctl dump-flows br-int |
2975 | ||
2976 | # Packet to Expect | |
3c1ae70a JP |
2977 | # The TTL should be decremented by 2. |
2978 | packet="eth.src==$rp_ls2_mac && eth.dst==$ls2_lp1_mac && | |
2979 | ip4 && ip.ttl==62 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
2980 | udp && udp.src==53 && udp.dst==4369" | |
2981 | echo $packet | ovstest test-ovn expr-to-packets > expected | |
509afdc3 | 2982 | |
49d7c759 | 2983 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
509afdc3 | 2984 | |
7a8f15e0 | 2985 | OVN_CLEANUP([hv1],[hv2]) |
509afdc3 GS |
2986 | |
2987 | AT_CLEANUP | |
5412db30 J |
2988 | |
2989 | ||
4685e523 JP |
2990 | AT_SETUP([ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR]) |
2991 | AT_KEYWORDS([router-admin-state]) | |
2992 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2993 | ovn_start | |
2994 | ||
2995 | # Logical network: | |
2996 | # One LR - R1 has switch ls1 with two subnets attached to it (191.168.1.0/24 | |
2997 | # and 172.16.1.0/24) connected to it. | |
2998 | ||
2999 | ovn-nbctl lr-add R1 | |
3000 | ||
3001 | ovn-nbctl ls-add ls1 | |
3002 | ||
3003 | # Connect ls1 to R1 | |
bf44c2cd | 3004 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 172.16.1.1/24 |
4685e523 JP |
3005 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
3006 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" | |
3007 | ||
3008 | # Create logical port ls1-lp1 in ls1 | |
3009 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3010 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
3011 | ||
3012 | # Create logical port ls1-lp2 in ls1 | |
3013 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3014 | -- lsp-set-addresses ls1-lp2 "f0:00:00:01:02:04 172.16.1.2" | |
3015 | ||
3016 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3017 | net_add n1 | |
3018 | ||
3019 | sim_add hv1 | |
3020 | as hv1 | |
3021 | ovs-vsctl add-br br-phys | |
3022 | ovn_attach n1 br-phys 192.168.0.1 | |
3023 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3024 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3025 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3026 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3027 | ofport-request=1 | |
3028 | ||
3029 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3030 | set interface vif2 external-ids:iface-id=ls1-lp2 \ | |
3031 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3032 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3033 | ofport-request=1 | |
3034 | ||
3035 | ||
3036 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3037 | # XXX This should be more systematic. | |
3038 | sleep 1 | |
3039 | ||
3040 | # Send ip packets between the two ports. | |
3041 | ip_to_hex() { | |
3042 | printf "%02x%02x%02x%02x" "$@" | |
3043 | } | |
4685e523 JP |
3044 | |
3045 | # Packet to send. | |
3046 | src_mac="f00000010203" | |
3047 | dst_mac="000000010203" | |
3048 | src_ip=`ip_to_hex 192 168 1 2` | |
3049 | dst_ip=`ip_to_hex 172 16 1 2` | |
3050 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3051 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3052 | ||
3053 | ||
3054 | echo "---------NB dump-----" | |
3055 | ovn-nbctl show | |
3056 | echo "---------------------" | |
3057 | ovn-nbctl list logical_router | |
3058 | echo "---------------------" | |
3059 | ovn-nbctl list logical_router_port | |
3060 | echo "---------------------" | |
3061 | ||
3062 | echo "---------SB dump-----" | |
3063 | ovn-sbctl list datapath_binding | |
3064 | echo "---------------------" | |
3065 | ovn-sbctl list logical_flow | |
3066 | echo "---------------------" | |
3067 | ||
3068 | echo "------ hv1 dump ----------" | |
3069 | as hv1 ovs-ofctl dump-flows br-int | |
3070 | ||
3071 | ||
3072 | #Disable router R1 | |
3073 | ovn-nbctl set Logical_Router R1 enabled=false | |
3074 | ||
3b8cd0ea BP |
3075 | # Allow some time for ovn-northd and ovn-controller to catch up. |
3076 | # XXX This should be more systematic. | |
3077 | sleep 1 | |
3078 | ||
4685e523 JP |
3079 | echo "---------SB dump-----" |
3080 | ovn-sbctl list datapath_binding | |
3081 | echo "---------------------" | |
3082 | ovn-sbctl list logical_flow | |
3083 | echo "---------------------" | |
3084 | ||
3085 | echo "------ hv1 dump ----------" | |
3086 | as hv1 ovs-ofctl dump-flows br-int | |
3087 | ||
3088 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3089 | ||
3090 | # Packet to Expect | |
3091 | expect_src_mac="000000010203" | |
3092 | expect_dst_mac="f00000010204" | |
49d7c759 | 3093 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
4685e523 | 3094 | |
49d7c759 | 3095 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
4685e523 JP |
3096 | |
3097 | ||
3098 | as hv1 | |
3099 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
3100 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3101 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3102 | ||
3103 | as ovn-sb | |
3104 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3105 | ||
3106 | as ovn-nb | |
3107 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3108 | ||
3109 | as northd | |
3110 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
3111 | ||
3112 | as main | |
3113 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3114 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3115 | ||
3116 | AT_CLEANUP | |
3117 | ||
3118 | ||
3119 | AT_SETUP([ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR]) | |
5412db30 J |
3120 | AT_KEYWORDS([router-admin-state]) |
3121 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3122 | ovn_start | |
3123 | ||
3124 | # Logical network: | |
3125 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
3126 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
3127 | ||
fa2a27b2 | 3128 | ovn-nbctl lr-add R1 |
5412db30 | 3129 | |
ea46a4e9 JP |
3130 | ovn-nbctl ls-add ls1 |
3131 | ovn-nbctl ls-add ls2 | |
5412db30 J |
3132 | |
3133 | # Connect ls1 to R1 | |
bf44c2cd | 3134 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3135 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
31114af7 | 3136 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" |
5412db30 J |
3137 | |
3138 | # Connect ls2 to R1 | |
bf44c2cd | 3139 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3140 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
31114af7 | 3141 | options:router-port=ls2 addresses=\"00:00:00:01:02:04\" |
5412db30 J |
3142 | |
3143 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
3144 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3145 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
5412db30 J |
3146 | |
3147 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
3148 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3149 | -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2" | |
5412db30 J |
3150 | |
3151 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3152 | net_add n1 | |
3153 | ||
3154 | sim_add hv1 | |
3155 | as hv1 | |
3156 | ovs-vsctl add-br br-phys | |
3157 | ovn_attach n1 br-phys 192.168.0.1 | |
3158 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3159 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3160 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3161 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3162 | ofport-request=1 | |
3163 | ||
3164 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3165 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
3166 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3167 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3168 | ofport-request=1 | |
3169 | ||
3170 | ||
3171 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3172 | # XXX This should be more systematic. | |
3173 | sleep 1 | |
3174 | ||
3175 | # Send ip packets between the two ports. | |
3176 | ip_to_hex() { | |
3177 | printf "%02x%02x%02x%02x" "$@" | |
3178 | } | |
5412db30 J |
3179 | |
3180 | # Packet to send. | |
3181 | src_mac="f00000010203" | |
3182 | dst_mac="000000010203" | |
3183 | src_ip=`ip_to_hex 192 168 1 2` | |
3184 | dst_ip=`ip_to_hex 172 16 1 2` | |
3185 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3186 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3187 | ||
3188 | ||
3189 | echo "---------NB dump-----" | |
3190 | ovn-nbctl show | |
3191 | echo "---------------------" | |
3192 | ovn-nbctl list logical_router | |
3193 | echo "---------------------" | |
3194 | ovn-nbctl list logical_router_port | |
3195 | echo "---------------------" | |
3196 | ||
3197 | echo "---------SB dump-----" | |
3198 | ovn-sbctl list datapath_binding | |
3199 | echo "---------------------" | |
3200 | ovn-sbctl list logical_flow | |
3201 | echo "---------------------" | |
3202 | ||
3203 | echo "------ hv1 dump ----------" | |
3204 | as hv1 ovs-ofctl dump-flows br-int | |
3205 | ||
5412db30 J |
3206 | #Disable router R1 |
3207 | ovn-nbctl set Logical_Router R1 enabled=false | |
3208 | ||
3209 | echo "---------SB dump-----" | |
3210 | ovn-sbctl list datapath_binding | |
3211 | echo "---------------------" | |
3212 | ovn-sbctl list logical_flow | |
3213 | echo "---------------------" | |
3214 | ||
3215 | echo "------ hv1 dump ----------" | |
3216 | as hv1 ovs-ofctl dump-flows br-int | |
3217 | ||
a1361a6e LR |
3218 | # Allow some time for the disabling of logical router R1 to propagate. |
3219 | # XXX This should be more systematic. | |
3220 | sleep 1 | |
3221 | ||
5412db30 J |
3222 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet |
3223 | ||
3224 | # Packet to Expect | |
3225 | expect_src_mac="000000010204" | |
3226 | expect_dst_mac="f00000010204" | |
49d7c759 | 3227 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
5412db30 | 3228 | |
49d7c759 | 3229 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
5412db30 | 3230 | |
7a8f15e0 | 3231 | OVN_CLEANUP([hv1]) |
5412db30 J |
3232 | |
3233 | AT_CLEANUP | |
3234 | ||
28dc3fe9 | 3235 | AT_SETUP([ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes]) |
28dc3fe9 SR |
3236 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3237 | ovn_start | |
3238 | ||
3239 | # Logical network: | |
3240 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
3241 | # network. R1 has switchess foo (192.168.1.0/24) | |
3242 | # connected to it. | |
3243 | # R2 has alice (172.16.1.0/24) and bob (172.16.2.0/24) connected to it. | |
3244 | ||
fa2a27b2 JP |
3245 | ovn-nbctl lr-add R1 |
3246 | ovn-nbctl lr-add R2 | |
28dc3fe9 | 3247 | |
ea46a4e9 JP |
3248 | ovn-nbctl ls-add foo |
3249 | ovn-nbctl ls-add alice | |
3250 | ovn-nbctl ls-add bob | |
28dc3fe9 SR |
3251 | |
3252 | # Connect foo to R1 | |
bf44c2cd | 3253 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3254 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 3255 | options:router-port=foo addresses=\"00:00:00:01:02:03\" |
28dc3fe9 SR |
3256 | |
3257 | # Connect alice to R2 | |
bf44c2cd | 3258 | ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3259 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 3260 | type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" |
28dc3fe9 SR |
3261 | |
3262 | # Connect bob to R2 | |
bf44c2cd | 3263 | ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24 |
31ed1192 | 3264 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob type=router \ |
31114af7 | 3265 | options:router-port=bob addresses=\"00:00:00:01:02:05\" |
28dc3fe9 SR |
3266 | |
3267 | # Connect R1 to R2 | |
4685e523 JP |
3268 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
3269 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
28dc3fe9 SR |
3270 | |
3271 | #install static routes | |
e48ccf3c JP |
3272 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
3273 | ovn-nbctl lr-route-add R2 172.16.2.0/24 20.0.0.2 R1_R2 | |
3274 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 | |
28dc3fe9 SR |
3275 | |
3276 | # Create logical port foo1 in foo | |
31ed1192 JP |
3277 | ovn-nbctl lsp-add foo foo1 \ |
3278 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
28dc3fe9 SR |
3279 | |
3280 | # Create logical port alice1 in alice | |
31ed1192 JP |
3281 | ovn-nbctl lsp-add alice alice1 \ |
3282 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
28dc3fe9 SR |
3283 | |
3284 | # Create logical port bob1 in bob | |
31ed1192 JP |
3285 | ovn-nbctl lsp-add bob bob1 \ |
3286 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 172.16.2.2" | |
28dc3fe9 SR |
3287 | |
3288 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3289 | net_add n1 | |
3290 | ||
3291 | sim_add hv1 | |
3292 | as hv1 | |
3293 | ovs-vsctl add-br br-phys | |
3294 | ovn_attach n1 br-phys 192.168.0.1 | |
3295 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3296 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3297 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3298 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3299 | ofport-request=1 | |
3300 | ||
3301 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3302 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
3303 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3304 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3305 | ofport-request=2 | |
3306 | ||
3307 | sim_add hv2 | |
3308 | as hv2 | |
3309 | ovs-vsctl add-br br-phys | |
3310 | ovn_attach n1 br-phys 192.168.0.2 | |
3311 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3312 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
3313 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3314 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3315 | ofport-request=1 | |
3316 | ||
3317 | ||
3318 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3319 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3320 | # for ARP resolution). | |
3321 | ovn_populate_arp | |
3322 | ||
3323 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3324 | # XXX This should be more systematic. | |
3325 | sleep 1 | |
3326 | ||
3327 | ip_to_hex() { | |
3328 | printf "%02x%02x%02x%02x" "$@" | |
3329 | } | |
28dc3fe9 SR |
3330 | |
3331 | # Send ip packets between foo1 and alice1 | |
3332 | src_mac="f00000010203" | |
3333 | dst_mac="000000010203" | |
3334 | src_ip=`ip_to_hex 192 168 1 2` | |
3335 | dst_ip=`ip_to_hex 172 16 1 2` | |
3336 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3337 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3338 | ||
3339 | # Send ip packets between foo1 and bob1 | |
3340 | src_mac="f00000010203" | |
3341 | dst_mac="000000010203" | |
3342 | src_ip=`ip_to_hex 192 168 1 2` | |
3343 | dst_ip=`ip_to_hex 172 16 2 2` | |
3344 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3345 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3346 | ||
3347 | echo "---------NB dump-----" | |
3348 | ovn-nbctl show | |
3349 | echo "---------------------" | |
3350 | ovn-nbctl list logical_router | |
3351 | echo "---------------------" | |
3352 | ovn-nbctl list logical_router_port | |
3353 | echo "---------------------" | |
3354 | ||
3355 | echo "---------SB dump-----" | |
3356 | ovn-sbctl list datapath_binding | |
3357 | echo "---------------------" | |
3358 | ovn-sbctl list port_binding | |
3359 | echo "---------------------" | |
3360 | ||
3361 | echo "------ hv1 dump ----------" | |
3362 | as hv1 ovs-ofctl dump-flows br-int | |
3363 | echo "------ hv2 dump ----------" | |
3364 | as hv2 ovs-ofctl dump-flows br-int | |
3365 | ||
3366 | # Packet to Expect at bob1 | |
3367 | src_mac="000000010205" | |
3368 | dst_mac="f00000010205" | |
3369 | src_ip=`ip_to_hex 192 168 1 2` | |
3370 | dst_ip=`ip_to_hex 172 16 2 2` | |
49d7c759 | 3371 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 3372 | |
49d7c759 | 3373 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
28dc3fe9 SR |
3374 | |
3375 | # Packet to Expect at alice1 | |
3376 | src_mac="000000010204" | |
3377 | dst_mac="f00000010204" | |
3378 | src_ip=`ip_to_hex 192 168 1 2` | |
3379 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 3380 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 3381 | |
49d7c759 | 3382 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
28dc3fe9 | 3383 | |
7a8f15e0 | 3384 | OVN_CLEANUP([hv1],[hv2]) |
28dc3fe9 SR |
3385 | |
3386 | AT_CLEANUP | |
5412db30 | 3387 | |
0ee8aaf6 | 3388 | AT_SETUP([ovn -- send gratuitous arp on localnet]) |
d08dbed7 | 3389 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
0ee8aaf6 | 3390 | ovn_start |
ea46a4e9 | 3391 | ovn-nbctl ls-add lsw0 |
0ee8aaf6 RR |
3392 | net_add n1 |
3393 | sim_add hv | |
3394 | as hv | |
3395 | ovs-vsctl \ | |
3396 | -- add-br br-phys \ | |
3397 | -- add-br br-eth0 | |
3398 | ||
3399 | ovn_attach n1 br-phys 192.168.0.1 | |
3400 | ||
3401 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
3402 | 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]) | |
3403 | ||
3404 | # Create a vif. | |
31ed1192 JP |
3405 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) |
3406 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.2"]) | |
3407 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
0ee8aaf6 RR |
3408 | |
3409 | # Create a localnet port. | |
31ed1192 JP |
3410 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) |
3411 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
3412 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
3413 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
0ee8aaf6 RR |
3414 | |
3415 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
3416 | ||
3417 | # Wait for packet to be received. | |
49d7c759 BP |
3418 | echo "fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" > expected |
3419 | OVN_CHECK_PACKETS([hv/snoopvif-tx.pcap], [expected]) | |
0ee8aaf6 RR |
3420 | |
3421 | # Delete the localnet ports. | |
3422 | AT_CHECK([ovs-vsctl del-port localvif1]) | |
31ed1192 | 3423 | AT_CHECK([ovn-nbctl lsp-del ln_port]) |
0ee8aaf6 | 3424 | |
7a8f15e0 | 3425 | OVN_CLEANUP([hv]) |
0ee8aaf6 RR |
3426 | |
3427 | AT_CLEANUP | |
75cf9d2b GS |
3428 | |
3429 | AT_SETUP([ovn -- 2 HVs, 3 LRs connected via LS, static routes]) | |
75cf9d2b GS |
3430 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3431 | ovn_start | |
3432 | ||
3433 | # Logical network: | |
3434 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
3435 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
3436 | # connected to it. R2 has alice (172.16.1.0/24) and R3 has bob (10.32.1.0/24) | |
3437 | # connected to it. | |
3438 | ||
fa2a27b2 JP |
3439 | ovn-nbctl lr-add R1 |
3440 | ovn-nbctl lr-add R2 | |
3441 | ovn-nbctl lr-add R3 | |
75cf9d2b | 3442 | |
ea46a4e9 JP |
3443 | ovn-nbctl ls-add foo |
3444 | ovn-nbctl ls-add alice | |
3445 | ovn-nbctl ls-add bob | |
3446 | ovn-nbctl ls-add join | |
75cf9d2b GS |
3447 | |
3448 | # Connect foo to R1 | |
31114af7 | 3449 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 3450 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 3451 | options:router-port=foo addresses=\"00:00:01:01:02:03\" |
75cf9d2b GS |
3452 | |
3453 | # Connect alice to R2 | |
31114af7 | 3454 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 3455 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 3456 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
75cf9d2b GS |
3457 | |
3458 | # Connect bob to R3 | |
31114af7 | 3459 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24 |
31ed1192 | 3460 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ |
80f408f4 | 3461 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" |
75cf9d2b GS |
3462 | |
3463 | # Connect R1 to join | |
31114af7 | 3464 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 3465 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 3466 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
75cf9d2b GS |
3467 | |
3468 | # Connect R2 to join | |
31114af7 | 3469 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 3470 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 3471 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
75cf9d2b GS |
3472 | |
3473 | # Connect R3 to join | |
31114af7 | 3474 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 |
31ed1192 | 3475 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ |
80f408f4 | 3476 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' |
75cf9d2b GS |
3477 | |
3478 | #install static routes | |
e48ccf3c JP |
3479 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
3480 | ovn-nbctl lr-route-add R1 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 3481 | |
e48ccf3c JP |
3482 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 |
3483 | ovn-nbctl lr-route-add R2 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 3484 | |
e48ccf3c JP |
3485 | ovn-nbctl lr-route-add R3 192.168.1.0/24 20.0.0.1 |
3486 | ovn-nbctl lr-route-add R3 172.16.1.0/24 20.0.0.2 | |
75cf9d2b GS |
3487 | |
3488 | # Create logical port foo1 in foo | |
31ed1192 JP |
3489 | ovn-nbctl lsp-add foo foo1 \ |
3490 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
75cf9d2b GS |
3491 | |
3492 | # Create logical port alice1 in alice | |
31ed1192 JP |
3493 | ovn-nbctl lsp-add alice alice1 \ |
3494 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
75cf9d2b GS |
3495 | |
3496 | # Create logical port bob1 in bob | |
31ed1192 JP |
3497 | ovn-nbctl lsp-add bob bob1 \ |
3498 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 10.32.1.2" | |
75cf9d2b GS |
3499 | |
3500 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3501 | net_add n1 | |
3502 | ||
3503 | sim_add hv1 | |
3504 | as hv1 | |
3505 | ovs-vsctl add-br br-phys | |
3506 | ovn_attach n1 br-phys 192.168.0.1 | |
3507 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3508 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3509 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3510 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3511 | ofport-request=1 | |
3512 | ||
3513 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3514 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
3515 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3516 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3517 | ofport-request=2 | |
3518 | ||
3519 | sim_add hv2 | |
3520 | as hv2 | |
3521 | ovs-vsctl add-br br-phys | |
3522 | ovn_attach n1 br-phys 192.168.0.2 | |
3523 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3524 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
3525 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3526 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3527 | ofport-request=1 | |
3528 | ||
3529 | ||
3530 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3531 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3532 | # for ARP resolution). | |
3533 | ovn_populate_arp | |
3534 | ||
3535 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3536 | # XXX This should be more systematic. | |
3537 | sleep 1 | |
3538 | ||
3539 | ip_to_hex() { | |
3540 | printf "%02x%02x%02x%02x" "$@" | |
3541 | } | |
75cf9d2b GS |
3542 | |
3543 | # Send ip packets between foo1 and alice1 | |
3544 | src_mac="f00000010203" | |
3545 | dst_mac="000001010203" | |
3546 | src_ip=`ip_to_hex 192 168 1 2` | |
3547 | dst_ip=`ip_to_hex 172 16 1 2` | |
3548 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3549 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3550 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
3551 | ||
3552 | # Send ip packets between foo1 and bob1 | |
3553 | src_mac="f00000010203" | |
3554 | dst_mac="000001010203" | |
3555 | src_ip=`ip_to_hex 192 168 1 2` | |
3556 | dst_ip=`ip_to_hex 10 32 1 2` | |
3557 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3558 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3559 | ||
3560 | echo "---------NB dump-----" | |
3561 | ovn-nbctl show | |
3562 | echo "---------------------" | |
3563 | ovn-nbctl list logical_router | |
3564 | echo "---------------------" | |
3565 | ovn-nbctl list logical_router_port | |
3566 | echo "---------------------" | |
3567 | ||
3568 | echo "---------SB dump-----" | |
3569 | ovn-sbctl list datapath_binding | |
3570 | echo "---------------------" | |
3571 | ovn-sbctl list port_binding | |
3572 | echo "---------------------" | |
3573 | ovn-sbctl dump-flows | |
3574 | echo "---------------------" | |
3575 | ||
3576 | echo "------ hv1 dump ----------" | |
3577 | as hv1 ovs-ofctl show br-int | |
3578 | as hv1 ovs-ofctl dump-flows br-int | |
3579 | echo "------ hv2 dump ----------" | |
3580 | as hv2 ovs-ofctl show br-int | |
3581 | as hv2 ovs-ofctl dump-flows br-int | |
3582 | echo "----------------------------" | |
3583 | ||
3584 | # Packet to Expect at bob1 | |
3585 | src_mac="000003010203" | |
3586 | dst_mac="f00000010205" | |
3587 | src_ip=`ip_to_hex 192 168 1 2` | |
3588 | dst_ip=`ip_to_hex 10 32 1 2` | |
49d7c759 | 3589 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 3590 | |
49d7c759 | 3591 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
75cf9d2b GS |
3592 | |
3593 | # Packet to Expect at alice1 | |
3594 | src_mac="000002010203" | |
3595 | dst_mac="f00000010204" | |
3596 | src_ip=`ip_to_hex 192 168 1 2` | |
3597 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 3598 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 3599 | |
49d7c759 | 3600 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
75cf9d2b | 3601 | |
7a8f15e0 | 3602 | OVN_CLEANUP([hv1],[hv2]) |
75cf9d2b GS |
3603 | |
3604 | AT_CLEANUP | |
c1645003 | 3605 | |
281977f7 | 3606 | AT_SETUP([ovn -- dhcpv4 : 1 HV, 2 LS, 2 LSPs/LS]) |
281977f7 NS |
3607 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3608 | ovn_start | |
3609 | ||
3610 | ovn-nbctl ls-add ls1 | |
3611 | ||
3612 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3613 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
3614 | ||
3615 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
3616 | ||
3617 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3618 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
3619 | ||
3620 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
3621 | ||
3622 | ovn-nbctl ls-add ls2 | |
3623 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
3624 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
3625 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
3626 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
3627 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
3628 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
3629 | ||
3630 | ovn-nbctl -- --id=@d1 create DHCP_Options cidr=10.0.0.0/24 \ | |
3631 | options="\"server_id\"=\"10.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:01\" \ | |
3632 | \"lease_time\"=\"3600\" \"router\"=\"10.0.0.1\"" \ | |
3633 | -- add Logical_Switch_Port ls1-lp1 dhcpv4_options @d1 \ | |
3634 | -- add Logical_Switch_Port ls1-lp2 dhcpv4_options @d1 | |
3635 | ||
3636 | ovn-nbctl -- --id=@d2 create DHCP_Options cidr=30.0.0.0/24 \ | |
3637 | options="\"server_id\"=\"30.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:02\" \ | |
3638 | \"lease_time\"=\"3600\"" -- add Logical_Switch_Port ls2-lp2 dhcpv4_options @d2 | |
3639 | ||
3640 | net_add n1 | |
3641 | sim_add hv1 | |
3642 | ||
3643 | as hv1 | |
3644 | ovs-vsctl add-br br-phys | |
3645 | ovn_attach n1 br-phys 192.168.0.1 | |
3646 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3647 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
3648 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3649 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3650 | ofport-request=1 | |
3651 | ||
3652 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3653 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
3654 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3655 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3656 | ofport-request=2 | |
3657 | ||
3658 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
3659 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
3660 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
3661 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
3662 | ofport-request=3 | |
3663 | ||
3664 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
3665 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
3666 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
3667 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
3668 | ofport-request=4 | |
3669 | ||
3670 | ovn_populate_arp | |
3671 | ||
3672 | sleep 2 | |
3673 | ||
3674 | as hv1 ovs-vsctl show | |
3675 | ||
281977f7 NS |
3676 | # This shell function sends a DHCP request packet |
3677 | # test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ... | |
3678 | test_dhcp() { | |
3679 | local inport=$1 src_mac=$2 dhcp_type=$3 offer_ip=$4 | |
3680 | local request=ffffffffffff${src_mac}080045100110000000008011000000000000ffffffff | |
3681 | # udp header and dhcp header | |
ab187e7e BP |
3682 | request=${request}0044004300fc0000 |
3683 | request=${request}010106006359aa760000000000000000000000000000000000000000${src_mac} | |
281977f7 | 3684 | # client hardware padding |
ab187e7e | 3685 | request=${request}00000000000000000000 |
281977f7 | 3686 | # server hostname |
ab187e7e BP |
3687 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 |
3688 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3689 | # boot file name |
ab187e7e BP |
3690 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 |
3691 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
3692 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
3693 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3694 | # dhcp magic cookie |
ab187e7e | 3695 | request=${request}63825363 |
281977f7 | 3696 | # dhcp message type |
ab187e7e | 3697 | request=${request}3501${dhcp_type}ff |
281977f7 NS |
3698 | |
3699 | if test $offer_ip != 0; then | |
3700 | local srv_mac=$5 srv_ip=$6 expected_dhcp_opts=$7 | |
3701 | # total IP length will be the IP length of the request packet | |
3702 | # (which is 272 in our case) + 8 (padding bytes) + (expected_dhcp_opts / 2) | |
3703 | ip_len=`expr 280 + ${#expected_dhcp_opts} / 2` | |
3704 | udp_len=`expr $ip_len - 20` | |
04d60f6e YT |
3705 | ip_len=$(printf "%x" $ip_len) |
3706 | udp_len=$(printf "%x" $udp_len) | |
281977f7 NS |
3707 | # $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len |
3708 | local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip} | |
3709 | # udp header and dhcp header. | |
3710 | # $udp_len var will be in 3 digits. So adding a '0' before $udp_len | |
ab187e7e | 3711 | reply=${reply}004300440${udp_len}0000020106006359aa760000000000000000 |
281977f7 | 3712 | # your ip address |
ab187e7e | 3713 | reply=${reply}${offer_ip} |
281977f7 | 3714 | # next server ip address, relay agent ip address, client mac address |
ab187e7e | 3715 | reply=${reply}0000000000000000${src_mac} |
281977f7 | 3716 | # client hardware padding |
ab187e7e | 3717 | reply=${reply}00000000000000000000 |
281977f7 | 3718 | # server hostname |
ab187e7e BP |
3719 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 |
3720 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3721 | # boot file name |
ab187e7e BP |
3722 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 |
3723 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
3724 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
3725 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3726 | # dhcp magic cookie |
ab187e7e | 3727 | reply=${reply}63825363 |
281977f7 NS |
3728 | # dhcp message type |
3729 | local dhcp_reply_type=02 | |
3730 | if test $dhcp_type = 03; then | |
3731 | dhcp_reply_type=05 | |
3732 | fi | |
ab187e7e | 3733 | reply=${reply}3501${dhcp_reply_type}${expected_dhcp_opts}00000000ff00000000 |
281977f7 NS |
3734 | echo $reply >> $inport.expected |
3735 | else | |
3736 | shift; shift; shift; shift; | |
3737 | for outport; do | |
e4543cfe | 3738 | echo $request >> $outport.expected |
281977f7 NS |
3739 | done |
3740 | fi | |
3741 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
3742 | } | |
3743 | ||
3744 | reset_pcap_file() { | |
3745 | local iface=$1 | |
3746 | local pcap_file=$2 | |
3747 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
3748 | options:rxq_pcap=dummy-rx.pcap | |
3749 | rm -f ${pcap_file}*.pcap | |
3750 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
3751 | options:rxq_pcap=${pcap_file}-rx.pcap | |
3752 | } | |
3753 | ||
3754 | ip_to_hex() { | |
3755 | printf "%02x%02x%02x%02x" "$@" | |
3756 | } | |
3757 | ||
3758 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
3759 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
3760 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
3761 | ||
3762 | echo "---------NB dump-----" | |
3763 | ovn-nbctl show | |
3764 | echo "---------------------" | |
3765 | echo "---------SB dump-----" | |
3766 | ovn-sbctl list datapath_binding | |
3767 | echo "---------------------" | |
3768 | ovn-sbctl list logical_flow | |
3769 | echo "---------------------" | |
3770 | ||
3771 | echo "---------------------" | |
3772 | ovn-sbctl dump-flows | |
3773 | echo "---------------------" | |
3774 | ||
3775 | echo "------ hv1 dump ----------" | |
3776 | as hv1 ovs-ofctl dump-flows br-int | |
3777 | ||
3778 | # Send DHCPDISCOVER. | |
3779 | offer_ip=`ip_to_hex 10 0 0 4` | |
3780 | server_ip=`ip_to_hex 10 0 0 1` | |
7c76bf4e | 3781 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
281977f7 NS |
3782 | test_dhcp 1 f00000000001 01 $offer_ip ff1000000001 $server_ip $expected_dhcp_opts |
3783 | ||
3784 | # NXT_RESUMEs should be 1. | |
3785 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3786 | ||
3787 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
3788 | cat 1.expected | cut -c -48 > expout | |
3789 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
3790 | # Skipping the IPv4 checksum. | |
3791 | cat 1.expected | cut -c 53- > expout | |
3792 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
3793 | ||
3794 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
3795 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
3796 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3797 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3798 | rm -f 1.expected | |
3799 | rm -f 2.expected | |
3800 | ||
3801 | # Send DHCPREQUEST. | |
3802 | offer_ip=`ip_to_hex 10 0 0 6` | |
3803 | server_ip=`ip_to_hex 10 0 0 1` | |
7c76bf4e | 3804 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
281977f7 NS |
3805 | test_dhcp 2 f00000000002 03 $offer_ip ff1000000001 $server_ip $expected_dhcp_opts |
3806 | ||
3807 | # NXT_RESUMEs should be 2. | |
3808 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3809 | ||
3810 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
3811 | cat 2.expected | cut -c -48 > expout | |
3812 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
3813 | # Skipping the IPv4 checksum. | |
3814 | cat 2.expected | cut -c 53- > expout | |
3815 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
3816 | ||
3817 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3818 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3819 | rm -f 1.expected | |
3820 | rm -f 2.expected | |
3821 | ||
3822 | # Send Invalid DHCPv4 packet on ls1-lp2. It should be received by ovn-controller | |
3823 | # but should be resumed without the reply. | |
3824 | # ls1-lp1 (vif1-tx.pcap) should receive the DHCPv4 request packet twice, | |
3825 | # one from ovn-controller and the other from "ovs-ofctl resume." | |
3826 | offer_ip=0 | |
3827 | test_dhcp 2 f00000000002 08 $offer_ip 1 1 | |
3828 | ||
3829 | # NXT_RESUMEs should be 3. | |
3830 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3831 | ||
3832 | # vif1-tx.pcap should have received the DHCPv4 (invalid) request packet | |
49d7c759 | 3833 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected]) |
281977f7 NS |
3834 | |
3835 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3836 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3837 | rm -f 1.expected | |
3838 | rm -f 2.expected | |
3839 | ||
3840 | # Send DHCPv4 packet on ls2-lp1. It doesn't have any DHCPv4 options defined. | |
3841 | # ls2-lp2 (vif4-tx.pcap) should receive the DHCPv4 request packet once. | |
3842 | ||
3843 | test_dhcp 3 f00000000003 01 0 4 | |
3844 | ||
3845 | # Send DHCPv4 packet on ls2-lp2. "router" DHCPv4 option is not defined for | |
3846 | # this lport. | |
3847 | test_dhcp 4 f00000000004 01 0 3 | |
3848 | ||
3849 | # NXT_RESUMEs should be 3. | |
3850 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3851 | ||
49d7c759 BP |
3852 | OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected]) |
3853 | OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [4.expected]) | |
281977f7 NS |
3854 | |
3855 | as hv1 | |
33ac3c83 NS |
3856 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) |
3857 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3858 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3859 | ||
3860 | as ovn-sb | |
3861 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3862 | ||
3863 | as ovn-nb | |
3864 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3865 | ||
3866 | as northd | |
3867 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
3868 | ||
3869 | as main | |
3870 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3871 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3872 | ||
3873 | AT_CLEANUP | |
3874 | ||
40df4566 | 3875 | AT_SETUP([ovn -- dhcpv6 : 1 HV, 2 LS, 5 LSPs]) |
33ac3c83 NS |
3876 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3877 | ovn_start | |
3878 | ||
3879 | ovn-nbctl ls-add ls1 | |
3880 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3881 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
3882 | ||
3883 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
3884 | ||
3885 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3886 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
3887 | ||
3888 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
3889 | ||
40df4566 ZKL |
3890 | ovn-nbctl lsp-add ls1 ls1-lp3 \ |
3891 | -- lsp-set-addresses ls1-lp3 "f0:00:00:00:00:22 ae70::22" | |
3892 | ||
3893 | ovn-nbctl lsp-set-port-security ls1-lp3 "f0:00:00:00:00:22 ae70::22" | |
3894 | ||
33ac3c83 NS |
3895 | ovn-nbctl -- --id=@d1 create DHCP_Options cidr="ae70\:\:/64" \ |
3896 | options="\"server_id\"=\"00:00:00:10:00:01\"" \ | |
3897 | -- add Logical_Switch_Port ls1-lp1 dhcpv6_options @d1 \ | |
3898 | -- add Logical_Switch_Port ls1-lp2 dhcpv6_options @d1 | |
3899 | ||
40df4566 ZKL |
3900 | ovn-nbctl -- --id=@d2 create DHCP_Options cidr="ae70\:\:/64" \ |
3901 | options="\"dhcpv6_stateless\"=\"true\" \"server_id\"=\"00:00:00:10:00:01\"" \ | |
3902 | -- add Logical_Switch_Port ls1-lp3 dhcpv6_options @d2 | |
3903 | ||
33ac3c83 NS |
3904 | ovn-nbctl ls-add ls2 |
3905 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
3906 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
3907 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
3908 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
3909 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
3910 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
3911 | ||
3912 | net_add n1 | |
3913 | sim_add hv1 | |
3914 | ||
3915 | as hv1 | |
3916 | ovs-vsctl add-br br-phys | |
3917 | ovn_attach n1 br-phys 192.168.0.1 | |
3918 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3919 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
3920 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3921 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3922 | ofport-request=1 | |
3923 | ||
3924 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3925 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
3926 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3927 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3928 | ofport-request=2 | |
3929 | ||
3930 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
3931 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
3932 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
3933 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
3934 | ofport-request=3 | |
3935 | ||
3936 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
3937 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
3938 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
3939 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
3940 | ofport-request=4 | |
3941 | ||
40df4566 ZKL |
3942 | ovs-vsctl -- add-port br-int hv1-vif5 -- \ |
3943 | set interface hv1-vif5 external-ids:iface-id=ls1-lp3 \ | |
3944 | options:tx_pcap=hv1/vif5-tx.pcap \ | |
3945 | options:rxq_pcap=hv1/vif5-rx.pcap \ | |
3946 | ofport-request=5 | |
3947 | ||
33ac3c83 NS |
3948 | ovn_populate_arp |
3949 | ||
3950 | sleep 2 | |
3951 | ||
3952 | trim_zeros() { | |
3953 | sed 's/\(00\)\{1,\}$//' | |
3954 | } | |
3955 | ||
3956 | # This shell function sends a DHCPv6 request packet | |
40df4566 ZKL |
3957 | # test_dhcpv6 INPORT SRC_MAC SRC_LLA DHCPv6_MSG_TYPE OFFER_IP OUTPORT... |
3958 | # The OUTPORTs (zero or more) list the VIFs on which the original DHCPv6 | |
33ac3c83 NS |
3959 | # packet should be received twice (one from ovn-controller and the other |
3960 | # from the "ovs-ofctl monitor br-int resume" | |
3961 | test_dhcpv6() { | |
3962 | local inport=$1 src_mac=$2 src_lla=$3 msg_code=$4 offer_ip=$5 | |
3963 | local request=ffffffffffff${src_mac}86dd00000000002a1101${src_lla} | |
3964 | # dst ip ff02::1:2 | |
ab187e7e | 3965 | request=${request}ff020000000000000000000000010002 |
33ac3c83 | 3966 | # udp header and dhcpv6 header |
ab187e7e | 3967 | request=${request}02220223002affff${msg_code}010203 |
33ac3c83 | 3968 | # Client identifier |
ab187e7e | 3969 | request=${request}0001000a00030001${src_mac} |
33ac3c83 | 3970 | # IA-NA (Identity Association for Non Temporary Address) |
ab187e7e | 3971 | request=${request}0003000c0102030400000e1000001518 |
33ac3c83 NS |
3972 | shift; shift; shift; shift; shift; |
3973 | if test $offer_ip != 0; then | |
3974 | local server_mac=000000100001 | |
3975 | local server_lla=fe80000000000000020000fffe100001 | |
3976 | local reply_code=07 | |
3977 | if test $msg_code = 01; then | |
3978 | reply_code=02 | |
3979 | fi | |
40df4566 ZKL |
3980 | local msg_len=54 |
3981 | if test $offer_ip = 1; then | |
3982 | msg_len=28 | |
3983 | fi | |
3984 | local reply=${src_mac}${server_mac}86dd0000000000${msg_len}1101${server_lla}${src_lla} | |
33ac3c83 | 3985 | # udp header and dhcpv6 header |
ab187e7e | 3986 | reply=${reply}0223022200${msg_len}ffff${reply_code}010203 |
33ac3c83 | 3987 | # Client identifier |
ab187e7e | 3988 | reply=${reply}0001000a00030001${src_mac} |
33ac3c83 | 3989 | # IA-NA |
40df4566 | 3990 | if test $offer_ip != 1; then |
ab187e7e | 3991 | reply=${reply}0003002801020304ffffffffffffffff00050018${offer_ip}ffffffffffffffff |
40df4566 | 3992 | fi |
33ac3c83 | 3993 | # Server identifier |
ab187e7e | 3994 | reply=${reply}0002000a00030001${server_mac} |
33ac3c83 NS |
3995 | echo $reply | trim_zeros >> $inport.expected |
3996 | else | |
3997 | for outport; do | |
3998 | echo $request | trim_zeros >> $outport.expected | |
3999 | done | |
4000 | fi | |
4001 | ||
4002 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
4003 | } | |
4004 | ||
4005 | reset_pcap_file() { | |
4006 | local iface=$1 | |
4007 | local pcap_file=$2 | |
4008 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
4009 | options:rxq_pcap=dummy-rx.pcap | |
4010 | rm -f ${pcap_file}*.pcap | |
4011 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
4012 | options:rxq_pcap=${pcap_file}-rx.pcap | |
4013 | } | |
4014 | ||
4015 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
4016 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
4017 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
4018 | ||
4019 | echo "---------NB dump-----" | |
4020 | ovn-nbctl show | |
4021 | echo "---------------------" | |
4022 | echo "---------SB dump-----" | |
4023 | ovn-sbctl list datapath_binding | |
4024 | echo "---------------------" | |
4025 | ovn-sbctl list logical_flow | |
4026 | echo "---------------------" | |
4027 | ||
4028 | echo "---------------------" | |
4029 | ovn-sbctl dump-flows | |
4030 | echo "---------------------" | |
4031 | ||
4032 | echo "------ hv1 dump ----------" | |
4033 | as hv1 ovs-ofctl dump-flows br-int | |
4034 | ||
4035 | src_mac=f00000000001 | |
4036 | src_lla=fe80000000000000f20000fffe000001 | |
4037 | offer_ip=ae700000000000000000000000000004 | |
4038 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
4039 | ||
4040 | # NXT_RESUMEs should be 1. | |
4041 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4042 | ||
4043 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
4044 | # cat 1.expected | trim_zeros > expout | |
4045 | cat 1.expected | cut -c -120 > expout | |
4046 | AT_CHECK([cat 1.packets | cut -c -120], [0], [expout]) | |
4047 | # Skipping the UDP checksum | |
4048 | cat 1.expected | cut -c 125- > expout | |
4049 | AT_CHECK([cat 1.packets | cut -c 125-], [0], [expout]) | |
4050 | ||
4051 | rm 1.expected | |
4052 | ||
4053 | # Send invalid packet on ls1-lp2. ovn-controller should resume the packet | |
4054 | # without any modifications and the packet should be received by ls1-lp1. | |
4055 | # ls1-lp1 will receive the packet twice, one from the ovn-controller after the | |
4056 | # resume and the other from ovs-ofctl monitor resume. | |
4057 | ||
4058 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4059 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4060 | ||
4061 | src_mac=f00000000002 | |
4062 | src_lla=fe80000000000000f20000fffe000002 | |
4063 | offer_ip=ae700000000000000000000000000005 | |
4064 | # Set invalid msg_type | |
4065 | ||
4066 | test_dhcpv6 2 $src_mac $src_lla 10 0 1 1 | |
4067 | ||
4068 | # NXT_RESUMEs should be 2. | |
4069 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4070 | ||
4071 | # vif2-tx.pcap should not have received the DHCPv6 reply packet | |
4072 | rm 2.packets | |
4073 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > 2.packets | |
4074 | AT_CHECK([cat 2.packets], [0], []) | |
4075 | ||
4076 | # vif1-tx.pcap should have received the DHCPv6 (invalid) request packet | |
4077 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
4078 | cat 1.expected > expout | |
4079 | AT_CHECK([cat 1.packets], [0], [expout]) | |
4080 | ||
4081 | # Send DHCPv6 packet on ls2-lp1. native DHCPv6 is disabled on this port. | |
4082 | # There should be no DHCPv6 reply from ovn-controller and the request packet | |
4083 | # should be received by ls2-lp2. | |
4084 | ||
4085 | src_mac=f00000000003 | |
4086 | src_lla=fe80000000000000f20000fffe000003 | |
4087 | test_dhcpv6 3 $src_mac $src_lla 01 0 4 | |
4088 | ||
4089 | # NXT_RESUMEs should be 2 only. | |
4090 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4091 | ||
4092 | # vif3-tx.pcap should not have received the DHCPv6 reply packet | |
4093 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap | trim_zeros > 3.packets | |
4094 | AT_CHECK([cat 3.packets], [0], []) | |
4095 | ||
4096 | # vif4-tx.pcap should have received the DHCPv6 request packet | |
4097 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif4-tx.pcap | trim_zeros > 4.packets | |
4098 | cat 4.expected > expout | |
4099 | AT_CHECK([cat 4.packets], [0], [expout]) | |
4100 | ||
40df4566 ZKL |
4101 | # Send DHCPv6 packet on ls1-lp3. native DHCPv6 works as stateless mode for this port. |
4102 | # The DHCPv6 reply should doesn't contian offer_ip. | |
4103 | src_mac=f00000000022 | |
4104 | src_lla=fe80000000000000f20000fffe000022 | |
4105 | reset_pcap_file hv1-vif5 hv1/vif5 | |
4106 | test_dhcpv6 5 $src_mac $src_lla 01 1 5 | |
4107 | ||
4108 | # NXT_RESUMEs should be 3. | |
4109 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4110 | ||
4111 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.packets | |
4112 | # Skipping the UDP checksum | |
4113 | cat 5.expected | cut -c 1-120,125- > expout | |
4114 | AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout]) | |
4115 | ||
33ac3c83 | 4116 | as hv1 |
281977f7 NS |
4117 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) |
4118 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4119 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4120 | ||
4121 | as ovn-sb | |
4122 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4123 | ||
4124 | as ovn-nb | |
4125 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4126 | ||
4127 | as northd | |
4128 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
4129 | ||
4130 | as main | |
4131 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4132 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4133 | ||
4134 | AT_CLEANUP | |
4135 | ||
c1645003 | 4136 | AT_SETUP([ovn -- 2 HVs, 2 LRs connected via LS, gateway router]) |
c1645003 GS |
4137 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4138 | ovn_start | |
4139 | ||
4140 | # Logical network: | |
4141 | # Two LRs - R1 and R2 that are connected to each other via LS "join" | |
4142 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
4143 | # connected to it. R2 has alice (172.16.1.0/24) connected to it. | |
4144 | # R2 is a gateway router. | |
4145 | ||
4146 | ||
4147 | ||
4148 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
4149 | net_add n1 | |
4150 | ||
4151 | sim_add hv1 | |
4152 | as hv1 | |
4153 | ovs-vsctl add-br br-phys | |
4154 | ovn_attach n1 br-phys 192.168.0.1 | |
4155 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4156 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
4157 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4158 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4159 | ofport-request=1 | |
4160 | ||
4161 | ||
4162 | sim_add hv2 | |
4163 | as hv2 | |
4164 | ovs-vsctl add-br br-phys | |
4165 | ovn_attach n1 br-phys 192.168.0.2 | |
4166 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
4167 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
4168 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
4169 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
4170 | ofport-request=1 | |
4171 | ||
4172 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
4173 | # packets for ARP resolution (native tunneling doesn't queue packets | |
4174 | # for ARP resolution). | |
4175 | ovn_populate_arp | |
4176 | ||
4177 | ovn-nbctl create Logical_Router name=R1 | |
4178 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
4179 | ||
ea46a4e9 JP |
4180 | ovn-nbctl ls-add foo |
4181 | ovn-nbctl ls-add alice | |
4182 | ovn-nbctl ls-add join | |
c1645003 GS |
4183 | |
4184 | # Connect foo to R1 | |
31114af7 | 4185 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 4186 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ |
80f408f4 | 4187 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" |
c1645003 GS |
4188 | |
4189 | # Connect alice to R2 | |
31114af7 | 4190 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 4191 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 4192 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
c1645003 GS |
4193 | |
4194 | # Connect R1 to join | |
31114af7 | 4195 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 4196 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 4197 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
c1645003 GS |
4198 | |
4199 | # Connect R2 to join | |
31114af7 | 4200 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 4201 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 4202 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
c1645003 GS |
4203 | |
4204 | ||
4205 | #install static routes | |
4206 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4207 | ip_prefix=172.16.1.0/24 nexthop=20.0.0.2 -- add Logical_Router \ | |
4208 | R1 static_routes @lrt | |
4209 | ||
4210 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4211 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
4212 | R2 static_routes @lrt | |
4213 | ||
4214 | # Create logical port foo1 in foo | |
31ed1192 JP |
4215 | ovn-nbctl lsp-add foo foo1 \ |
4216 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
c1645003 GS |
4217 | |
4218 | # Create logical port alice1 in alice | |
31ed1192 JP |
4219 | ovn-nbctl lsp-add alice alice1 \ |
4220 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
c1645003 GS |
4221 | |
4222 | ||
4223 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4224 | # XXX This should be more systematic. | |
4225 | sleep 2 | |
4226 | ||
4227 | ip_to_hex() { | |
4228 | printf "%02x%02x%02x%02x" "$@" | |
4229 | } | |
c1645003 GS |
4230 | |
4231 | # Send ip packets between foo1 and alice1 | |
4232 | src_mac="f00000010203" | |
4233 | dst_mac="000001010203" | |
4234 | src_ip=`ip_to_hex 192 168 1 2` | |
4235 | dst_ip=`ip_to_hex 172 16 1 2` | |
4236 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4237 | ||
4238 | echo "---------NB dump-----" | |
4239 | ovn-nbctl show | |
4240 | echo "---------------------" | |
4241 | ovn-nbctl list logical_router | |
4242 | echo "---------------------" | |
4243 | ovn-nbctl list logical_router_port | |
4244 | echo "---------------------" | |
4245 | ||
4246 | echo "---------SB dump-----" | |
4247 | ovn-sbctl list datapath_binding | |
4248 | echo "---------------------" | |
4249 | ovn-sbctl list port_binding | |
4250 | echo "---------------------" | |
4251 | ovn-sbctl dump-flows | |
4252 | echo "---------------------" | |
4253 | ovn-sbctl list chassis | |
4254 | ovn-sbctl list encap | |
4255 | echo "---------------------" | |
4256 | ||
c1645003 GS |
4257 | # Packet to Expect at alice1 |
4258 | src_mac="000002010203" | |
4259 | dst_mac="f00000010204" | |
4260 | src_ip=`ip_to_hex 192 168 1 2` | |
4261 | dst_ip=`ip_to_hex 172 16 1 2` | |
4262 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
4263 | ||
4264 | ||
4265 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4266 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
4267 | ||
ab39371d RM |
4268 | echo "------ hv1 dump after packet 1 ----------" |
4269 | as hv1 ovs-ofctl show br-int | |
4270 | as hv1 ovs-ofctl dump-flows br-int | |
4271 | echo "------ hv2 dump after packet 1 ----------" | |
4272 | as hv2 ovs-ofctl show br-int | |
4273 | as hv2 ovs-ofctl dump-flows br-int | |
4274 | echo "----------------------------" | |
4275 | ||
49d7c759 BP |
4276 | echo $expected > expected |
4277 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
c1645003 | 4278 | |
34114cf8 GS |
4279 | # Delete the router and re-create it. Things should work as before. |
4280 | ovn-nbctl lr-del R2 | |
4281 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
4282 | # Connect alice to R2 | |
4283 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
4284 | # Connect R2 to join | |
4285 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
4286 | ||
4287 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4288 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
4289 | R2 static_routes @lrt | |
4290 | ||
4291 | # Wait for ovn-controller to catch up. | |
4292 | sleep 1 | |
4293 | ||
4294 | # Send the packet again. | |
4295 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
ab39371d RM |
4296 | |
4297 | echo "------ hv1 dump after packet 2 ----------" | |
4298 | as hv1 ovs-ofctl show br-int | |
4299 | as hv1 ovs-ofctl dump-flows br-int | |
4300 | echo "------ hv2 dump after packet 2 ----------" | |
4301 | as hv2 ovs-ofctl show br-int | |
4302 | as hv2 ovs-ofctl dump-flows br-int | |
4303 | echo "----------------------------" | |
4304 | ||
49d7c759 BP |
4305 | echo $expected >> expected |
4306 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
34114cf8 | 4307 | |
7a8f15e0 | 4308 | OVN_CLEANUP([hv1],[hv2]) |
c1645003 GS |
4309 | |
4310 | AT_CLEANUP | |
bb3c4568 FF |
4311 | |
4312 | AT_SETUP([ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR]) | |
4313 | AT_KEYWORDS([router-icmp-reply]) | |
4314 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4315 | ovn_start | |
4316 | ||
4317 | # Logical network: | |
4318 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
4319 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
4320 | ||
fa2a27b2 | 4321 | ovn-nbctl lr-add R1 |
bb3c4568 | 4322 | |
ea46a4e9 JP |
4323 | ovn-nbctl ls-add ls1 |
4324 | ovn-nbctl ls-add ls2 | |
bb3c4568 FF |
4325 | |
4326 | # Connect ls1 to R1 | |
31114af7 | 4327 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24 |
31ed1192 | 4328 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \ |
80f408f4 | 4329 | type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\" |
bb3c4568 FF |
4330 | |
4331 | # Connect ls2 to R1 | |
31114af7 | 4332 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24 |
31ed1192 | 4333 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \ |
80f408f4 | 4334 | type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\" |
bb3c4568 FF |
4335 | |
4336 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
4337 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
4338 | -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2" | |
bb3c4568 FF |
4339 | |
4340 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
4341 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
4342 | -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2" | |
bb3c4568 FF |
4343 | |
4344 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
4345 | net_add n1 | |
4346 | ||
4347 | sim_add hv1 | |
4348 | as hv1 | |
4349 | ovs-vsctl add-br br-phys | |
4350 | ovn_attach n1 br-phys 192.168.0.1 | |
4351 | ovs-vsctl -- add-port br-int vif1 -- \ | |
4352 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
4353 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4354 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4355 | ofport-request=1 | |
4356 | ||
4357 | ovs-vsctl -- add-port br-int vif2 -- \ | |
4358 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
4359 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4360 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4361 | ofport-request=1 | |
4362 | ||
4363 | ||
4364 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4365 | # XXX This should be more systematic. | |
4366 | sleep 1 | |
4367 | ||
4368 | ||
4369 | ip_to_hex() { | |
4370 | printf "%02x%02x%02x%02x" "$@" | |
4371 | } | |
bb3c4568 FF |
4372 | for i in 1 2; do |
4373 | : > vif$i.expected | |
4374 | done | |
4375 | # test_ipv4_icmp_request INPORT ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM ICMP_CHKSUM [EXP_IP_CHKSUM EXP_ICMP_CHKSUM] | |
4376 | # | |
4377 | # Causes a packet to be received on INPORT. The packet is an ICMPv4 | |
4378 | # request with ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHSUM and | |
4379 | # ICMP_CHKSUM as specified. If EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are | |
4380 | # provided, then it should be the ip and icmp checksums of the packet | |
4381 | # responded; otherwise, no reply is expected. | |
4382 | # In the absence of an ip checksum calculation helpers, this relies | |
4383 | # on the caller to provide the checksums for the ip and icmp headers. | |
4384 | # XXX This should be more systematic. | |
4385 | # | |
4386 | # INPORT is an lport number, e.g. 11 for vif11. | |
4387 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
4388 | # IPV4_SRC and IPV4_DST are each 8 hex digits. | |
4389 | # IP_CHSUM and ICMP_CHKSUM are each 4 hex digits. | |
4390 | # EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits. | |
4391 | test_ipv4_icmp_request() { | |
4392 | local inport=$1 eth_src=$2 eth_dst=$3 ipv4_src=$4 ipv4_dst=$5 ip_chksum=$6 icmp_chksum=$7 | |
4393 | local exp_ip_chksum=$8 exp_icmp_chksum=$9 | |
4394 | shift; shift; shift; shift; shift; shift; shift | |
4395 | shift; shift | |
4396 | ||
4397 | # Use ttl to exercise section 4.2.2.9 of RFC1812 | |
4398 | local ip_ttl=01 | |
4399 | local icmp_id=5fbf | |
4400 | local icmp_seq=0001 | |
4401 | local icmp_data=$(seq 1 56 | xargs printf "%02x") | |
4402 | local icmp_type_code_request=0800 | |
4403 | local icmp_payload=${icmp_type_code_request}${icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
4404 | local packet=${eth_dst}${eth_src}08004500005400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${icmp_payload} | |
4405 | ||
4406 | as hv1 ovs-appctl netdev-dummy/receive vif$inport $packet | |
4407 | if test X$exp_icmp_chksum != X; then | |
4408 | # Expect to receive the reply, if any. In same port where packet was sent. | |
4409 | # Note: src and dst fields are expected to be reversed. | |
4410 | local icmp_type_code_response=0000 | |
4411 | local reply_icmp_ttl=fe | |
4412 | local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
4413 | local reply=${eth_src}${eth_dst}08004500005400004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload} | |
4414 | echo $reply >> vif$inport.expected | |
4415 | fi | |
4416 | } | |
4417 | ||
4418 | # Send ping packet to router's ip addresses, from each of the 2 logical ports. | |
4419 | rtr_l1_ip=$(ip_to_hex 192 168 1 1) | |
4420 | rtr_l2_ip=$(ip_to_hex 172 16 1 1) | |
4421 | l1_ip=$(ip_to_hex 192 168 1 2) | |
4422 | l2_ip=$(ip_to_hex 172 16 1 2) | |
4423 | ||
4424 | # Ping router ip address that is on same subnet as the logical port | |
4425 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
4426 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
4427 | ||
4428 | # Ping router ip address that is on the other side of the logical ports | |
4429 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
4430 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
4431 | ||
4432 | echo "---------NB dump-----" | |
4433 | ovn-nbctl show | |
4434 | echo "---------------------" | |
4435 | ovn-nbctl list logical_router | |
4436 | echo "---------------------" | |
4437 | ovn-nbctl list logical_router_port | |
4438 | echo "---------------------" | |
4439 | ||
4440 | echo "---------SB dump-----" | |
4441 | ovn-sbctl list datapath_binding | |
4442 | echo "---------------------" | |
4443 | ovn-sbctl list logical_flow | |
4444 | echo "---------------------" | |
4445 | ||
4446 | echo "------ hv1 dump ----------" | |
4447 | as hv1 ovs-ofctl dump-flows br-int | |
4448 | ||
4449 | # Now check the packets actually received against the ones expected. | |
4450 | for inport in 1 2; do | |
49d7c759 | 4451 | OVN_CHECK_PACKETS([hv1/vif${inport}-tx.pcap], [vif$inport.expected]) |
bb3c4568 FF |
4452 | done |
4453 | ||
7a8f15e0 | 4454 | OVN_CLEANUP([hv1]) |
bb3c4568 FF |
4455 | |
4456 | AT_CLEANUP | |
94f79fcb RB |
4457 | |
4458 | # 1 hypervisor, 1 port | |
4459 | # make sure that the port state is properly set to up and back down | |
4460 | # when created and deleted. | |
4461 | AT_SETUP([ovn -- port state up and down]) | |
94f79fcb RB |
4462 | ovn_start |
4463 | ||
4464 | ovn-nbctl ls-add ls1 | |
4465 | ovn-nbctl lsp-add ls1 lp1 | |
4466 | ovn-nbctl lsp-set-addresses lp1 unknown | |
4467 | ||
4468 | net_add n1 | |
4469 | sim_add hv1 | |
4470 | as hv1 ovs-vsctl add-br br-phys | |
4471 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
4472 | ||
4473 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
4474 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
4475 | ||
4476 | as hv1 ovs-vsctl del-port br-int vif1 | |
4477 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
4478 | ||
7a8f15e0 | 4479 | OVN_CLEANUP([hv1]) |
94f79fcb | 4480 | |
94f79fcb | 4481 | AT_CLEANUP |
e75451fe | 4482 | |
ccc6e1db FF |
4483 | # 1 hypervisor, 1 port |
4484 | # make sure that the OF rules created to support a datapath are added/cleared | |
4485 | # when logical switch is created and removed. | |
4486 | AT_SETUP([ovn -- datapath rules added/removed]) | |
1794d5f2 | 4487 | AT_KEYWORDS([cleanup]) |
ccc6e1db FF |
4488 | ovn_start |
4489 | ||
4490 | net_add n1 | |
4491 | sim_add hv1 | |
4492 | as hv1 ovs-vsctl add-br br-phys | |
4493 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
4494 | ||
4495 | # This shell function checks if OF rules in br-int have clauses | |
4496 | # related to OVN datapaths. The caller determines if it should find | |
4497 | # a match in the output, or not. | |
4498 | # | |
4499 | # EXPECT_DATAPATH param determines whether flows that refer to | |
4500 | # datapath to should be present or not. 0 means | |
4501 | # they should not be. | |
4502 | # STAGE_INFO param is a simple string to help identify the stage | |
4503 | # in the test when this function was invoked. | |
4504 | test_datapath_in_of_rules() { | |
4505 | local expect_datapath=$1 stage_info=$2 | |
4506 | echo "------ ovn-nbctl show ${stage_info} ------" | |
4507 | ovn-nbctl show | |
4508 | echo "------ ovn-sbctl show ${stage_info} ------" | |
4509 | ovn-sbctl show | |
4510 | echo "------ OF rules ${stage_info} ------" | |
4511 | AT_CHECK([ovs-ofctl dump-flows br-int], [0], [stdout]) | |
4512 | # if there is a datapath mentioned in the output, check for the | |
4513 | # magic keyword that represents one, based on the exit status of | |
4514 | # a quiet grep | |
4515 | if test $expect_datapath != 0; then | |
4618b102 | 4516 | AT_CHECK([grep -q -i 'metadata=' stdout], [0], [ignore-nolog]) |
ccc6e1db | 4517 | else |
4618b102 | 4518 | AT_CHECK([grep -q -i 'metadata=' stdout], [1], [ignore-nolog]) |
ccc6e1db FF |
4519 | fi |
4520 | } | |
4521 | ||
4522 | test_datapath_in_of_rules 0 "before ls+port create" | |
4523 | ||
4524 | ovn-nbctl ls-add ls1 | |
4525 | ovn-nbctl lsp-add ls1 lp1 | |
4526 | ovn-nbctl lsp-set-addresses lp1 unknown | |
4527 | ||
4528 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
4529 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
4530 | ||
4531 | test_datapath_in_of_rules 1 "after port is bound" | |
4532 | ||
4533 | as hv1 ovs-vsctl del-port br-int vif1 | |
4534 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
4535 | ||
4536 | ovn-nbctl lsp-set-addresses lp1 | |
4537 | ovn-nbctl lsp-del lp1 | |
4538 | ovn-nbctl ls-del ls1 | |
4539 | ||
4540 | # wait for earlier changes to take effect | |
4541 | AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) | |
4542 | ||
4543 | # ensure OF rules are no longer present. There used to be a bug here. | |
4544 | test_datapath_in_of_rules 0 "after lport+ls removal" | |
4545 | ||
4546 | OVN_CLEANUP([hv1]) | |
4547 | ||
4548 | AT_CLEANUP | |
4549 | ||
f8a8db39 | 4550 | AT_SETUP([ovn -- nd_na ]) |
e75451fe ZKL |
4551 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4552 | ovn_start | |
4553 | ||
4554 | #TODO: since patch port for IPv6 logical router port is not ready not, | |
4555 | # so we are not going to test vifs on different lswitches cases. Try | |
4556 | # to update for that once relevant stuff implemented. | |
4557 | ||
4558 | # In this test cases we create 1 lswitch, it has 2 VIF ports attached | |
4559 | # with. NS packet we test, from one VIF for another VIF, will be replied | |
4560 | # by local ovn-controller, but not by target VIF. | |
4561 | ||
4562 | # Create hypervisors and logical switch lsw0. | |
4563 | ovn-nbctl ls-add lsw0 | |
4564 | net_add n1 | |
4565 | sim_add hv1 | |
4566 | as hv1 | |
4567 | ovs-vsctl add-br br-phys | |
4568 | ovn_attach n1 br-phys 192.168.0.2 | |
4569 | ||
4570 | # Add vif1 to hv1 and lsw0, turn on l2 port security on vif1. | |
4571 | 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 | |
4572 | ovn-nbctl lsp-add lsw0 lp1 | |
4573 | ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598" | |
4574 | 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" | |
4575 | ||
4576 | # Add vif2 to hv1 and lsw0, turn on l2 port security on vif2. | |
4577 | 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 | |
4578 | ovn-nbctl lsp-add lsw0 lp2 | |
4579 | ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae" | |
4580 | 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" | |
4581 | ||
4582 | # Add ACL rule for ICMPv6 on lsw0 | |
4583 | ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related | |
4584 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related | |
4585 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related | |
4586 | ||
4587 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4588 | # XXX This should be more systematic. | |
4589 | sleep 1 | |
4590 | ||
4591 | # Given the name of a logical port, prints the name of the hypervisor | |
4592 | # on which it is located. | |
4593 | vif_to_hv() { | |
4594 | echo hv1${1%?} | |
4595 | } | |
e75451fe ZKL |
4596 | for i in 1 2; do |
4597 | : > $i.expected | |
4598 | done | |
4599 | ||
4600 | # Complete Neighbor Solicitation packet and Neighbor Advertisement packet | |
4601 | # vif1 -> NS -> vif2. vif1 <- NA <- ovn-controller. | |
4602 | # vif2 will not receive NS packet, since ovn-controller will reply for it. | |
4603 | ns_packet=3333ffa1f9aefa163e94059886dd6000000000203afffd81ce49a9480000f8163efffe940598fd81ce49a9480000f8163efffea1f9ae8700e01160000000fd81ce49a9480000f8163efffea1f9ae0101fa163e940598 | |
4604 | na_packet=fa163e940598fa163ea1f9ae86dd6000000000203afffd81ce49a9480000f8163efffea1f9aefd81ce49a9480000f8163efffe9405988800e9ed60000000fd81ce49a9480000f8163efffea1f9ae0201fa163ea1f9ae | |
4605 | ||
4606 | as hv1 ovs-appctl netdev-dummy/receive vif1 $ns_packet | |
e4543cfe | 4607 | echo $na_packet >> 1.expected |
e75451fe | 4608 | |
e75451fe ZKL |
4609 | echo "------ hv1 dump ------" |
4610 | as hv1 ovs-vsctl show | |
4611 | as hv1 ovs-ofctl -O OpenFlow13 show br-int | |
4612 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
4613 | ||
4614 | for i in 1 2; do | |
49d7c759 | 4615 | OVN_CHECK_PACKETS([hv1/vif$i-tx.pcap], [$i.expected]) |
e75451fe ZKL |
4616 | done |
4617 | ||
7a8f15e0 | 4618 | OVN_CLEANUP([hv1]) |
e75451fe ZKL |
4619 | |
4620 | AT_CLEANUP | |
7417d147 RM |
4621 | |
4622 | AT_SETUP([ovn -- address sets modification/removal smoke test]) | |
7417d147 RM |
4623 | ovn_start |
4624 | ||
4625 | net_add n1 | |
4626 | ||
4627 | sim_add hv1 | |
4628 | as hv1 | |
4629 | ovs-vsctl add-br br-phys | |
4630 | ovn_attach n1 br-phys 192.168.0.1 | |
4631 | ||
4632 | row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"` | |
4633 | ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\" | |
4634 | ovn-nbctl destroy Address_Set $row | |
4635 | ||
4636 | sleep 1 | |
4637 | ||
4638 | # A bug previously existed in the address set support code | |
4639 | # that caused ovn-controller to crash after an address set | |
4640 | # was updated and then removed. This test case ensures | |
4641 | # that ovn-controller is at least still running after | |
4642 | # creating, updating, and deleting an address set. | |
4643 | AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore]) | |
4644 | ||
4645 | OVN_CLEANUP([hv1]) | |
4646 | ||
4647 | AT_CLEANUP | |
8639f9be ND |
4648 | |
4649 | AT_SETUP([ovn -- ipam]) | |
8639f9be ND |
4650 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4651 | ovn_start | |
4652 | ||
4653 | # Add a port to a switch that does not have a subnet set, then set the | |
4654 | # subnet which should result in an address being allocated for the port. | |
4655 | ovn-nbctl ls-add sw0 | |
4656 | ovn-nbctl lsp-add sw0 p0 -- lsp-set-addresses p0 dynamic | |
fd3b31e9 | 4657 | ovn-nbctl --wait=sb add Logical-Switch sw0 other_config subnet=192.168.1.0/24 |
8639f9be ND |
4658 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0], |
4659 | ["0a:00:00:00:00:01 192.168.1.2" | |
4660 | ]) | |
4661 | ||
4662 | # Add 9 more ports to sw0, addresses should all be unique. | |
4663 | for n in `seq 1 9`; do | |
11547f85 | 4664 | ovn-nbctl --wait=sb lsp-add sw0 "p$n" -- lsp-set-addresses "p$n" dynamic |
8639f9be ND |
4665 | done |
4666 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p1 dynamic_addresses], [0], | |
4667 | ["0a:00:00:00:00:02 192.168.1.3" | |
4668 | ]) | |
4669 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p2 dynamic_addresses], [0], | |
4670 | ["0a:00:00:00:00:03 192.168.1.4" | |
4671 | ]) | |
4672 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p3 dynamic_addresses], [0], | |
4673 | ["0a:00:00:00:00:04 192.168.1.5" | |
4674 | ]) | |
4675 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p4 dynamic_addresses], [0], | |
4676 | ["0a:00:00:00:00:05 192.168.1.6" | |
4677 | ]) | |
4678 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p5 dynamic_addresses], [0], | |
4679 | ["0a:00:00:00:00:06 192.168.1.7" | |
4680 | ]) | |
4681 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p6 dynamic_addresses], [0], | |
4682 | ["0a:00:00:00:00:07 192.168.1.8" | |
4683 | ]) | |
4684 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p7 dynamic_addresses], [0], | |
4685 | ["0a:00:00:00:00:08 192.168.1.9" | |
4686 | ]) | |
4687 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p8 dynamic_addresses], [0], | |
4688 | ["0a:00:00:00:00:09 192.168.1.10" | |
4689 | ]) | |
4690 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p9 dynamic_addresses], [0], | |
4691 | ["0a:00:00:00:00:0a 192.168.1.11" | |
4692 | ]) | |
4693 | ||
4694 | # Trying similar tests with a second switch. MAC addresses should be unique | |
4695 | # across both switches but IP's only need to be unique within the same switch. | |
4696 | ovn-nbctl ls-add sw1 | |
4697 | ovn-nbctl lsp-add sw1 p10 -- lsp-set-addresses p10 dynamic | |
11547f85 | 4698 | ovn-nbctl --wait=sb add Logical-Switch sw1 other_config subnet=192.168.1.0/24 |
8639f9be ND |
4699 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p10 dynamic_addresses], [0], |
4700 | ["0a:00:00:00:00:0b 192.168.1.2" | |
4701 | ]) | |
4702 | ||
4703 | for n in `seq 11 19`; do | |
11547f85 | 4704 | ovn-nbctl --wait=sb lsp-add sw1 "p$n" -- lsp-set-addresses "p$n" dynamic |
8639f9be ND |
4705 | done |
4706 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p11 dynamic_addresses], [0], | |
4707 | ["0a:00:00:00:00:0c 192.168.1.3" | |
4708 | ]) | |
4709 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p12 dynamic_addresses], [0], | |
4710 | ["0a:00:00:00:00:0d 192.168.1.4" | |
4711 | ]) | |
4712 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p13 dynamic_addresses], [0], | |
4713 | ["0a:00:00:00:00:0e 192.168.1.5" | |
4714 | ]) | |
4715 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p14 dynamic_addresses], [0], | |
4716 | ["0a:00:00:00:00:0f 192.168.1.6" | |
4717 | ]) | |
4718 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p15 dynamic_addresses], [0], | |
4719 | ["0a:00:00:00:00:10 192.168.1.7" | |
4720 | ]) | |
4721 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p16 dynamic_addresses], [0], | |
4722 | ["0a:00:00:00:00:11 192.168.1.8" | |
4723 | ]) | |
4724 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p17 dynamic_addresses], [0], | |
4725 | ["0a:00:00:00:00:12 192.168.1.9" | |
4726 | ]) | |
4727 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p18 dynamic_addresses], [0], | |
4728 | ["0a:00:00:00:00:13 192.168.1.10" | |
4729 | ]) | |
4730 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p19 dynamic_addresses], [0], | |
4731 | ["0a:00:00:00:00:14 192.168.1.11" | |
4732 | ]) | |
4733 | ||
4734 | # Change a port's address to test for multiple ip's for a single address entry | |
4735 | # and addresses set by the user. | |
4736 | ovn-nbctl lsp-set-addresses p0 "0a:00:00:00:00:15 192.168.1.12 192.168.1.14" | |
11547f85 | 4737 | ovn-nbctl --wait=sb lsp-add sw0 p20 -- lsp-set-addresses p20 dynamic |
8639f9be ND |
4738 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p20 dynamic_addresses], [0], |
4739 | ["0a:00:00:00:00:16 192.168.1.13" | |
4740 | ]) | |
4741 | ||
4742 | # Test for logical router port address management. | |
4743 | ovn-nbctl create Logical_Router name=R1 | |
4744 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw0 \ | |
4745 | network="192.168.1.1/24" mac=\"0a:00:00:00:00:17\" \ | |
4746 | -- add Logical_Router R1 ports @lrp -- lsp-add sw0 rp-sw0 \ | |
4747 | -- set Logical_Switch_Port rp-sw0 type=router options:router-port=sw0 | |
11547f85 | 4748 | ovn-nbctl --wait=sb lsp-add sw0 p21 -- lsp-set-addresses p21 dynamic |
8639f9be ND |
4749 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p21 dynamic_addresses], [0], |
4750 | ["0a:00:00:00:00:18 192.168.1.15" | |
4751 | ]) | |
4752 | ||
4753 | # Test for address reuse after logical port is deleted. | |
4754 | ovn-nbctl lsp-del p0 | |
11547f85 | 4755 | ovn-nbctl --wait=sb lsp-add sw0 p23 -- lsp-set-addresses p23 dynamic |
8639f9be ND |
4756 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p23 dynamic_addresses], [0], |
4757 | ["0a:00:00:00:00:19 192.168.1.2" | |
4758 | ]) | |
4759 | ||
4760 | # Test for multiple addresses to one logical port. | |
4761 | ovn-nbctl lsp-add sw0 p25 -- lsp-set-addresses p25 \ | |
4762 | "0a:00:00:00:00:1a 192.168.1.12" "0a:00:00:00:00:1b 192.168.1.14" | |
11547f85 | 4763 | ovn-nbctl --wait=sb lsp-add sw0 p26 -- lsp-set-addresses p26 dynamic |
8639f9be ND |
4764 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p26 dynamic_addresses], [0], |
4765 | ["0a:00:00:00:00:1c 192.168.1.16" | |
4766 | ]) | |
4767 | ||
4768 | # Test for exhausting subnet address space. | |
4769 | ovn-nbctl ls-add sw2 -- add Logical-Switch sw2 other_config subnet=172.16.1.0/30 | |
11547f85 | 4770 | ovn-nbctl --wait=sb lsp-add sw2 p27 -- lsp-set-addresses p27 dynamic |
8639f9be ND |
4771 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p27 dynamic_addresses], [0], |
4772 | ["0a:00:00:00:00:1d 172.16.1.2" | |
4773 | ]) | |
4774 | ||
11547f85 | 4775 | ovn-nbctl --wait=sb lsp-add sw2 p28 -- lsp-set-addresses p28 dynamic |
8639f9be ND |
4776 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p28 dynamic_addresses], [0], |
4777 | [[[]] | |
4778 | ]) | |
4779 | ||
4780 | # Test that address management does not add duplicate MAC for lsp/lrp peers. | |
4781 | ovn-nbctl create Logical_Router name=R2 | |
4782 | ovn-nbctl ls-add sw3 | |
4783 | ovn-nbctl lsp-add sw3 p29 -- lsp-set-addresses p29 \ | |
4784 | "0a:00:00:00:00:1e" | |
4785 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw3 \ | |
4786 | network="192.168.2.1/24" mac=\"0a:00:00:00:00:1f\" \ | |
4787 | -- add Logical_Router R2 ports @lrp -- lsp-add sw3 rp-sw3 \ | |
4788 | -- set Logical_Switch_Port rp-sw3 type=router options:router-port=sw3 | |
11547f85 | 4789 | ovn-nbctl --wait=sb lsp-add sw0 p30 -- lsp-set-addresses p30 dynamic |
8639f9be ND |
4790 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p30 dynamic_addresses], [0], |
4791 | ["0a:00:00:00:00:20 192.168.1.17" | |
4792 | ]) | |
4793 | ||
6374d518 LR |
4794 | # Test static MAC address with dynamically allocated IP |
4795 | ovn-nbctl --wait=sb lsp-add sw0 p31 -- lsp-set-addresses p31 \ | |
4796 | "fe:dc:ba:98:76:54 dynamic" | |
4797 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
4798 | ["fe:dc:ba:98:76:54 192.168.1.18" | |
4799 | ]) | |
4800 | ||
8639f9be ND |
4801 | as ovn-sb |
4802 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4803 | ||
4804 | as ovn-nb | |
4805 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4806 | ||
4807 | as northd | |
4808 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
4809 | ||
4810 | AT_CLEANUP | |
4811 | ||
4812 | AT_SETUP([ovn -- ipam connectivity]) | |
8639f9be ND |
4813 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4814 | ovn_start | |
4815 | ||
4816 | ovn-nbctl lr-add R1 | |
4817 | ||
4818 | # Test for a ping using dynamically allocated addresses. | |
4819 | ovn-nbctl ls-add foo -- add Logical_Switch foo other_config subnet=192.168.1.0/24 | |
4820 | ovn-nbctl ls-add alice -- add Logical_Switch alice other_config subnet=192.168.2.0/24 | |
4821 | ||
4822 | # Connect foo to R1 | |
4823 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
4824 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
20418099 MS |
4825 | options:router-port=foo \ |
4826 | -- lsp-set-addresses rp-foo router | |
8639f9be ND |
4827 | |
4828 | # Connect alice to R1 | |
4829 | ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 192.168.2.1/24 | |
4830 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice type=router \ | |
4831 | options:router-port=alice addresses=\"00:00:00:01:02:04\" | |
4832 | ||
4833 | # Create logical port foo1 in foo | |
fd3b31e9 | 4834 | ovn-nbctl --wait=sb lsp-add foo foo1 \ |
8639f9be | 4835 | -- lsp-set-addresses foo1 "dynamic" |
8bc2c143 | 4836 | AT_CHECK([ovn-nbctl --timeout=10 wait-until Logical-Switch-Port foo1 dynamic_addresses='"0a:00:00:00:00:01 192.168.1.2"'], [0]) |
8639f9be ND |
4837 | |
4838 | # Create logical port alice1 in alice | |
fd3b31e9 | 4839 | ovn-nbctl --wait=sb lsp-add alice alice1 \ |
8639f9be | 4840 | -- lsp-set-addresses alice1 "dynamic" |
8bc2c143 | 4841 | AT_CHECK([ovn-nbctl --timeout=10 wait-until Logical-Switch-Port alice1 dynamic_addresses='"0a:00:00:00:00:02 192.168.2.2"']) |
8639f9be ND |
4842 | |
4843 | # Create logical port foo2 in foo | |
fd3b31e9 | 4844 | ovn-nbctl --wait=sb lsp-add foo foo2 \ |
8639f9be | 4845 | -- lsp-set-addresses foo2 "dynamic" |
8bc2c143 | 4846 | AT_CHECK([ovn-nbctl --timeout=10 wait-until Logical-Switch-Port foo2 dynamic_addresses='"0a:00:00:00:00:03 192.168.1.3"']) |
8639f9be ND |
4847 | |
4848 | # Create a hypervisor and create OVS ports corresponding to logical ports. | |
4849 | net_add n1 | |
4850 | ||
4851 | sim_add hv1 | |
4852 | as hv1 | |
4853 | ovs-vsctl add-br br-phys | |
4854 | ovn_attach n1 br-phys 192.168.0.1 | |
4855 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4856 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
4857 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4858 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4859 | ofport-request=1 | |
4860 | ||
4861 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4862 | set interface hv1-vif2 external-ids:iface-id=foo2 \ | |
4863 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4864 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4865 | ofport-request=2 | |
4866 | ||
4867 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
4868 | set interface hv1-vif3 external-ids:iface-id=alice1 \ | |
4869 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
4870 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
4871 | ofport-request=3 | |
4872 | ||
4873 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4874 | # XXX This should be more systematic. | |
4875 | sleep 1 | |
4876 | ||
4877 | ip_to_hex() { | |
4878 | printf "%02x%02x%02x%02x" "$@" | |
4879 | } | |
8639f9be ND |
4880 | |
4881 | # Send ip packets between foo1 and foo2 | |
4882 | src_mac="0a0000000001" | |
4883 | dst_mac="0a0000000003" | |
4884 | src_ip=`ip_to_hex 192 168 1 2` | |
4885 | dst_ip=`ip_to_hex 192 168 1 3` | |
4886 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4887 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4888 | ||
4889 | # Send ip packets between foo1 and alice1 | |
4890 | src_mac="0a0000000001" | |
4891 | dst_mac="000000010203" | |
4892 | src_ip=`ip_to_hex 192 168 1 2` | |
4893 | dst_ip=`ip_to_hex 192 168 2 2` | |
4894 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4895 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4896 | ||
4897 | echo "---------NB dump-----" | |
4898 | ovn-nbctl show | |
4899 | echo "---------------------" | |
4900 | ovn-nbctl list logical_router | |
4901 | echo "---------------------" | |
4902 | ovn-nbctl list logical_router_port | |
4903 | echo "---------------------" | |
4904 | ||
4905 | echo "---------SB dump-----" | |
4906 | ovn-sbctl list datapath_binding | |
4907 | echo "---------------------" | |
4908 | ovn-sbctl list port_binding | |
4909 | echo "---------------------" | |
4910 | ||
4911 | echo "------ hv1 dump ----------" | |
4912 | as hv1 ovs-ofctl dump-flows br-int | |
4913 | ||
4914 | # Packet to Expect at foo2 | |
4915 | src_mac="0a0000000001" | |
4916 | dst_mac="0a0000000003" | |
4917 | src_ip=`ip_to_hex 192 168 1 2` | |
4918 | dst_ip=`ip_to_hex 192 168 1 3` | |
4919 | expected=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4920 | ||
e4543cfe DDP |
4921 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets |
4922 | echo $expected > expout | |
8639f9be ND |
4923 | AT_CHECK([cat received1.packets], [0], [expout]) |
4924 | ||
4925 | # Packet to Expect at alice1 | |
4926 | src_mac="000000010204" | |
4927 | dst_mac="0a0000000002" | |
4928 | src_ip=`ip_to_hex 192 168 1 2` | |
4929 | dst_ip=`ip_to_hex 192 168 2 2` | |
4930 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
4931 | ||
e4543cfe DDP |
4932 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets |
4933 | echo $expected > expout | |
8639f9be ND |
4934 | AT_CHECK([cat received2.packets], [0], [expout]) |
4935 | ||
4936 | OVN_CLEANUP([hv1]) | |
4937 | ||
4938 | AT_CLEANUP | |
f5792c3f NS |
4939 | |
4940 | AT_SETUP([ovn -- ovs-vswitchd restart]) | |
1794d5f2 | 4941 | AT_KEYWORDS([vswitchd]) |
f5792c3f NS |
4942 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4943 | ovn_start | |
4944 | ||
4945 | ovn-nbctl ls-add ls1 | |
4946 | ||
4947 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
4948 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
4949 | ||
4950 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
4951 | ||
4952 | net_add n1 | |
4953 | sim_add hv1 | |
4954 | ||
4955 | as hv1 | |
4956 | ovs-vsctl add-br br-phys | |
4957 | ovn_attach n1 br-phys 192.168.0.1 | |
4958 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4959 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
4960 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4961 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4962 | ofport-request=1 | |
4963 | ||
4964 | ovn_populate_arp | |
4965 | sleep 2 | |
4966 | ||
4967 | as hv1 ovs-vsctl show | |
4968 | ||
4969 | echo "---------------------" | |
4970 | ovn-sbctl dump-flows | |
4971 | echo "---------------------" | |
4972 | ||
4973 | echo "------ hv1 dump ----------" | |
4974 | as hv1 ovs-ofctl dump-flows br-int | |
4975 | total_flows=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
4976 | ||
4977 | echo "Total flows before vswitchd restart = " $total_flows | |
4978 | ||
4979 | # Code taken from ovs-save utility | |
4980 | save_flows () { | |
4981 | echo "ovs-ofctl add-flows br-int - << EOF" > restore_flows.sh | |
4982 | as hv1 ovs-ofctl dump-flows "br-int" | sed -e '/NXST_FLOW/d' \ | |
4983 | -e 's/\(idle\|hard\)_age=[^,]*,//g' >> restore_flows.sh | |
4984 | echo "EOF" >> restore_flows.sh | |
4985 | } | |
4986 | ||
4987 | restart_vswitchd () { | |
4988 | restore_flows=$1 | |
4989 | ||
4990 | if test $restore_flows = true; then | |
4991 | save_flows | |
4992 | fi | |
4993 | ||
4994 | as hv1 | |
4995 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4996 | ||
4997 | if test $restore_flows = true; then | |
4998 | as hv1 | |
4999 | ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="true" | |
5000 | fi | |
5001 | ||
5002 | as hv1 | |
5003 | start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl | |
5004 | ovs-ofctl dump-flows br-int | |
5005 | ||
5006 | if test $restore_flows = true; then | |
5007 | sh ./restore_flows.sh | |
5008 | echo "Flows after restore" | |
5009 | as hv1 | |
5010 | ovs-ofctl dump-flows br-int | |
5011 | ovs-vsctl --no-wait --if-exists remove open_vswitch . other_config \ | |
5012 | flow-restore-wait="true" | |
5013 | fi | |
5014 | } | |
5015 | ||
5016 | # Save the flows, restart vswitchd and restore the flows | |
5017 | restart_vswitchd true | |
5018 | OVS_WAIT_UNTIL([ | |
5019 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
5020 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
5021 | test "${total_flows}" = "${total_flows_after_restart}" | |
5022 | ]) | |
5023 | ||
5024 | # Restart vswitchd without restoring | |
5025 | restart_vswitchd false | |
5026 | OVS_WAIT_UNTIL([ | |
5027 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
5028 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
5029 | test "${total_flows}" = "${total_flows_after_restart}" | |
5030 | ]) | |
5031 | ||
5032 | OVN_CLEANUP([hv1]) | |
5033 | AT_CLEANUP | |
47021598 CSV |
5034 | |
5035 | AT_SETUP([ovn -- send arp for nexthop]) | |
47021598 CSV |
5036 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5037 | ovn_start | |
5038 | ||
5039 | # Topology: Two LSs - ls1 and ls2 are connected via router r0 | |
5040 | ||
5041 | # Create logical switches | |
5042 | ovn-nbctl ls-add ls1 | |
5043 | ovn-nbctl ls-add ls2 | |
5044 | ||
5045 | # Create router | |
5046 | ovn-nbctl create Logical_Router name=lr0 | |
5047 | ||
5048 | # Add router ls1p1 port to gateway router | |
5049 | ovn-nbctl lrp-add lr0 lrp-ls1lp1 f0:00:00:00:00:01 192.168.0.1/24 | |
5050 | ovn-nbctl lsp-add ls1 ls1lp1 -- set Logical_Switch_Port ls1lp1 \ | |
5051 | type=router options:router-port=lrp-ls1lp1 \ | |
5052 | addresses='"f0:00:00:00:00:01 192.168.0.1"' | |
5053 | ||
5054 | # Add router ls2p2 port to gateway router | |
5055 | ovn-nbctl lrp-add lr0 lrp-ls2lp1 f0:00:00:00:00:02 192.168.1.1/24 | |
5056 | ovn-nbctl lsp-add ls2 ls2lp1 -- set Logical_Switch_Port ls2lp1 \ | |
5057 | type=router options:router-port=lrp-ls2lp1 \ | |
5058 | addresses='"f0:00:00:00:00:02 192.168.1.1"' | |
5059 | ||
5060 | # Set default gateway (nexthop) to 192.168.1.254 | |
5061 | ovn-nbctl lr-route-add lr0 "0.0.0.0/0" 192.168.1.254 lrp-ls2lp1 | |
5062 | ||
5063 | # Create logical port ls1lp2 in ls1 | |
5064 | ovn-nbctl lsp-add ls1 ls1lp2 \ | |
5065 | -- lsp-set-addresses ls1lp2 "f0:00:00:00:00:03 192.168.0.2" | |
5066 | ||
5067 | # Create logical port ls2lp2 in ls2 | |
5068 | ovn-nbctl lsp-add ls2 ls2lp2 \ | |
5069 | -- lsp-set-addresses ls2lp2 "f0:00:00:00:00:04 192.168.1.10" | |
5070 | ||
5071 | net_add n1 | |
5072 | sim_add hv1 | |
5073 | as hv1 | |
5074 | ovs-vsctl add-br br-phys | |
5075 | ovn_attach n1 br-phys 192.168.0.1 | |
5076 | ovs-vsctl -- add-port br-int hv1-ls1lp2 -- \ | |
5077 | set interface hv1-ls1lp2 external-ids:iface-id=ls1lp2 \ | |
5078 | options:tx_pcap=hv1/ls1lp2-tx.pcap \ | |
5079 | options:rxq_pcap=hv1/ls1lp2-rx.pcap \ | |
5080 | ofport-request=1 | |
5081 | ovs-vsctl -- add-port br-int hv1-ls2lp2 -- \ | |
5082 | set interface hv1-ls2lp2 external-ids:iface-id=ls2lp2 \ | |
5083 | options:tx_pcap=hv1/ls2lp2-tx.pcap \ | |
5084 | options:rxq_pcap=hv1/ls2lp2-rx.pcap \ | |
5085 | ofport-request=2 | |
5086 | ||
5087 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5088 | # XXX This should be more systematic. | |
5089 | sleep 1 | |
5090 | ||
5091 | echo "---------NB dump-----" | |
5092 | ovn-nbctl show | |
5093 | echo "---------------------" | |
5094 | ovn-nbctl list logical_router | |
5095 | echo "---------------------" | |
5096 | ovn-nbctl list logical_router_port | |
5097 | echo "---------------------" | |
5098 | ||
5099 | echo "---------SB dump-----" | |
5100 | ovn-sbctl list datapath_binding | |
5101 | echo "---------------------" | |
5102 | ovn-sbctl list port_binding | |
5103 | echo "---------------------" | |
5104 | ovn-sbctl dump-flows | |
5105 | echo "---------------------" | |
5106 | ovn-sbctl list chassis | |
5107 | ovn-sbctl list encap | |
5108 | echo "---------------------" | |
5109 | ||
5110 | echo "------Flows dump-----" | |
5111 | as hv1 | |
5112 | ovs-ofctl dump-flows | |
5113 | echo "---------------------" | |
5114 | ||
5115 | ip_to_hex() { | |
5116 | printf "%02x%02x%02x%02x" "$@" | |
5117 | } | |
5118 | ||
5119 | src_mac="f00000000003" | |
5120 | dst_mac="f00000000001" | |
5121 | src_ip=`ip_to_hex 192 168 0 2` | |
5122 | dst_ip=`ip_to_hex 8 8 8 8` | |
5123 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5124 | ||
5125 | # Send IP packet destined to 8.8.8.8 from lsp1lp2 | |
5126 | as hv1 ovs-appctl netdev-dummy/receive hv1-ls1lp2 $packet | |
5127 | ||
5128 | trim_zeros() { | |
5129 | sed 's/\(00\)\{1,\}$//' | |
5130 | } | |
5131 | ||
5132 | # ARP packet should be received with Target IP Address set to 192.168.1.254 and | |
5133 | # not 8.8.8.8 | |
5134 | ||
5135 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ls2lp2-tx.pcap | trim_zeros > packets | |
5136 | expected="fffffffffffff0000000000208060001080006040001f00000000002c0a80101000000000000c0a801fe" | |
5137 | echo $expected > expout | |
5138 | AT_CHECK([cat packets], [0], [expout]) | |
5139 | cat packets | |
5140 | ||
5141 | OVN_CLEANUP([hv1]) | |
5142 | ||
5143 | AT_CLEANUP | |
8439c2eb CSV |
5144 | |
5145 | AT_SETUP([ovn -- send gratuitous arp for nat ips in localnet]) | |
8439c2eb CSV |
5146 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5147 | ovn_start | |
5148 | # Create logical switch | |
5149 | ovn-nbctl ls-add ls0 | |
5150 | # Create gateway router | |
5151 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
5152 | # Add router port to gateway router | |
5153 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 | |
5154 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
5155 | type=router options:router-port=lrp0-rp addresses='"f0:00:00:00:00:01"' | |
5156 | # Add nat-address option | |
5157 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="f0:00:00:00:00:01 192.168.0.2" | |
5158 | ||
5159 | net_add n1 | |
5160 | sim_add hv1 | |
5161 | as hv1 | |
5162 | ovs-vsctl \ | |
5163 | -- add-br br-phys \ | |
5164 | -- add-br br-eth0 | |
5165 | ||
5166 | ovn_attach n1 br-phys 192.168.0.1 | |
5167 | ||
5168 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
5169 | 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]) | |
5170 | ||
5171 | # Create a localnet port. | |
5172 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
5173 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
5174 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
5175 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
5176 | ||
5177 | ||
5178 | # Wait for packet to be received. | |
5179 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) | |
5180 | trim_zeros() { | |
5181 | sed 's/\(00\)\{1,\}$//' | |
5182 | } | |
5183 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
5184 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
5185 | echo $expected > expout | |
5186 | AT_CHECK([sort packets], [0], [expout]) | |
5187 | cat packets | |
5188 | ||
5189 | OVN_CLEANUP([hv1]) | |
5190 | ||
5191 | AT_CLEANUP | |
6e31816f CSV |
5192 | |
5193 | AT_SETUP([ovn -- delete mac bindings]) | |
6e31816f CSV |
5194 | ovn_start |
5195 | net_add n1 | |
5196 | sim_add hv1 | |
5197 | as hv1 | |
5198 | ovs-vsctl -- add-br br-phys | |
5199 | ovn_attach n1 br-phys 192.168.0.1 | |
5200 | # Create logical switch ls0 | |
5201 | ovn-nbctl ls-add ls0 | |
5202 | # Create ports lp0, lp1 in ls0 | |
5203 | ovn-nbctl lsp-add ls0 lp0 | |
5204 | ovn-nbctl lsp-add ls0 lp1 | |
5205 | ovn-nbctl lsp-set-addresses lp0 "f0:00:00:00:00:01 192.168.0.1" | |
5206 | ovn-nbctl lsp-set-addresses lp1 "f0:00:00:00:00:02 192.168.0.2" | |
5207 | dp_uuid=`ovn-sbctl find datapath | grep uuid | cut -f2 -d ":" | cut -f2 -d " "` | |
5208 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp0 mac="mac1" | |
5209 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp1 mac="mac2" | |
5210 | ovn-sbctl find MAC_Binding | |
093aa761 | 5211 | # Delete port lp0 and check that its MAC_Binding is deleted. |
6e31816f CSV |
5212 | ovn-nbctl lsp-del lp0 |
5213 | ovn-sbctl find MAC_Binding | |
093aa761 BP |
5214 | OVS_WAIT_UNTIL([test `ovn-sbctl find MAC_Binding logical_port=lp0 | wc -l` = 0]) |
5215 | # Delete logical switch ls0 and check that its MAC_Binding is deleted. | |
6e31816f CSV |
5216 | ovn-nbctl ls-del ls0 |
5217 | ovn-sbctl find MAC_Binding | |
093aa761 | 5218 | OVS_WAIT_UNTIL([test `ovn-sbctl find MAC_Binding | wc -l` = 0]) |
6e31816f CSV |
5219 | |
5220 | OVN_CLEANUP([hv1]) | |
5221 | ||
5222 | AT_CLEANUP | |
926c34fd RM |
5223 | |
5224 | AT_SETUP([ovn -- conntrack zone allocation]) | |
926c34fd RM |
5225 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5226 | ovn_start | |
5227 | ||
5228 | # Logical network: | |
5229 | # 2 logical switches "foo" (192.168.1.0/24) and "bar" (172.16.1.0/24) | |
5230 | # connected to a router R1. | |
5231 | # foo has foo1 to act as a client. | |
5232 | # bar has bar1, bar2, bar3 to act as servers. | |
5233 | ||
5234 | net_add n1 | |
5235 | ||
5236 | sim_add hv1 | |
5237 | as hv1 | |
5238 | ovs-vsctl add-br br-phys | |
5239 | ovn_attach n1 br-phys 192.168.0.1 | |
5240 | for i in foo1 bar1 bar2 bar3; do | |
5241 | ovs-vsctl -- add-port br-int $i -- \ | |
5242 | set interface $i external-ids:iface-id=$i \ | |
5243 | options:tx_pcap=hv1/$i-tx.pcap \ | |
5244 | options:rxq_pcap=hv1/$i-rx.pcap | |
5245 | done | |
5246 | ||
5247 | ovn-nbctl create Logical_Router name=R1 | |
5248 | ovn-nbctl ls-add foo | |
5249 | ovn-nbctl ls-add bar | |
5250 | ||
5251 | # Connect foo to R1 | |
5252 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
5253 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
5254 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" | |
5255 | ||
5256 | # Connect bar to R1 | |
5257 | ovn-nbctl lrp-add R1 bar 00:00:01:01:02:04 172.16.1.1/24 | |
5258 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar \ | |
5259 | type=router options:router-port=bar addresses=\"00:00:01:01:02:04\" | |
5260 | ||
5261 | # Create logical port foo1 in foo | |
5262 | ovn-nbctl lsp-add foo foo1 \ | |
5263 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
5264 | ||
5265 | # Create logical port bar1, bar2 and bar3 in bar | |
5266 | for i in `seq 1 3`; do | |
5267 | ip=`expr $i + 1` | |
5268 | ovn-nbctl lsp-add bar bar$i \ | |
5269 | -- lsp-set-addresses bar$i "f0:00:0a:01:02:$i 172.16.1.$ip" | |
5270 | done | |
5271 | ||
5272 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=0 | grep REG13 | wc -l` -eq 4]) | |
5273 | ||
5274 | OVN_CLEANUP([hv1]) | |
5275 | ||
5276 | AT_CLEANUP | |
b511690b GS |
5277 | |
5278 | AT_SETUP([ovn -- tag allocation]) | |
b511690b GS |
5279 | ovn_start |
5280 | ||
5281 | AT_CHECK([ovn-nbctl ls-add ls0]) | |
5282 | AT_CHECK([ovn-nbctl lsp-add ls0 parent1]) | |
5283 | AT_CHECK([ovn-nbctl lsp-add ls0 parent2]) | |
5284 | AT_CHECK([ovn-nbctl ls-add ls1]) | |
5285 | ||
5286 | dnl When a tag is provided, no allocation is done | |
5287 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c0 parent1 3]) | |
5288 | AT_CHECK([ovn-nbctl lsp-get-tag c0], [0], [3 | |
5289 | ]) | |
5290 | dnl The same 'tag' gets created in southbound database. | |
5291 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5292 | logical_port="c0"], [0], [3 | |
5293 | ]) | |
5294 | ||
5295 | dnl Allocate tags and see it getting created in both NB and SB | |
5296 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c1 parent1 0]) | |
5297 | AT_CHECK([ovn-nbctl lsp-get-tag c1], [0], [1 | |
5298 | ]) | |
5299 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5300 | logical_port="c1"], [0], [1 | |
5301 | ]) | |
5302 | ||
5303 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c2 parent1 0]) | |
5304 | AT_CHECK([ovn-nbctl lsp-get-tag c2], [0], [2 | |
5305 | ]) | |
5306 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5307 | logical_port="c2"], [0], [2 | |
5308 | ]) | |
5309 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c3 parent1 0]) | |
5310 | AT_CHECK([ovn-nbctl lsp-get-tag c3], [0], [4 | |
5311 | ]) | |
5312 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5313 | logical_port="c3"], [0], [4 | |
5314 | ]) | |
5315 | ||
5316 | dnl A different parent. | |
5317 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c4 parent2 0]) | |
5318 | AT_CHECK([ovn-nbctl lsp-get-tag c4], [0], [1 | |
5319 | ]) | |
5320 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5321 | logical_port="c4"], [0], [1 | |
5322 | ]) | |
5323 | ||
5324 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c5 parent2 0]) | |
5325 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
5326 | ]) | |
5327 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5328 | logical_port="c5"], [0], [2 | |
5329 | ]) | |
5330 | ||
5331 | dnl Delete a logical port and create a new one. | |
5332 | AT_CHECK([ovn-nbctl --wait=sb lsp-del c1]) | |
5333 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c6 parent1 0]) | |
5334 | AT_CHECK([ovn-nbctl lsp-get-tag c6], [0], [1 | |
5335 | ]) | |
5336 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5337 | logical_port="c6"], [0], [1 | |
5338 | ]) | |
5339 | ||
5340 | dnl Restart northd to see that the same allocation remains. | |
5341 | as northd | |
5342 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
5343 | start_daemon ovn-northd \ | |
5344 | --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock \ | |
5345 | --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
5346 | ||
5347 | dnl Create a switch to make sure that ovn-northd has run through the main loop. | |
5348 | AT_CHECK([ovn-nbctl --wait=sb ls-add ls-dummy]) | |
5349 | AT_CHECK([ovn-nbctl lsp-get-tag c0], [0], [3 | |
5350 | ]) | |
5351 | AT_CHECK([ovn-nbctl lsp-get-tag c6], [0], [1 | |
5352 | ]) | |
5353 | AT_CHECK([ovn-nbctl lsp-get-tag c2], [0], [2 | |
5354 | ]) | |
5355 | AT_CHECK([ovn-nbctl lsp-get-tag c3], [0], [4 | |
5356 | ]) | |
5357 | AT_CHECK([ovn-nbctl lsp-get-tag c4], [0], [1 | |
5358 | ]) | |
5359 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
5360 | ]) | |
5361 | ||
5362 | dnl Create a switch port with a tag that has already been allocated. | |
5363 | dnl It should go through fine with a duplicate tag. | |
5364 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c7 parent2 2]) | |
5365 | AT_CHECK([ovn-nbctl lsp-get-tag c7], [0], [2 | |
5366 | ]) | |
5367 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5368 | logical_port="c7"], [0], [2 | |
5369 | ]) | |
5370 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
5371 | ]) | |
5372 | ||
5373 | AT_CHECK([ovn-nbctl ls-add ls2]) | |
5374 | dnl When there is no parent_name provided (for say, 'localnet'), 'tag_request' | |
5375 | dnl gets copied to 'tag' | |
5376 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls2 local0 "" 25]) | |
5377 | AT_CHECK([ovn-nbctl lsp-get-tag local0], [0], [25 | |
5378 | ]) | |
5379 | dnl The same 'tag' gets created in southbound database. | |
5380 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5381 | logical_port="local0"], [0], [25 | |
5382 | ]) | |
5383 | dnl If 'tag_request' is 0 for localnet, nothing gets written to 'tag' | |
5384 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls2 local1 "" 0]) | |
5385 | AT_CHECK([ovn-nbctl lsp-get-tag local1]) | |
5386 | dnl change the tag_request. | |
5387 | AT_CHECK([ovn-nbctl --wait=sb set logical_switch_port local1 tag_request=50]) | |
5388 | AT_CHECK([ovn-nbctl lsp-get-tag local1], [0], [50 | |
5389 | ]) | |
5390 | ||
5391 | AT_CLEANUP | |
57afd0c0 RR |
5392 | |
5393 | AT_SETUP([ovn -- lsp deletion and broadcast-flow deletion on localnet]) | |
57afd0c0 RR |
5394 | ovn_start |
5395 | ovn-nbctl ls-add lsw0 | |
5396 | net_add n1 | |
5397 | for i in 1 2; do | |
5398 | sim_add hv$i | |
5399 | as hv$i | |
5400 | ovs-vsctl add-br br-phys | |
5401 | ovn_attach n1 br-phys 192.168.0.$i | |
5402 | ovs-vsctl add-br br-eth0 | |
5403 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
5404 | done | |
5405 | ||
5406 | # Create a localnet port. | |
5407 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) | |
5408 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
5409 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
5410 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
5411 | ||
5412 | ||
5413 | # Create 3 vifs. | |
5414 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) | |
5415 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.1"]) | |
5416 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
5417 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif2]) | |
5418 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif2 "f0:00:00:00:00:01 192.168.1.2"]) | |
5419 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif2 "f0:00:00:00:00:02"]) | |
5420 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif3]) | |
5421 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif3 "f0:00:00:00:00:03 192.168.1.3"]) | |
5422 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif3 "f0:00:00:00:00:03"]) | |
5423 | ||
5424 | # Bind the localvif1 to hv1. | |
5425 | as hv1 | |
5426 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
5427 | ||
5428 | # On hv1, check that there are no flows outputting bcast to tunnel | |
5429 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) | |
5430 | ||
1ea9b847 | 5431 | # On hv2, check that no flow outputs bcast to tunnel to hv1. |
57afd0c0 | 5432 | as hv2 |
1ea9b847 | 5433 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) |
57afd0c0 RR |
5434 | |
5435 | # Now bind vif2 on hv2. | |
5436 | AT_CHECK([ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2]) | |
5437 | ||
5438 | # At this point, the broadcast flow on vif2 should be deleted. | |
5439 | # because, there is now a localnet vif bound (table=32 programming logic) | |
5440 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) | |
5441 | ||
5442 | # Verify that the local net patch port exists on hv2. | |
5443 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
5444 | ||
5445 | # Now bind vif3 on hv2. | |
5446 | AT_CHECK([ovs-vsctl add-port br-int localvif3 -- set Interface localvif3 external_ids:iface-id=localvif3]) | |
5447 | ||
5448 | # Verify that the local net patch port still exists on hv2 | |
5449 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
5450 | ||
5451 | # Delete localvif2 | |
5452 | AT_CHECK([ovn-nbctl lsp-del localvif2]) | |
5453 | ||
5454 | # Verify that the local net patch port still exists on hv2, | |
5455 | # because, localvif3 is still bound. | |
5456 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
5457 | ||
57afd0c0 | 5458 | OVN_CLEANUP([hv1],[hv2]) |
1a03fc7d BS |
5459 | |
5460 | AT_CLEANUP | |
5461 | ||
5462 | AT_SETUP([ovn -- DSCP marking check]) | |
5463 | AT_KEYWORDS([ovn]) | |
5464 | ovn_start | |
5465 | ||
5466 | ovn-nbctl ls-add lsw0 | |
5467 | ovn-nbctl --wait=sb lsp-add lsw0 lp1 | |
5468 | ovn-nbctl --wait=sb lsp-add lsw0 lp2 | |
5469 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
5470 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
5471 | ovn-nbctl lsp-set-port-security lp1 f0:00:00:00:00:01 | |
5472 | ovn-nbctl lsp-set-port-security lp2 f0:00:00:00:00:02 | |
5473 | ovn-nbctl --wait=sb sync | |
5474 | net_add n1 | |
5475 | sim_add hv | |
5476 | as hv | |
5477 | ovs-vsctl add-br br-phys | |
5478 | ovn_attach n1 br-phys 192.168.0.1 | |
5479 | ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 options:tx_pcap=vif1-tx.pcap options:rxq_pcap=vif1-rx.pcap ofport-request=1 | |
5480 | ovs-vsctl add-port br-int vif2 -- set Interface vif2 external-ids:iface-id=lp2 options:tx_pcap=vif2-tx.pcap options:rxq_pcap=vif2-rx.pcap ofport-request=2 | |
5481 | ||
5482 | AT_CAPTURE_FILE([trace]) | |
5483 | ovn_trace () { | |
5484 | ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' | |
5485 | } | |
5486 | ||
5487 | # Extracts nw_tos from the final flow from ofproto/trace output and prints | |
5488 | # it on stdout. Prints "none" if no nw_tos was included. | |
5489 | get_final_nw_tos() { | |
5490 | if flow=$(grep '^Final flow:' stdout); then :; else | |
5491 | # The output didn't have a final flow. | |
5492 | return 99 | |
5493 | fi | |
5494 | ||
5495 | tos=$(echo "$flow" | sed -n 's/.*nw_tos=\([[0-9]]\{1,\}\).*/\1/p') | |
5496 | case $tos in | |
5497 | '') echo none ;; | |
5498 | *) echo $tos ;; | |
5499 | esac | |
5500 | } | |
5501 | ||
5502 | # check_tos TOS | |
5503 | # | |
5504 | # Checks that a packet from 1.1.1.1 to 1.1.1.2 gets its DSCP set to TOS. | |
5505 | check_tos() { | |
5506 | # First check with ovn-trace for logical flows. | |
5507 | echo "checking for tos $1" | |
5508 | (if test $1 != 0; then echo "ip.dscp = $1;"; fi; | |
5509 | echo 'output("lp2");') > expout | |
5510 | AT_CHECK_UNQUOTED([ovn_trace lsw0 'inport == "lp1" && eth.src == f0:00:00:00:00:01 && eth.dst == f0:00:00:00:00:02 && ip4.src == 1.1.1.1 && ip4.dst == 1.1.1.2'], [0], [expout]) | |
5511 | ||
5512 | # Then re-check with ofproto/trace for a physical packet. | |
5513 | AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,dl_type=0x800,nw_src=1.1.1.1,nw_dst=1.1.1.2'], [0], [stdout-nolog]) | |
5514 | AT_CHECK_UNQUOTED([get_final_nw_tos], [0], [`expr $1 \* 4` | |
5515 | ]) | |
5516 | } | |
5517 | ||
5518 | # check at L2 | |
5519 | AT_CHECK([ovn_trace lsw0 'inport == "lp1" && eth.src == f0:00:00:00:00:01 && eth.dst == f0:00:00:00:00:02'], [0], [output("lp2"); | |
5520 | ]) | |
5521 | AT_CHECK([ovs-appctl ofproto/trace br-int 'in_port=1,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02'], [0], [stdout-nolog]) | |
5522 | AT_CHECK([get_final_nw_tos], [0], [none | |
5523 | ]) | |
5524 | ||
5525 | # check at L3 without dscp marking | |
5526 | check_tos 0 | |
5527 | ||
5528 | # Mark DSCP with a valid value | |
5529 | qos_id=$(ovn-nbctl --wait=hv -- --id=@lp1-qos create QoS priority=100 action=dscp=48 match="inport\=\=\"lp1\"" direction="from-lport" -- set Logical_Switch lsw0 qos_rules=@lp1-qos) | |
5530 | check_tos 48 | |
5531 | ||
5532 | # Update the DSCP marking | |
5533 | ovn-nbctl --wait=hv set QoS $qos_id action=dscp=63 | |
5534 | check_tos 63 | |
5535 | ||
5536 | ovn-nbctl --wait=hv set QoS $qos_id match="outport\=\=\"lp2\"" direction="to-lport" | |
5537 | check_tos 63 | |
5538 | ||
5539 | # Disable DSCP marking | |
5540 | ovn-nbctl --wait=hv clear Logical_Switch lsw0 qos_rules | |
5541 | check_tos 0 | |
5542 | ||
5543 | OVN_CLEANUP([hv]) | |
57afd0c0 | 5544 | AT_CLEANUP |
7fff4eb7 LR |
5545 | |
5546 | AT_SETUP([ovn -- read-only sb db:ptcp access]) | |
5547 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5548 | ||
5549 | : > .$1.db.~lock~ | |
5550 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
5551 | ||
5552 | # Add read-only remote to sb ovsdb-server | |
5553 | AT_CHECK( | |
5554 | [ovsdb-tool transact ovn-sb.db \ | |
5555 | ['["OVN_Southbound", | |
5556 | {"op": "insert", | |
5557 | "table": "SB_Global", | |
5558 | "row": { | |
5559 | "connections": ["set", [["named-uuid", "xyz"]]]}}, | |
5560 | {"op": "insert", | |
5561 | "table": "Connection", | |
5562 | "uuid-name": "xyz", | |
5563 | "row": {"target": "ptcp:0:127.0.0.1", | |
5564 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
5565 | ||
5566 | start_daemon ovsdb-server --remote=punix:ovn-sb.sock --remote=db:OVN_Southbound,SB_Global,connections ovn-sb.db | |
5567 | ||
5568 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5569 | ||
5570 | # read-only accesses should succeed | |
5571 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT list SB_Global], [0], [stdout], [ignore]) | |
5572 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT list Connection], [0], [stdout], [ignore]) | |
5573 | ||
5574 | # write access should fail | |
5575 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT chassis-add ch vxlan 1.2.4.8], [1], [ignore], | |
5576 | [ovn-sbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
5577 | ]) | |
5578 | ||
5579 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5580 | AT_CLEANUP | |
5581 | ||
5582 | AT_SETUP([ovn -- read-only sb db:pssl access]) | |
5583 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5584 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
5585 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5586 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
5587 | \\]"]) | |
5588 | ||
5589 | : > .$1.db.~lock~ | |
5590 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
5591 | ||
5592 | # Add read-only remote to sb ovsdb-server | |
5593 | AT_CHECK( | |
5594 | [ovsdb-tool transact ovn-sb.db \ | |
5595 | ['["OVN_Southbound", | |
5596 | {"op": "insert", | |
5597 | "table": "SB_Global", | |
5598 | "row": { | |
5599 | "connections": ["set", [["named-uuid", "xyz"]]]}}, | |
5600 | {"op": "insert", | |
5601 | "table": "Connection", | |
5602 | "uuid-name": "xyz", | |
5603 | "row": {"target": "pssl:0:127.0.0.1", | |
5604 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
5605 | ||
5606 | start_daemon ovsdb-server --remote=punix:ovn-sb.sock \ | |
5607 | --remote=db:OVN_Southbound,SB_Global,connections \ | |
5608 | --private-key="$PKIDIR/testpki-privkey2.pem" \ | |
5609 | --certificate="$PKIDIR/testpki-cert2.pem" \ | |
5610 | --ca-cert="$PKIDIR/testpki-cacert.pem" \ | |
5611 | ovn-sb.db | |
5612 | ||
5613 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5614 | ||
5615 | # read-only accesses should succeed | |
5616 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5617 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5618 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5619 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5620 | list SB_Global], [0], [stdout], [ignore]) | |
5621 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5622 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5623 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5624 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5625 | list Connection], [0], [stdout], [ignore]) | |
5626 | ||
5627 | # write access should fail | |
5628 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5629 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5630 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5631 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5632 | chassis-add ch vxlan 1.2.4.8], [1], [ignore], | |
5633 | [ovn-sbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
5634 | ]) | |
5635 | ||
5636 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5637 | AT_CLEANUP | |
5638 | ||
821302cf LR |
5639 | AT_SETUP([ovn -- nb connection/ssl commands]) |
5640 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5641 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
5642 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5643 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
5644 | \\]"]) | |
5645 | ||
5646 | : > .$1.db.~lock~ | |
5647 | ovsdb-tool create ovn-nb.db "$abs_top_srcdir"/ovn/ovn-nb.ovsschema | |
5648 | ||
5649 | # Start nb db server using db connection/ssl entries (unpopulated initially) | |
5650 | start_daemon ovsdb-server --remote=punix:ovnnb_db.sock \ | |
5651 | --remote=db:OVN_Northbound,NB_Global,connections \ | |
5652 | --private-key=db:OVN_Northbound,SSL,private_key \ | |
5653 | --certificate=db:OVN_Northbound,SSL,certificate \ | |
5654 | --ca-cert=db:OVN_Northbound,SSL,ca_cert \ | |
5655 | ovn-nb.db | |
5656 | ||
5657 | # Populate SSL configuration entries in nb db | |
5658 | AT_CHECK( | |
5659 | [ovn-nbctl set-ssl $PKIDIR/testpki-privkey.pem \ | |
5660 | $PKIDIR/testpki-cert.pem \ | |
5661 | $PKIDIR/testpki-cacert.pem], [0], [stdout], [ignore]) | |
5662 | ||
5663 | # Populate a passive SSL connection in nb db | |
5664 | AT_CHECK([ovn-nbctl set-connection pssl:0:127.0.0.1], [0], [stdout], [ignore]) | |
5665 | ||
5666 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5667 | ||
5668 | # Verify SSL connetivity to nb db server | |
5669 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5670 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5671 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5672 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5673 | list NB_Global], | |
5674 | [0], [stdout], [ignore]) | |
5675 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5676 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5677 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5678 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5679 | list Connection], | |
5680 | [0], [stdout], [ignore]) | |
5681 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5682 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
10471820 LR |
5683 | --certificate=$PKIDIR/testpki-cert.pem \ |
5684 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5685 | get-connection], | |
5686 | [0], [stdout], [ignore]) | |
5687 | ||
5688 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5689 | AT_CLEANUP | |
5690 | ||
5691 | AT_SETUP([ovn -- sb connection/ssl commands]) | |
5692 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5693 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
5694 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5695 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
5696 | \\]"]) | |
5697 | ||
5698 | : > .$1.db.~lock~ | |
5699 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
5700 | ||
5701 | # Start sb db server using db connection/ssl entries (unpopulated initially) | |
5702 | start_daemon ovsdb-server --remote=punix:ovnsb_db.sock \ | |
5703 | --remote=db:OVN_Southbound,SB_Global,connections \ | |
5704 | --private-key=db:OVN_Southbound,SSL,private_key \ | |
5705 | --certificate=db:OVN_Southbound,SSL,certificate \ | |
5706 | --ca-cert=db:OVN_Southbound,SSL,ca_cert \ | |
5707 | ovn-sb.db | |
5708 | ||
5709 | # Populate SSL configuration entries in sb db | |
5710 | AT_CHECK( | |
5711 | [ovn-sbctl set-ssl $PKIDIR/testpki-privkey.pem \ | |
5712 | $PKIDIR/testpki-cert.pem \ | |
5713 | $PKIDIR/testpki-cacert.pem], [0], [stdout], [ignore]) | |
5714 | ||
5715 | # Populate a passive SSL connection in sb db | |
5716 | AT_CHECK([ovn-sbctl set-connection pssl:0:127.0.0.1], [0], [stdout], [ignore]) | |
5717 | ||
5718 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5719 | ||
5720 | # Verify SSL connetivity to sb db server | |
5721 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5722 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5723 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5724 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5725 | list SB_Global], | |
5726 | [0], [stdout], [ignore]) | |
5727 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5728 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5729 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5730 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5731 | list Connection], | |
5732 | [0], [stdout], [ignore]) | |
5733 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5734 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
821302cf LR |
5735 | --certificate=$PKIDIR/testpki-cert.pem \ |
5736 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5737 | get-connection], | |
5738 | [0], [stdout], [ignore]) | |
5739 | ||
5740 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5741 | AT_CLEANUP | |
5742 | ||
75fd74f8 GS |
5743 | AT_SETUP([ovn -- nested containers]) |
5744 | ovn_start | |
5745 | ||
5746 | # Physical network: | |
5747 | # 2 HVs. HV1 has 2 VMs - "VM1" and "bar3". HV2 has 1 VM - "VM2" | |
5748 | ||
5749 | # Logical network: | |
5750 | # 3 Logical switches - "mgmt" (172.16.1.0/24), "foo" (192.168.1.0/24) | |
5751 | # and "bar" (192.168.2.0/24). They are all connected to router R1. | |
5752 | ||
5753 | ovn-nbctl lr-add R1 | |
5754 | ovn-nbctl ls-add mgmt | |
5755 | ovn-nbctl ls-add foo | |
5756 | ovn-nbctl ls-add bar | |
5757 | ||
5758 | # Connect mgmt to R1 | |
5759 | ovn-nbctl lrp-add R1 mgmt 00:00:00:01:02:02 172.16.1.1/24 | |
5760 | ovn-nbctl lsp-add mgmt rp-mgmt -- set Logical_Switch_Port rp-mgmt type=router \ | |
5761 | options:router-port=mgmt addresses=\"00:00:00:01:02:02\" | |
5762 | ||
5763 | # Connect foo to R1 | |
5764 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
5765 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
5766 | options:router-port=foo addresses=\"00:00:00:01:02:03\" | |
5767 | ||
5768 | # Connect bar to R1 | |
5769 | ovn-nbctl lrp-add R1 bar 00:00:00:01:02:04 192.168.2.1/24 | |
5770 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar type=router \ | |
5771 | options:router-port=bar addresses=\"00:00:00:01:02:04\" | |
5772 | ||
5773 | # "mgmt" has VM1 and VM2 connected | |
5774 | ovn-nbctl lsp-add mgmt vm1 \ | |
5775 | -- lsp-set-addresses vm1 "f0:00:00:01:02:03 172.16.1.2" | |
5776 | ||
5777 | ovn-nbctl lsp-add mgmt vm2 \ | |
5778 | -- lsp-set-addresses vm2 "f0:00:00:01:02:04 172.16.1.3" | |
5779 | ||
5780 | # "foo1" and "foo2" are containers belonging to switch "foo" | |
5781 | # "foo1" has "VM1" as parent_port and "foo2" has "VM2" as parent_port. | |
5782 | ovn-nbctl lsp-add foo foo1 vm1 1 \ | |
5783 | -- lsp-set-addresses foo1 "f0:00:00:01:02:05 192.168.1.2" | |
5784 | ||
5785 | ovn-nbctl lsp-add foo foo2 vm2 2 \ | |
5786 | -- lsp-set-addresses foo2 "f0:00:00:01:02:06 192.168.1.3" | |
5787 | ||
5788 | # "bar1" and "bar2" are containers belonging to switch "bar" | |
5789 | # "bar1" has "VM1" as parent_port and "bar2" has "VM2" as parent_port. | |
5790 | ovn-nbctl lsp-add bar bar1 vm1 2 \ | |
5791 | -- lsp-set-addresses bar1 "f0:00:00:01:02:07 192.168.2.2" | |
5792 | ||
5793 | ovn-nbctl lsp-add bar bar2 vm2 1 \ | |
5794 | -- lsp-set-addresses bar2 "f0:00:00:01:02:08 192.168.2.3" | |
5795 | ||
5796 | # bar3 is a standalone VM belonging to switch "bar" | |
5797 | ovn-nbctl lsp-add bar bar3 \ | |
5798 | -- lsp-set-addresses bar3 "f0:00:00:01:02:09 192.168.2.4" | |
5799 | ||
5800 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
5801 | net_add n1 | |
5802 | ||
5803 | sim_add hv1 | |
5804 | as hv1 | |
5805 | ovs-vsctl add-br br-phys | |
5806 | ovn_attach n1 br-phys 192.168.0.1 | |
5807 | ovs-vsctl -- add-port br-int vm1 -- \ | |
5808 | set interface vm1 external-ids:iface-id=vm1 \ | |
5809 | options:tx_pcap=hv1/vm1-tx.pcap \ | |
5810 | options:rxq_pcap=hv1/vm1-rx.pcap \ | |
5811 | ofport-request=1 | |
5812 | ||
5813 | ovs-vsctl -- add-port br-int bar3 -- \ | |
5814 | set interface bar3 external-ids:iface-id=bar3 \ | |
5815 | options:tx_pcap=hv1/bar3-tx.pcap \ | |
5816 | options:rxq_pcap=hv1/bar3-rx.pcap \ | |
5817 | ofport-request=2 | |
5818 | ||
5819 | sim_add hv2 | |
5820 | as hv2 | |
5821 | ovs-vsctl add-br br-phys | |
5822 | ovn_attach n1 br-phys 192.168.0.2 | |
5823 | ovs-vsctl -- add-port br-int vm2 -- \ | |
5824 | set interface vm2 external-ids:iface-id=vm2 \ | |
5825 | options:tx_pcap=hv2/vm2-tx.pcap \ | |
5826 | options:rxq_pcap=hv2/vm2-rx.pcap \ | |
5827 | ofport-request=1 | |
5828 | ||
5829 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
5830 | # packets for ARP resolution (native tunneling doesn't queue packets | |
5831 | # for ARP resolution). | |
5832 | ovn_populate_arp | |
5833 | ||
5834 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5835 | # XXX This should be more systematic. | |
5836 | sleep 1 | |
5837 | ||
5838 | ip_to_hex() { | |
5839 | printf "%02x%02x%02x%02x" "$@" | |
5840 | } | |
5841 | ||
5842 | # Send ip packets between foo1 and foo2 (same switch, different HVs and | |
5843 | # different VLAN tags). | |
5844 | src_mac="f00000010205" | |
5845 | dst_mac="f00000010206" | |
5846 | src_ip=`ip_to_hex 192 168 1 2` | |
5847 | dst_ip=`ip_to_hex 192 168 1 3` | |
5848 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5849 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
5850 | ||
5851 | # expected packet at foo2 | |
5852 | packet=${dst_mac}${src_mac}8100000208004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5853 | echo $packet > expected | |
5854 | OVN_CHECK_PACKETS([hv2/vm2-tx.pcap], [expected]) | |
5855 | ||
5856 | # Send ip packets between foo1 and bar2 (different switch, different HV) | |
5857 | src_mac="f00000010205" | |
5858 | dst_mac="000000010203" | |
5859 | src_ip=`ip_to_hex 192 168 1 2` | |
5860 | dst_ip=`ip_to_hex 192 168 2 3` | |
5861 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5862 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
5863 | ||
5864 | # expected packet at bar2 | |
5865 | src_mac="000000010204" | |
5866 | dst_mac="f00000010208" | |
5867 | packet=${dst_mac}${src_mac}8100000108004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
5868 | echo $packet >> expected | |
5869 | OVN_CHECK_PACKETS([hv2/vm2-tx.pcap], [expected]) | |
5870 | ||
5871 | # Send ip packets between foo1 and bar1 | |
5872 | # (different switch, loopback to same vm but different tag) | |
5873 | src_mac="f00000010205" | |
5874 | dst_mac="000000010203" | |
5875 | src_ip=`ip_to_hex 192 168 1 2` | |
5876 | dst_ip=`ip_to_hex 192 168 2 2` | |
5877 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5878 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
5879 | ||
5880 | # expected packet at bar1 | |
5881 | src_mac="000000010204" | |
5882 | dst_mac="f00000010207" | |
5883 | packet=${dst_mac}${src_mac}8100000208004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
5884 | echo $packet > expected1 | |
5885 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
5886 | ||
5887 | # Send ip packets between bar1 and bar3 | |
5888 | # (same switch. But one is container and another is a standalone VM) | |
5889 | src_mac="f00000010207" | |
5890 | dst_mac="f00000010209" | |
5891 | src_ip=`ip_to_hex 192 168 2 2` | |
5892 | dst_ip=`ip_to_hex 192 168 2 3` | |
5893 | packet=${dst_mac}${src_mac}8100000208004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5894 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
5895 | ||
5896 | # expected packet at bar3 | |
5897 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5898 | echo $packet > expected | |
5899 | OVN_CHECK_PACKETS([hv1/bar3-tx.pcap], [expected]) | |
5900 | ||
5901 | # Send ip packets between foo1 and vm1. | |
5902 | (different switch, container to the VM hosting it.) | |
5903 | src_mac="f00000010205" | |
5904 | dst_mac="000000010203" | |
5905 | src_ip=`ip_to_hex 192 168 1 2` | |
5906 | dst_ip=`ip_to_hex 172 16 1 2` | |
5907 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5908 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
5909 | ||
5910 | # expected packet at vm1 | |
5911 | src_mac="000000010202" | |
5912 | dst_mac="f00000010203" | |
5913 | packet=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
5914 | echo $packet >> expected1 | |
5915 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
5916 | ||
5917 | # Send packets from vm1 to bar1. | |
5918 | (different switch, A hosting VM to a container inside it) | |
5919 | src_mac="f00000010203" | |
5920 | dst_mac="000000010202" | |
5921 | src_ip=`ip_to_hex 172 16 1 2` | |
5922 | dst_ip=`ip_to_hex 192 168 2 2` | |
5923 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5924 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
5925 | ||
5926 | # expected packet at vm1 | |
5927 | src_mac="000000010204" | |
5928 | dst_mac="f00000010207" | |
5929 | packet=${dst_mac}${src_mac}8100000208004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
5930 | echo $packet >> expected1 | |
5931 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
5932 | ||
5933 | OVN_CLEANUP([hv1],[hv2]) | |
5934 | ||
5935 | AT_CLEANUP | |
440a9f4b GS |
5936 | |
5937 | AT_SETUP([ovn -- 3 HVs, 3 LRs connected via LS, source IP based routes]) | |
5938 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5939 | ovn_start | |
5940 | ||
5941 | # Logical network: | |
5942 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
5943 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) and bar | |
5944 | # (192.168.2.0/24) connected to it. | |
5945 | # | |
5946 | # R2 and R3 are gateway routers. | |
5947 | # R2 has alice (172.16.1.0/24) and R3 has bob (172.16.1.0/24) | |
5948 | # connected to it. Note how both alice and bob have the same subnet behind it. | |
5949 | # We are trying to simulate external network via those 2 switches. In real | |
5950 | # world the switch ports of these switches will have addresses set as "unknown" | |
5951 | # to make them learning switches. Or those switches will be "localnet" ones. | |
5952 | ||
5953 | # Create three hypervisors and create OVS ports corresponding to logical ports. | |
5954 | net_add n1 | |
5955 | ||
5956 | sim_add hv1 | |
5957 | as hv1 | |
5958 | ovs-vsctl add-br br-phys | |
5959 | ovn_attach n1 br-phys 192.168.0.1 | |
5960 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
5961 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
5962 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
5963 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
5964 | ofport-request=1 | |
5965 | ||
5966 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
5967 | set interface hv1-vif2 external-ids:iface-id=bar1 \ | |
5968 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
5969 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
5970 | ofport-request=2 | |
5971 | ||
5972 | sim_add hv2 | |
5973 | as hv2 | |
5974 | ovs-vsctl add-br br-phys | |
5975 | ovn_attach n1 br-phys 192.168.0.2 | |
5976 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
5977 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
5978 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
5979 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
5980 | ofport-request=1 | |
5981 | ||
5982 | sim_add hv3 | |
5983 | as hv3 | |
5984 | ovs-vsctl add-br br-phys | |
5985 | ovn_attach n1 br-phys 192.168.0.3 | |
5986 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
5987 | set interface hv3-vif1 external-ids:iface-id=bob1 \ | |
5988 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
5989 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
5990 | ofport-request=1 | |
5991 | ||
5992 | ||
5993 | ovn-nbctl create Logical_Router name=R1 | |
5994 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
5995 | ovn-nbctl create Logical_Router name=R3 options:chassis="hv3" | |
5996 | ||
5997 | ovn-nbctl ls-add foo | |
5998 | ovn-nbctl ls-add bar | |
5999 | ovn-nbctl ls-add alice | |
6000 | ovn-nbctl ls-add bob | |
6001 | ovn-nbctl ls-add join | |
6002 | ||
6003 | # Connect foo to R1 | |
6004 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
6005 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
6006 | options:router-port=foo addresses=\"00:00:01:01:02:03\" | |
6007 | ||
6008 | # Connect bar to R1 | |
6009 | ovn-nbctl lrp-add R1 bar 00:00:01:01:02:04 192.168.2.1/24 | |
6010 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar type=router \ | |
6011 | options:router-port=bar addresses=\"00:00:01:01:02:04\" | |
6012 | ||
6013 | # Connect alice to R2 | |
6014 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
6015 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
6016 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" | |
6017 | ||
6018 | # Connect bob to R3 | |
6019 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 172.16.1.2/24 | |
6020 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ | |
6021 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" | |
6022 | ||
6023 | # Connect R1 to join | |
6024 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 | |
6025 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ | |
6026 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' | |
6027 | ||
6028 | # Connect R2 to join | |
6029 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
6030 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ | |
6031 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' | |
6032 | ||
6033 | # Connect R3 to join | |
6034 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 | |
6035 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ | |
6036 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' | |
6037 | ||
6038 | # Install static routes with source ip address as the policy for routing. | |
6039 | # We want traffic from 'foo' to go via R2 and traffic of 'bar' to go via R3. | |
6040 | ovn-nbctl --policy="src-ip" lr-route-add R1 192.168.1.0/24 20.0.0.2 | |
6041 | ovn-nbctl --policy="src-ip" lr-route-add R1 192.168.2.0/24 20.0.0.3 | |
6042 | ||
6043 | # Install static routes with destination ip address as the policy for routing. | |
6044 | ovn-nbctl lr-route-add R2 192.168.0.0/16 20.0.0.1 | |
6045 | ||
6046 | ovn-nbctl lr-route-add R3 192.168.0.0/16 20.0.0.1 | |
6047 | ||
6048 | # Create logical port foo1 in foo | |
6049 | ovn-nbctl lsp-add foo foo1 \ | |
6050 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
6051 | ||
6052 | # Create logical port bar1 in bar | |
6053 | ovn-nbctl lsp-add bar bar1 \ | |
6054 | -- lsp-set-addresses bar1 "f0:00:00:01:02:04 192.168.2.2" | |
6055 | ||
6056 | # Create logical port alice1 in alice | |
6057 | ovn-nbctl lsp-add alice alice1 \ | |
6058 | -- lsp-set-addresses alice1 "f0:00:00:01:02:05 172.16.1.3" | |
6059 | ||
6060 | # Create logical port bob1 in bob | |
6061 | ovn-nbctl lsp-add bob bob1 \ | |
6062 | -- lsp-set-addresses bob1 "f0:00:00:01:02:06 172.16.1.4" | |
6063 | ||
6064 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
6065 | # packets for ARP resolution (native tunneling doesn't queue packets | |
6066 | # for ARP resolution). | |
6067 | ovn_populate_arp | |
6068 | ||
6069 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6070 | # XXX This should be more systematic. | |
6071 | sleep 1 | |
6072 | ||
6073 | ip_to_hex() { | |
6074 | printf "%02x%02x%02x%02x" "$@" | |
6075 | } | |
6076 | trim_zeros() { | |
6077 | sed 's/\(00\)\{1,\}$//' | |
6078 | } | |
6079 | ||
6080 | # Send ip packets between foo1 and bar1 | |
6081 | # (East-west traffic should flow normally) | |
6082 | src_mac="f00000010203" | |
6083 | dst_mac="000001010203" | |
6084 | src_ip=`ip_to_hex 192 168 1 2` | |
6085 | dst_ip=`ip_to_hex 192 168 2 2` | |
6086 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6087 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
6088 | ||
6089 | # Send ip packets between foo1 and alice1 | |
6090 | src_mac="f00000010203" | |
6091 | dst_mac="000001010203" | |
6092 | src_ip=`ip_to_hex 192 168 1 2` | |
6093 | dst_ip=`ip_to_hex 172 16 1 3` | |
6094 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6095 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
2d9b49dd | 6096 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet |
440a9f4b GS |
6097 | |
6098 | # Send ip packets between bar1 and bob1 | |
6099 | src_mac="f00000010204" | |
6100 | dst_mac="000001010204" | |
6101 | src_ip=`ip_to_hex 192 168 2 2` | |
6102 | dst_ip=`ip_to_hex 172 16 1 4` | |
6103 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6104 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif2 $packet | |
6105 | #as hv1 ovs-appctl ofproto/trace br-int in_port=2 $packet | |
6106 | ||
6107 | # Packet to expect at bar1 | |
6108 | src_mac="000001010204" | |
6109 | dst_mac="f00000010204" | |
6110 | src_ip=`ip_to_hex 192 168 1 2` | |
6111 | dst_ip=`ip_to_hex 192 168 2 2` | |
6112 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6113 | echo $expected > expected | |
6114 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) | |
6115 | ||
6116 | # Packet to Expect at alice1 | |
6117 | src_mac="000002010203" | |
6118 | dst_mac="f00000010205" | |
6119 | src_ip=`ip_to_hex 192 168 1 2` | |
6120 | dst_ip=`ip_to_hex 172 16 1 3` | |
6121 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
6122 | echo $expected > expected | |
6123 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
6124 | ||
6125 | # Packet to Expect at bob1 | |
6126 | src_mac="000003010203" | |
6127 | dst_mac="f00000010206" | |
6128 | src_ip=`ip_to_hex 192 168 2 2` | |
6129 | dst_ip=`ip_to_hex 172 16 1 4` | |
6130 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
6131 | echo $expected > expected | |
6132 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [expected]) | |
6133 | ||
6134 | for sim in hv1 hv2 hv3; do | |
6135 | as $sim | |
6136 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
6137 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6138 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6139 | done | |
6140 | ||
6141 | as ovn-sb | |
6142 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6143 | ||
6144 | as ovn-nb | |
6145 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6146 | ||
6147 | as northd | |
6148 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
6149 | ||
6150 | as main | |
6151 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6152 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6153 | ||
6154 | AT_CLEANUP | |
41a15b71 MS |
6155 | |
6156 | AT_SETUP([ovn -- 1 LR with distributed router gateway port]) | |
6157 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
6158 | ovn_start | |
6159 | ||
6160 | # Logical network: | |
6161 | # One LR R1 that has switches foo (192.168.1.0/24) and | |
6162 | # alice (172.16.1.0/24) connected to it. The logical port | |
6163 | # between R1 and alice has a "redirect-chassis" specified, | |
6164 | # i.e. it is the distributed router gateway port. | |
6165 | # Switch alice also has a localnet port defined. | |
6166 | # An additional switch outside has a localnet port and the | |
6167 | # same subnet as alice (172.16.1.0/24). | |
6168 | ||
6169 | # Physical network: | |
6170 | # Three hypervisors hv[123]. | |
6171 | # hv1 hosts vif foo1. | |
6172 | # hv2 is the "redirect-chassis" that hosts the distributed | |
6173 | # router gateway port. | |
6174 | # hv3 hosts vif outside1. | |
6175 | # In order to show that connectivity works only through hv2, | |
6176 | # an initial round of tests is run without any bridge-mapping | |
6177 | # defined for the localnet on hv2. These tests are expected | |
6178 | # to fail. | |
6179 | # Subsequent tests are run after defining the bridge-mapping | |
6180 | # for the localnet on hv2. These tests are expected to succeed. | |
6181 | ||
6182 | # Create three hypervisors and create OVS ports corresponding | |
6183 | to logical ports. | |
6184 | net_add n1 | |
6185 | ||
6186 | sim_add hv1 | |
6187 | as hv1 | |
6188 | ovs-vsctl add-br br-phys | |
6189 | ovn_attach n1 br-phys 192.168.0.1 | |
6190 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
6191 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
6192 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
6193 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
6194 | ofport-request=1 | |
6195 | ||
6196 | sim_add hv2 | |
6197 | as hv2 | |
6198 | ovs-vsctl add-br br-phys | |
6199 | ovn_attach n1 br-phys 192.168.0.2 | |
6200 | ||
6201 | sim_add hv3 | |
6202 | as hv3 | |
6203 | ovs-vsctl add-br br-phys | |
6204 | ovn_attach n1 br-phys 192.168.0.3 | |
6205 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
6206 | set interface hv3-vif1 external-ids:iface-id=outside1 \ | |
6207 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
6208 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
6209 | ofport-request=1 | |
6210 | ||
6211 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
6212 | # packets for ARP resolution (native tunneling doesn't queue packets | |
6213 | # for ARP resolution). | |
6214 | ovn_populate_arp | |
6215 | ||
6216 | ovn-nbctl create Logical_Router name=R1 | |
6217 | ||
6218 | ovn-nbctl ls-add foo | |
6219 | ovn-nbctl ls-add alice | |
6220 | ovn-nbctl ls-add outside | |
6221 | ||
6222 | # Connect foo to R1 | |
6223 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
6224 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
6225 | type=router options:router-port=foo \ | |
6226 | -- lsp-set-addresses rp-foo router | |
6227 | ||
6228 | # Connect alice to R1 as distributed router gateway port on hv2 | |
6229 | ovn-nbctl lrp-add R1 alice 00:00:02:01:02:03 172.16.1.1/24 \ | |
6230 | -- set Logical_Router_Port alice options:redirect-chassis="hv2" | |
6231 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
6232 | type=router options:router-port=alice \ | |
6233 | -- lsp-set-addresses rp-alice router | |
6234 | ||
6235 | # Create logical port foo1 in foo | |
6236 | ovn-nbctl lsp-add foo foo1 \ | |
6237 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
6238 | ||
6239 | # Create logical port outside1 in outside | |
6240 | ovn-nbctl lsp-add outside outside1 \ | |
6241 | -- lsp-set-addresses outside1 "f0:00:00:01:02:04 172.16.1.3" | |
6242 | ||
6243 | # Create localnet port in alice | |
6244 | ovn-nbctl lsp-add alice ln-alice | |
6245 | ovn-nbctl lsp-set-addresses ln-alice unknown | |
6246 | ovn-nbctl lsp-set-type ln-alice localnet | |
6247 | ovn-nbctl lsp-set-options ln-alice network_name=phys | |
6248 | ||
6249 | # Create localnet port in outside | |
6250 | ovn-nbctl lsp-add outside ln-outside | |
6251 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
6252 | ovn-nbctl lsp-set-type ln-outside localnet | |
6253 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
6254 | ||
6255 | # Create bridge-mappings on hv1 and hv3, leaving hv2 for later | |
6256 | as hv1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
6257 | as hv3 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
6258 | ||
6259 | ||
6260 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6261 | # XXX This should be more systematic. | |
6262 | sleep 2 | |
6263 | ||
6264 | echo "---------NB dump-----" | |
6265 | ovn-nbctl show | |
6266 | echo "---------------------" | |
6267 | ovn-nbctl list logical_router | |
6268 | echo "---------------------" | |
6269 | ovn-nbctl list logical_router_port | |
6270 | echo "---------------------" | |
6271 | ||
6272 | echo "---------SB dump-----" | |
6273 | ovn-sbctl list datapath_binding | |
6274 | echo "---------------------" | |
6275 | ovn-sbctl list port_binding | |
6276 | echo "---------------------" | |
6277 | ovn-sbctl dump-flows | |
6278 | echo "---------------------" | |
6279 | ovn-sbctl list chassis | |
6280 | ovn-sbctl list encap | |
6281 | echo "---------------------" | |
6282 | ||
6283 | echo "------ hv1 dump ----------" | |
6284 | as hv1 ovs-ofctl show br-int | |
6285 | as hv1 ovs-ofctl dump-flows br-int | |
6286 | echo "------ hv2 dump ----------" | |
6287 | as hv2 ovs-ofctl show br-int | |
6288 | as hv2 ovs-ofctl dump-flows br-int | |
6289 | echo "------ hv3 dump ----------" | |
6290 | as hv3 ovs-ofctl show br-int | |
6291 | as hv3 ovs-ofctl dump-flows br-int | |
6292 | echo "--------------------------" | |
6293 | ||
6294 | # Check that redirect mapping is programmed only on hv2 | |
6295 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 | wc -l], [0], [0 | |
6296 | ]) | |
6297 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 | grep load:0x2- | wc -l], [0], [1 | |
6298 | ]) | |
6299 | # Check that hv1 sends chassisredirect port traffic to hv2 | |
6300 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 | grep output | wc -l], [0], [1 | |
6301 | ]) | |
6302 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 | wc -l], [0], [0 | |
6303 | ]) | |
6304 | # Check that arp reply on distributed gateway port is only programmed on hv2 | |
6305 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep arp | grep =0x2,metadata=0x1 | wc -l], [0], [0 | |
6306 | ]) | |
6307 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep arp | grep =0x2,metadata=0x1 | wc -l], [0], [1 | |
6308 | ]) | |
6309 | ||
6310 | ||
6311 | ip_to_hex() { | |
6312 | printf "%02x%02x%02x%02x" "$@" | |
6313 | } | |
6314 | ||
6315 | ||
6316 | : > hv2-vif1.expected | |
6317 | : > hv3-vif1.expected | |
6318 | ||
6319 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
6320 | # | |
6321 | # Causes a packet to be received on INPORT. The packet is an ARP | |
6322 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
6323 | # it should be the hardware address of the target to expect to receive in an | |
6324 | # ARP reply; otherwise no reply is expected. | |
6325 | # | |
6326 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
6327 | # SHA and REPLY_HA are each 12 hex digits. | |
6328 | # SPA and TPA are each 8 hex digits. | |
6329 | test_arp() { | |
6330 | local hv=$1 inport=$2 sha=$3 spa=$4 tpa=$5 reply_ha=$6 | |
6331 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
6332 | as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request | |
6333 | ||
6334 | if test X$reply_ha != X; then | |
6335 | # Expect to receive the reply, if any. | |
6336 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
6337 | echo $reply >> hv${hv}-vif$inport.expected | |
6338 | fi | |
6339 | } | |
6340 | ||
6341 | rtr_ip=$(ip_to_hex 172 16 1 1) | |
6342 | foo_ip=$(ip_to_hex 192 168 1 2) | |
6343 | outside_ip=$(ip_to_hex 172 16 1 3) | |
6344 | ||
6345 | echo $rtr_ip | |
6346 | echo $foo_ip | |
6347 | echo $outside_ip | |
6348 | ||
6349 | # ARP for router IP address from outside1, no response expected | |
6350 | test_arp 3 1 f00000010204 $outside_ip $rtr_ip | |
6351 | ||
6352 | # Now check the packets actually received against the ones expected. | |
6353 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
6354 | ||
6355 | # Send ip packet between foo1 and outside1 | |
6356 | src_mac="f00000010203" | |
6357 | dst_mac="000001010203" | |
6358 | src_ip=`ip_to_hex 192 168 1 2` | |
6359 | dst_ip=`ip_to_hex 172 16 1 3` | |
6360 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6361 | ||
6362 | # Now check the packets actually received against the ones expected. | |
6363 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
6364 | ||
6365 | # Now add bridge-mappings on hv2, which should make everything work | |
6366 | as hv2 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
6367 | ||
6368 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6369 | # XXX This should be more systematic. | |
6370 | sleep 2 | |
6371 | ||
6372 | # ARP for router IP address from outside1 | |
6373 | test_arp 3 1 f00000010204 $outside_ip $rtr_ip 000002010203 | |
6374 | ||
6375 | # Now check the packets actually received against the ones expected. | |
6376 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
6377 | ||
6378 | # Send ip packet between foo1 and outside1 | |
6379 | src_mac="f00000010203" | |
6380 | dst_mac="000001010203" | |
6381 | src_ip=`ip_to_hex 192 168 1 2` | |
6382 | dst_ip=`ip_to_hex 172 16 1 3` | |
6383 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6384 | ||
6385 | # ARP request packet to expect at outside1 | |
6386 | src_mac="000002010203" | |
6387 | src_ip=`ip_to_hex 172 16 1 1` | |
6388 | arp_request=ffffffffffff${src_mac}08060001080006040001${src_mac}${src_ip}000000000000${dst_ip} | |
6389 | ||
6390 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
6391 | ||
6392 | echo $arp_request >> hv3-vif1.expected | |
6393 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
6394 | ||
6395 | # Send ARP reply from outside1 back to the router | |
6396 | reply_mac="f00000010204" | |
6397 | arp_reply=${src_mac}${reply_mac}08060001080006040002${reply_mac}${dst_ip}${src_mac}${src_ip} | |
6398 | ||
6399 | as hv3 ovs-appctl netdev-dummy/receive hv3-vif1 $arp_reply | |
6400 | ||
6401 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6402 | # XXX This should be more systematic. | |
6403 | sleep 1 | |
6404 | ||
6405 | # Packet to Expect at outside1 | |
6406 | src_mac="000002010203" | |
6407 | dst_mac="f00000010204" | |
6408 | src_ip=`ip_to_hex 192 168 1 2` | |
6409 | dst_ip=`ip_to_hex 172 16 1 3` | |
6410 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6411 | ||
6412 | # Resend packet from foo1 to outside1 | |
6413 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
6414 | ||
6415 | echo "------ hv1 dump ----------" | |
6416 | as hv1 ovs-ofctl show br-int | |
6417 | as hv1 ovs-ofctl dump-flows br-int | |
6418 | echo "------ hv2 dump ----------" | |
6419 | as hv2 ovs-ofctl show br-int | |
6420 | as hv2 ovs-ofctl dump-flows br-int | |
6421 | echo "------ hv3 dump ----------" | |
6422 | as hv3 ovs-ofctl show br-int | |
6423 | as hv3 ovs-ofctl dump-flows br-int | |
6424 | echo "----------------------------" | |
6425 | ||
6426 | echo $expected >> hv3-vif1.expected | |
6427 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
6428 | ||
6429 | #Check ovn-trace over "chassisredirect" port | |
6430 | AT_CAPTURE_FILE([trace]) | |
6431 | ovn_trace () { | |
6432 | ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' | |
6433 | } | |
6434 | ||
6435 | echo 'ip.ttl--;' > expout | |
6436 | echo 'eth.src = 00:00:02:01:02:03;' >> expout | |
6437 | echo 'eth.dst = f0:00:00:01:02:04;' >> expout | |
6438 | echo 'output("ln-alice");' >> expout | |
6439 | AT_CHECK_UNQUOTED([ovn_trace foo 'inport == "foo1" && eth.src == f0:00:00:01:02:03 && eth.dst == 00:00:01:01:02:03 && ip4.src == 192.168.1.2 && ip4.dst == 172.16.1.3 && ip.ttl == 0xff'], [0], [expout]) | |
6440 | ||
6441 | # Create logical port alice1 in alice on hv1 | |
6442 | as hv1 ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
6443 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
6444 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
6445 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
6446 | ofport-request=1 | |
6447 | ||
6448 | ovn-nbctl lsp-add alice alice1 \ | |
6449 | -- lsp-set-addresses alice1 "f0:00:00:01:02:05 172.16.1.4" | |
6450 | ||
6451 | # Create logical port foo2 in foo on hv2 | |
6452 | as hv2 ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
6453 | set interface hv2-vif1 external-ids:iface-id=foo2 \ | |
6454 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
6455 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
6456 | ofport-request=1 | |
6457 | ||
6458 | ovn-nbctl lsp-add foo foo2 \ | |
6459 | -- lsp-set-addresses foo2 "f0:00:00:01:02:06 192.168.1.3" | |
6460 | ||
6461 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6462 | # XXX This should be more systematic. | |
6463 | sleep 1 | |
6464 | ||
6465 | : > hv1-vif2.expected | |
6466 | ||
6467 | # Send ip packet between alice1 and foo2 | |
6468 | src_mac="f00000010205" | |
6469 | dst_mac="000002010203" | |
6470 | src_ip=`ip_to_hex 172 16 1 4` | |
6471 | dst_ip=`ip_to_hex 192 168 1 3` | |
6472 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6473 | ||
6474 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif2 $packet | |
6475 | ||
6476 | # Packet to Expect at foo2 | |
6477 | src_mac="000001010203" | |
6478 | dst_mac="f00000010206" | |
6479 | src_ip=`ip_to_hex 172 16 1 4` | |
6480 | dst_ip=`ip_to_hex 192 168 1 3` | |
6481 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6482 | ||
6483 | echo $expected >> hv2-vif1.expected | |
6484 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [hv2-vif1.expected]) | |
6485 | ||
6486 | OVN_CLEANUP([hv1],[hv2],[hv3]) | |
6487 | ||
6488 | AT_CLEANUP |