mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 13:59:24 +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:
parent
927a3dc322
commit
cfde6c3f55
@ -436,6 +436,8 @@ static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig,
|
|||||||
{
|
{
|
||||||
const struct l_dhcp_lease *lease;
|
const struct l_dhcp_lease *lease;
|
||||||
char *gateway;
|
char *gateway;
|
||||||
|
const struct ie_fils_ip_addr_response_info *fils =
|
||||||
|
netconfig->fils_override;
|
||||||
|
|
||||||
switch (netconfig->rtm_protocol) {
|
switch (netconfig->rtm_protocol) {
|
||||||
case RTPROT_STATIC:
|
case RTPROT_STATIC:
|
||||||
@ -449,15 +451,12 @@ static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig,
|
|||||||
return gateway;
|
return gateway;
|
||||||
|
|
||||||
case RTPROT_DHCP:
|
case RTPROT_DHCP:
|
||||||
if (netconfig->fils_override &&
|
if (fils && fils->ipv4_gateway) {
|
||||||
netconfig->fils_override->ipv4_gateway) {
|
gateway = netconfig_ipv4_to_string(fils->ipv4_gateway);
|
||||||
gateway = netconfig_ipv4_to_string(
|
|
||||||
netconfig->fils_override->ipv4_gateway);
|
|
||||||
|
|
||||||
if (gateway && !l_memeqzero(netconfig->fils_override->
|
if (gateway && out_mac &&
|
||||||
ipv4_gateway_mac, 6))
|
!l_memeqzero(fils->ipv4_gateway_mac, 6))
|
||||||
*out_mac = netconfig->fils_override->
|
*out_mac = fils->ipv4_gateway_mac;
|
||||||
ipv4_gateway_mac;
|
|
||||||
|
|
||||||
return gateway;
|
return gateway;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user