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