Commit 05e67af0 authored by Hugo Benichi's avatar Hugo Benichi Committed by Commit Bot

arc: net: deprecate usage of arc::mojom::IPConfiguration

Also do not consider shill::kIPConfigProperty as a possible IP
configuration dictionary. This is instead always a single string or a
list of string referring to DBus path strings of IP configuration
objects and therefore never contains immediately useful properties.

BUG=b:143258259
BUG=b:145960788
TEST=Compiled. Flashed eve, checked ARC++ connectivity for various types
of networks.

Change-Id: I330edf9e2cd747252cd81a00b883f6f6094c88ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217686Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Hugo Benichi <hugobenichi@google.com>
Auto-Submit: Hugo Benichi <hugobenichi@google.com>
Cr-Commit-Position: refs/heads/master@{#781856}
parent 936e436f
...@@ -92,7 +92,8 @@ enum IPAddressType { ...@@ -92,7 +92,8 @@ enum IPAddressType {
IPV6, IPV6,
}; };
// Layer 3 and proxy configuration information for an IP network. // Deprecated. Individual fields added to NetworkConfiguration in version 13 of
// this file should be used instead.
struct IPConfiguration { struct IPConfiguration {
// Literal representation of the IP address of the ARC gateway. // Literal representation of the IP address of the ARC gateway.
...@@ -190,8 +191,9 @@ struct NetworkConfiguration { ...@@ -190,8 +191,9 @@ struct NetworkConfiguration {
// A string token that uniquely identifies this network service. // A string token that uniquely identifies this network service.
string guid; string guid;
// IP configuration for the network service inside ARC. // Deprecated. Individual fields added to NetworkConfiguration in version 13
array<IPConfiguration>? ip_configs; // of this file should be used instead.
array<IPConfiguration>? deprecated_ip_configs;
// Deprecated field unused from ARC P and later. // Deprecated field unused from ARC P and later.
string? deprecated_mac_address; string? deprecated_mac_address;
......
...@@ -135,41 +135,32 @@ arc::mojom::NetworkType TranslateNetworkType(const std::string& type) { ...@@ -135,41 +135,32 @@ arc::mojom::NetworkType TranslateNetworkType(const std::string& type) {
return arc::mojom::NetworkType::ETHERNET; return arc::mojom::NetworkType::ETHERNET;
} }
// Parse a shill IPConfig dictionary and appends the resulting mojo // Parses a shill IPConfig dictionary and adds the relevant fields to
// IPConfiguration object to the given |ip_configs| vector, only if the // the given |network| NetworkConfiguration object.
// IPConfig dictionary contains an address and a gateway property.
// TODO(b/143258259) Stop setting IPConfiguration objects once ARC has
// migrated to the new IP configuration fields introduced in Change-Id
// I08dfd5daa9ba2946a847e555bb94a01da3866eb9.
void AddIpConfiguration(arc::mojom::NetworkConfiguration* network, void AddIpConfiguration(arc::mojom::NetworkConfiguration* network,
const base::Value* shill_ipconfig) { const base::Value* shill_ipconfig) {
if (!shill_ipconfig || !shill_ipconfig->is_dict()) if (!shill_ipconfig || !shill_ipconfig->is_dict())
return; return;
auto ip_config = arc::mojom::IPConfiguration::New(); // Only set the IP address and gateway if both are defined and non empty.
if (const auto* address_property = const auto* address = shill_ipconfig->FindStringPath(shill::kAddressProperty);
shill_ipconfig->FindStringPath(shill::kAddressProperty)) { const auto* gateway = shill_ipconfig->FindStringPath(shill::kGatewayProperty);
ip_config->ip_address = *address_property; const int prefixlen =
}
if (ip_config->ip_address.empty())
return;
if (const auto* gateway_property =
shill_ipconfig->FindStringPath(shill::kGatewayProperty)) {
ip_config->gateway = *gateway_property;
}
if (ip_config->gateway.empty())
return;
ip_config->routing_prefix =
shill_ipconfig->FindIntPath(shill::kPrefixlenProperty).value_or(0); shill_ipconfig->FindIntPath(shill::kPrefixlenProperty).value_or(0);
if (address && !address->empty() && gateway && !gateway->empty()) {
if (prefixlen < 64) {
network->host_ipv4_prefix_length = prefixlen;
network->host_ipv4_address = *address;
network->host_ipv4_gateway = *gateway;
} else {
network->host_ipv6_prefix_length = prefixlen;
network->host_ipv6_global_addresses->push_back(*address);
network->host_ipv6_gateway = *gateway;
}
}
ip_config->type = (ip_config->routing_prefix < 64) // If the user has overridden DNS with the "Google nameservers" UI options,
? arc::mojom::IPAddressType::IPV4 // the kStaticIPConfigProperty object will be empty except for DNS addresses.
: arc::mojom::IPAddressType::IPV6;
if (const auto* dns_list = if (const auto* dns_list =
shill_ipconfig->FindListKey(shill::kNameServersProperty)) { shill_ipconfig->FindListKey(shill::kNameServersProperty)) {
for (const auto& dns_value : dns_list->GetList()) { for (const auto& dns_value : dns_list->GetList()) {
...@@ -182,30 +173,10 @@ void AddIpConfiguration(arc::mojom::NetworkConfiguration* network, ...@@ -182,30 +173,10 @@ void AddIpConfiguration(arc::mojom::NetworkConfiguration* network,
if (dns == "0.0.0.0") if (dns == "0.0.0.0")
continue; continue;
ip_config->name_servers.push_back(dns);
network->host_dns_addresses->push_back(dns); network->host_dns_addresses->push_back(dns);
} }
} }
switch (ip_config->type) {
case arc::mojom::IPAddressType::IPV4: {
network->host_ipv4_prefix_length = ip_config->routing_prefix;
network->host_ipv4_address = ip_config->ip_address;
network->host_ipv4_gateway = ip_config->gateway;
break;
}
case arc::mojom::IPAddressType::IPV6: {
network->host_ipv6_prefix_length = ip_config->routing_prefix;
network->host_ipv6_global_addresses->push_back(ip_config->ip_address);
network->host_ipv6_gateway = ip_config->gateway;
break;
}
default: {
NOTREACHED() << "No IPAddressType defined";
break;
}
}
if (const auto* domains = if (const auto* domains =
shill_ipconfig->FindKey(shill::kSearchDomainsProperty)) { shill_ipconfig->FindKey(shill::kSearchDomainsProperty)) {
if (domains->is_list()) { if (domains->is_list()) {
...@@ -217,8 +188,6 @@ void AddIpConfiguration(arc::mojom::NetworkConfiguration* network, ...@@ -217,8 +188,6 @@ void AddIpConfiguration(arc::mojom::NetworkConfiguration* network,
const int mtu = shill_ipconfig->FindIntPath(shill::kMtuProperty).value_or(0); const int mtu = shill_ipconfig->FindIntPath(shill::kMtuProperty).value_or(0);
if (mtu > 0) if (mtu > 0)
network->host_mtu = mtu; network->host_mtu = mtu;
network->ip_configs->push_back(std::move(ip_config));
} }
arc::mojom::NetworkConfigurationPtr TranslateNetworkProperties( arc::mojom::NetworkConfigurationPtr TranslateNetworkProperties(
...@@ -226,7 +195,6 @@ arc::mojom::NetworkConfigurationPtr TranslateNetworkProperties( ...@@ -226,7 +195,6 @@ arc::mojom::NetworkConfigurationPtr TranslateNetworkProperties(
const base::Value* shill_dict) { const base::Value* shill_dict) {
auto mojo = arc::mojom::NetworkConfiguration::New(); auto mojo = arc::mojom::NetworkConfiguration::New();
// Initialize optional array fields to avoid null guards both here and in ARC. // Initialize optional array fields to avoid null guards both here and in ARC.
mojo->ip_configs = std::vector<arc::mojom::IPConfigurationPtr>();
mojo->host_ipv6_global_addresses = std::vector<std::string>(); mojo->host_ipv6_global_addresses = std::vector<std::string>();
mojo->host_search_domains = std::vector<std::string>(); mojo->host_search_domains = std::vector<std::string>();
mojo->host_dns_addresses = std::vector<std::string>(); mojo->host_dns_addresses = std::vector<std::string>();
...@@ -264,11 +232,7 @@ arc::mojom::NetworkConfigurationPtr TranslateNetworkProperties( ...@@ -264,11 +232,7 @@ arc::mojom::NetworkConfigurationPtr TranslateNetworkProperties(
if (shill_dict) { if (shill_dict) {
for (const auto* property : for (const auto* property :
{shill::kIPConfigProperty, shill::kStaticIPConfigProperty, {shill::kStaticIPConfigProperty, shill::kSavedIPConfigProperty}) {
shill::kSavedIPConfigProperty}) {
if (!mojo->ip_configs->empty())
break;
AddIpConfiguration(mojo.get(), shill_dict->FindKey(property)); AddIpConfiguration(mojo.get(), shill_dict->FindKey(property));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment