summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-05-18 07:00:48 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-06-07 23:33:27 +0200
commitd8350b60e084baa614765e4eb7634177a8a327f9 (patch)
tree56913b68f14f3f551d888d5650f3c5e5b99b2b5a
parentnetwork: introduce network_adjust_ipv6_proxy_ndp() (diff)
downloadsystemd-d8350b60e084baa614765e4eb7634177a8a327f9.tar.xz
systemd-d8350b60e084baa614765e4eb7634177a8a327f9.zip
network: move logic for setting proxy_ndp sysctl to networkd-sysctl.c
-rw-r--r--src/network/networkd-ipv6-proxy-ndp.c40
-rw-r--r--src/network/networkd-sysctl.c26
2 files changed, 26 insertions, 40 deletions
diff --git a/src/network/networkd-ipv6-proxy-ndp.c b/src/network/networkd-ipv6-proxy-ndp.c
index 897447a20c..df96d8ac9c 100644
--- a/src/network/networkd-ipv6-proxy-ndp.c
+++ b/src/network/networkd-ipv6-proxy-ndp.c
@@ -10,7 +10,6 @@
#include "networkd-network.h"
#include "socket-util.h"
#include "string-util.h"
-#include "sysctl-util.h"
void network_adjust_ipv6_proxy_ndp(Network *network) {
assert(network);
@@ -70,40 +69,6 @@ static int ipv6_proxy_ndp_address_configure(Link *link, const struct in6_addr *a
return 0;
}
-static bool ipv6_proxy_ndp_is_needed(Link *link) {
- assert(link);
-
- if (link->flags & IFF_LOOPBACK)
- return false;
-
- if (!link->network)
- return false;
-
- if (link->network->ipv6_proxy_ndp >= 0)
- return link->network->ipv6_proxy_ndp;
-
- return !set_isempty(link->network->ipv6_proxy_ndp_addresses);
-}
-
-static int ipv6_proxy_ndp_set(Link *link) {
- bool v;
- int r;
-
- assert(link);
-
- if (!socket_ipv6_is_supported())
- return 0;
-
- v = ipv6_proxy_ndp_is_needed(link);
-
- r = sysctl_write_ip_property_boolean(AF_INET6, link->ifname, "proxy_ndp", v);
- if (r < 0)
- return log_link_warning_errno(link, r, "Cannot configure proxy NDP for the interface, ignoring: %m");
-
- return v;
-}
-
-/* configure all ipv6 proxy ndp addresses */
int link_set_ipv6_proxy_ndp_addresses(Link *link) {
struct in6_addr *address;
int r;
@@ -111,11 +76,6 @@ int link_set_ipv6_proxy_ndp_addresses(Link *link) {
assert(link);
assert(link->network);
- /* enable or disable proxy_ndp itself depending on whether ipv6_proxy_ndp_addresses are set or not */
- r = ipv6_proxy_ndp_set(link);
- if (r <= 0)
- return 0;
-
SET_FOREACH(address, link->network->ipv6_proxy_ndp_addresses) {
r = ipv6_proxy_ndp_address_configure(link, address);
if (r < 0)
diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c
index 11681286e0..7ce92a17a4 100644
--- a/src/network/networkd-sysctl.c
+++ b/src/network/networkd-sysctl.c
@@ -161,6 +161,28 @@ static int link_set_ipv6_hop_limit(Link *link) {
return sysctl_write_ip_property_int(AF_INET6, link->ifname, "hop_limit", link->network->ipv6_hop_limit);
}
+static int link_set_ipv6_proxy_ndp(Link *link) {
+ bool v;
+
+ assert(link);
+
+ if (!socket_ipv6_is_supported())
+ return 0;
+
+ if (link->flags & IFF_LOOPBACK)
+ return 0;
+
+ if (!link->network)
+ return 0;
+
+ if (link->network->ipv6_proxy_ndp >= 0)
+ v = link->network->ipv6_proxy_ndp;
+ else
+ v = !set_isempty(link->network->ipv6_proxy_ndp_addresses);
+
+ return sysctl_write_ip_property_boolean(AF_INET6, link->ifname, "proxy_ndp", v);
+}
+
static int link_set_ipv4_accept_local(Link *link) {
assert(link);
@@ -224,6 +246,10 @@ int link_set_sysctl(Link *link) {
if (r < 0)
log_link_warning_errno(link, r, "Cannot set IPv6 hop limit for interface, ignoring: %m");
+ r = link_set_ipv6_proxy_ndp(link);
+ if (r < 0)
+ log_link_warning_errno(link, r, "Cannot set IPv6 proxy NDP, ignoring: %m");
+
r = link_set_ipv4_accept_local(link);
if (r < 0)
log_link_warning_errno(link, r, "Cannot set IPv4 accept_local flag for interface, ignoring: %m");