3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

netconfig: Refactor netconfig_ipv4_get_gateway

Use a separate fils variable to make the code a bit prettier.

Also make sure that the out_mac parameter is not NULL prior to storing
the gateway_mac in it.
This commit is contained in:
Andrew Zaborowski 2021-10-21 10:50:32 +02:00 committed by Denis Kenzior
parent 927a3dc322
commit cfde6c3f55

View File

@ -436,6 +436,8 @@ static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig,
{
const struct l_dhcp_lease *lease;
char *gateway;
const struct ie_fils_ip_addr_response_info *fils =
netconfig->fils_override;
switch (netconfig->rtm_protocol) {
case RTPROT_STATIC:
@ -449,15 +451,12 @@ static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig,
return gateway;
case RTPROT_DHCP:
if (netconfig->fils_override &&
netconfig->fils_override->ipv4_gateway) {
gateway = netconfig_ipv4_to_string(
netconfig->fils_override->ipv4_gateway);
if (fils && fils->ipv4_gateway) {
gateway = netconfig_ipv4_to_string(fils->ipv4_gateway);
if (gateway && !l_memeqzero(netconfig->fils_override->
ipv4_gateway_mac, 6))
*out_mac = netconfig->fils_override->
ipv4_gateway_mac;
if (gateway && out_mac &&
!l_memeqzero(fils->ipv4_gateway_mac, 6))
*out_mac = fils->ipv4_gateway_mac;
return gateway;
}