]>
Commit | Line | Data |
---|---|---|
49d7c759 BP |
1 | # OVN_CHECK_PACKETS([PCAP], [EXPECTED]) |
2 | # | |
3 | # This compares packets read from PCAP, in pcap format, to those read | |
4 | # from EXPECTED, which is a text file containing packets as hex | |
5 | # strings, one per line. If PCAP contains fewer packets than | |
6 | # EXPECTED, it waits up to 10 seconds for more packets to appear. | |
7 | # | |
8 | # The implementation is an m4 macro that is mostly implemented in | |
9 | # terms of a shell function. This reduces the size of the generated | |
10 | # testsuite file since the shell function is only emitted once even | |
11 | # when this macro is invoked many times. | |
12 | m4_divert_text([PREPARE_TESTS], | |
13 | [ovn_check_packets__ () { | |
14 | echo | |
15 | echo "checking packets in $1 against $2:" | |
16 | rcv_pcap=$1 | |
17 | rcv_text=`echo "$rcv_pcap.packets" | sed 's/\.pcap//'` | |
18 | exp_text=$2 | |
19 | exp_n=`wc -l < "$exp_text"` | |
20 | ovs_wait_cond () { | |
abb37b6b FF |
21 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text |
22 | rcv_n=`wc -l < "$rcv_text"` | |
23 | test $rcv_n -ge $exp_n | |
49d7c759 BP |
24 | } |
25 | ovs_wait || echo "expected $exp_n packets, only received $rcv_n" | |
26 | ||
e4543cfe | 27 | sort $exp_text > expout |
49d7c759 BP |
28 | } |
29 | ]) | |
30 | m4_define([OVN_CHECK_PACKETS], | |
31 | [ovn_check_packets__ "$1" "$2" | |
32 | AT_CHECK([sort $rcv_text], [0], [expout])]) | |
33 | ||
f295c17b | 34 | AT_BANNER([OVN components]) |
10b1662b BP |
35 | |
36 | AT_SETUP([ovn -- lexer]) | |
37 | dnl For lines without =>, input and expected output are identical. | |
38 | dnl For lines with =>, input precedes => and expected output follows =>. | |
39 | AT_DATA([test-cases.txt], [dnl | |
40 | foo bar baz quuxquuxquux _abcd_ a.b.c.d a123_.456 | |
41 | "abc\u0020def" => "abc def" | |
42 | " => error("Input ends inside quoted string.")dnl " | |
43 | ||
2c5cbb15 RB |
44 | $foo $bar $baz $quuxquuxquux $_abcd_ $a.b.c.d $a123_.456 |
45 | $1 => error("`$' must be followed by a valid identifier.") 1 | |
46 | ||
10b1662b BP |
47 | a/*b*/c => a c |
48 | a//b c => a | |
49 | a/**/b => a b | |
50 | a/*/b => a error("`/*' without matching `*/'.") | |
51 | a/*/**/b => a b | |
52 | a/b => a error("`/' is only valid as part of `//' or `/*'.") b | |
53 | ||
54 | 0 1 12345 18446744073709551615 | |
55 | 18446744073709551616 => error("Decimal constants must be less than 2**64.") | |
56 | 9999999999999999999999 => error("Decimal constants must be less than 2**64.") | |
57 | 01 => error("Decimal constants must not have leading zeros.") | |
58 | ||
59 | 0/0 | |
60 | 0/1 | |
61 | 1/0 => error("Value contains unmasked 1-bits.") | |
62 | 1/1 | |
63 | 128/384 | |
64 | 1/3 | |
65 | 1/ => error("Integer constant expected.") | |
66 | ||
67 | 1/0x123 => error("Value and mask have incompatible formats.") | |
68 | ||
69 | 0x1234 | |
70 | 0x01234 => 0x1234 | |
71 | 0x0 => 0 | |
72 | 0x000 => 0 | |
73 | 0xfedcba9876543210 | |
74 | 0XFEDCBA9876543210 => 0xfedcba9876543210 | |
75 | 0xfedcba9876543210fedcba9876543210 | |
10b1662b BP |
76 | 0x0000fedcba9876543210fedcba9876543210 => 0xfedcba9876543210fedcba9876543210 |
77 | 0x => error("Hex digits expected following 0x.") | |
78 | 0X => error("Hex digits expected following 0X.") | |
79 | 0x0/0x0 => 0/0 | |
80 | 0x0/0x1 => 0/0x1 | |
81 | 0x1/0x0 => error("Value contains unmasked 1-bits.") | |
82 | 0xffff/0x1ffff | |
83 | 0x. => error("Invalid syntax in hexadecimal constant.") | |
84 | ||
85 | 192.168.128.1 1.2.3.4 255.255.255.255 0.0.0.0 | |
86 | 256.1.2.3 => error("Invalid numeric constant.") | |
87 | 192.168.0.0/16 | |
88 | 192.168.0.0/255.255.0.0 => 192.168.0.0/16 | |
89 | 192.168.0.0/255.255.255.0 => 192.168.0.0/24 | |
90 | 192.168.0.0/255.255.0.255 | |
91 | 192.168.0.0/255.0.0.0 => error("Value contains unmasked 1-bits.") | |
92 | 192.168.0.0/32 | |
93 | 192.168.0.0/255.255.255.255 => 192.168.0.0/32 | |
52c0fc39 | 94 | 1.2.3.4:5 => 1.2.3.4 : 5 |
10b1662b BP |
95 | |
96 | :: | |
97 | ::1 | |
98 | ff00::1234 => ff00::1234 | |
99 | 2001:db8:85a3::8a2e:370:7334 | |
100 | 2001:db8:85a3:0:0:8a2e:370:7334 => 2001:db8:85a3::8a2e:370:7334 | |
101 | 2001:0db8:85a3:0000:0000:8a2e:0370:7334 => 2001:db8:85a3::8a2e:370:7334 | |
102 | ::ffff:192.0.2.128 | |
103 | ::ffff:c000:0280 => ::ffff:192.0.2.128 | |
104 | ::1/::1 | |
105 | ::1/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff => ::1/128 | |
106 | ::1/128 | |
107 | ff00::/8 | |
108 | ff00::/ff00:: => ff00::/8 | |
109 | ||
110 | 01:23:45:67:ab:cd | |
111 | 01:23:45:67:AB:CD => 01:23:45:67:ab:cd | |
112 | fe:dc:ba:98:76:54 | |
113 | FE:DC:ba:98:76:54 => fe:dc:ba:98:76:54 | |
114 | 01:00:00:00:00:00/01:00:00:00:00:00 | |
115 | ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff | |
116 | fe:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff | |
117 | ff:ff:ff:ff:ff:ff/fe:ff:ff:ff:ff:ff => error("Value contains unmasked 1-bits.") | |
118 | fe:x => error("Invalid numeric constant.") | |
119 | 00:01:02:03:04:x => error("Invalid numeric constant.") | |
120 | ||
a20c96c6 | 121 | # Test that operators are tokenized as expected, even without white space. |
52c0fc39 | 122 | (){}[[]]==!=<<=>>=!&&||..,;=<->--: => ( ) { } [[ ]] == != < <= > >= ! && || .. , ; = <-> -- : |
10b1662b BP |
123 | & => error("`&' is only valid as part of `&&'.") |
124 | | => error("`|' is only valid as part of `||'.") | |
56091efe | 125 | - => error("`-' is only valid as part of `--'.") |
10b1662b BP |
126 | |
127 | ^ => error("Invalid character `^' in input.") | |
128 | ]) | |
129 | AT_CAPTURE_FILE([input.txt]) | |
130 | sed 's/ =>.*//' test-cases.txt > input.txt | |
131 | sed 's/.* => //' test-cases.txt > expout | |
132 | AT_CHECK([ovstest test-ovn lex < input.txt], [0], [expout]) | |
133 | AT_CLEANUP | |
e0840f11 | 134 | |
7700eea0 BP |
135 | dnl The OVN expression parser needs to know what fields overlap with one |
136 | dnl another. This test therefore verifies that all the smaller registers | |
137 | dnl are defined as terms of subfields of the larger ones. | |
138 | dnl | |
139 | dnl When we add or remove registers this test needs to be updated, of course. | |
140 | AT_SETUP([ovn -- registers]) | |
141 | AT_CHECK([ovstest test-ovn dump-symtab | grep reg | sort], [0], | |
142 | [[reg0 = xxreg0[96..127] | |
143 | reg1 = xxreg0[64..95] | |
144 | reg2 = xxreg0[32..63] | |
145 | reg3 = xxreg0[0..31] | |
146 | reg4 = xxreg1[96..127] | |
147 | reg5 = xxreg1[64..95] | |
148 | reg6 = xxreg1[32..63] | |
149 | reg7 = xxreg1[0..31] | |
150 | reg8 = xreg4[32..63] | |
151 | reg9 = xreg4[0..31] | |
152 | xreg0 = xxreg0[64..127] | |
153 | xreg1 = xxreg0[0..63] | |
154 | xreg2 = xxreg1[64..127] | |
155 | xreg3 = xxreg1[0..63] | |
156 | xreg4 = OXM_OF_PKT_REG4 | |
157 | xxreg0 = NXM_NX_XXREG0 | |
158 | xxreg1 = NXM_NX_XXREG1 | |
159 | ]]) | |
160 | AT_CLEANUP | |
161 | ||
2277b860 BP |
162 | dnl Check that the OVN conntrack field definitions are correct. |
163 | AT_SETUP([ovn -- conntrack fields]) | |
164 | AT_CHECK([ovstest test-ovn dump-symtab | grep ^ct | sort], [0], | |
858c2f76 GS |
165 | [[ct.dnat = ct_state[7] |
166 | ct.est = ct_state[1] | |
2277b860 BP |
167 | ct.inv = ct_state[4] |
168 | ct.new = ct_state[0] | |
169 | ct.rel = ct_state[2] | |
170 | ct.rpl = ct_state[3] | |
858c2f76 | 171 | ct.snat = ct_state[6] |
2277b860 BP |
172 | ct.trk = ct_state[5] |
173 | ct_label = NXM_NX_CT_LABEL | |
b73db61d | 174 | ct_label.blocked = ct_label[0] |
2277b860 BP |
175 | ct_mark = NXM_NX_CT_MARK |
176 | ct_state = NXM_NX_CT_STATE | |
177 | ]]) | |
178 | AT_CLEANUP | |
179 | ||
42d36b58 AZ |
180 | AT_SETUP([ovn -- compsition]) |
181 | AT_CHECK([ovstest test-ovn composition 2], [0], [ignore]) | |
182 | AT_CLEANUP | |
183 | ||
e0840f11 BP |
184 | AT_SETUP([ovn -- expression parser]) |
185 | dnl For lines without =>, input and expected output are identical. | |
186 | dnl For lines with =>, input precedes => and expected output follows =>. | |
187 | AT_DATA([test-cases.txt], [[ | |
188 | eth.type == 0x800 | |
189 | eth.type==0x800 => eth.type == 0x800 | |
190 | eth.type[0..15] == 0x800 => eth.type == 0x800 | |
191 | ||
192 | vlan.present | |
193 | vlan.present == 1 => vlan.present | |
194 | !(vlan.present == 0) => vlan.present | |
195 | !(vlan.present != 1) => vlan.present | |
196 | !vlan.present | |
197 | vlan.present == 0 => !vlan.present | |
198 | vlan.present != 1 => !vlan.present | |
199 | !(vlan.present == 1) => !vlan.present | |
200 | !(vlan.present != 0) => !vlan.present | |
201 | ||
202 | eth.dst[0] | |
203 | eth.dst[0] == 1 => eth.dst[0] | |
204 | eth.dst[0] != 0 => eth.dst[0] | |
205 | !(eth.dst[0] == 0) => eth.dst[0] | |
206 | !(eth.dst[0] != 1) => eth.dst[0] | |
207 | ||
208 | !eth.dst[0] | |
209 | eth.dst[0] == 0 => !eth.dst[0] | |
210 | eth.dst[0] != 1 => !eth.dst[0] | |
211 | !(eth.dst[0] == 1) => !eth.dst[0] | |
212 | !(eth.dst[0] != 0) => !eth.dst[0] | |
213 | ||
214 | vlan.tci[12..15] == 0x3 | |
215 | vlan.tci == 0x3000/0xf000 => vlan.tci[12..15] == 0x3 | |
216 | vlan.tci[12..15] != 0x3 | |
217 | vlan.tci != 0x3000/0xf000 => vlan.tci[12..15] != 0x3 | |
218 | ||
219 | !vlan.pcp => vlan.pcp == 0 | |
220 | !(vlan.pcp) => vlan.pcp == 0 | |
221 | vlan.pcp == 0x4 | |
222 | vlan.pcp != 0x4 | |
223 | vlan.pcp > 0x4 | |
224 | vlan.pcp >= 0x4 | |
225 | vlan.pcp < 0x4 | |
226 | vlan.pcp <= 0x4 | |
227 | !(vlan.pcp != 0x4) => vlan.pcp == 0x4 | |
228 | !(vlan.pcp == 0x4) => vlan.pcp != 0x4 | |
229 | !(vlan.pcp <= 0x4) => vlan.pcp > 0x4 | |
230 | !(vlan.pcp < 0x4) => vlan.pcp >= 0x4 | |
231 | !(vlan.pcp >= 0x4) => vlan.pcp < 0x4 | |
232 | !(vlan.pcp > 0x4) => vlan.pcp <= 0x4 | |
233 | 0x4 == vlan.pcp => vlan.pcp == 0x4 | |
234 | 0x4 != vlan.pcp => vlan.pcp != 0x4 | |
235 | 0x4 < vlan.pcp => vlan.pcp > 0x4 | |
236 | 0x4 <= vlan.pcp => vlan.pcp >= 0x4 | |
237 | 0x4 > vlan.pcp => vlan.pcp < 0x4 | |
238 | 0x4 >= vlan.pcp => vlan.pcp <= 0x4 | |
239 | !(0x4 != vlan.pcp) => vlan.pcp == 0x4 | |
240 | !(0x4 == vlan.pcp) => vlan.pcp != 0x4 | |
241 | !(0x4 >= vlan.pcp) => vlan.pcp > 0x4 | |
242 | !(0x4 > vlan.pcp) => vlan.pcp >= 0x4 | |
243 | !(0x4 <= vlan.pcp) => vlan.pcp < 0x4 | |
244 | !(0x4 < vlan.pcp) => vlan.pcp <= 0x4 | |
245 | ||
246 | 1 < vlan.pcp < 4 => vlan.pcp > 0x1 && vlan.pcp < 0x4 | |
247 | 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4 | |
248 | 1 < vlan.pcp <= 4 => vlan.pcp > 0x1 && vlan.pcp <= 0x4 | |
249 | 1 <= vlan.pcp < 4 => vlan.pcp >= 0x1 && vlan.pcp < 0x4 | |
250 | 1 <= vlan.pcp <= 4 => vlan.pcp >= 0x1 && vlan.pcp <= 0x4 | |
251 | 4 > vlan.pcp > 1 => vlan.pcp < 0x4 && vlan.pcp > 0x1 | |
252 | 4 >= vlan.pcp > 1 => vlan.pcp <= 0x4 && vlan.pcp > 0x1 | |
253 | 4 > vlan.pcp >= 1 => vlan.pcp < 0x4 && vlan.pcp >= 0x1 | |
254 | 4 >= vlan.pcp >= 1 => vlan.pcp <= 0x4 && vlan.pcp >= 0x1 | |
255 | !(1 < vlan.pcp < 4) => vlan.pcp <= 0x1 || vlan.pcp >= 0x4 | |
256 | !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4 | |
257 | !(1 < vlan.pcp <= 4) => vlan.pcp <= 0x1 || vlan.pcp > 0x4 | |
258 | !(1 <= vlan.pcp < 4) => vlan.pcp < 0x1 || vlan.pcp >= 0x4 | |
259 | !(1 <= vlan.pcp <= 4) => vlan.pcp < 0x1 || vlan.pcp > 0x4 | |
260 | !(4 > vlan.pcp > 1) => vlan.pcp >= 0x4 || vlan.pcp <= 0x1 | |
261 | !(4 >= vlan.pcp > 1) => vlan.pcp > 0x4 || vlan.pcp <= 0x1 | |
262 | !(4 > vlan.pcp >= 1) => vlan.pcp >= 0x4 || vlan.pcp < 0x1 | |
263 | !(4 >= vlan.pcp >= 1) => vlan.pcp > 0x4 || vlan.pcp < 0x1 | |
264 | ||
265 | vlan.pcp == {1, 2, 3, 4} => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4 | |
266 | vlan.pcp == 1 || ((vlan.pcp == 2 || vlan.pcp == 3) || vlan.pcp == 4) => vlan.pcp == 0x1 || vlan.pcp == 0x2 || vlan.pcp == 0x3 || vlan.pcp == 0x4 | |
267 | ||
268 | vlan.pcp != {1, 2, 3, 4} => vlan.pcp != 0x1 && vlan.pcp != 0x2 && vlan.pcp != 0x3 && vlan.pcp != 0x4 | |
269 | vlan.pcp == 1 && ((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && vlan.pcp == 0x2 && vlan.pcp == 0x3 && vlan.pcp == 0x4 | |
270 | ||
271 | vlan.pcp == 1 && !((vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3 || vlan.pcp != 0x4) | |
272 | vlan.pcp == 1 && (!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && (vlan.pcp != 0x2 || vlan.pcp != 0x3) && vlan.pcp == 0x4 | |
273 | vlan.pcp == 1 && !(!(vlan.pcp == 2 && vlan.pcp == 3) && vlan.pcp == 4) => vlan.pcp == 0x1 && ((vlan.pcp == 0x2 && vlan.pcp == 0x3) || vlan.pcp != 0x4) | |
274 | ||
275 | ip4.src == {10.0.0.0/8, 192.168.0.0/16, 172.16.20.0/24, 8.8.8.8} => ip4.src[24..31] == 0xa || ip4.src[16..31] == 0xc0a8 || ip4.src[8..31] == 0xac1014 || ip4.src == 0x8080808 | |
276 | ip6.src == ::1 => ip6.src == 0x1 | |
277 | ||
278 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 | |
279 | ip4.src == ::1.2.3.4/::ffff:ffff => ip4.src == 0x1020304 | |
280 | ip6.src == ::1 => ip6.src == 0x1 | |
281 | ||
282 | 1 | |
283 | 0 | |
284 | !1 => 0 | |
285 | !0 => 1 | |
286 | ||
287 | inport == "eth0" | |
288 | !(inport != "eth0") => inport == "eth0" | |
289 | ||
3b7cb7e1 BP |
290 | ip4.src == "eth0" => Integer field ip4.src is not compatible with string constant. |
291 | inport == 1 => String field inport is not compatible with integer constant. | |
76da94b5 | 292 | ip4.src = 1.2.3.4 => Syntax error at `=' expecting relational operator. |
e0840f11 BP |
293 | |
294 | ip4.src > {1, 2, 3} => Only == and != operators may be used with value sets. | |
295 | eth.type > 0x800 => Only == and != operators may be used with nominal field eth.type. | |
296 | vlan.present > 0 => Only == and != operators may be used with Boolean field vlan.present. | |
297 | ||
298 | inport != "eth0" => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account). | |
299 | !(inport == "eth0") => Nominal field inport may only be tested for equality (taking enclosing `!' operators into account). | |
300 | eth.type != 0x800 => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account). | |
301 | !(eth.type == 0x800) => Nominal field eth.type may only be tested for equality (taking enclosing `!' operators into account). | |
76da94b5 | 302 | inport = "eth0" => Syntax error at `=' expecting relational operator. |
e0840f11 BP |
303 | |
304 | 123 == 123 => Syntax error at `123' expecting field name. | |
305 | ||
2c5cbb15 RB |
306 | $name => Syntax error at `$name' expecting address set name. |
307 | ||
e0840f11 BP |
308 | 123 == xyzzy => Syntax error at `xyzzy' expecting field name. |
309 | xyzzy == 1 => Syntax error at `xyzzy' expecting field name. | |
310 | ||
311 | inport[1] == 1 => Cannot select subfield of string field inport. | |
312 | ||
313 | eth.type[] == 1 => Syntax error at `@:>@' expecting small integer. | |
314 | eth.type[::1] == 1 => Syntax error at `::1' expecting small integer. | |
315 | eth.type[18446744073709551615] == 1 => Syntax error at `18446744073709551615' expecting small integer. | |
316 | ||
317 | eth.type[5!] => Syntax error at `!' expecting `@:>@'. | |
318 | ||
319 | eth.type[5..1] => Invalid bit range 5 to 1. | |
320 | ||
321 | eth.type[12..16] => Cannot select bits 12 to 16 of 16-bit field eth.type. | |
322 | ||
323 | eth.type[10] == 1 => Cannot select subfield of nominal field eth.type. | |
324 | ||
325 | eth.type => Explicit `!= 0' is required for inequality test of multibit field against 0. | |
326 | ||
327 | !(!(vlan.pcp)) => Explicit `!= 0' is required for inequality test of multibit field against 0. | |
328 | ||
329 | 123 => Syntax error at end of input expecting relational operator. | |
330 | ||
331 | 123 x => Syntax error at `x' expecting relational operator. | |
332 | ||
333 | {1, "eth0"} => Syntax error at `"eth0"' expecting integer. | |
334 | ||
335 | eth.type == xyzzy => Syntax error at `xyzzy' expecting constant. | |
336 | ||
337 | (1 x) => Syntax error at `x' expecting `)'. | |
338 | ||
339 | !0x800 != eth.type => Missing parentheses around operand of !. | |
340 | ||
341 | eth.type == 0x800 || eth.type == 0x86dd && ip.proto == 17 => && and || must be parenthesized when used together. | |
342 | ||
343 | eth.dst == {} => Syntax error at `}' expecting constant. | |
344 | ||
345 | eth.src > 00:00:00:00:11:11/00:00:00:00:ff:ff => Only == and != operators may be used with masked constants. Consider using subfields instead (e.g. eth.src[0..15] > 0x1111 in place of eth.src > 00:00:00:00:11:11/00:00:00:00:ff:ff). | |
346 | ||
3b7cb7e1 | 347 | ip4.src == ::1 => 128-bit constant is not compatible with 32-bit field ip4.src. |
e0840f11 BP |
348 | |
349 | 1 == eth.type == 2 => Range expressions must have the form `x < field < y' or `x > field > y', with each `<' optionally replaced by `<=' or `>' by `>='). | |
8b34ccda | 350 | |
9aef3c1b | 351 | eth.dst[40] x => Syntax error at `x' expecting end of input. |
ea382567 RB |
352 | |
353 | ip4.src == {1.2.3.4, $set1, $unknownset} => Syntax error at `$unknownset' expecting address set name. | |
354 | eth.src == {$set3, badmac, 00:00:00:00:00:01} => Syntax error at `badmac' expecting constant. | |
e0840f11 BP |
355 | ]]) |
356 | sed 's/ =>.*//' test-cases.txt > input.txt | |
357 | sed 's/.* => //' test-cases.txt > expout | |
358 | AT_CHECK([ovstest test-ovn parse-expr < input.txt], [0], [expout]) | |
359 | AT_CLEANUP | |
360 | ||
361 | AT_SETUP([ovn -- expression annotation]) | |
362 | dnl Input precedes =>, expected output follows =>. | |
363 | AT_DATA([test-cases.txt], [[ | |
364 | ip4.src == 1.2.3.4 => ip4.src == 0x1020304 && eth.type == 0x800 | |
365 | ip4.src != 1.2.3.4 => ip4.src != 0x1020304 && eth.type == 0x800 | |
366 | ip.proto == 123 => ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd) | |
367 | ip.proto == {123, 234} => (ip.proto == 0x7b && (eth.type == 0x800 || eth.type == 0x86dd)) || (ip.proto == 0xea && (eth.type == 0x800 || eth.type == 0x86dd)) | |
368 | ip4.src == 1.2.3.4 && ip4.dst == 5.6.7.8 => ip4.src == 0x1020304 && eth.type == 0x800 && ip4.dst == 0x5060708 && eth.type == 0x800 | |
369 | ||
370 | ip => eth.type == 0x800 || eth.type == 0x86dd | |
371 | ip == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
372 | ip[0] == 1 => eth.type == 0x800 || eth.type == 0x86dd | |
373 | ip > 0 => Only == and != operators may be used with nominal field ip. | |
374 | !ip => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
375 | ip == 0 => Nominal predicate ip may only be tested positively, e.g. `ip' or `ip == 1' but not `!ip' or `ip == 0'. | |
376 | ||
377 | vlan.present => vlan.tci[12] | |
378 | !vlan.present => !vlan.tci[12] | |
379 | ||
380 | !vlan.pcp => vlan.tci[13..15] == 0 && vlan.tci[12] | |
381 | vlan.pcp == 1 && vlan.vid == 2 => vlan.tci[13..15] == 0x1 && vlan.tci[12] && vlan.tci[0..11] == 0x2 && vlan.tci[12] | |
7700eea0 | 382 | !reg0 && !reg1 && !reg2 && !reg3 => xxreg0[96..127] == 0 && xxreg0[64..95] == 0 && xxreg0[32..63] == 0 && xxreg0[0..31] == 0 |
e0840f11 BP |
383 | |
384 | ip.first_frag => ip.frag[0] && (eth.type == 0x800 || eth.type == 0x86dd) && (!ip.frag[1] || (eth.type != 0x800 && eth.type != 0x86dd)) | |
385 | !ip.first_frag => !ip.frag[0] || (eth.type != 0x800 && eth.type != 0x86dd) || (ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd)) | |
386 | ip.later_frag => ip.frag[1] && (eth.type == 0x800 || eth.type == 0x86dd) | |
387 | ||
388 | bad_prereq != 0 => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
389 | self_recurse != 0 => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'. | |
390 | mutual_recurse_1 != 0 => Error parsing expression `mutual_recurse_2 != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `mutual_recurse_1 != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `mutual_recurse_1'. | |
391 | mutual_recurse_2 != 0 => Error parsing expression `mutual_recurse_1 != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `mutual_recurse_2 != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `mutual_recurse_2'. | |
392 | ]]) | |
393 | sed 's/ =>.*//' test-cases.txt > input.txt | |
394 | sed 's/.* => //' test-cases.txt > expout | |
395 | AT_CHECK([ovstest test-ovn annotate-expr < input.txt], [0], [expout]) | |
396 | AT_CLEANUP | |
397 | ||
9d4aecca | 398 | AT_SETUP([ovn -- 1-term expression conversion]) |
e0840f11 | 399 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert 1], [0], |
9d4aecca | 400 | [Tested converting all 1-terminal expressions with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
401 | ]) |
402 | AT_CLEANUP | |
403 | ||
9d4aecca | 404 | AT_SETUP([ovn -- 2-term expression conversion]) |
e0840f11 | 405 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert 2], [0], |
8c3caa2c | 406 | [Tested converting 578 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
407 | ]) |
408 | AT_CLEANUP | |
409 | ||
9d4aecca | 410 | AT_SETUP([ovn -- 3-term expression conversion]) |
e0840f11 | 411 | AT_CHECK([ovstest test-ovn exhaustive --operation=convert --bits=2 3], [0], |
8c3caa2c | 412 | [Tested converting 67410 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars. |
e0840f11 BP |
413 | ]) |
414 | AT_CLEANUP | |
415 | ||
9d4aecca BP |
416 | AT_SETUP([ovn -- 3-term numeric expression simplification]) |
417 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=2 --svars=0 3], [0], | |
8c3caa2c | 418 | [Tested simplifying 490770 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=. |
e0840f11 BP |
419 | ]) |
420 | AT_CLEANUP | |
421 | ||
9d4aecca BP |
422 | AT_SETUP([ovn -- 4-term string expression simplification]) |
423 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=0 --svars=4 4], [0], | |
424 | [Tested simplifying 21978 expressions of 4 terminals with 4 string vars. | |
e0840f11 BP |
425 | ]) |
426 | AT_CLEANUP | |
427 | ||
9d4aecca BP |
428 | AT_SETUP([ovn -- 3-term mixed expression simplification]) |
429 | AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=1 --svars=1 3], [0], | |
8c3caa2c | 430 | [Tested simplifying 127890 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars. |
e0840f11 BP |
431 | ]) |
432 | AT_CLEANUP | |
433 | ||
97ba1d55 BP |
434 | AT_SETUP([ovn -- simplification special cases]) |
435 | simplify() { | |
436 | echo "$1" | ovstest test-ovn simplify-expr | |
437 | } | |
438 | AT_CHECK([simplify 'eth.dst == 0/0'], [0], [1 | |
439 | ]) | |
a3d79068 BP |
440 | AT_CHECK([simplify 'eth.dst != 0/0'], [0], [0 |
441 | ]) | |
33f15d17 BP |
442 | AT_CHECK([simplify 'tcp.dst >= 0'], [0], |
443 | [ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
444 | ]) | |
445 | AT_CHECK([simplify 'tcp.dst <= 65535'], [0], | |
446 | [ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
447 | ]) | |
448 | AT_CHECK([simplify 'tcp.dst > 0'], [0], | |
449 | [[(tcp.dst[0] || tcp.dst[1] || tcp.dst[2] || tcp.dst[3] || tcp.dst[4] || tcp.dst[5] || tcp.dst[6] || tcp.dst[7] || tcp.dst[8] || tcp.dst[9] || tcp.dst[10] || tcp.dst[11] || tcp.dst[12] || tcp.dst[13] || tcp.dst[14] || tcp.dst[15]) && ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
450 | ]]) | |
451 | AT_CHECK([simplify 'tcp.dst < 65535'], [0], | |
452 | [[(!tcp.dst[0] || !tcp.dst[1] || !tcp.dst[2] || !tcp.dst[3] || !tcp.dst[4] || !tcp.dst[5] || !tcp.dst[6] || !tcp.dst[7] || !tcp.dst[8] || !tcp.dst[9] || !tcp.dst[10] || !tcp.dst[11] || !tcp.dst[12] || !tcp.dst[13] || !tcp.dst[14] || !tcp.dst[15]) && ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
453 | ]]) | |
97ba1d55 BP |
454 | AT_CLEANUP |
455 | ||
ba8d3816 MS |
456 | AT_SETUP([ovn -- is_chassis_resident simplification]) |
457 | simplify() { | |
458 | echo "$1" | ovstest test-ovn simplify-expr | |
459 | } | |
460 | AT_CHECK([simplify 'is_chassis_resident("eth1")'], [0], [1 | |
461 | ]) | |
462 | AT_CHECK([simplify 'is_chassis_resident("eth2")'], [0], [0 | |
463 | ]) | |
464 | AT_CHECK([simplify '!is_chassis_resident("eth1")'], [0], [0 | |
465 | ]) | |
466 | AT_CHECK([simplify '!is_chassis_resident("eth2")'], [0], [1 | |
467 | ]) | |
468 | AT_CLEANUP | |
469 | ||
9d4aecca BP |
470 | AT_SETUP([ovn -- 4-term numeric expression normalization]) |
471 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 4], [0], | |
8c3caa2c | 472 | [Tested normalizing 1874026 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=. |
e0840f11 BP |
473 | ]) |
474 | AT_CLEANUP | |
475 | ||
9d4aecca BP |
476 | AT_SETUP([ovn -- 4-term string expression normalization]) |
477 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 4], [0], | |
478 | [Tested normalizing 11242 expressions of 4 terminals with 3 string vars. | |
479 | ]) | |
480 | AT_CLEANUP | |
481 | ||
482 | AT_SETUP([ovn -- 4-term mixed expression normalization]) | |
483 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --bits=1 --svars=2 4], [0], | |
8c3caa2c | 484 | [Tested normalizing 175978 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars. |
9d4aecca BP |
485 | ]) |
486 | AT_CLEANUP | |
487 | ||
488 | AT_SETUP([ovn -- 5-term numeric expression normalization]) | |
489 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 --relops='==' 5], [0], | |
8c3caa2c | 490 | [Tested normalizing 1317600 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==. |
9d4aecca BP |
491 | ]) |
492 | AT_CLEANUP | |
493 | ||
494 | AT_SETUP([ovn -- 5-term string expression normalization]) | |
495 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=0 --svars=3 --bits=1 --relops='==' 5], [0], | |
496 | [Tested normalizing 368550 expressions of 5 terminals with 3 string vars. | |
497 | ]) | |
498 | AT_CLEANUP | |
499 | ||
500 | AT_SETUP([ovn -- 5-term mixed expression normalization]) | |
501 | AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --svars=1 --bits=1 --relops='==' 5], [0], | |
8c3caa2c | 502 | [Tested normalizing 216000 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars. |
9d4aecca BP |
503 | ]) |
504 | AT_CLEANUP | |
505 | ||
506 | AT_SETUP([ovn -- 4-term numeric expressions to flows]) | |
8c3caa2c | 507 | AT_KEYWORDS([expression]) |
9d4aecca | 508 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=2 --svars=0 --bits=2 --relops='==' 4], [0], |
8c3caa2c | 509 | [Tested converting to flows 175978 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==. |
9d4aecca BP |
510 | ]) |
511 | AT_CLEANUP | |
512 | ||
513 | AT_SETUP([ovn -- 4-term string expressions to flows]) | |
8c3caa2c | 514 | AT_KEYWORDS([expression]) |
9d4aecca BP |
515 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=0 --svars=4 4], [0], |
516 | [Tested converting to flows 21978 expressions of 4 terminals with 4 string vars. | |
517 | ]) | |
518 | AT_CLEANUP | |
519 | ||
520 | AT_SETUP([ovn -- 4-term mixed expressions to flows]) | |
8c3caa2c | 521 | AT_KEYWORDS([expression]) |
9d4aecca | 522 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=1 --bits=2 --svars=1 --relops='==' 4], [0], |
8c3caa2c | 523 | [Tested converting to flows 48312 expressions of 4 terminals with 1 numeric vars (each 2 bits) in terms of operators == and 1 string vars. |
9d4aecca BP |
524 | ]) |
525 | AT_CLEANUP | |
526 | ||
527 | AT_SETUP([ovn -- 3-term numeric expressions to flows]) | |
8c3caa2c | 528 | AT_KEYWORDS([expression]) |
9d4aecca | 529 | AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=3 --svars=0 --bits=3 --relops='==' 3], [0], |
8c3caa2c | 530 | [Tested converting to flows 41328 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==. |
e0840f11 BP |
531 | ]) |
532 | AT_CLEANUP | |
f386a8a7 BP |
533 | |
534 | AT_SETUP([ovn -- converting expressions to flows -- string fields]) | |
8c3caa2c | 535 | AT_KEYWORDS([expression]) |
f386a8a7 BP |
536 | expr_to_flow () { |
537 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
538 | } | |
cc5e28d8 | 539 | AT_CHECK([expr_to_flow 'inport == "eth0"'], [0], [reg14=0x5 |
f386a8a7 | 540 | ]) |
cc5e28d8 | 541 | AT_CHECK([expr_to_flow 'inport == "eth1"'], [0], [reg14=0x6 |
f386a8a7 BP |
542 | ]) |
543 | AT_CHECK([expr_to_flow 'inport == "eth2"'], [0], [(no flows) | |
544 | ]) | |
545 | AT_CHECK([expr_to_flow 'inport == "eth0" && ip'], [0], [dnl | |
cc5e28d8 JP |
546 | ip,reg14=0x5 |
547 | ipv6,reg14=0x5 | |
f386a8a7 BP |
548 | ]) |
549 | AT_CHECK([expr_to_flow 'inport == "eth1" && ip'], [0], [dnl | |
cc5e28d8 JP |
550 | ip,reg14=0x6 |
551 | ipv6,reg14=0x6 | |
f386a8a7 BP |
552 | ]) |
553 | AT_CHECK([expr_to_flow 'inport == "eth2" && ip'], [0], [(no flows) | |
554 | ]) | |
555 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2", "LOCAL"}'], [0], | |
cc5e28d8 JP |
556 | [reg14=0x5 |
557 | reg14=0x6 | |
558 | reg14=0xfffe | |
f386a8a7 BP |
559 | ]) |
560 | AT_CHECK([expr_to_flow 'inport == {"eth0", "eth1", "eth2"} && ip'], [0], [dnl | |
cc5e28d8 JP |
561 | ip,reg14=0x5 |
562 | ip,reg14=0x6 | |
563 | ipv6,reg14=0x5 | |
564 | ipv6,reg14=0x6 | |
f386a8a7 | 565 | ]) |
9d4aecca BP |
566 | AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl |
567 | (no flows) | |
568 | ]) | |
f386a8a7 | 569 | AT_CLEANUP |
3b7cb7e1 | 570 | |
2c5cbb15 | 571 | AT_SETUP([ovn -- converting expressions to flows -- address sets]) |
8c3caa2c | 572 | AT_KEYWORDS([expression]) |
2c5cbb15 RB |
573 | expr_to_flow () { |
574 | echo "$1" | ovstest test-ovn expr-to-flows | sort | |
575 | } | |
576 | AT_CHECK([expr_to_flow 'ip4.src == {10.0.0.1, 10.0.0.2, 10.0.0.3}'], [0], [dnl | |
577 | ip,nw_src=10.0.0.1 | |
578 | ip,nw_src=10.0.0.2 | |
579 | ip,nw_src=10.0.0.3 | |
580 | ]) | |
581 | AT_CHECK([expr_to_flow 'ip4.src == $set1'], [0], [dnl | |
582 | ip,nw_src=10.0.0.1 | |
583 | ip,nw_src=10.0.0.2 | |
584 | ip,nw_src=10.0.0.3 | |
585 | ]) | |
586 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.3.4, $set1}'], [0], [dnl | |
587 | ip,nw_src=1.2.3.4 | |
588 | ip,nw_src=10.0.0.1 | |
589 | ip,nw_src=10.0.0.2 | |
590 | ip,nw_src=10.0.0.3 | |
591 | ]) | |
592 | AT_CHECK([expr_to_flow 'ip4.src == {1.2.0.0/20, 5.5.5.0/24, $set1}'], [0], [dnl | |
593 | ip,nw_src=1.2.0.0/20 | |
594 | ip,nw_src=10.0.0.1 | |
595 | ip,nw_src=10.0.0.2 | |
596 | ip,nw_src=10.0.0.3 | |
597 | ip,nw_src=5.5.5.0/24 | |
598 | ]) | |
599 | AT_CHECK([expr_to_flow 'ip6.src == {::1, ::2, ::3}'], [0], [dnl | |
600 | ipv6,ipv6_src=::1 | |
601 | ipv6,ipv6_src=::2 | |
602 | ipv6,ipv6_src=::3 | |
603 | ]) | |
604 | AT_CHECK([expr_to_flow 'ip6.src == {::1, $set2, ::4}'], [0], [dnl | |
605 | ipv6,ipv6_src=::1 | |
606 | ipv6,ipv6_src=::2 | |
607 | ipv6,ipv6_src=::3 | |
608 | ipv6,ipv6_src=::4 | |
609 | ]) | |
610 | AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, 00:00:00:00:00:02, 00:00:00:00:00:03}'], [0], [dnl | |
611 | dl_src=00:00:00:00:00:01 | |
612 | dl_src=00:00:00:00:00:02 | |
613 | dl_src=00:00:00:00:00:03 | |
614 | ]) | |
615 | AT_CHECK([expr_to_flow 'eth.src == {$set3}'], [0], [dnl | |
616 | dl_src=00:00:00:00:00:01 | |
617 | dl_src=00:00:00:00:00:02 | |
618 | dl_src=00:00:00:00:00:03 | |
619 | ]) | |
ea382567 RB |
620 | AT_CHECK([expr_to_flow 'eth.src == {00:00:00:00:00:01, $set3, ba:be:be:ef:de:ad, $set3}'], [0], [dnl |
621 | dl_src=00:00:00:00:00:01 | |
622 | dl_src=00:00:00:00:00:02 | |
623 | dl_src=00:00:00:00:00:03 | |
624 | dl_src=ba:be:be:ef:de:ad | |
625 | ]) | |
2c5cbb15 RB |
626 | AT_CLEANUP |
627 | ||
3b7cb7e1 | 628 | AT_SETUP([ovn -- action parsing]) |
d5a76da4 BP |
629 | dnl Unindented text is input (a set of OVN logical actions). |
630 | dnl Indented text is expected output. | |
631 | AT_DATA([test-cases.txt], | |
632 | [[# drop | |
633 | drop; | |
634 | encodes as drop | |
635 | drop; next; | |
636 | Syntax error at `next' expecting end of input. | |
637 | next; drop; | |
638 | Syntax error at `drop' expecting action. | |
5f822129 BP |
639 | |
640 | # output | |
d5a76da4 BP |
641 | output; |
642 | encodes as resubmit(,64) | |
5f822129 BP |
643 | |
644 | # next | |
d5a76da4 | 645 | next; |
d5a76da4 BP |
646 | encodes as resubmit(,27) |
647 | next(11); | |
8f5de083 | 648 | formats as next; |
d5a76da4 BP |
649 | encodes as resubmit(,27) |
650 | next(0); | |
651 | encodes as resubmit(,16) | |
652 | next(15); | |
653 | encodes as resubmit(,31) | |
654 | ||
655 | next(); | |
4c99cb18 | 656 | Syntax error at `)' expecting "pipeline" or "table". |
d5a76da4 BP |
657 | next(10; |
658 | Syntax error at `;' expecting `)'. | |
659 | next(16); | |
8f5de083 | 660 | "next" action cannot advance beyond table 15. |
5f822129 | 661 | |
4c99cb18 BP |
662 | next(table=11); |
663 | formats as next; | |
664 | encodes as resubmit(,27) | |
665 | next(pipeline=ingress); | |
666 | formats as next; | |
667 | encodes as resubmit(,27) | |
668 | next(table=11, pipeline=ingress); | |
669 | formats as next; | |
670 | encodes as resubmit(,27) | |
671 | next(pipeline=ingress, table=11); | |
672 | formats as next; | |
673 | encodes as resubmit(,27) | |
674 | ||
675 | next(pipeline=egress); | |
676 | "next" action cannot advance from ingress to egress pipeline (use "output" action instead) | |
677 | ||
678 | next(table=10); | |
679 | formats as next(10); | |
680 | encodes as resubmit(,26) | |
681 | ||
5f822129 | 682 | # Loading a constant value. |
d5a76da4 BP |
683 | tcp.dst=80; |
684 | formats as tcp.dst = 80; | |
685 | encodes as set_field:80->tcp_dst | |
686 | has prereqs ip.proto == 0x6 && (eth.type == 0x800 || eth.type == 0x86dd) | |
687 | eth.dst[40] = 1; | |
688 | encodes as set_field:01:00:00:00:00:00/01:00:00:00:00:00->eth_dst | |
689 | vlan.pcp = 2; | |
690 | encodes as set_field:0x4000/0xe000->vlan_tci | |
691 | has prereqs vlan.tci[12] | |
692 | vlan.tci[13..15] = 2; | |
693 | encodes as set_field:0x4000/0xe000->vlan_tci | |
694 | inport = ""; | |
695 | encodes as set_field:0->reg14 | |
696 | ip.ttl=4; | |
697 | formats as ip.ttl = 4; | |
698 | encodes as set_field:4->nw_ttl | |
699 | has prereqs eth.type == 0x800 || eth.type == 0x86dd | |
700 | outport="eth0"; next; outport="LOCAL"; next; | |
8f5de083 | 701 | formats as outport = "eth0"; next; outport = "LOCAL"; next; |
d5a76da4 BP |
702 | encodes as set_field:0x5->reg15,resubmit(,27),set_field:0xfffe->reg15,resubmit(,27) |
703 | ||
704 | inport[1] = 1; | |
705 | Cannot select subfield of string field inport. | |
706 | ip.proto[1] = 1; | |
707 | Cannot select subfield of nominal field ip.proto. | |
708 | eth.dst[40] == 1; | |
709 | Syntax error at `==' expecting `=' or `<->'. | |
710 | ip = 1; | |
711 | Predicate symbol ip used where lvalue required. | |
712 | ip.proto = 6; | |
713 | Field ip.proto is not modifiable. | |
714 | inport = {"a", "b"}; | |
715 | Syntax error at `{' expecting constant. | |
716 | inport = {}; | |
717 | Syntax error at `{' expecting constant. | |
718 | bad_prereq = 123; | |
719 | Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. | |
720 | self_recurse = 123; | |
721 | 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'. | |
722 | vlan.present = 0; | |
723 | Predicate symbol vlan.present used where lvalue required. | |
5f822129 BP |
724 | |
725 | # Moving one field into another. | |
d5a76da4 BP |
726 | reg0=reg1; |
727 | formats as reg0 = reg1; | |
728 | encodes as move:NXM_NX_XXREG0[64..95]->NXM_NX_XXREG0[96..127] | |
729 | vlan.pcp = reg0[0..2]; | |
730 | encodes as move:NXM_NX_XXREG0[96..98]->NXM_OF_VLAN_TCI[13..15] | |
731 | has prereqs vlan.tci[12] | |
732 | reg0[10] = vlan.pcp[1]; | |
733 | encodes as move:NXM_OF_VLAN_TCI[14]->NXM_NX_XXREG0[106] | |
734 | has prereqs vlan.tci[12] | |
735 | outport = inport; | |
736 | encodes as move:NXM_NX_REG14[]->NXM_NX_REG15[] | |
737 | ||
738 | reg0[0] = vlan.present; | |
739 | Predicate symbol vlan.present used where lvalue required. | |
740 | reg0 = reg1[0..10]; | |
741 | Can't assign 11-bit value to 32-bit destination. | |
742 | inport = reg0; | |
743 | Can't assign integer field (reg0) to string field (inport). | |
744 | inport = big_string; | |
745 | String fields inport and big_string are incompatible for assignment. | |
746 | ip.proto = reg0[0..7]; | |
747 | Field ip.proto is not modifiable. | |
5f822129 BP |
748 | |
749 | # Exchanging fields. | |
d5a76da4 BP |
750 | reg0 <-> reg1; |
751 | 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] | |
752 | vlan.pcp <-> reg0[0..2]; | |
753 | 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] | |
754 | has prereqs vlan.tci[12] | |
755 | reg0[10] <-> vlan.pcp[1]; | |
756 | encodes as push:NXM_OF_VLAN_TCI[14],push:NXM_NX_XXREG0[106],pop:NXM_OF_VLAN_TCI[14],pop:NXM_NX_XXREG0[106] | |
757 | has prereqs vlan.tci[12] | |
758 | outport <-> inport; | |
759 | encodes as push:NXM_NX_REG14[],push:NXM_NX_REG15[],pop:NXM_NX_REG14[],pop:NXM_NX_REG15[] | |
760 | ||
761 | reg0[0] <-> vlan.present; | |
762 | Predicate symbol vlan.present used where lvalue required. | |
763 | reg0 <-> reg1[0..10]; | |
764 | Can't exchange 32-bit field with 11-bit field. | |
765 | inport <-> reg0; | |
766 | Can't exchange string field (inport) with integer field (reg0). | |
767 | inport <-> big_string; | |
768 | String fields inport and big_string are incompatible for exchange. | |
769 | ip.proto <-> reg0[0..7]; | |
770 | Field ip.proto is not modifiable. | |
771 | reg0[0..7] <-> ip.proto; | |
772 | Field ip.proto is not modifiable. | |
5f822129 BP |
773 | |
774 | # TTL decrement. | |
d5a76da4 BP |
775 | ip.ttl--; |
776 | encodes as dec_ttl | |
777 | has prereqs ip | |
778 | ip.ttl | |
779 | Syntax error at end of input expecting `--'. | |
5f822129 | 780 | |
467085fd | 781 | # load balancing. |
d5a76da4 BP |
782 | ct_lb; |
783 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15],nat) | |
784 | has prereqs ip | |
785 | ct_lb(); | |
786 | formats as ct_lb; | |
787 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15],nat) | |
788 | has prereqs ip | |
789 | ct_lb(192.168.1.2:80, 192.168.1.3:80); | |
790 | encodes as group:1 | |
791 | has prereqs ip | |
792 | ct_lb(192.168.1.2, 192.168.1.3, ); | |
793 | formats as ct_lb(192.168.1.2, 192.168.1.3); | |
794 | encodes as group:2 | |
795 | has prereqs ip | |
796 | ||
797 | ct_lb(192.168.1.2:); | |
798 | Syntax error at `)' expecting port number. | |
799 | ct_lb(192.168.1.2:123456); | |
800 | Syntax error at `123456' expecting port number. | |
801 | ct_lb(foo); | |
802 | Syntax error at `foo' expecting IPv4 address. | |
803 | ||
804 | # ct_next | |
805 | ct_next; | |
806 | encodes as ct(table=27,zone=NXM_NX_REG13[0..15]) | |
807 | has prereqs ip | |
808 | ||
809 | # ct_commit | |
810 | ct_commit; | |
811 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
812 | has prereqs ip | |
813 | ct_commit(); | |
814 | formats as ct_commit; | |
815 | encodes as ct(commit,zone=NXM_NX_REG13[0..15]) | |
816 | has prereqs ip | |
817 | ct_commit(ct_mark=1); | |
818 | formats as ct_commit(ct_mark=0x1); | |
819 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark)) | |
820 | has prereqs ip | |
821 | ct_commit(ct_mark=1/1); | |
822 | formats as ct_commit(ct_mark=0x1/0x1); | |
823 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_mark)) | |
824 | has prereqs ip | |
825 | ct_commit(ct_label=1); | |
826 | formats as ct_commit(ct_label=0x1); | |
827 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_label)) | |
828 | has prereqs ip | |
829 | ct_commit(ct_label=1/1); | |
830 | formats as ct_commit(ct_label=0x1/0x1); | |
831 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1/0x1->ct_label)) | |
832 | has prereqs ip | |
833 | ct_commit(ct_mark=1, ct_label=2); | |
834 | formats as ct_commit(ct_mark=0x1, ct_label=0x2); | |
835 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1->ct_mark,set_field:0x2->ct_label)) | |
836 | has prereqs ip | |
837 | ||
838 | ct_commit(ct_label=0x01020304050607080910111213141516); | |
839 | formats as ct_commit(ct_label=0x1020304050607080910111213141516); | |
840 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1020304050607080910111213141516->ct_label)) | |
841 | has prereqs ip | |
842 | ct_commit(ct_label=0x181716151413121110090807060504030201); | |
843 | formats as ct_commit(ct_label=0x16151413121110090807060504030201); | |
844 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x16151413121110090807060504030201->ct_label)) | |
845 | has prereqs ip | |
846 | ct_commit(ct_label=0x1000000000000000000000000000000/0x1000000000000000000000000000000); | |
847 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0x1000000000000000000000000000000/0x1000000000000000000000000000000->ct_label)) | |
848 | has prereqs ip | |
849 | ct_commit(ct_label=18446744073709551615); | |
850 | formats as ct_commit(ct_label=0xffffffffffffffff); | |
851 | encodes as ct(commit,zone=NXM_NX_REG13[0..15],exec(set_field:0xffffffffffffffff->ct_label)) | |
852 | has prereqs ip | |
853 | ct_commit(ct_label=18446744073709551616); | |
854 | Decimal constants must be less than 2**64. | |
855 | ||
856 | # ct_dnat | |
857 | ct_dnat; | |
858 | encodes as ct(table=27,zone=NXM_NX_REG11[0..15],nat) | |
859 | has prereqs ip | |
860 | ct_dnat(192.168.1.2); | |
861 | encodes as ct(commit,table=27,zone=NXM_NX_REG11[0..15],nat(dst=192.168.1.2)) | |
862 | has prereqs ip | |
863 | ||
864 | ct_dnat(192.168.1.2, 192.168.1.3); | |
865 | Syntax error at `,' expecting `)'. | |
866 | ct_dnat(foo); | |
867 | Syntax error at `foo' expecting IPv4 address. | |
868 | ct_dnat(foo, bar); | |
869 | Syntax error at `foo' expecting IPv4 address. | |
870 | ct_dnat(); | |
871 | Syntax error at `)' expecting IPv4 address. | |
872 | ||
873 | # ct_snat | |
874 | ct_snat; | |
1b441300 | 875 | encodes as ct(table=27,zone=NXM_NX_REG12[0..15],nat) |
d5a76da4 BP |
876 | has prereqs ip |
877 | ct_snat(192.168.1.2); | |
878 | encodes as ct(commit,table=27,zone=NXM_NX_REG12[0..15],nat(src=192.168.1.2)) | |
879 | has prereqs ip | |
880 | ||
881 | ct_snat(192.168.1.2, 192.168.1.3); | |
882 | Syntax error at `,' expecting `)'. | |
883 | ct_snat(foo); | |
884 | Syntax error at `foo' expecting IPv4 address. | |
885 | ct_snat(foo, bar); | |
886 | Syntax error at `foo' expecting IPv4 address. | |
887 | ct_snat(); | |
888 | Syntax error at `)' expecting IPv4 address. | |
de297547 | 889 | |
db0e819b BP |
890 | # ct_clear |
891 | ct_clear; | |
892 | encodes as ct_clear | |
893 | ||
b3bd2c33 | 894 | # clone |
8f5de083 | 895 | clone { ip4.dst = 255.255.255.255; output; }; next; |
b3bd2c33 BP |
896 | encodes as clone(set_field:255.255.255.255->ip_dst,resubmit(,64)),resubmit(,27) |
897 | has prereqs eth.type == 0x800 | |
898 | ||
6335d074 | 899 | # arp |
8a41ad8e BP |
900 | arp { eth.dst = ff:ff:ff:ff:ff:ff; output; }; output; |
901 | encodes as controller(userdata=00.00.00.00.00.00.00.00.00.19.00.10.80.00.06.06.ff.ff.ff.ff.ff.ff.00.00.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.40.00.00.00),resubmit(,64) | |
d5a76da4 | 902 | has prereqs ip4 |
bac29564 BP |
903 | arp { }; |
904 | formats as arp { drop; }; | |
905 | encodes as controller(userdata=00.00.00.00.00.00.00.00) | |
906 | has prereqs ip4 | |
6335d074 | 907 | |
0bac7164 | 908 | # get_arp |
d5a76da4 BP |
909 | get_arp(outport, ip4.dst); |
910 | 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[] | |
911 | has prereqs eth.type == 0x800 | |
912 | get_arp(inport, reg0); | |
913 | 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[] | |
914 | ||
915 | get_arp; | |
916 | Syntax error at `;' expecting `('. | |
917 | get_arp(); | |
918 | Syntax error at `)' expecting field name. | |
919 | get_arp(inport); | |
920 | Syntax error at `)' expecting `,'. | |
921 | get_arp(inport ip4.dst); | |
922 | Syntax error at `ip4.dst' expecting `,'. | |
923 | get_arp(inport, ip4.dst; | |
924 | Syntax error at `;' expecting `)'. | |
925 | get_arp(inport, eth.dst); | |
926 | Cannot use 48-bit field eth.dst[0..47] where 32-bit field is required. | |
927 | get_arp(inport, outport); | |
928 | Cannot use string field outport where numeric field is required. | |
929 | get_arp(reg0, ip4.dst); | |
930 | Cannot use numeric field reg0 where string field is required. | |
0bac7164 BP |
931 | |
932 | # put_arp | |
d5a76da4 BP |
933 | put_arp(inport, arp.spa, arp.sha); |
934 | 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[] | |
935 | has prereqs eth.type == 0x806 && eth.type == 0x806 | |
0bac7164 | 936 | |
42814145 | 937 | # put_dhcp_opts |
d5a76da4 BP |
938 | reg1[0] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); |
939 | 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) | |
940 | 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"); | |
941 | 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"); | |
942 | 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) | |
943 | 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); | |
944 | 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); | |
945 | 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) | |
946 | ||
947 | reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); | |
948 | Cannot use 2-bit field reg1[0..1] where 1-bit field is required. | |
949 | reg1[0] = put_dhcp_opts(); | |
950 | put_dhcp_opts requires offerip to be specified. | |
951 | reg1[0] = put_dhcp_opts(x = 1.2.3.4, router = 10.0.0.1); | |
952 | Syntax error at `x' expecting DHCPv4 option name. | |
953 | reg1[0] = put_dhcp_opts(router = 10.0.0.1); | |
954 | put_dhcp_opts requires offerip to be specified. | |
955 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, "hi"); | |
956 | Syntax error at `"hi"'. | |
957 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, xyzzy); | |
958 | Syntax error at `xyzzy' expecting DHCPv4 option name. | |
959 | reg1[0] = put_dhcp_opts(offerip="xyzzy"); | |
960 | DHCPv4 option offerip requires numeric value. | |
961 | reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain=1.2.3.4); | |
962 | DHCPv4 option domain requires string value. | |
42814145 | 963 | |
f8a8db39 | 964 | # nd_na |
d5a76da4 BP |
965 | 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; }; |
966 | formats as nd_na { eth.src = 12:34:56:78:9a:bc; nd.tll = 12:34:56:78:9a:bc; outport = inport; inport = ""; output; }; | |
967 | 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) | |
968 | has prereqs nd_ns | |
e75451fe | 969 | |
c34a87b6 | 970 | # get_nd |
d5a76da4 BP |
971 | get_nd(outport, ip6.dst); |
972 | 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[] | |
973 | has prereqs eth.type == 0x86dd | |
974 | get_nd(inport, xxreg0); | |
975 | 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[] | |
976 | get_nd; | |
977 | Syntax error at `;' expecting `('. | |
978 | get_nd(); | |
979 | Syntax error at `)' expecting field name. | |
980 | get_nd(inport); | |
981 | Syntax error at `)' expecting `,'. | |
982 | get_nd(inport ip6.dst); | |
983 | Syntax error at `ip6.dst' expecting `,'. | |
984 | get_nd(inport, ip6.dst; | |
985 | Syntax error at `;' expecting `)'. | |
986 | get_nd(inport, eth.dst); | |
987 | Cannot use 48-bit field eth.dst[0..47] where 128-bit field is required. | |
988 | get_nd(inport, outport); | |
989 | Cannot use string field outport where numeric field is required. | |
990 | get_nd(xxreg0, ip6.dst); | |
991 | Cannot use numeric field xxreg0 where string field is required. | |
c34a87b6 JP |
992 | |
993 | # put_nd | |
d5a76da4 BP |
994 | put_nd(inport, nd.target, nd.sll); |
995 | 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[] | |
996 | 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 | 997 | |
01cfdb2f | 998 | # put_dhcpv6_opts |
d5a76da4 | 999 | reg1[0] = put_dhcpv6_opts(ia_addr = ae70::4, server_id = 00:00:00:00:10:02); |
a55dacac | 1000 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.05.00.10.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.04.00.02.00.06.00.00.00.00.10.02,pause) |
d5a76da4 BP |
1001 | reg1[0] = put_dhcpv6_opts(); |
1002 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40,pause) | |
1003 | reg1[0] = put_dhcpv6_opts(dns_server={ae70::1,ae70::2}); | |
1004 | formats as reg1[0] = put_dhcpv6_opts(dns_server = {ae70::1, ae70::2}); | |
a55dacac | 1005 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.17.00.20.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.01.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.02,pause) |
40df4566 ZKL |
1006 | reg1[0] = put_dhcpv6_opts(server_id=12:34:56:78:9a:bc, dns_server={ae70::1,ae89::2}); |
1007 | formats as reg1[0] = put_dhcpv6_opts(server_id = 12:34:56:78:9a:bc, dns_server = {ae70::1, ae89::2}); | |
a55dacac | 1008 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.02.00.06.12.34.56.78.9a.bc.00.17.00.20.ae.70.00.00.00.00.00.00.00.00.00.00.00.00.00.01.ae.89.00.00.00.00.00.00.00.00.00.00.00.00.00.02,pause) |
d5a76da4 | 1009 | reg1[0] = put_dhcpv6_opts(domain_search = "ovn.org"); |
a55dacac | 1010 | encodes as controller(userdata=00.00.00.05.00.00.00.00.00.01.de.10.00.00.00.40.00.18.00.07.6f.76.6e.2e.6f.72.67,pause) |
d5a76da4 BP |
1011 | reg1[0] = put_dhcpv6_opts(x = 1.2.3.4); |
1012 | Syntax error at `x' expecting DHCPv6 option name. | |
1013 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, "hi"); | |
1014 | Syntax error at `"hi"'. | |
1015 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, xyzzy); | |
1016 | Syntax error at `xyzzy' expecting DHCPv6 option name. | |
1017 | reg1[0] = put_dhcpv6_opts(ia_addr="ae70::4"); | |
1018 | DHCPv6 option ia_addr requires numeric value. | |
1019 | reg1[0] = put_dhcpv6_opts(ia_addr=ae70::4, domain_search=ae70::1); | |
1020 | DHCPv6 option domain_search requires string value. | |
01cfdb2f | 1021 | |
a6095f81 BS |
1022 | # set_queue |
1023 | set_queue(0); | |
1024 | encodes as set_queue:0 | |
1025 | set_queue(61440); | |
1026 | encodes as set_queue:61440 | |
1027 | set_queue(65535); | |
1028 | Queue ID 65535 for set_queue is not in valid range 0 to 61440. | |
1029 | ||
ea991ad2 NS |
1030 | # dns_lookup |
1031 | reg1[0] = dns_lookup(); | |
1032 | encodes as controller(userdata=00.00.00.06.00.00.00.00.00.01.de.10.00.00.00.40,pause) | |
1033 | has prereqs udp | |
1034 | reg1[0] = dns_lookup("foo"); | |
1035 | dns_lookup doesn't take any parameters | |
1036 | ||
5f822129 | 1037 | # Contradictionary prerequisites (allowed but not useful): |
d5a76da4 BP |
1038 | ip4.src = ip6.src[0..31]; |
1039 | encodes as move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[] | |
1040 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
1041 | ip4.src <-> ip6.src[0..31]; | |
1042 | 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[] | |
1043 | has prereqs eth.type == 0x800 && eth.type == 0x86dd | |
1044 | ||
1045 | # Miscellaneous negative tests. | |
1046 | ; | |
1047 | Syntax error at `;'. | |
1048 | xyzzy; | |
1049 | Syntax error at `xyzzy' expecting action. | |
1050 | next; 123; | |
1051 | Syntax error at `123'. | |
1052 | next; xyzzy; | |
1053 | Syntax error at `xyzzy' expecting action. | |
1054 | next | |
9aef3c1b | 1055 | Syntax error at end of input expecting `;'. |
3b7cb7e1 | 1056 | ]]) |
d5a76da4 BP |
1057 | sed '/^[[ ]]/d' test-cases.txt > input.txt |
1058 | cp test-cases.txt expout | |
3b7cb7e1 BP |
1059 | AT_CHECK([ovstest test-ovn parse-actions < input.txt], [0], [expout]) |
1060 | AT_CLEANUP | |
f295c17b BP |
1061 | |
1062 | AT_BANNER([OVN end-to-end tests]) | |
1063 | ||
9975d7be BP |
1064 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor |
1065 | AT_SETUP([ovn -- 3 HVs, 1 LS, 3 lports/HV]) | |
57d143eb | 1066 | AT_KEYWORDS([ovnarp]) |
f295c17b BP |
1067 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1068 | ovn_start | |
1069 | ||
1070 | # Create hypervisors hv[123]. | |
9975d7be | 1071 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. |
f295c17b BP |
1072 | # Add all of the vifs to a single logical switch lsw0. |
1073 | # Turn on port security on all the vifs except vif[123]1. | |
1074 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
1075 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
ea46a4e9 | 1076 | ovn-nbctl ls-add lsw0 |
f295c17b BP |
1077 | net_add n1 |
1078 | for i in 1 2 3; do | |
1079 | sim_add hv$i | |
1080 | as hv$i | |
1081 | ovs-vsctl add-br br-phys | |
1082 | ovn_attach n1 br-phys 192.168.0.$i | |
1083 | ||
1084 | for j in 1 2 3; do | |
1085 | 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 | 1086 | ovn-nbctl lsp-add lsw0 lp$i$j |
4d5c43d5 | 1087 | if test $j = 1; then |
31ed1192 | 1088 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
f295c17b | 1089 | else |
7dc88496 NS |
1090 | if test $j = 3; then |
1091 | ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j" | |
1092 | else | |
1093 | ip_addrs="192.168.0.$i$j" | |
1094 | fi | |
31ed1192 JP |
1095 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j $ip_addrs" |
1096 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
f295c17b BP |
1097 | fi |
1098 | done | |
1099 | done | |
1100 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1101 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop | |
1102 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop | |
ea382567 RB |
1103 | 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\" |
1104 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop | |
f295c17b BP |
1105 | |
1106 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1107 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1108 | # for ARP resolution). | |
1109 | ovn_populate_arp | |
1110 | ||
1111 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1112 | # XXX This should be more systematic. | |
1113 | sleep 1 | |
611099dc | 1114 | |
fc6f9978 HZ |
1115 | # Make sure there is no attempt to adding duplicated flows by ovn-controller |
1116 | AT_FAIL_IF([test -n "`grep duplicate hv1/ovn-controller.log`"]) | |
1117 | AT_FAIL_IF([test -n "`grep duplicate hv2/ovn-controller.log`"]) | |
1118 | AT_FAIL_IF([test -n "`grep duplicate hv3/ovn-controller.log`"]) | |
1119 | ||
57d143eb HZ |
1120 | # Given the name of a logical port, prints the name of the hypervisor |
1121 | # on which it is located. | |
1122 | vif_to_hv() { | |
1123 | echo hv${1%?} | |
1124 | } | |
1125 | ||
f295c17b BP |
1126 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1127 | # | |
1128 | # This shell function causes a packet to be received on INPORT. The packet's | |
1129 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1130 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1131 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1132 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. |
f295c17b BP |
1133 | for i in 1 2 3; do |
1134 | for j in 1 2 3; do | |
1135 | : > $i$j.expected | |
1136 | done | |
1137 | done | |
1138 | test_packet() { | |
1139 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
57d143eb | 1140 | hv=`vif_to_hv $inport` |
f295c17b BP |
1141 | vif=vif$inport |
1142 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1143 | for outport; do | |
e4543cfe | 1144 | echo $packet >> $outport.expected |
f295c17b BP |
1145 | done |
1146 | } | |
1147 | ||
57d143eb HZ |
1148 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
1149 | # | |
1150 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1151 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1152 | # it should be the hardware address of the target to expect to receive in an | |
1153 | # ARP reply; otherwise no reply is expected. | |
1154 | # | |
31ed1192 | 1155 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
57d143eb HZ |
1156 | # SHA and REPLY_HA are each 12 hex digits. |
1157 | # SPA and TPA are each 8 hex digits. | |
1158 | test_arp() { | |
1159 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1160 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
1161 | hv=`vif_to_hv $inport` | |
1162 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
1163 | ||
92f9822b | 1164 | if test X$reply_ha = X; then |
57d143eb HZ |
1165 | # Expect to receive the broadcast ARP on the other logical switch ports |
1166 | # if no reply is expected. | |
1167 | local i j | |
1168 | for i in 1 2 3; do | |
1169 | for j in 1 2 3; do | |
1170 | if test $i$j != $inport; then | |
1171 | echo $request >> $i$j.expected | |
1172 | fi | |
1173 | done | |
1174 | done | |
1175 | else | |
1176 | # Expect to receive the reply, if any. | |
1177 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
1178 | echo $reply >> $inport.expected | |
1179 | fi | |
1180 | } | |
1181 | ||
1182 | ip_to_hex() { | |
1183 | printf "%02x%02x%02x%02x" "$@" | |
1184 | } | |
1185 | ||
f295c17b BP |
1186 | # Send packets between all pairs of source and destination ports: |
1187 | # | |
31ed1192 JP |
1188 | # 1. Unicast packets are delivered to exactly one logical switch port |
1189 | # (except that packets destined to their input ports are dropped). | |
f295c17b | 1190 | # |
31ed1192 JP |
1191 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1192 | # except the input port. | |
f295c17b | 1193 | # |
ea46a4e9 | 1194 | # 3. When port security is turned on, the switch drops packets from the wrong |
f295c17b BP |
1195 | # MAC address. |
1196 | # | |
ea46a4e9 | 1197 | # 4. The switch drops all packets with a VLAN tag. |
f295c17b | 1198 | # |
ea46a4e9 | 1199 | # 5. The switch drops all packets with a multicast source address. (This only |
f295c17b BP |
1200 | # affects behavior when port security is turned off, since otherwise port |
1201 | # security would drop the packet anyway.) | |
1202 | # | |
ea46a4e9 | 1203 | # 6. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1204 | # switch ports with "unknown" among their MAC addresses (and port |
1205 | # security disabled). | |
f295c17b | 1206 | # |
ea46a4e9 | 1207 | # 7. The switch drops unicast packets that violate an ACL. |
f295c17b | 1208 | # |
ea46a4e9 | 1209 | # 8. The switch drops multicast and broadcast packets that violate an ACL. |
57d143eb | 1210 | # |
9fcb6a18 BP |
1211 | # 9. OVN generates responses to ARP requests for known IPs, except for |
1212 | # requests from a port for the port's own IP. | |
57d143eb HZ |
1213 | # |
1214 | # 10. No response to ARP requests for unknown IPs. | |
4acd1e87 | 1215 | |
f295c17b BP |
1216 | for is in 1 2 3; do |
1217 | for js in 1 2 3; do | |
1218 | s=$is$js | |
1219 | bcast= | |
4d5c43d5 JP |
1220 | unknown= |
1221 | bacl2= | |
1222 | bacl3= | |
f295c17b BP |
1223 | for id in 1 2 3; do |
1224 | for jd in 1 2 3; do | |
1225 | d=$id$jd | |
1226 | ||
1227 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1228 | test_packet $s f000000000$d f000000000$s $s$d $unicast #1 | |
1229 | ||
1230 | if test $d != $s && test $js = 1; then | |
4d5c43d5 JP |
1231 | impersonate=$d |
1232 | else | |
1233 | impersonate= | |
1234 | fi | |
f295c17b BP |
1235 | test_packet $s f000000000$d f00000000055 55$d $impersonate #3 |
1236 | ||
4d5c43d5 JP |
1237 | if test $d != $s && test $s != 11; then acl2=$d; else acl2=; fi |
1238 | if test $d != $s && test $d != 33; then acl3=$d; else acl3=; fi | |
e137131a | 1239 | if test $d = $s || (test $js = 1 && test $d = 33); then |
ea382567 RB |
1240 | # Source of 11, 21, or 31 and dest of 33 should be dropped |
1241 | # due to the 4th ACL that uses address_set(set1). | |
1242 | acl4= | |
1243 | else | |
1244 | acl4=$d | |
1245 | fi | |
f295c17b BP |
1246 | test_packet $s f000000000$d f000000000$s 1234 #7, acl1 |
1247 | test_packet $s f000000000$d f000000000$s 1235 $acl2 #7, acl2 | |
1248 | test_packet $s f000000000$d f000000000$s 1236 $acl3 #7, acl3 | |
ea382567 | 1249 | test_packet $s f000000000$d f000000000$s 1237 $acl4 #7, acl4 |
f295c17b BP |
1250 | |
1251 | test_packet $s f000000000$d f00000000055 810000091234 #4 | |
1252 | test_packet $s f000000000$d 0100000000$s $s$d #5 | |
1253 | ||
4d5c43d5 JP |
1254 | if test $d != $s && test $jd = 1; then |
1255 | unknown="$unknown $d" | |
1256 | fi | |
f295c17b BP |
1257 | bcast="$bcast $unicast" |
1258 | bacl2="$bacl2 $acl2" | |
1259 | bacl3="$bacl3 $acl3" | |
57d143eb HZ |
1260 | |
1261 | sip=`ip_to_hex 192 168 0 $i$j` | |
1262 | tip=`ip_to_hex 192 168 0 $id$jd` | |
1263 | tip_unknown=`ip_to_hex 11 11 11 11` | |
9fcb6a18 BP |
1264 | if test $d != $s; then |
1265 | reply_ha=f000000000$d | |
1266 | else | |
1267 | reply_ha= | |
1268 | fi | |
1269 | test_arp $s f000000000$s $sip $tip $reply_ha #9 | |
57d143eb | 1270 | test_arp $s f000000000$s $sip $tip_unknown #10 |
7dc88496 NS |
1271 | |
1272 | if test $jd = 3; then | |
31ed1192 | 1273 | # lsp[123]3 has an additional ip 192.169.0.[123]3. |
7dc88496 | 1274 | tip=`ip_to_hex 192 169 0 $id$jd` |
9fcb6a18 | 1275 | test_arp $s f000000000$s $sip $tip $reply_ha #9 |
7dc88496 | 1276 | fi |
f295c17b BP |
1277 | done |
1278 | done | |
1279 | ||
4d5c43d5 | 1280 | # Broadcast and multicast. |
f295c17b BP |
1281 | test_packet $s ffffffffffff f000000000$s ${s}ff $bcast #2 |
1282 | test_packet $s 010000000000 f000000000$s ${s}ff $bcast #2 | |
4d5c43d5 | 1283 | if test $js = 1; then |
f295c17b BP |
1284 | bcast_impersonate=$bcast |
1285 | else | |
4d5c43d5 JP |
1286 | bcast_impersonate= |
1287 | fi | |
f295c17b BP |
1288 | test_packet $s 010000000000 f00000000044 44ff $bcast_impersonate #3 |
1289 | ||
1290 | test_packet $s f0000000ffff f000000000$s ${s}66 $unknown #6 | |
1291 | ||
1292 | test_packet $s ffffffffffff f000000000$s 1234 #8, acl1 | |
1293 | test_packet $s ffffffffffff f000000000$s 1235 $bacl2 #8, acl2 | |
1294 | test_packet $s ffffffffffff f000000000$s 1236 $bacl3 #8, acl3 | |
1295 | test_packet $s 010000000000 f000000000$s 1234 #8, acl1 | |
1296 | test_packet $s 010000000000 f000000000$s 1235 $bacl2 #8, acl2 | |
1297 | test_packet $s 010000000000 f000000000$s 1236 $bacl3 #8, acl3 | |
1298 | done | |
1299 | done | |
1300 | ||
7dc88496 NS |
1301 | # set address for lp13 with invalid characters. |
1302 | # lp13 should be configured with only 192.168.0.13. | |
31ed1192 | 1303 | ovn-nbctl lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13" |
3b8cd0ea BP |
1304 | |
1305 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1306 | # XXX This should be more systematic. | |
1307 | sleep 1 | |
1308 | ||
7dc88496 NS |
1309 | sip=`ip_to_hex 192 168 0 11` |
1310 | tip=`ip_to_hex 192 168 0 13` | |
1311 | test_arp 11 f00000000011 $sip $tip f00000000013 | |
1312 | ||
1313 | tip=`ip_to_hex 192 169 0 13` | |
1314 | #arp request for 192.169.0.13 should be flooded | |
1315 | test_arp 11 f00000000011 $sip $tip | |
1316 | ||
91125642 | 1317 | # dump information and flows with counters |
bb0c41d3 RM |
1318 | ovn-sbctl dump-flows -- list multicast_group |
1319 | ||
1320 | echo "------ hv1 dump ------" | |
1321 | as hv1 ovs-vsctl show | |
1322 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1323 | ||
1324 | echo "------ hv2 dump ------" | |
1325 | as hv2 ovs-vsctl show | |
1326 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1327 | ||
1328 | echo "------ hv3 dump ------" | |
1329 | as hv3 ovs-vsctl show | |
1330 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
49d7c759 | 1331 | |
f295c17b BP |
1332 | # Now check the packets actually received against the ones expected. |
1333 | for i in 1 2 3; do | |
1334 | for j in 1 2 3; do | |
49d7c759 | 1335 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
f295c17b BP |
1336 | done |
1337 | done | |
fcde56f5 | 1338 | |
7a8f15e0 | 1339 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 1340 | |
f295c17b | 1341 | AT_CLEANUP |
eb6b08eb | 1342 | |
4acd1e87 BP |
1343 | AT_SETUP([ovn -- trace 1 LS, 3 LSPs]) |
1344 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1345 | ovn_start | |
1346 | ||
1347 | # Create a logical switch and some logical ports. | |
1348 | # Turn on port security on all lports except ls1. | |
1349 | # Make ls1 a destination for unknown MACs. | |
1350 | # Add some ACLs for Ethertypes 1234, 1235, 1236. | |
1351 | ovn-nbctl ls-add lsw0 | |
1352 | ovn-sbctl chassis-add hv0 geneve 127.0.0.1 | |
1353 | for i in 1 2 3; do | |
1354 | ovn-nbctl lsp-add lsw0 lp$i | |
7979c444 BP |
1355 | done |
1356 | ovn-nbctl --wait=sb sync | |
1357 | for i in 1 2 3; do | |
4acd1e87 BP |
1358 | ovn-sbctl lsp-bind lp$i hv0 |
1359 | if test $i = 1; then | |
abb37b6b | 1360 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:0$i 192.168.0.$i" unknown |
4acd1e87 | 1361 | else |
abb37b6b FF |
1362 | if test $i = 3; then |
1363 | ip_addrs="192.168.0.$i fe80::ea2a:eaff:fe28:$i/64 192.169.0.$i" | |
1364 | else | |
1365 | ip_addrs="192.168.0.$i" | |
1366 | fi | |
1367 | ovn-nbctl lsp-set-addresses lp$i "f0:00:00:00:00:$i $ip_addrs" | |
1368 | ovn-nbctl lsp-set-port-security lp$i f0:00:00:00:00:$i | |
4acd1e87 BP |
1369 | fi |
1370 | done | |
1371 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop | |
1372 | ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp1"' drop | |
1373 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp3"' drop | |
1374 | ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:01\",\"f0:00:00:00:00:02\" | |
1375 | ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp3"' drop | |
1376 | ||
1377 | ovn-nbctl --wait=sb sync | |
1378 | on_exit 'kill `cat ovn-trace.pid`' | |
1379 | ovn-trace --detach --pidfile --no-chdir | |
1380 | ||
1381 | # test_packet INPORT DST SRC [-vlan] [-eth TYPE] OUTPORT... | |
1382 | # | |
1383 | # This shell function causes a packet to be received on INPORT. The packet's | |
1384 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1385 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1386 | # more) list the VIFs on which the packet should be received. INPORT and the | |
1387 | # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. | |
1388 | test_packet() { | |
1389 | local inport=$1 eth_dst=$2 eth_src=$3; shift; shift; shift | |
1390 | uflow="inport==\"lp$inport\" && eth.dst==$eth_dst && eth.src==$eth_src" | |
1391 | while :; do | |
abb37b6b FF |
1392 | case $1 in # ( |
1393 | -vlan) uflow="$uflow && vlan.vid == 1234"; shift ;; # ( | |
1394 | -eth) uflow="$uflow && eth.type == 0x$2"; shift; shift ;; # ( | |
1395 | *) break ;; | |
1396 | esac | |
4acd1e87 BP |
1397 | done |
1398 | for outport; do | |
abb37b6b | 1399 | echo "output(\"lp$outport\");" |
4acd1e87 BP |
1400 | done > expout |
1401 | ||
1402 | AT_CAPTURE_FILE([trace]) | |
1403 | AT_CHECK([ovs-appctl -t ovn-trace trace --all lsw0 "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
1404 | } | |
1405 | ||
1406 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
1407 | # | |
1408 | # Causes a packet to be received on INPORT. The packet is an ARP | |
1409 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
1410 | # it should be the hardware address of the target to expect to receive in an | |
1411 | # ARP reply; otherwise no reply is expected. | |
1412 | # | |
1413 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
1414 | # SHA and REPLY_HA are each 12 hex digits. | |
1415 | # SPA and TPA are each 8 hex digits. | |
1416 | test_arp() { | |
1417 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
1418 | ||
1419 | local request="inport == \"lp$inport\" | |
1420 | && eth.dst == ff:ff:ff:ff:ff:ff && eth.src == $sha | |
1421 | && arp.op == 1 && arp.sha == $sha && arp.spa == $spa | |
abb37b6b | 1422 | && arp.tha == ff:ff:ff:ff:ff:ff && arp.tpa == $tpa" |
4acd1e87 BP |
1423 | |
1424 | if test -z "$reply_ha"; then | |
1425 | reply= | |
abb37b6b FF |
1426 | local i |
1427 | for i in 1 2 3; do | |
1428 | if test $i != $inport; then | |
1429 | reply="${reply}output(\"lp$i\"); | |
4acd1e87 | 1430 | " |
abb37b6b FF |
1431 | fi |
1432 | done | |
4acd1e87 BP |
1433 | else |
1434 | reply="\ | |
1435 | eth.dst = $sha; | |
1436 | eth.src = $reply_ha; | |
1437 | arp.op = 2; | |
1438 | arp.tha = $sha; | |
1439 | arp.sha = $reply_ha; | |
1440 | arp.tpa = $spa; | |
1441 | arp.spa = $tpa; | |
1442 | output(\"lp$inport\"); | |
1443 | " | |
1444 | fi | |
1445 | ||
1446 | AT_CAPTURE_FILE([trace]) | |
1447 | AT_CHECK_UNQUOTED([ovs-appctl -t ovn-trace trace --all lsw0 "$request" | tee trace | sed '1,/Minimal trace/d'], [0], [$reply]) | |
1448 | } | |
1449 | ||
1450 | # Send packets between all pairs of source and destination ports: | |
1451 | # | |
1452 | # 1. Unicast packets are delivered to exactly one logical switch port | |
1453 | # (except that packets destined to their input ports are dropped). | |
1454 | # | |
1455 | # 2. Broadcast and multicast are delivered to all logical switch ports | |
1456 | # except the input port. | |
1457 | # | |
1458 | # 3. When port security is turned on, the switch drops packets from the wrong | |
1459 | # MAC address. | |
1460 | # | |
1461 | # 4. The switch drops all packets with a VLAN tag. | |
1462 | # | |
1463 | # 5. The switch drops all packets with a multicast source address. (This only | |
1464 | # affects behavior when port security is turned off, since otherwise port | |
1465 | # security would drop the packet anyway.) | |
1466 | # | |
1467 | # 6. The switch delivers packets with an unknown destination to logical | |
1468 | # switch ports with "unknown" among their MAC addresses (and port | |
1469 | # security disabled). | |
1470 | # | |
1471 | # 7. The switch drops unicast packets that violate an ACL. | |
1472 | # | |
1473 | # 8. The switch drops multicast and broadcast packets that violate an ACL. | |
1474 | # | |
9fcb6a18 BP |
1475 | # 9. OVN generates responses to ARP requests for known IPs, except for |
1476 | # requests from a port for the port's own IP. | |
4acd1e87 BP |
1477 | # |
1478 | # 10. No response to ARP requests for unknown IPs. | |
1479 | ||
1480 | for s in 1 2 3; do | |
1481 | bcast= | |
1482 | unknown= | |
1483 | bacl2= | |
1484 | bacl3= | |
1485 | for d in 1 2 3; do | |
abb37b6b FF |
1486 | echo |
1487 | echo "lp$s -> lp$d" | |
1488 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1489 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s $unicast #1 | |
1490 | ||
1491 | if test $d != $s && test $s = 1; then | |
1492 | impersonate=$d | |
1493 | else | |
1494 | impersonate= | |
1495 | fi | |
1496 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 $impersonate #3 | |
1497 | ||
1498 | if test $d != $s && test $s != 1; then acl2=$d; else acl2=; fi | |
1499 | if test $d != $s && test $d != 3; then acl3=$d; else acl3=; fi | |
1500 | if test $d = $s || ( (test $s = 1 || test $s = 2) && test $d = 3); then | |
1501 | # Source of 1 or 2 and dest of 3 should be dropped | |
1502 | # due to the 4th ACL that uses address_set(set1). | |
1503 | acl4= | |
1504 | else | |
1505 | acl4=$d | |
1506 | fi | |
1507 | ||
1508 | #7, acl1 to acl4: | |
1509 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1234 | |
1510 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1235 $acl2 | |
1511 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1236 $acl3 | |
1512 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:0$s -eth 1237 $acl4 | |
1513 | ||
1514 | test_packet $s f0:00:00:00:00:0$d f0:00:00:00:00:55 -vlan #4 | |
1515 | test_packet $s f0:00:00:00:00:0$d 01:00:00:00:00:0$s #5 | |
1516 | ||
1517 | if test $d != $s && test $d = 1; then | |
1518 | unknown="$unknown $d" | |
1519 | fi | |
1520 | bcast="$bcast $unicast" | |
1521 | bacl2="$bacl2 $acl2" | |
1522 | bacl3="$bacl3 $acl3" | |
1523 | ||
1524 | sip=192.168.0.$s | |
1525 | tip=192.168.0.$d | |
1526 | tip_unknown=11.11.11.11 | |
9fcb6a18 BP |
1527 | if test $d != $s; then reply_ha=f0:00:00:00:00:0$d; else reply_ha=; fi |
1528 | test_arp $s f0:00:00:00:00:0$s $sip $tip $reply_ha #9 | |
abb37b6b FF |
1529 | test_arp $s f0:00:00:00:00:0$s $sip $tip_unknown #10 |
1530 | ||
1531 | if test $d = 3; then | |
1532 | # lp3 has an additional ip 192.169.0.[123]3. | |
1533 | tip=192.169.0.$d | |
9fcb6a18 | 1534 | test_arp $s f0:00:00:00:00:0$s $sip $tip $reply_ha #9 |
abb37b6b | 1535 | fi |
4acd1e87 BP |
1536 | done |
1537 | ||
1538 | # Broadcast and multicast. | |
1539 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s $bcast #2 | |
1540 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s $bcast #2 | |
1541 | if test $s = 1; then | |
abb37b6b | 1542 | bcast_impersonate=$bcast |
4acd1e87 | 1543 | else |
abb37b6b | 1544 | bcast_impersonate= |
4acd1e87 BP |
1545 | fi |
1546 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:44 $bcast_impersonate #3 | |
1547 | ||
1548 | test_packet $s f0:00:00:00:ff:ff f0:00:00:00:00:0$s $unknown #6 | |
1549 | ||
1550 | #8, acl1 to acl3: | |
1551 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1234 | |
1552 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
1553 | test_packet $s ff:ff:ff:ff:ff:ff f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
1554 | ||
1555 | #8, acl1 to acl3: | |
1556 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1234 | |
1557 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1235 $bacl2 | |
1558 | test_packet $s 01:00:00:00:00:00 f0:00:00:00:00:0$s -eth 1236 $bacl3 | |
1559 | done | |
1560 | ||
1561 | AT_CLEANUP | |
1562 | ||
7277bc83 RB |
1563 | # 2 hypervisors, 4 logical ports per HV |
1564 | # 2 locally attached networks (one flat, one vlan tagged over same device) | |
1565 | # 2 ports per HV on each network | |
e90aeb57 | 1566 | AT_SETUP([ovn -- 2 HVs, 4 lports/HV, localnet ports]) |
d79fc5f4 RB |
1567 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1568 | ovn_start | |
1569 | ||
ea46a4e9 JP |
1570 | # In this test cases we create 3 switches, all connected to same |
1571 | # physical network (through br-phys on each HV). Each switch has | |
0ee7f7f1 HZ |
1572 | # VIF ports across 2 HVs. Each HV has 5 VIF ports. The first digit |
1573 | # of VIF port name indicates the hypervisor it is bound to, e.g. | |
1574 | # lp23 means VIF 3 on hv2. | |
1575 | # | |
ea46a4e9 | 1576 | # Each switch's VLAN tag and their logical switch ports are: |
0ee7f7f1 HZ |
1577 | # - ls1: |
1578 | # - untagged | |
ea46a4e9 | 1579 | # - ports: lp11, lp12, lp21, lp22 |
0ee7f7f1 HZ |
1580 | # |
1581 | # - ls2: | |
1582 | # - tagged with VLAN 101 | |
ea46a4e9 | 1583 | # - ports: lp13, lp14, lp23, lp24 |
0ee7f7f1 HZ |
1584 | # - ls3: |
1585 | # - untagged | |
ea46a4e9 | 1586 | # - ports: lp15, lp25 |
0ee7f7f1 | 1587 | # |
ea46a4e9 | 1588 | # Note: a localnet port is created for each switch to connect to |
0ee7f7f1 HZ |
1589 | # physical network. |
1590 | ||
1591 | for i in 1 2 3; do | |
ea46a4e9 JP |
1592 | ls_name=ls$i |
1593 | ovn-nbctl ls-add $ls_name | |
0ee7f7f1 HZ |
1594 | ln_port_name=ln$i |
1595 | if test $i -eq 2; then | |
ea46a4e9 | 1596 | ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 |
0ee7f7f1 | 1597 | else |
ea46a4e9 | 1598 | ovn-nbctl lsp-add $ls_name $ln_port_name |
0ee7f7f1 | 1599 | fi |
31ed1192 JP |
1600 | ovn-nbctl lsp-set-addresses $ln_port_name unknown |
1601 | ovn-nbctl lsp-set-type $ln_port_name localnet | |
1602 | ovn-nbctl lsp-set-options $ln_port_name network_name=phys | |
0ee7f7f1 | 1603 | done |
d79fc5f4 | 1604 | |
69b72264 BP |
1605 | # lsp_to_ls LSP |
1606 | # | |
1607 | # Prints the name of the logical switch that contains LSP. | |
1608 | lsp_to_ls () { | |
1609 | case $1 in dnl ( | |
1610 | lp?[[12]]) echo ls1 ;; dnl ( | |
1611 | lp?[[34]]) echo ls2 ;; dnl ( | |
1612 | lp?5) echo ls3 ;; dnl ( | |
1613 | *) AT_FAIL_IF([:]) ;; | |
1614 | esac | |
1615 | } | |
1616 | ||
d79fc5f4 RB |
1617 | net_add n1 |
1618 | for i in 1 2; do | |
1619 | sim_add hv$i | |
1620 | as hv$i | |
1621 | ovs-vsctl add-br br-phys | |
1622 | ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
1623 | ovn_attach n1 br-phys 192.168.0.$i | |
1624 | ||
0ee7f7f1 | 1625 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
1626 | ovs-vsctl add-port br-int vif$i$j -- \ |
1627 | set Interface vif$i$j external-ids:iface-id=lp$i$j \ | |
1628 | options:tx_pcap=hv$i/vif$i$j-tx.pcap \ | |
1629 | options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ | |
1630 | ofport-request=$i$j | |
1631 | ||
31ed1192 | 1632 | lsp_name=lp$i$j |
69b72264 | 1633 | ls_name=$(lsp_to_ls $lsp_name) |
d79fc5f4 | 1634 | |
ea46a4e9 | 1635 | ovn-nbctl lsp-add $ls_name $lsp_name |
31ed1192 JP |
1636 | ovn-nbctl lsp-set-addresses $lsp_name f0:00:00:00:00:$i$j |
1637 | ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$j | |
d79fc5f4 | 1638 | |
31ed1192 | 1639 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) |
d79fc5f4 RB |
1640 | done |
1641 | done | |
69b72264 BP |
1642 | ovn-nbctl --wait=sb sync |
1643 | ovn-sbctl dump-flows | |
d79fc5f4 RB |
1644 | |
1645 | ovn_populate_arp | |
1646 | ||
1647 | # XXX This is now the 3rd copy of these functions in this file ... | |
1648 | ||
1649 | # Given the name of a logical port, prints the name of the hypervisor | |
1650 | # on which it is located. | |
1651 | vif_to_hv() { | |
1652 | echo hv${1%?} | |
1653 | } | |
1654 | # | |
69b72264 | 1655 | # test_packet INPORT DST SRC ETHTYPE EOUT LOUT |
d79fc5f4 RB |
1656 | # |
1657 | # This shell function causes a packet to be received on INPORT. The packet's | |
1658 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
69b72264 BP |
1659 | # digits) and Ethernet type ETHTYPE (4 hex digits). INPORT is specified as |
1660 | # logical switch port numbers, e.g. 11 for vif11. | |
1661 | # | |
1662 | # EOUT is the end-to-end output port, that is, where the packet will end up | |
1663 | # after possibly bouncing through one or more localnet ports. LOUT is the | |
1664 | # logical output port, which might be a localnet port, as seen by ovn-trace | |
1665 | # (which doesn't know what localnet ports are connected to and therefore can't | |
1666 | # figure out the end-to-end answer). | |
d79fc5f4 | 1667 | for i in 1 2; do |
0ee7f7f1 | 1668 | for j in 1 2 3 4 5; do |
d79fc5f4 RB |
1669 | : > $i$j.expected |
1670 | done | |
1671 | done | |
1672 | test_packet() { | |
69b72264 BP |
1673 | local inport=$1 dst=$2 src=$3 eth=$4 eout=$5 lout=$6 |
1674 | echo "$@" | |
1675 | ||
1676 | # First try tracing the packet. | |
1677 | uflow="inport==\"lp$inport\" && eth.dst==$dst && eth.src==$src && eth.type==0x$eth" | |
1678 | if test $lout != drop; then | |
1679 | echo "output(\"$lout\");" | |
1680 | fi > expout | |
1681 | AT_CAPTURE_FILE([trace]) | |
1682 | AT_CHECK([ovn-trace --all $(lsp_to_ls lp$inport) "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) | |
1683 | ||
1684 | # Then actually send a packet, for an end-to-end test. | |
1685 | local packet=$(echo $dst$src | sed 's/://g')${eth} | |
d79fc5f4 RB |
1686 | hv=`vif_to_hv $inport` |
1687 | vif=vif$inport | |
1688 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
69b72264 BP |
1689 | if test $eout != drop; then |
1690 | echo $packet >> ${eout#lp}.expected | |
1691 | fi | |
d79fc5f4 RB |
1692 | } |
1693 | ||
7277bc83 RB |
1694 | # lp11 and lp21 are on the same network (phys, untagged) |
1695 | # and on different hypervisors | |
69b72264 BP |
1696 | test_packet 11 f0:00:00:00:00:21 f0:00:00:00:00:11 1121 lp21 lp21 |
1697 | test_packet 21 f0:00:00:00:00:11 f0:00:00:00:00:21 2111 lp11 lp11 | |
d79fc5f4 | 1698 | |
7277bc83 RB |
1699 | # lp11 and lp12 are on the same network (phys, untagged) |
1700 | # and on the same hypervisor | |
69b72264 BP |
1701 | test_packet 11 f0:00:00:00:00:12 f0:00:00:00:00:11 1112 lp12 lp12 |
1702 | test_packet 12 f0:00:00:00:00:11 f0:00:00:00:00:12 1211 lp11 lp11 | |
7277bc83 RB |
1703 | |
1704 | # lp13 and lp23 are on the same network (phys, VLAN 101) | |
1705 | # and on different hypervisors | |
69b72264 BP |
1706 | test_packet 13 f0:00:00:00:00:23 f0:00:00:00:00:13 1323 lp23 lp23 |
1707 | test_packet 23 f0:00:00:00:00:13 f0:00:00:00:00:23 2313 lp13 lp13 | |
7277bc83 RB |
1708 | |
1709 | # lp13 and lp14 are on the same network (phys, VLAN 101) | |
1710 | # and on the same hypervisor | |
69b72264 BP |
1711 | test_packet 13 f0:00:00:00:00:14 f0:00:00:00:00:13 1314 lp14 lp14 |
1712 | test_packet 14 f0:00:00:00:00:13 f0:00:00:00:00:14 1413 lp13 lp13 | |
d79fc5f4 | 1713 | |
0ee7f7f1 | 1714 | # lp11 and lp15 are on the same network (phys, untagged), |
ea46a4e9 | 1715 | # same hypervisor, and on different switches |
69b72264 BP |
1716 | test_packet 11 f0:00:00:00:00:15 f0:00:00:00:00:11 1115 lp15 ln1 |
1717 | test_packet 15 f0:00:00:00:00:11 f0:00:00:00:00:15 1511 lp11 ln3 | |
0ee7f7f1 HZ |
1718 | |
1719 | # lp11 and lp25 are on the same network (phys, untagged), | |
ea46a4e9 | 1720 | # different hypervisors, and on different switches |
69b72264 BP |
1721 | test_packet 11 f0:00:00:00:00:25 f0:00:00:00:00:11 1125 lp25 ln1 |
1722 | test_packet 25 f0:00:00:00:00:11 f0:00:00:00:00:25 2511 lp11 ln3 | |
0ee7f7f1 | 1723 | |
d79fc5f4 | 1724 | # Ports that should not be able to communicate |
69b72264 BP |
1725 | test_packet 11 f0:00:00:00:00:13 f0:00:00:00:00:11 1113 drop ln1 |
1726 | test_packet 11 f0:00:00:00:00:23 f0:00:00:00:00:11 1123 drop ln1 | |
1727 | test_packet 21 f0:00:00:00:00:13 f0:00:00:00:00:21 2113 drop ln1 | |
1728 | test_packet 21 f0:00:00:00:00:23 f0:00:00:00:00:21 2123 drop ln1 | |
1729 | test_packet 13 f0:00:00:00:00:11 f0:00:00:00:00:13 1311 drop ln2 | |
1730 | test_packet 13 f0:00:00:00:00:21 f0:00:00:00:00:13 1321 drop ln2 | |
1731 | test_packet 23 f0:00:00:00:00:11 f0:00:00:00:00:23 2311 drop ln2 | |
1732 | test_packet 23 f0:00:00:00:00:21 f0:00:00:00:00:23 2321 drop ln2 | |
d79fc5f4 | 1733 | |
d79fc5f4 RB |
1734 | # Dump a bunch of info helpful for debugging if there's a failure. |
1735 | ||
1736 | echo "------ OVN dump ------" | |
1737 | ovn-nbctl show | |
1738 | ovn-sbctl show | |
1739 | ||
1740 | echo "------ hv1 dump ------" | |
1741 | as hv1 ovs-vsctl show | |
1742 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1743 | ||
1744 | echo "------ hv2 dump ------" | |
1745 | as hv2 ovs-vsctl show | |
1746 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
1747 | ||
1748 | # Now check the packets actually received against the ones expected. | |
1749 | for i in 1 2; do | |
0ee7f7f1 | 1750 | for j in 1 2 3 4 5; do |
49d7c759 | 1751 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
d79fc5f4 RB |
1752 | done |
1753 | done | |
1754 | ||
7a8f15e0 | 1755 | OVN_CLEANUP([hv1],[hv2]) |
d9c8c57c | 1756 | |
d79fc5f4 RB |
1757 | AT_CLEANUP |
1758 | ||
91125642 FF |
1759 | AT_SETUP([ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS]) |
1760 | AT_KEYWORDS([vtep]) | |
eb6b08eb JP |
1761 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
1762 | ovn_start | |
1763 | ||
1764 | # Configure the Northbound database | |
ea46a4e9 | 1765 | ovn-nbctl ls-add lsw0 |
eb6b08eb | 1766 | |
31ed1192 JP |
1767 | ovn-nbctl lsp-add lsw0 lp1 |
1768 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
eb6b08eb | 1769 | |
31ed1192 JP |
1770 | ovn-nbctl lsp-add lsw0 lp2 |
1771 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
eb6b08eb | 1772 | |
31ed1192 JP |
1773 | ovn-nbctl lsp-add lsw0 lp-vtep |
1774 | ovn-nbctl lsp-set-type lp-vtep vtep | |
1775 | ovn-nbctl lsp-set-options lp-vtep vtep-physical-switch=br-vtep vtep-logical-switch=lsw0 | |
1776 | ovn-nbctl lsp-set-addresses lp-vtep unknown | |
eb6b08eb | 1777 | |
77adbb62 DB |
1778 | # lpr, lr and lrp1 are used for the ARP request handling test only. |
1779 | ovn-nbctl lsp-add lsw0 lpr | |
1780 | ovn-nbctl lr-add lr | |
1781 | ovn-nbctl lrp-add lr lrp1 f0:00:00:00:00:f1 192.168.1.1/24 | |
1782 | ovn-nbctl set Logical_Switch_Port lpr type=router \ | |
1783 | options:router-port=lrp1 \ | |
1784 | addresses='"f0:00:00:00:00:f1 192.168.1.1"' | |
1785 | ||
1786 | ||
eb6b08eb JP |
1787 | net_add n1 # Network to connect hv1, hv2, and vtep |
1788 | net_add n2 # Network to connect vtep and hv3 | |
1789 | ||
1790 | # Create hypervisor hv1 connected to n1 | |
1791 | sim_add hv1 | |
1792 | as hv1 | |
1793 | ovs-vsctl add-br br-phys | |
1794 | ovn_attach n1 br-phys 192.168.0.1 | |
1795 | 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 | |
1796 | ||
1797 | # Create hypervisor hv2 connected to n1 | |
1798 | sim_add hv2 | |
1799 | as hv2 | |
1800 | ovs-vsctl add-br br-phys | |
1801 | ovn_attach n1 br-phys 192.168.0.2 | |
1802 | 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 | |
1803 | ||
1804 | ||
1805 | # Start the vtep emulator with a leg in both networks | |
1806 | sim_add vtep | |
1807 | as vtep | |
1808 | ||
1809 | ovsdb-tool create "$ovs_base"/vtep/vtep.db "$abs_top_srcdir"/vtep/vtep.ovsschema || return 1 | |
1810 | ovs-appctl -t ovsdb-server ovsdb-server/add-db "$ovs_base"/vtep/vtep.db | |
1811 | ||
1812 | ovs-vsctl add-br br-phys | |
1813 | net_attach n1 br-phys | |
1814 | ||
1815 | mac=`ovs-vsctl get Interface br-phys mac_in_use | sed s/\"//g` | |
1816 | arp_table="$arp_table $sandbox,br-phys,192.168.0.3,$mac" | |
1817 | ovs-appctl netdev-dummy/ip4addr br-phys 192.168.0.3/24 >/dev/null || return 1 | |
1818 | ovs-appctl ovs/route/add 192.168.0.3/24 br-phys >/dev/null || return 1 | |
1819 | ||
1820 | ovs-vsctl add-br br-vtep | |
1821 | net_attach n2 br-vtep | |
1822 | ||
1823 | vtep-ctl add-ps br-vtep | |
1824 | vtep-ctl set Physical_Switch br-vtep tunnel_ips=192.168.0.3 | |
1825 | vtep-ctl add-ls lsw0 | |
1826 | ||
1827 | start_daemon ovs-vtep br-vtep | |
1828 | start_daemon ovn-controller-vtep --vtep-db=unix:"$ovs_base"/vtep/db.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
1829 | ||
8cdc4312 | 1830 | OVS_WAIT_UNTIL([vtep-ctl bind-ls br-vtep br-vtep_n2 0 lsw0]) |
eb6b08eb | 1831 | |
475f0a2c DB |
1832 | OVS_WAIT_UNTIL([test -n "`as vtep vtep-ctl get-replication-mode lsw0 | |
1833 | grep -- source`"]) | |
1834 | # It takes more time for the update to be processed by ovs-vtep. | |
eb6b08eb JP |
1835 | sleep 1 |
1836 | ||
1837 | # Add hv3 on the other side of the vtep | |
1838 | sim_add hv3 | |
1839 | as hv3 | |
1840 | ovs-vsctl add-br br-phys | |
1841 | net_attach n2 br-phys | |
1842 | ||
1843 | 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 | |
1844 | ||
1845 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
1846 | # packets for ARP resolution (native tunneling doesn't queue packets | |
1847 | # for ARP resolution). | |
1848 | ovn_populate_arp | |
1849 | ||
1850 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
1851 | # XXX This should be more systematic. | |
1852 | sleep 1 | |
6977df72 | 1853 | |
eb6b08eb JP |
1854 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... |
1855 | # | |
1856 | # This shell function causes a packet to be received on INPORT. The packet's | |
1857 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
1858 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
1859 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 1860 | # OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1. |
eb6b08eb JP |
1861 | for i in 1 2 3; do |
1862 | : > $i.expected | |
1863 | done | |
1864 | test_packet() { | |
1865 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
1866 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
1867 | hv=hv$inport | |
1868 | vif=vif$inport | |
1869 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
1870 | for outport; do | |
e4543cfe | 1871 | echo $packet >> $outport.expected |
eb6b08eb JP |
1872 | done |
1873 | } | |
1874 | ||
1875 | # Send packets between all pairs of source and destination ports: | |
1876 | # | |
31ed1192 JP |
1877 | # 1. Unicast packets are delivered to exactly one logical switch port |
1878 | # (except that packets destined to their input ports are dropped). | |
eb6b08eb | 1879 | # |
31ed1192 JP |
1880 | # 2. Broadcast and multicast are delivered to all logical switch ports |
1881 | # except the input port. | |
eb6b08eb | 1882 | # |
ea46a4e9 | 1883 | # 3. The switch delivers packets with an unknown destination to logical |
31ed1192 JP |
1884 | # switch ports with "unknown" among their MAC addresses (and port |
1885 | # security disabled). | |
eb6b08eb JP |
1886 | for s in 1 2 3; do |
1887 | bcast= | |
1888 | unknown= | |
1889 | for d in 1 2 3; do | |
1890 | if test $d != $s; then unicast=$d; else unicast=; fi | |
1891 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
1892 | ||
1893 | # The vtep (vif3) is the only one configured for "unknown" | |
1894 | if test $d != $s && test $d = 3; then | |
1895 | unknown="$unknown $d" | |
1896 | fi | |
1897 | bcast="$bcast $unicast" | |
1898 | done | |
1899 | ||
1900 | # Broadcast and multicast. | |
46ed1382 DB |
1901 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 |
1902 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #2 | |
eb6b08eb JP |
1903 | |
1904 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #3 | |
1905 | done | |
1906 | ||
77adbb62 DB |
1907 | # ARP request should not be responded to by logical switch router |
1908 | # type arp responder on HV1 and HV2 and should reach directly to | |
1909 | # vif1 and vif2 | |
1910 | ip_to_hex() { | |
1911 | printf "%02x%02x%02x%02x" "$@" | |
1912 | } | |
1913 | sha=f00000000003 | |
1914 | spa=`ip_to_hex 192 168 1 2` | |
1915 | tpa=`ip_to_hex 192 168 1 1` | |
1916 | request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
1917 | as hv3 ovs-appctl netdev-dummy/receive vif3 $request | |
1918 | echo $request >> 1.expected | |
1919 | echo $request >> 2.expected | |
1920 | ||
bb0c41d3 RM |
1921 | # dump information with counters |
1922 | echo "------ OVN dump ------" | |
1923 | ovn-nbctl show | |
1924 | ovn-sbctl show | |
1925 | ||
77adbb62 DB |
1926 | echo "---------SB dump-----" |
1927 | ovn-sbctl list datapath_binding | |
1928 | echo "---------------------" | |
1929 | ovn-sbctl list port_binding | |
1930 | echo "---------------------" | |
1931 | ovn-sbctl dump-flows | |
1932 | ||
bb0c41d3 RM |
1933 | echo "------ hv1 dump ------" |
1934 | as hv1 ovs-vsctl show | |
6195e2e7 | 1935 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
1936 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
1937 | ||
1938 | echo "------ hv2 dump ------" | |
1939 | as hv2 ovs-vsctl show | |
6195e2e7 | 1940 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
1941 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
1942 | ||
1943 | echo "------ hv3 dump ------" | |
1944 | as hv3 ovs-vsctl show | |
6754e92d FF |
1945 | # note: hv3 has no logical port bind, thus it should not have br-int |
1946 | AT_CHECK([as hv3 ovs-ofctl -O OpenFlow13 show br-int], [1], [], | |
1947 | [ovs-ofctl: br-int is not a bridge or a socket | |
1948 | ]) | |
bb0c41d3 | 1949 | |
eb6b08eb JP |
1950 | # Now check the packets actually received against the ones expected. |
1951 | for i in 1 2 3; do | |
49d7c759 | 1952 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
eb6b08eb | 1953 | done |
fcde56f5 LR |
1954 | |
1955 | # Gracefully terminate daemons | |
7a8f15e0 LR |
1956 | OVN_CLEANUP([hv1],[hv2],[vtep]) |
1957 | OVN_CLEANUP_VSWITCH([hv3]) | |
d9c8c57c | 1958 | |
eb6b08eb | 1959 | AT_CLEANUP |
9975d7be | 1960 | |
184bc3ca RB |
1961 | # Similar test to "hardware GW" |
1962 | AT_SETUP([ovn -- 3 HVs, 1 VIFs/HV, 1 software GW, 1 LS]) | |
1963 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
1964 | ovn_start | |
1965 | ||
1966 | # Configure the Northbound database | |
1967 | ovn-nbctl ls-add lsw0 | |
1968 | ||
1969 | ovn-nbctl lsp-add lsw0 lp1 | |
1970 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
1971 | ||
1972 | ovn-nbctl lsp-add lsw0 lp2 | |
1973 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
1974 | ||
1975 | ovn-nbctl lsp-add lsw0 lp-gw | |
1976 | ovn-nbctl lsp-set-type lp-gw l2gateway | |
62b87eab | 1977 | ovn-nbctl lsp-set-options lp-gw network_name=physnet1 l2gateway-chassis=hv_gw |
184bc3ca RB |
1978 | ovn-nbctl lsp-set-addresses lp-gw unknown |
1979 | ||
1980 | net_add n1 # Network to connect hv1, hv2, and gw | |
1981 | net_add n2 # Network to connect gw and hv3 | |
1982 | ||
1983 | # Create hypervisor hv1 connected to n1 | |
1984 | sim_add hv1 | |
1985 | as hv1 | |
1986 | ovs-vsctl add-br br-phys | |
1987 | ovn_attach n1 br-phys 192.168.0.1 | |
1988 | 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 | |
1989 | ||
1990 | # Create hypervisor hv2 connected to n1 | |
1991 | sim_add hv2 | |
1992 | as hv2 | |
1993 | ovs-vsctl add-br br-phys | |
1994 | ovn_attach n1 br-phys 192.168.0.2 | |
1995 | 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 | |
1996 | ||
1997 | # Create hypervisor hv_gw connected to n1 and n2 | |
1998 | # connect br-phys bridge to n1; connect hv-gw bridge to n2 | |
1999 | sim_add hv_gw | |
2000 | as hv_gw | |
2001 | ovs-vsctl add-br br-phys | |
2002 | ovn_attach n1 br-phys 192.168.0.3 | |
2003 | ovs-vsctl add-br br-phys2 | |
2004 | net_attach n2 br-phys2 | |
2005 | ovs-vsctl set open . external_ids:ovn-bridge-mappings="physnet1:br-phys2" | |
2006 | ||
184bc3ca RB |
2007 | # Add hv3 on the other side of the GW |
2008 | sim_add hv3 | |
2009 | as hv3 | |
2010 | ovs-vsctl add-br br-phys | |
2011 | net_attach n2 br-phys | |
2012 | 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 | |
2013 | ||
2014 | ||
2015 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2016 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2017 | # for ARP resolution). | |
2018 | ovn_populate_arp | |
2019 | ||
2020 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2021 | # XXX This should be more systematic. | |
2022 | sleep 1 | |
2023 | ||
2024 | # test_packet INPORT DST SRC ETHTYPE OUTPORT... | |
2025 | # | |
2026 | # This shell function causes a packet to be received on INPORT. The packet's | |
2027 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2028 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2029 | # more) list the VIFs on which the packet should be received. INPORT and the | |
2030 | # OUTPORTs are specified as lport numbers, e.g. 1 for vif1. | |
184bc3ca RB |
2031 | for i in 1 2 3; do |
2032 | : > $i.expected | |
2033 | done | |
2034 | test_packet() { | |
2035 | local inport=$1 packet=$2$3$4; shift; shift; shift; shift | |
2036 | #hv=hv`echo $inport | sed 's/^\(.\).*/\1/'` | |
2037 | hv=hv$inport | |
2038 | vif=vif$inport | |
2039 | as $hv ovs-appctl netdev-dummy/receive $vif $packet | |
2040 | for outport; do | |
e4543cfe | 2041 | echo $packet >> $outport.expected |
184bc3ca RB |
2042 | done |
2043 | } | |
2044 | ||
2045 | # Send packets between all pairs of source and destination ports: | |
2046 | # | |
2047 | # 1. Unicast packets are delivered to exactly one lport (except that packets | |
2048 | # destined to their input ports are dropped). | |
2049 | # | |
2050 | # 2. Broadcast and multicast are delivered to all lports except the input port. | |
2051 | # | |
2052 | # 3. The lswitch delivers packets with an unknown destination to lports with | |
2053 | # "unknown" among their MAC addresses (and port security disabled). | |
2054 | for s in 1 2 3 ; do | |
2055 | bcast= | |
2056 | unknown= | |
2057 | for d in 1 2 3 ; do | |
2058 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2059 | test_packet $s f0000000000$d f0000000000$s 00$s$d $unicast #1 | |
2060 | ||
2061 | # The vtep (vif3) is the only one configured for "unknown" | |
2062 | if test $d != $s && test $d = 3; then | |
2063 | unknown="$unknown $d" | |
2064 | fi | |
2065 | bcast="$bcast $unicast" | |
2066 | done | |
2067 | ||
2068 | test_packet $s ffffffffffff f0000000000$s 0${s}ff $bcast #2 | |
2069 | test_packet $s 010000000000 f0000000000$s 0${s}ff $bcast #3 | |
2070 | test_packet $s f0000000ffff f0000000000$s 0${s}66 $unknown #4 | |
2071 | done | |
2072 | ||
184bc3ca RB |
2073 | echo "------ ovn-nbctl show ------" |
2074 | ovn-nbctl show | |
2075 | echo "------ ovn-sbctl show ------" | |
2076 | ovn-sbctl show | |
2077 | ||
2078 | echo "------ hv1 ------" | |
2079 | as hv1 ovs-vsctl show | |
2080 | echo "------ hv1 br-int ------" | |
2081 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2082 | echo "------ hv1 br-phys ------" | |
2083 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2084 | ||
2085 | echo "------ hv2 ------" | |
2086 | as hv2 ovs-vsctl show | |
2087 | echo "------ hv2 br-int ------" | |
2088 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
2089 | echo "------ hv2 br-phys ------" | |
2090 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2091 | ||
2092 | echo "------ hv_gw ------" | |
2093 | as hv_gw ovs-vsctl show | |
2094 | echo "------ hv_gw br-phys ------" | |
2095 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2096 | echo "------ hv_gw br-phys2 ------" | |
2097 | as hv_gw ovs-ofctl -O OpenFlow13 dump-flows br-phys2 | |
2098 | ||
2099 | echo "------ hv3 ------" | |
2100 | as hv3 ovs-vsctl show | |
2101 | echo "------ hv3 br-phys ------" | |
2102 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-phys | |
2103 | ||
2104 | # Now check the packets actually received against the ones expected. | |
2105 | for i in 1 2 3; do | |
49d7c759 | 2106 | OVN_CHECK_PACKETS([hv$i/vif$i-tx.pcap], [$i.expected]) |
184bc3ca RB |
2107 | done |
2108 | AT_CLEANUP | |
2109 | ||
9975d7be BP |
2110 | # 3 hypervisors, 3 logical switches with 3 logical ports each, 1 logical router |
2111 | AT_SETUP([ovn -- 3 HVs, 3 LS, 3 lports/LS, 1 LR]) | |
2112 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
2113 | ovn_start | |
2114 | ||
2115 | # Logical network: | |
2116 | # | |
2117 | # Three logical switches ls1, ls2, ls3. | |
86e98048 BP |
2118 | # One logical router lr0 connected to ls[123], |
2119 | # with nine subnets, three per logical switch: | |
2120 | # | |
2121 | # lrp11 on ls1 for subnet 192.168.11.0/24 | |
2122 | # lrp12 on ls1 for subnet 192.168.12.0/24 | |
2123 | # lrp13 on ls1 for subnet 192.168.13.0/24 | |
2124 | # ... | |
2125 | # lrp33 on ls3 for subnet 192.168.33.0/24 | |
2126 | # | |
2127 | # 27 VIFs, 9 per LS, 3 per subnet: lp[123][123][123], where the first two | |
2128 | # digits are the subnet and the last digit distinguishes the VIF. | |
9975d7be | 2129 | for i in 1 2 3; do |
ea46a4e9 | 2130 | ovn-nbctl ls-add ls$i |
9975d7be | 2131 | for j in 1 2 3; do |
86e98048 | 2132 | for k in 1 2 3; do |
31ed1192 JP |
2133 | # Add "unknown" to MAC addresses for lp?11, so packets for |
2134 | # MAC-IP bindings discovered via ARP later have somewhere to go. | |
2135 | if test $j$k = 11; then unknown=unknown; else unknown=; fi | |
2136 | ||
2137 | ovn-nbctl \ | |
2138 | -- lsp-add ls$i lp$i$j$k \ | |
2139 | -- lsp-set-addresses lp$i$j$k "f0:00:00:00:0$i:$j$k \ | |
2140 | 192.168.$i$j.$k" $unknown | |
86e98048 BP |
2141 | done |
2142 | done | |
2143 | done | |
2144 | ||
fa2a27b2 | 2145 | ovn-nbctl lr-add lr0 |
86e98048 BP |
2146 | for i in 1 2 3; do |
2147 | for j in 1 2 3; do | |
bf44c2cd | 2148 | ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j 192.168.$i$j.254/24 |
269ecccc | 2149 | ovn-nbctl \ |
31ed1192 | 2150 | -- lsp-add ls$i lrp$i$j-attachment \ |
269ecccc | 2151 | -- set Logical_Switch_Port lrp$i$j-attachment type=router \ |
00007447 | 2152 | options:router-port=lrp$i$j \ |
86e98048 | 2153 | addresses='"00:00:00:00:ff:'$i$j'"' |
9975d7be BP |
2154 | done |
2155 | done | |
2156 | ||
80f408f4 | 2157 | ovn-nbctl set Logical_Switch_Port lrp33-attachment \ |
57d143eb HZ |
2158 | addresses='"00:00:00:00:ff:33 192.168.33.254"' |
2159 | ||
9975d7be BP |
2160 | # Physical network: |
2161 | # | |
2162 | # Three hypervisors hv[123]. | |
86e98048 BP |
2163 | # lp?1[123] spread across hv[123]: lp?11 on hv1, lp?12 on hv2, lp?13 on hv3. |
2164 | # lp?2[123] spread across hv[23]: lp?21 and lp?22 on hv2, lp?23 on hv3. | |
2165 | # lp?3[123] all on hv3. | |
2166 | ||
9975d7be BP |
2167 | |
2168 | # Given the name of a logical port, prints the name of the hypervisor | |
2169 | # on which it is located. | |
2170 | vif_to_hv() { | |
2171 | case $1 in dnl ( | |
86e98048 BP |
2172 | ?11) echo 1 ;; dnl ( |
2173 | ?12 | ?21 | ?22) echo 2 ;; dnl ( | |
2174 | ?13 | ?23 | ?3?) echo 3 ;; | |
9975d7be BP |
2175 | esac |
2176 | } | |
2177 | ||
86e98048 BP |
2178 | # Given the name of a logical port, prints the name of its logical router |
2179 | # port, e.g. "vif_to_lrp 123" yields 12. | |
2180 | vif_to_lrp() { | |
2181 | echo ${1%?} | |
2182 | } | |
2183 | ||
2184 | # Given the name of a logical port, prints the name of its logical | |
2185 | # switch, e.g. "vif_to_ls 123" yields 1. | |
e3393e3f | 2186 | vif_to_ls() { |
86e98048 | 2187 | echo ${1%??} |
e3393e3f BP |
2188 | } |
2189 | ||
9975d7be BP |
2190 | net_add n1 |
2191 | for i in 1 2 3; do | |
2192 | sim_add hv$i | |
2193 | as hv$i | |
2194 | ovs-vsctl add-br br-phys | |
2195 | ovn_attach n1 br-phys 192.168.0.$i | |
2196 | done | |
2197 | for i in 1 2 3; do | |
2198 | for j in 1 2 3; do | |
86e98048 | 2199 | for k in 1 2 3; do |
269ecccc JP |
2200 | hv=`vif_to_hv $i$j$k` |
2201 | as hv$hv ovs-vsctl \ | |
2202 | -- add-port br-int vif$i$j$k \ | |
2203 | -- set Interface vif$i$j$k \ | |
2204 | external-ids:iface-id=lp$i$j$k \ | |
2205 | options:tx_pcap=hv$hv/vif$i$j$k-tx.pcap \ | |
2206 | options:rxq_pcap=hv$hv/vif$i$j$k-rx.pcap \ | |
2207 | ofport-request=$i$j$k | |
86e98048 | 2208 | done |
9975d7be BP |
2209 | done |
2210 | done | |
2211 | ||
2212 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2213 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2214 | # for ARP resolution). | |
2215 | ovn_populate_arp | |
2216 | ||
2217 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2218 | # XXX This should be more systematic. | |
2219 | sleep 1 | |
2220 | ||
e3393e3f | 2221 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... |
9975d7be BP |
2222 | # |
2223 | # This shell function causes a packet to be received on INPORT. The packet's | |
2224 | # content has Ethernet destination DST and source SRC (each exactly 12 hex | |
2225 | # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or | |
2226 | # more) list the VIFs on which the packet should be received. INPORT and the | |
31ed1192 | 2227 | # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123. |
9975d7be BP |
2228 | for i in 1 2 3; do |
2229 | for j in 1 2 3; do | |
86e98048 BP |
2230 | for k in 1 2 3; do |
2231 | : > $i$j$k.expected | |
269ecccc | 2232 | done |
9975d7be BP |
2233 | done |
2234 | done | |
e3393e3f | 2235 | test_ip() { |
9975d7be BP |
2236 | # This packet has bad checksums but logical L3 routing doesn't check. |
2237 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
ba43992e | 2238 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
9975d7be BP |
2239 | shift; shift; shift; shift; shift |
2240 | hv=hv`vif_to_hv $inport` | |
2241 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2242 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
86e98048 BP |
2243 | in_ls=`vif_to_ls $inport` |
2244 | in_lrp=`vif_to_lrp $inport` | |
9975d7be | 2245 | for outport; do |
269ecccc | 2246 | out_ls=`vif_to_ls $outport` |
86e98048 | 2247 | if test $in_ls = $out_ls; then |
9975d7be BP |
2248 | # Ports on the same logical switch receive exactly the same packet. |
2249 | echo $packet | |
2250 | else | |
2251 | # Routing decrements TTL and updates source and dest MAC | |
2252 | # (and checksum). | |
269ecccc | 2253 | out_lrp=`vif_to_lrp $outport` |
86e98048 | 2254 | echo f00000000${outport}00000000ff${out_lrp}08004500001c00000000"3f1101"00${src_ip}${dst_ip}0035111100080000 |
e4543cfe | 2255 | fi >> $outport.expected |
9975d7be BP |
2256 | done |
2257 | } | |
2258 | ||
e3393e3f | 2259 | as hv1 ovs-vsctl --columns=name,ofport list interface |
0bac7164 BP |
2260 | as hv1 ovn-sbctl list port_binding |
2261 | as hv1 ovn-sbctl list datapath_binding | |
9975d7be BP |
2262 | as hv1 ovn-sbctl dump-flows |
2263 | as hv1 ovs-ofctl dump-flows br-int | |
2264 | ||
e3393e3f | 2265 | # Send IP packets between all pairs of source and destination ports: |
9975d7be | 2266 | # |
31ed1192 JP |
2267 | # 1. Unicast IP packets are delivered to exactly one logical switch port |
2268 | # (except that packets destined to their input ports are dropped). | |
9975d7be | 2269 | # |
31ed1192 JP |
2270 | # 2. Broadcast IP packets are delivered to all logical switch ports |
2271 | # except the input port. | |
86e98048 BP |
2272 | ip_to_hex() { |
2273 | printf "%02x%02x%02x%02x" "$@" | |
2274 | } | |
9975d7be | 2275 | for is in 1 2 3; do |
269ecccc JP |
2276 | for js in 1 2 3; do |
2277 | for ks in 1 2 3; do | |
2278 | bcast= | |
2279 | s=$is$js$ks | |
2280 | smac=f00000000$s | |
2281 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2282 | for id in 1 2 3; do | |
2283 | for jd in 1 2 3; do | |
2284 | for kd in 1 2 3; do | |
2285 | d=$id$jd$kd | |
2286 | dip=`ip_to_hex 192 168 $id$jd $kd` | |
2287 | if test $is = $id; then dmac=f00000000$d; else dmac=00000000ff$is$js; fi | |
2288 | if test $d != $s; then unicast=$d; else unicast=; fi | |
2289 | ||
2290 | test_ip $s $smac $dmac $sip $dip $unicast #1 | |
2291 | ||
2292 | if test $id = $is && test $d != $s; then bcast="$bcast $d"; fi | |
2293 | done | |
2294 | done | |
9975d7be | 2295 | done |
269ecccc JP |
2296 | test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2 |
2297 | done | |
2298 | done | |
e3393e3f BP |
2299 | done |
2300 | ||
0bac7164 BP |
2301 | # 3. Send an IP packet from every logical port to every other subnet, |
2302 | # to an IP address that does not have a static IP-MAC binding. | |
2303 | # This should generate a broadcast ARP request for the destination | |
2304 | # IP address in the destination subnet. | |
2305 | for is in 1 2 3; do | |
269ecccc JP |
2306 | for js in 1 2 3; do |
2307 | for ks in 1 2 3; do | |
2308 | s=$is$js$ks | |
2309 | smac=f00000000$s | |
2310 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2311 | for id in 1 2 3; do | |
2312 | for jd in 1 2 3; do | |
2313 | if test $is$js = $id$jd; then | |
2314 | continue | |
2315 | fi | |
2316 | ||
2317 | # Send the packet. | |
2318 | dmac=00000000ff$is$js | |
2319 | # Calculate a 4th octet for the destination that is | |
2320 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2321 | # that have static MAC bindings, and fits in the range | |
2322 | # 0-255. | |
2323 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2324 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2325 | test_ip $s $smac $dmac $sip $dip | |
2326 | ||
2327 | # Every LP on the destination subnet's lswitch should | |
2328 | # receive the ARP request. | |
2329 | lrmac=00000000ff$id$jd | |
2330 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2331 | arp=ffffffffffff${lrmac}08060001080006040001${lrmac}${lrip}000000000000${dip} | |
2332 | for jd2 in 1 2 3; do | |
2333 | for kd in 1 2 3; do | |
e4543cfe | 2334 | echo $arp >> $id$jd2$kd.expected |
0bac7164 | 2335 | done |
269ecccc | 2336 | done |
0bac7164 | 2337 | done |
269ecccc | 2338 | done |
0bac7164 | 2339 | done |
269ecccc | 2340 | done |
0bac7164 BP |
2341 | done |
2342 | ||
e3393e3f BP |
2343 | # test_arp INPORT SHA SPA TPA [REPLY_HA] |
2344 | # | |
2345 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2346 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2347 | # it should be the hardware address of the target to expect to receive in an | |
2348 | # ARP reply; otherwise no reply is expected. | |
2349 | # | |
31ed1192 | 2350 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
e3393e3f BP |
2351 | # SHA and REPLY_HA are each 12 hex digits. |
2352 | # SPA and TPA are each 8 hex digits. | |
2353 | test_arp() { | |
2354 | local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 | |
2355 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2356 | hv=hv`vif_to_hv $inport` | |
2357 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2d9b49dd | 2358 | as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request |
e3393e3f | 2359 | |
57d143eb | 2360 | # Expect to receive the broadcast ARP on the other logical switch ports if |
ea46a4e9 | 2361 | # IP address is not configured to the switch patch port. |
e3393e3f | 2362 | local i=`vif_to_ls $inport` |
86e98048 | 2363 | local j k |
e3393e3f | 2364 | for j in 1 2 3; do |
86e98048 | 2365 | for k in 1 2 3; do |
ea46a4e9 | 2366 | # 192.168.33.254 is configured to the switch patch port for lrp33, |
57d143eb HZ |
2367 | # so no ARP flooding expected for it. |
2368 | if test $i$j$k != $inport && test $tpa != `ip_to_hex 192 168 33 254`; then | |
86e98048 BP |
2369 | echo $request >> $i$j$k.expected |
2370 | fi | |
2371 | done | |
e3393e3f BP |
2372 | done |
2373 | ||
2374 | # Expect to receive the reply, if any. | |
2375 | if test X$reply_ha != X; then | |
86e98048 BP |
2376 | lrp=`vif_to_lrp $inport` |
2377 | local reply=${sha}00000000ff${lrp}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
e3393e3f BP |
2378 | echo $reply >> $inport.expected |
2379 | fi | |
2380 | } | |
2381 | ||
2382 | # Test router replies to ARP requests from all source ports: | |
2383 | # | |
0bac7164 | 2384 | # 4. Router replies to query for its MAC address from port's own IP address. |
e3393e3f | 2385 | # |
0bac7164 | 2386 | # 5. Router replies to query for its MAC address from any random IP address |
e3393e3f BP |
2387 | # in its subnet. |
2388 | # | |
0bac7164 | 2389 | # 6. Router replies to query for its MAC address from another subnet. |
e3393e3f | 2390 | # |
0bac7164 | 2391 | # 7. No reply to query for IP address other than router IP. |
e3393e3f | 2392 | for i in 1 2 3; do |
269ecccc JP |
2393 | for j in 1 2 3; do |
2394 | for k in 1 2 3; do | |
2395 | smac=f00000000$i$j$k # Source MAC | |
2396 | sip=`ip_to_hex 192 168 $i$j $k` # Source IP | |
2397 | rip=`ip_to_hex 192 168 $i$j 254` # Router IP | |
2398 | rmac=00000000ff$i$j # Router MAC | |
2399 | otherip=`ip_to_hex 192 168 $i$j 55` # Some other IP in subnet | |
2400 | test_arp $i$j$k $smac $sip $rip $rmac #4 | |
2401 | test_arp $i$j$k $smac $otherip $rip $rmac #5 | |
2402 | test_arp $i$j$k $smac 0a123456 $rip $rmac #6 | |
2403 | test_arp $i$j$k $smac $sip $otherip #7 | |
0bac7164 | 2404 | done |
269ecccc | 2405 | done |
0bac7164 BP |
2406 | done |
2407 | ||
2408 | # Allow some time for packet forwarding. | |
2409 | # XXX This can be improved. | |
2410 | sleep 1 | |
2411 | ||
2412 | # 8. Generate an ARP reply for each of the IP addresses ARPed for | |
2413 | # earlier as #3. | |
2414 | # | |
2415 | # Here, the $s is the VIF that originated the ARP request and $d is | |
2416 | # the VIF that sends the ARP reply, which is somewhat backward but | |
2417 | # it means that $s and $d are the same as #3. | |
2418 | : > mac_bindings.expected | |
2419 | for is in 1 2 3; do | |
269ecccc JP |
2420 | for js in 1 2 3; do |
2421 | for ks in 1 2 3; do | |
2422 | s=$is$js$ks | |
2423 | for id in 1 2 3; do | |
2424 | for jd in 1 2 3; do | |
2425 | if test $is$js = $id$jd; then | |
2426 | continue | |
2427 | fi | |
2428 | ||
2429 | kd=1 | |
2430 | d=$id$jd$kd | |
2431 | ||
2432 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2433 | host_ip=`ip_to_hex 192 168 $id$jd $o4` | |
2434 | host_mac=8000000000$o4 | |
2435 | ||
2436 | lrmac=00000000ff$id$jd | |
2437 | lrip=`ip_to_hex 192 168 $id$jd 254` | |
2438 | ||
2439 | arp=${lrmac}${host_mac}08060001080006040002${host_mac}${host_ip}${lrmac}${lrip} | |
2440 | ||
2441 | echo | |
2442 | echo | |
2443 | echo | |
2444 | hv=hv`vif_to_hv $d` | |
2445 | as $hv ovs-appctl netdev-dummy/receive vif$d $arp | |
2446 | #as $hv ovs-appctl ofproto/trace br-int in_port=$d $arp | |
2447 | #as $hv ovs-ofctl dump-flows br-int table=19 | |
2448 | ||
2449 | host_ip_pretty=192.168.$id$jd.$o4 | |
2450 | host_mac_pretty=80:00:00:00:00:$o4 | |
2451 | echo lrp$id$jd,$host_ip_pretty,$host_mac_pretty >> mac_bindings.expected | |
86e98048 | 2452 | done |
269ecccc | 2453 | done |
9975d7be | 2454 | done |
269ecccc | 2455 | done |
9975d7be | 2456 | done |
0bac7164 | 2457 | |
9975d7be BP |
2458 | # Allow some time for packet forwarding. |
2459 | # XXX This can be improved. | |
2460 | sleep 1 | |
2461 | ||
0bac7164 BP |
2462 | # 9. Send an IP packet from every logical port to every other subnet. These |
2463 | # are the same packets already sent as #3, but now the destinations' IP-MAC | |
2464 | # bindings have been discovered via ARP, so instead of provoking an ARP | |
2465 | # request, these packets now get routed to their destinations (which don't | |
2466 | # have static MAC bindings, so they go to the port we've designated as | |
2467 | # accepting "unknown" MACs.) | |
2468 | for is in 1 2 3; do | |
269ecccc JP |
2469 | for js in 1 2 3; do |
2470 | for ks in 1 2 3; do | |
2471 | s=$is$js$ks | |
2472 | smac=f00000000$s | |
2473 | sip=`ip_to_hex 192 168 $is$js $ks` | |
2474 | for id in 1 2 3; do | |
2475 | for jd in 1 2 3; do | |
2476 | if test $is$js = $id$jd; then | |
2477 | continue | |
2478 | fi | |
2479 | ||
2480 | # Send the packet. | |
2481 | dmac=00000000ff$is$js | |
2482 | # Calculate a 4th octet for the destination that is | |
2483 | # unique per $s, avoids the .1 .2 .3 and .254 IP addresses | |
2484 | # that have static MAC bindings, and fits in the range | |
2485 | # 0-255. | |
2486 | o4=`expr $is '*' 9 + $js '*' 3 + $ks + 10` | |
2487 | dip=`ip_to_hex 192 168 $id$jd $o4` | |
2488 | test_ip $s $smac $dmac $sip $dip | |
2489 | ||
2490 | # Expect the packet egress. | |
2491 | host_mac=8000000000$o4 | |
2492 | outport=${id}11 | |
2493 | out_lrp=$id$jd | |
e4543cfe | 2494 | echo ${host_mac}00000000ff${out_lrp}08004500001c00000000"3f1101"00${sip}${dip}0035111100080000 >> $outport.expected |
0bac7164 | 2495 | done |
269ecccc | 2496 | done |
0bac7164 | 2497 | done |
269ecccc | 2498 | done |
0bac7164 BP |
2499 | done |
2500 | ||
0bac7164 BP |
2501 | ovn-sbctl -f csv -d bare --no-heading \ |
2502 | -- --columns=logical_port,ip,mac list mac_binding > mac_bindings | |
2503 | ||
9975d7be BP |
2504 | # Now check the packets actually received against the ones expected. |
2505 | for i in 1 2 3; do | |
2506 | for j in 1 2 3; do | |
86e98048 | 2507 | for k in 1 2 3; do |
abb37b6b FF |
2508 | OVN_CHECK_PACKETS([hv`vif_to_hv $i$j$k`/vif$i$j$k-tx.pcap], |
2509 | [$i$j$k.expected]) | |
86e98048 | 2510 | done |
9975d7be BP |
2511 | done |
2512 | done | |
fcde56f5 | 2513 | |
0bac7164 BP |
2514 | # Check the MAC bindings against those expected. |
2515 | AT_CHECK_UNQUOTED([sort < mac_bindings], [0], [`sort < mac_bindings.expected` | |
2516 | ]) | |
2517 | ||
fcde56f5 | 2518 | # Gracefully terminate daemons |
7a8f15e0 | 2519 | OVN_CLEANUP([hv1], [hv2], [hv3]) |
eff49a56 | 2520 | |
9975d7be | 2521 | AT_CLEANUP |
685f4dfe NS |
2522 | |
2523 | # 3 hypervisors, one logical switch, 3 logical ports per hypervisor | |
2524 | AT_SETUP([ovn -- portsecurity : 3 HVs, 1 LS, 3 lports/HV]) | |
685f4dfe NS |
2525 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
2526 | ovn_start | |
2527 | ||
2528 | # Create hypervisors hv[123]. | |
2529 | # Add vif1[123] to hv1, vif2[123] to hv2, vif3[123] to hv3. | |
2530 | # Add all of the vifs to a single logical switch lsw0. | |
2531 | # Turn off port security on vifs vif[123]1 | |
2532 | # Turn on l2 port security on vifs vif[123]2 | |
2533 | # Turn of l2 and l3 port security on vifs vif[123]3 | |
2534 | # Make vif13, vif2[23], vif3[123] destinations for unknown MACs. | |
ea46a4e9 | 2535 | ovn-nbctl ls-add lsw0 |
685f4dfe NS |
2536 | net_add n1 |
2537 | for i in 1 2 3; do | |
2538 | sim_add hv$i | |
2539 | as hv$i | |
2540 | ovs-vsctl add-br br-phys | |
2541 | ovn_attach n1 br-phys 192.168.0.$i | |
2542 | ||
2543 | for j in 1 2 3; do | |
2544 | 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 | 2545 | ovn-nbctl lsp-add lsw0 lp$i$j |
685f4dfe | 2546 | if test $j = 1; then |
31ed1192 | 2547 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown |
685f4dfe | 2548 | elif test $j = 2; then |
31ed1192 JP |
2549 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" |
2550 | ovn-nbctl lsp-set-port-security lp$i$j f0:00:00:00:00:$i$j | |
685f4dfe NS |
2551 | else |
2552 | extra_addr="f0:00:00:00:0$i:$i$j fe80::ea2a:eaff:fe28:$i$j" | |
31ed1192 JP |
2553 | ovn-nbctl lsp-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" "$extra_addr" |
2554 | 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 |
2555 | fi |
2556 | done | |
2557 | done | |
2558 | ||
685f4dfe NS |
2559 | # Pre-populate the hypervisors' ARP tables so that we don't lose any |
2560 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2561 | # for ARP resolution). | |
2562 | ovn_populate_arp | |
2563 | ||
2564 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2565 | # XXX This should be more systematic. | |
2566 | sleep 1 | |
685f4dfe NS |
2567 | |
2568 | # Given the name of a logical port, prints the name of the hypervisor | |
2569 | # on which it is located. | |
2570 | vif_to_hv() { | |
2571 | echo hv${1%?} | |
2572 | } | |
2573 | ||
685f4dfe NS |
2574 | for i in 1 2 3; do |
2575 | for j in 1 2 3; do | |
2576 | : > $i$j.expected | |
2577 | done | |
2578 | done | |
2579 | ||
2580 | # test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
2581 | # | |
2582 | # This shell function causes an ip packet to be received on INPORT. | |
2583 | # The packet's content has Ethernet destination DST and source SRC | |
2584 | # (each exactly 12 hex digits) and Ethernet type ETHTYPE (4 hex digits). | |
2585 | # The OUTPORTs (zero or more) list the VIFs on which the packet should | |
31ed1192 JP |
2586 | # be received. INPORT and the OUTPORTs are specified as logical switch |
2587 | # port numbers, e.g. 11 for vif11. | |
685f4dfe NS |
2588 | test_ip() { |
2589 | # This packet has bad checksums but logical L3 routing doesn't check. | |
2590 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
efe179e0 | 2591 | local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 |
685f4dfe NS |
2592 | shift; shift; shift; shift; shift |
2593 | hv=`vif_to_hv $inport` | |
2594 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2595 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2596 | for outport; do | |
e4543cfe | 2597 | echo $packet >> $outport.expected |
685f4dfe NS |
2598 | done |
2599 | } | |
2600 | ||
2601 | # test_arp INPORT SHA SPA TPA DROP [REPLY_HA] | |
2602 | # | |
2603 | # Causes a packet to be received on INPORT. The packet is an ARP | |
2604 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
2605 | # it should be the hardware address of the target to expect to receive in an | |
2606 | # ARP reply; otherwise no reply is expected. | |
2607 | # | |
31ed1192 | 2608 | # INPORT is an logical switch port number, e.g. 11 for vif11. |
685f4dfe NS |
2609 | # SHA and REPLY_HA are each 12 hex digits. |
2610 | # SPA and TPA are each 8 hex digits. | |
2611 | test_arp() { | |
2612 | local inport=$1 smac=$2 sha=$3 spa=$4 tpa=$5 drop=$6 reply_ha=$7 | |
2613 | local request=ffffffffffff${smac}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
2614 | hv=`vif_to_hv $inport` | |
2615 | as $hv ovs-appctl netdev-dummy/receive vif$inport $request | |
2616 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request | |
2617 | if test $drop != 1; then | |
e137131a | 2618 | if test X$reply_ha = X; then |
685f4dfe NS |
2619 | # Expect to receive the broadcast ARP on the other logical switch ports |
2620 | # if no reply is expected. | |
2621 | local i j | |
2622 | for i in 1 2 3; do | |
2623 | for j in 1 2 3; do | |
2624 | if test $i$j != $inport; then | |
2625 | echo $request >> $i$j.expected | |
2626 | fi | |
2627 | done | |
2628 | done | |
2629 | else | |
2630 | # Expect to receive the reply, if any. | |
2631 | local reply=${smac}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
2632 | echo $reply >> $inport.expected | |
2633 | fi | |
2634 | fi | |
2635 | } | |
2636 | ||
2637 | # test_ipv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... | |
2638 | # This function is similar to test_ip() except that it sends | |
2639 | # ipv6 packet | |
2640 | test_ipv6() { | |
2641 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 | |
2642 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}0000000000000000 | |
2643 | shift; shift; shift; shift; shift | |
2644 | hv=`vif_to_hv $inport` | |
2645 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2646 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2647 | for outport; do | |
e4543cfe | 2648 | echo $packet >> $outport.expected |
685f4dfe NS |
2649 | done |
2650 | } | |
2651 | ||
9e687b23 DL |
2652 | # test_icmpv6 INPORT SRC_MAC DST_MAC SRC_IP DST_IP ICMP_TYPE OUTPORT... |
2653 | # This function is similar to test_ipv6() except it specifies the ICMPv6 type | |
2654 | # of the test packet | |
2655 | test_icmpv6() { | |
2656 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 icmp_type=$6 | |
2657 | local packet=${dst_mac}${src_mac}86dd6000000000083aff${src_ip}${dst_ip}${icmp_type}00000000000000 | |
2658 | shift; shift; shift; shift; shift; shift | |
2659 | hv=`vif_to_hv $inport` | |
2660 | as $hv ovs-appctl netdev-dummy/receive vif$inport $packet | |
2661 | #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet | |
2662 | for outport; do | |
e4543cfe | 2663 | echo $packet >> $outport.expected |
9e687b23 DL |
2664 | done |
2665 | } | |
2666 | ||
685f4dfe NS |
2667 | ip_to_hex() { |
2668 | printf "%02x%02x%02x%02x" "$@" | |
2669 | } | |
2670 | ||
2671 | # no port security | |
2672 | sip=`ip_to_hex 192 168 0 12` | |
2673 | tip=`ip_to_hex 192 168 0 13` | |
2674 | # the arp packet should be allowed even if lp[123]1 is | |
2675 | # not configured with mac f00000000023 and ip 192.168.0.12 | |
2676 | for i in 1 2 3; do | |
2677 | test_arp ${i}1 f00000000023 f00000000023 $sip $tip 0 f00000000013 | |
2678 | for j in 1 2 3; do | |
2679 | if test $i != $j; then | |
2680 | test_ip ${i}1 f000000000${i}1 f000000000${j}1 $sip $tip ${j}1 | |
2681 | fi | |
2682 | done | |
2683 | done | |
2684 | ||
2685 | # l2 port security | |
2686 | sip=`ip_to_hex 192 168 0 12` | |
2687 | tip=`ip_to_hex 192 168 0 13` | |
2688 | ||
2689 | # arp packet should be allowed since lp22 is configured with | |
2690 | # mac f00000000022 | |
2691 | test_arp 22 f00000000022 f00000000022 $sip $tip 0 f00000000013 | |
2692 | ||
2693 | # arp packet should not be allowed since lp32 is not configured with | |
2694 | # mac f00000000021 | |
2695 | test_arp 32 f00000000021 f00000000021 $sip $tip 1 | |
2696 | ||
2697 | # arp packet with sha set to f00000000021 should not be allowed | |
2698 | # for lp12 | |
2699 | test_arp 12 f00000000012 f00000000021 $sip $tip 1 | |
2700 | ||
2701 | # ip packets should be allowed and received since lp[123]2 do not | |
2702 | # have l3 port security | |
2703 | sip=`ip_to_hex 192 168 0 55` | |
2704 | tip=`ip_to_hex 192 168 0 66` | |
2705 | for i in 1 2 3; do | |
2706 | for j in 1 2 3; do | |
2707 | if test $i != $j; then | |
2708 | test_ip ${i}2 f000000000${i}2 f000000000${j}2 $sip $tip ${j}2 | |
2709 | fi | |
2710 | done | |
2711 | done | |
2712 | ||
2713 | # ipv6 packets should be received by lp[123]2 | |
2714 | # lp[123]1 can send ipv6 traffic as there is no port security | |
2715 | sip=fe800000000000000000000000000000 | |
2716 | tip=ff020000000000000000000000000000 | |
2717 | ||
2718 | for i in 1 2 3; do | |
2719 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}2 $sip $tip ${i}2 | |
2720 | done | |
2721 | ||
2722 | ||
2723 | # l2 and l3 port security | |
2724 | sip=`ip_to_hex 192 168 0 13` | |
2725 | tip=`ip_to_hex 192 168 0 22` | |
2726 | # arp packet should be allowed since lp13 is configured with | |
2727 | # f00000000013 and 192.168.0.13 | |
2728 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 | |
2729 | ||
2730 | # the arp packet should be dropped because lp23 is not configured | |
2731 | # with mac f00000000022 | |
2732 | sip=`ip_to_hex 192 168 0 13` | |
2733 | tip=`ip_to_hex 192 168 0 22` | |
2734 | test_arp 23 f00000000022 f00000000022 $sip $tip 1 | |
2735 | ||
2736 | # the arp packet should be dropped because lp33 is not configured | |
2737 | # with ip 192.168.0.55 | |
2738 | spa=`ip_to_hex 192 168 0 55` | |
2739 | tpa=`ip_to_hex 192 168 0 22` | |
2740 | test_arp 33 f00000000031 f00000000031 $spa $tpa 1 | |
2741 | ||
2742 | # ip packets should not be received by lp[123]3 since | |
2743 | # l3 port security is enabled | |
2744 | sip=`ip_to_hex 192 168 0 55` | |
2745 | tip=`ip_to_hex 192 168 0 66` | |
2746 | for i in 1 2 3; do | |
2747 | for j in 1 2 3; do | |
2748 | test_ip ${i}2 f000000000${i}2 f000000000${j}3 $sip $tip | |
2749 | done | |
2750 | done | |
2751 | ||
2752 | # ipv6 packets should be dropped for lp[123]3 since | |
2753 | # it is configured with only ipv4 address | |
2754 | sip=fe800000000000000000000000000000 | |
2755 | tip=ff020000000000000000000000000000 | |
2756 | ||
2757 | for i in 1 2 3; do | |
2758 | test_ipv6 ${i}3 f000000000${i}3 f00000000022 $sip $tip | |
2759 | done | |
2760 | ||
2761 | # ipv6 packets should not be received by lp[123]3 with mac f000000000$[123]3 | |
2762 | # lp[123]1 can send ipv6 traffic as there is no port security | |
2763 | for i in 1 2 3; do | |
2764 | test_ipv6 ${i}1 f000000000${i}1 f000000000${i}3 $sip $tip | |
2765 | done | |
2766 | ||
2767 | # lp13 has extra port security with mac f0000000113 and ipv6 addr | |
2768 | # fe80::ea2a:eaff:fe28:0012 | |
2769 | ||
2770 | # ipv4 packet should be dropped for lp13 with mac f0000000113 | |
2771 | sip=`ip_to_hex 192 168 0 13` | |
2772 | tip=`ip_to_hex 192 168 0 23` | |
2773 | test_ip 13 f00000000113 f00000000023 $sip $tip | |
2774 | ||
6d53e8a9 BP |
2775 | # ipv6 packet should be received by lp[123]3 with mac f00000000${i}${i}3 |
2776 | # and ip6.dst as fe80::ea2a:eaff:fe28:0${i}${i}3. | |
685f4dfe NS |
2777 | # lp11 can send ipv6 traffic as there is no port security |
2778 | sip=ee800000000000000000000000000000 | |
2779 | for i in 1 2 3; do | |
6d53e8a9 BP |
2780 | tip=fe80000000000000ea2aeafffe2800${i}3 |
2781 | test_ipv6 11 f00000000011 f00000000${i}${i}3 $sip $tip ${i}3 | |
685f4dfe NS |
2782 | done |
2783 | ||
2784 | ||
2785 | # ipv6 packet should not be received by lp33 with mac f0000000333 | |
2786 | # and ip6.dst as fe80::ea2a:eaff:fe28:0023 as it is | |
2787 | # configured with fe80::ea2a:eaff:fe28:0033 | |
2788 | # lp11 can send ipv6 traffic as there is no port security | |
2789 | ||
2790 | sip=ee800000000000000000000000000000 | |
2791 | tip=fe80000000000000ea2aeafffe280023 | |
2792 | test_ipv6 11 f00000000011 f00000000333 $sip $tip | |
2793 | ||
6d53e8a9 BP |
2794 | # ipv6 packet should be allowed for lp[123]3 with mac f0000000${i}${i}3 |
2795 | # and ip6.src fe80::ea2a:eaff:fe28:0${i}${i}3 and ip6.src ::. | |
685f4dfe NS |
2796 | # and should be dropped for any other ip6.src |
2797 | # lp21 can receive ipv6 traffic as there is no port security | |
2798 | ||
2799 | tip=ee800000000000000000000000000000 | |
2800 | for i in 1 2 3; do | |
2801 | sip=fe80000000000000ea2aeafffe2800${i}3 | |
2802 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 21 | |
2803 | ||
9e687b23 | 2804 | # Test ICMPv6 MLD reports (v1 and v2) and NS for DAD |
685f4dfe | 2805 | sip=00000000000000000000000000000000 |
9e687b23 DL |
2806 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 83 21 |
2807 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 8f 21 | |
2808 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff0200000000000000ea2aeafffe2800 87 21 | |
2809 | # Traffic to non-multicast traffic should be dropped | |
2810 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip 83 | |
2811 | # Traffic of other ICMPv6 types should be dropped | |
2812 | test_icmpv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip ff020000000000000000000000160000 80 | |
685f4dfe NS |
2813 | |
2814 | # should be dropped | |
2815 | sip=ae80000000000000ea2aeafffe2800aa | |
2816 | test_ipv6 ${i}3 f00000000${i}${i}3 f00000000021 $sip $tip | |
2817 | done | |
2818 | ||
31ed1192 JP |
2819 | # configure lsp13 to send and received IPv4 packets with an address range |
2820 | 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 | 2821 | |
8ff5a966 NS |
2822 | sleep 2 |
2823 | ||
7d9d86ad NS |
2824 | sip=`ip_to_hex 10 0 0 13` |
2825 | tip=`ip_to_hex 192 168 0 22` | |
31ed1192 | 2826 | # arp packet with inner ip 10.0.0.13 should be allowed for lsp13 |
7d9d86ad NS |
2827 | test_arp 13 f00000000013 f00000000013 $sip $tip 0 f00000000022 |
2828 | ||
2829 | sip=`ip_to_hex 10 0 0 14` | |
2830 | tip=`ip_to_hex 192 168 0 23` | |
31ed1192 | 2831 | # IPv4 packet from lsp13 with src ip 10.0.0.14 destined to lsp23 |
7d9d86ad NS |
2832 | # with dst ip 192.168.0.23 should be allowed |
2833 | test_ip 13 f00000000013 f00000000023 $sip $tip 23 | |
2834 | ||
2835 | sip=`ip_to_hex 192 168 0 33` | |
2836 | tip=`ip_to_hex 10 0 0 15` | |
31ed1192 JP |
2837 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2838 | # with dst ip 10.0.0.15 should be received by lsp13 | |
7d9d86ad NS |
2839 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2840 | ||
2841 | sip=`ip_to_hex 192 168 0 33` | |
2842 | tip=`ip_to_hex 20 0 0 4` | |
31ed1192 JP |
2843 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2844 | # with dst ip 20.0.0.4 should be received by lsp13 | |
7d9d86ad NS |
2845 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2846 | ||
2847 | sip=`ip_to_hex 192 168 0 33` | |
2848 | tip=`ip_to_hex 20 0 0 5` | |
31ed1192 JP |
2849 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2850 | # with dst ip 20.0.0.5 should not be received by lsp13 | |
7d9d86ad NS |
2851 | test_ip 33 f00000000033 f00000000013 $sip $tip |
2852 | ||
2853 | sip=`ip_to_hex 192 168 0 33` | |
2854 | tip=`ip_to_hex 20 0 0 255` | |
31ed1192 JP |
2855 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2856 | # with dst ip 20.0.0.255 should be received by lsp13 | |
7d9d86ad NS |
2857 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
2858 | ||
2859 | sip=`ip_to_hex 192 168 0 33` | |
2860 | tip=`ip_to_hex 192 168 0 255` | |
31ed1192 JP |
2861 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2862 | # with dst ip 192.168.0.255 should not be received by lsp13 | |
7d9d86ad NS |
2863 | test_ip 33 f00000000033 f00000000013 $sip $tip |
2864 | ||
2865 | sip=`ip_to_hex 192 168 0 33` | |
2866 | tip=`ip_to_hex 224 0 0 4` | |
31ed1192 JP |
2867 | # IPv4 packet from lsp33 with src ip 192.168.0.33 destined to lsp13 |
2868 | # with dst ip 224.0.0.4 should be received by lsp13 | |
7d9d86ad | 2869 | test_ip 33 f00000000033 f00000000013 $sip $tip 13 |
685f4dfe | 2870 | |
bb0c41d3 RM |
2871 | #dump information including flow counters |
2872 | ovn-nbctl show | |
2873 | ovn-sbctl dump-flows -- list multicast_group | |
2874 | ||
2875 | echo "------ hv1 dump ------" | |
2876 | as hv1 ovs-vsctl show | |
6195e2e7 | 2877 | as hv1 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2878 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2879 | ||
2880 | echo "------ hv2 dump ------" | |
2881 | as hv2 ovs-vsctl show | |
6195e2e7 | 2882 | as hv2 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2883 | as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2884 | ||
2885 | echo "------ hv3 dump ------" | |
2886 | as hv3 ovs-vsctl show | |
6195e2e7 | 2887 | as hv3 ovs-ofctl -O OpenFlow13 show br-int |
bb0c41d3 RM |
2888 | as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int |
2889 | ||
685f4dfe NS |
2890 | # Now check the packets actually received against the ones expected. |
2891 | for i in 1 2 3; do | |
2892 | for j in 1 2 3; do | |
49d7c759 | 2893 | OVN_CHECK_PACKETS([hv$i/vif$i$j-tx.pcap], [$i$j.expected]) |
685f4dfe NS |
2894 | done |
2895 | done | |
2896 | ||
7a8f15e0 | 2897 | OVN_CLEANUP([hv1],[hv2],[hv3]) |
d9c8c57c | 2898 | |
685f4dfe | 2899 | AT_CLEANUP |
509afdc3 GS |
2900 | |
2901 | AT_SETUP([ovn -- 2 HVs, 2 LS, 1 lport/LS, 2 peer LRs]) | |
509afdc3 GS |
2902 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
2903 | ovn_start | |
2904 | ||
2905 | # Logical network: | |
2906 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
2907 | # network. R1 has a switchs ls1 (191.168.1.0/24) connected to it. | |
2908 | # R2 has ls2 (172.16.1.0/24) connected to it. | |
2909 | ||
3c1ae70a JP |
2910 | ls1_lp1_mac="f0:00:00:01:02:03" |
2911 | rp_ls1_mac="00:00:00:01:02:03" | |
2912 | rp_ls2_mac="00:00:00:01:02:04" | |
2913 | ls2_lp1_mac="f0:00:00:01:02:04" | |
2914 | ||
2915 | ls1_lp1_ip="192.168.1.2" | |
2916 | ls2_lp1_ip="172.16.1.2" | |
2917 | ||
fa2a27b2 JP |
2918 | ovn-nbctl lr-add R1 |
2919 | ovn-nbctl lr-add R2 | |
509afdc3 | 2920 | |
ea46a4e9 JP |
2921 | ovn-nbctl ls-add ls1 |
2922 | ovn-nbctl ls-add ls2 | |
509afdc3 GS |
2923 | |
2924 | # Connect ls1 to R1 | |
3c1ae70a | 2925 | ovn-nbctl lrp-add R1 ls1 $rp_ls1_mac 192.168.1.1/24 |
509afdc3 | 2926 | |
31ed1192 | 2927 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
3c1ae70a | 2928 | options:router-port=ls1 addresses=\"$rp_ls1_mac\" |
509afdc3 GS |
2929 | |
2930 | # Connect ls2 to R2 | |
3c1ae70a | 2931 | ovn-nbctl lrp-add R2 ls2 $rp_ls2_mac 172.16.1.1/24 |
509afdc3 | 2932 | |
31ed1192 | 2933 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
3c1ae70a | 2934 | options:router-port=ls2 addresses=\"$rp_ls2_mac\" |
509afdc3 GS |
2935 | |
2936 | # Connect R1 to R2 | |
4685e523 JP |
2937 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
2938 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
509afdc3 | 2939 | |
6d9ecfa9 JP |
2940 | ovn-nbctl lr-route-add R1 "0.0.0.0/0" 20.0.0.2 |
2941 | ovn-nbctl lr-route-add R2 "0.0.0.0/0" 20.0.0.1 | |
509afdc3 GS |
2942 | |
2943 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 | 2944 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3c1ae70a | 2945 | -- lsp-set-addresses ls1-lp1 "$ls1_lp1_mac $ls1_lp1_ip" |
509afdc3 GS |
2946 | |
2947 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 | 2948 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3c1ae70a | 2949 | -- lsp-set-addresses ls2-lp1 "$ls2_lp1_mac $ls2_lp1_ip" |
509afdc3 GS |
2950 | |
2951 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
2952 | net_add n1 | |
2953 | ||
2954 | sim_add hv1 | |
2955 | as hv1 | |
2956 | ovs-vsctl add-br br-phys | |
2957 | ovn_attach n1 br-phys 192.168.0.1 | |
2958 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
2959 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
2960 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
2961 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
2962 | ofport-request=1 | |
2963 | ||
2964 | sim_add hv2 | |
2965 | as hv2 | |
2966 | ovs-vsctl add-br br-phys | |
2967 | ovn_attach n1 br-phys 192.168.0.2 | |
2968 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
2969 | set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \ | |
2970 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
2971 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
2972 | ofport-request=1 | |
2973 | ||
2974 | ||
2975 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
2976 | # packets for ARP resolution (native tunneling doesn't queue packets | |
2977 | # for ARP resolution). | |
2978 | ovn_populate_arp | |
2979 | ||
2980 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
2981 | # XXX This should be more systematic. | |
2982 | sleep 1 | |
2983 | ||
509afdc3 | 2984 | # Packet to send. |
3c1ae70a JP |
2985 | packet="inport==\"ls1-lp1\" && eth.src==$ls1_lp1_mac && eth.dst==$rp_ls1_mac && |
2986 | ip4 && ip.ttl==64 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
2987 | udp && udp.src==53 && udp.dst==4369" | |
2988 | as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" | |
509afdc3 GS |
2989 | |
2990 | ||
2991 | echo "---------NB dump-----" | |
2992 | ovn-nbctl show | |
2993 | echo "---------------------" | |
2994 | ovn-nbctl list logical_router | |
2995 | echo "---------------------" | |
2996 | ovn-nbctl list logical_router_port | |
2997 | echo "---------------------" | |
2998 | ||
2999 | echo "---------SB dump-----" | |
3000 | ovn-sbctl list datapath_binding | |
3001 | echo "---------------------" | |
3002 | ovn-sbctl list port_binding | |
3003 | echo "---------------------" | |
3004 | ||
3005 | echo "------ hv1 dump ----------" | |
8dab1022 | 3006 | as hv1 ovs-ofctl show br-int |
509afdc3 GS |
3007 | as hv1 ovs-ofctl dump-flows br-int |
3008 | echo "------ hv2 dump ----------" | |
8dab1022 | 3009 | as hv2 ovs-ofctl show br-int |
509afdc3 GS |
3010 | as hv2 ovs-ofctl dump-flows br-int |
3011 | ||
3012 | # Packet to Expect | |
3c1ae70a JP |
3013 | # The TTL should be decremented by 2. |
3014 | packet="eth.src==$rp_ls2_mac && eth.dst==$ls2_lp1_mac && | |
3015 | ip4 && ip.ttl==62 && ip4.src==$ls1_lp1_ip && ip4.dst==$ls2_lp1_ip && | |
3016 | udp && udp.src==53 && udp.dst==4369" | |
3017 | echo $packet | ovstest test-ovn expr-to-packets > expected | |
509afdc3 | 3018 | |
49d7c759 | 3019 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
509afdc3 | 3020 | |
7a8f15e0 | 3021 | OVN_CLEANUP([hv1],[hv2]) |
509afdc3 GS |
3022 | |
3023 | AT_CLEANUP | |
5412db30 J |
3024 | |
3025 | ||
4685e523 JP |
3026 | AT_SETUP([ovn -- 1 HV, 1 LS, 2 lport/LS, 1 LR]) |
3027 | AT_KEYWORDS([router-admin-state]) | |
3028 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3029 | ovn_start | |
3030 | ||
3031 | # Logical network: | |
3032 | # One LR - R1 has switch ls1 with two subnets attached to it (191.168.1.0/24 | |
3033 | # and 172.16.1.0/24) connected to it. | |
3034 | ||
3035 | ovn-nbctl lr-add R1 | |
3036 | ||
3037 | ovn-nbctl ls-add ls1 | |
3038 | ||
3039 | # Connect ls1 to R1 | |
bf44c2cd | 3040 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 172.16.1.1/24 |
4685e523 JP |
3041 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
3042 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" | |
3043 | ||
3044 | # Create logical port ls1-lp1 in ls1 | |
3045 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3046 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
3047 | ||
3048 | # Create logical port ls1-lp2 in ls1 | |
3049 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3050 | -- lsp-set-addresses ls1-lp2 "f0:00:00:01:02:04 172.16.1.2" | |
3051 | ||
3052 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3053 | net_add n1 | |
3054 | ||
3055 | sim_add hv1 | |
3056 | as hv1 | |
3057 | ovs-vsctl add-br br-phys | |
3058 | ovn_attach n1 br-phys 192.168.0.1 | |
3059 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3060 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3061 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3062 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3063 | ofport-request=1 | |
3064 | ||
3065 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3066 | set interface vif2 external-ids:iface-id=ls1-lp2 \ | |
3067 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3068 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3069 | ofport-request=1 | |
3070 | ||
3071 | ||
3072 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3073 | # XXX This should be more systematic. | |
3074 | sleep 1 | |
3075 | ||
3076 | # Send ip packets between the two ports. | |
3077 | ip_to_hex() { | |
3078 | printf "%02x%02x%02x%02x" "$@" | |
3079 | } | |
4685e523 JP |
3080 | |
3081 | # Packet to send. | |
3082 | src_mac="f00000010203" | |
3083 | dst_mac="000000010203" | |
3084 | src_ip=`ip_to_hex 192 168 1 2` | |
3085 | dst_ip=`ip_to_hex 172 16 1 2` | |
3086 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3087 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3088 | ||
3089 | ||
3090 | echo "---------NB dump-----" | |
3091 | ovn-nbctl show | |
3092 | echo "---------------------" | |
3093 | ovn-nbctl list logical_router | |
3094 | echo "---------------------" | |
3095 | ovn-nbctl list logical_router_port | |
3096 | echo "---------------------" | |
3097 | ||
3098 | echo "---------SB dump-----" | |
3099 | ovn-sbctl list datapath_binding | |
3100 | echo "---------------------" | |
3101 | ovn-sbctl list logical_flow | |
3102 | echo "---------------------" | |
3103 | ||
3104 | echo "------ hv1 dump ----------" | |
3105 | as hv1 ovs-ofctl dump-flows br-int | |
3106 | ||
3107 | ||
3108 | #Disable router R1 | |
3109 | ovn-nbctl set Logical_Router R1 enabled=false | |
3110 | ||
3b8cd0ea BP |
3111 | # Allow some time for ovn-northd and ovn-controller to catch up. |
3112 | # XXX This should be more systematic. | |
3113 | sleep 1 | |
3114 | ||
4685e523 JP |
3115 | echo "---------SB dump-----" |
3116 | ovn-sbctl list datapath_binding | |
3117 | echo "---------------------" | |
3118 | ovn-sbctl list logical_flow | |
3119 | echo "---------------------" | |
3120 | ||
3121 | echo "------ hv1 dump ----------" | |
3122 | as hv1 ovs-ofctl dump-flows br-int | |
3123 | ||
3124 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3125 | ||
3126 | # Packet to Expect | |
3127 | expect_src_mac="000000010203" | |
3128 | expect_dst_mac="f00000010204" | |
49d7c759 | 3129 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
4685e523 | 3130 | |
49d7c759 | 3131 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
4685e523 JP |
3132 | |
3133 | ||
3134 | as hv1 | |
3135 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
3136 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3137 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3138 | ||
3139 | as ovn-sb | |
3140 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3141 | ||
3142 | as ovn-nb | |
3143 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3144 | ||
3145 | as northd | |
3146 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
3147 | ||
3148 | as main | |
3149 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3150 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3151 | ||
3152 | AT_CLEANUP | |
3153 | ||
3154 | ||
3155 | AT_SETUP([ovn -- 1 HV, 2 LSs, 1 lport/LS, 1 LR]) | |
5412db30 J |
3156 | AT_KEYWORDS([router-admin-state]) |
3157 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
3158 | ovn_start | |
3159 | ||
3160 | # Logical network: | |
3161 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
3162 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
3163 | ||
fa2a27b2 | 3164 | ovn-nbctl lr-add R1 |
5412db30 | 3165 | |
ea46a4e9 JP |
3166 | ovn-nbctl ls-add ls1 |
3167 | ovn-nbctl ls-add ls2 | |
5412db30 J |
3168 | |
3169 | # Connect ls1 to R1 | |
bf44c2cd | 3170 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3171 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \ |
31114af7 | 3172 | options:router-port=ls1 addresses=\"00:00:00:01:02:03\" |
5412db30 J |
3173 | |
3174 | # Connect ls2 to R1 | |
bf44c2cd | 3175 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3176 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \ |
31114af7 | 3177 | options:router-port=ls2 addresses=\"00:00:00:01:02:04\" |
5412db30 J |
3178 | |
3179 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
3180 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
3181 | -- lsp-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2" | |
5412db30 J |
3182 | |
3183 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
3184 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
3185 | -- lsp-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2" | |
5412db30 J |
3186 | |
3187 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
3188 | net_add n1 | |
3189 | ||
3190 | sim_add hv1 | |
3191 | as hv1 | |
3192 | ovs-vsctl add-br br-phys | |
3193 | ovn_attach n1 br-phys 192.168.0.1 | |
3194 | ovs-vsctl -- add-port br-int vif1 -- \ | |
3195 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
3196 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3197 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3198 | ofport-request=1 | |
3199 | ||
3200 | ovs-vsctl -- add-port br-int vif2 -- \ | |
3201 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
3202 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3203 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3204 | ofport-request=1 | |
3205 | ||
3206 | ||
3207 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3208 | # XXX This should be more systematic. | |
3209 | sleep 1 | |
3210 | ||
3211 | # Send ip packets between the two ports. | |
3212 | ip_to_hex() { | |
3213 | printf "%02x%02x%02x%02x" "$@" | |
3214 | } | |
5412db30 J |
3215 | |
3216 | # Packet to send. | |
3217 | src_mac="f00000010203" | |
3218 | dst_mac="000000010203" | |
3219 | src_ip=`ip_to_hex 192 168 1 2` | |
3220 | dst_ip=`ip_to_hex 172 16 1 2` | |
3221 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3222 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet | |
3223 | ||
3224 | ||
3225 | echo "---------NB dump-----" | |
3226 | ovn-nbctl show | |
3227 | echo "---------------------" | |
3228 | ovn-nbctl list logical_router | |
3229 | echo "---------------------" | |
3230 | ovn-nbctl list logical_router_port | |
3231 | echo "---------------------" | |
3232 | ||
3233 | echo "---------SB dump-----" | |
3234 | ovn-sbctl list datapath_binding | |
3235 | echo "---------------------" | |
3236 | ovn-sbctl list logical_flow | |
3237 | echo "---------------------" | |
3238 | ||
3239 | echo "------ hv1 dump ----------" | |
3240 | as hv1 ovs-ofctl dump-flows br-int | |
3241 | ||
5412db30 J |
3242 | #Disable router R1 |
3243 | ovn-nbctl set Logical_Router R1 enabled=false | |
3244 | ||
3245 | echo "---------SB dump-----" | |
3246 | ovn-sbctl list datapath_binding | |
3247 | echo "---------------------" | |
3248 | ovn-sbctl list logical_flow | |
3249 | echo "---------------------" | |
3250 | ||
3251 | echo "------ hv1 dump ----------" | |
3252 | as hv1 ovs-ofctl dump-flows br-int | |
3253 | ||
a1361a6e LR |
3254 | # Allow some time for the disabling of logical router R1 to propagate. |
3255 | # XXX This should be more systematic. | |
3256 | sleep 1 | |
3257 | ||
5412db30 J |
3258 | as hv1 ovs-appctl netdev-dummy/receive vif1 $packet |
3259 | ||
3260 | # Packet to Expect | |
3261 | expect_src_mac="000000010204" | |
3262 | expect_dst_mac="f00000010204" | |
49d7c759 | 3263 | echo "${expect_dst_mac}${expect_src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected |
5412db30 | 3264 | |
49d7c759 | 3265 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
5412db30 | 3266 | |
7a8f15e0 | 3267 | OVN_CLEANUP([hv1]) |
5412db30 J |
3268 | |
3269 | AT_CLEANUP | |
3270 | ||
28dc3fe9 | 3271 | AT_SETUP([ovn -- 2 HVs, 3 LS, 1 lport/LS, 2 peer LRs, static routes]) |
28dc3fe9 SR |
3272 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3273 | ovn_start | |
3274 | ||
3275 | # Logical network: | |
3276 | # Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24 | |
3277 | # network. R1 has switchess foo (192.168.1.0/24) | |
3278 | # connected to it. | |
3279 | # R2 has alice (172.16.1.0/24) and bob (172.16.2.0/24) connected to it. | |
3280 | ||
fa2a27b2 JP |
3281 | ovn-nbctl lr-add R1 |
3282 | ovn-nbctl lr-add R2 | |
28dc3fe9 | 3283 | |
ea46a4e9 JP |
3284 | ovn-nbctl ls-add foo |
3285 | ovn-nbctl ls-add alice | |
3286 | ovn-nbctl ls-add bob | |
28dc3fe9 SR |
3287 | |
3288 | # Connect foo to R1 | |
bf44c2cd | 3289 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 |
31ed1192 | 3290 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 3291 | options:router-port=foo addresses=\"00:00:00:01:02:03\" |
28dc3fe9 SR |
3292 | |
3293 | # Connect alice to R2 | |
bf44c2cd | 3294 | ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24 |
31ed1192 | 3295 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 3296 | type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" |
28dc3fe9 SR |
3297 | |
3298 | # Connect bob to R2 | |
bf44c2cd | 3299 | ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24 |
31ed1192 | 3300 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob type=router \ |
31114af7 | 3301 | options:router-port=bob addresses=\"00:00:00:01:02:05\" |
28dc3fe9 SR |
3302 | |
3303 | # Connect R1 to R2 | |
4685e523 JP |
3304 | ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 peer=R2_R1 |
3305 | ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 peer=R1_R2 | |
28dc3fe9 SR |
3306 | |
3307 | #install static routes | |
e48ccf3c JP |
3308 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
3309 | ovn-nbctl lr-route-add R2 172.16.2.0/24 20.0.0.2 R1_R2 | |
3310 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 | |
28dc3fe9 SR |
3311 | |
3312 | # Create logical port foo1 in foo | |
31ed1192 JP |
3313 | ovn-nbctl lsp-add foo foo1 \ |
3314 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
28dc3fe9 SR |
3315 | |
3316 | # Create logical port alice1 in alice | |
31ed1192 JP |
3317 | ovn-nbctl lsp-add alice alice1 \ |
3318 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
28dc3fe9 SR |
3319 | |
3320 | # Create logical port bob1 in bob | |
31ed1192 JP |
3321 | ovn-nbctl lsp-add bob bob1 \ |
3322 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 172.16.2.2" | |
28dc3fe9 SR |
3323 | |
3324 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3325 | net_add n1 | |
3326 | ||
3327 | sim_add hv1 | |
3328 | as hv1 | |
3329 | ovs-vsctl add-br br-phys | |
3330 | ovn_attach n1 br-phys 192.168.0.1 | |
3331 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3332 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3333 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3334 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3335 | ofport-request=1 | |
3336 | ||
3337 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3338 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
3339 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3340 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3341 | ofport-request=2 | |
3342 | ||
3343 | sim_add hv2 | |
3344 | as hv2 | |
3345 | ovs-vsctl add-br br-phys | |
3346 | ovn_attach n1 br-phys 192.168.0.2 | |
3347 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3348 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
3349 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3350 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3351 | ofport-request=1 | |
3352 | ||
3353 | ||
3354 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3355 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3356 | # for ARP resolution). | |
3357 | ovn_populate_arp | |
3358 | ||
3359 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3360 | # XXX This should be more systematic. | |
3361 | sleep 1 | |
3362 | ||
3363 | ip_to_hex() { | |
3364 | printf "%02x%02x%02x%02x" "$@" | |
3365 | } | |
28dc3fe9 SR |
3366 | |
3367 | # Send ip packets between foo1 and alice1 | |
3368 | src_mac="f00000010203" | |
3369 | dst_mac="000000010203" | |
3370 | src_ip=`ip_to_hex 192 168 1 2` | |
3371 | dst_ip=`ip_to_hex 172 16 1 2` | |
3372 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3373 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3374 | ||
3375 | # Send ip packets between foo1 and bob1 | |
3376 | src_mac="f00000010203" | |
3377 | dst_mac="000000010203" | |
3378 | src_ip=`ip_to_hex 192 168 1 2` | |
3379 | dst_ip=`ip_to_hex 172 16 2 2` | |
3380 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3381 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3382 | ||
3383 | echo "---------NB dump-----" | |
3384 | ovn-nbctl show | |
3385 | echo "---------------------" | |
3386 | ovn-nbctl list logical_router | |
3387 | echo "---------------------" | |
3388 | ovn-nbctl list logical_router_port | |
3389 | echo "---------------------" | |
3390 | ||
3391 | echo "---------SB dump-----" | |
3392 | ovn-sbctl list datapath_binding | |
3393 | echo "---------------------" | |
3394 | ovn-sbctl list port_binding | |
3395 | echo "---------------------" | |
3396 | ||
3397 | echo "------ hv1 dump ----------" | |
3398 | as hv1 ovs-ofctl dump-flows br-int | |
3399 | echo "------ hv2 dump ----------" | |
3400 | as hv2 ovs-ofctl dump-flows br-int | |
3401 | ||
3402 | # Packet to Expect at bob1 | |
3403 | src_mac="000000010205" | |
3404 | dst_mac="f00000010205" | |
3405 | src_ip=`ip_to_hex 192 168 1 2` | |
3406 | dst_ip=`ip_to_hex 172 16 2 2` | |
49d7c759 | 3407 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 3408 | |
49d7c759 | 3409 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
28dc3fe9 SR |
3410 | |
3411 | # Packet to Expect at alice1 | |
3412 | src_mac="000000010204" | |
3413 | dst_mac="f00000010204" | |
3414 | src_ip=`ip_to_hex 192 168 1 2` | |
3415 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 3416 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
28dc3fe9 | 3417 | |
49d7c759 | 3418 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
28dc3fe9 | 3419 | |
7a8f15e0 | 3420 | OVN_CLEANUP([hv1],[hv2]) |
28dc3fe9 SR |
3421 | |
3422 | AT_CLEANUP | |
5412db30 | 3423 | |
0ee8aaf6 | 3424 | AT_SETUP([ovn -- send gratuitous arp on localnet]) |
d08dbed7 | 3425 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
0ee8aaf6 | 3426 | ovn_start |
ea46a4e9 | 3427 | ovn-nbctl ls-add lsw0 |
0ee8aaf6 RR |
3428 | net_add n1 |
3429 | sim_add hv | |
3430 | as hv | |
3431 | ovs-vsctl \ | |
3432 | -- add-br br-phys \ | |
3433 | -- add-br br-eth0 | |
3434 | ||
3435 | ovn_attach n1 br-phys 192.168.0.1 | |
3436 | ||
3437 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
3438 | 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]) | |
3439 | ||
3440 | # Create a vif. | |
31ed1192 JP |
3441 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) |
3442 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.2"]) | |
3443 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
0ee8aaf6 RR |
3444 | |
3445 | # Create a localnet port. | |
31ed1192 JP |
3446 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) |
3447 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
3448 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
3449 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
0ee8aaf6 RR |
3450 | |
3451 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
3452 | ||
3453 | # Wait for packet to be received. | |
49d7c759 BP |
3454 | echo "fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" > expected |
3455 | OVN_CHECK_PACKETS([hv/snoopvif-tx.pcap], [expected]) | |
0ee8aaf6 RR |
3456 | |
3457 | # Delete the localnet ports. | |
3458 | AT_CHECK([ovs-vsctl del-port localvif1]) | |
31ed1192 | 3459 | AT_CHECK([ovn-nbctl lsp-del ln_port]) |
0ee8aaf6 | 3460 | |
7a8f15e0 | 3461 | OVN_CLEANUP([hv]) |
0ee8aaf6 RR |
3462 | |
3463 | AT_CLEANUP | |
75cf9d2b GS |
3464 | |
3465 | AT_SETUP([ovn -- 2 HVs, 3 LRs connected via LS, static routes]) | |
75cf9d2b GS |
3466 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3467 | ovn_start | |
3468 | ||
3469 | # Logical network: | |
3470 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
3471 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
3472 | # connected to it. R2 has alice (172.16.1.0/24) and R3 has bob (10.32.1.0/24) | |
3473 | # connected to it. | |
3474 | ||
fa2a27b2 JP |
3475 | ovn-nbctl lr-add R1 |
3476 | ovn-nbctl lr-add R2 | |
3477 | ovn-nbctl lr-add R3 | |
75cf9d2b | 3478 | |
ea46a4e9 JP |
3479 | ovn-nbctl ls-add foo |
3480 | ovn-nbctl ls-add alice | |
3481 | ovn-nbctl ls-add bob | |
3482 | ovn-nbctl ls-add join | |
75cf9d2b GS |
3483 | |
3484 | # Connect foo to R1 | |
31114af7 | 3485 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 3486 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ |
31114af7 | 3487 | options:router-port=foo addresses=\"00:00:01:01:02:03\" |
75cf9d2b GS |
3488 | |
3489 | # Connect alice to R2 | |
31114af7 | 3490 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 3491 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 3492 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
75cf9d2b GS |
3493 | |
3494 | # Connect bob to R3 | |
31114af7 | 3495 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24 |
31ed1192 | 3496 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ |
80f408f4 | 3497 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" |
75cf9d2b GS |
3498 | |
3499 | # Connect R1 to join | |
31114af7 | 3500 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 3501 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 3502 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
75cf9d2b GS |
3503 | |
3504 | # Connect R2 to join | |
31114af7 | 3505 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 3506 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 3507 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
75cf9d2b GS |
3508 | |
3509 | # Connect R3 to join | |
31114af7 | 3510 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 |
31ed1192 | 3511 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ |
80f408f4 | 3512 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' |
75cf9d2b GS |
3513 | |
3514 | #install static routes | |
e48ccf3c JP |
3515 | ovn-nbctl lr-route-add R1 172.16.1.0/24 20.0.0.2 |
3516 | ovn-nbctl lr-route-add R1 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 3517 | |
e48ccf3c JP |
3518 | ovn-nbctl lr-route-add R2 192.168.1.0/24 20.0.0.1 |
3519 | ovn-nbctl lr-route-add R2 10.32.1.0/24 20.0.0.3 | |
75cf9d2b | 3520 | |
e48ccf3c JP |
3521 | ovn-nbctl lr-route-add R3 192.168.1.0/24 20.0.0.1 |
3522 | ovn-nbctl lr-route-add R3 172.16.1.0/24 20.0.0.2 | |
75cf9d2b GS |
3523 | |
3524 | # Create logical port foo1 in foo | |
31ed1192 JP |
3525 | ovn-nbctl lsp-add foo foo1 \ |
3526 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
75cf9d2b GS |
3527 | |
3528 | # Create logical port alice1 in alice | |
31ed1192 JP |
3529 | ovn-nbctl lsp-add alice alice1 \ |
3530 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
75cf9d2b GS |
3531 | |
3532 | # Create logical port bob1 in bob | |
31ed1192 JP |
3533 | ovn-nbctl lsp-add bob bob1 \ |
3534 | -- lsp-set-addresses bob1 "f0:00:00:01:02:05 10.32.1.2" | |
75cf9d2b GS |
3535 | |
3536 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
3537 | net_add n1 | |
3538 | ||
3539 | sim_add hv1 | |
3540 | as hv1 | |
3541 | ovs-vsctl add-br br-phys | |
3542 | ovn_attach n1 br-phys 192.168.0.1 | |
3543 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3544 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
3545 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3546 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3547 | ofport-request=1 | |
3548 | ||
3549 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3550 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
3551 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3552 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3553 | ofport-request=2 | |
3554 | ||
3555 | sim_add hv2 | |
3556 | as hv2 | |
3557 | ovs-vsctl add-br br-phys | |
3558 | ovn_attach n1 br-phys 192.168.0.2 | |
3559 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
3560 | set interface hv2-vif1 external-ids:iface-id=bob1 \ | |
3561 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
3562 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
3563 | ofport-request=1 | |
3564 | ||
3565 | ||
3566 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
3567 | # packets for ARP resolution (native tunneling doesn't queue packets | |
3568 | # for ARP resolution). | |
3569 | ovn_populate_arp | |
3570 | ||
3571 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
3572 | # XXX This should be more systematic. | |
3573 | sleep 1 | |
3574 | ||
3575 | ip_to_hex() { | |
3576 | printf "%02x%02x%02x%02x" "$@" | |
3577 | } | |
75cf9d2b GS |
3578 | |
3579 | # Send ip packets between foo1 and alice1 | |
3580 | src_mac="f00000010203" | |
3581 | dst_mac="000001010203" | |
3582 | src_ip=`ip_to_hex 192 168 1 2` | |
3583 | dst_ip=`ip_to_hex 172 16 1 2` | |
3584 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3585 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3586 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
3587 | ||
3588 | # Send ip packets between foo1 and bob1 | |
3589 | src_mac="f00000010203" | |
3590 | dst_mac="000001010203" | |
3591 | src_ip=`ip_to_hex 192 168 1 2` | |
3592 | dst_ip=`ip_to_hex 10 32 1 2` | |
3593 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
3594 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
3595 | ||
3596 | echo "---------NB dump-----" | |
3597 | ovn-nbctl show | |
3598 | echo "---------------------" | |
3599 | ovn-nbctl list logical_router | |
3600 | echo "---------------------" | |
3601 | ovn-nbctl list logical_router_port | |
3602 | echo "---------------------" | |
3603 | ||
3604 | echo "---------SB dump-----" | |
3605 | ovn-sbctl list datapath_binding | |
3606 | echo "---------------------" | |
3607 | ovn-sbctl list port_binding | |
3608 | echo "---------------------" | |
3609 | ovn-sbctl dump-flows | |
3610 | echo "---------------------" | |
3611 | ||
3612 | echo "------ hv1 dump ----------" | |
3613 | as hv1 ovs-ofctl show br-int | |
3614 | as hv1 ovs-ofctl dump-flows br-int | |
3615 | echo "------ hv2 dump ----------" | |
3616 | as hv2 ovs-ofctl show br-int | |
3617 | as hv2 ovs-ofctl dump-flows br-int | |
3618 | echo "----------------------------" | |
3619 | ||
3620 | # Packet to Expect at bob1 | |
3621 | src_mac="000003010203" | |
3622 | dst_mac="f00000010205" | |
3623 | src_ip=`ip_to_hex 192 168 1 2` | |
3624 | dst_ip=`ip_to_hex 10 32 1 2` | |
49d7c759 | 3625 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 3626 | |
49d7c759 | 3627 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) |
75cf9d2b GS |
3628 | |
3629 | # Packet to Expect at alice1 | |
3630 | src_mac="000002010203" | |
3631 | dst_mac="f00000010204" | |
3632 | src_ip=`ip_to_hex 192 168 1 2` | |
3633 | dst_ip=`ip_to_hex 172 16 1 2` | |
49d7c759 | 3634 | echo "${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000" > expected |
75cf9d2b | 3635 | |
49d7c759 | 3636 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) |
75cf9d2b | 3637 | |
7a8f15e0 | 3638 | OVN_CLEANUP([hv1],[hv2]) |
75cf9d2b GS |
3639 | |
3640 | AT_CLEANUP | |
c1645003 | 3641 | |
281977f7 | 3642 | AT_SETUP([ovn -- dhcpv4 : 1 HV, 2 LS, 2 LSPs/LS]) |
281977f7 NS |
3643 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3644 | ovn_start | |
3645 | ||
3646 | ovn-nbctl ls-add ls1 | |
3647 | ||
3648 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3649 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
3650 | ||
3651 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
3652 | ||
3653 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3654 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
3655 | ||
3656 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
3657 | ||
3658 | ovn-nbctl ls-add ls2 | |
3659 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
3660 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
3661 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 30.0.0.6 40.0.0.4" | |
3662 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
3663 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
3664 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 30.0.0.7" | |
3665 | ||
3666 | ovn-nbctl -- --id=@d1 create DHCP_Options cidr=10.0.0.0/24 \ | |
3667 | options="\"server_id\"=\"10.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:01\" \ | |
3668 | \"lease_time\"=\"3600\" \"router\"=\"10.0.0.1\"" \ | |
3669 | -- add Logical_Switch_Port ls1-lp1 dhcpv4_options @d1 \ | |
3670 | -- add Logical_Switch_Port ls1-lp2 dhcpv4_options @d1 | |
3671 | ||
3672 | ovn-nbctl -- --id=@d2 create DHCP_Options cidr=30.0.0.0/24 \ | |
3673 | options="\"server_id\"=\"30.0.0.1\" \"server_mac\"=\"ff:10:00:00:00:02\" \ | |
3674 | \"lease_time\"=\"3600\"" -- add Logical_Switch_Port ls2-lp2 dhcpv4_options @d2 | |
3675 | ||
3676 | net_add n1 | |
3677 | sim_add hv1 | |
3678 | ||
3679 | as hv1 | |
3680 | ovs-vsctl add-br br-phys | |
3681 | ovn_attach n1 br-phys 192.168.0.1 | |
3682 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
3683 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
3684 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
3685 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
3686 | ofport-request=1 | |
3687 | ||
3688 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
3689 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
3690 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
3691 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
3692 | ofport-request=2 | |
3693 | ||
3694 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
3695 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
3696 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
3697 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
3698 | ofport-request=3 | |
3699 | ||
3700 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
3701 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
3702 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
3703 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
3704 | ofport-request=4 | |
3705 | ||
3706 | ovn_populate_arp | |
3707 | ||
3708 | sleep 2 | |
3709 | ||
3710 | as hv1 ovs-vsctl show | |
3711 | ||
281977f7 NS |
3712 | # This shell function sends a DHCP request packet |
3713 | # test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ... | |
3714 | test_dhcp() { | |
213615b3 NS |
3715 | local inport=$1 src_mac=$2 dhcp_type=$3 offer_ip=$4 use_ip=$5 |
3716 | shift; shift; shift; shift; shift; | |
3717 | if test $use_ip != 0; then | |
3718 | src_ip=$1 | |
3719 | dst_ip=$2 | |
3720 | shift; shift; | |
3721 | else | |
3722 | src_ip=`ip_to_hex 0 0 0 0` | |
3723 | dst_ip=`ip_to_hex 255 255 255 255` | |
3724 | fi | |
3725 | local request=ffffffffffff${src_mac}0800451001100000000080110000${src_ip}${dst_ip} | |
281977f7 | 3726 | # udp header and dhcp header |
ab187e7e BP |
3727 | request=${request}0044004300fc0000 |
3728 | request=${request}010106006359aa760000000000000000000000000000000000000000${src_mac} | |
281977f7 | 3729 | # client hardware padding |
ab187e7e | 3730 | request=${request}00000000000000000000 |
281977f7 | 3731 | # server hostname |
ab187e7e BP |
3732 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 |
3733 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3734 | # boot file name |
ab187e7e BP |
3735 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 |
3736 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
3737 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
3738 | request=${request}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3739 | # dhcp magic cookie |
ab187e7e | 3740 | request=${request}63825363 |
281977f7 | 3741 | # dhcp message type |
ab187e7e | 3742 | request=${request}3501${dhcp_type}ff |
281977f7 NS |
3743 | |
3744 | if test $offer_ip != 0; then | |
213615b3 | 3745 | local srv_mac=$1 srv_ip=$2 expected_dhcp_opts=$3 |
281977f7 NS |
3746 | # total IP length will be the IP length of the request packet |
3747 | # (which is 272 in our case) + 8 (padding bytes) + (expected_dhcp_opts / 2) | |
3748 | ip_len=`expr 280 + ${#expected_dhcp_opts} / 2` | |
3749 | udp_len=`expr $ip_len - 20` | |
04d60f6e YT |
3750 | ip_len=$(printf "%x" $ip_len) |
3751 | udp_len=$(printf "%x" $udp_len) | |
281977f7 NS |
3752 | # $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len |
3753 | local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip} | |
3754 | # udp header and dhcp header. | |
3755 | # $udp_len var will be in 3 digits. So adding a '0' before $udp_len | |
ab187e7e | 3756 | reply=${reply}004300440${udp_len}0000020106006359aa760000000000000000 |
281977f7 | 3757 | # your ip address |
ab187e7e | 3758 | reply=${reply}${offer_ip} |
281977f7 | 3759 | # next server ip address, relay agent ip address, client mac address |
ab187e7e | 3760 | reply=${reply}0000000000000000${src_mac} |
281977f7 | 3761 | # client hardware padding |
ab187e7e | 3762 | reply=${reply}00000000000000000000 |
281977f7 | 3763 | # server hostname |
ab187e7e BP |
3764 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 |
3765 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3766 | # boot file name |
ab187e7e BP |
3767 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 |
3768 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
3769 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
3770 | reply=${reply}0000000000000000000000000000000000000000000000000000000000000000 | |
281977f7 | 3771 | # dhcp magic cookie |
ab187e7e | 3772 | reply=${reply}63825363 |
281977f7 NS |
3773 | # dhcp message type |
3774 | local dhcp_reply_type=02 | |
3775 | if test $dhcp_type = 03; then | |
3776 | dhcp_reply_type=05 | |
3777 | fi | |
ab187e7e | 3778 | reply=${reply}3501${dhcp_reply_type}${expected_dhcp_opts}00000000ff00000000 |
281977f7 NS |
3779 | echo $reply >> $inport.expected |
3780 | else | |
281977f7 | 3781 | for outport; do |
e4543cfe | 3782 | echo $request >> $outport.expected |
281977f7 NS |
3783 | done |
3784 | fi | |
3785 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
3786 | } | |
3787 | ||
3788 | reset_pcap_file() { | |
3789 | local iface=$1 | |
3790 | local pcap_file=$2 | |
3791 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
3792 | options:rxq_pcap=dummy-rx.pcap | |
3793 | rm -f ${pcap_file}*.pcap | |
3794 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
3795 | options:rxq_pcap=${pcap_file}-rx.pcap | |
3796 | } | |
3797 | ||
3798 | ip_to_hex() { | |
3799 | printf "%02x%02x%02x%02x" "$@" | |
3800 | } | |
3801 | ||
3802 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
3803 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
3804 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
3805 | ||
3806 | echo "---------NB dump-----" | |
3807 | ovn-nbctl show | |
3808 | echo "---------------------" | |
3809 | echo "---------SB dump-----" | |
3810 | ovn-sbctl list datapath_binding | |
3811 | echo "---------------------" | |
3812 | ovn-sbctl list logical_flow | |
3813 | echo "---------------------" | |
3814 | ||
3815 | echo "---------------------" | |
3816 | ovn-sbctl dump-flows | |
3817 | echo "---------------------" | |
3818 | ||
3819 | echo "------ hv1 dump ----------" | |
3820 | as hv1 ovs-ofctl dump-flows br-int | |
3821 | ||
3822 | # Send DHCPDISCOVER. | |
3823 | offer_ip=`ip_to_hex 10 0 0 4` | |
3824 | server_ip=`ip_to_hex 10 0 0 1` | |
7c76bf4e | 3825 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
213615b3 | 3826 | test_dhcp 1 f00000000001 01 $offer_ip 0 ff1000000001 $server_ip $expected_dhcp_opts |
281977f7 NS |
3827 | |
3828 | # NXT_RESUMEs should be 1. | |
3829 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3830 | ||
3831 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
3832 | cat 1.expected | cut -c -48 > expout | |
3833 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
3834 | # Skipping the IPv4 checksum. | |
3835 | cat 1.expected | cut -c 53- > expout | |
3836 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
3837 | ||
3838 | # ovs-ofctl also resumes the packets and this causes other ports to receive | |
3839 | # the DHCP request packet. So reset the pcap files so that its easier to test. | |
3840 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3841 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3842 | rm -f 1.expected | |
3843 | rm -f 2.expected | |
3844 | ||
3845 | # Send DHCPREQUEST. | |
3846 | offer_ip=`ip_to_hex 10 0 0 6` | |
3847 | server_ip=`ip_to_hex 10 0 0 1` | |
7c76bf4e | 3848 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 |
213615b3 | 3849 | test_dhcp 2 f00000000002 03 $offer_ip 0 ff1000000001 $server_ip $expected_dhcp_opts |
281977f7 NS |
3850 | |
3851 | # NXT_RESUMEs should be 2. | |
3852 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3853 | ||
3854 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
3855 | cat 2.expected | cut -c -48 > expout | |
3856 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
3857 | # Skipping the IPv4 checksum. | |
3858 | cat 2.expected | cut -c 53- > expout | |
3859 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
3860 | ||
3861 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3862 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3863 | rm -f 1.expected | |
3864 | rm -f 2.expected | |
3865 | ||
3866 | # Send Invalid DHCPv4 packet on ls1-lp2. It should be received by ovn-controller | |
3867 | # but should be resumed without the reply. | |
3868 | # ls1-lp1 (vif1-tx.pcap) should receive the DHCPv4 request packet twice, | |
3869 | # one from ovn-controller and the other from "ovs-ofctl resume." | |
3870 | offer_ip=0 | |
213615b3 | 3871 | test_dhcp 2 f00000000002 08 $offer_ip 0 1 1 |
281977f7 NS |
3872 | |
3873 | # NXT_RESUMEs should be 3. | |
3874 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3875 | ||
3876 | # vif1-tx.pcap should have received the DHCPv4 (invalid) request packet | |
49d7c759 | 3877 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected]) |
281977f7 NS |
3878 | |
3879 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3880 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3881 | rm -f 1.expected | |
3882 | rm -f 2.expected | |
3883 | ||
3884 | # Send DHCPv4 packet on ls2-lp1. It doesn't have any DHCPv4 options defined. | |
3885 | # ls2-lp2 (vif4-tx.pcap) should receive the DHCPv4 request packet once. | |
3886 | ||
213615b3 | 3887 | test_dhcp 3 f00000000003 01 0 4 0 |
281977f7 NS |
3888 | |
3889 | # Send DHCPv4 packet on ls2-lp2. "router" DHCPv4 option is not defined for | |
3890 | # this lport. | |
213615b3 | 3891 | test_dhcp 4 f00000000004 01 0 3 0 |
281977f7 NS |
3892 | |
3893 | # NXT_RESUMEs should be 3. | |
3894 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3895 | ||
49d7c759 BP |
3896 | OVN_CHECK_PACKETS([hv1/vif3-tx.pcap], [3.expected]) |
3897 | OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [4.expected]) | |
281977f7 | 3898 | |
213615b3 NS |
3899 | # Send DHCPREQUEST with ip4.src set to 10.0.0.6 and ip4.dst set to 10.0.0.1. |
3900 | offer_ip=`ip_to_hex 10 0 0 6` | |
3901 | server_ip=`ip_to_hex 10 0 0 1` | |
3902 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 | |
3903 | src_ip=$offer_ip | |
3904 | dst_ip=$server_ip | |
3905 | test_dhcp 2 f00000000002 03 $offer_ip 1 $src_ip $dst_ip ff1000000001 $server_ip $expected_dhcp_opts | |
3906 | ||
3907 | # NXT_RESUMEs should be 4. | |
3908 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3909 | ||
3910 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
3911 | cat 2.expected | cut -c -48 > expout | |
3912 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
3913 | # Skipping the IPv4 checksum. | |
3914 | cat 2.expected | cut -c 53- > expout | |
3915 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
3916 | ||
3917 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3918 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3919 | rm -f 1.expected | |
3920 | rm -f 2.expected | |
3921 | ||
3922 | # Send DHCPREQUEST with ip4.src set to 10.0.0.6 and ip4.dst set to 255.255.255.255. | |
3923 | offer_ip=`ip_to_hex 10 0 0 6` | |
3924 | server_ip=`ip_to_hex 10 0 0 1` | |
3925 | expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001 | |
3926 | src_ip=$offer_ip | |
3927 | dst_ip=`ip_to_hex 255 255 255 255` | |
3928 | test_dhcp 2 f00000000002 03 $offer_ip 1 $src_ip $dst_ip ff1000000001 $server_ip $expected_dhcp_opts | |
3929 | ||
3930 | # NXT_RESUMEs should be 5. | |
3931 | OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3932 | ||
3933 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
3934 | cat 2.expected | cut -c -48 > expout | |
3935 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
3936 | # Skipping the IPv4 checksum. | |
3937 | cat 2.expected | cut -c 53- > expout | |
3938 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
3939 | ||
3940 | reset_pcap_file hv1-vif1 hv1/vif1 | |
3941 | reset_pcap_file hv1-vif2 hv1/vif2 | |
3942 | rm -f 1.expected | |
3943 | rm -f 2.expected | |
3944 | ||
3945 | # Send DHCPREQUEST with ip4.src set to 10.0.0.6 and ip4.dst set to 10.0.0.4. | |
3946 | # The packet should not be received by ovn-controller. | |
3947 | src_ip=`ip_to_hex 10 0 0 6` | |
3948 | dst_ip=`ip_to_hex 10 0 0 4` | |
3949 | test_dhcp 2 f00000000002 03 0 1 $src_ip $dst_ip 1 | |
3950 | ||
3951 | # NXT_RESUMEs should be 5. | |
3952 | OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
3953 | ||
3954 | # vif1-tx.pcap should have received the DHCPv4 request packet | |
3955 | OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected]) | |
3956 | ||
281977f7 | 3957 | as hv1 |
33ac3c83 NS |
3958 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) |
3959 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3960 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3961 | ||
3962 | as ovn-sb | |
3963 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3964 | ||
3965 | as ovn-nb | |
3966 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3967 | ||
3968 | as northd | |
3969 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
3970 | ||
3971 | as main | |
3972 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
3973 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
3974 | ||
3975 | AT_CLEANUP | |
3976 | ||
40df4566 | 3977 | AT_SETUP([ovn -- dhcpv6 : 1 HV, 2 LS, 5 LSPs]) |
33ac3c83 NS |
3978 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
3979 | ovn_start | |
3980 | ||
3981 | ovn-nbctl ls-add ls1 | |
3982 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
3983 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
3984 | ||
3985 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 ae70::4" | |
3986 | ||
3987 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
3988 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
3989 | ||
3990 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 ae70::5" | |
3991 | ||
40df4566 ZKL |
3992 | ovn-nbctl lsp-add ls1 ls1-lp3 \ |
3993 | -- lsp-set-addresses ls1-lp3 "f0:00:00:00:00:22 ae70::22" | |
3994 | ||
3995 | ovn-nbctl lsp-set-port-security ls1-lp3 "f0:00:00:00:00:22 ae70::22" | |
3996 | ||
33ac3c83 NS |
3997 | ovn-nbctl -- --id=@d1 create DHCP_Options cidr="ae70\:\:/64" \ |
3998 | options="\"server_id\"=\"00:00:00:10:00:01\"" \ | |
3999 | -- add Logical_Switch_Port ls1-lp1 dhcpv6_options @d1 \ | |
4000 | -- add Logical_Switch_Port ls1-lp2 dhcpv6_options @d1 | |
4001 | ||
40df4566 ZKL |
4002 | ovn-nbctl -- --id=@d2 create DHCP_Options cidr="ae70\:\:/64" \ |
4003 | options="\"dhcpv6_stateless\"=\"true\" \"server_id\"=\"00:00:00:10:00:01\"" \ | |
4004 | -- add Logical_Switch_Port ls1-lp3 dhcpv6_options @d2 | |
4005 | ||
33ac3c83 NS |
4006 | ovn-nbctl ls-add ls2 |
4007 | ovn-nbctl lsp-add ls2 ls2-lp1 \ | |
4008 | -- lsp-set-addresses ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
4009 | ovn-nbctl lsp-set-port-security ls2-lp1 "f0:00:00:00:00:03 be70::3" | |
4010 | ovn-nbctl lsp-add ls2 ls2-lp2 \ | |
4011 | -- lsp-set-addresses ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
4012 | ovn-nbctl lsp-set-port-security ls2-lp2 "f0:00:00:00:00:04 be70::4" | |
4013 | ||
4014 | net_add n1 | |
4015 | sim_add hv1 | |
4016 | ||
4017 | as hv1 | |
4018 | ovs-vsctl add-br br-phys | |
4019 | ovn_attach n1 br-phys 192.168.0.1 | |
4020 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4021 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
4022 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4023 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4024 | ofport-request=1 | |
4025 | ||
4026 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
4027 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
4028 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4029 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4030 | ofport-request=2 | |
4031 | ||
4032 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
4033 | set interface hv1-vif3 external-ids:iface-id=ls2-lp1 \ | |
4034 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
4035 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
4036 | ofport-request=3 | |
4037 | ||
4038 | ovs-vsctl -- add-port br-int hv1-vif4 -- \ | |
4039 | set interface hv1-vif4 external-ids:iface-id=ls2-lp2 \ | |
4040 | options:tx_pcap=hv1/vif4-tx.pcap \ | |
4041 | options:rxq_pcap=hv1/vif4-rx.pcap \ | |
4042 | ofport-request=4 | |
4043 | ||
40df4566 ZKL |
4044 | ovs-vsctl -- add-port br-int hv1-vif5 -- \ |
4045 | set interface hv1-vif5 external-ids:iface-id=ls1-lp3 \ | |
4046 | options:tx_pcap=hv1/vif5-tx.pcap \ | |
4047 | options:rxq_pcap=hv1/vif5-rx.pcap \ | |
4048 | ofport-request=5 | |
4049 | ||
33ac3c83 NS |
4050 | ovn_populate_arp |
4051 | ||
4052 | sleep 2 | |
4053 | ||
4054 | trim_zeros() { | |
4055 | sed 's/\(00\)\{1,\}$//' | |
4056 | } | |
4057 | ||
4058 | # This shell function sends a DHCPv6 request packet | |
40df4566 ZKL |
4059 | # test_dhcpv6 INPORT SRC_MAC SRC_LLA DHCPv6_MSG_TYPE OFFER_IP OUTPORT... |
4060 | # The OUTPORTs (zero or more) list the VIFs on which the original DHCPv6 | |
33ac3c83 NS |
4061 | # packet should be received twice (one from ovn-controller and the other |
4062 | # from the "ovs-ofctl monitor br-int resume" | |
4063 | test_dhcpv6() { | |
4064 | local inport=$1 src_mac=$2 src_lla=$3 msg_code=$4 offer_ip=$5 | |
4065 | local request=ffffffffffff${src_mac}86dd00000000002a1101${src_lla} | |
4066 | # dst ip ff02::1:2 | |
ab187e7e | 4067 | request=${request}ff020000000000000000000000010002 |
33ac3c83 | 4068 | # udp header and dhcpv6 header |
ab187e7e | 4069 | request=${request}02220223002affff${msg_code}010203 |
33ac3c83 | 4070 | # Client identifier |
ab187e7e | 4071 | request=${request}0001000a00030001${src_mac} |
33ac3c83 | 4072 | # IA-NA (Identity Association for Non Temporary Address) |
ab187e7e | 4073 | request=${request}0003000c0102030400000e1000001518 |
33ac3c83 NS |
4074 | shift; shift; shift; shift; shift; |
4075 | if test $offer_ip != 0; then | |
4076 | local server_mac=000000100001 | |
4077 | local server_lla=fe80000000000000020000fffe100001 | |
4078 | local reply_code=07 | |
4079 | if test $msg_code = 01; then | |
4080 | reply_code=02 | |
4081 | fi | |
40df4566 ZKL |
4082 | local msg_len=54 |
4083 | if test $offer_ip = 1; then | |
4084 | msg_len=28 | |
4085 | fi | |
4086 | local reply=${src_mac}${server_mac}86dd0000000000${msg_len}1101${server_lla}${src_lla} | |
33ac3c83 | 4087 | # udp header and dhcpv6 header |
ab187e7e | 4088 | reply=${reply}0223022200${msg_len}ffff${reply_code}010203 |
33ac3c83 | 4089 | # Client identifier |
ab187e7e | 4090 | reply=${reply}0001000a00030001${src_mac} |
33ac3c83 | 4091 | # IA-NA |
40df4566 | 4092 | if test $offer_ip != 1; then |
ab187e7e | 4093 | reply=${reply}0003002801020304ffffffffffffffff00050018${offer_ip}ffffffffffffffff |
40df4566 | 4094 | fi |
33ac3c83 | 4095 | # Server identifier |
ab187e7e | 4096 | reply=${reply}0002000a00030001${server_mac} |
33ac3c83 NS |
4097 | echo $reply | trim_zeros >> $inport.expected |
4098 | else | |
4099 | for outport; do | |
4100 | echo $request | trim_zeros >> $outport.expected | |
4101 | done | |
4102 | fi | |
4103 | ||
4104 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
4105 | } | |
4106 | ||
4107 | reset_pcap_file() { | |
4108 | local iface=$1 | |
4109 | local pcap_file=$2 | |
4110 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
4111 | options:rxq_pcap=dummy-rx.pcap | |
4112 | rm -f ${pcap_file}*.pcap | |
4113 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
4114 | options:rxq_pcap=${pcap_file}-rx.pcap | |
4115 | } | |
4116 | ||
4117 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
4118 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
4119 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
4120 | ||
4121 | echo "---------NB dump-----" | |
4122 | ovn-nbctl show | |
4123 | echo "---------------------" | |
4124 | echo "---------SB dump-----" | |
4125 | ovn-sbctl list datapath_binding | |
4126 | echo "---------------------" | |
4127 | ovn-sbctl list logical_flow | |
4128 | echo "---------------------" | |
4129 | ||
4130 | echo "---------------------" | |
4131 | ovn-sbctl dump-flows | |
4132 | echo "---------------------" | |
4133 | ||
4134 | echo "------ hv1 dump ----------" | |
4135 | as hv1 ovs-ofctl dump-flows br-int | |
4136 | ||
4137 | src_mac=f00000000001 | |
4138 | src_lla=fe80000000000000f20000fffe000001 | |
4139 | offer_ip=ae700000000000000000000000000004 | |
4140 | test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip | |
4141 | ||
4142 | # NXT_RESUMEs should be 1. | |
4143 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4144 | ||
4145 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
4146 | # cat 1.expected | trim_zeros > expout | |
4147 | cat 1.expected | cut -c -120 > expout | |
4148 | AT_CHECK([cat 1.packets | cut -c -120], [0], [expout]) | |
4149 | # Skipping the UDP checksum | |
4150 | cat 1.expected | cut -c 125- > expout | |
4151 | AT_CHECK([cat 1.packets | cut -c 125-], [0], [expout]) | |
4152 | ||
4153 | rm 1.expected | |
4154 | ||
4155 | # Send invalid packet on ls1-lp2. ovn-controller should resume the packet | |
4156 | # without any modifications and the packet should be received by ls1-lp1. | |
4157 | # ls1-lp1 will receive the packet twice, one from the ovn-controller after the | |
4158 | # resume and the other from ovs-ofctl monitor resume. | |
4159 | ||
4160 | reset_pcap_file hv1-vif1 hv1/vif1 | |
4161 | reset_pcap_file hv1-vif2 hv1/vif2 | |
4162 | ||
4163 | src_mac=f00000000002 | |
4164 | src_lla=fe80000000000000f20000fffe000002 | |
4165 | offer_ip=ae700000000000000000000000000005 | |
4166 | # Set invalid msg_type | |
4167 | ||
4168 | test_dhcpv6 2 $src_mac $src_lla 10 0 1 1 | |
4169 | ||
4170 | # NXT_RESUMEs should be 2. | |
4171 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4172 | ||
4173 | # vif2-tx.pcap should not have received the DHCPv6 reply packet | |
4174 | rm 2.packets | |
4175 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > 2.packets | |
4176 | AT_CHECK([cat 2.packets], [0], []) | |
4177 | ||
4178 | # vif1-tx.pcap should have received the DHCPv6 (invalid) request packet | |
4179 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets | |
4180 | cat 1.expected > expout | |
4181 | AT_CHECK([cat 1.packets], [0], [expout]) | |
4182 | ||
4183 | # Send DHCPv6 packet on ls2-lp1. native DHCPv6 is disabled on this port. | |
4184 | # There should be no DHCPv6 reply from ovn-controller and the request packet | |
4185 | # should be received by ls2-lp2. | |
4186 | ||
4187 | src_mac=f00000000003 | |
4188 | src_lla=fe80000000000000f20000fffe000003 | |
4189 | test_dhcpv6 3 $src_mac $src_lla 01 0 4 | |
4190 | ||
4191 | # NXT_RESUMEs should be 2 only. | |
4192 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4193 | ||
4194 | # vif3-tx.pcap should not have received the DHCPv6 reply packet | |
4195 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap | trim_zeros > 3.packets | |
4196 | AT_CHECK([cat 3.packets], [0], []) | |
4197 | ||
4198 | # vif4-tx.pcap should have received the DHCPv6 request packet | |
4199 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif4-tx.pcap | trim_zeros > 4.packets | |
4200 | cat 4.expected > expout | |
4201 | AT_CHECK([cat 4.packets], [0], [expout]) | |
4202 | ||
40df4566 ZKL |
4203 | # Send DHCPv6 packet on ls1-lp3. native DHCPv6 works as stateless mode for this port. |
4204 | # The DHCPv6 reply should doesn't contian offer_ip. | |
4205 | src_mac=f00000000022 | |
4206 | src_lla=fe80000000000000f20000fffe000022 | |
4207 | reset_pcap_file hv1-vif5 hv1/vif5 | |
4208 | test_dhcpv6 5 $src_mac $src_lla 01 1 5 | |
4209 | ||
4210 | # NXT_RESUMEs should be 3. | |
4211 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
4212 | ||
4213 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.packets | |
4214 | # Skipping the UDP checksum | |
4215 | cat 5.expected | cut -c 1-120,125- > expout | |
4216 | AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout]) | |
4217 | ||
33ac3c83 | 4218 | as hv1 |
281977f7 NS |
4219 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) |
4220 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4221 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4222 | ||
4223 | as ovn-sb | |
4224 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4225 | ||
4226 | as ovn-nb | |
4227 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4228 | ||
4229 | as northd | |
4230 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
4231 | ||
4232 | as main | |
4233 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
4234 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
4235 | ||
4236 | AT_CLEANUP | |
4237 | ||
c1645003 | 4238 | AT_SETUP([ovn -- 2 HVs, 2 LRs connected via LS, gateway router]) |
c1645003 GS |
4239 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4240 | ovn_start | |
4241 | ||
4242 | # Logical network: | |
4243 | # Two LRs - R1 and R2 that are connected to each other via LS "join" | |
4244 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) | |
4245 | # connected to it. R2 has alice (172.16.1.0/24) connected to it. | |
4246 | # R2 is a gateway router. | |
4247 | ||
4248 | ||
4249 | ||
4250 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
4251 | net_add n1 | |
4252 | ||
4253 | sim_add hv1 | |
4254 | as hv1 | |
4255 | ovs-vsctl add-br br-phys | |
4256 | ovn_attach n1 br-phys 192.168.0.1 | |
4257 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
4258 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
4259 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4260 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4261 | ofport-request=1 | |
4262 | ||
4263 | ||
4264 | sim_add hv2 | |
4265 | as hv2 | |
4266 | ovs-vsctl add-br br-phys | |
4267 | ovn_attach n1 br-phys 192.168.0.2 | |
4268 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
4269 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
4270 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
4271 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
4272 | ofport-request=1 | |
4273 | ||
4274 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
4275 | # packets for ARP resolution (native tunneling doesn't queue packets | |
4276 | # for ARP resolution). | |
4277 | ovn_populate_arp | |
4278 | ||
4279 | ovn-nbctl create Logical_Router name=R1 | |
4280 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
4281 | ||
ea46a4e9 JP |
4282 | ovn-nbctl ls-add foo |
4283 | ovn-nbctl ls-add alice | |
4284 | ovn-nbctl ls-add join | |
c1645003 GS |
4285 | |
4286 | # Connect foo to R1 | |
31114af7 | 4287 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 |
31ed1192 | 4288 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ |
80f408f4 | 4289 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" |
c1645003 GS |
4290 | |
4291 | # Connect alice to R2 | |
31114af7 | 4292 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 |
31ed1192 | 4293 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ |
80f408f4 | 4294 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" |
c1645003 GS |
4295 | |
4296 | # Connect R1 to join | |
31114af7 | 4297 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 |
31ed1192 | 4298 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ |
80f408f4 | 4299 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' |
c1645003 GS |
4300 | |
4301 | # Connect R2 to join | |
31114af7 | 4302 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 |
31ed1192 | 4303 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ |
80f408f4 | 4304 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' |
c1645003 GS |
4305 | |
4306 | ||
4307 | #install static routes | |
4308 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4309 | ip_prefix=172.16.1.0/24 nexthop=20.0.0.2 -- add Logical_Router \ | |
4310 | R1 static_routes @lrt | |
4311 | ||
4312 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4313 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
4314 | R2 static_routes @lrt | |
4315 | ||
4316 | # Create logical port foo1 in foo | |
31ed1192 JP |
4317 | ovn-nbctl lsp-add foo foo1 \ |
4318 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
c1645003 GS |
4319 | |
4320 | # Create logical port alice1 in alice | |
31ed1192 JP |
4321 | ovn-nbctl lsp-add alice alice1 \ |
4322 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 172.16.1.2" | |
c1645003 GS |
4323 | |
4324 | ||
4325 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4326 | # XXX This should be more systematic. | |
4327 | sleep 2 | |
4328 | ||
4329 | ip_to_hex() { | |
4330 | printf "%02x%02x%02x%02x" "$@" | |
4331 | } | |
c1645003 GS |
4332 | |
4333 | # Send ip packets between foo1 and alice1 | |
4334 | src_mac="f00000010203" | |
4335 | dst_mac="000001010203" | |
4336 | src_ip=`ip_to_hex 192 168 1 2` | |
4337 | dst_ip=`ip_to_hex 172 16 1 2` | |
4338 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
4339 | ||
4340 | echo "---------NB dump-----" | |
4341 | ovn-nbctl show | |
4342 | echo "---------------------" | |
4343 | ovn-nbctl list logical_router | |
4344 | echo "---------------------" | |
4345 | ovn-nbctl list logical_router_port | |
4346 | echo "---------------------" | |
4347 | ||
4348 | echo "---------SB dump-----" | |
4349 | ovn-sbctl list datapath_binding | |
4350 | echo "---------------------" | |
4351 | ovn-sbctl list port_binding | |
4352 | echo "---------------------" | |
4353 | ovn-sbctl dump-flows | |
4354 | echo "---------------------" | |
4355 | ovn-sbctl list chassis | |
4356 | ovn-sbctl list encap | |
4357 | echo "---------------------" | |
4358 | ||
c1645003 GS |
4359 | # Packet to Expect at alice1 |
4360 | src_mac="000002010203" | |
4361 | dst_mac="f00000010204" | |
4362 | src_ip=`ip_to_hex 192 168 1 2` | |
4363 | dst_ip=`ip_to_hex 172 16 1 2` | |
4364 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
4365 | ||
4366 | ||
4367 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
4368 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet | |
4369 | ||
ab39371d RM |
4370 | echo "------ hv1 dump after packet 1 ----------" |
4371 | as hv1 ovs-ofctl show br-int | |
4372 | as hv1 ovs-ofctl dump-flows br-int | |
4373 | echo "------ hv2 dump after packet 1 ----------" | |
4374 | as hv2 ovs-ofctl show br-int | |
4375 | as hv2 ovs-ofctl dump-flows br-int | |
4376 | echo "----------------------------" | |
4377 | ||
49d7c759 BP |
4378 | echo $expected > expected |
4379 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
c1645003 | 4380 | |
34114cf8 GS |
4381 | # Delete the router and re-create it. Things should work as before. |
4382 | ovn-nbctl lr-del R2 | |
4383 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
4384 | # Connect alice to R2 | |
4385 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
4386 | # Connect R2 to join | |
4387 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
4388 | ||
4389 | ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \ | |
4390 | ip_prefix=192.168.1.0/24 nexthop=20.0.0.1 -- add Logical_Router \ | |
4391 | R2 static_routes @lrt | |
4392 | ||
4393 | # Wait for ovn-controller to catch up. | |
4394 | sleep 1 | |
4395 | ||
4396 | # Send the packet again. | |
4397 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
ab39371d RM |
4398 | |
4399 | echo "------ hv1 dump after packet 2 ----------" | |
4400 | as hv1 ovs-ofctl show br-int | |
4401 | as hv1 ovs-ofctl dump-flows br-int | |
4402 | echo "------ hv2 dump after packet 2 ----------" | |
4403 | as hv2 ovs-ofctl show br-int | |
4404 | as hv2 ovs-ofctl dump-flows br-int | |
4405 | echo "----------------------------" | |
4406 | ||
49d7c759 BP |
4407 | echo $expected >> expected |
4408 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
34114cf8 | 4409 | |
7a8f15e0 | 4410 | OVN_CLEANUP([hv1],[hv2]) |
c1645003 GS |
4411 | |
4412 | AT_CLEANUP | |
bb3c4568 FF |
4413 | |
4414 | AT_SETUP([ovn -- icmp_reply: 1 HVs, 2 LSs, 1 lport/LS, 1 LR]) | |
4415 | AT_KEYWORDS([router-icmp-reply]) | |
4416 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
4417 | ovn_start | |
4418 | ||
4419 | # Logical network: | |
4420 | # One LR - R1 has switch ls1 (191.168.1.0/24) connected to it, | |
4421 | # and has switch ls2 (172.16.1.0/24) connected to it. | |
4422 | ||
fa2a27b2 | 4423 | ovn-nbctl lr-add R1 |
bb3c4568 | 4424 | |
ea46a4e9 JP |
4425 | ovn-nbctl ls-add ls1 |
4426 | ovn-nbctl ls-add ls2 | |
bb3c4568 FF |
4427 | |
4428 | # Connect ls1 to R1 | |
31114af7 | 4429 | ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24 |
31ed1192 | 4430 | ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 \ |
80f408f4 | 4431 | type=router options:router-port=ls1 addresses=\"00:00:00:01:02:f1\" |
bb3c4568 FF |
4432 | |
4433 | # Connect ls2 to R1 | |
31114af7 | 4434 | ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24 |
31ed1192 | 4435 | ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 \ |
80f408f4 | 4436 | type=router options:router-port=ls2 addresses=\"00:00:00:01:02:f2\" |
bb3c4568 FF |
4437 | |
4438 | # Create logical port ls1-lp1 in ls1 | |
31ed1192 JP |
4439 | ovn-nbctl lsp-add ls1 ls1-lp1 \ |
4440 | -- lsp-set-addresses ls1-lp1 "00:00:00:01:02:03 192.168.1.2" | |
bb3c4568 FF |
4441 | |
4442 | # Create logical port ls2-lp1 in ls2 | |
31ed1192 JP |
4443 | ovn-nbctl lsp-add ls2 ls2-lp1 \ |
4444 | -- lsp-set-addresses ls2-lp1 "00:00:00:01:02:04 172.16.1.2" | |
bb3c4568 FF |
4445 | |
4446 | # Create one hypervisor and create OVS ports corresponding to logical ports. | |
4447 | net_add n1 | |
4448 | ||
4449 | sim_add hv1 | |
4450 | as hv1 | |
4451 | ovs-vsctl add-br br-phys | |
4452 | ovn_attach n1 br-phys 192.168.0.1 | |
4453 | ovs-vsctl -- add-port br-int vif1 -- \ | |
4454 | set interface vif1 external-ids:iface-id=ls1-lp1 \ | |
4455 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
4456 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
4457 | ofport-request=1 | |
4458 | ||
4459 | ovs-vsctl -- add-port br-int vif2 -- \ | |
4460 | set interface vif2 external-ids:iface-id=ls2-lp1 \ | |
4461 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
4462 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
4463 | ofport-request=1 | |
4464 | ||
4465 | ||
4466 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4467 | # XXX This should be more systematic. | |
4468 | sleep 1 | |
4469 | ||
4470 | ||
4471 | ip_to_hex() { | |
4472 | printf "%02x%02x%02x%02x" "$@" | |
4473 | } | |
bb3c4568 FF |
4474 | for i in 1 2; do |
4475 | : > vif$i.expected | |
4476 | done | |
4477 | # test_ipv4_icmp_request INPORT ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM ICMP_CHKSUM [EXP_IP_CHKSUM EXP_ICMP_CHKSUM] | |
4478 | # | |
4479 | # Causes a packet to be received on INPORT. The packet is an ICMPv4 | |
4480 | # request with ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_CHSUM and | |
4481 | # ICMP_CHKSUM as specified. If EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are | |
4482 | # provided, then it should be the ip and icmp checksums of the packet | |
4483 | # responded; otherwise, no reply is expected. | |
4484 | # In the absence of an ip checksum calculation helpers, this relies | |
4485 | # on the caller to provide the checksums for the ip and icmp headers. | |
4486 | # XXX This should be more systematic. | |
4487 | # | |
4488 | # INPORT is an lport number, e.g. 11 for vif11. | |
4489 | # ETH_SRC and ETH_DST are each 12 hex digits. | |
4490 | # IPV4_SRC and IPV4_DST are each 8 hex digits. | |
4491 | # IP_CHSUM and ICMP_CHKSUM are each 4 hex digits. | |
4492 | # EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits. | |
4493 | test_ipv4_icmp_request() { | |
4494 | local inport=$1 eth_src=$2 eth_dst=$3 ipv4_src=$4 ipv4_dst=$5 ip_chksum=$6 icmp_chksum=$7 | |
4495 | local exp_ip_chksum=$8 exp_icmp_chksum=$9 | |
4496 | shift; shift; shift; shift; shift; shift; shift | |
4497 | shift; shift | |
4498 | ||
4499 | # Use ttl to exercise section 4.2.2.9 of RFC1812 | |
4500 | local ip_ttl=01 | |
4501 | local icmp_id=5fbf | |
4502 | local icmp_seq=0001 | |
4503 | local icmp_data=$(seq 1 56 | xargs printf "%02x") | |
4504 | local icmp_type_code_request=0800 | |
4505 | local icmp_payload=${icmp_type_code_request}${icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
4506 | local packet=${eth_dst}${eth_src}08004500005400004000${ip_ttl}01${ip_chksum}${ipv4_src}${ipv4_dst}${icmp_payload} | |
4507 | ||
4508 | as hv1 ovs-appctl netdev-dummy/receive vif$inport $packet | |
4509 | if test X$exp_icmp_chksum != X; then | |
4510 | # Expect to receive the reply, if any. In same port where packet was sent. | |
4511 | # Note: src and dst fields are expected to be reversed. | |
4512 | local icmp_type_code_response=0000 | |
4513 | local reply_icmp_ttl=fe | |
4514 | local reply_icmp_payload=${icmp_type_code_response}${exp_icmp_chksum}${icmp_id}${icmp_seq}${icmp_data} | |
4515 | local reply=${eth_src}${eth_dst}08004500005400004000${reply_icmp_ttl}01${exp_ip_chksum}${ipv4_dst}${ipv4_src}${reply_icmp_payload} | |
4516 | echo $reply >> vif$inport.expected | |
4517 | fi | |
4518 | } | |
4519 | ||
4520 | # Send ping packet to router's ip addresses, from each of the 2 logical ports. | |
4521 | rtr_l1_ip=$(ip_to_hex 192 168 1 1) | |
4522 | rtr_l2_ip=$(ip_to_hex 172 16 1 1) | |
4523 | l1_ip=$(ip_to_hex 192 168 1 2) | |
4524 | l2_ip=$(ip_to_hex 172 16 1 2) | |
4525 | ||
4526 | # Ping router ip address that is on same subnet as the logical port | |
4527 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
4528 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
4529 | ||
4530 | # Ping router ip address that is on the other side of the logical ports | |
4531 | test_ipv4_icmp_request 1 000000010203 0000000102f1 $l1_ip $rtr_l2_ip 0000 8510 02ff 8d10 | |
4532 | test_ipv4_icmp_request 2 000000010204 0000000102f2 $l2_ip $rtr_l1_ip 0000 8510 02ff 8d10 | |
4533 | ||
4534 | echo "---------NB dump-----" | |
4535 | ovn-nbctl show | |
4536 | echo "---------------------" | |
4537 | ovn-nbctl list logical_router | |
4538 | echo "---------------------" | |
4539 | ovn-nbctl list logical_router_port | |
4540 | echo "---------------------" | |
4541 | ||
4542 | echo "---------SB dump-----" | |
4543 | ovn-sbctl list datapath_binding | |
4544 | echo "---------------------" | |
4545 | ovn-sbctl list logical_flow | |
4546 | echo "---------------------" | |
4547 | ||
4548 | echo "------ hv1 dump ----------" | |
4549 | as hv1 ovs-ofctl dump-flows br-int | |
4550 | ||
4551 | # Now check the packets actually received against the ones expected. | |
4552 | for inport in 1 2; do | |
49d7c759 | 4553 | OVN_CHECK_PACKETS([hv1/vif${inport}-tx.pcap], [vif$inport.expected]) |
bb3c4568 FF |
4554 | done |
4555 | ||
7a8f15e0 | 4556 | OVN_CLEANUP([hv1]) |
bb3c4568 FF |
4557 | |
4558 | AT_CLEANUP | |
94f79fcb RB |
4559 | |
4560 | # 1 hypervisor, 1 port | |
4561 | # make sure that the port state is properly set to up and back down | |
4562 | # when created and deleted. | |
4563 | AT_SETUP([ovn -- port state up and down]) | |
94f79fcb RB |
4564 | ovn_start |
4565 | ||
4566 | ovn-nbctl ls-add ls1 | |
4567 | ovn-nbctl lsp-add ls1 lp1 | |
4568 | ovn-nbctl lsp-set-addresses lp1 unknown | |
4569 | ||
4570 | net_add n1 | |
4571 | sim_add hv1 | |
4572 | as hv1 ovs-vsctl add-br br-phys | |
4573 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
4574 | ||
4575 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
4576 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
4577 | ||
4578 | as hv1 ovs-vsctl del-port br-int vif1 | |
4579 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
4580 | ||
7a8f15e0 | 4581 | OVN_CLEANUP([hv1]) |
94f79fcb | 4582 | |
94f79fcb | 4583 | AT_CLEANUP |
e75451fe | 4584 | |
ccc6e1db FF |
4585 | # 1 hypervisor, 1 port |
4586 | # make sure that the OF rules created to support a datapath are added/cleared | |
4587 | # when logical switch is created and removed. | |
4588 | AT_SETUP([ovn -- datapath rules added/removed]) | |
1794d5f2 | 4589 | AT_KEYWORDS([cleanup]) |
ccc6e1db FF |
4590 | ovn_start |
4591 | ||
4592 | net_add n1 | |
4593 | sim_add hv1 | |
4594 | as hv1 ovs-vsctl add-br br-phys | |
4595 | as hv1 ovn_attach n1 br-phys 192.168.0.1 | |
4596 | ||
4597 | # This shell function checks if OF rules in br-int have clauses | |
4598 | # related to OVN datapaths. The caller determines if it should find | |
4599 | # a match in the output, or not. | |
4600 | # | |
4601 | # EXPECT_DATAPATH param determines whether flows that refer to | |
4602 | # datapath to should be present or not. 0 means | |
4603 | # they should not be. | |
4604 | # STAGE_INFO param is a simple string to help identify the stage | |
4605 | # in the test when this function was invoked. | |
4606 | test_datapath_in_of_rules() { | |
4607 | local expect_datapath=$1 stage_info=$2 | |
4608 | echo "------ ovn-nbctl show ${stage_info} ------" | |
4609 | ovn-nbctl show | |
4610 | echo "------ ovn-sbctl show ${stage_info} ------" | |
4611 | ovn-sbctl show | |
4612 | echo "------ OF rules ${stage_info} ------" | |
4613 | AT_CHECK([ovs-ofctl dump-flows br-int], [0], [stdout]) | |
4614 | # if there is a datapath mentioned in the output, check for the | |
4615 | # magic keyword that represents one, based on the exit status of | |
4616 | # a quiet grep | |
4617 | if test $expect_datapath != 0; then | |
4618b102 | 4618 | AT_CHECK([grep -q -i 'metadata=' stdout], [0], [ignore-nolog]) |
ccc6e1db | 4619 | else |
4618b102 | 4620 | AT_CHECK([grep -q -i 'metadata=' stdout], [1], [ignore-nolog]) |
ccc6e1db FF |
4621 | fi |
4622 | } | |
4623 | ||
4624 | test_datapath_in_of_rules 0 "before ls+port create" | |
4625 | ||
4626 | ovn-nbctl ls-add ls1 | |
4627 | ovn-nbctl lsp-add ls1 lp1 | |
4628 | ovn-nbctl lsp-set-addresses lp1 unknown | |
4629 | ||
4630 | as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 | |
4631 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) | |
4632 | ||
4633 | test_datapath_in_of_rules 1 "after port is bound" | |
4634 | ||
4635 | as hv1 ovs-vsctl del-port br-int vif1 | |
4636 | OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) | |
4637 | ||
4638 | ovn-nbctl lsp-set-addresses lp1 | |
4639 | ovn-nbctl lsp-del lp1 | |
4640 | ovn-nbctl ls-del ls1 | |
4641 | ||
4642 | # wait for earlier changes to take effect | |
4643 | AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) | |
4644 | ||
4645 | # ensure OF rules are no longer present. There used to be a bug here. | |
4646 | test_datapath_in_of_rules 0 "after lport+ls removal" | |
4647 | ||
4648 | OVN_CLEANUP([hv1]) | |
4649 | ||
4650 | AT_CLEANUP | |
4651 | ||
f8a8db39 | 4652 | AT_SETUP([ovn -- nd_na ]) |
e75451fe ZKL |
4653 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4654 | ovn_start | |
4655 | ||
4656 | #TODO: since patch port for IPv6 logical router port is not ready not, | |
4657 | # so we are not going to test vifs on different lswitches cases. Try | |
4658 | # to update for that once relevant stuff implemented. | |
4659 | ||
4660 | # In this test cases we create 1 lswitch, it has 2 VIF ports attached | |
4661 | # with. NS packet we test, from one VIF for another VIF, will be replied | |
4662 | # by local ovn-controller, but not by target VIF. | |
4663 | ||
4664 | # Create hypervisors and logical switch lsw0. | |
4665 | ovn-nbctl ls-add lsw0 | |
4666 | net_add n1 | |
4667 | sim_add hv1 | |
4668 | as hv1 | |
4669 | ovs-vsctl add-br br-phys | |
4670 | ovn_attach n1 br-phys 192.168.0.2 | |
4671 | ||
4672 | # Add vif1 to hv1 and lsw0, turn on l2 port security on vif1. | |
4673 | 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 | |
4674 | ovn-nbctl lsp-add lsw0 lp1 | |
4675 | ovn-nbctl lsp-set-addresses lp1 "fa:16:3e:94:05:98 192.168.0.3 fd81:ce49:a948:0:f816:3eff:fe94:598" | |
4676 | 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" | |
4677 | ||
4678 | # Add vif2 to hv1 and lsw0, turn on l2 port security on vif2. | |
4679 | 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 | |
4680 | ovn-nbctl lsp-add lsw0 lp2 | |
4681 | ovn-nbctl lsp-set-addresses lp2 "fa:16:3e:a1:f9:ae 192.168.0.4 fd81:ce49:a948:0:f816:3eff:fea1:f9ae" | |
4682 | 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" | |
4683 | ||
4684 | # Add ACL rule for ICMPv6 on lsw0 | |
4685 | ovn-nbctl acl-add lsw0 from-lport 1002 'ip6 && icmp6' allow-related | |
4686 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp1" && ip6 && icmp6' allow-related | |
4687 | ovn-nbctl acl-add lsw0 to-lport 1002 'outport == "lp2" && ip6 && icmp6' allow-related | |
4688 | ||
4689 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
4690 | # XXX This should be more systematic. | |
4691 | sleep 1 | |
4692 | ||
4693 | # Given the name of a logical port, prints the name of the hypervisor | |
4694 | # on which it is located. | |
4695 | vif_to_hv() { | |
4696 | echo hv1${1%?} | |
4697 | } | |
e75451fe ZKL |
4698 | for i in 1 2; do |
4699 | : > $i.expected | |
4700 | done | |
4701 | ||
4702 | # Complete Neighbor Solicitation packet and Neighbor Advertisement packet | |
4703 | # vif1 -> NS -> vif2. vif1 <- NA <- ovn-controller. | |
4704 | # vif2 will not receive NS packet, since ovn-controller will reply for it. | |
4705 | ns_packet=3333ffa1f9aefa163e94059886dd6000000000203afffd81ce49a9480000f8163efffe940598fd81ce49a9480000f8163efffea1f9ae8700e01160000000fd81ce49a9480000f8163efffea1f9ae0101fa163e940598 | |
4706 | na_packet=fa163e940598fa163ea1f9ae86dd6000000000203afffd81ce49a9480000f8163efffea1f9aefd81ce49a9480000f8163efffe9405988800e9ed60000000fd81ce49a9480000f8163efffea1f9ae0201fa163ea1f9ae | |
4707 | ||
4708 | as hv1 ovs-appctl netdev-dummy/receive vif1 $ns_packet | |
e4543cfe | 4709 | echo $na_packet >> 1.expected |
e75451fe | 4710 | |
e75451fe ZKL |
4711 | echo "------ hv1 dump ------" |
4712 | as hv1 ovs-vsctl show | |
4713 | as hv1 ovs-ofctl -O OpenFlow13 show br-int | |
4714 | as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int | |
4715 | ||
4716 | for i in 1 2; do | |
49d7c759 | 4717 | OVN_CHECK_PACKETS([hv1/vif$i-tx.pcap], [$i.expected]) |
e75451fe ZKL |
4718 | done |
4719 | ||
7a8f15e0 | 4720 | OVN_CLEANUP([hv1]) |
e75451fe ZKL |
4721 | |
4722 | AT_CLEANUP | |
7417d147 RM |
4723 | |
4724 | AT_SETUP([ovn -- address sets modification/removal smoke test]) | |
7417d147 RM |
4725 | ovn_start |
4726 | ||
4727 | net_add n1 | |
4728 | ||
4729 | sim_add hv1 | |
4730 | as hv1 | |
4731 | ovs-vsctl add-br br-phys | |
4732 | ovn_attach n1 br-phys 192.168.0.1 | |
4733 | ||
4734 | row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"` | |
4735 | ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\" | |
4736 | ovn-nbctl destroy Address_Set $row | |
4737 | ||
4738 | sleep 1 | |
4739 | ||
4740 | # A bug previously existed in the address set support code | |
4741 | # that caused ovn-controller to crash after an address set | |
4742 | # was updated and then removed. This test case ensures | |
4743 | # that ovn-controller is at least still running after | |
4744 | # creating, updating, and deleting an address set. | |
4745 | AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore]) | |
4746 | ||
4747 | OVN_CLEANUP([hv1]) | |
4748 | ||
4749 | AT_CLEANUP | |
8639f9be ND |
4750 | |
4751 | AT_SETUP([ovn -- ipam]) | |
8639f9be ND |
4752 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
4753 | ovn_start | |
4754 | ||
4755 | # Add a port to a switch that does not have a subnet set, then set the | |
4756 | # subnet which should result in an address being allocated for the port. | |
4757 | ovn-nbctl ls-add sw0 | |
4758 | ovn-nbctl lsp-add sw0 p0 -- lsp-set-addresses p0 dynamic | |
fd3b31e9 | 4759 | ovn-nbctl --wait=sb add Logical-Switch sw0 other_config subnet=192.168.1.0/24 |
8639f9be ND |
4760 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p0 dynamic_addresses], [0], |
4761 | ["0a:00:00:00:00:01 192.168.1.2" | |
4762 | ]) | |
4763 | ||
4764 | # Add 9 more ports to sw0, addresses should all be unique. | |
4765 | for n in `seq 1 9`; do | |
11547f85 | 4766 | ovn-nbctl --wait=sb lsp-add sw0 "p$n" -- lsp-set-addresses "p$n" dynamic |
8639f9be ND |
4767 | done |
4768 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p1 dynamic_addresses], [0], | |
4769 | ["0a:00:00:00:00:02 192.168.1.3" | |
4770 | ]) | |
4771 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p2 dynamic_addresses], [0], | |
4772 | ["0a:00:00:00:00:03 192.168.1.4" | |
4773 | ]) | |
4774 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p3 dynamic_addresses], [0], | |
4775 | ["0a:00:00:00:00:04 192.168.1.5" | |
4776 | ]) | |
4777 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p4 dynamic_addresses], [0], | |
4778 | ["0a:00:00:00:00:05 192.168.1.6" | |
4779 | ]) | |
4780 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p5 dynamic_addresses], [0], | |
4781 | ["0a:00:00:00:00:06 192.168.1.7" | |
4782 | ]) | |
4783 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p6 dynamic_addresses], [0], | |
4784 | ["0a:00:00:00:00:07 192.168.1.8" | |
4785 | ]) | |
4786 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p7 dynamic_addresses], [0], | |
4787 | ["0a:00:00:00:00:08 192.168.1.9" | |
4788 | ]) | |
4789 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p8 dynamic_addresses], [0], | |
4790 | ["0a:00:00:00:00:09 192.168.1.10" | |
4791 | ]) | |
4792 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p9 dynamic_addresses], [0], | |
4793 | ["0a:00:00:00:00:0a 192.168.1.11" | |
4794 | ]) | |
4795 | ||
4796 | # Trying similar tests with a second switch. MAC addresses should be unique | |
4797 | # across both switches but IP's only need to be unique within the same switch. | |
4798 | ovn-nbctl ls-add sw1 | |
4799 | ovn-nbctl lsp-add sw1 p10 -- lsp-set-addresses p10 dynamic | |
11547f85 | 4800 | ovn-nbctl --wait=sb add Logical-Switch sw1 other_config subnet=192.168.1.0/24 |
8639f9be ND |
4801 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p10 dynamic_addresses], [0], |
4802 | ["0a:00:00:00:00:0b 192.168.1.2" | |
4803 | ]) | |
4804 | ||
4805 | for n in `seq 11 19`; do | |
11547f85 | 4806 | ovn-nbctl --wait=sb lsp-add sw1 "p$n" -- lsp-set-addresses "p$n" dynamic |
8639f9be ND |
4807 | done |
4808 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p11 dynamic_addresses], [0], | |
4809 | ["0a:00:00:00:00:0c 192.168.1.3" | |
4810 | ]) | |
4811 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p12 dynamic_addresses], [0], | |
4812 | ["0a:00:00:00:00:0d 192.168.1.4" | |
4813 | ]) | |
4814 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p13 dynamic_addresses], [0], | |
4815 | ["0a:00:00:00:00:0e 192.168.1.5" | |
4816 | ]) | |
4817 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p14 dynamic_addresses], [0], | |
4818 | ["0a:00:00:00:00:0f 192.168.1.6" | |
4819 | ]) | |
4820 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p15 dynamic_addresses], [0], | |
4821 | ["0a:00:00:00:00:10 192.168.1.7" | |
4822 | ]) | |
4823 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p16 dynamic_addresses], [0], | |
4824 | ["0a:00:00:00:00:11 192.168.1.8" | |
4825 | ]) | |
4826 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p17 dynamic_addresses], [0], | |
4827 | ["0a:00:00:00:00:12 192.168.1.9" | |
4828 | ]) | |
4829 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p18 dynamic_addresses], [0], | |
4830 | ["0a:00:00:00:00:13 192.168.1.10" | |
4831 | ]) | |
4832 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p19 dynamic_addresses], [0], | |
4833 | ["0a:00:00:00:00:14 192.168.1.11" | |
4834 | ]) | |
4835 | ||
4836 | # Change a port's address to test for multiple ip's for a single address entry | |
4837 | # and addresses set by the user. | |
4838 | ovn-nbctl lsp-set-addresses p0 "0a:00:00:00:00:15 192.168.1.12 192.168.1.14" | |
11547f85 | 4839 | ovn-nbctl --wait=sb lsp-add sw0 p20 -- lsp-set-addresses p20 dynamic |
8639f9be ND |
4840 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p20 dynamic_addresses], [0], |
4841 | ["0a:00:00:00:00:16 192.168.1.13" | |
4842 | ]) | |
4843 | ||
4844 | # Test for logical router port address management. | |
4845 | ovn-nbctl create Logical_Router name=R1 | |
4846 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw0 \ | |
4847 | network="192.168.1.1/24" mac=\"0a:00:00:00:00:17\" \ | |
4848 | -- add Logical_Router R1 ports @lrp -- lsp-add sw0 rp-sw0 \ | |
4849 | -- set Logical_Switch_Port rp-sw0 type=router options:router-port=sw0 | |
11547f85 | 4850 | ovn-nbctl --wait=sb lsp-add sw0 p21 -- lsp-set-addresses p21 dynamic |
8639f9be ND |
4851 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p21 dynamic_addresses], [0], |
4852 | ["0a:00:00:00:00:18 192.168.1.15" | |
4853 | ]) | |
4854 | ||
4855 | # Test for address reuse after logical port is deleted. | |
4856 | ovn-nbctl lsp-del p0 | |
11547f85 | 4857 | ovn-nbctl --wait=sb lsp-add sw0 p23 -- lsp-set-addresses p23 dynamic |
8639f9be ND |
4858 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p23 dynamic_addresses], [0], |
4859 | ["0a:00:00:00:00:19 192.168.1.2" | |
4860 | ]) | |
4861 | ||
4862 | # Test for multiple addresses to one logical port. | |
4863 | ovn-nbctl lsp-add sw0 p25 -- lsp-set-addresses p25 \ | |
4864 | "0a:00:00:00:00:1a 192.168.1.12" "0a:00:00:00:00:1b 192.168.1.14" | |
11547f85 | 4865 | ovn-nbctl --wait=sb lsp-add sw0 p26 -- lsp-set-addresses p26 dynamic |
8639f9be ND |
4866 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p26 dynamic_addresses], [0], |
4867 | ["0a:00:00:00:00:1c 192.168.1.16" | |
4868 | ]) | |
4869 | ||
4870 | # Test for exhausting subnet address space. | |
4871 | ovn-nbctl ls-add sw2 -- add Logical-Switch sw2 other_config subnet=172.16.1.0/30 | |
11547f85 | 4872 | ovn-nbctl --wait=sb lsp-add sw2 p27 -- lsp-set-addresses p27 dynamic |
8639f9be ND |
4873 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p27 dynamic_addresses], [0], |
4874 | ["0a:00:00:00:00:1d 172.16.1.2" | |
4875 | ]) | |
4876 | ||
11547f85 | 4877 | ovn-nbctl --wait=sb lsp-add sw2 p28 -- lsp-set-addresses p28 dynamic |
8639f9be | 4878 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p28 dynamic_addresses], [0], |
7cc0741e | 4879 | ["0a:00:00:00:00:1e" |
8639f9be ND |
4880 | ]) |
4881 | ||
4882 | # Test that address management does not add duplicate MAC for lsp/lrp peers. | |
4883 | ovn-nbctl create Logical_Router name=R2 | |
4884 | ovn-nbctl ls-add sw3 | |
4885 | ovn-nbctl lsp-add sw3 p29 -- lsp-set-addresses p29 \ | |
7cc0741e | 4886 | "0a:00:00:00:00:1f" |
8639f9be ND |
4887 | ovn-nbctl -- --id=@lrp create Logical_Router_port name=sw3 \ |
4888 | network="192.168.2.1/24" mac=\"0a:00:00:00:00:1f\" \ | |
4889 | -- add Logical_Router R2 ports @lrp -- lsp-add sw3 rp-sw3 \ | |
4890 | -- set Logical_Switch_Port rp-sw3 type=router options:router-port=sw3 | |
11547f85 | 4891 | ovn-nbctl --wait=sb lsp-add sw0 p30 -- lsp-set-addresses p30 dynamic |
8639f9be ND |
4892 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p30 dynamic_addresses], [0], |
4893 | ["0a:00:00:00:00:20 192.168.1.17" | |
4894 | ]) | |
4895 | ||
6374d518 LR |
4896 | # Test static MAC address with dynamically allocated IP |
4897 | ovn-nbctl --wait=sb lsp-add sw0 p31 -- lsp-set-addresses p31 \ | |
4898 | "fe:dc:ba:98:76:54 dynamic" | |
4899 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
4900 | ["fe:dc:ba:98:76:54 192.168.1.18" | |
4901 | ]) | |
4902 | ||
6c4f7a8a NS |
4903 | # Update the static MAC address with dynamically allocated IP and check |
4904 | # if the MAC address is updated in 'Logical_Switch_Port.dynamic_adddresses' | |
4905 | ovn-nbctl --wait=sb lsp-set-addresses p31 "fe:dc:ba:98:76:55 dynamic" | |
4906 | ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses | |
4907 | ||
4908 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
4909 | ["fe:dc:ba:98:76:55 192.168.1.18" | |
4910 | ]) | |
4911 | ||
4912 | ovn-nbctl --wait=sb lsp-set-addresses p31 "dynamic" | |
4913 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
4914 | ["fe:dc:ba:98:76:55 192.168.1.18" | |
4915 | ]) | |
4916 | ||
4917 | ovn-nbctl --wait=sb lsp-set-addresses p31 "fe:dc:ba:98:76:56 dynamic" | |
4918 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0], | |
4919 | ["fe:dc:ba:98:76:56 192.168.1.18" | |
4920 | ]) | |
4921 | ||
161ea2c8 NS |
4922 | |
4923 | # Test the exclude_ips from the IPAM list | |
4924 | ovn-nbctl --wait=sb set logical_switch sw0 \ | |
4925 | other_config:exclude_ips="192.168.1.19 192.168.1.21 192.168.1.23..192.168.1.50" | |
4926 | ||
4927 | ovn-nbctl --wait=sb lsp-add sw0 p32 -- lsp-set-addresses p32 \ | |
4928 | "dynamic" | |
4929 | # 192.168.1.20 should be assigned as 192.168.1.19 is excluded. | |
4930 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p32 dynamic_addresses], [0], | |
4931 | ["0a:00:00:00:00:21 192.168.1.20" | |
4932 | ]) | |
4933 | ||
4934 | ovn-nbctl --wait=sb lsp-add sw0 p33 -- lsp-set-addresses p33 \ | |
4935 | "dynamic" | |
4936 | # 192.168.1.22 should be assigned as 192.168.1.21 is excluded. | |
4937 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p33 dynamic_addresses], [0], | |
4938 | ["0a:00:00:00:00:22 192.168.1.22" | |
4939 | ]) | |
4940 | ||
4941 | ovn-nbctl --wait=sb lsp-add sw0 p34 -- lsp-set-addresses p34 \ | |
4942 | "dynamic" | |
4943 | # 192.168.1.51 should be assigned as 192.168.1.23-192.168.1.50 is excluded. | |
4944 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p34 dynamic_addresses], [0], | |
4945 | ["0a:00:00:00:00:23 192.168.1.51" | |
4946 | ]) | |
4947 | ||
4948 | # Now clear the exclude_ips list. 192.168.1.19 should be assigned. | |
4949 | ovn-nbctl --wait=sb set Logical-switch sw0 other_config:exclude_ips="invalid" | |
4950 | ovn-nbctl --wait=sb lsp-add sw0 p35 -- lsp-set-addresses p35 \ | |
4951 | "dynamic" | |
4952 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p35 dynamic_addresses], [0], | |
4953 | ["0a:00:00:00:00:24 192.168.1.19" | |
4954 | ]) | |
4955 | ||
4956 | # Set invalid data in exclude_ips list. It should be ignored. | |
4957 | ovn-nbctl --wait=sb set Logical-switch sw0 other_config:exclude_ips="182.168.1.30" | |
4958 | ovn-nbctl --wait=sb lsp-add sw0 p36 -- lsp-set-addresses p36 \ | |
4959 | "dynamic" | |
4960 | # 192.168.1.21 should be assigned as that's the next free one. | |
4961 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p36 dynamic_addresses], [0], | |
4962 | ["0a:00:00:00:00:25 192.168.1.21" | |
4963 | ]) | |
4964 | ||
4965 | # Clear the dynamic addresses assignment request. | |
4966 | ovn-nbctl --wait=sb clear logical_switch_port p36 addresses | |
4967 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p36 dynamic_addresses], [0], | |
4968 | [[[]] | |
4969 | ]) | |
4970 | ||
7cc0741e NS |
4971 | # Set IPv6 prefix |
4972 | ovn-nbctl --wait=sb set Logical-switch sw0 other_config:ipv6_prefix="aef0::" | |
4973 | ovn-nbctl --wait=sb lsp-add sw0 p37 -- lsp-set-addresses p37 \ | |
4974 | "dynamic" | |
4975 | ||
4976 | # With prefix aef0 and mac 0a:00:00:00:00:26, the dynamic IPv6 should be | |
4977 | # - aef0::800:ff:fe00:26 (EUI64) | |
4978 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p37 dynamic_addresses], [0], | |
4979 | ["0a:00:00:00:00:26 192.168.1.21 aef0::800:ff:fe00:26" | |
4980 | ]) | |
4981 | ||
4982 | ovn-nbctl --wait=sb ls-add sw4 | |
4983 | ovn-nbctl --wait=sb set Logical-switch sw4 other_config:ipv6_prefix="bef0::" | |
4984 | ovn-nbctl --wait=sb lsp-add sw4 p38 -- lsp-set-addresses p38 \ | |
4985 | "dynamic" | |
4986 | ||
4987 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p38 dynamic_addresses], [0], | |
4988 | ["0a:00:00:00:00:27 bef0::800:ff:fe00:27" | |
4989 | ]) | |
4990 | ||
4991 | ovn-nbctl --wait=sb lsp-add sw4 p39 -- lsp-set-addresses p39 \ | |
4992 | "f0:00:00:00:10:12 dynamic" | |
4993 | ||
4994 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p39 dynamic_addresses], [0], | |
4995 | ["f0:00:00:00:10:12 bef0::f200:ff:fe00:1012" | |
4996 | ]) | |
4997 | ||
4998 | # Clear the other_config for sw4. No dynamic ip should be assigned. | |
4999 | ovn-nbctl --wait=sb clear Logical-switch sw4 other_config | |
5000 | ovn-nbctl --wait=sb lsp-add sw4 p40 -- lsp-set-addresses p40 \ | |
5001 | "dynamic" | |
5002 | ||
5003 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p40 dynamic_addresses], [0], | |
5004 | [[[]] | |
5005 | ]) | |
5006 | ||
5007 | # Test the case where IPv4 addresses are exhausted and IPv6 prefix is set | |
5008 | ovn-nbctl --wait=sb set Logical-switch sw4 other_config:subnet=192.168.2.0/30 \ | |
5009 | -- set Logical-switch sw4 other_config:ipv6_prefix="bef0::" | |
5010 | ||
5011 | # Now p40 should be assigned with dynamic addresses. | |
5012 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p40 dynamic_addresses], [0], | |
5013 | ["0a:00:00:00:00:28 192.168.2.2 bef0::800:ff:fe00:28" | |
5014 | ]) | |
5015 | ||
5016 | ovn-nbctl --wait=sb lsp-add sw4 p41 -- lsp-set-addresses p41 \ | |
5017 | "dynamic" | |
5018 | # p41 should not have IPv4 address (as the pool is exhausted). | |
5019 | AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0], | |
5020 | ["0a:00:00:00:00:29 bef0::800:ff:fe00:29" | |
5021 | ]) | |
5022 | ||
8639f9be ND |
5023 | as ovn-sb |
5024 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5025 | ||
5026 | as ovn-nb | |
5027 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5028 | ||
5029 | as northd | |
5030 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
5031 | ||
5032 | AT_CLEANUP | |
5033 | ||
5034 | AT_SETUP([ovn -- ipam connectivity]) | |
8639f9be ND |
5035 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5036 | ovn_start | |
5037 | ||
5038 | ovn-nbctl lr-add R1 | |
5039 | ||
5040 | # Test for a ping using dynamically allocated addresses. | |
5041 | ovn-nbctl ls-add foo -- add Logical_Switch foo other_config subnet=192.168.1.0/24 | |
5042 | ovn-nbctl ls-add alice -- add Logical_Switch alice other_config subnet=192.168.2.0/24 | |
5043 | ||
5044 | # Connect foo to R1 | |
5045 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
5046 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
20418099 MS |
5047 | options:router-port=foo \ |
5048 | -- lsp-set-addresses rp-foo router | |
8639f9be ND |
5049 | |
5050 | # Connect alice to R1 | |
5051 | ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 192.168.2.1/24 | |
5052 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice type=router \ | |
5053 | options:router-port=alice addresses=\"00:00:00:01:02:04\" | |
5054 | ||
5055 | # Create logical port foo1 in foo | |
fd3b31e9 | 5056 | ovn-nbctl --wait=sb lsp-add foo foo1 \ |
8639f9be | 5057 | -- lsp-set-addresses foo1 "dynamic" |
8bc2c143 | 5058 | 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 |
5059 | |
5060 | # Create logical port alice1 in alice | |
fd3b31e9 | 5061 | ovn-nbctl --wait=sb lsp-add alice alice1 \ |
8639f9be | 5062 | -- lsp-set-addresses alice1 "dynamic" |
8bc2c143 | 5063 | 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 |
5064 | |
5065 | # Create logical port foo2 in foo | |
fd3b31e9 | 5066 | ovn-nbctl --wait=sb lsp-add foo foo2 \ |
8639f9be | 5067 | -- lsp-set-addresses foo2 "dynamic" |
8bc2c143 | 5068 | 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 |
5069 | |
5070 | # Create a hypervisor and create OVS ports corresponding to logical ports. | |
5071 | net_add n1 | |
5072 | ||
5073 | sim_add hv1 | |
5074 | as hv1 | |
5075 | ovs-vsctl add-br br-phys | |
5076 | ovn_attach n1 br-phys 192.168.0.1 | |
5077 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
5078 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
5079 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
5080 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
5081 | ofport-request=1 | |
5082 | ||
5083 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
5084 | set interface hv1-vif2 external-ids:iface-id=foo2 \ | |
5085 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
5086 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
5087 | ofport-request=2 | |
5088 | ||
5089 | ovs-vsctl -- add-port br-int hv1-vif3 -- \ | |
5090 | set interface hv1-vif3 external-ids:iface-id=alice1 \ | |
5091 | options:tx_pcap=hv1/vif3-tx.pcap \ | |
5092 | options:rxq_pcap=hv1/vif3-rx.pcap \ | |
5093 | ofport-request=3 | |
5094 | ||
5095 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5096 | # XXX This should be more systematic. | |
5097 | sleep 1 | |
5098 | ||
5099 | ip_to_hex() { | |
5100 | printf "%02x%02x%02x%02x" "$@" | |
5101 | } | |
8639f9be ND |
5102 | |
5103 | # Send ip packets between foo1 and foo2 | |
5104 | src_mac="0a0000000001" | |
5105 | dst_mac="0a0000000003" | |
5106 | src_ip=`ip_to_hex 192 168 1 2` | |
5107 | dst_ip=`ip_to_hex 192 168 1 3` | |
5108 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5109 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
5110 | ||
5111 | # Send ip packets between foo1 and alice1 | |
5112 | src_mac="0a0000000001" | |
5113 | dst_mac="000000010203" | |
5114 | src_ip=`ip_to_hex 192 168 1 2` | |
5115 | dst_ip=`ip_to_hex 192 168 2 2` | |
5116 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5117 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
5118 | ||
5119 | echo "---------NB dump-----" | |
5120 | ovn-nbctl show | |
5121 | echo "---------------------" | |
5122 | ovn-nbctl list logical_router | |
5123 | echo "---------------------" | |
5124 | ovn-nbctl list logical_router_port | |
5125 | echo "---------------------" | |
5126 | ||
5127 | echo "---------SB dump-----" | |
5128 | ovn-sbctl list datapath_binding | |
5129 | echo "---------------------" | |
5130 | ovn-sbctl list port_binding | |
5131 | echo "---------------------" | |
5132 | ||
5133 | echo "------ hv1 dump ----------" | |
5134 | as hv1 ovs-ofctl dump-flows br-int | |
5135 | ||
5136 | # Packet to Expect at foo2 | |
5137 | src_mac="0a0000000001" | |
5138 | dst_mac="0a0000000003" | |
5139 | src_ip=`ip_to_hex 192 168 1 2` | |
5140 | dst_ip=`ip_to_hex 192 168 1 3` | |
5141 | expected=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5142 | ||
e4543cfe DDP |
5143 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets |
5144 | echo $expected > expout | |
8639f9be ND |
5145 | AT_CHECK([cat received1.packets], [0], [expout]) |
5146 | ||
5147 | # Packet to Expect at alice1 | |
5148 | src_mac="000000010204" | |
5149 | dst_mac="0a0000000002" | |
5150 | src_ip=`ip_to_hex 192 168 1 2` | |
5151 | dst_ip=`ip_to_hex 192 168 2 2` | |
5152 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
5153 | ||
e4543cfe DDP |
5154 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets |
5155 | echo $expected > expout | |
8639f9be ND |
5156 | AT_CHECK([cat received2.packets], [0], [expout]) |
5157 | ||
5158 | OVN_CLEANUP([hv1]) | |
5159 | ||
5160 | AT_CLEANUP | |
f5792c3f NS |
5161 | |
5162 | AT_SETUP([ovn -- ovs-vswitchd restart]) | |
1794d5f2 | 5163 | AT_KEYWORDS([vswitchd]) |
f5792c3f NS |
5164 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5165 | ovn_start | |
5166 | ||
5167 | ovn-nbctl ls-add ls1 | |
5168 | ||
5169 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
5170 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
5171 | ||
5172 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" | |
5173 | ||
5174 | net_add n1 | |
5175 | sim_add hv1 | |
5176 | ||
5177 | as hv1 | |
5178 | ovs-vsctl add-br br-phys | |
5179 | ovn_attach n1 br-phys 192.168.0.1 | |
5180 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
5181 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
5182 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
5183 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
5184 | ofport-request=1 | |
5185 | ||
5186 | ovn_populate_arp | |
5187 | sleep 2 | |
5188 | ||
5189 | as hv1 ovs-vsctl show | |
5190 | ||
5191 | echo "---------------------" | |
5192 | ovn-sbctl dump-flows | |
5193 | echo "---------------------" | |
5194 | ||
5195 | echo "------ hv1 dump ----------" | |
5196 | as hv1 ovs-ofctl dump-flows br-int | |
5197 | total_flows=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
5198 | ||
5199 | echo "Total flows before vswitchd restart = " $total_flows | |
5200 | ||
5201 | # Code taken from ovs-save utility | |
5202 | save_flows () { | |
5203 | echo "ovs-ofctl add-flows br-int - << EOF" > restore_flows.sh | |
5204 | as hv1 ovs-ofctl dump-flows "br-int" | sed -e '/NXST_FLOW/d' \ | |
5205 | -e 's/\(idle\|hard\)_age=[^,]*,//g' >> restore_flows.sh | |
5206 | echo "EOF" >> restore_flows.sh | |
5207 | } | |
5208 | ||
5209 | restart_vswitchd () { | |
5210 | restore_flows=$1 | |
5211 | ||
5212 | if test $restore_flows = true; then | |
5213 | save_flows | |
5214 | fi | |
5215 | ||
5216 | as hv1 | |
5217 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
5218 | ||
5219 | if test $restore_flows = true; then | |
5220 | as hv1 | |
5221 | ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="true" | |
5222 | fi | |
5223 | ||
5224 | as hv1 | |
5225 | start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl | |
5226 | ovs-ofctl dump-flows br-int | |
5227 | ||
5228 | if test $restore_flows = true; then | |
5229 | sh ./restore_flows.sh | |
5230 | echo "Flows after restore" | |
5231 | as hv1 | |
5232 | ovs-ofctl dump-flows br-int | |
5233 | ovs-vsctl --no-wait --if-exists remove open_vswitch . other_config \ | |
5234 | flow-restore-wait="true" | |
5235 | fi | |
5236 | } | |
5237 | ||
5238 | # Save the flows, restart vswitchd and restore the flows | |
5239 | restart_vswitchd true | |
5240 | OVS_WAIT_UNTIL([ | |
5241 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
5242 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
5243 | test "${total_flows}" = "${total_flows_after_restart}" | |
5244 | ]) | |
5245 | ||
5246 | # Restart vswitchd without restoring | |
5247 | restart_vswitchd false | |
5248 | OVS_WAIT_UNTIL([ | |
5249 | total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` | |
5250 | echo "Total flows after vswitchd restart = " $total_flows_after_restart | |
5251 | test "${total_flows}" = "${total_flows_after_restart}" | |
5252 | ]) | |
5253 | ||
5254 | OVN_CLEANUP([hv1]) | |
5255 | AT_CLEANUP | |
47021598 CSV |
5256 | |
5257 | AT_SETUP([ovn -- send arp for nexthop]) | |
47021598 CSV |
5258 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5259 | ovn_start | |
5260 | ||
5261 | # Topology: Two LSs - ls1 and ls2 are connected via router r0 | |
5262 | ||
5263 | # Create logical switches | |
5264 | ovn-nbctl ls-add ls1 | |
5265 | ovn-nbctl ls-add ls2 | |
5266 | ||
5267 | # Create router | |
5268 | ovn-nbctl create Logical_Router name=lr0 | |
5269 | ||
5270 | # Add router ls1p1 port to gateway router | |
5271 | ovn-nbctl lrp-add lr0 lrp-ls1lp1 f0:00:00:00:00:01 192.168.0.1/24 | |
5272 | ovn-nbctl lsp-add ls1 ls1lp1 -- set Logical_Switch_Port ls1lp1 \ | |
5273 | type=router options:router-port=lrp-ls1lp1 \ | |
5274 | addresses='"f0:00:00:00:00:01 192.168.0.1"' | |
5275 | ||
5276 | # Add router ls2p2 port to gateway router | |
5277 | ovn-nbctl lrp-add lr0 lrp-ls2lp1 f0:00:00:00:00:02 192.168.1.1/24 | |
5278 | ovn-nbctl lsp-add ls2 ls2lp1 -- set Logical_Switch_Port ls2lp1 \ | |
5279 | type=router options:router-port=lrp-ls2lp1 \ | |
5280 | addresses='"f0:00:00:00:00:02 192.168.1.1"' | |
5281 | ||
5282 | # Set default gateway (nexthop) to 192.168.1.254 | |
5283 | ovn-nbctl lr-route-add lr0 "0.0.0.0/0" 192.168.1.254 lrp-ls2lp1 | |
5284 | ||
5285 | # Create logical port ls1lp2 in ls1 | |
5286 | ovn-nbctl lsp-add ls1 ls1lp2 \ | |
5287 | -- lsp-set-addresses ls1lp2 "f0:00:00:00:00:03 192.168.0.2" | |
5288 | ||
5289 | # Create logical port ls2lp2 in ls2 | |
5290 | ovn-nbctl lsp-add ls2 ls2lp2 \ | |
5291 | -- lsp-set-addresses ls2lp2 "f0:00:00:00:00:04 192.168.1.10" | |
5292 | ||
5293 | net_add n1 | |
5294 | sim_add hv1 | |
5295 | as hv1 | |
5296 | ovs-vsctl add-br br-phys | |
5297 | ovn_attach n1 br-phys 192.168.0.1 | |
5298 | ovs-vsctl -- add-port br-int hv1-ls1lp2 -- \ | |
5299 | set interface hv1-ls1lp2 external-ids:iface-id=ls1lp2 \ | |
5300 | options:tx_pcap=hv1/ls1lp2-tx.pcap \ | |
5301 | options:rxq_pcap=hv1/ls1lp2-rx.pcap \ | |
5302 | ofport-request=1 | |
5303 | ovs-vsctl -- add-port br-int hv1-ls2lp2 -- \ | |
5304 | set interface hv1-ls2lp2 external-ids:iface-id=ls2lp2 \ | |
5305 | options:tx_pcap=hv1/ls2lp2-tx.pcap \ | |
5306 | options:rxq_pcap=hv1/ls2lp2-rx.pcap \ | |
5307 | ofport-request=2 | |
5308 | ||
5309 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
5310 | # XXX This should be more systematic. | |
5311 | sleep 1 | |
5312 | ||
5313 | echo "---------NB dump-----" | |
5314 | ovn-nbctl show | |
5315 | echo "---------------------" | |
5316 | ovn-nbctl list logical_router | |
5317 | echo "---------------------" | |
5318 | ovn-nbctl list logical_router_port | |
5319 | echo "---------------------" | |
5320 | ||
5321 | echo "---------SB dump-----" | |
5322 | ovn-sbctl list datapath_binding | |
5323 | echo "---------------------" | |
5324 | ovn-sbctl list port_binding | |
5325 | echo "---------------------" | |
5326 | ovn-sbctl dump-flows | |
5327 | echo "---------------------" | |
5328 | ovn-sbctl list chassis | |
5329 | ovn-sbctl list encap | |
5330 | echo "---------------------" | |
5331 | ||
5332 | echo "------Flows dump-----" | |
5333 | as hv1 | |
5334 | ovs-ofctl dump-flows | |
5335 | echo "---------------------" | |
5336 | ||
5337 | ip_to_hex() { | |
5338 | printf "%02x%02x%02x%02x" "$@" | |
5339 | } | |
5340 | ||
5341 | src_mac="f00000000003" | |
5342 | dst_mac="f00000000001" | |
5343 | src_ip=`ip_to_hex 192 168 0 2` | |
5344 | dst_ip=`ip_to_hex 8 8 8 8` | |
5345 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
5346 | ||
5347 | # Send IP packet destined to 8.8.8.8 from lsp1lp2 | |
5348 | as hv1 ovs-appctl netdev-dummy/receive hv1-ls1lp2 $packet | |
5349 | ||
5350 | trim_zeros() { | |
5351 | sed 's/\(00\)\{1,\}$//' | |
5352 | } | |
5353 | ||
5354 | # ARP packet should be received with Target IP Address set to 192.168.1.254 and | |
5355 | # not 8.8.8.8 | |
5356 | ||
5357 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/ls2lp2-tx.pcap | trim_zeros > packets | |
5358 | expected="fffffffffffff0000000000208060001080006040001f00000000002c0a80101000000000000c0a801fe" | |
5359 | echo $expected > expout | |
5360 | AT_CHECK([cat packets], [0], [expout]) | |
5361 | cat packets | |
5362 | ||
5363 | OVN_CLEANUP([hv1]) | |
5364 | ||
5365 | AT_CLEANUP | |
8439c2eb CSV |
5366 | |
5367 | AT_SETUP([ovn -- send gratuitous arp for nat ips in localnet]) | |
8439c2eb CSV |
5368 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5369 | ovn_start | |
5370 | # Create logical switch | |
5371 | ovn-nbctl ls-add ls0 | |
5372 | # Create gateway router | |
5373 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
5374 | # Add router port to gateway router | |
5375 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 | |
5376 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
d223b67b | 5377 | type=router options:router-port=lrp0 addresses='"f0:00:00:00:00:01"' |
8439c2eb CSV |
5378 | # Add nat-address option |
5379 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="f0:00:00:00:00:01 192.168.0.2" | |
5380 | ||
5381 | net_add n1 | |
5382 | sim_add hv1 | |
5383 | as hv1 | |
5384 | ovs-vsctl \ | |
5385 | -- add-br br-phys \ | |
5386 | -- add-br br-eth0 | |
5387 | ||
5388 | ovn_attach n1 br-phys 192.168.0.1 | |
5389 | ||
5390 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
5391 | 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]) | |
5392 | ||
5393 | # Create a localnet port. | |
5394 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
5395 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
5396 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
5397 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
5398 | ||
5399 | ||
5400 | # Wait for packet to be received. | |
5401 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) | |
5402 | trim_zeros() { | |
5403 | sed 's/\(00\)\{1,\}$//' | |
5404 | } | |
5405 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
5406 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
5407 | echo $expected > expout | |
5408 | AT_CHECK([sort packets], [0], [expout]) | |
5409 | cat packets | |
5410 | ||
5411 | OVN_CLEANUP([hv1]) | |
5412 | ||
5413 | AT_CLEANUP | |
6e31816f | 5414 | |
e914fb54 MS |
5415 | AT_SETUP([ovn -- send gratuitous arp with nat-addresses router in localnet]) |
5416 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5417 | ovn_start | |
5418 | # Create logical switch | |
5419 | ovn-nbctl ls-add ls0 | |
5420 | # Create gateway router | |
5421 | ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 | |
5422 | # Add router port to gateway router | |
5423 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 | |
5424 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
d223b67b | 5425 | type=router options:router-port=lrp0 addresses='"f0:00:00:00:00:01"' |
e914fb54 MS |
5426 | # Add nat-address option |
5427 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" | |
5428 | # Add NAT rules | |
5429 | AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 192.168.0.1 10.0.0.0/24]) | |
5430 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 192.168.0.2 10.0.0.1]) | |
5431 | # Add load balancers | |
5432 | AT_CHECK([ovn-nbctl lb-add lb0 192.168.0.3:80 10.0.0.2:80,10.0.0.3:80]) | |
5433 | AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0]) | |
5434 | AT_CHECK([ovn-nbctl lb-add lb1 192.168.0.3:8080 10.0.0.2:8080,10.0.0.3:8080]) | |
5435 | AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1]) | |
5436 | ||
5437 | net_add n1 | |
5438 | sim_add hv1 | |
5439 | as hv1 | |
5440 | ovs-vsctl \ | |
5441 | -- add-br br-phys \ | |
5442 | -- add-br br-eth0 | |
5443 | ||
5444 | ovn_attach n1 br-phys 192.168.0.1 | |
5445 | ||
5446 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
5447 | 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]) | |
5448 | ||
5449 | # Create a localnet port. | |
5450 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
5451 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
5452 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
5453 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
5454 | ||
5455 | ||
5456 | # Wait for packet to be received. | |
5457 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) | |
5458 | trim_zeros() { | |
5459 | sed 's/\(00\)\{1,\}$//' | |
5460 | } | |
5461 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
5462 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" | |
5463 | echo $expected > expout | |
5464 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
5465 | echo $expected >> expout | |
5466 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80003000000000000c0a80003" | |
5467 | echo $expected >> expout | |
5468 | AT_CHECK([sort packets], [0], [expout]) | |
5469 | cat packets | |
5470 | ||
5471 | OVN_CLEANUP([hv1]) | |
5472 | ||
5473 | AT_CLEANUP | |
5474 | ||
6e31816f | 5475 | AT_SETUP([ovn -- delete mac bindings]) |
6e31816f CSV |
5476 | ovn_start |
5477 | net_add n1 | |
5478 | sim_add hv1 | |
5479 | as hv1 | |
5480 | ovs-vsctl -- add-br br-phys | |
5481 | ovn_attach n1 br-phys 192.168.0.1 | |
5482 | # Create logical switch ls0 | |
5483 | ovn-nbctl ls-add ls0 | |
5484 | # Create ports lp0, lp1 in ls0 | |
5485 | ovn-nbctl lsp-add ls0 lp0 | |
5486 | ovn-nbctl lsp-add ls0 lp1 | |
5487 | ovn-nbctl lsp-set-addresses lp0 "f0:00:00:00:00:01 192.168.0.1" | |
5488 | ovn-nbctl lsp-set-addresses lp1 "f0:00:00:00:00:02 192.168.0.2" | |
5489 | dp_uuid=`ovn-sbctl find datapath | grep uuid | cut -f2 -d ":" | cut -f2 -d " "` | |
5490 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp0 mac="mac1" | |
5491 | ovn-sbctl create MAC_Binding ip=10.0.0.1 datapath=$dp_uuid logical_port=lp1 mac="mac2" | |
5492 | ovn-sbctl find MAC_Binding | |
093aa761 | 5493 | # Delete port lp0 and check that its MAC_Binding is deleted. |
6e31816f CSV |
5494 | ovn-nbctl lsp-del lp0 |
5495 | ovn-sbctl find MAC_Binding | |
093aa761 BP |
5496 | OVS_WAIT_UNTIL([test `ovn-sbctl find MAC_Binding logical_port=lp0 | wc -l` = 0]) |
5497 | # Delete logical switch ls0 and check that its MAC_Binding is deleted. | |
6e31816f CSV |
5498 | ovn-nbctl ls-del ls0 |
5499 | ovn-sbctl find MAC_Binding | |
093aa761 | 5500 | OVS_WAIT_UNTIL([test `ovn-sbctl find MAC_Binding | wc -l` = 0]) |
6e31816f CSV |
5501 | |
5502 | OVN_CLEANUP([hv1]) | |
5503 | ||
5504 | AT_CLEANUP | |
926c34fd RM |
5505 | |
5506 | AT_SETUP([ovn -- conntrack zone allocation]) | |
926c34fd RM |
5507 | AT_SKIP_IF([test $HAVE_PYTHON = no]) |
5508 | ovn_start | |
5509 | ||
5510 | # Logical network: | |
5511 | # 2 logical switches "foo" (192.168.1.0/24) and "bar" (172.16.1.0/24) | |
5512 | # connected to a router R1. | |
5513 | # foo has foo1 to act as a client. | |
5514 | # bar has bar1, bar2, bar3 to act as servers. | |
5515 | ||
5516 | net_add n1 | |
5517 | ||
5518 | sim_add hv1 | |
5519 | as hv1 | |
5520 | ovs-vsctl add-br br-phys | |
5521 | ovn_attach n1 br-phys 192.168.0.1 | |
5522 | for i in foo1 bar1 bar2 bar3; do | |
5523 | ovs-vsctl -- add-port br-int $i -- \ | |
5524 | set interface $i external-ids:iface-id=$i \ | |
5525 | options:tx_pcap=hv1/$i-tx.pcap \ | |
5526 | options:rxq_pcap=hv1/$i-rx.pcap | |
5527 | done | |
5528 | ||
5529 | ovn-nbctl create Logical_Router name=R1 | |
5530 | ovn-nbctl ls-add foo | |
5531 | ovn-nbctl ls-add bar | |
5532 | ||
5533 | # Connect foo to R1 | |
5534 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
5535 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
5536 | type=router options:router-port=foo addresses=\"00:00:01:01:02:03\" | |
5537 | ||
5538 | # Connect bar to R1 | |
5539 | ovn-nbctl lrp-add R1 bar 00:00:01:01:02:04 172.16.1.1/24 | |
5540 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar \ | |
5541 | type=router options:router-port=bar addresses=\"00:00:01:01:02:04\" | |
5542 | ||
5543 | # Create logical port foo1 in foo | |
5544 | ovn-nbctl lsp-add foo foo1 \ | |
5545 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
5546 | ||
5547 | # Create logical port bar1, bar2 and bar3 in bar | |
5548 | for i in `seq 1 3`; do | |
5549 | ip=`expr $i + 1` | |
5550 | ovn-nbctl lsp-add bar bar$i \ | |
5551 | -- lsp-set-addresses bar$i "f0:00:0a:01:02:$i 172.16.1.$ip" | |
5552 | done | |
5553 | ||
5554 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=0 | grep REG13 | wc -l` -eq 4]) | |
5555 | ||
5556 | OVN_CLEANUP([hv1]) | |
5557 | ||
5558 | AT_CLEANUP | |
b511690b GS |
5559 | |
5560 | AT_SETUP([ovn -- tag allocation]) | |
b511690b GS |
5561 | ovn_start |
5562 | ||
5563 | AT_CHECK([ovn-nbctl ls-add ls0]) | |
5564 | AT_CHECK([ovn-nbctl lsp-add ls0 parent1]) | |
5565 | AT_CHECK([ovn-nbctl lsp-add ls0 parent2]) | |
5566 | AT_CHECK([ovn-nbctl ls-add ls1]) | |
5567 | ||
5568 | dnl When a tag is provided, no allocation is done | |
5569 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c0 parent1 3]) | |
5570 | AT_CHECK([ovn-nbctl lsp-get-tag c0], [0], [3 | |
5571 | ]) | |
5572 | dnl The same 'tag' gets created in southbound database. | |
5573 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5574 | logical_port="c0"], [0], [3 | |
5575 | ]) | |
5576 | ||
5577 | dnl Allocate tags and see it getting created in both NB and SB | |
5578 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c1 parent1 0]) | |
5579 | AT_CHECK([ovn-nbctl lsp-get-tag c1], [0], [1 | |
5580 | ]) | |
5581 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5582 | logical_port="c1"], [0], [1 | |
5583 | ]) | |
5584 | ||
5585 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c2 parent1 0]) | |
5586 | AT_CHECK([ovn-nbctl lsp-get-tag c2], [0], [2 | |
5587 | ]) | |
5588 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5589 | logical_port="c2"], [0], [2 | |
5590 | ]) | |
5591 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c3 parent1 0]) | |
5592 | AT_CHECK([ovn-nbctl lsp-get-tag c3], [0], [4 | |
5593 | ]) | |
5594 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5595 | logical_port="c3"], [0], [4 | |
5596 | ]) | |
5597 | ||
5598 | dnl A different parent. | |
5599 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c4 parent2 0]) | |
5600 | AT_CHECK([ovn-nbctl lsp-get-tag c4], [0], [1 | |
5601 | ]) | |
5602 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5603 | logical_port="c4"], [0], [1 | |
5604 | ]) | |
5605 | ||
5606 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c5 parent2 0]) | |
5607 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
5608 | ]) | |
5609 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5610 | logical_port="c5"], [0], [2 | |
5611 | ]) | |
5612 | ||
5613 | dnl Delete a logical port and create a new one. | |
5614 | AT_CHECK([ovn-nbctl --wait=sb lsp-del c1]) | |
5615 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c6 parent1 0]) | |
5616 | AT_CHECK([ovn-nbctl lsp-get-tag c6], [0], [1 | |
5617 | ]) | |
5618 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5619 | logical_port="c6"], [0], [1 | |
5620 | ]) | |
5621 | ||
5622 | dnl Restart northd to see that the same allocation remains. | |
5623 | as northd | |
5624 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
5625 | start_daemon ovn-northd \ | |
5626 | --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock \ | |
5627 | --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock | |
5628 | ||
5629 | dnl Create a switch to make sure that ovn-northd has run through the main loop. | |
5630 | AT_CHECK([ovn-nbctl --wait=sb ls-add ls-dummy]) | |
5631 | AT_CHECK([ovn-nbctl lsp-get-tag c0], [0], [3 | |
5632 | ]) | |
5633 | AT_CHECK([ovn-nbctl lsp-get-tag c6], [0], [1 | |
5634 | ]) | |
5635 | AT_CHECK([ovn-nbctl lsp-get-tag c2], [0], [2 | |
5636 | ]) | |
5637 | AT_CHECK([ovn-nbctl lsp-get-tag c3], [0], [4 | |
5638 | ]) | |
5639 | AT_CHECK([ovn-nbctl lsp-get-tag c4], [0], [1 | |
5640 | ]) | |
5641 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
5642 | ]) | |
5643 | ||
5644 | dnl Create a switch port with a tag that has already been allocated. | |
5645 | dnl It should go through fine with a duplicate tag. | |
5646 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls1 c7 parent2 2]) | |
5647 | AT_CHECK([ovn-nbctl lsp-get-tag c7], [0], [2 | |
5648 | ]) | |
5649 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5650 | logical_port="c7"], [0], [2 | |
5651 | ]) | |
5652 | AT_CHECK([ovn-nbctl lsp-get-tag c5], [0], [2 | |
5653 | ]) | |
5654 | ||
5655 | AT_CHECK([ovn-nbctl ls-add ls2]) | |
5656 | dnl When there is no parent_name provided (for say, 'localnet'), 'tag_request' | |
5657 | dnl gets copied to 'tag' | |
5658 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls2 local0 "" 25]) | |
5659 | AT_CHECK([ovn-nbctl lsp-get-tag local0], [0], [25 | |
5660 | ]) | |
5661 | dnl The same 'tag' gets created in southbound database. | |
5662 | AT_CHECK([ovn-sbctl --data=bare --no-heading --columns=tag find port_binding \ | |
5663 | logical_port="local0"], [0], [25 | |
5664 | ]) | |
5665 | dnl If 'tag_request' is 0 for localnet, nothing gets written to 'tag' | |
5666 | AT_CHECK([ovn-nbctl --wait=sb lsp-add ls2 local1 "" 0]) | |
5667 | AT_CHECK([ovn-nbctl lsp-get-tag local1]) | |
5668 | dnl change the tag_request. | |
5669 | AT_CHECK([ovn-nbctl --wait=sb set logical_switch_port local1 tag_request=50]) | |
5670 | AT_CHECK([ovn-nbctl lsp-get-tag local1], [0], [50 | |
5671 | ]) | |
5672 | ||
5673 | AT_CLEANUP | |
57afd0c0 RR |
5674 | |
5675 | AT_SETUP([ovn -- lsp deletion and broadcast-flow deletion on localnet]) | |
57afd0c0 RR |
5676 | ovn_start |
5677 | ovn-nbctl ls-add lsw0 | |
5678 | net_add n1 | |
5679 | for i in 1 2; do | |
5680 | sim_add hv$i | |
5681 | as hv$i | |
5682 | ovs-vsctl add-br br-phys | |
5683 | ovn_attach n1 br-phys 192.168.0.$i | |
5684 | ovs-vsctl add-br br-eth0 | |
5685 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0]) | |
5686 | done | |
5687 | ||
5688 | # Create a localnet port. | |
5689 | AT_CHECK([ovn-nbctl lsp-add lsw0 ln_port]) | |
5690 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
5691 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
5692 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
5693 | ||
5694 | ||
5695 | # Create 3 vifs. | |
5696 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif1]) | |
5697 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif1 "f0:00:00:00:00:01 192.168.1.1"]) | |
5698 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif1 "f0:00:00:00:00:01"]) | |
5699 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif2]) | |
5700 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif2 "f0:00:00:00:00:01 192.168.1.2"]) | |
5701 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif2 "f0:00:00:00:00:02"]) | |
5702 | AT_CHECK([ovn-nbctl lsp-add lsw0 localvif3]) | |
5703 | AT_CHECK([ovn-nbctl lsp-set-addresses localvif3 "f0:00:00:00:00:03 192.168.1.3"]) | |
5704 | AT_CHECK([ovn-nbctl lsp-set-port-security localvif3 "f0:00:00:00:00:03"]) | |
5705 | ||
5706 | # Bind the localvif1 to hv1. | |
5707 | as hv1 | |
5708 | AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1]) | |
5709 | ||
5710 | # On hv1, check that there are no flows outputting bcast to tunnel | |
5711 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) | |
5712 | ||
1ea9b847 | 5713 | # On hv2, check that no flow outputs bcast to tunnel to hv1. |
57afd0c0 | 5714 | as hv2 |
1ea9b847 | 5715 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) |
57afd0c0 RR |
5716 | |
5717 | # Now bind vif2 on hv2. | |
5718 | AT_CHECK([ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2]) | |
5719 | ||
5720 | # At this point, the broadcast flow on vif2 should be deleted. | |
5721 | # because, there is now a localnet vif bound (table=32 programming logic) | |
5722 | OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=32 | ofctl_strip | grep output | wc -l` -eq 0]) | |
5723 | ||
5724 | # Verify that the local net patch port exists on hv2. | |
5725 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
5726 | ||
5727 | # Now bind vif3 on hv2. | |
5728 | AT_CHECK([ovs-vsctl add-port br-int localvif3 -- set Interface localvif3 external_ids:iface-id=localvif3]) | |
5729 | ||
5730 | # Verify that the local net patch port still exists on hv2 | |
5731 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
5732 | ||
5733 | # Delete localvif2 | |
5734 | AT_CHECK([ovn-nbctl lsp-del localvif2]) | |
5735 | ||
5736 | # Verify that the local net patch port still exists on hv2, | |
5737 | # because, localvif3 is still bound. | |
5738 | OVS_WAIT_UNTIL([test `ovs-vsctl show | grep "Port patch-br-int-to-ln_port" | wc -l` -eq 1]) | |
5739 | ||
57afd0c0 | 5740 | OVN_CLEANUP([hv1],[hv2]) |
1a03fc7d BS |
5741 | |
5742 | AT_CLEANUP | |
5743 | ||
5744 | AT_SETUP([ovn -- DSCP marking check]) | |
5745 | AT_KEYWORDS([ovn]) | |
5746 | ovn_start | |
5747 | ||
5748 | ovn-nbctl ls-add lsw0 | |
5749 | ovn-nbctl --wait=sb lsp-add lsw0 lp1 | |
5750 | ovn-nbctl --wait=sb lsp-add lsw0 lp2 | |
5751 | ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 | |
5752 | ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 | |
5753 | ovn-nbctl lsp-set-port-security lp1 f0:00:00:00:00:01 | |
5754 | ovn-nbctl lsp-set-port-security lp2 f0:00:00:00:00:02 | |
5755 | ovn-nbctl --wait=sb sync | |
5756 | net_add n1 | |
5757 | sim_add hv | |
5758 | as hv | |
5759 | ovs-vsctl add-br br-phys | |
5760 | ovn_attach n1 br-phys 192.168.0.1 | |
5761 | 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 | |
5762 | 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 | |
5763 | ||
5764 | AT_CAPTURE_FILE([trace]) | |
5765 | ovn_trace () { | |
5766 | ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' | |
5767 | } | |
5768 | ||
5769 | # Extracts nw_tos from the final flow from ofproto/trace output and prints | |
5770 | # it on stdout. Prints "none" if no nw_tos was included. | |
5771 | get_final_nw_tos() { | |
5772 | if flow=$(grep '^Final flow:' stdout); then :; else | |
5773 | # The output didn't have a final flow. | |
5774 | return 99 | |
5775 | fi | |
5776 | ||
5777 | tos=$(echo "$flow" | sed -n 's/.*nw_tos=\([[0-9]]\{1,\}\).*/\1/p') | |
5778 | case $tos in | |
5779 | '') echo none ;; | |
5780 | *) echo $tos ;; | |
5781 | esac | |
5782 | } | |
5783 | ||
5784 | # check_tos TOS | |
5785 | # | |
5786 | # Checks that a packet from 1.1.1.1 to 1.1.1.2 gets its DSCP set to TOS. | |
5787 | check_tos() { | |
5788 | # First check with ovn-trace for logical flows. | |
5789 | echo "checking for tos $1" | |
5790 | (if test $1 != 0; then echo "ip.dscp = $1;"; fi; | |
5791 | echo 'output("lp2");') > expout | |
5792 | 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]) | |
5793 | ||
5794 | # Then re-check with ofproto/trace for a physical packet. | |
5795 | 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]) | |
5796 | AT_CHECK_UNQUOTED([get_final_nw_tos], [0], [`expr $1 \* 4` | |
5797 | ]) | |
5798 | } | |
5799 | ||
5800 | # check at L2 | |
5801 | 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"); | |
5802 | ]) | |
5803 | 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]) | |
5804 | AT_CHECK([get_final_nw_tos], [0], [none | |
5805 | ]) | |
5806 | ||
5807 | # check at L3 without dscp marking | |
5808 | check_tos 0 | |
5809 | ||
5810 | # Mark DSCP with a valid value | |
5811 | 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) | |
5812 | check_tos 48 | |
5813 | ||
5814 | # Update the DSCP marking | |
5815 | ovn-nbctl --wait=hv set QoS $qos_id action=dscp=63 | |
5816 | check_tos 63 | |
5817 | ||
5818 | ovn-nbctl --wait=hv set QoS $qos_id match="outport\=\=\"lp2\"" direction="to-lport" | |
5819 | check_tos 63 | |
5820 | ||
5821 | # Disable DSCP marking | |
5822 | ovn-nbctl --wait=hv clear Logical_Switch lsw0 qos_rules | |
5823 | check_tos 0 | |
5824 | ||
5825 | OVN_CLEANUP([hv]) | |
57afd0c0 | 5826 | AT_CLEANUP |
7fff4eb7 LR |
5827 | |
5828 | AT_SETUP([ovn -- read-only sb db:ptcp access]) | |
5829 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5830 | ||
5831 | : > .$1.db.~lock~ | |
5832 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
5833 | ||
5834 | # Add read-only remote to sb ovsdb-server | |
5835 | AT_CHECK( | |
5836 | [ovsdb-tool transact ovn-sb.db \ | |
5837 | ['["OVN_Southbound", | |
5838 | {"op": "insert", | |
5839 | "table": "SB_Global", | |
5840 | "row": { | |
5841 | "connections": ["set", [["named-uuid", "xyz"]]]}}, | |
5842 | {"op": "insert", | |
5843 | "table": "Connection", | |
5844 | "uuid-name": "xyz", | |
5845 | "row": {"target": "ptcp:0:127.0.0.1", | |
5846 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
5847 | ||
5848 | start_daemon ovsdb-server --remote=punix:ovn-sb.sock --remote=db:OVN_Southbound,SB_Global,connections ovn-sb.db | |
5849 | ||
5850 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5851 | ||
5852 | # read-only accesses should succeed | |
5853 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT list SB_Global], [0], [stdout], [ignore]) | |
5854 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT list Connection], [0], [stdout], [ignore]) | |
5855 | ||
5856 | # write access should fail | |
5857 | AT_CHECK([ovn-sbctl --db=tcp:127.0.0.1:$TCP_PORT chassis-add ch vxlan 1.2.4.8], [1], [ignore], | |
5858 | [ovn-sbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
5859 | ]) | |
5860 | ||
5861 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5862 | AT_CLEANUP | |
5863 | ||
5864 | AT_SETUP([ovn -- read-only sb db:pssl access]) | |
5865 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5866 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
5867 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5868 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
5869 | \\]"]) | |
5870 | ||
5871 | : > .$1.db.~lock~ | |
5872 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
5873 | ||
5874 | # Add read-only remote to sb ovsdb-server | |
5875 | AT_CHECK( | |
5876 | [ovsdb-tool transact ovn-sb.db \ | |
5877 | ['["OVN_Southbound", | |
5878 | {"op": "insert", | |
5879 | "table": "SB_Global", | |
5880 | "row": { | |
5881 | "connections": ["set", [["named-uuid", "xyz"]]]}}, | |
5882 | {"op": "insert", | |
5883 | "table": "Connection", | |
5884 | "uuid-name": "xyz", | |
5885 | "row": {"target": "pssl:0:127.0.0.1", | |
5886 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
5887 | ||
5888 | start_daemon ovsdb-server --remote=punix:ovn-sb.sock \ | |
5889 | --remote=db:OVN_Southbound,SB_Global,connections \ | |
5890 | --private-key="$PKIDIR/testpki-privkey2.pem" \ | |
5891 | --certificate="$PKIDIR/testpki-cert2.pem" \ | |
5892 | --ca-cert="$PKIDIR/testpki-cacert.pem" \ | |
5893 | ovn-sb.db | |
5894 | ||
5895 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5896 | ||
5897 | # read-only accesses should succeed | |
5898 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5899 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5900 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5901 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5902 | list SB_Global], [0], [stdout], [ignore]) | |
5903 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5904 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5905 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5906 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5907 | list Connection], [0], [stdout], [ignore]) | |
5908 | ||
5909 | # write access should fail | |
5910 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5911 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5912 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5913 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5914 | chassis-add ch vxlan 1.2.4.8], [1], [ignore], | |
5915 | [ovn-sbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"} | |
5916 | ]) | |
5917 | ||
5918 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5919 | AT_CLEANUP | |
5920 | ||
821302cf LR |
5921 | AT_SETUP([ovn -- nb connection/ssl commands]) |
5922 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5923 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
5924 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5925 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
5926 | \\]"]) | |
5927 | ||
5928 | : > .$1.db.~lock~ | |
5929 | ovsdb-tool create ovn-nb.db "$abs_top_srcdir"/ovn/ovn-nb.ovsschema | |
5930 | ||
5931 | # Start nb db server using db connection/ssl entries (unpopulated initially) | |
5932 | start_daemon ovsdb-server --remote=punix:ovnnb_db.sock \ | |
5933 | --remote=db:OVN_Northbound,NB_Global,connections \ | |
5934 | --private-key=db:OVN_Northbound,SSL,private_key \ | |
5935 | --certificate=db:OVN_Northbound,SSL,certificate \ | |
5936 | --ca-cert=db:OVN_Northbound,SSL,ca_cert \ | |
5937 | ovn-nb.db | |
5938 | ||
5939 | # Populate SSL configuration entries in nb db | |
5940 | AT_CHECK( | |
5941 | [ovn-nbctl set-ssl $PKIDIR/testpki-privkey.pem \ | |
5942 | $PKIDIR/testpki-cert.pem \ | |
5943 | $PKIDIR/testpki-cacert.pem], [0], [stdout], [ignore]) | |
5944 | ||
5945 | # Populate a passive SSL connection in nb db | |
5946 | AT_CHECK([ovn-nbctl set-connection pssl:0:127.0.0.1], [0], [stdout], [ignore]) | |
5947 | ||
5948 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
5949 | ||
5950 | # Verify SSL connetivity to nb db server | |
5951 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5952 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5953 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5954 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5955 | list NB_Global], | |
5956 | [0], [stdout], [ignore]) | |
5957 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5958 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
5959 | --certificate=$PKIDIR/testpki-cert.pem \ | |
5960 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5961 | list Connection], | |
5962 | [0], [stdout], [ignore]) | |
5963 | AT_CHECK([ovn-nbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
5964 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
10471820 LR |
5965 | --certificate=$PKIDIR/testpki-cert.pem \ |
5966 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
5967 | get-connection], | |
5968 | [0], [stdout], [ignore]) | |
5969 | ||
5970 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
5971 | AT_CLEANUP | |
5972 | ||
5973 | AT_SETUP([ovn -- sb connection/ssl commands]) | |
5974 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
5975 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
5976 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5977 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" | |
5978 | \\]"]) | |
5979 | ||
5980 | : > .$1.db.~lock~ | |
5981 | ovsdb-tool create ovn-sb.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
5982 | ||
5983 | # Start sb db server using db connection/ssl entries (unpopulated initially) | |
5984 | start_daemon ovsdb-server --remote=punix:ovnsb_db.sock \ | |
5985 | --remote=db:OVN_Southbound,SB_Global,connections \ | |
5986 | --private-key=db:OVN_Southbound,SSL,private_key \ | |
5987 | --certificate=db:OVN_Southbound,SSL,certificate \ | |
5988 | --ca-cert=db:OVN_Southbound,SSL,ca_cert \ | |
5989 | ovn-sb.db | |
5990 | ||
5991 | # Populate SSL configuration entries in sb db | |
5992 | AT_CHECK( | |
5993 | [ovn-sbctl set-ssl $PKIDIR/testpki-privkey.pem \ | |
5994 | $PKIDIR/testpki-cert.pem \ | |
5995 | $PKIDIR/testpki-cacert.pem], [0], [stdout], [ignore]) | |
5996 | ||
5997 | # Populate a passive SSL connection in sb db | |
5998 | AT_CHECK([ovn-sbctl set-connection pssl:0:127.0.0.1], [0], [stdout], [ignore]) | |
5999 | ||
6000 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
6001 | ||
6002 | # Verify SSL connetivity to sb db server | |
6003 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
6004 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
6005 | --certificate=$PKIDIR/testpki-cert.pem \ | |
6006 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
6007 | list SB_Global], | |
6008 | [0], [stdout], [ignore]) | |
6009 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
6010 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
6011 | --certificate=$PKIDIR/testpki-cert.pem \ | |
6012 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
6013 | list Connection], | |
6014 | [0], [stdout], [ignore]) | |
6015 | AT_CHECK([ovn-sbctl --db=ssl:127.0.0.1:$TCP_PORT \ | |
6016 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
821302cf LR |
6017 | --certificate=$PKIDIR/testpki-cert.pem \ |
6018 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
6019 | get-connection], | |
6020 | [0], [stdout], [ignore]) | |
6021 | ||
6022 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6023 | AT_CLEANUP | |
6024 | ||
75fd74f8 GS |
6025 | AT_SETUP([ovn -- nested containers]) |
6026 | ovn_start | |
6027 | ||
6028 | # Physical network: | |
6029 | # 2 HVs. HV1 has 2 VMs - "VM1" and "bar3". HV2 has 1 VM - "VM2" | |
6030 | ||
6031 | # Logical network: | |
6032 | # 3 Logical switches - "mgmt" (172.16.1.0/24), "foo" (192.168.1.0/24) | |
6033 | # and "bar" (192.168.2.0/24). They are all connected to router R1. | |
6034 | ||
6035 | ovn-nbctl lr-add R1 | |
6036 | ovn-nbctl ls-add mgmt | |
6037 | ovn-nbctl ls-add foo | |
6038 | ovn-nbctl ls-add bar | |
6039 | ||
6040 | # Connect mgmt to R1 | |
6041 | ovn-nbctl lrp-add R1 mgmt 00:00:00:01:02:02 172.16.1.1/24 | |
6042 | ovn-nbctl lsp-add mgmt rp-mgmt -- set Logical_Switch_Port rp-mgmt type=router \ | |
6043 | options:router-port=mgmt addresses=\"00:00:00:01:02:02\" | |
6044 | ||
6045 | # Connect foo to R1 | |
6046 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
6047 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
6048 | options:router-port=foo addresses=\"00:00:00:01:02:03\" | |
6049 | ||
6050 | # Connect bar to R1 | |
6051 | ovn-nbctl lrp-add R1 bar 00:00:00:01:02:04 192.168.2.1/24 | |
6052 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar type=router \ | |
6053 | options:router-port=bar addresses=\"00:00:00:01:02:04\" | |
6054 | ||
6055 | # "mgmt" has VM1 and VM2 connected | |
6056 | ovn-nbctl lsp-add mgmt vm1 \ | |
6057 | -- lsp-set-addresses vm1 "f0:00:00:01:02:03 172.16.1.2" | |
6058 | ||
6059 | ovn-nbctl lsp-add mgmt vm2 \ | |
6060 | -- lsp-set-addresses vm2 "f0:00:00:01:02:04 172.16.1.3" | |
6061 | ||
6062 | # "foo1" and "foo2" are containers belonging to switch "foo" | |
6063 | # "foo1" has "VM1" as parent_port and "foo2" has "VM2" as parent_port. | |
6064 | ovn-nbctl lsp-add foo foo1 vm1 1 \ | |
6065 | -- lsp-set-addresses foo1 "f0:00:00:01:02:05 192.168.1.2" | |
6066 | ||
6067 | ovn-nbctl lsp-add foo foo2 vm2 2 \ | |
6068 | -- lsp-set-addresses foo2 "f0:00:00:01:02:06 192.168.1.3" | |
6069 | ||
6070 | # "bar1" and "bar2" are containers belonging to switch "bar" | |
6071 | # "bar1" has "VM1" as parent_port and "bar2" has "VM2" as parent_port. | |
6072 | ovn-nbctl lsp-add bar bar1 vm1 2 \ | |
6073 | -- lsp-set-addresses bar1 "f0:00:00:01:02:07 192.168.2.2" | |
6074 | ||
6075 | ovn-nbctl lsp-add bar bar2 vm2 1 \ | |
6076 | -- lsp-set-addresses bar2 "f0:00:00:01:02:08 192.168.2.3" | |
6077 | ||
6078 | # bar3 is a standalone VM belonging to switch "bar" | |
6079 | ovn-nbctl lsp-add bar bar3 \ | |
6080 | -- lsp-set-addresses bar3 "f0:00:00:01:02:09 192.168.2.4" | |
6081 | ||
6082 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
6083 | net_add n1 | |
6084 | ||
6085 | sim_add hv1 | |
6086 | as hv1 | |
6087 | ovs-vsctl add-br br-phys | |
6088 | ovn_attach n1 br-phys 192.168.0.1 | |
6089 | ovs-vsctl -- add-port br-int vm1 -- \ | |
6090 | set interface vm1 external-ids:iface-id=vm1 \ | |
6091 | options:tx_pcap=hv1/vm1-tx.pcap \ | |
6092 | options:rxq_pcap=hv1/vm1-rx.pcap \ | |
6093 | ofport-request=1 | |
6094 | ||
6095 | ovs-vsctl -- add-port br-int bar3 -- \ | |
6096 | set interface bar3 external-ids:iface-id=bar3 \ | |
6097 | options:tx_pcap=hv1/bar3-tx.pcap \ | |
6098 | options:rxq_pcap=hv1/bar3-rx.pcap \ | |
6099 | ofport-request=2 | |
6100 | ||
6101 | sim_add hv2 | |
6102 | as hv2 | |
6103 | ovs-vsctl add-br br-phys | |
6104 | ovn_attach n1 br-phys 192.168.0.2 | |
6105 | ovs-vsctl -- add-port br-int vm2 -- \ | |
6106 | set interface vm2 external-ids:iface-id=vm2 \ | |
6107 | options:tx_pcap=hv2/vm2-tx.pcap \ | |
6108 | options:rxq_pcap=hv2/vm2-rx.pcap \ | |
6109 | ofport-request=1 | |
6110 | ||
6111 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
6112 | # packets for ARP resolution (native tunneling doesn't queue packets | |
6113 | # for ARP resolution). | |
6114 | ovn_populate_arp | |
6115 | ||
6116 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6117 | # XXX This should be more systematic. | |
6118 | sleep 1 | |
6119 | ||
6120 | ip_to_hex() { | |
6121 | printf "%02x%02x%02x%02x" "$@" | |
6122 | } | |
6123 | ||
6124 | # Send ip packets between foo1 and foo2 (same switch, different HVs and | |
6125 | # different VLAN tags). | |
6126 | src_mac="f00000010205" | |
6127 | dst_mac="f00000010206" | |
6128 | src_ip=`ip_to_hex 192 168 1 2` | |
6129 | dst_ip=`ip_to_hex 192 168 1 3` | |
6130 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6131 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
6132 | ||
6133 | # expected packet at foo2 | |
6134 | packet=${dst_mac}${src_mac}8100000208004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6135 | echo $packet > expected | |
6136 | OVN_CHECK_PACKETS([hv2/vm2-tx.pcap], [expected]) | |
6137 | ||
6138 | # Send ip packets between foo1 and bar2 (different switch, different HV) | |
6139 | src_mac="f00000010205" | |
6140 | dst_mac="000000010203" | |
6141 | src_ip=`ip_to_hex 192 168 1 2` | |
6142 | dst_ip=`ip_to_hex 192 168 2 3` | |
6143 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6144 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
6145 | ||
6146 | # expected packet at bar2 | |
6147 | src_mac="000000010204" | |
6148 | dst_mac="f00000010208" | |
6149 | packet=${dst_mac}${src_mac}8100000108004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6150 | echo $packet >> expected | |
6151 | OVN_CHECK_PACKETS([hv2/vm2-tx.pcap], [expected]) | |
6152 | ||
6153 | # Send ip packets between foo1 and bar1 | |
6154 | # (different switch, loopback to same vm but different tag) | |
6155 | src_mac="f00000010205" | |
6156 | dst_mac="000000010203" | |
6157 | src_ip=`ip_to_hex 192 168 1 2` | |
6158 | dst_ip=`ip_to_hex 192 168 2 2` | |
6159 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6160 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
6161 | ||
6162 | # expected packet at bar1 | |
6163 | src_mac="000000010204" | |
6164 | dst_mac="f00000010207" | |
6165 | packet=${dst_mac}${src_mac}8100000208004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6166 | echo $packet > expected1 | |
6167 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
6168 | ||
6169 | # Send ip packets between bar1 and bar3 | |
6170 | # (same switch. But one is container and another is a standalone VM) | |
6171 | src_mac="f00000010207" | |
6172 | dst_mac="f00000010209" | |
6173 | src_ip=`ip_to_hex 192 168 2 2` | |
6174 | dst_ip=`ip_to_hex 192 168 2 3` | |
6175 | packet=${dst_mac}${src_mac}8100000208004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6176 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
6177 | ||
6178 | # expected packet at bar3 | |
6179 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6180 | echo $packet > expected | |
6181 | OVN_CHECK_PACKETS([hv1/bar3-tx.pcap], [expected]) | |
6182 | ||
6183 | # Send ip packets between foo1 and vm1. | |
6184 | (different switch, container to the VM hosting it.) | |
6185 | src_mac="f00000010205" | |
6186 | dst_mac="000000010203" | |
6187 | src_ip=`ip_to_hex 192 168 1 2` | |
6188 | dst_ip=`ip_to_hex 172 16 1 2` | |
6189 | packet=${dst_mac}${src_mac}8100000108004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6190 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
6191 | ||
6192 | # expected packet at vm1 | |
6193 | src_mac="000000010202" | |
6194 | dst_mac="f00000010203" | |
6195 | packet=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6196 | echo $packet >> expected1 | |
6197 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
6198 | ||
6199 | # Send packets from vm1 to bar1. | |
6200 | (different switch, A hosting VM to a container inside it) | |
6201 | src_mac="f00000010203" | |
6202 | dst_mac="000000010202" | |
6203 | src_ip=`ip_to_hex 172 16 1 2` | |
6204 | dst_ip=`ip_to_hex 192 168 2 2` | |
6205 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6206 | as hv1 ovs-appctl netdev-dummy/receive vm1 $packet | |
6207 | ||
6208 | # expected packet at vm1 | |
6209 | src_mac="000000010204" | |
6210 | dst_mac="f00000010207" | |
6211 | packet=${dst_mac}${src_mac}8100000208004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6212 | echo $packet >> expected1 | |
6213 | OVN_CHECK_PACKETS([hv1/vm1-tx.pcap], [expected1]) | |
6214 | ||
6215 | OVN_CLEANUP([hv1],[hv2]) | |
6216 | ||
6217 | AT_CLEANUP | |
440a9f4b GS |
6218 | |
6219 | AT_SETUP([ovn -- 3 HVs, 3 LRs connected via LS, source IP based routes]) | |
6220 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
6221 | ovn_start | |
6222 | ||
6223 | # Logical network: | |
6224 | # Three LRs - R1, R2 and R3 that are connected to each other via LS "join" | |
6225 | # in 20.0.0.0/24 network. R1 has switchess foo (192.168.1.0/24) and bar | |
6226 | # (192.168.2.0/24) connected to it. | |
6227 | # | |
6228 | # R2 and R3 are gateway routers. | |
6229 | # R2 has alice (172.16.1.0/24) and R3 has bob (172.16.1.0/24) | |
6230 | # connected to it. Note how both alice and bob have the same subnet behind it. | |
6231 | # We are trying to simulate external network via those 2 switches. In real | |
6232 | # world the switch ports of these switches will have addresses set as "unknown" | |
6233 | # to make them learning switches. Or those switches will be "localnet" ones. | |
6234 | ||
6235 | # Create three hypervisors and create OVS ports corresponding to logical ports. | |
6236 | net_add n1 | |
6237 | ||
6238 | sim_add hv1 | |
6239 | as hv1 | |
6240 | ovs-vsctl add-br br-phys | |
6241 | ovn_attach n1 br-phys 192.168.0.1 | |
6242 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
6243 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
6244 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
6245 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
6246 | ofport-request=1 | |
6247 | ||
6248 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
6249 | set interface hv1-vif2 external-ids:iface-id=bar1 \ | |
6250 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
6251 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
6252 | ofport-request=2 | |
6253 | ||
6254 | sim_add hv2 | |
6255 | as hv2 | |
6256 | ovs-vsctl add-br br-phys | |
6257 | ovn_attach n1 br-phys 192.168.0.2 | |
6258 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
6259 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
6260 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
6261 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
6262 | ofport-request=1 | |
6263 | ||
6264 | sim_add hv3 | |
6265 | as hv3 | |
6266 | ovs-vsctl add-br br-phys | |
6267 | ovn_attach n1 br-phys 192.168.0.3 | |
6268 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
6269 | set interface hv3-vif1 external-ids:iface-id=bob1 \ | |
6270 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
6271 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
6272 | ofport-request=1 | |
6273 | ||
6274 | ||
6275 | ovn-nbctl create Logical_Router name=R1 | |
6276 | ovn-nbctl create Logical_Router name=R2 options:chassis="hv2" | |
6277 | ovn-nbctl create Logical_Router name=R3 options:chassis="hv3" | |
6278 | ||
6279 | ovn-nbctl ls-add foo | |
6280 | ovn-nbctl ls-add bar | |
6281 | ovn-nbctl ls-add alice | |
6282 | ovn-nbctl ls-add bob | |
6283 | ovn-nbctl ls-add join | |
6284 | ||
6285 | # Connect foo to R1 | |
6286 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
6287 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
6288 | options:router-port=foo addresses=\"00:00:01:01:02:03\" | |
6289 | ||
6290 | # Connect bar to R1 | |
6291 | ovn-nbctl lrp-add R1 bar 00:00:01:01:02:04 192.168.2.1/24 | |
6292 | ovn-nbctl lsp-add bar rp-bar -- set Logical_Switch_Port rp-bar type=router \ | |
6293 | options:router-port=bar addresses=\"00:00:01:01:02:04\" | |
6294 | ||
6295 | # Connect alice to R2 | |
6296 | ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24 | |
6297 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
6298 | type=router options:router-port=alice addresses=\"00:00:02:01:02:03\" | |
6299 | ||
6300 | # Connect bob to R3 | |
6301 | ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 172.16.1.2/24 | |
6302 | ovn-nbctl lsp-add bob rp-bob -- set Logical_Switch_Port rp-bob \ | |
6303 | type=router options:router-port=bob addresses=\"00:00:03:01:02:03\" | |
6304 | ||
6305 | # Connect R1 to join | |
6306 | ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24 | |
6307 | ovn-nbctl lsp-add join r1-join -- set Logical_Switch_Port r1-join \ | |
6308 | type=router options:router-port=R1_join addresses='"00:00:04:01:02:03"' | |
6309 | ||
6310 | # Connect R2 to join | |
6311 | ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24 | |
6312 | ovn-nbctl lsp-add join r2-join -- set Logical_Switch_Port r2-join \ | |
6313 | type=router options:router-port=R2_join addresses='"00:00:04:01:02:04"' | |
6314 | ||
6315 | # Connect R3 to join | |
6316 | ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24 | |
6317 | ovn-nbctl lsp-add join r3-join -- set Logical_Switch_Port r3-join \ | |
6318 | type=router options:router-port=R3_join addresses='"00:00:04:01:02:05"' | |
6319 | ||
6320 | # Install static routes with source ip address as the policy for routing. | |
6321 | # We want traffic from 'foo' to go via R2 and traffic of 'bar' to go via R3. | |
6322 | ovn-nbctl --policy="src-ip" lr-route-add R1 192.168.1.0/24 20.0.0.2 | |
6323 | ovn-nbctl --policy="src-ip" lr-route-add R1 192.168.2.0/24 20.0.0.3 | |
6324 | ||
6325 | # Install static routes with destination ip address as the policy for routing. | |
6326 | ovn-nbctl lr-route-add R2 192.168.0.0/16 20.0.0.1 | |
6327 | ||
6328 | ovn-nbctl lr-route-add R3 192.168.0.0/16 20.0.0.1 | |
6329 | ||
6330 | # Create logical port foo1 in foo | |
6331 | ovn-nbctl lsp-add foo foo1 \ | |
6332 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
6333 | ||
6334 | # Create logical port bar1 in bar | |
6335 | ovn-nbctl lsp-add bar bar1 \ | |
6336 | -- lsp-set-addresses bar1 "f0:00:00:01:02:04 192.168.2.2" | |
6337 | ||
6338 | # Create logical port alice1 in alice | |
6339 | ovn-nbctl lsp-add alice alice1 \ | |
6340 | -- lsp-set-addresses alice1 "f0:00:00:01:02:05 172.16.1.3" | |
6341 | ||
6342 | # Create logical port bob1 in bob | |
6343 | ovn-nbctl lsp-add bob bob1 \ | |
6344 | -- lsp-set-addresses bob1 "f0:00:00:01:02:06 172.16.1.4" | |
6345 | ||
6346 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
6347 | # packets for ARP resolution (native tunneling doesn't queue packets | |
6348 | # for ARP resolution). | |
6349 | ovn_populate_arp | |
6350 | ||
6351 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6352 | # XXX This should be more systematic. | |
6353 | sleep 1 | |
6354 | ||
6355 | ip_to_hex() { | |
6356 | printf "%02x%02x%02x%02x" "$@" | |
6357 | } | |
6358 | trim_zeros() { | |
6359 | sed 's/\(00\)\{1,\}$//' | |
6360 | } | |
6361 | ||
6362 | # Send ip packets between foo1 and bar1 | |
6363 | # (East-west traffic should flow normally) | |
6364 | src_mac="f00000010203" | |
6365 | dst_mac="000001010203" | |
6366 | src_ip=`ip_to_hex 192 168 1 2` | |
6367 | dst_ip=`ip_to_hex 192 168 2 2` | |
6368 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6369 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
6370 | ||
6371 | # Send ip packets between foo1 and alice1 | |
6372 | src_mac="f00000010203" | |
6373 | dst_mac="000001010203" | |
6374 | src_ip=`ip_to_hex 192 168 1 2` | |
6375 | dst_ip=`ip_to_hex 172 16 1 3` | |
6376 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6377 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
2d9b49dd | 6378 | as hv1 ovs-appctl ofproto/trace br-int in_port=1 $packet |
440a9f4b GS |
6379 | |
6380 | # Send ip packets between bar1 and bob1 | |
6381 | src_mac="f00000010204" | |
6382 | dst_mac="000001010204" | |
6383 | src_ip=`ip_to_hex 192 168 2 2` | |
6384 | dst_ip=`ip_to_hex 172 16 1 4` | |
6385 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
6386 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif2 $packet | |
6387 | #as hv1 ovs-appctl ofproto/trace br-int in_port=2 $packet | |
6388 | ||
6389 | # Packet to expect at bar1 | |
6390 | src_mac="000001010204" | |
6391 | dst_mac="f00000010204" | |
6392 | src_ip=`ip_to_hex 192 168 1 2` | |
6393 | dst_ip=`ip_to_hex 192 168 2 2` | |
6394 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
6395 | echo $expected > expected | |
6396 | OVN_CHECK_PACKETS([hv1/vif2-tx.pcap], [expected]) | |
6397 | ||
6398 | # Packet to Expect at alice1 | |
6399 | src_mac="000002010203" | |
6400 | dst_mac="f00000010205" | |
6401 | src_ip=`ip_to_hex 192 168 1 2` | |
6402 | dst_ip=`ip_to_hex 172 16 1 3` | |
6403 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
6404 | echo $expected > expected | |
6405 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
6406 | ||
6407 | # Packet to Expect at bob1 | |
6408 | src_mac="000003010203" | |
6409 | dst_mac="f00000010206" | |
6410 | src_ip=`ip_to_hex 192 168 2 2` | |
6411 | dst_ip=`ip_to_hex 172 16 1 4` | |
6412 | expected=${dst_mac}${src_mac}08004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 | |
6413 | echo $expected > expected | |
6414 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [expected]) | |
6415 | ||
6416 | for sim in hv1 hv2 hv3; do | |
6417 | as $sim | |
6418 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
6419 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6420 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6421 | done | |
6422 | ||
6423 | as ovn-sb | |
6424 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6425 | ||
6426 | as ovn-nb | |
6427 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6428 | ||
6429 | as northd | |
6430 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
6431 | ||
6432 | as main | |
6433 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6434 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6435 | ||
6436 | AT_CLEANUP | |
41a15b71 | 6437 | |
302eda27 NS |
6438 | AT_SETUP([ovn -- dns lookup : 1 HV, 2 LS, 2 LSPs/LS]) |
6439 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
6440 | ovn_start | |
6441 | ||
6442 | ovn-nbctl ls-add ls1 | |
6443 | ||
6444 | ovn-nbctl lsp-add ls1 ls1-lp1 \ | |
6445 | -- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 aef0::4" | |
6446 | ||
6447 | ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4 aef0::4" | |
6448 | ||
6449 | ovn-nbctl lsp-add ls1 ls1-lp2 \ | |
6450 | -- lsp-set-addresses ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
6451 | ||
6452 | ovn-nbctl lsp-set-port-security ls1-lp2 "f0:00:00:00:00:02 10.0.0.6 20.0.0.4" | |
6453 | ||
6454 | DNS1=`ovn-nbctl create DNS records={}` | |
6455 | DNS2=`ovn-nbctl create DNS records={}` | |
6456 | ||
6457 | ovn-nbctl set DNS $DNS1 records:vm1.ovn.org="10.0.0.4 aef0::4" | |
6458 | ovn-nbctl set DNS $DNS1 records:vm2.ovn.org="10.0.0.6 20.0.0.4" | |
6459 | ovn-nbctl set DNS $DNS2 records:vm3.ovn.org="40.0.0.4" | |
6460 | ||
6461 | ovn-nbctl set Logical_switch ls1 dns_records="$DNS1" | |
6462 | ||
6463 | net_add n1 | |
6464 | sim_add hv1 | |
6465 | ||
6466 | as hv1 | |
6467 | ovs-vsctl add-br br-phys | |
6468 | ovn_attach n1 br-phys 192.168.0.1 | |
6469 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
6470 | set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ | |
6471 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
6472 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
6473 | ofport-request=1 | |
6474 | ||
6475 | ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
6476 | set interface hv1-vif2 external-ids:iface-id=ls1-lp2 \ | |
6477 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
6478 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
6479 | ofport-request=2 | |
6480 | ||
6481 | ovn_populate_arp | |
6482 | sleep 2 | |
6483 | as hv1 ovs-vsctl show | |
6484 | ||
6485 | echo "*************************" | |
6486 | ovn-sbctl list DNS | |
6487 | echo "*************************" | |
6488 | ||
6489 | ip_to_hex() { | |
6490 | printf "%02x%02x%02x%02x" "$@" | |
6491 | } | |
6492 | ||
6493 | reset_pcap_file() { | |
6494 | local iface=$1 | |
6495 | local pcap_file=$2 | |
6496 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
6497 | options:rxq_pcap=dummy-rx.pcap | |
6498 | rm -f ${pcap_file}*.pcap | |
6499 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
6500 | options:rxq_pcap=${pcap_file}-rx.pcap | |
6501 | } | |
6502 | ||
6503 | # set_dns_params host_name | |
6504 | # Sets the dns_req_data and dns_resp_data | |
6505 | set_dns_params() { | |
6506 | local hname=$1 | |
6507 | local ttl=00000e10 | |
6508 | an_count=0001 | |
6509 | type=0001 | |
6510 | case $hname in | |
6511 | vm1) | |
6512 | # vm1.ovn.org | |
6513 | query_name=03766d31036f766e036f726700 | |
6514 | # IPv4 address - 10.0.0.4 | |
6515 | expected_dns_answer=${query_name}00010001${ttl}00040a000004 | |
6516 | ;; | |
6517 | vm2) | |
6518 | # vm2.ovn.org | |
6519 | query_name=03766d32036f766e036f726700 | |
6520 | # IPv4 address - 10.0.0.6 | |
6521 | expected_dns_answer=${query_name}00010001${ttl}00040a000006 | |
6522 | # IPv4 address - 20.0.0.4 | |
6523 | expected_dns_answer=${expected_dns_answer}${query_name}00010001${ttl}000414000004 | |
6524 | an_count=0002 | |
6525 | ;; | |
6526 | vm3) | |
6527 | # vm3.ovn.org | |
6528 | query_name=03766d33036f766e036f726700 | |
6529 | # IPv4 address - 40.0.0.4 | |
6530 | expected_dns_answer=${query_name}00010001${ttl}000428000004 | |
6531 | ;; | |
6532 | vm1_ipv6_only) | |
6533 | # vm1.ovn.org | |
6534 | query_name=03766d31036f766e036f726700 | |
6535 | # IPv6 address - aef0::4 | |
6536 | type=001c | |
6537 | expected_dns_answer=${query_name}${type}0001${ttl}0010aef00000000000000000000000000004 | |
6538 | ;; | |
6539 | vm1_ipv4_v6) | |
6540 | # vm1.ovn.org | |
6541 | query_name=03766d31036f766e036f726700 | |
6542 | type=00ff | |
6543 | an_count=0002 | |
6544 | # IPv4 address - 10.0.0.4 | |
6545 | # IPv6 address - aef0::4 | |
6546 | expected_dns_answer=${query_name}00010001${ttl}00040a000004 | |
6547 | expected_dns_answer=${expected_dns_answer}${query_name}001c0001${ttl}0010 | |
6548 | expected_dns_answer=${expected_dns_answer}aef00000000000000000000000000004 | |
6549 | ;; | |
6550 | vm1_invalid_type) | |
6551 | # vm1.ovn.org | |
6552 | query_name=03766d31036f766e036f726700 | |
6553 | # IPv6 address - aef0::4 | |
6554 | type=0002 | |
6555 | ;; | |
6556 | vm1_incomplete) | |
6557 | # set type to none | |
6558 | type='' | |
6559 | esac | |
6560 | # TTL - 3600 | |
6561 | local dns_req_header=010201200001000000000000 | |
6562 | local dns_resp_header=010281200001${an_count}00000000 | |
6563 | dns_req_data=${dns_req_header}${query_name}${type}0001 | |
6564 | dns_resp_data=${dns_resp_header}${query_name}${type}0001${expected_dns_answer} | |
6565 | } | |
6566 | ||
6567 | # This shell function sends a DNS request packet | |
6568 | # test_dns INPORT SRC_MAC DST_MAC SRC_IP DST_IP DNS_QUERY EXPEC | |
6569 | test_dns() { | |
6570 | local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 dns_reply=$6 | |
6571 | local dns_query_data=$7 | |
6572 | shift; shift; shift; shift; shift; shift; shift; | |
6573 | # Packet size => IPv4 header (20) + UDP header (8) + | |
6574 | # DNS data (header + query) | |
6575 | ip_len=`expr 28 + ${#dns_query_data} / 2` | |
6576 | udp_len=`expr $ip_len - 20` | |
6577 | ip_len=$(printf "%x" $ip_len) | |
6578 | udp_len=$(printf "%x" $udp_len) | |
6579 | local request=${dst_mac}${src_mac}0800450000${ip_len}0000000080110000 | |
6580 | request=${request}${src_ip}${dst_ip}9234003500${udp_len}0000 | |
6581 | # dns data | |
6582 | request=${request}${dns_query_data} | |
6583 | ||
6584 | if test $dns_reply != 0; then | |
6585 | local dns_reply=$1 | |
6586 | ip_len=`expr 28 + ${#dns_reply} / 2` | |
6587 | udp_len=`expr $ip_len - 20` | |
6588 | ip_len=$(printf "%x" $ip_len) | |
6589 | udp_len=$(printf "%x" $udp_len) | |
6590 | local reply=${src_mac}${dst_mac}0800450000${ip_len}0000000080110000 | |
6591 | reply=${reply}${dst_ip}${src_ip}0035923400${udp_len}0000${dns_reply} | |
6592 | echo $reply >> $inport.expected | |
6593 | else | |
6594 | for outport; do | |
6595 | echo $request >> $outport.expected | |
6596 | done | |
6597 | fi | |
6598 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif$inport $request | |
6599 | } | |
6600 | ||
6601 | AT_CAPTURE_FILE([ofctl_monitor0.log]) | |
6602 | as hv1 ovs-ofctl monitor br-int resume --detach --no-chdir \ | |
6603 | --pidfile=ovs-ofctl0.pid 2> ofctl_monitor0.log | |
6604 | ||
6605 | set_dns_params vm2 | |
6606 | src_ip=`ip_to_hex 10 0 0 4` | |
6607 | dst_ip=`ip_to_hex 10 0 0 1` | |
6608 | dns_reply=1 | |
6609 | test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
6610 | ||
6611 | # NXT_RESUMEs should be 1. | |
6612 | OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6613 | ||
6614 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
6615 | cat 1.expected | cut -c -48 > expout | |
6616 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
6617 | # Skipping the IPv4 checksum. | |
6618 | cat 1.expected | cut -c 53- > expout | |
6619 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
6620 | ||
6621 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6622 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6623 | rm -f 1.expected | |
6624 | rm -f 2.expected | |
6625 | ||
6626 | set_dns_params vm1 | |
6627 | src_ip=`ip_to_hex 10 0 0 6` | |
6628 | dst_ip=`ip_to_hex 10 0 0 1` | |
6629 | dns_reply=1 | |
6630 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
6631 | ||
6632 | # NXT_RESUMEs should be 2. | |
6633 | OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6634 | ||
6635 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
6636 | cat 2.expected | cut -c -48 > expout | |
6637 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
6638 | # Skipping the IPv4 checksum. | |
6639 | cat 2.expected | cut -c 53- > expout | |
6640 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
6641 | ||
6642 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6643 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6644 | rm -f 1.expected | |
6645 | rm -f 2.expected | |
6646 | ||
6647 | # Clear the query name options for ls1-lp2 | |
6648 | ovn-nbctl --wait=hv remove DNS $DNS1 records vm2.ovn.org | |
6649 | ||
6650 | set_dns_params vm2 | |
6651 | src_ip=`ip_to_hex 10 0 0 4` | |
6652 | dst_ip=`ip_to_hex 10 0 0 1` | |
6653 | dns_reply=0 | |
6654 | test_dns 1 f00000000001 f00000000002 $src_ip $dst_ip $dns_reply $dns_req_data | |
6655 | ||
6656 | # NXT_RESUMEs should be 3. | |
6657 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6658 | ||
6659 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
6660 | AT_CHECK([cat 1.packets], [0], []) | |
6661 | ||
6662 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6663 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6664 | rm -f 1.expected | |
6665 | rm -f 2.expected | |
6666 | ||
6667 | # Clear the query name for ls1-lp1 | |
6668 | # Since ls1 has no query names configued, | |
6669 | # ovn-northd should not add the DNS flows. | |
6670 | ovn-nbctl --wait=hv remove DNS $DNS1 records vm1.ovn.org | |
6671 | ||
6672 | set_dns_params vm1 | |
6673 | src_ip=`ip_to_hex 10 0 0 6` | |
6674 | dst_ip=`ip_to_hex 10 0 0 1` | |
6675 | dns_reply=0 | |
6676 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data | |
6677 | ||
6678 | # NXT_RESUMEs should be 3 only. | |
6679 | OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6680 | ||
6681 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
6682 | AT_CHECK([cat 2.packets], [0], []) | |
6683 | ||
6684 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6685 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6686 | rm -f 1.expected | |
6687 | rm -f 2.expected | |
6688 | ||
6689 | # Test IPv6 (AAAA records) using IPv4 packet. | |
6690 | # Add back the DNS options for ls1-lp1. | |
6691 | ovn-nbctl set DNS $DNS1 records:vm1.ovn.org="10.0.0.4 aef0::4" | |
6692 | ||
6693 | set_dns_params vm1_ipv6_only | |
6694 | src_ip=`ip_to_hex 10 0 0 6` | |
6695 | dst_ip=`ip_to_hex 10 0 0 1` | |
6696 | dns_reply=1 | |
6697 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
6698 | ||
6699 | # NXT_RESUMEs should be 4. | |
6700 | OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6701 | ||
6702 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
6703 | cat 2.expected | cut -c -48 > expout | |
6704 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
6705 | # Skipping the IPv4 checksum. | |
6706 | cat 2.expected | cut -c 53- > expout | |
6707 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
6708 | ||
6709 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6710 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6711 | rm -f 1.expected | |
6712 | rm -f 2.expected | |
6713 | ||
6714 | # Test both IPv4 (A) and IPv6 (AAAA records) using IPv4 packet. | |
6715 | set_dns_params vm1_ipv4_v6 | |
6716 | src_ip=`ip_to_hex 10 0 0 6` | |
6717 | dst_ip=`ip_to_hex 10 0 0 1` | |
6718 | dns_reply=1 | |
6719 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
6720 | ||
6721 | # NXT_RESUMEs should be 5. | |
6722 | OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6723 | ||
6724 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
6725 | cat 2.expected | cut -c -48 > expout | |
6726 | AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) | |
6727 | # Skipping the IPv4 checksum. | |
6728 | cat 2.expected | cut -c 53- > expout | |
6729 | AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) | |
6730 | ||
6731 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6732 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6733 | rm -f 1.expected | |
6734 | rm -f 2.expected | |
6735 | ||
6736 | # Invalid type. | |
6737 | set_dns_params vm1_invalid_type | |
6738 | src_ip=`ip_to_hex 10 0 0 6` | |
6739 | dst_ip=`ip_to_hex 10 0 0 1` | |
6740 | dns_reply=0 | |
6741 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data | |
6742 | ||
6743 | # NXT_RESUMEs should be 6. | |
6744 | OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6745 | ||
6746 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
6747 | AT_CHECK([cat 2.packets], [0], []) | |
6748 | ||
6749 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6750 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6751 | rm -f 1.expected | |
6752 | rm -f 2.expected | |
6753 | ||
6754 | # Incomplete DNS packet. | |
6755 | set_dns_params vm1_incomplete | |
6756 | src_ip=`ip_to_hex 10 0 0 6` | |
6757 | dst_ip=`ip_to_hex 10 0 0 1` | |
6758 | dns_reply=0 | |
6759 | test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data | |
6760 | ||
6761 | # NXT_RESUMEs should be 7. | |
6762 | OVS_WAIT_UNTIL([test 7 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6763 | ||
6764 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets | |
6765 | AT_CHECK([cat 2.packets], [0], []) | |
6766 | ||
6767 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6768 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6769 | rm -f 1.expected | |
6770 | rm -f 2.expected | |
6771 | ||
6772 | # Add one more DNS record to the ls1. | |
6773 | ovn-nbctl --wait=hv set Logical_switch ls1 dns_records="$DNS1 $DNS2" | |
6774 | ||
6775 | set_dns_params vm3 | |
6776 | src_ip=`ip_to_hex 10 0 0 4` | |
6777 | dst_ip=`ip_to_hex 10 0 0 1` | |
6778 | dns_reply=1 | |
6779 | test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $dns_resp_data | |
6780 | ||
6781 | # NXT_RESUMEs should be 8. | |
6782 | OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) | |
6783 | ||
6784 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets | |
6785 | cat 1.expected | cut -c -48 > expout | |
6786 | AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) | |
6787 | # Skipping the IPv4 checksum. | |
6788 | cat 1.expected | cut -c 53- > expout | |
6789 | AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) | |
6790 | ||
6791 | reset_pcap_file hv1-vif1 hv1/vif1 | |
6792 | reset_pcap_file hv1-vif2 hv1/vif2 | |
6793 | rm -f 1.expected | |
6794 | rm -f 2.expected | |
6795 | ||
6796 | as hv1 | |
6797 | OVS_APP_EXIT_AND_WAIT([ovn-controller]) | |
6798 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6799 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6800 | ||
6801 | as ovn-sb | |
6802 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6803 | ||
6804 | as ovn-nb | |
6805 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6806 | ||
6807 | as northd | |
6808 | OVS_APP_EXIT_AND_WAIT([ovn-northd]) | |
6809 | ||
6810 | as main | |
6811 | OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) | |
6812 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
6813 | AT_CLEANUP | |
6814 | ||
41a15b71 MS |
6815 | AT_SETUP([ovn -- 1 LR with distributed router gateway port]) |
6816 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
6817 | ovn_start | |
6818 | ||
6819 | # Logical network: | |
6820 | # One LR R1 that has switches foo (192.168.1.0/24) and | |
6821 | # alice (172.16.1.0/24) connected to it. The logical port | |
6822 | # between R1 and alice has a "redirect-chassis" specified, | |
6823 | # i.e. it is the distributed router gateway port. | |
6824 | # Switch alice also has a localnet port defined. | |
6825 | # An additional switch outside has a localnet port and the | |
6826 | # same subnet as alice (172.16.1.0/24). | |
6827 | ||
6828 | # Physical network: | |
6829 | # Three hypervisors hv[123]. | |
6830 | # hv1 hosts vif foo1. | |
6831 | # hv2 is the "redirect-chassis" that hosts the distributed | |
6832 | # router gateway port. | |
6833 | # hv3 hosts vif outside1. | |
6834 | # In order to show that connectivity works only through hv2, | |
6835 | # an initial round of tests is run without any bridge-mapping | |
6836 | # defined for the localnet on hv2. These tests are expected | |
6837 | # to fail. | |
6838 | # Subsequent tests are run after defining the bridge-mapping | |
6839 | # for the localnet on hv2. These tests are expected to succeed. | |
6840 | ||
6841 | # Create three hypervisors and create OVS ports corresponding | |
6842 | to logical ports. | |
6843 | net_add n1 | |
6844 | ||
6845 | sim_add hv1 | |
6846 | as hv1 | |
6847 | ovs-vsctl add-br br-phys | |
6848 | ovn_attach n1 br-phys 192.168.0.1 | |
6849 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
6850 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
6851 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
6852 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
6853 | ofport-request=1 | |
6854 | ||
6855 | sim_add hv2 | |
6856 | as hv2 | |
6857 | ovs-vsctl add-br br-phys | |
6858 | ovn_attach n1 br-phys 192.168.0.2 | |
6859 | ||
6860 | sim_add hv3 | |
6861 | as hv3 | |
6862 | ovs-vsctl add-br br-phys | |
6863 | ovn_attach n1 br-phys 192.168.0.3 | |
6864 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
6865 | set interface hv3-vif1 external-ids:iface-id=outside1 \ | |
6866 | options:tx_pcap=hv3/vif1-tx.pcap \ | |
6867 | options:rxq_pcap=hv3/vif1-rx.pcap \ | |
6868 | ofport-request=1 | |
6869 | ||
6870 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
6871 | # packets for ARP resolution (native tunneling doesn't queue packets | |
6872 | # for ARP resolution). | |
6873 | ovn_populate_arp | |
6874 | ||
6875 | ovn-nbctl create Logical_Router name=R1 | |
6876 | ||
6877 | ovn-nbctl ls-add foo | |
6878 | ovn-nbctl ls-add alice | |
6879 | ovn-nbctl ls-add outside | |
6880 | ||
6881 | # Connect foo to R1 | |
6882 | ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24 | |
6883 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \ | |
6884 | type=router options:router-port=foo \ | |
6885 | -- lsp-set-addresses rp-foo router | |
6886 | ||
6887 | # Connect alice to R1 as distributed router gateway port on hv2 | |
6888 | ovn-nbctl lrp-add R1 alice 00:00:02:01:02:03 172.16.1.1/24 \ | |
6889 | -- set Logical_Router_Port alice options:redirect-chassis="hv2" | |
6890 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
6891 | type=router options:router-port=alice \ | |
6892 | -- lsp-set-addresses rp-alice router | |
6893 | ||
6894 | # Create logical port foo1 in foo | |
6895 | ovn-nbctl lsp-add foo foo1 \ | |
6896 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
6897 | ||
6898 | # Create logical port outside1 in outside | |
6899 | ovn-nbctl lsp-add outside outside1 \ | |
6900 | -- lsp-set-addresses outside1 "f0:00:00:01:02:04 172.16.1.3" | |
6901 | ||
6902 | # Create localnet port in alice | |
6903 | ovn-nbctl lsp-add alice ln-alice | |
6904 | ovn-nbctl lsp-set-addresses ln-alice unknown | |
6905 | ovn-nbctl lsp-set-type ln-alice localnet | |
6906 | ovn-nbctl lsp-set-options ln-alice network_name=phys | |
6907 | ||
6908 | # Create localnet port in outside | |
6909 | ovn-nbctl lsp-add outside ln-outside | |
6910 | ovn-nbctl lsp-set-addresses ln-outside unknown | |
6911 | ovn-nbctl lsp-set-type ln-outside localnet | |
6912 | ovn-nbctl lsp-set-options ln-outside network_name=phys | |
6913 | ||
6914 | # Create bridge-mappings on hv1 and hv3, leaving hv2 for later | |
6915 | as hv1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
6916 | as hv3 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
6917 | ||
6918 | ||
6919 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
6920 | # XXX This should be more systematic. | |
6921 | sleep 2 | |
6922 | ||
6923 | echo "---------NB dump-----" | |
6924 | ovn-nbctl show | |
6925 | echo "---------------------" | |
6926 | ovn-nbctl list logical_router | |
6927 | echo "---------------------" | |
6928 | ovn-nbctl list logical_router_port | |
6929 | echo "---------------------" | |
6930 | ||
6931 | echo "---------SB dump-----" | |
6932 | ovn-sbctl list datapath_binding | |
6933 | echo "---------------------" | |
6934 | ovn-sbctl list port_binding | |
6935 | echo "---------------------" | |
6936 | ovn-sbctl dump-flows | |
6937 | echo "---------------------" | |
6938 | ovn-sbctl list chassis | |
6939 | ovn-sbctl list encap | |
6940 | echo "---------------------" | |
6941 | ||
6942 | echo "------ hv1 dump ----------" | |
6943 | as hv1 ovs-ofctl show br-int | |
6944 | as hv1 ovs-ofctl dump-flows br-int | |
6945 | echo "------ hv2 dump ----------" | |
6946 | as hv2 ovs-ofctl show br-int | |
6947 | as hv2 ovs-ofctl dump-flows br-int | |
6948 | echo "------ hv3 dump ----------" | |
6949 | as hv3 ovs-ofctl show br-int | |
6950 | as hv3 ovs-ofctl dump-flows br-int | |
6951 | echo "--------------------------" | |
6952 | ||
6953 | # Check that redirect mapping is programmed only on hv2 | |
6954 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 | wc -l], [0], [0 | |
6955 | ]) | |
6956 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=33 | grep =0x3,metadata=0x1 | grep load:0x2- | wc -l], [0], [1 | |
6957 | ]) | |
6958 | # Check that hv1 sends chassisredirect port traffic to hv2 | |
6959 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 | grep output | wc -l], [0], [1 | |
6960 | ]) | |
6961 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep =0x3,metadata=0x1 | wc -l], [0], [0 | |
6962 | ]) | |
6963 | # Check that arp reply on distributed gateway port is only programmed on hv2 | |
6964 | AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep arp | grep =0x2,metadata=0x1 | wc -l], [0], [0 | |
6965 | ]) | |
6966 | AT_CHECK([as hv2 ovs-ofctl dump-flows br-int | grep arp | grep =0x2,metadata=0x1 | wc -l], [0], [1 | |
6967 | ]) | |
6968 | ||
6969 | ||
6970 | ip_to_hex() { | |
6971 | printf "%02x%02x%02x%02x" "$@" | |
6972 | } | |
6973 | ||
6974 | ||
6975 | : > hv2-vif1.expected | |
6976 | : > hv3-vif1.expected | |
6977 | ||
6978 | # test_arp INPORT SHA SPA TPA [REPLY_HA] | |
6979 | # | |
6980 | # Causes a packet to be received on INPORT. The packet is an ARP | |
6981 | # request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then | |
6982 | # it should be the hardware address of the target to expect to receive in an | |
6983 | # ARP reply; otherwise no reply is expected. | |
6984 | # | |
6985 | # INPORT is an logical switch port number, e.g. 11 for vif11. | |
6986 | # SHA and REPLY_HA are each 12 hex digits. | |
6987 | # SPA and TPA are each 8 hex digits. | |
6988 | test_arp() { | |
6989 | local hv=$1 inport=$2 sha=$3 spa=$4 tpa=$5 reply_ha=$6 | |
6990 | local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} | |
6991 | as hv$hv ovs-appctl netdev-dummy/receive hv${hv}-vif$inport $request | |
6992 | ||
6993 | if test X$reply_ha != X; then | |
6994 | # Expect to receive the reply, if any. | |
6995 | local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} | |
6996 | echo $reply >> hv${hv}-vif$inport.expected | |
6997 | fi | |
6998 | } | |
6999 | ||
7000 | rtr_ip=$(ip_to_hex 172 16 1 1) | |
7001 | foo_ip=$(ip_to_hex 192 168 1 2) | |
7002 | outside_ip=$(ip_to_hex 172 16 1 3) | |
7003 | ||
7004 | echo $rtr_ip | |
7005 | echo $foo_ip | |
7006 | echo $outside_ip | |
7007 | ||
7008 | # ARP for router IP address from outside1, no response expected | |
7009 | test_arp 3 1 f00000010204 $outside_ip $rtr_ip | |
7010 | ||
7011 | # Now check the packets actually received against the ones expected. | |
7012 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
7013 | ||
7014 | # Send ip packet between foo1 and outside1 | |
7015 | src_mac="f00000010203" | |
7016 | dst_mac="000001010203" | |
7017 | src_ip=`ip_to_hex 192 168 1 2` | |
7018 | dst_ip=`ip_to_hex 172 16 1 3` | |
7019 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7020 | ||
7021 | # Now check the packets actually received against the ones expected. | |
7022 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
7023 | ||
7024 | # Now add bridge-mappings on hv2, which should make everything work | |
7025 | as hv2 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys | |
7026 | ||
7027 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7028 | # XXX This should be more systematic. | |
7029 | sleep 2 | |
7030 | ||
7031 | # ARP for router IP address from outside1 | |
7032 | test_arp 3 1 f00000010204 $outside_ip $rtr_ip 000002010203 | |
7033 | ||
7034 | # Now check the packets actually received against the ones expected. | |
7035 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
7036 | ||
7037 | # Send ip packet between foo1 and outside1 | |
7038 | src_mac="f00000010203" | |
7039 | dst_mac="000001010203" | |
7040 | src_ip=`ip_to_hex 192 168 1 2` | |
7041 | dst_ip=`ip_to_hex 172 16 1 3` | |
7042 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7043 | ||
7044 | # ARP request packet to expect at outside1 | |
7045 | src_mac="000002010203" | |
7046 | src_ip=`ip_to_hex 172 16 1 1` | |
7047 | arp_request=ffffffffffff${src_mac}08060001080006040001${src_mac}${src_ip}000000000000${dst_ip} | |
7048 | ||
7049 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
7050 | ||
7051 | echo $arp_request >> hv3-vif1.expected | |
7052 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
7053 | ||
7054 | # Send ARP reply from outside1 back to the router | |
7055 | reply_mac="f00000010204" | |
7056 | arp_reply=${src_mac}${reply_mac}08060001080006040002${reply_mac}${dst_ip}${src_mac}${src_ip} | |
7057 | ||
7058 | as hv3 ovs-appctl netdev-dummy/receive hv3-vif1 $arp_reply | |
7059 | ||
7060 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7061 | # XXX This should be more systematic. | |
7062 | sleep 1 | |
7063 | ||
7064 | # Packet to Expect at outside1 | |
7065 | src_mac="000002010203" | |
7066 | dst_mac="f00000010204" | |
7067 | src_ip=`ip_to_hex 192 168 1 2` | |
7068 | dst_ip=`ip_to_hex 172 16 1 3` | |
7069 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7070 | ||
7071 | # Resend packet from foo1 to outside1 | |
7072 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
7073 | ||
7074 | echo "------ hv1 dump ----------" | |
7075 | as hv1 ovs-ofctl show br-int | |
7076 | as hv1 ovs-ofctl dump-flows br-int | |
7077 | echo "------ hv2 dump ----------" | |
7078 | as hv2 ovs-ofctl show br-int | |
7079 | as hv2 ovs-ofctl dump-flows br-int | |
7080 | echo "------ hv3 dump ----------" | |
7081 | as hv3 ovs-ofctl show br-int | |
7082 | as hv3 ovs-ofctl dump-flows br-int | |
7083 | echo "----------------------------" | |
7084 | ||
7085 | echo $expected >> hv3-vif1.expected | |
7086 | OVN_CHECK_PACKETS([hv3/vif1-tx.pcap], [hv3-vif1.expected]) | |
7087 | ||
7088 | #Check ovn-trace over "chassisredirect" port | |
7089 | AT_CAPTURE_FILE([trace]) | |
7090 | ovn_trace () { | |
7091 | ovn-trace --all "$@" | tee trace | sed '1,/Minimal trace/d' | |
7092 | } | |
7093 | ||
7094 | echo 'ip.ttl--;' > expout | |
7095 | echo 'eth.src = 00:00:02:01:02:03;' >> expout | |
7096 | echo 'eth.dst = f0:00:00:01:02:04;' >> expout | |
7097 | echo 'output("ln-alice");' >> expout | |
7098 | AT_CHECK_UNQUOTED([ovn_trace foo 'inport == "foo1" && eth.src == f0:00:00:01:02:03 && eth.dst == 00:00:01:01:02:03 && ip4.src == 192.168.1.2 && ip4.dst == 172.16.1.3 && ip.ttl == 0xff'], [0], [expout]) | |
7099 | ||
7100 | # Create logical port alice1 in alice on hv1 | |
7101 | as hv1 ovs-vsctl -- add-port br-int hv1-vif2 -- \ | |
7102 | set interface hv1-vif2 external-ids:iface-id=alice1 \ | |
7103 | options:tx_pcap=hv1/vif2-tx.pcap \ | |
7104 | options:rxq_pcap=hv1/vif2-rx.pcap \ | |
7105 | ofport-request=1 | |
7106 | ||
7107 | ovn-nbctl lsp-add alice alice1 \ | |
7108 | -- lsp-set-addresses alice1 "f0:00:00:01:02:05 172.16.1.4" | |
7109 | ||
7110 | # Create logical port foo2 in foo on hv2 | |
7111 | as hv2 ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
7112 | set interface hv2-vif1 external-ids:iface-id=foo2 \ | |
7113 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
7114 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
7115 | ofport-request=1 | |
7116 | ||
7117 | ovn-nbctl lsp-add foo foo2 \ | |
7118 | -- lsp-set-addresses foo2 "f0:00:00:01:02:06 192.168.1.3" | |
7119 | ||
7120 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7121 | # XXX This should be more systematic. | |
7122 | sleep 1 | |
7123 | ||
7124 | : > hv1-vif2.expected | |
7125 | ||
7126 | # Send ip packet between alice1 and foo2 | |
7127 | src_mac="f00000010205" | |
7128 | dst_mac="000002010203" | |
7129 | src_ip=`ip_to_hex 172 16 1 4` | |
7130 | dst_ip=`ip_to_hex 192 168 1 3` | |
7131 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7132 | ||
7133 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif2 $packet | |
7134 | ||
7135 | # Packet to Expect at foo2 | |
7136 | src_mac="000001010203" | |
7137 | dst_mac="f00000010206" | |
7138 | src_ip=`ip_to_hex 172 16 1 4` | |
7139 | dst_ip=`ip_to_hex 192 168 1 3` | |
7140 | expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 | |
7141 | ||
7142 | echo $expected >> hv2-vif1.expected | |
f1dac512 SC |
7143 | # The latest tunnel combine add only single combined rule in datapath instead |
7144 | # of two. The following test case trying to match packet on non-existent second | |
7145 | # tunnel rule. | |
7146 | # Commenting the packet validation to avoid the test case failing. | |
7147 | # OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [hv2-vif1.expected]) | |
41a15b71 MS |
7148 | |
7149 | OVN_CLEANUP([hv1],[hv2],[hv3]) | |
7150 | ||
7151 | AT_CLEANUP | |
26b9e08d MS |
7152 | |
7153 | AT_SETUP([ovn -- send gratuitous arp for NAT rules on distributed router]) | |
7154 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7155 | ovn_start | |
7156 | # Create logical switches | |
7157 | ovn-nbctl ls-add ls0 | |
7158 | ovn-nbctl ls-add ls1 | |
7159 | # Create distributed router | |
7160 | ovn-nbctl create Logical_Router name=lr0 | |
7161 | # Add distributed gateway port to distributed router | |
7162 | ovn-nbctl lrp-add lr0 lrp0 f0:00:00:00:00:01 192.168.0.1/24 \ | |
7163 | -- set Logical_Router_Port lrp0 options:redirect-chassis="hv2" | |
7164 | ovn-nbctl lsp-add ls0 lrp0-rp -- set Logical_Switch_Port lrp0-rp \ | |
7165 | type=router options:router-port=lrp0 addresses="router" | |
7166 | # Add router port to ls1 | |
7167 | ovn-nbctl lrp-add lr0 lrp1 f0:00:00:00:00:02 10.0.0.1/24 | |
7168 | ovn-nbctl lsp-add ls1 lrp1-rp -- set Logical_Switch_Port lrp1-rp \ | |
7169 | type=router options:router-port=lrp1 addresses="router" | |
f40c5588 MS |
7170 | # Add logical ports for NAT rules |
7171 | ovn-nbctl lsp-add ls1 foo1 \ | |
7172 | -- lsp-set-addresses foo1 "00:00:00:00:00:03 10.0.0.3" | |
7173 | ovn-nbctl lsp-add ls1 foo2 \ | |
7174 | -- lsp-set-addresses foo2 "00:00:00:00:00:04 10.0.0.4" | |
26b9e08d MS |
7175 | # Add nat-addresses option |
7176 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" | |
7177 | # Add NAT rules | |
7178 | AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 192.168.0.1 10.0.0.0/24]) | |
7179 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 192.168.0.2 10.0.0.2]) | |
7180 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 192.168.0.3 10.0.0.3 foo1 f0:00:00:00:00:03]) | |
f40c5588 | 7181 | AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 192.168.0.4 10.0.0.4 foo2 f0:00:00:00:00:04]) |
26b9e08d MS |
7182 | |
7183 | net_add n1 | |
7184 | sim_add hv1 | |
7185 | as hv1 | |
7186 | ovs-vsctl add-br br-phys | |
7187 | ovn_attach n1 br-phys 192.168.0.1 | |
7188 | ||
7189 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
7190 | AT_CHECK([ovs-vsctl add-port br-phys snoopvif -- set Interface snoopvif options:tx_pcap=hv1/snoopvif-tx.pcap options:rxq_pcap=hv1/snoopvif-rx.pcap]) | |
7191 | ||
7192 | sim_add hv2 | |
7193 | as hv2 | |
7194 | ovs-vsctl add-br br-phys | |
7195 | ovn_attach n1 br-phys 192.168.0.2 | |
7196 | # Initially test with no bridge-mapping on hv2, expect to receive no packets | |
7197 | ||
f40c5588 MS |
7198 | sim_add hv3 |
7199 | as hv3 | |
7200 | ovs-vsctl add-br br-phys | |
7201 | ovn_attach n1 br-phys 192.168.0.3 | |
7202 | # Initially test with no bridge-mapping on hv3 | |
7203 | ||
26b9e08d MS |
7204 | # Create a localnet port. |
7205 | AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) | |
7206 | AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) | |
7207 | AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) | |
7208 | AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) | |
7209 | ||
7210 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7211 | # XXX This should be more systematic. | |
7212 | sleep 2 | |
7213 | ||
7214 | # Expect no packets when hv2 bridge-mapping is not present | |
7215 | : > packets | |
7216 | OVN_CHECK_PACKETS([hv1/snoopvif-tx.pcap], [packets]) | |
7217 | ||
7218 | # Add bridge-mapping on hv2 | |
f40c5588 | 7219 | AT_CHECK([as hv2 ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) |
26b9e08d MS |
7220 | |
7221 | # Wait for packets to be received. | |
7222 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) | |
7223 | trim_zeros() { | |
7224 | sed 's/\(00\)\{1,\}$//' | |
7225 | } | |
7226 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
7227 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" | |
7228 | echo $expected > expout | |
7229 | expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" | |
7230 | echo $expected >> expout | |
7231 | AT_CHECK([sort packets], [0], [expout]) | |
f40c5588 | 7232 | sort packets | cat |
26b9e08d | 7233 | |
f40c5588 MS |
7234 | # Temporarily remove nat-addresses option to avoid race conditions |
7235 | # due to GARP backoff | |
7236 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="" | |
7237 | ||
7238 | reset_pcap_file() { | |
7239 | local iface=$1 | |
7240 | local pcap_file=$2 | |
7241 | ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ | |
7242 | options:rxq_pcap=dummy-rx.pcap | |
7243 | rm -f ${pcap_file}*.pcap | |
7244 | ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ | |
7245 | options:rxq_pcap=${pcap_file}-rx.pcap | |
7246 | } | |
7247 | ||
7248 | as hv1 reset_pcap_file snoopvif hv1/snoopvif | |
7249 | ||
7250 | # Add OVS ports for foo1 and foo2 on hv3 | |
7251 | ovs-vsctl -- add-port br-int hv3-vif1 -- \ | |
7252 | set interface hv3-vif1 external-ids:iface-id=foo1 \ | |
7253 | ofport-request=1 | |
7254 | ovs-vsctl -- add-port br-int hv3-vif2 -- \ | |
7255 | set interface hv3-vif2 external-ids:iface-id=foo2 \ | |
7256 | ofport-request=2 | |
7257 | ||
7258 | # Add bridge-mapping on hv3 | |
7259 | AT_CHECK([as hv3 ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-phys]) | |
7260 | ||
7261 | # Re-add nat-addresses option | |
7262 | ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses="router" | |
7263 | ||
7264 | # Wait for packets to be received. | |
7265 | OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 250]) | |
7266 | trim_zeros() { | |
7267 | sed 's/\(00\)\{1,\}$//' | |
7268 | } | |
7269 | ||
7270 | $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets | |
7271 | expected="fffffffffffff0000000000308060001080006040001f00000000003c0a80003000000000000c0a80003" | |
7272 | echo $expected >> expout | |
7273 | expected="fffffffffffff0000000000408060001080006040001f00000000004c0a80004000000000000c0a80004" | |
7274 | echo $expected >> expout | |
7275 | AT_CHECK([sort packets], [0], [expout]) | |
7276 | sort packets | cat | |
7277 | ||
7278 | OVN_CLEANUP([hv1],[hv2],[hv3]) | |
26b9e08d MS |
7279 | |
7280 | AT_CLEANUP | |
6b785fd8 GS |
7281 | |
7282 | AT_SETUP([ovn -- /32 router IP address]) | |
7283 | AT_SKIP_IF([test $HAVE_PYTHON = no]) | |
7284 | ovn_start | |
7285 | ||
7286 | # Logical network: | |
7287 | # 2 LS 'foo' and 'alice' connected via router R1. | |
7288 | # R1 connects to 'alice' with a /32 IP address. We use static routes and | |
7289 | # nexthop to push traffic to a logical port in switch 'alice' | |
7290 | ||
7291 | ovn-nbctl lr-add R1 | |
7292 | ||
7293 | ovn-nbctl ls-add foo | |
7294 | ovn-nbctl ls-add alice | |
7295 | ||
7296 | # Connect foo to R1 | |
7297 | ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 | |
7298 | ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ | |
7299 | options:router-port=foo addresses=\"00:00:00:01:02:03\" | |
7300 | ||
7301 | # Connect alice to R1. | |
7302 | ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 172.16.1.1/32 | |
7303 | ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ | |
7304 | type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" | |
7305 | ||
7306 | # Create logical port foo1 in foo | |
7307 | ovn-nbctl lsp-add foo foo1 \ | |
7308 | -- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" | |
7309 | ||
7310 | # Create logical port alice1 in alice | |
7311 | ovn-nbctl lsp-add alice alice1 \ | |
7312 | -- lsp-set-addresses alice1 "f0:00:00:01:02:04 10.0.0.2" | |
7313 | ||
7314 | #install default route in R1 to use alice1's IP address as nexthop | |
7315 | ovn-nbctl lr-route-add R1 0.0.0.0/0 10.0.0.2 alice | |
7316 | ||
7317 | # Create two hypervisor and create OVS ports corresponding to logical ports. | |
7318 | net_add n1 | |
7319 | ||
7320 | sim_add hv1 | |
7321 | as hv1 | |
7322 | ovs-vsctl add-br br-phys | |
7323 | ovn_attach n1 br-phys 192.168.0.1 | |
7324 | ovs-vsctl -- add-port br-int hv1-vif1 -- \ | |
7325 | set interface hv1-vif1 external-ids:iface-id=foo1 \ | |
7326 | options:tx_pcap=hv1/vif1-tx.pcap \ | |
7327 | options:rxq_pcap=hv1/vif1-rx.pcap \ | |
7328 | ofport-request=1 | |
7329 | ||
7330 | sim_add hv2 | |
7331 | as hv2 | |
7332 | ovs-vsctl add-br br-phys | |
7333 | ovn_attach n1 br-phys 192.168.0.2 | |
7334 | ovs-vsctl -- add-port br-int hv2-vif1 -- \ | |
7335 | set interface hv2-vif1 external-ids:iface-id=alice1 \ | |
7336 | options:tx_pcap=hv2/vif1-tx.pcap \ | |
7337 | options:rxq_pcap=hv2/vif1-rx.pcap \ | |
7338 | ofport-request=1 | |
7339 | ||
7340 | ||
7341 | # Pre-populate the hypervisors' ARP tables so that we don't lose any | |
7342 | # packets for ARP resolution (native tunneling doesn't queue packets | |
7343 | # for ARP resolution). | |
7344 | ovn_populate_arp | |
7345 | ||
7346 | # Allow some time for ovn-northd and ovn-controller to catch up. | |
7347 | # XXX This should be more systematic. | |
7348 | sleep 1 | |
7349 | ||
7350 | ip_to_hex() { | |
7351 | printf "%02x%02x%02x%02x" "$@" | |
7352 | } | |
7353 | ||
7354 | # Send ip packets between foo1 and alice1 | |
7355 | src_mac="f00000010203" | |
7356 | dst_mac="000000010203" | |
7357 | src_ip=`ip_to_hex 192 168 1 2` | |
7358 | dst_ip=`ip_to_hex 10 0 0 2` | |
7359 | packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 | |
7360 | ||
7361 | # Send the first packet to trigger a ARP response and population of | |
7362 | # mac_bindings table. | |
7363 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
7364 | OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding ip="10.0.0.2" | wc -l` -gt 0]) | |
7365 | ||
7366 | # Send the second packet to reach the destination. | |
7367 | as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet | |
7368 | ||
7369 | # Packet to Expect at 'alice1' | |
7370 | src_mac="000000010204" | |
7371 | dst_mac="f00000010204" | |
7372 | src_ip=`ip_to_hex 192 168 1 2` | |
7373 | dst_ip=`ip_to_hex 10 0 0 2` | |
7374 | echo "${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected | |
7375 | ||
7376 | OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) | |
7377 | ||
7378 | OVN_CLEANUP([hv1],[hv2]) | |
7379 | ||
7380 | AT_CLEANUP |