mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-18 06:03:42 +03:00
networkd: rearrange checks when to write something into sysctl a bit
Move check whether ipv6 is available into link_ipv6_privacy_extensions() to keep it as internal and early as possible. Always check if there's a network attached to a link before we apply sysctls. We do this for most of the sysctl functions already, with this change we do it for all.
This commit is contained in:
parent
66a6bd6897
commit
d68e2e59b3
@ -147,6 +147,10 @@ bool link_ipv6_accept_ra_enabled(Link *link) {
|
||||
}
|
||||
|
||||
static IPv6PrivacyExtensions link_ipv6_privacy_extensions(Link *link) {
|
||||
|
||||
if (!socket_ipv6_is_supported())
|
||||
return _IPV6_PRIVACY_EXTENSIONS_INVALID;
|
||||
|
||||
if (link->flags & IFF_LOOPBACK)
|
||||
return _IPV6_PRIVACY_EXTENSIONS_INVALID;
|
||||
|
||||
@ -1896,10 +1900,6 @@ static int link_set_ipv6_privacy_extensions(Link *link) {
|
||||
const char *p = NULL;
|
||||
int r;
|
||||
|
||||
/* Make this a NOP if IPv6 is not available */
|
||||
if (!socket_ipv6_is_supported())
|
||||
return 0;
|
||||
|
||||
s = link_ipv6_privacy_extensions(link);
|
||||
if (s < 0)
|
||||
return 0;
|
||||
@ -1925,6 +1925,9 @@ static int link_set_ipv6_accept_ra(Link *link) {
|
||||
if (link->flags & IFF_LOOPBACK)
|
||||
return 0;
|
||||
|
||||
if (!link->network)
|
||||
return 0;
|
||||
|
||||
p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/accept_ra");
|
||||
|
||||
/* We handle router advertisments ourselves, tell the kernel to GTFO */
|
||||
@ -1947,6 +1950,9 @@ static int link_set_ipv6_dad_transmits(Link *link) {
|
||||
if (link->flags & IFF_LOOPBACK)
|
||||
return 0;
|
||||
|
||||
if (!link->network)
|
||||
return 0;
|
||||
|
||||
if (link->network->ipv6_dad_transmits < 0)
|
||||
return 0;
|
||||
|
||||
@ -1972,6 +1978,9 @@ static int link_set_ipv6_hop_limit(Link *link) {
|
||||
if (link->flags & IFF_LOOPBACK)
|
||||
return 0;
|
||||
|
||||
if (!link->network)
|
||||
return 0;
|
||||
|
||||
if (link->network->ipv6_hop_limit < 0)
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user