Mike Frysinger | 3a446f2 | 2022-09-08 07:37:14 | [diff] [blame] | 1 | // Copyright 2016 The ChromiumOS Authors |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 5 | #ifndef PATCHPANEL_MANAGER_H_ |
| 6 | #define PATCHPANEL_MANAGER_H_ |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 7 | |
Garrick Evans | 4987953 | 2018-12-03 04:15:36 | [diff] [blame] | 8 | #include <map> |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 9 | #include <memory> |
Hugo Benichi | f880350 | 2023-06-29 11:12:42 | [diff] [blame] | 10 | #include <optional> |
Garrick Evans | 4987953 | 2018-12-03 04:15:36 | [diff] [blame] | 11 | #include <set> |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 12 | #include <string> |
Jason Jeremy Iman | f4156cb | 2019-11-14 06:36:22 | [diff] [blame] | 13 | #include <vector> |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 14 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 15 | #include <base/files/scoped_file.h> |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 16 | #include <base/memory/weak_ptr.h> |
Jie Jiang | e970cc2 | 2024-06-12 07:03:10 | [diff] [blame] | 17 | #include <chromeos/net-base/process_manager.h> |
Hugo Benichi | 8135e56 | 2019-12-12 06:56:36 | [diff] [blame] | 18 | #include <patchpanel/proto_bindings/patchpanel_service.pb.h> |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 19 | |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 20 | #include "patchpanel/address_manager.h" |
| 21 | #include "patchpanel/arc_service.h" |
naoyatezuka | 88b26ef | 2023-08-17 04:27:21 | [diff] [blame] | 22 | #include "patchpanel/clat_service.h" |
Jie Jiang | 493cde4 | 2020-07-17 12:43:39 | [diff] [blame] | 23 | #include "patchpanel/counters_service.h" |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 24 | #include "patchpanel/crostini_service.h" |
Hugo Benichi | fcf8102 | 2020-12-04 02:01:37 | [diff] [blame] | 25 | #include "patchpanel/datapath.h" |
Hugo Benichi | 8b891a6 | 2023-09-05 06:33:45 | [diff] [blame] | 26 | #include "patchpanel/dbus_client_notifier.h" |
Hugo Benichi | abcd7c9 | 2024-05-21 06:09:06 | [diff] [blame] | 27 | #include "patchpanel/downstream_network_info.h" |
Hugo Benichi | 00a001b | 2024-05-22 07:37:12 | [diff] [blame] | 28 | #include "patchpanel/downstream_network_service.h" |
Hugo Benichi | 8b4d2fc | 2023-10-23 05:11:25 | [diff] [blame] | 29 | #include "patchpanel/forwarding_service.h" |
Taoyu Li | 0093a58 | 2022-07-13 09:29:22 | [diff] [blame] | 30 | #include "patchpanel/guest_ipv6_service.h" |
Hugo Benichi | 44d11a3 | 2024-04-29 14:18:55 | [diff] [blame] | 31 | #include "patchpanel/lifeline_fd_service.h" |
Chuwei He | e1c068a | 2023-06-02 02:51:34 | [diff] [blame] | 32 | #include "patchpanel/multicast_counters_service.h" |
Chuwei He | d94b322 | 2024-05-21 05:24:23 | [diff] [blame] | 33 | #include "patchpanel/multicast_forwarder.h" |
Jason Jeremy Iman | ac627e6 | 2023-06-08 01:06:49 | [diff] [blame] | 34 | #include "patchpanel/multicast_metrics.h" |
Jie Jiang | c99d3be | 2024-06-15 06:41:36 | [diff] [blame] | 35 | #include "patchpanel/network/network_applier.h" |
Jie Jiang | 01c1a2e | 2020-04-08 11:58:30 | [diff] [blame] | 36 | #include "patchpanel/network_monitor_service.h" |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 37 | #include "patchpanel/qos_service.h" |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 38 | #include "patchpanel/routing_service.h" |
Chih-Yu Huang | 26eee6e | 2023-06-08 06:08:22 | [diff] [blame] | 39 | #include "patchpanel/rtnl_client.h" |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 40 | #include "patchpanel/shill_client.h" |
Taoyu Li | a6c0dd2 | 2022-07-27 08:20:44 | [diff] [blame] | 41 | #include "patchpanel/subprocess_controller.h" |
Hugo Benichi | 03be896 | 2022-03-17 04:16:38 | [diff] [blame] | 42 | #include "patchpanel/system.h" |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 43 | |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 44 | namespace patchpanel { |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 45 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 46 | // The core implementation of the patchpanel daemon. |
Hugo Benichi | 8b4d2fc | 2023-10-23 05:11:25 | [diff] [blame] | 47 | class Manager : public ForwardingService { |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 48 | public: |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 49 | // The caller should guarantee |system|, |process_manager|, |metrics| and |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 50 | // |dbus_client_notifier| variables outlive the created Manager instance. |
Chih-Yu Huang | 5e114cb | 2024-07-25 02:41:08 | [diff] [blame] | 51 | Manager(const base::FilePath& cmd_path, |
Jie Jiang | 0c389c5 | 2024-10-12 16:00:46 | [diff] [blame] | 52 | const scoped_refptr<dbus::Bus>& bus, |
Chih-Yu Huang | 5e114cb | 2024-07-25 02:41:08 | [diff] [blame] | 53 | System* system, |
| 54 | net_base::ProcessManager* process_manager, |
| 55 | MetricsLibraryInterface* metrics, |
| 56 | DbusClientNotifier* dbus_client_notifier, |
| 57 | std::unique_ptr<ShillClient> shill_client, |
| 58 | std::unique_ptr<RTNLClient> rtnl_client); |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 59 | |
Qijiang Fan | 6bc59e1 | 2020-11-10 17:51:06 | [diff] [blame] | 60 | Manager(const Manager&) = delete; |
| 61 | Manager& operator=(const Manager&) = delete; |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 62 | virtual ~Manager(); |
Qijiang Fan | 6bc59e1 | 2020-11-10 17:51:06 | [diff] [blame] | 63 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 64 | // Queries the list of virtual devices managed by patchpanel. |
Chih-Yu Huang | 1682977 | 2023-05-08 05:18:52 | [diff] [blame] | 65 | GetDevicesResponse GetDevices() const; |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 66 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 67 | // Handles notification indicating ARC++ is booting up. |
| 68 | bool ArcStartup(pid_t pid); |
Garrick Evans | 4ac0985 | 2020-01-16 05:09:22 | [diff] [blame] | 69 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 70 | // Handles notification indicating ARC++ is spinning down. |
| 71 | void ArcShutdown(); |
Garrick Evans | 4ac0985 | 2020-01-16 05:09:22 | [diff] [blame] | 72 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 73 | // Handles notification indicating ARCVM is booting up. |
Hugo Benichi | 35e98b8 | 2023-10-17 15:10:01 | [diff] [blame] | 74 | std::optional<patchpanel::ArcVmStartupResponse> ArcVmStartup(uint32_t cid); |
Jason Jeremy Iman | f4156cb | 2019-11-14 06:36:22 | [diff] [blame] | 75 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 76 | // Handles notification indicating ARCVM is spinning down. |
| 77 | void ArcVmShutdown(uint32_t cid); |
| 78 | |
| 79 | // Handles notification indicating a Termina VM is booting up. |
Hugo Benichi | c911b75 | 2023-07-31 04:02:19 | [diff] [blame] | 80 | const CrostiniService::CrostiniDevice* const TerminaVmStartup(uint64_t vm_id); |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 81 | |
| 82 | // Handles notification indicating a Termina VM is spinning down. |
| 83 | void TerminaVmShutdown(uint64_t vm_id); |
| 84 | |
Hugo Benichi | 9c6c546 | 2023-05-14 15:34:43 | [diff] [blame] | 85 | // Handles notification indicating a Parallels VM is booting up. |
Hugo Benichi | c911b75 | 2023-07-31 04:02:19 | [diff] [blame] | 86 | const CrostiniService::CrostiniDevice* const ParallelsVmStartup( |
| 87 | uint64_t vm_id, uint32_t subnet_index); |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 88 | |
Hugo Benichi | 9c6c546 | 2023-05-14 15:34:43 | [diff] [blame] | 89 | // Handles notification indicating a Parallels VM is spinning down. |
| 90 | void ParallelsVmShutdown(uint64_t vm_id); |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 91 | |
Chih-Yu Huang | 90ff647 | 2023-08-25 06:12:05 | [diff] [blame] | 92 | // Handles notification indicating a Bruschetta VM is booting up. |
| 93 | const CrostiniService::CrostiniDevice* const BruschettaVmStartup( |
| 94 | uint64_t vm_id); |
| 95 | |
| 96 | // Handles notification indicating a Bruschetta VM is spinning down. |
| 97 | void BruschettaVmShutdown(uint64_t vm_id); |
| 98 | |
Damien Dejean | f608ff8 | 2023-11-08 12:47:03 | [diff] [blame] | 99 | // Handles notification indicating a Borealis VM is booting up. |
| 100 | const CrostiniService::CrostiniDevice* const BorealisVmStartup( |
| 101 | uint64_t vm_id); |
| 102 | |
| 103 | // Handles notification indicating a Borealis VM is spinning down. |
| 104 | void BorealisVmShutdown(uint64_t vm_id); |
| 105 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 106 | // Connects and routes an existing network namespace created via minijail or |
| 107 | // through rtnetlink RTM_NEWNSID. |
| 108 | ConnectNamespaceResponse ConnectNamespace( |
| 109 | const patchpanel::ConnectNamespaceRequest& request, |
Hugo Benichi | 44d11a3 | 2024-04-29 14:18:55 | [diff] [blame] | 110 | base::ScopedFD client_fd); |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 111 | |
| 112 | // Queries traffic counters. |
| 113 | std::map<CountersService::CounterKey, CountersService::Counter> |
Chih-Yu Huang | 1682977 | 2023-05-08 05:18:52 | [diff] [blame] | 114 | GetTrafficCounters(const std::set<std::string>& shill_devices) const; |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 115 | |
| 116 | // Creates iptables rules requests from permission_broker. |
| 117 | bool ModifyPortRule(const patchpanel::ModifyPortRuleRequest& request); |
| 118 | |
| 119 | // Starts or stops VPN lockdown. |
| 120 | void SetVpnLockdown(bool enable_vpn_lockdown); |
| 121 | |
| 122 | // Creates iptables rules requests from dns-proxy. |
| 123 | bool SetDnsRedirectionRule( |
| 124 | const patchpanel::SetDnsRedirectionRuleRequest& request, |
Hugo Benichi | 44d11a3 | 2024-04-29 14:18:55 | [diff] [blame] | 125 | base::ScopedFD client_fd); |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 126 | |
Jie Jiang | afb1163 | 2024-01-30 09:54:38 | [diff] [blame] | 127 | // Tags the socket pointed by |sock_fd| for routing and other purposes. |
| 128 | bool TagSocket(const patchpanel::TagSocketRequest& request, |
| 129 | const base::ScopedFD& sock_fd); |
| 130 | |
Chuwei He | 5849a7c | 2024-06-25 08:16:59 | [diff] [blame] | 131 | // Unimplemented, keep the call for future use. |
| 132 | void NotifyAndroidInteractiveState(bool is_interactive) {} |
Chuwei He | bd0dec7 | 2023-04-13 07:39:25 | [diff] [blame] | 133 | |
Chuwei He | 5849a7c | 2024-06-25 08:16:59 | [diff] [blame] | 134 | // Start/Stop forwarding inbound WiFi multicast traffic for ARC when Android |
| 135 | // WiFi multicast lock held status changes (and only for ARC V+, any offload |
| 136 | // service also needs to be registered for |is_held| to be true). |
| 137 | // Start forwarding IPv4 and IPv6 multicast mDNS and SSDP traffic for WiFi |
| 138 | // interfaces only when |is_held| status is `true` for ARC WiFi interface. |
Chuwei He | bd0dec7 | 2023-04-13 07:39:25 | [diff] [blame] | 139 | void NotifyAndroidWifiMulticastLockChange(bool is_held); |
| 140 | |
Chuwei He | 629ee7f | 2023-08-28 06:12:13 | [diff] [blame] | 141 | // Apply changes based on the socket connection event. |
| 142 | // Currently this is only used for ARC socket connections and applies QoS |
| 143 | // setup and resets the QoS setup on connection closed. |
Chuwei He | 33fede0 | 2023-08-14 07:00:54 | [diff] [blame] | 144 | void NotifySocketConnectionEvent( |
| 145 | const NotifySocketConnectionEventRequest& request); |
| 146 | |
Chuwei He | eb9f649 | 2024-01-12 03:13:03 | [diff] [blame] | 147 | // Apply changes based on the socket connection event from ARC VPN. |
| 148 | // Currently this is only used for ARC VPN traffic counting. |
Chuwei He | 32c9b7b | 2024-01-23 05:39:32 | [diff] [blame] | 149 | void NotifyARCVPNSocketConnectionEvent( |
| 150 | const NotifyARCVPNSocketConnectionEventRequest& request); |
Chuwei He | eb9f649 | 2024-01-12 03:13:03 | [diff] [blame] | 151 | |
Chuwei He | bfcacfc | 2023-08-25 02:12:49 | [diff] [blame] | 152 | // Set feature enabled flag. |
Damien Dejean | de59f98 | 2023-10-03 14:05:05 | [diff] [blame] | 153 | bool SetFeatureFlag(patchpanel::SetFeatureFlagRequest::FeatureFlag flag, |
Chuwei He | bfcacfc | 2023-08-25 02:12:49 | [diff] [blame] | 154 | bool enabled); |
| 155 | |
Chuwei He | 867402a | 2024-05-22 05:02:19 | [diff] [blame] | 156 | void StartIPv6NDPForwarding( |
| 157 | const ShillClient::Device& shill_device, |
Chuwei He | ca57f7e | 2024-05-30 05:41:14 | [diff] [blame] | 158 | std::string_view ifname_virtual, |
Chuwei He | 867402a | 2024-05-22 05:02:19 | [diff] [blame] | 159 | std::optional<int> mtu = std::nullopt, |
| 160 | std::optional<int> hop_limit = std::nullopt) override; |
| 161 | |
| 162 | void StopIPv6NDPForwarding(const ShillClient::Device& shill_device, |
Chuwei He | ca57f7e | 2024-05-30 05:41:14 | [diff] [blame] | 163 | std::string_view ifname_virtual) override; |
Chuwei He | 867402a | 2024-05-22 05:02:19 | [diff] [blame] | 164 | |
| 165 | void StartBroadcastForwarding(const ShillClient::Device& shill_device, |
Chuwei He | ca57f7e | 2024-05-30 05:41:14 | [diff] [blame] | 166 | std::string_view ifname_virtual) override; |
Chuwei He | 867402a | 2024-05-22 05:02:19 | [diff] [blame] | 167 | |
| 168 | void StopBroadcastForwarding(const ShillClient::Device& shill_device, |
Chuwei He | ca57f7e | 2024-05-30 05:41:14 | [diff] [blame] | 169 | std::string_view ifname_virtual) override; |
Chuwei He | 867402a | 2024-05-22 05:02:19 | [diff] [blame] | 170 | |
Chuwei He | d94b322 | 2024-05-21 05:24:23 | [diff] [blame] | 171 | void StartMulticastForwarding( |
| 172 | const ShillClient::Device& shill_device, |
Chuwei He | 4f4ab29 | 2024-06-06 02:33:57 | [diff] [blame] | 173 | std::string_view ifname_virtual, |
Chuwei He | d94b322 | 2024-05-21 05:24:23 | [diff] [blame] | 174 | MulticastForwarder::Direction dir = |
| 175 | MulticastForwarder::Direction::kTwoWays) override; |
Chuwei He | 867402a | 2024-05-22 05:02:19 | [diff] [blame] | 176 | |
Chuwei He | d94b322 | 2024-05-21 05:24:23 | [diff] [blame] | 177 | void StopMulticastForwarding( |
| 178 | const ShillClient::Device& shill_device, |
Chuwei He | 4f4ab29 | 2024-06-06 02:33:57 | [diff] [blame] | 179 | std::string_view ifname_virtual, |
Chuwei He | d94b322 | 2024-05-21 05:24:23 | [diff] [blame] | 180 | MulticastForwarder::Direction dir = |
| 181 | MulticastForwarder::Direction::kTwoWays) override; |
Hugo Benichi | 8b4d2fc | 2023-10-23 05:11:25 | [diff] [blame] | 182 | |
Jie Jiang | c99d3be | 2024-06-15 06:41:36 | [diff] [blame] | 183 | void ConfigureNetwork(int ifindex, |
| 184 | const std::string& ifname, |
| 185 | NetworkApplier::Area area, |
| 186 | const net_base::NetworkConfig& network_config, |
| 187 | net_base::NetworkPriority priority, |
Jie Jiang | cd0402c | 2024-10-09 06:11:00 | [diff] [blame] | 188 | NetworkApplier::Technology technology, |
| 189 | int session_id); |
Jie Jiang | c99d3be | 2024-06-15 06:41:36 | [diff] [blame] | 190 | |
Hugo Benichi | 4b7db06 | 2024-05-22 07:37:51 | [diff] [blame] | 191 | DownstreamNetworkService* downstream_network_service() { |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 192 | return &downstream_network_svc_; |
Hugo Benichi | 4b7db06 | 2024-05-22 07:37:51 | [diff] [blame] | 193 | } |
Hugo Benichi | 00a001b | 2024-05-22 07:37:12 | [diff] [blame] | 194 | |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 195 | private: |
Chuwei He | bd0dec7 | 2023-04-13 07:39:25 | [diff] [blame] | 196 | friend class ManagerTest; |
| 197 | |
Taoyu Li | 8dcef8a | 2024-01-31 07:55:02 | [diff] [blame] | 198 | // The initialization tasks that are not necessary for handling dbus methods. |
Jie Jiang | fbd181e | 2024-03-08 02:12:40 | [diff] [blame] | 199 | void RunDelayedInitialization(); |
Taoyu Li | 8dcef8a | 2024-01-31 07:55:02 | [diff] [blame] | 200 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 201 | // Callbacks from |shill_client_|. |
Jason Jeremy Iman | b6a1893 | 2021-07-27 06:22:14 | [diff] [blame] | 202 | void OnShillDefaultLogicalDeviceChanged( |
Hugo Benichi | f880350 | 2023-06-29 11:12:42 | [diff] [blame] | 203 | const ShillClient::Device* new_device, |
| 204 | const ShillClient::Device* prev_device); |
Jason Jeremy Iman | 6a7c395 | 2021-07-05 14:15:10 | [diff] [blame] | 205 | void OnShillDefaultPhysicalDeviceChanged( |
Hugo Benichi | f880350 | 2023-06-29 11:12:42 | [diff] [blame] | 206 | const ShillClient::Device* new_device, |
| 207 | const ShillClient::Device* prev_device); |
Hugo Benichi | 93c556c | 2023-05-23 02:56:38 | [diff] [blame] | 208 | void OnShillDevicesChanged(const std::vector<ShillClient::Device>& added, |
| 209 | const std::vector<ShillClient::Device>& removed); |
Hugo Benichi | 9a2f91a | 2023-05-23 02:43:02 | [diff] [blame] | 210 | void OnIPConfigsChanged(const ShillClient::Device& shill_device); |
Hugo Benichi | d7abeca | 2023-05-23 01:08:56 | [diff] [blame] | 211 | void OnIPv6NetworkChanged(const ShillClient::Device& shill_device); |
Jie Jiang | 09104cc | 2024-09-08 06:03:42 | [diff] [blame] | 212 | void OnDoHProvidersChanged(); |
Garrick Evans | 209a80a | 2020-11-30 05:42:40 | [diff] [blame] | 213 | |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 214 | // Callback from |network_monitor_svc_|. |
Jie Jiang | 25c1b97 | 2020-11-12 06:42:53 | [diff] [blame] | 215 | void OnNeighborReachabilityEvent( |
| 216 | int ifindex, |
Chih-Yu Huang | 3e5aca2 | 2023-07-03 04:34:39 | [diff] [blame] | 217 | const net_base::IPAddress& ip_addr, |
Jie Jiang | 25c1b97 | 2020-11-12 06:42:53 | [diff] [blame] | 218 | NeighborLinkMonitor::NeighborRole role, |
| 219 | NeighborReachabilityEventSignal::EventType event_type); |
Jie Jiang | 8496685 | 2020-09-18 09:49:05 | [diff] [blame] | 220 | |
Hugo Benichi | 44d11a3 | 2024-04-29 14:18:55 | [diff] [blame] | 221 | // Tears down a ConnectedNamespace setup given its connected namespace id. |
| 222 | void OnConnectedNamespaceAutoclose(int connected_namespace_id); |
| 223 | // Tears down a DNS redirection rule request given the lifeline fd value |
| 224 | // committed by the client dns-proxy instance. |
| 225 | void OnDnsRedirectionRulesAutoclose(int lifeline_fd); |
Hugo Benichi | adf1ec5 | 2020-01-17 07:23:58 | [diff] [blame] | 226 | |
Hugo Benichi | c911b75 | 2023-07-31 04:02:19 | [diff] [blame] | 227 | const CrostiniService::CrostiniDevice* StartCrosVm( |
| 228 | uint64_t vm_id, |
| 229 | CrostiniService::VMType vm_type, |
| 230 | uint32_t subnet_index = kAnySubnetIndex); |
Taoyu Li | 73d63a0 | 2023-09-28 04:33:23 | [diff] [blame] | 231 | void StopCrosVm(uint64_t vm_id, CrostiniService::VMType vm_type); |
Jason Jeremy Iman | 58b7091 | 2021-04-22 21:15:52 | [diff] [blame] | 232 | |
Chih-Yu Huang | 26eee6e | 2023-06-08 06:08:22 | [diff] [blame] | 233 | std::vector<DownstreamClientInfo> GetDownstreamClientInfo( |
Chuwei He | ca57f7e | 2024-05-30 05:41:14 | [diff] [blame] | 234 | std::string_view downstream_ifname) const; |
Chih-Yu Huang | 26eee6e | 2023-06-08 06:08:22 | [diff] [blame] | 235 | |
Jason Jeremy Iman | a183d7a | 2021-08-05 16:35:40 | [diff] [blame] | 236 | // Disable and re-enable IPv6 inside a namespace. |
Chuwei He | ca57f7e | 2024-05-30 05:41:14 | [diff] [blame] | 237 | void RestartIPv6(std::string_view netns_name); |
Jason Jeremy Iman | a183d7a | 2021-08-05 16:35:40 | [diff] [blame] | 238 | |
Garrick Evans | e94a14e | 2019-11-11 01:32:13 | [diff] [blame] | 239 | // Dispatch |msg| to child processes. |
| 240 | void SendGuestMessage(const GuestMessage& msg); |
Garrick Evans | 96e0304 | 2019-05-28 05:30:52 | [diff] [blame] | 241 | |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 242 | // The factory of the WeakPtr. Declare it at the beginning to make the |
| 243 | // following services able to use it. |
| 244 | // Note: We should invalidate the WeakPtr manually before releasing the |
| 245 | // following services. |
| 246 | base::WeakPtrFactory<Manager> weak_factory_{this}; |
| 247 | |
Hugo Benichi | 40a71b9 | 2024-04-23 06:05:03 | [diff] [blame] | 248 | // patchpanel::System shared for all subsystems, owned by PatchpanelDaemon. |
Chih-Yu Huang | 26eee6e | 2023-06-08 06:08:22 | [diff] [blame] | 249 | System* system_; |
Hugo Benichi | 00a001b | 2024-05-22 07:37:12 | [diff] [blame] | 250 | // UMA metrics client. Owned by PatchpanelDaemon. |
Chih-Yu Huang | 19e4982 | 2023-06-23 08:17:55 | [diff] [blame] | 251 | MetricsLibraryInterface* metrics_; |
Chih-Yu Huang | 77d53dd | 2023-03-31 08:52:56 | [diff] [blame] | 252 | // The client of the Manager. |
Hugo Benichi | 8b891a6 | 2023-09-05 06:33:45 | [diff] [blame] | 253 | DbusClientNotifier* dbus_client_notifier_; |
Hugo Benichi | a85c0db | 2021-11-01 05:20:37 | [diff] [blame] | 254 | // Shill Dbus client. |
Garrick Evans | 69b8587 | 2020-02-04 02:40:26 | [diff] [blame] | 255 | std::unique_ptr<ShillClient> shill_client_; |
Chih-Yu Huang | 26eee6e | 2023-06-08 06:08:22 | [diff] [blame] | 256 | // rtnetlink client. |
| 257 | std::unique_ptr<RTNLClient> rtnl_client_; |
| 258 | |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 259 | // IPv4 prefix and address manager. |
| 260 | AddressManager addr_mgr_; |
| 261 | // LifelineFD management service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 262 | LifelineFDService lifeline_fd_svc_; |
Hugo Benichi | a85c0db | 2021-11-01 05:20:37 | [diff] [blame] | 263 | // adb connection forwarder service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 264 | SubprocessController adb_proxy_; |
Hugo Benichi | a85c0db | 2021-11-01 05:20:37 | [diff] [blame] | 265 | // IPv4 and IPv6 Multicast forwarder service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 266 | SubprocessController mcast_proxy_; |
Taoyu Li | 0093a58 | 2022-07-13 09:29:22 | [diff] [blame] | 267 | // IPv6 neighbor discovery forwarder process handler. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 268 | SubprocessController nd_proxy_; |
Damien Dejean | c3f94d6 | 2024-04-12 07:47:50 | [diff] [blame] | 269 | // Socket service process handler. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 270 | SubprocessController socket_service_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 271 | // High level routing and iptables controller service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 272 | Datapath datapath_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 273 | // Routing service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 274 | RoutingService routing_svc_; |
Chih-Yu Huang | 5e114cb | 2024-07-25 02:41:08 | [diff] [blame] | 275 | // Conntrack monitor. |
| 276 | ConntrackMonitor conntrack_monitor_; |
Hugo Benichi | a85c0db | 2021-11-01 05:20:37 | [diff] [blame] | 277 | // Traffic counter service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 278 | CountersService counters_svc_; |
Chuwei He | e1c068a | 2023-06-02 02:51:34 | [diff] [blame] | 279 | // Multicast packet counter service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 280 | MulticastCountersService multicast_counters_svc_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 281 | // Fetches and reports multicast packet count to UMA metrics. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 282 | MulticastMetrics multicast_metrics_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 283 | // IPv6 address provisioning / ndp forwarding service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 284 | GuestIPv6Service ipv6_svc_; |
Jie Jiang | 1d64627 | 2023-08-23 04:26:20 | [diff] [blame] | 285 | // QoS service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 286 | QoSService qos_svc_; |
Hugo Benichi | 00a001b | 2024-05-22 07:37:12 | [diff] [blame] | 287 | // TetheredNetwork and LocalOnlyNetwork management service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 288 | DownstreamNetworkService downstream_network_svc_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 289 | // ARC++/ARCVM service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 290 | ArcService arc_svc_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 291 | // Crostini and other VM service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 292 | CrostiniService cros_svc_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 293 | // L2 neighbor monitor service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 294 | NetworkMonitorService network_monitor_svc_; |
Chih-Yu Huang | 11c6d09 | 2024-07-17 08:53:05 | [diff] [blame] | 295 | // CLAT service. |
Chih-Yu Huang | 9cd750a | 2024-07-18 04:58:22 | [diff] [blame] | 296 | ClatService clat_svc_; |
Garrick Evans | f4a9329 | 2019-03-13 05:19:43 | [diff] [blame] | 297 | |
Hugo Benichi | adf1ec5 | 2020-01-17 07:23:58 | [diff] [blame] | 298 | // All namespaces currently connected through patchpanel ConnectNamespace |
Hugo Benichi | 44d11a3 | 2024-04-29 14:18:55 | [diff] [blame] | 299 | // API, keyed by the the namespace id of the ConnectedNamespace. |
Hugo Benichi | fcf8102 | 2020-12-04 02:01:37 | [diff] [blame] | 300 | std::map<int, ConnectedNamespace> connected_namespaces_; |
Hugo Benichi | adf1ec5 | 2020-01-17 07:23:58 | [diff] [blame] | 301 | int connected_namespaces_next_id_{0}; |
Jason Jeremy Iman | 58b7091 | 2021-04-22 21:15:52 | [diff] [blame] | 302 | |
Jason Jeremy Iman | 880a22f | 2022-07-13 05:51:55 | [diff] [blame] | 303 | // DNS proxy's IPv4 and IPv6 addresses keyed by its guest interface. |
Chih-Yu Huang | 1bacdd3 | 2023-06-27 03:46:10 | [diff] [blame] | 304 | std::map<std::string, net_base::IPv4Address> dns_proxy_ipv4_addrs_; |
| 305 | std::map<std::string, net_base::IPv6Address> dns_proxy_ipv6_addrs_; |
Jason Jeremy Iman | 880a22f | 2022-07-13 05:51:55 | [diff] [blame] | 306 | |
Jason Jeremy Iman | 58b7091 | 2021-04-22 21:15:52 | [diff] [blame] | 307 | // All rules currently created through patchpanel RedirectDns |
Hugo Benichi | 44d11a3 | 2024-04-29 14:18:55 | [diff] [blame] | 308 | // API, keyed by the host-side interface name of the ConnectedNamespace of the |
| 309 | // target dns-proxy instance to which the queries should be redirected. |
Jason Jeremy Iman | 58b7091 | 2021-04-22 21:15:52 | [diff] [blame] | 310 | std::map<int, DnsRedirectionRule> dns_redirection_rules_; |
Kevin Cernekee | 95d4ae9 | 2016-06-19 17:26:29 | [diff] [blame] | 311 | }; |
| 312 | |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 313 | } // namespace patchpanel |
Garrick Evans | 3388a03 | 2020-03-24 02:25:55 | [diff] [blame] | 314 | #endif // PATCHPANEL_MANAGER_H_ |