summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@gmail.com>2015-09-12 08:18:06 +0530
committerSusant Sahani <ssahani@gmail.com>2015-09-12 08:18:06 +0530
commit4f2e437ad7b04bc0690d1f8202577cbf47acb215 (patch)
tree8668cc0f846a32e7211229b043c502cd40e40c64 /src/network/networkd-link.c
parentf24aa148ab793054a5a29e0e16c5ad9b3f7da93e (diff)
networkd:add support to configure ipv6 acceprt ra
This patch support to configure the ipv6 acceprt ra option. for more information see http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/proc-sys-net-ipv6..html
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9d4a69b0db..215c47b8af 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1789,6 +1789,45 @@ static int link_set_ipv6_privacy_extensions(Link *link) {
return 0;
}
+static int link_set_ipv6_accept_ra(Link *link) {
+ const char *p = NULL, *v = NULL;
+ bool b;
+ 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 unset check the ip forwarding setting maintained for the interface
+ * and then set it to depending on that. enabled if local forwarding
+ * is disabled. disabled if local forwarding is enabled.
+ */
+ if (link->network->ipv6_accept_ra < 0) {
+ if (IN_SET(link->network->ip_forward, ADDRESS_FAMILY_YES, ADDRESS_FAMILY_IPV6))
+ b = false;
+ else
+ b = true;
+ } else
+ b = link->network->ipv6_accept_ra;
+
+ p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/accept_ra");
+ v = one_zero(b);
+
+ r = write_string_file(p, v, 0);
+ if (r < 0) {
+ /* If the right value is set anyway, don't complain */
+ if (verify_one_line_file(p, v) > 0)
+ return 0;
+
+ log_link_warning_errno(link, r, "Cannot configure IPv6 accept_ra for interface: %m");
+ }
+
+ return 0;
+}
+
static int link_configure(Link *link) {
int r;
@@ -1812,6 +1851,10 @@ static int link_configure(Link *link) {
if (r < 0)
return r;
+ r = link_set_ipv6_accept_ra(link);
+ if (r < 0)
+ return r;
+
if (link_ipv4ll_enabled(link)) {
r = ipv4ll_configure(link);
if (r < 0)