Set accept_ra to 2 when enabling IPv6.

The default value of accept_ra causes the kernel to accept
Router Advertisements only if forwarding is off. This causes
problems with clatd, which uses IPv6 forwarding on a tun
interface, and it may cause problems with IPv6 tethering when
we implement it.

Fix this by setting accept_ra to 2, which accepts RAs regardless
of whether forwarding is on.

Bug: 8276725
Change-Id: Ifee0ceaa68ce438a845fa2d7f3b76c60857114a0
diff --git a/InterfaceController.cpp b/InterfaceController.cpp
index c0110be..00ab6d1 100644
--- a/InterfaceController.cpp
+++ b/InterfaceController.cpp
@@ -111,6 +111,13 @@
 }
 
 int InterfaceController::setEnableIPv6(const char *interface, const int on) {
+	// When IPv6 is on, accept RAs regardless of forwarding state.
+	// When IPv6 is off, accept RAs only if forwarding is off (the default).
+	const char *accept_ra = on ? "2" : "1";
+	if (writeIPv6ProcPath(interface, "accept_ra", accept_ra)) {
+		return -1;
+	}
+
 	// When disable_ipv6 changes from 1 to 0, the kernel starts autoconf.
 	// When disable_ipv6 changes from 0 to 1, the kernel clears all autoconf
 	// addresses and routes and disables IPv6 on the interface.