Skip to contentSkip to conversation

ipsec-tools 0.1 + kernel 2.5.64

DISCUSSION Derek Atkins 2 participants 6 messages Mar 5, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

Quoted 2 lines

If you mention www.sf.net/projects/ipsec-tools they does not compiles for me I cot following error

Yes, this is what we mean...

Quoted 9 lines

grabmyaddr.c:69:1: warning: "HAVE_GETIFADDRS" redefined
<command line>:1:1: warning: this is the location of the previous definition grabmyaddr.c:88: redefinition of struct ifaddrs' grabmyaddr.c:200: warning: static declaration for getifaddrs' follows non-static
grabmyaddr.c:254: warning: static declaration for `freeifaddrs' follows non-static
make[3]: *** [grabmyaddr.o] Error 1
make[3]: Leaving directory `/usr/src/ipsec-tools-0.1/src/racoon'

Hmm... What version of glibc are you using? This seems to imply that getifaddrs() and freeifaddrs() is now in libc, where it wasn't before. I didn't know it got added -- I wonder when that happened?

Quoted 1 line

I can provide additional info if needed (gcc-3.2.2)

Please. Feel free to follow up personally rather than to this list (or at least be sure to CC me on all your replies, as I'm not actually subscribed directly).

Can you try this patch and see if that fixes the problem?

racoon/grabmyaddr.c +2 -2
diff -u -r1.3 grabmyaddr.c
@@ -65,7 +65,7 @@
 #include "isakmp_var.h"
 #include "gcmalloc.h"
 
-#ifdef __linux__
+#if defined(__linux__) && !defined(HAVE_GETIFADDRS)
 #define HAVE_GETIFADDRS
 #endif
 
@@ -78,7 +78,7 @@
 static int suitable_ifaddr6 __P((const char *, const struct sockaddr *));
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) && !defined(HAVE_GETIFADDRS)
 
 /* We could do this _much_ better. kame racoon in its current form
  * will esentially die at frequent changes of address configuration.

Thanks,

-derek, ipsec-tools maintainer

Signature · 3 lines
       Derek Atkins
       Computer and Internet Security Consultant
       [email protected]             www.ihtfp.com
#1 lore raw
Quoted 3 lines · Derek Atkins

Hmm... What version of glibc are you using? This seems to imply that getifaddrs() and freeifaddrs() is now in libc, where it wasn't before. I didn't know it got added -- I wonder when that happened?

It's new in glibc 2.3

racoon/grabmyaddr.c line 81

Quoted 7 lines
racoon/grabmyaddr.c +1 -1
@@ -78,7 +78,7 @@
 static int suitable_ifaddr6 __P((const char *, const struct sockaddr *));
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) && !defined(HAVE_GETIFADDRS)

#ifdef <OS> is a very bad style. As you're already using autoconf I'd suggest just checking for HAVE_GETIFADDRS

#2 lore raw
Quoted 1 line · Christoph Hellwig

It's new in glibc 2.3

Ahh.. Thanks. I'm still using older versions myself.

Quoted 2 lines

#ifdef <OS> is a very bad style. As you're already using autoconf I'd suggest just checking for HAVE_GETIFADDRS

Well, the problem is that the replacement function is only valid on Linux, so I need to have the <OS> test in there anyways. It may be "bad style", but the test needs to exist _somewhere_. Besides, I've never been one to be convinced to do something purely based on stylistic arguments. Give me a real technical reason why it needs to be different and I'll consider changing it.

-derek

Signature · 4 lines
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       [email protected]                        PGP key available
#3 lore raw
Quoted 2 lines · Derek Atkins

Well, the problem is that the replacement function is only valid on Linux, so I need to have the <OS> test in there anyways.

It's probably not valid on Linux but on OSes that support the functionality you use to implement it. It might e.g. work on the Hurd that uses old Linux networking code.

Quoted 5 lines

It may be
"bad style", but the test needs to exist _somewhere_. Besides, I've never been one to be convinced to do something purely based on stylistic arguments. Give me a real technical reason why it needs to be different and I'll consider changing it.

Checking for OSes is wrong because you couldn't care less for the OS, you care for the functionality that is provided. This is the nice idea behind autoconf (the implementation of autoconf is a completly different issue, though).

#4 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Derek Atkins

Well, the problem is that the replacement function is only valid on Linux, so I need to have the <OS> test in there anyways.

It's probably not valid on Linux but on OSes that support the functionality you use to implement it. It might e.g. work on the Hurd that uses old Linux networking code.

I find it extremely unlikely that the hurd would have the include file <linux/rtnetlink.h>, which is part of the code chunk in question. As I said, the code is extremely linux-specific.

Quoted 4 lines

Checking for OSes is wrong because you couldn't care less for the OS, you care for the functionality that is provided. This is the nice idea behind autoconf (the implementation of autoconf is a completly different issue, though).

As I said, the current code is OS specific. I find is EXTREMELY unlikely it would work on anything that isn't Linux. I wont argue about autoconf implementation.

However, I will acknowledge that my original patch was broken. Here is a better one. This should work on both pre- and post- glibc-2.3 linux systems.

-derek

racoon/grabmyaddr.c +3 -2
diff -u -r1.3 -r1.4
@@ -65,8 +65,9 @@
 #include "isakmp_var.h"
 #include "gcmalloc.h"
 
-#ifdef __linux__
+#if defined(__linux__) && !defined(HAVE_GETIFADDRS)
 #define HAVE_GETIFADDRS
+#define NEED_LINUX_GETIFADDRS
 #endif
 
 #ifndef HAVE_GETIFADDRS
@@ -78,7 +79,7 @@
 static int suitable_ifaddr6 __P((const char *, const struct sockaddr *));
 #endif
 
-#ifdef __linux__
+#ifdef NEED_LINUX_GETIFADDRS
 
 /* We could do this _much_ better. kame racoon in its current form
  * will esentially die at frequent changes of address configuration.
Signature · 3 lines
       Derek Atkins
       Computer and Internet Security Consultant
       [email protected]             www.ihtfp.com
#5 lore raw
In reply to Christoph Hellwig

Sorry, that was the wrong patch.

Try this one.

-derek

racoon/grabmyaddr.c +4 -3
diff -u -r1.4 grabmyaddr.c
@@ -65,10 +65,13 @@
 #include "isakmp_var.h"
 #include "gcmalloc.h"
 
-#if defined(__linux__) && !defined(HAVE_GETIFADDRS)
+#ifdef __linux__
+#include <linux/rtnetlink.h>
+ifndef HAVE_GETIFADDRS
 #define HAVE_GETIFADDRS
 #define NEED_LINUX_GETIFADDRS
 #endif
+#endif
 
 #ifndef HAVE_GETIFADDRS
 static unsigned int if_maxindex __P((void));
@@ -93,8 +96,6 @@
 	struct sockaddr *ifa_addr;
 	struct sockaddr_storage ifa_addrbuf;
 };
-
-#include <linux/rtnetlink.h>
 
 __u32 nl_pid;
 int nl_rescan;
Signature · 3 lines
       Derek Atkins
       Computer and Internet Security Consultant
       [email protected]             www.ihtfp.com