2 run vppbuild stty -echo
3 run vppbuild sudo -u ubuntu -i bash -c "(cd vpp && make plugins && echo ALLGOOD)"
4 expect vppbuild ALLGOOD
24 function session_get_bash_pid(s)
25 if not has_session(s) then
28 local fname = "/tmp/lute-"..s.."-pid.txt"
30 session_exec(s, "echo $$ >" .. fname)
31 -- it's a dirty hack but it's quick
33 local pid = io.lines(fname)()
34 print("Got pid for " .. s .. " : " .. tostring(pid))
38 function session_connect_with(s0, s1)
39 -- local pid0 = tostring(session_get_bash_pid(s0))
40 local pid1 = tostring(session_get_bash_pid(s1))
41 local eth_options = { "rx", "tx", "sg", "tso", "ufo", "gso", "gro", "lro", "rxvlan", "txvlan", "rxhash" }
42 local this_end = s0 .. "_" .. s1
43 local other_end = s1 .. "_" .. s0
44 session_exec(s0, "ip link add name " .. this_end .. " type veth peer name " .. other_end)
45 session_exec(s0, "ip link set dev " .. this_end .. " up promisc on")
46 for i, option in ipairs(eth_options) do
47 session_exec(s0, "/sbin/ethtool --offload " .. this_end .. " " .. option .. " off")
48 session_exec(s0, "/sbin/ethtool --offload " .. other_end .. " " .. option .. " off")
50 session_exec(s0, "ip link set dev " .. other_end .. " up promisc on netns /proc/" .. pid1 .. "/ns/net")
55 run lua session_connect_with("s0", "s1")
56 run lua session_connect_with("s0", "s2")
59 ip -6 addr add dev s1_s0 2001:db8:1::1/64
60 ip -4 addr add dev s1_s0 192.0.2.1/24
61 ip link set dev s1_s0 up promisc on
65 ip -6 addr add dev s2_s0 2001:db8:1::2/64
66 ip -6 addr add dev s2_s0 2001:db8:1::3/64
67 ip -6 addr add dev s2_s0 2001:db8:1::4/64
68 ip -4 addr add dev s2_s0 192.0.2.2/24
69 ip -4 addr add dev s2_s0:1 192.0.2.3/24
70 ip -4 addr add dev s2_s0:2 192.0.2.4/24
71 ip link set dev s2_s0 up promisc on
85 -- Initialization of the Lua environment for talking to VPP
86 vpp = require("vpp-lapi")
87 root_dir = "/home/ubuntu/vpp"
88 pneum_path = root_dir .. "/build-root/install-vpp_debug-native/vpp-api/lib64/libpneum.so"
89 vpp:init({ pneum_path = pneum_path })
90 vpp:consume_api(root_dir .. "/build-root/install-vpp_debug-native/vlib-api/vlibmemory/memclnt.api")
91 vpp:consume_api(root_dir .. "/build-root/install-vpp_debug-native/vpp/vpp-api/vpe.api")
93 vpp:consume_api(root_dir .. "/plugins/acl-plugin/acl/acl.api", "acl")
99 reply = vpp:api_call("af_packet_create", { host_if_name = "s0_s1", hw_addr = "AAAAAA" })
100 vpp_if_to_s1 = reply[1].sw_if_index
102 reply = vpp:api_call("af_packet_create", { host_if_name = "s0_s2", hw_addr = "AAAAAA" })
103 vpp_if_to_s2 = reply[1].sw_if_index
105 ifaces = { vpp_if_to_s1, vpp_if_to_s2 }
107 reply = vpp:api_call("sw_interface_set_flags", { sw_if_index = vpp_if_to_s1, admin_up_down = 1, link_up_down = 1 })
108 print(vpp.dump(reply))
109 reply = vpp:api_call("sw_interface_set_flags", { sw_if_index = vpp_if_to_s2, admin_up_down = 1, link_up_down = 1 })
110 print(vpp.dump(reply))
114 reply = vpp:api_call("bridge_domain_add_del", { bd_id = bd_id, flood = 1, uu_flood = 1, forward = 1, learn = 1, arp_term = 0, is_add = 1 })
115 print(vpp.dump(reply))
117 for i, v in ipairs(ifaces) do
118 reply = vpp:api_call("sw_interface_set_l2_bridge", { rx_sw_if_index = v, bd_id = bd_id, shg = 0, bvi = 0, enable = 1 } )
119 print(vpp.dump(reply))
124 run s1 ping -c 3 192.0.2.2
125 expect s1 packet loss
126 run s1 ping -c 3 192.0.2.3
127 expect s1 packet loss
128 run s1 ping -c 3 192.0.2.4
129 expect s1 packet loss
130 run s1 ping6 -c 3 2001:db8:1::2
131 expect s1 packet loss
132 run s1 ping6 -c 3 2001:db8:1::3
133 expect s1 packet loss
134 run s1 ping6 -c 3 2001:db8:1::4
135 expect s1 packet loss
141 --[[ temporary comment out
143 reply = vpp:api_call("acl_del", { context = 42, acl_index = 230 })
144 print(vpp.dump(reply))
147 reply = vpp:api_call("acl_del", { context = 42, acl_index = 8 })
148 print(vpp.dump(reply))
151 reply = vpp:api_call("acl_del", { context = 42, acl_index = 15 })
152 print(vpp.dump(reply))
155 reply = vpp:api_call("acl_add_replace", { context = 42, acl_index = -1, count = 2, r = { { is_permit = 1, is_ipv6 = 1 }, { is_permit = 0, is_ipv6 = 1 } } })
156 print(vpp.dump(reply))
158 interface_acl_in = reply[1].acl_index
160 reply = vpp:api_call("acl_add_replace", { context = 42, acl_index = -1, count = 3, r = { { is_permit = 1, is_ipv6 = 1 }, { is_permit = 0, is_ipv6 = 1 }, { is_permit = 1, is_ipv6 = 0 } } })
161 print(vpp.dump(reply))
163 interface_acl_out = reply[1].acl_index
166 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 1, acl_index = interface_acl_in })
167 print(vpp.dump(reply))
170 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 1, acl_index = interface_acl_in })
171 print(vpp.dump(reply))
174 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 0, acl_index = interface_acl_out })
175 print(vpp.dump(reply))
178 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 0, acl_index = interface_acl_out })
179 print(vpp.dump(reply))
182 reply = vpp:api_call("acl_add_replace", { context = 42, acl_index = -1, count = 0 })
183 print(vpp.dump(reply))
186 acl_index_to_delete = reply[1].acl_index
187 print("Deleting " .. tostring(acl_index_to_delete))
188 reply = vpp:api_call("acl_del", { context = 42, acl_index = acl_index_to_delete })
189 print(vpp.dump(reply))
192 reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 0})
193 for ri, rv in ipairs(reply) do
194 print("Reply message #" .. tostring(ri))
196 for ai, av in ipairs(rv.r) do
197 print("ACL rule #" .. tostring(ai) .. " : " .. vpp.dump(av))
203 reply = vpp:api_call("acl_del", { context = 42, acl_index = interface_acl_out })
204 print(vpp.dump(reply))
206 reply = vpp:api_call("acl_del", { context = 42, acl_index = interface_acl_in })
207 print(vpp.dump(reply))
210 reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 0})
211 print(vpp.dump(reply))
214 reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 4294967295 })
215 print(vpp.dump(reply))
219 ]] -- end of comment out
221 ---- Should be nothing ^^
223 { is_permit = 1, is_ipv6 = 1, dst_ip_addr = ip46("2001:db8:1::2"), dst_ip_prefix_len = 128 },
224 { is_permit = 0, is_ipv6 = 1, dst_ip_addr = ip46("2001:db8:1::3"), dst_ip_prefix_len = 128 },
225 { is_permit = 1, is_ipv6 = 1, dst_ip_addr = ip46("2001:db8::"), dst_ip_prefix_len = 32 },
226 { is_permit = 1, is_ipv6 = 0, dst_ip_addr = ip46("192.0.2.2"), dst_ip_prefix_len = 32},
227 { is_permit = 0, is_ipv6 = 0, dst_ip_addr = ip46("192.0.2.3"), dst_ip_prefix_len = 32 },
230 reply = vpp:api_call("acl_add_replace", { context = 42, acl_index = -1, count = 5, r = r })
231 print(vpp.dump(reply))
233 interface_acl_in = reply[1].acl_index
235 reply = vpp:api_call("acl_add_replace", { context = 42, acl_index = -1, count = 3, r = { { is_permit = 1, is_ipv6 = 1 }, { is_permit = 0, is_ipv6 = 1 }, { is_permit = 1, is_ipv6 = 0 } } })
236 print(vpp.dump(reply))
238 interface_acl_out = reply[1].acl_in
240 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = vpp_if_to_s1, is_add = 1, is_input = 1, acl_index = interface_acl_in })
241 print(vpp.dump(reply))
244 --reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = vpp_if_to_s2, is_add = 1, is_input = 0, acl_index = interface_acl_out })
245 -- print(vpp.dump(reply))
251 run VPP trace add af-packet-input 100
252 run s1 ping6 -c 3 2001:db8:1::2
253 expect s1 packet loss
255 expect VPP match: inacl 0 rule 0
258 run VPP trace add af-packet-input 100
259 run s1 ping6 -c 3 2001:db8:1::3
260 expect s1 packet loss
262 expect VPP match: inacl 0 rule 1
265 run VPP trace add af-packet-input 100
266 run s1 ping6 -c 3 2001:db8:1::4
267 expect s1 packet loss
269 expect VPP match: inacl 0 rule 2
272 run VPP trace add af-packet-input 100
273 run s1 ping -c 3 192.0.2.2
274 expect s1 packet loss
276 expect VPP match: inacl 0 rule 3
279 run VPP trace add af-packet-input 100
280 run s1 ping -c 3 192.0.2.3
281 expect s1 packet loss
283 expect VPP match: inacl 0 rule 4
288 --- TEST OUTBOUND ACL
291 { is_permit = 1, is_ipv6 = 1, src_ip_addr = ip46("2001:db8:1::1"), src_ip_prefix_len = 128, dst_ip_addr = ip46("2001:db8:1::2"), dst_ip_prefix_len = 128 },
292 { is_permit = 0, is_ipv6 = 1, src_ip_addr = ip46("2001:db8:1::1"), src_ip_prefix_len = 128, dst_ip_addr = ip46("2001:db8:1::4"), dst_ip_prefix_len = 128 }
295 reply = vpp:api_call("acl_add_replace", { context = 42, acl_index = -1, count = 3, r = r1 })
296 print(vpp.dump(reply))
298 interface_acl_out = reply[1].acl_index
300 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = vpp_if_to_s2, is_add = 1, is_input = 0, acl_index = interface_acl_out })
301 print(vpp.dump(reply))
308 run VPP trace add af-packet-input 100
309 run s1 ping6 -c 3 2001:db8:1::2
310 expect s1 packet loss
312 expect VPP match: outacl 2 rule 0
315 run VPP trace add af-packet-input 100
316 run s1 ping6 -c 3 2001:db8:1::3
317 expect s1 packet loss
319 expect VPP match: inacl 0 rule 1
322 run VPP trace add af-packet-input 100
323 run s1 ping6 -c 3 2001:db8:1::4
324 expect s1 packet loss
326 expect VPP match: outacl 2 rule 1
328 run lua print("ALL GOOD!")