diff --git a/configure.ac b/configure.ac index afa9cd39ea..c52f212438 100644 --- a/configure.ac +++ b/configure.ac @@ -207,7 +207,8 @@ dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw geteuid getgid getgrnam_r getmntent_r \ getpwuid_r getuid kill mmap newlocale posix_fallocate posix_memalign \ - prlimit regexec sched_getaffinity setgroups setns setrlimit symlink]) + prlimit regexec sched_getaffinity setgroups setns setrlimit symlink \ + sysctlbyname]) dnl Availability of pthread functions (if missing, win32 threading is dnl assumed). Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE. @@ -220,8 +221,8 @@ LIBS=$old_libs dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \ sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \ - sys/un.h sys/syscall.h netinet/tcp.h ifaddrs.h libtasn1.h \ - sys/ucred.h sys/mount.h]) + sys/un.h sys/syscall.h sys/sysctl.h netinet/tcp.h ifaddrs.h \ + libtasn1.h sys/ucred.h sys/mount.h]) dnl Check whether endian provides handy macros. AC_CHECK_DECLS([htole64], [], [], [[#include ]]) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 00f2befcaf..62ae0b7eb0 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -41,6 +41,9 @@ #include #include #include +#if HAVE_SYS_SYSCTL_H +# include +#endif #include "virerror.h" #include "datatypes.h" @@ -1545,10 +1548,20 @@ static int networkEnableIpForwarding(bool enableIPv4, bool enableIPv6) { int ret = 0; +#ifdef HAVE_SYSCTLBYNAME + int enabled = 1; + if (enableIPv4) + ret = sysctlbyname("net.inet.ip.forwarding", NULL, 0, + &enabled, sizeof(enabled)); + if (enableIPv6 && ret == 0) + ret = sysctlbyname("net.inet6.ip6.forwarding", NULL, 0, + &enabled, sizeof(enabled)); +#else if (enableIPv4) ret = virFileWriteStr("/proc/sys/net/ipv4/ip_forward", "1\n", 0); if (enableIPv6 && ret == 0) ret = virFileWriteStr("/proc/sys/net/ipv6/conf/all/forwarding", "1\n", 0); +#endif return ret; }