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