summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-14 02:42:51 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-15 14:56:42 +0200
commitbafa9641446852f7fa15ca12d08a223d345c78ea (patch)
tree5fb2f36e09a048b61f341ced732ed1a78ac26378 /src
parentMerge pull request #12796 from yuwata/test-network-use-wait-online (diff)
downloadsystemd-bafa9641446852f7fa15ca12d08a223d345c78ea.tar.xz
systemd-bafa9641446852f7fa15ca12d08a223d345c78ea.zip
network: read link specific sysctl value
This introduce link_sysctl_ipv6_enabled() and replaces manager_sysctl_ipv6_enabled() with it.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-address.c2
-rw-r--r--src/network/networkd-fdb.c2
-rw-r--r--src/network/networkd-link.c23
-rw-r--r--src/network/networkd-link.h4
-rw-r--r--src/network/networkd-manager.c17
-rw-r--r--src/network/networkd-manager.h4
-rw-r--r--src/network/networkd-route.c2
-rw-r--r--src/network/networkd-routing-policy-rule.c2
8 files changed, 27 insertions, 29 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 7fe99bc485..e75a49f614 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -566,7 +566,7 @@ int address_configure(
assert(link->manager->rtnl);
assert(callback);
- if (address->family == AF_INET6 && manager_sysctl_ipv6_enabled(link->manager) == 0) {
+ if (address->family == AF_INET6 && link_sysctl_ipv6_enabled(link) == 0) {
log_link_warning(link, "An IPv6 address is requested, but IPv6 is disabled by sysctl, ignoring.");
return 0;
}
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c
index 4cacc44106..e3333698f8 100644
--- a/src/network/networkd-fdb.c
+++ b/src/network/networkd-fdb.c
@@ -124,7 +124,7 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) {
assert(link->manager);
assert(fdb_entry);
- if (fdb_entry->family == AF_INET6 && manager_sysctl_ipv6_enabled(link->manager) == 0) {
+ if (fdb_entry->family == AF_INET6 && link_sysctl_ipv6_enabled(link) == 0) {
log_link_warning(link, "An IPv6 fdb entry is requested, but IPv6 is disabled by sysctl, ignoring.");
return 0;
}
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 115e26e307..67c0903fa6 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -62,6 +62,20 @@ DUID* link_get_duid(Link *link) {
return &link->manager->duid;
}
+int link_sysctl_ipv6_enabled(Link *link) {
+ _cleanup_free_ char *value = NULL;
+ int r;
+
+ r = sysctl_read_ip_property(AF_INET6, link->ifname, "disable_ipv6", &value);
+ if (r < 0)
+ return log_link_warning_errno(link, r,
+ "Failed to read net.ipv6.conf.%s.disable_ipv6 sysctl property: %m",
+ link->ifname);
+
+ link->sysctl_ipv6_enabled = value[0] == '0';
+ return link->sysctl_ipv6_enabled;
+}
+
static bool link_dhcp6_enabled(Link *link) {
assert(link);
@@ -80,7 +94,7 @@ static bool link_dhcp6_enabled(Link *link) {
if (STRPTR_IN_SET(link->kind, "can", "vcan", "vxcan"))
return false;
- if (manager_sysctl_ipv6_enabled(link->manager) == 0)
+ if (link_sysctl_ipv6_enabled(link) == 0)
return false;
return link->network->dhcp & ADDRESS_FAMILY_IPV6;
@@ -166,7 +180,7 @@ static bool link_ipv6ll_enabled(Link *link) {
if (link->network->bond)
return false;
- if (manager_sysctl_ipv6_enabled(link->manager) == 0)
+ if (link_sysctl_ipv6_enabled(link) == 0)
return false;
return link->network->link_local & ADDRESS_FAMILY_IPV6;
@@ -181,7 +195,7 @@ static bool link_ipv6_enabled(Link *link) {
if (link->network->bond)
return false;
- if (manager_sysctl_ipv6_enabled(link->manager) == 0)
+ if (link_sysctl_ipv6_enabled(link) == 0)
return false;
if (STRPTR_IN_SET(link->kind, "can", "vcan", "vxcan"))
@@ -230,7 +244,7 @@ static bool link_ipv6_forward_enabled(Link *link) {
if (link->network->ip_forward == _ADDRESS_FAMILY_BOOLEAN_INVALID)
return false;
- if (manager_sysctl_ipv6_enabled(link->manager) == 0)
+ if (link_sysctl_ipv6_enabled(link) == 0)
return false;
return link->network->ip_forward & ADDRESS_FAMILY_IPV6;
@@ -541,6 +555,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
.rtnl_extended_attrs = true,
.ifindex = ifindex,
.iftype = iftype,
+ .sysctl_ipv6_enabled = -1,
};
link->ifname = strdup(ifname);
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index f2aa504f1f..80fc4baee6 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -126,6 +126,8 @@ typedef struct Link {
/* For speed meter */
struct rtnl_link_stats64 stats_old, stats_new;
bool stats_updated;
+
+ int sysctl_ipv6_enabled;
} Link;
typedef int (*link_netlink_message_handler_t)(sd_netlink*, sd_netlink_message*, Link*);
@@ -192,6 +194,8 @@ uint32_t link_get_dhcp_route_table(Link *link);
uint32_t link_get_ipv6_accept_ra_route_table(Link *link);
int link_request_set_routes(Link *link);
+int link_sysctl_ipv6_enabled(Link *link);
+
#define ADDRESS_FMT_VAL(address) \
be32toh((address).s_addr) >> 24, \
(be32toh((address).s_addr) >> 16) & 0xFFu, \
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index e1f4d7623f..92e3b0a0f1 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -1382,8 +1382,6 @@ int manager_new(Manager **ret) {
if (!m->state_file)
return -ENOMEM;
- m->sysctl_ipv6_enabled = -1;
-
r = sd_event_default(&m->event);
if (r < 0)
return r;
@@ -1886,18 +1884,3 @@ int manager_request_product_uuid(Manager *m, Link *link) {
return 0;
}
-
-int manager_sysctl_ipv6_enabled(Manager *manager) {
- _cleanup_free_ char *value = NULL;
- int r;
-
- if (manager->sysctl_ipv6_enabled >= 0)
- return manager->sysctl_ipv6_enabled;
-
- r = sysctl_read_ip_property(AF_INET6, "all", "disable_ipv6", &value);
- if (r < 0)
- return log_warning_errno(r, "Failed to read net.ipv6.conf.all.disable_ipv6 sysctl property: %m");
-
- manager->sysctl_ipv6_enabled = value[0] == '0';
- return manager->sysctl_ipv6_enabled;
-}
diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h
index c816d86d18..281e9cbac4 100644
--- a/src/network/networkd-manager.h
+++ b/src/network/networkd-manager.h
@@ -55,8 +55,6 @@ struct Manager {
Set *rules_foreign;
Set *rules_saved;
- int sysctl_ipv6_enabled;
-
/* For link speed meter*/
bool use_speed_meter;
sd_event_source *speed_meter_event_source;
@@ -100,6 +98,4 @@ Link *manager_dhcp6_prefix_get(Manager *m, struct in6_addr *addr);
int manager_dhcp6_prefix_add(Manager *m, struct in6_addr *addr, Link *link);
int manager_dhcp6_prefix_remove_all(Manager *m, Link *link);
-int manager_sysctl_ipv6_enabled(Manager *manager);
-
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index b3a3d4134e..cd31548f94 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -500,7 +500,7 @@ int route_configure(
assert(IN_SET(route->family, AF_INET, AF_INET6));
assert(callback);
- if (route->family == AF_INET6 && manager_sysctl_ipv6_enabled(link->manager) == 0) {
+ if (route->family == AF_INET6 && link_sysctl_ipv6_enabled(link) == 0) {
log_link_warning(link, "An IPv6 route is requested, but IPv6 is disabled by sysctl, ignoring.");
return 0;
}
diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c
index be7f2f225b..e4dca83071 100644
--- a/src/network/networkd-routing-policy-rule.c
+++ b/src/network/networkd-routing-policy-rule.c
@@ -484,7 +484,7 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netl
assert(link->manager);
assert(link->manager->rtnl);
- if (rule->family == AF_INET6 && manager_sysctl_ipv6_enabled(link->manager) == 0) {
+ if (rule->family == AF_INET6 && link_sysctl_ipv6_enabled(link) == 0) {
log_link_warning(link, "An IPv6 routing policy rule is requested, but IPv6 is disabled by sysctl, ignoring.");
return 0;
}