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