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