radvd: fix building for x32

Fix is from upstream Gentoo.

BUG=chromium-os:36866
TEST=`emerge-x32-generic radvd` works

Change-Id: Id95f875a9e0bc513bda136d6c62c90fdaf565835
Reviewed-on: https://gerrit.chromium.org/gerrit/45423
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/net-misc/radvd/files/radvd-1.9.2-sysctl.patch b/net-misc/radvd/files/radvd-1.9.2-sysctl.patch
new file mode 100644
index 0000000..e8f8aae
--- /dev/null
+++ b/net-misc/radvd/files/radvd-1.9.2-sysctl.patch
@@ -0,0 +1,85 @@
+From 140c59074c70d7951d046c751b7eaed3cc16946c Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Thu, 14 Mar 2013 10:17:58 -0400
+Subject: [PATCH] check for sys/sysctl.h availability
+
+Newer Linux ports are dropping sysctl support.  If you try to even
+include the header, you'll get build failures:
+/usr/include/bits/sysctl.h:19:3: error: #error "sysctl system call is unsupported"
+
+Check for the header before we try to use it.
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ configure.ac | 1 +
+ includes.h   | 4 +++-
+ radvd.c      | 8 +++++++-
+ 3 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 55d6673..0e12d9c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -151,6 +151,7 @@ AC_CHECK_HEADERS( \
+ 	net/if_types.h \
+ 	sys/param.h \
+ 	sys/sockio.h \
++	sys/sysctl.h \
+ 	sys/time.h \
+ 	time.h \
+ )
+diff --git a/includes.h b/includes.h
+index 882c34f..7765925 100644
+--- a/includes.h
++++ b/includes.h
+@@ -72,7 +72,9 @@
+ 
+ #include <arpa/inet.h>
+ 
+-#include <sys/sysctl.h>
++#ifdef HAVE_SYS_SYSCTL_H
++# include <sys/sysctl.h>
++#endif
+ 
+ #include <net/if.h>
+ 
+diff --git a/radvd.c b/radvd.c
+index 7b475de..444574d 100644
+--- a/radvd.c
++++ b/radvd.c
+@@ -761,7 +761,9 @@ check_conffile_perm(const char *username, const char *conf_file)
+ int
+ check_ip6_forwarding(void)
+ {
++#ifdef HAVE_SYS_SYSCTL_H
+ 	int forw_sysctl[] = { SYSCTL_IP6_FORWARDING };
++#endif
+ 	int value;
+ 	size_t size = sizeof(value);
+ 	FILE *fp = NULL;
+@@ -777,18 +779,22 @@ check_ip6_forwarding(void)
+ 		}
+ 		fclose(fp);
+ 	}
+-	else
++	else {
+ 		flog(LOG_DEBUG, "Correct IPv6 forwarding procfs entry not found, "
+ 	                       "perhaps the procfs is disabled, "
+ 	                        "or the kernel interface has changed?");
++		value = -1;
++	}
+ #endif /* __linux__ */
+ 
++#ifdef HAVE_SYS_SYSCTL_H
+ 	if (!fp && sysctl(forw_sysctl, sizeof(forw_sysctl)/sizeof(forw_sysctl[0]),
+ 	    &value, &size, NULL, 0) < 0) {
+ 		flog(LOG_DEBUG, "Correct IPv6 forwarding sysctl branch not found, "
+ 			"perhaps the kernel interface has changed?");
+ 		return(0);	/* this is of advisory value only */
+ 	}
++#endif
+ 
+ 	if (value != 1 && !warned) {
+ 		warned = 1;
+-- 
+1.8.1.2
diff --git a/net-misc/radvd/radvd-1.9.2-r1.ebuild b/net-misc/radvd/radvd-1.9.2-r1.ebuild
index d5c7341..9d3a5c0 100644
--- a/net-misc/radvd/radvd-1.9.2-r1.ebuild
+++ b/net-misc/radvd/radvd-1.9.2-r1.ebuild
@@ -1,10 +1,10 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/radvd/radvd-1.9.2-r1.ebuild,v 1.7 2013/02/06 19:44:28 ago Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/radvd/radvd-1.9.2-r1.ebuild,v 1.8 2013/03/14 14:23:43 vapier Exp $
 
 EAPI=4
 
-inherit systemd user
+inherit systemd user eutils autotools
 
 DESCRIPTION="Linux IPv6 Router Advertisement Daemon"
 HOMEPAGE="http://v6web.litech.org/radvd/"
@@ -32,6 +32,11 @@
 	[[ -d ${ROOT}/var/run/radvd ]] && chown radvd:radvd "${ROOT}"/var/run/radvd
 }
 
+src_prepare() {
+	epatch "${FILESDIR}"/${PN}-1.9.2-sysctl.patch
+	eautoreconf
+}
+
 src_configure() {
 	econf --with-pidfile=/var/run/radvd/radvd.pid
 }