blob: dd4967525b3eae739144ae6d22cc077f3f542558 [file] [log] [blame]
Garrick Evans54861622019-07-19 09:05:09 +09001// Copyright 2019 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Garrick Evans3388a032020-03-24 11:25:55 +09005#include "patchpanel/arc_service.h"
Garrick Evans54861622019-07-19 09:05:09 +09006
Garrick Evanse94b6de2020-02-20 09:19:13 +09007#include <net/if.h>
8
Garrick Evans54861622019-07-19 09:05:09 +09009#include <utility>
10#include <vector>
11
12#include <base/bind.h>
13
14#include <gmock/gmock.h>
15#include <gtest/gtest.h>
16
Garrick Evans3388a032020-03-24 11:25:55 +090017#include "patchpanel/address_manager.h"
18#include "patchpanel/fake_process_runner.h"
19#include "patchpanel/fake_shill_client.h"
20#include "patchpanel/mock_datapath.h"
Jason Jeremy Imana7273a32020-08-04 11:25:31 +090021#include "patchpanel/mock_firewall.h"
Garrick Evans3388a032020-03-24 11:25:55 +090022#include "patchpanel/net_util.h"
Garrick Evans54861622019-07-19 09:05:09 +090023
24using testing::_;
Garrick Evanse94b6de2020-02-20 09:19:13 +090025using testing::AnyNumber;
Garrick Evansc7071122020-04-17 12:31:57 +090026using testing::Eq;
27using testing::Pointee;
Garrick Evans54861622019-07-19 09:05:09 +090028using testing::Return;
Garrick Evansb4eb3892019-11-13 12:07:07 +090029using testing::ReturnRef;
Garrick Evans54861622019-07-19 09:05:09 +090030using testing::StrEq;
31
Garrick Evans3388a032020-03-24 11:25:55 +090032namespace patchpanel {
Garrick Evans54861622019-07-19 09:05:09 +090033namespace {
Garrick Evansb4eb3892019-11-13 12:07:07 +090034constexpr pid_t kTestPID = -2;
Garrick Evansb4eb3892019-11-13 12:07:07 +090035constexpr uint32_t kTestCID = 2;
Garrick Evans7a1a9ee2020-01-28 11:03:57 +090036constexpr uint32_t kArcHostIP = Ipv4Addr(100, 115, 92, 1);
37constexpr uint32_t kArcGuestIP = Ipv4Addr(100, 115, 92, 2);
Hugo Benichiad1bdd92020-06-12 13:48:37 +090038constexpr uint32_t kFirstEthHostIP = Ipv4Addr(100, 115, 92, 5);
39constexpr uint32_t kFirstEthGuestIP = Ipv4Addr(100, 115, 92, 6);
Garrick Evans86c7d9c2020-03-17 09:25:48 +090040constexpr uint32_t kSecondEthHostIP = Ipv4Addr(100, 115, 92, 9);
41constexpr uint32_t kFirstWifiHostIP = Ipv4Addr(100, 115, 92, 13);
42constexpr uint32_t kSecondWifiHostIP = Ipv4Addr(100, 115, 92, 17);
43constexpr uint32_t kFirstCellHostIP = Ipv4Addr(100, 115, 92, 21);
Garrick Evansc7071122020-04-17 12:31:57 +090044constexpr MacAddress kArcVmArc0MacAddr = {0x42, 0x37, 0x05, 0x13, 0x17, 0x01};
Garrick Evans54861622019-07-19 09:05:09 +090045
Garrick Evans2e5c9ab2020-03-05 14:33:58 +090046class MockTrafficForwarder : public TrafficForwarder {
47 public:
48 MockTrafficForwarder() = default;
49 ~MockTrafficForwarder() = default;
50
Jason Jeremy Iman0e9f8262020-03-06 14:50:49 +090051 MOCK_METHOD4(StartForwarding,
Garrick Evans2e5c9ab2020-03-05 14:33:58 +090052 void(const std::string& ifname_physical,
53 const std::string& ifname_virtual,
Garrick Evans2e5c9ab2020-03-05 14:33:58 +090054 bool ipv6,
55 bool multicast));
56
57 MOCK_METHOD4(StopForwarding,
58 void(const std::string& ifname_physical,
59 const std::string& ifname_virtual,
60 bool ipv6,
61 bool multicast));
62};
63
Garrick Evans54861622019-07-19 09:05:09 +090064} // namespace
65
66class ArcServiceTest : public testing::Test {
67 public:
Garrick Evans4ee5ce22020-03-18 07:05:17 +090068 ArcServiceTest() : testing::Test() {}
Garrick Evans54861622019-07-19 09:05:09 +090069
70 protected:
71 void SetUp() override {
Taoyu Li179dcc62019-10-17 11:21:08 +090072 runner_ = std::make_unique<FakeProcessRunner>();
Garrick Evans54861622019-07-19 09:05:09 +090073 runner_->Capture(false);
Jason Jeremy Imana7273a32020-08-04 11:25:31 +090074 datapath_ = std::make_unique<MockDatapath>(runner_.get(), &firewall_);
Garrick Evans69b85872020-02-04 11:40:26 +090075 shill_client_ = shill_helper_.Client();
Garrick Evans4ee5ce22020-03-18 07:05:17 +090076 addr_mgr_ = std::make_unique<AddressManager>();
Garrick Evans54861622019-07-19 09:05:09 +090077 }
78
Hugo Benichiad1bdd92020-06-12 13:48:37 +090079 std::unique_ptr<ArcService> NewService(GuestMessage::GuestType guest) {
Garrick Evans6e4eb3b2020-03-09 07:18:31 +090080 return std::make_unique<ArcService>(shill_client_.get(), datapath_.get(),
Hugo Benichiad1bdd92020-06-12 13:48:37 +090081 addr_mgr_.get(), &forwarder_, guest);
Garrick Evans54861622019-07-19 09:05:09 +090082 }
83
Garrick Evans69b85872020-02-04 11:40:26 +090084 FakeShillClientHelper shill_helper_;
85 std::unique_ptr<ShillClient> shill_client_;
Garrick Evans4ee5ce22020-03-18 07:05:17 +090086 std::unique_ptr<AddressManager> addr_mgr_;
Garrick Evans2e5c9ab2020-03-05 14:33:58 +090087 MockTrafficForwarder forwarder_;
Taoyu Li179dcc62019-10-17 11:21:08 +090088 std::unique_ptr<MockDatapath> datapath_;
89 std::unique_ptr<FakeProcessRunner> runner_;
Jason Jeremy Imana7273a32020-08-04 11:25:31 +090090 MockFirewall firewall_;
Garrick Evans54861622019-07-19 09:05:09 +090091};
92
Hugo Benichiad1bdd92020-06-12 13:48:37 +090093TEST_F(ArcServiceTest, NotStarted_AddDevice) {
94 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), _, _)).Times(0);
Hugo Benichi8d622b52020-08-13 15:24:12 +090095 EXPECT_CALL(*datapath_,
96 StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), _, _))
97 .Times(0);
Garrick Evans54861622019-07-19 09:05:09 +090098
Hugo Benichiad1bdd92020-06-12 13:48:37 +090099 auto svc = NewService(GuestMessage::ARC);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900100 svc->OnDevicesChanged({"eth0"}, {});
101 EXPECT_TRUE(svc->devices_.find("eth0") == svc->devices_.end());
102 EXPECT_FALSE(svc->shill_devices_.find("eth0") == svc->shill_devices_.end());
Garrick Evans54861622019-07-19 09:05:09 +0900103}
104
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900105TEST_F(ArcServiceTest, NotStarted_AddRemoveDevice) {
106 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), _, _)).Times(0);
Hugo Benichi8d622b52020-08-13 15:24:12 +0900107 EXPECT_CALL(*datapath_,
108 StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), _, _))
109 .Times(0);
110 EXPECT_CALL(*datapath_,
111 StopRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), _, _))
112 .Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900113 EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0"))).Times(0);
Garrick Evans54861622019-07-19 09:05:09 +0900114
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900115 auto svc = NewService(GuestMessage::ARC);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900116 svc->OnDevicesChanged({"eth0"}, {});
117 svc->OnDevicesChanged({}, {"eth0"});
Garrick Evans6e4eb3b2020-03-09 07:18:31 +0900118 EXPECT_TRUE(svc->devices_.find("eth0") == svc->devices_.end());
Hugo Benichif0f10c72020-07-09 10:42:45 +0900119 EXPECT_TRUE(svc->shill_devices_.find("eth0") == svc->shill_devices_.end());
Garrick Evans54861622019-07-19 09:05:09 +0900120}
121
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900122TEST_F(ArcServiceTest, VerifyAddrConfigs) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900123 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
124 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900125 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
126 .WillOnce(Return(true));
127 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900128 .WillOnce(Return(true));
129 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth1"), kSecondEthHostIP, 30))
130 .WillOnce(Return(true));
131 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30))
132 .WillOnce(Return(true));
133 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan1"), kSecondWifiHostIP, 30))
134 .WillOnce(Return(true));
135 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wwan0"), kFirstCellHostIP, 30))
136 .WillOnce(Return(true));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900137 EXPECT_CALL(*datapath_, AddVirtualInterfacePair(StrEq("arc_netns"), _, _))
138 .WillRepeatedly(Return(true));
139 EXPECT_CALL(*datapath_, ToggleInterface(_, true))
140 .WillRepeatedly(Return(true));
141 EXPECT_CALL(*datapath_, ConfigureInterface(_, _, _, _, _, _))
142 .WillRepeatedly(Return(true));
143 EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true));
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900144
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900145 auto svc = NewService(GuestMessage::ARC);
146 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900147 svc->OnDevicesChanged({"eth0", "eth1", "wlan0", "wlan1", "wwan0"}, {});
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900148}
149
150TEST_F(ArcServiceTest, VerifyAddrOrder) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900151 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
152 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900153 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
154 .WillOnce(Return(true));
155 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900156 .Times(2)
157 .WillRepeatedly(Return(true));
158 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30))
159 .WillOnce(Return(true));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900160 EXPECT_CALL(*datapath_, AddVirtualInterfacePair(StrEq("arc_netns"), _, _))
161 .WillRepeatedly(Return(true));
162 EXPECT_CALL(*datapath_, ToggleInterface(_, true))
163 .WillRepeatedly(Return(true));
164 EXPECT_CALL(*datapath_, ConfigureInterface(_, _, _, _, _, _))
165 .WillRepeatedly(Return(true));
166 EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true));
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900167
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900168 auto svc = NewService(GuestMessage::ARC);
169 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900170 svc->OnDevicesChanged({"wlan0"}, {});
171 svc->OnDevicesChanged({"eth0"}, {});
172 svc->OnDevicesChanged({}, {"eth0"});
173 svc->OnDevicesChanged({"eth0"}, {});
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900174}
175
Garrick Evansc7071122020-04-17 12:31:57 +0900176TEST_F(ArcServiceTest, StableArcVmMacAddrs) {
177 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
178 .WillRepeatedly(Return("vmtap"));
179 EXPECT_CALL(*datapath_, AddBridge(_, _, 30)).WillRepeatedly(Return(true));
180 EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true));
181
182 auto svc = NewService(GuestMessage::ARC_VM);
183 svc->Start(kTestCID);
184 auto configs = svc->GetDeviceConfigs();
185 EXPECT_EQ(configs.size(), 6);
186 auto mac_addr = kArcVmArc0MacAddr;
187 for (const auto* config : configs) {
188 EXPECT_EQ(config->mac_addr(), mac_addr);
189 mac_addr[5]++;
190 }
191}
192
Garrick Evansb4eb3892019-11-13 12:07:07 +0900193// ContainerImpl
194
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900195TEST_F(ArcServiceTest, ContainerImpl_Start) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900196 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
197 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900198 // Expectations for arc0 setup.
Garrick Evanse94b6de2020-02-20 09:19:13 +0900199 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
200 .WillOnce(Return(true));
Garrick Evansb4eb3892019-11-13 12:07:07 +0900201 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900202 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
203 StrEq("arc0")))
Garrick Evansb4eb3892019-11-13 12:07:07 +0900204 .WillOnce(Return(true));
Garrick Evans2470caa2020-03-04 14:15:41 +0900205 EXPECT_CALL(*datapath_,
206 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
207 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900208 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
Garrick Evans2470caa2020-03-04 14:15:41 +0900209 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900210 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
Garrick Evans2470caa2020-03-04 14:15:41 +0900211 .WillOnce(Return(true));
Jason Jeremy Iman0e9f8262020-03-06 14:50:49 +0900212 EXPECT_CALL(forwarder_, StartForwarding(_, _, _, _)).Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900213
214 auto svc = NewService(GuestMessage::ARC);
215 svc->Start(kTestPID);
Garrick Evansb4eb3892019-11-13 12:07:07 +0900216}
217
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900218TEST_F(ArcServiceTest, ContainerImpl_FailsToCreateInterface) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900219 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
220 .WillOnce(Return(true));
Garrick Evans63378b32020-01-14 10:36:16 +0900221 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900222 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
223 StrEq("arc0")))
Garrick Evans2470caa2020-03-04 14:15:41 +0900224 .WillOnce(Return(false));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900225
Garrick Evans2470caa2020-03-04 14:15:41 +0900226 EXPECT_CALL(*datapath_, ConfigureInterface(_, _, _, _, _, _)).Times(0);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900227 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true)).Times(0);
228 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)).Times(0);
Garrick Evanse94b6de2020-02-20 09:19:13 +0900229 EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900230
231 auto svc = NewService(GuestMessage::ARC);
232 svc->Start(kTestPID);
Garrick Evans63378b32020-01-14 10:36:16 +0900233}
234
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900235TEST_F(ArcServiceTest, ContainerImpl_FailsToConfigureInterface) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900236 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
237 .WillOnce(Return(true));
Garrick Evansb4eb3892019-11-13 12:07:07 +0900238 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900239 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
240 StrEq("arc0")))
Garrick Evans63378b32020-01-14 10:36:16 +0900241 .WillOnce(Return(true));
Garrick Evans63378b32020-01-14 10:36:16 +0900242 EXPECT_CALL(*datapath_,
Garrick Evans2470caa2020-03-04 14:15:41 +0900243 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
Garrick Evans63378b32020-01-14 10:36:16 +0900244 .WillOnce(Return(false));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900245
Garrick Evans2f581a02020-05-11 10:43:35 +0900246 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true)).Times(0);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900247 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)).Times(0);
Garrick Evans63378b32020-01-14 10:36:16 +0900248 EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900249
250 auto svc = NewService(GuestMessage::ARC);
251 svc->Start(kTestPID);
Garrick Evans63378b32020-01-14 10:36:16 +0900252}
253
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900254TEST_F(ArcServiceTest, ContainerImpl_FailsToAddInterfaceToBridge) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900255 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
256 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900257 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
258 .WillOnce(Return(true));
259 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900260 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
261 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900262 .WillOnce(Return(true));
263 EXPECT_CALL(*datapath_,
264 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
265 .WillOnce(Return(true));
266 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
267 .WillOnce(Return(true));
268 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
269 .WillOnce(Return(false));
270
271 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vetharc0")));
272 EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0);
273
274 auto svc = NewService(GuestMessage::ARC);
275 svc->Start(kTestPID);
276}
277
278TEST_F(ArcServiceTest, ContainerImpl_OnStartDevice) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900279 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
280 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900281 // Expectations for arc0 setup.
282 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
283 .WillOnce(Return(true));
284 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900285 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
286 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900287 .WillOnce(Return(true));
288 EXPECT_CALL(*datapath_,
289 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
290 .WillOnce(Return(true));
291 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
292 .WillOnce(Return(true));
293 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
294 .WillOnce(Return(true));
295 // Expectations for eth0 setup.
296 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
297 .WillOnce(Return(true));
Garrick Evansb4eb3892019-11-13 12:07:07 +0900298 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900299 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetheth0"),
300 StrEq("eth0")))
Garrick Evansb4eb3892019-11-13 12:07:07 +0900301 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900302 EXPECT_CALL(*datapath_, ConfigureInterface(StrEq("eth0"), _, kFirstEthGuestIP,
303 30, true, _))
Garrick Evans2470caa2020-03-04 14:15:41 +0900304 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900305 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetheth0"), true))
Garrick Evans2470caa2020-03-04 14:15:41 +0900306 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900307 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0")))
Garrick Evans2470caa2020-03-04 14:15:41 +0900308 .WillOnce(Return(true));
Jason Jeremy Iman0e9f8262020-03-06 14:50:49 +0900309 EXPECT_CALL(forwarder_,
310 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900311 EXPECT_CALL(*datapath_,
312 StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
313 kFirstEthGuestIP, TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900314
315 auto svc = NewService(GuestMessage::ARC);
316 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900317 svc->OnDevicesChanged({"eth0"}, {});
318}
319
320TEST_F(ArcServiceTest, ContainerImpl_StartAfterDevice) {
321 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
322 .WillOnce(Return(true));
323 // Expectations for arc0 setup.
324 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
325 .WillOnce(Return(true));
326 EXPECT_CALL(*datapath_,
327 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
328 StrEq("arc0")))
329 .WillOnce(Return(true));
330 EXPECT_CALL(*datapath_,
331 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
332 .WillOnce(Return(true));
333 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
334 .WillOnce(Return(true));
335 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
336 .WillOnce(Return(true));
337 // Expectations for eth0 setup.
338 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
339 .WillOnce(Return(true));
340 EXPECT_CALL(*datapath_,
341 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetheth0"),
342 StrEq("eth0")))
343 .WillOnce(Return(true));
344 EXPECT_CALL(*datapath_, ConfigureInterface(StrEq("eth0"), _, kFirstEthGuestIP,
345 30, true, _))
346 .WillOnce(Return(true));
347 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetheth0"), true))
348 .WillOnce(Return(true));
349 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0")))
350 .WillOnce(Return(true));
351 EXPECT_CALL(forwarder_,
352 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900353 EXPECT_CALL(*datapath_,
354 StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
355 kFirstEthGuestIP, TrafficSource::ARC));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900356
357 auto svc = NewService(GuestMessage::ARC);
358 svc->OnDevicesChanged({"eth0"}, {});
359 svc->Start(kTestPID);
Garrick Evansb4eb3892019-11-13 12:07:07 +0900360}
361
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900362TEST_F(ArcServiceTest, ContainerImpl_Stop) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900363 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
364 .WillOnce(Return(true));
365 EXPECT_CALL(*datapath_, NetnsDeleteName(StrEq("arc_netns")))
366 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900367 // Expectations for arc0 setup.
368 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
369 .WillOnce(Return(true));
Garrick Evanse94b6de2020-02-20 09:19:13 +0900370 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900371 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
372 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900373 .WillOnce(Return(true));
374 EXPECT_CALL(*datapath_,
375 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
376 .WillOnce(Return(true));
377 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
378 .WillOnce(Return(true));
379 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
380 .WillOnce(Return(true));
381 // Expectations for arc0 teardown.
382 EXPECT_CALL(*datapath_,
383 MaskInterfaceFlags(StrEq("arcbr0"), IFF_DEBUG, IFF_UP))
384 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900385 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vetharc0")));
Garrick Evans2e5c9ab2020-03-05 14:33:58 +0900386 EXPECT_CALL(forwarder_, StopForwarding(_, _, _, _)).Times(0);
Garrick Evanse94b6de2020-02-20 09:19:13 +0900387
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900388 auto svc = NewService(GuestMessage::ARC);
389 svc->Start(kTestPID);
390 svc->Stop(kTestPID);
Garrick Evansb4eb3892019-11-13 12:07:07 +0900391}
392
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900393TEST_F(ArcServiceTest, ContainerImpl_OnStopDevice) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900394 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
395 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900396 // Expectations for arc0 setup.
397 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
398 .WillOnce(Return(true));
399 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900400 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
401 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900402 .WillOnce(Return(true));
403 EXPECT_CALL(*datapath_,
404 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
405 .WillOnce(Return(true));
406 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
407 .WillOnce(Return(true));
408 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
409 .WillOnce(Return(true));
410 // Expectations for eth0 setup.
411 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
412 .WillOnce(Return(true));
413 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900414 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetheth0"),
415 StrEq("eth0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900416 .WillOnce(Return(true));
417 EXPECT_CALL(*datapath_, ConfigureInterface(StrEq("eth0"), _, kFirstEthGuestIP,
418 30, true, _))
419 .WillOnce(Return(true));
420 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetheth0"), true))
421 .WillOnce(Return(true));
422 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0")))
423 .WillOnce(Return(true));
424 // Expectations for eth0 teardown.
Garrick Evans2e5c9ab2020-03-05 14:33:58 +0900425 EXPECT_CALL(forwarder_,
426 StopForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900427 EXPECT_CALL(*datapath_,
Hugo Benichi8d622b52020-08-13 15:24:12 +0900428 StopRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
429 Ipv4Addr(100, 115, 92, 6), TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900430 EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0")));
Garrick Evanse94b6de2020-02-20 09:19:13 +0900431
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900432 auto svc = NewService(GuestMessage::ARC);
433 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900434 svc->OnDevicesChanged({"eth0"}, {});
435 svc->OnDevicesChanged({}, {"eth0"});
Garrick Evansb4eb3892019-11-13 12:07:07 +0900436}
437
Garrick Evansb4eb3892019-11-13 12:07:07 +0900438// VM Impl
439
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900440TEST_F(ArcServiceTest, VmImpl_Start) {
441 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900442 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900443 .WillOnce(Return("vmtap0"))
444 .WillOnce(Return("vmtap1"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900445 .WillOnce(Return("vmtap2"))
446 .WillOnce(Return("vmtap3"))
447 .WillOnce(Return("vmtap4"))
448 .WillOnce(Return("vmtap5"));
449 // Expectations for "arc0" setup.
450 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900451 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900452 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900453 .WillOnce(Return(true));
454
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900455 auto svc = NewService(GuestMessage::ARC_VM);
456 svc->Start(kTestPID);
Garrick Evans2961c7c2020-04-03 11:34:40 +0900457}
458
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900459TEST_F(ArcServiceTest, VmImpl_StartDevice) {
460 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900461 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900462 .WillOnce(Return("vmtap0"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900463 .WillOnce(Return("vmtap1"))
464 .WillOnce(Return("vmtap2"))
465 .WillOnce(Return("vmtap3"))
466 .WillOnce(Return("vmtap4"))
467 .WillOnce(Return("vmtap5"));
468 // Expectations for "arc0" setup.
469 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900470 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900471 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
472 .WillOnce(Return(true));
473 // Expectations for eth0 setup.
474 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900475 .WillOnce(Return(true));
476 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1")))
477 .WillOnce(Return(true));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900478 EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
479 Ipv4Addr(100, 115, 92, 6),
480 TrafficSource::ARC));
Garrick Evans2961c7c2020-04-03 11:34:40 +0900481 EXPECT_CALL(forwarder_,
482 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
483
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900484 auto svc = NewService(GuestMessage::ARC_VM);
485 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900486 svc->OnDevicesChanged({"eth0"}, {});
Garrick Evans2961c7c2020-04-03 11:34:40 +0900487}
488
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900489TEST_F(ArcServiceTest, VmImpl_StartMultipleDevices) {
490 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900491 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900492 .WillOnce(Return("vmtap0"))
493 .WillOnce(Return("vmtap1"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900494 .WillOnce(Return("vmtap2"))
495 .WillOnce(Return("vmtap3"))
496 .WillOnce(Return("vmtap4"))
497 .WillOnce(Return("vmtap5"));
498 // Expectations for "arc0" setup.
499 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900500 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900501 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900502 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900503 // Expectations for eth0 setup.
504 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
505 .WillOnce(Return(true));
506 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1")))
507 .WillOnce(Return(true));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900508 EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
509 Ipv4Addr(100, 115, 92, 6),
510 TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900511 EXPECT_CALL(forwarder_,
512 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
513 // Expectations for wlan0 setup.
514 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30))
515 .WillOnce(Return(true));
516 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_wlan0"), StrEq("vmtap3")))
517 .WillOnce(Return(true));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900518 EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("wlan0"), StrEq("arc_wlan0"),
519 Ipv4Addr(100, 115, 92, 14),
520 TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900521 EXPECT_CALL(forwarder_,
522 StartForwarding(StrEq("wlan0"), StrEq("arc_wlan0"), _, _));
523 // Expectations for eth1 setup.
524 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth1"), kSecondEthHostIP, 30))
525 .WillOnce(Return(true));
526 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth1"), StrEq("vmtap2")))
527 .WillOnce(Return(true));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900528 EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth1"), StrEq("arc_eth1"),
529 Ipv4Addr(100, 115, 92, 10),
530 TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900531 EXPECT_CALL(forwarder_,
532 StartForwarding(StrEq("eth1"), StrEq("arc_eth1"), _, _));
533
534 auto svc = NewService(GuestMessage::ARC_VM);
535 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900536 svc->OnDevicesChanged({"eth0"}, {});
537 svc->OnDevicesChanged({"wlan0"}, {});
538 svc->OnDevicesChanged({"eth1"}, {});
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900539}
540
541TEST_F(ArcServiceTest, VmImpl_Stop) {
542 // Expectations for tap devices pre-creation.
543 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
544 .WillOnce(Return("vmtap0"))
545 .WillOnce(Return("vmtap1"))
546 .WillOnce(Return("vmtap2"))
547 .WillOnce(Return("vmtap3"))
548 .WillOnce(Return("vmtap4"))
549 .WillOnce(Return("vmtap5"));
550 // Expectations for "arc0" setup.
551 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
552 .WillOnce(Return(true));
553 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
554 .WillOnce(Return(true));
555 // Expectations for "arc0" teardown.
556 EXPECT_CALL(*datapath_,
557 MaskInterfaceFlags(StrEq("arcbr0"), IFF_DEBUG, IFF_UP))
558 .WillOnce(Return(true));
559 // Expectations for tap devices teardown
Garrick Evans2961c7c2020-04-03 11:34:40 +0900560 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap0")));
561 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap1")));
562 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap2")));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900563 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap3")));
564 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap4")));
565 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap5")));
Garrick Evans2961c7c2020-04-03 11:34:40 +0900566
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900567 auto svc = NewService(GuestMessage::ARC_VM);
568 svc->Start(kTestPID);
569 svc->Stop(kTestPID);
Garrick Evans2961c7c2020-04-03 11:34:40 +0900570}
571
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900572TEST_F(ArcServiceTest, VmImpl_StopDevice) {
573 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900574 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900575 .WillOnce(Return("vmtap0"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900576 .WillOnce(Return("vmtap1"))
577 .WillOnce(Return("vmtap2"))
578 .WillOnce(Return("vmtap3"))
579 .WillOnce(Return("vmtap4"))
580 .WillOnce(Return("vmtap5"));
581 // Expectations for "arc0" setup.
582 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900583 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900584 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900585 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900586 // Expectations for eth0 setup.
587 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
588 .WillOnce(Return(true));
589 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1")))
590 .WillOnce(Return(true));
Hugo Benichi8d622b52020-08-13 15:24:12 +0900591 EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
592 Ipv4Addr(100, 115, 92, 6),
593 TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900594 EXPECT_CALL(forwarder_,
595 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
596 // Expectations for eth0 teardown.
Garrick Evans2961c7c2020-04-03 11:34:40 +0900597 EXPECT_CALL(forwarder_,
598 StopForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900599 EXPECT_CALL(*datapath_,
Hugo Benichi8d622b52020-08-13 15:24:12 +0900600 StopRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"),
601 Ipv4Addr(100, 115, 92, 6), TrafficSource::ARC));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900602 EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0")));
Garrick Evans2961c7c2020-04-03 11:34:40 +0900603
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900604 auto svc = NewService(GuestMessage::ARC_VM);
605 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900606 svc->OnDevicesChanged({"eth0"}, {});
607 svc->OnDevicesChanged({}, {"eth0"});
Garrick Evans2961c7c2020-04-03 11:34:40 +0900608}
Garrick Evans3388a032020-03-24 11:25:55 +0900609
610} // namespace patchpanel