mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
netconfig: Split ipv4 route setters
Split this function into two, one for setting the gateway route and one for setting the subnet route.
This commit is contained in:
parent
76c41775fb
commit
5e7949c144
@ -813,10 +813,8 @@ static void netconfig_route6_add_cb(int error, uint16_t type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool netconfig_ipv4_routes_install(struct netconfig *netconfig)
|
static bool netconfig_ipv4_subnet_route_install(struct netconfig *netconfig)
|
||||||
{
|
{
|
||||||
L_AUTO_FREE_VAR(char *, gateway) = NULL;
|
|
||||||
const uint8_t *gateway_mac = NULL;
|
|
||||||
struct in_addr in_addr;
|
struct in_addr in_addr;
|
||||||
char ip[INET_ADDRSTRLEN];
|
char ip[INET_ADDRSTRLEN];
|
||||||
char network[INET_ADDRSTRLEN];
|
char network[INET_ADDRSTRLEN];
|
||||||
@ -839,10 +837,19 @@ static bool netconfig_ipv4_routes_install(struct netconfig *netconfig)
|
|||||||
netconfig_route_generic_cb,
|
netconfig_route_generic_cb,
|
||||||
netconfig, NULL)) {
|
netconfig, NULL)) {
|
||||||
l_error("netconfig: Failed to add subnet route.");
|
l_error("netconfig: Failed to add subnet route.");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool netconfig_ipv4_gateway_route_install(struct netconfig *netconfig)
|
||||||
|
{
|
||||||
|
L_AUTO_FREE_VAR(char *, gateway) = NULL;
|
||||||
|
const uint8_t *gateway_mac = NULL;
|
||||||
|
struct in_addr in_addr;
|
||||||
|
char ip[INET_ADDRSTRLEN];
|
||||||
|
|
||||||
gateway = netconfig_ipv4_get_gateway(netconfig, &gateway_mac);
|
gateway = netconfig_ipv4_get_gateway(netconfig, &gateway_mac);
|
||||||
if (!gateway) {
|
if (!gateway) {
|
||||||
l_debug("No gateway obtained from %s.",
|
l_debug("No gateway obtained from %s.",
|
||||||
@ -858,6 +865,10 @@ static bool netconfig_ipv4_routes_install(struct netconfig *netconfig)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!l_rtnl_address_get_address(netconfig->v4_address, ip) ||
|
||||||
|
inet_pton(AF_INET, ip, &in_addr) < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
netconfig->route4_add_gateway_cmd_id =
|
netconfig->route4_add_gateway_cmd_id =
|
||||||
l_rtnl_route4_add_gateway(rtnl, netconfig->ifindex, gateway, ip,
|
l_rtnl_route4_add_gateway(rtnl, netconfig->ifindex, gateway, ip,
|
||||||
ROUTE_PRIORITY_OFFSET,
|
ROUTE_PRIORITY_OFFSET,
|
||||||
@ -871,23 +882,20 @@ static bool netconfig_ipv4_routes_install(struct netconfig *netconfig)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gateway_mac) {
|
/*
|
||||||
/*
|
* Attempt to use the gateway MAC address received from the AP by
|
||||||
* Attempt to use the gateway MAC address received from the AP
|
* writing the mapping directly into the netdev's ARP table so as
|
||||||
* by writing the mapping directly into the netdev's ARP table
|
* to save one data frame roundtrip before first IP connections
|
||||||
* so as to save one data frame roundtrip before first IP
|
* are established. This is very low-priority but print error
|
||||||
* connections are established. This is very low-priority but
|
* messages just because they may indicate bigger problems.
|
||||||
* print error messages just because they may indicate bigger
|
*/
|
||||||
* problems.
|
if (gateway_mac && !l_rtnl_neighbor_set_hwaddr(rtnl, netconfig->ifindex,
|
||||||
*/
|
|
||||||
if (!l_rtnl_neighbor_set_hwaddr(rtnl, netconfig->ifindex,
|
|
||||||
AF_INET,
|
AF_INET,
|
||||||
&netconfig->fils_override->ipv4_gateway,
|
&netconfig->fils_override->ipv4_gateway,
|
||||||
gateway_mac, 6,
|
gateway_mac, 6,
|
||||||
netconfig_set_neighbor_entry_cb, NULL,
|
netconfig_set_neighbor_entry_cb, NULL,
|
||||||
NULL))
|
NULL))
|
||||||
l_debug("l_rtnl_neighbor_set_hwaddr failed");
|
l_debug("l_rtnl_neighbor_set_hwaddr failed");
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -908,10 +916,9 @@ static void netconfig_ipv4_ifaddr_add_cmd_cb(int error, uint16_t type,
|
|||||||
|
|
||||||
netconfig_gateway_to_arp(netconfig);
|
netconfig_gateway_to_arp(netconfig);
|
||||||
|
|
||||||
if (!netconfig_ipv4_routes_install(netconfig)) {
|
if (!netconfig_ipv4_subnet_route_install(netconfig) ||
|
||||||
l_error("netconfig: Failed to install IPv4 routes.");
|
!netconfig_ipv4_gateway_route_install(netconfig))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
netconfig_set_dns(netconfig);
|
netconfig_set_dns(netconfig);
|
||||||
netconfig_set_domains(netconfig);
|
netconfig_set_domains(netconfig);
|
||||||
|
Loading…
Reference in New Issue
Block a user