diff options
author | Susant Sahani <ssahani@gmail.com> | 2015-11-10 09:26:38 +0530 |
---|---|---|
committer | Susant Sahani <ssahani@gmail.com> | 2015-11-10 09:26:38 +0530 |
commit | b69c318040acaefdd02a710998676312d764040b (patch) | |
tree | 99022516c48f7c7daf1e4328f71d6f978268b134 /src/network/networkd-link.c | |
parent | 89c22dc342548ba2596157caa72356efb26f4bfd (diff) |
networkd: Add support to configure IPV6 hop limit
This patch adds support to configure IPV6 hop limit.
For example:
/proc/sys/net/ipv6/conf/wlp3s0/hop_limit
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r-- | src/network/networkd-link.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 46979ffa12..13d2fc6d0d 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1952,6 +1952,37 @@ static int link_set_ipv6_dad_transmits(Link *link) { return 0; } +static int link_set_ipv6_hop_limit(Link *link) { + char buf[DECIMAL_STR_MAX(unsigned) + 1]; + const char *p = NULL; + int r; + + /* Make this a NOP if IPv6 is not available */ + if (!socket_ipv6_is_supported()) + return 0; + + if (link->flags & IFF_LOOPBACK) + return 0; + + if (link->network->ipv6_hop_limit < 0) + return 0; + + p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/hop_limit"); + + xsprintf(buf, "%u", link->network->ipv6_hop_limit); + + r = write_string_file(p, buf, 0); + if (r < 0) { + /* If the right value is set anyway, don't complain */ + if (verify_one_line_file(p, buf) > 0) + return 0; + + log_link_warning_errno(link, r, "Cannot set IPv6 hop limit for interface: %m"); + } + + return 0; +} + static int link_configure(Link *link) { int r; @@ -1983,6 +2014,10 @@ static int link_configure(Link *link) { if (r < 0) return r; + r = link_set_ipv6_hop_limit(link); + if (r < 0) + return r; + if (link_ipv4ll_enabled(link)) { r = ipv4ll_configure(link); if (r < 0) |