From 735cc5fa7fe19ba10ef5677d89f5229a965776da Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 24 Apr 2010 19:02:22 +0200 Subject: [PATCH 1/2] lib/replace: add replacement for IPV6_V6ONLY on linux systems with broken headers This is needed on SLES8. See bug 7196. metze (cherry picked from commit e06cf3950252a46486aa046a4552ed6ebff175b3) Signed-off-by: Stefan Metzmacher --- lib/replace/libreplace_network.m4 | 44 +++++++++++++++++++++++++++++++++++++ lib/replace/system/network.h | 7 ++++++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/lib/replace/libreplace_network.m4 b/lib/replace/libreplace_network.m4 index b7d15ea..6554a59 100644 --- a/lib/replace/libreplace_network.m4 +++ b/lib/replace/libreplace_network.m4 @@ -350,6 +350,50 @@ if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then fi fi +dnl Some old Linux systems have broken header files and +dnl miss the IPV6_V6ONLY define in netinet/in.h, +dnl but have it in linux/in6.h. +dnl We can't include both files so we just check if the value +dnl if defined and do the replacement in system/network.h +AC_CACHE_CHECK([for IPV6_V6ONLY support],libreplace_cv_HAVE_IPV6_V6ONLY,[ + AC_TRY_COMPILE([ +#include /* for NULL */ +#include +#include +#include +#include + ], + [ +#ifndef IPV6_V6ONLY +#error no IPV6_V6ONLY +#endif + ],[ + libreplace_cv_HAVE_IPV6_V6ONLY=yes + ],[ + libreplace_cv_HAVE_IPV6_V6ONLY=no + ]) +]) +if test x"$libreplace_cv_HAVE_IPV6_V6ONLY" != x"yes"; then + dnl test for IPV6_V6ONLY + AC_CACHE_CHECK([for IPV6_V6ONLY in linux/in6.h],libreplace_cv_HAVE_LINUX_IPV6_V6ONLY_26,[ + AC_TRY_COMPILE([ + #include + ], + [ + #if (IPV6_V6ONLY != 26) + #error no linux IPV6_V6ONLY + #endif + ],[ + libreplace_cv_HAVE_LINUX_IPV6_V6ONLY_26=yes + ],[ + libreplace_cv_HAVE_LINUX_IPV6_V6ONLY_26=no + ]) + ]) + if test x"$libreplace_cv_HAVE_LINUX_IPV6_V6ONLY_26" = x"yes"; then + AC_DEFINE(HAVE_LINUX_IPV6_V6ONLY_26,1,[Whether the system has IPV6_V6ONLY in linux/in6.h]) + fi +fi + dnl test for ipv6 AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[ AC_TRY_LINK([ diff --git a/lib/replace/system/network.h b/lib/replace/system/network.h index 1f51035..93d533c 100644 --- a/lib/replace/system/network.h +++ b/lib/replace/system/network.h @@ -360,6 +360,13 @@ struct addrinfo { #define ifr_netmask ifr_addr #endif +/* Some old Linux systems have broken header files */ +#ifdef HAVE_IPV6 +#ifdef HAVE_LINUX_IPV6_V6ONLY_26 +#define IPV6_V6ONLY 26 +#endif /* HAVE_LINUX_IPV6_V6ONLY_26 */ +#endif /* HAVE_IPV6 */ + #ifdef SOCKET_WRAPPER #ifndef SOCKET_WRAPPER_DISABLE #ifndef SOCKET_WRAPPER_NOT_REPLACE -- 1.6.3.3 From 3bcbf55387cc4fdde8d19991e9a73c8ac12ca927 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 24 Apr 2010 13:07:50 +0200 Subject: [PATCH 2/2] lib/replace: make sure IPV6_V6ONLY is available for IPv6 support We rely on IPV6_V6ONLY being supported. See bug #7196. metze (cherry picked from commit 41cd6f992829c45c890f5daf78eb3019633f3620) Signed-off-by: Stefan Metzmacher --- lib/replace/libreplace_network.m4 | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/lib/replace/libreplace_network.m4 b/lib/replace/libreplace_network.m4 index 6554a59..d8ed8a1 100644 --- a/lib/replace/libreplace_network.m4 +++ b/lib/replace/libreplace_network.m4 @@ -414,6 +414,14 @@ if (ret != 0) { const char *es = gai_strerror(ret); } freeaddrinfo(ai); +{ + int val = 1; + #ifdef HAVE_LINUX_IPV6_V6ONLY_26 + #define IPV6_V6ONLY 26 + #endif + ret = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + (const void *)&val, sizeof(val)); +} ],[ libreplace_cv_HAVE_IPV6=yes ],[ -- 1.6.3.3