]>
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"` | |
697f5993 BP |
20 | OVS_WAIT_UNTIL( |
21 | [$PYTHON "$top_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text | |
22 | rcv_n=`wc -l < "$rcv_text"` | |
23 | echo "rcv_n=$rcv_n exp_n=$exp_n" | |
24 | test $rcv_n -ge $exp_n]) | |
e4543cfe | 25 | sort $exp_text > expout |
49d7c759 BP |
26 | } |
27 | ]) | |
28 | m4_define([OVN_CHECK_PACKETS], | |
29 | [ovn_check_packets__ "$1" "$2" | |
30 | AT_CHECK([sort $rcv_text], [0], [expout])]) | |
31 | ||
f295c17b | 32 | AT_BANNER([OVN components]) |
10b1662b BP |
33 | |
34 | AT_SETUP([ovn -- lexer]) | |
35 | dnl For lines without =>, input and expected output are identical. | |
36 | dnl For lines with =>, input precedes => and expected output follows =>. | |
37 | AT_DATA([test-cases.txt], [dnl | |
38 | foo bar baz quuxquuxquux _abcd_ a.b.c.d a123_.456 | |
39 | "abc\u0020def" => "abc def" | |
40 | " => error("Input ends inside quoted string.")dnl " | |
41 | ||
2c5cbb15 RB |
42 | $foo $bar $baz $quuxquuxquux $_abcd_ $a.b.c.d $a123_.456 |
43 | $1 => error("`$' must be followed by a valid identifier.") 1 | |
44 | ||
10b1662b BP |
45 | a/*b*/c => a c |
46 | a//b c => a | |
47 | a/**/b => a b | |
48 | a/*/b => a error("`/*' without matching `*/'.") | |
49 | a/*/**/b => a b | |
50 | a/b => a error("`/' is only valid as part of `//' or `/*'.") b | |
51 | ||
52 | 0 1 12345 18446744073709551615 | |
53 | 18446744073709551616 => error("Decimal constants must be less than 2**64.") | |
54 | 9999999999999999999999 => error("Decimal constants must be less than 2**64.") | |
55 | 01 => error("Decimal constants must not have leading zeros.") | |
56 | ||
57 | 0/0 | |
58 | 0/1 | |
59 | 1/0 => error("Value contains unmasked 1-bits.") | |
60 | 1/1 | |
61 | 128/384 | |
62 | 1/3 | |
63 | 1/ => error("Integer constant expected.") | |
64 | ||
65 | 1/0x123 => error("Value and mask have incompatible formats.") | |
66 | ||
67 | 0x1234 | |
68 | 0x01234 => 0x1234 | |
69 | 0x0 => 0 | |
70 | 0x000 => 0 | |
71 | 0xfedcba9876543210 | |
72 | 0XFEDCBA9876543210 => 0xfedcba9876543210 | |
73 | 0xfedcba9876543210fedcba9876543210 | |
10b1662b BP |
74 | 0x0000fedcba9876543210fedcba9876543210 => 0xfedcba9876543210fedcba9876543210 |
75 | 0x => error("Hex digits expected following 0x.") | |
76 | 0X => error("Hex digits expected following 0X.") | |
77 | 0x0/0x0 => 0/0 | |
78 | 0x0/0x1 => 0/0x1 | |
79 | 0x1/0x0 => error("Value contains unmasked 1-bits.") | |
80 | 0xffff/0x1ffff | |
81 | 0x. => error("Invalid syntax in hexadecimal constant.") | |
82 | ||
83 | 192.168.128.1 1.2.3.4 255.255.255.255 0.0.0.0 | |
84 | 256.1.2.3 => error("Invalid numeric constant.") | |
85 | 192.168.0.0/16 | |
86 | 192.168.0.0/255.255.0.0 => 192.168.0.0/16 | |
87 | 192.168.0.0/255.255.255.0 => 192.168.0.0/24 | |
88 | 192.168.0.0/255.255.0.255 | |
89 | 192.168.0.0/255.0.0.0 => error("Value contains unmasked 1-bits.") | |
90 | 192.168.0.0/32 | |
91 | 192.168.0.0/255.255.255.255 => 192.168.0.0/32 | |
52c0fc39 | 92 | 1.2.3.4:5 => 1.2.3.4 : 5 |
10b1662b BP |
93 | |
94 | :: | |
95 | ::1 | |
96 | ff00::1234 => ff00::1234 | |
97 | 2001:db8:85a3::8a2e:370:7334 | |
98 | 2001:db8:85a3:0:0:8a2e:370:7334 => 2001:db8:85a3::8a2e:370:7334 | |
99 | 2001:0db8:85a3:0000:0000:8a2e:0370:7334 => 2001:db8:85a3::8a2e:370:7334 | |
100 | ::ffff:192.0.2.128 | |
101 | ::ffff:c000:0280 => ::ffff:192.0.2.128 | |
102 | ::1/::1 | |
103 | ::1/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff => ::1/128 | |
104 | ::1/128 | |
105 | ff00::/8 | |
106 | ff00::/ff00:: => ff00::/8 | |
107 | ||
108 | 01:23:45:67:ab:cd | |
109 | 01:23:45:67:AB:CD => 01:23:45:67:ab:cd | |
110 | fe:dc:ba:98:76:54 | |
111 | FE:DC:ba:98:76:54 => fe:dc:ba:98:76:54 | |
112 | 01:00:00:00:00:00/01:00:00:00:00:00 | |
113 | ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff | |
114 | fe:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff | |
115 | ff:ff:ff:ff:ff:ff/fe:ff:ff:ff:ff:ff => error("Value contains unmasked 1-bits.") | |
116 | fe:x => error("Invalid numeric constant.") | |
117 | 00:01:02:03:04:x => error("Invalid numeric constant.") | |
118 | ||
a20c96c6 | 119 | # Test that operators are tokenized as expected, even without white space. |
52c0fc39 | 120 | (){}[[]]==!=<<=>>=!&&||..,;=<->--: => ( ) { } [[ ]] == != < <= > >= ! && || .. , ; = <-> -- : |
10b1662b BP |
121 | & => error("`&' is only valid as part of `&&'.") |
122 | | => error("`|' is only valid as part of `||'.") | |
56091efe | 123 | - => error("`-' is only valid as part of `--'.") |
10b1662b BP |
124 | |
125 | ^ => error("Invalid character `^' in input.") | |
126 | ]) | |
127 | AT_CAPTURE_FILE([input.txt]) | |
128 | sed 's/ =>.*//' test-cases.txt > input.txt | |
129 | sed 's/.* => //' test-cases.txt > expout | |
130 | AT_CHECK([ovstest test-ovn lex < input.txt], [0], [expout]) | |
131 | AT_CLEANUP | |
e0840f11 | 132 | |
7700eea0 BP |
133 | dnl The OVN expression parser needs to know what fields overlap with one |
134 | dnl another. This test therefore verifies that all the smaller registers | |
135 | dnl are defined as terms of subfields of the larger ones. | |
136 | dnl | |
137 | dnl When we add or remove registers this test needs to be updated, of course. | |
138 | AT_SETUP([ovn -- registers]) | |
139 | AT_CHECK([ovstest test-ovn dump-symtab | grep reg | sort], [0], | |
140 | [[reg0 = xxreg0[96..127] | |
141 | reg1 = xxreg0[64..95] | |
142 | reg2 = xxreg0[32..63] | |
143 | reg3 = xxreg0[0..31] | |
144 | reg4 = xxreg1[96..127] | |
145 | reg5 = xxreg1[64..95] | |
146 | reg6 = xxreg1[32..63] | |
147 | reg7 = xxreg1[0..31] | |
148 | reg8 = xreg4[32..63] | |
149 | reg9 = xreg4[0..31] | |
150 | xreg0 = xxreg0[64..127] | |
151 | xreg1 = xxreg0[0..63] | |
152 | xreg2 = xxreg1[64..127] | |
153 | xreg3 = xxreg1[0..63] | |
154 | xreg4 = OXM_OF_PKT_REG4 | |
155 | xxreg0 = NXM_NX_XXREG0 | |
156 | xxreg1 = NXM_NX_XXREG1 | |
157 | ]]) | |
158 | AT_CLEANUP | |
159 | ||
2277b860 BP |
160 | dnl Check that the OVN conntrack field definitions are correct. |
161 | AT_SETUP([ovn -- conntrack fields]) | |
162 | AT_CHECK([ovstest test-ovn dump-symtab | grep ^ct | sort], [0], | |
858c2f76 GS |
163 | [[ct.dnat = ct_state[7] |
164 | ct.est = ct_state[1] | |
2277b860 BP |
165 | ct.inv = ct_state[4] |
166 | ct.new = ct_state[0] | |
167 | ct.rel = ct_state[2] | |
168 | ct.rpl = ct_state[3] | |
858c2f76 | 169 | ct.snat = ct_state[6] |
2277b860 BP |
170 | ct.trk = ct_state[5] |
171 | ct_label = NXM_NX_CT_LABEL | |
b73db61d | 172 | ct_label.blocked = ct_label[0] |
2277b860 BP |
173 | ct_mark = NXM_NX_CT_MARK |
174 | ct_state = NXM_NX_CT_STATE | |
175 | ]]) | |
176 | AT_CLEANUP | |
177 | ||
fb8635c5 | 178 | AT_SETUP([ovn -- composition]) |
42d36b58 AZ |
179 | AT_CHECK([ovstest test-ovn composition 2], [0], [ignore]) |
180 | AT_CLEANUP | |
181 | ||
e0840f11 BP |
182 | AT_SETUP([ovn -- expression parser]) |
183 | dnl For lines without =>, input and expected output are identical. | |
184 | dnl For lines with =>, input precedes => and expected output follows =>. | |
185 | AT_DATA([test-cases.txt], [[ | |
186 | eth.type == 0x800 | |
187 | eth.type==0x800 => eth.type == 0x800 | |
188 | eth.type[0..15] == 0x800 => eth.type == 0x800 | |
189 | ||
190 | vlan.present | |
191 | vlan.present == 1 => vlan.present | |
192 | !(vlan.present == 0) => vlan.present | |
193 | !(vlan.present != 1) => vlan.present | |
194 | !vlan.present | |
195 | vlan.present == 0 => !vlan.present | |
196 | vlan.present != 1 => !vlan.present | |
197 | !(vlan.present == 1) => !vlan.present | |
198 | !(vlan.present != 0) => !vlan.present | |
199 | ||
200 | eth.dst[0] | |
201 | eth.dst[0] == 1 => eth.dst[0] | |
202 | eth.dst[0] != 0 => eth.dst[0] | |
203 | !(eth.dst[0] == 0) => eth.dst[0] | |
204 | !(eth.dst[0] != 1) => eth.dst[0] | |
205 | ||
206 | !eth.dst[0] | |
207 | eth.dst[0] == 0 => !eth.dst[0] | |
208 | eth.dst[0] != 1 => !eth.dst[0] | |
209 | !(eth.dst[0] == 1) => !eth.dst[0] | |
210 | !(eth.dst[0] != 0) => !eth.dst[0] | |
211 | ||
212 | vlan.tci[12..15] == 0x3 | |
213 | vlan.tci == 0x3000/0xf000 => vlan.tci[12..15] == 0x3 | |
214 | vlan.tci[12..15] != 0x3 | |
215 | vlan.tci != 0x3000/0xf000 => vlan.tci[12..15] != 0x3 | |
216 | ||
217 | !vlan.pcp => vlan.pcp == 0 | |
218 | !(vlan.pcp) => vlan.pcp == 0 | |
219 | vlan.pcp == 0x4 | |
220 | vlan.pcp != 0x4 | |
221 | vlan.pcp > 0x4 | |
222 | vlan.pcp >= 0x4 | |
223 | vlan.pcp < 0x4 | |
224 | vlan.pcp <= 0x4 | |
225 | !(vlan.pcp != 0x4) => vlan.pcp == 0x4 | |
226 | !(vlan.pcp == 0x4) => 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 | 0x4 == vlan.pcp => vlan.pcp == 0x4 | |
232 | 0x4 != vlan.pcp => vlan.pcp != 0x4 | |
233 | 0x4 < vlan.pcp => vlan.pcp > 0x4 | |
234 | 0x4 <= vlan.pcp => vlan.pcp >= 0x4 | |
235 | 0x4 > vlan.pcp => vlan.pcp < 0x4 | |
236 | 0x4 >= vlan.pcp => vlan.pcp <= 0x4 | |
237 | !(0x4 != vlan.pcp) => vlan.pcp == 0x4 | |
238 | !(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 | ||
244 | 1 < vlan.pcp < 4 => vlan.pcp > 0x1 && vlan.pcp < 0x4 | |
245 | 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4 | |
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 | 4 > vlan.pcp > 1 => vlan.pcp < 0x4 && vlan.pcp > 0x1 | |
250 | 4 >= vlan.pcp > 1 => vlan.pcp <= 0x4 && vlan.pcp > 0x1 | |
251 | 4 > vlan.pcp >= 1 => vlan.pcp < 0x4 && vlan.pcp >= 0x1 | |
252 | 4 >= vlan.pcp >= 1 => vlan.pcp <= 0x4 && vlan.pcp >= 0x1 | |
253 | !(1 < vlan.pcp < 4) => vlan.pcp <= 0x1 || vlan.pcp >= 0x4 | |
254 | !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4 | |
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 | !(4 > vlan.pcp > 1) => vlan.pcp >= 0x4 || vlan.pcp <= 0x1 | |
259 | !(4 >= vlan.pcp > 1) => vlan.pcp > 0x4 || vlan.pcp <= 0x1 | |
260 | !(4 > vlan.pcp >= 1) => vlan.pcp >= 0x4 || vlan.pcp < 0x1 | |
261 | !(4 >= vlan.pcp >= 1) => vlan.pcp > 0x4 || vlan.pcp < 0x1 | |
262 | ||
263 | vlan.pcp == {1, 2, 3, 4} => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4 | |
264 | vlan.pcp == 1 || ((vlan.pcp == 2 || vlan.pcp == 3) || vlan.pcp == 4) => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4 | |
265 | ||
266 | vlan.pcp != {1, 2, 3, 4} => vlan.pcp != 0x1 && vlan.pcp != 0x2 && vlan.pcp != 0x3 && vlan.pcp != 0x4 | |
267 | vlan.pcp == 1 && ((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && vlan.pcp == 0x2 && vlan.pcp == 0x3 && vlan.pcp == 0x4 | |
268 | ||
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 | vlan.pcp == 1 && (!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3) && vlan.pcp == 0x4 | |
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 | ||
273 | 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 | |
274 | ip6.src == ::1 => ip6.src == 0x1 | |
275 | ||
276 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 | |
277 | ip4.src == ::1.2.3.4/::ffff:ffff => ip4.src == 0x1020304 | |
278 | ip6.src == ::1 => ip6.src == 0x1 | |
279 | ||
280 | 1 | |
281 | 0 | |
282 | !1 => 0 | |
283 | !0 => 1 | |
284 | ||
285 | inport == "eth0" | |
286 | !(inport != "eth0") => inport == "eth0" | |
287 | ||
474756fc YS |
288 | (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) => 0 |
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 | 306 | $name => Syntax error at `$name' expecting address set name. |
3d2848ba | 307 | @name => Syntax error at `@name' expecting port group name. |
2c5cbb15 | 308 | |
e0840f11 BP |
309 | 123 == xyzzy => Syntax error at `xyzzy' expecting field name. |
310 | xyzzy == 1 => Syntax error at `xyzzy' expecting field name. | |
311 | ||
312 | inport[1] == 1 => Cannot select subfield of string field inport. | |
313 | ||
314 | eth.type[] == 1 => Syntax error at `@:>@' expecting small integer. | |
315 | eth.type[::1] == 1 => Syntax error at `::1' expecting small integer. | |
316 | eth.type[18446744073709551615] == 1 => Syntax error at `18446744073709551615' expecting small integer. | |
317 | ||
318 | eth.type[5!] => Syntax error at `!' expecting `@:>@'. | |
319 | ||
320 | eth.type[5..1] => Invalid bit range 5 to 1. | |
321 | ||
322 | eth.type[12..16] => Cannot select bits 12 to 16 of 16-bit field eth.type. | |
323 | ||
324 | eth.type[10] == 1 => Cannot select subfield of nominal field eth.type. | |
325 | ||
326 | eth.type => Explicit `!= 0' is required for inequality test of multibit field against 0. | |
327 | ||
328 | !(!(vlan.pcp)) => Explicit `!= 0' is required for inequality test of multibit field against 0. | |
329 | ||
330 | 123 => Syntax error at end of input expecting relational operator. | |
331 | ||
332 | 123 x => Syntax error at `x' expecting relational operator. | |
333 | ||
334 | {1, "eth0"} => Syntax error at `"eth0"' expecting integer. | |
335 | ||
336 | eth.type == xyzzy => Syntax error at `xyzzy' expecting constant. | |
337 | ||
338 | (1 x) => Syntax error at `x' expecting `)'. | |
339 | ||
340 | !0x800 != eth.type => Missing parentheses around operand of !. | |
341 | ||
342 | eth.type == 0x800 || eth.type == 0x86dd && ip.proto == 17 => && and || must be parenthesized when used together. | |
343 | ||
344 | eth.dst == {} => Syntax error at `}' expecting constant. | |
345 | ||
346 | 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). | |
347 | ||
3b7cb7e1 | 348 | ip4.src == ::1 => 128-bit constant is not compatible with 32-bit field ip4.src. |
e0840f11 BP |
349 | |
350 | 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 | 351 | |
9aef3c1b | 352 | eth.dst[40] x => Syntax error at `x' expecting end of input. |
ea382567 RB |
353 | |
354 | ip4.src == {1.2.3.4, $set1, $unknownset} => Syntax error at `$unknownset' expecting address set name. | |
355 | eth.src == {$set3, badmac, 00:00:00:00:00:01} => Syntax error at `badmac' expecting constant. | |
474756fc YS |
356 | |
357 | ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) => Parentheses nested too deeply. | |
f54c5e59 BP |
358 | |
359 | ct_label > $set4 => Only == and != operators may be used to compare a field against an empty value set. | |
e0840f11 BP |
360 | ]]) |
361 | sed 's/ =>.*//' test-cases.txt > input.txt | |
362 | sed 's/.* => //' test-cases.txt > expout | |
363 | AT_CHECK([ovstest test-ovn parse-expr < input.txt], [0], [expout]) | |
364 | AT_CLEANUP | |
365 | ||
366 | AT_SETUP([ovn -- expression annotation]) | |
367 | dnl Input precedes =>, expected output follows =>. | |
32157c87 | 368 | dnl Empty lines and lines starting with # are ignored. |
e0840f11 BP |
369 | AT_DATA([test-cases.txt], [[ |
370 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 && eth.type == 0x800 | |
371 | ip4.src != 1.2.3.4 => ip4.src != 0x1020304 && eth.type == 0x800 | |
372 | ip.proto == 123 => ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd) | |
32157c87 | 373 | ip.proto == {123, 234} => (ip.proto == 0x7b || ip.proto == 0xea) && (eth.type == 0x800 || eth.type == 0x86dd) |
e0840f11 BP |
374 | ip4.src == 1.2.3.4 && ip4.dst == 5.6.7.8 => ip4.src == 0x1020304 && eth.type == 0x800 && ip4.dst == 0x5060708 && eth.type == 0x800 |
375 | ||
32157c87 JS |
376 | # Nested expressions over a single symbol should be annotated with symbol's |
377 | # prerequisites only once, at the top level. | |
378 | tcp.dst == 1 || (tcp.dst >= 2 && tcp.dst <= 3) => (tcp.dst == 0x1 || (tcp.dst >= 0x2 && tcp.dst <= 0x3)) && ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
379 | ||
e0840f11 BP |
380 | ip => eth.type == 0x800 || eth.type == 0x86dd |
381 | ip == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
382 | ip[0] == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
383 | ip > 0 => Only == and != operators may be used with nominal field ip. | |
384 | !ip => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
385 | ip == 0 => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
386 | ||
387 | vlan.present => vlan.tci[12] | |
388 | !vlan.present => !vlan.tci[12] | |
389 | ||
390 | !vlan.pcp => vlan.tci[13..15] == 0 && vlan.tci[12] | |
391 | vlan.pcp == 1 && vlan.vid == 2 => vlan.tci[13..15] == 0x1 && vlan.tci[12] && vlan.tci[0..11] == 0x2 && vlan.tci[12] | |
7700eea0 | 392 | !reg0 && !reg1 && !reg2 && !reg3 => xxreg0[96..127] == 0 && xxreg0[64..95] == 0 && xxreg0[32..63] == 0 && xxreg0[0..31] == 0 |
e0840f11 BP |
393 | |
394 | ip.first_frag => ip.frag[0] && (eth.type == 0x800 || eth.type == 0x86dd) && (!ip.frag[1] || (eth.type != 0x800 && eth.type != 0x86dd)) | |
395 | !ip.first_frag => !ip.frag[0] || (eth.type != 0x800 && eth.type != 0x86dd) || (ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd)) | |
396 | ip.later_frag => ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd) | |
397 | ||
398 | bad_prereq != 0 => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
399 | self_recurse != 0 => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'. | |
400 | 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'. | |
401 | 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'. | |
402 | ]]) | |
403 | sed 's/ =>.*//' test-cases.txt > input.txt | |
404 | sed 's/.* => //' test-cases.txt > expout | |
405 | AT_CHECK([ovstest test-ovn annotate-expr < input.txt], [0], [expout]) | |
406 | AT_CLEANUP | |
407 | ||
9d4aecca | 408 | AT_SETUP([ovn -- 1-term expression conversion]) |
e0840f11 | 409 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert 1], [0], |
9d4aecca | 410 | [Tested converting all 1-terminal expressions with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
411 | ]) |
412 | AT_CLEANUP | |
413 | ||
9d4aecca | 414 | AT_SETUP([ovn -- 2-term expression conversion]) |
e0840f11 | 415 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert 2], [0], |
8c3caa2c | 416 | [Tested converting 578 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
417 | ]) |
418 | AT_CLEANUP | |
419 | ||
9d4aecca | 420 | AT_SETUP([ovn -- 3-term expression conversion]) |
e0840f11 | 421 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert --bits=2 3], [0], |
8c3caa2c | 422 | [Tested converting 67410 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
423 | ]) |
424 | AT_CLEANUP | |
425 | ||
9d4aecca BP |
426 | AT_SETUP([ovn -- 3-term numeric expression simplification]) |
427 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=2 --svars=0 3], [0], | |
8c3caa2c | 428 | [Tested simplifying 490770 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=. |
e0840f11 BP |
429 | ]) |
430 | AT_CLEANUP | |
431 | ||
9d4aecca BP |
432 | AT_SETUP([ovn -- 4-term string expression simplification]) |
433 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=0 --svars=4 4], [0], | |
434 | [Tested simplifying 21978 expressions of 4 terminals with 4 string vars. | |
e0840f11 BP |
435 | ]) |
436 | AT_CLEANUP | |
437 | ||
9d4aecca BP |
438 | AT_SETUP([ovn -- 3-term mixed expression simplification]) |
439 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=1 --svars=1 3], [0], | |
8c3caa2c | 440 | [Tested simplifying 127890 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars. |
e0840f11 BP |
441 | ]) |
442 | AT_CLEANUP | |
443 | ||
97ba1d55 BP |
444 | AT_SETUP([ovn -- simplification special cases]) |
445 | simplify() { | |
446 | echo "$1" | ovstest test-ovn simplify-expr | |
447 | } | |
448 | AT_CHECK([simplify 'eth.dst == 0/0'], [0], [1 | |
449 | ]) | |
a3d79068 BP |
450 | AT_CHECK([simplify 'eth.dst != 0/0'], [0], [0 |
451 | ]) | |
33f15d17 BP |
452 | AT_CHECK([simplify 'tcp.dst >= 0'], [0], |
453 | [ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
454 | ]) | |
455 | AT_CHECK([simplify 'tcp.dst <= 65535'], [0], | |
456 | [ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
457 | ]) | |
458 | AT_CHECK([simplify 'tcp.dst > 0'], [0], | |
459 | [[(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) | |
460 | ]]) | |
461 | AT_CHECK([simplify 'tcp.dst < 65535'], [0], | |
462 | [[(!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) | |
463 | ]]) | |
97ba1d55 BP |
464 | AT_CLEANUP |
465 | ||
ba8d3816 MS |
466 | AT_SETUP([ovn -- is_chassis_resident simplification]) |
467 | simplify() { | |
468 | echo "$1" | ovstest test-ovn simplify-expr | |
469 | } | |
470 | AT_CHECK([simplify 'is_chassis_resident("eth1")'], [0], [1 | |
471 | ]) | |
472 | AT_CHECK([simplify 'is_chassis_resident("eth2")'], [0], [0 | |
473 | ]) | |
474 | AT_CHECK([simplify '!is_chassis_resident("eth1")'], [0], [0 | |
475 | ]) | |
476 | AT_CHECK([simplify '!is_chassis_resident("eth2")'], [0], [1 | |
477 | ]) | |
478 | AT_CLEANUP | |
479 | ||
9d4aecca BP |
480 | AT_SETUP([ovn -- 4-term numeric expression normalization]) |
481 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 4], [0], | |
8c3caa2c | 482 | [Tested normalizing 1874026 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=. |
e0840f11 BP |
483 | ]) |
484 | AT_CLEANUP | |
485 | ||
9d4aecca BP |
486 | AT_SETUP([ovn -- 4-term string expression normalization]) |
487 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 4], [0], | |
488 | [Tested normalizing 11242 expressions of 4 terminals with 3 string vars. | |
489 | ]) | |
490 | AT_CLEANUP | |
491 | ||
492 | AT_SETUP([ovn -- 4-term mixed expression normalization]) | |
493 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --bits=1 --svars=2 4], [0], | |
8c3caa2c | 494 | [Tested normalizing 175978 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars. |
9d4aecca BP |
495 | ]) |
496 | AT_CLEANUP | |
497 | ||
498 | AT_SETUP([ovn -- 5-term numeric expression normalization]) | |
499 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 --relops='==' 5], [0], | |
8c3caa2c | 500 | [Tested normalizing 1317600 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==. |
9d4aecca BP |
501 | ]) |
502 | AT_CLEANUP | |
503 | ||
504 | AT_SETUP([ovn -- 5-term string expression normalization]) | |
505 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 --relops='==' 5], [0], | |
506 | [Tested normalizing 368550 expressions of 5 terminals with 3 string vars. | |
507 | ]) | |
508 | AT_CLEANUP | |
509 | ||
510 | AT_SETUP([ovn -- 5-term mixed expression normalization]) | |
511 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --svars=1 --bits=1 --relops='==' 5], [0], | |
8c3caa2c | 512 | [Tested normalizing 216000 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars. |
9d4aecca BP |
513 | ]) |
514 | AT_CLEANUP | |
515 | ||
516 | AT_SETUP([ovn -- 4-term numeric expressions to flows]) | |
8c3caa2c | 517 | AT_KEYWORDS([expression]) |
9d4aecca | 518 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=2 --svars=0 --bits=2 --relops='==' 4], [0], |
8c3caa2c | 519 | [Tested converting to flows 175978 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==. |
9d4aecca BP |
520 | ]) |
521 | AT_CLEANUP | |
522 | ||
523 | AT_SETUP([ovn -- 4-term string expressions to flows]) | |
8c3caa2c | 524 | AT_KEYWORDS([expression]) |
9d4aecca BP |
525 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=0 --svars=4 4], [0], |
526 | [Tested converting to flows 21978 expressions of 4 terminals with 4 string vars. | |
527 | ]) | |
528 | AT_CLEANUP | |
529 | ||
530 | AT_SETUP([ovn -- 4-term mixed expressions to flows]) | |
8c3caa2c | 531 | AT_KEYWORDS([expression]) |
9d4aecca | 532 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=1 --bits=2 --svars=1 --relops='==' 4], [0], |
8c3caa2c | 533 | [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 |
534 | ]) |
535 | AT_CLEANUP | |
536 | ||
537 | AT_SETUP([ovn -- 3-term numeric expressions to flows]) | |
8c3caa2c | 538 | AT_KEYWORDS([expression]) |
9d4aecca | 539 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=3 --svars=0 --bits=3 --relops='==' 3], [0], |
8c3caa2c | 540 | [Tested converting to flows 41328 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==. |
e0840f11 BP |
541 | ]) |
542 | AT_CLEANUP | |
f386a8a7 BP |
543 | |
544 | AT_SETUP([ovn -- converting expressions to flows -- string fields]) | |
8c3caa2c | 545 | AT_KEYWORDS([expression]) |
f386a8a7 BP |
546 | expr_to_flow () { |
547 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
548 | } | |
cc5e28d8 | 549 | AT_CHECK([expr_to_flow 'inport == "eth0"'], [0], [reg14=0x5 |
f386a8a7 | 550 | ]) |
cc5e28d8 | 551 | AT_CHECK([expr_to_flow 'inport == "eth1"'], [0], [reg14=0x6 |
f386a8a7 BP |
552 | ]) |
553 | AT_CHECK([expr_to_flow 'inport == "eth2"'], [0], [(no flows) | |
554 | ]) | |
555 | AT_CHECK([expr_to_flow 'inport == "eth0" && ip'], [0], [dnl | |
cc5e28d8 JP |
556 | ip,reg14=0x5 |
557 | ipv6,reg14=0x5 | |
f386a8a7 BP |
558 | ]) |
559 | AT_CHECK([expr_to_flow 'inport == "eth1" && ip'], [0], [dnl | |
cc5e28d8 JP |
560 | ip,reg14=0x6 |
561 | ipv6,reg14=0x6 | |
f386a8a7 BP |
562 | ]) |
563 | AT_CHECK([expr_to_flow 'inport == "eth2" && ip'], [0], [(no flows) | |
564 | ]) | |
565 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2", "LOCAL"}'], [0], | |
cc5e28d8 JP |
566 | [reg14=0x5 |
567 | reg14=0x6 | |
568 | reg14=0xfffe | |
f386a8a7 BP |
569 | ]) |
570 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2"} && ip'], [0], [dnl | |
cc5e28d8 JP |
571 | ip,reg14=0x5 |
572 | ip,reg14=0x6 | |
573 | ipv6,reg14=0x5 | |
574 | ipv6,reg14=0x6 | |
f386a8a7 | 575 | ]) |
9d4aecca BP |
576 | AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl |
577 | (no flows) | |
578 | ]) | |
f386a8a7 | 579 | AT_CLEANUP |
3b7cb7e1 | 580 | |
2c5cbb15 | 581 | AT_SETUP([ovn -- converting expressions to flows -- address sets]) |
8c3caa2c | 582 | AT_KEYWORDS([expression]) |
2c5cbb15 RB |
583 | expr_to_flow () { |
584 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
585 | } | |
586 | AT_CHECK([expr_to_flow 'ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3}'], [0], [dnl | |
587 | ip,nw_src=10.0.0.1 | |
588 | ip,nw_src=10.0.0.2 | |
589 | ip,nw_src=10.0.0.3 | |
590 | ]) | |
591 | AT_CHECK([expr_to_flow 'ip4.src == $set1'], [0], [dnl | |
592 | ip,nw_src=10.0.0.1 | |
593 | ip,nw_src=10.0.0.2 | |
594 | ip,nw_src=10.0.0.3 | |
595 | ]) | |
596 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set1}'], [0], [dnl | |
597 | ip,nw_src=1.2.3.4 | |
598 | ip,nw_src=10.0.0.1 | |
599 | ip,nw_src=10.0.0.2 | |
600 | ip,nw_src=10.0.0.3 | |
601 | ]) | |
602 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.0.0/20, 5.5.5.0/24, $set1}'], [0], [dnl | |
603 | ip,nw_src=1.2.0.0/20 | |
604 | ip,nw_src=10.0.0.1 | |
605 | ip,nw_src=10.0.0.2 | |
606 | ip,nw_src=10.0.0.3 | |
607 | ip,nw_src=5.5.5.0/24 | |
608 | ]) | |
609 | AT_CHECK([expr_to_flow 'ip6.src == {::1, ::2, ::3}'], [0], [dnl | |
610 | ipv6,ipv6_src=::1 | |
611 | ipv6,ipv6_src=::2 | |
612 | ipv6,ipv6_src=::3 | |
613 | ]) | |
614 | AT_CHECK([expr_to_flow 'ip6.src == {::1, $set2, ::4}'], [0], [dnl | |
615 | ipv6,ipv6_src=::1 | |
616 | ipv6,ipv6_src=::2 | |
617 | ipv6,ipv6_src=::3 | |
618 | ipv6,ipv6_src=::4 | |
619 | ]) | |
620 | 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 | |
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 | ]) | |
625 | AT_CHECK([expr_to_flow 'eth.src == {$set3}'], [0], [dnl | |
626 | dl_src=00:00:00:00:00:01 | |
627 | dl_src=00:00:00:00:00:02 | |
628 | dl_src=00:00:00:00:00:03 | |
629 | ]) | |
ea382567 RB |
630 | AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, $set3, ba:be:be:ef:de:ad, $set3}'], [0], [dnl |
631 | dl_src=00:00:00:00:00:01 | |
632 | dl_src=00:00:00:00:00:02 | |
633 | dl_src=00:00:00:00:00:03 | |
634 | dl_src=ba:be:be:ef:de:ad | |
635 | ]) | |
f3a4e992 HZ |
636 | AT_CHECK([expr_to_flow 'ip4.src == {$set4}'], [0], [dnl |
637 | (no flows) | |
638 | ]) | |
639 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set4}'], [0], [dnl | |
640 | ip,nw_src=1.2.3.4 | |
641 | ]) | |
642 | AT_CHECK([expr_to_flow 'ip4.src == 1.2.3.4 || ip4.src == {$set4}'], [0], [dnl | |
643 | ip,nw_src=1.2.3.4 | |
644 | ]) | |
645 | AT_CHECK([expr_to_flow 'ip4.src != {$set4}'], [0], [dnl | |
646 | ||
647 | ]) | |
648 | AT_CHECK([expr_to_flow 'ip4.src != {1.0.0.0/8, $set4}'], [0], [dnl | |
649 | ip,nw_src=0.0.0.0/1.0.0.0 | |
650 | ip,nw_src=128.0.0.0/1 | |
651 | ip,nw_src=16.0.0.0/16.0.0.0 | |
652 | ip,nw_src=2.0.0.0/2.0.0.0 | |
653 | ip,nw_src=32.0.0.0/32.0.0.0 | |
654 | ip,nw_src=4.0.0.0/4.0.0.0 | |
655 | ip,nw_src=64.0.0.0/64.0.0.0 | |
656 | ip,nw_src=8.0.0.0/8.0.0.0 | |
657 | ]) | |
658 | AT_CHECK([expr_to_flow 'ip4.src != 1.0.0.0/8 && ip4.src != {$set4}'], [0], [dnl | |
659 | ip,nw_src=0.0.0.0/1.0.0.0 | |
660 | ip,nw_src=128.0.0.0/1 | |
661 | ip,nw_src=16.0.0.0/16.0.0.0 | |
662 | ip,nw_src=2.0.0.0/2.0.0.0 | |
663 | ip,nw_src=32.0.0.0/32.0.0.0 | |
664 | ip,nw_src=4.0.0.0/4.0.0.0 | |
665 | ip,nw_src=64.0.0.0/64.0.0.0 | |
666 | ip,nw_src=8.0.0.0/8.0.0.0 | |
667 | ]) | |
2c5cbb15 RB |
668 | AT_CLEANUP |
669 | ||
3d2848ba HZ |
670 | AT_SETUP([ovn -- converting expressions to flows -- port groups]) |
671 | AT_KEYWORDS([expression]) | |
672 | expr_to_flow () { | |
673 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
674 | } | |
675 | AT_CHECK([expr_to_flow 'outport == @pg1'], [0], [dnl | |
676 | reg15=0x11 | |
677 | reg15=0x12 | |
678 | reg15=0x13 | |
679 | ]) | |
680 | AT_CHECK([expr_to_flow 'outport == {@pg_empty}'], [0], [dnl | |
681 | (no flows) | |
682 | ]) | |
683 | AT_CHECK([expr_to_flow 'outport == {"lsp1", @pg_empty}'], [0], [dnl | |
684 | reg15=0x11 | |
685 | ]) | |
686 | AT_CLEANUP | |
687 | ||
55b25947 NS |
688 | AT_SETUP([ovn -- converting expressions to flows -- conjunction]) |
689 | AT_KEYWORDS([conjunction]) | |
690 | expr_to_flow () { | |
691 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
692 | } | |
693 | ||
694 | lflow="ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3} && \ | |
695 | ip4.dst == {20.0.0.1, 20.0.0.2, 20.0.0.3}" | |
696 | AT_CHECK([expr_to_flow "$lflow"], [0], [dnl | |
697 | conj_id=1,ip | |
698 | ip,nw_dst=20.0.0.1: conjunction(1, 0/2) | |
699 | ip,nw_dst=20.0.0.2: conjunction(1, 0/2) | |
700 | ip,nw_dst=20.0.0.3: conjunction(1, 0/2) | |
701 | ip,nw_src=10.0.0.1: conjunction(1, 1/2) | |
702 | ip,nw_src=10.0.0.2: conjunction(1, 1/2) | |
703 | ip,nw_src=10.0.0.3: conjunction(1, 1/2) | |
704 | ]) | |
705 | ||
706 | lflow="ip && (!ct.est || (ct.est && ct_label.blocked == 1))" | |
707 | AT_CHECK([expr_to_flow "$lflow"], [0], [dnl | |
708 | ct_state=+est+trk,ct_label=0x1/0x1,ip | |
709 | ct_state=+est+trk,ct_label=0x1/0x1,ipv6 | |
710 | ct_state=-est+trk,ip | |
711 | ct_state=-est+trk,ipv6 | |
712 | ]) | |
713 | ||
714 | lflow="ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3} && \ | |
715 | ip4.dst == {20.0.0.1, 20.0.0.2}" | |
716 | AT_CHECK([expr_to_flow "$lflow"], [0], [dnl | |
717 | conj_id=1,ip | |
718 | ip,nw_dst=20.0.0.1: conjunction(1, 0/2) | |
719 | ip,nw_dst=20.0.0.2: conjunction(1, 0/2) | |
720 | ip,nw_src=10.0.0.1: conjunction(1, 1/2) | |
721 | ip,nw_src=10.0.0.2: conjunction(1, 1/2) | |
722 | ip,nw_src=10.0.0.3: conjunction(1, 1/2) | |
723 | ]) | |
724 | ||
725 | lflow="ip4 && ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3} && \ | |
726 | ip4.dst == {20.0.0.1, 20.0.0.2, 20.0.0.3} && \ | |
727 | tcp.dst >= 1000 && tcp.dst <= 1010" | |
728 | ||
729 | AT_CHECK([expr_to_flow "$lflow"], [0], [dnl | |
730 | conj_id=1,tcp | |
731 | tcp,nw_dst=20.0.0.1: conjunction(1, 0/3) | |
732 | tcp,nw_dst=20.0.0.2: conjunction(1, 0/3) | |
733 | tcp,nw_dst=20.0.0.3: conjunction(1, 0/3) | |
734 | tcp,nw_src=10.0.0.1: conjunction(1, 1/3) | |
735 | tcp,nw_src=10.0.0.2: conjunction(1, 1/3) | |
736 | tcp,nw_src=10.0.0.3: conjunction(1, 1/3) | |
737 | tcp,tp_dst=0x3ea/0xfffe: conjunction(1, 2/3) | |
738 | tcp,tp_dst=0x3ec/0xfffc: conjunction(1, 2/3) | |
739 | tcp,tp_dst=0x3f0/0xfffe: conjunction(1, 2/3) | |
740 | tcp,tp_dst=1000: conjunction(1, 2/3) | |
741 | tcp,tp_dst=1001: conjunction(1, 2/3) | |
742 | tcp,tp_dst=1010: conjunction(1, 2/3) | |
743 | ]) | |
744 | ||
745 | lflow="ip4 && ip4.src == {10.0.0.4, 10.0.0.5, 10.0.0.6} && \ | |
746 | ((ip4.dst == {20.0.0.4, 20.0.0.7, 20.0.0.8} && tcp.dst >= 1000 && \ | |
747 | tcp.dst <= 2000 && tcp.src >=1000 && tcp.src <= 2000) \ | |
748 | || ip4.dst == 20.0.0.5 || ip4.dst == 20.0.0.6)" | |
749 | ||
750 | AT_CHECK([expr_to_flow "$lflow"], [0], [dnl | |
751 | conj_id=1,tcp | |
752 | ip,nw_src=10.0.0.4,nw_dst=20.0.0.5 | |
753 | ip,nw_src=10.0.0.4,nw_dst=20.0.0.6 | |
754 | ip,nw_src=10.0.0.5,nw_dst=20.0.0.5 | |
755 | ip,nw_src=10.0.0.5,nw_dst=20.0.0.6 | |
756 | ip,nw_src=10.0.0.6,nw_dst=20.0.0.5 | |
757 | ip,nw_src=10.0.0.6,nw_dst=20.0.0.6 | |
758 | tcp,nw_dst=20.0.0.4: conjunction(1, 0/4) | |
759 | tcp,nw_dst=20.0.0.7: conjunction(1, 0/4) | |
760 | tcp,nw_dst=20.0.0.8: conjunction(1, 0/4) | |
761 | tcp,nw_src=10.0.0.4: conjunction(1, 1/4) | |
762 | tcp,nw_src=10.0.0.5: conjunction(1, 1/4) | |
763 | tcp,nw_src=10.0.0.6: conjunction(1, 1/4) | |
764 | tcp,tp_dst=0x3ea/0xfffe: conjunction(1, 2/4) | |
765 | tcp,tp_dst=0x3ec/0xfffc: conjunction(1, 2/4) | |
766 | tcp,tp_dst=0x3f0/0xfff0: conjunction(1, 2/4) | |
767 | tcp,tp_dst=0x400/0xfe00: conjunction(1, 2/4) | |
768 | tcp,tp_dst=0x600/0xff00: conjunction(1, 2/4) | |
769 | tcp,tp_dst=0x700/0xff80: conjunction(1, 2/4) | |
770 | tcp,tp_dst=0x780/0xffc0: conjunction(1, 2/4) | |
771 | tcp,tp_dst=0x7c0/0xfff0: conjunction(1, 2/4) | |
772 | tcp,tp_dst=1000: conjunction(1, 2/4) | |
773 | tcp,tp_dst=1001: conjunction(1, 2/4) | |
774 | tcp,tp_dst=2000: conjunction(1, 2/4) | |
775 | tcp,tp_src=0x3ea/0xfffe: conjunction(1, 3/4) | |
776 | tcp,tp_src=0x3ec/0xfffc: conjunction(1, 3/4) | |
777 | tcp,tp_src=0x3f0/0xfff0: conjunction(1, 3/4) | |
778 | tcp,tp_src=0x400/0xfe00: conjunction(1, 3/4) | |
779 | tcp,tp_src=0x600/0xff00: conjunction(1, 3/4) | |
780 | tcp,tp_src=0x700/0xff80: conjunction(1, 3/4) | |
781 | tcp,tp_src=0x780/0xffc0: conjunction(1, 3/4) | |
782 | tcp,tp_src=0x7c0/0xfff0: conjunction(1, 3/4) | |
783 | tcp,tp_src=1000: conjunction(1, 3/4) | |
784 | tcp,tp_src=1001: conjunction(1, 3/4) | |
785 | tcp,tp_src=2000: conjunction(1, 3/4) | |
786 | ]) | |
787 | AT_CLEANUP | |
788 | ||
3b7cb7e1 | 789 | AT_SETUP([ovn -- action parsing]) |
d5a76da4 BP |
790 | dnl Unindented text is input (a set of OVN logical actions). |
791 | dnl Indented text is expected output. | |
792 | AT_DATA([test-cases.txt], | |
793 | [[# drop | |
794 | drop; | |
795 | encodes as drop | |
796 | drop; next; | |
797 | Syntax error at `next' expecting end of input. | |
798 | next; drop; | |
799 | Syntax error at `drop' expecting action. | |
5f822129 BP |
800 | |
801 | # output | |
d5a76da4 BP |
802 | output; |
803 | encodes as resubmit(,64) | |
5f822129 BP |
804 | |
805 | # next | |
d5a76da4 | 806 | next; |
00c875d0 | 807 | encodes as resubmit(,19) |
d5a76da4 | 808 | next(11); |
8f5de083 | 809 | formats as next; |
00c875d0 | 810 | encodes as resubmit(,19) |
d5a76da4 | 811 | next(0); |
00c875d0 MS |
812 | encodes as resubmit(,8) |
813 | next(23); | |
d5a76da4 BP |
814 | encodes as resubmit(,31) |
815 | ||
816 | next(); | |
4c99cb18 | 817 | Syntax error at `)' expecting "pipeline" or "table". |
d5a76da4 BP |
818 | next(10; |
819 | Syntax error at `;' expecting `)'. | |
00c875d0 MS |
820 | next(24); |
821 | "next" action cannot advance beyond table 23. | |
5f822129 | 822 | |
4c99cb18 BP |
823 | next(table=11); |
824 | formats as next; | |
00c875d0 | 825 | encodes as resubmit(,19) |
4c99cb18 BP |
826 | next(pipeline=ingress); |
827 | formats as next; | |
00c875d0 | 828 | encodes as resubmit(,19) |
4c99cb18 BP |
829 | next(table=11, pipeline=ingress); |
830 | formats as next; | |
00c875d0 | 831 | encodes as resubmit(,19) |
4c99cb18 BP |
832 | next(pipeline=ingress, table=11); |
833 | formats as next; | |
00c875d0 | 834 | encodes as resubmit(,19) |
4c99cb18 BP |
835 | |
836 | next(pipeline=egress); | |
837 | "next" action cannot advance from ingress to egress pipeline (use "output" action instead) | |
838 | ||
839 | next(table=10); | |
840 | formats as next(10); | |
00c875d0 | 841 | encodes as resubmit(,18) |
4c99cb18 | 842 | |
5f822129 | 843 | # Loading a constant value. |
d5a76da4 BP |
844 | tcp.dst=80; |
845 | formats as tcp.dst = 80; | |
846 | encodes as set_field:80->tcp_dst | |
847 | has prereqs ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
848 | eth.dst[40] = 1; | |
849 | encodes as set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dst | |
850 | vlan.pcp = 2; | |
851 | encodes as set_field:0x4000/0xe000->vlan_tci | |
852 | has prereqs vlan.tci[12] | |
853 | vlan.tci[13..15] = 2; | |
854 | encodes as set_field:0x4000/0xe000->vlan_tci | |
855 | inport = ""; | |
856 | encodes as set_field:0->reg14 | |
857 | ip.ttl=4; | |
858 | formats as ip.ttl = 4; | |
859 | encodes as set_field:4->nw_ttl | |
860 | has prereqs eth.type == 0x800 || eth.type == 0x86dd | |
861 | outport="eth0"; next; outport="LOCAL"; next; | |
8f5de083 | 862 | formats as outport = "eth0"; next; outport = "LOCAL"; next; |
00c875d0 | 863 | encodes as set_field:0x5->reg15,resubmit(,19),set_field:0xfffe->reg15,resubmit(,19) |
d5a76da4 BP |
864 | |
865 | inport[1] = 1; | |
866 | Cannot select subfield of string field inport. | |
867 | ip.proto[1] = 1; | |
868 | Cannot select subfield of nominal field ip.proto. | |
869 | eth.dst[40] == 1; | |
870 | Syntax error at `==' expecting `=' or `<->'. | |
871 | ip = 1; | |
872 | Predicate symbol ip used where lvalue required. | |
873 | ip.proto = 6; | |
874 | Field ip.proto is not modifiable. | |
875 | inport = {"a", "b"}; | |
876 | Syntax error at `{' expecting constant. | |
877 | inport = {}; | |
878 | Syntax error at `{' expecting constant. | |
879 | bad_prereq = 123; | |
880 | Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
881 | self_recurse = 123; | |
882 | 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'. | |
883 | vlan.present = 0; | |
884 | Predicate symbol vlan.present used where lvalue required. | |
5f822129 BP |
885 | |
886 | # Moving one field into another. | |
d5a76da4 BP |
887 | reg0=reg1; |
888 | formats as reg0 = reg1; | |
889 | encodes as move:NXM_NX_XXREG0[64..95]->NXM_NX_XXREG0[96..127] | |
890 | vlan.pcp = reg0[0..2]; | |
891 | encodes as move:NXM_NX_XXREG0[96..98]->NXM_OF_VLAN_TCI[13..15] | |
892 | has prereqs vlan.tci[12] | |
893 | reg0[10] = vlan.pcp[1]; | |
894 | encodes as move:NXM_OF_VLAN_TCI[14]->NXM_NX_XXREG0[106] | |
895 | has prereqs vlan.tci[12] | |
896 | outport = inport; | |
897 | encodes as move:NXM_NX_REG14[]->NXM_NX_REG15[] | |
898 | ||
899 | reg0[0] = vlan.present; | |
900 | Predicate symbol vlan.present used where lvalue required. | |
901 | reg0 = reg1[0..10]; | |
902 | Can't assign 11-bit value to 32-bit destination. | |
903 | inport = reg0; | |
904 | Can't assign integer field (reg0) to string field (inport). | |
905 | inport = big_string; | |
906 | String fields inport and big_string are incompatible for assignment. | |
907 | ip.proto = reg0[0..7]; | |
908 | Field ip.proto is not modifiable. | |
5f822129 BP |
909 | |
910 | # Exchanging fields. | |
d5a76da4 BP |
911 | reg0 <-> reg1; |
912 | 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] | |
913 | vlan.pcp <-> reg0[0..2]; | |
914 | 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] | |
915 | has prereqs vlan.tci[12] | |
916 | reg0[10] <-> vlan.pcp[1]; | |
917 | encodes as push:NXM_OF_VLAN_TCI[14],push:NXM_NX_XXREG0[106],pop:NXM_OF_VLAN_TCI[14],pop:NXM_NX_XXREG0[106] | |
918 | has prereqs vlan.tci[12] | |
919 | outport <-> inport; | |
920 | encodes as push:NXM_NX_REG14[],push:NXM_NX_REG15[],pop:NXM_NX_REG14[],pop:NXM_NX_REG15[] | |
921 | ||
922 | reg0[0] <-> vlan.present; | |
923 | Predicate symbol vlan.present used where lvalue required. | |
924 | reg0 <-> reg1[0..10]; | |
925 | Can't exchange 32-bit field with 11-bit field. | |
926 | inport <-> reg0; | |
927 | Can't exchange string field (inport) with integer field (reg0). | |
928 | inport <-> big_string; | |
929 | String fields inport and big_string are incompatible for exchange. | |
930 | ip.proto <-> reg0[0..7]; | |
931 | Field ip.proto is not modifiable. | |
932 | reg0[0..7] <-> ip.proto; | |
933 | Field ip.proto is not modifiable. | |
5f822129 BP |
934 | |
935 | # TTL decrement. | |
d5a76da4 BP |
936 | ip.ttl--; |
937 | encodes as dec_ttl | |
938 | has prereqs ip | |
939 | ip.ttl | |
940 | Syntax error at end of input expecting `--'. | |
5f822129 | 941 | |
467085fd | 942 | # load balancing. |
d5a76da4 | 943 | ct_lb; |
00c875d0 | 944 | encodes as ct(table=19,zone=NXM_NX_REG13[0..15],nat) |
d5a76da4 BP |
945 | has prereqs ip |
946 | ct_lb(); | |
947 | formats as ct_lb; | |
00c875d0 | 948 | encodes as ct(table=19,zone=NXM_NX_REG13[0..15],nat) |
d5a76da4 BP |
949 | has prereqs ip |
950 | ct_lb(192.168.1.2:80, 192.168.1.3:80); | |
951 | encodes as group:1 | |
952 | has prereqs ip | |
953 | ct_lb(192.168.1.2, 192.168.1.3, ); | |
954 | formats as ct_lb(192.168.1.2, 192.168.1.3); | |
955 | encodes as group:2 | |
956 | has prereqs ip | |
9d236afa MM |
957 | ct_lb(fd0f::2, fd0f::3, ); |
958 | formats as ct_lb(fd0f::2, fd0f::3); | |
959 | encodes as group:3 | |
960 | has prereqs ip | |
d5a76da4 BP |
961 | |
962 | ct_lb(192.168.1.2:); | |
963 | Syntax error at `)' expecting port number. | |
964 | ct_lb(192.168.1.2:123456); | |
965 | Syntax error at `123456' expecting port number. | |
966 | ct_lb(foo); | |
9d236afa MM |
967 | Syntax error at `foo' expecting IP address. |
968 | ct_lb([192.168.1.2]); | |
969 | Syntax error at `192.168.1.2' expecting IPv6 address. | |
d5a76da4 BP |
970 | |
971 | # ct_next | |
972 | ct_next; | |
00c875d0 | 973 | encodes as ct(table=19,zone=NXM_NX_REG13[0..15]) |
d5a76da4 BP |
974 | has prereqs ip |
975 | ||
976 | # ct_commit | |
977 | ct_commit; | |
978 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
979 | has prereqs ip | |
980 | ct_commit(); | |
981 | formats as ct_commit; | |
982 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
983 | has prereqs ip | |
984 | ct_commit(ct_mark=1); | |
985 | formats as ct_commit(ct_mark=0x1); | |
986 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark)) | |
987 | has prereqs ip | |
988 | ct_commit(ct_mark=1/1); | |
989 | formats as ct_commit(ct_mark=0x1/0x1); | |
990 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_mark)) | |
991 | has prereqs ip | |
992 | ct_commit(ct_label=1); | |
993 | formats as ct_commit(ct_label=0x1); | |
994 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_label)) | |
995 | has prereqs ip | |
996 | ct_commit(ct_label=1/1); | |
997 | formats as ct_commit(ct_label=0x1/0x1); | |
998 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_label)) | |
999 | has prereqs ip | |
1000 | ct_commit(ct_mark=1, ct_label=2); | |
1001 | formats as ct_commit(ct_mark=0x1, ct_label=0x2); | |
1002 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark,set_field:0x2->ct_label)) | |
1003 | has prereqs ip | |
1004 | ||
1005 | ct_commit(ct_label=0x01020304050607080910111213141516); | |
1006 | formats as ct_commit(ct_label=0x1020304050607080910111213141516); | |
1007 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1020304050607080910111213141516->ct_label)) | |
1008 | has prereqs ip | |
1009 | ct_commit(ct_label=0x181716151413121110090807060504030201); | |
1010 | formats as ct_commit(ct_label=0x16151413121110090807060504030201); | |
1011 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x16151413121110090807060504030201->ct_label)) | |
1012 | has prereqs ip | |
1013 | ct_commit(ct_label=0x1000000000000000000000000000000/0x1000000000000000000000000000000); | |
1014 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1000000000000000000000000000000/0x1000000000000000000000000000000->ct_label)) | |
1015 | has prereqs ip | |
1016 | ct_commit(ct_label=18446744073709551615); | |
1017 | formats as ct_commit(ct_label=0xffffffffffffffff); | |
1018 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0xffffffffffffffff->ct_label)) | |
1019 | has prereqs ip | |
1020 | ct_commit(ct_label=18446744073709551616); | |
1021 | Decimal constants must be less than 2**64. | |
1022 | ||
1023 | # ct_dnat | |
1024 | ct_dnat; | |
00c875d0 | 1025 | encodes as ct(table=19,zone=NXM_NX_REG11[0..15],nat) |
d5a76da4 BP |
1026 | has prereqs ip |
1027 | ct_dnat(192.168.1.2); | |
00c875d0 | 1028 | encodes as ct(commit,table=19,zone=NXM_NX_REG11[0..15],nat(dst=192.168.1.2)) |
d5a76da4 BP |
1029 | has prereqs ip |
1030 | ||
1031 | ct_dnat(192.168.1.2, 192.168.1.3); | |
1032 | Syntax error at `,' expecting `)'. | |
1033 | ct_dnat(foo); | |
1034 | Syntax error at `foo' expecting IPv4 address. | |
1035 | ct_dnat(foo, bar); | |
1036 | Syntax error at `foo' expecting IPv4 address. | |
1037 | ct_dnat(); | |
1038 | Syntax error at `)' expecting IPv4 address. | |
1039 | ||
1040 | # ct_snat | |
1041 | ct_snat; | |
00c875d0 | 1042 | encodes as ct(table=19,zone=NXM_NX_REG12[0..15],nat) |
d5a76da4 BP |
1043 | has prereqs ip |
1044 | ct_snat(192.168.1.2); | |
00c875d0 | 1045 | encodes as ct(commit,table=19,zone=NXM_NX_REG12[0..15],nat(src=192.168.1.2)) |
d5a76da4 BP |
1046 | has prereqs ip |
1047 | ||
1048 | ct_snat(192.168.1.2, 192.168.1.3); | |
1049 | Syntax error at `,' expecting `)'. | |
1050 | ct_snat(foo); | |
1051 | Syntax error at `foo' expecting IPv4 address. | |
1052 | ct_snat(foo, bar); | |
1053 | Syntax error at `foo' expecting IPv4 address. | |
1054 | ct_snat(); | |
1055 | Syntax error at `)' expecting IPv4 address. | |
de297547 | 1056 | |
db0e819b BP |
1057 | # ct_clear |
1058 | ct_clear; | |
1059 | encodes as ct_clear | |
1060 | ||
b3bd2c33 | 1061 | # clone |
8f5de083 | 1062 | clone { ip4.dst = 255.255.255.255; output; }; next; |
00c875d0 | 1063 | encodes as clone(set_field:255.255.255.255->ip_dst,resubmit(,64)),resubmit(,19) |
b3bd2c33 BP |
1064 | has prereqs eth.type == 0x800 |
1065 | ||
6335d074 | 1066 | # arp |
8a41ad8e BP |
1067 | arp { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; |
1068 | 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 | 1069 | has prereqs ip4 |
bac29564 BP |
1070 | arp { }; |
1071 | formats as arp { drop; }; | |
1072 | encodes as controller(userdata=00.00.00.00.00.00.00.00) | |
1073 | has prereqs ip4 | |
6335d074 | 1074 | |
0bac7164 | 1075 | # get_arp |
d5a76da4 BP |
1076 | get_arp(outport, ip4.dst); |
1077 | 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[] | |
1078 | has prereqs eth.type == 0x800 | |
1079 | get_arp(inport, reg0); | |
1080 | 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[] | |
1081 | ||
1082 | get_arp; | |
1083 | Syntax error at `;' expecting `('. | |
1084 | get_arp(); | |
1085 | Syntax error at `)' expecting field name. | |
1086 | get_arp(inport); | |
1087 | Syntax error at `)' expecting `,'. | |
1088 | get_arp(inport ip4.dst); | |
1089 | Syntax error at `ip4.dst' expecting `,'. | |
1090 | get_arp(inport, ip4.dst; | |
1091 | Syntax error at `;' expecting `)'. | |
1092 | get_arp(inport, eth.dst); | |
1093 | Cannot use 48-bit field eth.dst[0..47] where 32-bit field is required. | |
1094 | get_arp(inport, outport); | |
1095 | Cannot use string field outport where numeric field is required. | |
1096 | get_arp(reg0, ip4.dst); | |
1097 | Cannot use numeric field reg0 where string field is required. | |
0bac7164 BP |
1098 | |
1099 | # put_arp | |
d5a76da4 BP |
1100 | put_arp(inport, arp.spa, arp.sha); |
1101 | 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[] | |
1102 | has prereqs eth.type == 0x806 && eth.type == 0x806 | |
0bac7164 | 1103 | |
42814145 | 1104 | # put_dhcp_opts |
d5a76da4 BP |
1105 | reg1[0] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); |
1106 | 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) | |
cbf49545 MJ |
1107 | reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,mtu=1400,domain_name="ovn.org",wpad="https://example.org",bootfile_name="https://127.0.0.1/boot.ipxe",path_prefix="/tftpboot"); |
1108 | 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_name = "ovn.org", wpad = "https://example.org", bootfile_name = "https://127.0.0.1/boot.ipxe", path_prefix = "/tftpboot"); | |
318799a2 | 1109 | 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.fc.13.68.74.74.70.73.3a.2f.2f.65.78.61.6d.70.6c.65.2e.6f.72.67.43.1b.68.74.74.70.73.3a.2f.2f.31.32.37.2e.30.2e.30.2e.31.2f.62.6f.6f.74.2e.69.70.78.65.d2.09.2f.74.66.74.70.62.6f.6f.74,pause) |
2a7be04e LAG |
1110 | 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,tftp_server_address={10.0.0.4,10.0.0.5}); |
1111 | 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, tftp_server_address = {10.0.0.4, 10.0.0.5}); | |
1112 | 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.96.08.0a.00.00.04.0a.00.00.05,pause) | |
d5a76da4 BP |
1113 | |
1114 | reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); | |
1115 | Cannot use 2-bit field reg1[0..1] where 1-bit field is required. | |
1116 | reg1[0] = put_dhcp_opts(); | |
1117 | put_dhcp_opts requires offerip to be specified. | |
1118 | reg1[0] = put_dhcp_opts(x = 1.2.3.4, router = 10.0.0.1); | |
1119 | Syntax error at `x' expecting DHCPv4 option name. | |
1120 | reg1[0] = put_dhcp_opts(router = 10.0.0.1); | |
1121 | put_dhcp_opts requires offerip to be specified. | |
1122 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, "hi"); | |
1123 | Syntax error at `"hi"'. | |
1124 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, xyzzy); | |
1125 | Syntax error at `xyzzy' expecting DHCPv4 option name. | |
1126 | reg1[0] = put_dhcp_opts(offerip="xyzzy"); | |
1127 | DHCPv4 option offerip requires numeric value. | |
cbf49545 MJ |
1128 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain_name=1.2.3.4); |
1129 | DHCPv4 option domain_name requires string value. | |
42814145 | 1130 | |
b1a3a6a4 NS |
1131 | # nd_ns |
1132 | nd_ns { nd.target = xxreg0; output; }; | |
1133 | encodes as controller(userdata=00.00.00.09.00.00.00.00.ff.ff.00.18.00.00.23.20.00.06.00.80.00.00.00.00.00.01.de.10.00.01.2e.10.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00) | |
1134 | has prereqs ip6 | |
1135 | ||
1136 | nd_ns { }; | |
1137 | formats as nd_ns { drop; }; | |
1138 | encodes as controller(userdata=00.00.00.09.00.00.00.00) | |
1139 | has prereqs ip6 | |
1140 | ||
f8a8db39 | 1141 | # nd_na |
d5a76da4 BP |
1142 | 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; }; |
1143 | formats as nd_na { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; output; }; | |
1144 | 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) | |
1145 | has prereqs nd_ns | |
c9756229 NS |
1146 | # nd_na_router |
1147 | nd_na_router { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; /* Allow sending out inport. */ output; }; | |
1148 | formats as nd_na_router { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; output; }; | |
1149 | encodes as controller(userdata=00.00.00.0c.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) | |
1150 | has prereqs nd_ns | |
e75451fe | 1151 | |
c34a87b6 | 1152 | # get_nd |
d5a76da4 BP |
1153 | get_nd(outport, ip6.dst); |
1154 | 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[] | |
1155 | has prereqs eth.type == 0x86dd | |
1156 | get_nd(inport, xxreg0); | |
1157 | 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[] | |
1158 | get_nd; | |
1159 | Syntax error at `;' expecting `('. | |
1160 | get_nd(); | |
1161 | Syntax error at `)' expecting field name. | |
1162 | get_nd(inport); | |
1163 | Syntax error at `)' expecting `,'. | |
1164 | get_nd(inport ip6.dst); | |
1165 | Syntax error at `ip6.dst' expecting `,'. | |
1166 | get_nd(inport, ip6.dst; | |
1167 | Syntax error at `;' expecting `)'. | |
1168 | get_nd(inport, eth.dst); | |
1169 | Cannot use 48-bit field eth.dst[0..47] where 128-bit field is required. | |
1170 | get_nd(inport, outport); | |
1171 | Cannot use string field outport where numeric field is required. | |
1172 | get_nd(xxreg0, ip6.dst); | |
1173 | Cannot use numeric field xxreg0 where string field is required. | |
c34a87b6 JP |
1174 | |
1175 | # put_nd | |
d5a76da4 BP |
1176 | put_nd(inport, nd.target, nd.sll); |
1177 | 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[] | |
32157c87 | 1178 | has prereqs (icmp6.type == 0x87 || 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 | 1179 | |
01cfdb2f | 1180 | # put_dhcpv6_opts |
d5a76da4 | 1181 | reg1[0] = put_dhcpv6_opts(ia_addr = ae70::4, server_id = 00:00:00:00:10:02); |
a55dacac | 1182 | 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 |
1183 | reg1[0] = put_dhcpv6_opts(); |
1184 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40,pause) | |
1185 | reg1[0] = put_dhcpv6_opts(dns_server={ae70::1,ae70::2}); | |
1186 | formats as reg1[0] = put_dhcpv6_opts(dns_server = {ae70::1, ae70::2}); | |
a55dacac | 1187 | 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 |
1188 | reg1[0] = put_dhcpv6_opts(server_id=12:34:56:78:9a:bc, dns_server={ae70::1,ae89::2}); |
1189 | formats as reg1[0] = put_dhcpv6_opts(server_id = 12:34:56:78:9a:bc, dns_server = {ae70::1, ae89::2}); | |
a55dacac | 1190 | 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 | 1191 | reg1[0] = put_dhcpv6_opts(domain_search = "ovn.org"); |
a55dacac | 1192 | 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 |
1193 | reg1[0] = put_dhcpv6_opts(x = 1.2.3.4); |
1194 | Syntax error at `x' expecting DHCPv6 option name. | |
1195 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, "hi"); | |
1196 | Syntax error at `"hi"'. | |
1197 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, xyzzy); | |
1198 | Syntax error at `xyzzy' expecting DHCPv6 option name. | |
1199 | reg1[0] = put_dhcpv6_opts(ia_addr="ae70::4"); | |
1200 | DHCPv6 option ia_addr requires numeric value. | |
1201 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, domain_search=ae70::1); | |
1202 | DHCPv6 option domain_search requires string value. | |
01cfdb2f | 1203 | |
a6095f81 BS |
1204 | # set_queue |
1205 | set_queue(0); | |
1206 | encodes as set_queue:0 | |
1207 | set_queue(61440); | |
1208 | encodes as set_queue:61440 | |
1209 | set_queue(65535); | |
1210 | Queue ID 65535 for set_queue is not in valid range 0 to 61440. | |
1211 | ||
ea991ad2 NS |
1212 | # dns_lookup |
1213 | reg1[0] = dns_lookup(); | |
1214 | encodes as controller(userdata=00.00.00.06.00.00.00.00.00.01.de.10.00.00.00.40,pause) | |
1215 | has prereqs udp | |
1216 | reg1[0] = dns_lookup("foo"); | |
1217 | dns_lookup doesn't take any parameters | |
1218 | ||
66d89287 GL |
1219 | # set_meter |
1220 | set_meter(0); | |
1221 | Rate 0 for set_meter is not in valid. | |
1222 | set_meter(1); | |
1223 | encodes as meter:1 | |
1224 | set_meter(100, 1000); | |
1225 | encodes as meter:2 | |
1226 | set_meter(100, 1000, ); | |
1227 | Syntax error at `,' expecting `)'. | |
1228 | set_meter(4294967295, 4294967295); | |
1229 | encodes as meter:3 | |
1230 | ||
977433d8 JP |
1231 | # log |
1232 | log(verdict=allow, severity=warning); | |
1233 | encodes as controller(userdata=00.00.00.07.00.00.00.00.00.04) | |
1234 | log(name="test1", verdict=drop, severity=info); | |
1235 | encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31) | |
1236 | log(verdict=drop, severity=info, meter="meter1"); | |
1237 | encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06,meter_id=4) | |
1238 | log(name="test1", verdict=drop, severity=info, meter="meter1"); | |
1239 | encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31,meter_id=4) | |
1240 | log(verdict=drop); | |
1241 | formats as log(verdict=drop, severity=info); | |
1242 | encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06) | |
1243 | log(verdict=bad_verdict, severity=info); | |
1244 | Syntax error at `bad_verdict' unknown verdict. | |
1245 | log(verdict=drop, severity=bad_severity); | |
1246 | Syntax error at `bad_severity' unknown severity. | |
1247 | log(severity=notice); | |
1248 | Syntax error at `;' expecting verdict. | |
1249 | ||
52ed5fcc NS |
1250 | # put_nd_ra_opts |
1251 | reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::/64, slla = ae:01:02:03:04:05); | |
1252 | encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.00.ff.ff.00.00.00.00.00.00.00.00.05.01.00.00.00.00.05.dc.03.04.40.c0.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.05,pause) | |
1253 | has prereqs ip6 | |
1254 | reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", slla = ae:01:02:03:04:10, mtu = 1450); | |
1255 | encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.80.ff.ff.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.10.05.01.00.00.00.00.05.aa,pause) | |
1256 | has prereqs ip6 | |
1257 | reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateless", slla = ae:01:02:03:04:06, prefix = aef0::/64); | |
1258 | encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.40.ff.ff.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.06.03.04.40.c0.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00,pause) | |
1259 | has prereqs ip6 | |
1260 | reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::/64); | |
1261 | slla option not present | |
1262 | reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", mtu = 1450, prefix = aef0::/64, prefix = bef0::/64, slla = ae:01:02:03:04:10); | |
36ffc466 MM |
1263 | encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.80.ff.ff.00.00.00.00.00.00.00.00.05.01.00.00.00.00.05.aa.03.04.40.80.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.03.04.40.80.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.be.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.10,pause) |
1264 | has prereqs ip6 | |
52ed5fcc | 1265 | reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", mtu = 1450, prefix = aef0::/64, prefix = bef0::/64, slla = ae:01:02:03:04:10); |
36ffc466 MM |
1266 | encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.80.ff.ff.00.00.00.00.00.00.00.00.05.01.00.00.00.00.05.aa.03.04.40.80.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.03.04.40.80.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.be.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.10,pause) |
1267 | has prereqs ip6 | |
52ed5fcc NS |
1268 | reg1[0] = put_nd_ra_opts(addr_mode = "slaac", slla = ae:01:02:03:04:10); |
1269 | prefix option needs to be set when address mode is slaac/dhcpv6_stateless. | |
1270 | reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateless", slla = ae:01:02:03:04:10); | |
1271 | prefix option needs to be set when address mode is slaac/dhcpv6_stateless. | |
1272 | reg1[0] = put_nd_ra_opts(addr_mode = dhcpv6_stateless, prefix = aef0::/64, slla = ae:01:02:03:04:10); | |
1273 | Syntax error at `dhcpv6_stateless' expecting constant. | |
1274 | reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::, slla = ae:01:02:03:04:10); | |
1275 | Invalid value for "prefix" option | |
1276 | reg1[0] = put_nd_ra_opts(addr_mode = "foo", mtu = 1500, slla = ae:01:02:03:04:10); | |
1277 | Invalid value for "addr_mode" option | |
1278 | reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = "1500", slla = ae:01:02:03:04:10); | |
1279 | IPv6 ND RA option mtu requires numeric value. | |
1280 | reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 10.0.0.4, slla = ae:01:02:03:04:10); | |
1281 | Invalid value for "mtu" option | |
1282 | ||
bc3d6a63 LB |
1283 | # icmp4 |
1284 | icmp4 { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; | |
1285 | encodes as controller(userdata=00.00.00.0a.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) | |
1286 | has prereqs ip4 | |
1287 | ||
1288 | icmp4 { }; | |
1289 | formats as icmp4 { drop; }; | |
1290 | encodes as controller(userdata=00.00.00.0a.00.00.00.00) | |
1291 | has prereqs ip4 | |
1292 | ||
086470cd NS |
1293 | # icmp4 with icmp4.frag_mtu |
1294 | icmp4 { eth.dst = ff:ff:ff:ff:ff:ff; icmp4.frag_mtu = 1500; output; }; output; | |
1295 | encodes as controller(userdata=00.00.00.0a.00.00.00.00.00.19.00.10.80.00.06.06.ff.ff.ff.ff.ff.ff.00.00.ff.ff.00.28.00.00.23.20.00.25.00.00.00.00.00.00.00.03.00.0e.00.00.00.0d.00.00.00.00.05.dc.00.00.00.04.00.04.00.00.00.00.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00),resubmit(,64) | |
1296 | has prereqs ip4 | |
1297 | ||
5e35f78a NS |
1298 | # icmp4_error |
1299 | icmp4_error { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; | |
1300 | encodes as controller(userdata=00.00.00.0e.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) | |
1301 | has prereqs ip4 | |
1302 | ||
1303 | icmp4_error { }; | |
1304 | formats as icmp4_error { drop; }; | |
1305 | encodes as controller(userdata=00.00.00.0e.00.00.00.00) | |
1306 | has prereqs ip4 | |
1307 | ||
1308 | # icmp4_error with icmp4.frag_mtu | |
1309 | icmp4_error { eth.dst = ff:ff:ff:ff:ff:ff; icmp4.frag_mtu = 1500; output; }; output; | |
1310 | encodes as controller(userdata=00.00.00.0e.00.00.00.00.00.19.00.10.80.00.06.06.ff.ff.ff.ff.ff.ff.00.00.ff.ff.00.28.00.00.23.20.00.25.00.00.00.00.00.00.00.03.00.0e.00.00.00.0d.00.00.00.00.05.dc.00.00.00.04.00.04.00.00.00.00.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00),resubmit(,64) | |
1311 | has prereqs ip4 | |
1312 | ||
086470cd NS |
1313 | icmp4.frag_mtu = 1500; |
1314 | encodes as controller(userdata=00.00.00.0d.00.00.00.00.05.dc,pause) | |
1315 | ||
3e7fa1e3 LB |
1316 | # icmp6 |
1317 | icmp6 { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; | |
1318 | encodes as controller(userdata=00.00.00.0a.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) | |
1319 | has prereqs ip6 | |
1320 | ||
1321 | icmp6 { }; | |
1322 | formats as icmp6 { drop; }; | |
1323 | encodes as controller(userdata=00.00.00.0a.00.00.00.00) | |
1324 | has prereqs ip6 | |
1325 | ||
22b65e4d LB |
1326 | # tcp_reset |
1327 | tcp_reset { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; | |
1328 | encodes as controller(userdata=00.00.00.0b.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) | |
1329 | has prereqs tcp | |
1330 | ||
1331 | tcp_reset { }; | |
1332 | formats as tcp_reset { drop; }; | |
1333 | encodes as controller(userdata=00.00.00.0b.00.00.00.00) | |
1334 | has prereqs tcp | |
1335 | ||
5e0d2837 LB |
1336 | # trigger_event |
1337 | trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c"); | |
1338 | encodes as controller(userdata=00.00.00.0f.00.00.00.00.00.00.00.00.00.01.00.0b.31.30.2e.30.2e.30.2e.31.3a.38.30.00.02.00.03.74.63.70.00.03.00.24.31.32.33.34.35.36.37.38.2d.61.62.63.64.2d.39.38.37.36.2d.66.65.64.63.2d.31.31.31.31.39.66.38.65.37.64.36.63) | |
1339 | ||
1340 | # Testing invalid vip results in extra error messages from socket-util.c | |
1341 | trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "sctp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c"); | |
1342 | Load balancer protocol 'sctp' is not 'tcp' or 'udp' | |
1343 | trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "bacon"); | |
1344 | Load balancer 'bacon' is not a UUID | |
1345 | ||
5f822129 | 1346 | # Contradictionary prerequisites (allowed but not useful): |
d5a76da4 BP |
1347 | ip4.src = ip6.src[0..31]; |
1348 | encodes as move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[] | |
1349 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
1350 | ip4.src <-> ip6.src[0..31]; | |
1351 | 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[] | |
1352 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
1353 | ||
e3fcc19d NS |
1354 | # check_pkt_larger |
1355 | reg0[0] = check_pkt_larger(1500); | |
1356 | encodes as check_pkt_larger(1500)->NXM_NX_XXREG0[96] | |
1357 | ||
1358 | reg0 = check_pkt_larger(1500); | |
1359 | Cannot use 32-bit field reg0[0..31] where 1-bit field is required. | |
1360 | ||
1361 | reg0 = check_pkt_larger(foo); | |
1362 | Cannot use 32-bit field reg0[0..31] where 1-bit field is required. | |
1363 | ||
1364 | reg0[0] = check_pkt_larger(foo); | |
1365 | Syntax error at `foo' expecting `;'. | |
1366 | ||
d5a76da4 BP |
1367 | # Miscellaneous negative tests. |
1368 | ; | |
1369 | Syntax error at `;'. | |
1370 | xyzzy; | |
1371 | Syntax error at `xyzzy' expecting action. | |
1372 | next; 123; | |
1373 | Syntax error at `123'. | |
1374 | next; xyzzy; | |
1375 | Syntax error at `xyzzy' expecting action. | |
1376 | next | |
9aef3c1b | 1377 | Syntax error at end of input expecting `;'. |
3b7cb7e1 | 1378 | ]]) |
d5a76da4 BP |
1379 | sed '/^[[ ]]/d' test-cases.txt > input.txt |
1380 | cp test-cases.txt expout | |
3b7cb7e1 BP |
1381 | AT_CHECK([ovstest test-ovn parse-actions < input.txt], [0], [expout]) |
1382 | AT_CLEANUP | |
f295c17b BP |
1383 | |
1384 | AT_BANNER([OVN end-to-end tests]) | |
1385 | ||
9975d7be BP |
1386 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor |
1387 | AT_SETUP([ovn -- 3 HVs, 1 LS, 3 lports/HV]) | |
57d143eb | 1388 | AT_KEYWORDS([ovnarp]) |
f295c17b BP |
1389 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1390 | ovn_start | |
1391 | ||
1392 | # Create hypervisors hv[123]. | |
9975d7be | 1393 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. |
f295c17b BP |
1394 | # Add all of the vifs to a single logical switch lsw0. |
1395 | # Turn on port security on all the vifs except vif[123]1. | |
1396 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
1397 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
ea46a4e9 | 1398 | ovn-nbctl ls-add lsw0 |
f295c17b BP |
1399 | net_add n1 |
1400 | for i in 1 2 3; do | |
1401 | sim_add hv$i | |
1402 | as hv$i | |
1403 | ovs-vsctl add-br br-phys | |
1404 | ovn_attach n1 br-phys 192.168.0.$i | |
1405 | ||
1406 | for j in 1 2 3; do | |
1407 | 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 | 1408 | ovn-nbctl lsp-add lsw0 lp$i$j |
4d5c43d5 | 1409 | if test $j = 1; then |
31ed1192 | 1410 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
f295c17b | 1411 | else |
7dc88496 NS |
1412 | if test $j = 3; then |
1413 | ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j" | |
1414 | else | |
1415 | ip_addrs="192.168.0.$i$j" | |
1416 | fi | |
31ed1192 JP |
1417 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs" |
1418 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
f295c17b BP |
1419 | fi |
1420 | done | |
1421 | done | |
1422 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1423 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop | |
1424 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop | |
ea382567 RB |
1425 | 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\" |
1426 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop | |
f295c17b | 1427 | |
3d2848ba HZ |
1428 | get_lsp_uuid () { |
1429 | ovn-nbctl lsp-list lsw0 | grep $1 | awk '{ print $1 }' | |
1430 | } | |
1431 | ||
1432 | ovn-nbctl create Port_Group name=pg1 ports=`get_lsp_uuid lp22`,`get_lsp_uuid lp33` | |
1433 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1238 && outport == @pg1' drop | |
1434 | ||
f295c17b BP |
1435 | # Pre-populate the hypervisors' ARP tables so that we don't lose any |
1436 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1437 | # for ARP resolution). | |
74868f2c | 1438 | OVN_POPULATE_ARP |
f295c17b BP |
1439 | |
1440 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1441 | # XXX This should be more systematic. | |
1442 | sleep 1 | |
611099dc | 1443 | |
fc6f9978 HZ |
1444 | # Make sure there is no attempt to adding duplicated flows by ovn-controller |
1445 | AT_FAIL_IF([test -n "`grep duplicate hv1/ovn-controller.log`"]) | |
1446 | AT_FAIL_IF([test -n "`grep duplicate hv2/ovn-controller.log`"]) | |
1447 | AT_FAIL_IF([test -n "`grep duplicate hv3/ovn-controller.log`"]) | |
1448 | ||
57d143eb HZ |
1449 | # Given the name of a logical port, prints the name of the hypervisor |
1450 | # on which it is located. | |
1451 | vif_to_hv() { | |
1452 | echo hv${1%?} | |
1453 | } | |
1454 | ||
f295c17b BP |
1455 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1456 | # | |
1457 | # This shell function causes a packet to be received on INPORT. The packet's | |
1458 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1459 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1460 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1461 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. |
f295c17b BP |
1462 | for i in 1 2 3; do |
1463 | for j in 1 2 3; do | |
1464 | : > $i$j.expected | |
1465 | done | |
1466 | done | |
1467 | test_packet() { | |
1468 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
57d143eb | 1469 | hv=`vif_to_hv $inport` |
f295c17b BP |
1470 | vif=vif$inport |
1471 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1472 | for outport; do | |
e4543cfe | 1473 | echo $packet >> $outport.expected |
f295c17b BP |
1474 | done |
1475 | } | |
1476 | ||
57d143eb HZ |
1477 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
1478 | # | |
1479 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1480 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1481 | # it should be the hardware address of the target to expect to receive in an | |
1482 | # ARP reply; otherwise no reply is expected. | |
1483 | # | |
31ed1192 | 1484 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
57d143eb HZ |
1485 | # SHA and REPLY_HA are each 12 hex digits. |
1486 | # SPA and TPA are each 8 hex digits. | |
1487 | test_arp() { | |
1488 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1489 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
1490 | hv=`vif_to_hv $inport` | |
1491 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
1492 | ||
92f9822b | 1493 | if test X$reply_ha = X; then |
57d143eb HZ |
1494 | # Expect to receive the broadcast ARP on the other logical switch ports |
1495 | # if no reply is expected. | |
1496 | local i j | |
1497 | for i in 1 2 3; do | |
1498 | for j in 1 2 3; do | |
1499 | if test $i$j != $inport; then | |
1500 | echo $request >> $i$j.expected | |
1501 | fi | |
1502 | done | |
1503 | done | |
1504 | else | |
1505 | # Expect to receive the reply, if any. | |
1506 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
1507 | echo $reply >> $inport.expected | |
1508 | fi | |
1509 | } | |
1510 | ||
1511 | ip_to_hex() { | |
1512 | printf "%02x%02x%02x%02x" "$@" | |
1513 | } | |
1514 | ||
f295c17b BP |
1515 | # Send packets between all pairs of source and destination ports: |
1516 | # | |
31ed1192 JP |
1517 | # 1. Unicast packets are delivered to exactly one logical switch port |
1518 | # (except that packets destined to their input ports are dropped). | |
f295c17b | 1519 | # |
31ed1192 JP |
1520 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1521 | # except the input port. | |
f295c17b | 1522 | # |
ea46a4e9 | 1523 | # 3. When port security is turned on, the switch drops packets from the wrong |
f295c17b BP |
1524 | # MAC address. |
1525 | # | |
ea46a4e9 | 1526 | # 4. The switch drops all packets with a VLAN tag. |
f295c17b | 1527 | # |
ea46a4e9 | 1528 | # 5. The switch drops all packets with a multicast source address. (This only |
f295c17b BP |
1529 | # affects behavior when port security is turned off, since otherwise port |
1530 | # security would drop the packet anyway.) | |
1531 | # | |
ea46a4e9 | 1532 | # 6. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1533 | # switch ports with "unknown" among their MAC addresses (and port |
1534 | # security disabled). | |
f295c17b | 1535 | # |
ea46a4e9 | 1536 | # 7. The switch drops unicast packets that violate an ACL. |
f295c17b | 1537 | # |
ea46a4e9 | 1538 | # 8. The switch drops multicast and broadcast packets that violate an ACL. |
57d143eb | 1539 | # |
9fcb6a18 BP |
1540 | # 9. OVN generates responses to ARP requests for known IPs, except for |
1541 | # requests from a port for the port's own IP. | |
57d143eb HZ |
1542 | # |
1543 | # 10. No response to ARP requests for unknown IPs. | |
4acd1e87 | 1544 | |
f295c17b BP |
1545 | for is in 1 2 3; do |
1546 | for js in 1 2 3; do | |
1547 | s=$is$js | |
1548 | bcast= | |
4d5c43d5 JP |
1549 | unknown= |
1550 | bacl2= | |
1551 | bacl3= | |
f295c17b BP |
1552 | for id in 1 2 3; do |
1553 | for jd in 1 2 3; do | |
1554 | d=$id$jd | |
1555 | ||
1556 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1557 | test_packet $s f000000000$d f000000000$s $s$d $unicast #1 | |
1558 | ||
1559 | if test $d != $s && test $js = 1; then | |
4d5c43d5 JP |
1560 | impersonate=$d |
1561 | else | |
1562 | impersonate= | |
1563 | fi | |
f295c17b BP |
1564 | test_packet $s f000000000$d f00000000055 55$d $impersonate #3 |
1565 | ||
4d5c43d5 JP |
1566 | if test $d != $s && test $s != 11; then acl2=$d; else acl2=; fi |
1567 | if test $d != $s && test $d != 33; then acl3=$d; else acl3=; fi | |
e137131a | 1568 | if test $d = $s || (test $js = 1 && test $d = 33); then |
ea382567 RB |
1569 | # Source of 11, 21, or 31 and dest of 33 should be dropped |
1570 | # due to the 4th ACL that uses address_set(set1). | |
1571 | acl4= | |
1572 | else | |
1573 | acl4=$d | |
1574 | fi | |
3d2848ba HZ |
1575 | if test $d = $s || test $d = 22 || test $d = 33; then |
1576 | # dest of 22 and 33 should be dropped | |
1577 | # due to the 5th ACL that uses port_group(pg1). | |
1578 | acl5= | |
1579 | else | |
1580 | acl5=$d | |
1581 | fi | |
f295c17b BP |
1582 | test_packet $s f000000000$d f000000000$s 1234 #7, acl1 |
1583 | test_packet $s f000000000$d f000000000$s 1235 $acl2 #7, acl2 | |
1584 | test_packet $s f000000000$d f000000000$s 1236 $acl3 #7, acl3 | |
ea382567 | 1585 | test_packet $s f000000000$d f000000000$s 1237 $acl4 #7, acl4 |
3d2848ba | 1586 | test_packet $s f000000000$d f000000000$s 1238 $acl5 #7, acl5 |
f295c17b BP |
1587 | |
1588 | test_packet $s f000000000$d f00000000055 810000091234 #4 | |
1589 | test_packet $s f000000000$d 0100000000$s $s$d #5 | |
1590 | ||
4d5c43d5 JP |
1591 | if test $d != $s && test $jd = 1; then |
1592 | unknown="$unknown $d" | |
1593 | fi | |
f295c17b BP |
1594 | bcast="$bcast $unicast" |
1595 | bacl2="$bacl2 $acl2" | |
1596 | bacl3="$bacl3 $acl3" | |
57d143eb | 1597 | |
db02f370 | 1598 | sip=`ip_to_hex 192 168 0 $is$js` |
57d143eb HZ |
1599 | tip=`ip_to_hex 192 168 0 $id$jd` |
1600 | tip_unknown=`ip_to_hex 11 11 11 11` | |
9fcb6a18 BP |
1601 | if test $d != $s; then |
1602 | reply_ha=f000000000$d | |
1603 | else | |
1604 | reply_ha= | |
1605 | fi | |
1606 | test_arp $s f000000000$s $sip $tip $reply_ha #9 | |
57d143eb | 1607 | test_arp $s f000000000$s $sip $tip_unknown #10 |
7dc88496 NS |
1608 | |
1609 | if test $jd = 3; then | |
31ed1192 | 1610 | # lsp[123]3 has an additional ip 192.169.0.[123]3. |
7dc88496 | 1611 | tip=`ip_to_hex 192 169 0 $id$jd` |
9fcb6a18 | 1612 | test_arp $s f000000000$s $sip $tip $reply_ha #9 |
7dc88496 | 1613 | fi |
f295c17b BP |
1614 | done |
1615 | done | |
1616 | ||
4d5c43d5 | 1617 | # Broadcast and multicast. |
f295c17b BP |
1618 | test_packet $s ffffffffffff f000000000$s ${s}ff $bcast #2 |
1619 | test_packet $s 010000000000 f000000000$s ${s}ff $bcast #2 | |
4d5c43d5 | 1620 | if test $js = 1; then |
f295c17b BP |
1621 | bcast_impersonate=$bcast |
1622 | else | |
4d5c43d5 JP |
1623 | bcast_impersonate= |
1624 | fi | |
f295c17b BP |
1625 | test_packet $s 010000000000 f00000000044 44ff $bcast_impersonate #3 |
1626 | ||
1627 | test_packet $s f0000000ffff f000000000$s ${s}66 $unknown #6 | |
1628 | ||
1629 | test_packet $s ffffffffffff f000000000$s 1234 #8, acl1 | |
1630 | test_packet $s ffffffffffff f000000000$s 1235 $bacl2 #8, acl2 | |
1631 | test_packet $s ffffffffffff f000000000$s 1236 $bacl3 #8, acl3 | |
1632 | test_packet $s 010000000000 f000000000$s 1234 #8, acl1 | |
1633 | test_packet $s 010000000000 f000000000$s 1235 $bacl2 #8, acl2 | |
1634 | test_packet $s 010000000000 f000000000$s 1236 $bacl3 #8, acl3 | |
1635 | done | |
1636 | done | |
1637 | ||
7dc88496 NS |
1638 | # set address for lp13 with invalid characters. |
1639 | # lp13 should be configured with only 192.168.0.13. | |
31ed1192 | 1640 | ovn-nbctl lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13" |
3b8cd0ea BP |
1641 | |
1642 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1643 | # XXX This should be more systematic. | |
1644 | sleep 1 | |
1645 | ||
7dc88496 NS |
1646 | sip=`ip_to_hex 192 168 0 11` |
1647 | tip=`ip_to_hex 192 168 0 13` | |
1648 | test_arp 11 f00000000011 $sip $tip f00000000013 | |
1649 | ||
1650 | tip=`ip_to_hex 192 169 0 13` | |
1651 | #arp request for 192.169.0.13 should be flooded | |
1652 | test_arp 11 f00000000011 $sip $tip | |
1653 | ||
91125642 | 1654 | # dump information and flows with counters |
bb0c41d3 RM |
1655 | ovn-sbctl dump-flows -- list multicast_group |
1656 | ||
1657 | echo "------ hv1 dump ------" | |
1658 | as hv1 ovs-vsctl show | |
1659 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1660 | ||
1661 | echo "------ hv2 dump ------" | |
1662 | as hv2 ovs-vsctl show | |
1663 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1664 | ||
1665 | echo "------ hv3 dump ------" | |
1666 | as hv3 ovs-vsctl show | |
1667 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
49d7c759 | 1668 | |
f295c17b BP |
1669 | # Now check the packets actually received against the ones expected. |
1670 | for i in 1 2 3; do | |
1671 | for j in 1 2 3; do | |
49d7c759 | 1672 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
f295c17b BP |
1673 | done |
1674 | done | |
fcde56f5 | 1675 | |
7a8f15e0 | 1676 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 1677 | |
f295c17b | 1678 | AT_CLEANUP |
eb6b08eb | 1679 | |
1f4a175e | 1680 | # 2 hypervisors, one logical switch, 2 logical ports per hypervisor |
1681 | # logical ports bound to chassis encap-ip. | |
1682 | AT_SETUP([ovn -- 2 HVs, 1 LS, 2 lports/HV]) | |
1683 | AT_KEYWORDS([ovnarp]) | |
1684 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1685 | ovn_start | |
1686 | ||
1687 | # Create hypervisors hv[12]. | |
1688 | # Add vif1[12] to hv1, vif2[12] to hv2 | |
1689 | ovn-nbctl ls-add lsw0 | |
1690 | net_add n1 | |
1691 | for i in 1 2; do | |
1692 | sim_add hv$i | |
1693 | as hv$i | |
1694 | ovs-vsctl add-br br-phys | |
1695 | ovn_attach n1 br-phys 192.168.0.$i | |
1696 | ||
1697 | for j in 1 2; do | |
1698 | 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 | |
1699 | ovn-nbctl lsp-add lsw0 lp$i$j | |
1700 | ip_addrs="192.168.0.$i$j" | |
1701 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs" | |
abf11558 | 1702 | ovn-nbctl --wait=hv lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j |
1f4a175e | 1703 | done |
1704 | done | |
1705 | ||
1706 | get_lsp_uuid () { | |
1707 | ovn-nbctl lsp-list lsw0 | grep $1 | awk '{ print $1 }' | |
1708 | } | |
1709 | ||
1710 | # XXX-Check how to pass lp$i1 in AT_CHECK_UNQUOTED, for now just do it | |
1711 | # explictly | |
1712 | ||
1713 | # For Chassis hv1 | |
1714 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp11], [0], [dnl | |
1715 | encap : [[]] | |
1716 | ]) | |
1717 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp12], [0], [dnl | |
1718 | encap : [[]] | |
1719 | ]) | |
1720 | ||
1721 | # For Chassis hv2 | |
1722 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp21], [0], [dnl | |
1723 | encap : [[]] | |
1724 | ]) | |
1725 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp22], [0], [dnl | |
1726 | encap : [[]] | |
1727 | ]) | |
1728 | ||
1729 | # Bind the ports to the encap-ip | |
1730 | for i in 1 2; do | |
1731 | for j in 1 2; do | |
1732 | as hv$i | |
1733 | ovs-vsctl set Interface vif$i$j external-ids:encap-ip=192.168.0.$i | |
1734 | done | |
1735 | done | |
1736 | ||
1737 | sleep 1 | |
1738 | ||
1739 | # dump port bindings; since we have vxlan and geneve tunnels, we expect the | |
1740 | # ports to be bound to geneve tunnels. | |
1741 | ||
1742 | # For Chassis 1 | |
1743 | encap_rec=`ovn-sbctl --data=bare --no-heading --column _uuid find encap chassis_name=hv1 type=geneve ip=192.168.0.1` | |
1744 | ||
1745 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp11], [0], [dnl | |
1746 | encap : ${encap_rec} | |
1747 | ]) | |
1748 | ||
1749 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp12], [0], [dnl | |
1750 | encap : ${encap_rec} | |
1751 | ]) | |
1752 | ||
1753 | # For Chassis 2 | |
1754 | encap_rec=`ovn-sbctl --data=bare --no-heading --column _uuid find encap chassis_name=hv2 type=geneve ip=192.168.0.2` | |
1755 | ||
1756 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp21], [0], [dnl | |
1757 | encap : ${encap_rec} | |
1758 | ]) | |
1759 | ||
1760 | AT_CHECK_UNQUOTED([ovn-sbctl --column encap list port_binding lp22], [0], [dnl | |
1761 | encap : ${encap_rec} | |
1762 | ]) | |
1763 | ||
1764 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1765 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1766 | # for ARP resolution). | |
1767 | OVN_POPULATE_ARP | |
1768 | ||
1769 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1770 | # XXX This should be more systematic. | |
1771 | sleep 1 | |
1772 | ||
1773 | # Make sure there is no attempt to adding duplicated flows by ovn-controller | |
1774 | AT_FAIL_IF([test -n "`grep duplicate hv1/ovn-controller.log`"]) | |
1775 | AT_FAIL_IF([test -n "`grep duplicate hv2/ovn-controller.log`"]) | |
1776 | AT_FAIL_IF([test -n "`grep duplicate hv3/ovn-controller.log`"]) | |
1777 | ||
1778 | # Given the name of a logical port, prints the name of the hypervisor | |
1779 | # on which it is located. | |
1780 | vif_to_hv() { | |
1781 | echo hv${1%?} | |
1782 | } | |
1783 | ||
1784 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... | |
1785 | # | |
1786 | # This shell function causes a packet to be received on INPORT. The packet's | |
1787 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1788 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1789 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1790 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. | |
1791 | for i in 1 2; do | |
1792 | for j in 1 2; do | |
1793 | : > $i$j.expected | |
1794 | done | |
1795 | done | |
1796 | test_packet() { | |
1797 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
1798 | hv=`vif_to_hv $inport` | |
1799 | vif=vif$inport | |
1800 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1801 | for outport; do | |
1802 | echo $packet >> $outport.expected | |
1803 | done | |
1804 | } | |
1805 | ||
1806 | ip_to_hex() { | |
1807 | printf "%02x%02x%02x%02x" "$@" | |
1808 | } | |
1809 | ||
1810 | # Send packets between all pairs of source and destination ports: | |
1811 | # | |
1812 | # 1. Unicast packets are delivered to exactly one logical switch port | |
1813 | # (except that packets destined to their input ports are dropped). | |
1814 | ||
1815 | for is in 1 2; do | |
1816 | for js in 1 2; do | |
1817 | s=$is$js | |
1818 | bcast= | |
1819 | unknown= | |
1820 | bacl2= | |
1821 | bacl3= | |
1822 | for id in 1 2 3; do | |
1823 | for jd in 1 2 3; do | |
1824 | d=$id$jd | |
1825 | ||
1826 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1827 | test_packet $s f000000000$d f000000000$s $s$d $unicast #1 | |
1828 | done | |
1829 | done | |
1830 | ||
1831 | done | |
1832 | done | |
1833 | ||
1834 | # dump information and flows with counters | |
1835 | ovn-sbctl dump-flows -- list multicast_group | |
1836 | ||
1837 | echo "------ hv1 dump ------" | |
1838 | as hv1 ovs-vsctl show | |
1839 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1840 | ||
1841 | echo "------ hv2 dump ------" | |
1842 | as hv2 ovs-vsctl show | |
1843 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1844 | ||
1845 | echo "------ hv3 dump ------" | |
1846 | as hv3 ovs-vsctl show | |
1847 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1848 | ||
1849 | # Now check the packets actually received against the ones expected. | |
1850 | for i in 1 2; do | |
1851 | for j in 1 2; do | |
1852 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) | |
1853 | done | |
1854 | done | |
1855 | ||
1856 | OVN_CLEANUP([hv1],[hv2]) | |
1857 | ||
1858 | AT_CLEANUP | |
1859 | ||
4acd1e87 BP |
1860 | AT_SETUP([ovn -- trace 1 LS, 3 LSPs]) |
1861 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1862 | ovn_start | |
1863 | ||
1864 | # Create a logical switch and some logical ports. | |
1865 | # Turn on port security on all lports except ls1. | |
1866 | # Make ls1 a destination for unknown MACs. | |
1867 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
1868 | ovn-nbctl ls-add lsw0 | |
1869 | ovn-sbctl chassis-add hv0 geneve 127.0.0.1 | |
1870 | for i in 1 2 3; do | |
1871 | ovn-nbctl lsp-add lsw0 lp$i | |
7979c444 BP |
1872 | done |
1873 | ovn-nbctl --wait=sb sync | |
1874 | for i in 1 2 3; do | |
4acd1e87 BP |
1875 | ovn-sbctl lsp-bind lp$i hv0 |
1876 | if test $i = 1; then | |
abb37b6b | 1877 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:0$i 192.168.0.$i" unknown |
4acd1e87 | 1878 | else |
abb37b6b FF |
1879 | if test $i = 3; then |
1880 | ip_addrs="192.168.0.$i fe80::ea2a:eaff:fe28:$i/64 192.169.0.$i" | |
1881 | else | |
1882 | ip_addrs="192.168.0.$i" | |
1883 | fi | |
a8e2addc LR |
1884 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:0$i $ip_addrs" |
1885 | ovn-nbctl lsp-set-port-security lp$i f0:00:00:00:00:0$i | |
4acd1e87 BP |
1886 | fi |
1887 | done | |
1888 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1889 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp1"' drop | |
1890 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp3"' drop | |
1891 | ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:01\",\"f0:00:00:00:00:02\" | |
1892 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp3"' drop | |
1893 | ||
1894 | ovn-nbctl --wait=sb sync | |
1895 | on_exit 'kill `cat ovn-trace.pid`' | |
1896 | ovn-trace --detach --pidfile --no-chdir | |
1897 | ||
1898 | # test_packet INPORT DST SRC [-vlan] [-eth TYPE] OUTPORT... | |
1899 | # | |
1900 | # This shell function causes a packet to be received on INPORT. The packet's | |
1901 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1902 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1903 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1904 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. | |
1905 | test_packet() { | |
1906 | local inport=$1 eth_dst=$2 eth_src=$3; shift; shift; shift | |
1907 | uflow="inport==\"lp$inport\" && eth.dst==$eth_dst && eth.src==$eth_src" | |
1908 | while :; do | |
abb37b6b FF |
1909 | case $1 in # ( |
1910 | -vlan) uflow="$uflow && vlan.vid == 1234"; shift ;; # ( | |
1911 | -eth) uflow="$uflow && eth.type == 0x$2"; shift; shift ;; # ( | |
1912 | *) break ;; | |
1913 | esac | |
4acd1e87 BP |
1914 | done |
1915 | for outport; do | |
abb37b6b | 1916 | echo "output(\"lp$outport\");" |
4acd1e87 BP |
1917 | done > expout |
1918 | ||
1919 | AT_CAPTURE_FILE([trace]) | |
1920 | AT_CHECK([ovs-appctl -t ovn-trace trace --all lsw0 "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
1921 | } | |
1922 | ||
1923 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
1924 | # | |
1925 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1926 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1927 | # it should be the hardware address of the target to expect to receive in an | |
1928 | # ARP reply; otherwise no reply is expected. | |
1929 | # | |
1930 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
1931 | # SHA and REPLY_HA are each 12 hex digits. | |
1932 | # SPA and TPA are each 8 hex digits. | |
1933 | test_arp() { | |
1934 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1935 | ||
1936 | local request="inport == \"lp$inport\" | |
1937 | && eth.dst == ff:ff:ff:ff:ff:ff && eth.src == $sha | |
1938 | && arp.op == 1 && arp.sha == $sha && arp.spa == $spa | |
abb37b6b | 1939 | && arp.tha == ff:ff:ff:ff:ff:ff && arp.tpa == $tpa" |
4acd1e87 BP |
1940 | |
1941 | if test -z "$reply_ha"; then | |
1942 | reply= | |
abb37b6b FF |
1943 | local i |
1944 | for i in 1 2 3; do | |
1945 | if test $i != $inport; then | |
1946 | reply="${reply}output(\"lp$i\"); | |
4acd1e87 | 1947 | " |
abb37b6b FF |
1948 | fi |
1949 | done | |
4acd1e87 BP |
1950 | else |
1951 | reply="\ | |
1952 | eth.dst = $sha; | |
1953 | eth.src = $reply_ha; | |
1954 | arp.op = 2; | |
1955 | arp.tha = $sha; | |
1956 | arp.sha = $reply_ha; | |
1957 | arp.tpa = $spa; | |
1958 | arp.spa = $tpa; | |
1959 | output(\"lp$inport\"); | |
1960 | " | |
1961 | fi | |
1962 | ||
1963 | AT_CAPTURE_FILE([trace]) | |
1964 | AT_CHECK_UNQUOTED([ovs-appctl -t ovn-trace trace --all lsw0 "$request" | tee trace | sed '1,/Minimal trace/d'], [0], [$reply]) | |
1965 | } | |
1966 | ||
1967 | # Send packets between all pairs of source and destination ports: | |
1968 | # | |
1969 | # 1. Unicast packets are delivered to exactly one logical switch port | |
1970 | # (except that packets destined to their input ports are dropped). | |
1971 | # | |
1972 | # 2. Broadcast and multicast are delivered to all logical switch ports | |
1973 | # except the input port. | |
1974 | # | |
1975 | # 3. When port security is turned on, the switch drops packets from the wrong | |
1976 | # MAC address. | |
1977 | # | |
1978 | # 4. The switch drops all packets with a VLAN tag. | |
1979 | # | |
1980 | # 5. The switch drops all packets with a multicast source address. (This only | |
1981 | # affects behavior when port security is turned off, since otherwise port | |
1982 | # security would drop the packet anyway.) | |
1983 | # | |
1984 | # 6. The switch delivers packets with an unknown destination to logical | |
1985 | # switch ports with "unknown" among their MAC addresses (and port | |
1986 | # security disabled). | |
1987 | # | |
1988 | # 7. The switch drops unicast packets that violate an ACL. | |
1989 | # | |
1990 | # 8. The switch drops multicast and broadcast packets that violate an ACL. | |
1991 | # | |
9fcb6a18 BP |
1992 | # 9. OVN generates responses to ARP requests for known IPs, except for |
1993 | # requests from a port for the port's own IP. | |
4acd1e87 BP |
1994 | # |
1995 | # 10. No response to ARP requests for unknown IPs. | |
1996 | ||
1997 | for s in 1 2 3; do | |
1998 | bcast= | |
1999 | unknown= | |
2000 | bacl2= | |
2001 | bacl3= | |
2002 | for d in 1 2 3; do | |
abb37b6b FF |
2003 | echo |
2004 | echo "lp$s -> lp$d" | |
2005 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2006 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s $unicast #1 | |
2007 | ||
2008 | if test $d != $s && test $s = 1; then | |
2009 | impersonate=$d | |
2010 | else | |
2011 | impersonate= | |
2012 | fi | |
2013 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 $impersonate #3 | |
2014 | ||
2015 | if test $d != $s && test $s != 1; then acl2=$d; else acl2=; fi | |
2016 | if test $d != $s && test $d != 3; then acl3=$d; else acl3=; fi | |
2017 | if test $d = $s || ( (test $s = 1 || test $s = 2) && test $d = 3); then | |
2018 | # Source of 1 or 2 and dest of 3 should be dropped | |
2019 | # due to the 4th ACL that uses address_set(set1). | |
2020 | acl4= | |
2021 | else | |
2022 | acl4=$d | |
2023 | fi | |
2024 | ||
2025 | #7, acl1 to acl4: | |
2026 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1234 | |
2027 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1235 $acl2 | |
2028 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1236 $acl3 | |
2029 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1237 $acl4 | |
2030 | ||
2031 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 -vlan #4 | |
2032 | test_packet $s f0:00:00:00:00:0$d 01:00:00:00:00:0$s #5 | |
2033 | ||
2034 | if test $d != $s && test $d = 1; then | |
2035 | unknown="$unknown $d" | |
2036 | fi | |
2037 | bcast="$bcast $unicast" | |
2038 | bacl2="$bacl2 $acl2" | |
2039 | bacl3="$bacl3 $acl3" | |
2040 | ||
2041 | sip=192.168.0.$s | |
2042 | tip=192.168.0.$d | |
2043 | tip_unknown=11.11.11.11 | |
9fcb6a18 BP |
2044 | if test $d != $s; then reply_ha=f0:00:00:00:00:0$d; else reply_ha=; fi |
2045 | test_arp $s f0:00:00:00:00:0$s $sip $tip $reply_ha #9 | |
abb37b6b FF |
2046 | test_arp $s f0:00:00:00:00:0$s $sip $tip_unknown #10 |
2047 | ||
2048 | if test $d = 3; then | |
2049 | # lp3 has an additional ip 192.169.0.[123]3. | |
2050 | tip=192.169.0.$d | |
9fcb6a18 | 2051 | test_arp $s f0:00:00:00:00:0$s $sip $tip $reply_ha #9 |
abb37b6b | 2052 | fi |
4acd1e87 BP |
2053 | done |
2054 | ||
2055 | # Broadcast and multicast. | |
2056 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s $bcast #2 | |
2057 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s $bcast #2 | |
2058 | if test $s = 1; then | |
abb37b6b | 2059 | bcast_impersonate=$bcast |
4acd1e87 | 2060 | else |
abb37b6b | 2061 | bcast_impersonate= |
4acd1e87 BP |
2062 | fi |
2063 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:44 $bcast_impersonate #3 | |
2064 | ||
2065 | test_packet $s f0:00:00:00:ff:ff f0:00:00:00:00:0$s $unknown #6 | |
2066 | ||
2067 | #8, acl1 to acl3: | |
2068 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1234 | |
2069 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
2070 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
2071 | ||
2072 | #8, acl1 to acl3: | |
2073 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1234 | |
2074 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
2075 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
2076 | done | |
2077 | ||
2078 | AT_CLEANUP | |
2079 | ||
7277bc83 RB |
2080 | # 2 hypervisors, 4 logical ports per HV |
2081 | # 2 locally attached networks (one flat, one vlan tagged over same device) | |
2082 | # 2 ports per HV on each network | |
e90aeb57 | 2083 | AT_SETUP([ovn -- 2 HVs, 4 lports/HV, localnet ports]) |
d79fc5f4 RB |
2084 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
2085 | ovn_start | |
2086 | ||
ea46a4e9 JP |
2087 | # In this test cases we create 3 switches, all connected to same |
2088 | # physical network (through br-phys on each HV). Each switch has | |
0ee7f7f1 HZ |
2089 | # VIF ports across 2 HVs. Each HV has 5 VIF ports. The first digit |
2090 | # of VIF port name indicates the hypervisor it is bound to, e.g. | |
2091 | # lp23 means VIF 3 on hv2. | |
2092 | # | |
ea46a4e9 | 2093 | # Each switch's VLAN tag and their logical switch ports are: |
0ee7f7f1 HZ |
2094 | # - ls1: |
2095 | # - untagged | |
ea46a4e9 | 2096 | # - ports: lp11, lp12, lp21, lp22 |
0ee7f7f1 HZ |
2097 | # |
2098 | # - ls2: | |
2099 | # - tagged with VLAN 101 | |
ea46a4e9 | 2100 | # - ports: lp13, lp14, lp23, lp24 |
0ee7f7f1 HZ |
2101 | # - ls3: |
2102 | # - untagged | |
ea46a4e9 | 2103 | # - ports: lp15, lp25 |
0ee7f7f1 | 2104 | # |
ea46a4e9 | 2105 | # Note: a localnet port is created for each switch to connect to |
0ee7f7f1 HZ |
2106 | # physical network. |
2107 | ||
2108 | for i in 1 2 3; do | |
ea46a4e9 JP |
2109 | ls_name=ls$i |
2110 | ovn-nbctl ls-add $ls_name | |
0ee7f7f1 HZ |
2111 | ln_port_name=ln$i |
2112 | if test $i -eq 2; then | |
ea46a4e9 | 2113 | ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 |
0ee7f7f1 | 2114 | else |
ea46a4e9 | 2115 | ovn-nbctl lsp-add $ls_name $ln_port_name |
0ee7f7f1 | 2116 | fi |
31ed1192 JP |
2117 | ovn-nbctl lsp-set-addresses $ln_port_name unknown |
2118 | ovn-nbctl lsp-set-type $ln_port_name localnet | |
2119 | ovn-nbctl lsp-set-options $ln_port_name network_name=phys | |
0ee7f7f1 | 2120 | done |
d79fc5f4 | 2121 | |
69b72264 BP |
2122 | # lsp_to_ls LSP |
2123 | # | |
2124 | # Prints the name of the logical switch that contains LSP. | |
2125 | lsp_to_ls () { | |
2126 | case $1 in dnl ( | |
5a0e4aec BP |
2127 | lp?[[12]]) echo ls1 ;; dnl ( |
2128 | lp?[[34]]) echo ls2 ;; dnl ( | |
2129 | lp?5) echo ls3 ;; dnl ( | |
2130 | *) AT_FAIL_IF([:]) ;; | |
69b72264 BP |
2131 | esac |
2132 | } | |
2133 | ||
d79fc5f4 RB |
2134 | net_add n1 |
2135 | for i in 1 2; do | |
2136 | sim_add hv$i | |
2137 | as hv$i | |
2138 | ovs-vsctl add-br br-phys | |
2139 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
2140 | ovn_attach n1 br-phys 192.168.0.$i | |
2141 | ||
0ee7f7f1 | 2142 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
2143 | ovs-vsctl add-port br-int vif$i$j -- \ |
2144 | set Interface vif$i$j external-ids:iface-id=lp$i$j \ | |
2145 | options:tx_pcap=hv$i/vif$i$j-tx.pcap \ | |
2146 | options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ | |
2147 | ofport-request=$i$j | |
2148 | ||
31ed1192 | 2149 | lsp_name=lp$i$j |
5a0e4aec | 2150 | ls_name=$(lsp_to_ls $lsp_name) |
d79fc5f4 | 2151 | |
ea46a4e9 | 2152 | ovn-nbctl lsp-add $ls_name $lsp_name |
31ed1192 JP |
2153 | ovn-nbctl lsp-set-addresses $lsp_name f0:00:00:00:00:$i$j |
2154 | ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$j | |
d79fc5f4 | 2155 | |
31ed1192 | 2156 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) |
d79fc5f4 RB |
2157 | done |
2158 | done | |
69b72264 BP |
2159 | ovn-nbctl --wait=sb sync |
2160 | ovn-sbctl dump-flows | |
d79fc5f4 | 2161 | |
74868f2c | 2162 | OVN_POPULATE_ARP |
d79fc5f4 RB |
2163 | |
2164 | # XXX This is now the 3rd copy of these functions in this file ... | |
2165 | ||
2166 | # Given the name of a logical port, prints the name of the hypervisor | |
2167 | # on which it is located. | |
2168 | vif_to_hv() { | |
2169 | echo hv${1%?} | |
2170 | } | |
2171 | # | |
69b72264 | 2172 | # test_packet INPORT DST SRC ETHTYPE EOUT LOUT |
d79fc5f4 RB |
2173 | # |
2174 | # This shell function causes a packet to be received on INPORT. The packet's | |
2175 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
69b72264 BP |
2176 | # digits) and Ethernet type ETHTYPE (4 hex digits). INPORT is specified as |
2177 | # logical switch port numbers, e.g. 11 for vif11. | |
2178 | # | |
2179 | # EOUT is the end-to-end output port, that is, where the packet will end up | |
2180 | # after possibly bouncing through one or more localnet ports. LOUT is the | |
2181 | # logical output port, which might be a localnet port, as seen by ovn-trace | |
2182 | # (which doesn't know what localnet ports are connected to and therefore can't | |
2183 | # figure out the end-to-end answer). | |
d79fc5f4 | 2184 | for i in 1 2; do |
0ee7f7f1 | 2185 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
2186 | : > $i$j.expected |
2187 | done | |
2188 | done | |
2189 | test_packet() { | |
69b72264 BP |
2190 | local inport=$1 dst=$2 src=$3 eth=$4 eout=$5 lout=$6 |
2191 | echo "$@" | |
2192 | ||
2193 | # First try tracing the packet. | |
2194 | uflow="inport==\"lp$inport\" && eth.dst==$dst && eth.src==$src && eth.type==0x$eth" | |
2195 | if test $lout != drop; then | |
2196 | echo "output(\"$lout\");" | |
2197 | fi > expout | |
2198 | AT_CAPTURE_FILE([trace]) | |
2199 | AT_CHECK([ovn-trace --all $(lsp_to_ls lp$inport) "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
2200 | ||
2201 | # Then actually send a packet, for an end-to-end test. | |
2202 | local packet=$(echo $dst$src | sed 's/://g')${eth} | |
d79fc5f4 RB |
2203 | hv=`vif_to_hv $inport` |
2204 | vif=vif$inport | |
2205 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
69b72264 BP |
2206 | if test $eout != drop; then |
2207 | echo $packet >> ${eout#lp}.expected | |
2208 | fi | |
d79fc5f4 RB |
2209 | } |
2210 | ||
7277bc83 RB |
2211 | # lp11 and lp21 are on the same network (phys, untagged) |
2212 | # and on different hypervisors | |
69b72264 BP |
2213 | test_packet 11 f0:00:00:00:00:21 f0:00:00:00:00:11 1121 lp21 lp21 |
2214 | test_packet 21 f0:00:00:00:00:11 f0:00:00:00:00:21 2111 lp11 lp11 | |
d79fc5f4 | 2215 | |
7277bc83 RB |
2216 | # lp11 and lp12 are on the same network (phys, untagged) |
2217 | # and on the same hypervisor | |
69b72264 BP |
2218 | test_packet 11 f0:00:00:00:00:12 f0:00:00:00:00:11 1112 lp12 lp12 |
2219 | test_packet 12 f0:00:00:00:00:11 f0:00:00:00:00:12 1211 lp11 lp11 | |
7277bc83 RB |
2220 | |
2221 | # lp13 and lp23 are on the same network (phys, VLAN 101) | |
2222 | # and on different hypervisors | |
69b72264 BP |
2223 | test_packet 13 f0:00:00:00:00:23 f0:00:00:00:00:13 1323 lp23 lp23 |
2224 | test_packet 23 f0:00:00:00:00:13 f0:00:00:00:00:23 2313 lp13 lp13 | |
7277bc83 RB |
2225 | |
2226 | # lp13 and lp14 are on the same network (phys, VLAN 101) | |
2227 | # and on the same hypervisor | |
69b72264 BP |
2228 | test_packet 13 f0:00:00:00:00:14 f0:00:00:00:00:13 1314 lp14 lp14 |
2229 | test_packet 14 f0:00:00:00:00:13 f0:00:00:00:00:14 1413 lp13 lp13 | |
d79fc5f4 | 2230 | |
0ee7f7f1 | 2231 | # lp11 and lp15 are on the same network (phys, untagged), |
ea46a4e9 | 2232 | # same hypervisor, and on different switches |
69b72264 BP |
2233 | test_packet 11 f0:00:00:00:00:15 f0:00:00:00:00:11 1115 lp15 ln1 |
2234 | test_packet 15 f0:00:00:00:00:11 f0:00:00:00:00:15 1511 lp11 ln3 | |
0ee7f7f1 HZ |
2235 | |
2236 | # lp11 and lp25 are on the same network (phys, untagged), | |
ea46a4e9 | 2237 | # different hypervisors, and on different switches |
69b72264 BP |
2238 | test_packet 11 f0:00:00:00:00:25 f0:00:00:00:00:11 1125 lp25 ln1 |
2239 | test_packet 25 f0:00:00:00:00:11 f0:00:00:00:00:25 2511 lp11 ln3 | |
0ee7f7f1 | 2240 | |
d79fc5f4 | 2241 | # Ports that should not be able to communicate |
69b72264 BP |
2242 | test_packet 11 f0:00:00:00:00:13 f0:00:00:00:00:11 1113 drop ln1 |
2243 | test_packet 11 f0:00:00:00:00:23 f0:00:00:00:00:11 1123 drop ln1 | |
2244 | test_packet 21 f0:00:00:00:00:13 f0:00:00:00:00:21 2113 drop ln1 | |
2245 | test_packet 21 f0:00:00:00:00:23 f0:00:00:00:00:21 2123 drop ln1 | |
2246 | test_packet 13 f0:00:00:00:00:11 f0:00:00:00:00:13 1311 drop ln2 | |
2247 | test_packet 13 f0:00:00:00:00:21 f0:00:00:00:00:13 1321 drop ln2 | |
2248 | test_packet 23 f0:00:00:00:00:11 f0:00:00:00:00:23 2311 drop ln2 | |
2249 | test_packet 23 f0:00:00:00:00:21 f0:00:00:00:00:23 2321 drop ln2 | |
d79fc5f4 | 2250 | |
d79fc5f4 RB |
2251 | # Dump a bunch of info helpful for debugging if there's a failure. |
2252 | ||
2253 | echo "------ OVN dump ------" | |
2254 | ovn-nbctl show | |
2255 | ovn-sbctl show | |
2256 | ||
2257 | echo "------ hv1 dump ------" | |
2258 | as hv1 ovs-vsctl show | |
2259 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2260 | ||
2261 | echo "------ hv2 dump ------" | |
2262 | as hv2 ovs-vsctl show | |
2263 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2264 | ||
2265 | # Now check the packets actually received against the ones expected. | |
2266 | for i in 1 2; do | |
0ee7f7f1 | 2267 | for j in 1 2 3 4 5; do |
49d7c759 | 2268 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
d79fc5f4 RB |
2269 | done |
2270 | done | |
2271 | ||
7a8f15e0 | 2272 | OVN_CLEANUP([hv1],[hv2]) |
d9c8c57c | 2273 | |
d79fc5f4 RB |
2274 | AT_CLEANUP |
2275 | ||
91125642 FF |
2276 | AT_SETUP([ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS]) |
2277 | AT_KEYWORDS([vtep]) | |
eb6b08eb JP |
2278 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
2279 | ovn_start | |
2280 | ||
2281 | # Configure the Northbound database | |
ea46a4e9 | 2282 | ovn-nbctl ls-add lsw0 |
eb6b08eb | 2283 | |
31ed1192 JP |
2284 | ovn-nbctl lsp-add lsw0 lp1 |
2285 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
eb6b08eb | 2286 | |
31ed1192 JP |
2287 | ovn-nbctl lsp-add lsw0 lp2 |
2288 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
eb6b08eb | 2289 | |
31ed1192 JP |
2290 | ovn-nbctl lsp-add lsw0 lp-vtep |
2291 | ovn-nbctl lsp-set-type lp-vtep vtep | |
2292 | ovn-nbctl lsp-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0 | |
2293 | ovn-nbctl lsp-set-addresses lp-vtep unknown | |
eb6b08eb | 2294 | |
77adbb62 DB |
2295 | # lpr, lr and lrp1 are used for the ARP request handling test only. |
2296 | ovn-nbctl lsp-add lsw0 lpr | |
2297 | ovn-nbctl lr-add lr | |
2298 | ovn-nbctl lrp-add lr lrp1 f0:00:00:00:00:f1 192.168.1.1/24 | |
2299 | ovn-nbctl set Logical_Switch_Port lpr type=router \ | |
2300 | options:router-port=lrp1 \ | |
2301 | addresses='"f0:00:00:00:00:f1 192.168.1.1"' | |
2302 | ||
2303 | ||
eb6b08eb JP |
2304 | net_add n1 # Network to connect hv1, hv2, and vtep |
2305 | net_add n2 # Network to connect vtep and hv3 | |
2306 | ||
2307 | # Create hypervisor hv1 connected to n1 | |
2308 | sim_add hv1 | |
2309 | as hv1 | |
2310 | ovs-vsctl add-br br-phys | |
2311 | ovn_attach n1 br-phys 192.168.0.1 | |
2312 | 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 | |
2313 | ||
2314 | # Create hypervisor hv2 connected to n1 | |
2315 | sim_add hv2 | |
2316 | as hv2 | |
2317 | ovs-vsctl add-br br-phys | |
2318 | ovn_attach n1 br-phys 192.168.0.2 | |
2319 | 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 | |
2320 | ||
2321 | ||
2322 | # Start the vtep emulator with a leg in both networks | |
2323 | sim_add vtep | |
2324 | as vtep | |
2325 | ||
2326 | ovsdb-tool create "$ovs_base"/vtep/vtep.db "$abs_top_srcdir"/vtep/vtep.ovsschema || return 1 | |
2327 | ovs-appctl -t ovsdb-server ovsdb-server/add-db "$ovs_base"/vtep/vtep.db | |
2328 | ||
2329 | ovs-vsctl add-br br-phys | |
2330 | net_attach n1 br-phys | |
2331 | ||
2332 | mac=`ovs-vsctl get Interface br-phys mac_in_use | sed s/\"//g` | |
2333 | arp_table="$arp_table $sandbox,br-phys,192.168.0.3,$mac" | |
2334 | ovs-appctl netdev-dummy/ip4addr br-phys 192.168.0.3/24 >/dev/null || return 1 | |
2335 | ovs-appctl ovs/route/add 192.168.0.3/24 br-phys >/dev/null || return 1 | |
2336 | ||
2337 | ovs-vsctl add-br br-vtep | |
2338 | net_attach n2 br-vtep | |
2339 | ||
2340 | vtep-ctl add-ps br-vtep | |
2341 | vtep-ctl set Physical_Switch br-vtep tunnel_ips=192.168.0.3 | |
2342 | vtep-ctl add-ls lsw0 | |
2343 | ||
2344 | start_daemon ovs-vtep br-vtep | |
2345 | start_daemon ovn-controller-vtep --vtep-db=unix:"$ovs_base"/vtep/db.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
2346 | ||
8cdc4312 | 2347 | OVS_WAIT_UNTIL([vtep-ctl bind-ls br-vtep br-vtep_n2 0 lsw0]) |
eb6b08eb | 2348 | |
475f0a2c DB |
2349 | OVS_WAIT_UNTIL([test -n "`as vtep vtep-ctl get-replication-mode lsw0 | |
2350 | grep -- source`"]) | |
2351 | # It takes more time for the update to be processed by ovs-vtep. | |
eb6b08eb JP |
2352 | sleep 1 |
2353 | ||
2354 | # Add hv3 on the other side of the vtep | |
2355 | sim_add hv3 | |
2356 | as hv3 | |
2357 | ovs-vsctl add-br br-phys | |
2358 | net_attach n2 br-phys | |
2359 | ||
2360 | 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 | |
2361 | ||
2362 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2363 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2364 | # for ARP resolution). | |
74868f2c | 2365 | OVN_POPULATE_ARP |
eb6b08eb JP |
2366 | |
2367 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2368 | # XXX This should be more systematic. | |
2369 | sleep 1 | |
6977df72 | 2370 | |
eb6b08eb JP |
2371 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
2372 | # | |
2373 | # This shell function causes a packet to be received on INPORT. The packet's | |
2374 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2375 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2376 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 2377 | # OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1. |
eb6b08eb JP |
2378 | for i in 1 2 3; do |
2379 | : > $i.expected | |
2380 | done | |
2381 | test_packet() { | |
2382 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
2383 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
2384 | hv=hv$inport | |
2385 | vif=vif$inport | |
2386 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
2387 | for outport; do | |
e4543cfe | 2388 | echo $packet >> $outport.expected |
eb6b08eb JP |
2389 | done |
2390 | } | |
2391 | ||
2392 | # Send packets between all pairs of source and destination ports: | |
2393 | # | |
31ed1192 JP |
2394 | # 1. Unicast packets are delivered to exactly one logical switch port |
2395 | # (except that packets destined to their input ports are dropped). | |
eb6b08eb | 2396 | # |
31ed1192 JP |
2397 | # 2. Broadcast and multicast are delivered to all logical switch ports |
2398 | # except the input port. | |
eb6b08eb | 2399 | # |
ea46a4e9 | 2400 | # 3. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
2401 | # switch ports with "unknown" among their MAC addresses (and port |
2402 | # security disabled). | |
eb6b08eb JP |
2403 | for s in 1 2 3; do |
2404 | bcast= | |
2405 | unknown= | |
2406 | for d in 1 2 3; do | |
2407 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2408 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
2409 | ||
2410 | # The vtep (vif3) is the only one configured for "unknown" | |
2411 | if test $d != $s && test $d = 3; then | |
2412 | unknown="$unknown $d" | |
2413 | fi | |
2414 | bcast="$bcast $unicast" | |
2415 | done | |
2416 | ||
2417 | # Broadcast and multicast. | |
46ed1382 DB |
2418 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 |
2419 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #2 | |
eb6b08eb JP |
2420 | |
2421 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #3 | |
2422 | done | |
2423 | ||
77adbb62 DB |
2424 | # ARP request should not be responded to by logical switch router |
2425 | # type arp responder on HV1 and HV2 and should reach directly to | |
2426 | # vif1 and vif2 | |
2427 | ip_to_hex() { | |
2428 | printf "%02x%02x%02x%02x" "$@" | |
2429 | } | |
2430 | sha=f00000000003 | |
2431 | spa=`ip_to_hex 192 168 1 2` | |
2432 | tpa=`ip_to_hex 192 168 1 1` | |
2433 | request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2434 | as hv3 ovs-appctl netdev-dummy/receive vif3 $request | |
2435 | echo $request >> 1.expected | |
2436 | echo $request >> 2.expected | |
2437 | ||
bb0c41d3 RM |
2438 | # dump information with counters |
2439 | echo "------ OVN dump ------" | |
2440 | ovn-nbctl show | |
2441 | ovn-sbctl show | |
2442 | ||
77adbb62 DB |
2443 | echo "---------SB dump-----" |
2444 | ovn-sbctl list datapath_binding | |
2445 | echo "---------------------" | |
2446 | ovn-sbctl list port_binding | |
2447 | echo "---------------------" | |
2448 | ovn-sbctl dump-flows | |
2449 | ||
bb0c41d3 RM |
2450 | echo "------ hv1 dump ------" |
2451 | as hv1 ovs-vsctl show | |
6195e2e7 | 2452 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2453 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2454 | ||
2455 | echo "------ hv2 dump ------" | |
2456 | as hv2 ovs-vsctl show | |
6195e2e7 | 2457 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2458 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2459 | ||
2460 | echo "------ hv3 dump ------" | |
2461 | as hv3 ovs-vsctl show | |
6754e92d FF |
2462 | # note: hv3 has no logical port bind, thus it should not have br-int |
2463 | AT_CHECK([as hv3 ovs-ofctl -O OpenFlow13 show br-int], [1], [], | |
2464 | [ovs-ofctl: br-int is not a bridge or a socket | |
2465 | ]) | |
bb0c41d3 | 2466 | |
eb6b08eb JP |
2467 | # Now check the packets actually received against the ones expected. |
2468 | for i in 1 2 3; do | |
49d7c759 | 2469 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
eb6b08eb | 2470 | done |
fcde56f5 LR |
2471 | |
2472 | # Gracefully terminate daemons | |
7a8f15e0 LR |
2473 | OVN_CLEANUP([hv1],[hv2],[vtep]) |
2474 | OVN_CLEANUP_VSWITCH([hv3]) | |
d9c8c57c | 2475 | |
eb6b08eb | 2476 | AT_CLEANUP |
9975d7be | 2477 | |
184bc3ca RB |
2478 | # Similar test to "hardware GW" |
2479 | AT_SETUP([ovn -- 3 HVs, 1 VIFs/HV, 1 software GW, 1 LS]) | |
2480 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2481 | ovn_start | |
2482 | ||
2483 | # Configure the Northbound database | |
2484 | ovn-nbctl ls-add lsw0 | |
2485 | ||
2486 | ovn-nbctl lsp-add lsw0 lp1 | |
2487 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
2488 | ||
2489 | ovn-nbctl lsp-add lsw0 lp2 | |
2490 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
2491 | ||
2492 | ovn-nbctl lsp-add lsw0 lp-gw | |
2493 | ovn-nbctl lsp-set-type lp-gw l2gateway | |
62b87eab | 2494 | ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw |
184bc3ca RB |
2495 | ovn-nbctl lsp-set-addresses lp-gw unknown |
2496 | ||
2497 | net_add n1 # Network to connect hv1, hv2, and gw | |
2498 | net_add n2 # Network to connect gw and hv3 | |
2499 | ||
2500 | # Create hypervisor hv1 connected to n1 | |
2501 | sim_add hv1 | |
2502 | as hv1 | |
2503 | ovs-vsctl add-br br-phys | |
2504 | ovn_attach n1 br-phys 192.168.0.1 | |
2505 | 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 | |
2506 | ||
2507 | # Create hypervisor hv2 connected to n1 | |
2508 | sim_add hv2 | |
2509 | as hv2 | |
2510 | ovs-vsctl add-br br-phys | |
2511 | ovn_attach n1 br-phys 192.168.0.2 | |
2512 | 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 | |
2513 | ||
2514 | # Create hypervisor hv_gw connected to n1 and n2 | |
2515 | # connect br-phys bridge to n1; connect hv-gw bridge to n2 | |
2516 | sim_add hv_gw | |
2517 | as hv_gw | |
2518 | ovs-vsctl add-br br-phys | |
2519 | ovn_attach n1 br-phys 192.168.0.3 | |
2520 | ovs-vsctl add-br br-phys2 | |
2521 | net_attach n2 br-phys2 | |
2522 | ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2" | |
2523 | ||
184bc3ca RB |
2524 | # Add hv3 on the other side of the GW |
2525 | sim_add hv3 | |
2526 | as hv3 | |
2527 | ovs-vsctl add-br br-phys | |
2528 | net_attach n2 br-phys | |
2529 | 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 | |
2530 | ||
2531 | ||
2532 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2533 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2534 | # for ARP resolution). | |
74868f2c | 2535 | OVN_POPULATE_ARP |
184bc3ca RB |
2536 | |
2537 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2538 | # XXX This should be more systematic. | |
2539 | sleep 1 | |
2540 | ||
2541 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... | |
2542 | # | |
2543 | # This shell function causes a packet to be received on INPORT. The packet's | |
2544 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2545 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2546 | # more) list the VIFs on which the packet should be received. INPORT and the | |
2547 | # OUTPORTs are specified as lport numbers, e.g. 1 for vif1. | |
184bc3ca RB |
2548 | for i in 1 2 3; do |
2549 | : > $i.expected | |
2550 | done | |
2551 | test_packet() { | |
2552 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
2553 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
2554 | hv=hv$inport | |
2555 | vif=vif$inport | |
2556 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
2557 | for outport; do | |
e4543cfe | 2558 | echo $packet >> $outport.expected |
184bc3ca RB |
2559 | done |
2560 | } | |
2561 | ||
2562 | # Send packets between all pairs of source and destination ports: | |
2563 | # | |
2564 | # 1. Unicast packets are delivered to exactly one lport (except that packets | |
2565 | # destined to their input ports are dropped). | |
2566 | # | |
2567 | # 2. Broadcast and multicast are delivered to all lports except the input port. | |
2568 | # | |
2569 | # 3. The lswitch delivers packets with an unknown destination to lports with | |
2570 | # "unknown" among their MAC addresses (and port security disabled). | |
2571 | for s in 1 2 3 ; do | |
2572 | bcast= | |
2573 | unknown= | |
2574 | for d in 1 2 3 ; do | |
2575 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2576 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
2577 | ||
2578 | # The vtep (vif3) is the only one configured for "unknown" | |
2579 | if test $d != $s && test $d = 3; then | |
2580 | unknown="$unknown $d" | |
2581 | fi | |
2582 | bcast="$bcast $unicast" | |
2583 | done | |
2584 | ||
2585 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 | |
2586 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #3 | |
2587 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #4 | |
2588 | done | |
2589 | ||
184bc3ca RB |
2590 | echo "------ ovn-nbctl show ------" |
2591 | ovn-nbctl show | |
2592 | echo "------ ovn-sbctl show ------" | |
2593 | ovn-sbctl show | |
2594 | ||
2595 | echo "------ hv1 ------" | |
2596 | as hv1 ovs-vsctl show | |
2597 | echo "------ hv1 br-int ------" | |
2598 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2599 | echo "------ hv1 br-phys ------" | |
2600 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2601 | ||
2602 | echo "------ hv2 ------" | |
2603 | as hv2 ovs-vsctl show | |
2604 | echo "------ hv2 br-int ------" | |
2605 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2606 | echo "------ hv2 br-phys ------" | |
2607 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2608 | ||
2609 | echo "------ hv_gw ------" | |
2610 | as hv_gw ovs-vsctl show | |
2611 | echo "------ hv_gw br-phys ------" | |
2612 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2613 | echo "------ hv_gw br-phys2 ------" | |
2614 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys2 | |
2615 | ||
2616 | echo "------ hv3 ------" | |
2617 | as hv3 ovs-vsctl show | |
2618 | echo "------ hv3 br-phys ------" | |
2619 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2620 | ||
2621 | # Now check the packets actually received against the ones expected. | |
2622 | for i in 1 2 3; do | |
49d7c759 | 2623 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
184bc3ca RB |
2624 | done |
2625 | AT_CLEANUP | |
2626 | ||
9975d7be BP |
2627 | # 3 hypervisors, 3 logical switches with 3 logical ports each, 1 logical router |
2628 | AT_SETUP([ovn -- 3 HVs, 3 LS, 3 lports/LS, 1 LR]) | |
2629 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2630 | ovn_start | |
2631 | ||
2632 | # Logical network: | |
2633 | # | |
2634 | # Three logical switches ls1, ls2, ls3. | |
86e98048 BP |
2635 | # One logical router lr0 connected to ls[123], |
2636 | # with nine subnets, three per logical switch: | |
2637 | # | |
2638 | # lrp11 on ls1 for subnet 192.168.11.0/24 | |
2639 | # lrp12 on ls1 for subnet 192.168.12.0/24 | |
2640 | # lrp13 on ls1 for subnet 192.168.13.0/24 | |
2641 | # ... | |
2642 | # lrp33 on ls3 for subnet 192.168.33.0/24 | |
2643 | # | |
2644 | # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two | |
2645 | # digits are the subnet and the last digit distinguishes the VIF. | |
9975d7be | 2646 | for i in 1 2 3; do |
ea46a4e9 | 2647 | ovn-nbctl ls-add ls$i |
9975d7be | 2648 | for j in 1 2 3; do |
86e98048 | 2649 | for k in 1 2 3; do |
31ed1192 JP |
2650 | # Add "unknown" to MAC addresses for lp?11, so packets for |
2651 | # MAC-IP bindings discovered via ARP later have somewhere to go. | |
2652 | if test $j$k = 11; then unknown=unknown; else unknown=; fi | |
2653 | ||
2654 | ovn-nbctl \ | |
2655 | -- lsp-add ls$i lp$i$j$k \ | |
4357b6bc BP |
2656 | -- lsp-set-addresses lp$i$j$k \ |
2657 | "f0:00:00:00:0$i:$j$k 192.168.$i$j.$k" $unknown | |
86e98048 BP |
2658 | done |
2659 | done | |
2660 | done | |
2661 | ||
fa2a27b2 | 2662 | ovn-nbctl lr-add lr0 |
86e98048 BP |
2663 | for i in 1 2 3; do |
2664 | for j in 1 2 3; do | |
bf44c2cd | 2665 | ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24 |
269ecccc | 2666 | ovn-nbctl \ |
31ed1192 | 2667 | -- lsp-add ls$i lrp$i$j-attachment \ |
269ecccc | 2668 | -- set Logical_Switch_Port lrp$i$j-attachment type=router \ |
00007447 | 2669 | options:router-port=lrp$i$j \ |
86e98048 | 2670 | addresses='"00:00:00:00:ff:'$i$j'"' |
9975d7be BP |
2671 | done |
2672 | done | |
2673 | ||
80f408f4 | 2674 | ovn-nbctl set Logical_Switch_Port lrp33-attachment \ |
57d143eb HZ |
2675 | addresses='"00:00:00:00:ff:33 192.168.33.254"' |
2676 | ||
9975d7be BP |
2677 | # Physical network: |
2678 | # | |
2679 | # Three hypervisors hv[123]. | |
86e98048 BP |
2680 | # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3. |
2681 | # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3. | |
2682 | # lp?3[123] all on hv3. | |
2683 | ||
9975d7be BP |
2684 | |
2685 | # Given the name of a logical port, prints the name of the hypervisor | |
2686 | # on which it is located. | |
2687 | vif_to_hv() { | |
2688 | case $1 in dnl ( | |
86e98048 BP |
2689 | ?11) echo 1 ;; dnl ( |
2690 | ?12 | ?21 | ?22) echo 2 ;; dnl ( | |
2691 | ?13 | ?23 | ?3?) echo 3 ;; | |
9975d7be BP |
2692 | esac |
2693 | } | |
2694 | ||
86e98048 BP |
2695 | # Given the name of a logical port, prints the name of its logical router |
2696 | # port, e.g. "vif_to_lrp 123" yields 12. | |
2697 | vif_to_lrp() { | |
2698 | echo ${1%?} | |
2699 | } | |
2700 | ||
2701 | # Given the name of a logical port, prints the name of its logical | |
2702 | # switch, e.g. "vif_to_ls 123" yields 1. | |
e3393e3f | 2703 | vif_to_ls() { |
86e98048 | 2704 | echo ${1%??} |
e3393e3f BP |
2705 | } |
2706 | ||
9975d7be BP |
2707 | net_add n1 |
2708 | for i in 1 2 3; do | |
2709 | sim_add hv$i | |
2710 | as hv$i | |
2711 | ovs-vsctl add-br br-phys | |
2712 | ovn_attach n1 br-phys 192.168.0.$i | |
2713 | done | |
2714 | for i in 1 2 3; do | |
2715 | for j in 1 2 3; do | |
86e98048 | 2716 | for k in 1 2 3; do |
269ecccc JP |
2717 | hv=`vif_to_hv $i$j$k` |
2718 | as hv$hv ovs-vsctl \ | |
2719 | -- add-port br-int vif$i$j$k \ | |
2720 | -- set Interface vif$i$j$k \ | |
2721 | external-ids:iface-id=lp$i$j$k \ | |
2722 | options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \ | |
2723 | options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \ | |
2724 | ofport-request=$i$j$k | |
86e98048 | 2725 | done |
9975d7be BP |
2726 | done |
2727 | done | |
2728 | ||
2729 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2730 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2731 | # for ARP resolution). | |
74868f2c | 2732 | OVN_POPULATE_ARP |
9975d7be BP |
2733 | |
2734 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2735 | # XXX This should be more systematic. | |
2736 | sleep 1 | |
2737 | ||
e3393e3f | 2738 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... |
9975d7be BP |
2739 | # |
2740 | # This shell function causes a packet to be received on INPORT. The packet's | |
2741 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2742 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2743 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 2744 | # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123. |
9975d7be BP |
2745 | for i in 1 2 3; do |
2746 | for j in 1 2 3; do | |
86e98048 BP |
2747 | for k in 1 2 3; do |
2748 | : > $i$j$k.expected | |
269ecccc | 2749 | done |
9975d7be BP |
2750 | done |
2751 | done | |
e3393e3f | 2752 | test_ip() { |
9975d7be BP |
2753 | # This packet has bad checksums but logical L3 routing doesn't check. |
2754 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
ba43992e | 2755 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
9975d7be BP |
2756 | shift; shift; shift; shift; shift |
2757 | hv=hv`vif_to_hv $inport` | |
2758 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2759 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
86e98048 BP |
2760 | in_ls=`vif_to_ls $inport` |
2761 | in_lrp=`vif_to_lrp $inport` | |
9975d7be | 2762 | for outport; do |
269ecccc | 2763 | out_ls=`vif_to_ls $outport` |
86e98048 | 2764 | if test $in_ls = $out_ls; then |
9975d7be BP |
2765 | # Ports on the same logical switch receive exactly the same packet. |
2766 | echo $packet | |
2767 | else | |
2768 | # Routing decrements TTL and updates source and dest MAC | |
2769 | # (and checksum). | |
269ecccc | 2770 | out_lrp=`vif_to_lrp $outport` |
86e98048 | 2771 | echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 |
e4543cfe | 2772 | fi >> $outport.expected |
9975d7be BP |
2773 | done |
2774 | } | |
2775 | ||
d7abfe39 LB |
2776 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
2777 | # | |
2778 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2779 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2780 | # it should be the hardware address of the target to expect to receive in an | |
2781 | # ARP reply; otherwise no reply is expected. | |
2782 | # | |
2783 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
2784 | # SHA and REPLY_HA are each 12 hex digits. | |
2785 | # SPA and TPA are each 8 hex digits. | |
2786 | test_arp() { | |
2787 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
2788 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2789 | hv=hv`vif_to_hv $inport` | |
2790 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2791 | as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request | |
2792 | ||
2793 | # Expect to receive the broadcast ARP on the other logical switch ports if | |
2794 | # IP address is not configured to the switch patch port. | |
2795 | local i=`vif_to_ls $inport` | |
2796 | local j k | |
2797 | for j in 1 2 3; do | |
2798 | for k in 1 2 3; do | |
2799 | # 192.168.33.254 is configured to the switch patch port for lrp33, | |
2800 | # so no ARP flooding expected for it. | |
2801 | if test $i$j$k != $inport && test $tpa != `ip_to_hex 192 168 33 254`; then | |
2802 | echo $request >> $i$j$k.expected | |
2803 | fi | |
2804 | done | |
2805 | done | |
2806 | ||
2807 | # Expect to receive the reply, if any. | |
2808 | if test X$reply_ha != X; then | |
2809 | lrp=`vif_to_lrp $inport` | |
2810 | local reply=${sha}00000000ff${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
2811 | echo $reply >> $inport.expected | |
2812 | fi | |
2813 | } | |
2814 | ||
e3393e3f | 2815 | as hv1 ovs-vsctl --columns=name,ofport list interface |
0bac7164 BP |
2816 | as hv1 ovn-sbctl list port_binding |
2817 | as hv1 ovn-sbctl list datapath_binding | |
9975d7be BP |
2818 | as hv1 ovn-sbctl dump-flows |
2819 | as hv1 ovs-ofctl dump-flows br-int | |
2820 | ||
e3393e3f | 2821 | # Send IP packets between all pairs of source and destination ports: |
9975d7be | 2822 | # |
31ed1192 JP |
2823 | # 1. Unicast IP packets are delivered to exactly one logical switch port |
2824 | # (except that packets destined to their input ports are dropped). | |
9975d7be | 2825 | # |
31ed1192 JP |
2826 | # 2. Broadcast IP packets are delivered to all logical switch ports |
2827 | # except the input port. | |
86e98048 BP |
2828 | ip_to_hex() { |
2829 | printf "%02x%02x%02x%02x" "$@" | |
2830 | } | |
9975d7be | 2831 | for is in 1 2 3; do |
269ecccc JP |
2832 | for js in 1 2 3; do |
2833 | for ks in 1 2 3; do | |
2834 | bcast= | |
2835 | s=$is$js$ks | |
2836 | smac=f00000000$s | |
2837 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2838 | for id in 1 2 3; do | |
2839 | for jd in 1 2 3; do | |
2840 | for kd in 1 2 3; do | |
2841 | d=$id$jd$kd | |
2842 | dip=`ip_to_hex 192 168 $id$jd $kd` | |
2843 | if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi | |
2844 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2845 | ||
2846 | test_ip $s $smac $dmac $sip $dip $unicast #1 | |
2847 | ||
2848 | if test $id = $is && test $d != $s; then bcast="$bcast $d"; fi | |
2849 | done | |
2850 | done | |
9975d7be | 2851 | done |
269ecccc JP |
2852 | test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2 |
2853 | done | |
2854 | done | |
e3393e3f BP |
2855 | done |
2856 | ||
d7abfe39 LB |
2857 | : > mac_bindings.expected |
2858 | ||
0bac7164 BP |
2859 | # 3. Send an IP packet from every logical port to every other subnet, |
2860 | # to an IP address that does not have a static IP-MAC binding. | |
2861 | # This should generate a broadcast ARP request for the destination | |
2862 | # IP address in the destination subnet. | |
d7abfe39 | 2863 | # Moreover generate an ARP reply for each of the IP addresses ARPed |
0bac7164 | 2864 | for is in 1 2 3; do |
269ecccc JP |
2865 | for js in 1 2 3; do |
2866 | for ks in 1 2 3; do | |
2867 | s=$is$js$ks | |
2868 | smac=f00000000$s | |
2869 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2870 | for id in 1 2 3; do | |
2871 | for jd in 1 2 3; do | |
2872 | if test $is$js = $id$jd; then | |
2873 | continue | |
2874 | fi | |
2875 | ||
2876 | # Send the packet. | |
2877 | dmac=00000000ff$is$js | |
2878 | # Calculate a 4th octet for the destination that is | |
2879 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2880 | # that have static MAC bindings, and fits in the range | |
2881 | # 0-255. | |
2882 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2883 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2884 | test_ip $s $smac $dmac $sip $dip | |
2885 | ||
2886 | # Every LP on the destination subnet's lswitch should | |
2887 | # receive the ARP request. | |
2888 | lrmac=00000000ff$id$jd | |
2889 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2890 | arp=ffffffffffff${lrmac}08060001080006040001${lrmac}${lrip}000000000000${dip} | |
2891 | for jd2 in 1 2 3; do | |
2892 | for kd in 1 2 3; do | |
e4543cfe | 2893 | echo $arp >> $id$jd2$kd.expected |
0bac7164 | 2894 | done |
269ecccc | 2895 | done |
1c24b2f4 LB |
2896 | |
2897 | hmac=8000000000$o4 | |
2898 | rmac=00000000ff$id$jd | |
2899 | echo ${hmac}${rmac}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 >> ${id}11.expected | |
d7abfe39 LB |
2900 | |
2901 | host_mac=8000000000$o4 | |
2902 | lrmac=00000000ff$id$jd | |
2903 | ||
2904 | arp_reply=${lrmac}${host_mac}08060001080006040002${host_mac}${dip}${lrmac}${lrip} | |
2905 | ||
2906 | hv=hv`vif_to_hv ${id}${jd}1` | |
2907 | as $hv ovs-appctl netdev-dummy/receive vif${id}${jd}1 $arp_reply | |
2908 | ||
2909 | host_ip_pretty=192.168.$id$jd.$o4 | |
2910 | host_mac_pretty=80:00:00:00:00:$o4 | |
2911 | echo lrp$id$jd,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected | |
0bac7164 | 2912 | done |
269ecccc | 2913 | done |
0bac7164 | 2914 | done |
269ecccc | 2915 | done |
0bac7164 BP |
2916 | done |
2917 | ||
e3393e3f BP |
2918 | # Test router replies to ARP requests from all source ports: |
2919 | # | |
0bac7164 | 2920 | # 4. Router replies to query for its MAC address from port's own IP address. |
e3393e3f | 2921 | # |
0bac7164 | 2922 | # 5. Router replies to query for its MAC address from any random IP address |
e3393e3f BP |
2923 | # in its subnet. |
2924 | # | |
054008ad | 2925 | # 6. No reply to query for IP address other than router IP. |
e3393e3f | 2926 | # |
054008ad | 2927 | # 7. No reply to query from another subnet. |
e3393e3f | 2928 | for i in 1 2 3; do |
269ecccc JP |
2929 | for j in 1 2 3; do |
2930 | for k in 1 2 3; do | |
2931 | smac=f00000000$i$j$k # Source MAC | |
2932 | sip=`ip_to_hex 192 168 $i$j $k` # Source IP | |
2933 | rip=`ip_to_hex 192 168 $i$j 254` # Router IP | |
2934 | rmac=00000000ff$i$j # Router MAC | |
2935 | otherip=`ip_to_hex 192 168 $i$j 55` # Some other IP in subnet | |
054008ad HZ |
2936 | externalip=`ip_to_hex 1 2 3 4` # Some other IP not in subnet |
2937 | ||
2938 | test_arp $i$j$k $smac $sip $rip $rmac #4 | |
2939 | test_arp $i$j$k $smac $otherip $rip $rmac #5 | |
2940 | test_arp $i$j$k $smac $sip $otherip #6 | |
2941 | ||
2942 | # When rip is 192.168.33.254, ARP request from externalip won't be | |
2943 | # filtered, because 192.168.33.254 is configured to switch peer port | |
2944 | # for lrp33. | |
2945 | lrp33_rsp= | |
2946 | if test $i = 3 && test $j = 3; then | |
2947 | lrp33_rsp=$rmac | |
2948 | fi | |
2949 | test_arp $i$j$k $smac $externalip $rip $lrp33_rsp #7 | |
2950 | ||
b0684540 HZ |
2951 | # MAC binding should be learned from ARP request. |
2952 | host_mac_pretty=f0:00:00:00:0$i:$j$k | |
2953 | ||
2954 | host_ip_pretty=192.168.$i$j.$k | |
2955 | echo lrp$i$j,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected | |
2956 | ||
2957 | # mac_binding is learned and overwritten so only the last one remains. | |
2958 | if test $k = 3; then | |
2959 | # lrp33 will not learn from ARP request, because 192.168.33.254 is | |
2960 | # configured to switch peer port for lrp33. | |
2961 | if test $i != 3 || test $j != 3; then | |
2962 | host_ip_pretty=192.168.$i$j.55 | |
2963 | echo lrp$i$j,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected | |
2964 | fi | |
2965 | fi | |
2966 | ||
0bac7164 | 2967 | done |
269ecccc | 2968 | done |
0bac7164 BP |
2969 | done |
2970 | ||
0bac7164 | 2971 | |
9975d7be BP |
2972 | # Allow some time for packet forwarding. |
2973 | # XXX This can be improved. | |
2974 | sleep 1 | |
2975 | ||
d7abfe39 | 2976 | # 8. Send an IP packet from every logical port to every other subnet. These |
0bac7164 BP |
2977 | # are the same packets already sent as #3, but now the destinations' IP-MAC |
2978 | # bindings have been discovered via ARP, so instead of provoking an ARP | |
2979 | # request, these packets now get routed to their destinations (which don't | |
2980 | # have static MAC bindings, so they go to the port we've designated as | |
2981 | # accepting "unknown" MACs.) | |
2982 | for is in 1 2 3; do | |
269ecccc JP |
2983 | for js in 1 2 3; do |
2984 | for ks in 1 2 3; do | |
2985 | s=$is$js$ks | |
2986 | smac=f00000000$s | |
2987 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2988 | for id in 1 2 3; do | |
2989 | for jd in 1 2 3; do | |
2990 | if test $is$js = $id$jd; then | |
2991 | continue | |
2992 | fi | |
2993 | ||
2994 | # Send the packet. | |
2995 | dmac=00000000ff$is$js | |
2996 | # Calculate a 4th octet for the destination that is | |
2997 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2998 | # that have static MAC bindings, and fits in the range | |
2999 | # 0-255. | |
3000 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
3001 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
3002 | test_ip $s $smac $dmac $sip $dip | |
3003 | ||
3004 | # Expect the packet egress. | |
3005 | host_mac=8000000000$o4 | |
3006 | outport=${id}11 | |
3007 | out_lrp=$id$jd | |
e4543cfe | 3008 | echo ${host_mac}00000000ff${out_lrp}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 >> $outport.expected |
0bac7164 | 3009 | done |
269ecccc | 3010 | done |
0bac7164 | 3011 | done |
269ecccc | 3012 | done |
0bac7164 BP |
3013 | done |
3014 | ||
0bac7164 BP |
3015 | ovn-sbctl -f csv -d bare --no-heading \ |
3016 | -- --columns=logical_port,ip,mac list mac_binding > mac_bindings | |
3017 | ||
9975d7be BP |
3018 | # Now check the packets actually received against the ones expected. |
3019 | for i in 1 2 3; do | |
3020 | for j in 1 2 3; do | |
86e98048 | 3021 | for k in 1 2 3; do |
abb37b6b FF |
3022 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap], |
3023 | [$i$j$k.expected]) | |
86e98048 | 3024 | done |
9975d7be BP |
3025 | done |
3026 | done | |
fcde56f5 | 3027 | |
0bac7164 BP |
3028 | # Check the MAC bindings against those expected. |
3029 | AT_CHECK_UNQUOTED([sort < mac_bindings], [0], [`sort < mac_bindings.expected` | |
3030 | ]) | |
3031 | ||
fcde56f5 | 3032 | # Gracefully terminate daemons |
7a8f15e0 | 3033 | OVN_CLEANUP([hv1], [hv2], [hv3]) |
eff49a56 | 3034 | |
9975d7be | 3035 | AT_CLEANUP |
685f4dfe | 3036 | |
b0684540 HZ |
3037 | AT_SETUP([ovn -- IP relocation using GARP request]) |
3038 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3039 | ovn_start | |
3040 | ||
3041 | # Logical network: | |
3042 | # | |
3043 | # Two logical switches ls1, ls2. | |
3044 | # One logical router lr0 connected to ls[12], | |
3045 | # with 2 subnets, 1 per logical switch: | |
3046 | # | |
3047 | # lrp1 on ls1 for subnet 192.168.1.1/24 | |
3048 | # lrp2 on ls2 for subnet 192.168.2.1/24 | |
3049 | # | |
3050 | # 4 VIFs, 2 per LS lp[12][12], first digit being LS. | |
3051 | # VIFs' fixed IP addresses are 192.168.[12].1[12]. | |
3052 | # | |
3053 | # There is a secondary IP 192.168.1.100 that is unknown in NB and learned | |
3054 | # through ARP only, and it can move between lp11 and lp12. | |
3055 | # | |
3056 | ovn-nbctl lr-add lr0 | |
3057 | for i in 1 2 ; do | |
3058 | ovn-nbctl ls-add ls$i | |
3059 | ovn-nbctl lrp-add lr0 lrp$i 00:00:00:00:ff:0$i 192.168.$i.1/24 | |
3060 | ovn-nbctl \ | |
3061 | -- lsp-add ls$i lrp$i-attachment \ | |
3062 | -- set Logical_Switch_Port lrp$i-attachment type=router \ | |
3063 | options:router-port=lrp$i \ | |
3064 | addresses=router | |
3065 | for j in 1 2; do | |
3066 | ovn-nbctl \ | |
3067 | -- lsp-add ls$i lp$i$j \ | |
3068 | -- lsp-set-addresses lp$i$j \ | |
3069 | "f0:00:00:00:00:$i$j 192.168.$i.1$j" | |
3070 | done | |
3071 | done | |
3072 | ||
3073 | # Physical network: | |
3074 | # 2 hypervisors hv[12], lp?1 on hv1, lp?2 on hv2. | |
3075 | ||
3076 | # Given the name of a logical port, prints the name of the hypervisor | |
3077 | # on which it is located, e.g. "vif_to_hv 12" yields 2. | |
3078 | vif_to_hv() { | |
3079 | echo ${1#?} | |
3080 | } | |
3081 | ||
3082 | # Given the name of a logical port, prints the name of its logical router | |
3083 | # port, e.g. "vif_to_lrp 12" yields 1. | |
3084 | vif_to_lrp() { | |
3085 | echo ${1%?} | |
3086 | } | |
3087 | ||
3088 | # Given the name of a logical port, prints the name of its logical | |
3089 | # switch, e.g. "vif_to_ls 12" yields 1. | |
3090 | vif_to_ls() { | |
3091 | echo ${1%?} | |
3092 | } | |
3093 | ||
3094 | net_add n1 | |
3095 | for i in 1 2; do | |
3096 | sim_add hv$i | |
3097 | as hv$i | |
3098 | ovs-vsctl add-br br-phys | |
3099 | ovn_attach n1 br-phys 192.168.0.$i | |
3100 | done | |
3101 | for i in 1 2; do | |
3102 | for j in 1 2; do | |
3103 | hv=`vif_to_hv $i$j` | |
3104 | as hv$hv ovs-vsctl \ | |
3105 | -- add-port br-int vif$i$j \ | |
3106 | -- set Interface vif$i$j \ | |
3107 | external-ids:iface-id=lp$i$j \ | |
3108 | options:tx_pcap=hv$hv/vif$i$j-tx.pcap \ | |
3109 | options:rxq_pcap=hv$hv/vif$i$j-rx.pcap \ | |
3110 | ofport-request=$i$j | |
3111 | done | |
3112 | done | |
3113 | ||
3114 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3115 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3116 | # for ARP resolution). | |
3117 | OVN_POPULATE_ARP | |
3118 | ||
3119 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3120 | # XXX This should be more systematic. | |
3121 | sleep 1 | |
3122 | ||
3123 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
3124 | # | |
3125 | # This shell function causes a packet to be received on INPORT. The packet's | |
3126 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
3127 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
3128 | # more) list the VIFs on which the packet should be received. INPORT and the | |
3129 | # OUTPORTs are specified as logical switch port numbers, e.g. 12 for vif12. | |
3130 | for i in 1 2; do | |
3131 | for j in 1 2; do | |
3132 | : > $i$j.expected | |
3133 | done | |
3134 | done | |
3135 | test_ip() { | |
3136 | # This packet has bad checksums but logical L3 routing doesn't check. | |
3137 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
3138 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3139 | shift; shift; shift; shift; shift | |
3140 | hv=hv`vif_to_hv $inport` | |
3141 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
3142 | in_ls=`vif_to_ls $inport` | |
3143 | in_lrp=`vif_to_lrp $inport` | |
3144 | for outport; do | |
3145 | out_ls=`vif_to_ls $outport` | |
3146 | if test $in_ls = $out_ls; then | |
3147 | # Ports on the same logical switch receive exactly the same packet. | |
3148 | echo $packet | |
3149 | else | |
3150 | # Routing decrements TTL and updates source and dest MAC | |
3151 | # (and checksum). | |
3152 | out_lrp=`vif_to_lrp $outport` | |
3153 | echo f000000000${outport}00000000ff0${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 | |
3154 | fi >> $outport.expected | |
3155 | done | |
3156 | } | |
3157 | ||
3158 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
3159 | # | |
3160 | # Causes a packet to be received on INPORT. The packet is an ARP | |
3161 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
3162 | # it should be the hardware address of the target to expect to receive in an | |
3163 | # ARP reply; otherwise no reply is expected. | |
3164 | # | |
3165 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
3166 | # SHA and REPLY_HA are each 12 hex digits. | |
3167 | # SPA and TPA are each 8 hex digits. | |
3168 | test_arp() { | |
3169 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
3170 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
3171 | hv=hv`vif_to_hv $inport` | |
3172 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
3173 | ||
3174 | # Expect to receive the broadcast ARP on the other logical switch ports if | |
3175 | # IP address is not configured to the switch patch port. | |
3176 | local i=`vif_to_ls $inport` | |
3177 | local j | |
3178 | for j in 1 2; do | |
3179 | if test $i$j != $inport; then | |
3180 | echo $request >> $i$j$k.expected | |
3181 | fi | |
3182 | done | |
3183 | ||
3184 | # Expect to receive the reply, if any. | |
3185 | if test X$reply_ha != X; then | |
3186 | lrp=`vif_to_lrp $inport` | |
3187 | local reply=${sha}00000000ff0${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
3188 | echo $reply >> $inport.expected | |
3189 | fi | |
3190 | } | |
3191 | ||
3192 | ip_to_hex() { | |
3193 | printf "%02x%02x%02x%02x" "$@" | |
3194 | } | |
3195 | ||
3196 | # lp11 send GARP request to announce ownership of 192.168.1.100. | |
3197 | ||
3198 | sha=f00000000011 | |
3199 | spa=`ip_to_hex 192 168 1 100` | |
3200 | tpa=$spa | |
3201 | test_arp 11 $sha $spa $tpa | |
3202 | OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding ip="192.168.1.100" | wc -l` -gt 0]) | |
3203 | ovn-nbctl --wait=hv sync | |
3204 | ||
3205 | # Send an IP packet from lp21 to 192.168.1.100, which should go to lp11. | |
3206 | ||
3207 | smac=f00000000021 | |
3208 | dmac=00000000ff02 | |
3209 | sip=`ip_to_hex 192 168 2 11` | |
3210 | dip=`ip_to_hex 192 168 1 100` | |
3211 | test_ip 21 $smac $dmac $sip $dip 11 | |
3212 | ||
3213 | # lp12 send GARP request to announce ownership of 192.168.1.100. | |
3214 | ||
3215 | sha=f00000000012 | |
3216 | test_arp 12 $sha $spa $tpa | |
3217 | OVS_WAIT_UNTIL([ovn-sbctl find mac_binding ip="192.168.1.100" | grep f0:00:00:00:00:12]) | |
3218 | ovn-nbctl --wait=hv sync | |
1c24b2f4 LB |
3219 | # give to the hv the time to send queued ip packets |
3220 | sleep 1 | |
b0684540 HZ |
3221 | |
3222 | # Send an IP packet from lp21 to 192.168.1.100, which should go to lp12. | |
3223 | ||
3224 | test_ip 21 $smac $dmac $sip $dip 12 | |
3225 | ||
3226 | # Now check the packets actually received against the ones expected. | |
3227 | for i in 1 2; do | |
3228 | for j in 1 2; do | |
3229 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j`/vif$i$j-tx.pcap], | |
3230 | [$i$j.expected]) | |
3231 | done | |
3232 | done | |
3233 | ||
3234 | # Gracefully terminate daemons | |
3235 | OVN_CLEANUP([hv1], [hv2]) | |
3236 | ||
3237 | AT_CLEANUP | |
3238 | ||
685f4dfe NS |
3239 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor |
3240 | AT_SETUP([ovn -- portsecurity : 3 HVs, 1 LS, 3 lports/HV]) | |
685f4dfe NS |
3241 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3242 | ovn_start | |
3243 | ||
3244 | # Create hypervisors hv[123]. | |
3245 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. | |
3246 | # Add all of the vifs to a single logical switch lsw0. | |
3247 | # Turn off port security on vifs vif[123]1 | |
3248 | # Turn on l2 port security on vifs vif[123]2 | |
3249 | # Turn of l2 and l3 port security on vifs vif[123]3 | |
3250 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
ea46a4e9 | 3251 | ovn-nbctl ls-add lsw0 |
685f4dfe NS |
3252 | net_add n1 |
3253 | for i in 1 2 3; do | |
3254 | sim_add hv$i | |
3255 | as hv$i | |
3256 | ovs-vsctl add-br br-phys | |
3257 | ovn_attach n1 br-phys 192.168.0.$i | |
3258 | ||
3259 | for j in 1 2 3; do | |
3260 | 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 | 3261 | ovn-nbctl lsp-add lsw0 lp$i$j |
685f4dfe | 3262 | if test $j = 1; then |
31ed1192 | 3263 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
685f4dfe | 3264 | elif test $j = 2; then |
31ed1192 JP |
3265 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" |
3266 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
685f4dfe NS |
3267 | else |
3268 | extra_addr="f0:00:00:00:0$i:$i$j fe80::ea2a:eaff:fe28:$i$j" | |
31ed1192 JP |
3269 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr" |
3270 | 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 |
3271 | fi |
3272 | done | |
3273 | done | |
3274 | ||
685f4dfe NS |
3275 | # Pre-populate the hypervisors' ARP tables so that we don't lose any |
3276 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3277 | # for ARP resolution). | |
74868f2c | 3278 | OVN_POPULATE_ARP |
685f4dfe NS |
3279 | |
3280 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3281 | # XXX This should be more systematic. | |
3282 | sleep 1 | |
685f4dfe NS |
3283 | |
3284 | # Given the name of a logical port, prints the name of the hypervisor | |
3285 | # on which it is located. | |
3286 | vif_to_hv() { | |
3287 | echo hv${1%?} | |
3288 | } | |
3289 | ||
685f4dfe NS |
3290 | for i in 1 2 3; do |
3291 | for j in 1 2 3; do | |
3292 | : > $i$j.expected | |
3293 | done | |
3294 | done | |
3295 | ||
3296 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
3297 | # | |
3298 | # This shell function causes an ip packet to be received on INPORT. | |
3299 | # The packet's content has Ethernet destination DST and source SRC | |
3300 | # (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits). | |
3301 | # The OUTPORTs (zero or more) list the VIFs on which the packet should | |
31ed1192 JP |
3302 | # be received. INPORT and the OUTPORTs are specified as logical switch |
3303 | # port numbers, e.g. 11 for vif11. | |
685f4dfe NS |
3304 | test_ip() { |
3305 | # This packet has bad checksums but logical L3 routing doesn't check. | |
3306 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
efe179e0 | 3307 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
685f4dfe NS |
3308 | shift; shift; shift; shift; shift |
3309 | hv=`vif_to_hv $inport` | |
3310 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
3311 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
3312 | for outport; do | |
e4543cfe | 3313 | echo $packet >> $outport.expected |
685f4dfe NS |
3314 | done |
3315 | } | |
3316 | ||
3317 | # test_arp INPORT SHA SPA TPA DROP [REPLY_HA] | |
3318 | # | |
3319 | # Causes a packet to be received on INPORT. The packet is an ARP | |
3320 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
3321 | # it should be the hardware address of the target to expect to receive in an | |
3322 | # ARP reply; otherwise no reply is expected. | |
3323 | # | |
31ed1192 | 3324 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
685f4dfe NS |
3325 | # SHA and REPLY_HA are each 12 hex digits. |
3326 | # SPA and TPA are each 8 hex digits. | |
3327 | test_arp() { | |
3328 | local inport=$1 smac=$2 sha=$3 spa=$4 tpa=$5 drop=$6 reply_ha=$7 | |
3329 | local request=ffffffffffff${smac}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
3330 | hv=`vif_to_hv $inport` | |
3331 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
3332 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request | |
3333 | if test $drop != 1; then | |
e137131a | 3334 | if test X$reply_ha = X; then |
685f4dfe NS |
3335 | # Expect to receive the broadcast ARP on the other logical switch ports |
3336 | # if no reply is expected. | |
3337 | local i j | |
3338 | for i in 1 2 3; do | |
3339 | for j in 1 2 3; do | |
3340 | if test $i$j != $inport; then | |
3341 | echo $request >> $i$j.expected | |
3342 | fi | |
3343 | done | |
3344 | done | |
3345 | else | |
3346 | # Expect to receive the reply, if any. | |
3347 | local reply=${smac}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
3348 | echo $reply >> $inport.expected | |
3349 | fi | |
3350 | fi | |
3351 | } | |
3352 | ||
3353 | # test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
3354 | # This function is similar to test_ip() except that it sends | |
3355 | # ipv6 packet | |
3356 | test_ipv6() { | |
3357 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
3358 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}0000000000000000 | |
3359 | shift; shift; shift; shift; shift | |
3360 | hv=`vif_to_hv $inport` | |
3361 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
3362 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
3363 | for outport; do | |
e4543cfe | 3364 | echo $packet >> $outport.expected |
685f4dfe NS |
3365 | done |
3366 | } | |
3367 | ||
9e687b23 DL |
3368 | # test_icmpv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT... |
3369 | # This function is similar to test_ipv6() except it specifies the ICMPv6 type | |
3370 | # of the test packet | |
3371 | test_icmpv6() { | |
3372 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6 | |
3373 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}${icmp_type}00000000000000 | |
3374 | shift; shift; shift; shift; shift; shift | |
3375 | hv=`vif_to_hv $inport` | |
3376 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
3377 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
3378 | for outport; do | |
e4543cfe | 3379 | echo $packet >> $outport.expected |
9e687b23 DL |
3380 | done |
3381 | } | |
3382 | ||
685f4dfe NS |
3383 | ip_to_hex() { |
3384 | printf "%02x%02x%02x%02x" "$@" | |
3385 | } | |
3386 | ||
3387 | # no port security | |
3388 | sip=`ip_to_hex 192 168 0 12` | |
3389 | tip=`ip_to_hex 192 168 0 13` | |
3390 | # the arp packet should be allowed even if lp[123]1 is | |
3391 | # not configured with mac f00000000023 and ip 192.168.0.12 | |
3392 | for i in 1 2 3; do | |
3393 | test_arp ${i}1 f00000000023 f00000000023 $sip $tip 0 f00000000013 | |
3394 | for j in 1 2 3; do | |
3395 | if test $i != $j; then | |
3396 | test_ip ${i}1 f000000000${i}1 f000000000${j}1 $sip $tip ${j}1 | |
3397 | fi | |
3398 | done | |
3399 | done | |
3400 | ||
3401 | # l2 port security | |
3402 | sip=`ip_to_hex 192 168 0 12` | |
3403 | tip=`ip_to_hex 192 168 0 13` | |
3404 | ||
3405 | # arp packet should be allowed since lp22 is configured with | |
3406 | # mac f00000000022 | |
3407 | test_arp 22 f00000000022 f00000000022 $sip $tip 0 f00000000013 | |
3408 | ||
3409 | # arp packet should not be allowed since lp32 is not configured with | |
3410 | # mac f00000000021 | |
3411 | test_arp 32 f00000000021 f00000000021 $sip $tip 1 | |
3412 | ||
3413 | # arp packet with sha set to f00000000021 should not be allowed | |
3414 | # for lp12 | |
3415 | test_arp 12 f00000000012 f00000000021 $sip $tip 1 | |
3416 | ||
3417 | # ip packets should be allowed and received since lp[123]2 do not | |
3418 | # have l3 port security | |
3419 | sip=`ip_to_hex 192 168 0 55` | |
3420 | tip=`ip_to_hex 192 168 0 66` | |
3421 | for i in 1 2 3; do | |
3422 | for j in 1 2 3; do | |
3423 | if test $i != $j; then | |
3424 | test_ip ${i}2 f000000000${i}2 f000000000${j}2 $sip $tip ${j}2 | |
3425 | fi | |
3426 | done | |
3427 | done | |
3428 | ||
3429 | # ipv6 packets should be received by lp[123]2 | |
3430 | # lp[123]1 can send ipv6 traffic as there is no port security | |
3431 | sip=fe800000000000000000000000000000 | |
3432 | tip=ff020000000000000000000000000000 | |
3433 | ||
3434 | for i in 1 2 3; do | |
3435 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}2 $sip $tip ${i}2 | |
3436 | done | |
3437 | ||
3438 | ||
3439 | # l2 and l3 port security | |
3440 | sip=`ip_to_hex 192 168 0 13` | |
3441 | tip=`ip_to_hex 192 168 0 22` | |
3442 | # arp packet should be allowed since lp13 is configured with | |
3443 | # f00000000013 and 192.168.0.13 | |
3444 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 | |
3445 | ||
3446 | # the arp packet should be dropped because lp23 is not configured | |
3447 | # with mac f00000000022 | |
3448 | sip=`ip_to_hex 192 168 0 13` | |
3449 | tip=`ip_to_hex 192 168 0 22` | |
3450 | test_arp 23 f00000000022 f00000000022 $sip $tip 1 | |
3451 | ||
3452 | # the arp packet should be dropped because lp33 is not configured | |
3453 | # with ip 192.168.0.55 | |
3454 | spa=`ip_to_hex 192 168 0 55` | |
3455 | tpa=`ip_to_hex 192 168 0 22` | |
3456 | test_arp 33 f00000000031 f00000000031 $spa $tpa 1 | |
3457 | ||
3458 | # ip packets should not be received by lp[123]3 since | |
3459 | # l3 port security is enabled | |
3460 | sip=`ip_to_hex 192 168 0 55` | |
3461 | tip=`ip_to_hex 192 168 0 66` | |
3462 | for i in 1 2 3; do | |
3463 | for j in 1 2 3; do | |
3464 | test_ip ${i}2 f000000000${i}2 f000000000${j}3 $sip $tip | |
3465 | done | |
3466 | done | |
3467 | ||
3468 | # ipv6 packets should be dropped for lp[123]3 since | |
3469 | # it is configured with only ipv4 address | |
3470 | sip=fe800000000000000000000000000000 | |
3471 | tip=ff020000000000000000000000000000 | |
3472 | ||
3473 | for i in 1 2 3; do | |
3474 | test_ipv6 ${i}3 f000000000${i}3 f00000000022 $sip $tip | |
3475 | done | |
3476 | ||
3477 | # ipv6 packets should not be received by lp[123]3 with mac f000000000$[123]3 | |
3478 | # lp[123]1 can send ipv6 traffic as there is no port security | |
3479 | for i in 1 2 3; do | |
3480 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}3 $sip $tip | |
3481 | done | |
3482 | ||
3483 | # lp13 has extra port security with mac f0000000113 and ipv6 addr | |
3484 | # fe80::ea2a:eaff:fe28:0012 | |
3485 | ||
3486 | # ipv4 packet should be dropped for lp13 with mac f0000000113 | |
3487 | sip=`ip_to_hex 192 168 0 13` | |
3488 | tip=`ip_to_hex 192 168 0 23` | |
3489 | test_ip 13 f00000000113 f00000000023 $sip $tip | |
3490 | ||
6d53e8a9 BP |
3491 | # ipv6 packet should be received by lp[123]3 with mac f00000000${i}${i}3 |
3492 | # and ip6.dst as fe80::ea2a:eaff:fe28:0${i}${i}3. | |
685f4dfe NS |
3493 | # lp11 can send ipv6 traffic as there is no port security |
3494 | sip=ee800000000000000000000000000000 | |
3495 | for i in 1 2 3; do | |
6d53e8a9 BP |
3496 | tip=fe80000000000000ea2aeafffe2800${i}3 |
3497 | test_ipv6 11 f00000000011 f00000000${i}${i}3 $sip $tip ${i}3 | |
685f4dfe NS |
3498 | done |
3499 | ||
3500 | ||
3501 | # ipv6 packet should not be received by lp33 with mac f0000000333 | |
3502 | # and ip6.dst as fe80::ea2a:eaff:fe28:0023 as it is | |
3503 | # configured with fe80::ea2a:eaff:fe28:0033 | |
3504 | # lp11 can send ipv6 traffic as there is no port security | |
3505 | ||
3506 | sip=ee800000000000000000000000000000 | |
3507 | tip=fe80000000000000ea2aeafffe280023 | |
3508 | test_ipv6 11 f00000000011 f00000000333 $sip $tip | |
3509 | ||
6d53e8a9 BP |
3510 | # ipv6 packet should be allowed for lp[123]3 with mac f0000000${i}${i}3 |
3511 | # and ip6.src fe80::ea2a:eaff:fe28:0${i}${i}3 and ip6.src ::. | |
685f4dfe NS |
3512 | # and should be dropped for any other ip6.src |
3513 | # lp21 can receive ipv6 traffic as there is no port security | |
3514 | ||
3515 | tip=ee800000000000000000000000000000 | |
3516 | for i in 1 2 3; do | |
3517 | sip=fe80000000000000ea2aeafffe2800${i}3 | |
3518 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 21 | |
3519 | ||
9e687b23 | 3520 | # Test ICMPv6 MLD reports (v1 and v2) and NS for DAD |
685f4dfe | 3521 | sip=00000000000000000000000000000000 |
9e687b23 DL |
3522 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 83 21 |
3523 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 8f 21 | |
3524 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff0200000000000000ea2aeafffe2800 87 21 | |
3525 | # Traffic to non-multicast traffic should be dropped | |
3526 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 83 | |
3527 | # Traffic of other ICMPv6 types should be dropped | |
3528 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 80 | |
685f4dfe NS |
3529 | |
3530 | # should be dropped | |
3531 | sip=ae80000000000000ea2aeafffe2800aa | |
3532 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip | |
3533 | done | |
3534 | ||
31ed1192 JP |
3535 | # configure lsp13 to send and received IPv4 packets with an address range |
3536 | 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 | 3537 | |
8ff5a966 NS |
3538 | sleep 2 |
3539 | ||
7d9d86ad NS |
3540 | sip=`ip_to_hex 10 0 0 13` |
3541 | tip=`ip_to_hex 192 168 0 22` | |
31ed1192 | 3542 | # arp packet with inner ip 10.0.0.13 should be allowed for lsp13 |
7d9d86ad NS |
3543 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 |
3544 | ||
3545 | sip=`ip_to_hex 10 0 0 14` | |
3546 | tip=`ip_to_hex 192 168 0 23` | |
31ed1192 | 3547 | # IPv4 packet from lsp13 with src ip 10.0.0.14 destined to lsp23 |
7d9d86ad NS |
3548 | # with dst ip 192.168.0.23 should be allowed |
3549 | test_ip 13 f00000000013 f00000000023 $sip $tip 23 | |
3550 | ||
3551 | sip=`ip_to_hex 192 168 0 33` | |
3552 | tip=`ip_to_hex 10 0 0 15` | |
31ed1192 JP |
3553 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
3554 | # with dst ip 10.0.0.15 should be received by lsp13 | |
7d9d86ad NS |
3555 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
3556 | ||
3557 | sip=`ip_to_hex 192 168 0 33` | |
3558 | tip=`ip_to_hex 20 0 0 4` | |
31ed1192 JP |
3559 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
3560 | # with dst ip 20.0.0.4 should be received by lsp13 | |
7d9d86ad NS |
3561 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
3562 | ||
3563 | sip=`ip_to_hex 192 168 0 33` | |
3564 | tip=`ip_to_hex 20 0 0 5` | |
31ed1192 JP |
3565 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
3566 | # with dst ip 20.0.0.5 should not be received by lsp13 | |
7d9d86ad NS |
3567 | test_ip 33 f00000000033 f00000000013 $sip $tip |
3568 | ||
3569 | sip=`ip_to_hex 192 168 0 33` | |
3570 | tip=`ip_to_hex 20 0 0 255` | |
31ed1192 JP |
3571 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
3572 | # with dst ip 20.0.0.255 should be received by lsp13 | |
7d9d86ad NS |
3573 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
3574 | ||
3575 | sip=`ip_to_hex 192 168 0 33` | |
3576 | tip=`ip_to_hex 192 168 0 255` | |
31ed1192 JP |
3577 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
3578 | # with dst ip 192.168.0.255 should not be received by lsp13 | |
7d9d86ad NS |
3579 | test_ip 33 f00000000033 f00000000013 $sip $tip |
3580 | ||
3581 | sip=`ip_to_hex 192 168 0 33` | |
3582 | tip=`ip_to_hex 224 0 0 4` | |
31ed1192 JP |
3583 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
3584 | # with dst ip 224.0.0.4 should be received by lsp13 | |
7d9d86ad | 3585 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
685f4dfe | 3586 | |
bb0c41d3 RM |
3587 | #dump information including flow counters |
3588 | ovn-nbctl show | |
3589 | ovn-sbctl dump-flows -- list multicast_group | |
3590 | ||
3591 | echo "------ hv1 dump ------" | |
3592 | as hv1 ovs-vsctl show | |
6195e2e7 | 3593 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
3594 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
3595 | ||
3596 | echo "------ hv2 dump ------" | |
3597 | as hv2 ovs-vsctl show | |
6195e2e7 | 3598 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
3599 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
3600 | ||
3601 | echo "------ hv3 dump ------" | |
3602 | as hv3 ovs-vsctl show | |
6195e2e7 | 3603 | as hv3 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
3604 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int |
3605 | ||
685f4dfe NS |
3606 | # Now check the packets actually received against the ones expected. |
3607 | for i in 1 2 3; do | |
3608 | for j in 1 2 3; do | |
49d7c759 | 3609 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
685f4dfe NS |
3610 | done |
3611 | done | |
3612 | ||
7a8f15e0 | 3613 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 3614 | |
685f4dfe | 3615 | AT_CLEANUP |
509afdc3 GS |
3616 | |
3617 | AT_SETUP([ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs]) | |
509afdc3 GS |
3618 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3619 | ovn_start | |
3620 | ||
3621 | # Logical network: | |
3622 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
3623 | # network. R1 has a switchs ls1 (191.168.1.0/24) connected to it. | |
3624 | # R2 has ls2 (172.16.1.0/24) connected to it. | |
3625 | ||
3c1ae70a JP |
3626 | ls1_lp1_mac="f0:00:00:01:02:03" |
3627 | rp_ls1_mac="00:00:00:01:02:03" | |
3628 | rp_ls2_mac="00:00:00:01:02:04" | |
3629 | ls2_lp1_mac="f0:00:00:01:02:04" | |
3630 | ||
3631 | ls1_lp1_ip="192.168.1.2" | |
3632 | ls2_lp1_ip="172.16.1.2" | |
3633 | ||
fa2a27b2 JP |
3634 | ovn-nbctl lr-add R1 |
3635 | ovn-nbctl lr-add R2 | |
509afdc3 | 3636 | |
ea46a4e9 JP |
3637 | ovn-nbctl ls-add ls1 |
3638 | ovn-nbctl ls-add ls2 | |
509afdc3 GS |
3639 | |
3640 | # Connect ls1 to R1 | |
3c1ae70a | 3641 | ovn-nbctl lrp-add R1 ls1 $rp_ls1_mac 192.168.1.1/24 |
509afdc3 | 3642 | |
31ed1192 | 3643 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
3c1ae70a | 3644 | options:router-port=ls1 addresses=\"$rp_ls1_mac\" |
509afdc3 GS |
3645 | |
3646 | # Connect ls2 to R2 | |
3c1ae70a | 3647 | ovn-nbctl lrp-add R2 ls2 $rp_ls2_mac 172.16.1.1/24 |
509afdc3 | 3648 | |
31ed1192 | 3649 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
3c1ae70a | 3650 | options:router-port=ls2 addresses=\"$rp_ls2_mac\" |
509afdc3 GS |
3651 | |
3652 | # Connect R1 to R2 | |
4685e523 JP |
3653 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
3654 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
509afdc3 | 3655 | |
6d9ecfa9 JP |
3656 | ovn-nbctl lr-route-add R1 "0.0.0.0/0" 20.0.0.2 |
3657 | ovn-nbctl lr-route-add R2 "0.0.0.0/0" 20.0.0.1 | |
509afdc3 GS |
3658 | |
3659 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 | 3660 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3c1ae70a | 3661 | -- lsp-set-addresses ls1-lp1 "$ls1_lp1_mac $ls1_lp1_ip" |
509afdc3 GS |
3662 | |
3663 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 | 3664 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3c1ae70a | 3665 | -- lsp-set-addresses ls2-lp1 "$ls2_lp1_mac $ls2_lp1_ip" |
509afdc3 GS |
3666 | |
3667 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3668 | net_add n1 | |
3669 | ||
3670 | sim_add hv1 | |
3671 | as hv1 | |
3672 | ovs-vsctl add-br br-phys | |
3673 | ovn_attach n1 br-phys 192.168.0.1 | |
3674 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3675 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
3676 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3677 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3678 | ofport-request=1 | |
3679 | ||
3680 | sim_add hv2 | |
3681 | as hv2 | |
3682 | ovs-vsctl add-br br-phys | |
3683 | ovn_attach n1 br-phys 192.168.0.2 | |
3684 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3685 | set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \ | |
3686 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3687 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3688 | ofport-request=1 | |
3689 | ||
3690 | ||
3691 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3692 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3693 | # for ARP resolution). | |
74868f2c | 3694 | OVN_POPULATE_ARP |
509afdc3 GS |
3695 | |
3696 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3697 | # XXX This should be more systematic. | |
3698 | sleep 1 | |
3699 | ||
509afdc3 | 3700 | # Packet to send. |
3c1ae70a JP |
3701 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_lp1_mac && eth.dst==$rp_ls1_mac && |
3702 | ip4 && ip.ttl==64 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
3703 | udp && udp.src==53 && udp.dst==4369" | |
3704 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
509afdc3 GS |
3705 | |
3706 | ||
3707 | echo "---------NB dump-----" | |
3708 | ovn-nbctl show | |
3709 | echo "---------------------" | |
3710 | ovn-nbctl list logical_router | |
3711 | echo "---------------------" | |
3712 | ovn-nbctl list logical_router_port | |
3713 | echo "---------------------" | |
3714 | ||
3715 | echo "---------SB dump-----" | |
3716 | ovn-sbctl list datapath_binding | |
3717 | echo "---------------------" | |
3718 | ovn-sbctl list port_binding | |
3719 | echo "---------------------" | |
3720 | ||
3721 | echo "------ hv1 dump ----------" | |
8dab1022 | 3722 | as hv1 ovs-ofctl show br-int |
509afdc3 GS |
3723 | as hv1 ovs-ofctl dump-flows br-int |
3724 | echo "------ hv2 dump ----------" | |
8dab1022 | 3725 | as hv2 ovs-ofctl show br-int |
509afdc3 GS |
3726 | as hv2 ovs-ofctl dump-flows br-int |
3727 | ||
3728 | # Packet to Expect | |
3c1ae70a JP |
3729 | # The TTL should be decremented by 2. |
3730 | packet="eth.src==$rp_ls2_mac && eth.dst==$ls2_lp1_mac && | |
3731 | ip4 && ip.ttl==62 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
3732 | udp && udp.src==53 && udp.dst==4369" | |
3733 | echo $packet | ovstest test-ovn expr-to-packets > expected | |
509afdc3 | 3734 | |
49d7c759 | 3735 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
509afdc3 | 3736 | |
7ebfcd3d NS |
3737 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_arp_resolve | \ |
3738 | grep "reg0 == 172.16.1.2" | wc -l], [0], [1 | |
3739 | ]) | |
3740 | ||
3741 | # Disable the ls2-lp1 port. | |
3742 | ovn-nbctl --wait=hv set logical_switch_port ls2-lp1 enabled=false | |
3743 | ||
3744 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_arp_resolve | \ | |
3745 | grep "reg0 == 172.16.1.2" | wc -l], [0], [0 | |
3746 | ]) | |
3747 | ||
3748 | # Generate the packet destined for ls2-lp1 and it should not be delivered. | |
3749 | # Packet to send. | |
3750 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_lp1_mac && eth.dst==$rp_ls1_mac && | |
3751 | ip4 && ip.ttl==64 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
3752 | udp && udp.src==53 && udp.dst==4369" | |
3753 | ||
3754 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
3755 | # The 2nd packet sent shound not be received. | |
3756 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
3757 | ||
7a8f15e0 | 3758 | OVN_CLEANUP([hv1],[hv2]) |
509afdc3 GS |
3759 | |
3760 | AT_CLEANUP | |
5412db30 J |
3761 | |
3762 | ||
4685e523 JP |
3763 | AT_SETUP([ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR]) |
3764 | AT_KEYWORDS([router-admin-state]) | |
3765 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3766 | ovn_start | |
3767 | ||
3768 | # Logical network: | |
3769 | # One LR - R1 has switch ls1 with two subnets attached to it (191.168.1.0/24 | |
3770 | # and 172.16.1.0/24) connected to it. | |
3771 | ||
3772 | ovn-nbctl lr-add R1 | |
3773 | ||
3774 | ovn-nbctl ls-add ls1 | |
3775 | ||
3776 | # Connect ls1 to R1 | |
bf44c2cd | 3777 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 172.16.1.1/24 |
4685e523 JP |
3778 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
3779 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" | |
3780 | ||
3781 | # Create logical port ls1-lp1 in ls1 | |
3782 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3783 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
3784 | ||
3785 | # Create logical port ls1-lp2 in ls1 | |
3786 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3787 | -- lsp-set-addresses ls1-lp2 "f0:00:00:01:02:04 172.16.1.2" | |
3788 | ||
3789 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3790 | net_add n1 | |
3791 | ||
3792 | sim_add hv1 | |
3793 | as hv1 | |
3794 | ovs-vsctl add-br br-phys | |
3795 | ovn_attach n1 br-phys 192.168.0.1 | |
3796 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3797 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3798 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3799 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3800 | ofport-request=1 | |
3801 | ||
3802 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3803 | set interface vif2 external-ids:iface-id=ls1-lp2 \ | |
3804 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3805 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3806 | ofport-request=1 | |
3807 | ||
3808 | ||
3809 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3810 | # XXX This should be more systematic. | |
3811 | sleep 1 | |
3812 | ||
3813 | # Send ip packets between the two ports. | |
3814 | ip_to_hex() { | |
3815 | printf "%02x%02x%02x%02x" "$@" | |
3816 | } | |
4685e523 JP |
3817 | |
3818 | # Packet to send. | |
3819 | src_mac="f00000010203" | |
3820 | dst_mac="000000010203" | |
3821 | src_ip=`ip_to_hex 192 168 1 2` | |
3822 | dst_ip=`ip_to_hex 172 16 1 2` | |
3823 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3824 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3825 | ||
3826 | ||
3827 | echo "---------NB dump-----" | |
3828 | ovn-nbctl show | |
3829 | echo "---------------------" | |
3830 | ovn-nbctl list logical_router | |
3831 | echo "---------------------" | |
3832 | ovn-nbctl list logical_router_port | |
3833 | echo "---------------------" | |
3834 | ||
3835 | echo "---------SB dump-----" | |
3836 | ovn-sbctl list datapath_binding | |
3837 | echo "---------------------" | |
3838 | ovn-sbctl list logical_flow | |
3839 | echo "---------------------" | |
3840 | ||
3841 | echo "------ hv1 dump ----------" | |
3842 | as hv1 ovs-ofctl dump-flows br-int | |
3843 | ||
3844 | ||
3845 | #Disable router R1 | |
3846 | ovn-nbctl set Logical_Router R1 enabled=false | |
3847 | ||
3b8cd0ea BP |
3848 | # Allow some time for ovn-northd and ovn-controller to catch up. |
3849 | # XXX This should be more systematic. | |
3850 | sleep 1 | |
3851 | ||
4685e523 JP |
3852 | echo "---------SB dump-----" |
3853 | ovn-sbctl list datapath_binding | |
3854 | echo "---------------------" | |
3855 | ovn-sbctl list logical_flow | |
3856 | echo "---------------------" | |
3857 | ||
3858 | echo "------ hv1 dump ----------" | |
3859 | as hv1 ovs-ofctl dump-flows br-int | |
3860 | ||
3861 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3862 | ||
3863 | # Packet to Expect | |
3864 | expect_src_mac="000000010203" | |
3865 | expect_dst_mac="f00000010204" | |
49d7c759 | 3866 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
4685e523 | 3867 | |
49d7c759 | 3868 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
4685e523 | 3869 | |
c4d0e4f2 | 3870 | OVN_CLEANUP([hv1]) |
4685e523 JP |
3871 | |
3872 | AT_CLEANUP | |
3873 | ||
3874 | ||
3875 | AT_SETUP([ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR]) | |
5412db30 J |
3876 | AT_KEYWORDS([router-admin-state]) |
3877 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3878 | ovn_start | |
3879 | ||
3880 | # Logical network: | |
3881 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
3882 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
3883 | ||
fa2a27b2 | 3884 | ovn-nbctl lr-add R1 |
5412db30 | 3885 | |
ea46a4e9 JP |
3886 | ovn-nbctl ls-add ls1 |
3887 | ovn-nbctl ls-add ls2 | |
5412db30 J |
3888 | |
3889 | # Connect ls1 to R1 | |
bf44c2cd | 3890 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3891 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
31114af7 | 3892 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" |
5412db30 J |
3893 | |
3894 | # Connect ls2 to R1 | |
bf44c2cd | 3895 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3896 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
31114af7 | 3897 | options:router-port=ls2 addresses=\"00:00:00:01:02:04\" |
5412db30 J |
3898 | |
3899 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
3900 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3901 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
5412db30 J |
3902 | |
3903 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
3904 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3905 | -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2" | |
5412db30 J |
3906 | |
3907 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3908 | net_add n1 | |
3909 | ||
3910 | sim_add hv1 | |
3911 | as hv1 | |
3912 | ovs-vsctl add-br br-phys | |
3913 | ovn_attach n1 br-phys 192.168.0.1 | |
3914 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3915 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3916 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3917 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3918 | ofport-request=1 | |
3919 | ||
3920 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3921 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
3922 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3923 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3924 | ofport-request=1 | |
3925 | ||
3926 | ||
3927 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3928 | # XXX This should be more systematic. | |
3929 | sleep 1 | |
3930 | ||
3931 | # Send ip packets between the two ports. | |
3932 | ip_to_hex() { | |
3933 | printf "%02x%02x%02x%02x" "$@" | |
3934 | } | |
5412db30 J |
3935 | |
3936 | # Packet to send. | |
3937 | src_mac="f00000010203" | |
3938 | dst_mac="000000010203" | |
3939 | src_ip=`ip_to_hex 192 168 1 2` | |
3940 | dst_ip=`ip_to_hex 172 16 1 2` | |
3941 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3942 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3943 | ||
3944 | ||
3945 | echo "---------NB dump-----" | |
3946 | ovn-nbctl show | |
3947 | echo "---------------------" | |
3948 | ovn-nbctl list logical_router | |
3949 | echo "---------------------" | |
3950 | ovn-nbctl list logical_router_port | |
3951 | echo "---------------------" | |
3952 | ||
3953 | echo "---------SB dump-----" | |
3954 | ovn-sbctl list datapath_binding | |
3955 | echo "---------------------" | |
3956 | ovn-sbctl list logical_flow | |
3957 | echo "---------------------" | |
3958 | ||
3959 | echo "------ hv1 dump ----------" | |
3960 | as hv1 ovs-ofctl dump-flows br-int | |
3961 | ||
5412db30 J |
3962 | #Disable router R1 |
3963 | ovn-nbctl set Logical_Router R1 enabled=false | |
3964 | ||
3965 | echo "---------SB dump-----" | |
3966 | ovn-sbctl list datapath_binding | |
3967 | echo "---------------------" | |
3968 | ovn-sbctl list logical_flow | |
3969 | echo "---------------------" | |
3970 | ||
3971 | echo "------ hv1 dump ----------" | |
3972 | as hv1 ovs-ofctl dump-flows br-int | |
3973 | ||
a1361a6e LR |
3974 | # Allow some time for the disabling of logical router R1 to propagate. |
3975 | # XXX This should be more systematic. | |
3976 | sleep 1 | |
3977 | ||
5412db30 J |
3978 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet |
3979 | ||
3980 | # Packet to Expect | |
3981 | expect_src_mac="000000010204" | |
3982 | expect_dst_mac="f00000010204" | |
49d7c759 | 3983 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
5412db30 | 3984 | |
49d7c759 | 3985 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
5412db30 | 3986 | |
7a8f15e0 | 3987 | OVN_CLEANUP([hv1]) |
5412db30 J |
3988 | |
3989 | AT_CLEANUP | |
3990 | ||
28dc3fe9 | 3991 | AT_SETUP([ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes]) |
28dc3fe9 SR |
3992 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3993 | ovn_start | |
3994 | ||
3995 | # Logical network: | |
3996 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
3997 | # network. R1 has switchess foo (192.168.1.0/24) | |
3998 | # connected to it. | |
3999 | # R2 has alice (172.16.1.0/24) and bob (172.16.2.0/24) connected to it. | |
4000 | ||
fa2a27b2 JP |
4001 | ovn-nbctl lr-add R1 |
4002 | ovn-nbctl lr-add R2 | |
28dc3fe9 | 4003 | |
ea46a4e9 JP |
4004 | ovn-nbctl ls-add foo |
4005 | ovn-nbctl ls-add alice | |
4006 | ovn-nbctl ls-add bob | |
28dc3fe9 SR |
4007 | |
4008 | # Connect foo to R1 | |
bf44c2cd | 4009 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 4010 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 4011 | options:router-port=foo addresses=\"00:00:00:01:02:03\" |
28dc3fe9 SR |
4012 | |
4013 | # Connect alice to R2 | |
bf44c2cd | 4014 | ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 4015 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 4016 | type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" |
28dc3fe9 SR |
4017 | |
4018 | # Connect bob to R2 | |
bf44c2cd | 4019 | ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24 |
31ed1192 | 4020 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob type=router \ |
31114af7 | 4021 | options:router-port=bob addresses=\"00:00:00:01:02:05\" |
28dc3fe9 SR |
4022 | |
4023 | # Connect R1 to R2 | |
4685e523 JP |
4024 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
4025 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
28dc3fe9 SR |
4026 | |
4027 | #install static routes | |
e48ccf3c JP |
4028 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
4029 | ovn-nbctl lr-route-add R2 172.16.2.0/24 20.0.0.2 R1_R2 | |
4030 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 | |
28dc3fe9 SR |
4031 | |
4032 | # Create logical port foo1 in foo | |
31ed1192 JP |
4033 | ovn-nbctl lsp-add foo foo1 \ |
4034 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
28dc3fe9 SR |
4035 | |
4036 | # Create logical port alice1 in alice | |
31ed1192 JP |
4037 | ovn-nbctl lsp-add alice alice1 \ |
4038 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
28dc3fe9 SR |
4039 | |
4040 | # Create logical port bob1 in bob | |
31ed1192 JP |
4041 | ovn-nbctl lsp-add bob bob1 \ |
4042 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 172.16.2.2" | |
28dc3fe9 SR |
4043 | |
4044 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
4045 | net_add n1 | |
4046 | ||
4047 | sim_add hv1 | |
4048 | as hv1 | |
4049 | ovs-vsctl add-br br-phys | |
4050 | ovn_attach n1 br-phys 192.168.0.1 | |
4051 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4052 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
4053 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4054 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4055 | ofport-request=1 | |
4056 | ||
4057 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4058 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
4059 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4060 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4061 | ofport-request=2 | |
4062 | ||
4063 | sim_add hv2 | |
4064 | as hv2 | |
4065 | ovs-vsctl add-br br-phys | |
4066 | ovn_attach n1 br-phys 192.168.0.2 | |
4067 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
4068 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
4069 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
4070 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
4071 | ofport-request=1 | |
4072 | ||
4073 | ||
4074 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
4075 | # packets for ARP resolution (native tunneling doesn't queue packets | |
4076 | # for ARP resolution). | |
74868f2c | 4077 | OVN_POPULATE_ARP |
28dc3fe9 SR |
4078 | |
4079 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4080 | # XXX This should be more systematic. | |
4081 | sleep 1 | |
4082 | ||
4083 | ip_to_hex() { | |
4084 | printf "%02x%02x%02x%02x" "$@" | |
4085 | } | |
28dc3fe9 SR |
4086 | |
4087 | # Send ip packets between foo1 and alice1 | |
4088 | src_mac="f00000010203" | |
4089 | dst_mac="000000010203" | |
4090 | src_ip=`ip_to_hex 192 168 1 2` | |
4091 | dst_ip=`ip_to_hex 172 16 1 2` | |
4092 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4093 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4094 | ||
4095 | # Send ip packets between foo1 and bob1 | |
4096 | src_mac="f00000010203" | |
4097 | dst_mac="000000010203" | |
4098 | src_ip=`ip_to_hex 192 168 1 2` | |
4099 | dst_ip=`ip_to_hex 172 16 2 2` | |
4100 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4101 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4102 | ||
4103 | echo "---------NB dump-----" | |
4104 | ovn-nbctl show | |
4105 | echo "---------------------" | |
4106 | ovn-nbctl list logical_router | |
4107 | echo "---------------------" | |
4108 | ovn-nbctl list logical_router_port | |
4109 | echo "---------------------" | |
4110 | ||
4111 | echo "---------SB dump-----" | |
4112 | ovn-sbctl list datapath_binding | |
4113 | echo "---------------------" | |
4114 | ovn-sbctl list port_binding | |
4115 | echo "---------------------" | |
4116 | ||
4117 | echo "------ hv1 dump ----------" | |
4118 | as hv1 ovs-ofctl dump-flows br-int | |
4119 | echo "------ hv2 dump ----------" | |
4120 | as hv2 ovs-ofctl dump-flows br-int | |
4121 | ||
4122 | # Packet to Expect at bob1 | |
4123 | src_mac="000000010205" | |
4124 | dst_mac="f00000010205" | |
4125 | src_ip=`ip_to_hex 192 168 1 2` | |
4126 | dst_ip=`ip_to_hex 172 16 2 2` | |
49d7c759 | 4127 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 4128 | |
49d7c759 | 4129 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
28dc3fe9 SR |
4130 | |
4131 | # Packet to Expect at alice1 | |
4132 | src_mac="000000010204" | |
4133 | dst_mac="f00000010204" | |
4134 | src_ip=`ip_to_hex 192 168 1 2` | |
4135 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 4136 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 4137 | |
49d7c759 | 4138 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
28dc3fe9 | 4139 | |
7a8f15e0 | 4140 | OVN_CLEANUP([hv1],[hv2]) |
28dc3fe9 SR |
4141 | |
4142 | AT_CLEANUP | |
5412db30 | 4143 | |
0ee8aaf6 | 4144 | AT_SETUP([ovn -- send gratuitous arp on localnet]) |
d08dbed7 | 4145 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
0ee8aaf6 | 4146 | ovn_start |
ea46a4e9 | 4147 | ovn-nbctl ls-add lsw0 |
0ee8aaf6 RR |
4148 | net_add n1 |
4149 | sim_add hv | |
4150 | as hv | |
4151 | ovs-vsctl \ | |
4152 | -- add-br br-phys \ | |
4153 | -- add-br br-eth0 | |
4154 | ||
4155 | ovn_attach n1 br-phys 192.168.0.1 | |
4156 | ||
4157 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
4158 | 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]) | |
4159 | ||
4160 | # Create a vif. | |
31ed1192 JP |
4161 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) |
4162 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.2"]) | |
4163 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
0ee8aaf6 RR |
4164 | |
4165 | # Create a localnet port. | |
31ed1192 JP |
4166 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) |
4167 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
4168 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
4169 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
0ee8aaf6 RR |
4170 | |
4171 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
4172 | ||
4173 | # Wait for packet to be received. | |
49d7c759 BP |
4174 | echo "fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" > expected |
4175 | OVN_CHECK_PACKETS([hv/snoopvif-tx.pcap], [expected]) | |
0ee8aaf6 | 4176 | |
5b57e12a GL |
4177 | # Check GARP packet when restart openflow connection. |
4178 | as hv | |
4179 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4180 | ||
4181 | OVS_WAIT_UNTIL([grep -c "waiting 4 seconds before reconnect" hv/ovn-controller.log]) | |
4182 | ||
4183 | as hv | |
4184 | start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl | |
4185 | ||
4186 | # Wait for packet to be received. | |
4187 | echo "fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" > expected | |
4188 | OVN_CHECK_PACKETS([hv/snoopvif-tx.pcap], [expected]) | |
4189 | ||
0ee8aaf6 RR |
4190 | # Delete the localnet ports. |
4191 | AT_CHECK([ovs-vsctl del-port localvif1]) | |
31ed1192 | 4192 | AT_CHECK([ovn-nbctl lsp-del ln_port]) |
0ee8aaf6 | 4193 | |
7a8f15e0 | 4194 | OVN_CLEANUP([hv]) |
0ee8aaf6 RR |
4195 | |
4196 | AT_CLEANUP | |
75cf9d2b GS |
4197 | |
4198 | AT_SETUP([ovn -- 2 HVs, 3 LRs connected via LS, static routes]) | |
75cf9d2b GS |
4199 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4200 | ovn_start | |
4201 | ||
4202 | # Logical network: | |
4203 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
4204 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
4205 | # connected to it. R2 has alice (172.16.1.0/24) and R3 has bob (10.32.1.0/24) | |
4206 | # connected to it. | |
4207 | ||
fa2a27b2 JP |
4208 | ovn-nbctl lr-add R1 |
4209 | ovn-nbctl lr-add R2 | |
4210 | ovn-nbctl lr-add R3 | |
75cf9d2b | 4211 | |
ea46a4e9 JP |
4212 | ovn-nbctl ls-add foo |
4213 | ovn-nbctl ls-add alice | |
4214 | ovn-nbctl ls-add bob | |
4215 | ovn-nbctl ls-add join | |
75cf9d2b GS |
4216 | |
4217 | # Connect foo to R1 | |
31114af7 | 4218 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 4219 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 4220 | options:router-port=foo addresses=\"00:00:01:01:02:03\" |
75cf9d2b GS |
4221 | |
4222 | # Connect alice to R2 | |
31114af7 | 4223 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 4224 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 4225 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
75cf9d2b GS |
4226 | |
4227 | # Connect bob to R3 | |
31114af7 | 4228 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24 |
31ed1192 | 4229 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ |
80f408f4 | 4230 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" |
75cf9d2b GS |
4231 | |
4232 | # Connect R1 to join | |
31114af7 | 4233 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 4234 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 4235 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
75cf9d2b GS |
4236 | |
4237 | # Connect R2 to join | |
31114af7 | 4238 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 4239 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 4240 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
75cf9d2b GS |
4241 | |
4242 | # Connect R3 to join | |
31114af7 | 4243 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 |
31ed1192 | 4244 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ |
80f408f4 | 4245 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' |
75cf9d2b GS |
4246 | |
4247 | #install static routes | |
e48ccf3c JP |
4248 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
4249 | ovn-nbctl lr-route-add R1 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 4250 | |
e48ccf3c JP |
4251 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 |
4252 | ovn-nbctl lr-route-add R2 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 4253 | |
e48ccf3c JP |
4254 | ovn-nbctl lr-route-add R3 192.168.1.0/24 20.0.0.1 |
4255 | ovn-nbctl lr-route-add R3 172.16.1.0/24 20.0.0.2 | |
75cf9d2b GS |
4256 | |
4257 | # Create logical port foo1 in foo | |
31ed1192 JP |
4258 | ovn-nbctl lsp-add foo foo1 \ |
4259 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
75cf9d2b GS |
4260 | |
4261 | # Create logical port alice1 in alice | |
31ed1192 JP |
4262 | ovn-nbctl lsp-add alice alice1 \ |
4263 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
75cf9d2b GS |
4264 | |
4265 | # Create logical port bob1 in bob | |
31ed1192 JP |
4266 | ovn-nbctl lsp-add bob bob1 \ |
4267 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 10.32.1.2" | |
75cf9d2b GS |
4268 | |
4269 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
4270 | net_add n1 | |
4271 | ||
4272 | sim_add hv1 | |
4273 | as hv1 | |
4274 | ovs-vsctl add-br br-phys | |
4275 | ovn_attach n1 br-phys 192.168.0.1 | |
4276 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4277 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
4278 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4279 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4280 | ofport-request=1 | |
4281 | ||
4282 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4283 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
4284 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4285 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4286 | ofport-request=2 | |
4287 | ||
4288 | sim_add hv2 | |
4289 | as hv2 | |
4290 | ovs-vsctl add-br br-phys | |
4291 | ovn_attach n1 br-phys 192.168.0.2 | |
4292 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
4293 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
4294 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
4295 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
4296 | ofport-request=1 | |
4297 | ||
4298 | ||
4299 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
4300 | # packets for ARP resolution (native tunneling doesn't queue packets | |
4301 | # for ARP resolution). | |
74868f2c | 4302 | OVN_POPULATE_ARP |
75cf9d2b GS |
4303 | |
4304 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4305 | # XXX This should be more systematic. | |
4306 | sleep 1 | |
4307 | ||
4308 | ip_to_hex() { | |
4309 | printf "%02x%02x%02x%02x" "$@" | |
4310 | } | |
75cf9d2b GS |
4311 | |
4312 | # Send ip packets between foo1 and alice1 | |
4313 | src_mac="f00000010203" | |
4314 | dst_mac="000001010203" | |
4315 | src_ip=`ip_to_hex 192 168 1 2` | |
4316 | dst_ip=`ip_to_hex 172 16 1 2` | |
4317 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4318 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4319 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
4320 | ||
4321 | # Send ip packets between foo1 and bob1 | |
4322 | src_mac="f00000010203" | |
4323 | dst_mac="000001010203" | |
4324 | src_ip=`ip_to_hex 192 168 1 2` | |
4325 | dst_ip=`ip_to_hex 10 32 1 2` | |
4326 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4327 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4328 | ||
4329 | echo "---------NB dump-----" | |
4330 | ovn-nbctl show | |
4331 | echo "---------------------" | |
4332 | ovn-nbctl list logical_router | |
4333 | echo "---------------------" | |
4334 | ovn-nbctl list logical_router_port | |
4335 | echo "---------------------" | |
4336 | ||
4337 | echo "---------SB dump-----" | |
4338 | ovn-sbctl list datapath_binding | |
4339 | echo "---------------------" | |
4340 | ovn-sbctl list port_binding | |
4341 | echo "---------------------" | |
4342 | ovn-sbctl dump-flows | |
4343 | echo "---------------------" | |
4344 | ||
4345 | echo "------ hv1 dump ----------" | |
4346 | as hv1 ovs-ofctl show br-int | |
4347 | as hv1 ovs-ofctl dump-flows br-int | |
4348 | echo "------ hv2 dump ----------" | |
4349 | as hv2 ovs-ofctl show br-int | |
4350 | as hv2 ovs-ofctl dump-flows br-int | |
4351 | echo "----------------------------" | |
4352 | ||
4353 | # Packet to Expect at bob1 | |
4354 | src_mac="000003010203" | |
4355 | dst_mac="f00000010205" | |
4356 | src_ip=`ip_to_hex 192 168 1 2` | |
4357 | dst_ip=`ip_to_hex 10 32 1 2` | |
49d7c759 | 4358 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 4359 | |
49d7c759 | 4360 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
75cf9d2b GS |
4361 | |
4362 | # Packet to Expect at alice1 | |
4363 | src_mac="000002010203" | |
4364 | dst_mac="f00000010204" | |
4365 | src_ip=`ip_to_hex 192 168 1 2` | |
4366 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 4367 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 4368 | |
49d7c759 | 4369 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
75cf9d2b | 4370 | |
7a8f15e0 | 4371 | OVN_CLEANUP([hv1],[hv2]) |
75cf9d2b GS |
4372 | |
4373 | AT_CLEANUP | |
c1645003 | 4374 | |
281977f7 | 4375 | AT_SETUP([ovn -- dhcpv4 : 1 HV, 2 LS, 2 LSPs/LS]) |
281977f7 NS |
4376 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4377 | ovn_start | |
4378 | ||
4379 | ovn-nbctl ls-add ls1 | |
4380 | ||
4381 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
4382 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
4383 | ||
4384 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
4385 | ||
4386 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
4387 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
4388 | ||
4389 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
4390 | ||
4391 | ovn-nbctl ls-add ls2 | |
4392 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
4393 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
4394 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
4395 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
4396 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
4397 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
4398 | ||
9060fc9a | 4399 | d1="$(ovn-nbctl create DHCP_Options cidr=10.0.0.0/24 \ |
281977f7 | 4400 | options="\"server_id\"=\"10.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:01\" \ |
9060fc9a | 4401 | \"lease_time\"=\"3600\" \"router\"=\"10.0.0.1\"")" |
281977f7 | 4402 | |
9060fc9a MM |
4403 | ovn-nbctl lsp-set-dhcpv4-options ls1-lp1 ${d1} |
4404 | ovn-nbctl lsp-set-dhcpv4-options ls1-lp2 ${d1} | |
4405 | ||
4406 | d2="$(ovn-nbctl create DHCP_Options cidr=30.0.0.0/24 \ | |
281977f7 | 4407 | options="\"server_id\"=\"30.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:02\" \ |
9060fc9a MM |
4408 | \"lease_time\"=\"3600\"")" |
4409 | ||
4410 | ovn-nbctl lsp-set-dhcpv4-options ls2-lp2 ${d2} | |
281977f7 NS |
4411 | |
4412 | net_add n1 | |
4413 | sim_add hv1 | |
4414 | ||
4415 | as hv1 | |
4416 | ovs-vsctl add-br br-phys | |
4417 | ovn_attach n1 br-phys 192.168.0.1 | |
4418 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4419 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
4420 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4421 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4422 | ofport-request=1 | |
4423 | ||
4424 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4425 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
4426 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4427 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4428 | ofport-request=2 | |
4429 | ||
4430 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
4431 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
4432 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
4433 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
4434 | ofport-request=3 | |
4435 | ||
4436 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
4437 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
4438 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
4439 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
4440 | ofport-request=4 | |
4441 | ||
74868f2c | 4442 | OVN_POPULATE_ARP |
281977f7 NS |
4443 | |
4444 | sleep 2 | |
4445 | ||
4446 | as hv1 ovs-vsctl show | |
4447 | ||
281977f7 | 4448 | # This shell function sends a DHCP request packet |
fcc3c93f | 4449 | # test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP REQUEST_IP ... |
281977f7 | 4450 | test_dhcp() { |
fcc3c93f GS |
4451 | local inport=$1 src_mac=$2 dhcp_type=$3 ciaddr=$4 offer_ip=$5 request_ip=$6 use_ip=$7 |
4452 | shift; shift; shift; shift; shift; shift; shift; | |
213615b3 NS |
4453 | if test $use_ip != 0; then |
4454 | src_ip=$1 | |
4455 | dst_ip=$2 | |
4456 | shift; shift; | |
4457 | else | |
4458 | src_ip=`ip_to_hex 0 0 0 0` | |
4459 | dst_ip=`ip_to_hex 255 255 255 255` | |
4460 | fi | |
fcc3c93f GS |
4461 | if test $request_ip != 0; then |
4462 | ip_len=0120 | |
4463 | udp_len=010b | |
4464 | else | |
4465 | ip_len=011a | |
4466 | udp_len=0106 | |
4467 | fi | |
4468 | local request=ffffffffffff${src_mac}08004510${ip_len}0000000080110000${src_ip}${dst_ip} | |
281977f7 | 4469 | # udp header and dhcp header |
fcc3c93f GS |
4470 | request=${request}00440043${udp_len}0000 |
4471 | request=${request}010106006359aa7600000000${ciaddr}000000000000000000000000${src_mac} | |
281977f7 | 4472 | # client hardware padding |
ab187e7e | 4473 | request=${request}00000000000000000000 |
281977f7 | 4474 | # server hostname |
ab187e7e BP |
4475 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 |
4476 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 4477 | # boot file name |
ab187e7e BP |
4478 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 |
4479 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
4480 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
4481 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 4482 | # dhcp magic cookie |
ab187e7e | 4483 | request=${request}63825363 |
281977f7 | 4484 | # dhcp message type |
fcc3c93f GS |
4485 | request=${request}3501${dhcp_type} |
4486 | # dhcp unknown option | |
4487 | request=${request}d70701020304050607 | |
4488 | # dhcp pad option | |
4489 | request=${request}00 | |
4490 | if test $request_ip != 0; then | |
4491 | # dhcp requested ip | |
4492 | request=${request}3204${request_ip} | |
4493 | fi | |
4494 | # dhcp end option | |
4495 | request=${request}ff | |
281977f7 | 4496 | |
697f5993 BP |
4497 | for port in $inport "$@"; do |
4498 | : >> $port.expected | |
4499 | done | |
281977f7 | 4500 | if test $offer_ip != 0; then |
fcc3c93f | 4501 | local srv_mac=$1 srv_ip=$2 dhcp_reply_type=$3 expected_dhcp_opts=$4 |
281977f7 NS |
4502 | # total IP length will be the IP length of the request packet |
4503 | # (which is 272 in our case) + 8 (padding bytes) + (expected_dhcp_opts / 2) | |
4504 | ip_len=`expr 280 + ${#expected_dhcp_opts} / 2` | |
4505 | udp_len=`expr $ip_len - 20` | |
04d60f6e YT |
4506 | ip_len=$(printf "%x" $ip_len) |
4507 | udp_len=$(printf "%x" $udp_len) | |
281977f7 NS |
4508 | # $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len |
4509 | local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip} | |
4510 | # udp header and dhcp header. | |
4511 | # $udp_len var will be in 3 digits. So adding a '0' before $udp_len | |
fcc3c93f GS |
4512 | reply=${reply}004300440${udp_len}0000020106006359aa7600000000${ciaddr} |
4513 | # your ip address; 0 for NAK | |
4514 | if test $dhcp_reply_type = 06; then | |
4515 | reply=${reply}00000000 | |
4516 | else | |
4517 | reply=${reply}${offer_ip} | |
4518 | fi | |
281977f7 | 4519 | # next server ip address, relay agent ip address, client mac address |
ab187e7e | 4520 | reply=${reply}0000000000000000${src_mac} |
281977f7 | 4521 | # client hardware padding |
ab187e7e | 4522 | reply=${reply}00000000000000000000 |
281977f7 | 4523 | # server hostname |
ab187e7e BP |
4524 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 |
4525 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 4526 | # boot file name |
ab187e7e BP |
4527 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 |
4528 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
4529 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
4530 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 4531 | # dhcp magic cookie |
ab187e7e | 4532 | reply=${reply}63825363 |
ab187e7e | 4533 | reply=${reply}3501${dhcp_reply_type}${expected_dhcp_opts}00000000ff00000000 |
281977f7 NS |
4534 | echo $reply >> $inport.expected |
4535 | else | |
281977f7 | 4536 | for outport; do |
e4543cfe | 4537 | echo $request >> $outport.expected |
281977f7 NS |
4538 | done |
4539 | fi | |
4540 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
4541 | } | |
4542 | ||
4543 | reset_pcap_file() { | |
4544 | local iface=$1 | |
4545 | local pcap_file=$2 | |
4546 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
4547 | options:rxq_pcap=dummy-rx.pcap | |
4548 | rm -f ${pcap_file}*.pcap | |
4549 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
4550 | options:rxq_pcap=${pcap_file}-rx.pcap | |
4551 | } | |
4552 | ||
4553 | ip_to_hex() { | |
4554 | printf "%02x%02x%02x%02x" "$@" | |
4555 | } | |
4556 | ||
4557 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
4558 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
4559 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
4560 | ||
4561 | echo "---------NB dump-----" | |
4562 | ovn-nbctl show | |
4563 | echo "---------------------" | |
4564 | echo "---------SB dump-----" | |
4565 | ovn-sbctl list datapath_binding | |
4566 | echo "---------------------" | |
4567 | ovn-sbctl list logical_flow | |
4568 | echo "---------------------" | |
4569 | ||
4570 | echo "---------------------" | |
4571 | ovn-sbctl dump-flows | |
4572 | echo "---------------------" | |
4573 | ||
4574 | echo "------ hv1 dump ----------" | |
4575 | as hv1 ovs-ofctl dump-flows br-int | |
4576 | ||
4577 | # Send DHCPDISCOVER. | |
4578 | offer_ip=`ip_to_hex 10 0 0 4` | |
4579 | server_ip=`ip_to_hex 10 0 0 1` | |
fcc3c93f GS |
4580 | ciaddr=`ip_to_hex 0 0 0 0` |
4581 | request_ip=0 | |
7c76bf4e | 4582 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
fcc3c93f | 4583 | test_dhcp 1 f00000000001 01 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 02 $expected_dhcp_opts |
281977f7 NS |
4584 | |
4585 | # NXT_RESUMEs should be 1. | |
4586 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4587 | ||
4588 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
4589 | cat 1.expected | cut -c -48 > expout | |
4590 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
4591 | # Skipping the IPv4 checksum. | |
4592 | cat 1.expected | cut -c 53- > expout | |
4593 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
4594 | ||
4595 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
4596 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
4597 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4598 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4599 | rm -f 1.expected | |
4600 | rm -f 2.expected | |
4601 | ||
fcc3c93f GS |
4602 | # Send DHCPREQUEST in the SELECTING/INIT-REBOOT state with the offered IP |
4603 | # address in the Requested IP Address option. | |
281977f7 NS |
4604 | offer_ip=`ip_to_hex 10 0 0 6` |
4605 | server_ip=`ip_to_hex 10 0 0 1` | |
fcc3c93f GS |
4606 | ciaddr=`ip_to_hex 0 0 0 0` |
4607 | request_ip=$offer_ip | |
7c76bf4e | 4608 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
fcc3c93f | 4609 | test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 05 $expected_dhcp_opts |
281977f7 NS |
4610 | |
4611 | # NXT_RESUMEs should be 2. | |
4612 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4613 | ||
4614 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
4615 | cat 2.expected | cut -c -48 > expout | |
4616 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
4617 | # Skipping the IPv4 checksum. | |
4618 | cat 2.expected | cut -c 53- > expout | |
4619 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
4620 | ||
4621 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4622 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4623 | rm -f 1.expected | |
4624 | rm -f 2.expected | |
4625 | ||
fcc3c93f GS |
4626 | # Send DHCPREQUEST in the SELECTING/INIT-REBOOT state with a mismatched IP in |
4627 | # the Requested IP Address option, expect a DHCPNAK. | |
4628 | offer_ip=`ip_to_hex 10 0 0 6` | |
4629 | server_ip=`ip_to_hex 10 0 0 1` | |
4630 | ciaddr=`ip_to_hex 0 0 0 0` | |
4631 | request_ip=`ip_to_hex 10 0 0 7` | |
4632 | expected_dhcp_opts="" | |
4633 | test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 06 $expected_dhcp_opts | |
4634 | ||
4635 | # NXT_RESUMEs should be 3. | |
4636 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4637 | ||
4638 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
4639 | cat 2.expected | cut -c -48 > expout | |
4640 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
4641 | # Skipping the IPv4 checksum. | |
4642 | cat 2.expected | cut -c 53- > expout | |
4643 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
4644 | ||
4645 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4646 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4647 | rm -f 1.expected | |
4648 | rm -f 2.expected | |
4649 | ||
281977f7 NS |
4650 | # Send Invalid DHCPv4 packet on ls1-lp2. It should be received by ovn-controller |
4651 | # but should be resumed without the reply. | |
4652 | # ls1-lp1 (vif1-tx.pcap) should receive the DHCPv4 request packet twice, | |
4653 | # one from ovn-controller and the other from "ovs-ofctl resume." | |
fcc3c93f | 4654 | ciaddr=`ip_to_hex 0 0 0 0` |
281977f7 | 4655 | offer_ip=0 |
fcc3c93f GS |
4656 | request_ip=0 |
4657 | test_dhcp 2 f00000000002 08 $ciaddr $offer_ip $request_ip 0 1 1 | |
281977f7 | 4658 | |
fcc3c93f GS |
4659 | # NXT_RESUMEs should be 4. |
4660 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
281977f7 NS |
4661 | |
4662 | # vif1-tx.pcap should have received the DHCPv4 (invalid) request packet | |
49d7c759 | 4663 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected]) |
281977f7 NS |
4664 | |
4665 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4666 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4667 | rm -f 1.expected | |
4668 | rm -f 2.expected | |
4669 | ||
4670 | # Send DHCPv4 packet on ls2-lp1. It doesn't have any DHCPv4 options defined. | |
4671 | # ls2-lp2 (vif4-tx.pcap) should receive the DHCPv4 request packet once. | |
4672 | ||
fcc3c93f GS |
4673 | ciaddr=`ip_to_hex 0 0 0 0` |
4674 | test_dhcp 3 f00000000003 01 $ciaddr 0 0 4 0 | |
281977f7 NS |
4675 | |
4676 | # Send DHCPv4 packet on ls2-lp2. "router" DHCPv4 option is not defined for | |
4677 | # this lport. | |
fcc3c93f GS |
4678 | ciaddr=`ip_to_hex 0 0 0 0` |
4679 | test_dhcp 4 f00000000004 01 $ciaddr 0 0 3 0 | |
281977f7 | 4680 | |
fcc3c93f GS |
4681 | # NXT_RESUMEs should be 4. |
4682 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
281977f7 | 4683 | |
fcc3c93f GS |
4684 | #OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected]) |
4685 | #OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [4.expected]) | |
281977f7 | 4686 | |
fcc3c93f GS |
4687 | # Send DHCPREQUEST in the RENEWING/REBINDING state with ip4.src set to 10.0.0.6 |
4688 | # and ip4.dst set to 10.0.0.1. | |
213615b3 NS |
4689 | offer_ip=`ip_to_hex 10 0 0 6` |
4690 | server_ip=`ip_to_hex 10 0 0 1` | |
fcc3c93f GS |
4691 | ciaddr=$offer_ip |
4692 | request_ip=0 | |
213615b3 NS |
4693 | src_ip=$offer_ip |
4694 | dst_ip=$server_ip | |
fcc3c93f GS |
4695 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
4696 | test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 05 $expected_dhcp_opts | |
213615b3 | 4697 | |
fcc3c93f GS |
4698 | # NXT_RESUMEs should be 5. |
4699 | OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
213615b3 NS |
4700 | |
4701 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
4702 | cat 2.expected | cut -c -48 > expout | |
4703 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
4704 | # Skipping the IPv4 checksum. | |
4705 | cat 2.expected | cut -c 53- > expout | |
4706 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
4707 | ||
4708 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4709 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4710 | rm -f 1.expected | |
4711 | rm -f 2.expected | |
4712 | ||
fcc3c93f GS |
4713 | # Send DHCPREQUEST in the RENEWING/REBINDING state with ip4.src set to 10.0.0.6 |
4714 | # and ip4.dst set to 255.255.255.255. | |
213615b3 NS |
4715 | offer_ip=`ip_to_hex 10 0 0 6` |
4716 | server_ip=`ip_to_hex 10 0 0 1` | |
fcc3c93f GS |
4717 | ciaddr=$offer_ip |
4718 | request_ip=0 | |
4719 | src_ip=$offer_ip | |
4720 | dst_ip=`ip_to_hex 255 255 255 255` | |
213615b3 | 4721 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
fcc3c93f GS |
4722 | test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 05 $expected_dhcp_opts |
4723 | ||
4724 | # NXT_RESUMEs should be 6. | |
4725 | OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4726 | ||
4727 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
4728 | cat 2.expected | cut -c -48 > expout | |
4729 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
4730 | # Skipping the IPv4 checksum. | |
4731 | cat 2.expected | cut -c 53- > expout | |
4732 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
4733 | ||
4734 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4735 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4736 | rm -f 1.expected | |
4737 | rm -f 2.expected | |
4738 | ||
4739 | # Send DHCPREQUEST in the RENEWING/REBINDING state with a mismatched IP in the | |
4740 | # ciaddr, expect a DHCPNAK. | |
4741 | offer_ip=`ip_to_hex 10 0 0 6` | |
4742 | server_ip=`ip_to_hex 10 0 0 1` | |
4743 | ciaddr=`ip_to_hex 10 0 0 7` | |
4744 | request_ip=0 | |
213615b3 NS |
4745 | src_ip=$offer_ip |
4746 | dst_ip=`ip_to_hex 255 255 255 255` | |
fcc3c93f GS |
4747 | expected_dhcp_opts="" |
4748 | test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 06 $expected_dhcp_opts | |
213615b3 | 4749 | |
fcc3c93f GS |
4750 | # NXT_RESUMEs should be 7. |
4751 | OVS_WAIT_UNTIL([test 7 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4752 | ||
4753 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
4754 | cat 2.expected | cut -c -48 > expout | |
4755 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
4756 | # Skipping the IPv4 checksum. | |
4757 | cat 2.expected | cut -c 53- > expout | |
4758 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
4759 | ||
4760 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4761 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4762 | rm -f 1.expected | |
4763 | rm -f 2.expected | |
4764 | ||
4765 | # Send DHCPREQUEST in the RENEWING/REBINDING state without a specifyied ciaddr, | |
4766 | # expect a DHCPNAK. | |
4767 | offer_ip=`ip_to_hex 10 0 0 6` | |
4768 | server_ip=`ip_to_hex 10 0 0 1` | |
4769 | ciaddr=`ip_to_hex 0 0 0 0` | |
4770 | request_ip=0 | |
4771 | src_ip=$offer_ip | |
4772 | dst_ip=`ip_to_hex 255 255 255 255` | |
4773 | expected_dhcp_opts="" | |
4774 | test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 06 $expected_dhcp_opts | |
4775 | ||
4776 | # NXT_RESUMEs should be 8. | |
4777 | OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
213615b3 NS |
4778 | |
4779 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
4780 | cat 2.expected | cut -c -48 > expout | |
4781 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
4782 | # Skipping the IPv4 checksum. | |
4783 | cat 2.expected | cut -c 53- > expout | |
4784 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
4785 | ||
4786 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4787 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4788 | rm -f 1.expected | |
4789 | rm -f 2.expected | |
4790 | ||
4791 | # Send DHCPREQUEST with ip4.src set to 10.0.0.6 and ip4.dst set to 10.0.0.4. | |
4792 | # The packet should not be received by ovn-controller. | |
fcc3c93f | 4793 | ciaddr=`ip_to_hex 0 0 0 0` |
213615b3 NS |
4794 | src_ip=`ip_to_hex 10 0 0 6` |
4795 | dst_ip=`ip_to_hex 10 0 0 4` | |
fcc3c93f | 4796 | test_dhcp 2 f00000000002 03 $ciaddr 0 0 1 $src_ip $dst_ip 1 |
213615b3 | 4797 | |
fcc3c93f GS |
4798 | # NXT_RESUMEs should be 8. |
4799 | OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
213615b3 NS |
4800 | |
4801 | # vif1-tx.pcap should have received the DHCPv4 request packet | |
4802 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected]) | |
4803 | ||
c4d0e4f2 | 4804 | OVN_CLEANUP([hv1]) |
33ac3c83 NS |
4805 | |
4806 | AT_CLEANUP | |
4807 | ||
40df4566 | 4808 | AT_SETUP([ovn -- dhcpv6 : 1 HV, 2 LS, 5 LSPs]) |
33ac3c83 NS |
4809 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4810 | ovn_start | |
4811 | ||
4812 | ovn-nbctl ls-add ls1 | |
4813 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
4814 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
4815 | ||
4816 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
4817 | ||
4818 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
4819 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
4820 | ||
4821 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
4822 | ||
40df4566 ZKL |
4823 | ovn-nbctl lsp-add ls1 ls1-lp3 \ |
4824 | -- lsp-set-addresses ls1-lp3 "f0:00:00:00:00:22 ae70::22" | |
4825 | ||
4826 | ovn-nbctl lsp-set-port-security ls1-lp3 "f0:00:00:00:00:22 ae70::22" | |
4827 | ||
9060fc9a MM |
4828 | d1="$(ovn-nbctl create DHCP_Options cidr="ae70\:\:/64" \ |
4829 | options="\"server_id\"=\"00:00:00:10:00:01\"")" | |
4830 | ||
4831 | ovn-nbctl lsp-set-dhcpv6-options ls1-lp1 ${d1} | |
4832 | ovn-nbctl lsp-set-dhcpv6-options ls1-lp2 ${d1} | |
4833 | ||
4834 | d2="$(ovn-nbctl create DHCP_Options cidr="ae70\:\:/64" \ | |
4835 | options="\"dhcpv6_stateless\"=\"true\" \"server_id\"=\"00:00:00:10:00:01\"")" | |
33ac3c83 | 4836 | |
9060fc9a | 4837 | ovn-nbctl lsp-set-dhcpv6-options ls1-lp3 ${d2} |
40df4566 | 4838 | |
33ac3c83 NS |
4839 | ovn-nbctl ls-add ls2 |
4840 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
4841 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
4842 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
4843 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
4844 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
4845 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
4846 | ||
4847 | net_add n1 | |
4848 | sim_add hv1 | |
4849 | ||
4850 | as hv1 | |
4851 | ovs-vsctl add-br br-phys | |
4852 | ovn_attach n1 br-phys 192.168.0.1 | |
4853 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4854 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
4855 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4856 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4857 | ofport-request=1 | |
4858 | ||
4859 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4860 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
4861 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4862 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4863 | ofport-request=2 | |
4864 | ||
4865 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
4866 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
4867 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
4868 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
4869 | ofport-request=3 | |
4870 | ||
4871 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
4872 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
4873 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
4874 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
4875 | ofport-request=4 | |
4876 | ||
40df4566 ZKL |
4877 | ovs-vsctl -- add-port br-int hv1-vif5 -- \ |
4878 | set interface hv1-vif5 external-ids:iface-id=ls1-lp3 \ | |
4879 | options:tx_pcap=hv1/vif5-tx.pcap \ | |
4880 | options:rxq_pcap=hv1/vif5-rx.pcap \ | |
4881 | ofport-request=5 | |
4882 | ||
74868f2c | 4883 | OVN_POPULATE_ARP |
33ac3c83 NS |
4884 | |
4885 | sleep 2 | |
4886 | ||
4887 | trim_zeros() { | |
4888 | sed 's/\(00\)\{1,\}$//' | |
4889 | } | |
4890 | ||
4891 | # This shell function sends a DHCPv6 request packet | |
40df4566 ZKL |
4892 | # test_dhcpv6 INPORT SRC_MAC SRC_LLA DHCPv6_MSG_TYPE OFFER_IP OUTPORT... |
4893 | # The OUTPORTs (zero or more) list the VIFs on which the original DHCPv6 | |
33ac3c83 NS |
4894 | # packet should be received twice (one from ovn-controller and the other |
4895 | # from the "ovs-ofctl monitor br-int resume" | |
4896 | test_dhcpv6() { | |
4897 | local inport=$1 src_mac=$2 src_lla=$3 msg_code=$4 offer_ip=$5 | |
2e5fceb0 NS |
4898 | if test $msg_code != 0b; then |
4899 | req_len=2a | |
4900 | else | |
4901 | req_len=1a | |
4902 | fi | |
4903 | local request=ffffffffffff${src_mac}86dd0000000000${req_len}1101${src_lla} | |
33ac3c83 | 4904 | # dst ip ff02::1:2 |
ab187e7e | 4905 | request=${request}ff020000000000000000000000010002 |
33ac3c83 | 4906 | # udp header and dhcpv6 header |
2e5fceb0 | 4907 | request=${request}0222022300${req_len}ffff${msg_code}010203 |
33ac3c83 | 4908 | # Client identifier |
ab187e7e | 4909 | request=${request}0001000a00030001${src_mac} |
2e5fceb0 NS |
4910 | # Add IA-NA (Identity Association for Non Temporary Address) if msg_code |
4911 | # is not 11 (information request packet) | |
4912 | if test $msg_code != 0b; then | |
4913 | request=${request}0003000c0102030400000e1000001518 | |
4914 | fi | |
33ac3c83 NS |
4915 | shift; shift; shift; shift; shift; |
4916 | if test $offer_ip != 0; then | |
4917 | local server_mac=000000100001 | |
4918 | local server_lla=fe80000000000000020000fffe100001 | |
4919 | local reply_code=07 | |
4920 | if test $msg_code = 01; then | |
4921 | reply_code=02 | |
4922 | fi | |
40df4566 ZKL |
4923 | local msg_len=54 |
4924 | if test $offer_ip = 1; then | |
4925 | msg_len=28 | |
4926 | fi | |
4927 | local reply=${src_mac}${server_mac}86dd0000000000${msg_len}1101${server_lla}${src_lla} | |
33ac3c83 | 4928 | # udp header and dhcpv6 header |
ab187e7e | 4929 | reply=${reply}0223022200${msg_len}ffff${reply_code}010203 |
33ac3c83 | 4930 | # Client identifier |
ab187e7e | 4931 | reply=${reply}0001000a00030001${src_mac} |
33ac3c83 | 4932 | # IA-NA |
40df4566 | 4933 | if test $offer_ip != 1; then |
ab187e7e | 4934 | reply=${reply}0003002801020304ffffffffffffffff00050018${offer_ip}ffffffffffffffff |
40df4566 | 4935 | fi |
33ac3c83 | 4936 | # Server identifier |
ab187e7e | 4937 | reply=${reply}0002000a00030001${server_mac} |
33ac3c83 NS |
4938 | echo $reply | trim_zeros >> $inport.expected |
4939 | else | |
4940 | for outport; do | |
4941 | echo $request | trim_zeros >> $outport.expected | |
4942 | done | |
4943 | fi | |
4944 | ||
4945 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
4946 | } | |
4947 | ||
4948 | reset_pcap_file() { | |
4949 | local iface=$1 | |
4950 | local pcap_file=$2 | |
4951 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
4952 | options:rxq_pcap=dummy-rx.pcap | |
4953 | rm -f ${pcap_file}*.pcap | |
4954 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
4955 | options:rxq_pcap=${pcap_file}-rx.pcap | |
4956 | } | |
4957 | ||
4958 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
4959 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
4960 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
4961 | ||
4962 | echo "---------NB dump-----" | |
4963 | ovn-nbctl show | |
4964 | echo "---------------------" | |
4965 | echo "---------SB dump-----" | |
4966 | ovn-sbctl list datapath_binding | |
4967 | echo "---------------------" | |
4968 | ovn-sbctl list logical_flow | |
4969 | echo "---------------------" | |
4970 | ||
4971 | echo "---------------------" | |
4972 | ovn-sbctl dump-flows | |
4973 | echo "---------------------" | |
4974 | ||
4975 | echo "------ hv1 dump ----------" | |
4976 | as hv1 ovs-ofctl dump-flows br-int | |
4977 | ||
4978 | src_mac=f00000000001 | |
4979 | src_lla=fe80000000000000f20000fffe000001 | |
4980 | offer_ip=ae700000000000000000000000000004 | |
4981 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
4982 | ||
4983 | # NXT_RESUMEs should be 1. | |
4984 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4985 | ||
4986 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
4987 | # cat 1.expected | trim_zeros > expout | |
4988 | cat 1.expected | cut -c -120 > expout | |
4989 | AT_CHECK([cat 1.packets | cut -c -120], [0], [expout]) | |
4990 | # Skipping the UDP checksum | |
4991 | cat 1.expected | cut -c 125- > expout | |
4992 | AT_CHECK([cat 1.packets | cut -c 125-], [0], [expout]) | |
4993 | ||
4994 | rm 1.expected | |
4995 | ||
4996 | # Send invalid packet on ls1-lp2. ovn-controller should resume the packet | |
4997 | # without any modifications and the packet should be received by ls1-lp1. | |
4998 | # ls1-lp1 will receive the packet twice, one from the ovn-controller after the | |
4999 | # resume and the other from ovs-ofctl monitor resume. | |
5000 | ||
5001 | reset_pcap_file hv1-vif1 hv1/vif1 | |
5002 | reset_pcap_file hv1-vif2 hv1/vif2 | |
5003 | ||
5004 | src_mac=f00000000002 | |
5005 | src_lla=fe80000000000000f20000fffe000002 | |
5006 | offer_ip=ae700000000000000000000000000005 | |
5007 | # Set invalid msg_type | |
5008 | ||
5009 | test_dhcpv6 2 $src_mac $src_lla 10 0 1 1 | |
5010 | ||
5011 | # NXT_RESUMEs should be 2. | |
5012 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
5013 | ||
5014 | # vif2-tx.pcap should not have received the DHCPv6 reply packet | |
5015 | rm 2.packets | |
5016 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > 2.packets | |
5017 | AT_CHECK([cat 2.packets], [0], []) | |
5018 | ||
5019 | # vif1-tx.pcap should have received the DHCPv6 (invalid) request packet | |
5020 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
5021 | cat 1.expected > expout | |
5022 | AT_CHECK([cat 1.packets], [0], [expout]) | |
5023 | ||
5024 | # Send DHCPv6 packet on ls2-lp1. native DHCPv6 is disabled on this port. | |
5025 | # There should be no DHCPv6 reply from ovn-controller and the request packet | |
5026 | # should be received by ls2-lp2. | |
5027 | ||
5028 | src_mac=f00000000003 | |
5029 | src_lla=fe80000000000000f20000fffe000003 | |
5030 | test_dhcpv6 3 $src_mac $src_lla 01 0 4 | |
5031 | ||
5032 | # NXT_RESUMEs should be 2 only. | |
5033 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
5034 | ||
5035 | # vif3-tx.pcap should not have received the DHCPv6 reply packet | |
5036 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap | trim_zeros > 3.packets | |
5037 | AT_CHECK([cat 3.packets], [0], []) | |
5038 | ||
5039 | # vif4-tx.pcap should have received the DHCPv6 request packet | |
5040 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif4-tx.pcap | trim_zeros > 4.packets | |
5041 | cat 4.expected > expout | |
5042 | AT_CHECK([cat 4.packets], [0], [expout]) | |
5043 | ||
40df4566 | 5044 | # Send DHCPv6 packet on ls1-lp3. native DHCPv6 works as stateless mode for this port. |
2e5fceb0 | 5045 | # The DHCPv6 reply shouldn't contain offer_ip. |
40df4566 ZKL |
5046 | src_mac=f00000000022 |
5047 | src_lla=fe80000000000000f20000fffe000022 | |
5048 | reset_pcap_file hv1-vif5 hv1/vif5 | |
5049 | test_dhcpv6 5 $src_mac $src_lla 01 1 5 | |
5050 | ||
5051 | # NXT_RESUMEs should be 3. | |
5052 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
5053 | ||
5054 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.packets | |
5055 | # Skipping the UDP checksum | |
5056 | cat 5.expected | cut -c 1-120,125- > expout | |
2e5fceb0 NS |
5057 | AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout]) |
5058 | ||
5059 | # Send DHCPv6 information request (code 11) on ls1-lp3. The DHCPv6 reply | |
5060 | # shouldn't contain offer_ip | |
5061 | src_mac=f00000000022 | |
5062 | src_lla=fe80000000000000f20000fffe000022 | |
5063 | reset_pcap_file hv1-vif5 hv1/vif5 | |
5064 | rm -f 5.expected | |
5065 | test_dhcpv6 5 $src_mac $src_lla 0b 1 5 | |
5066 | ||
5067 | # NXT_RESUMEs should be 4. | |
5068 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
5069 | ||
5070 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | | |
5071 | trim_zeros > 5.packets | |
5072 | # Skipping the UDP checksum | |
5073 | cat 5.expected | cut -c 1-120,125- > expout | |
40df4566 ZKL |
5074 | AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout]) |
5075 | ||
c4d0e4f2 | 5076 | OVN_CLEANUP([hv1]) |
281977f7 NS |
5077 | |
5078 | AT_CLEANUP | |
5079 | ||
c1645003 | 5080 | AT_SETUP([ovn -- 2 HVs, 2 LRs connected via LS, gateway router]) |
c1645003 GS |
5081 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5082 | ovn_start | |
5083 | ||
5084 | # Logical network: | |
5085 | # Two LRs - R1 and R2 that are connected to each other via LS "join" | |
5086 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
5087 | # connected to it. R2 has alice (172.16.1.0/24) connected to it. | |
5088 | # R2 is a gateway router. | |
5089 | ||
5090 | ||
5091 | ||
5092 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
5093 | net_add n1 | |
5094 | ||
5095 | sim_add hv1 | |
5096 | as hv1 | |
5097 | ovs-vsctl add-br br-phys | |
5098 | ovn_attach n1 br-phys 192.168.0.1 | |
5099 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
5100 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
5101 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
5102 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
5103 | ofport-request=1 | |
5104 | ||
5105 | ||
5106 | sim_add hv2 | |
5107 | as hv2 | |
5108 | ovs-vsctl add-br br-phys | |
5109 | ovn_attach n1 br-phys 192.168.0.2 | |
5110 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
5111 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
5112 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
5113 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
5114 | ofport-request=1 | |
5115 | ||
5116 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
5117 | # packets for ARP resolution (native tunneling doesn't queue packets | |
5118 | # for ARP resolution). | |
74868f2c | 5119 | OVN_POPULATE_ARP |
c1645003 GS |
5120 | |
5121 | ovn-nbctl create Logical_Router name=R1 | |
5122 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
5123 | ||
ea46a4e9 JP |
5124 | ovn-nbctl ls-add foo |
5125 | ovn-nbctl ls-add alice | |
5126 | ovn-nbctl ls-add join | |
c1645003 GS |
5127 | |
5128 | # Connect foo to R1 | |
31114af7 | 5129 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 5130 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ |
80f408f4 | 5131 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" |
c1645003 GS |
5132 | |
5133 | # Connect alice to R2 | |
31114af7 | 5134 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 5135 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 5136 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
c1645003 GS |
5137 | |
5138 | # Connect R1 to join | |
31114af7 | 5139 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 5140 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 5141 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
c1645003 GS |
5142 | |
5143 | # Connect R2 to join | |
31114af7 | 5144 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 5145 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 5146 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
c1645003 GS |
5147 | |
5148 | ||
5149 | #install static routes | |
5150 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
5151 | ip_prefix=172.16.1.0/24 nexthop=20.0.0.2 -- add Logical_Router \ | |
5152 | R1 static_routes @lrt | |
5153 | ||
5154 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
5155 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
5156 | R2 static_routes @lrt | |
5157 | ||
5158 | # Create logical port foo1 in foo | |
31ed1192 JP |
5159 | ovn-nbctl lsp-add foo foo1 \ |
5160 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
c1645003 GS |
5161 | |
5162 | # Create logical port alice1 in alice | |
31ed1192 JP |
5163 | ovn-nbctl lsp-add alice alice1 \ |
5164 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
c1645003 GS |
5165 | |
5166 | ||
5167 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5168 | # XXX This should be more systematic. | |
5169 | sleep 2 | |
5170 | ||
5171 | ip_to_hex() { | |
5172 | printf "%02x%02x%02x%02x" "$@" | |
5173 | } | |
c1645003 GS |
5174 | |
5175 | # Send ip packets between foo1 and alice1 | |
5176 | src_mac="f00000010203" | |
5177 | dst_mac="000001010203" | |
5178 | src_ip=`ip_to_hex 192 168 1 2` | |
5179 | dst_ip=`ip_to_hex 172 16 1 2` | |
5180 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5181 | ||
5182 | echo "---------NB dump-----" | |
5183 | ovn-nbctl show | |
5184 | echo "---------------------" | |
5185 | ovn-nbctl list logical_router | |
5186 | echo "---------------------" | |
5187 | ovn-nbctl list logical_router_port | |
5188 | echo "---------------------" | |
5189 | ||
5190 | echo "---------SB dump-----" | |
5191 | ovn-sbctl list datapath_binding | |
5192 | echo "---------------------" | |
5193 | ovn-sbctl list port_binding | |
5194 | echo "---------------------" | |
5195 | ovn-sbctl dump-flows | |
5196 | echo "---------------------" | |
5197 | ovn-sbctl list chassis | |
5198 | ovn-sbctl list encap | |
5199 | echo "---------------------" | |
5200 | ||
c1645003 GS |
5201 | # Packet to Expect at alice1 |
5202 | src_mac="000002010203" | |
5203 | dst_mac="f00000010204" | |
5204 | src_ip=`ip_to_hex 192 168 1 2` | |
5205 | dst_ip=`ip_to_hex 172 16 1 2` | |
5206 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
5207 | ||
5208 | ||
5209 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
5210 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
5211 | ||
ab39371d RM |
5212 | echo "------ hv1 dump after packet 1 ----------" |
5213 | as hv1 ovs-ofctl show br-int | |
5214 | as hv1 ovs-ofctl dump-flows br-int | |
5215 | echo "------ hv2 dump after packet 1 ----------" | |
5216 | as hv2 ovs-ofctl show br-int | |
5217 | as hv2 ovs-ofctl dump-flows br-int | |
5218 | echo "----------------------------" | |
5219 | ||
49d7c759 BP |
5220 | echo $expected > expected |
5221 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
c1645003 | 5222 | |
34114cf8 GS |
5223 | # Delete the router and re-create it. Things should work as before. |
5224 | ovn-nbctl lr-del R2 | |
5225 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
5226 | # Connect alice to R2 | |
5227 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
5228 | # Connect R2 to join | |
5229 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
5230 | ||
5231 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
5232 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
5233 | R2 static_routes @lrt | |
5234 | ||
5235 | # Wait for ovn-controller to catch up. | |
5236 | sleep 1 | |
5237 | ||
5238 | # Send the packet again. | |
5239 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
ab39371d RM |
5240 | |
5241 | echo "------ hv1 dump after packet 2 ----------" | |
5242 | as hv1 ovs-ofctl show br-int | |
5243 | as hv1 ovs-ofctl dump-flows br-int | |
5244 | echo "------ hv2 dump after packet 2 ----------" | |
5245 | as hv2 ovs-ofctl show br-int | |
5246 | as hv2 ovs-ofctl dump-flows br-int | |
5247 | echo "----------------------------" | |
5248 | ||
49d7c759 BP |
5249 | echo $expected >> expected |
5250 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
34114cf8 | 5251 | |
7a8f15e0 | 5252 | OVN_CLEANUP([hv1],[hv2]) |
c1645003 GS |
5253 | |
5254 | AT_CLEANUP | |
bb3c4568 FF |
5255 | |
5256 | AT_SETUP([ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR]) | |
5257 | AT_KEYWORDS([router-icmp-reply]) | |
5258 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5259 | ovn_start | |
5260 | ||
5261 | # Logical network: | |
5262 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
5263 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
5264 | ||
fa2a27b2 | 5265 | ovn-nbctl lr-add R1 |
bb3c4568 | 5266 | |
ea46a4e9 JP |
5267 | ovn-nbctl ls-add ls1 |
5268 | ovn-nbctl ls-add ls2 | |
bb3c4568 FF |
5269 | |
5270 | # Connect ls1 to R1 | |
31114af7 | 5271 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24 |
31ed1192 | 5272 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \ |
80f408f4 | 5273 | type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\" |
bb3c4568 FF |
5274 | |
5275 | # Connect ls2 to R1 | |
31114af7 | 5276 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24 |
31ed1192 | 5277 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \ |
80f408f4 | 5278 | type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\" |
bb3c4568 FF |
5279 | |
5280 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
5281 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
5282 | -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2" | |
bb3c4568 FF |
5283 | |
5284 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
5285 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
5286 | -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2" | |
bb3c4568 FF |
5287 | |
5288 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
5289 | net_add n1 | |
5290 | ||
5291 | sim_add hv1 | |
5292 | as hv1 | |
5293 | ovs-vsctl add-br br-phys | |
5294 | ovn_attach n1 br-phys 192.168.0.1 | |
5295 | ovs-vsctl -- add-port br-int vif1 -- \ | |
5296 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
5297 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
5298 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
5299 | ofport-request=1 | |
5300 | ||
5301 | ovs-vsctl -- add-port br-int vif2 -- \ | |
5302 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
5303 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
5304 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
5305 | ofport-request=1 | |
5306 | ||
5307 | ||
5308 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5309 | # XXX This should be more systematic. | |
5310 | sleep 1 | |
5311 | ||
5312 | ||
5313 | ip_to_hex() { | |
5314 | printf "%02x%02x%02x%02x" "$@" | |
5315 | } | |
bb3c4568 FF |
5316 | for i in 1 2; do |
5317 | : > vif$i.expected | |
5318 | done | |
5319 | # test_ipv4_icmp_request INPORT ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM ICMP_CHKSUM [EXP_IP_CHKSUM EXP_ICMP_CHKSUM] | |
5320 | # | |
5321 | # Causes a packet to be received on INPORT. The packet is an ICMPv4 | |
5322 | # request with ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHSUM and | |
5323 | # ICMP_CHKSUM as specified. If EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are | |
5324 | # provided, then it should be the ip and icmp checksums of the packet | |
5325 | # responded; otherwise, no reply is expected. | |
5326 | # In the absence of an ip checksum calculation helpers, this relies | |
5327 | # on the caller to provide the checksums for the ip and icmp headers. | |
5328 | # XXX This should be more systematic. | |
5329 | # | |
5330 | # INPORT is an lport number, e.g. 11 for vif11. | |
5331 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
5332 | # IPV4_SRC and IPV4_DST are each 8 hex digits. | |
5333 | # IP_CHSUM and ICMP_CHKSUM are each 4 hex digits. | |
5334 | # EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits. | |
5335 | test_ipv4_icmp_request() { | |
5336 | local inport=$1 eth_src=$2 eth_dst=$3 ipv4_src=$4 ipv4_dst=$5 ip_chksum=$6 icmp_chksum=$7 | |
5337 | local exp_ip_chksum=$8 exp_icmp_chksum=$9 | |
5338 | shift; shift; shift; shift; shift; shift; shift | |
5339 | shift; shift | |
5340 | ||
5341 | # Use ttl to exercise section 4.2.2.9 of RFC1812 | |
5342 | local ip_ttl=01 | |
5343 | local icmp_id=5fbf | |
5344 | local icmp_seq=0001 | |
5345 | local icmp_data=$(seq 1 56 | xargs printf "%02x") | |
5346 | local icmp_type_code_request=0800 | |
5347 | local icmp_payload=${icmp_type_code_request}${icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
5348 | local packet=${eth_dst}${eth_src}08004500005400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${icmp_payload} | |
5349 | ||
5350 | as hv1 ovs-appctl netdev-dummy/receive vif$inport $packet | |
5351 | if test X$exp_icmp_chksum != X; then | |
5352 | # Expect to receive the reply, if any. In same port where packet was sent. | |
5353 | # Note: src and dst fields are expected to be reversed. | |
5354 | local icmp_type_code_response=0000 | |
5355 | local reply_icmp_ttl=fe | |
5356 | local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
5357 | local reply=${eth_src}${eth_dst}08004500005400004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload} | |
5358 | echo $reply >> vif$inport.expected | |
5359 | fi | |
5360 | } | |
5361 | ||
5362 | # Send ping packet to router's ip addresses, from each of the 2 logical ports. | |
5363 | rtr_l1_ip=$(ip_to_hex 192 168 1 1) | |
5364 | rtr_l2_ip=$(ip_to_hex 172 16 1 1) | |
5365 | l1_ip=$(ip_to_hex 192 168 1 2) | |
5366 | l2_ip=$(ip_to_hex 172 16 1 2) | |
5367 | ||
5368 | # Ping router ip address that is on same subnet as the logical port | |
5369 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
5370 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
5371 | ||
5372 | # Ping router ip address that is on the other side of the logical ports | |
5373 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
5374 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
5375 | ||
a64bb573 | 5376 | |
bb3c4568 FF |
5377 | echo "---------NB dump-----" |
5378 | ovn-nbctl show | |
5379 | echo "---------------------" | |
5380 | ovn-nbctl list logical_router | |
5381 | echo "---------------------" | |
5382 | ovn-nbctl list logical_router_port | |
5383 | echo "---------------------" | |
5384 | ||
5385 | echo "---------SB dump-----" | |
5386 | ovn-sbctl list datapath_binding | |
5387 | echo "---------------------" | |
5388 | ovn-sbctl list logical_flow | |
5389 | echo "---------------------" | |
5390 | ||
5391 | echo "------ hv1 dump ----------" | |
5392 | as hv1 ovs-ofctl dump-flows br-int | |
5393 | ||
5394 | # Now check the packets actually received against the ones expected. | |
5395 | for inport in 1 2; do | |
49d7c759 | 5396 | OVN_CHECK_PACKETS([hv1/vif${inport}-tx.pcap], [vif$inport.expected]) |
bb3c4568 FF |
5397 | done |
5398 | ||
7a8f15e0 | 5399 | OVN_CLEANUP([hv1]) |
a64bb573 MM |
5400 | AT_CLEANUP |
5401 | ||
5402 | AT_SETUP([ovn -- policy-based routing: 1 HVs, 2 LSs, 1 lport/LS, 1 LR]) | |
5403 | AT_KEYWORDS([policy-based-routing]) | |
5404 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5405 | ovn_start | |
5406 | ||
5407 | # Logical network: | |
5408 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
5409 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
5410 | ||
5411 | ovn-nbctl lr-add R1 | |
5412 | ||
5413 | ovn-nbctl ls-add ls1 | |
5414 | ovn-nbctl ls-add ls2 | |
5415 | ovn-nbctl ls-add ls3 | |
5416 | ||
5417 | # Connect ls1 to R1 | |
5418 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24 | |
5419 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \ | |
5420 | type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\" | |
5421 | ||
5422 | # Connect ls2 to R1 | |
5423 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24 | |
5424 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \ | |
5425 | type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\" | |
5426 | ||
5427 | # Connect ls3 to R1 | |
5428 | ovn-nbctl lrp-add R1 ls3 00:00:00:01:02:f3 20.20.1.1/24 | |
5429 | ovn-nbctl lsp-add ls3 rp-ls3 -- set Logical_Switch_Port rp-ls3 \ | |
5430 | type=router options:router-port=ls3 addresses=\"00:00:00:01:02:f3\" | |
5431 | ||
5432 | # Create logical port ls1-lp1 in ls1 | |
5433 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
5434 | -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2" | |
5435 | ||
5436 | # Create logical port ls2-lp1 in ls2 | |
5437 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
5438 | -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2" | |
5439 | ||
5440 | # Create logical port ls3-lp1 in ls3 | |
5441 | ovn-nbctl lsp-add ls3 ls3-lp1 \ | |
5442 | -- lsp-set-addresses ls3-lp1 "00:00:00:01:02:05 20.20.1.2" | |
5443 | ||
5444 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
5445 | net_add n1 | |
5446 | ||
5447 | sim_add pbr-hv | |
5448 | as pbr-hv | |
5449 | ovs-vsctl add-br br-phys | |
5450 | ovn_attach n1 br-phys 192.168.0.1 | |
5451 | ||
5452 | ovs-vsctl -- add-port br-int vif1 -- \ | |
5453 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
5454 | options:tx_pcap=pbr-hv/vif1-tx.pcap \ | |
5455 | options:rxq_pcap=pbr-hv/vif1-rx.pcap \ | |
5456 | ofport-request=1 | |
5457 | ||
5458 | ovs-vsctl -- add-port br-int vif2 -- \ | |
5459 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
5460 | options:tx_pcap=pbr-hv/vif2-tx.pcap \ | |
5461 | options:rxq_pcap=pbr-hv/vif2-rx.pcap \ | |
5462 | ofport-request=1 | |
5463 | ||
5464 | ovs-vsctl -- add-port br-int vif3 -- \ | |
5465 | set interface vif3 external-ids:iface-id=ls3-lp1 \ | |
5466 | options:tx_pcap=pbr-hv/vif3-tx.pcap \ | |
5467 | options:rxq_pcap=pbr-hv/vif3-rx.pcap \ | |
5468 | ofport-request=1 | |
5469 | ||
5470 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5471 | # XXX This should be more systematic. | |
5472 | sleep 1 | |
5473 | ||
5474 | ls1_ro_mac=00:00:00:01:02:f1 | |
5475 | ls1_ro_ip=192.168.1.1 | |
5476 | ||
5477 | ls2_ro_mac=00:00:00:01:02:f2 | |
5478 | ls2_ro_ip=172.16.1.1 | |
5479 | ||
5480 | ls3_ro_mac=00:00:00:01:02:f3 | |
5481 | ||
5482 | ls1_p1_mac=00:00:00:01:02:03 | |
5483 | ls1_p1_ip=192.168.1.2 | |
5484 | ||
5485 | ls2_p1_mac=00:00:00:01:02:04 | |
5486 | ls2_p1_ip=172.16.1.2 | |
5487 | ||
5488 | ls3_p1_mac=00:00:00:01:02:05 | |
5489 | ||
5490 | # Create a drop policy | |
5491 | ovn-nbctl lr-policy-add R1 10 "ip4.src==192.168.1.0/24 && ip4.dst==172.16.1.0/24" drop | |
5492 | ||
5493 | # Check logical flow | |
5494 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | grep "192.168.1.0" | wc -l], [0], [dnl | |
5495 | 1 | |
5496 | ]) | |
5497 | ||
5498 | # Send packet. | |
5499 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_p1_mac && eth.dst==$ls1_ro_mac && | |
5500 | ip4 && ip.ttl==64 && ip4.src==$ls1_p1_ip && ip4.dst==$ls2_p1_ip && | |
5501 | udp && udp.src==53 && udp.dst==4369" | |
5502 | ||
5503 | as pbr-hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
5504 | ||
5505 | # Check if packet hit the drop policy | |
5506 | AT_CHECK([ovs-ofctl dump-flows br-int | \ | |
5507 | grep "nw_src=192.168.1.0/24,nw_dst=172.16.1.0/24 actions=drop" | \ | |
5508 | grep "priority=10" | \ | |
5509 | grep "n_packets=1" | wc -l], [0], [dnl | |
5510 | 1 | |
5511 | ]) | |
5512 | ||
5513 | # Expected to drop the packet. | |
5514 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" pbr-hv/vif2-tx.pcap > vif2.packets | |
5515 | rcvd_packet=`cat vif2.packets` | |
5516 | AT_FAIL_IF([rcvd_packet = ""]) | |
5517 | ||
5518 | # Override drop policy with allow | |
5519 | ovn-nbctl lr-policy-add R1 20 "ip4.src==192.168.1.0/24 && ip4.dst==172.16.1.0/24" allow | |
5520 | ||
5521 | # Check logical flow | |
5522 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | grep "192.168.1.0" | wc -l], [0], [dnl | |
5523 | 2 | |
5524 | ]) | |
5525 | ||
5526 | # Send packet. | |
5527 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_p1_mac && eth.dst==$ls1_ro_mac && | |
5528 | ip4 && ip.ttl==64 && ip4.src==$ls1_p1_ip && ip4.dst==$ls2_p1_ip && | |
5529 | udp && udp.src==53 && udp.dst==4369" | |
5530 | as pbr-hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
5531 | ||
5532 | # Check if packet hit the allow policy | |
5533 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | \ | |
5534 | grep "192.168.1.0" | \ | |
5535 | grep "priority=20" | wc -l], [0], [dnl | |
5536 | 1 | |
5537 | ]) | |
5538 | ||
5539 | # Expected packet has TTL decreased by 1 | |
5540 | expected="eth.src==$ls2_ro_mac && eth.dst==$ls2_p1_mac && | |
5541 | ip4 && ip.ttl==63 && ip4.src==$ls1_p1_ip && ip4.dst==$ls2_p1_ip && | |
5542 | udp && udp.src==53 && udp.dst==4369" | |
5543 | echo $expected | ovstest test-ovn expr-to-packets > expected | |
5544 | ||
5545 | OVN_CHECK_PACKETS([pbr-hv/vif2-tx.pcap], [expected]) | |
5546 | ||
5547 | # Override allow policy with reroute | |
5548 | ovn-nbctl lr-policy-add R1 30 "ip4.src==192.168.1.0/24 && ip4.dst==172.16.1.0/24" reroute 20.20.1.2 | |
5549 | ||
5550 | # Check logical flow | |
5551 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | \ | |
5552 | grep "192.168.1.0" | \ | |
5553 | grep "priority=30" | wc -l], [0], [dnl | |
5554 | 1 | |
5555 | ]) | |
5556 | ||
5557 | # Send packet. | |
5558 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_p1_mac && eth.dst==$ls1_ro_mac && | |
5559 | ip4 && ip.ttl==64 && ip4.src==$ls1_p1_ip && ip4.dst==$ls2_p1_ip && | |
5560 | udp && udp.src==53 && udp.dst==4369" | |
5561 | as pbr-hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
5562 | ||
5563 | echo "southbound flows" | |
5564 | ||
5565 | ovn-sbctl dump-flows | grep lr_in_policy | |
5566 | echo "ovs flows" | |
5567 | ovs-ofctl dump-flows br-int | |
5568 | # Check if packet hit the allow policy | |
5569 | AT_CHECK([ovs-ofctl dump-flows br-int | \ | |
5570 | grep "nw_src=192.168.1.0/24,nw_dst=172.16.1.0/24" | \ | |
5571 | grep "priority=30" | \ | |
5572 | grep "n_packets=1" | wc -l], [0], [dnl | |
5573 | 1 | |
5574 | ]) | |
5575 | echo "packet hit reroute policy" | |
5576 | ||
5577 | # Expected packet has TTL decreased by 1 | |
5578 | expected="eth.src==$ls3_ro_mac && eth.dst==$ls3_p1_mac && | |
5579 | ip4 && ip.ttl==63 && ip4.src==$ls1_p1_ip && ip4.dst==$ls2_p1_ip && | |
5580 | udp && udp.src==53 && udp.dst==4369" | |
5581 | echo $expected | ovstest test-ovn expr-to-packets > 3.expected | |
5582 | ||
5583 | OVN_CHECK_PACKETS([pbr-hv/vif3-tx.pcap], [3.expected]) | |
5584 | ||
5585 | OVN_CLEANUP([pbr-hv]) | |
5586 | AT_CLEANUP | |
5587 | ||
5588 | AT_SETUP([ovn -- policy-based routing IPv6: 1 HVs, 3 LSs, 1 lport/LS, 1 LR]) | |
5589 | AT_KEYWORDS([policy-based-routing]) | |
5590 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5591 | ovn_start | |
5592 | ||
5593 | # Logical network: | |
5594 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
5595 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
5596 | ||
5597 | ovn-nbctl lr-add R1 | |
5598 | ||
5599 | ovn-nbctl ls-add ls1 | |
5600 | ovn-nbctl ls-add ls2 | |
5601 | ovn-nbctl ls-add ls3 | |
5602 | ||
5603 | # Connect ls1 to R1 | |
5604 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 2001::1/64 | |
5605 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \ | |
5606 | type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\" | |
5607 | ||
5608 | # Connect ls2 to R1 | |
5609 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 2002::1/64 | |
5610 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \ | |
5611 | type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\" | |
5612 | ||
5613 | # Connect ls3 to R1 | |
5614 | ovn-nbctl lrp-add R1 ls3 00:00:00:01:02:f3 2003::1/64 | |
5615 | ovn-nbctl lsp-add ls3 rp-ls3 -- set Logical_Switch_Port rp-ls3 \ | |
5616 | type=router options:router-port=ls3 addresses=\"00:00:00:01:02:f3\" | |
5617 | ||
5618 | # Create logical port ls1-lp1 in ls1 | |
5619 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
5620 | -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 2001::2" | |
5621 | ||
5622 | # Create logical port ls2-lp1 in ls2 | |
5623 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
5624 | -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 2002::2" | |
5625 | ||
5626 | # Create logical port ls3-lp1 in ls3 | |
5627 | ovn-nbctl lsp-add ls3 ls3-lp1 \ | |
5628 | -- lsp-set-addresses ls3-lp1 "00:00:00:01:02:05 2003::2" | |
5629 | ||
5630 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
5631 | net_add n1 | |
5632 | ||
5633 | sim_add pbr-hv | |
5634 | as pbr-hv | |
5635 | ovs-vsctl add-br br-phys | |
5636 | ovn_attach n1 br-phys 192.168.0.1 | |
5637 | ||
5638 | ovs-vsctl -- add-port br-int vif1 -- \ | |
5639 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
5640 | options:tx_pcap=pbr-hv/vif1-tx.pcap \ | |
5641 | options:rxq_pcap=pbr-hv/vif1-rx.pcap \ | |
5642 | ofport-request=1 | |
5643 | ||
5644 | ovs-vsctl -- add-port br-int vif2 -- \ | |
5645 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
5646 | options:tx_pcap=pbr-hv/vif2-tx.pcap \ | |
5647 | options:rxq_pcap=pbr-hv/vif2-rx.pcap \ | |
5648 | ofport-request=1 | |
5649 | ||
5650 | ovs-vsctl -- add-port br-int vif3 -- \ | |
5651 | set interface vif3 external-ids:iface-id=ls3-lp1 \ | |
5652 | options:tx_pcap=pbr-hv/vif3-tx.pcap \ | |
5653 | options:rxq_pcap=pbr-hv/vif3-rx.pcap \ | |
5654 | ofport-request=1 | |
5655 | ||
5656 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5657 | # XXX This should be more systematic. | |
5658 | sleep 1 | |
5659 | ||
5660 | ls1_ro_mac=00:00:00:01:02:f1 | |
5661 | ls1_ro_ip=2001::1 | |
5662 | ||
5663 | ls2_ro_mac=00:00:00:01:02:f2 | |
5664 | ls2_ro_ip=2002::1 | |
5665 | ||
5666 | ls3_ro_mac=00:00:00:01:02:f3 | |
5667 | ||
5668 | ls1_p1_mac=00:00:00:01:02:03 | |
5669 | ls1_p1_ip=2001::2 | |
5670 | ||
5671 | ls2_p1_mac=00:00:00:01:02:04 | |
5672 | ls2_p1_ip=2002::2 | |
5673 | ||
5674 | ls3_p1_mac=00:00:00:01:02:05 | |
5675 | ||
5676 | # Create a drop policy | |
5677 | ovn-nbctl lr-policy-add R1 10 "ip6.src==2001::/64 && ip6.dst==2002::/64" drop | |
5678 | ||
5679 | # Check logical flow | |
5680 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | grep "2001" | wc -l], [0], [dnl | |
5681 | 1 | |
5682 | ]) | |
5683 | ||
5684 | # Send packet. | |
5685 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_p1_mac && eth.dst==$ls1_ro_mac && | |
5686 | ip6 && ip.ttl==64 && ip6.src==$ls1_p1_ip && ip6.dst==$ls2_p1_ip && | |
5687 | udp && udp.src==53 && udp.dst==4369" | |
5688 | ||
5689 | as pbr-hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
5690 | ||
5691 | # Check if packet hit the drop policy | |
5692 | AT_CHECK([ovs-ofctl dump-flows br-int | \ | |
5693 | grep "ipv6_src=2001::/64,ipv6_dst=2002::/64 actions=drop" | \ | |
5694 | grep "priority=10" | \ | |
5695 | grep "n_packets=1" | wc -l], [0], [dnl | |
5696 | 1 | |
5697 | ]) | |
5698 | ||
5699 | # Expected to drop the packet. | |
5700 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" pbr-hv/vif2-tx.pcap > vif2.packets | |
5701 | rcvd_packet=`cat vif2.packets` | |
5702 | AT_FAIL_IF([rcvd_packet = ""]) | |
5703 | ||
5704 | # Override drop policy with allow | |
5705 | ovn-nbctl lr-policy-add R1 20 "ip6.src==2001::/64 && ip6.dst==2002::/64" allow | |
5706 | ||
5707 | # Check logical flow | |
5708 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | grep "2001" | wc -l], [0], [dnl | |
5709 | 2 | |
5710 | ]) | |
5711 | ||
5712 | # Send packet. | |
5713 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_p1_mac && eth.dst==$ls1_ro_mac && | |
5714 | ip6 && ip.ttl==64 && ip6.src==$ls1_p1_ip && ip6.dst==$ls2_p1_ip && | |
5715 | udp && udp.src==53 && udp.dst==4369" | |
5716 | as pbr-hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
5717 | ||
5718 | # Check if packet hit the allow policy | |
5719 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | \ | |
5720 | grep "2001" | \ | |
5721 | grep "priority=20" | wc -l], [0], [dnl | |
5722 | 1 | |
5723 | ]) | |
5724 | ||
5725 | # Expected packet has TTL decreased by 1 | |
5726 | expected="eth.src==$ls2_ro_mac && eth.dst==$ls2_p1_mac && | |
5727 | ip6 && ip.ttl==63 && ip6.src==$ls1_p1_ip && ip6.dst==$ls2_p1_ip && | |
5728 | udp && udp.src==53 && udp.dst==4369" | |
5729 | echo $expected | ovstest test-ovn expr-to-packets > expected | |
5730 | ||
5731 | OVN_CHECK_PACKETS([pbr-hv/vif2-tx.pcap], [expected]) | |
5732 | ||
5733 | # Override allow policy with reroute | |
5734 | ovn-nbctl lr-policy-add R1 30 "ip6.src==2001::/64 && ip6.dst==2002::/64" reroute 2003::2 | |
5735 | ||
5736 | # Check logical flow | |
5737 | AT_CHECK([ovn-sbctl dump-flows | grep lr_in_policy | \ | |
5738 | grep "2001" | \ | |
5739 | grep "priority=30" | wc -l], [0], [dnl | |
5740 | 1 | |
5741 | ]) | |
5742 | ||
5743 | # Send packet. | |
5744 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_p1_mac && eth.dst==$ls1_ro_mac && | |
5745 | ip6 && ip.ttl==64 && ip6.src==$ls1_p1_ip && ip6.dst==$ls2_p1_ip && | |
5746 | udp && udp.src==53 && udp.dst==4369" | |
5747 | as pbr-hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
5748 | ||
5749 | echo "southbound flows" | |
5750 | ||
5751 | ovn-sbctl dump-flows | grep lr_in_policy | |
5752 | echo "ovs flows" | |
5753 | ovs-ofctl dump-flows br-int | |
5754 | # Check if packet hit the allow policy | |
5755 | AT_CHECK([ovs-ofctl dump-flows br-int | \ | |
5756 | grep "ipv6_src=2001::/64,ipv6_dst=2002::/64" | \ | |
5757 | grep "priority=30" | \ | |
5758 | grep "n_packets=1" | wc -l], [0], [dnl | |
5759 | 1 | |
5760 | ]) | |
5761 | echo "packet hit reroute policy" | |
5762 | ||
5763 | # Expected packet has TTL decreased by 1 | |
5764 | expected="eth.src==$ls3_ro_mac && eth.dst==$ls3_p1_mac && | |
5765 | ip6 && ip.ttl==63 && ip6.src==$ls1_p1_ip && ip6.dst==$ls2_p1_ip && | |
5766 | udp && udp.src==53 && udp.dst==4369" | |
5767 | echo $expected | ovstest test-ovn expr-to-packets > 3.expected | |
5768 | ||
5769 | OVN_CHECK_PACKETS([pbr-hv/vif3-tx.pcap], [3.expected]) | |
bb3c4568 | 5770 | |
a64bb573 | 5771 | OVN_CLEANUP([pbr-hv]) |
bb3c4568 | 5772 | AT_CLEANUP |
94f79fcb RB |
5773 | |
5774 | # 1 hypervisor, 1 port | |
5775 | # make sure that the port state is properly set to up and back down | |
5776 | # when created and deleted. | |
5777 | AT_SETUP([ovn -- port state up and down]) | |
94f79fcb RB |
5778 | ovn_start |
5779 | ||
5780 | ovn-nbctl ls-add ls1 | |
5781 | ovn-nbctl lsp-add ls1 lp1 | |
5782 | ovn-nbctl lsp-set-addresses lp1 unknown | |
5783 | ||
5784 | net_add n1 | |
5785 | sim_add hv1 | |
5786 | as hv1 ovs-vsctl add-br br-phys | |
5787 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
5788 | ||
5789 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
5790 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
5791 | ||
5792 | as hv1 ovs-vsctl del-port br-int vif1 | |
5793 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
5794 | ||
7a8f15e0 | 5795 | OVN_CLEANUP([hv1]) |
94f79fcb | 5796 | |
94f79fcb | 5797 | AT_CLEANUP |
e75451fe | 5798 | |
ccc6e1db FF |
5799 | # 1 hypervisor, 1 port |
5800 | # make sure that the OF rules created to support a datapath are added/cleared | |
5801 | # when logical switch is created and removed. | |
5802 | AT_SETUP([ovn -- datapath rules added/removed]) | |
1794d5f2 | 5803 | AT_KEYWORDS([cleanup]) |
ccc6e1db FF |
5804 | ovn_start |
5805 | ||
5806 | net_add n1 | |
5807 | sim_add hv1 | |
5808 | as hv1 ovs-vsctl add-br br-phys | |
5809 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
5810 | ||
5811 | # This shell function checks if OF rules in br-int have clauses | |
5812 | # related to OVN datapaths. The caller determines if it should find | |
5813 | # a match in the output, or not. | |
5814 | # | |
5815 | # EXPECT_DATAPATH param determines whether flows that refer to | |
5816 | # datapath to should be present or not. 0 means | |
5817 | # they should not be. | |
5818 | # STAGE_INFO param is a simple string to help identify the stage | |
5819 | # in the test when this function was invoked. | |
5820 | test_datapath_in_of_rules() { | |
5821 | local expect_datapath=$1 stage_info=$2 | |
5822 | echo "------ ovn-nbctl show ${stage_info} ------" | |
5823 | ovn-nbctl show | |
5824 | echo "------ ovn-sbctl show ${stage_info} ------" | |
5825 | ovn-sbctl show | |
5826 | echo "------ OF rules ${stage_info} ------" | |
5827 | AT_CHECK([ovs-ofctl dump-flows br-int], [0], [stdout]) | |
5828 | # if there is a datapath mentioned in the output, check for the | |
5829 | # magic keyword that represents one, based on the exit status of | |
5830 | # a quiet grep | |
5831 | if test $expect_datapath != 0; then | |
4618b102 | 5832 | AT_CHECK([grep -q -i 'metadata=' stdout], [0], [ignore-nolog]) |
ccc6e1db | 5833 | else |
4618b102 | 5834 | AT_CHECK([grep -q -i 'metadata=' stdout], [1], [ignore-nolog]) |
ccc6e1db FF |
5835 | fi |
5836 | } | |
5837 | ||
5838 | test_datapath_in_of_rules 0 "before ls+port create" | |
5839 | ||
5840 | ovn-nbctl ls-add ls1 | |
5841 | ovn-nbctl lsp-add ls1 lp1 | |
5842 | ovn-nbctl lsp-set-addresses lp1 unknown | |
5843 | ||
5844 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
5845 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
5846 | ||
5847 | test_datapath_in_of_rules 1 "after port is bound" | |
5848 | ||
5849 | as hv1 ovs-vsctl del-port br-int vif1 | |
5850 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
5851 | ||
5852 | ovn-nbctl lsp-set-addresses lp1 | |
5853 | ovn-nbctl lsp-del lp1 | |
5854 | ovn-nbctl ls-del ls1 | |
5855 | ||
5856 | # wait for earlier changes to take effect | |
5857 | AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) | |
5858 | ||
5859 | # ensure OF rules are no longer present. There used to be a bug here. | |
5860 | test_datapath_in_of_rules 0 "after lport+ls removal" | |
5861 | ||
5862 | OVN_CLEANUP([hv1]) | |
5863 | ||
5864 | AT_CLEANUP | |
5865 | ||
f8a8db39 | 5866 | AT_SETUP([ovn -- nd_na ]) |
e75451fe ZKL |
5867 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5868 | ovn_start | |
5869 | ||
5870 | #TODO: since patch port for IPv6 logical router port is not ready not, | |
5871 | # so we are not going to test vifs on different lswitches cases. Try | |
5872 | # to update for that once relevant stuff implemented. | |
5873 | ||
5874 | # In this test cases we create 1 lswitch, it has 2 VIF ports attached | |
5875 | # with. NS packet we test, from one VIF for another VIF, will be replied | |
5876 | # by local ovn-controller, but not by target VIF. | |
5877 | ||
5878 | # Create hypervisors and logical switch lsw0. | |
5879 | ovn-nbctl ls-add lsw0 | |
5880 | net_add n1 | |
5881 | sim_add hv1 | |
5882 | as hv1 | |
5883 | ovs-vsctl add-br br-phys | |
5884 | ovn_attach n1 br-phys 192.168.0.2 | |
5885 | ||
5886 | # Add vif1 to hv1 and lsw0, turn on l2 port security on vif1. | |
5887 | 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 | |
5888 | ovn-nbctl lsp-add lsw0 lp1 | |
5889 | ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598" | |
5890 | 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" | |
5891 | ||
5892 | # Add vif2 to hv1 and lsw0, turn on l2 port security on vif2. | |
5893 | 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 | |
5894 | ovn-nbctl lsp-add lsw0 lp2 | |
5895 | ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae" | |
5896 | 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" | |
5897 | ||
5898 | # Add ACL rule for ICMPv6 on lsw0 | |
5899 | ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related | |
5900 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related | |
5901 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related | |
5902 | ||
5903 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5904 | # XXX This should be more systematic. | |
5905 | sleep 1 | |
5906 | ||
5907 | # Given the name of a logical port, prints the name of the hypervisor | |
5908 | # on which it is located. | |
5909 | vif_to_hv() { | |
5910 | echo hv1${1%?} | |
5911 | } | |
e75451fe ZKL |
5912 | for i in 1 2; do |
5913 | : > $i.expected | |
5914 | done | |
5915 | ||
5916 | # Complete Neighbor Solicitation packet and Neighbor Advertisement packet | |
5917 | # vif1 -> NS -> vif2. vif1 <- NA <- ovn-controller. | |
5918 | # vif2 will not receive NS packet, since ovn-controller will reply for it. | |
5919 | ns_packet=3333ffa1f9aefa163e94059886dd6000000000203afffd81ce49a9480000f8163efffe940598fd81ce49a9480000f8163efffea1f9ae8700e01160000000fd81ce49a9480000f8163efffea1f9ae0101fa163e940598 | |
5920 | na_packet=fa163e940598fa163ea1f9ae86dd6000000000203afffd81ce49a9480000f8163efffea1f9aefd81ce49a9480000f8163efffe9405988800e9ed60000000fd81ce49a9480000f8163efffea1f9ae0201fa163ea1f9ae | |
5921 | ||
5922 | as hv1 ovs-appctl netdev-dummy/receive vif1 $ns_packet | |
e4543cfe | 5923 | echo $na_packet >> 1.expected |
e75451fe | 5924 | |
e75451fe ZKL |
5925 | echo "------ hv1 dump ------" |
5926 | as hv1 ovs-vsctl show | |
5927 | as hv1 ovs-ofctl -O OpenFlow13 show br-int | |
5928 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
5929 | ||
5930 | for i in 1 2; do | |
49d7c759 | 5931 | OVN_CHECK_PACKETS([hv1/vif$i-tx.pcap], [$i.expected]) |
e75451fe ZKL |
5932 | done |
5933 | ||
7a8f15e0 | 5934 | OVN_CLEANUP([hv1]) |
e75451fe ZKL |
5935 | |
5936 | AT_CLEANUP | |
7417d147 RM |
5937 | |
5938 | AT_SETUP([ovn -- address sets modification/removal smoke test]) | |
7417d147 RM |
5939 | ovn_start |
5940 | ||
5941 | net_add n1 | |
5942 | ||
5943 | sim_add hv1 | |
5944 | as hv1 | |
5945 | ovs-vsctl add-br br-phys | |
5946 | ovn_attach n1 br-phys 192.168.0.1 | |
5947 | ||
5948 | row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"` | |
5949 | ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\" | |
5950 | ovn-nbctl destroy Address_Set $row | |
5951 | ||
5952 | sleep 1 | |
5953 | ||
5954 | # A bug previously existed in the address set support code | |
5955 | # that caused ovn-controller to crash after an address set | |
5956 | # was updated and then removed. This test case ensures | |
5957 | # that ovn-controller is at least still running after | |
5958 | # creating, updating, and deleting an address set. | |
5959 | AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore]) | |
5960 | ||
5961 | OVN_CLEANUP([hv1]) | |
5962 | ||
5963 | AT_CLEANUP | |
8639f9be ND |
5964 | |
5965 | AT_SETUP([ovn -- ipam]) | |
8639f9be ND |
5966 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5967 | ovn_start | |
5968 | ||
5969 | # Add a port to a switch that does not have a subnet set, then set the | |
5970 | # subnet which should result in an address being allocated for the port. | |
f1301a25 | 5971 | ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="0a:00:00:00:00:00" |
8639f9be ND |
5972 | ovn-nbctl ls-add sw0 |
5973 | ovn-nbctl lsp-add sw0 p0 -- lsp-set-addresses p0 dynamic | |
fd3b31e9 | 5974 | ovn-nbctl --wait=sb add Logical-Switch sw0 other_config subnet=192.168.1.0/24 |
8639f9be | 5975 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0], |
c814545b | 5976 | ["0a:00:00:a8:01:03 192.168.1.2" |
8639f9be ND |
5977 | ]) |
5978 | ||
5979 | # Add 9 more ports to sw0, addresses should all be unique. | |
5980 | for n in `seq 1 9`; do | |
11547f85 | 5981 | ovn-nbctl --wait=sb lsp-add sw0 "p$n" -- lsp-set-addresses "p$n" dynamic |
8639f9be ND |
5982 | done |
5983 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p1 dynamic_addresses], [0], | |
c814545b | 5984 | ["0a:00:00:a8:01:04 192.168.1.3" |
8639f9be ND |
5985 | ]) |
5986 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p2 dynamic_addresses], [0], | |
c814545b | 5987 | ["0a:00:00:a8:01:05 192.168.1.4" |
8639f9be ND |
5988 | ]) |
5989 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p3 dynamic_addresses], [0], | |
c814545b | 5990 | ["0a:00:00:a8:01:06 192.168.1.5" |
8639f9be ND |
5991 | ]) |
5992 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p4 dynamic_addresses], [0], | |
c814545b | 5993 | ["0a:00:00:a8:01:07 192.168.1.6" |
8639f9be ND |
5994 | ]) |
5995 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p5 dynamic_addresses], [0], | |
c814545b | 5996 | ["0a:00:00:a8:01:08 192.168.1.7" |
8639f9be ND |
5997 | ]) |
5998 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p6 dynamic_addresses], [0], | |
c814545b | 5999 | ["0a:00:00:a8:01:09 192.168.1.8" |
8639f9be ND |
6000 | ]) |
6001 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p7 dynamic_addresses], [0], | |
c814545b | 6002 | ["0a:00:00:a8:01:0a 192.168.1.9" |
8639f9be ND |
6003 | ]) |
6004 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p8 dynamic_addresses], [0], | |
c814545b | 6005 | ["0a:00:00:a8:01:0b 192.168.1.10" |
8639f9be ND |
6006 | ]) |
6007 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p9 dynamic_addresses], [0], | |
c814545b | 6008 | ["0a:00:00:a8:01:0c 192.168.1.11" |
8639f9be ND |
6009 | ]) |
6010 | ||
6011 | # Trying similar tests with a second switch. MAC addresses should be unique | |
6012 | # across both switches but IP's only need to be unique within the same switch. | |
6013 | ovn-nbctl ls-add sw1 | |
6014 | ovn-nbctl lsp-add sw1 p10 -- lsp-set-addresses p10 dynamic | |
11547f85 | 6015 | ovn-nbctl --wait=sb add Logical-Switch sw1 other_config subnet=192.168.1.0/24 |
8639f9be | 6016 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p10 dynamic_addresses], [0], |
c814545b | 6017 | ["0a:00:00:a8:01:0d 192.168.1.2" |
8639f9be ND |
6018 | ]) |
6019 | ||
6020 | for n in `seq 11 19`; do | |
11547f85 | 6021 | ovn-nbctl --wait=sb lsp-add sw1 "p$n" -- lsp-set-addresses "p$n" dynamic |
8639f9be ND |
6022 | done |
6023 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p11 dynamic_addresses], [0], | |
c814545b | 6024 | ["0a:00:00:a8:01:0e 192.168.1.3" |
8639f9be ND |
6025 | ]) |
6026 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p12 dynamic_addresses], [0], | |
c814545b | 6027 | ["0a:00:00:a8:01:0f 192.168.1.4" |
8639f9be ND |
6028 | ]) |
6029 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p13 dynamic_addresses], [0], | |
c814545b | 6030 | ["0a:00:00:a8:01:10 192.168.1.5" |
8639f9be ND |
6031 | ]) |
6032 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p14 dynamic_addresses], [0], | |
c814545b | 6033 | ["0a:00:00:a8:01:11 192.168.1.6" |
8639f9be ND |
6034 | ]) |
6035 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p15 dynamic_addresses], [0], | |
c814545b | 6036 | ["0a:00:00:a8:01:12 192.168.1.7" |
8639f9be ND |
6037 | ]) |
6038 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p16 dynamic_addresses], [0], | |
c814545b | 6039 | ["0a:00:00:a8:01:13 192.168.1.8" |
8639f9be ND |
6040 | ]) |
6041 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p17 dynamic_addresses], [0], | |
c814545b | 6042 | ["0a:00:00:a8:01:14 192.168.1.9" |
8639f9be ND |
6043 | ]) |
6044 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p18 dynamic_addresses], [0], | |
c814545b | 6045 | ["0a:00:00:a8:01:15 192.168.1.10" |
8639f9be ND |
6046 | ]) |
6047 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p19 dynamic_addresses], [0], | |
c814545b | 6048 | ["0a:00:00:a8:01:16 192.168.1.11" |
8639f9be ND |
6049 | ]) |
6050 | ||
6051 | # Change a port's address to test for multiple ip's for a single address entry | |
6052 | # and addresses set by the user. | |
c814545b | 6053 | ovn-nbctl lsp-set-addresses p0 "0a:00:00:a8:01:17 192.168.1.2 192.168.1.12 192.168.1.14" |
11547f85 | 6054 | ovn-nbctl --wait=sb lsp-add sw0 p20 -- lsp-set-addresses p20 dynamic |
8639f9be | 6055 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p20 dynamic_addresses], [0], |
c814545b | 6056 | ["0a:00:00:a8:01:18 192.168.1.13" |
8639f9be ND |
6057 | ]) |
6058 | ||
6059 | # Test for logical router port address management. | |
6060 | ovn-nbctl create Logical_Router name=R1 | |
6061 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw0 \ | |
c814545b | 6062 | network="192.168.1.1/24" mac=\"0a:00:00:a8:01:19\" \ |
8639f9be ND |
6063 | -- add Logical_Router R1 ports @lrp -- lsp-add sw0 rp-sw0 \ |
6064 | -- set Logical_Switch_Port rp-sw0 type=router options:router-port=sw0 | |
11547f85 | 6065 | ovn-nbctl --wait=sb lsp-add sw0 p21 -- lsp-set-addresses p21 dynamic |
8639f9be | 6066 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p21 dynamic_addresses], [0], |
c814545b | 6067 | ["0a:00:00:a8:01:1a 192.168.1.15" |
8639f9be ND |
6068 | ]) |
6069 | ||
6070 | # Test for address reuse after logical port is deleted. | |
6071 | ovn-nbctl lsp-del p0 | |
11547f85 | 6072 | ovn-nbctl --wait=sb lsp-add sw0 p23 -- lsp-set-addresses p23 dynamic |
8639f9be | 6073 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p23 dynamic_addresses], [0], |
c814545b | 6074 | ["0a:00:00:a8:01:03 192.168.1.2" |
8639f9be ND |
6075 | ]) |
6076 | ||
6077 | # Test for multiple addresses to one logical port. | |
6078 | ovn-nbctl lsp-add sw0 p25 -- lsp-set-addresses p25 \ | |
c814545b | 6079 | "0a:00:00:a8:01:1b 192.168.1.12" "0a:00:00:a8:01:1c 192.168.1.14" |
11547f85 | 6080 | ovn-nbctl --wait=sb lsp-add sw0 p26 -- lsp-set-addresses p26 dynamic |
8639f9be | 6081 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p26 dynamic_addresses], [0], |
c814545b | 6082 | ["0a:00:00:a8:01:17 192.168.1.16" |
8639f9be ND |
6083 | ]) |
6084 | ||
6085 | # Test for exhausting subnet address space. | |
6086 | ovn-nbctl ls-add sw2 -- add Logical-Switch sw2 other_config subnet=172.16.1.0/30 | |
11547f85 | 6087 | ovn-nbctl --wait=sb lsp-add sw2 p27 -- lsp-set-addresses p27 dynamic |
8639f9be | 6088 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p27 dynamic_addresses], [0], |
c814545b | 6089 | ["0a:00:00:10:01:03 172.16.1.2" |
8639f9be ND |
6090 | ]) |
6091 | ||
11547f85 | 6092 | ovn-nbctl --wait=sb lsp-add sw2 p28 -- lsp-set-addresses p28 dynamic |
8639f9be | 6093 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p28 dynamic_addresses], [0], |
c814545b | 6094 | ["0a:00:00:00:00:01" |
8639f9be ND |
6095 | ]) |
6096 | ||
6097 | # Test that address management does not add duplicate MAC for lsp/lrp peers. | |
6098 | ovn-nbctl create Logical_Router name=R2 | |
6099 | ovn-nbctl ls-add sw3 | |
6100 | ovn-nbctl lsp-add sw3 p29 -- lsp-set-addresses p29 \ | |
c814545b | 6101 | "0a:00:00:a8:01:18" |
8639f9be | 6102 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw3 \ |
c814545b | 6103 | network="192.168.2.1/24" mac=\"0a:00:00:a8:01:18\" \ |
8639f9be ND |
6104 | -- add Logical_Router R2 ports @lrp -- lsp-add sw3 rp-sw3 \ |
6105 | -- set Logical_Switch_Port rp-sw3 type=router options:router-port=sw3 | |
11547f85 | 6106 | ovn-nbctl --wait=sb lsp-add sw0 p30 -- lsp-set-addresses p30 dynamic |
8639f9be | 6107 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p30 dynamic_addresses], [0], |
c814545b | 6108 | ["0a:00:00:a8:01:1d 192.168.1.17" |
8639f9be ND |
6109 | ]) |
6110 | ||
6374d518 LR |
6111 | # Test static MAC address with dynamically allocated IP |
6112 | ovn-nbctl --wait=sb lsp-add sw0 p31 -- lsp-set-addresses p31 \ | |
6113 | "fe:dc:ba:98:76:54 dynamic" | |
6114 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
6115 | ["fe:dc:ba:98:76:54 192.168.1.18" | |
6116 | ]) | |
6117 | ||
6c4f7a8a NS |
6118 | # Update the static MAC address with dynamically allocated IP and check |
6119 | # if the MAC address is updated in 'Logical_Switch_Port.dynamic_adddresses' | |
6120 | ovn-nbctl --wait=sb lsp-set-addresses p31 "fe:dc:ba:98:76:55 dynamic" | |
6c4f7a8a NS |
6121 | |
6122 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
6123 | ["fe:dc:ba:98:76:55 192.168.1.18" | |
6124 | ]) | |
6125 | ||
6126 | ovn-nbctl --wait=sb lsp-set-addresses p31 "dynamic" | |
6127 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
c814545b | 6128 | ["0a:00:00:a8:01:1e 192.168.1.18" |
6c4f7a8a NS |
6129 | ]) |
6130 | ||
6131 | ovn-nbctl --wait=sb lsp-set-addresses p31 "fe:dc:ba:98:76:56 dynamic" | |
6132 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
6133 | ["fe:dc:ba:98:76:56 192.168.1.18" | |
6134 | ]) | |
6135 | ||
161ea2c8 NS |
6136 | |
6137 | # Test the exclude_ips from the IPAM list | |
6138 | ovn-nbctl --wait=sb set logical_switch sw0 \ | |
6139 | other_config:exclude_ips="192.168.1.19 192.168.1.21 192.168.1.23..192.168.1.50" | |
6140 | ||
6141 | ovn-nbctl --wait=sb lsp-add sw0 p32 -- lsp-set-addresses p32 \ | |
6142 | "dynamic" | |
6143 | # 192.168.1.20 should be assigned as 192.168.1.19 is excluded. | |
6144 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p32 dynamic_addresses], [0], | |
c814545b | 6145 | ["0a:00:00:a8:01:1e 192.168.1.20" |
161ea2c8 NS |
6146 | ]) |
6147 | ||
6148 | ovn-nbctl --wait=sb lsp-add sw0 p33 -- lsp-set-addresses p33 \ | |
6149 | "dynamic" | |
6150 | # 192.168.1.22 should be assigned as 192.168.1.21 is excluded. | |
6151 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p33 dynamic_addresses], [0], | |
c814545b | 6152 | ["0a:00:00:a8:01:1f 192.168.1.22" |
161ea2c8 NS |
6153 | ]) |
6154 | ||
6155 | ovn-nbctl --wait=sb lsp-add sw0 p34 -- lsp-set-addresses p34 \ | |
6156 | "dynamic" | |
6157 | # 192.168.1.51 should be assigned as 192.168.1.23-192.168.1.50 is excluded. | |
6158 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p34 dynamic_addresses], [0], | |
c814545b | 6159 | ["0a:00:00:a8:01:34 192.168.1.51" |
161ea2c8 NS |
6160 | ]) |
6161 | ||
6162 | # Now clear the exclude_ips list. 192.168.1.19 should be assigned. | |
6163 | ovn-nbctl --wait=sb set Logical-switch sw0 other_config:exclude_ips="invalid" | |
6164 | ovn-nbctl --wait=sb lsp-add sw0 p35 -- lsp-set-addresses p35 \ | |
6165 | "dynamic" | |
6166 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p35 dynamic_addresses], [0], | |
c814545b | 6167 | ["0a:00:00:a8:01:20 192.168.1.19" |
161ea2c8 NS |
6168 | ]) |
6169 | ||
6170 | # Set invalid data in exclude_ips list. It should be ignored. | |
6171 | ovn-nbctl --wait=sb set Logical-switch sw0 other_config:exclude_ips="182.168.1.30" | |
6172 | ovn-nbctl --wait=sb lsp-add sw0 p36 -- lsp-set-addresses p36 \ | |
6173 | "dynamic" | |
6174 | # 192.168.1.21 should be assigned as that's the next free one. | |
6175 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p36 dynamic_addresses], [0], | |
c814545b | 6176 | ["0a:00:00:a8:01:21 192.168.1.21" |
161ea2c8 NS |
6177 | ]) |
6178 | ||
6179 | # Clear the dynamic addresses assignment request. | |
6180 | ovn-nbctl --wait=sb clear logical_switch_port p36 addresses | |
6181 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p36 dynamic_addresses], [0], | |
6182 | [[[]] | |
6183 | ]) | |
6184 | ||
7cc0741e NS |
6185 | # Set IPv6 prefix |
6186 | ovn-nbctl --wait=sb set Logical-switch sw0 other_config:ipv6_prefix="aef0::" | |
6187 | ovn-nbctl --wait=sb lsp-add sw0 p37 -- lsp-set-addresses p37 \ | |
6188 | "dynamic" | |
6189 | ||
6190 | # With prefix aef0 and mac 0a:00:00:00:00:26, the dynamic IPv6 should be | |
6191 | # - aef0::800:ff:fe00:26 (EUI64) | |
6192 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p37 dynamic_addresses], [0], | |
c814545b | 6193 | ["0a:00:00:a8:01:21 192.168.1.21 aef0::800:ff:fea8:121" |
7cc0741e NS |
6194 | ]) |
6195 | ||
6196 | ovn-nbctl --wait=sb ls-add sw4 | |
451624fe MM |
6197 | ovn-nbctl --wait=sb set Logical-switch sw4 other_config:ipv6_prefix="bef0::" \ |
6198 | -- set Logical-switch sw4 other_config:subnet=192.168.2.0/30 | |
7cc0741e NS |
6199 | ovn-nbctl --wait=sb lsp-add sw4 p38 -- lsp-set-addresses p38 \ |
6200 | "dynamic" | |
6201 | ||
6202 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p38 dynamic_addresses], [0], | |
c814545b | 6203 | ["0a:00:00:a8:02:03 192.168.2.2 bef0::800:ff:fea8:203" |
7cc0741e NS |
6204 | ]) |
6205 | ||
6206 | ovn-nbctl --wait=sb lsp-add sw4 p39 -- lsp-set-addresses p39 \ | |
6207 | "f0:00:00:00:10:12 dynamic" | |
6208 | ||
6209 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p39 dynamic_addresses], [0], | |
6210 | ["f0:00:00:00:10:12 bef0::f200:ff:fe00:1012" | |
6211 | ]) | |
6212 | ||
451624fe MM |
6213 | # Test the case where IPv4 addresses are exhausted and IPv6 prefix is set |
6214 | # p40 should not have an IPv4 address since the pool is exhausted | |
7cc0741e NS |
6215 | ovn-nbctl --wait=sb lsp-add sw4 p40 -- lsp-set-addresses p40 \ |
6216 | "dynamic" | |
7cc0741e | 6217 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p40 dynamic_addresses], [0], |
c814545b | 6218 | ["0a:00:00:00:00:02 bef0::800:ff:fe00:2" |
451624fe MM |
6219 | ]) |
6220 | ||
6221 | # Test dynamic changes on switch ports. | |
6222 | # | |
6223 | ovn-nbctl --wait=sb ls-add sw5 | |
6224 | ovn-nbctl --wait=sb lsp-add sw5 p41 -- lsp-set-addresses p41 \ | |
6225 | "dynamic" | |
6226 | # p41 will start with nothing | |
6227 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
7cc0741e NS |
6228 | [[[]] |
6229 | ]) | |
6230 | ||
451624fe MM |
6231 | # Set a subnet. Now p41 should have an ipv4 address, too |
6232 | ovn-nbctl --wait=sb add Logical-Switch sw5 other_config subnet=192.168.1.0/24 | |
6233 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
c814545b | 6234 | ["0a:00:00:a8:01:22 192.168.1.2" |
451624fe | 6235 | ]) |
7cc0741e | 6236 | |
451624fe MM |
6237 | # Clear the other_config. The IPv4 address should be gone |
6238 | ovn-nbctl --wait=sb clear Logical-Switch sw5 other_config | |
6239 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
6240 | [[[]] | |
7cc0741e NS |
6241 | ]) |
6242 | ||
451624fe MM |
6243 | # Set an IPv6 prefix. Now p41 should have an IPv6 address. |
6244 | ovn-nbctl --wait=sb set Logical-Switch sw5 other_config:ipv6_prefix="aef0::" | |
7cc0741e | 6245 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], |
c814545b | 6246 | ["0a:00:00:00:00:03 aef0::800:ff:fe00:3" |
451624fe MM |
6247 | ]) |
6248 | ||
6249 | # Change the MAC address to a static one. The IPv6 address should update. | |
6250 | ovn-nbctl --wait=sb lsp-set-addresses p41 "f0:00:00:00:10:2b dynamic" | |
6251 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
6252 | ["f0:00:00:00:10:2b aef0::f200:ff:fe00:102b" | |
6253 | ]) | |
6254 | ||
6255 | # Change the IPv6 prefix. The IPv6 address should update. | |
6256 | ovn-nbctl --wait=sb set Logical-Switch sw5 other_config:ipv6_prefix="bef0::" | |
6257 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
6258 | ["f0:00:00:00:10:2b bef0::f200:ff:fe00:102b" | |
6259 | ]) | |
6260 | ||
6261 | # Clear the other_config. The IPv6 address should be gone | |
6262 | ovn-nbctl --wait=sb clear Logical-Switch sw5 other_config | |
6263 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
6264 | [[[]] | |
6265 | ]) | |
6266 | ||
6267 | # Set the subnet again. Now p41 should get the IPv4 address again. | |
6268 | ovn-nbctl --wait=sb add Logical-Switch sw5 other_config subnet=192.168.1.0/24 | |
6269 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
6270 | ["f0:00:00:00:10:2b 192.168.1.2" | |
6271 | ]) | |
6272 | ||
451624fe MM |
6273 | # Add an excluded IP address that conflicts with p41. p41 should update. |
6274 | ovn-nbctl --wait=sb add Logical-Switch sw5 other_config \ | |
863fb61f | 6275 | exclude_ips="192.168.1.2" |
451624fe | 6276 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], |
863fb61f | 6277 | ["f0:00:00:00:10:2b 192.168.1.3" |
7cc0741e NS |
6278 | ]) |
6279 | ||
e46b7020 LB |
6280 | # Add static ip address |
6281 | ovn-nbctl --wait=sb lsp-set-addresses p41 "dynamic 192.168.1.100" | |
6282 | ovn-nbctl list Logical-Switch-Port p41 | |
6283 | ovn-nbctl --wait=sb lsp-add sw5 p42 -- lsp-set-addresses p42 \ | |
6284 | "dynamic 192.168.1.101" | |
6285 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
6286 | ["0a:00:00:a8:01:65 192.168.1.100" | |
6287 | ]) | |
6288 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p42 dynamic_addresses], [0], | |
6289 | ["0a:00:00:a8:01:66 192.168.1.101" | |
6290 | ]) | |
6291 | ||
282e5357 LB |
6292 | # define a mac address prefix |
6293 | ovn-nbctl ls-add sw6 | |
6294 | ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="00:11:22:33:44:55" | |
6295 | ovn-nbctl --wait=sb set Logical-Switch sw6 other_config:subnet=192.168.100.0/24 | |
6296 | for n in $(seq 1 3); do | |
6297 | ovn-nbctl --wait=sb lsp-add sw6 "p5$n" -- lsp-set-addresses "p5$n" dynamic | |
6298 | done | |
6299 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p51 dynamic_addresses], [0], | |
c814545b | 6300 | ["00:11:22:a8:64:03 192.168.100.2" |
282e5357 LB |
6301 | ]) |
6302 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p52 dynamic_addresses], [0], | |
c814545b | 6303 | ["00:11:22:a8:64:04 192.168.100.3" |
282e5357 LB |
6304 | ]) |
6305 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p53 dynamic_addresses], [0], | |
c814545b | 6306 | ["00:11:22:a8:64:05 192.168.100.4" |
282e5357 LB |
6307 | ]) |
6308 | ||
04438dbf LB |
6309 | # verify configuration order does not break IPAM/MACAM |
6310 | ovn-nbctl ls-add sw7 | |
6311 | for n in $(seq 1 3); do | |
6312 | ovn-nbctl --wait=sb lsp-add sw7 "p7$n" -- lsp-set-addresses "p7$n" dynamic | |
6313 | done | |
6314 | ovn-nbctl --wait=sb set Logical-Switch sw7 other_config:ipv6_prefix="bef0::" | |
6315 | p71_addr=$(ovn-nbctl get Logical-Switch-Port p71 dynamic_addresses) | |
6316 | p72_addr=$(ovn-nbctl get Logical-Switch-Port p72 dynamic_addresses) | |
6317 | p73_addr=$(ovn-nbctl get Logical-Switch-Port p73 dynamic_addresses) | |
6318 | AT_CHECK([test "$p71_addr" != "$p72_addr"], [0], []) | |
6319 | AT_CHECK([test "$p71_addr" != "$p73_addr"], [0], []) | |
6320 | AT_CHECK([test "$p72_addr" != "$p73_addr"], [0], []) | |
6321 | ||
10b9890f LB |
6322 | # request to assign mac only |
6323 | # | |
6324 | ovn-nbctl ls-add sw8 | |
6325 | ovn-nbctl --wait=sb set Logical-Switch sw8 other_config:mac_only=true | |
6326 | for n in $(seq 1 3); do | |
6327 | ovn-nbctl --wait=sb lsp-add sw8 "p8$n" -- lsp-set-addresses "p8$n" dynamic | |
6328 | done | |
6329 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p81 dynamic_addresses], [0], | |
6330 | ["00:11:22:00:00:06" | |
6331 | ]) | |
6332 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p82 dynamic_addresses], [0], | |
6333 | ["00:11:22:00:00:07" | |
6334 | ]) | |
6335 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p83 dynamic_addresses], [0], | |
6336 | ["00:11:22:00:00:08" | |
6337 | ]) | |
6338 | ||
f1301a25 LB |
6339 | # clear mac_prefix and check it is allocated in a random manner |
6340 | ovn-nbctl --wait=hv remove NB_Global . options mac_prefix | |
6341 | ovn-nbctl ls-add sw9 | |
6342 | ovn-nbctl --wait=sb set Logical-Switch sw9 other_config:mac_only=true | |
6343 | ovn-nbctl --wait=sb lsp-add sw9 p91 -- lsp-set-addresses p91 dynamic | |
6344 | ||
6345 | mac_prefix=$(ovn-nbctl --wait=sb get NB_Global . options:mac_prefix | tr -d \") | |
6346 | port_addr=$(ovn-nbctl get Logical-Switch-Port p91 dynamic_addresses | tr -d \") | |
6347 | AT_CHECK([test "$port_addr" = "${mac_prefix}:00:00:09"], [0], []) | |
6348 | ||
de0c1c32 LB |
6349 | ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="00:11:22" |
6350 | ovn-nbctl ls-add sw10 | |
6351 | ovn-nbctl --wait=sb set Logical-Switch sw10 other_config:ipv6_prefix="ae01::" | |
6352 | ovn-nbctl --wait=sb lsp-add sw10 p101 -- lsp-set-addresses p101 "dynamic ae01::1" | |
6353 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p101 dynamic_addresses], [0], | |
6354 | ["00:11:22:00:00:0a ae01::1" | |
6355 | ]) | |
6356 | ||
6357 | ovn-nbctl --wait=sb set Logical-Switch sw10 other_config:subnet=192.168.110.0/24 | |
6358 | ovn-nbctl --wait=sb lsp-add sw10 p102 -- lsp-set-addresses p102 "dynamic 192.168.110.10 ae01::2" | |
6359 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p102 dynamic_addresses], [0], | |
6360 | ["00:11:22:a8:6e:0b 192.168.110.10 ae01::2" | |
6361 | ]) | |
6362 | ||
8639f9be ND |
6363 | as ovn-sb |
6364 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6365 | ||
6366 | as ovn-nb | |
6367 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6368 | ||
6369 | as northd | |
6370 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
6371 | ||
7861ca30 JP |
6372 | as northd-backup |
6373 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
6374 | ||
8639f9be ND |
6375 | AT_CLEANUP |
6376 | ||
6377 | AT_SETUP([ovn -- ipam connectivity]) | |
8639f9be ND |
6378 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
6379 | ovn_start | |
6380 | ||
6381 | ovn-nbctl lr-add R1 | |
6382 | ||
6383 | # Test for a ping using dynamically allocated addresses. | |
f1301a25 | 6384 | ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="0a:00:00:00:00:00" |
8639f9be ND |
6385 | ovn-nbctl ls-add foo -- add Logical_Switch foo other_config subnet=192.168.1.0/24 |
6386 | ovn-nbctl ls-add alice -- add Logical_Switch alice other_config subnet=192.168.2.0/24 | |
6387 | ||
6388 | # Connect foo to R1 | |
6389 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
6390 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
20418099 MS |
6391 | options:router-port=foo \ |
6392 | -- lsp-set-addresses rp-foo router | |
8639f9be ND |
6393 | |
6394 | # Connect alice to R1 | |
6395 | ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 192.168.2.1/24 | |
6396 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice type=router \ | |
6397 | options:router-port=alice addresses=\"00:00:00:01:02:04\" | |
6398 | ||
6399 | # Create logical port foo1 in foo | |
fd3b31e9 | 6400 | ovn-nbctl --wait=sb lsp-add foo foo1 \ |
8639f9be | 6401 | -- lsp-set-addresses foo1 "dynamic" |
c814545b | 6402 | AT_CHECK([ovn-nbctl --timeout=10 wait-until Logical-Switch-Port foo1 dynamic_addresses='"0a:00:00:a8:01:03 192.168.1.2"'], [0]) |
8639f9be ND |
6403 | |
6404 | # Create logical port alice1 in alice | |
fd3b31e9 | 6405 | ovn-nbctl --wait=sb lsp-add alice alice1 \ |
8639f9be | 6406 | -- lsp-set-addresses alice1 "dynamic" |
c814545b | 6407 | AT_CHECK([ovn-nbctl --timeout=10 wait-until Logical-Switch-Port alice1 dynamic_addresses='"0a:00:00:a8:02:03 192.168.2.2"']) |
8639f9be ND |
6408 | |
6409 | # Create logical port foo2 in foo | |
fd3b31e9 | 6410 | ovn-nbctl --wait=sb lsp-add foo foo2 \ |
8639f9be | 6411 | -- lsp-set-addresses foo2 "dynamic" |
c814545b | 6412 | AT_CHECK([ovn-nbctl --timeout=10 wait-until Logical-Switch-Port foo2 dynamic_addresses='"0a:00:00:a8:01:04 192.168.1.3"']) |
8639f9be ND |
6413 | |
6414 | # Create a hypervisor and create OVS ports corresponding to logical ports. | |
6415 | net_add n1 | |
6416 | ||
6417 | sim_add hv1 | |
6418 | as hv1 | |
6419 | ovs-vsctl add-br br-phys | |
6420 | ovn_attach n1 br-phys 192.168.0.1 | |
6421 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
6422 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
6423 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
6424 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
6425 | ofport-request=1 | |
6426 | ||
6427 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
6428 | set interface hv1-vif2 external-ids:iface-id=foo2 \ | |
6429 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
6430 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
6431 | ofport-request=2 | |
6432 | ||
6433 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
6434 | set interface hv1-vif3 external-ids:iface-id=alice1 \ | |
6435 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
6436 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
6437 | ofport-request=3 | |
6438 | ||
6439 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6440 | # XXX This should be more systematic. | |
6441 | sleep 1 | |
6442 | ||
6443 | ip_to_hex() { | |
6444 | printf "%02x%02x%02x%02x" "$@" | |
6445 | } | |
8639f9be ND |
6446 | |
6447 | # Send ip packets between foo1 and foo2 | |
c814545b LB |
6448 | src_mac="0a0000a80103" |
6449 | dst_mac="0a0000a80104" | |
8639f9be ND |
6450 | src_ip=`ip_to_hex 192 168 1 2` |
6451 | dst_ip=`ip_to_hex 192 168 1 3` | |
6452 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6453 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
6454 | ||
6455 | # Send ip packets between foo1 and alice1 | |
c814545b | 6456 | src_mac="0a0000a80103" |
8639f9be ND |
6457 | dst_mac="000000010203" |
6458 | src_ip=`ip_to_hex 192 168 1 2` | |
6459 | dst_ip=`ip_to_hex 192 168 2 2` | |
6460 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6461 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
6462 | ||
6463 | echo "---------NB dump-----" | |
6464 | ovn-nbctl show | |
6465 | echo "---------------------" | |
6466 | ovn-nbctl list logical_router | |
6467 | echo "---------------------" | |
6468 | ovn-nbctl list logical_router_port | |
6469 | echo "---------------------" | |
6470 | ||
6471 | echo "---------SB dump-----" | |
6472 | ovn-sbctl list datapath_binding | |
6473 | echo "---------------------" | |
6474 | ovn-sbctl list port_binding | |
6475 | echo "---------------------" | |
6476 | ||
6477 | echo "------ hv1 dump ----------" | |
6478 | as hv1 ovs-ofctl dump-flows br-int | |
6479 | ||
6480 | # Packet to Expect at foo2 | |
c814545b LB |
6481 | src_mac="0a0000a80103" |
6482 | dst_mac="0a0000a80104" | |
8639f9be ND |
6483 | src_ip=`ip_to_hex 192 168 1 2` |
6484 | dst_ip=`ip_to_hex 192 168 1 3` | |
6485 | expected=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6486 | ||
e4543cfe DDP |
6487 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets |
6488 | echo $expected > expout | |
8639f9be ND |
6489 | AT_CHECK([cat received1.packets], [0], [expout]) |
6490 | ||
6491 | # Packet to Expect at alice1 | |
6492 | src_mac="000000010204" | |
c814545b | 6493 | dst_mac="0a0000a80203" |
8639f9be ND |
6494 | src_ip=`ip_to_hex 192 168 1 2` |
6495 | dst_ip=`ip_to_hex 192 168 2 2` | |
6496 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6497 | ||
e4543cfe DDP |
6498 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets |
6499 | echo $expected > expout | |
8639f9be ND |
6500 | AT_CHECK([cat received2.packets], [0], [expout]) |
6501 | ||
6502 | OVN_CLEANUP([hv1]) | |
6503 | ||
6504 | AT_CLEANUP | |
f5792c3f NS |
6505 | |
6506 | AT_SETUP([ovn -- ovs-vswitchd restart]) | |
1794d5f2 | 6507 | AT_KEYWORDS([vswitchd]) |
f5792c3f NS |
6508 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
6509 | ovn_start | |
6510 | ||
6511 | ovn-nbctl ls-add ls1 | |
6512 | ||
6513 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
6514 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
6515 | ||
6516 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
6517 | ||
6518 | net_add n1 | |
6519 | sim_add hv1 | |
6520 | ||
6521 | as hv1 | |
6522 | ovs-vsctl add-br br-phys | |
6523 | ovn_attach n1 br-phys 192.168.0.1 | |
6524 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
6525 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
6526 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
6527 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
6528 | ofport-request=1 | |
6529 | ||
74868f2c | 6530 | OVN_POPULATE_ARP |
f5792c3f NS |
6531 | sleep 2 |
6532 | ||
6533 | as hv1 ovs-vsctl show | |
6534 | ||
6535 | echo "---------------------" | |
6536 | ovn-sbctl dump-flows | |
6537 | echo "---------------------" | |
6538 | ||
6539 | echo "------ hv1 dump ----------" | |
6540 | as hv1 ovs-ofctl dump-flows br-int | |
6541 | total_flows=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
6542 | ||
6543 | echo "Total flows before vswitchd restart = " $total_flows | |
6544 | ||
6545 | # Code taken from ovs-save utility | |
6546 | save_flows () { | |
6547 | echo "ovs-ofctl add-flows br-int - << EOF" > restore_flows.sh | |
6548 | as hv1 ovs-ofctl dump-flows "br-int" | sed -e '/NXST_FLOW/d' \ | |
6549 | -e 's/\(idle\|hard\)_age=[^,]*,//g' >> restore_flows.sh | |
6550 | echo "EOF" >> restore_flows.sh | |
6551 | } | |
6552 | ||
6553 | restart_vswitchd () { | |
6554 | restore_flows=$1 | |
6555 | ||
6556 | if test $restore_flows = true; then | |
6557 | save_flows | |
6558 | fi | |
6559 | ||
6560 | as hv1 | |
6561 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6562 | ||
6563 | if test $restore_flows = true; then | |
6564 | as hv1 | |
6565 | ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="true" | |
6566 | fi | |
6567 | ||
6568 | as hv1 | |
6569 | start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl | |
6570 | ovs-ofctl dump-flows br-int | |
6571 | ||
6572 | if test $restore_flows = true; then | |
6573 | sh ./restore_flows.sh | |
6574 | echo "Flows after restore" | |
6575 | as hv1 | |
6576 | ovs-ofctl dump-flows br-int | |
6577 | ovs-vsctl --no-wait --if-exists remove open_vswitch . other_config \ | |
6578 | flow-restore-wait="true" | |
6579 | fi | |
6580 | } | |
6581 | ||
6582 | # Save the flows, restart vswitchd and restore the flows | |
6583 | restart_vswitchd true | |
6584 | OVS_WAIT_UNTIL([ | |
6585 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
6586 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
6587 | test "${total_flows}" = "${total_flows_after_restart}" | |
6588 | ]) | |
6589 | ||
6590 | # Restart vswitchd without restoring | |
6591 | restart_vswitchd false | |
6592 | OVS_WAIT_UNTIL([ | |
6593 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
6594 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
6595 | test "${total_flows}" = "${total_flows_after_restart}" | |
6596 | ]) | |
6597 | ||
6598 | OVN_CLEANUP([hv1]) | |
6599 | AT_CLEANUP | |
47021598 CSV |
6600 | |
6601 | AT_SETUP([ovn -- send arp for nexthop]) | |
47021598 CSV |
6602 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
6603 | ovn_start | |
6604 | ||
6605 | # Topology: Two LSs - ls1 and ls2 are connected via router r0 | |
6606 | ||
6607 | # Create logical switches | |
6608 | ovn-nbctl ls-add ls1 | |
6609 | ovn-nbctl ls-add ls2 | |
6610 | ||
6611 | # Create router | |
6612 | ovn-nbctl create Logical_Router name=lr0 | |
6613 | ||
6614 | # Add router ls1p1 port to gateway router | |
6615 | ovn-nbctl lrp-add lr0 lrp-ls1lp1 f0:00:00:00:00:01 192.168.0.1/24 | |
6616 | ovn-nbctl lsp-add ls1 ls1lp1 -- set Logical_Switch_Port ls1lp1 \ | |
6617 | type=router options:router-port=lrp-ls1lp1 \ | |
6618 | addresses='"f0:00:00:00:00:01 192.168.0.1"' | |
6619 | ||
6620 | # Add router ls2p2 port to gateway router | |
6621 | ovn-nbctl lrp-add lr0 lrp-ls2lp1 f0:00:00:00:00:02 192.168.1.1/24 | |
6622 | ovn-nbctl lsp-add ls2 ls2lp1 -- set Logical_Switch_Port ls2lp1 \ | |
6623 | type=router options:router-port=lrp-ls2lp1 \ | |
6624 | addresses='"f0:00:00:00:00:02 192.168.1.1"' | |
6625 | ||
6626 | # Set default gateway (nexthop) to 192.168.1.254 | |
6627 | ovn-nbctl lr-route-add lr0 "0.0.0.0/0" 192.168.1.254 lrp-ls2lp1 | |
6628 | ||
6629 | # Create logical port ls1lp2 in ls1 | |
6630 | ovn-nbctl lsp-add ls1 ls1lp2 \ | |
6631 | -- lsp-set-addresses ls1lp2 "f0:00:00:00:00:03 192.168.0.2" | |
6632 | ||
6633 | # Create logical port ls2lp2 in ls2 | |
6634 | ovn-nbctl lsp-add ls2 ls2lp2 \ | |
6635 | -- lsp-set-addresses ls2lp2 "f0:00:00:00:00:04 192.168.1.10" | |
6636 | ||
6637 | net_add n1 | |
6638 | sim_add hv1 | |
6639 | as hv1 | |
6640 | ovs-vsctl add-br br-phys | |
6641 | ovn_attach n1 br-phys 192.168.0.1 | |
6642 | ovs-vsctl -- add-port br-int hv1-ls1lp2 -- \ | |
6643 | set interface hv1-ls1lp2 external-ids:iface-id=ls1lp2 \ | |
6644 | options:tx_pcap=hv1/ls1lp2-tx.pcap \ | |
6645 | options:rxq_pcap=hv1/ls1lp2-rx.pcap \ | |
6646 | ofport-request=1 | |
6647 | ovs-vsctl -- add-port br-int hv1-ls2lp2 -- \ | |
6648 | set interface hv1-ls2lp2 external-ids:iface-id=ls2lp2 \ | |
6649 | options:tx_pcap=hv1/ls2lp2-tx.pcap \ | |
6650 | options:rxq_pcap=hv1/ls2lp2-rx.pcap \ | |
6651 | ofport-request=2 | |
6652 | ||
6653 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6654 | # XXX This should be more systematic. | |
6655 | sleep 1 | |
6656 | ||
6657 | echo "---------NB dump-----" | |
6658 | ovn-nbctl show | |
6659 | echo "---------------------" | |
6660 | ovn-nbctl list logical_router | |
6661 | echo "---------------------" | |
6662 | ovn-nbctl list logical_router_port | |
6663 | echo "---------------------" | |
6664 | ||
6665 | echo "---------SB dump-----" | |
6666 | ovn-sbctl list datapath_binding | |
6667 | echo "---------------------" | |
6668 | ovn-sbctl list port_binding | |
6669 | echo "---------------------" | |
6670 | ovn-sbctl dump-flows | |
6671 | echo "---------------------" | |
6672 | ovn-sbctl list chassis | |
6673 | ovn-sbctl list encap | |
6674 | echo "---------------------" | |
6675 | ||
6676 | echo "------Flows dump-----" | |
6677 | as hv1 | |
6678 | ovs-ofctl dump-flows | |
6679 | echo "---------------------" | |
6680 | ||
6681 | ip_to_hex() { | |
6682 | printf "%02x%02x%02x%02x" "$@" | |
6683 | } | |
6684 | ||
6685 | src_mac="f00000000003" | |
6686 | dst_mac="f00000000001" | |
6687 | src_ip=`ip_to_hex 192 168 0 2` | |
6688 | dst_ip=`ip_to_hex 8 8 8 8` | |
6689 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6690 | ||
6691 | # Send IP packet destined to 8.8.8.8 from lsp1lp2 | |
6692 | as hv1 ovs-appctl netdev-dummy/receive hv1-ls1lp2 $packet | |
6693 | ||
6694 | trim_zeros() { | |
6695 | sed 's/\(00\)\{1,\}$//' | |
6696 | } | |
6697 | ||
6698 | # ARP packet should be received with Target IP Address set to 192.168.1.254 and | |
6699 | # not 8.8.8.8 | |
6700 | ||
6701 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ls2lp2-tx.pcap | trim_zeros > packets | |
6702 | expected="fffffffffffff0000000000208060001080006040001f00000000002c0a80101000000000000c0a801fe" | |
6703 | echo $expected > expout | |
6704 | AT_CHECK([cat packets], [0], [expout]) | |
6705 | cat packets | |
6706 | ||
6707 | OVN_CLEANUP([hv1]) | |
6708 | ||
6709 | AT_CLEANUP | |
8439c2eb CSV |
6710 | |
6711 | AT_SETUP([ovn -- send gratuitous arp for nat ips in localnet]) | |
8439c2eb CSV |
6712 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
6713 | ovn_start | |
6714 | # Create logical switch | |
6715 | ovn-nbctl ls-add ls0 | |
6716 | # Create gateway router | |
6717 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
6718 | # Add router port to gateway router | |
6719 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 | |
6720 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
d223b67b | 6721 | type=router options:router-port=lrp0 addresses='"f0:00:00:00:00:01"' |
8439c2eb CSV |
6722 | # Add nat-address option |
6723 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="f0:00:00:00:00:01 192.168.0.2" | |
6724 | ||
6725 | net_add n1 | |
6726 | sim_add hv1 | |
6727 | as hv1 | |
6728 | ovs-vsctl \ | |
6729 | -- add-br br-phys \ | |
6730 | -- add-br br-eth0 | |
6731 | ||
6732 | ovn_attach n1 br-phys 192.168.0.1 | |
6733 | ||
6734 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
6735 | 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]) | |
6736 | ||
6737 | # Create a localnet port. | |
6738 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
6739 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
6740 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
6741 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
6742 | ||
d65586b6 NS |
6743 | # Wait until the patch ports are created in hv1 to connect br-int to br-eth0 |
6744 | OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-vsctl show | \ | |
6745 | grep "Port patch-br-int-to-ln_port" | wc -l`]) | |
8439c2eb CSV |
6746 | |
6747 | # Wait for packet to be received. | |
6748 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) | |
6749 | trim_zeros() { | |
6750 | sed 's/\(00\)\{1,\}$//' | |
6751 | } | |
6752 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
d65586b6 | 6753 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" |
8439c2eb | 6754 | echo $expected > expout |
d65586b6 NS |
6755 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" |
6756 | echo $expected >> expout | |
8439c2eb | 6757 | AT_CHECK([sort packets], [0], [expout]) |
8439c2eb CSV |
6758 | |
6759 | OVN_CLEANUP([hv1]) | |
6760 | ||
6761 | AT_CLEANUP | |
6e31816f | 6762 | |
e914fb54 MS |
6763 | AT_SETUP([ovn -- send gratuitous arp with nat-addresses router in localnet]) |
6764 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
6765 | ovn_start | |
6766 | # Create logical switch | |
6767 | ovn-nbctl ls-add ls0 | |
6768 | # Create gateway router | |
6769 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
6770 | # Add router port to gateway router | |
6771 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 | |
6772 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
d223b67b | 6773 | type=router options:router-port=lrp0 addresses='"f0:00:00:00:00:01"' |
e914fb54 MS |
6774 | # Add nat-address option |
6775 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" | |
6776 | # Add NAT rules | |
6777 | AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 192.168.0.1 10.0.0.0/24]) | |
6778 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 192.168.0.2 10.0.0.1]) | |
6779 | # Add load balancers | |
6780 | AT_CHECK([ovn-nbctl lb-add lb0 192.168.0.3:80 10.0.0.2:80,10.0.0.3:80]) | |
6781 | AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0]) | |
6782 | AT_CHECK([ovn-nbctl lb-add lb1 192.168.0.3:8080 10.0.0.2:8080,10.0.0.3:8080]) | |
6783 | AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1]) | |
6784 | ||
6785 | net_add n1 | |
6786 | sim_add hv1 | |
6787 | as hv1 | |
6788 | ovs-vsctl \ | |
6789 | -- add-br br-phys \ | |
6790 | -- add-br br-eth0 | |
6791 | ||
6792 | ovn_attach n1 br-phys 192.168.0.1 | |
6793 | ||
6794 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
6795 | 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]) | |
6796 | ||
6797 | # Create a localnet port. | |
6798 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
6799 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
6800 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
6801 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
6802 | ||
d65586b6 NS |
6803 | # Wait until the patch ports are created to connect br-int to br-eth0 |
6804 | OVS_WAIT_UNTIL([test 1 = `ovs-vsctl show | \ | |
6805 | grep "Port patch-br-int-to-ln_port" | wc -l`]) | |
e914fb54 | 6806 | |
d65586b6 NS |
6807 | ovn-sbctl list port_binding lrp0-rp |
6808 | echo "*****" | |
6809 | ovn-nbctl list logical_switch_port lrp0-rp | |
6810 | ovn-nbctl list logical_router_port lrp0 | |
6811 | ovn-nbctl show | |
e914fb54 MS |
6812 | # Wait for packet to be received. |
6813 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) | |
6814 | trim_zeros() { | |
6815 | sed 's/\(00\)\{1,\}$//' | |
6816 | } | |
6817 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
6818 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" | |
6819 | echo $expected > expout | |
6820 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
6821 | echo $expected >> expout | |
6822 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80003000000000000c0a80003" | |
6823 | echo $expected >> expout | |
6824 | AT_CHECK([sort packets], [0], [expout]) | |
e914fb54 MS |
6825 | |
6826 | OVN_CLEANUP([hv1]) | |
6827 | ||
6828 | AT_CLEANUP | |
6829 | ||
6e31816f | 6830 | AT_SETUP([ovn -- delete mac bindings]) |
6e31816f CSV |
6831 | ovn_start |
6832 | net_add n1 | |
6833 | sim_add hv1 | |
6834 | as hv1 | |
6835 | ovs-vsctl -- add-br br-phys | |
6836 | ovn_attach n1 br-phys 192.168.0.1 | |
6837 | # Create logical switch ls0 | |
6838 | ovn-nbctl ls-add ls0 | |
6839 | # Create ports lp0, lp1 in ls0 | |
6840 | ovn-nbctl lsp-add ls0 lp0 | |
6841 | ovn-nbctl lsp-add ls0 lp1 | |
6842 | ovn-nbctl lsp-set-addresses lp0 "f0:00:00:00:00:01 192.168.0.1" | |
6843 | ovn-nbctl lsp-set-addresses lp1 "f0:00:00:00:00:02 192.168.0.2" | |
6844 | dp_uuid=`ovn-sbctl find datapath | grep uuid | cut -f2 -d ":" | cut -f2 -d " "` | |
6845 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp0 mac="mac1" | |
6846 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp1 mac="mac2" | |
6847 | ovn-sbctl find MAC_Binding | |
093aa761 | 6848 | # Delete port lp0 and check that its MAC_Binding is deleted. |
6e31816f CSV |
6849 | ovn-nbctl lsp-del lp0 |
6850 | ovn-sbctl find MAC_Binding | |
093aa761 BP |
6851 | OVS_WAIT_UNTIL([test `ovn-sbctl find MAC_Binding logical_port=lp0 | wc -l` = 0]) |
6852 | # Delete logical switch ls0 and check that its MAC_Binding is deleted. | |
6e31816f CSV |
6853 | ovn-nbctl ls-del ls0 |
6854 | ovn-sbctl find MAC_Binding | |
093aa761 | 6855 | OVS_WAIT_UNTIL([test `ovn-sbctl find MAC_Binding | wc -l` = 0]) |
6e31816f CSV |
6856 | |
6857 | OVN_CLEANUP([hv1]) | |
6858 | ||
6859 | AT_CLEANUP | |
926c34fd RM |
6860 | |
6861 | AT_SETUP([ovn -- conntrack zone allocation]) | |
926c34fd RM |
6862 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
6863 | ovn_start | |
6864 | ||
6865 | # Logical network: | |
6866 | # 2 logical switches "foo" (192.168.1.0/24) and "bar" (172.16.1.0/24) | |
6867 | # connected to a router R1. | |
6868 | # foo has foo1 to act as a client. | |
6869 | # bar has bar1, bar2, bar3 to act as servers. | |
6870 | ||
6871 | net_add n1 | |
6872 | ||
6873 | sim_add hv1 | |
6874 | as hv1 | |
6875 | ovs-vsctl add-br br-phys | |
6876 | ovn_attach n1 br-phys 192.168.0.1 | |
6877 | for i in foo1 bar1 bar2 bar3; do | |
6878 | ovs-vsctl -- add-port br-int $i -- \ | |
6879 | set interface $i external-ids:iface-id=$i \ | |
6880 | options:tx_pcap=hv1/$i-tx.pcap \ | |
6881 | options:rxq_pcap=hv1/$i-rx.pcap | |
6882 | done | |
6883 | ||
6884 | ovn-nbctl create Logical_Router name=R1 | |
6885 | ovn-nbctl ls-add foo | |
6886 | ovn-nbctl ls-add bar | |
6887 | ||
6888 | # Connect foo to R1 | |
6889 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
6890 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
6891 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" | |
6892 | ||
6893 | # Connect bar to R1 | |
6894 | ovn-nbctl lrp-add R1 bar 00:00:01:01:02:04 172.16.1.1/24 | |
6895 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar \ | |
6896 | type=router options:router-port=bar addresses=\"00:00:01:01:02:04\" | |
6897 | ||
6898 | # Create logical port foo1 in foo | |
6899 | ovn-nbctl lsp-add foo foo1 \ | |
6900 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
6901 | ||
6902 | # Create logical port bar1, bar2 and bar3 in bar | |
6903 | for i in `seq 1 3`; do | |
6904 | ip=`expr $i + 1` | |
6905 | ovn-nbctl lsp-add bar bar$i \ | |
6906 | -- lsp-set-addresses bar$i "f0:00:0a:01:02:$i 172.16.1.$ip" | |
6907 | done | |
6908 | ||
6909 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=0 | grep REG13 | wc -l` -eq 4]) | |
6910 | ||
6911 | OVN_CLEANUP([hv1]) | |
6912 | ||
6913 | AT_CLEANUP | |
b511690b GS |
6914 | |
6915 | AT_SETUP([ovn -- tag allocation]) | |
b511690b GS |
6916 | ovn_start |
6917 | ||
6918 | AT_CHECK([ovn-nbctl ls-add ls0]) | |
6919 | AT_CHECK([ovn-nbctl lsp-add ls0 parent1]) | |
6920 | AT_CHECK([ovn-nbctl lsp-add ls0 parent2]) | |
6921 | AT_CHECK([ovn-nbctl ls-add ls1]) | |
6922 | ||
6923 | dnl When a tag is provided, no allocation is done | |
6924 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c0 parent1 3]) | |
6925 | AT_CHECK([ovn-nbctl lsp-get-tag c0], [0], [3 | |
6926 | ]) | |
6927 | dnl The same 'tag' gets created in southbound database. | |
6928 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6929 | logical_port="c0"], [0], [3 | |
6930 | ]) | |
6931 | ||
6932 | dnl Allocate tags and see it getting created in both NB and SB | |
6933 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c1 parent1 0]) | |
6934 | AT_CHECK([ovn-nbctl lsp-get-tag c1], [0], [1 | |
6935 | ]) | |
6936 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6937 | logical_port="c1"], [0], [1 | |
6938 | ]) | |
6939 | ||
6940 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c2 parent1 0]) | |
6941 | AT_CHECK([ovn-nbctl lsp-get-tag c2], [0], [2 | |
6942 | ]) | |
6943 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6944 | logical_port="c2"], [0], [2 | |
6945 | ]) | |
6946 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c3 parent1 0]) | |
6947 | AT_CHECK([ovn-nbctl lsp-get-tag c3], [0], [4 | |
6948 | ]) | |
6949 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6950 | logical_port="c3"], [0], [4 | |
6951 | ]) | |
6952 | ||
6953 | dnl A different parent. | |
6954 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c4 parent2 0]) | |
6955 | AT_CHECK([ovn-nbctl lsp-get-tag c4], [0], [1 | |
6956 | ]) | |
6957 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6958 | logical_port="c4"], [0], [1 | |
6959 | ]) | |
6960 | ||
6961 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c5 parent2 0]) | |
6962 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
6963 | ]) | |
6964 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6965 | logical_port="c5"], [0], [2 | |
6966 | ]) | |
6967 | ||
6968 | dnl Delete a logical port and create a new one. | |
6969 | AT_CHECK([ovn-nbctl --wait=sb lsp-del c1]) | |
6970 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c6 parent1 0]) | |
6971 | AT_CHECK([ovn-nbctl lsp-get-tag c6], [0], [1 | |
6972 | ]) | |
6973 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
6974 | logical_port="c6"], [0], [1 | |
6975 | ]) | |
6976 | ||
6977 | dnl Restart northd to see that the same allocation remains. | |
6978 | as northd | |
6979 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
6980 | start_daemon ovn-northd \ | |
6981 | --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock \ | |
6982 | --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
6983 | ||
6984 | dnl Create a switch to make sure that ovn-northd has run through the main loop. | |
6985 | AT_CHECK([ovn-nbctl --wait=sb ls-add ls-dummy]) | |
6986 | AT_CHECK([ovn-nbctl lsp-get-tag c0], [0], [3 | |
6987 | ]) | |
6988 | AT_CHECK([ovn-nbctl lsp-get-tag c6], [0], [1 | |
6989 | ]) | |
6990 | AT_CHECK([ovn-nbctl lsp-get-tag c2], [0], [2 | |
6991 | ]) | |
6992 | AT_CHECK([ovn-nbctl lsp-get-tag c3], [0], [4 | |
6993 | ]) | |
6994 | AT_CHECK([ovn-nbctl lsp-get-tag c4], [0], [1 | |
6995 | ]) | |
6996 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
6997 | ]) | |
6998 | ||
6999 | dnl Create a switch port with a tag that has already been allocated. | |
7000 | dnl It should go through fine with a duplicate tag. | |
7001 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c7 parent2 2]) | |
7002 | AT_CHECK([ovn-nbctl lsp-get-tag c7], [0], [2 | |
7003 | ]) | |
7004 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
7005 | logical_port="c7"], [0], [2 | |
7006 | ]) | |
7007 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
7008 | ]) | |
7009 | ||
7010 | AT_CHECK([ovn-nbctl ls-add ls2]) | |
7011 | dnl When there is no parent_name provided (for say, 'localnet'), 'tag_request' | |
7012 | dnl gets copied to 'tag' | |
7013 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls2 local0 "" 25]) | |
7014 | AT_CHECK([ovn-nbctl lsp-get-tag local0], [0], [25 | |
7015 | ]) | |
7016 | dnl The same 'tag' gets created in southbound database. | |
7017 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
7018 | logical_port="local0"], [0], [25 | |
7019 | ]) | |
7020 | dnl If 'tag_request' is 0 for localnet, nothing gets written to 'tag' | |
7021 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls2 local1 "" 0]) | |
7022 | AT_CHECK([ovn-nbctl lsp-get-tag local1]) | |
7023 | dnl change the tag_request. | |
7024 | AT_CHECK([ovn-nbctl --wait=sb set logical_switch_port local1 tag_request=50]) | |
7025 | AT_CHECK([ovn-nbctl lsp-get-tag local1], [0], [50 | |
7026 | ]) | |
7027 | ||
7028 | AT_CLEANUP | |
57afd0c0 RR |
7029 | |
7030 | AT_SETUP([ovn -- lsp deletion and broadcast-flow deletion on localnet]) | |
57afd0c0 RR |
7031 | ovn_start |
7032 | ovn-nbctl ls-add lsw0 | |
7033 | net_add n1 | |
7034 | for i in 1 2; do | |
7035 | sim_add hv$i | |
7036 | as hv$i | |
7037 | ovs-vsctl add-br br-phys | |
7038 | ovn_attach n1 br-phys 192.168.0.$i | |
7039 | ovs-vsctl add-br br-eth0 | |
7040 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
7041 | done | |
7042 | ||
7043 | # Create a localnet port. | |
7044 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) | |
7045 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
7046 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
7047 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
7048 | ||
7049 | ||
7050 | # Create 3 vifs. | |
7051 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) | |
7052 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.1"]) | |
7053 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
7054 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif2]) | |
863fb61f | 7055 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif2 "f0:00:00:00:00:02 192.168.1.2"]) |
57afd0c0 RR |
7056 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif2 "f0:00:00:00:00:02"]) |
7057 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif3]) | |
7058 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif3 "f0:00:00:00:00:03 192.168.1.3"]) | |
7059 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif3 "f0:00:00:00:00:03"]) | |
7060 | ||
7061 | # Bind the localvif1 to hv1. | |
7062 | as hv1 | |
7063 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
7064 | ||
7065 | # On hv1, check that there are no flows outputting bcast to tunnel | |
7066 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) | |
7067 | ||
1ea9b847 | 7068 | # On hv2, check that no flow outputs bcast to tunnel to hv1. |
57afd0c0 | 7069 | as hv2 |
1ea9b847 | 7070 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) |
57afd0c0 RR |
7071 | |
7072 | # Now bind vif2 on hv2. | |
7073 | AT_CHECK([ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2]) | |
7074 | ||
7075 | # At this point, the broadcast flow on vif2 should be deleted. | |
7076 | # because, there is now a localnet vif bound (table=32 programming logic) | |
7077 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) | |
7078 | ||
7079 | # Verify that the local net patch port exists on hv2. | |
7080 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
7081 | ||
7082 | # Now bind vif3 on hv2. | |
7083 | AT_CHECK([ovs-vsctl add-port br-int localvif3 -- set Interface localvif3 external_ids:iface-id=localvif3]) | |
7084 | ||
7085 | # Verify that the local net patch port still exists on hv2 | |
7086 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
7087 | ||
7088 | # Delete localvif2 | |
7089 | AT_CHECK([ovn-nbctl lsp-del localvif2]) | |
7090 | ||
7091 | # Verify that the local net patch port still exists on hv2, | |
7092 | # because, localvif3 is still bound. | |
7093 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
7094 | ||
57afd0c0 | 7095 | OVN_CLEANUP([hv1],[hv2]) |
1a03fc7d BS |
7096 | |
7097 | AT_CLEANUP | |
7098 | ||
d383eed5 JP |
7099 | |
7100 | AT_SETUP([ovn -- ACL logging]) | |
7101 | AT_KEYWORDS([ovn]) | |
7102 | ovn_start | |
7103 | ||
7104 | net_add n1 | |
7105 | ||
7106 | sim_add hv | |
7107 | as hv | |
7108 | ovs-vsctl add-br br-phys | |
7109 | ovn_attach n1 br-phys 192.168.0.1 | |
7110 | for i in lp1 lp2; do | |
7111 | ovs-vsctl -- add-port br-int $i -- \ | |
7112 | set interface $i external-ids:iface-id=$i \ | |
7113 | options:tx_pcap=hv/$i-tx.pcap \ | |
7114 | options:rxq_pcap=hv/$i-rx.pcap | |
7115 | done | |
7116 | ||
7117 | lp1_mac="f0:00:00:00:00:01" | |
7118 | lp1_ip="192.168.1.2" | |
7119 | ||
7120 | lp2_mac="f0:00:00:00:00:02" | |
7121 | lp2_ip="192.168.1.3" | |
7122 | ||
7123 | ovn-nbctl ls-add lsw0 | |
7124 | ovn-nbctl --wait=sb lsp-add lsw0 lp1 | |
7125 | ovn-nbctl --wait=sb lsp-add lsw0 lp2 | |
7126 | ovn-nbctl lsp-set-addresses lp1 $lp1_mac | |
7127 | ovn-nbctl lsp-set-addresses lp2 $lp2_mac | |
7128 | ovn-nbctl --wait=sb sync | |
7129 | ||
7130 | ovn-nbctl acl-add lsw0 to-lport 1000 'tcp.dst==80' drop | |
7131 | ovn-nbctl --log --severity=alert --name=drop-flow acl-add lsw0 to-lport 1000 'tcp.dst==81' drop | |
7132 | ||
7133 | ovn-nbctl acl-add lsw0 to-lport 1000 'tcp.dst==82' allow | |
7134 | ovn-nbctl --log --severity=info --name=allow-flow acl-add lsw0 to-lport 1000 'tcp.dst==83' allow | |
7135 | ||
7136 | ovn-nbctl acl-add lsw0 to-lport 1000 'tcp.dst==84' allow-related | |
7137 | ovn-nbctl --log acl-add lsw0 to-lport 1000 'tcp.dst==85' allow-related | |
7138 | ||
7139 | ovn-nbctl acl-add lsw0 to-lport 1000 'tcp.dst==86' reject | |
abf11558 | 7140 | ovn-nbctl --wait=hv --log --severity=alert --name=reject-flow acl-add lsw0 to-lport 1000 'tcp.dst==87' reject |
d383eed5 JP |
7141 | |
7142 | ovn-sbctl dump-flows | |
7143 | ||
7144 | ||
7145 | # Send packet that should be dropped without logging. | |
7146 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && | |
7147 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7148 | tcp && tcp.flags==2 && tcp.src==4360 && tcp.dst==80" | |
7149 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7150 | ||
7151 | # Send packet that should be dropped with logging. | |
7152 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && | |
7153 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7154 | tcp && tcp.flags==2 && tcp.src==4361 && tcp.dst==81" | |
7155 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7156 | ||
7157 | # Send packet that should be allowed without logging. | |
7158 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && | |
7159 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7160 | tcp && tcp.flags==2 && tcp.src==4362 && tcp.dst==82" | |
7161 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7162 | ||
7163 | # Send packet that should be allowed with logging. | |
7164 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && | |
7165 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7166 | tcp && tcp.flags==2 && tcp.src==4363 && tcp.dst==83" | |
7167 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7168 | ||
7169 | # Send packet that should allow related flows without logging. | |
7170 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && | |
7171 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7172 | tcp && tcp.flags==2 && tcp.src==4364 && tcp.dst==84" | |
7173 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7174 | ||
7175 | # Send packet that should allow related flows with logging. | |
7176 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && | |
7177 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7178 | tcp && tcp.flags==2 && tcp.src==4365 && tcp.dst==85" | |
7179 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7180 | ||
df48cfc7 | 7181 | # Send packet that should be rejected without logging. |
d383eed5 JP |
7182 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && |
7183 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7184 | tcp && tcp.flags==2 && tcp.src==4366 && tcp.dst==86" | |
7185 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7186 | ||
df48cfc7 | 7187 | # Send packet that should be rejected with logging. |
d383eed5 JP |
7188 | packet="inport==\"lp1\" && eth.src==$lp1_mac && eth.dst==$lp2_mac && |
7189 | ip4 && ip.ttl==64 && ip4.src==$lp1_ip && ip4.dst==$lp2_ip && | |
7190 | tcp && tcp.flags==2 && tcp.src==4367 && tcp.dst==87" | |
7191 | as hv ovs-appctl -t ovn-controller inject-pkt "$packet" | |
7192 | ||
c1f272f9 NS |
7193 | OVS_WAIT_UNTIL([ test 4 = $(grep -c 'acl_log' hv/ovn-controller.log) ]) |
7194 | ||
d383eed5 JP |
7195 | AT_CHECK([grep 'acl_log' hv/ovn-controller.log | sed 's/.*name=/name=/'], [0], [dnl |
7196 | name="drop-flow", verdict=drop, severity=alert: tcp,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=192.168.1.2,nw_dst=192.168.1.3,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=4361,tp_dst=81,tcp_flags=syn | |
7197 | name="allow-flow", verdict=allow, severity=info: tcp,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=192.168.1.2,nw_dst=192.168.1.3,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=4363,tp_dst=83,tcp_flags=syn | |
7198 | name="<unnamed>", verdict=allow, severity=info: tcp,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=192.168.1.2,nw_dst=192.168.1.3,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=4365,tp_dst=85,tcp_flags=syn | |
7199 | name="reject-flow", verdict=reject, severity=alert: tcp,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=f0:00:00:00:00:02,nw_src=192.168.1.2,nw_dst=192.168.1.3,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=4367,tp_dst=87,tcp_flags=syn | |
7200 | ]) | |
7201 | ||
7202 | OVN_CLEANUP([hv]) | |
7203 | AT_CLEANUP | |
7204 | ||
7205 | ||
23749245 JP |
7206 | AT_SETUP([ovn -- ACL rate-limited logging]) |
7207 | AT_KEYWORDS([ovn]) | |
7208 | ovn_start | |
7209 | ||
7210 | net_add n1 | |
7211 | ||
7212 | sim_add hv | |
7213 | as hv | |
7214 | ovs-vsctl add-br br-phys | |
7215 | ovn_attach n1 br-phys 192.168.0.1 | |
7216 | for i in lp1 lp2; do | |
7217 | ovs-vsctl -- add-port br-int $i -- \ | |
7218 | set interface $i external-ids:iface-id=$i \ | |
7219 | options:tx_pcap=hv/$i-tx.pcap \ | |
7220 | options:rxq_pcap=hv/$i-rx.pcap | |
7221 | done | |
7222 | ||
7223 | lp1_mac="f0:00:00:00:00:01" | |
7224 | lp1_ip="192.168.1.2" | |
7225 | ||
7226 | lp2_mac="f0:00:00:00:00:02" | |
7227 | lp2_ip="192.168.1.3" | |
7228 | ||
7229 | ovn-nbctl ls-add lsw0 | |
7230 | ovn-nbctl --wait=sb lsp-add lsw0 lp1 | |
7231 | ovn-nbctl --wait=sb lsp-add lsw0 lp2 | |
7232 | ovn-nbctl lsp-set-addresses lp1 $lp1_mac | |
7233 | ovn-nbctl lsp-set-addresses lp2 $lp2_mac | |
7234 | ovn-nbctl --wait=sb sync | |
7235 | ||
7236 | ||
7237 | # Add an ACL that rate-limits logs at 10 per second. | |
7238 | ovn-nbctl meter-add http-rl1 drop 10 pktps | |
7239 | ovn-nbctl --log --severity=alert --meter=http-rl1 --name=http-acl1 acl-add lsw0 to-lport 1000 'tcp.dst==80' drop | |
7240 | ||
7241 | # Add an ACL that rate-limits logs at 5 per second. | |
7242 | ovn-nbctl meter-add http-rl2 drop 5 pktps | |
7243 | ovn-nbctl --log --severity=alert --meter=http-rl2 --name=http-acl2 acl-add lsw0 to-lport 1000 'tcp.dst==81' allow | |
7244 | ||
7245 | # Add an ACL that doesn't rate-limit logs. | |
7246 | ovn-nbctl --log --severity=alert --name=http-acl3 acl-add lsw0 to-lport 1000 'tcp.dst==82' drop | |
abf11558 | 7247 | ovn-nbctl --wait=hv sync |
23749245 JP |
7248 | |
7249 | # For each ACL, send 100 packets. | |
7250 | for i in `seq 1 100`; do | |
7251 | ovs-appctl netdev-dummy/receive lp1 'in_port(1),eth(src=f0:00:00:00:00:01,dst=f0:00:00:00:00:02),eth_type(0x0800),ipv4(src=192.168.1.2,dst=192.168.1.3,proto=6,tos=0,ttl=64,frag=no),tcp(src=7777,dst=80)' | |
7252 | ||
7253 | ovs-appctl netdev-dummy/receive lp1 'in_port(1),eth(src=f0:00:00:00:00:01,dst=f0:00:00:00:00:02),eth_type(0x0800),ipv4(src=192.168.1.2,dst=192.168.1.3,proto=6,tos=0,ttl=64,frag=no),tcp(src=7777,dst=81)' | |
7254 | ||
7255 | ovs-appctl netdev-dummy/receive lp1 'in_port(1),eth(src=f0:00:00:00:00:01,dst=f0:00:00:00:00:02),eth_type(0x0800),ipv4(src=192.168.1.2,dst=192.168.1.3,proto=6,tos=0,ttl=64,frag=no),tcp(src=7777,dst=82)' | |
7256 | done | |
7257 | ||
2600ef02 JP |
7258 | # The rate at which packets are sent is highly system-dependent, so we |
7259 | # can't count on precise drop counts. To work around that, we just | |
7260 | # check that exactly 100 "http-acl3" actions were logged and that there | |
7261 | # were more "http-acl1" actions than "http-acl2" ones. | |
7262 | OVS_WAIT_UNTIL([ test 100 = $(grep -c 'http-acl3' hv/ovn-controller.log) ]) | |
7263 | ||
7264 | # On particularly slow or overloaded systems, the transmission rate may | |
7265 | # be lower than the configured meter rate. To prevent false test | |
7266 | # failures, we check the duration count of the meter, and if it's | |
7267 | # greater than nine seconds, just skip the test. | |
7268 | d_secs=$(as hv ovs-ofctl -O OpenFlow13 meter-stats br-int | grep "meter:1" | sed 's/.* duration:\([[0-9]]\{1,\}\)\.[[0-9]]\+s .*/\1/') | |
7269 | ||
7270 | echo "Meter duration: $d_secs" | |
7271 | AT_SKIP_IF([test $d_secs -gt 9]) | |
7272 | ||
23749245 JP |
7273 | # Print some information that may help debugging. |
7274 | as hv ovs-appctl -t ovn-controller meter-table-list | |
7275 | as hv ovs-ofctl -O OpenFlow13 meter-stats br-int | |
7276 | ||
23749245 JP |
7277 | n_acl1=$(grep -c 'http-acl1' hv/ovn-controller.log) |
7278 | n_acl2=$(grep -c 'http-acl2' hv/ovn-controller.log) | |
7279 | n_acl3=$(grep -c 'http-acl3' hv/ovn-controller.log) | |
7280 | ||
7281 | AT_CHECK([ test $n_acl3 -gt $n_acl1 ], [0], []) | |
7282 | AT_CHECK([ test $n_acl1 -gt $n_acl2 ], [0], []) | |
7283 | ||
23749245 JP |
7284 | OVN_CLEANUP([hv]) |
7285 | AT_CLEANUP | |
7286 | ||
7287 | ||
66d89287 | 7288 | AT_SETUP([ovn -- DSCP marking and meter check]) |
1a03fc7d BS |
7289 | AT_KEYWORDS([ovn]) |
7290 | ovn_start | |
7291 | ||
7292 | ovn-nbctl ls-add lsw0 | |
7293 | ovn-nbctl --wait=sb lsp-add lsw0 lp1 | |
7294 | ovn-nbctl --wait=sb lsp-add lsw0 lp2 | |
e50ed58a | 7295 | ovn-nbctl --wait=sb lsp-add lsw0 lp3 |
1a03fc7d BS |
7296 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 |
7297 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
e50ed58a | 7298 | ovn-nbctl lsp-set-addresses lp3 f0:00:00:00:00:03 |
1a03fc7d BS |
7299 | ovn-nbctl lsp-set-port-security lp1 f0:00:00:00:00:01 |
7300 | ovn-nbctl lsp-set-port-security lp2 f0:00:00:00:00:02 | |
7301 | ovn-nbctl --wait=sb sync | |
7302 | net_add n1 | |
7303 | sim_add hv | |
7304 | as hv | |
7305 | ovs-vsctl add-br br-phys | |
7306 | ovn_attach n1 br-phys 192.168.0.1 | |
7307 | 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 | |
7308 | 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 | |
7309 | ||
7310 | AT_CAPTURE_FILE([trace]) | |
7311 | ovn_trace () { | |
7312 | ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' | |
7313 | } | |
7314 | ||
7315 | # Extracts nw_tos from the final flow from ofproto/trace output and prints | |
7316 | # it on stdout. Prints "none" if no nw_tos was included. | |
7317 | get_final_nw_tos() { | |
7318 | if flow=$(grep '^Final flow:' stdout); then :; else | |
7319 | # The output didn't have a final flow. | |
7320 | return 99 | |
7321 | fi | |
7322 | ||
7323 | tos=$(echo "$flow" | sed -n 's/.*nw_tos=\([[0-9]]\{1,\}\).*/\1/p') | |
7324 | case $tos in | |
7325 | '') echo none ;; | |
5a0e4aec | 7326 | *) echo $tos ;; |
1a03fc7d BS |
7327 | esac |
7328 | } | |
7329 | ||
7330 | # check_tos TOS | |
7331 | # | |
7332 | # Checks that a packet from 1.1.1.1 to 1.1.1.2 gets its DSCP set to TOS. | |
7333 | check_tos() { | |
7334 | # First check with ovn-trace for logical flows. | |
7335 | echo "checking for tos $1" | |
7336 | (if test $1 != 0; then echo "ip.dscp = $1;"; fi; | |
7337 | echo 'output("lp2");') > expout | |
7338 | 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]) | |
7339 | ||
7340 | # Then re-check with ofproto/trace for a physical packet. | |
7341 | 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]) | |
7342 | AT_CHECK_UNQUOTED([get_final_nw_tos], [0], [`expr $1 \* 4` | |
7343 | ]) | |
7344 | } | |
7345 | ||
7346 | # check at L2 | |
7347 | 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"); | |
7348 | ]) | |
7349 | 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]) | |
7350 | AT_CHECK([get_final_nw_tos], [0], [none | |
7351 | ]) | |
7352 | ||
7353 | # check at L3 without dscp marking | |
7354 | check_tos 0 | |
7355 | ||
7356 | # Mark DSCP with a valid value | |
e50ed58a | 7357 | qos_id=$(ovn-nbctl --wait=hv -- --id=@lp1-qos create QoS priority=100 action=dscp=48 match="inport\=\=\"lp1\"\ &&\ is_chassis_resident(\"lp1\")" direction="from-lport" -- set Logical_Switch lsw0 qos_rules=@lp1-qos) |
5ee33cbd GL |
7358 | AT_CHECK([as hv ovn-nbctl qos-list lsw0 | wc -l], [0], [1 |
7359 | ]) | |
1a03fc7d BS |
7360 | check_tos 48 |
7361 | ||
66d89287 GL |
7362 | # check at hv without qos meter |
7363 | AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [0 | |
7364 | ]) | |
7365 | ||
7366 | # Update the meter rate | |
7367 | ovn-nbctl --wait=hv set QoS $qos_id bandwidth=rate=100 | |
7368 | ||
7369 | # check at hv with a qos meter table | |
7370 | AT_CHECK([as hv ovs-ofctl dump-meters br-int -O OpenFlow13 | grep rate=100 | wc -l], [0], [1 | |
7371 | ]) | |
7372 | AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [1 | |
7373 | ]) | |
7374 | ||
1a03fc7d BS |
7375 | # Update the DSCP marking |
7376 | ovn-nbctl --wait=hv set QoS $qos_id action=dscp=63 | |
7377 | check_tos 63 | |
7378 | ||
66d89287 GL |
7379 | # Update the meter rate |
7380 | ovn-nbctl --wait=hv set QoS $qos_id bandwidth=rate=4294967295,burst=4294967295 | |
7381 | ||
7382 | # check at hv with a qos meter table | |
7383 | AT_CHECK([as hv ovs-ofctl dump-meters br-int -O OpenFlow13 | grep burst_size=4294967295 | wc -l], [0], [1 | |
7384 | ]) | |
7385 | AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [1 | |
7386 | ]) | |
7387 | ||
1a03fc7d BS |
7388 | ovn-nbctl --wait=hv set QoS $qos_id match="outport\=\=\"lp2\"" direction="to-lport" |
7389 | check_tos 63 | |
7390 | ||
7391 | # Disable DSCP marking | |
5ee33cbd GL |
7392 | ovn-nbctl --wait=hv qos-del lsw0 |
7393 | AT_CHECK([as hv ovn-nbctl qos-list lsw0 | wc -l], [0], [0 | |
7394 | ]) | |
1a03fc7d BS |
7395 | check_tos 0 |
7396 | ||
66d89287 GL |
7397 | # check at hv without qos meter |
7398 | AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [0 | |
7399 | ]) | |
7400 | ||
e50ed58a GL |
7401 | # check meter with chassis not resident |
7402 | ovn-nbctl qos-add lsw0 to-lport 1001 'inport=="lp3" && is_chassis_resident("lp3")' rate=11123 burst=111230 | |
7403 | AT_CHECK([as hv ovn-nbctl qos-list lsw0 | wc -l], [0], [1 | |
7404 | ]) | |
7405 | ||
7406 | # check no meter table | |
7407 | AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [0 | |
7408 | ]) | |
7409 | AT_CHECK([as hv ovs-ofctl dump-meters br-int -O OpenFlow13 | grep rate=11123 | wc -l], [0], [0 | |
7410 | ]) | |
7411 | ||
1a03fc7d | 7412 | OVN_CLEANUP([hv]) |
57afd0c0 | 7413 | AT_CLEANUP |
7fff4eb7 LR |
7414 | |
7415 | AT_SETUP([ovn -- read-only sb db:ptcp access]) | |
7416 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7417 | ||
7418 | : > .$1.db.~lock~ | |
7419 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
7420 | ||
7421 | # Add read-only remote to sb ovsdb-server | |
7422 | AT_CHECK( | |
7423 | [ovsdb-tool transact ovn-sb.db \ | |
7424 | ['["OVN_Southbound", | |
7425 | {"op": "insert", | |
7426 | "table": "SB_Global", | |
7427 | "row": { | |
7428 | "connections": ["set", [["named-uuid", "xyz"]]]}}, | |
7429 | {"op": "insert", | |
7430 | "table": "Connection", | |
7431 | "uuid-name": "xyz", | |
7432 | "row": {"target": "ptcp:0:127.0.0.1", | |
7433 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
7434 | ||
7435 | start_daemon ovsdb-server --remote=punix:ovn-sb.sock --remote=db:OVN_Southbound,SB_Global,connections ovn-sb.db | |
7436 | ||
7437 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
7438 | ||
7439 | # read-only accesses should succeed | |
7440 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT list SB_Global], [0], [stdout], [ignore]) | |
7441 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT list Connection], [0], [stdout], [ignore]) | |
7442 | ||
7443 | # write access should fail | |
7444 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT chassis-add ch vxlan 1.2.4.8], [1], [ignore], | |
7445 | [ovn-sbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
7446 | ]) | |
7447 | ||
7448 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
7449 | AT_CLEANUP | |
7450 | ||
7451 | AT_SETUP([ovn -- read-only sb db:pssl access]) | |
7452 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7453 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
7454 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
7455 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
7456 | \\]"]) | |
7457 | ||
7458 | : > .$1.db.~lock~ | |
7459 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
7460 | ||
7461 | # Add read-only remote to sb ovsdb-server | |
7462 | AT_CHECK( | |
7463 | [ovsdb-tool transact ovn-sb.db \ | |
7464 | ['["OVN_Southbound", | |
7465 | {"op": "insert", | |
7466 | "table": "SB_Global", | |
7467 | "row": { | |
7468 | "connections": ["set", [["named-uuid", "xyz"]]]}}, | |
7469 | {"op": "insert", | |
7470 | "table": "Connection", | |
7471 | "uuid-name": "xyz", | |
7472 | "row": {"target": "pssl:0:127.0.0.1", | |
7473 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
7474 | ||
7475 | start_daemon ovsdb-server --remote=punix:ovn-sb.sock \ | |
7476 | --remote=db:OVN_Southbound,SB_Global,connections \ | |
7477 | --private-key="$PKIDIR/testpki-privkey2.pem" \ | |
7478 | --certificate="$PKIDIR/testpki-cert2.pem" \ | |
7479 | --ca-cert="$PKIDIR/testpki-cacert.pem" \ | |
7480 | ovn-sb.db | |
7481 | ||
7482 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
7483 | ||
7484 | # read-only accesses should succeed | |
7485 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7486 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7487 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7488 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7489 | list SB_Global], [0], [stdout], [ignore]) | |
7490 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7491 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7492 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7493 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7494 | list Connection], [0], [stdout], [ignore]) | |
7495 | ||
7496 | # write access should fail | |
7497 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7498 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7499 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7500 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7501 | chassis-add ch vxlan 1.2.4.8], [1], [ignore], | |
7502 | [ovn-sbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
7503 | ]) | |
7504 | ||
7505 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
7506 | AT_CLEANUP | |
7507 | ||
821302cf LR |
7508 | AT_SETUP([ovn -- nb connection/ssl commands]) |
7509 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7510 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
7511 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
7512 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
7513 | \\]"]) | |
7514 | ||
7515 | : > .$1.db.~lock~ | |
7516 | ovsdb-tool create ovn-nb.db "$abs_top_srcdir"/ovn/ovn-nb.ovsschema | |
7517 | ||
7518 | # Start nb db server using db connection/ssl entries (unpopulated initially) | |
7519 | start_daemon ovsdb-server --remote=punix:ovnnb_db.sock \ | |
7520 | --remote=db:OVN_Northbound,NB_Global,connections \ | |
7521 | --private-key=db:OVN_Northbound,SSL,private_key \ | |
7522 | --certificate=db:OVN_Northbound,SSL,certificate \ | |
7523 | --ca-cert=db:OVN_Northbound,SSL,ca_cert \ | |
7524 | ovn-nb.db | |
7525 | ||
7526 | # Populate SSL configuration entries in nb db | |
7527 | AT_CHECK( | |
7528 | [ovn-nbctl set-ssl $PKIDIR/testpki-privkey.pem \ | |
7529 | $PKIDIR/testpki-cert.pem \ | |
7530 | $PKIDIR/testpki-cacert.pem], [0], [stdout], [ignore]) | |
7531 | ||
7532 | # Populate a passive SSL connection in nb db | |
7533 | AT_CHECK([ovn-nbctl set-connection pssl:0:127.0.0.1], [0], [stdout], [ignore]) | |
7534 | ||
7535 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
7536 | ||
7537 | # Verify SSL connetivity to nb db server | |
7538 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7539 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7540 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7541 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7542 | list NB_Global], | |
7543 | [0], [stdout], [ignore]) | |
7544 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7545 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7546 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7547 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7548 | list Connection], | |
7549 | [0], [stdout], [ignore]) | |
7550 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7551 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
10471820 LR |
7552 | --certificate=$PKIDIR/testpki-cert.pem \ |
7553 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7554 | get-connection], | |
7555 | [0], [stdout], [ignore]) | |
7556 | ||
7557 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
7558 | AT_CLEANUP | |
7559 | ||
7560 | AT_SETUP([ovn -- sb connection/ssl commands]) | |
7561 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7562 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
7563 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
7564 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
7565 | \\]"]) | |
7566 | ||
7567 | : > .$1.db.~lock~ | |
7568 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
7569 | ||
7570 | # Start sb db server using db connection/ssl entries (unpopulated initially) | |
7571 | start_daemon ovsdb-server --remote=punix:ovnsb_db.sock \ | |
7572 | --remote=db:OVN_Southbound,SB_Global,connections \ | |
7573 | --private-key=db:OVN_Southbound,SSL,private_key \ | |
7574 | --certificate=db:OVN_Southbound,SSL,certificate \ | |
7575 | --ca-cert=db:OVN_Southbound,SSL,ca_cert \ | |
7576 | ovn-sb.db | |
7577 | ||
7578 | # Populate SSL configuration entries in sb db | |
7579 | AT_CHECK( | |
7580 | [ovn-sbctl set-ssl $PKIDIR/testpki-privkey.pem \ | |
7581 | $PKIDIR/testpki-cert.pem \ | |
7582 | $PKIDIR/testpki-cacert.pem], [0], [stdout], [ignore]) | |
7583 | ||
7584 | # Populate a passive SSL connection in sb db | |
7585 | AT_CHECK([ovn-sbctl set-connection pssl:0:127.0.0.1], [0], [stdout], [ignore]) | |
7586 | ||
7587 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
7588 | ||
7589 | # Verify SSL connetivity to sb db server | |
7590 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7591 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7592 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7593 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7594 | list SB_Global], | |
7595 | [0], [stdout], [ignore]) | |
7596 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7597 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
7598 | --certificate=$PKIDIR/testpki-cert.pem \ | |
7599 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7600 | list Connection], | |
7601 | [0], [stdout], [ignore]) | |
7602 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
7603 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
821302cf LR |
7604 | --certificate=$PKIDIR/testpki-cert.pem \ |
7605 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
7606 | get-connection], | |
7607 | [0], [stdout], [ignore]) | |
7608 | ||
7609 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
7610 | AT_CLEANUP | |
7611 | ||
75fd74f8 GS |
7612 | AT_SETUP([ovn -- nested containers]) |
7613 | ovn_start | |
7614 | ||
7615 | # Physical network: | |
7616 | # 2 HVs. HV1 has 2 VMs - "VM1" and "bar3". HV2 has 1 VM - "VM2" | |
7617 | ||
7618 | # Logical network: | |
7619 | # 3 Logical switches - "mgmt" (172.16.1.0/24), "foo" (192.168.1.0/24) | |
7620 | # and "bar" (192.168.2.0/24). They are all connected to router R1. | |
7621 | ||
7622 | ovn-nbctl lr-add R1 | |
7623 | ovn-nbctl ls-add mgmt | |
7624 | ovn-nbctl ls-add foo | |
7625 | ovn-nbctl ls-add bar | |
7626 | ||
7627 | # Connect mgmt to R1 | |
7628 | ovn-nbctl lrp-add R1 mgmt 00:00:00:01:02:02 172.16.1.1/24 | |
7629 | ovn-nbctl lsp-add mgmt rp-mgmt -- set Logical_Switch_Port rp-mgmt type=router \ | |
7630 | options:router-port=mgmt addresses=\"00:00:00:01:02:02\" | |
7631 | ||
7632 | # Connect foo to R1 | |
7633 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
7634 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
7635 | options:router-port=foo addresses=\"00:00:00:01:02:03\" | |
7636 | ||
7637 | # Connect bar to R1 | |
7638 | ovn-nbctl lrp-add R1 bar 00:00:00:01:02:04 192.168.2.1/24 | |
7639 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar type=router \ | |
7640 | options:router-port=bar addresses=\"00:00:00:01:02:04\" | |
7641 | ||
7642 | # "mgmt" has VM1 and VM2 connected | |
7643 | ovn-nbctl lsp-add mgmt vm1 \ | |
7644 | -- lsp-set-addresses vm1 "f0:00:00:01:02:03 172.16.1.2" | |
7645 | ||
7646 | ovn-nbctl lsp-add mgmt vm2 \ | |
7647 | -- lsp-set-addresses vm2 "f0:00:00:01:02:04 172.16.1.3" | |
7648 | ||
7649 | # "foo1" and "foo2" are containers belonging to switch "foo" | |
7650 | # "foo1" has "VM1" as parent_port and "foo2" has "VM2" as parent_port. | |
7651 | ovn-nbctl lsp-add foo foo1 vm1 1 \ | |
7652 | -- lsp-set-addresses foo1 "f0:00:00:01:02:05 192.168.1.2" | |
7653 | ||
7654 | ovn-nbctl lsp-add foo foo2 vm2 2 \ | |
7655 | -- lsp-set-addresses foo2 "f0:00:00:01:02:06 192.168.1.3" | |
7656 | ||
7657 | # "bar1" and "bar2" are containers belonging to switch "bar" | |
7658 | # "bar1" has "VM1" as parent_port and "bar2" has "VM2" as parent_port. | |
7659 | ovn-nbctl lsp-add bar bar1 vm1 2 \ | |
7660 | -- lsp-set-addresses bar1 "f0:00:00:01:02:07 192.168.2.2" | |
7661 | ||
7662 | ovn-nbctl lsp-add bar bar2 vm2 1 \ | |
7663 | -- lsp-set-addresses bar2 "f0:00:00:01:02:08 192.168.2.3" | |
7664 | ||
7665 | # bar3 is a standalone VM belonging to switch "bar" | |
7666 | ovn-nbctl lsp-add bar bar3 \ | |
7667 | -- lsp-set-addresses bar3 "f0:00:00:01:02:09 192.168.2.4" | |
7668 | ||
7669 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
7670 | net_add n1 | |
7671 | ||
7672 | sim_add hv1 | |
7673 | as hv1 | |
7674 | ovs-vsctl add-br br-phys | |
7675 | ovn_attach n1 br-phys 192.168.0.1 | |
7676 | ovs-vsctl -- add-port br-int vm1 -- \ | |
7677 | set interface vm1 external-ids:iface-id=vm1 \ | |
7678 | options:tx_pcap=hv1/vm1-tx.pcap \ | |
7679 | options:rxq_pcap=hv1/vm1-rx.pcap \ | |
7680 | ofport-request=1 | |
7681 | ||
7682 | ovs-vsctl -- add-port br-int bar3 -- \ | |
7683 | set interface bar3 external-ids:iface-id=bar3 \ | |
7684 | options:tx_pcap=hv1/bar3-tx.pcap \ | |
7685 | options:rxq_pcap=hv1/bar3-rx.pcap \ | |
7686 | ofport-request=2 | |
7687 | ||
7688 | sim_add hv2 | |
7689 | as hv2 | |
7690 | ovs-vsctl add-br br-phys | |
7691 | ovn_attach n1 br-phys 192.168.0.2 | |
7692 | ovs-vsctl -- add-port br-int vm2 -- \ | |
7693 | set interface vm2 external-ids:iface-id=vm2 \ | |
7694 | options:tx_pcap=hv2/vm2-tx.pcap \ | |
7695 | options:rxq_pcap=hv2/vm2-rx.pcap \ | |
7696 | ofport-request=1 | |
7697 | ||
7698 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
7699 | # packets for ARP resolution (native tunneling doesn't queue packets | |
7700 | # for ARP resolution). | |
74868f2c | 7701 | OVN_POPULATE_ARP |
75fd74f8 GS |
7702 | |
7703 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7704 | # XXX This should be more systematic. | |
7705 | sleep 1 | |
7706 | ||
7707 | ip_to_hex() { | |
7708 | printf "%02x%02x%02x%02x" "$@" | |
7709 | } | |
7710 | ||
7711 | # Send ip packets between foo1 and foo2 (same switch, different HVs and | |
7712 | # different VLAN tags). | |
7713 | src_mac="f00000010205" | |
7714 | dst_mac="f00000010206" | |
7715 | src_ip=`ip_to_hex 192 168 1 2` | |
7716 | dst_ip=`ip_to_hex 192 168 1 3` | |
7717 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7718 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7719 | ||
7720 | # expected packet at foo2 | |
7721 | packet=${dst_mac}${src_mac}8100000208004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7722 | echo $packet > expected | |
7723 | OVN_CHECK_PACKETS([hv2/vm2-tx.pcap], [expected]) | |
7724 | ||
7725 | # Send ip packets between foo1 and bar2 (different switch, different HV) | |
7726 | src_mac="f00000010205" | |
7727 | dst_mac="000000010203" | |
7728 | src_ip=`ip_to_hex 192 168 1 2` | |
7729 | dst_ip=`ip_to_hex 192 168 2 3` | |
7730 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7731 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7732 | ||
7733 | # expected packet at bar2 | |
7734 | src_mac="000000010204" | |
7735 | dst_mac="f00000010208" | |
7736 | packet=${dst_mac}${src_mac}8100000108004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7737 | echo $packet >> expected | |
7738 | OVN_CHECK_PACKETS([hv2/vm2-tx.pcap], [expected]) | |
7739 | ||
7740 | # Send ip packets between foo1 and bar1 | |
7741 | # (different switch, loopback to same vm but different tag) | |
7742 | src_mac="f00000010205" | |
7743 | dst_mac="000000010203" | |
7744 | src_ip=`ip_to_hex 192 168 1 2` | |
7745 | dst_ip=`ip_to_hex 192 168 2 2` | |
7746 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7747 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7748 | ||
7749 | # expected packet at bar1 | |
7750 | src_mac="000000010204" | |
7751 | dst_mac="f00000010207" | |
7752 | packet=${dst_mac}${src_mac}8100000208004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7753 | echo $packet > expected1 | |
7754 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
7755 | ||
7756 | # Send ip packets between bar1 and bar3 | |
7757 | # (same switch. But one is container and another is a standalone VM) | |
7758 | src_mac="f00000010207" | |
7759 | dst_mac="f00000010209" | |
7760 | src_ip=`ip_to_hex 192 168 2 2` | |
7761 | dst_ip=`ip_to_hex 192 168 2 3` | |
7762 | packet=${dst_mac}${src_mac}8100000208004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7763 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7764 | ||
7765 | # expected packet at bar3 | |
7766 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7767 | echo $packet > expected | |
7768 | OVN_CHECK_PACKETS([hv1/bar3-tx.pcap], [expected]) | |
7769 | ||
7770 | # Send ip packets between foo1 and vm1. | |
7771 | (different switch, container to the VM hosting it.) | |
7772 | src_mac="f00000010205" | |
7773 | dst_mac="000000010203" | |
7774 | src_ip=`ip_to_hex 192 168 1 2` | |
7775 | dst_ip=`ip_to_hex 172 16 1 2` | |
7776 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7777 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7778 | ||
7779 | # expected packet at vm1 | |
7780 | src_mac="000000010202" | |
7781 | dst_mac="f00000010203" | |
7782 | packet=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7783 | echo $packet >> expected1 | |
7784 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
7785 | ||
7786 | # Send packets from vm1 to bar1. | |
7787 | (different switch, A hosting VM to a container inside it) | |
7788 | src_mac="f00000010203" | |
7789 | dst_mac="000000010202" | |
7790 | src_ip=`ip_to_hex 172 16 1 2` | |
7791 | dst_ip=`ip_to_hex 192 168 2 2` | |
7792 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7793 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7794 | ||
7795 | # expected packet at vm1 | |
7796 | src_mac="000000010204" | |
7797 | dst_mac="f00000010207" | |
7798 | packet=${dst_mac}${src_mac}8100000208004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7799 | echo $packet >> expected1 | |
7800 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
7801 | ||
22e506d3 NS |
7802 | # Send broadcast packet from foo1. foo1 should not receive the same packet. |
7803 | src_mac="f00000010205" | |
7804 | dst_mac="ffffffffffff" | |
7805 | src_ip=`ip_to_hex 192 168 1 2` | |
7806 | dst_ip=`ip_to_hex 255 255 255 255` | |
7807 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7808 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
7809 | ||
7810 | # expected packet at VM1 | |
7811 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
7812 | ||
75fd74f8 GS |
7813 | OVN_CLEANUP([hv1],[hv2]) |
7814 | ||
7815 | AT_CLEANUP | |
440a9f4b GS |
7816 | |
7817 | AT_SETUP([ovn -- 3 HVs, 3 LRs connected via LS, source IP based routes]) | |
7818 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7819 | ovn_start | |
7820 | ||
7821 | # Logical network: | |
7822 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
7823 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) and bar | |
7824 | # (192.168.2.0/24) connected to it. | |
7825 | # | |
7826 | # R2 and R3 are gateway routers. | |
7827 | # R2 has alice (172.16.1.0/24) and R3 has bob (172.16.1.0/24) | |
7828 | # connected to it. Note how both alice and bob have the same subnet behind it. | |
7829 | # We are trying to simulate external network via those 2 switches. In real | |
7830 | # world the switch ports of these switches will have addresses set as "unknown" | |
7831 | # to make them learning switches. Or those switches will be "localnet" ones. | |
7832 | ||
7833 | # Create three hypervisors and create OVS ports corresponding to logical ports. | |
7834 | net_add n1 | |
7835 | ||
7836 | sim_add hv1 | |
7837 | as hv1 | |
7838 | ovs-vsctl add-br br-phys | |
7839 | ovn_attach n1 br-phys 192.168.0.1 | |
7840 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
7841 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
7842 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
7843 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
7844 | ofport-request=1 | |
7845 | ||
7846 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
7847 | set interface hv1-vif2 external-ids:iface-id=bar1 \ | |
7848 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
7849 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
7850 | ofport-request=2 | |
7851 | ||
7852 | sim_add hv2 | |
7853 | as hv2 | |
7854 | ovs-vsctl add-br br-phys | |
7855 | ovn_attach n1 br-phys 192.168.0.2 | |
7856 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
7857 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
7858 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
7859 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
7860 | ofport-request=1 | |
7861 | ||
7862 | sim_add hv3 | |
7863 | as hv3 | |
7864 | ovs-vsctl add-br br-phys | |
7865 | ovn_attach n1 br-phys 192.168.0.3 | |
7866 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
7867 | set interface hv3-vif1 external-ids:iface-id=bob1 \ | |
7868 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
7869 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
7870 | ofport-request=1 | |
7871 | ||
7872 | ||
7873 | ovn-nbctl create Logical_Router name=R1 | |
7874 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
7875 | ovn-nbctl create Logical_Router name=R3 options:chassis="hv3" | |
7876 | ||
7877 | ovn-nbctl ls-add foo | |
7878 | ovn-nbctl ls-add bar | |
7879 | ovn-nbctl ls-add alice | |
7880 | ovn-nbctl ls-add bob | |
7881 | ovn-nbctl ls-add join | |
7882 | ||
7883 | # Connect foo to R1 | |
7884 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
7885 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
7886 | options:router-port=foo addresses=\"00:00:01:01:02:03\" | |
7887 | ||
7888 | # Connect bar to R1 | |
7889 | ovn-nbctl lrp-add R1 bar 00:00:01:01:02:04 192.168.2.1/24 | |
7890 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar type=router \ | |
7891 | options:router-port=bar addresses=\"00:00:01:01:02:04\" | |
7892 | ||
7893 | # Connect alice to R2 | |
7894 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
7895 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
7896 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" | |
7897 | ||
7898 | # Connect bob to R3 | |
7899 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 172.16.1.2/24 | |
7900 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ | |
7901 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" | |
7902 | ||
7903 | # Connect R1 to join | |
7904 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 | |
7905 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ | |
7906 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' | |
7907 | ||
7908 | # Connect R2 to join | |
7909 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
7910 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ | |
7911 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' | |
7912 | ||
7913 | # Connect R3 to join | |
7914 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 | |
7915 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ | |
7916 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' | |
7917 | ||
7918 | # Install static routes with source ip address as the policy for routing. | |
7919 | # We want traffic from 'foo' to go via R2 and traffic of 'bar' to go via R3. | |
7920 | ovn-nbctl --policy="src-ip" lr-route-add R1 192.168.1.0/24 20.0.0.2 | |
7921 | ovn-nbctl --policy="src-ip" lr-route-add R1 192.168.2.0/24 20.0.0.3 | |
7922 | ||
7923 | # Install static routes with destination ip address as the policy for routing. | |
7924 | ovn-nbctl lr-route-add R2 192.168.0.0/16 20.0.0.1 | |
7925 | ||
7926 | ovn-nbctl lr-route-add R3 192.168.0.0/16 20.0.0.1 | |
7927 | ||
7928 | # Create logical port foo1 in foo | |
7929 | ovn-nbctl lsp-add foo foo1 \ | |
7930 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
7931 | ||
7932 | # Create logical port bar1 in bar | |
7933 | ovn-nbctl lsp-add bar bar1 \ | |
7934 | -- lsp-set-addresses bar1 "f0:00:00:01:02:04 192.168.2.2" | |
7935 | ||
7936 | # Create logical port alice1 in alice | |
7937 | ovn-nbctl lsp-add alice alice1 \ | |
7938 | -- lsp-set-addresses alice1 "f0:00:00:01:02:05 172.16.1.3" | |
7939 | ||
7940 | # Create logical port bob1 in bob | |
7941 | ovn-nbctl lsp-add bob bob1 \ | |
7942 | -- lsp-set-addresses bob1 "f0:00:00:01:02:06 172.16.1.4" | |
7943 | ||
7944 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
7945 | # packets for ARP resolution (native tunneling doesn't queue packets | |
7946 | # for ARP resolution). | |
74868f2c | 7947 | OVN_POPULATE_ARP |
440a9f4b GS |
7948 | |
7949 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7950 | # XXX This should be more systematic. | |
7951 | sleep 1 | |
7952 | ||
7953 | ip_to_hex() { | |
7954 | printf "%02x%02x%02x%02x" "$@" | |
7955 | } | |
7956 | trim_zeros() { | |
7957 | sed 's/\(00\)\{1,\}$//' | |
7958 | } | |
7959 | ||
7960 | # Send ip packets between foo1 and bar1 | |
7961 | # (East-west traffic should flow normally) | |
7962 | src_mac="f00000010203" | |
7963 | dst_mac="000001010203" | |
7964 | src_ip=`ip_to_hex 192 168 1 2` | |
7965 | dst_ip=`ip_to_hex 192 168 2 2` | |
7966 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7967 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
7968 | ||
7969 | # Send ip packets between foo1 and alice1 | |
7970 | src_mac="f00000010203" | |
7971 | dst_mac="000001010203" | |
7972 | src_ip=`ip_to_hex 192 168 1 2` | |
7973 | dst_ip=`ip_to_hex 172 16 1 3` | |
7974 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7975 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
2d9b49dd | 7976 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet |
440a9f4b GS |
7977 | |
7978 | # Send ip packets between bar1 and bob1 | |
7979 | src_mac="f00000010204" | |
7980 | dst_mac="000001010204" | |
7981 | src_ip=`ip_to_hex 192 168 2 2` | |
7982 | dst_ip=`ip_to_hex 172 16 1 4` | |
7983 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7984 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif2 $packet | |
7985 | #as hv1 ovs-appctl ofproto/trace br-int in_port=2 $packet | |
7986 | ||
7987 | # Packet to expect at bar1 | |
7988 | src_mac="000001010204" | |
7989 | dst_mac="f00000010204" | |
7990 | src_ip=`ip_to_hex 192 168 1 2` | |
7991 | dst_ip=`ip_to_hex 192 168 2 2` | |
7992 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7993 | echo $expected > expected | |
7994 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) | |
7995 | ||
7996 | # Packet to Expect at alice1 | |
7997 | src_mac="000002010203" | |
7998 | dst_mac="f00000010205" | |
7999 | src_ip=`ip_to_hex 192 168 1 2` | |
8000 | dst_ip=`ip_to_hex 172 16 1 3` | |
8001 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
8002 | echo $expected > expected | |
8003 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
8004 | ||
8005 | # Packet to Expect at bob1 | |
8006 | src_mac="000003010203" | |
8007 | dst_mac="f00000010206" | |
8008 | src_ip=`ip_to_hex 192 168 2 2` | |
8009 | dst_ip=`ip_to_hex 172 16 1 4` | |
8010 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
8011 | echo $expected > expected | |
8012 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [expected]) | |
8013 | ||
c4d0e4f2 | 8014 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
440a9f4b GS |
8015 | |
8016 | AT_CLEANUP | |
41a15b71 | 8017 | |
302eda27 NS |
8018 | AT_SETUP([ovn -- dns lookup : 1 HV, 2 LS, 2 LSPs/LS]) |
8019 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
8020 | ovn_start | |
8021 | ||
8022 | ovn-nbctl ls-add ls1 | |
8023 | ||
8024 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
8025 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 aef0::4" | |
8026 | ||
8027 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 aef0::4" | |
8028 | ||
8029 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
8030 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
8031 | ||
8032 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
8033 | ||
8034 | DNS1=`ovn-nbctl create DNS records={}` | |
8035 | DNS2=`ovn-nbctl create DNS records={}` | |
8036 | ||
8037 | ovn-nbctl set DNS $DNS1 records:vm1.ovn.org="10.0.0.4 aef0::4" | |
8038 | ovn-nbctl set DNS $DNS1 records:vm2.ovn.org="10.0.0.6 20.0.0.4" | |
8039 | ovn-nbctl set DNS $DNS2 records:vm3.ovn.org="40.0.0.4" | |
8040 | ||
8041 | ovn-nbctl set Logical_switch ls1 dns_records="$DNS1" | |
8042 | ||
8043 | net_add n1 | |
8044 | sim_add hv1 | |
8045 | ||
8046 | as hv1 | |
8047 | ovs-vsctl add-br br-phys | |
8048 | ovn_attach n1 br-phys 192.168.0.1 | |
8049 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
8050 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
8051 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
8052 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
8053 | ofport-request=1 | |
8054 | ||
8055 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
8056 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
8057 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
8058 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
8059 | ofport-request=2 | |
8060 | ||
74868f2c | 8061 | OVN_POPULATE_ARP |
302eda27 NS |
8062 | sleep 2 |
8063 | as hv1 ovs-vsctl show | |
8064 | ||
8065 | echo "*************************" | |
8066 | ovn-sbctl list DNS | |
8067 | echo "*************************" | |
8068 | ||
8069 | ip_to_hex() { | |
8070 | printf "%02x%02x%02x%02x" "$@" | |
8071 | } | |
8072 | ||
8073 | reset_pcap_file() { | |
8074 | local iface=$1 | |
8075 | local pcap_file=$2 | |
8076 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
8077 | options:rxq_pcap=dummy-rx.pcap | |
8078 | rm -f ${pcap_file}*.pcap | |
8079 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
8080 | options:rxq_pcap=${pcap_file}-rx.pcap | |
8081 | } | |
8082 | ||
8083 | # set_dns_params host_name | |
8084 | # Sets the dns_req_data and dns_resp_data | |
8085 | set_dns_params() { | |
8086 | local hname=$1 | |
8087 | local ttl=00000e10 | |
8088 | an_count=0001 | |
8089 | type=0001 | |
8090 | case $hname in | |
8091 | vm1) | |
8092 | # vm1.ovn.org | |
8093 | query_name=03766d31036f766e036f726700 | |
8094 | # IPv4 address - 10.0.0.4 | |
8095 | expected_dns_answer=${query_name}00010001${ttl}00040a000004 | |
8096 | ;; | |
8097 | vm2) | |
8098 | # vm2.ovn.org | |
8099 | query_name=03766d32036f766e036f726700 | |
8100 | # IPv4 address - 10.0.0.6 | |
8101 | expected_dns_answer=${query_name}00010001${ttl}00040a000006 | |
8102 | # IPv4 address - 20.0.0.4 | |
8103 | expected_dns_answer=${expected_dns_answer}${query_name}00010001${ttl}000414000004 | |
8104 | an_count=0002 | |
8105 | ;; | |
8106 | vm3) | |
8107 | # vm3.ovn.org | |
8108 | query_name=03766d33036f766e036f726700 | |
8109 | # IPv4 address - 40.0.0.4 | |
8110 | expected_dns_answer=${query_name}00010001${ttl}000428000004 | |
8111 | ;; | |
8112 | vm1_ipv6_only) | |
8113 | # vm1.ovn.org | |
8114 | query_name=03766d31036f766e036f726700 | |
8115 | # IPv6 address - aef0::4 | |
8116 | type=001c | |
8117 | expected_dns_answer=${query_name}${type}0001${ttl}0010aef00000000000000000000000000004 | |
8118 | ;; | |
8119 | vm1_ipv4_v6) | |
8120 | # vm1.ovn.org | |
8121 | query_name=03766d31036f766e036f726700 | |
8122 | type=00ff | |
8123 | an_count=0002 | |
8124 | # IPv4 address - 10.0.0.4 | |
8125 | # IPv6 address - aef0::4 | |
8126 | expected_dns_answer=${query_name}00010001${ttl}00040a000004 | |
8127 | expected_dns_answer=${expected_dns_answer}${query_name}001c0001${ttl}0010 | |
8128 | expected_dns_answer=${expected_dns_answer}aef00000000000000000000000000004 | |
8129 | ;; | |
8130 | vm1_invalid_type) | |
8131 | # vm1.ovn.org | |
8132 | query_name=03766d31036f766e036f726700 | |
8133 | # IPv6 address - aef0::4 | |
8134 | type=0002 | |
8135 | ;; | |
8136 | vm1_incomplete) | |
8137 | # set type to none | |
8138 | type='' | |
8139 | esac | |
8140 | # TTL - 3600 | |
8141 | local dns_req_header=010201200001000000000000 | |
8142 | local dns_resp_header=010281200001${an_count}00000000 | |
8143 | dns_req_data=${dns_req_header}${query_name}${type}0001 | |
8144 | dns_resp_data=${dns_resp_header}${query_name}${type}0001${expected_dns_answer} | |
8145 | } | |
8146 | ||
8147 | # This shell function sends a DNS request packet | |
8148 | # test_dns INPORT SRC_MAC DST_MAC SRC_IP DST_IP DNS_QUERY EXPEC | |
8149 | test_dns() { | |
8150 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 dns_reply=$6 | |
8151 | local dns_query_data=$7 | |
8152 | shift; shift; shift; shift; shift; shift; shift; | |
8153 | # Packet size => IPv4 header (20) + UDP header (8) + | |
8154 | # DNS data (header + query) | |
8155 | ip_len=`expr 28 + ${#dns_query_data} / 2` | |
8156 | udp_len=`expr $ip_len - 20` | |
8157 | ip_len=$(printf "%x" $ip_len) | |
8158 | udp_len=$(printf "%x" $udp_len) | |
8159 | local request=${dst_mac}${src_mac}0800450000${ip_len}0000000080110000 | |
8160 | request=${request}${src_ip}${dst_ip}9234003500${udp_len}0000 | |
8161 | # dns data | |
8162 | request=${request}${dns_query_data} | |
8163 | ||
8164 | if test $dns_reply != 0; then | |
8165 | local dns_reply=$1 | |
8166 | ip_len=`expr 28 + ${#dns_reply} / 2` | |
8167 | udp_len=`expr $ip_len - 20` | |
8168 | ip_len=$(printf "%x" $ip_len) | |
8169 | udp_len=$(printf "%x" $udp_len) | |
8170 | local reply=${src_mac}${dst_mac}0800450000${ip_len}0000000080110000 | |
8171 | reply=${reply}${dst_ip}${src_ip}0035923400${udp_len}0000${dns_reply} | |
8172 | echo $reply >> $inport.expected | |
8173 | else | |
8174 | for outport; do | |
8175 | echo $request >> $outport.expected | |
8176 | done | |
8177 | fi | |
8178 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
8179 | } | |
8180 | ||
f8e79d82 MM |
8181 | test_dns6() { |
8182 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 dns_reply=$6 | |
8183 | local dns_query_data=$7 | |
8184 | shift; shift; shift; shift; shift; shift; shift; | |
8185 | # Packet size => UDP header (8) + | |
8186 | # DNS data (header + query) | |
8187 | ip_len=`expr 8 + ${#dns_query_data} / 2` | |
8188 | udp_len=$ip_len | |
8189 | ip_len=$(printf "%x" $ip_len) | |
8190 | udp_len=$(printf "%x" $udp_len) | |
8191 | local request=${dst_mac}${src_mac}86dd6000000000${ip_len}11ff${src_ip}${dst_ip} | |
8192 | request=${request}9234003500${udp_len}0000 | |
8193 | #dns data | |
8194 | request=${request}${dns_query_data} | |
8195 | ||
8196 | if test $dns_reply != 0; then | |
8197 | local dns_reply=$1 | |
8198 | ip_len=`expr 8 + ${#dns_reply} / 2` | |
8199 | udp_len=$ip_len | |
8200 | ip_len=$(printf "%x" $ip_len) | |
8201 | udp_len=$(printf "%x" $udp_len) | |
8202 | local reply=${src_mac}${dst_mac}86dd6000000000${ip_len}11ff${dst_ip}${src_ip} | |
8203 | reply=${reply}0035923400${udp_len}0000${dns_reply} | |
8204 | echo $reply >> $inport.expected | |
8205 | else | |
8206 | for outport; do | |
8207 | echo $request >> $outport.expected | |
8208 | done | |
8209 | fi | |
8210 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
8211 | } | |
8212 | ||
302eda27 NS |
8213 | AT_CAPTURE_FILE([ofctl_monitor0.log]) |
8214 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
8215 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
8216 | ||
8217 | set_dns_params vm2 | |
8218 | src_ip=`ip_to_hex 10 0 0 4` | |
8219 | dst_ip=`ip_to_hex 10 0 0 1` | |
8220 | dns_reply=1 | |
8221 | test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
8222 | ||
8223 | # NXT_RESUMEs should be 1. | |
8224 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8225 | ||
8226 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
8227 | cat 1.expected | cut -c -48 > expout | |
8228 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
8229 | # Skipping the IPv4 checksum. | |
8230 | cat 1.expected | cut -c 53- > expout | |
8231 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
8232 | ||
8233 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8234 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8235 | rm -f 1.expected | |
8236 | rm -f 2.expected | |
8237 | ||
8238 | set_dns_params vm1 | |
8239 | src_ip=`ip_to_hex 10 0 0 6` | |
8240 | dst_ip=`ip_to_hex 10 0 0 1` | |
8241 | dns_reply=1 | |
8242 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
8243 | ||
8244 | # NXT_RESUMEs should be 2. | |
8245 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8246 | ||
8247 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
8248 | cat 2.expected | cut -c -48 > expout | |
8249 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
8250 | # Skipping the IPv4 checksum. | |
8251 | cat 2.expected | cut -c 53- > expout | |
8252 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
8253 | ||
8254 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8255 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8256 | rm -f 1.expected | |
8257 | rm -f 2.expected | |
8258 | ||
8259 | # Clear the query name options for ls1-lp2 | |
8260 | ovn-nbctl --wait=hv remove DNS $DNS1 records vm2.ovn.org | |
8261 | ||
8262 | set_dns_params vm2 | |
8263 | src_ip=`ip_to_hex 10 0 0 4` | |
8264 | dst_ip=`ip_to_hex 10 0 0 1` | |
8265 | dns_reply=0 | |
8266 | test_dns 1 f00000000001 f00000000002 $src_ip $dst_ip $dns_reply $dns_req_data | |
8267 | ||
8268 | # NXT_RESUMEs should be 3. | |
8269 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8270 | ||
8271 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
8272 | AT_CHECK([cat 1.packets], [0], []) | |
8273 | ||
8274 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8275 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8276 | rm -f 1.expected | |
8277 | rm -f 2.expected | |
8278 | ||
8279 | # Clear the query name for ls1-lp1 | |
8280 | # Since ls1 has no query names configued, | |
8281 | # ovn-northd should not add the DNS flows. | |
8282 | ovn-nbctl --wait=hv remove DNS $DNS1 records vm1.ovn.org | |
8283 | ||
8284 | set_dns_params vm1 | |
8285 | src_ip=`ip_to_hex 10 0 0 6` | |
8286 | dst_ip=`ip_to_hex 10 0 0 1` | |
8287 | dns_reply=0 | |
8288 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data | |
8289 | ||
8290 | # NXT_RESUMEs should be 3 only. | |
8291 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8292 | ||
8293 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
8294 | AT_CHECK([cat 2.packets], [0], []) | |
8295 | ||
8296 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8297 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8298 | rm -f 1.expected | |
8299 | rm -f 2.expected | |
8300 | ||
8301 | # Test IPv6 (AAAA records) using IPv4 packet. | |
8302 | # Add back the DNS options for ls1-lp1. | |
4f4ac4bb | 8303 | ovn-nbctl --wait=hv set DNS $DNS1 records:vm1.ovn.org="10.0.0.4 aef0::4" |
302eda27 NS |
8304 | |
8305 | set_dns_params vm1_ipv6_only | |
8306 | src_ip=`ip_to_hex 10 0 0 6` | |
8307 | dst_ip=`ip_to_hex 10 0 0 1` | |
8308 | dns_reply=1 | |
8309 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
8310 | ||
8311 | # NXT_RESUMEs should be 4. | |
8312 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8313 | ||
8314 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
8315 | cat 2.expected | cut -c -48 > expout | |
8316 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
8317 | # Skipping the IPv4 checksum. | |
8318 | cat 2.expected | cut -c 53- > expout | |
8319 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
8320 | ||
8321 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8322 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8323 | rm -f 1.expected | |
8324 | rm -f 2.expected | |
8325 | ||
8326 | # Test both IPv4 (A) and IPv6 (AAAA records) using IPv4 packet. | |
8327 | set_dns_params vm1_ipv4_v6 | |
8328 | src_ip=`ip_to_hex 10 0 0 6` | |
8329 | dst_ip=`ip_to_hex 10 0 0 1` | |
8330 | dns_reply=1 | |
8331 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
8332 | ||
8333 | # NXT_RESUMEs should be 5. | |
8334 | OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8335 | ||
8336 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
8337 | cat 2.expected | cut -c -48 > expout | |
8338 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
8339 | # Skipping the IPv4 checksum. | |
8340 | cat 2.expected | cut -c 53- > expout | |
8341 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
8342 | ||
8343 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8344 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8345 | rm -f 1.expected | |
8346 | rm -f 2.expected | |
8347 | ||
8348 | # Invalid type. | |
8349 | set_dns_params vm1_invalid_type | |
8350 | src_ip=`ip_to_hex 10 0 0 6` | |
8351 | dst_ip=`ip_to_hex 10 0 0 1` | |
8352 | dns_reply=0 | |
8353 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data | |
8354 | ||
8355 | # NXT_RESUMEs should be 6. | |
8356 | OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8357 | ||
8358 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
8359 | AT_CHECK([cat 2.packets], [0], []) | |
8360 | ||
8361 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8362 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8363 | rm -f 1.expected | |
8364 | rm -f 2.expected | |
8365 | ||
8366 | # Incomplete DNS packet. | |
8367 | set_dns_params vm1_incomplete | |
8368 | src_ip=`ip_to_hex 10 0 0 6` | |
8369 | dst_ip=`ip_to_hex 10 0 0 1` | |
8370 | dns_reply=0 | |
8371 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data | |
8372 | ||
8373 | # NXT_RESUMEs should be 7. | |
8374 | OVS_WAIT_UNTIL([test 7 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8375 | ||
8376 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
8377 | AT_CHECK([cat 2.packets], [0], []) | |
8378 | ||
8379 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8380 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8381 | rm -f 1.expected | |
8382 | rm -f 2.expected | |
8383 | ||
8384 | # Add one more DNS record to the ls1. | |
8385 | ovn-nbctl --wait=hv set Logical_switch ls1 dns_records="$DNS1 $DNS2" | |
8386 | ||
8387 | set_dns_params vm3 | |
8388 | src_ip=`ip_to_hex 10 0 0 4` | |
8389 | dst_ip=`ip_to_hex 10 0 0 1` | |
8390 | dns_reply=1 | |
8391 | test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
8392 | ||
8393 | # NXT_RESUMEs should be 8. | |
8394 | OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8395 | ||
8396 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
8397 | cat 1.expected | cut -c -48 > expout | |
8398 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
8399 | # Skipping the IPv4 checksum. | |
8400 | cat 1.expected | cut -c 53- > expout | |
8401 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
8402 | ||
8403 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8404 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8405 | rm -f 1.expected | |
8406 | rm -f 2.expected | |
8407 | ||
f8e79d82 MM |
8408 | # Try DNS query over IPv6 |
8409 | set_dns_params vm1 | |
8410 | src_ip=aef00000000000000000000000000004 | |
8411 | dst_ip=aef00000000000000000000000000001 | |
8412 | dns_reply=1 | |
8413 | test_dns6 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
8414 | ||
8415 | # NXT_RESUMEs should be 9. | |
8416 | OVS_WAIT_UNTIL([test 9 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
8417 | ||
8418 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
b75f2651 MM |
8419 | # Skipping the UDP checksum. |
8420 | cat 1.expected | cut -c 1-120,125- > expout | |
8421 | AT_CHECK([cat 1.packets | cut -c 1-120,125-], [0], [expout]) | |
f8e79d82 MM |
8422 | |
8423 | reset_pcap_file hv1-vif1 hv1/vif1 | |
8424 | reset_pcap_file hv1-vif2 hv1/vif2 | |
8425 | rm -f 1.expected | |
8426 | rm -f 2.expected | |
8427 | ||
c4d0e4f2 | 8428 | OVN_CLEANUP([hv1]) |
302eda27 | 8429 | |
302eda27 NS |
8430 | AT_CLEANUP |
8431 | ||
75f9e007 | 8432 | AT_SETUP([ovn -- 4 HV, 1 LS, 1 LR, packet test with HA distributed router gateway port]) |
1da17a0b | 8433 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
8434 | ovn_start | |
8435 | ||
8436 | net_add n1 | |
8437 | ||
8438 | sim_add hv1 | |
8439 | as hv1 | |
8440 | ovs-vsctl add-br br-phys | |
8441 | ovn_attach n1 br-phys 192.168.0.1 | |
8442 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
8443 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
8444 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
8445 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
8446 | ofport-request=1 | |
8447 | ||
8448 | sim_add gw1 | |
8449 | as gw1 | |
8450 | ovs-vsctl add-br br-phys | |
8451 | ovn_attach n1 br-phys 192.168.0.2 | |
8452 | ||
8453 | sim_add gw2 | |
8454 | as gw2 | |
8455 | ovs-vsctl add-br br-phys | |
8456 | ovn_attach n1 br-phys 192.168.0.4 | |
8457 | ||
8458 | sim_add ext1 | |
8459 | as ext1 | |
8460 | ovs-vsctl add-br br-phys | |
8461 | ovn_attach n1 br-phys 192.168.0.3 | |
8462 | ovs-vsctl -- add-port br-int ext1-vif1 -- \ | |
8463 | set interface ext1-vif1 external-ids:iface-id=outside1 \ | |
8464 | options:tx_pcap=ext1/vif1-tx.pcap \ | |
8465 | options:rxq_pcap=ext1/vif1-rx.pcap \ | |
8466 | ofport-request=1 | |
8467 | ||
8468 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
8469 | # packets for ARP resolution (native tunneling doesn't queue packets | |
8470 | # for ARP resolution). | |
74868f2c | 8471 | OVN_POPULATE_ARP |
1da17a0b | 8472 | |
8473 | ovn-nbctl create Logical_Router name=R1 | |
8474 | ||
8475 | ovn-nbctl ls-add foo | |
8476 | ovn-nbctl ls-add alice | |
8477 | ovn-nbctl ls-add outside | |
8478 | ||
8479 | # Connect foo to R1 | |
8480 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
8481 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
8482 | type=router options:router-port=foo \ | |
8483 | -- lsp-set-addresses rp-foo router | |
8484 | ||
8485 | # Connect alice to R1 as distributed router gateway port on gw1 | |
8486 | ovn-nbctl lrp-add R1 alice 00:00:02:01:02:03 172.16.1.1/24 | |
8487 | ||
8488 | ovn-nbctl \ | |
8489 | --id=@gc0 create Gateway_Chassis name=alice_gw1 \ | |
8490 | chassis_name=gw1 \ | |
8491 | priority=20 -- \ | |
8492 | --id=@gc1 create Gateway_Chassis name=alice_gw2 \ | |
8493 | chassis_name=gw2 \ | |
8494 | priority=10 -- \ | |
8495 | set Logical_Router_Port alice 'gateway_chassis=[@gc0,@gc1]' | |
8496 | ||
8497 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
8498 | type=router options:router-port=alice \ | |
8499 | -- lsp-set-addresses rp-alice router | |
8500 | ||
8501 | # Create logical port foo1 in foo | |
8502 | ovn-nbctl lsp-add foo foo1 \ | |
8503 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
8504 | ||
8505 | # Create logical port outside1 in outside | |
8506 | ovn-nbctl lsp-add outside outside1 \ | |
8507 | -- lsp-set-addresses outside1 "f0:00:00:01:02:04 172.16.1.3" | |
8508 | ||
8509 | # Create localnet port in alice | |
8510 | ovn-nbctl lsp-add alice ln-alice | |
8511 | ovn-nbctl lsp-set-addresses ln-alice unknown | |
8512 | ovn-nbctl lsp-set-type ln-alice localnet | |
8513 | ovn-nbctl lsp-set-options ln-alice network_name=phys | |
8514 | ||
8515 | # Create localnet port in outside | |
8516 | ovn-nbctl lsp-add outside ln-outside | |
8517 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
8518 | ovn-nbctl lsp-set-type ln-outside localnet | |
8519 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
8520 | ||
8521 | # Create bridge-mappings on gw1, gw2 and ext1, hv1 doesn't need | |
8522 | # mapping to the external network, is the one generating packets | |
8523 | as gw1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8524 | as gw2 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8525 | as ext1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8526 | ||
8527 | AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) | |
8528 | ||
8529 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
8530 | # XXX This should be more systematic. | |
8531 | sleep 2 | |
8532 | ||
8533 | ip_to_hex() { | |
8534 | printf "%02x%02x%02x%02x" "$@" | |
8535 | } | |
8536 | ||
8537 | reset_pcap_file() { | |
8538 | local iface=$1 | |
8539 | local pcap_file=$2 | |
8540 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
8541 | options:rxq_pcap=dummy-rx.pcap | |
8542 | rm -f ${pcap_file}*.pcap | |
8543 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
8544 | options:rxq_pcap=${pcap_file}-rx.pcap | |
8545 | } | |
8546 | ||
8547 | test_ip_packet() | |
8548 | { | |
8549 | local active_gw=$1 | |
8550 | local backup_gw=$2 | |
8e37d8fb | 8551 | local backup_vswitchd_dead=$3 |
1da17a0b | 8552 | |
8553 | # Send ip packet between foo1 and outside1 | |
8554 | src_mac="f00000010203" # foo1 mac | |
8555 | dst_mac="000001010203" # rp-foo mac (internal router leg) | |
8556 | src_ip=`ip_to_hex 192 168 1 2` | |
8557 | dst_ip=`ip_to_hex 172 16 1 3` | |
8558 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
8559 | ||
8560 | # ARP request packet to expect at outside1 | |
8561 | #arp_request=ffffffffffff${src_mac}08060001080006040001${src_mac}${src_ip}000000000000${dst_ip} | |
8562 | ||
8563 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
8564 | ||
8565 | # Send ARP reply from outside1 back to the router | |
8566 | # XXX: note, we could avoid this if we plug this port into a netns | |
8567 | # and setup the IP address into the port, so the kernel would simply reply | |
8568 | src_mac="000002010203" | |
8569 | reply_mac="f00000010204" | |
8570 | dst_ip=`ip_to_hex 172 16 1 3` | |
8571 | src_ip=`ip_to_hex 172 16 1 1` | |
8572 | arp_reply=${src_mac}${reply_mac}08060001080006040002${reply_mac}${dst_ip}${src_mac}${src_ip} | |
8573 | ||
8574 | as ext1 ovs-appctl netdev-dummy/receive ext1-vif1 $arp_reply | |
8575 | ||
86c9d79a NS |
8576 | OVS_WAIT_UNTIL([ |
8577 | test `as $active_gw ovs-ofctl dump-flows br-int | grep table=66 | \ | |
8578 | grep actions=mod_dl_dst:f0:00:00:01:02:04 | wc -l` -eq 1 | |
8579 | ]) | |
8580 | ||
1da17a0b | 8581 | # Packet to Expect at ext1 chassis, outside1 port |
8582 | src_mac="000002010203" | |
8583 | dst_mac="f00000010204" | |
8584 | src_ip=`ip_to_hex 192 168 1 2` | |
8585 | dst_ip=`ip_to_hex 172 16 1 3` | |
8586 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
8587 | echo $expected > ext1-vif1.expected | |
d65586b6 NS |
8588 | exp_gw_ip_garp=ffffffffffff00000201020308060001080006040001000002010203ac100101000000000000ac100101 |
8589 | echo $exp_gw_ip_garp >> ext1-vif1.expected | |
1da17a0b | 8590 | as $active_gw reset_pcap_file br-phys_n1 $active_gw/br-phys_n1 |
8e37d8fb NS |
8591 | |
8592 | if test $backup_vswitchd_dead != 1; then | |
8593 | # Reset the file only if vswitchd in backup gw is alive | |
8594 | as $backup_gw reset_pcap_file br-phys_n1 $backup_gw/br-phys_n1 | |
8595 | fi | |
1da17a0b | 8596 | as ext1 reset_pcap_file ext1-vif1 ext1/vif1 |
8597 | ||
8598 | # Resend packet from foo1 to outside1 | |
8599 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
8600 | ||
8601 | sleep 1 | |
8602 | ||
8603 | OVN_CHECK_PACKETS([ext1/vif1-tx.pcap], [ext1-vif1.expected]) | |
8604 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $active_gw/br-phys_n1-tx.pcap > packets | |
d65586b6 | 8605 | cat packets | grep $expected > exp |
fbe67a7d NS |
8606 | # Its possible that $active_gw/br-phys_n1-tx.pcap may have received multiple |
8607 | # garp packets. So consider only the first packet. | |
8608 | cat packets | grep $exp_gw_ip_garp | head -1 >> exp | |
d65586b6 NS |
8609 | AT_CHECK([cat exp], [0], [expout]) |
8610 | rm -f expout | |
8e37d8fb NS |
8611 | if test $backup_vswitchd_dead != 1; then |
8612 | # Check for backup gw only if vswitchd is alive | |
8613 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $backup_gw/br-phys_n1-tx.pcap > packets | |
8614 | AT_CHECK([grep $expected packets | sort], [0], []) | |
8615 | fi | |
1da17a0b | 8616 | } |
8617 | ||
8e37d8fb | 8618 | test_ip_packet gw1 gw2 0 |
1da17a0b | 8619 | |
75f9e007 GZ |
8620 | ovn-nbctl --timeout=3 --wait=hv \ |
8621 | --id=@gc0 create Gateway_Chassis name=alice_gw1 \ | |
8622 | chassis_name=gw1 \ | |
8623 | priority=10 -- \ | |
8624 | --id=@gc1 create Gateway_Chassis name=alice_gw2 \ | |
8625 | chassis_name=gw2 \ | |
8626 | priority=20 -- \ | |
8627 | set Logical_Router_Port alice 'gateway_chassis=[@gc0,@gc1]' | |
8628 | ||
8e37d8fb NS |
8629 | test_ip_packet gw2 gw1 0 |
8630 | ||
8631 | # Get the claim count of both gw1 and gw2. | |
8632 | gw1_claim_ct=`grep "cr-alice: Claiming" gw1/ovn-controller.log | wc -l` | |
8633 | gw2_claim_ct=`grep "cr-alice: Claiming" gw2/ovn-controller.log | wc -l` | |
8634 | ||
8635 | # Stop ovs-vswitchd in gw2. gw1 should claim the gateway port. | |
8636 | as gw2 | |
8637 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
8638 | ||
8639 | # gw1 should claim the cr-alice and the claim count of gw1 should be | |
8640 | # incremented by 1. | |
8641 | gw1_claim_ct=$((gw1_claim_ct+1)) | |
8642 | ||
8643 | OVS_WAIT_UNTIL([test $gw1_claim_ct = `cat gw1/ovn-controller.log \ | |
8644 | | grep -c "cr-alice: Claiming"`]) | |
8645 | ||
8646 | AT_CHECK([test $gw2_claim_ct = `cat gw2/ovn-controller.log | \ | |
8647 | grep -c "cr-alice: Claiming"`]) | |
8648 | ||
8649 | test_ip_packet gw1 gw2 1 | |
8650 | ||
8651 | as gw2 | |
8652 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
8653 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
8654 | ||
8655 | OVN_CLEANUP([hv1],[gw1],[ext1]) | |
75f9e007 | 8656 | |
75f9e007 GZ |
8657 | AT_CLEANUP |
8658 | ||
8659 | AT_SETUP([ovn -- 4 HV, 3 LS, 2 LR, packet test with HA distributed router gateway port]) | |
8660 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
8661 | ovn_start | |
8662 | ||
8663 | net_add n1 | |
8664 | ||
8665 | sim_add hv1 | |
8666 | as hv1 | |
8667 | ovs-vsctl add-br br-phys | |
8668 | ovn_attach n1 br-phys 192.168.0.1 | |
8669 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
8670 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
8671 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
8672 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
8673 | ofport-request=1 | |
8674 | ||
8675 | sim_add gw1 | |
8676 | as gw1 | |
8677 | ovs-vsctl add-br br-phys | |
8678 | ovn_attach n1 br-phys 192.168.0.2 | |
8679 | ||
8680 | sim_add gw2 | |
8681 | as gw2 | |
8682 | ovs-vsctl add-br br-phys | |
8683 | ovn_attach n1 br-phys 192.168.0.4 | |
8684 | ||
8685 | sim_add ext1 | |
8686 | as ext1 | |
8687 | ovs-vsctl add-br br-phys | |
8688 | ovn_attach n1 br-phys 192.168.0.3 | |
8689 | ovs-vsctl -- add-port br-int ext1-vif1 -- \ | |
8690 | set interface ext1-vif1 external-ids:iface-id=outside1 \ | |
8691 | options:tx_pcap=ext1/vif1-tx.pcap \ | |
8692 | options:rxq_pcap=ext1/vif1-rx.pcap \ | |
8693 | ofport-request=1 | |
8694 | ||
8695 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
8696 | # packets for ARP resolution (native tunneling doesn't queue packets | |
8697 | # for ARP resolution). | |
74868f2c | 8698 | OVN_POPULATE_ARP |
75f9e007 GZ |
8699 | |
8700 | ovn-nbctl create Logical_Router name=R0 | |
8701 | ovn-nbctl create Logical_Router name=R1 | |
8702 | ||
8703 | ovn-nbctl ls-add foo | |
8704 | ovn-nbctl ls-add join | |
8705 | ovn-nbctl ls-add alice | |
8706 | ovn-nbctl ls-add outside | |
8707 | ||
8708 | #Connect foo to R0 | |
8709 | ovn-nbctl lrp-add R0 R0-foo 00:00:01:01:02:03 192.168.1.1/24 | |
8710 | ovn-nbctl lsp-add foo foo-R0 -- set Logical_Switch_Port foo-R0 \ | |
8711 | type=router options:router-port=R0-foo \ | |
8712 | -- lsp-set-addresses foo-R0 router | |
8713 | ||
8714 | #Connect R0 to join | |
8715 | ovn-nbctl lrp-add R0 R0-join 00:00:0d:01:02:03 100.60.1.1/24 | |
8716 | ovn-nbctl lsp-add join join-R0 -- set Logical_Switch_Port join-R0 \ | |
8717 | type=router options:router-port=R0-join \ | |
8718 | -- lsp-set-addresses join-R0 router | |
8719 | ||
8720 | #Connect join to R1 | |
8721 | ovn-nbctl lrp-add R1 R1-join 00:00:0e:01:02:03 100.60.1.2/24 | |
8722 | ovn-nbctl lsp-add join join-R1 -- set Logical_Switch_Port join-R1 \ | |
8723 | type=router options:router-port=R1-join \ | |
8724 | -- lsp-set-addresses join-R1 router | |
8725 | ||
8726 | #add route rules | |
8727 | ovn-nbctl lr-route-add R0 0.0.0.0/0 100.60.1.2 | |
8728 | ovn-nbctl lr-route-add R1 192.168.0.0/16 100.60.1.1 | |
8729 | ||
8730 | # Connect alice to R1 as distributed router gateway port on gw1 | |
8731 | ovn-nbctl lrp-add R1 alice 00:00:02:01:02:03 172.16.1.1/24 | |
8732 | ||
8733 | ovn-nbctl \ | |
8734 | --id=@gc0 create Gateway_Chassis name=alice_gw1 \ | |
8735 | chassis_name=gw1 \ | |
8736 | priority=20 -- \ | |
8737 | --id=@gc1 create Gateway_Chassis name=alice_gw2 \ | |
8738 | chassis_name=gw2 \ | |
8739 | priority=10 -- \ | |
8740 | set Logical_Router_Port alice 'gateway_chassis=[@gc0,@gc1]' | |
8741 | ||
8742 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
8743 | type=router options:router-port=alice \ | |
8744 | -- lsp-set-addresses rp-alice router | |
8745 | ||
8746 | # Create logical port foo1 in foo | |
8747 | ovn-nbctl lsp-add foo foo1 \ | |
8748 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
8749 | ||
8750 | # Create logical port outside1 in outside | |
8751 | ovn-nbctl lsp-add outside outside1 \ | |
8752 | -- lsp-set-addresses outside1 "f0:00:00:01:02:04 172.16.1.3" | |
8753 | ||
8754 | # Create localnet port in alice | |
8755 | ovn-nbctl lsp-add alice ln-alice | |
8756 | ovn-nbctl lsp-set-addresses ln-alice unknown | |
8757 | ovn-nbctl lsp-set-type ln-alice localnet | |
8758 | ovn-nbctl lsp-set-options ln-alice network_name=phys | |
8759 | ||
8760 | # Create localnet port in outside | |
8761 | ovn-nbctl lsp-add outside ln-outside | |
8762 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
8763 | ovn-nbctl lsp-set-type ln-outside localnet | |
8764 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
8765 | ||
8766 | # Create bridge-mappings on gw1, gw2 and ext1, hv1 doesn't need | |
8767 | # mapping to the external network, is the one generating packets | |
8768 | as gw1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8769 | as gw2 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8770 | as ext1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8771 | ||
8772 | AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) | |
8773 | ||
1be1e0e5 NS |
8774 | # hv1 should be in 'ref_chassis' of the ha_chasssi_group as logical |
8775 | # switch 'foo' can reach the router 'R1' (which has gw router port) | |
8776 | # via foo1 -> foo -> R0 -> join -> R1 | |
8777 | hv1_ch_uuid=`ovn-sbctl --bare --columns _uuid find chassis name="hv1"` | |
8778 | OVS_WAIT_UNTIL( | |
8779 | [ref_ch_list=`ovn-sbctl --bare --columns ref_chassis find ha_chassis_group | sort` | |
8780 | # Trim the spaces. | |
8781 | ref_ch_list=`echo $ref_ch_list | sed 's/ //g'` | |
8782 | test "$hv1_ch_uuid" = "$ref_ch_list"]) | |
8783 | ||
75f9e007 GZ |
8784 | # Allow some time for ovn-northd and ovn-controller to catch up. |
8785 | # XXX This should be more systematic. | |
8786 | sleep 2 | |
8787 | ||
8788 | ip_to_hex() { | |
8789 | printf "%02x%02x%02x%02x" "$@" | |
8790 | } | |
8791 | ||
8792 | reset_pcap_file() { | |
8793 | local iface=$1 | |
8794 | local pcap_file=$2 | |
8795 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
8796 | options:rxq_pcap=dummy-rx.pcap | |
8797 | rm -f ${pcap_file}*.pcap | |
8798 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
8799 | options:rxq_pcap=${pcap_file}-rx.pcap | |
8800 | } | |
8801 | ||
8802 | test_ip_packet() | |
8803 | { | |
8804 | local active_gw=$1 | |
8805 | local backup_gw=$2 | |
8806 | ||
8807 | # Send ip packet between foo1 and outside1 | |
8808 | src_mac="f00000010203" # foo1 mac | |
8809 | dst_mac="000001010203" # foo-R0 mac (internal router leg) | |
8810 | src_ip=`ip_to_hex 192 168 1 2` | |
8811 | dst_ip=`ip_to_hex 172 16 1 3` | |
8812 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
8813 | ||
8814 | # ARP request packet to expect at outside1 | |
8815 | #arp_request=ffffffffffff${src_mac}08060001080006040001${src_mac}${src_ip}000000000000${dst_ip} | |
8816 | ||
8817 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
8818 | ||
8819 | # Send ARP reply from outside1 back to the router | |
8820 | # XXX: note, we could avoid this if we plug this port into a netns | |
8821 | # and setup the IP address into the port, so the kernel would simply reply | |
8822 | src_mac="000002010203" | |
8823 | reply_mac="f00000010204" | |
8824 | dst_ip=`ip_to_hex 172 16 1 3` | |
8825 | src_ip=`ip_to_hex 172 16 1 1` | |
8826 | arp_reply=${src_mac}${reply_mac}08060001080006040002${reply_mac}${dst_ip}${src_mac}${src_ip} | |
8827 | ||
8828 | as ext1 ovs-appctl netdev-dummy/receive ext1-vif1 $arp_reply | |
8829 | ||
86c9d79a NS |
8830 | OVS_WAIT_UNTIL([ |
8831 | test `as $active_gw ovs-ofctl dump-flows br-int | grep table=66 | \ | |
8832 | grep actions=mod_dl_dst:f0:00:00:01:02:04 | wc -l` -eq 1 | |
8833 | ]) | |
8834 | ||
75f9e007 GZ |
8835 | # Packet to Expect at ext1 chassis, outside1 port |
8836 | src_mac="000002010203" | |
8837 | dst_mac="f00000010204" | |
8838 | src_ip=`ip_to_hex 192 168 1 2` | |
8839 | dst_ip=`ip_to_hex 172 16 1 3` | |
8840 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
8841 | echo $expected > ext1-vif1.expected | |
d65586b6 NS |
8842 | exp_gw_ip_garp=ffffffffffff00000201020308060001080006040001000002010203ac100101000000000000ac100101 |
8843 | echo $exp_gw_ip_garp >> ext1-vif1.expected | |
75f9e007 GZ |
8844 | |
8845 | as $active_gw reset_pcap_file br-phys_n1 $active_gw/br-phys_n1 | |
8846 | as $backup_gw reset_pcap_file br-phys_n1 $backup_gw/br-phys_n1 | |
8847 | as ext1 reset_pcap_file ext1-vif1 ext1/vif1 | |
8848 | ||
8849 | # Resend packet from foo1 to outside1 | |
8850 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
8851 | ||
75f9e007 GZ |
8852 | OVN_CHECK_PACKETS([ext1/vif1-tx.pcap], [ext1-vif1.expected]) |
8853 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $active_gw/br-phys_n1-tx.pcap > packets | |
d65586b6 | 8854 | cat packets | grep $expected > exp |
fbe67a7d | 8855 | cat packets | grep $exp_gw_ip_garp | head -1 >> exp |
d65586b6 NS |
8856 | AT_CHECK([cat exp], [0], [expout]) |
8857 | ||
75f9e007 GZ |
8858 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $backup_gw/br-phys_n1-tx.pcap > packets |
8859 | AT_CHECK([grep $expected packets | sort], [0], []) | |
8860 | } | |
8861 | ||
8862 | test_ip_packet gw1 gw2 | |
8863 | ||
8e1d9349 | 8864 | ovn-nbctl --timeout=3 --wait=hv \ |
1da17a0b | 8865 | --id=@gc0 create Gateway_Chassis name=alice_gw1 \ |
8866 | chassis_name=gw1 \ | |
8867 | priority=10 -- \ | |
8868 | --id=@gc1 create Gateway_Chassis name=alice_gw2 \ | |
8869 | chassis_name=gw2 \ | |
8870 | priority=20 -- \ | |
8871 | set Logical_Router_Port alice 'gateway_chassis=[@gc0,@gc1]' | |
8872 | ||
8873 | test_ip_packet gw2 gw1 | |
8874 | ||
8875 | OVN_CLEANUP([hv1],[gw1],[gw2],[ext1]) | |
8876 | AT_CLEANUP | |
8877 | ||
41a15b71 MS |
8878 | AT_SETUP([ovn -- 1 LR with distributed router gateway port]) |
8879 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
8880 | ovn_start | |
8881 | ||
8882 | # Logical network: | |
8883 | # One LR R1 that has switches foo (192.168.1.0/24) and | |
8884 | # alice (172.16.1.0/24) connected to it. The logical port | |
8885 | # between R1 and alice has a "redirect-chassis" specified, | |
8886 | # i.e. it is the distributed router gateway port. | |
8887 | # Switch alice also has a localnet port defined. | |
8888 | # An additional switch outside has a localnet port and the | |
8889 | # same subnet as alice (172.16.1.0/24). | |
8890 | ||
8891 | # Physical network: | |
8892 | # Three hypervisors hv[123]. | |
8893 | # hv1 hosts vif foo1. | |
8894 | # hv2 is the "redirect-chassis" that hosts the distributed | |
8895 | # router gateway port. | |
8896 | # hv3 hosts vif outside1. | |
8897 | # In order to show that connectivity works only through hv2, | |
8898 | # an initial round of tests is run without any bridge-mapping | |
8899 | # defined for the localnet on hv2. These tests are expected | |
8900 | # to fail. | |
8901 | # Subsequent tests are run after defining the bridge-mapping | |
8902 | # for the localnet on hv2. These tests are expected to succeed. | |
8903 | ||
8904 | # Create three hypervisors and create OVS ports corresponding | |
8a5a5e3c | 8905 | # to logical ports. |
41a15b71 MS |
8906 | net_add n1 |
8907 | ||
8908 | sim_add hv1 | |
8909 | as hv1 | |
8910 | ovs-vsctl add-br br-phys | |
8911 | ovn_attach n1 br-phys 192.168.0.1 | |
8912 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
8913 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
8914 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
8915 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
8916 | ofport-request=1 | |
8917 | ||
8918 | sim_add hv2 | |
8919 | as hv2 | |
8920 | ovs-vsctl add-br br-phys | |
8921 | ovn_attach n1 br-phys 192.168.0.2 | |
8922 | ||
8923 | sim_add hv3 | |
8924 | as hv3 | |
8925 | ovs-vsctl add-br br-phys | |
8926 | ovn_attach n1 br-phys 192.168.0.3 | |
8927 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
8928 | set interface hv3-vif1 external-ids:iface-id=outside1 \ | |
8929 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
8930 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
8931 | ofport-request=1 | |
8932 | ||
8933 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
8934 | # packets for ARP resolution (native tunneling doesn't queue packets | |
8935 | # for ARP resolution). | |
74868f2c | 8936 | OVN_POPULATE_ARP |
41a15b71 MS |
8937 | |
8938 | ovn-nbctl create Logical_Router name=R1 | |
8939 | ||
8940 | ovn-nbctl ls-add foo | |
8941 | ovn-nbctl ls-add alice | |
8942 | ovn-nbctl ls-add outside | |
8943 | ||
8944 | # Connect foo to R1 | |
8945 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
8946 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
8947 | type=router options:router-port=foo \ | |
8948 | -- lsp-set-addresses rp-foo router | |
8949 | ||
8950 | # Connect alice to R1 as distributed router gateway port on hv2 | |
8951 | ovn-nbctl lrp-add R1 alice 00:00:02:01:02:03 172.16.1.1/24 \ | |
8952 | -- set Logical_Router_Port alice options:redirect-chassis="hv2" | |
8953 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
8954 | type=router options:router-port=alice \ | |
8955 | -- lsp-set-addresses rp-alice router | |
8956 | ||
8957 | # Create logical port foo1 in foo | |
8958 | ovn-nbctl lsp-add foo foo1 \ | |
8959 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
8960 | ||
8961 | # Create logical port outside1 in outside | |
8962 | ovn-nbctl lsp-add outside outside1 \ | |
8963 | -- lsp-set-addresses outside1 "f0:00:00:01:02:04 172.16.1.3" | |
8964 | ||
8965 | # Create localnet port in alice | |
8966 | ovn-nbctl lsp-add alice ln-alice | |
8967 | ovn-nbctl lsp-set-addresses ln-alice unknown | |
8968 | ovn-nbctl lsp-set-type ln-alice localnet | |
8969 | ovn-nbctl lsp-set-options ln-alice network_name=phys | |
8970 | ||
8971 | # Create localnet port in outside | |
8972 | ovn-nbctl lsp-add outside ln-outside | |
8973 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
8974 | ovn-nbctl lsp-set-type ln-outside localnet | |
8975 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
8976 | ||
8977 | # Create bridge-mappings on hv1 and hv3, leaving hv2 for later | |
8978 | as hv1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8979 | as hv3 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
8980 | ||
8981 | ||
8982 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
8983 | # XXX This should be more systematic. | |
8984 | sleep 2 | |
8985 | ||
8986 | echo "---------NB dump-----" | |
8987 | ovn-nbctl show | |
8988 | echo "---------------------" | |
8989 | ovn-nbctl list logical_router | |
8990 | echo "---------------------" | |
8991 | ovn-nbctl list logical_router_port | |
8992 | echo "---------------------" | |
8993 | ||
8994 | echo "---------SB dump-----" | |
8995 | ovn-sbctl list datapath_binding | |
8996 | echo "---------------------" | |
8997 | ovn-sbctl list port_binding | |
8998 | echo "---------------------" | |
8999 | ovn-sbctl dump-flows | |
9000 | echo "---------------------" | |
9001 | ovn-sbctl list chassis | |
9002 | ovn-sbctl list encap | |
1da17a0b | 9003 | echo "------ Gateway_Chassis dump (SBDB) -------" |
9004 | ovn-sbctl list Gateway_Chassis | |
9005 | echo "------ Port_Binding chassisredirect -------" | |
9006 | ovn-sbctl find Port_Binding type=chassisredirect | |
9007 | echo "-------------------------------------------" | |
41a15b71 MS |
9008 | |
9009 | echo "------ hv1 dump ----------" | |
9010 | as hv1 ovs-ofctl show br-int | |
9011 | as hv1 ovs-ofctl dump-flows br-int | |
9012 | echo "------ hv2 dump ----------" | |
9013 | as hv2 ovs-ofctl show br-int | |
9014 | as hv2 ovs-ofctl dump-flows br-int | |
9015 | echo "------ hv3 dump ----------" | |
9016 | as hv3 ovs-ofctl show br-int | |
9017 | as hv3 ovs-ofctl dump-flows br-int | |
9018 | echo "--------------------------" | |
9019 | ||
1da17a0b | 9020 | |
41a15b71 MS |
9021 | # Check that redirect mapping is programmed only on hv2 |
9022 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 | wc -l], [0], [0 | |
9023 | ]) | |
9024 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 | grep load:0x2- | wc -l], [0], [1 | |
9025 | ]) | |
9026 | # Check that hv1 sends chassisredirect port traffic to hv2 | |
9027 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 | grep output | wc -l], [0], [1 | |
9028 | ]) | |
9029 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 | wc -l], [0], [0 | |
9030 | ]) | |
9031 | # Check that arp reply on distributed gateway port is only programmed on hv2 | |
b0684540 | 9032 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep arp | grep load:0x2- | grep =0x2,metadata=0x1 | wc -l], [0], [0 |
41a15b71 | 9033 | ]) |
b0684540 | 9034 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep arp | grep load:0x2- | grep =0x2,metadata=0x1 | wc -l], [0], [1 |
41a15b71 MS |
9035 | ]) |
9036 | ||
9037 | ||
9038 | ip_to_hex() { | |
9039 | printf "%02x%02x%02x%02x" "$@" | |
9040 | } | |
9041 | ||
9042 | ||
9043 | : > hv2-vif1.expected | |
9044 | : > hv3-vif1.expected | |
9045 | ||
9046 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
9047 | # | |
9048 | # Causes a packet to be received on INPORT. The packet is an ARP | |
9049 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
9050 | # it should be the hardware address of the target to expect to receive in an | |
9051 | # ARP reply; otherwise no reply is expected. | |
9052 | # | |
9053 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
9054 | # SHA and REPLY_HA are each 12 hex digits. | |
9055 | # SPA and TPA are each 8 hex digits. | |
9056 | test_arp() { | |
9057 | local hv=$1 inport=$2 sha=$3 spa=$4 tpa=$5 reply_ha=$6 | |
9058 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
9059 | as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request | |
9060 | ||
9061 | if test X$reply_ha != X; then | |
9062 | # Expect to receive the reply, if any. | |
9063 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
9064 | echo $reply >> hv${hv}-vif$inport.expected | |
9065 | fi | |
9066 | } | |
9067 | ||
9068 | rtr_ip=$(ip_to_hex 172 16 1 1) | |
9069 | foo_ip=$(ip_to_hex 192 168 1 2) | |
9070 | outside_ip=$(ip_to_hex 172 16 1 3) | |
9071 | ||
9072 | echo $rtr_ip | |
9073 | echo $foo_ip | |
9074 | echo $outside_ip | |
9075 | ||
9076 | # ARP for router IP address from outside1, no response expected | |
9077 | test_arp 3 1 f00000010204 $outside_ip $rtr_ip | |
9078 | ||
9079 | # Now check the packets actually received against the ones expected. | |
9080 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
9081 | ||
9082 | # Send ip packet between foo1 and outside1 | |
9083 | src_mac="f00000010203" | |
9084 | dst_mac="000001010203" | |
9085 | src_ip=`ip_to_hex 192 168 1 2` | |
9086 | dst_ip=`ip_to_hex 172 16 1 3` | |
9087 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
9088 | ||
9089 | # Now check the packets actually received against the ones expected. | |
9090 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
9091 | ||
9092 | # Now add bridge-mappings on hv2, which should make everything work | |
9093 | as hv2 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
9094 | ||
d65586b6 NS |
9095 | # Wait until the patch ports are created in hv2 to connect br-int to br-phys |
9096 | OVS_WAIT_UNTIL([test 1 = `as hv2 ovs-vsctl show | \ | |
9097 | grep "Port patch-br-int-to-ln-alice" | wc -l`]) | |
41a15b71 MS |
9098 | |
9099 | # ARP for router IP address from outside1 | |
9100 | test_arp 3 1 f00000010204 $outside_ip $rtr_ip 000002010203 | |
9101 | ||
d65586b6 NS |
9102 | # hv3-vif1.expected should also have the gw router port garp packet. |
9103 | exp_gw_ip_garp=ffffffffffff00000201020308060001080006040001000002010203ac100101000000000000ac100101 | |
9104 | echo $exp_gw_ip_garp >> hv3-vif1.expected | |
9105 | ||
41a15b71 MS |
9106 | # Now check the packets actually received against the ones expected. |
9107 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
9108 | ||
9109 | # Send ip packet between foo1 and outside1 | |
9110 | src_mac="f00000010203" | |
9111 | dst_mac="000001010203" | |
9112 | src_ip=`ip_to_hex 192 168 1 2` | |
9113 | dst_ip=`ip_to_hex 172 16 1 3` | |
9114 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
9115 | ||
41a15b71 MS |
9116 | # Packet to Expect at outside1 |
9117 | src_mac="000002010203" | |
9118 | dst_mac="f00000010204" | |
41a15b71 MS |
9119 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 |
9120 | ||
41a15b71 MS |
9121 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet |
9122 | ||
9123 | echo "------ hv1 dump ----------" | |
9124 | as hv1 ovs-ofctl show br-int | |
9125 | as hv1 ovs-ofctl dump-flows br-int | |
9126 | echo "------ hv2 dump ----------" | |
9127 | as hv2 ovs-ofctl show br-int | |
9128 | as hv2 ovs-ofctl dump-flows br-int | |
9129 | echo "------ hv3 dump ----------" | |
9130 | as hv3 ovs-ofctl show br-int | |
9131 | as hv3 ovs-ofctl dump-flows br-int | |
9132 | echo "----------------------------" | |
9133 | ||
9134 | echo $expected >> hv3-vif1.expected | |
9135 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
9136 | ||
9137 | #Check ovn-trace over "chassisredirect" port | |
9138 | AT_CAPTURE_FILE([trace]) | |
9139 | ovn_trace () { | |
9140 | ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' | |
9141 | } | |
9142 | ||
9143 | echo 'ip.ttl--;' > expout | |
9144 | echo 'eth.src = 00:00:02:01:02:03;' >> expout | |
9145 | echo 'eth.dst = f0:00:00:01:02:04;' >> expout | |
9146 | echo 'output("ln-alice");' >> expout | |
9147 | 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]) | |
9148 | ||
9149 | # Create logical port alice1 in alice on hv1 | |
9150 | as hv1 ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
9151 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
9152 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
9153 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
9154 | ofport-request=1 | |
9155 | ||
9156 | ovn-nbctl lsp-add alice alice1 \ | |
9157 | -- lsp-set-addresses alice1 "f0:00:00:01:02:05 172.16.1.4" | |
9158 | ||
9159 | # Create logical port foo2 in foo on hv2 | |
9160 | as hv2 ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
9161 | set interface hv2-vif1 external-ids:iface-id=foo2 \ | |
9162 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
9163 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
9164 | ofport-request=1 | |
9165 | ||
9166 | ovn-nbctl lsp-add foo foo2 \ | |
9167 | -- lsp-set-addresses foo2 "f0:00:00:01:02:06 192.168.1.3" | |
9168 | ||
9169 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
9170 | # XXX This should be more systematic. | |
9171 | sleep 1 | |
9172 | ||
9173 | : > hv1-vif2.expected | |
9174 | ||
9175 | # Send ip packet between alice1 and foo2 | |
9176 | src_mac="f00000010205" | |
9177 | dst_mac="000002010203" | |
9178 | src_ip=`ip_to_hex 172 16 1 4` | |
9179 | dst_ip=`ip_to_hex 192 168 1 3` | |
9180 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
9181 | ||
9182 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif2 $packet | |
9183 | ||
9184 | # Packet to Expect at foo2 | |
9185 | src_mac="000001010203" | |
9186 | dst_mac="f00000010206" | |
9187 | src_ip=`ip_to_hex 172 16 1 4` | |
9188 | dst_ip=`ip_to_hex 192 168 1 3` | |
9189 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
9190 | ||
9191 | echo $expected >> hv2-vif1.expected | |
f5f64552 | 9192 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [hv2-vif1.expected]) |
41a15b71 | 9193 | |
0d31e5be | 9194 | AT_CHECK([ovn-sbctl --bare --columns _uuid find Port_Binding logical_port=cr-alice | wc -l], [0], [1 |
415ed5d7 | 9195 | ]) |
9196 | ||
8e1d9349 | 9197 | ovn-nbctl --timeout=3 --wait=sb remove Logical_Router_Port alice options redirect-chassis |
415ed5d7 | 9198 | |
0d31e5be | 9199 | AT_CHECK([ovn-sbctl find Port_Binding logical_port=cr-alice | wc -l], [0], [0 |
415ed5d7 | 9200 | ]) |
9201 | ||
41a15b71 MS |
9202 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
9203 | ||
9204 | AT_CLEANUP | |
26b9e08d MS |
9205 | |
9206 | AT_SETUP([ovn -- send gratuitous arp for NAT rules on distributed router]) | |
9207 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
9208 | ovn_start | |
9209 | # Create logical switches | |
9210 | ovn-nbctl ls-add ls0 | |
9211 | ovn-nbctl ls-add ls1 | |
9212 | # Create distributed router | |
9213 | ovn-nbctl create Logical_Router name=lr0 | |
9214 | # Add distributed gateway port to distributed router | |
9215 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 \ | |
9216 | -- set Logical_Router_Port lrp0 options:redirect-chassis="hv2" | |
9217 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
9218 | type=router options:router-port=lrp0 addresses="router" | |
9219 | # Add router port to ls1 | |
9220 | ovn-nbctl lrp-add lr0 lrp1 f0:00:00:00:00:02 10.0.0.1/24 | |
9221 | ovn-nbctl lsp-add ls1 lrp1-rp -- set Logical_Switch_Port lrp1-rp \ | |
9222 | type=router options:router-port=lrp1 addresses="router" | |
f40c5588 MS |
9223 | # Add logical ports for NAT rules |
9224 | ovn-nbctl lsp-add ls1 foo1 \ | |
9225 | -- lsp-set-addresses foo1 "00:00:00:00:00:03 10.0.0.3" | |
9226 | ovn-nbctl lsp-add ls1 foo2 \ | |
9227 | -- lsp-set-addresses foo2 "00:00:00:00:00:04 10.0.0.4" | |
26b9e08d MS |
9228 | # Add nat-addresses option |
9229 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" | |
9230 | # Add NAT rules | |
9231 | AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 192.168.0.1 10.0.0.0/24]) | |
9232 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 192.168.0.2 10.0.0.2]) | |
9233 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 192.168.0.3 10.0.0.3 foo1 f0:00:00:00:00:03]) | |
f40c5588 | 9234 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 192.168.0.4 10.0.0.4 foo2 f0:00:00:00:00:04]) |
26b9e08d MS |
9235 | |
9236 | net_add n1 | |
9237 | sim_add hv1 | |
9238 | as hv1 | |
9239 | ovs-vsctl add-br br-phys | |
9240 | ovn_attach n1 br-phys 192.168.0.1 | |
9241 | ||
9242 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
9243 | AT_CHECK([ovs-vsctl add-port br-phys snoopvif -- set Interface snoopvif options:tx_pcap=hv1/snoopvif-tx.pcap options:rxq_pcap=hv1/snoopvif-rx.pcap]) | |
9244 | ||
9245 | sim_add hv2 | |
9246 | as hv2 | |
9247 | ovs-vsctl add-br br-phys | |
9248 | ovn_attach n1 br-phys 192.168.0.2 | |
9249 | # Initially test with no bridge-mapping on hv2, expect to receive no packets | |
9250 | ||
f40c5588 MS |
9251 | sim_add hv3 |
9252 | as hv3 | |
9253 | ovs-vsctl add-br br-phys | |
9254 | ovn_attach n1 br-phys 192.168.0.3 | |
9255 | # Initially test with no bridge-mapping on hv3 | |
9256 | ||
26b9e08d MS |
9257 | # Create a localnet port. |
9258 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
9259 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
9260 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
d65586b6 | 9261 | AT_CHECK([ovn-nbctl --wait=hv lsp-set-options ln_port network_name=physnet1]) |
26b9e08d MS |
9262 | |
9263 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
9264 | # XXX This should be more systematic. | |
9265 | sleep 2 | |
9266 | ||
9267 | # Expect no packets when hv2 bridge-mapping is not present | |
9268 | : > packets | |
9269 | OVN_CHECK_PACKETS([hv1/snoopvif-tx.pcap], [packets]) | |
9270 | ||
9271 | # Add bridge-mapping on hv2 | |
f40c5588 | 9272 | AT_CHECK([as hv2 ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) |
26b9e08d | 9273 | |
d65586b6 NS |
9274 | # Wait until the patch ports are created in hv2 to connect br-int to br-phys |
9275 | OVS_WAIT_UNTIL([test 1 = `as hv2 ovs-vsctl show | \ | |
9276 | grep "Port patch-br-int-to-ln_port" | wc -l`]) | |
9277 | ||
26b9e08d MS |
9278 | # Wait for packets to be received. |
9279 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) | |
9280 | trim_zeros() { | |
9281 | sed 's/\(00\)\{1,\}$//' | |
9282 | } | |
9283 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
9284 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" | |
9285 | echo $expected > expout | |
9286 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
9287 | echo $expected >> expout | |
9288 | AT_CHECK([sort packets], [0], [expout]) | |
f40c5588 | 9289 | sort packets | cat |
26b9e08d | 9290 | |
f40c5588 MS |
9291 | # Temporarily remove nat-addresses option to avoid race conditions |
9292 | # due to GARP backoff | |
9293 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="" | |
9294 | ||
9295 | reset_pcap_file() { | |
9296 | local iface=$1 | |
9297 | local pcap_file=$2 | |
9298 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
9299 | options:rxq_pcap=dummy-rx.pcap | |
9300 | rm -f ${pcap_file}*.pcap | |
9301 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
9302 | options:rxq_pcap=${pcap_file}-rx.pcap | |
9303 | } | |
9304 | ||
9305 | as hv1 reset_pcap_file snoopvif hv1/snoopvif | |
9306 | ||
9307 | # Add OVS ports for foo1 and foo2 on hv3 | |
9308 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
9309 | set interface hv3-vif1 external-ids:iface-id=foo1 \ | |
9310 | ofport-request=1 | |
9311 | ovs-vsctl -- add-port br-int hv3-vif2 -- \ | |
9312 | set interface hv3-vif2 external-ids:iface-id=foo2 \ | |
9313 | ofport-request=2 | |
9314 | ||
9315 | # Add bridge-mapping on hv3 | |
9316 | AT_CHECK([as hv3 ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
9317 | ||
d65586b6 NS |
9318 | # Wait until the patch ports are created in hv3 to connect br-int to br-phys |
9319 | OVS_WAIT_UNTIL([test 1 = `as hv3 ovs-vsctl show | \ | |
9320 | grep "Port patch-br-int-to-ln_port" | wc -l`]) | |
9321 | ||
f40c5588 MS |
9322 | # Re-add nat-addresses option |
9323 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" | |
9324 | ||
9325 | # Wait for packets to be received. | |
9326 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 250]) | |
9327 | trim_zeros() { | |
9328 | sed 's/\(00\)\{1,\}$//' | |
9329 | } | |
9330 | ||
9331 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
d65586b6 NS |
9332 | garp_1="fffffffffffff0000000000308060001080006040001f00000000003c0a80003000000000000c0a80003" |
9333 | echo $garp_1 > expout | |
9334 | garp_2="fffffffffffff0000000000408060001080006040001f00000000004c0a80004000000000000c0a80004" | |
9335 | echo $garp_2 >> expout | |
9336 | ||
9337 | cat packets | grep $garp_1 | head -1 > exp | |
9338 | cat packets | grep $garp_2 | head -1 >> exp | |
9339 | AT_CHECK([cat exp], [0], [expout]) | |
f40c5588 MS |
9340 | |
9341 | OVN_CLEANUP([hv1],[hv2],[hv3]) | |
26b9e08d MS |
9342 | |
9343 | AT_CLEANUP | |
6b785fd8 | 9344 | |
85706c34 NS |
9345 | # VLAN traffic for external network redirected through distributed router |
9346 | # gateway port should use vlans(i.e input network vlan tag) across hypervisors | |
9347 | # instead of tunneling. | |
9348 | AT_SETUP([ovn -- vlan traffic for external network with distributed router gateway port]) | |
9349 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
9350 | ovn_start | |
9351 | ||
9352 | # Logical network: | |
9353 | # # One LR R1 that has switches foo (192.168.1.0/24) and | |
9354 | # # alice (172.16.1.0/24) connected to it. The logical port | |
9355 | # # between R1 and alice has a "redirect-chassis" specified, | |
9356 | # # i.e. it is the distributed router gateway port(172.16.1.6). | |
9357 | # # Switch alice also has a localnet port defined. | |
9358 | # # An additional switch outside has the same subnet as alice | |
9359 | # # (172.16.1.0/24), a localnet port and nexthop port(172.16.1.1) | |
9360 | # # which will receive the packet destined for external network | |
9361 | # # (i.e 8.8.8.8 as destination ip). | |
9362 | ||
9363 | # Physical network: | |
ed198fb3 | 9364 | # # Four hypervisors hv[1234]. |
85706c34 NS |
9365 | # # hv1 hosts vif foo1. |
9366 | # # hv2 is the "redirect-chassis" that hosts the distributed router gateway port. | |
ed198fb3 | 9367 | # # Later to test GARPs for the router port - foo, hv2 and hv4 are added to the ha_chassis_group |
85706c34 NS |
9368 | # # hv3 hosts nexthop port vif outside1. |
9369 | # # All other tests connect hypervisors to network n1 through br-phys for tunneling. | |
9370 | # # But in this test, hv1 won't connect to n1(and no br-phys in hv1), and | |
9371 | # # in order to show vlans(instead of tunneling) used between hv1 and hv2, | |
9372 | # # a new network n2 created and hv1 and hv2 connected to this network through br-ex. | |
9373 | # # hv2 and hv3 are still connected to n1 network through br-phys. | |
9374 | net_add n1 | |
9375 | ||
9376 | # We are not calling ovn_attach for hv1, to avoid adding br-phys. | |
9377 | # Tunneling won't work in hv1 as ovn-encap-ip is not added to any bridge in hv1 | |
9378 | sim_add hv1 | |
9379 | as hv1 | |
9380 | ovs-vsctl \ | |
9381 | -- set Open_vSwitch . external-ids:system-id=hv1 \ | |
9382 | -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \ | |
9383 | -- set Open_vSwitch . external-ids:ovn-encap-type=geneve,vxlan \ | |
9384 | -- set Open_vSwitch . external-ids:ovn-encap-ip=192.168.0.1 \ | |
9385 | -- add-br br-int \ | |
9386 | -- set bridge br-int fail-mode=secure other-config:disable-in-band=true \ | |
9387 | -- set Open_vSwitch . external-ids:ovn-bridge-mappings=public:br-ex | |
9388 | ||
9389 | start_daemon ovn-controller | |
9390 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
9391 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
ed198fb3 NS |
9392 | options:tx_pcap=hv1/vif1-tx.pcap \ |
9393 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
85706c34 NS |
9394 | ofport-request=1 |
9395 | ||
9396 | sim_add hv2 | |
9397 | as hv2 | |
9398 | ovs-vsctl add-br br-phys | |
9399 | ovn_attach n1 br-phys 192.168.0.2 | |
9400 | ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings="public:br-ex,phys:br-phys" | |
9401 | ||
9402 | sim_add hv3 | |
9403 | as hv3 | |
9404 | ovs-vsctl add-br br-phys | |
9405 | ovn_attach n1 br-phys 192.168.0.3 | |
9406 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
9407 | set interface hv3-vif1 external-ids:iface-id=outside1 \ | |
9408 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
9409 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
9410 | ofport-request=1 | |
9411 | ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings="phys:br-phys" | |
9412 | ||
ed198fb3 NS |
9413 | sim_add hv4 |
9414 | as hv4 | |
9415 | ovs-vsctl add-br br-phys | |
9416 | ovn_attach n1 br-phys 192.168.0.4 | |
9417 | ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings="public:br-ex,phys:br-phys" | |
9418 | ||
85706c34 NS |
9419 | # Create network n2 for vlan connectivity between hv1 and hv2 |
9420 | net_add n2 | |
9421 | ||
9422 | as hv1 | |
9423 | ovs-vsctl add-br br-ex | |
9424 | net_attach n2 br-ex | |
9425 | ||
9426 | as hv2 | |
9427 | ovs-vsctl add-br br-ex | |
9428 | net_attach n2 br-ex | |
9429 | ||
ed198fb3 NS |
9430 | as hv4 |
9431 | ovs-vsctl add-br br-ex | |
9432 | net_attach n2 br-ex | |
9433 | ||
85706c34 NS |
9434 | OVN_POPULATE_ARP |
9435 | ||
9436 | ovn-nbctl create Logical_Router name=R1 | |
9437 | ||
9438 | ovn-nbctl ls-add foo | |
9439 | ovn-nbctl ls-add alice | |
9440 | ovn-nbctl ls-add outside | |
9441 | ||
9442 | # Connect foo to R1 | |
9443 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
9444 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
9445 | type=router options:router-port=foo \ | |
9446 | -- lsp-set-addresses rp-foo router | |
9447 | ||
9448 | # Connect alice to R1 as distributed router gateway port (172.16.1.6) on hv2 | |
9449 | ovn-nbctl lrp-add R1 alice 00:00:02:01:02:03 172.16.1.6/24 \ | |
9450 | -- set Logical_Router_Port alice options:redirect-chassis="hv2" | |
9451 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
9452 | type=router options:router-port=alice \ | |
9453 | -- lsp-set-addresses rp-alice router \ | |
9454 | ||
9455 | # Create logical port foo1 in foo | |
9456 | ovn-nbctl lsp-add foo foo1 \ | |
9457 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
9458 | ||
9459 | # Create logical port outside1 in outside, which is a nexthop address | |
9460 | # for 172.16.1.0/24 | |
9461 | ovn-nbctl lsp-add outside outside1 \ | |
9462 | -- lsp-set-addresses outside1 "f0:00:00:01:02:04 172.16.1.1" | |
9463 | ||
9464 | # Set default gateway (nexthop) to 172.16.1.1 | |
9465 | ovn-nbctl lr-route-add R1 "0.0.0.0/0" 172.16.1.1 alice | |
9466 | AT_CHECK([ovn-nbctl lr-nat-add R1 snat 172.16.1.6 192.168.1.1/24]) | |
9467 | ovn-nbctl set Logical_Switch_Port rp-alice options:nat-addresses=router | |
9468 | ||
9469 | ovn-nbctl lsp-add foo ln-foo | |
9470 | ovn-nbctl lsp-set-addresses ln-foo unknown | |
9471 | ovn-nbctl lsp-set-options ln-foo network_name=public | |
9472 | ovn-nbctl lsp-set-type ln-foo localnet | |
9473 | AT_CHECK([ovn-nbctl set Logical_Switch_Port ln-foo tag=2]) | |
9474 | ||
9475 | # Create localnet port in alice | |
9476 | ovn-nbctl lsp-add alice ln-alice | |
9477 | ovn-nbctl lsp-set-addresses ln-alice unknown | |
9478 | ovn-nbctl lsp-set-type ln-alice localnet | |
9479 | ovn-nbctl lsp-set-options ln-alice network_name=phys | |
9480 | ||
9481 | # Create localnet port in outside | |
9482 | ovn-nbctl lsp-add outside ln-outside | |
9483 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
9484 | ovn-nbctl lsp-set-type ln-outside localnet | |
9485 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
9486 | ||
9487 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
9488 | # XXX This should be more systematic. | |
9489 | ovn-nbctl --wait=hv --timeout=3 sync | |
9490 | ||
9491 | # Check that there is a logical flow in logical switch foo's pipeline | |
9492 | # to set the outport to rp-foo (which is expected). | |
9493 | OVS_WAIT_UNTIL([test 1 = `ovn-sbctl dump-flows foo | grep ls_in_l2_lkup | \ | |
9494 | grep rp-foo | grep -v is_chassis_resident | wc -l`]) | |
9495 | ||
9496 | # Set the option 'reside-on-redirect-chassis' for foo | |
9497 | ovn-nbctl set logical_router_port foo options:reside-on-redirect-chassis=true | |
9498 | # Check that there is a logical flow in logical switch foo's pipeline | |
9499 | # to set the outport to rp-foo with the condition is_chassis_redirect. | |
9500 | ovn-sbctl dump-flows foo | |
9501 | OVS_WAIT_UNTIL([test 1 = `ovn-sbctl dump-flows foo | grep ls_in_l2_lkup | \ | |
9502 | grep rp-foo | grep is_chassis_resident | wc -l`]) | |
9503 | ||
9504 | echo "---------NB dump-----" | |
9505 | ovn-nbctl show | |
9506 | echo "---------------------" | |
9507 | ovn-nbctl list logical_router | |
9508 | echo "---------------------" | |
9509 | ovn-nbctl list nat | |
9510 | echo "---------------------" | |
9511 | ovn-nbctl list logical_router_port | |
9512 | echo "---------------------" | |
9513 | ||
9514 | echo "---------SB dump-----" | |
9515 | ovn-sbctl list datapath_binding | |
9516 | echo "---------------------" | |
9517 | ovn-sbctl list port_binding | |
9518 | echo "---------------------" | |
9519 | ovn-sbctl dump-flows | |
9520 | echo "---------------------" | |
9521 | ovn-sbctl list chassis | |
9522 | echo "---------------------" | |
9523 | ||
9524 | for chassis in hv1 hv2 hv3; do | |
9525 | as $chassis | |
9526 | echo "------ $chassis dump ----------" | |
9527 | ovs-vsctl show br-int | |
9528 | ovs-ofctl show br-int | |
9529 | ovs-ofctl dump-flows br-int | |
9530 | echo "--------------------------" | |
9531 | done | |
9532 | ||
9533 | ip_to_hex() { | |
9534 | printf "%02x%02x%02x%02x" "$@" | |
9535 | } | |
9536 | ||
9537 | foo1_ip=$(ip_to_hex 192 168 1 2) | |
9538 | gw_ip=$(ip_to_hex 172 16 1 6) | |
9539 | dst_ip=$(ip_to_hex 8 8 8 8) | |
9540 | nexthop_ip=$(ip_to_hex 172 16 1 1) | |
9541 | ||
9542 | foo1_mac="f00000010203" | |
9543 | foo_mac="000001010203" | |
9544 | gw_mac="000002010203" | |
9545 | nexthop_mac="f00000010204" | |
9546 | ||
9547 | # Send ip packet from foo1 to 8.8.8.8 | |
9548 | src_mac="f00000010203" | |
9549 | dst_mac="000001010203" | |
9550 | packet=${foo_mac}${foo1_mac}08004500001c0000000040110000${foo1_ip}${dst_ip}0035111100080000 | |
9551 | ||
81e92852 | 9552 | # Wait for GARPs announcing gw IP to arrive |
85706c34 NS |
9553 | OVS_WAIT_UNTIL([ |
9554 | test `as hv2 ovs-ofctl dump-flows br-int | grep table=66 | \ | |
9555 | grep actions=mod_dl_dst:f0:00:00:01:02:04 | wc -l` -eq 1 | |
9556 | ]) | |
9557 | ||
9558 | # VLAN tagged packet with router port(192.168.1.1) MAC as destination MAC | |
9559 | # is expected on bridge connecting hv1 and hv2 | |
9560 | expected=${foo_mac}${foo1_mac}8100000208004500001c0000000040110000${foo1_ip}${dst_ip}0035111100080000 | |
9561 | echo $expected > hv1-br-ex_n2.expected | |
9562 | ||
9563 | # Packet to Expect at outside1 i.e nexthop(172.16.1.1) port. | |
9564 | # As connection tracking not enabled for this test, snat can't be done on the packet. | |
9565 | # We still see foo1 as the source ip address. But source mac(gateway MAC) and | |
9566 | # dest mac(nexthop mac) are properly configured. | |
9567 | expected=${nexthop_mac}${gw_mac}08004500001c000000003f110100${foo1_ip}${dst_ip}0035111100080000 | |
9568 | echo $expected > hv3-vif1.expected | |
9569 | ||
9570 | reset_pcap_file() { | |
9571 | local iface=$1 | |
9572 | local pcap_file=$2 | |
9573 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
9574 | options:rxq_pcap=dummy-rx.pcap | |
9575 | rm -f ${pcap_file}*.pcap | |
9576 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
9577 | options:rxq_pcap=${pcap_file}-rx.pcap | |
9578 | } | |
9579 | ||
9580 | as hv1 reset_pcap_file br-ex_n2 hv1/br-ex_n2 | |
9581 | as hv3 reset_pcap_file hv3-vif1 hv3/vif1 | |
85706c34 NS |
9582 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet |
9583 | sleep 2 | |
9584 | ||
85706c34 NS |
9585 | # On hv1, table 32 check that no packet goes via the tunnel port |
9586 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 \ | |
9587 | | grep "NXM_NX_TUN_ID" | grep -v n_packets=0 | wc -l], [0], [[0 | |
9588 | ]]) | |
9589 | ||
9590 | ip_packet() { | |
9591 | grep "1010203f00000010203" | |
9592 | } | |
9593 | ||
9594 | # Check vlan tagged packet on the bridge connecting hv1 and hv2 with the | |
9595 | # foo1's mac. | |
9596 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-ex_n2-tx.pcap | ip_packet | uniq > hv1-br-ex_n2 | |
9597 | cat hv1-br-ex_n2.expected > expout | |
9598 | AT_CHECK([sort hv1-br-ex_n2], [0], [expout]) | |
9599 | ||
9600 | # Check expected packet on nexthop interface | |
9601 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv3/vif1-tx.pcap | grep ${foo1_ip}${dst_ip} | uniq > hv3-vif1 | |
9602 | cat hv3-vif1.expected > expout | |
9603 | AT_CHECK([sort hv3-vif1], [0], [expout]) | |
9604 | ||
ed198fb3 NS |
9605 | # Test the GARP for the router port ip - 192.168.1.1 |
9606 | ovn-nbctl --wait=sb ha-chassis-group-add hagrp1 | |
9607 | ||
9608 | as hv1 reset_pcap_file hv1-vif1 hv1/vif1 | |
9609 | as hv2 reset_pcap_file br-ex_n2 hv2/br-ex_n2 | |
9610 | as hv4 reset_pcap_file br-ex_n2 hv4/br-ex_n2 | |
9611 | ||
9612 | ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 hv2 30 | |
9613 | ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 hv4 20 | |
9614 | ||
9615 | hagrp1_uuid=`ovn-nbctl --bare --columns _uuid find ha_chassis_group name=hagrp1` | |
9616 | ovn-nbctl remove logical_router_port alice options redirect-chassis | |
9617 | ovn-nbctl --wait=sb set logical_router_port alice ha_chassis_group=$hagrp1_uuid | |
9618 | ||
9619 | # When hv2 claims the gw router port cr-alice, it should send out | |
9620 | # GARP for 192.168.1.1 and it should be received by foo1 on hv1. | |
9621 | ||
9622 | # foo1 (on hv1) should receive GARP without VLAN tag | |
9623 | exp_garp_on_foo1="ffffffffffff00000101020308060001080006040001000001010203c0a80101000000000000c0a80101" | |
9624 | echo $exp_garp_on_foo1 > foo1.expout | |
9625 | ||
9626 | # ovn-controller on hv2 should send garp with VLAN tag | |
9627 | sent_garp="ffffffffffff0000010102038100000208060001080006040001000001010203c0a80101000000000000c0a80101" | |
ed198fb3 NS |
9628 | |
9629 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [foo1.expout]) | |
fbe67a7d NS |
9630 | # Wait until we receive atleast 1 packet |
9631 | OVS_WAIT_UNTIL([test 1=`$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap | wc -l`]) | |
9632 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap | head -1 > packets | |
9633 | echo $sent_garp > expout | |
9634 | AT_CHECK([cat packets], [0], [expout]) | |
ed198fb3 NS |
9635 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv4/br-ex_n2-tx.pcap > empty |
9636 | AT_CHECK([cat empty], [0], []) | |
9637 | ||
9638 | # Make hv4 master | |
9639 | as hv1 reset_pcap_file hv1-vif1 hv1/vif1 | |
ed198fb3 NS |
9640 | as hv4 reset_pcap_file br-ex_n2 hv4/br-ex_n2 |
9641 | ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 hv4 40 | |
9642 | ||
fbe67a7d NS |
9643 | # Wait till cr-alice is claimed by hv4 |
9644 | hv4_chassis=$(ovn-sbctl --bare --columns=_uuid find Chassis name=hv4) | |
9645 | # check that the chassis redirect port has been claimed by the gw1 chassis | |
9646 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ | |
9647 | logical_port=cr-alice | grep $hv4_chassis | wc -l], [0],[[1 | |
9648 | ]]) | |
9649 | ||
9650 | # Reset the pcap file for hv2/br-ex_n2. From now on ovn-controller in hv2 | |
9651 | # should not send GARPs for the router ports. | |
9652 | as hv2 reset_pcap_file br-ex_n2 hv2/br-ex_n2 | |
9653 | ||
9654 | echo $sent_garp > br-ex_n2.expout | |
ed198fb3 NS |
9655 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [foo1.expout]) |
9656 | OVN_CHECK_PACKETS([hv4/br-ex_n2-tx.pcap], [br-ex_n2.expout]) | |
fbe67a7d NS |
9657 | |
9658 | sleep 2 | |
9659 | ||
ed198fb3 NS |
9660 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap > empty |
9661 | AT_CHECK([cat empty], [0], []) | |
9662 | ||
9663 | OVN_CLEANUP([hv1],[hv2],[hv3], [hv4]) | |
85706c34 NS |
9664 | AT_CLEANUP |
9665 | ||
4364646c ZKL |
9666 | AT_SETUP([ovn -- IPv6 ND Router Solicitation responder]) |
9667 | AT_KEYWORDS([ovn-nd_ra]) | |
9668 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
9669 | ovn_start | |
9670 | ||
9671 | # In this test case we create 1 lswitch with 3 VIF ports attached, | |
9672 | # and a lrouter connected to the lswitch. | |
9673 | # We generate the Router solicitation packet and verify the Router Advertisement | |
9674 | # reply packet from the ovn-controller. | |
9675 | ||
9676 | # Create hypervisor and logical switch lsw0, logical router lr0, attach lsw0 | |
9677 | # onto lr0, set Logical_Router_Port.ipv6_ra_configs:address_mode column to | |
9678 | # 'slaac' to allow lrp0 send RA for SLAAC mode. | |
9679 | ovn-nbctl ls-add lsw0 | |
9680 | ovn-nbctl lr-add lr0 | |
9681 | ovn-nbctl lrp-add lr0 lrp0 fa:16:3e:00:00:01 fdad:1234:5678::1/64 | |
9682 | ovn-nbctl set Logical_Router_Port lrp0 ipv6_ra_configs:address_mode="slaac" | |
9683 | ovn-nbctl \ | |
9684 | -- lsp-add lsw0 lsp0 \ | |
9685 | -- set Logical_Switch_Port lsp0 type=router \ | |
9686 | options:router-port=lrp0 \ | |
9687 | addresses='"fa:16:3e:00:00:01 fdad:1234:5678::1"' | |
9688 | net_add n1 | |
9689 | sim_add hv1 | |
9690 | as hv1 | |
9691 | ovs-vsctl add-br br-phys | |
9692 | ovn_attach n1 br-phys 192.168.0.2 | |
9693 | ||
9694 | ovn-nbctl lsp-add lsw0 lp1 | |
9695 | ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:00:00:02 10.0.0.12 fdad:1234:5678:0:f816:3eff:fe:2" | |
9696 | ovn-nbctl lsp-set-port-security lp1 "fa:16:3e:00:00:02 10.0.0.12 fdad:1234:5678:0:f816:3eff:fe:2" | |
9697 | ||
9698 | ovn-nbctl lsp-add lsw0 lp2 | |
9699 | ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:00:00:03 10.0.0.13 fdad:1234:5678:0:f816:3eff:fe:3" | |
9700 | ovn-nbctl lsp-set-port-security lp2 "fa:16:3e:00:00:03 10.0.0.13 fdad:1234:5678:0:f816:3eff:fe:3" | |
9701 | ||
9702 | ovn-nbctl lsp-add lsw0 lp3 | |
9703 | ovn-nbctl lsp-set-addresses lp3 "fa:16:3e:00:00:04 10.0.0.14 fdad:1234:5678:0:f816:3eff:fe:4" | |
9704 | ovn-nbctl lsp-set-port-security lp3 "fa:16:3e:00:00:04 10.0.0.14 fdad:1234:5678:0:f816:3eff:fe:4" | |
9705 | ||
9706 | # Add ACL rule for ICMPv6 on lsw0 | |
9707 | ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related | |
9708 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related | |
9709 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related | |
9710 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp3" && ip6 && icmp6' allow-related | |
9711 | ||
9712 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
9713 | set interface hv1-vif1 external-ids:iface-id=lp1 \ | |
9714 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
9715 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
9716 | ofport-request=1 | |
9717 | ||
9718 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
9719 | set interface hv1-vif2 external-ids:iface-id=lp2 \ | |
9720 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
9721 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
9722 | ofport-request=2 | |
9723 | ||
9724 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
9725 | set interface hv1-vif3 external-ids:iface-id=lp3 \ | |
9726 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
9727 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
9728 | ofport-request=3 | |
9729 | ||
9730 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
9731 | # XXX This should be more systematic. | |
9732 | sleep 1 | |
9733 | ||
9734 | reset_pcap_file() { | |
9735 | local iface=$1 | |
9736 | local pcap_file=$2 | |
9737 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
9738 | options:rxq_pcap=dummy-rx.pcap | |
9739 | rm -f ${pcap_file}*.pcap | |
9740 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
9741 | options:rxq_pcap=${pcap_file}-rx.pcap | |
9742 | } | |
9743 | ||
9744 | # Make sure that ovn-controller has installed the corresponding OF Flow. | |
9745 | OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) | |
9746 | ||
9747 | # This shell function sends a Router Solicitation packet. | |
9748 | # test_ipv6_ra INPORT SRC_MAC SRC_LLA ADDR_MODE MTU RA_PREFIX_OPT | |
9749 | test_ipv6_ra() { | |
9750 | local inport=$1 src_mac=$2 src_lla=$3 addr_mode=$4 mtu=$5 prefix_opt=$6 | |
9751 | local request=333300000002${src_mac}86dd6000000000103aff${src_lla}ff02000000000000000000000000000285000efc000000000101${src_mac} | |
9752 | ||
9753 | local len=24 | |
9754 | local mtu_opt="" | |
9755 | if test $mtu != 0; then | |
9756 | len=`expr $len + 8` | |
9757 | mtu_opt=05010000${mtu} | |
9758 | fi | |
9759 | ||
9760 | if test ${#prefix_opt} != 0; then | |
9761 | prefix_opt=${prefix_opt}fdad1234567800000000000000000000 | |
9762 | len=`expr $len + ${#prefix_opt} / 2` | |
9763 | fi | |
9764 | ||
9765 | len=$(printf "%x" $len) | |
9766 | local lrp_mac=fa163e000001 | |
9767 | local lrp_lla=fe80000000000000f8163efffe000001 | |
9768 | local reply=${src_mac}${lrp_mac}86dd6000000000${len}3aff${lrp_lla}${src_lla}8600XXXXff${addr_mode}ffff00000000000000000101${lrp_mac}${mtu_opt}${prefix_opt} | |
9769 | echo $reply >> $inport.expected | |
9770 | ||
9771 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif${inport} $request | |
9772 | } | |
9773 | ||
9774 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
9775 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
9776 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
9777 | ||
9778 | # MTU is not set and the address mode is set to slaac | |
9779 | addr_mode=00 | |
9780 | default_prefix_option_config=030440c0ffffffffffffffff00000000 | |
9781 | src_mac=fa163e000002 | |
9782 | src_lla=fe80000000000000f8163efffe000002 | |
9783 | test_ipv6_ra 1 $src_mac $src_lla $addr_mode 0 $default_prefix_option_config | |
9784 | ||
9785 | # NXT_RESUME should be 1. | |
9786 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
9787 | ||
9788 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
9789 | ||
9790 | cat 1.expected | cut -c -112 > expout | |
9791 | AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) | |
9792 | ||
9793 | # Skipping the ICMPv6 checksum. | |
9794 | cat 1.expected | cut -c 117- > expout | |
9795 | AT_CHECK([cat 1.packets | cut -c 117-], [0], [expout]) | |
9796 | ||
9797 | rm -f *.expected | |
9798 | reset_pcap_file hv1-vif1 hv1/vif1 | |
9799 | reset_pcap_file hv1-vif2 hv1/vif2 | |
9800 | reset_pcap_file hv1-vif3 hv1/vif3 | |
9801 | ||
9802 | # Set the MTU to 1500 | |
9803 | ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:mtu=1500 | |
9804 | ||
9805 | # Make sure that ovn-controller has installed the corresponding OF Flow. | |
9806 | OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) | |
9807 | ||
9808 | addr_mode=00 | |
9809 | default_prefix_option_config=030440c0ffffffffffffffff00000000 | |
9810 | src_mac=fa163e000003 | |
9811 | src_lla=fe80000000000000f8163efffe000003 | |
9812 | mtu=000005dc | |
9813 | ||
9814 | test_ipv6_ra 2 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config | |
9815 | ||
9816 | # NXT_RESUME should be 2. | |
9817 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
9818 | ||
9819 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
9820 | ||
9821 | cat 2.expected | cut -c -112 > expout | |
9822 | AT_CHECK([cat 2.packets | cut -c -112], [0], [expout]) | |
9823 | ||
9824 | # Skipping the ICMPv6 checksum. | |
9825 | cat 2.expected | cut -c 117- > expout | |
9826 | AT_CHECK([cat 2.packets | cut -c 117-], [0], [expout]) | |
9827 | ||
9828 | rm -f *.expected | |
9829 | reset_pcap_file hv1-vif1 hv1/vif1 | |
9830 | reset_pcap_file hv1-vif2 hv1/vif2 | |
9831 | reset_pcap_file hv1-vif3 hv1/vif3 | |
9832 | ||
9833 | # Set the address mode to dhcpv6_stateful | |
9834 | ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:address_mode=dhcpv6_stateful | |
9835 | # Make sure that ovn-controller has installed the corresponding OF Flow. | |
9836 | OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) | |
9837 | ||
9838 | addr_mode=80 | |
36ffc466 | 9839 | default_prefix_option_config=03044080ffffffffffffffff00000000 |
4364646c ZKL |
9840 | src_mac=fa163e000004 |
9841 | src_lla=fe80000000000000f8163efffe000004 | |
9842 | mtu=000005dc | |
9843 | ||
9844 | test_ipv6_ra 3 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config | |
9845 | ||
9846 | # NXT_RESUME should be 3. | |
9847 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
9848 | ||
9849 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > 3.packets | |
9850 | ||
9851 | cat 3.expected | cut -c -112 > expout | |
9852 | AT_CHECK([cat 3.packets | cut -c -112], [0], [expout]) | |
9853 | ||
9854 | # Skipping the ICMPv6 checksum. | |
9855 | cat 3.expected | cut -c 117- > expout | |
9856 | AT_CHECK([cat 3.packets | cut -c 117-], [0], [expout]) | |
9857 | ||
9858 | rm -f *.expected | |
9859 | reset_pcap_file hv1-vif1 hv1/vif1 | |
9860 | reset_pcap_file hv1-vif2 hv1/vif2 | |
9861 | reset_pcap_file hv1-vif3 hv1/vif3 | |
9862 | ||
9863 | # Set the address mode to dhcpv6_stateless | |
9864 | ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:address_mode=dhcpv6_stateless | |
9865 | # Make sure that ovn-controller has installed the corresponding OF Flow. | |
9866 | OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) | |
9867 | ||
9868 | addr_mode=40 | |
9869 | default_prefix_option_config=030440c0ffffffffffffffff00000000 | |
9870 | src_mac=fa163e000002 | |
9871 | src_lla=fe80000000000000f8163efffe000002 | |
9872 | mtu=000005dc | |
9873 | ||
9874 | test_ipv6_ra 1 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config | |
9875 | ||
9876 | # NXT_RESUME should be 4. | |
9877 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
9878 | ||
9879 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
9880 | ||
9881 | cat 1.expected | cut -c -112 > expout | |
9882 | AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) | |
9883 | ||
9884 | # Skipping the ICMPv6 checksum. | |
9885 | cat 1.expected | cut -c 117- > expout | |
9886 | AT_CHECK([cat 1.packets | cut -c 117-], [0], [expout]) | |
9887 | ||
9888 | rm -f *.expected | |
9889 | reset_pcap_file hv1-vif1 hv1/vif1 | |
9890 | reset_pcap_file hv1-vif2 hv1/vif2 | |
9891 | reset_pcap_file hv1-vif3 hv1/vif3 | |
9892 | ||
9893 | # Set the address mode to invalid. | |
9894 | ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:address_mode=invalid | |
9895 | # Make sure that ovn-controller has not installed any OF Flow for IPv6 ND RA. | |
9896 | OVS_WAIT_UNTIL([test 0 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) | |
9897 | ||
9898 | addr_mode=40 | |
9899 | default_prefix_option_config="" | |
9900 | src_mac=fa163e000002 | |
9901 | src_lla=fe80000000000000f8163efffe000002 | |
9902 | mtu=000005dc | |
9903 | ||
9904 | test_ipv6_ra 1 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config | |
9905 | ||
9906 | # NXT_RESUME should be 4 only. | |
9907 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
9908 | ||
9909 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
9910 | AT_CHECK([cat 1.packets], [0], []) | |
9911 | ||
9912 | OVN_CLEANUP([hv1]) | |
9913 | AT_CLEANUP | |
9914 | ||
6b785fd8 GS |
9915 | AT_SETUP([ovn -- /32 router IP address]) |
9916 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
9917 | ovn_start | |
9918 | ||
9919 | # Logical network: | |
9920 | # 2 LS 'foo' and 'alice' connected via router R1. | |
9921 | # R1 connects to 'alice' with a /32 IP address. We use static routes and | |
9922 | # nexthop to push traffic to a logical port in switch 'alice' | |
9923 | ||
9924 | ovn-nbctl lr-add R1 | |
9925 | ||
9926 | ovn-nbctl ls-add foo | |
9927 | ovn-nbctl ls-add alice | |
9928 | ||
9929 | # Connect foo to R1 | |
9930 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
9931 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
9932 | options:router-port=foo addresses=\"00:00:00:01:02:03\" | |
9933 | ||
9934 | # Connect alice to R1. | |
9935 | ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 172.16.1.1/32 | |
9936 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
9937 | type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" | |
9938 | ||
9939 | # Create logical port foo1 in foo | |
9940 | ovn-nbctl lsp-add foo foo1 \ | |
9941 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
9942 | ||
9943 | # Create logical port alice1 in alice | |
9944 | ovn-nbctl lsp-add alice alice1 \ | |
9945 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 10.0.0.2" | |
9946 | ||
9947 | #install default route in R1 to use alice1's IP address as nexthop | |
9948 | ovn-nbctl lr-route-add R1 0.0.0.0/0 10.0.0.2 alice | |
9949 | ||
9950 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
9951 | net_add n1 | |
9952 | ||
9953 | sim_add hv1 | |
9954 | as hv1 | |
9955 | ovs-vsctl add-br br-phys | |
9956 | ovn_attach n1 br-phys 192.168.0.1 | |
9957 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
9958 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
9959 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
9960 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
9961 | ofport-request=1 | |
9962 | ||
9963 | sim_add hv2 | |
9964 | as hv2 | |
9965 | ovs-vsctl add-br br-phys | |
9966 | ovn_attach n1 br-phys 192.168.0.2 | |
9967 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
9968 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
9969 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
9970 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
9971 | ofport-request=1 | |
9972 | ||
9973 | ||
9974 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
9975 | # packets for ARP resolution (native tunneling doesn't queue packets | |
9976 | # for ARP resolution). | |
74868f2c | 9977 | OVN_POPULATE_ARP |
6b785fd8 GS |
9978 | |
9979 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
9980 | # XXX This should be more systematic. | |
9981 | sleep 1 | |
9982 | ||
9983 | ip_to_hex() { | |
9984 | printf "%02x%02x%02x%02x" "$@" | |
9985 | } | |
9986 | ||
9987 | # Send ip packets between foo1 and alice1 | |
9988 | src_mac="f00000010203" | |
9989 | dst_mac="000000010203" | |
9990 | src_ip=`ip_to_hex 192 168 1 2` | |
9991 | dst_ip=`ip_to_hex 10 0 0 2` | |
9992 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
9993 | ||
9994 | # Send the first packet to trigger a ARP response and population of | |
9995 | # mac_bindings table. | |
9996 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
9997 | OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding ip="10.0.0.2" | wc -l` -gt 0]) | |
b0b27a83 | 9998 | ovn-nbctl --wait=hv sync |
6b785fd8 GS |
9999 | |
10000 | # Packet to Expect at 'alice1' | |
10001 | src_mac="000000010204" | |
10002 | dst_mac="f00000010204" | |
10003 | src_ip=`ip_to_hex 192 168 1 2` | |
10004 | dst_ip=`ip_to_hex 10 0 0 2` | |
10005 | echo "${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected | |
10006 | ||
10007 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
10008 | ||
10009 | OVN_CLEANUP([hv1],[hv2]) | |
10010 | ||
10011 | AT_CLEANUP | |
2a38ef45 DA |
10012 | |
10013 | AT_SETUP([ovn -- 2 HVs, 1 lport/HV, localport ports]) | |
10014 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
10015 | ovn_start | |
10016 | ||
10017 | ovn-nbctl ls-add ls1 | |
10018 | ||
10019 | # Add localport to the switch | |
10020 | ovn-nbctl lsp-add ls1 lp01 | |
10021 | ovn-nbctl lsp-set-addresses lp01 f0:00:00:00:00:01 | |
10022 | ovn-nbctl lsp-set-type lp01 localport | |
10023 | ||
10024 | net_add n1 | |
10025 | ||
10026 | for i in 1 2; do | |
10027 | sim_add hv$i | |
10028 | as hv$i | |
10029 | ovs-vsctl add-br br-phys | |
10030 | ovn_attach n1 br-phys 192.168.0.$i | |
10031 | ovs-vsctl add-port br-int vif01 -- \ | |
10032 | set Interface vif01 external-ids:iface-id=lp01 \ | |
10033 | options:tx_pcap=hv${i}/vif01-tx.pcap \ | |
10034 | options:rxq_pcap=hv${i}/vif01-rx.pcap \ | |
10035 | ofport-request=${i}0 | |
10036 | ||
10037 | ovs-vsctl add-port br-int vif${i}1 -- \ | |
10038 | set Interface vif${i}1 external-ids:iface-id=lp${i}1 \ | |
10039 | options:tx_pcap=hv${i}/vif${i}1-tx.pcap \ | |
10040 | options:rxq_pcap=hv${i}/vif${i}1-rx.pcap \ | |
10041 | ofport-request=${i}1 | |
10042 | ||
10043 | ovn-nbctl lsp-add ls1 lp${i}1 | |
10044 | ovn-nbctl lsp-set-addresses lp${i}1 f0:00:00:00:00:${i}1 | |
10045 | ovn-nbctl lsp-set-port-security lp${i}1 f0:00:00:00:00:${i}1 | |
10046 | ||
10047 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp${i}1` = xup]) | |
10048 | done | |
10049 | ||
10050 | ovn-nbctl --wait=sb sync | |
10051 | ovn-sbctl dump-flows | |
10052 | ||
74868f2c | 10053 | OVN_POPULATE_ARP |
2a38ef45 DA |
10054 | |
10055 | # Given the name of a logical port, prints the name of the hypervisor | |
10056 | # on which it is located. | |
10057 | vif_to_hv() { | |
10058 | echo hv${1%?} | |
10059 | } | |
10060 | # | |
10061 | # test_packet INPORT DST SRC ETHTYPE EOUT LOUT DEFHV | |
10062 | # | |
10063 | # This shell function causes a packet to be received on INPORT. The packet's | |
10064 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
10065 | # digits) and Ethernet type ETHTYPE (4 hex digits). INPORT is specified as | |
10066 | # logical switch port numbers, e.g. 11 for vif11. | |
10067 | # | |
10068 | # EOUT is the end-to-end output port, that is, where the packet will end up | |
10069 | # after possibly bouncing through one or more localnet ports. LOUT is the | |
10070 | # logical output port, which might be a localnet port, as seen by ovn-trace | |
10071 | # (which doesn't know what localnet ports are connected to and therefore can't | |
10072 | # figure out the end-to-end answer). | |
10073 | # | |
10074 | # DEFHV is the default hypervisor from where the packet is going to be sent | |
10075 | # if the source port is a localport. | |
10076 | for i in 1 2; do | |
10077 | for j in 0 1; do | |
10078 | : > $i$j.expected | |
10079 | done | |
10080 | done | |
10081 | test_packet() { | |
10082 | local inport=$1 dst=$2 src=$3 eth=$4 eout=$5 lout=$6 defhv=$7 | |
10083 | echo "$@" | |
10084 | ||
10085 | # First try tracing the packet. | |
10086 | uflow="inport==\"lp$inport\" && eth.dst==$dst && eth.src==$src && eth.type==0x$eth" | |
10087 | if test $lout != drop; then | |
10088 | echo "output(\"$lout\");" | |
10089 | fi > expout | |
10090 | AT_CAPTURE_FILE([trace]) | |
10091 | AT_CHECK([ovn-trace --all ls1 "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
10092 | ||
10093 | # Then actually send a packet, for an end-to-end test. | |
10094 | local packet=$(echo $dst$src | sed 's/://g')${eth} | |
10095 | hv=`vif_to_hv $inport` | |
10096 | # If hypervisor 0 (localport) use the defhv parameter | |
da88b550 | 10097 | if test $hv = hv0; then |
2a38ef45 DA |
10098 | hv=$defhv |
10099 | fi | |
10100 | vif=vif$inport | |
10101 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
10102 | if test $eout != drop; then | |
10103 | echo $packet >> ${eout#lp}.expected | |
10104 | fi | |
10105 | } | |
10106 | ||
10107 | ||
10108 | # lp11 and lp21 are on different hypervisors | |
10109 | test_packet 11 f0:00:00:00:00:21 f0:00:00:00:00:11 1121 lp21 lp21 | |
10110 | test_packet 21 f0:00:00:00:00:11 f0:00:00:00:00:21 2111 lp11 lp11 | |
10111 | ||
10112 | # Both VIFs should be able to reach the localport on their own HV | |
10113 | test_packet 11 f0:00:00:00:00:01 f0:00:00:00:00:11 1101 lp01 lp01 | |
10114 | test_packet 21 f0:00:00:00:00:01 f0:00:00:00:00:21 2101 lp01 lp01 | |
10115 | ||
10116 | # Packet sent from localport on same hv should reach the vif | |
10117 | test_packet 01 f0:00:00:00:00:11 f0:00:00:00:00:01 0111 lp11 lp11 hv1 | |
10118 | test_packet 01 f0:00:00:00:00:21 f0:00:00:00:00:01 0121 lp21 lp21 hv2 | |
10119 | ||
10120 | # Packet sent from localport on different hv should be dropped | |
10121 | test_packet 01 f0:00:00:00:00:21 f0:00:00:00:00:01 0121 drop lp21 hv1 | |
10122 | test_packet 01 f0:00:00:00:00:11 f0:00:00:00:00:01 0111 drop lp11 hv2 | |
10123 | ||
10124 | # Now check the packets actually received against the ones expected. | |
10125 | for i in 1 2; do | |
10126 | for j in 0 1; do | |
10127 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) | |
10128 | done | |
10129 | done | |
10130 | ||
10131 | OVN_CLEANUP([hv1],[hv2]) | |
10132 | ||
10133 | AT_CLEANUP | |
1da17a0b | 10134 | |
10135 | AT_SETUP([ovn -- 1 LR with HA distributed router gateway port]) | |
10136 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
10137 | ovn_start | |
10138 | ||
10139 | net_add n1 | |
10140 | ||
10141 | # create gateways with external network connectivity | |
10142 | ||
10143 | for i in 1 2; do | |
10144 | sim_add gw$i | |
10145 | as gw$i | |
10146 | ovs-vsctl add-br br-phys | |
10147 | ovn_attach n1 br-phys 192.168.0.$i | |
10148 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
10149 | done | |
10150 | ||
10151 | ovn-nbctl ls-add inside | |
10152 | ovn-nbctl ls-add outside | |
10153 | ||
10154 | # create hypervisors with a vif port each to an internal network | |
10155 | ||
10156 | for i in 1 2; do | |
10157 | sim_add hv$i | |
10158 | as hv$i | |
10159 | ovs-vsctl add-br br-phys | |
10160 | ovn_attach n1 br-phys 192.168.0.1$i | |
10161 | ovs-vsctl -- add-port br-int hv$i-vif1 -- \ | |
10162 | set interface hv$i-vif1 external-ids:iface-id=inside$i \ | |
10163 | options:tx_pcap=hv$i/vif1-tx.pcap \ | |
10164 | options:rxq_pcap=hv$i/vif1-rx.pcap \ | |
10165 | ofport-request=1 | |
10166 | ||
10167 | ovn-nbctl lsp-add inside inside$i \ | |
10168 | -- lsp-set-addresses inside$i "f0:00:00:01:22:$i 192.168.1.10$i" | |
10169 | ||
10170 | done | |
10171 | ||
74868f2c | 10172 | OVN_POPULATE_ARP |
1da17a0b | 10173 | |
10174 | ovn-nbctl create Logical_Router name=R1 | |
10175 | ||
10176 | # Connect inside to R1 | |
10177 | ovn-nbctl lrp-add R1 inside 00:00:01:01:02:03 192.168.1.1/24 | |
10178 | ovn-nbctl lsp-add inside rp-inside -- set Logical_Switch_Port rp-inside \ | |
10179 | type=router options:router-port=inside \ | |
10180 | -- lsp-set-addresses rp-inside router | |
10181 | ||
10182 | # Connect outside to R1 as distributed router gateway port on gw1+gw2 | |
10183 | ovn-nbctl lrp-add R1 outside 00:00:02:01:02:04 192.168.0.101/24 | |
10184 | ||
10185 | ovn-nbctl --id=@gc0 create Gateway_Chassis \ | |
10186 | name=outside_gw1 chassis_name=gw1 priority=20 -- \ | |
10187 | --id=@gc1 create Gateway_Chassis \ | |
10188 | name=outside_gw2 chassis_name=gw2 priority=10 -- \ | |
10189 | set Logical_Router_Port outside 'gateway_chassis=[@gc0,@gc1]' | |
10190 | ||
10191 | ovn-nbctl lsp-add outside rp-outside -- set Logical_Switch_Port rp-outside \ | |
10192 | type=router options:router-port=outside \ | |
10193 | -- lsp-set-addresses rp-outside router | |
10194 | ||
10195 | # Create localnet port in outside | |
10196 | ovn-nbctl lsp-add outside ln-outside | |
10197 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
10198 | ovn-nbctl lsp-set-type ln-outside localnet | |
10199 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
10200 | ||
10201 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
10202 | # XXX This should be more systematic. | |
8e1d9349 | 10203 | ovn-nbctl --wait=hv --timeout=3 sync |
1da17a0b | 10204 | |
10205 | echo "---------NB dump-----" | |
10206 | ovn-nbctl show | |
10207 | echo "---------------------" | |
10208 | ovn-nbctl list logical_router | |
10209 | echo "---------------------" | |
10210 | ovn-nbctl list logical_router_port | |
10211 | echo "---------------------" | |
10212 | ||
10213 | echo "---------SB dump-----" | |
10214 | ovn-sbctl list datapath_binding | |
10215 | echo "---------------------" | |
10216 | ovn-sbctl list port_binding | |
10217 | echo "---------------------" | |
10218 | ovn-sbctl dump-flows | |
10219 | echo "---------------------" | |
10220 | ovn-sbctl list chassis | |
10221 | ovn-sbctl list encap | |
10222 | echo "---------------------" | |
10223 | echo "------ Gateway_Chassis dump (SBDB) -------" | |
10224 | ovn-sbctl list Gateway_Chassis | |
10225 | echo "------ Port_Binding chassisredirect -------" | |
10226 | ovn-sbctl find Port_Binding type=chassisredirect | |
10227 | echo "-------------------------------------------" | |
10228 | ||
1be1e0e5 NS |
10229 | # There should be one ha_chassis_group with the name "outside" |
10230 | ha_chassi_grp_name=`ovn-sbctl --bare --columns name find \ | |
10231 | ha_chassis_group name="outside"` | |
10232 | ||
10233 | AT_CHECK([test $ha_chassi_grp_name = outside]) | |
10234 | ||
10235 | # There should be 2 ha_chassis rows in SB DB. | |
de779178 NS |
10236 | AT_CHECK([ovn-sbctl list ha_chassis | grep chassis | \ |
10237 | grep -v chassis-name | awk '{print $3}' \ | |
1be1e0e5 NS |
10238 | | grep '-' | wc -l ], [0], [2 |
10239 | ]) | |
10240 | ||
10241 | ha_ch=`ovn-sbctl --bare --columns ha_chassis find ha_chassis_group` | |
10242 | # Trim the spaces. | |
10243 | ha_ch=`echo $ha_ch | sed 's/ //g'` | |
10244 | ||
10245 | ha_ch_list='' | |
10246 | for i in `ovn-sbctl --bare --columns _uuid list ha_chassis | sort` | |
10247 | do | |
10248 | ha_ch_list="$ha_ch_list $i" | |
10249 | done | |
10250 | ||
10251 | # Trim the spaces. | |
10252 | ha_ch_list=`echo $ha_ch_list | sed 's/ //g'` | |
10253 | ||
10254 | AT_CHECK([test "$ha_ch_list" = "$ha_ch"]) | |
10255 | ||
3475695e VA |
10256 | for chassis in gw1 gw2 hv1 hv2; do |
10257 | as $chassis | |
10258 | echo "------ $chassis dump ----------" | |
10259 | ovs-ofctl show br-int | |
10260 | ovs-ofctl dump-flows br-int | |
3475695e VA |
10261 | echo "--------------------------" |
10262 | done | |
20be3a72 | 10263 | bfd_dump() { |
508b7f96 | 10264 | for chassis in gw1 gw2 hv1 hv2; do |
10265 | as $chassis | |
10266 | echo "------ $chassis dump (BFD)----" | |
10267 | echo "BFD (from $chassis):" | |
10268 | # dump BFD config and status to the other chassis | |
10269 | for chassis2 in gw1 gw2 hv1 hv2; do | |
10270 | if [[ "$chassis" != "$chassis2" ]]; then | |
10271 | echo " -> $chassis2:" | |
10272 | echo " $(ovs-vsctl --bare --columns bfd,bfd_status find Interface name=ovn-$chassis2-0)" | |
10273 | fi | |
10274 | done | |
10275 | echo "--------------------------" | |
10276 | done | |
10277 | } | |
10278 | ||
10279 | bfd_dump | |
1da17a0b | 10280 | |
10281 | hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw1-0) | |
10282 | hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw2-0) | |
10283 | hv2_gw1_ofport=$(as hv2 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw1-0) | |
10284 | hv2_gw2_ofport=$(as hv2 ovs-vsctl --bare --columns ofport find Interface name=ovn-gw2-0) | |
10285 | ||
10286 | echo $hv1_gw1_ofport | |
10287 | echo $hv1_gw2_ofport | |
10288 | echo $hv2_gw1_ofport | |
10289 | echo $hv2_gw2_ofport | |
10290 | ||
10291 | echo "--- hv1 ---" | |
10292 | as hv1 ovs-ofctl dump-flows br-int table=32 | |
10293 | ||
10294 | echo "--- hv2 ---" | |
10295 | as hv2 ovs-ofctl dump-flows br-int table=32 | |
10296 | ||
508b7f96 | 10297 | gw1_chassis=$(ovn-sbctl --bare --columns=_uuid find Chassis name=gw1) |
10298 | gw2_chassis=$(ovn-sbctl --bare --columns=_uuid find Chassis name=gw2) | |
10299 | ||
1be1e0e5 NS |
10300 | OVS_WAIT_UNTIL([as hv1 ovs-ofctl dump-flows br-int table=32 | \ |
10301 | grep active_backup | grep slaves:$hv1_gw1_ofport,$hv1_gw2_ofport \ | |
10302 | | wc -l], [0], [1 | |
1da17a0b | 10303 | ]) |
10304 | ||
1be1e0e5 NS |
10305 | OVS_WAIT_UNTIL([as hv2 ovs-ofctl dump-flows br-int table=32 | \ |
10306 | grep active_backup | grep slaves:$hv2_gw1_ofport,$hv2_gw2_ofport \ | |
10307 | | wc -l], [0], [1 | |
1da17a0b | 10308 | ]) |
10309 | ||
508b7f96 | 10310 | # make sure that flows for handling the outside router port reside on gw1 |
96080083 | 10311 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=25 | \ |
1be1e0e5 | 10312 | grep 00:00:02:01:02:04 | wc -l], [0], [[1 |
508b7f96 | 10313 | ]]) |
96080083 | 10314 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=25 | \ |
1be1e0e5 | 10315 | grep 00:00:02:01:02:04 | wc -l], [0], [[0 |
508b7f96 | 10316 | ]]) |
10317 | ||
10318 | # make sure ARP responder flows for outside router port reside on gw1 too | |
1be1e0e5 NS |
10319 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=9 | \ |
10320 | grep arp_tpa=192.168.0.101 | wc -l], [0], [[1 | |
508b7f96 | 10321 | ]]) |
1be1e0e5 | 10322 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=9 | grep arp_tpa=192.168.0.101 | wc -l], [0], [[0 |
508b7f96 | 10323 | ]]) |
10324 | ||
508b7f96 | 10325 | # check that the chassis redirect port has been claimed by the gw1 chassis |
1be1e0e5 NS |
10326 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ |
10327 | logical_port=cr-outside | grep $gw1_chassis | wc -l], [0],[[1 | |
508b7f96 | 10328 | ]]) |
10329 | ||
1be1e0e5 NS |
10330 | hv1_ch_uuid=`ovn-sbctl --bare --columns _uuid find chassis name="hv1"` |
10331 | hv2_ch_uuid=`ovn-sbctl --bare --columns _uuid find chassis name="hv2"` | |
10332 | ||
10333 | exp_ref_ch_list='' | |
10334 | for i in `ovn-sbctl --bare --columns _uuid list chassis | sort` | |
10335 | do | |
10336 | if test $i = $hv1_ch_uuid; then | |
10337 | exp_ref_ch_list="${exp_ref_ch_list}$i" | |
10338 | elif test $i = $hv2_ch_uuid; then | |
10339 | exp_ref_ch_list="${exp_ref_ch_list}$i" | |
10340 | fi | |
10341 | done | |
10342 | ||
10343 | OVS_WAIT_UNTIL( | |
10344 | [ref_ch_list=`ovn-sbctl --bare --columns ref_chassis find ha_chassis_group | sort` | |
10345 | # Trim the spaces. | |
10346 | ref_ch_list=`echo $ref_ch_list | sed 's/ //g'` | |
10347 | test "$exp_ref_ch_list" = "$ref_ch_list"]) | |
10348 | ||
508b7f96 | 10349 | |
10350 | # at this point, we invert the priority of the gw chassis between gw1 and gw2 | |
1da17a0b | 10351 | |
10352 | ovn-nbctl --id=@gc0 create Gateway_Chassis \ | |
10353 | name=outside_gw1 chassis_name=gw1 priority=10 -- \ | |
10354 | --id=@gc1 create Gateway_Chassis \ | |
10355 | name=outside_gw2 chassis_name=gw2 priority=20 -- \ | |
10356 | set Logical_Router_Port outside 'gateway_chassis=[@gc0,@gc1]' | |
10357 | ||
508b7f96 | 10358 | |
1da17a0b | 10359 | # XXX: Let the change propagate down to the ovn-controllers |
8e1d9349 | 10360 | ovn-nbctl --wait=hv --timeout=3 sync |
1da17a0b | 10361 | |
508b7f96 | 10362 | # we make sure that the hypervisors noticed, and inverted the slave ports |
1be1e0e5 NS |
10363 | OVS_WAIT_UNTIL([as hv1 ovs-ofctl dump-flows br-int table=32 | \ |
10364 | grep active_backup | grep slaves:$hv1_gw2_ofport,$hv1_gw1_ofport \ | |
10365 | | wc -l], [0], [1 | |
1da17a0b | 10366 | ]) |
10367 | ||
1be1e0e5 NS |
10368 | OVS_WAIT_UNTIL([as hv2 ovs-ofctl dump-flows br-int table=32 | \ |
10369 | grep active_backup | grep slaves:$hv2_gw2_ofport,$hv2_gw1_ofport \ | |
10370 | | wc -l], [0], [1 | |
1da17a0b | 10371 | ]) |
10372 | ||
508b7f96 | 10373 | # check that the chassis redirect port has been reclaimed by the gw2 chassis |
1be1e0e5 NS |
10374 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ |
10375 | logical_port=cr-outside | grep $gw2_chassis | wc -l], [0],[[1 | |
508b7f96 | 10376 | ]]) |
1da17a0b | 10377 | |
3475695e VA |
10378 | # check BFD enablement on tunnel ports from gw1 ######### |
10379 | as gw1 | |
10380 | for chassis in gw2 hv1 hv2; do | |
10381 | echo "checking gw1 -> $chassis" | |
10382 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10383 | [[enable=true | |
10384 | ]]) | |
10385 | done | |
10386 | ||
10387 | ||
10388 | # check BFD enablement on tunnel ports from gw2 ########## | |
10389 | as gw2 | |
10390 | for chassis in gw1 hv1 hv2; do | |
10391 | echo "checking gw2 -> $chassis" | |
10392 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10393 | [[enable=true | |
10394 | ]]) | |
10395 | done | |
10396 | ||
10397 | # check BFD enablement on tunnel ports from hv1 ########### | |
10398 | as hv1 | |
10399 | for chassis in gw1 gw2; do | |
10400 | echo "checking hv1 -> $chassis" | |
10401 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10402 | [[enable=true | |
10403 | ]]) | |
10404 | done | |
10405 | # make sure BFD is not enabled to hv2, we don't need it | |
10406 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0], | |
2d661a27 | 10407 | [[ |
3475695e VA |
10408 | ]]) |
10409 | ||
10410 | ||
10411 | # check BFD enablement on tunnel ports from hv2 ########## | |
10412 | as hv2 | |
10413 | for chassis in gw1 gw2; do | |
10414 | echo "checking hv2 -> $chassis" | |
10415 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10416 | [[enable=true | |
10417 | ]]) | |
10418 | done | |
10419 | # make sure BFD is not enabled to hv1, we don't need it | |
10420 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-0],[0], | |
2d661a27 | 10421 | [[ |
3475695e VA |
10422 | ]]) |
10423 | ||
508b7f96 | 10424 | # make sure that flows for handling the outside router port reside on gw2 now |
96080083 | 10425 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=25 | \ |
1be1e0e5 | 10426 | grep 00:00:02:01:02:04 | wc -l], [0], [[1 |
508b7f96 | 10427 | ]]) |
96080083 | 10428 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=25 | \ |
1be1e0e5 | 10429 | grep 00:00:02:01:02:04 | wc -l], [0], [[0 |
508b7f96 | 10430 | ]]) |
10431 | ||
10432 | # disconnect GW2 from the network, GW1 should take over | |
10433 | as gw2 | |
10434 | port=${sandbox}_br-phys | |
10435 | as main ovs-vsctl del-port n1 $port | |
508b7f96 | 10436 | |
10437 | bfd_dump | |
10438 | ||
10439 | # make sure that flows for handling the outside router port reside on gw2 now | |
96080083 | 10440 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=25 | \ |
1be1e0e5 | 10441 | grep 00:00:02:01:02:04 | wc -l], [0], [[1 |
508b7f96 | 10442 | ]]) |
96080083 | 10443 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=25 | \ |
1be1e0e5 | 10444 | grep 00:00:02:01:02:04 | wc -l], [0], [[0 |
508b7f96 | 10445 | ]]) |
10446 | ||
10447 | # check that the chassis redirect port has been reclaimed by the gw1 chassis | |
1be1e0e5 NS |
10448 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ |
10449 | logical_port=cr-outside | grep $gw1_chassis | wc -l], [0],[[1 | |
508b7f96 | 10450 | ]]) |
10451 | ||
2d661a27 NS |
10452 | ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-rx"=2000 |
10453 | as gw2 | |
10454 | for chassis in gw1 hv1 hv2; do | |
10455 | echo "checking gw2 -> $chassis" | |
10456 | OVS_WAIT_UNTIL([ | |
10457 | bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0) | |
10458 | test "$bfd_cfg" = "enable=true min_rx=2000" | |
10459 | ]) | |
10460 | done | |
10461 | ovn-nbctl --wait=hv set NB_Global . options:"bfd-min-tx"=1500 | |
10462 | for chassis in gw1 hv1 hv2; do | |
10463 | echo "checking gw2 -> $chassis" | |
10464 | OVS_WAIT_UNTIL([ | |
10465 | bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0) | |
10466 | test "$bfd_cfg" = "enable=true min_rx=2000 min_tx=1500" | |
10467 | ]) | |
10468 | done | |
10469 | ovn-nbctl remove NB_Global . options "bfd-min-rx" | |
10470 | ovn-nbctl --wait=hv set NB_Global . options:"bfd-mult"=5 | |
10471 | for chassis in gw1 hv1 hv2; do | |
10472 | echo "checking gw2 -> $chassis" | |
10473 | OVS_WAIT_UNTIL([ | |
10474 | bfd_cfg=$(ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0) | |
10475 | test "$bfd_cfg" = "enable=true min_tx=1500 mult=5" | |
10476 | ]) | |
10477 | done | |
10478 | ||
1be1e0e5 NS |
10479 | # Delete the inside1 vif. The ref_chassis in ha_chassis_group shouldn't have |
10480 | # reference to hv1. | |
10481 | as hv1 ovs-vsctl del-port hv1-vif1 | |
10482 | ||
10483 | OVS_WAIT_UNTIL( | |
10484 | [ref_ch_list=`ovn-sbctl --bare --columns ref_chassis find ha_chassis_group | sort` | |
10485 | # Trim the spaces. | |
10486 | ref_ch_list=`echo $ref_ch_list | sed 's/ //g'` | |
10487 | test "$hv2_ch_uuid" = "$ref_ch_list"]) | |
10488 | ||
10489 | # Delete the inside2 vif. | |
10490 | ovn-sbctl show | |
10491 | ||
10492 | echo "Deleting hv2-vif1" | |
10493 | as hv2 ovs-vsctl del-port hv2-vif1 | |
10494 | ||
10495 | # ref_chassis of ha_chassis_group should be empty | |
10496 | OVS_WAIT_UNTIL( | |
10497 | [ref_ch_list=`ovn-sbctl --bare --columns ref_chassis find ha_chassis_group | sort` | |
10498 | # Trim the spaces. | |
10499 | ref_ch_list=`echo $ref_ch_list | sed 's/ //g'` | |
10500 | exp_ref_ch_list="" | |
10501 | test "$exp_ref_ch_list" = "$ref_ch_list"]) | |
10502 | ||
10503 | # Delete the Gateway_Chassis for lrp - outside | |
10504 | ovn-nbctl clear Logical_Router_Port outside gateway_chassis | |
10505 | ||
10506 | # There shoud be no ha_chassis_group rows in SB DB. | |
10507 | OVS_WAIT_UNTIL([test 0 = `ovn-sbctl list ha_chassis_group | wc -l`]) | |
10508 | OVS_WAIT_UNTIL([test 0 = `ovn-sbctl list ha_chassis | wc -l`]) | |
10509 | ||
bddb73db NS |
10510 | ovn-nbctl remove NB_Global . options "bfd-min-rx" |
10511 | ovn-nbctl remove NB_Global . options "bfd-min-tx" | |
10512 | ovn-nbctl remove NB_Global . options "bfd-mult" | |
10513 | ||
10514 | # Now test with HA chassis group instead of Gateway chassis in NB DB | |
10515 | ovn-nbctl --wait=sb ha-chassis-group-add hagrp1 | |
10516 | ||
10517 | ovn-nbctl list ha_chassis_group | |
10518 | ovn-nbctl --bare --columns _uuid find ha_chassis_group name=hagrp1 | |
10519 | hagrp1_uuid=`ovn-nbctl --bare --columns _uuid find ha_chassis_group name=hagrp1` | |
10520 | ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 gw1 30 | |
10521 | ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 gw2 20 | |
10522 | ||
10523 | # ovn-northd should not create HA chassis group and HA chassis rows | |
10524 | # unless the HA chassis group in OVN NB DB is associated to | |
10525 | # a logical router port. | |
10526 | OVS_WAIT_UNTIL([test 0 = `ovn-sbctl list ha_chassis | wc -l`]) | |
10527 | ||
10528 | # Associate hagrp1 to outside logical router port | |
10529 | ovn-nbctl set Logical_Router_Port outside ha_chassis_group=$hagrp1_uuid | |
10530 | ||
10531 | OVS_WAIT_UNTIL([test 1 = `ovn-sbctl --bare --columns _uuid \ | |
10532 | find ha_chassis_group | wc -l`]) | |
10533 | ||
de779178 NS |
10534 | OVS_WAIT_UNTIL([test 2 = `ovn-sbctl list ha_chassis | grep chassis | \ |
10535 | grep -v chassis-name | wc -l`]) | |
bddb73db NS |
10536 | |
10537 | OVS_WAIT_UNTIL([as hv1 ovs-ofctl dump-flows br-int table=32 | \ | |
10538 | grep active_backup | grep slaves:$hv1_gw1_ofport,$hv1_gw2_ofport \ | |
10539 | | wc -l], [0], [1 | |
10540 | ]) | |
10541 | ||
10542 | OVS_WAIT_UNTIL([as hv2 ovs-ofctl dump-flows br-int table=32 | \ | |
10543 | grep active_backup | grep slaves:$hv2_gw1_ofport,$hv2_gw2_ofport \ | |
10544 | | wc -l], [0], [1 | |
10545 | ]) | |
10546 | ||
10547 | # make sure that flows for handling the outside router port reside on gw1 | |
10548 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=24 | \ | |
10549 | grep 00:00:02:01:02:04 | wc -l], [0], [[1 | |
10550 | ]]) | |
10551 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=24 | \ | |
10552 | grep 00:00:02:01:02:04 | wc -l], [0], [[0 | |
10553 | ]]) | |
10554 | ||
10555 | # make sure ARP responder flows for outside router port reside on gw1 too | |
10556 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=9 | \ | |
10557 | grep arp_tpa=192.168.0.101 | wc -l], [0], [[1 | |
10558 | ]]) | |
10559 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=9 | grep arp_tpa=192.168.0.101 | wc -l], [0], [[0 | |
10560 | ]]) | |
10561 | ||
10562 | # check that the chassis redirect port has been claimed by the gw1 chassis | |
10563 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ | |
10564 | logical_port=cr-outside | grep $gw1_chassis | wc -l], [0],[[1 | |
10565 | ]]) | |
10566 | ||
10567 | # Re add the ovs ports. | |
10568 | for i in 1 2; do | |
10569 | as hv$i | |
10570 | ovs-vsctl -- add-port br-int hv$i-vif1 -- \ | |
10571 | set interface hv$i-vif1 external-ids:iface-id=inside$i \ | |
10572 | options:tx_pcap=hv$i/vif1-tx.pcap \ | |
10573 | options:rxq_pcap=hv$i/vif1-rx.pcap \ | |
10574 | ofport-request=1 | |
10575 | done | |
10576 | ||
10577 | hv1_ch_uuid=`ovn-sbctl --bare --columns _uuid find chassis name="hv1"` | |
10578 | hv2_ch_uuid=`ovn-sbctl --bare --columns _uuid find chassis name="hv2"` | |
10579 | ||
10580 | exp_ref_ch_list='' | |
10581 | for i in `ovn-sbctl --bare --columns _uuid list chassis | sort` | |
10582 | do | |
10583 | if test $i = $hv1_ch_uuid; then | |
10584 | exp_ref_ch_list="${exp_ref_ch_list}$i" | |
10585 | elif test $i = $hv2_ch_uuid; then | |
10586 | exp_ref_ch_list="${exp_ref_ch_list}$i" | |
10587 | fi | |
10588 | done | |
10589 | ||
10590 | OVS_WAIT_UNTIL( | |
10591 | [ref_ch_list=`ovn-sbctl --bare --columns ref_chassis find ha_chassis_group | sort` | |
10592 | # Trim the spaces. | |
10593 | ref_ch_list=`echo $ref_ch_list | sed 's/ //g'` | |
10594 | test "$exp_ref_ch_list" = "$ref_ch_list"]) | |
10595 | ||
10596 | # Increase the priority of gw2 | |
10597 | ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 gw2 40 | |
10598 | ||
10599 | OVS_WAIT_UNTIL([as hv1 ovs-ofctl dump-flows br-int table=32 | \ | |
10600 | grep active_backup | grep slaves:$hv1_gw2_ofport,$hv1_gw1_ofport \ | |
10601 | | wc -l], [0], [1 | |
10602 | ]) | |
10603 | ||
10604 | OVS_WAIT_UNTIL([as hv2 ovs-ofctl dump-flows br-int table=32 | \ | |
10605 | grep active_backup | grep slaves:$hv2_gw2_ofport,$hv2_gw1_ofport \ | |
10606 | | wc -l], [0], [1 | |
10607 | ]) | |
10608 | ||
10609 | # check that the chassis redirect port has been reclaimed by the gw2 chassis | |
10610 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ | |
10611 | logical_port=cr-outside | grep $gw2_chassis | wc -l], [0],[[1 | |
10612 | ]]) | |
10613 | ||
10614 | # check BFD enablement on tunnel ports from gw1 ######### | |
10615 | as gw1 | |
10616 | for chassis in gw2 hv1 hv2; do | |
10617 | echo "checking gw1 -> $chassis" | |
10618 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10619 | [[enable=true | |
10620 | ]]) | |
10621 | done | |
10622 | ||
10623 | # check BFD enablement on tunnel ports from gw2 ########## | |
10624 | as gw2 | |
10625 | for chassis in gw1 hv1 hv2; do | |
10626 | echo "checking gw2 -> $chassis" | |
10627 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10628 | [[enable=true | |
10629 | ]]) | |
10630 | done | |
10631 | ||
10632 | # check BFD enablement on tunnel ports from hv1 ########### | |
10633 | as hv1 | |
10634 | for chassis in gw1 gw2; do | |
10635 | echo "checking hv1 -> $chassis" | |
10636 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10637 | [[enable=true | |
10638 | ]]) | |
10639 | done | |
10640 | # make sure BFD is not enabled to hv2, we don't need it | |
10641 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv2-0],[0], | |
10642 | [[ | |
10643 | ]]) | |
10644 | ||
10645 | # check BFD enablement on tunnel ports from hv2 ########## | |
10646 | as hv2 | |
10647 | for chassis in gw1 gw2; do | |
10648 | echo "checking hv2 -> $chassis" | |
10649 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-$chassis-0],[0], | |
10650 | [[enable=true | |
10651 | ]]) | |
10652 | done | |
10653 | # make sure BFD is not enabled to hv1, we don't need it | |
10654 | AT_CHECK([ovs-vsctl --bare --columns bfd find Interface name=ovn-hv1-0],[0], | |
10655 | [[ | |
10656 | ]]) | |
10657 | ||
10658 | # make sure that flows for handling the outside router port reside on gw2 now | |
10659 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=24 | \ | |
10660 | grep 00:00:02:01:02:04 | wc -l], [0], [[1 | |
10661 | ]]) | |
10662 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=24 | \ | |
10663 | grep 00:00:02:01:02:04 | wc -l], [0], [[0 | |
10664 | ]]) | |
10665 | ||
10666 | # disconnect GW2 from the network, GW1 should take over | |
10667 | as gw2 | |
10668 | port=${sandbox}_br-phys | |
10669 | as main ovs-vsctl del-port n1 $port | |
10670 | ||
10671 | bfd_dump | |
10672 | ||
10673 | # make sure that flows for handling the outside router port reside on gw2 now | |
10674 | OVS_WAIT_UNTIL([as gw1 ovs-ofctl dump-flows br-int table=24 | \ | |
10675 | grep 00:00:02:01:02:04 | wc -l], [0], [[1 | |
10676 | ]]) | |
10677 | OVS_WAIT_UNTIL([as gw2 ovs-ofctl dump-flows br-int table=24 | \ | |
10678 | grep 00:00:02:01:02:04 | wc -l], [0], [[0 | |
10679 | ]]) | |
10680 | ||
10681 | # check that the chassis redirect port has been reclaimed by the gw1 chassis | |
10682 | OVS_WAIT_UNTIL([ovn-sbctl --columns chassis --bare find Port_Binding \ | |
10683 | logical_port=cr-outside | grep $gw1_chassis | wc -l], [0],[[1 | |
10684 | ]]) | |
10685 | ||
1da17a0b | 10686 | OVN_CLEANUP([gw1],[gw2],[hv1],[hv2]) |
10687 | ||
10688 | AT_CLEANUP | |
acfc41ff VAK |
10689 | |
10690 | AT_SETUP([ovn -- send gratuitous ARP for NAT rules on HA distributed router]) | |
10691 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
10692 | ovn_start | |
10693 | ovn-nbctl ls-add ls0 | |
10694 | ovn-nbctl ls-add ls1 | |
10695 | ovn-nbctl create Logical_Router name=lr0 | |
10696 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.100/24 | |
10697 | ||
10698 | ovn-nbctl --id=@gc0 create Gateway_Chassis \ | |
10699 | name=outside_gw1 chassis_name=hv2 priority=10 -- \ | |
10700 | --id=@gc1 create Gateway_Chassis \ | |
10701 | name=outside_gw2 chassis_name=hv3 priority=1 -- \ | |
10702 | set Logical_Router_Port lrp0 'gateway_chassis=[@gc0,@gc1]' | |
10703 | ||
10704 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
10705 | type=router options:router-port=lrp0 addresses="router" | |
10706 | ovn-nbctl lrp-add lr0 lrp1 f0:00:00:00:00:02 10.0.0.1/24 | |
10707 | ovn-nbctl lsp-add ls1 lrp1-rp -- set Logical_Switch_Port lrp1-rp \ | |
10708 | type=router options:router-port=lrp1 addresses="router" | |
10709 | ||
10710 | # Add NAT rules | |
10711 | AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 192.168.0.100 10.0.0.0/24]) | |
10712 | ||
10713 | net_add n1 | |
10714 | sim_add hv1 | |
10715 | as hv1 | |
10716 | ovs-vsctl add-br br-phys | |
10717 | ovn_attach n1 br-phys 192.168.0.1 | |
10718 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
10719 | AT_CHECK([ovs-vsctl add-port br-phys snoopvif -- set Interface snoopvif options:tx_pcap=hv1/snoopvif-tx.pcap options:rxq_pcap=hv1/snoopvif-rx.pcap]) | |
10720 | ||
10721 | sim_add hv2 | |
10722 | as hv2 | |
10723 | ovs-vsctl add-br br-phys | |
10724 | ovn_attach n1 br-phys 192.168.0.2 | |
10725 | AT_CHECK([as hv2 ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
10726 | ||
10727 | sim_add hv3 | |
10728 | as hv3 | |
10729 | ovs-vsctl add-br br-phys | |
10730 | ovn_attach n1 br-phys 192.168.0.3 | |
10731 | AT_CHECK([as hv3 ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
10732 | ||
10733 | # Create a localnet port. | |
10734 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
10735 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
10736 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
10737 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
10738 | ||
10739 | # wait for earlier changes to take effect | |
6c8d3d69 | 10740 | AT_CHECK([ovn-nbctl --timeout=3 --wait=hv sync], [0], [ignore]) |
acfc41ff VAK |
10741 | |
10742 | reset_pcap_file() { | |
10743 | local iface=$1 | |
10744 | local pcap_file=$2 | |
10745 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
10746 | options:rxq_pcap=dummy-rx.pcap | |
10747 | rm -f ${pcap_file}*.pcap | |
10748 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
10749 | options:rxq_pcap=${pcap_file}-rx.pcap | |
10750 | } | |
10751 | ||
10752 | as hv1 reset_pcap_file snoopvif hv1/snoopvif | |
10753 | as hv2 reset_pcap_file br-phys_n1 hv2/br-phys_n1 | |
10754 | as hv3 reset_pcap_file br-phys_n1 hv3/br-phys_n1 | |
10755 | # add nat-addresses option | |
6c8d3d69 | 10756 | ovn-nbctl --wait=hv lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" |
acfc41ff VAK |
10757 | |
10758 | # Wait for packets to be received through hv2. | |
10759 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) | |
10760 | trim_zeros() { | |
10761 | sed 's/\(00\)\{1,\}$//' | |
10762 | } | |
10763 | ||
2db7bb2c | 10764 | only_broadcast_from_lrp1() { |
10765 | grep "fffffffffffff00000000001" | |
10766 | } | |
10767 | ||
acfc41ff | 10768 | garp="fffffffffffff0000000000108060001080006040001f00000000001c0a80064000000000000c0a80064" |
2db7bb2c | 10769 | echo $garp > expout |
10770 | ||
10771 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoop_tx | |
acfc41ff VAK |
10772 | echo "packets on hv1-snoopvif:" |
10773 | cat hv1_snoop_tx | |
10774 | AT_CHECK([sort hv1_snoop_tx], [0], [expout]) | |
2db7bb2c | 10775 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx |
acfc41ff VAK |
10776 | echo "packets on hv2 br-phys tx" |
10777 | cat hv2_br_phys_tx | |
10778 | AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], [expout]) | |
2db7bb2c | 10779 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx |
acfc41ff VAK |
10780 | echo "packets on hv3 br-phys tx" |
10781 | cat hv3_br_phys_tx | |
10782 | AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], []) | |
10783 | ||
10784 | ||
10785 | # at this point, we invert the priority of the gw chassis between hv2 and hv3 | |
10786 | ||
10787 | ovn-nbctl --wait=hv \ | |
10788 | --id=@gc0 create Gateway_Chassis \ | |
10789 | name=outside_gw1 chassis_name=hv2 priority=1 -- \ | |
10790 | --id=@gc1 create Gateway_Chassis \ | |
10791 | name=outside_gw2 chassis_name=hv3 priority=10 -- \ | |
10792 | set Logical_Router_Port lrp0 'gateway_chassis=[@gc0,@gc1]' | |
10793 | ||
10794 | ||
10795 | as hv1 reset_pcap_file snoopvif hv1/snoopvif | |
10796 | as hv2 reset_pcap_file br-phys_n1 hv2/br-phys_n1 | |
10797 | as hv3 reset_pcap_file br-phys_n1 hv3/br-phys_n1 | |
10798 | ||
10799 | # Wait for packets to be received. | |
10800 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) | |
10801 | trim_zeros() { | |
10802 | sed 's/\(00\)\{1,\}$//' | |
10803 | } | |
10804 | ||
2db7bb2c | 10805 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx |
acfc41ff | 10806 | AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) |
2db7bb2c | 10807 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx |
acfc41ff | 10808 | AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout]) |
2db7bb2c | 10809 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx |
acfc41ff | 10810 | AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], []) |
03b85a58 GL |
10811 | |
10812 | # change localnet port tag. | |
10813 | AT_CHECK([ovn-nbctl set Logical_Switch_Port ln_port tag=2014]) | |
10814 | ||
10815 | # wait for earlier changes to take effect | |
d65586b6 NS |
10816 | OVS_WAIT_UNTIL([test 1 = `as hv2 ovs-ofctl dump-flows br-int table=65 | \ |
10817 | grep "actions=mod_vlan_vid:2014" | wc -l` | |
10818 | ]) | |
10819 | ||
10820 | OVS_WAIT_UNTIL([test 1 = `as hv3 ovs-ofctl dump-flows br-int table=65 | \ | |
10821 | grep "actions=mod_vlan_vid:2014" | wc -l` | |
10822 | ]) | |
03b85a58 GL |
10823 | |
10824 | # update nat-addresses option | |
d65586b6 NS |
10825 | ovn-nbctl --wait=hv clear logical_switch_port lrp0-rp options |
10826 | ||
10827 | #Wait until the Port_Binding.nat_addresses is cleared. | |
10828 | OVS_WAIT_UNTIL([test 0 = `ovn-sbctl --bare --columns nat_addresses find port_binding \ | |
10829 | logical_port=lrp0-rp | grep is_chassis | wc -l`]) | |
03b85a58 GL |
10830 | |
10831 | as hv1 reset_pcap_file snoopvif hv1/snoopvif | |
10832 | as hv2 reset_pcap_file br-phys_n1 hv2/br-phys_n1 | |
10833 | as hv3 reset_pcap_file br-phys_n1 hv3/br-phys_n1 | |
10834 | ||
d65586b6 NS |
10835 | ovn-nbctl --wait=hv lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" |
10836 | ||
10837 | #Wait until the Port_Binding.nat_addresses is set. | |
10838 | OVS_WAIT_UNTIL([test 1 = `ovn-sbctl --bare --columns nat_addresses find port_binding \ | |
10839 | logical_port=lrp0-rp | grep is_chassis | wc -l`]) | |
10840 | ||
03b85a58 GL |
10841 | # Wait for packets to be received. |
10842 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) | |
10843 | trim_zeros() { | |
10844 | sed 's/\(00\)\{1,\}$//' | |
10845 | } | |
10846 | ||
10847 | garp="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80064000000000000c0a80064" | |
10848 | echo $garp > expout | |
10849 | ||
10850 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx | |
10851 | AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) | |
10852 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx | |
10853 | AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout]) | |
10854 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx | |
10855 | AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], []) | |
10856 | ||
acfc41ff VAK |
10857 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
10858 | ||
10859 | AT_CLEANUP | |
79371ff5 | 10860 | |
10861 | AT_SETUP([ovn -- ensure one gw controller restart in HA doesn't bounce the master]) | |
10862 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
10863 | ovn_start | |
10864 | ||
10865 | net_add n1 | |
10866 | ||
10867 | # create two gateways with external network connectivity | |
10868 | for i in 1 2; do | |
10869 | sim_add gw$i | |
10870 | as gw$i | |
10871 | ovs-vsctl add-br br-phys | |
10872 | ovn_attach n1 br-phys 192.168.0.$i | |
10873 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
10874 | done | |
10875 | ||
10876 | ovn-nbctl ls-add inside | |
10877 | ovn-nbctl ls-add outside | |
10878 | ||
10879 | # create one hypervisors with a vif port the internal network | |
10880 | sim_add hv1 | |
10881 | as hv1 | |
10882 | ovs-vsctl add-br br-phys | |
10883 | ovn_attach n1 br-phys 192.168.0.11 | |
10884 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
10885 | set interface hv1-vif1 external-ids:iface-id=inside1 \ | |
10886 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
10887 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
10888 | ofport-request=1 | |
10889 | ||
10890 | ovn-nbctl lsp-add inside inside1 \ | |
10891 | -- lsp-set-addresses inside1 "f0:00:00:01:22:01 192.168.1.101" | |
10892 | ||
10893 | ||
74868f2c | 10894 | OVN_POPULATE_ARP |
79371ff5 | 10895 | |
10896 | ovn-nbctl create Logical_Router name=R1 | |
10897 | ||
10898 | # Connect inside to R1 | |
10899 | ovn-nbctl lrp-add R1 inside 00:00:01:01:02:03 192.168.1.1/24 | |
10900 | ovn-nbctl lsp-add inside rp-inside -- set Logical_Switch_Port rp-inside \ | |
10901 | type=router options:router-port=inside \ | |
10902 | -- lsp-set-addresses rp-inside router | |
10903 | ||
10904 | # Connect outside to R1 as distributed router gateway port on gw1+gw2 | |
10905 | ovn-nbctl lrp-add R1 outside 00:00:02:01:02:04 192.168.0.101/24 | |
10906 | ||
10907 | ovn-nbctl --id=@gc0 create Gateway_Chassis \ | |
10908 | name=outside_gw1 chassis_name=gw1 priority=20 -- \ | |
10909 | --id=@gc1 create Gateway_Chassis \ | |
10910 | name=outside_gw2 chassis_name=gw2 priority=10 -- \ | |
10911 | set Logical_Router_Port outside 'gateway_chassis=[@gc0,@gc1]' | |
10912 | ||
10913 | ovn-nbctl lsp-add outside rp-outside -- set Logical_Switch_Port rp-outside \ | |
10914 | type=router options:router-port=outside \ | |
10915 | -- lsp-set-addresses rp-outside router | |
10916 | ||
10917 | # Create localnet port in outside | |
10918 | ovn-nbctl lsp-add outside ln-outside | |
10919 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
10920 | ovn-nbctl lsp-set-type ln-outside localnet | |
10921 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
10922 | ||
10923 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
8e1d9349 | 10924 | ovn-nbctl --wait=hv --timeout=3 sync |
79371ff5 | 10925 | |
10926 | # currently when ovn-controller is restarted, the old entry is deleted | |
10927 | # and a new one is created, which leaves the Gateway_Chassis with | |
10928 | # an empty chassis for a while. NOTE: restarting ovn-controller in tests | |
10929 | # doesn't have the same effect because "name" is conserved, and the | |
10930 | # Chassis entry is not replaced. | |
10931 | ||
3a0c5805 | 10932 | > gw1/ovn-controller.log |
325b2b1a | 10933 | |
79371ff5 | 10934 | gw2_chassis=$(ovn-sbctl --bare --columns=_uuid find Chassis name=gw2) |
10935 | ovn-sbctl destroy Chassis $gw2_chassis | |
10936 | ||
1be1e0e5 | 10937 | OVS_WAIT_UNTIL([test 0 = `grep -c "Releasing lport" gw1/ovn-controller.log`]) |
79371ff5 | 10938 | |
10939 | OVN_CLEANUP([gw1],[gw2],[hv1]) | |
10940 | ||
10941 | AT_CLEANUP | |
63d91afa | 10942 | |
b1a3a6a4 NS |
10943 | AT_SETUP([ovn -- IPv6 Neighbor Solicitation for unknown MAC]) |
10944 | AT_KEYWORDS([ovn-nd_ns for unknown mac]) | |
10945 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
10946 | ovn_start | |
10947 | ||
10948 | ovn-nbctl ls-add sw0_ip6 | |
10949 | ovn-nbctl lsp-add sw0_ip6 sw0_ip6-port1 | |
10950 | ovn-nbctl lsp-set-addresses sw0_ip6-port1 \ | |
10951 | "50:64:00:00:00:02 aef0::5264:00ff:fe00:0002" | |
10952 | ||
10953 | ovn-nbctl lsp-set-port-security sw0_ip6-port1 \ | |
10954 | "50:64:00:00:00:02 aef0::5264:00ff:fe00:0002" | |
10955 | ||
10956 | ovn-nbctl lr-add lr0_ip6 | |
847dc1c2 | 10957 | ovn-nbctl lrp-add lr0_ip6 lrp0_ip6 00:00:00:00:af:01 aef0:0:0:0:0:0:0:0/64 |
b1a3a6a4 NS |
10958 | ovn-nbctl lsp-add sw0_ip6 lrp0_ip6-attachment |
10959 | ovn-nbctl lsp-set-type lrp0_ip6-attachment router | |
bec7c641 | 10960 | ovn-nbctl lsp-set-addresses lrp0_ip6-attachment router |
b1a3a6a4 NS |
10961 | ovn-nbctl lsp-set-options lrp0_ip6-attachment router-port=lrp0_ip6 |
10962 | ovn-nbctl set logical_router_port lrp0_ip6 ipv6_ra_configs:address_mode=slaac | |
10963 | ||
10964 | ovn-nbctl ls-add public | |
10965 | ovn-nbctl lsp-add public ln-public | |
10966 | ovn-nbctl lsp-set-addresses ln-public unknown | |
10967 | ovn-nbctl lsp-set-type ln-public localnet | |
10968 | ovn-nbctl lsp-set-options ln-public network_name=phys | |
10969 | ||
10970 | ovn-nbctl lrp-add lr0_ip6 ip6_public 00:00:02:01:02:04 \ | |
10971 | 2001:db8:1:0:200:02ff:fe01:0204/64 \ | |
10972 | -- set Logical_Router_port ip6_public options:redirect-chassis="hv1" | |
10973 | ||
250ed434 NS |
10974 | #install static route |
10975 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
10976 | ip_prefix="\:\:/0" nexthop="2001\:db8\:1\:0\:200\:02ff\:fe01\:1305" \ | |
10977 | -- add Logical_Router lr0_ip6 static_routes @lrt | |
b1a3a6a4 NS |
10978 | |
10979 | ovn-nbctl lsp-add public rp-ip6_public -- set Logical_Switch_Port \ | |
10980 | rp-ip6_public type=router options:router-port=ip6_public \ | |
10981 | -- lsp-set-addresses rp-ip6_public router | |
10982 | ||
10983 | net_add n1 | |
10984 | sim_add hv1 | |
10985 | as hv1 | |
10986 | ovs-vsctl add-br br-phys | |
10987 | ovn_attach n1 br-phys 192.168.0.2 | |
10988 | ||
10989 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
10990 | set interface hv1-vif1 external-ids:iface-id=sw0_ip6-port1 \ | |
10991 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
10992 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
10993 | ofport-request=1 | |
10994 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
10995 | ||
86c9d79a | 10996 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up sw0_ip6-port1` = xup]) |
bec7c641 NS |
10997 | |
10998 | # There should be 2 Neighbor Advertisement flows for the router port | |
10999 | # aef0:: ip address in logical switch pipeline with action nd_na_router. | |
11000 | AT_CHECK([ovn-sbctl dump-flows sw0_ip6 | grep ls_in_arp_rsp | \ | |
11001 | grep "nd_na_router" | wc -l], [0], [2 | |
11002 | ]) | |
11003 | ||
11004 | # There should be 4 Neighbor Advertisement flows with action nd_na_router | |
11005 | # in the router pipeline for the router lr0_ip6. | |
11006 | AT_CHECK([ovn-sbctl dump-flows lr0_ip6 | grep nd_na_router | \ | |
11007 | wc -l], [0], [4 | |
11008 | ]) | |
11009 | ||
86c9d79a NS |
11010 | cr_uuid=`ovn-sbctl find port_binding logical_port=cr-ip6_public | grep _uuid | cut -f2 -d ":"` |
11011 | ||
11012 | # There is only one chassis. | |
11013 | chassis_uuid=`ovn-sbctl list chassis | grep _uuid | cut -f2 -d ":"` | |
11014 | OVS_WAIT_UNTIL([test $chassis_uuid = `ovn-sbctl get port_binding $cr_uuid chassis`]) | |
b1a3a6a4 NS |
11015 | |
11016 | trim_zeros() { | |
11017 | sed 's/\(00\)\{1,\}$//' | |
11018 | } | |
11019 | ||
250ed434 NS |
11020 | reset_pcap_file() { |
11021 | local iface=$1 | |
11022 | local pcap_file=$2 | |
11023 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
11024 | options:rxq_pcap=dummy-rx.pcap | |
11025 | rm -f ${pcap_file}*.pcap | |
11026 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
11027 | options:rxq_pcap=${pcap_file}-rx.pcap | |
11028 | } | |
11029 | ||
b1a3a6a4 NS |
11030 | # Test the IPv6 Neighbor Solicitation (NS) - nd_ns action for unknown MAC |
11031 | # addresses. ovn-controller should generate an IPv6 NS request for IPv6 | |
11032 | # packets whose MAC is unknown (in the ARP_REQUEST router pipeline stage. | |
11033 | # test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
11034 | # This function sends ipv6 packet | |
11035 | test_ipv6() { | |
250ed434 NS |
11036 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 |
11037 | local dst_mcast_mac=$6 mcast_node_ip=$7 nd_target=$8 | |
b1a3a6a4 NS |
11038 | |
11039 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip} | |
11040 | packet=${packet}8000000000000000 | |
b1a3a6a4 | 11041 | |
b1a3a6a4 | 11042 | src_mac=000002010204 |
250ed434 NS |
11043 | expected_packet=${dst_mcast_mac}${src_mac}86dd6000000000203aff${src_ip} |
11044 | expected_packet=${expected_packet}${mcast_node_ip}8700XXXX00000000 | |
11045 | expected_packet=${expected_packet}${nd_target}0101${src_mac} | |
b1a3a6a4 NS |
11046 | |
11047 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif${inport} $packet | |
250ed434 | 11048 | rm -f ipv6_ns.expected |
b1a3a6a4 NS |
11049 | echo $expected_packet >> ipv6_ns.expected |
11050 | } | |
11051 | ||
11052 | src_mac=506400000002 | |
11053 | dst_mac=00000000af01 | |
11054 | src_ip=aef0000000000000526400fffe000002 | |
250ed434 NS |
11055 | dst_ip=20010db800010000020002fffe010205 |
11056 | dst_mcast_mac=3333ff010205 | |
11057 | mcast_node_ip=ff0200000000000000000001ff010205 | |
11058 | nd_target=20010db800010000020002fffe010205 | |
b1a3a6a4 NS |
11059 | # Send an IPv6 packet. Generated IPv6 Neighbor solicitation packet |
11060 | # should be received by the ports attached to br-phys. | |
250ed434 NS |
11061 | test_ipv6 1 $src_mac $dst_mac $src_ip $dst_ip $dst_mcast_mac \ |
11062 | $mcast_node_ip $nd_target | |
11063 | ||
11064 | OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys_n1-tx.pcap | cut -d " " -f1)]) | |
11065 | OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys-tx.pcap | cut -d " " -f1)]) | |
11066 | ||
11067 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap | \ | |
11068 | trim_zeros > 1.packets | |
11069 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | \ | |
11070 | trim_zeros > 2.packets | |
11071 | ||
11072 | cat ipv6_ns.expected | cut -c -112 > expout | |
11073 | AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) | |
11074 | AT_CHECK([cat 2.packets | cut -c -112], [0], [expout]) | |
11075 | ||
11076 | # Skipping the ICMPv6 checksum | |
11077 | cat ipv6_ns.expected | cut -c 117- > expout | |
11078 | AT_CHECK([cat 1.packets | cut -c 117-], [0], [expout]) | |
11079 | AT_CHECK([cat 2.packets | cut -c 117-], [0], [expout]) | |
11080 | ||
11081 | # Now send a packet with destination ip other than | |
11082 | # 2001:db8:1:0:200:02ff:fe01:0204/64 prefix. | |
11083 | reset_pcap_file br-phys_n1 hv1/br-phys_n1 | |
11084 | reset_pcap_file br-phys hv1/br-phys | |
11085 | ||
11086 | src_mac=506400000002 | |
11087 | dst_mac=00000000af01 | |
11088 | src_ip=aef0000000000000526400fffe000002 | |
11089 | dst_ip=20020ab8000100000200020000020306 | |
11090 | # multicast mac of the nexthop IP - 2001:db8:1:0:200:02ff:fe01:1305 | |
11091 | dst_mcast_mac=3333ff011305 | |
11092 | mcast_node_ip=ff0200000000000000000001ff011305 | |
11093 | nd_target=20010db800010000020002fffe011305 | |
11094 | test_ipv6 1 $src_mac $dst_mac $src_ip $dst_ip $dst_mcast_mac \ | |
11095 | $mcast_node_ip $nd_target | |
b1a3a6a4 | 11096 | |
86c9d79a NS |
11097 | OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys_n1-tx.pcap | cut -d " " -f1)]) |
11098 | OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys-tx.pcap | cut -d " " -f1)]) | |
11099 | ||
b1a3a6a4 NS |
11100 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap | \ |
11101 | trim_zeros > 1.packets | |
11102 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | \ | |
11103 | trim_zeros > 2.packets | |
11104 | ||
11105 | cat ipv6_ns.expected | cut -c -112 > expout | |
11106 | AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) | |
11107 | AT_CHECK([cat 2.packets | cut -c -112], [0], [expout]) | |
11108 | ||
11109 | # Skipping the ICMPv6 checksum | |
11110 | cat ipv6_ns.expected | cut -c 117- > expout | |
11111 | AT_CHECK([cat 1.packets | cut -c 117-], [0], [expout]) | |
11112 | AT_CHECK([cat 2.packets | cut -c 117-], [0], [expout]) | |
11113 | ||
11114 | OVN_CLEANUP([hv1]) | |
11115 | ||
11116 | AT_CLEANUP | |
11117 | ||
63d91afa LR |
11118 | AT_SETUP([ovn -- options:requested-chassis for logical port]) |
11119 | ovn_start | |
11120 | ||
11121 | net_add n1 | |
11122 | ||
11123 | ovn-nbctl ls-add ls0 | |
11124 | ovn-nbctl lsp-add ls0 lsp0 | |
11125 | ||
11126 | # create two hypervisors, each with one vif port | |
11127 | sim_add hv1 | |
11128 | as hv1 | |
11129 | ovs-vsctl add-br br-phys | |
11130 | ovn_attach n1 br-phys 192.168.0.11 | |
99cc5c92 NS |
11131 | ovs-vsctl -- add-port br-int hv1-vif0 -- \ |
11132 | set Interface hv1-vif0 ofport-request=1 | |
63d91afa LR |
11133 | |
11134 | sim_add hv2 | |
11135 | as hv2 | |
11136 | ovs-vsctl add-br br-phys | |
11137 | ovn_attach n1 br-phys 192.168.0.12 | |
99cc5c92 NS |
11138 | ovs-vsctl -- add-port br-int hv2-vif0 -- \ |
11139 | set Interface hv2-vif0 ofport-request=1 | |
63d91afa LR |
11140 | |
11141 | # Allow only chassis hv1 to bind logical port lsp0. | |
11142 | ovn-nbctl lsp-set-options lsp0 requested-chassis=hv1 | |
11143 | ||
11144 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
11145 | ovn-nbctl --wait=hv --timeout=3 sync | |
11146 | ||
11147 | # Retrieve hv1 and hv2 chassis UUIDs from southbound database | |
2aa57f08 HZ |
11148 | ovn-sbctl wait-until chassis hv1 |
11149 | ovn-sbctl wait-until chassis hv2 | |
63d91afa LR |
11150 | hv1_uuid=$(ovn-sbctl --bare --columns _uuid find chassis name=hv1) |
11151 | hv2_uuid=$(ovn-sbctl --bare --columns _uuid find chassis name=hv2) | |
11152 | ||
11153 | # (1) Chassis hv2 should not bind lsp0 when requested-chassis is hv1. | |
11154 | echo "verifying that hv2 does not bind lsp0 when hv2 physical/logical mapping is added" | |
11155 | as hv2 | |
11156 | ovs-vsctl set interface hv2-vif0 external-ids:iface-id=lsp0 | |
11157 | ||
11158 | OVS_WAIT_UNTIL([test 1 = $(grep -c "Not claiming lport lsp0" hv2/ovn-controller.log)]) | |
11159 | AT_CHECK([test x$(ovn-sbctl --bare --columns chassis find port_binding logical_port=lsp0) = x], [0], []) | |
11160 | ||
99cc5c92 NS |
11161 | # (2) Chassis hv2 should not add flows in OFTABLE_PHY_TO_LOG and OFTABLE_LOG_TO_PHY tables. |
11162 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=0 | grep in_port=1], [1], []) | |
11163 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=65 | grep output], [1], []) | |
11164 | ||
11165 | # (3) Chassis hv1 should bind lsp0 when physical to logical mapping exists on hv1. | |
63d91afa LR |
11166 | echo "verifying that hv1 binds lsp0 when hv1 physical/logical mapping is added" |
11167 | as hv1 | |
11168 | ovs-vsctl set interface hv1-vif0 external-ids:iface-id=lsp0 | |
11169 | ||
11170 | OVS_WAIT_UNTIL([test 1 = $(grep -c "Claiming lport lsp0" hv1/ovn-controller.log)]) | |
2aa57f08 | 11171 | AT_CHECK([test x$(ovn-sbctl --bare --columns chassis find port_binding logical_port=lsp0) = x"$hv1_uuid"], [0], []) |
63d91afa | 11172 | |
99cc5c92 NS |
11173 | # (4) Chassis hv1 should add flows in OFTABLE_PHY_TO_LOG and OFTABLE_LOG_TO_PHY tables. |
11174 | as hv1 ovs-ofctl dump-flows br-int | |
11175 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=0 | grep in_port=1], [0], [ignore]) | |
11176 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=65 | grep actions=output:1], [0], [ignore]) | |
11177 | ||
11178 | # (5) Chassis hv1 should release lsp0 binding and chassis hv2 should bind lsp0 when | |
63d91afa LR |
11179 | # the requested chassis for lsp0 is changed from hv1 to hv2. |
11180 | echo "verifying that lsp0 binding moves when requested-chassis is changed" | |
11181 | ||
11182 | ovn-nbctl lsp-set-options lsp0 requested-chassis=hv2 | |
11183 | OVS_WAIT_UNTIL([test 1 = $(grep -c "Releasing lport lsp0 from this chassis" hv1/ovn-controller.log)]) | |
2aa57f08 | 11184 | OVS_WAIT_UNTIL([test x$(ovn-sbctl --bare --columns chassis find port_binding logical_port=lsp0) = x"$hv2_uuid"]) |
63d91afa | 11185 | |
99cc5c92 NS |
11186 | # (6) Chassis hv2 should add flows and hv1 should not. |
11187 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=0 | grep in_port=1], [0], [ignore]) | |
11188 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=65 | grep actions=output:1], [0], [ignore]) | |
11189 | ||
11190 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=0 | grep in_port=1], [1], []) | |
11191 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=65 | grep output], [1], []) | |
11192 | ||
63d91afa LR |
11193 | OVN_CLEANUP([hv1],[hv2]) |
11194 | ||
11195 | AT_CLEANUP | |
bd32425f RB |
11196 | |
11197 | AT_SETUP([ovn -- options:requested-chassis with hostname]) | |
11198 | ||
11199 | ovn_start | |
11200 | ||
11201 | ovn-nbctl ls-add ls0 | |
11202 | ovn-nbctl lsp-add ls0 lsp0 | |
11203 | ||
11204 | net_add n1 | |
11205 | sim_add hv1 | |
11206 | as hv1 | |
11207 | ovs-vsctl add-br br-phys | |
11208 | ovn_attach n1 br-phys 192.168.0.11 | |
99cc5c92 | 11209 | ovs-vsctl -- add-port br-int hv1-vif0 -- set Interface hv1-vif0 ofport-request=1 |
bd32425f | 11210 | |
362ab40a | 11211 | ovn-sbctl wait-until chassis hv1 |
bd32425f RB |
11212 | hv1_hostname=$(ovn-sbctl --bare --columns hostname find Chassis name=hv1) |
11213 | echo "hv1_hostname=${hv1_hostname}" | |
11214 | ovn-nbctl --wait=hv --timeout=3 lsp-set-options lsp0 requested-chassis=${hv1_hostname} | |
11215 | as hv1 ovs-vsctl set interface hv1-vif0 external-ids:iface-id=lsp0 | |
11216 | ||
11217 | hv1_uuid=$(ovn-sbctl --bare --columns _uuid find Chassis name=hv1) | |
11218 | echo "hv1_uuid=${hv1_uuid}" | |
11219 | OVS_WAIT_UNTIL([test 1 = $(grep -c "Claiming lport lsp0" hv1/ovn-controller.log)]) | |
11220 | AT_CHECK([test x$(ovn-sbctl --bare --columns chassis find port_binding logical_port=lsp0) = x"$hv1_uuid"], [0], []) | |
99cc5c92 NS |
11221 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=0 | grep in_port=1], [0], [ignore]) |
11222 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=65 | grep actions=output:1], [0], [ignore]) | |
bd32425f RB |
11223 | |
11224 | ovn-nbctl --wait=hv --timeout=3 lsp-set-options lsp0 requested-chassis=non-existant-chassis | |
11225 | OVS_WAIT_UNTIL([test 1 = $(grep -c "Releasing lport lsp0 from this chassis" hv1/ovn-controller.log)]) | |
11226 | ovn-nbctl --wait=hv --timeout=3 sync | |
11227 | AT_CHECK([test x$(ovn-sbctl --bare --columns chassis find port_binding logical_port=lsp0) = x], [0], []) | |
99cc5c92 NS |
11228 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=0 | grep in_port=1], [1], []) |
11229 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=65 | grep output], [1], []) | |
bd32425f RB |
11230 | |
11231 | OVN_CLEANUP([hv1]) | |
11232 | ||
11233 | AT_CLEANUP | |
4446661a MM |
11234 | |
11235 | AT_SETUP([ovn -- IPv6 periodic RA]) | |
11236 | ovn_start | |
11237 | ||
11238 | # This test sets up two hypervisors. | |
11239 | # hv1 and hv2 run ovn-controllers, and | |
11240 | # each has a VIF connected to the same | |
11241 | # logical switch in OVN. The logical | |
11242 | # switch is connected to a logical | |
11243 | # router port that is configured to send | |
11244 | # periodic router advertisements. | |
11245 | # | |
11246 | # The reason for having two ovn-controller | |
11247 | # hypervisors is to ensure that the | |
11248 | # periodic RAs being sent by each ovn-controller | |
11249 | # are kept to their local hypervisors. If the | |
11250 | # packets are not kept local, then each port | |
11251 | # will receive too many RAs. | |
11252 | ||
11253 | net_add n1 | |
11254 | sim_add hv1 | |
11255 | sim_add hv2 | |
11256 | as hv1 | |
11257 | ovs-vsctl add-br br-phys | |
11258 | ovn_attach n1 br-phys 192.168.0.2 | |
11259 | as hv2 | |
11260 | ovs-vsctl add-br br-phys | |
11261 | ovn_attach n1 br-phys 192.168.0.3 | |
11262 | ||
11263 | ovn-nbctl lr-add ro | |
1ea1b0d0 | 11264 | ovn-nbctl lrp-add ro ro-sw 00:00:00:00:00:01 aef0:0:0:0:0:0:0:1/64 |
4446661a MM |
11265 | |
11266 | ovn-nbctl ls-add sw | |
11267 | ovn-nbctl lsp-add sw sw-ro | |
11268 | ovn-nbctl lsp-set-type sw-ro router | |
11269 | ovn-nbctl lsp-set-options sw-ro router-port=ro-sw | |
11270 | ovn-nbctl lsp-set-addresses sw-ro 00:00:00:00:00:01 | |
11271 | ovn-nbctl lsp-add sw sw-p1 | |
11272 | ovn-nbctl lsp-set-addresses sw-p1 "00:00:00:00:00:02 aef0::200:ff:fe00:2" | |
11273 | ovn-nbctl lsp-add sw sw-p2 | |
11274 | ovn-nbctl lsp-set-addresses sw-p2 "00:00:00:00:00:03 aef0::200:ff:fe00:3" | |
11275 | ||
11276 | ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:send_periodic=true | |
11277 | ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=slaac | |
11278 | ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:max_interval=4 | |
11279 | ovn-nbctl set Logical_Router_Port ro-sw ipv6_ra_configs:min_interval=3 | |
11280 | ||
86c9d79a NS |
11281 | for i in 1 2 ; do |
11282 | as hv$i | |
11283 | ovs-vsctl -- add-port br-int hv$i-vif1 -- \ | |
11284 | set interface hv$i-vif1 external-ids:iface-id=sw-p$i \ | |
11285 | options:tx_pcap=hv$i/vif1-tx.pcap \ | |
11286 | options:rxq_pcap=hv$i/vif1-rx.pcap \ | |
4446661a MM |
11287 | ofport-request=1 |
11288 | done | |
11289 | ||
86c9d79a NS |
11290 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up sw-p1` = xup]) |
11291 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up sw-p2` = xup]) | |
4446661a MM |
11292 | |
11293 | reset_pcap_file() { | |
11294 | local iface=$1 | |
11295 | local pcap_file=$2 | |
11296 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
11297 | options:rxq_pcap=dummy-rx.pcap | |
11298 | rm -f ${pcap_file}*.pcap | |
11299 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
11300 | options:rxq_pcap=${pcap_file}-rx.pcap | |
11301 | ||
11302 | } | |
11303 | ||
11304 | construct_expected_ra() { | |
11305 | local src_mac=000000000001 | |
11306 | local dst_mac=333300000001 | |
11307 | local src_addr=fe80000000000000020000fffe000001 | |
11308 | local dst_addr=ff020000000000000000000000000001 | |
11309 | ||
11310 | local mtu=$1 | |
11311 | local ra_mo=$2 | |
11312 | local ra_prefix_la=$3 | |
11313 | ||
11314 | local slla=0101${src_mac} | |
11315 | local mtu_opt="" | |
11316 | if test $mtu != 0; then | |
11317 | mtu_opt=05010000${mtu} | |
11318 | fi | |
11319 | shift 3 | |
11320 | ||
11321 | local prefix="" | |
11322 | while [[ $# -gt 0 ]] ; do | |
11323 | local size=$1 | |
11324 | local net=$2 | |
11325 | prefix=${prefix}0304${size}${ra_prefix_la}ffffffffffffffff00000000${net} | |
11326 | shift 2 | |
11327 | done | |
11328 | ||
895ceaf7 | 11329 | local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix} |
4446661a MM |
11330 | local icmp=8600XXXX${ra} |
11331 | ||
11332 | local ip_len=$(expr ${#icmp} / 2) | |
1ea1b0d0 | 11333 | ip_len=$(echo "$ip_len" | awk '{printf "%0.4x\n", $0}') |
4446661a MM |
11334 | |
11335 | local ip=60000000${ip_len}3aff${src_addr}${dst_addr}${icmp} | |
11336 | local eth=${dst_mac}${src_mac}86dd${ip} | |
11337 | local packet=${eth} | |
11338 | echo $packet >> expected | |
11339 | } | |
11340 | ||
11341 | ra_test() { | |
11342 | construct_expected_ra $@ | |
11343 | ||
11344 | for i in hv1 hv2 ; do | |
11345 | OVS_WAIT_WHILE([test 24 = $(wc -c $i/vif1-tx.pcap | cut -d " " -f1)]) | |
11346 | ||
11347 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $i/vif1-tx.pcap > packets | |
11348 | ||
11349 | cat expected | cut -c -112 > expout | |
11350 | AT_CHECK([cat packets | cut -c -112], [0], [expout]) | |
11351 | ||
11352 | # Skip ICMPv6 checksum. | |
11353 | cat expected | cut -c 117- > expout | |
11354 | AT_CHECK([cat packets | cut -c 117-], [0], [expout]) | |
11355 | ||
11356 | rm -f packets | |
11357 | as $i reset_pcap_file $i-vif1 $i/vif1 | |
11358 | done | |
11359 | ||
11360 | rm -f expected | |
11361 | } | |
11362 | ||
11363 | # Baseline test with no MTU | |
11364 | ra_test 0 00 c0 40 aef00000000000000000000000000000 | |
11365 | ||
11366 | # Now make sure an MTU option makes it | |
11367 | ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:mtu=1500 | |
11368 | ra_test 000005dc 00 c0 40 aef00000000000000000000000000000 | |
11369 | ||
11370 | # Now test for multiple network prefixes | |
11371 | ovn-nbctl --wait=hv set Logical_Router_port ro-sw networks='aef0\:\:1/64 fd0f\:\:1/48' | |
11372 | ra_test 000005dc 00 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 | |
11373 | ||
11374 | # Test a different address mode now | |
11375 | ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateful | |
11376 | ra_test 000005dc 80 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 | |
11377 | ||
11378 | # And the other address mode | |
11379 | ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateless | |
c7ea79f5 | 11380 | ra_test 000005dc 40 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 |
4446661a MM |
11381 | |
11382 | OVN_CLEANUP([hv1],[hv2]) | |
11383 | AT_CLEANUP | |
4826add0 LB |
11384 | |
11385 | AT_SETUP([ovn -- ACL reject rule test]) | |
11386 | AT_KEYWORDS([acl-reject]) | |
11387 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
11388 | ovn_start | |
11389 | ||
11390 | # test_ip_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM EXP_IP_CHKSUM EXP_ICMP_CHKSUM | |
11391 | # | |
11392 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv4 packet with | |
11393 | # ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHKSUM as specified. | |
11394 | # EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are the ip and icmp checksums of the icmp destination | |
11395 | # unreachable frame generated from ACL rule hit | |
11396 | # | |
11397 | # INPORT is a lport number, e.g. 11 for vif11. | |
11398 | # HV is a hypervisor number | |
11399 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
11400 | # IPV4_SRC and IPV4_DST are each 8 hex digits. | |
11401 | # IP_CHKSUM, EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits | |
11402 | test_ip_packet() { | |
11403 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ipv4_dst=$6 ip_chksum=$7 | |
11404 | local exp_ip_chksum=$8 exp_icmp_chksum=$9 | |
11405 | shift 9 | |
11406 | ||
11407 | local ip_ttl=ff | |
11408 | local packet=${eth_dst}${eth_src}08004500001400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst} | |
11409 | ||
11410 | local reply_icmp_ttl=ff | |
11411 | local icmp_type_code_response=0301 | |
11412 | local icmp_data=00000000 | |
11413 | local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_data} | |
11414 | local reply=${eth_src}${eth_dst}08004500001c00004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload} | |
11415 | echo $reply >> vif$inport.expected | |
11416 | ||
11417 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
11418 | } | |
11419 | ||
c319fabc LB |
11420 | # test_ipv6_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_DST EXP_ICMP_CHKSUM |
11421 | # | |
11422 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv6 packet with | |
11423 | # ETH_SRC, ETH_DST, IPV6_SRC, IPV6_DST as specified. | |
11424 | # EXP_ICMP_CHKSUM is the icmp6 checksums of the icmp6 destination unreachable frame generated from ACL rule hit | |
11425 | test_ipv6_packet() { | |
11426 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_dst=$6 exp_icmp_chksum=$7 | |
11427 | shift 7 | |
11428 | ||
11429 | local ip6_hdr=6000000000083aff${ipv6_src}${ipv6_dst} | |
11430 | local packet=${eth_dst}${eth_src}86dd${ip6_hdr}0000000000000000 | |
11431 | ||
11432 | local reply=${eth_src}${eth_dst}86dd6000000000303aff${ipv6_dst}${ipv6_src}0101${exp_icmp_chksum}00000000${ip6_hdr} | |
11433 | echo $reply >> vif$inport.expected | |
11434 | ||
11435 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
11436 | } | |
11437 | ||
c20ab6aa LB |
11438 | # test_tcp_syn_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM TCP_SPORT TCP_DPORT TCP_CHKSUM EXP_IP_CHKSUM EXP_TCP_RST_CHKSUM |
11439 | # | |
11440 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an TCP syn segment with | |
11441 | # ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHKSUM, TCP_SPORT, TCP_DPORT, TCP_CHKSUM as specified. | |
11442 | # EXP_IP_CHKSUM and EXP_TCP_RST_CHKSUM are the ip and tcp checksums of the tcp reset segment generated from ACL rule hit | |
11443 | # | |
11444 | # INPORT is an lport number, e.g. 11 for vif11. | |
11445 | # HV is an hypervisor number | |
11446 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
11447 | # IPV4_SRC and IPV4_DST are each 8 hex digits. | |
11448 | # TCP_SPORT and TCP_DPORT are 4 hex digits. | |
11449 | # IP_CHKSUM, TCP_CHKSUM, EXP_IP_CHSUM and EXP_TCP_RST_CHKSUM are each 4 hex digits | |
11450 | test_tcp_syn_packet() { | |
11451 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ipv4_dst=$6 ip_chksum=$7 | |
11452 | local tcp_sport=$8 tcp_dport=$9 tcp_chksum=${10} | |
11453 | local exp_ip_chksum=${11} exp_tcp_rst_chksum=${12} | |
11454 | shift 12 | |
11455 | ||
11456 | local ip_ttl=ff | |
11457 | local packet=${eth_dst}${eth_src}08004500002800004000${ip_ttl}06${ip_chksum}${ipv4_src}${ipv4_dst}${tcp_sport}${tcp_dport}000000010000000050027210${tcp_chksum}0000 | |
11458 | ||
11459 | local tcp_rst_ttl=ff | |
11460 | local reply=${eth_src}${eth_dst}08004500002800004000${tcp_rst_ttl}06${exp_ip_chksum}${ipv4_dst}${ipv4_src}${tcp_dport}${tcp_sport}000000000000000150040000${exp_tcp_rst_chksum}0000 | |
11461 | echo $reply >> vif$inport.expected | |
11462 | ||
11463 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
11464 | } | |
11465 | ||
4826add0 LB |
11466 | # Create hypervisors hv[123]. |
11467 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. | |
11468 | # Add all of the vifs to a single logical switch sw0. | |
11469 | ||
11470 | net_add n1 | |
11471 | ovn-nbctl ls-add sw0 | |
11472 | for i in 1 2 3; do | |
11473 | sim_add hv$i | |
11474 | as hv$i | |
11475 | ovs-vsctl add-br br-phys | |
11476 | ovn_attach n1 br-phys 192.168.0.$i | |
11477 | ||
11478 | for j in 1 2 3; do | |
11479 | ovn-nbctl lsp-add sw0 sw0-p$i$j -- \ | |
11480 | lsp-set-addresses sw0-p$i$j "00:00:00:00:00:$i$j 192.168.1.$i$j" | |
11481 | ||
11482 | ovs-vsctl -- add-port br-int vif$i$j -- \ | |
11483 | set interface vif$i$j \ | |
11484 | external-ids:iface-id=sw0-p$i$j \ | |
11485 | options:tx_pcap=hv$i/vif$i$j-tx.pcap \ | |
11486 | options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ | |
11487 | ofport-request=$i$j | |
11488 | done | |
11489 | done | |
11490 | ||
11491 | OVN_POPULATE_ARP | |
11492 | # allow some time for ovn-northd and ovn-controller to catch up. | |
11493 | sleep 1 | |
11494 | ||
11495 | ip_to_hex() { | |
11496 | printf "%02x%02x%02x%02x" "$@" | |
11497 | } | |
11498 | ||
11499 | for i in 1 2 3; do | |
11500 | : > vif${i}1.expected | |
11501 | done | |
11502 | ||
11503 | ovn-nbctl --log acl-add sw0 to-lport 1000 "outport == \"sw0-p12\"" reject | |
11504 | ovn-nbctl --log acl-add sw0 from-lport 1000 "inport == \"sw0-p11\"" reject | |
11505 | ovn-nbctl --log acl-add sw0 from-lport 1000 "inport == \"sw0-p21\"" reject | |
732965bc HZ |
11506 | |
11507 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
11508 | ovn-nbctl --timeout=3 --wait=hv sync | |
4826add0 LB |
11509 | |
11510 | test_ip_packet 11 1 000000000011 000000000021 $(ip_to_hex 192 168 1 11) $(ip_to_hex 192 168 1 21) 0000 7d8d fcfe | |
11511 | test_ip_packet 21 2 000000000021 000000000011 $(ip_to_hex 192 168 1 21) $(ip_to_hex 192 168 1 11) 0000 7d8d fcfe | |
11512 | test_ip_packet 31 3 000000000031 000000000012 $(ip_to_hex 192 168 1 31) $(ip_to_hex 192 168 1 12) 0000 7d82 fcfe | |
11513 | ||
c319fabc LB |
11514 | test_ipv6_packet 11 1 000000000011 000000000021 fe80000000000000020001fffe000001 fe80000000000000020001fffe000002 6183 |
11515 | ||
c20ab6aa LB |
11516 | test_tcp_syn_packet 11 1 000000000011 000000000021 $(ip_to_hex 192 168 1 11) $(ip_to_hex 192 168 1 21) 0000 8b40 3039 0000 7d8d 4486 |
11517 | test_tcp_syn_packet 21 2 000000000021 000000000011 $(ip_to_hex 192 168 1 21) $(ip_to_hex 192 168 1 11) 0000 8b40 3039 0000 7d8d 4486 | |
11518 | test_tcp_syn_packet 31 3 000000000031 000000000012 $(ip_to_hex 192 168 1 31) $(ip_to_hex 192 168 1 12) 0000 8b40 3039 0000 7d82 4486 | |
11519 | ||
4826add0 LB |
11520 | for i in 1 2 3; do |
11521 | OVN_CHECK_PACKETS([hv$i/vif${i}1-tx.pcap], [vif${i}1.expected]) | |
11522 | done | |
11523 | ||
11524 | OVN_CLEANUP([hv1], [hv2], [hv3]) | |
11525 | AT_CLEANUP | |
689829d5 HZ |
11526 | |
11527 | AT_SETUP([ovn -- Port Groups]) | |
11528 | AT_KEYWORDS([ovnpg]) | |
11529 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
11530 | ovn_start | |
11531 | ||
11532 | # Logical network: | |
11533 | # | |
11534 | # Three logical switches ls1, ls2, ls3. | |
11535 | # One logical router lr0 connected to ls[123], | |
11536 | # with nine subnets, three per logical switch: | |
11537 | # | |
11538 | # lrp11 on ls1 for subnet 192.168.11.0/24 | |
11539 | # lrp12 on ls1 for subnet 192.168.12.0/24 | |
11540 | # lrp13 on ls1 for subnet 192.168.13.0/24 | |
11541 | # ... | |
11542 | # lrp33 on ls3 for subnet 192.168.33.0/24 | |
11543 | # | |
11544 | # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two | |
11545 | # digits are the subnet and the last digit distinguishes the VIF. | |
11546 | # | |
11547 | # This test will create two port groups and uses them in ACL. | |
11548 | ||
11549 | get_lsp_uuid () { | |
11550 | ovn-nbctl lsp-list ls${1%??} | grep lp$1 | awk '{ print $1 }' | |
11551 | } | |
11552 | ||
11553 | pg1_ports= | |
11554 | pg2_ports= | |
11555 | for i in 1 2 3; do | |
11556 | ovn-nbctl ls-add ls$i | |
11557 | for j in 1 2 3; do | |
11558 | for k in 1 2 3; do | |
11559 | ovn-nbctl \ | |
11560 | -- lsp-add ls$i lp$i$j$k \ | |
4357b6bc BP |
11561 | -- lsp-set-addresses lp$i$j$k \ |
11562 | "f0:00:00:00:0$i:$j$k 192.168.$i$j.$k" | |
689829d5 HZ |
11563 | # logical ports lp[12]?1 belongs to port group pg1 |
11564 | if test $i != 3 && test $k == 1; then | |
11565 | pg1_ports="$pg1_ports `get_lsp_uuid $i$j$k`" | |
11566 | fi | |
11567 | # logical ports lp[23]?2 belongs to port group pg2 | |
11568 | if test $i != 1 && test $k == 2; then | |
11569 | pg2_ports="$pg2_ports `get_lsp_uuid $i$j$k`" | |
11570 | fi | |
11571 | done | |
11572 | done | |
11573 | done | |
11574 | ||
11575 | ovn-nbctl lr-add lr0 | |
11576 | for i in 1 2 3; do | |
11577 | for j in 1 2 3; do | |
11578 | ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24 | |
11579 | ovn-nbctl \ | |
11580 | -- lsp-add ls$i lrp$i$j-attachment \ | |
11581 | -- set Logical_Switch_Port lrp$i$j-attachment type=router \ | |
11582 | options:router-port=lrp$i$j \ | |
11583 | addresses='"00:00:00:00:ff:'$i$j'"' | |
11584 | done | |
11585 | done | |
11586 | ||
11587 | ovn-nbctl create Port_Group name=pg1 ports="$pg1_ports" | |
11588 | ovn-nbctl create Port_Group name=pg2 ports="$pg2_ports" | |
11589 | ||
11590 | # create ACLs on all lswitches to drop traffic from pg2 to pg1 | |
11591 | ovn-nbctl acl-add ls1 to-lport 1001 'outport == @pg1 && ip4.src == $pg2_ip4' drop | |
11592 | ovn-nbctl acl-add ls2 to-lport 1001 'outport == @pg1 && ip4.src == $pg2_ip4' drop | |
11593 | ovn-nbctl acl-add ls3 to-lport 1001 'outport == @pg1 && ip4.src == $pg2_ip4' drop | |
11594 | ||
11595 | # Physical network: | |
11596 | # | |
11597 | # Three hypervisors hv[123]. | |
11598 | # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3. | |
11599 | # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3. | |
11600 | # lp?3[123] all on hv3. | |
11601 | ||
11602 | # Given the name of a logical port, prints the name of the hypervisor | |
11603 | # on which it is located. | |
11604 | vif_to_hv() { | |
11605 | case $1 in dnl ( | |
11606 | ?11) echo 1 ;; dnl ( | |
11607 | ?12 | ?21 | ?22) echo 2 ;; dnl ( | |
11608 | ?13 | ?23 | ?3?) echo 3 ;; | |
11609 | esac | |
11610 | } | |
11611 | ||
11612 | # Given the name of a logical port, prints the name of its logical router | |
11613 | # port, e.g. "vif_to_lrp 123" yields 12. | |
11614 | vif_to_lrp() { | |
11615 | echo ${1%?} | |
11616 | } | |
11617 | ||
11618 | # Given the name of a logical port, prints the name of its logical | |
11619 | # switch, e.g. "vif_to_ls 123" yields 1. | |
11620 | vif_to_ls() { | |
11621 | echo ${1%??} | |
11622 | } | |
11623 | ||
11624 | net_add n1 | |
11625 | for i in 1 2 3; do | |
11626 | sim_add hv$i | |
11627 | as hv$i | |
11628 | ovs-vsctl add-br br-phys | |
11629 | ovn_attach n1 br-phys 192.168.0.$i | |
11630 | done | |
11631 | for i in 1 2 3; do | |
11632 | for j in 1 2 3; do | |
11633 | for k in 1 2 3; do | |
11634 | hv=`vif_to_hv $i$j$k` | |
11635 | as hv$hv ovs-vsctl \ | |
11636 | -- add-port br-int vif$i$j$k \ | |
11637 | -- set Interface vif$i$j$k \ | |
11638 | external-ids:iface-id=lp$i$j$k \ | |
11639 | options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \ | |
11640 | options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \ | |
11641 | ofport-request=$i$j$k | |
11642 | done | |
11643 | done | |
11644 | done | |
11645 | ||
11646 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
11647 | # packets for ARP resolution (native tunneling doesn't queue packets | |
11648 | # for ARP resolution). | |
11649 | OVN_POPULATE_ARP | |
11650 | ||
11651 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
11652 | # XXX This should be more systematic. | |
11653 | sleep 1 | |
11654 | ||
11655 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
11656 | # | |
11657 | # This shell function causes a packet to be received on INPORT. The packet's | |
11658 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
11659 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
11660 | # more) list the VIFs on which the packet should be received. INPORT and the | |
11661 | # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123. | |
11662 | for i in 1 2 3; do | |
11663 | for j in 1 2 3; do | |
11664 | for k in 1 2 3; do | |
11665 | : > $i$j$k.expected | |
11666 | done | |
11667 | done | |
11668 | done | |
11669 | test_ip() { | |
11670 | # This packet has bad checksums but logical L3 routing doesn't check. | |
11671 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
11672 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
11673 | shift; shift; shift; shift; shift | |
11674 | hv=hv`vif_to_hv $inport` | |
11675 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
11676 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
11677 | in_ls=`vif_to_ls $inport` | |
11678 | in_lrp=`vif_to_lrp $inport` | |
11679 | for outport; do | |
11680 | out_ls=`vif_to_ls $outport` | |
11681 | if test $in_ls = $out_ls; then | |
11682 | # Ports on the same logical switch receive exactly the same packet. | |
11683 | echo $packet | |
11684 | else | |
11685 | # Routing decrements TTL and updates source and dest MAC | |
11686 | # (and checksum). | |
11687 | out_lrp=`vif_to_lrp $outport` | |
11688 | echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 | |
11689 | fi >> $outport.expected | |
11690 | done | |
11691 | } | |
11692 | ||
11693 | as hv1 ovs-vsctl --columns=name,ofport list interface | |
11694 | as hv1 ovn-sbctl list port_binding | |
11695 | as hv1 ovn-sbctl list datapath_binding | |
11696 | as hv1 ovn-sbctl list port_group | |
11697 | as hv1 ovn-sbctl list address_set | |
11698 | as hv1 ovn-sbctl dump-flows | |
11699 | as hv1 ovs-ofctl dump-flows br-int | |
11700 | ||
11701 | # Send IP packets between all pairs of source and destination ports, | |
11702 | # packets matches ACL (pg2 to pg1) should be dropped | |
11703 | ip_to_hex() { | |
11704 | printf "%02x%02x%02x%02x" "$@" | |
11705 | } | |
11706 | for is in 1 2 3; do | |
11707 | for js in 1 2 3; do | |
11708 | for ks in 1 2 3; do | |
11709 | bcast= | |
11710 | s=$is$js$ks | |
11711 | smac=f00000000$s | |
11712 | sip=`ip_to_hex 192 168 $is$js $ks` | |
11713 | for id in 1 2 3; do | |
11714 | for jd in 1 2 3; do | |
11715 | for kd in 1 2 3; do | |
11716 | d=$id$jd$kd | |
11717 | dip=`ip_to_hex 192 168 $id$jd $kd` | |
11718 | if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi | |
11719 | if test $d != $s; then unicast=$d; else unicast=; fi | |
11720 | ||
11721 | # packets matches ACL should be dropped | |
11722 | if test $id != 3 && test $kd == 1; then | |
11723 | if test $is != 1 && test $ks == 2; then | |
11724 | unicast= | |
11725 | fi | |
11726 | fi | |
11727 | test_ip $s $smac $dmac $sip $dip $unicast #1 | |
11728 | done | |
11729 | done | |
11730 | done | |
11731 | done | |
11732 | done | |
11733 | done | |
11734 | ||
11735 | # Allow some time for packet forwarding. | |
11736 | # XXX This can be improved. | |
11737 | sleep 1 | |
11738 | ||
11739 | # Now check the packets actually received against the ones expected. | |
11740 | for i in 1 2 3; do | |
11741 | for j in 1 2 3; do | |
11742 | for k in 1 2 3; do | |
11743 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap], | |
11744 | [$i$j$k.expected]) | |
11745 | done | |
11746 | done | |
11747 | done | |
11748 | ||
11749 | # Gracefully terminate daemons | |
11750 | OVN_CLEANUP([hv1], [hv2], [hv3]) | |
11751 | AT_CLEANUP | |
1beb60af HZ |
11752 | |
11753 | AT_SETUP([ovn -- ACLs on Port Groups]) | |
11754 | AT_KEYWORDS([ovnpg_acl]) | |
11755 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
11756 | ovn_start | |
11757 | ||
11758 | # Logical network: | |
11759 | # | |
11760 | # Three logical switches ls1, ls2, ls3. | |
11761 | # One logical router lr0 connected to ls[123], | |
11762 | # with nine subnets, three per logical switch: | |
11763 | # | |
11764 | # lrp11 on ls1 for subnet 192.168.11.0/24 | |
11765 | # lrp12 on ls1 for subnet 192.168.12.0/24 | |
11766 | # lrp13 on ls1 for subnet 192.168.13.0/24 | |
11767 | # ... | |
11768 | # lrp33 on ls3 for subnet 192.168.33.0/24 | |
11769 | # | |
11770 | # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two | |
11771 | # digits are the subnet and the last digit distinguishes the VIF. | |
11772 | # | |
11773 | # This test will create two port groups and ACLs will be applied on them. | |
11774 | ||
11775 | get_lsp_uuid () { | |
11776 | ovn-nbctl lsp-list ls${1%??} | grep lp$1 | awk '{ print $1 }' | |
11777 | } | |
11778 | ||
11779 | pg1_ports= | |
11780 | pg2_ports= | |
11781 | for i in 1 2 3; do | |
11782 | ovn-nbctl ls-add ls$i | |
11783 | for j in 1 2 3; do | |
11784 | for k in 1 2 3; do | |
11785 | ovn-nbctl \ | |
11786 | -- lsp-add ls$i lp$i$j$k \ | |
4357b6bc BP |
11787 | -- lsp-set-addresses lp$i$j$k \ |
11788 | "f0:00:00:00:0$i:$j$k 192.168.$i$j.$k" | |
1beb60af HZ |
11789 | # logical ports lp[12]?1 belongs to port group pg1 |
11790 | if test $i != 3 && test $k == 1; then | |
11791 | pg1_ports="$pg1_ports `get_lsp_uuid $i$j$k`" | |
11792 | fi | |
11793 | # logical ports lp[23]?2 belongs to port group pg2 | |
11794 | if test $i != 1 && test $k == 2; then | |
11795 | pg2_ports="$pg2_ports `get_lsp_uuid $i$j$k`" | |
11796 | fi | |
11797 | done | |
11798 | done | |
11799 | done | |
11800 | ||
11801 | ovn-nbctl lr-add lr0 | |
11802 | for i in 1 2 3; do | |
11803 | for j in 1 2 3; do | |
11804 | ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24 | |
11805 | ovn-nbctl \ | |
11806 | -- lsp-add ls$i lrp$i$j-attachment \ | |
11807 | -- set Logical_Switch_Port lrp$i$j-attachment type=router \ | |
11808 | options:router-port=lrp$i$j \ | |
11809 | addresses='"00:00:00:00:ff:'$i$j'"' | |
11810 | done | |
11811 | done | |
11812 | ||
d87e0897 | 11813 | ovn-nbctl create Port_Group name=pg1 ports="$pg1_ports" |
1beb60af HZ |
11814 | ovn-nbctl create Port_Group name=pg2 ports="$pg2_ports" |
11815 | ||
11816 | # create ACLs on pg1 to drop traffic from pg2 to pg1 | |
d87e0897 HZ |
11817 | ovn-nbctl acl-add pg1 to-lport 1001 'outport == @pg1' drop |
11818 | ovn-nbctl --type=port-group acl-add pg1 to-lport 1002 \ | |
cdc9a84a | 11819 | 'outport == @pg1 && ip4.src == $pg2_ip4' allow-related |
1beb60af HZ |
11820 | |
11821 | # Physical network: | |
11822 | # | |
11823 | # Three hypervisors hv[123]. | |
11824 | # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3. | |
11825 | # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3. | |
11826 | # lp?3[123] all on hv3. | |
11827 | ||
11828 | # Given the name of a logical port, prints the name of the hypervisor | |
11829 | # on which it is located. | |
11830 | vif_to_hv() { | |
11831 | case $1 in dnl ( | |
11832 | ?11) echo 1 ;; dnl ( | |
11833 | ?12 | ?21 | ?22) echo 2 ;; dnl ( | |
11834 | ?13 | ?23 | ?3?) echo 3 ;; | |
11835 | esac | |
11836 | } | |
11837 | ||
11838 | # Given the name of a logical port, prints the name of its logical router | |
11839 | # port, e.g. "vif_to_lrp 123" yields 12. | |
11840 | vif_to_lrp() { | |
11841 | echo ${1%?} | |
11842 | } | |
11843 | ||
11844 | # Given the name of a logical port, prints the name of its logical | |
11845 | # switch, e.g. "vif_to_ls 123" yields 1. | |
11846 | vif_to_ls() { | |
11847 | echo ${1%??} | |
11848 | } | |
11849 | ||
11850 | net_add n1 | |
11851 | for i in 1 2 3; do | |
11852 | sim_add hv$i | |
11853 | as hv$i | |
11854 | ovs-vsctl add-br br-phys | |
11855 | ovn_attach n1 br-phys 192.168.0.$i | |
11856 | done | |
11857 | for i in 1 2 3; do | |
11858 | for j in 1 2 3; do | |
11859 | for k in 1 2 3; do | |
11860 | hv=`vif_to_hv $i$j$k` | |
11861 | as hv$hv ovs-vsctl \ | |
11862 | -- add-port br-int vif$i$j$k \ | |
11863 | -- set Interface vif$i$j$k \ | |
11864 | external-ids:iface-id=lp$i$j$k \ | |
11865 | options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \ | |
11866 | options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \ | |
11867 | ofport-request=$i$j$k | |
11868 | done | |
11869 | done | |
11870 | done | |
11871 | ||
11872 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
11873 | # packets for ARP resolution (native tunneling doesn't queue packets | |
11874 | # for ARP resolution). | |
11875 | OVN_POPULATE_ARP | |
11876 | ||
11877 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
11878 | # XXX This should be more systematic. | |
11879 | sleep 1 | |
11880 | ||
cdc9a84a HZ |
11881 | lsp_to_mac() { |
11882 | echo f0:00:00:00:0${1:0:1}:${1:1:2} | |
11883 | } | |
11884 | ||
11885 | lrp_to_mac() { | |
11886 | echo 00:00:00:00:ff:$1 | |
11887 | } | |
11888 | ||
11889 | # test_icmp INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT... | |
1beb60af | 11890 | # |
cdc9a84a HZ |
11891 | # This shell function causes a ICMP packet to be received on INPORT. |
11892 | # The OUTPORTs (zero or more) list the VIFs on which the packet should | |
11893 | # be received. INPORT and the OUTPORTs are specified as logical switch | |
11894 | # port numbers, e.g. 123 for vif123. | |
1beb60af HZ |
11895 | for i in 1 2 3; do |
11896 | for j in 1 2 3; do | |
11897 | for k in 1 2 3; do | |
11898 | : > $i$j$k.expected | |
11899 | done | |
11900 | done | |
11901 | done | |
cdc9a84a HZ |
11902 | |
11903 | test_icmp() { | |
11904 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6 | |
11905 | local packet="inport==\"lp$inport\" && eth.src==$src_mac && | |
11906 | eth.dst==$dst_mac && ip.ttl==64 && ip4.src==$src_ip | |
11907 | && ip4.dst==$dst_ip && icmp4.type==$icmp_type && | |
11908 | icmp4.code==0" | |
11909 | shift; shift; shift; shift; shift; shift | |
1beb60af | 11910 | hv=hv`vif_to_hv $inport` |
cdc9a84a | 11911 | as $hv ovs-appctl -t ovn-controller inject-pkt "$packet" |
1beb60af HZ |
11912 | in_ls=`vif_to_ls $inport` |
11913 | in_lrp=`vif_to_lrp $inport` | |
11914 | for outport; do | |
11915 | out_ls=`vif_to_ls $outport` | |
11916 | if test $in_ls = $out_ls; then | |
11917 | # Ports on the same logical switch receive exactly the same packet. | |
cdc9a84a | 11918 | echo $packet | ovstest test-ovn expr-to-packets |
1beb60af HZ |
11919 | else |
11920 | # Routing decrements TTL and updates source and dest MAC | |
11921 | # (and checksum). | |
11922 | out_lrp=`vif_to_lrp $outport` | |
cdc9a84a HZ |
11923 | exp_smac=`lrp_to_mac $out_lrp` |
11924 | exp_dmac=`lsp_to_mac $outport` | |
11925 | exp_packet="eth.src==$exp_smac && eth.dst==$exp_dmac && | |
11926 | ip.ttl==63 && ip4.src==$src_ip && ip4.dst==$dst_ip && | |
11927 | icmp4.type==$icmp_type && icmp4.code==0" | |
11928 | echo $exp_packet | ovstest test-ovn expr-to-packets | |
11929 | ||
1beb60af HZ |
11930 | fi >> $outport.expected |
11931 | done | |
11932 | } | |
11933 | ||
11934 | as hv1 ovs-vsctl --columns=name,ofport list interface | |
11935 | as hv1 ovn-sbctl list port_binding | |
11936 | as hv1 ovn-sbctl list datapath_binding | |
11937 | as hv1 ovn-sbctl list port_group | |
11938 | as hv1 ovn-sbctl list address_set | |
11939 | as hv1 ovn-sbctl dump-flows | |
11940 | as hv1 ovs-ofctl dump-flows br-int | |
11941 | ||
11942 | # Send IP packets between all pairs of source and destination ports, | |
11943 | # packets matches ACL1 but not ACL2 should be dropped | |
11944 | ip_to_hex() { | |
11945 | printf "%02x%02x%02x%02x" "$@" | |
11946 | } | |
11947 | for is in 1 2 3; do | |
11948 | for js in 1 2 3; do | |
11949 | for ks in 1 2 3; do | |
11950 | bcast= | |
11951 | s=$is$js$ks | |
cdc9a84a HZ |
11952 | slsp_mac=`lsp_to_mac $s` |
11953 | slrp_mac=`lrp_to_mac $is$js` | |
11954 | sip=192.168.$is$js.$ks | |
1beb60af HZ |
11955 | for id in 1 2 3; do |
11956 | for jd in 1 2 3; do | |
11957 | for kd in 1 2 3; do | |
11958 | d=$id$jd$kd | |
cdc9a84a HZ |
11959 | dlsp_mac=`lsp_to_mac $d` |
11960 | dlrp_mac=`lrp_to_mac $id$jd` | |
11961 | dip=192.168.$id$jd.$kd | |
11962 | if test $is = $id; then dmac=$dlsp_mac; else dmac=$slrp_mac; fi | |
1beb60af HZ |
11963 | if test $d != $s; then unicast=$d; else unicast=; fi |
11964 | ||
11965 | # packets matches ACL1 but not ACL2 should be dropped | |
11966 | if test $id != 3 && test $kd == 1; then | |
11967 | if test $is == 1 || test $ks != 2; then | |
11968 | unicast= | |
11969 | fi | |
11970 | fi | |
cdc9a84a HZ |
11971 | # icmp request (type = 8) |
11972 | test_icmp $s $slsp_mac $dmac $sip $dip 8 $unicast | |
11973 | ||
11974 | # if packets are not dropped, test the return traffic (icmp echo) | |
11975 | # to make sure stateful works, too. | |
11976 | if test x$unicast != x; then | |
11977 | if test $is = $id; then dmac=$slsp_mac; else dmac=$dlrp_mac; fi | |
11978 | # icmp echo (type = 0) | |
11979 | test_icmp $unicast $dlsp_mac $dmac $dip $sip 0 $s | |
11980 | fi | |
1beb60af HZ |
11981 | done |
11982 | done | |
11983 | done | |
11984 | done | |
11985 | done | |
11986 | done | |
11987 | ||
11988 | # Allow some time for packet forwarding. | |
11989 | # XXX This can be improved. | |
11990 | sleep 1 | |
11991 | ||
11992 | # Now check the packets actually received against the ones expected. | |
11993 | for i in 1 2 3; do | |
11994 | for j in 1 2 3; do | |
11995 | for k in 1 2 3; do | |
11996 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap], | |
11997 | [$i$j$k.expected]) | |
11998 | done | |
11999 | done | |
12000 | done | |
12001 | ||
12002 | # Gracefully terminate daemons | |
12003 | OVN_CLEANUP([hv1], [hv2], [hv3]) | |
12004 | AT_CLEANUP | |
55b25947 | 12005 | |
2342c266 JS |
12006 | AT_SETUP([ovn -- Address Set generation from Port Groups (static addressing)]) |
12007 | ovn_start | |
12008 | ||
12009 | ovn-nbctl ls-add ls1 | |
12010 | ||
12011 | ovn-nbctl lsp-add ls1 lp1 | |
12012 | ovn-nbctl lsp-add ls1 lp2 | |
12013 | ovn-nbctl lsp-add ls1 lp3 | |
12014 | ||
12015 | ovn-nbctl lsp-set-addresses lp1 "02:00:00:00:00:01 10.0.0.1 2001:db8::1" | |
12016 | ovn-nbctl lsp-set-addresses lp2 "02:00:00:00:00:02 10.0.0.2 2001:db8::2" | |
12017 | ovn-nbctl lsp-set-addresses lp3 "02:00:00:00:00:03 10.0.0.3 2001:db8::3" | |
12018 | ||
12019 | ovn-nbctl create Port_Group name=pg1 | |
12020 | ovn-nbctl create Port_Group name=pg2 | |
12021 | ||
12022 | ovn-nbctl --id=@p get Logical_Switch_Port lp1 -- add Port_Group pg1 ports @p | |
12023 | ovn-nbctl --id=@p get Logical_Switch_Port lp2 -- add Port_Group pg1 ports @p | |
12024 | ovn-nbctl --id=@p get Logical_Switch_Port lp2 -- add Port_Group pg2 ports @p | |
12025 | ovn-nbctl --id=@p get Logical_Switch_Port lp3 -- add Port_Group pg2 ports @p | |
12026 | ||
12027 | ovn-nbctl --wait=sb sync | |
12028 | ||
12029 | dnl Check if port group address sets were populated with ports' addresses | |
12030 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip4 addresses], | |
12031 | [0], [[["10.0.0.1", "10.0.0.2"]] | |
12032 | ]) | |
12033 | AT_CHECK([ovn-sbctl get Address_Set pg2_ip4 addresses], | |
12034 | [0], [[["10.0.0.2", "10.0.0.3"]] | |
12035 | ]) | |
12036 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip6 addresses], | |
12037 | [0], [[["2001:db8::1", "2001:db8::2"]] | |
12038 | ]) | |
12039 | AT_CHECK([ovn-sbctl get Address_Set pg2_ip6 addresses], | |
12040 | [0], [[["2001:db8::2", "2001:db8::3"]] | |
12041 | ]) | |
12042 | ||
12043 | ovn-nbctl --wait=sb lsp-set-addresses lp1 \ | |
12044 | "02:00:00:00:00:01 10.0.0.11 2001:db8::11" | |
12045 | ||
12046 | dnl Check if updated address got propagated to the port group address sets | |
12047 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip4 addresses], | |
12048 | [0], [[["10.0.0.11", "10.0.0.2"]] | |
12049 | ]) | |
12050 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip6 addresses], | |
12051 | [0], [[["2001:db8::11", "2001:db8::2"]] | |
12052 | ]) | |
12053 | ||
12054 | AT_CLEANUP | |
12055 | ||
984c7d5e JS |
12056 | AT_SETUP([ovn -- Address Set generation from Port Groups (dynamic addressing)]) |
12057 | ovn_start | |
12058 | ||
12059 | ovn-nbctl ls-add ls1 | |
12060 | ovn-nbctl ls-add ls2 | |
12061 | ovn-nbctl ls-add ls3 | |
12062 | ||
12063 | ovn-nbctl set Logical_Switch ls1 \ | |
12064 | other_config:subnet=10.1.0.0/24 other_config:ipv6_prefix="2001:db8:1::" | |
12065 | ovn-nbctl set Logical_Switch ls2 \ | |
12066 | other_config:subnet=10.2.0.0/24 other_config:ipv6_prefix="2001:db8:2::" | |
12067 | ovn-nbctl set Logical_Switch ls3 \ | |
12068 | other_config:subnet=10.3.0.0/24 other_config:ipv6_prefix="2001:db8:3::" | |
12069 | ||
12070 | ovn-nbctl lsp-add ls1 lp1 | |
12071 | ovn-nbctl lsp-add ls2 lp2 | |
12072 | ovn-nbctl lsp-add ls3 lp3 | |
12073 | ||
12074 | ovn-nbctl lsp-set-addresses lp1 "02:00:00:00:00:01 dynamic" | |
12075 | ovn-nbctl lsp-set-addresses lp2 "02:00:00:00:00:02 dynamic" | |
12076 | ovn-nbctl lsp-set-addresses lp3 "02:00:00:00:00:03 dynamic" | |
12077 | ||
12078 | ovn-nbctl create Port_Group name=pg1 | |
12079 | ovn-nbctl create Port_Group name=pg2 | |
12080 | ||
12081 | ovn-nbctl --id=@p get Logical_Switch_Port lp1 -- add Port_Group pg1 ports @p | |
12082 | ovn-nbctl --id=@p get Logical_Switch_Port lp2 -- add Port_Group pg1 ports @p | |
12083 | ovn-nbctl --id=@p get Logical_Switch_Port lp2 -- add Port_Group pg2 ports @p | |
12084 | ovn-nbctl --id=@p get Logical_Switch_Port lp3 -- add Port_Group pg2 ports @p | |
12085 | ||
12086 | ovn-nbctl --wait=sb sync | |
12087 | ||
12088 | dnl Check if port group address sets were populated with ports' addresses | |
12089 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip4 addresses], | |
12090 | [0], [[["10.1.0.2", "10.2.0.2"]] | |
12091 | ]) | |
12092 | AT_CHECK([ovn-sbctl get Address_Set pg2_ip4 addresses], | |
12093 | [0], [[["10.2.0.2", "10.3.0.2"]] | |
12094 | ]) | |
12095 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip6 addresses], | |
12096 | [0], [[["2001:db8:1::ff:fe00:1", "2001:db8:2::ff:fe00:2"]] | |
12097 | ]) | |
12098 | AT_CHECK([ovn-sbctl get Address_Set pg2_ip6 addresses], | |
12099 | [0], [[["2001:db8:2::ff:fe00:2", "2001:db8:3::ff:fe00:3"]] | |
12100 | ]) | |
12101 | ||
abf11558 | 12102 | ovn-nbctl --wait=sb set Logical_Switch ls1 \ |
984c7d5e JS |
12103 | other_config:subnet=10.11.0.0/24 other_config:ipv6_prefix="2001:db8:11::" |
12104 | ||
12105 | dnl Check if updated address got propagated to the port group address sets | |
12106 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip4 addresses], | |
451624fe | 12107 | [0], [[["10.11.0.2", "10.2.0.2"]] |
984c7d5e JS |
12108 | ]) |
12109 | AT_CHECK([ovn-sbctl get Address_Set pg1_ip6 addresses], | |
451624fe | 12110 | [0], [[["2001:db8:11::ff:fe00:1", "2001:db8:2::ff:fe00:2"]] |
984c7d5e JS |
12111 | ]) |
12112 | ||
12113 | AT_CLEANUP | |
12114 | ||
55b25947 NS |
12115 | AT_SETUP([ovn -- ACL conjunction]) |
12116 | ovn_start | |
12117 | ||
12118 | ovn-nbctl ls-add ls1 | |
12119 | ||
12120 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
12121 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
12122 | ||
12123 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
12124 | ||
12125 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
12126 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6" | |
12127 | ||
12128 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6" | |
12129 | ||
12130 | net_add n1 | |
12131 | sim_add hv1 | |
12132 | ||
12133 | as hv1 | |
12134 | ovs-vsctl add-br br-phys | |
12135 | ovn_attach n1 br-phys 192.168.0.1 | |
12136 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
12137 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
12138 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
12139 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
12140 | ofport-request=1 | |
12141 | ||
12142 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
12143 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
12144 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
12145 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
12146 | ofport-request=2 | |
12147 | ||
12148 | ovn-nbctl create Address_Set name=set1 \ | |
12149 | addresses=\"10.0.0.4\",\"10.0.0.5\",\"10.0.0.6\" | |
12150 | ovn-nbctl create Address_Set name=set2 \ | |
12151 | addresses=\"10.0.0.7\",\"10.0.0.8\",\"10.0.0.9\" | |
12152 | ovn-nbctl acl-add ls1 to-lport 1002 \ | |
12153 | 'ip4 && ip4.src == $set1 && ip4.dst == $set1' allow | |
12154 | ovn-nbctl acl-add ls1 to-lport 1001 \ | |
12155 | 'ip4 && ip4.src == $set1 && ip4.dst == $set2' drop | |
12156 | ||
12157 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
12158 | # | |
12159 | # This shell function causes an ip packet to be received on INPORT. | |
12160 | # The packet's content has Ethernet destination DST and source SRC | |
12161 | # (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits). | |
12162 | # The OUTPORTs (zero or more) list the VIFs on which the packet should | |
12163 | # be received. INPORT and the OUTPORTs are specified as logical switch | |
12164 | # port numbers, e.g. 11 for vif11. | |
12165 | test_ip() { | |
12166 | # This packet has bad checksums but logical L3 routing doesn't check. | |
12167 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
12168 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}\ | |
12169 | ${dst_ip}0035111100080000 | |
12170 | shift; shift; shift; shift; shift | |
12171 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
12172 | for outport; do | |
12173 | echo $packet >> $outport.expected | |
12174 | done | |
12175 | } | |
12176 | ||
12177 | ip_to_hex() { | |
12178 | printf "%02x%02x%02x%02x" "$@" | |
12179 | } | |
12180 | ||
12181 | reset_pcap_file() { | |
12182 | local iface=$1 | |
12183 | local pcap_file=$2 | |
12184 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
12185 | options:rxq_pcap=dummy-rx.pcap | |
12186 | rm -f ${pcap_file}*.pcap | |
12187 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
12188 | options:rxq_pcap=${pcap_file}-rx.pcap | |
12189 | } | |
12190 | ||
12191 | ||
12192 | sip=`ip_to_hex 10 0 0 4` | |
12193 | dip=`ip_to_hex 10 0 0 6` | |
12194 | ||
12195 | test_ip 1 f00000000001 f00000000002 $sip $dip 2 | |
12196 | ||
12197 | cat 2.expected > expout | |
12198 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
12199 | AT_CHECK([cat 2.packets], [0], [expout]) | |
12200 | ||
12201 | # There should be total of 12 flows present with conjunction action and 2 flows | |
12202 | # with conj match. Eg. | |
12203 | # table=44, priority=2002,conj_id=2,metadata=0x1 actions=resubmit(,45) | |
12204 | # table=44, priority=2001,conj_id=3,metadata=0x1 actions=drop | |
12205 | # priority=2002,ip,metadata=0x1,nw_dst=10.0.0.6 actions=conjunction(2,2/2) | |
12206 | # priority=2002,ip,metadata=0x1,nw_dst=10.0.0.4 actions=conjunction(2,2/2) | |
12207 | # priority=2002,ip,metadata=0x1,nw_dst=10.0.0.5 actions=conjunction(2,2/2) | |
12208 | # priority=2001,ip,metadata=0x1,nw_dst=10.0.0.7 actions=conjunction(3,2/2) | |
12209 | # priority=2001,ip,metadata=0x1,nw_dst=10.0.0.9 actions=conjunction(3,2/2) | |
12210 | # priority=2001,ip,metadata=0x1,nw_dst=10.0.0.8 actions=conjunction(3,2/2) | |
12211 | # priority=2002,ip,metadata=0x1,nw_src=10.0.0.6 actions=conjunction(2,1/2) | |
12212 | # priority=2002,ip,metadata=0x1,nw_src=10.0.0.4 actions=conjunction(2,1/2) | |
12213 | # priority=2002,ip,metadata=0x1,nw_src=10.0.0.5 actions=conjunction(2,1/2) | |
12214 | # priority=2001,ip,metadata=0x1,nw_src=10.0.0.6 actions=conjunction(3,1/2) | |
12215 | # priority=2001,ip,metadata=0x1,nw_src=10.0.0.4 actions=conjunction(3,1/2) | |
12216 | # priority=2001,ip,metadata=0x1,nw_src=10.0.0.5 actions=conjunction(3,1/2) | |
12217 | ||
12218 | OVS_WAIT_UNTIL([test 12 = `as hv1 ovs-ofctl dump-flows br-int | \ | |
12219 | grep conjunction | wc -l`]) | |
12220 | OVS_WAIT_UNTIL([test 2 = `as hv1 ovs-ofctl dump-flows br-int | \ | |
12221 | grep conj_id | wc -l`]) | |
12222 | ||
12223 | as hv1 ovs-ofctl dump-flows br-int | |
12224 | ||
12225 | # Set the ip address for ls1-lp2 from set2 so that the drop ACL flow is hit. | |
12226 | ovn-nbctl lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.7 20.0.0.4" | |
12227 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.7 20.0.0.4" | |
12228 | ||
12229 | reset_pcap_file hv1-vif2 hv1/vif2 | |
12230 | ||
12231 | rm -f 2.packets | |
12232 | ||
12233 | sip=`ip_to_hex 10 0 0 4` | |
12234 | dip=`ip_to_hex 10 0 0 7` | |
12235 | ||
12236 | test_ip 1 f00000000001 f00000000002 $sip $dip | |
12237 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
12238 | AT_CHECK([cat 2.packets], [0], []) | |
12239 | ||
12240 | AT_CLEANUP | |
0e2751ed LB |
12241 | |
12242 | AT_SETUP([ovn -- TTL exceeded]) | |
12243 | AT_KEYWORDS([ttl-exceeded]) | |
12244 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
12245 | ovn_start | |
12246 | ||
12247 | # test_ip_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_DST IPV4_ROUTER IP_CHKSUM EXP_IP_CHKSUM EXP_ICMP_CHKSUM | |
12248 | # | |
12249 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv4 packet with | |
12250 | # ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHKSUM as specified and TTL set to 1. | |
12251 | # EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are the ip and icmp checksums of the icmp time exceeded frame | |
12252 | # generated by OVN logical router | |
12253 | # | |
12254 | # INPORT is a lport number, e.g. 11 for vif11. | |
12255 | # HV is a hypervisor number | |
12256 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
12257 | # IPV4_SRC, IPV4_DST and IPV4_ROUTER are each 8 hex digits. | |
12258 | # IP_CHKSUM, EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits | |
12259 | test_ip_packet() { | |
12260 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ipv4_dst=$6 ip_router=$7 ip_chksum=$8 | |
12261 | local exp_ip_chksum=$9 exp_icmp_chksum=${10} | |
12262 | shift 10 | |
12263 | ||
12264 | local ip_ttl=01 | |
12265 | local packet=${eth_dst}${eth_src}08004500001400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst} | |
12266 | ||
12267 | local reply_icmp_ttl=fe | |
12268 | local icmp_type_code_response=0b00 | |
12269 | local icmp_data=00000000 | |
12270 | local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_data} | |
12271 | local reply=${eth_src}${eth_dst}08004500001c00004000${reply_icmp_ttl}01${exp_ip_chksum}${ip_router}${ipv4_src}${reply_icmp_payload} | |
12272 | echo $reply >> vif$inport.expected | |
12273 | ||
12274 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
12275 | } | |
12276 | ||
e6a84e1e LB |
12277 | # test_ip6_packet INPORT HV ETH_SRC ETH_DST IPV6_SRC IPV6_DST IPV6_ROUTER EXP_ICMP_CHKSUM |
12278 | # | |
12279 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv6 | |
12280 | # packet with ETH_SRC, ETH_DST, IPV6_SRC and IPV6_DST as specified. | |
12281 | # IPV6_ROUTER and EXP_ICMP_CHKSUM are the source IP and checksum of the icmpv6 ttl exceeded | |
12282 | # packet sent by OVN logical router | |
12283 | test_ip6_packet() { | |
12284 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_dst=$6 ipv6_router=$7 exp_icmp_chksum=$8 | |
12285 | shift 8 | |
12286 | ||
12287 | local ip6_hdr=6000000000151101${ipv6_src}${ipv6_dst} | |
12288 | local packet=${eth_dst}${eth_src}86dd${ip6_hdr}dbb8303900155bac6b646f65206676676e6d66720a | |
12289 | ||
12290 | local reply=${eth_src}${eth_dst}86dd6000000000303afe${ipv6_router}${ipv6_src}0300${exp_icmp_chksum}00000000${ip6_hdr} | |
12291 | echo $reply >> vif$inport.expected | |
12292 | ||
12293 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
12294 | } | |
12295 | ||
0e2751ed LB |
12296 | ip_to_hex() { |
12297 | printf "%02x%02x%02x%02x" "$@" | |
12298 | } | |
12299 | ||
12300 | for i in 1 2; do | |
12301 | net_add n$i | |
12302 | ovn-nbctl ls-add sw$i | |
12303 | ||
12304 | sim_add hv$i | |
12305 | as hv$i | |
12306 | ovs-vsctl add-br br-phys | |
12307 | ovn_attach n$i br-phys 192.168.$i.1 | |
12308 | ||
12309 | ovn-nbctl lsp-add sw$i sw$i-p${i}0 -- \ | |
e6a84e1e | 12310 | lsp-set-addresses sw$i-p${i}0 "00:00:00:00:00:0$i 192.168.$i.1 2001:db8:$i::11" |
0e2751ed LB |
12311 | |
12312 | ovs-vsctl -- add-port br-int vif$i -- \ | |
12313 | set interface vif$i \ | |
12314 | external-ids:iface-id=sw$i-p${i}0 \ | |
12315 | options:tx_pcap=hv$i/vif$i-tx.pcap \ | |
12316 | options:rxq_pcap=hv$i/vif$i-rx.pcap \ | |
12317 | ofport-request=$i | |
12318 | done | |
12319 | ||
12320 | ovn-nbctl lr-add lr0 | |
12321 | for i in 1 2; do | |
e6a84e1e | 12322 | ovn-nbctl lrp-add lr0 lrp$i 00:00:00:00:ff:0$i 192.168.$i.254/24 2001:db8:$i::1/64 |
0e2751ed LB |
12323 | ovn-nbctl -- lsp-add sw$i lrp$i-attachment \ |
12324 | -- set Logical_Switch_Port lrp$i-attachment type=router \ | |
e6a84e1e | 12325 | options:router-port=lrp$i addresses='"00:00:00:00:ff:0'$i' 192.168.'$i'.254 2001:db8:'$i'::1"' |
0e2751ed LB |
12326 | done |
12327 | ||
12328 | OVN_POPULATE_ARP | |
12329 | # allow some time for ovn-northd and ovn-controller to catch up. | |
12330 | ovn-nbctl --wait=hv sync | |
12331 | ||
12332 | test_ip_packet 1 1 000000000001 00000000ff01 $(ip_to_hex 192 168 1 1) $(ip_to_hex 192 168 2 1) $(ip_to_hex 192 168 1 254) 0000 7dae f4ff | |
e6a84e1e | 12333 | test_ip6_packet 1 1 000000000001 00000000ff01 20010db8000100000000000000000011 20010db8000200000000000000000011 20010db8000100000000000000000001 d461 |
0e2751ed LB |
12334 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [vif1.expected]) |
12335 | ||
12336 | OVN_CLEANUP([hv1], [hv2]) | |
12337 | AT_CLEANUP | |
86558ac2 LB |
12338 | |
12339 | AT_SETUP([ovn -- router port unreachable]) | |
12340 | AT_KEYWORDS([router-port-unreachable]) | |
12341 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
12342 | ovn_start | |
12343 | ||
12344 | # test_ip_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_ROUTER L4_PROTCOL IP_CHKSUM EXP_IP_CHKSUM EXP_ICMP_CHKSUM EXP_ICMP_CODE | |
12345 | # | |
12346 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv4 packet with | |
12347 | # ETH_SRC, ETH_DST, IPV4_SRC, IPV4_ROUTER, L4_PROTCOL, IP_CHKSUM as specified. | |
12348 | # EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are the ip and icmp checksums of the icmp frame generated by OVN logical router | |
12349 | # EXP_ICMP_CODE are code and type of the icmp frame generated by OVN logical router | |
12350 | # | |
12351 | # INPORT is a lport number, e.g. 11 for vif11. | |
12352 | # HV is a hypervisor number | |
12353 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
12354 | # IPV4_SRC and IPV4_ROUTER are each 8 hex digits. | |
12355 | # IP_CHKSUM, EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits | |
12356 | test_ip_packet() { | |
12357 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ip_router=$6 l4_proto=$7 ip_chksum=$8 | |
12358 | local exp_ip_chksum=$9 exp_icmp_chksum=${10} exp_icmp_code=${11} | |
12359 | shift 11 | |
12360 | ||
12361 | local ip_ttl=ff | |
12362 | local packet=${eth_dst}${eth_src}08004500001400004000${ip_ttl}${l4_proto}${ip_chksum}${ipv4_src}${ip_router} | |
12363 | ||
12364 | local reply_icmp_ttl=fe | |
12365 | local icmp_data=00000000 | |
12366 | local reply_icmp_payload=${exp_icmp_code}${exp_icmp_chksum}${icmp_data} | |
12367 | local reply=${eth_src}${eth_dst}08004500001c00004000${reply_icmp_ttl}01${exp_ip_chksum}${ip_router}${ipv4_src}${reply_icmp_payload} | |
12368 | echo $reply >> vif$inport.expected | |
12369 | ||
12370 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
12371 | } | |
12372 | ||
159932c9 LB |
12373 | # test_tcp_syn_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_ROUTER IP_CHKSUM TCP_SPORT TCP_DPORT TCP_CHKSUM EXP_IP_CHKSUM EXP_TCP_RST_CHKSUM |
12374 | # | |
12375 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an TCP syn segment with | |
12376 | # ETH_SRC, ETH_DST, IPV4_SRC, IPV4_ROUTER, IP_CHKSUM, TCP_SPORT, TCP_DPORT, TCP_CHKSUM as specified. | |
12377 | # EXP_IP_CHKSUM and EXP_TCP_RST_CHKSUM are the ip and tcp checksums of the tcp reset segment generated by OVN logical router | |
12378 | # | |
12379 | # INPORT is an lport number, e.g. 11 for vif11. | |
12380 | # HV is an hypervisor number | |
12381 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
12382 | # IPV4_SRC and IPV4_ROUTER are each 8 hex digits. | |
12383 | # TCP_SPORT and TCP_DPORT are 4 hex digits. | |
12384 | # IP_CHKSUM, TCP_CHKSUM, EXP_IP_CHSUM and EXP_TCP_RST_CHKSUM are each 4 hex digits | |
12385 | test_tcp_syn_packet() { | |
12386 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ip_router=$6 ip_chksum=$7 | |
12387 | local tcp_sport=$8 tcp_dport=$9 tcp_chksum=${10} | |
12388 | local exp_ip_chksum=${11} exp_tcp_rst_chksum=${12} | |
12389 | shift 12 | |
12390 | ||
12391 | local ip_ttl=ff | |
12392 | local packet=${eth_dst}${eth_src}08004500002800004000${ip_ttl}06${ip_chksum}${ipv4_src}${ip_router}${tcp_sport}${tcp_dport}000000010000000050027210${tcp_chksum}0000 | |
12393 | ||
12394 | local tcp_rst_ttl=fe | |
12395 | local reply=${eth_src}${eth_dst}08004500002800004000${tcp_rst_ttl}06${exp_ip_chksum}${ip_router}${ipv4_src}${tcp_dport}${tcp_sport}000000000000000150040000${exp_tcp_rst_chksum}0000 | |
12396 | echo $reply >> vif$inport.expected | |
12397 | ||
12398 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
12399 | } | |
12400 | ||
98af55fc LB |
12401 | # test_tcp6_packet INPORT HV ETH_SRC ETH_DST IPV6_SRC IPV6_ROUTER TCP_SPORT TCP_DPORT TCP_CHKSUM EXP_TCP_RST_CHKSUM |
12402 | # | |
12403 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is a TCP syn segment with | |
12404 | # ETH_SRC, ETH_DST, IPV6_SRC, IPV6_ROUTER, TCP_SPORT, TCP_DPORT and TCP_CHKSUM as specified. | |
12405 | # EXP_TCP_RST_CHKSUM is the tcp checksums of the tcp reset segment generated by OVN logical router | |
12406 | test_tcp6_packet() { | |
12407 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_router=$6 | |
12408 | local tcp_sport=$7 tcp_dport=$8 tcp_chksum=$9 | |
12409 | local exp_tcp_rst_chksum=${10} | |
12410 | shift 10 | |
12411 | ||
12412 | local ip6_hdr=60000000001406ff${ipv6_src}${ipv6_router} | |
12413 | local packet=${eth_dst}${eth_src}86dd${ip6_hdr}${tcp_sport}${tcp_dport}000000010000000050027210${tcp_chksum}0000 | |
12414 | ||
12415 | local reply=${eth_src}${eth_dst}86dd60000000001406fe${ipv6_router}${ipv6_src}${tcp_dport}${tcp_sport}000000000000000150040000${exp_tcp_rst_chksum}0000 | |
12416 | echo $reply >> vif$inport.expected | |
12417 | ||
12418 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
12419 | } | |
12420 | ||
4c25c3b8 LB |
12421 | # test_ip6_packet INPORT HV ETH_SRC ETH_DST IPV6_SRC IPV6_DST IPV6_PROTO IPV6_LEN DATA EXP_ICMP_CODE EXP_ICMP_CHKSUM |
12422 | # | |
12423 | # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv6 | |
12424 | # packet with ETH_SRC, ETH_DST, IPV6_SRC, IPV6_DST, IPV6_PROTO, IPV6_LEN and DATA as specified. | |
12425 | # EXP_ICMP_CODE and EXP_ICMP_CHKSUM are the code and checksum of the icmp6 packet sent by OVN logical router | |
12426 | test_ip6_packet() { | |
12427 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_dst=$6 ipv6_proto=$7 ipv6_len=$8 data=$9 | |
12428 | local exp_icmp_code=${10} exp_icmp_chksum=${11} | |
12429 | shift 11 | |
12430 | ||
12431 | local ip6_hdr=60000000${ipv6_len}${ipv6_proto}ff${ipv6_src}${ipv6_dst} | |
12432 | local packet=${eth_dst}${eth_src}86dd${ip6_hdr}${data} | |
12433 | ||
12434 | local reply=${eth_src}${eth_dst}86dd6000000000303afe${ipv6_dst}${ipv6_src}${exp_icmp_code}${exp_icmp_chksum}00000000${ip6_hdr} | |
12435 | echo $reply >> vif$inport.expected | |
12436 | ||
12437 | as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
12438 | } | |
12439 | ||
86558ac2 LB |
12440 | ip_to_hex() { |
12441 | printf "%02x%02x%02x%02x" "$@" | |
12442 | } | |
12443 | ||
12444 | for i in 1 2; do | |
12445 | net_add n$i | |
12446 | ovn-nbctl ls-add sw$i | |
12447 | ||
12448 | sim_add hv$i | |
12449 | as hv$i | |
12450 | ovs-vsctl add-br br-phys | |
12451 | ovn_attach n$i br-phys 192.168.$i.1 | |
12452 | ||
12453 | ovn-nbctl lsp-add sw$i sw$i-p${i}0 -- \ | |
4c25c3b8 | 12454 | lsp-set-addresses sw$i-p${i}0 "00:00:00:00:00:0$i 192.168.$i.1 2001:db8:$i::11" |
86558ac2 LB |
12455 | |
12456 | ovs-vsctl -- add-port br-int vif$i -- \ | |
12457 | set interface vif$i \ | |
12458 | external-ids:iface-id=sw$i-p${i}0 \ | |
12459 | options:tx_pcap=hv$i/vif$i-tx.pcap \ | |
12460 | options:rxq_pcap=hv$i/vif$i-rx.pcap \ | |
12461 | ofport-request=$i | |
12462 | done | |
12463 | ||
12464 | ovn-nbctl lr-add lr0 | |
12465 | for i in 1 2; do | |
4c25c3b8 | 12466 | ovn-nbctl lrp-add lr0 lrp$i 00:00:00:00:ff:0$i 192.168.$i.254/24 2001:db8:$i::1/64 |
86558ac2 LB |
12467 | ovn-nbctl -- lsp-add sw$i lrp$i-attachment \ |
12468 | -- set Logical_Switch_Port lrp$i-attachment type=router \ | |
4c25c3b8 | 12469 | options:router-port=lrp$i addresses='"00:00:00:00:ff:0'$i' 192.168.'$i'.254 2001:db8:'$i'::1"' |
86558ac2 LB |
12470 | done |
12471 | ||
12472 | OVN_POPULATE_ARP | |
12473 | # allow some time for ovn-northd and ovn-controller to catch up. | |
12474 | ovn-nbctl --wait=hv sync | |
12475 | ||
12476 | test_ip_packet 1 1 000000000001 00000000ff01 $(ip_to_hex 192 168 1 1) $(ip_to_hex 192 168 1 254) 11 0000 7dae fcfc 0303 | |
0e858e05 | 12477 | test_ip_packet 1 1 000000000001 00000000ff01 $(ip_to_hex 192 168 1 1) $(ip_to_hex 192 168 1 254) 84 0000 7dae fcfd 0302 |
4c25c3b8 | 12478 | test_ip6_packet 1 1 000000000001 00000000ff01 20010db8000100000000000000000011 20010db8000100000000000000000001 11 0015 dbb8303900155bac6b646f65206676676e6d66720a 0104 d570 |
86558ac2 LB |
12479 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [vif1.expected]) |
12480 | ||
159932c9 | 12481 | test_tcp_syn_packet 2 2 000000000002 00000000ff02 $(ip_to_hex 192 168 2 1) $(ip_to_hex 192 168 2 254) 0000 8b40 3039 0000 7bae 4486 |
9c937ec5 | 12482 | test_ip6_packet 2 2 000000000002 00000000ff02 20010db8000200000000000000000011 20010db8000200000000000000000001 84 0004 01020304 0103 627e |
98af55fc | 12483 | test_tcp6_packet 2 2 000000000002 00000000ff02 20010db8000200000000000000000011 20010db8000200000000000000000001 8b40 3039 0000 4486 |
159932c9 LB |
12484 | OVN_CHECK_PACKETS([hv2/vif2-tx.pcap], [vif2.expected]) |
12485 | ||
86558ac2 LB |
12486 | OVN_CLEANUP([hv1], [hv2]) |
12487 | AT_CLEANUP | |
96ea0ecb MM |
12488 | |
12489 | AT_SETUP([ovn -- ovn-controller exit]) | |
12490 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
12491 | ovn_start | |
12492 | # Logical network: | |
12493 | # One Logical Router: ro, with two logical switches sw1 and sw2. | |
12494 | # sw1 is for subnet 10.0.0.0/8 | |
12495 | # sw2 is for subnet 20.0.0.0/8 | |
12496 | # sw1 has a single port bound on hv1 | |
12497 | # sw2 has a single port bound on hv2 | |
12498 | ||
12499 | ovn-nbctl lr-add ro | |
12500 | ovn-nbctl ls-add sw1 | |
12501 | ovn-nbctl ls-add sw2 | |
12502 | ||
12503 | sw1_ro_mac=00:00:10:00:00:01 | |
12504 | sw1_ro_ip=10.0.0.1 | |
12505 | sw2_ro_mac=00:00:20:00:00:01 | |
12506 | sw2_ro_ip=20.0.0.1 | |
12507 | sw1_p1_mac=00:00:10:00:00:02 | |
12508 | sw1_p1_ip=10.0.0.2 | |
12509 | sw2_p1_mac=00:00:20:00:00:02 | |
12510 | sw2_p1_ip=20.0.0.2 | |
12511 | ||
12512 | ovn-nbctl lrp-add ro ro-sw1 $sw1_ro_mac ${sw1_ro_ip}/8 | |
12513 | ovn-nbctl lrp-add ro ro-sw2 $sw2_ro_mac ${sw2_ro_ip}/8 | |
12514 | ovn-nbctl lsp-add sw1 sw1-ro -- set Logical_Switch_Port sw1-ro type=router \ | |
12515 | options:router-port=ro-sw1 addresses=\"$sw1_ro_mac\" | |
12516 | ovn-nbctl lsp-add sw2 sw2-ro -- set Logical_Switch_Port sw2-ro type=router \ | |
12517 | options:router-port=ro-sw2 addresses=\"$sw2_ro_mac\" | |
12518 | ||
12519 | ovn-nbctl lsp-add sw1 sw1-p1 \ | |
12520 | -- lsp-set-addresses sw1-p1 "$sw1_p1_mac $sw1_p1_ip" | |
12521 | ||
12522 | ovn-nbctl lsp-add sw2 sw2-p1 \ | |
12523 | -- lsp-set-addresses sw2-p1 "$sw2_p1_mac $sw2_p1_ip" | |
12524 | ||
12525 | net_add n1 | |
12526 | ||
12527 | sim_add hv1 | |
12528 | as hv1 | |
12529 | ovs-vsctl add-br br-phys | |
12530 | ovn_attach n1 br-phys 192.168.0.1 | |
12531 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
12532 | set interface hv1-vif1 external-ids:iface-id=sw1-p1 \ | |
12533 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
12534 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
12535 | ofport-request=1 | |
12536 | ||
12537 | sim_add hv2 | |
12538 | as hv2 | |
12539 | ovs-vsctl add-br br-phys | |
12540 | ovn_attach n1 br-phys 192.168.0.2 | |
12541 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
12542 | set interface hv2-vif1 external-ids:iface-id=sw2-p1 \ | |
12543 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
12544 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
12545 | ofport-request=1 | |
12546 | ||
12547 | OVN_POPULATE_ARP | |
12548 | ||
12549 | sleep 1 | |
12550 | ||
12551 | packet="inport==\"sw1-p1\" && eth.src==$sw1_p1_mac && eth.dst==$sw1_ro_mac && | |
12552 | ip4 && ip.ttl==64 && ip4.src==$sw1_p1_ip && ip4.dst==$sw2_p1_ip && | |
12553 | udp && udp.src==53 && udp.dst==4369" | |
12554 | ||
12555 | # Start by Sending the packet and make sure it makes it there as expected | |
12556 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
12557 | ||
12558 | # Expected packet has TTL decreased by 1 | |
12559 | expected="eth.src==$sw2_ro_mac && eth.dst==$sw2_p1_mac && | |
12560 | ip4 && ip.ttl==63 && ip4.src==$sw1_p1_ip && ip4.dst==$sw2_p1_ip && | |
12561 | udp && udp.src==53 && udp.dst==4369" | |
12562 | echo $expected | ovstest test-ovn expr-to-packets > expected | |
12563 | ||
12564 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
12565 | ||
12566 | # Stop ovn-controller on hv2 | |
12567 | as hv2 ovs-appctl -t ovn-controller exit | |
12568 | ||
12569 | # Now send the packet again. This time, it should not arrive. | |
12570 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
12571 | ||
12572 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
12573 | ||
12574 | # Start ovn-controller again just so OVN_CLEANUP doesn't complain | |
12575 | as hv2 start_daemon ovn-controller | |
12576 | ||
12577 | OVN_CLEANUP([hv1],[hv2]) | |
12578 | AT_CLEANUP | |
12579 | ||
96080083 NS |
12580 | AT_SETUP([ovn -- external logical port]) |
12581 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
12582 | ovn_start | |
12583 | ||
12584 | net_add n1 | |
12585 | sim_add hv1 | |
12586 | sim_add hv2 | |
12587 | sim_add hv3 | |
12588 | ||
12589 | ovn-nbctl ls-add ls1 | |
12590 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
12591 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
12592 | ||
12593 | # Add a couple of external logical port | |
12594 | ovn-nbctl lsp-add ls1 ls1-lp_ext1 \ | |
12595 | -- lsp-set-addresses ls1-lp_ext1 "f0:00:00:00:00:03 10.0.0.6 ae70::6" | |
12596 | ovn-nbctl lsp-set-port-security ls1-lp_ext1 \ | |
12597 | "f0:00:00:00:00:03 10.0.0.6 ae70::6" | |
12598 | ovn-nbctl lsp-set-type ls1-lp_ext1 external | |
12599 | ||
12600 | ovn-nbctl lsp-add ls1 ls1-lp_ext2 \ | |
12601 | -- lsp-set-addresses ls1-lp_ext2 "f0:00:00:00:00:04 10.0.0.7 ae70::7" | |
12602 | ovn-nbctl lsp-set-port-security ls1-lp_ext2 \ | |
12603 | "f0:00:00:00:00:04 10.0.0.7 ae70::8" | |
12604 | ovn-nbctl lsp-set-type ls1-lp_ext2 external | |
12605 | ||
12606 | d1="$(ovn-nbctl create DHCP_Options cidr=10.0.0.0/24 \ | |
12607 | options="\"server_id\"=\"10.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:01\" \ | |
12608 | \"lease_time\"=\"3600\" \"router\"=\"10.0.0.1\"")" | |
12609 | ||
12610 | d2="$(ovn-nbctl create DHCP_Options cidr="ae70\:\:/64" \ | |
12611 | options="\"server_id\"=\"00:00:00:10:00:01\"")" | |
12612 | ||
12613 | ovn-nbctl lsp-set-dhcpv4-options ls1-lp1 ${d1} | |
12614 | ovn-nbctl lsp-set-dhcpv4-options ls1-lp_ext1 ${d1} | |
12615 | ovn-nbctl lsp-set-dhcpv4-options ls1-lp_ext2 ${d1} | |
12616 | ||
12617 | ovn-nbctl lsp-set-dhcpv6-options ls1-lp1 ${d2} | |
12618 | ovn-nbctl lsp-set-dhcpv6-options ls1-lp_ext1 ${d2} | |
12619 | ovn-nbctl lsp-set-dhcpv6-options ls1-lp_ext2 ${d2} | |
12620 | ||
12621 | # Create a logical router and connect it to ls1 | |
12622 | ovn-nbctl lr-add lr0 | |
12623 | ovn-nbctl lrp-add lr0 lr0-ls1 a0:10:00:00:00:01 10.0.0.1/24 | |
12624 | ovn-nbctl lsp-add ls1 ls1-lr0 | |
12625 | ovn-nbctl set Logical_Switch_Port ls1-lr0 type=router \ | |
12626 | options:router-port=lr0-ls1 addresses=router | |
12627 | ||
12628 | # Create HA chassis group | |
12629 | ovn-nbctl ha-chassis-group-add hagrp1 | |
12630 | ovn-nbctl ha-chassis-group-add-chassis hagrp1 hv1 30 | |
12631 | ||
12632 | hagrp1_uuid=`ovn-nbctl --bare --columns _uuid find ha_chassis_group name="hagrp1"` | |
12633 | ||
12634 | # There should be 1 HA_Chassis rows with chassis sets | |
12635 | OVS_WAIT_UNTIL([ovn-sbctl list ha_chassis | grep chassis | awk '{print $3}' \ | |
12636 | | grep '-' | wc -l ], [0], [1 | |
12637 | ]) | |
12638 | ||
12639 | as hv1 | |
12640 | ovs-vsctl add-br br-phys | |
12641 | ovn_attach n1 br-phys 192.168.0.1 | |
12642 | ovs-vsctl -- add-port br-phys hv1-ext1 -- \ | |
12643 | set interface hv1-ext1 options:tx_pcap=hv1/ext1-tx.pcap \ | |
12644 | options:rxq_pcap=hv1/ext1-rx.pcap \ | |
12645 | ofport-request=2 | |
12646 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
12647 | ||
12648 | as hv2 | |
12649 | ovs-vsctl add-br br-phys | |
12650 | ovn_attach n1 br-phys 192.168.0.2 | |
12651 | ovs-vsctl -- add-port br-phys hv2-ext2 -- \ | |
12652 | set interface hv2-ext2 options:tx_pcap=hv2/ext2-tx.pcap \ | |
12653 | options:rxq_pcap=hv2/ext2-rx.pcap \ | |
12654 | ofport-request=2 | |
12655 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
12656 | ||
12657 | as hv3 | |
12658 | ovs-vsctl add-br br-phys | |
12659 | ovn_attach n1 br-phys 192.168.0.3 | |
12660 | ovs-vsctl -- add-port br-phys hv3-ext3 -- \ | |
12661 | set interface hv3-ext3 options:tx_pcap=hv3/ext3-tx.pcap \ | |
12662 | options:rxq_pcap=hv3/ext3-rx.pcap \ | |
12663 | ofport-request=2 | |
12664 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
12665 | ||
12666 | # No DHCPv4/v6 flows for the external port - ls1-lp_ext1 - 10.0.0.6 in hv1 and | |
12667 | # hv2 as ha-chassis-group is not set and no localnet port added to ls1. | |
12668 | AT_CHECK([ovn-sbctl dump-flows ls1 | grep "offerip = 10.0.0.6" | \ | |
12669 | wc -l], [0], [0 | |
12670 | ]) | |
12671 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12672 | grep controller | grep "0a.00.00.06" | wc -l], [0], [0 | |
12673 | ]) | |
12674 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12675 | grep controller | grep "0a.00.00.06" | wc -l], [0], [0 | |
12676 | ]) | |
12677 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12678 | grep controller | grep tp_src=546 | grep \ | |
12679 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | wc -l], [0], [0 | |
12680 | ]) | |
12681 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12682 | grep controller | grep tp_src=546 | grep \ | |
12683 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | wc -l], [0], [0 | |
12684 | ]) | |
12685 | ||
12686 | hv1_uuid=$(ovn-sbctl list chassis hv1 | grep uuid | awk '{print $3}') | |
12687 | hv2_uuid=$(ovn-sbctl list chassis hv2 | grep uuid | awk '{print $3}') | |
12688 | hv3_uuid=$(ovn-sbctl list chassis hv3 | grep uuid | awk '{print $3}') | |
12689 | ||
12690 | # The port_binding row for ls1-lp_ext1 should have empty chassis | |
12691 | chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
12692 | logical_port=ls1-lp_ext1` | |
12693 | ||
12694 | AT_CHECK([test x$chassis == x], [0], []) | |
12695 | ||
12696 | # Associate hagrp1 ha-chassis-group to ls1-lp_ext1 | |
12697 | ovn-nbctl --wait=hv set Logical_Switch_Port ls1-lp_ext1 \ | |
12698 | ha-chassis-group=$hagrp1_uuid | |
12699 | ||
12700 | # Get the hagrp1 uuid in SB DB. | |
12701 | sb_hagrp1_uuid=`ovn-sbctl --bare --columns _uuid find ha_chassis_group \ | |
12702 | name="hagrp1"` | |
12703 | ||
12704 | # Wait till ls1-lp_ext1 port_binding has ha_chassis_group set | |
12705 | OVS_WAIT_UNTIL( | |
12706 | [sb_pb_hagrp=`ovn-sbctl --bare --columns ha_chassis_group find \ | |
12707 | port_binding logical_port=ls1-lp_ext1` | |
12708 | test "$sb_pb_hagrp" = "$sb_hagrp1_uuid"]) | |
12709 | ||
12710 | # No DHCPv4/v6 flows for the external port - ls1-lp_ext1 - 10.0.0.6 in hv1 and hv2 | |
12711 | # as no localnet port added to ls1 yet. | |
12712 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12713 | grep controller | grep "0a.00.00.06" | wc -l], [0], [0 | |
12714 | ]) | |
12715 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12716 | grep controller | grep "0a.00.00.06" | wc -l], [0], [0 | |
12717 | ]) | |
12718 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12719 | grep controller | grep tp_src=546 | grep \ | |
12720 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | wc -l], [0], [0 | |
12721 | ]) | |
12722 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12723 | grep controller | grep tp_src=546 | grep \ | |
12724 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | wc -l], [0], [0 | |
12725 | ]) | |
12726 | ||
12727 | # Add the localnet port to the logical switch ls1 | |
12728 | ovn-nbctl lsp-add ls1 ln-public | |
12729 | ovn-nbctl lsp-set-addresses ln-public unknown | |
12730 | ovn-nbctl lsp-set-type ln-public localnet | |
12731 | ovn-nbctl --wait=hv lsp-set-options ln-public network_name=phys | |
12732 | ||
12733 | ln_public_key=$(ovn-sbctl list port_binding ln-public | grep tunnel_key | \ | |
12734 | awk '{print $3}') | |
12735 | ||
12736 | # The ls1-lp_ext1 should be bound to hv1 as only hv1 is part of the | |
12737 | # ha chassis group. | |
12738 | OVS_WAIT_UNTIL( | |
12739 | [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
12740 | logical_port=ls1-lp_ext1` | |
12741 | test "$chassis" = "$hv1_uuid"]) | |
12742 | ||
12743 | # There should be DHCPv4/v6 OF flows for the ls1-lp_ext1 port in hv1 | |
12744 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12745 | grep controller | grep "0a.00.00.06" | grep reg14=0x$ln_public_key | \ | |
12746 | wc -l], [0], [3 | |
12747 | ]) | |
12748 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12749 | grep controller | grep tp_src=546 | grep \ | |
12750 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | \ | |
12751 | grep reg14=0x$ln_public_key | wc -l], [0], [1 | |
12752 | ]) | |
12753 | ||
12754 | # There should be no DHCPv4/v6 flows for ls1-lp_ext1 on hv2 | |
12755 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12756 | grep controller | grep "0a.00.00.06" | wc -l], [0], [0 | |
12757 | ]) | |
12758 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12759 | grep controller | grep tp_src=546 | grep \ | |
12760 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | wc -l], [0], [0 | |
12761 | ]) | |
12762 | ||
12763 | # No DHCPv4/v6 flows for the external port - ls1-lp_ext2 - 10.0.0.7 in hv1 and | |
12764 | # hv2 as requested-chassis option is not set. | |
12765 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12766 | grep controller | grep "0a.00.00.07" | wc -l], [0], [0 | |
12767 | ]) | |
12768 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12769 | grep controller | grep "0a.00.00.07" | wc -l], [0], [0 | |
12770 | ]) | |
12771 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12772 | grep controller | grep tp_src=546 | grep \ | |
12773 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.07" | wc -l], [0], [0 | |
12774 | ]) | |
12775 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
12776 | grep controller | grep tp_src=546 | grep \ | |
12777 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.07" | wc -l], [0], [0 | |
12778 | ]) | |
12779 | ||
12780 | as hv1 | |
12781 | ovs-vsctl show | |
12782 | ||
12783 | # This shell function sends a DHCP request packet | |
12784 | # test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ... | |
12785 | test_dhcp() { | |
12786 | local inport=$1 src_mac=$2 dhcp_type=$3 offer_ip=$4 use_ip=$5 | |
12787 | shift; shift; shift; shift; shift; | |
12788 | if test $use_ip != 0; then | |
12789 | src_ip=$1 | |
12790 | dst_ip=$2 | |
12791 | shift; shift; | |
12792 | else | |
12793 | src_ip=`ip_to_hex 0 0 0 0` | |
12794 | dst_ip=`ip_to_hex 255 255 255 255` | |
12795 | fi | |
12796 | local request=ffffffffffff${src_mac}0800451001100000000080110000${src_ip}${dst_ip} | |
12797 | # udp header and dhcp header | |
12798 | request=${request}0044004300fc0000 | |
12799 | request=${request}010106006359aa760000000000000000000000000000000000000000${src_mac} | |
12800 | # client hardware padding | |
12801 | request=${request}00000000000000000000 | |
12802 | # server hostname | |
12803 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
12804 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
12805 | # boot file name | |
12806 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
12807 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
12808 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
12809 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
12810 | # dhcp magic cookie | |
12811 | request=${request}63825363 | |
12812 | # dhcp message type | |
12813 | request=${request}3501${dhcp_type}ff | |
12814 | ||
12815 | local srv_mac=$1 srv_ip=$2 expected_dhcp_opts=$3 | |
12816 | # total IP length will be the IP length of the request packet | |
12817 | # (which is 272 in our case) + 8 (padding bytes) + (expected_dhcp_opts / 2) | |
12818 | ip_len=`expr 280 + ${#expected_dhcp_opts} / 2` | |
12819 | udp_len=`expr $ip_len - 20` | |
12820 | ip_len=$(printf "%x" $ip_len) | |
12821 | udp_len=$(printf "%x" $udp_len) | |
12822 | # $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len | |
12823 | local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip} | |
12824 | # udp header and dhcp header. | |
12825 | # $udp_len var will be in 3 digits. So adding a '0' before $udp_len | |
12826 | reply=${reply}004300440${udp_len}0000020106006359aa760000000000000000 | |
12827 | # your ip address | |
12828 | reply=${reply}${offer_ip} | |
12829 | # next server ip address, relay agent ip address, client mac address | |
12830 | reply=${reply}0000000000000000${src_mac} | |
12831 | # client hardware padding | |
12832 | reply=${reply}00000000000000000000 | |
12833 | # server hostname | |
12834 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
12835 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
12836 | # boot file name | |
12837 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
12838 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
12839 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
12840 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
12841 | # dhcp magic cookie | |
12842 | reply=${reply}63825363 | |
12843 | # dhcp message type | |
12844 | local dhcp_reply_type=02 | |
12845 | if test $dhcp_type = 03; then | |
12846 | dhcp_reply_type=05 | |
12847 | fi | |
12848 | reply=${reply}3501${dhcp_reply_type}${expected_dhcp_opts}00000000ff00000000 | |
12849 | echo $reply >> ext1_v4.expected | |
12850 | ||
12851 | as hv1 ovs-appctl netdev-dummy/receive hv${inport}-ext${inport} $request | |
12852 | } | |
12853 | ||
12854 | ||
12855 | trim_zeros() { | |
12856 | sed 's/\(00\)\{1,\}$//' | |
12857 | } | |
12858 | ||
12859 | # This shell function sends a DHCPv6 request packet | |
12860 | # test_dhcpv6 INPORT SRC_MAC SRC_LLA DHCPv6_MSG_TYPE OFFER_IP OUTPORT... | |
12861 | # The OUTPORTs (zero or more) list the VIFs on which the original DHCPv6 | |
12862 | # packet should be received twice (one from ovn-controller and the other | |
12863 | # from the "ovs-ofctl monitor br-int resume" | |
12864 | test_dhcpv6() { | |
12865 | local inport=$1 src_mac=$2 src_lla=$3 msg_code=$4 offer_ip=$5 | |
12866 | local req_pkt_in_expected=$6 | |
12867 | local request=ffffffffffff${src_mac}86dd00000000002a1101${src_lla} | |
12868 | # dst ip ff02::1:2 | |
12869 | request=${request}ff020000000000000000000000010002 | |
12870 | # udp header and dhcpv6 header | |
12871 | request=${request}02220223002affff${msg_code}010203 | |
12872 | # Client identifier | |
12873 | request=${request}0001000a00030001${src_mac} | |
12874 | # IA-NA (Identity Association for Non Temporary Address) | |
12875 | request=${request}0003000c0102030400000e1000001518 | |
12876 | shift; shift; shift; shift; shift; | |
12877 | ||
12878 | local server_mac=000000100001 | |
12879 | local server_lla=fe80000000000000020000fffe100001 | |
12880 | local reply_code=07 | |
12881 | if test $msg_code = 01; then | |
12882 | reply_code=02 | |
12883 | fi | |
12884 | local msg_len=54 | |
12885 | if test $offer_ip = 1; then | |
12886 | msg_len=28 | |
12887 | fi | |
12888 | local reply=${src_mac}${server_mac}86dd0000000000${msg_len}1101 | |
12889 | reply=${reply}${server_lla}${src_lla} | |
12890 | ||
12891 | # udp header and dhcpv6 header | |
12892 | reply=${reply}0223022200${msg_len}ffff${reply_code}010203 | |
12893 | # Client identifier | |
12894 | reply=${reply}0001000a00030001${src_mac} | |
12895 | # IA-NA | |
12896 | if test $offer_ip != 1; then | |
12897 | reply=${reply}0003002801020304ffffffffffffffff00050018${offer_ip} | |
12898 | reply=${reply}ffffffffffffffff | |
12899 | fi | |
12900 | # Server identifier | |
12901 | reply=${reply}0002000a00030001${server_mac} | |
12902 | ||
12903 | echo $reply | trim_zeros >> ext${inport}_v6.expected | |
12904 | # The inport also receives the request packet since it is connected | |
12905 | # to the br-phys. | |
12906 | #echo $request >> ext${inport}_v6.expected | |
12907 | ||
12908 | as hv1 ovs-appctl netdev-dummy/receive hv${inport}-ext${inport} $request | |
12909 | } | |
12910 | ||
12911 | reset_pcap_file() { | |
12912 | local iface=$1 | |
12913 | local pcap_file=$2 | |
12914 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
12915 | options:rxq_pcap=dummy-rx.pcap | |
12916 | rm -f ${pcap_file}*.pcap | |
12917 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
12918 | options:rxq_pcap=${pcap_file}-rx.pcap | |
12919 | } | |
12920 | ||
12921 | ip_to_hex() { | |
12922 | printf "%02x%02x%02x%02x" "$@" | |
12923 | } | |
12924 | ||
12925 | AT_CAPTURE_FILE([ofctl_monitor0_hv1.log]) | |
12926 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
12927 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0_hv1.log | |
12928 | ||
12929 | AT_CAPTURE_FILE([ofctl_monitor0_hv2.log]) | |
12930 | as hv2 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
12931 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0_hv2.log | |
12932 | ||
12933 | AT_CAPTURE_FILE([ofctl_monitor0_hv3.log]) | |
12934 | as hv3 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
12935 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0_hv3.log | |
12936 | ||
12937 | as hv1 | |
12938 | reset_pcap_file hv1-ext1 hv1/ext1 | |
12939 | ||
12940 | # Send DHCPDISCOVER. | |
12941 | offer_ip=`ip_to_hex 10 0 0 6` | |
12942 | server_ip=`ip_to_hex 10 0 0 1` | |
12943 | server_mac=ff1000000001 | |
12944 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 | |
12945 | test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \ | |
12946 | $expected_dhcp_opts | |
12947 | ||
12948 | # NXT_RESUMEs should be 1 in hv1. | |
12949 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
12950 | ||
12951 | # NXT_RESUMEs should be 0 in hv2. | |
12952 | OVS_WAIT_UNTIL([test 0 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
12953 | ||
12954 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets | |
12955 | cat ext1_v4.expected | cut -c -48 > expout | |
12956 | AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) | |
12957 | # Skipping the IPv4 checksum. | |
12958 | cat ext1_v4.expected | cut -c 53- > expout | |
12959 | AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) | |
12960 | ||
12961 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
12962 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
12963 | as hv1 | |
12964 | reset_pcap_file hv1-ext1 hv1/ext1 | |
12965 | ||
12966 | rm -f ext1_v4.expected | |
12967 | rm -f ext1_v4.packets | |
12968 | ||
12969 | # Send DHCPv6 request | |
12970 | src_mac=f00000000003 | |
12971 | src_lla=fe80000000000000f20000fffe000003 | |
12972 | offer_ip=ae700000000000000000000000000006 | |
12973 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
12974 | ||
12975 | # NXT_RESUMEs should be 2 in hv1. | |
12976 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
12977 | ||
12978 | # NXT_RESUMEs should be 0 in hv2. | |
12979 | OVS_WAIT_UNTIL([test 0 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
12980 | ||
12981 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ | |
12982 | sort > ext1_v6.packets | |
12983 | cat ext1_v6.expected | cut -c -120 > expout | |
12984 | AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) | |
12985 | # Skipping the UDP checksum | |
12986 | cat ext1_v6.expected | cut -c 125- > expout | |
12987 | AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) | |
12988 | ||
12989 | rm -f ext1_v6.expected | |
12990 | rm -f ext1_v6.packets | |
12991 | ||
12992 | as hv1 | |
12993 | reset_pcap_file hv1-ext1 hv1/ext1 | |
12994 | ||
12995 | # Delete the ha-chassis hv1. | |
12996 | ovn-nbctl ha-chassis-group-remove-chassis hagrp1 hv1 | |
12997 | OVS_WAIT_UNTIL( | |
12998 | [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
12999 | logical_port=ls1-lp_ext1` | |
13000 | test "$chassis" = ""]) | |
13001 | ||
13002 | # Add hv2 to the ha chassis group | |
13003 | ovn-nbctl --wait=hv ha-chassis-group-add-chassis hagrp1 hv2 20 | |
13004 | ||
13005 | ovn-sbctl list ha_chassis_group | |
13006 | ovn-sbctl list ha_chassis | |
13007 | ||
13008 | ovn-sbctl find port_binding logical_port=ls1-lp_ext1 | |
13009 | ||
13010 | # The ls1-lp_ext1 should be bound to hv2 | |
13011 | OVS_WAIT_UNTIL( | |
13012 | [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
13013 | logical_port=ls1-lp_ext1` | |
13014 | test "$chassis" = "$hv2_uuid"]) | |
13015 | ||
13016 | # There should be OF flows for DHCP4/v6 for the ls1-lp_ext1 port in hv2 | |
13017 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
13018 | grep controller | grep "0a.00.00.06" | grep reg14=0x$ln_public_key | \ | |
13019 | wc -l], [0], [3 | |
13020 | ]) | |
13021 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
13022 | grep controller | grep tp_src=546 | grep \ | |
13023 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | \ | |
13024 | grep reg14=0x$ln_public_key | wc -l], [0], [1 | |
13025 | ]) | |
13026 | ||
13027 | # There should be no DHCPv4/v6 flows for ls1-lp_ext1 on hv1 | |
13028 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
13029 | grep controller | grep "0a.00.00.06" | wc -l], [0], [0 | |
13030 | ]) | |
13031 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=20 | \ | |
13032 | grep controller | grep tp_src=546 | grep \ | |
13033 | "ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.06" | \ | |
13034 | grep reg14=0x$ln_public_key | wc -l], [0], [0 | |
13035 | ]) | |
13036 | ||
13037 | # Send DHCPDISCOVER again for hv1/ext1. The DHCP response should come from | |
13038 | # hv2 ovn-controller. | |
13039 | offer_ip=`ip_to_hex 10 0 0 6` | |
13040 | server_ip=`ip_to_hex 10 0 0 1` | |
13041 | server_mac=ff1000000001 | |
13042 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 | |
13043 | test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \ | |
13044 | $expected_dhcp_opts | |
13045 | ||
13046 | # NXT_RESUMEs should be 2 in hv1. | |
13047 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
13048 | ||
13049 | # NXT_RESUMEs should be 1 in hv2. | |
13050 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
13051 | ||
13052 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets | |
13053 | cat ext1_v4.expected | cut -c -48 > expout | |
13054 | AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) | |
13055 | # Skipping the IPv4 checksum. | |
13056 | cat ext1_v4.expected | cut -c 53- > expout | |
13057 | AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) | |
13058 | ||
13059 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
13060 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
13061 | as hv1 | |
13062 | reset_pcap_file hv1-ext1 hv1/ext1 | |
13063 | ||
13064 | rm -f ext1_v4.expected | |
13065 | ||
13066 | # Send DHCPv6 request again | |
13067 | src_mac=f00000000003 | |
13068 | src_lla=fe80000000000000f20000fffe000003 | |
13069 | offer_ip=ae700000000000000000000000000006 | |
13070 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip 1 | |
13071 | ||
13072 | # NXT_RESUMEs should be 2 in hv1. | |
13073 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
13074 | ||
13075 | # NXT_RESUMEs should be 2 in hv2. | |
13076 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
13077 | ||
13078 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ | |
13079 | sort > ext1_v6.packets | |
13080 | cat ext1_v6.expected | cut -c -120 > expout | |
13081 | AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) | |
13082 | # Skipping the UDP checksum | |
13083 | cat ext1_v6.expected | cut -c 125- > expout | |
13084 | AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) | |
13085 | ||
13086 | rm -f ext1_v6.expected | |
13087 | rm -f ext1_v6.packets | |
13088 | ||
13089 | as hv1 | |
13090 | ovs-vsctl show | |
13091 | reset_pcap_file hv1-ext1 hv1/ext1 | |
13092 | reset_pcap_file br-phys_n1 hv1/br-phys_n1 | |
13093 | reset_pcap_file br-phys hv1/br-phys | |
13094 | ||
13095 | as hv2 | |
13096 | ovs-vsctl show | |
13097 | reset_pcap_file hv2-ext2 hv2/ext2 | |
13098 | reset_pcap_file br-phys_n1 hv2/br-phys_n1 | |
13099 | reset_pcap_file br-phys hv2/br-phys | |
13100 | ||
13101 | # From ls1-lp_ext1, send ARP request for the router ip. The ARP | |
13102 | # response should come from the router pipeline of hv2. | |
13103 | ext1_mac=f00000000003 | |
13104 | router_mac=a01000000001 | |
13105 | ext1_ip=`ip_to_hex 10 0 0 6` | |
13106 | router_ip=`ip_to_hex 10 0 0 1` | |
13107 | arp_request=ffffffffffff${ext1_mac}08060001080006040001${ext1_mac}${ext1_ip}000000000000${router_ip} | |
13108 | ||
13109 | as hv1 ovs-appctl netdev-dummy/receive hv1-ext1 $arp_request | |
13110 | expected_response=${src_mac}${router_mac}08060001080006040002${router_mac}${router_ip}${ext1_mac}${ext1_ip} | |
13111 | echo $expected_response > expout | |
13112 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_arp_resp | |
13113 | AT_CHECK([cat ext1_arp_resp], [0], [expout]) | |
13114 | ||
13115 | # Verify that the response came from hv2 | |
13116 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap > ext1_arp_resp | |
13117 | AT_CHECK([cat ext1_arp_resp], [0], [expout]) | |
13118 | ||
13119 | # Now add 3 ha chassis to the ha chassis group | |
13120 | ovn-nbctl ha-chassis-group-add-chassis hagrp1 hv1 30 | |
13121 | ovn-nbctl ha-chassis-group-add-chassis hagrp1 hv2 20 | |
13122 | ovn-nbctl ha-chassis-group-add-chassis hagrp1 hv3 10 | |
13123 | ||
13124 | # hv1 should be master and claim ls1-lp_ext1 | |
13125 | OVS_WAIT_UNTIL( | |
13126 | [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
13127 | logical_port=ls1-lp_ext1` | |
13128 | test "$chassis" = "$hv1_uuid"]) | |
13129 | ||
13130 | as hv1 | |
13131 | ovs-vsctl show | |
13132 | reset_pcap_file hv1-ext1 hv1/ext1 | |
13133 | reset_pcap_file br-phys_n1 hv1/br-phys_n1 | |
13134 | reset_pcap_file br-phys hv1/br-phys | |
13135 | ||
13136 | as hv2 | |
13137 | ovs-vsctl show | |
13138 | reset_pcap_file hv2-ext2 hv2/ext2 | |
13139 | reset_pcap_file br-phys_n1 hv2/br-phys_n1 | |
13140 | reset_pcap_file br-phys hv2/br-phys | |
13141 | ||
13142 | as hv3 | |
13143 | ovs-vsctl show | |
13144 | reset_pcap_file hv3-ext3 hv3/ext3 | |
13145 | reset_pcap_file br-phys_n1 hv3/br-phys_n1 | |
13146 | reset_pcap_file br-phys hv3/br-phys | |
13147 | ||
13148 | # Send DHCPDISCOVER. | |
13149 | offer_ip=`ip_to_hex 10 0 0 6` | |
13150 | server_ip=`ip_to_hex 10 0 0 1` | |
13151 | server_mac=ff1000000001 | |
13152 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 | |
13153 | test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \ | |
13154 | $expected_dhcp_opts | |
13155 | ||
13156 | # NXT_RESUMEs should be 3 in hv1. | |
13157 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
13158 | ||
13159 | # NXT_RESUMEs should be 2 in hv2. | |
13160 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
13161 | ||
13162 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets | |
13163 | cat ext1_v4.expected | cut -c -48 > expout | |
13164 | AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) | |
13165 | # Skipping the IPv4 checksum. | |
13166 | cat ext1_v4.expected | cut -c 53- > expout | |
13167 | AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) | |
13168 | ||
13169 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
13170 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
13171 | as hv1 | |
13172 | reset_pcap_file hv1-ext1 hv1/ext1 | |
13173 | ||
13174 | rm -f ext1_v4.expected | |
13175 | rm -f ext1_v4.packets | |
13176 | ||
13177 | # Send DHCPv6 request | |
13178 | src_mac=f00000000003 | |
13179 | src_lla=fe80000000000000f20000fffe000003 | |
13180 | offer_ip=ae700000000000000000000000000006 | |
13181 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
13182 | ||
13183 | # NXT_RESUMEs should be 4 in hv1. | |
13184 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
13185 | ||
13186 | # NXT_RESUMEs should be 2 in hv2. | |
13187 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
13188 | ||
13189 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ | |
13190 | sort > ext1_v6.packets | |
13191 | cat ext1_v6.expected | cut -c -120 > expout | |
13192 | AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) | |
13193 | # Skipping the UDP checksum | |
13194 | cat ext1_v6.expected | cut -c 125- > expout | |
13195 | AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) | |
13196 | ||
13197 | rm -f ext1_v6.expected | |
13198 | rm -f ext1_v6.packets | |
13199 | as hv1 reset_pcap_file hv1-ext1 hv1/ext1 | |
13200 | ||
13201 | # Now increase the priority of hv3 so it becomes master. | |
13202 | ovn-nbctl ha-chassis-group-add-chassis hagrp1 hv3 50 | |
13203 | ||
13204 | # hv3 should be master and claim ls1-lp_ext1 | |
13205 | OVS_WAIT_UNTIL( | |
13206 | [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
13207 | logical_port=ls1-lp_ext1` | |
13208 | test "$chassis" = "$hv3_uuid"]) | |
13209 | ||
13210 | as hv1 | |
13211 | ovs-vsctl show | |
13212 | reset_pcap_file hv1-ext1 hv1/ext1 | |
13213 | reset_pcap_file br-phys_n1 hv1/br-phys_n1 | |
13214 | reset_pcap_file br-phys hv1/br-phys | |
13215 | ||
13216 | as hv2 | |
13217 | ovs-vsctl show | |
13218 | reset_pcap_file hv2-ext2 hv2/ext2 | |
13219 | reset_pcap_file br-phys_n1 hv2/br-phys_n1 | |
13220 | reset_pcap_file br-phys hv2/br-phys | |
13221 | ||
13222 | as hv2 | |
13223 | ovs-vsctl show | |
13224 | reset_pcap_file hv3-ext3 hv3/ext3 | |
13225 | reset_pcap_file br-phys_n1 hv3/br-phys_n1 | |
13226 | reset_pcap_file br-phys hv3/br-phys | |
13227 | ||
13228 | # Send DHCPDISCOVER. | |
13229 | offer_ip=`ip_to_hex 10 0 0 6` | |
13230 | server_ip=`ip_to_hex 10 0 0 1` | |
13231 | server_mac=ff1000000001 | |
13232 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 | |
13233 | test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \ | |
13234 | $expected_dhcp_opts | |
13235 | ||
13236 | # NXT_RESUMEs should be 4 in hv1. | |
13237 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
13238 | ||
13239 | # NXT_RESUMEs should be 2 in hv2. | |
13240 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
13241 | ||
13242 | # NXT_RESUMEs should be 1 in hv3. | |
13243 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv3.log | grep -c NXT_RESUME`]) | |
13244 | ||
13245 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets | |
13246 | cat ext1_v4.expected | cut -c -48 > expout | |
13247 | AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) | |
13248 | # Skipping the IPv4 checksum. | |
13249 | cat ext1_v4.expected | cut -c 53- > expout | |
13250 | AT_CHECK([cat ext1_v4.packets | cut -c 53-], [0], [expout]) | |
13251 | ||
13252 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
13253 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
13254 | as hv1 | |
13255 | reset_pcap_file hv1-ext1 hv1/ext1 | |
13256 | ||
13257 | rm -f ext1_v4.expected | |
13258 | rm -f ext1_v4.packets | |
13259 | ||
13260 | # Send DHCPv6 request | |
13261 | src_mac=f00000000003 | |
13262 | src_lla=fe80000000000000f20000fffe000003 | |
13263 | offer_ip=ae700000000000000000000000000006 | |
13264 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
13265 | ||
13266 | # NXT_RESUMEs should be 4 in hv1. | |
13267 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) | |
13268 | ||
13269 | # NXT_RESUMEs should be 2 in hv2. | |
13270 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) | |
13271 | ||
13272 | # NXT_RESUMEs should be 2 in hv3. | |
13273 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv3.log | grep -c NXT_RESUME`]) | |
13274 | ||
13275 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ | |
13276 | sort > ext1_v6.packets | |
13277 | cat ext1_v6.expected | cut -c -120 > expout | |
13278 | AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) | |
13279 | # Skipping the UDP checksum | |
13280 | cat ext1_v6.expected | cut -c 125- > expout | |
13281 | AT_CHECK([cat ext1_v6.packets | cut -c 125-], [0], [expout]) | |
13282 | ||
13283 | # disconnect hv3 from the network, hv1 should take over | |
13284 | as hv3 | |
13285 | port=${sandbox}_br-phys | |
13286 | as main ovs-vsctl del-port n1 $port | |
13287 | ||
13288 | # hv1 should be master and claim ls1-lp_ext1 | |
13289 | OVS_WAIT_UNTIL( | |
13290 | [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ | |
13291 | logical_port=ls1-lp_ext1` | |
13292 | test "$chassis" = "$hv1_uuid"]) | |
13293 | ||
13294 | OVN_CLEANUP([hv1],[hv2],[hv3]) | |
13295 | AT_CLEANUP | |
13296 | ||
37c951b2 HZ |
13297 | AT_SETUP([ovn -- Address Set Incremental Processing]) |
13298 | AT_KEYWORDS([ovn_as_inc]) | |
13299 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
13300 | ovn_start | |
13301 | ||
13302 | net_add n1 | |
13303 | sim_add hv1 | |
13304 | as hv1 | |
13305 | ovs-vsctl add-br br-phys | |
13306 | ovn_attach n1 br-phys 192.168.0.10 | |
13307 | ||
13308 | ovn-nbctl ls-add ls1 | |
13309 | for i in 1 2; do | |
13310 | ovn-nbctl lsp-add ls1 lp$i \ | |
13311 | -- lsp-set-addresses lp$i "f0:00:00:00:00:0$i 192.168.1.$i" | |
13312 | as hv1 ovs-vsctl \ | |
13313 | -- add-port br-int vif$i \ | |
13314 | -- set Interface vif$i \ | |
13315 | external-ids:iface-id=lp$i | |
13316 | done | |
13317 | ||
13318 | for i in 1 2 3; do | |
13319 | as1_uuid=`ovn-nbctl --wait=hv create addr name=as1` | |
13320 | as2_uuid=`ovn-nbctl --wait=hv create addr name=as2` | |
13321 | ovn-nbctl --wait=hv acl-add ls1 to-lport 200 \ | |
13322 | 'outport=="lp1" && ip4 && ip4.src == {$as1, $as2}' allow-related | |
13323 | ovn-nbctl --wait=hv set addr as1 addresses="10.1.2.10" | |
13324 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.10"], [0], [ignore]) | |
13325 | ||
13326 | # Update address set as1 | |
13327 | ovn-nbctl --wait=hv set addr as1 addresses="10.1.2.10 10.1.2.11" | |
13328 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.11"], [0], [ignore]) | |
13329 | ||
13330 | # Update address set as2 | |
13331 | ovn-nbctl --wait=hv set addr as2 addresses="10.1.2.12 10.1.2.13" | |
13332 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.12"], [0], [ignore]) | |
13333 | ||
13334 | # Add another ACL referencing as1 | |
13335 | n_flows_before=`ovs-ofctl dump-flows br-int | grep "10.1.2.10" | wc -l` | |
13336 | ovn-nbctl --wait=hv acl-add ls1 to-lport 200 \ | |
13337 | 'outport=="lp2" && ip4 && ip4.src == $as1' allow-related | |
13338 | n_flows_after=`ovs-ofctl dump-flows br-int | grep "10.1.2.10" | wc -l` | |
13339 | AT_CHECK([test $(expr $n_flows_before \* 2) = $n_flows_after], [0], [ignore]) | |
13340 | ||
13341 | # Remove an ACL | |
13342 | ovn-nbctl --wait=hv acl-del ls1 to-lport 200 \ | |
13343 | 'outport=="lp2" && ip4 && ip4.src == $as1' | |
13344 | n_flows_after=`ovs-ofctl dump-flows br-int | grep "10.1.2.10" | wc -l` | |
13345 | AT_CHECK([test $n_flows_before = $n_flows_after], [0], [ignore]) | |
13346 | ||
13347 | # Remove as1 while it is still used by an ACL, the lflows should be reparsed and | |
13348 | # parsing should fail. | |
13349 | echo "before del as1" | |
13350 | ovn-nbctl list addr | grep as1 | |
13351 | ovn-nbctl --wait=hv destroy addr $as1_uuid | |
13352 | echo "after del as1" | |
13353 | ovn-nbctl list addr | grep as1 | |
13354 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.10"], [1], [ignore]) | |
13355 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.12"], [1], [ignore]) | |
13356 | ||
13357 | # Recreate as1 | |
13358 | as1_uuid=`ovn-nbctl --wait=hv create addr name=as1` | |
13359 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.12"], [0], [ignore]) | |
13360 | ||
13361 | # Remove ACLs and address sets | |
13362 | ovn-nbctl --wait=hv destroy addr $as1_uuid -- destroy addr $as2_uuid | |
13363 | AT_CHECK([ovs-ofctl dump-flows br-int | grep "10.1.2.12"], [1], [ignore]) | |
13364 | ||
13365 | ovn-nbctl --wait=hv acl-del ls1 | |
13366 | done | |
13367 | ||
13368 | # Gracefully terminate daemons | |
13369 | OVN_CLEANUP([hv1]) | |
13370 | AT_CLEANUP | |
13371 | ||
96ea0ecb MM |
13372 | AT_SETUP([ovn -- ovn-controller restart]) |
13373 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
13374 | ovn_start | |
13375 | ||
13376 | # Logical network: | |
13377 | # One Logical Router: ro, with two logical switches sw1 and sw2. | |
13378 | # sw1 is for subnet 10.0.0.0/8 | |
13379 | # sw2 is for subnet 20.0.0.0/8 | |
13380 | # sw1 has a single port bound on hv1 | |
13381 | # sw2 has a single port bound on hv2 | |
13382 | ||
13383 | ovn-nbctl lr-add ro | |
13384 | ovn-nbctl ls-add sw1 | |
13385 | ovn-nbctl ls-add sw2 | |
13386 | ||
13387 | sw1_ro_mac=00:00:10:00:00:01 | |
13388 | sw1_ro_ip=10.0.0.1 | |
13389 | sw2_ro_mac=00:00:20:00:00:01 | |
13390 | sw2_ro_ip=20.0.0.1 | |
13391 | sw1_p1_mac=00:00:10:00:00:02 | |
13392 | sw1_p1_ip=10.0.0.2 | |
13393 | sw2_p1_mac=00:00:20:00:00:02 | |
13394 | sw2_p1_ip=20.0.0.2 | |
13395 | ||
13396 | ovn-nbctl lrp-add ro ro-sw1 $sw1_ro_mac ${sw1_ro_ip}/8 | |
13397 | ovn-nbctl lrp-add ro ro-sw2 $sw2_ro_mac ${sw2_ro_ip}/8 | |
13398 | ovn-nbctl lsp-add sw1 sw1-ro -- set Logical_Switch_Port sw1-ro type=router \ | |
13399 | options:router-port=ro-sw1 addresses=\"$sw1_ro_mac\" | |
13400 | ovn-nbctl lsp-add sw2 sw2-ro -- set Logical_Switch_Port sw2-ro type=router \ | |
13401 | options:router-port=ro-sw2 addresses=\"$sw2_ro_mac\" | |
13402 | ||
13403 | ovn-nbctl lsp-add sw1 sw1-p1 \ | |
13404 | -- lsp-set-addresses sw1-p1 "$sw1_p1_mac $sw1_p1_ip" | |
13405 | ||
13406 | ovn-nbctl lsp-add sw2 sw2-p1 \ | |
13407 | -- lsp-set-addresses sw2-p1 "$sw2_p1_mac $sw2_p1_ip" | |
13408 | ||
13409 | net_add n1 | |
13410 | ||
13411 | sim_add hv1 | |
13412 | as hv1 | |
13413 | ovs-vsctl add-br br-phys | |
13414 | ovn_attach n1 br-phys 192.168.0.1 | |
13415 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
13416 | set interface hv1-vif1 external-ids:iface-id=sw1-p1 \ | |
13417 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
13418 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
13419 | ofport-request=1 | |
13420 | ||
13421 | sim_add hv2 | |
13422 | as hv2 | |
13423 | ovs-vsctl add-br br-phys | |
13424 | ovn_attach n1 br-phys 192.168.0.2 | |
13425 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
13426 | set interface hv2-vif1 external-ids:iface-id=sw2-p1 \ | |
13427 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
13428 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
13429 | ofport-request=1 | |
13430 | ||
13431 | OVN_POPULATE_ARP | |
13432 | ||
13433 | sleep 1 | |
13434 | ||
13435 | packet="inport==\"sw1-p1\" && eth.src==$sw1_p1_mac && eth.dst==$sw1_ro_mac && | |
13436 | ip4 && ip.ttl==64 && ip4.src==$sw1_p1_ip && ip4.dst==$sw2_p1_ip && | |
13437 | udp && udp.src==53 && udp.dst==4369" | |
13438 | ||
13439 | # Start by Sending the packet and make sure it makes it there as expected | |
13440 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
13441 | ||
13442 | # Expected packet has TTL decreased by 1 | |
13443 | expected="eth.src==$sw2_ro_mac && eth.dst==$sw2_p1_mac && | |
13444 | ip4 && ip.ttl==63 && ip4.src==$sw1_p1_ip && ip4.dst==$sw2_p1_ip && | |
13445 | udp && udp.src==53 && udp.dst==4369" | |
13446 | echo $expected | ovstest test-ovn expr-to-packets > expected | |
13447 | ||
13448 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
13449 | ||
13450 | # Stop ovn-controller on hv2 with --restart flag | |
13451 | as hv2 ovs-appctl -t ovn-controller exit --restart | |
13452 | ||
13453 | # Now send the packet again. This time, it should still arrive | |
13454 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
13455 | ||
13456 | cat expected expected > expected2 | |
13457 | ||
13458 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected2]) | |
13459 | ||
13460 | # Start ovn-controller again just so OVN_CLEANUP doesn't complain | |
13461 | as hv2 start_daemon ovn-controller | |
13462 | ||
13463 | OVN_CLEANUP([hv1],[hv2]) | |
13464 | ||
ba11e162 | 13465 | |
96ea0ecb | 13466 | AT_CLEANUP |
863fb61f MM |
13467 | |
13468 | AT_SETUP([ovn -- ovn-nbctl duplicate addresses]) | |
13469 | ovn_start | |
13470 | ||
13471 | # Set up a switch with some switch ports of varying address types | |
13472 | ovn-nbctl ls-add sw1 | |
13473 | ovn-nbctl set logical_switch sw1 other_config:subnet=192.168.0.0/24 | |
13474 | ||
13475 | ovn-nbctl lsp-add sw1 sw1-p1 | |
13476 | ovn-nbctl lsp-add sw1 sw1-p2 | |
13477 | ovn-nbctl lsp-add sw1 sw1-p3 | |
13478 | ovn-nbctl lsp-add sw1 sw1-p4 | |
13479 | ||
13480 | ovn-nbctl lsp-set-addresses sw1-p1 "00:00:00:00:00:01 10.0.0.1 aef0::1" "00:00:00:00:00:02 10.0.0.2 aef0::2" | |
13481 | ovn-nbctl lsp-set-addresses sw1-p2 "00:00:00:00:00:03 dynamic" | |
13482 | ovn-nbctl lsp-set-addresses sw1-p3 "dynamic" | |
13483 | ovn-nbctl lsp-set-addresses sw1-p4 "router" | |
13484 | ovn-nbctl lsp-set-addresses sw1-p5 "unknown" | |
13485 | ||
13486 | ovn-nbctl list logical_switch_port | |
13487 | ||
13488 | # Now try to add duplicate addresses on a new port. These should all fail | |
abf11558 | 13489 | ovn-nbctl --wait=sb lsp-add sw1 sw1-p5 |
863fb61f MM |
13490 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p5 "00:00:00:00:00:04 10.0.0.1"], [1], [], |
13491 | [ovn-nbctl: Error on switch sw1: duplicate IPv4 address 10.0.0.1 | |
13492 | ]) | |
13493 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p5 "00:00:00:00:00:04 10.0.0.2"], [1], [], | |
13494 | [ovn-nbctl: Error on switch sw1: duplicate IPv4 address 10.0.0.2 | |
13495 | ]) | |
13496 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p5 "00:00:00:00:00:04 aef0::1"], [1], [], | |
13497 | [ovn-nbctl: Error on switch sw1: duplicate IPv6 address aef0::1 | |
13498 | ]) | |
13499 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p5 "00:00:00:00:00:04 aef0::2"], [1], [], | |
13500 | [ovn-nbctl: Error on switch sw1: duplicate IPv6 address aef0::2 | |
13501 | ]) | |
13502 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p5 "00:00:00:00:00:04 192.168.0.2"], [1], [], | |
13503 | [ovn-nbctl: Error on switch sw1: duplicate IPv4 address 192.168.0.2 | |
13504 | ]) | |
13505 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p5 "00:00:00:00:00:04 192.168.0.3"], [1], [], | |
13506 | [ovn-nbctl: Error on switch sw1: duplicate IPv4 address 192.168.0.3 | |
13507 | ]) | |
13508 | ||
13509 | # Now try re-setting sw1-p1. This should succeed | |
13510 | AT_CHECK([ovn-nbctl lsp-set-addresses sw1-p1 "00:00:00:00:00:01 10.0.0.1 aef0::1"]) | |
13511 | ||
13512 | # Now create a new switch and try setting IP addresses the same as the | |
13513 | # first switch. This should succeed. | |
13514 | ovn-nbctl ls-add sw2 | |
13515 | ovn-nbctl lsp-add sw2 sw2-p1 | |
13516 | ||
13517 | AT_CHECK([ovn-nbctl lsp-set-addresses sw2-p1 "00:00:00:00:00:04 10.0.0.1"]) | |
13518 | AT_CHECK([ovn-nbctl lsp-set-addresses sw2-p1 "00:00:00:00:00:04 192.168.0.2"]) | |
13519 | AT_CHECK([ovn-nbctl lsp-set-addresses sw2-p1 "00:00:00:00:00:04 192.168.0.3"]) | |
13520 | AT_CHECK([ovn-nbctl lsp-set-addresses sw2-p1 "00:00:00:00:00:04 aef0::1"]) | |
13521 | ||
13522 | AT_CLEANUP | |
d7abfe39 | 13523 | |
ba11e162 NS |
13524 | AT_SETUP([ovn -- router - check packet length - icmp defrag]) |
13525 | AT_KEYWORDS([check packet length]) | |
13526 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
13527 | ovn_start | |
13528 | ||
13529 | ovn-nbctl ls-add sw0 | |
13530 | ovn-nbctl lsp-add sw0 sw0-port1 | |
13531 | ovn-nbctl lsp-set-addresses sw0-port1 "50:54:00:00:00:01 10.0.0.3" | |
13532 | ||
13533 | ovn-nbctl lr-add lr0 | |
13534 | ovn-nbctl lrp-add lr0 lr0-sw0 00:00:00:00:ff:01 10.0.0.1/24 | |
13535 | ovn-nbctl lsp-add sw0 sw0-lr0 | |
13536 | ovn-nbctl lsp-set-type sw0-lr0 router | |
13537 | ovn-nbctl lsp-set-addresses sw0-lr0 router | |
13538 | ovn-nbctl lsp-set-options sw0-lr0 router-port=lr0-sw0 | |
13539 | ||
13540 | ovn-nbctl ls-add public | |
13541 | ovn-nbctl lrp-add lr0 lr0-public 00:00:20:20:12:13 172.168.0.100/24 | |
13542 | ovn-nbctl lsp-add public public-lr0 | |
13543 | ovn-nbctl lsp-set-type public-lr0 router | |
13544 | ovn-nbctl lsp-set-addresses public-lr0 router | |
13545 | ovn-nbctl lsp-set-options public-lr0 router-port=lr0-public | |
13546 | ||
13547 | # localnet port | |
13548 | ovn-nbctl lsp-add public ln-public | |
13549 | ovn-nbctl lsp-set-type ln-public localnet | |
13550 | ovn-nbctl lsp-set-addresses ln-public unknown | |
13551 | ovn-nbctl lsp-set-options ln-public network_name=phys | |
13552 | ||
13553 | ovn-nbctl lrp-set-gateway-chassis lr0-public hv1 20 | |
13554 | ovn-nbctl lr-nat-add lr0 snat 172.168.0.100 10.0.0.0/24 | |
13555 | ||
13556 | net_add n1 | |
13557 | ||
13558 | sim_add hv1 | |
13559 | as hv1 | |
13560 | ovs-vsctl add-br br-phys | |
13561 | ovn_attach n1 br-phys 192.168.0.1 | |
13562 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
13563 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
13564 | set interface hv1-vif1 external-ids:iface-id=sw0-port1 \ | |
13565 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
13566 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
13567 | ofport-request=1 | |
13568 | ||
13569 | reset_pcap_file() { | |
13570 | local iface=$1 | |
13571 | local pcap_file=$2 | |
13572 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
13573 | options:rxq_pcap=dummy-rx.pcap | |
13574 | rm -f ${pcap_file}*.pcap | |
13575 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
13576 | options:rxq_pcap=${pcap_file}-rx.pcap | |
13577 | } | |
13578 | ||
13579 | ip_to_hex() { | |
13580 | printf "%02x%02x%02x%02x" "$@" | |
13581 | } | |
13582 | ||
13583 | test_ip_packet_larger() { | |
13584 | local icmp_pmtu_reply_expected=$1 | |
13585 | ||
13586 | # Send ip packet from sw0-port1 to outside | |
13587 | src_mac="505400000001" # sw-port1 mac | |
13588 | dst_mac="00000000ff01" # sw0-lr0 mac (internal router leg) | |
13589 | src_ip=`ip_to_hex 10 0 0 3` | |
13590 | dst_ip=`ip_to_hex 172 168 0 3` | |
13591 | # Set the packet length to 100. | |
13592 | pkt_len=0064 | |
13593 | packet=${dst_mac}${src_mac}08004500${pkt_len}0000000040010000 | |
13594 | orig_packet_l3=${src_ip}${dst_ip}0304000000000000 | |
13595 | orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 | |
13596 | orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 | |
13597 | orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 | |
13598 | orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 | |
13599 | packet=${packet}${orig_packet_l3} | |
13600 | ||
fbe67a7d NS |
13601 | gw_ip_garp=ffffffffffff00002020121308060001080006040001000020201213aca80064000000000000aca80064 |
13602 | ||
ba11e162 NS |
13603 | # If icmp_pmtu_reply_expected is 0, it means the packet is lesser than |
13604 | # the gateway mtu and should be delivered to the provider bridge via the | |
13605 | # localnet port. | |
13606 | # If icmp_pmtu_reply_expected is 1, it means the packet is larger than | |
13607 | # the gateway mtu and ovn-controller should drop the packet and instead | |
13608 | # generate ICMPv4 Destination Unreachable message with pmtu set to 42. | |
13609 | if test $icmp_pmtu_reply_expected = 0; then | |
13610 | # Packet to expect at br-phys. | |
13611 | src_mac="000020201213" | |
13612 | dst_mac="00000012af11" | |
13613 | src_ip=`ip_to_hex 10 0 0 3` | |
13614 | dst_ip=`ip_to_hex 172 168 0 3` | |
13615 | expected=${dst_mac}${src_mac}08004500${pkt_len}000000003f010100 | |
13616 | expected=${expected}${src_ip}${dst_ip}0304000000000000 | |
13617 | expected=${expected}000000000000000000000000000000000000 | |
13618 | expected=${expected}000000000000000000000000000000000000 | |
13619 | expected=${expected}000000000000000000000000000000000000 | |
13620 | expected=${expected}000000000000000000000000000000000000 | |
13621 | echo $expected > br_phys_n1.expected | |
fbe67a7d | 13622 | echo $gw_ip_garp >> br_phys_n1.expected |
ba11e162 NS |
13623 | else |
13624 | # MTU would be 100 - 18 = 82 (hex 0052) | |
13625 | mtu=0052 | |
13626 | src_ip=`ip_to_hex 10 0 0 1` | |
13627 | dst_ip=`ip_to_hex 10 0 0 3` | |
13628 | # pkt len should be 128 (28 (icmp packet) + 100 (orig ip + payload)) | |
13629 | reply_pkt_len=0080 | |
13630 | ip_csum=bd91 | |
13631 | icmp_reply=${src_mac}${dst_mac}08004500${reply_pkt_len}00004000fe016879 | |
13632 | icmp_reply=${icmp_reply}${src_ip}${dst_ip}0304${ip_csum}0000${mtu} | |
13633 | icmp_reply=${icmp_reply}4500${pkt_len}000000003f010100 | |
13634 | icmp_reply=${icmp_reply}${orig_packet_l3} | |
13635 | echo $icmp_reply > hv1-vif1.expected | |
13636 | fi | |
13637 | ||
13638 | as hv1 reset_pcap_file br-phys_n1 hv1/br-phys_n1 | |
13639 | as hv1 reset_pcap_file hv1-vif1 hv1/vif1 | |
13640 | ||
13641 | # Send packet from sw0-port1 to outside | |
13642 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
13643 | ||
13644 | if test $icmp_pmtu_reply_expected = 0; then | |
13645 | OVN_CHECK_PACKETS([hv1/br-phys_n1-tx.pcap], [br_phys_n1.expected]) | |
fbe67a7d NS |
13646 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > pkts |
13647 | # hv1/vif1-tx.pcap can receive the GARP packet generated by ovn-controller | |
13648 | # for the gateway router port. So ignore this packet. | |
13649 | cat pkts | grep -v $gw_ip_garp > packets | |
ba11e162 NS |
13650 | AT_CHECK([cat packets], [0], []) |
13651 | else | |
13652 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [hv1-vif1.expected]) | |
13653 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap > \ | |
fbe67a7d NS |
13654 | pkts |
13655 | # hv1/br-phys_n1-tx.pcap can receive the GARP packet generated by ovn-controller | |
13656 | # for the gateway router port. So ignore this packet. | |
13657 | cat pkts | grep -v $gw_ip_garp > packets | |
ba11e162 NS |
13658 | AT_CHECK([cat packets], [0], []) |
13659 | fi | |
13660 | } | |
13661 | ||
13662 | ovn-nbctl show | |
13663 | ovn-sbctl show | |
13664 | ||
13665 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int \ | |
13666 | | grep "check_pkt_larger" | wc -l], [0], [[0 | |
13667 | ]]) | |
13668 | dp_uuid=$(ovn-sbctl find datapath_binding | grep sw0 -B2 | grep _uuid | \ | |
13669 | awk '{print $3}') | |
13670 | ovn-sbctl create MAC_Binding ip=172.168.0.3 datapath=$dp_uuid \ | |
13671 | logical_port=lr0-public mac="00\:00\:00\:12\:af\:11" | |
13672 | ||
13673 | # Set the gateway mtu to 100. If the packet length is > 100, ovn-controller | |
13674 | # should send icmp host not reachable with pmtu set to 100. | |
13675 | ovn-nbctl --wait=hv set logical_router_port lr0-public options:gateway_mtu=100 | |
13676 | as hv3 ovs-appctl netdev-dummy/receive hv3-vif1 $arp_reply | |
13677 | OVS_WAIT_UNTIL([ | |
13678 | test `as hv1 ovs-ofctl dump-flows br-int | grep "check_pkt_larger(100)" | \ | |
13679 | wc -l` -eq 1 | |
13680 | ]) | |
13681 | ||
13682 | icmp_reply_expected=1 | |
13683 | test_ip_packet_larger $icmp_reply_expected | |
13684 | ||
13685 | # Set the gateway mtu to 500. | |
13686 | ovn-nbctl --wait=hv set logical_router_port lr0-public options:gateway_mtu=500 | |
13687 | as hv3 ovs-appctl netdev-dummy/receive hv3-vif1 $arp_reply | |
13688 | OVS_WAIT_UNTIL([ | |
13689 | test `as hv1 ovs-ofctl dump-flows br-int | grep "check_pkt_larger(500)" | \ | |
13690 | wc -l` -eq 1 | |
13691 | ]) | |
13692 | ||
13693 | # Now the packet should be sent via the localnet port to br-phys. | |
13694 | icmp_reply_expected=0 | |
13695 | test_ip_packet_larger $icmp_reply_expected | |
13696 | OVN_CLEANUP([hv1]) | |
13697 | AT_CLEANUP | |
13698 | ||
d7abfe39 LB |
13699 | AT_SETUP([ovn -- IP packet buffering]) |
13700 | AT_KEYWORDS([ip-buffering]) | |
13701 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
13702 | ovn_start | |
13703 | ||
13704 | # Logical network: | |
13705 | # One LR lr0 that has switches sw0 (192.168.1.0/24) and | |
13706 | # sw1 (172.16.1.0/24) connected to it. | |
13707 | # | |
13708 | # Physical network: | |
13709 | # Tw0 hypervisors hv[12]. | |
13710 | # hv1 hosts vif sw0-p0. | |
13711 | # hv1 hosts vif sw1-p0. | |
13712 | ||
13713 | send_icmp_packet() { | |
13714 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ipv4_dst=$6 ip_chksum=$7 data=$8 | |
13715 | shift 8 | |
13716 | ||
13717 | local ip_ttl=ff | |
13718 | local ip_len=001c | |
13719 | local packet=${eth_dst}${eth_src}08004500${ip_len}00004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${data} | |
13720 | as hv$hv ovs-appctl netdev-dummy/receive hv$hv-vif$inport $packet | |
13721 | } | |
13722 | ||
13723 | send_icmp6_packet() { | |
13724 | local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_dst=$6 ipv6_router=$7 exp_icmp_chksum=$8 | |
13725 | shift 8 | |
13726 | ||
13727 | local ip6_hdr=6000000000083aff${ipv6_src}${ipv6_dst} | |
13728 | local packet=${eth_dst}${eth_src}86dd${ip6_hdr}8000dcb662f00001 | |
13729 | ||
13730 | as hv$hv ovs-appctl netdev-dummy/receive hv$hv-vif$inport $packet | |
13731 | } | |
13732 | ||
13733 | get_arp_req() { | |
13734 | local eth_src=$1 spa=$2 tpa=$3 | |
13735 | local request=ffffffffffff${eth_src}08060001080006040001${eth_src}${spa}000000000000${tpa} | |
13736 | echo $request | |
13737 | } | |
13738 | ||
13739 | send_arp_reply() { | |
13740 | local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 | |
13741 | local request=${eth_dst}${eth_src}08060001080006040002${eth_src}${spa}${eth_dst}${tpa} | |
13742 | as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request | |
13743 | } | |
13744 | ||
13745 | send_na() { | |
13746 | local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 src_ip=$5 dst_ip=$6 | |
13747 | local ip6_hdr=6000000000203aff${src_ip}${dst_ip} | |
13748 | local request=${eth_dst}${eth_src}86dd${ip6_hdr}8800d78440000000${src_ip}0201${eth_src} | |
13749 | ||
13750 | as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request | |
13751 | } | |
13752 | ||
13753 | get_nd() { | |
13754 | local eth_src=$1 src_ip=$2 dst_ip=$3 ta=$4 | |
13755 | local ip6_hdr=6000000000203aff${src_ip}${dst_ip} | |
13756 | request=3333ff000010${eth_src}86dd${ip6_hdr}8700357600000000${ta}0101${eth_src} | |
13757 | ||
13758 | echo $request | |
13759 | } | |
13760 | ||
13761 | net_add n1 | |
13762 | ||
13763 | sim_add hv1 | |
13764 | as hv1 | |
13765 | ovs-vsctl add-br br-phys | |
13766 | ovn_attach n1 br-phys 192.168.0.1 | |
13767 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
13768 | set interface hv1-vif1 external-ids:iface-id=sw0-p0 \ | |
13769 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
13770 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
13771 | ofport-request=1 | |
13772 | ||
13773 | sim_add hv2 | |
13774 | as hv2 | |
13775 | ovs-vsctl add-br br-phys | |
13776 | ovn_attach n1 br-phys 192.168.0.2 | |
13777 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
13778 | set interface hv2-vif1 external-ids:iface-id=sw1-p0 \ | |
13779 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
13780 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
13781 | ofport-request=1 | |
13782 | ||
13783 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
13784 | ovn-nbctl ls-add sw0 | |
13785 | ovn-nbctl ls-add sw1 | |
13786 | ||
409f7245 | 13787 | ovn-nbctl lrp-add lr0 sw0 00:00:01:01:02:03 192.168.1.1/24 2001:0:0:0:0:0:0:1/64 |
d7abfe39 LB |
13788 | ovn-nbctl lsp-add sw0 rp-sw0 -- set Logical_Switch_Port rp-sw0 \ |
13789 | type=router options:router-port=sw0 \ | |
13790 | -- lsp-set-addresses rp-sw0 router | |
13791 | ||
409f7245 | 13792 | ovn-nbctl lrp-add lr0 sw1 00:00:02:01:02:03 172.16.1.1/24 2002:0:0:0:0:0:0:1/64 |
d7abfe39 LB |
13793 | ovn-nbctl lsp-add sw1 rp-sw1 -- set Logical_Switch_Port rp-sw1 \ |
13794 | type=router options:router-port=sw1 \ | |
13795 | -- lsp-set-addresses rp-sw1 router | |
13796 | ||
13797 | ovn-nbctl lsp-add sw0 sw0-p0 \ | |
13798 | -- lsp-set-addresses sw0-p0 "f0:00:00:01:02:03 192.168.1.2 2001::2" | |
13799 | ||
13800 | ovn-nbctl lsp-add sw1 sw1-p0 \ | |
13801 | -- lsp-set-addresses sw1-p0 unknown | |
13802 | ||
13803 | OVN_POPULATE_ARP | |
13804 | ovn-nbctl --wait=hv sync | |
13805 | ||
13806 | ip_to_hex() { | |
13807 | printf "%02x%02x%02x%02x" "$@" | |
13808 | } | |
13809 | ||
13810 | src_mac=f00000010203 | |
13811 | src_ip=$(ip_to_hex 192 168 1 2) | |
13812 | src_ip6=20010000000000000000000000000002 | |
13813 | ||
13814 | router_mac0=000001010203 | |
13815 | router_mac1=000002010203 | |
13816 | router_ip=$(ip_to_hex 172 16 1 1) | |
13817 | router_ip6=20020000000000000000000000000001 | |
13818 | ||
13819 | dst_mac=001122334455 | |
13820 | dst_ip=$(ip_to_hex 172 16 1 10) | |
13821 | dst_ip6=20020000000000000000000000000010 | |
13822 | ||
13823 | data=0800bee4391a0001 | |
13824 | ||
13825 | send_icmp_packet 1 1 $src_mac $router_mac0 $src_ip $dst_ip 0000 $data | |
13826 | send_arp_reply 2 1 $dst_mac $router_mac1 $dst_ip $router_ip | |
13827 | echo $(get_arp_req $router_mac1 $router_ip $dst_ip) > expected | |
13828 | echo "${dst_mac}${router_mac1}08004500001c00004000fe010100${src_ip}${dst_ip}${data}" >> expected | |
13829 | ||
13830 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
13831 | ||
13832 | nd_ip=ff0200000000000000000001ff000010 | |
13833 | ip6_hdr=6000000000083afe${src_ip6}${dst_ip6} | |
13834 | ||
13835 | send_icmp6_packet 1 1 $src_mac $router_mac0 $src_ip6 $dst_ip6 | |
13836 | echo $(get_nd $router_mac1 $src_ip6 $nd_ip $dst_ip6) >> expected | |
13837 | echo "${dst_mac}${router_mac1}86dd${ip6_hdr}8000dcb662f00001" >> expected | |
13838 | send_na 2 1 $dst_mac $router_mac1 $dst_ip6 $router_ip6 | |
13839 | ||
13840 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
13841 | ||
13842 | OVN_CLEANUP([hv1],[hv2]) | |
13843 | AT_CLEANUP | |
81e92852 DA |
13844 | |
13845 | AT_SETUP([ovn -- neighbor update on same HV]) | |
13846 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
13847 | ovn_start | |
13848 | ||
13849 | # Logical network: | |
13850 | # A public switch (pub) with a localnet port connected to two LRs (lr0 and lr1) | |
13851 | # each with a distributed gateway port. | |
13852 | # Two VMs: lp0 on sw0 connected to lr0 | |
13853 | # lp1 on sw1 connected to lr1 | |
13854 | # | |
13855 | # This test adds a floating IP to each VM so when they are bound to the same | |
13856 | # hypervisor, it checks that the GARP sent by ovn-controller causes the | |
13857 | # MAC_Binding entries to be updated properly on each logical router. | |
13858 | # It will also capture packets on the physical interface to make sure that the | |
13859 | # GARPs have been sent out to the external network as well. | |
13860 | ||
13861 | # Create logical switches | |
13862 | ovn-nbctl ls-add sw0 | |
13863 | ovn-nbctl ls-add sw1 | |
13864 | ovn-nbctl ls-add pub | |
13865 | ||
13866 | # Created localnet port on public switch | |
13867 | ovn-nbctl lsp-add pub ln-pub | |
13868 | ovn-nbctl lsp-set-type ln-pub localnet | |
13869 | ovn-nbctl lsp-set-addresses ln-pub unknown | |
13870 | ovn-nbctl lsp-set-options ln-pub network_name=phys | |
13871 | ||
13872 | # Create logical routers and connect them to public switch | |
13873 | ovn-nbctl create Logical_Router name=lr0 | |
13874 | ovn-nbctl create Logical_Router name=lr1 | |
13875 | ||
13876 | ovn-nbctl lrp-add lr0 lr0-pub f0:00:00:00:00:01 172.24.4.220/24 | |
13877 | ovn-nbctl lsp-add pub pub-lr0 -- set Logical_Switch_Port pub-lr0 \ | |
13878 | type=router options:router-port=lr0-pub options:nat-addresses="router" addresses="router" | |
13879 | ovn-nbctl lrp-add lr1 lr1-pub f0:00:00:00:01:01 172.24.4.221/24 | |
13880 | ovn-nbctl lsp-add pub pub-lr1 -- set Logical_Switch_Port pub-lr1 \ | |
13881 | type=router options:router-port=lr1-pub options:nat-addresses="router" addresses="router" | |
13882 | ||
13883 | ovn-nbctl lrp-set-gateway-chassis lr0-pub hv1 10 | |
13884 | ovn-nbctl lrp-set-gateway-chassis lr1-pub hv1 10 | |
13885 | ||
13886 | # Connect sw0 and sw1 to lr0 and lr1 | |
13887 | ovn-nbctl lrp-add lr0 lr0-sw0 00:00:00:00:ff:01 10.0.0.254/24 | |
13888 | ovn-nbctl lsp-add sw0 sw0-lr0 -- set Logical_Switch_Port sw0-lr0 type=router \ | |
13889 | options:router-port=lr0-sw0 addresses="router" | |
13890 | ovn-nbctl lrp-add lr1 lr1-sw1 00:00:00:00:ff:02 20.0.0.254/24 | |
13891 | ovn-nbctl lsp-add sw1 sw1-lr1 -- set Logical_Switch_Port sw1-lr1 type=router \ | |
13892 | options:router-port=lr1-sw1 addresses="router" | |
13893 | ||
13894 | ||
13895 | # Add SNAT rules | |
13896 | ovn-nbctl lr-nat-add lr0 snat 172.24.4.220 10.0.0.0/24 | |
13897 | ovn-nbctl lr-nat-add lr1 snat 172.24.4.221 20.0.0.0/24 | |
13898 | ||
13899 | net_add n1 | |
13900 | sim_add hv1 | |
13901 | as hv1 | |
13902 | ovs-vsctl add-br br-phys | |
13903 | ovn_attach n1 br-phys 172.24.4.1 | |
13904 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
13905 | ||
13906 | ovs-vsctl add-port br-int vif0 -- set Interface vif0 external-ids:iface-id=lp0 | |
13907 | ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
13908 | ||
13909 | ovn-nbctl lsp-add sw0 lp0 | |
13910 | ovn-nbctl lsp-add sw1 lp1 | |
13911 | ovn-nbctl lsp-set-addresses lp0 "50:54:00:00:00:01 10.0.0.10" | |
13912 | ovn-nbctl lsp-set-addresses lp1 "50:54:00:00:00:02 20.0.0.10" | |
13913 | ||
13914 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp0` = xup]) | |
13915 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
13916 | ||
13917 | # Create two floating IPs, one for each VIF | |
13918 | ovn-nbctl lr-nat-add lr0 dnat_and_snat 172.24.4.100 10.0.0.10 | |
13919 | ovn-nbctl lr-nat-add lr1 dnat_and_snat 172.24.4.200 20.0.0.10 | |
13920 | ||
13921 | # Check that the MAC_Binding entries have been properly created | |
13922 | OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding logical_port="lr0-pub" ip="172.24.4.200" | wc -l` -gt 0]) | |
13923 | OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding logical_port="lr1-pub" ip="172.24.4.100" | wc -l` -gt 0]) | |
13924 | ||
13925 | # Check that the GARPs went also to the external physical network | |
13926 | # Wait until at least 4 packets have arrived and copy them to a separate file as | |
13927 | # more GARPs are expected in the capture in order to avoid race conditions. | |
13928 | OVS_WAIT_UNTIL([test `$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | wc -l` -gt 4]) | |
13929 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | head -n4 > hv1/br-phys-tx4.pcap | |
13930 | ||
13931 | # GARP for lp0 172.24.4.100 on lr0-pub MAC (f0:00:00:00:00:01) | |
13932 | echo "fffffffffffff0000000000108060001080006040001f00000000001ac180464000000000000ac180464" > expout | |
13933 | # GARP for 172.24.4.220 on lr0-pub (f0:00:00:00:00:01) | |
13934 | echo "fffffffffffff0000000000108060001080006040001f00000000001ac1804dc000000000000ac1804dc" >> expout | |
13935 | #Â GARP for lp1 172.24.4.200 on lr1-pub MAC (f0:00:00:00:01:01) | |
13936 | echo "fffffffffffff0000000010108060001080006040001f00000000101ac1804c8000000000000ac1804c8" >> expout | |
13937 | # GARP for 172.24.4.221 on lr1-pub (f0:00:00:00:01:01) | |
13938 | echo "fffffffffffff0000000010108060001080006040001f00000000101ac1804dd000000000000ac1804dd" >> expout | |
13939 | AT_CHECK([sort hv1/br-phys-tx4.pcap], [0], [expout]) | |
13940 | #OVN_CHECK_PACKETS([hv1/br-phys-tx4.pcap], [br-phys.expected]) | |
13941 | ||
13942 | OVN_CLEANUP([hv1]) | |
13943 | AT_CLEANUP | |
dcad4473 MM |
13944 | |
13945 | AT_SETUP([ovn -- ipam to non-ipam]) | |
13946 | ovn_start | |
13947 | ||
f1301a25 | 13948 | ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="0a:00:00:00:00:00" |
dcad4473 MM |
13949 | ovn-nbctl ls-add sw0 |
13950 | ovn-nbctl lsp-add sw0 p0 -- lsp-set-addresses p0 dynamic | |
13951 | ovn-nbctl --wait=sb add Logical-Switch sw0 other_config subnet=192.168.1.0/24 | |
13952 | ||
13953 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0], | |
13954 | ["0a:00:00:a8:01:03 192.168.1.2" | |
13955 | ]) | |
13956 | ||
abf11558 | 13957 | ovn-nbctl --wait=sb lsp-set-addresses p0 router |
dcad4473 MM |
13958 | |
13959 | ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses | |
13960 | ||
13961 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0], [[[]] | |
13962 | ]) | |
13963 | AT_CLEANUP | |
6f5cc61c MM |
13964 | |
13965 | AT_SETUP([ovn -- ipam router ports]) | |
13966 | ovn_start | |
13967 | ||
13968 | ovn-nbctl ls-add sw | |
13969 | ovn-nbctl set logical_switch sw other-config:subnet=192.168.1.0/24 | |
13970 | ||
13971 | for i in 2 3 4; do | |
13972 | ovn-nbctl lr-add ro$i | |
13973 | ovn-nbctl lsp-add sw swp$i | |
13974 | ovn-nbctl --wait=sb lsp-set-addresses swp$i "02:00:00:00:00:0$i dynamic" | |
13975 | cidr=$(ovn-nbctl get logical_switch_port swp$i dynamic_addresses |cut -f2 -d' '|cut -f1 -d\") | |
13976 | ovn-nbctl lrp-add ro$i rop$i 02:00:00:00:00:0$i $cidr/24 -- set logical_switch_port swp$i type=router options:router-port=rop$i addresses=router; | |
13977 | AT_CHECK_UNQUOTED([ovn-nbctl get logical_router_port rop$i networks], [0], [[["192.168.1.$i/24"]] | |
13978 | ]) | |
13979 | done | |
13980 | ||
13981 | ovn-nbctl list logical_switch_port | |
13982 | ovn-nbctl list logical_router_port | |
13983 | ||
13984 | AT_CLEANUP | |
3bb479d9 LAG |
13985 | |
13986 | AT_SETUP([ovn -- test transport zones]) | |
13987 | ovn_start | |
13988 | ||
13989 | net_add n1 | |
13990 | for i in 1 2 3 4 5; do | |
13991 | sim_add hv$i | |
13992 | as hv$i | |
13993 | ovs-vsctl add-br br-phys | |
13994 | ovn_attach n1 br-phys 192.168.$i.1 | |
13995 | done | |
13996 | ||
13997 | dnl Wait for the changes to be propagated | |
13998 | ovn-nbctl --wait=sb --timeout=3 sync | |
13999 | ovn-nbctl --wait=hv --timeout=3 sync | |
14000 | ||
14001 | dnl Assert that each Chassis has a tunnel formed to every other Chassis | |
14002 | as hv1 | |
14003 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14004 | [[ovn-hv2-0 | |
14005 | ovn-hv3-0 | |
14006 | ovn-hv4-0 | |
14007 | ovn-hv5-0 | |
14008 | ]]) | |
14009 | ||
14010 | as hv2 | |
14011 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14012 | [[ovn-hv1-0 | |
14013 | ovn-hv3-0 | |
14014 | ovn-hv4-0 | |
14015 | ovn-hv5-0 | |
14016 | ]]) | |
14017 | ||
14018 | as hv3 | |
14019 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14020 | [[ovn-hv1-0 | |
14021 | ovn-hv2-0 | |
14022 | ovn-hv4-0 | |
14023 | ovn-hv5-0 | |
14024 | ]]) | |
14025 | ||
14026 | as hv4 | |
14027 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14028 | [[ovn-hv1-0 | |
14029 | ovn-hv2-0 | |
14030 | ovn-hv3-0 | |
14031 | ovn-hv5-0 | |
14032 | ]]) | |
14033 | ||
14034 | as hv5 | |
14035 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14036 | [[ovn-hv1-0 | |
14037 | ovn-hv2-0 | |
14038 | ovn-hv3-0 | |
14039 | ovn-hv4-0 | |
14040 | ]]) | |
14041 | ||
14042 | dnl Let's now add some Chassis to different transport zones | |
14043 | dnl * hv1: Will be part of two transport zones: tz1 and tz2 so it | |
14044 | dnl should have tunnels formed between the other two Chassis (hv2 and hv3) | |
14045 | dnl | |
14046 | dnl * hv2: Will be part of one transport zone: tz1. It should have a tunnel | |
14047 | dnl to hv1 but not to hv3 | |
14048 | dnl | |
14049 | dnl * hv3: Will be part of one transport zone: tz2. It should have a tunnel | |
14050 | dnl to hv1 but not to hv2 | |
14051 | dnl | |
14052 | dnl * hv4 and hv5: Will not have any TZ set so they will keep the tunnels | |
14053 | dnl between themselves and remove the tunnels to other Chassis which now | |
14054 | dnl belongs to some TZs | |
14055 | dnl | |
14056 | as hv1 | |
14057 | ovs-vsctl set open . external-ids:ovn-transport-zones=tz1,tz2 | |
14058 | ||
14059 | as hv2 | |
14060 | ovs-vsctl set open . external-ids:ovn-transport-zones=tz1 | |
14061 | ||
14062 | as hv3 | |
14063 | ovs-vsctl set open . external-ids:ovn-transport-zones=tz2 | |
14064 | ||
14065 | dnl Wait for the changes to be propagated | |
14066 | ovn-nbctl --wait=sb --timeout=3 sync | |
14067 | ovn-nbctl --wait=hv --timeout=3 sync | |
14068 | ||
14069 | as hv1 | |
14070 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14071 | [[ovn-hv2-0 | |
14072 | ovn-hv3-0 | |
14073 | ]]) | |
14074 | ||
14075 | as hv2 | |
14076 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14077 | [[ovn-hv1-0 | |
14078 | ]]) | |
14079 | ||
14080 | as hv3 | |
14081 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14082 | [[ovn-hv1-0 | |
14083 | ]]) | |
14084 | ||
14085 | as hv4 | |
14086 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14087 | [[ovn-hv5-0 | |
14088 | ]]) | |
14089 | ||
14090 | as hv5 | |
14091 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14092 | [[ovn-hv4-0 | |
14093 | ]]) | |
14094 | ||
14095 | dnl Removing the transport zones should make all Chassis to create | |
14096 | dnl tunnels between every other Chassis again | |
14097 | for i in 1 2 3; do | |
14098 | as hv$i | |
14099 | ovs-vsctl remove open . external-ids ovn-transport-zones | |
14100 | done | |
14101 | ||
14102 | dnl Wait for the changes to be propagated | |
14103 | ovn-nbctl --wait=sb --timeout=3 sync | |
14104 | ovn-nbctl --wait=hv --timeout=3 sync | |
14105 | ||
14106 | as hv1 | |
14107 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14108 | [[ovn-hv2-0 | |
14109 | ovn-hv3-0 | |
14110 | ovn-hv4-0 | |
14111 | ovn-hv5-0 | |
14112 | ]]) | |
14113 | ||
14114 | as hv2 | |
14115 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14116 | [[ovn-hv1-0 | |
14117 | ovn-hv3-0 | |
14118 | ovn-hv4-0 | |
14119 | ovn-hv5-0 | |
14120 | ]]) | |
14121 | ||
14122 | as hv3 | |
14123 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14124 | [[ovn-hv1-0 | |
14125 | ovn-hv2-0 | |
14126 | ovn-hv4-0 | |
14127 | ovn-hv5-0 | |
14128 | ]]) | |
14129 | ||
14130 | as hv4 | |
14131 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14132 | [[ovn-hv1-0 | |
14133 | ovn-hv2-0 | |
14134 | ovn-hv3-0 | |
14135 | ovn-hv5-0 | |
14136 | ]]) | |
14137 | ||
14138 | as hv5 | |
14139 | AT_CHECK([ovs-vsctl --bare --columns=name find interface type="geneve" | awk NF | sort], [0], | |
14140 | [[ovn-hv1-0 | |
14141 | ovn-hv2-0 | |
14142 | ovn-hv3-0 | |
14143 | ovn-hv4-0 | |
14144 | ]]) | |
14145 | ||
14146 | OVN_CLEANUP([hv1], [hv2], [hv3]) | |
14147 | AT_CLEANUP | |
795d7f24 AS |
14148 | |
14149 | AT_SETUP([ovn -- 2 HVs, 2 lports/HV, localnet ports, DVR chassis mac]) | |
14150 | ovn_start | |
14151 | ||
14152 | ||
14153 | # In this test cases we create 2 switches, all connected to same | |
14154 | # physical network (through br-phys on each HV). Each switch has | |
14155 | # 1 VIF. Each HV has 1 VIF port. The first digit | |
14156 | # of VIF port name indicates the hypervisor it is bound to, e.g. | |
14157 | # lp23 means VIF 3 on hv2. | |
14158 | # | |
14159 | # Each switch's VLAN tag and their logical switch ports are: | |
14160 | # - ls1: | |
14161 | # - tagged with VLAN 101 | |
14162 | # - ports: lp11 | |
14163 | # - ls2: | |
14164 | # - tagged with VLAN 201 | |
14165 | # - ports: lp22 | |
14166 | # | |
14167 | # Note: a localnet port is created for each switch to connect to | |
14168 | # physical network. | |
14169 | ||
14170 | for i in 1 2; do | |
14171 | ls_name=ls$i | |
14172 | ovn-nbctl ls-add $ls_name | |
14173 | ln_port_name=ln$i | |
14174 | if test $i -eq 1; then | |
14175 | ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 | |
14176 | elif test $i -eq 2; then | |
14177 | ovn-nbctl lsp-add $ls_name $ln_port_name "" 201 | |
14178 | fi | |
14179 | ovn-nbctl lsp-set-addresses $ln_port_name unknown | |
14180 | ovn-nbctl lsp-set-type $ln_port_name localnet | |
14181 | ovn-nbctl lsp-set-options $ln_port_name network_name=phys | |
14182 | done | |
14183 | ||
14184 | # lsp_to_ls LSP | |
14185 | # | |
14186 | # Prints the name of the logical switch that contains LSP. | |
14187 | lsp_to_ls () { | |
14188 | case $1 in dnl ( | |
14189 | lp?[[11]]) echo ls1 ;; dnl ( | |
14190 | lp?[[12]]) echo ls2 ;; dnl ( | |
14191 | *) AT_FAIL_IF([:]) ;; | |
14192 | esac | |
14193 | } | |
14194 | ||
14195 | vif_to_ls () { | |
14196 | case $1 in dnl ( | |
14197 | vif?[[11]]) echo ls1 ;; dnl ( | |
14198 | vif?[[12]]) echo ls2 ;; dnl ( | |
14199 | *) AT_FAIL_IF([:]) ;; | |
14200 | esac | |
14201 | } | |
14202 | ||
14203 | hv_to_num () { | |
14204 | case $1 in dnl ( | |
14205 | hv1) echo 1 ;; dnl ( | |
14206 | hv2) echo 2 ;; dnl ( | |
14207 | *) AT_FAIL_IF([:]) ;; | |
14208 | esac | |
14209 | } | |
14210 | ||
14211 | vif_to_num () { | |
14212 | case $1 in dnl ( | |
14213 | vif22) echo 22 ;; dnl ( | |
14214 | vif21) echo 21 ;; dnl ( | |
14215 | *) AT_FAIL_IF([:]) ;; | |
14216 | esac | |
14217 | } | |
14218 | ||
14219 | vif_to_hv () { | |
14220 | case $1 in dnl ( | |
14221 | vif[[1]]?) echo hv1 ;; dnl ( | |
14222 | vif[[2]]?) echo hv2 ;; dnl ( | |
14223 | *) AT_FAIL_IF([:]) ;; | |
14224 | esac | |
14225 | } | |
14226 | ||
14227 | vif_to_lrp () { | |
14228 | echo router-to-`vif_to_ls $1` | |
14229 | } | |
14230 | ||
14231 | hv_to_chassis_mac () { | |
14232 | case $1 in dnl ( | |
14233 | hv[[1]]) echo aa:bb:cc:dd:ee:11 ;; dnl ( | |
14234 | hv[[2]]) echo aa:bb:cc:dd:ee:22 ;; dnl ( | |
14235 | *) AT_FAIL_IF([:]) ;; | |
14236 | esac | |
14237 | } | |
14238 | ||
14239 | ip_to_hex() { | |
14240 | printf "%02x%02x%02x%02x" "$@" | |
14241 | } | |
14242 | ||
14243 | net_add n1 | |
14244 | for i in 1 2; do | |
14245 | sim_add hv$i | |
14246 | as hv$i | |
14247 | ovs-vsctl add-br br-phys | |
14248 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
14249 | ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:$i$i" | |
14250 | ovn_attach n1 br-phys 192.168.0.$i | |
14251 | ||
14252 | ovs-vsctl add-port br-int vif$i$i -- \ | |
14253 | set Interface vif$i$i external-ids:iface-id=lp$i$i \ | |
14254 | options:tx_pcap=hv$i/vif$i$i-tx.pcap \ | |
14255 | options:rxq_pcap=hv$i/vif$i$i-rx.pcap \ | |
14256 | ofport-request=$i$i | |
14257 | ||
14258 | lsp_name=lp$i$i | |
14259 | ls_name=$(lsp_to_ls $lsp_name) | |
14260 | ||
14261 | ovn-nbctl lsp-add $ls_name $lsp_name | |
14262 | ovn-nbctl lsp-set-addresses $lsp_name "f0:00:00:00:00:$i$i 192.168.$i.$i" | |
14263 | ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$i | |
14264 | ||
14265 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) | |
14266 | ||
14267 | done | |
14268 | ||
14269 | ovn-nbctl lr-add router | |
14270 | ovn-nbctl lrp-add router router-to-ls1 00:00:01:01:02:03 192.168.1.3/24 | |
14271 | ovn-nbctl lrp-add router router-to-ls2 00:00:01:01:02:05 192.168.2.3/24 | |
14272 | ||
14273 | ovn-nbctl lsp-add ls1 ls1-to-router -- set Logical_Switch_Port ls1-to-router type=router options:router-port=router-to-ls1 -- lsp-set-addresses ls1-to-router router | |
14274 | ovn-nbctl lsp-add ls2 ls2-to-router -- set Logical_Switch_Port ls2-to-router type=router options:router-port=router-to-ls2 -- lsp-set-addresses ls2-to-router router | |
14275 | ||
14276 | ovn-nbctl --wait=sb sync | |
14277 | #ovn-sbctl dump-flows | |
14278 | ||
14279 | ovn-nbctl show | |
14280 | ovn-sbctl show | |
14281 | ||
14282 | OVN_POPULATE_ARP | |
14283 | ||
14284 | test_ip() { | |
14285 | # This packet has bad checksums but logical L3 routing doesn't check. | |
14286 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
14287 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
14288 | shift; shift; shift; shift; shift | |
14289 | hv=`vif_to_hv $inport` | |
14290 | hv_num=`hv_to_num $hv` | |
14291 | chassis_mac=`hv_to_chassis_mac $hv` | |
14292 | as $hv ovs-appctl netdev-dummy/receive $inport $packet | |
14293 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
14294 | in_ls=`vif_to_ls $inport` | |
14295 | in_lrp=`vif_to_lrp $inport` | |
14296 | for outport; do | |
14297 | out_ls=`vif_to_ls $outport` | |
14298 | if test $in_ls = $out_ls; then | |
14299 | # Ports on the same logical switch receive exactly the same packet. | |
14300 | echo $packet | |
14301 | else | |
14302 | # Routing decrements TTL and updates source and dest MAC | |
14303 | # (and checksum). | |
14304 | outport_num=`vif_to_num $outport` | |
14305 | out_lrp=`vif_to_lrp $outport` | |
14306 | echo f000000000${outport_num}aabbccddee${hv_num}${hv_num}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 | |
14307 | fi >> $outport.expected | |
14308 | done | |
14309 | } | |
14310 | ||
14311 | # Dump a bunch of info helpful for debugging if there's a failure. | |
14312 | ||
14313 | echo "------ OVN dump ------" | |
14314 | ovn-nbctl show | |
14315 | ovn-sbctl show | |
14316 | ||
14317 | echo "------ hv1 dump ------" | |
14318 | as hv1 ovs-vsctl show | |
14319 | as hv1 ovs-vsctl list Open_Vswitch | |
14320 | ||
14321 | echo "------ hv2 dump ------" | |
14322 | as hv2 ovs-vsctl show | |
14323 | as hv2 ovs-vsctl list Open_Vswitch | |
14324 | ||
14325 | echo "Send traffic" | |
14326 | sip=`ip_to_hex 192 168 1 1` | |
14327 | dip=`ip_to_hex 192 168 2 2` | |
14328 | test_ip vif11 f00000000011 000001010203 $sip $dip vif22 | |
14329 | ||
14330 | echo "----------- Post Traffic hv1 dump -----------" | |
14331 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
14332 | as hv1 ovs-appctl fdb/show br-phys | |
14333 | ||
14334 | echo "----------- Post Traffic hv2 dump -----------" | |
14335 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
14336 | as hv2 ovs-appctl fdb/show br-phys | |
14337 | ||
14338 | OVN_CHECK_PACKETS([hv2/vif22-tx.pcap], [vif22.expected]) | |
14339 | ||
14340 | OVN_CLEANUP([hv1],[hv2]) | |
14341 | ||
14342 | AT_CLEANUP | |
2a9679e3 DA |
14343 | |
14344 | # Run ovn-nbctl in daemon mode, change to a backup database and verify that | |
14345 | # an insert operation is not allowed. | |
14346 | AT_SETUP([ovn -- can't write to a backup database server instance]) | |
14347 | ovn_start | |
14348 | on_exit 'kill $(cat ovn-nbctl.pid)' | |
14349 | export OVN_NB_DAEMON=$(ovn-nbctl --pidfile --detach) | |
14350 | ||
14351 | AT_CHECK([ovn-nbctl ls-add sw0]) | |
14352 | as ovn-nb | |
14353 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/sync-status | grep active | wc -l], [0], [1 | |
14354 | ]) | |
14355 | ovs-appctl -t ovsdb-server ovsdb-server/set-active-ovsdb-server tcp:192.0.2.2:6641 | |
14356 | ovs-appctl -t ovsdb-server ovsdb-server/connect-active-ovsdb-server | |
14357 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/sync-status | grep -c backup], [0], [1 | |
14358 | ]) | |
14359 | AT_CHECK([ovn-nbctl ls-add sw1], [1], [ignore], | |
14360 | [ovn-nbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
14361 | ]) | |
14362 | ||
14363 | AT_CLEANUP | |
821e1e54 LB |
14364 | |
14365 | AT_SETUP([ovn -- controller event]) | |
14366 | AT_KEYWORDS([ovn_controller_event]) | |
14367 | ovn_start | |
14368 | ||
14369 | # Create hypervisors hv[12]. | |
14370 | # Add vif1[12] to hv1, vif2[12] to hv2 | |
14371 | # Add all of the vifs to a single logical switch sw0. | |
14372 | ||
14373 | net_add n1 | |
14374 | ovn-nbctl ls-add sw0 | |
14375 | for i in 1 2; do | |
14376 | sim_add hv$i | |
14377 | as hv$i | |
14378 | ovs-vsctl add-br br-phys | |
14379 | ovn_attach n1 br-phys 192.168.0.$i | |
14380 | ||
14381 | for j in 1 2; do | |
14382 | ovn-nbctl lsp-add sw0 sw0-p$i$j -- \ | |
14383 | lsp-set-addresses sw0-p$i$j "00:00:00:00:00:$i$j 192.168.1.$i$j" | |
14384 | ||
14385 | ovs-vsctl -- add-port br-int vif$i$j -- \ | |
14386 | set interface vif$i$j \ | |
14387 | external-ids:iface-id=sw0-p$i$j \ | |
14388 | options:tx_pcap=hv$i/vif$i$j-tx.pcap \ | |
14389 | options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ | |
14390 | ofport-request=$i$j | |
14391 | done | |
14392 | done | |
14393 | ||
14394 | ovn-nbctl --wait=hv set NB_Global . options:controller_event=true | |
14395 | ovn-nbctl lb-add lb0 192.168.1.100:80 "" | |
14396 | ovn-nbctl ls-lb-add sw0 lb0 | |
14397 | uuid_lb=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0) | |
14398 | ||
14399 | OVN_POPULATE_ARP | |
14400 | ovn-nbctl --timeout=3 --wait=hv sync | |
14401 | ovn-sbctl lflow-list | |
14402 | as hv1 ovs-ofctl dump-flows br-int | |
14403 | ||
14404 | packet="inport==\"sw0-p11\" && eth.src==00:00:00:00:00:11 && eth.dst==00:00:00:00:00:21 && | |
14405 | ip4 && ip.ttl==64 && ip4.src==192.168.1.11 && ip4.dst==192.168.1.100 && | |
14406 | tcp && tcp.src==10000 && tcp.dst==80" | |
14407 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
14408 | ||
14409 | ovn-sbctl list controller_event | |
14410 | uuid=$(ovn-sbctl list controller_event | awk '/_uuid/{print $3}') | |
14411 | AT_CHECK([ovn-sbctl get controller_event $uuid event_type], [0], [dnl | |
14412 | empty_lb_backends | |
14413 | ]) | |
14414 | AT_CHECK([ovn-sbctl get controller_event $uuid event_info:vip], [0], [dnl | |
14415 | "192.168.1.100:80" | |
14416 | ]) | |
14417 | AT_CHECK([ovn-sbctl get controller_event $uuid event_info:protocol], [0], [dnl | |
14418 | tcp | |
14419 | ]) | |
14420 | AT_CHECK_UNQUOTED([ovn-sbctl get controller_event $uuid event_info:load_balancer], [0], [dnl | |
14421 | "$uuid_lb" | |
14422 | ]) | |
14423 | AT_CHECK([ovn-sbctl get controller_event $uuid seq_num], [0], [dnl | |
14424 | 1 | |
14425 | ]) | |
14426 | ||
14427 | OVN_CLEANUP([hv1], [hv2]) | |
14428 | AT_CLEANUP |