blob: a94a0f47e03b25de0e1b8dd52df1725a5e1b3af2 [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);
95 EXPECT_CALL(*datapath_, AddInboundIPv4DNAT(StrEq("eth0"), _)).Times(0);
96 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0"))).Times(0);
Garrick Evans54861622019-07-19 09:05:09 +090097
Hugo Benichiad1bdd92020-06-12 13:48:37 +090098 auto svc = NewService(GuestMessage::ARC);
Hugo Benichif0f10c72020-07-09 10:42:45 +090099 svc->OnDevicesChanged({"eth0"}, {});
100 EXPECT_TRUE(svc->devices_.find("eth0") == svc->devices_.end());
101 EXPECT_FALSE(svc->shill_devices_.find("eth0") == svc->shill_devices_.end());
Garrick Evans54861622019-07-19 09:05:09 +0900102}
103
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900104TEST_F(ArcServiceTest, NotStarted_AddRemoveDevice) {
105 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), _, _)).Times(0);
106 EXPECT_CALL(*datapath_, AddInboundIPv4DNAT(StrEq("eth0"), _)).Times(0);
107 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0"))).Times(0);
108 EXPECT_CALL(*datapath_, RemoveOutboundIPv4(StrEq("arc_eth0"))).Times(0);
109 EXPECT_CALL(*datapath_, RemoveInboundIPv4DNAT(StrEq("eth0"), _)).Times(0);
110 EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0"))).Times(0);
Garrick Evans54861622019-07-19 09:05:09 +0900111
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900112 auto svc = NewService(GuestMessage::ARC);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900113 svc->OnDevicesChanged({"eth0"}, {});
114 svc->OnDevicesChanged({}, {"eth0"});
Garrick Evans6e4eb3b2020-03-09 07:18:31 +0900115 EXPECT_TRUE(svc->devices_.find("eth0") == svc->devices_.end());
Hugo Benichif0f10c72020-07-09 10:42:45 +0900116 EXPECT_TRUE(svc->shill_devices_.find("eth0") == svc->shill_devices_.end());
Garrick Evans54861622019-07-19 09:05:09 +0900117}
118
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900119TEST_F(ArcServiceTest, VerifyAddrConfigs) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900120 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
121 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900122 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
123 .WillOnce(Return(true));
124 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900125 .WillOnce(Return(true));
126 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth1"), kSecondEthHostIP, 30))
127 .WillOnce(Return(true));
128 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30))
129 .WillOnce(Return(true));
130 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan1"), kSecondWifiHostIP, 30))
131 .WillOnce(Return(true));
132 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wwan0"), kFirstCellHostIP, 30))
133 .WillOnce(Return(true));
134 EXPECT_CALL(*datapath_, AddInboundIPv4DNAT(_, _))
135 .WillRepeatedly(Return(true));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900136 EXPECT_CALL(*datapath_, AddOutboundIPv4(_)).WillRepeatedly(Return(true));
137 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));
160 EXPECT_CALL(*datapath_, AddInboundIPv4DNAT(_, _))
161 .WillRepeatedly(Return(true));
162 EXPECT_CALL(*datapath_, AddOutboundIPv4(_)).WillRepeatedly(Return(true));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900163 EXPECT_CALL(*datapath_, AddVirtualInterfacePair(StrEq("arc_netns"), _, _))
164 .WillRepeatedly(Return(true));
165 EXPECT_CALL(*datapath_, ToggleInterface(_, true))
166 .WillRepeatedly(Return(true));
167 EXPECT_CALL(*datapath_, ConfigureInterface(_, _, _, _, _, _))
168 .WillRepeatedly(Return(true));
169 EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true));
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900170
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900171 auto svc = NewService(GuestMessage::ARC);
172 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900173 svc->OnDevicesChanged({"wlan0"}, {});
174 svc->OnDevicesChanged({"eth0"}, {});
175 svc->OnDevicesChanged({}, {"eth0"});
176 svc->OnDevicesChanged({"eth0"}, {});
Garrick Evans86c7d9c2020-03-17 09:25:48 +0900177}
178
Garrick Evansc7071122020-04-17 12:31:57 +0900179TEST_F(ArcServiceTest, StableArcVmMacAddrs) {
180 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
181 .WillRepeatedly(Return("vmtap"));
182 EXPECT_CALL(*datapath_, AddBridge(_, _, 30)).WillRepeatedly(Return(true));
183 EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true));
184
185 auto svc = NewService(GuestMessage::ARC_VM);
186 svc->Start(kTestCID);
187 auto configs = svc->GetDeviceConfigs();
188 EXPECT_EQ(configs.size(), 6);
189 auto mac_addr = kArcVmArc0MacAddr;
190 for (const auto* config : configs) {
191 EXPECT_EQ(config->mac_addr(), mac_addr);
192 mac_addr[5]++;
193 }
194}
195
Garrick Evansb4eb3892019-11-13 12:07:07 +0900196// ContainerImpl
197
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900198TEST_F(ArcServiceTest, ContainerImpl_Start) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900199 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
200 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900201 // Expectations for arc0 setup.
Garrick Evanse94b6de2020-02-20 09:19:13 +0900202 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
203 .WillOnce(Return(true));
Garrick Evansb4eb3892019-11-13 12:07:07 +0900204 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900205 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
206 StrEq("arc0")))
Garrick Evansb4eb3892019-11-13 12:07:07 +0900207 .WillOnce(Return(true));
Garrick Evans2470caa2020-03-04 14:15:41 +0900208 EXPECT_CALL(*datapath_,
209 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
210 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900211 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
Garrick Evans2470caa2020-03-04 14:15:41 +0900212 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900213 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
Garrick Evans2470caa2020-03-04 14:15:41 +0900214 .WillOnce(Return(true));
Jason Jeremy Iman0e9f8262020-03-06 14:50:49 +0900215 EXPECT_CALL(forwarder_, StartForwarding(_, _, _, _)).Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900216
217 auto svc = NewService(GuestMessage::ARC);
218 svc->Start(kTestPID);
Garrick Evansb4eb3892019-11-13 12:07:07 +0900219}
220
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900221TEST_F(ArcServiceTest, ContainerImpl_FailsToCreateInterface) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900222 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
223 .WillOnce(Return(true));
Garrick Evans63378b32020-01-14 10:36:16 +0900224 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900225 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
226 StrEq("arc0")))
Garrick Evans2470caa2020-03-04 14:15:41 +0900227 .WillOnce(Return(false));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900228
Garrick Evans2470caa2020-03-04 14:15:41 +0900229 EXPECT_CALL(*datapath_, ConfigureInterface(_, _, _, _, _, _)).Times(0);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900230 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true)).Times(0);
231 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)).Times(0);
Garrick Evanse94b6de2020-02-20 09:19:13 +0900232 EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900233
234 auto svc = NewService(GuestMessage::ARC);
235 svc->Start(kTestPID);
Garrick Evans63378b32020-01-14 10:36:16 +0900236}
237
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900238TEST_F(ArcServiceTest, ContainerImpl_FailsToConfigureInterface) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900239 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
240 .WillOnce(Return(true));
Garrick Evansb4eb3892019-11-13 12:07:07 +0900241 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900242 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
243 StrEq("arc0")))
Garrick Evans63378b32020-01-14 10:36:16 +0900244 .WillOnce(Return(true));
Garrick Evans63378b32020-01-14 10:36:16 +0900245 EXPECT_CALL(*datapath_,
Garrick Evans2470caa2020-03-04 14:15:41 +0900246 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
Garrick Evans63378b32020-01-14 10:36:16 +0900247 .WillOnce(Return(false));
Hugo Benichif0f10c72020-07-09 10:42:45 +0900248
Garrick Evans2f581a02020-05-11 10:43:35 +0900249 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true)).Times(0);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900250 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)).Times(0);
Garrick Evans63378b32020-01-14 10:36:16 +0900251 EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0);
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900252
253 auto svc = NewService(GuestMessage::ARC);
254 svc->Start(kTestPID);
Garrick Evans63378b32020-01-14 10:36:16 +0900255}
256
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900257TEST_F(ArcServiceTest, ContainerImpl_FailsToAddInterfaceToBridge) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900258 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
259 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900260 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
261 .WillOnce(Return(true));
262 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900263 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
264 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900265 .WillOnce(Return(true));
266 EXPECT_CALL(*datapath_,
267 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
268 .WillOnce(Return(true));
269 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
270 .WillOnce(Return(true));
271 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
272 .WillOnce(Return(false));
273
274 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vetharc0")));
275 EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0);
276
277 auto svc = NewService(GuestMessage::ARC);
278 svc->Start(kTestPID);
279}
280
281TEST_F(ArcServiceTest, ContainerImpl_OnStartDevice) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900282 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
283 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900284 // Expectations for arc0 setup.
285 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
286 .WillOnce(Return(true));
287 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900288 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
289 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900290 .WillOnce(Return(true));
291 EXPECT_CALL(*datapath_,
292 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
293 .WillOnce(Return(true));
294 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
295 .WillOnce(Return(true));
296 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
297 .WillOnce(Return(true));
298 // Expectations for eth0 setup.
299 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
300 .WillOnce(Return(true));
Garrick Evansb4eb3892019-11-13 12:07:07 +0900301 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900302 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetheth0"),
303 StrEq("eth0")))
Garrick Evansb4eb3892019-11-13 12:07:07 +0900304 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900305 EXPECT_CALL(*datapath_, ConfigureInterface(StrEq("eth0"), _, kFirstEthGuestIP,
306 30, true, _))
Garrick Evans2470caa2020-03-04 14:15:41 +0900307 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900308 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetheth0"), true))
Garrick Evans2470caa2020-03-04 14:15:41 +0900309 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900310 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0")))
Garrick Evans2470caa2020-03-04 14:15:41 +0900311 .WillOnce(Return(true));
Jason Jeremy Iman0e9f8262020-03-06 14:50:49 +0900312 EXPECT_CALL(forwarder_,
313 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900314 EXPECT_CALL(
315 *datapath_,
316 AddInboundIPv4DNAT(StrEq("eth0"), IPv4AddressToString(kFirstEthGuestIP)))
317 .WillOnce(Return(true));
318 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0")))
319 .WillOnce(Return(true));
320
321 auto svc = NewService(GuestMessage::ARC);
322 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900323 svc->OnDevicesChanged({"eth0"}, {});
324}
325
326TEST_F(ArcServiceTest, ContainerImpl_StartAfterDevice) {
327 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
328 .WillOnce(Return(true));
329 // Expectations for arc0 setup.
330 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
331 .WillOnce(Return(true));
332 EXPECT_CALL(*datapath_,
333 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
334 StrEq("arc0")))
335 .WillOnce(Return(true));
336 EXPECT_CALL(*datapath_,
337 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
338 .WillOnce(Return(true));
339 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
340 .WillOnce(Return(true));
341 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
342 .WillOnce(Return(true));
343 // Expectations for eth0 setup.
344 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
345 .WillOnce(Return(true));
346 EXPECT_CALL(*datapath_,
347 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetheth0"),
348 StrEq("eth0")))
349 .WillOnce(Return(true));
350 EXPECT_CALL(*datapath_, ConfigureInterface(StrEq("eth0"), _, kFirstEthGuestIP,
351 30, true, _))
352 .WillOnce(Return(true));
353 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetheth0"), true))
354 .WillOnce(Return(true));
355 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0")))
356 .WillOnce(Return(true));
357 EXPECT_CALL(forwarder_,
358 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
359 EXPECT_CALL(
360 *datapath_,
361 AddInboundIPv4DNAT(StrEq("eth0"), IPv4AddressToString(kFirstEthGuestIP)))
362 .WillOnce(Return(true));
363 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0")))
364 .WillOnce(Return(true));
365
366 auto svc = NewService(GuestMessage::ARC);
367 svc->OnDevicesChanged({"eth0"}, {});
368 svc->Start(kTestPID);
Garrick Evansb4eb3892019-11-13 12:07:07 +0900369}
370
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900371TEST_F(ArcServiceTest, ContainerImpl_Stop) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900372 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
373 .WillOnce(Return(true));
374 EXPECT_CALL(*datapath_, NetnsDeleteName(StrEq("arc_netns")))
375 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900376 // Expectations for arc0 setup.
377 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
378 .WillOnce(Return(true));
Garrick Evanse94b6de2020-02-20 09:19:13 +0900379 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900380 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
381 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900382 .WillOnce(Return(true));
383 EXPECT_CALL(*datapath_,
384 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
385 .WillOnce(Return(true));
386 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
387 .WillOnce(Return(true));
388 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
389 .WillOnce(Return(true));
390 // Expectations for arc0 teardown.
391 EXPECT_CALL(*datapath_,
392 MaskInterfaceFlags(StrEq("arcbr0"), IFF_DEBUG, IFF_UP))
393 .WillOnce(Return(true));
Garrick Evans2f581a02020-05-11 10:43:35 +0900394 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vetharc0")));
Garrick Evans2e5c9ab2020-03-05 14:33:58 +0900395 EXPECT_CALL(forwarder_, StopForwarding(_, _, _, _)).Times(0);
Garrick Evanse94b6de2020-02-20 09:19:13 +0900396
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900397 auto svc = NewService(GuestMessage::ARC);
398 svc->Start(kTestPID);
399 svc->Stop(kTestPID);
Garrick Evansb4eb3892019-11-13 12:07:07 +0900400}
401
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900402TEST_F(ArcServiceTest, ContainerImpl_OnStopDevice) {
Hugo Benichi33860d72020-07-09 16:34:01 +0900403 EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID))
404 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900405 // Expectations for arc0 setup.
406 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
407 .WillOnce(Return(true));
408 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900409 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetharc0"),
410 StrEq("arc0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900411 .WillOnce(Return(true));
412 EXPECT_CALL(*datapath_,
413 ConfigureInterface(StrEq("arc0"), _, kArcGuestIP, 30, true, _))
414 .WillOnce(Return(true));
415 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetharc0"), true))
416 .WillOnce(Return(true));
417 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0")))
418 .WillOnce(Return(true));
419 // Expectations for eth0 setup.
420 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
421 .WillOnce(Return(true));
422 EXPECT_CALL(*datapath_,
Hugo Benichi33860d72020-07-09 16:34:01 +0900423 AddVirtualInterfacePair(StrEq("arc_netns"), StrEq("vetheth0"),
424 StrEq("eth0")))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900425 .WillOnce(Return(true));
426 EXPECT_CALL(*datapath_, ConfigureInterface(StrEq("eth0"), _, kFirstEthGuestIP,
427 30, true, _))
428 .WillOnce(Return(true));
429 EXPECT_CALL(*datapath_, ToggleInterface(StrEq("vetheth0"), true))
430 .WillOnce(Return(true));
431 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0")))
432 .WillOnce(Return(true));
433 // Expectations for eth0 teardown.
Garrick Evans2e5c9ab2020-03-05 14:33:58 +0900434 EXPECT_CALL(forwarder_,
435 StopForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900436 EXPECT_CALL(*datapath_, RemoveOutboundIPv4(StrEq("arc_eth0")));
437 EXPECT_CALL(*datapath_,
438 RemoveInboundIPv4DNAT(StrEq("eth0"), StrEq("100.115.92.6")));
439 EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0")));
Garrick Evanse94b6de2020-02-20 09:19:13 +0900440
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900441 auto svc = NewService(GuestMessage::ARC);
442 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900443 svc->OnDevicesChanged({"eth0"}, {});
444 svc->OnDevicesChanged({}, {"eth0"});
Garrick Evansb4eb3892019-11-13 12:07:07 +0900445}
446
Garrick Evansb4eb3892019-11-13 12:07:07 +0900447// VM Impl
448
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900449TEST_F(ArcServiceTest, VmImpl_Start) {
450 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900451 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900452 .WillOnce(Return("vmtap0"))
453 .WillOnce(Return("vmtap1"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900454 .WillOnce(Return("vmtap2"))
455 .WillOnce(Return("vmtap3"))
456 .WillOnce(Return("vmtap4"))
457 .WillOnce(Return("vmtap5"));
458 // Expectations for "arc0" setup.
459 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900460 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900461 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900462 .WillOnce(Return(true));
463
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900464 auto svc = NewService(GuestMessage::ARC_VM);
465 svc->Start(kTestPID);
Garrick Evans2961c7c2020-04-03 11:34:40 +0900466}
467
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900468TEST_F(ArcServiceTest, VmImpl_StartDevice) {
469 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900470 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900471 .WillOnce(Return("vmtap0"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900472 .WillOnce(Return("vmtap1"))
473 .WillOnce(Return("vmtap2"))
474 .WillOnce(Return("vmtap3"))
475 .WillOnce(Return("vmtap4"))
476 .WillOnce(Return("vmtap5"));
477 // Expectations for "arc0" setup.
478 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900479 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900480 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
481 .WillOnce(Return(true));
482 // Expectations for eth0 setup.
483 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900484 .WillOnce(Return(true));
485 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1")))
486 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900487 EXPECT_CALL(*datapath_,
488 AddInboundIPv4DNAT(StrEq("eth0"), StrEq("100.115.92.6")));
489 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0")));
Garrick Evans2961c7c2020-04-03 11:34:40 +0900490 EXPECT_CALL(forwarder_,
491 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
492
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900493 auto svc = NewService(GuestMessage::ARC_VM);
494 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900495 svc->OnDevicesChanged({"eth0"}, {});
Garrick Evans2961c7c2020-04-03 11:34:40 +0900496}
497
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900498TEST_F(ArcServiceTest, VmImpl_StartMultipleDevices) {
499 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900500 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900501 .WillOnce(Return("vmtap0"))
502 .WillOnce(Return("vmtap1"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900503 .WillOnce(Return("vmtap2"))
504 .WillOnce(Return("vmtap3"))
505 .WillOnce(Return("vmtap4"))
506 .WillOnce(Return("vmtap5"));
507 // Expectations for "arc0" setup.
508 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900509 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900510 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900511 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900512 // Expectations for eth0 setup.
513 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
514 .WillOnce(Return(true));
515 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1")))
516 .WillOnce(Return(true));
517 EXPECT_CALL(*datapath_,
518 AddInboundIPv4DNAT(StrEq("eth0"), StrEq("100.115.92.6")));
519 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0")));
520 EXPECT_CALL(forwarder_,
521 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
522 // Expectations for wlan0 setup.
523 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30))
524 .WillOnce(Return(true));
525 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_wlan0"), StrEq("vmtap3")))
526 .WillOnce(Return(true));
527 EXPECT_CALL(*datapath_,
528 AddInboundIPv4DNAT(StrEq("wlan0"), StrEq("100.115.92.14")));
529 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_wlan0")));
530 EXPECT_CALL(forwarder_,
531 StartForwarding(StrEq("wlan0"), StrEq("arc_wlan0"), _, _));
532 // Expectations for eth1 setup.
533 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth1"), kSecondEthHostIP, 30))
534 .WillOnce(Return(true));
535 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth1"), StrEq("vmtap2")))
536 .WillOnce(Return(true));
537 EXPECT_CALL(*datapath_,
538 AddInboundIPv4DNAT(StrEq("eth1"), StrEq("100.115.92.10")));
539 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth1")));
540 EXPECT_CALL(forwarder_,
541 StartForwarding(StrEq("eth1"), StrEq("arc_eth1"), _, _));
542
543 auto svc = NewService(GuestMessage::ARC_VM);
544 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900545 svc->OnDevicesChanged({"eth0"}, {});
546 svc->OnDevicesChanged({"wlan0"}, {});
547 svc->OnDevicesChanged({"eth1"}, {});
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900548}
549
550TEST_F(ArcServiceTest, VmImpl_Stop) {
551 // Expectations for tap devices pre-creation.
552 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
553 .WillOnce(Return("vmtap0"))
554 .WillOnce(Return("vmtap1"))
555 .WillOnce(Return("vmtap2"))
556 .WillOnce(Return("vmtap3"))
557 .WillOnce(Return("vmtap4"))
558 .WillOnce(Return("vmtap5"));
559 // Expectations for "arc0" setup.
560 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
561 .WillOnce(Return(true));
562 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
563 .WillOnce(Return(true));
564 // Expectations for "arc0" teardown.
565 EXPECT_CALL(*datapath_,
566 MaskInterfaceFlags(StrEq("arcbr0"), IFF_DEBUG, IFF_UP))
567 .WillOnce(Return(true));
568 // Expectations for tap devices teardown
Garrick Evans2961c7c2020-04-03 11:34:40 +0900569 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap0")));
570 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap1")));
571 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap2")));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900572 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap3")));
573 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap4")));
574 EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap5")));
Garrick Evans2961c7c2020-04-03 11:34:40 +0900575
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900576 auto svc = NewService(GuestMessage::ARC_VM);
577 svc->Start(kTestPID);
578 svc->Stop(kTestPID);
Garrick Evans2961c7c2020-04-03 11:34:40 +0900579}
580
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900581TEST_F(ArcServiceTest, VmImpl_StopDevice) {
582 // Expectations for tap devices pre-creation.
Garrick Evansc7071122020-04-17 12:31:57 +0900583 EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900584 .WillOnce(Return("vmtap0"))
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900585 .WillOnce(Return("vmtap1"))
586 .WillOnce(Return("vmtap2"))
587 .WillOnce(Return("vmtap3"))
588 .WillOnce(Return("vmtap4"))
589 .WillOnce(Return("vmtap5"));
590 // Expectations for "arc0" setup.
591 EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900592 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900593 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0")))
Garrick Evans2961c7c2020-04-03 11:34:40 +0900594 .WillOnce(Return(true));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900595 // Expectations for eth0 setup.
596 EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30))
597 .WillOnce(Return(true));
598 EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1")))
599 .WillOnce(Return(true));
600 EXPECT_CALL(*datapath_,
601 AddInboundIPv4DNAT(StrEq("eth0"), StrEq("100.115.92.6")));
602 EXPECT_CALL(*datapath_, AddOutboundIPv4(StrEq("arc_eth0")));
603 EXPECT_CALL(forwarder_,
604 StartForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
605 // Expectations for eth0 teardown.
Garrick Evans2961c7c2020-04-03 11:34:40 +0900606 EXPECT_CALL(forwarder_,
607 StopForwarding(StrEq("eth0"), StrEq("arc_eth0"), _, _));
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900608 EXPECT_CALL(*datapath_, RemoveOutboundIPv4(StrEq("arc_eth0")));
609 EXPECT_CALL(*datapath_,
610 RemoveInboundIPv4DNAT(StrEq("eth0"), StrEq("100.115.92.6")));
611 EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0")));
Garrick Evans2961c7c2020-04-03 11:34:40 +0900612
Hugo Benichiad1bdd92020-06-12 13:48:37 +0900613 auto svc = NewService(GuestMessage::ARC_VM);
614 svc->Start(kTestPID);
Hugo Benichif0f10c72020-07-09 10:42:45 +0900615 svc->OnDevicesChanged({"eth0"}, {});
616 svc->OnDevicesChanged({}, {"eth0"});
Garrick Evans2961c7c2020-04-03 11:34:40 +0900617}
Garrick Evans3388a032020-03-24 11:25:55 +0900618
619} // namespace patchpanel