]> git.puffer.fish Git - matthieu/frr.git/commitdiff
build: check actually-used BSD link state fields
authorDoug VanLeuven <roamdad@sonic.net>
Wed, 10 Oct 2012 23:12:32 +0000 (16:12 -0700)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 5 Nov 2012 16:22:24 +0000 (11:22 -0500)
ifi_link_state missing in OS X. There could be other *BSD's that haven't
implemented it and possibly affects older implementations.

The existing HAVE_BSD_LINK_DETECT configure.ac check is only confirming
the link state detection using ifmediareq.ifm_status found in
<net/if_media.h>. This is the link state detection used in
zebra/ioctl.c. Later, *BSD redefined struct if_data in <net/if.h> and
included link state detection. This is the method used in
zebra/kernel_socket.c

Additional test defined in config.ac to test for member struct
if_data.ifi_link_state defined in <net/if.h> separate from test for
<net/if_media.h> ifmediareq.ifm_status

Fixed #ifdef's in zebra/kernel_socket.c to use the new #define
No impact on older function calls in zebra/ioctl.c

Tested on 64bit OS X 10.7, FreeBSD 9.0 amd64 & i386 (32bit)
using gcc & clang. Tested on linux 64bit.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
configure.ac
zebra/kernel_socket.c

index dcca9682ce4ed6aa3b2061ef6414aa0f86981492..425fe27373bd1f66e2aa778bf076ddce927e5806 100755 (executable)
@@ -992,6 +992,16 @@ AC_CHECK_HEADER([net/if.h],
     QUAGGA_INCLUDES)], 
   [], QUAGGA_INCLUDES )
 
+dnl ---------------------------------------------------------------
+dnl Additional, newer way to check link-state using ifi_link_state.
+dnl Not available in all BSD's when ifmediareq available
+dnl ---------------------------------------------------------------
+AC_CHECK_HEADER([net/if.h],
+    AC_CHECK_MEMBERS([struct if_data.ifi_link_state],
+      AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]),
+      [], QUAGGA_INCLUDES),
+    ,)
+
 dnl ------------------------
 dnl TCP_MD5SIG socket option
 dnl ------------------------
index 20c17f9ee802111379445c373e8ad86098904fd1..cde36bd034447eeb6b683308dcc438b0cf2af42e 100644 (file)
@@ -316,7 +316,7 @@ ifan_read (struct if_announcemsghdr *ifan)
 }
 #endif /* RTM_IFANNOUNCE */
 
-#ifdef HAVE_BSD_LINK_DETECT
+#ifdef HAVE_BSD_IFI_LINK_STATE
 /* BSD link detect translation */
 static void
 bsd_linkdetect_translate (struct if_msghdr *ifm)
@@ -327,7 +327,7 @@ bsd_linkdetect_translate (struct if_msghdr *ifm)
   else
     UNSET_FLAG(ifm->ifm_flags, IFF_RUNNING);
 }
-#endif /* HAVE_BSD_LINK_DETECT */
+#endif /* HAVE_BSD_IFI_LINK_STATE */
 
 /*
  * Handle struct if_msghdr obtained from reading routing socket or
@@ -463,9 +463,9 @@ ifm_read (struct if_msghdr *ifm)
        */
       ifp->ifindex = ifm->ifm_index;
       
-#ifdef HAVE_BSD_LINK_DETECT /* translate BSD kernel msg for link-state */
+#ifdef HAVE_BSD_IFI_LINK_STATE /* translate BSD kernel msg for link-state */
       bsd_linkdetect_translate(ifm);
-#endif /* HAVE_BSD_LINK_DETECT */
+#endif /* HAVE_BSD_IFI_LINK_STATE */
 
       if_flags_update (ifp, ifm->ifm_flags);
 #if defined(__bsdi__)
@@ -504,9 +504,9 @@ ifm_read (struct if_msghdr *ifm)
           return -1;
         }
       
-#ifdef HAVE_BSD_LINK_DETECT /* translate BSD kernel msg for link-state */
+#ifdef HAVE_BSD_IFI_LINK_STATE /* translate BSD kernel msg for link-state */
       bsd_linkdetect_translate(ifm);
-#endif /* HAVE_BSD_LINK_DETECT */
+#endif /* HAVE_BSD_IFI_LINK_STATE */
 
       /* update flags and handle operative->inoperative transition, if any */
       if_flags_update (ifp, ifm->ifm_flags);