From 826a3602d834a08b76ffe2219587e1a399b21b9b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 18 Feb 2019 14:47:13 +0900 Subject: [PATCH] network: use sysctl_read_ip_property() --- src/network/networkd-link.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 267b9c6..4bfa610 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1907,20 +1907,12 @@ static int link_configure_addrgen_mode(Link *link) { if (!link_ipv6ll_enabled(link)) ipv6ll_mode = IN6_ADDR_GEN_MODE_NONE; - else { - const char *p = NULL; - _cleanup_free_ char *stable_secret = NULL; - - p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/stable_secret"); - + else if (sysctl_read_ip_property(AF_INET6, link->ifname, "stable_secret", NULL) < 0) /* The file may not exist. And event if it exists, when stable_secret is unset, - * then reading the file fails and EIO is returned. */ - r = read_one_line_file(p, &stable_secret); - if (r < 0) - ipv6ll_mode = IN6_ADDR_GEN_MODE_EUI64; - else - ipv6ll_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY; - } + * reading the file fails with EIO. */ + ipv6ll_mode = IN6_ADDR_GEN_MODE_EUI64; + else + ipv6ll_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY; r = sd_netlink_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode); if (r < 0) -- 2.7.4