[quagga-dev 12371] [PATCH] lib: fix "sockunion: add hash function" for BSD (9196caf)

David Lamparter equinox at opensourcerouting.org
Wed May 20 21:47:20 BST 2015


The sockunion_hash() function uses s6_addr32, which is not defined on
BSD systems.  (It only works on glibc because we set _GNU_SOURCE)

ripngd/ripng_nexthop.h already contains a workaround for this.  Bump
workaround to prefix.h so it's available everywhere.

Reported-by: NetDEF CI System <mwinter at netdef.org>
Fixes: 9196caf ("sockunion: add hash function")
Cc: Timo Teräs <timo.teras at iki.fi>
Signed-off-by: David Lamparter <equinox at opensourcerouting.org>
---

Oops, broke the build on FreeBSD & NetBSD...
... pushed fix to master already.  Good thing we have a CI system :)
[ https://ci1.netdef.org/ ]

---
 lib/prefix.h           | 10 ++++++++++
 ripngd/ripng_nexthop.h | 13 ++-----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/prefix.h b/lib/prefix.h
index 45889e0..a1a0679 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -156,6 +156,16 @@ union prefix46constptr
 /* Prefix's family member. */
 #define PREFIX_FAMILY(p)  ((p)->family)
 
+/* glibc defines s6_addr32 to __in6_u.__u6_addr32 if __USE_{MISC || GNU} */
+#ifndef s6_addr32
+#if defined(SUNOS_5)
+/* Some SunOS define s6_addr32 only to kernel */
+#define s6_addr32 _S6_un._S6_u32
+#else
+#define s6_addr32 __u6_addr.__u6_addr32
+#endif /* SUNOS_5 */
+#endif /*s6_addr32*/
+
 /* Prototypes. */
 extern int afi2family (afi_t);
 extern afi_t family2afi (int);
diff --git a/ripngd/ripng_nexthop.h b/ripngd/ripng_nexthop.h
index 7c04105..19bd32b 100644
--- a/ripngd/ripng_nexthop.h
+++ b/ripngd/ripng_nexthop.h
@@ -41,17 +41,8 @@ extern void ripng_rte_send(struct list *ripng_rte_list, struct interface *ifp,
  * -1 if A < B
  **/
 static inline int
-addr6_cmp(struct in6_addr *A, struct in6_addr *B) {
-
-#ifndef s6_addr32
-#if defined(SUNOS_5)
-/* Some SunOS define s6_addr32 only to kernel */
-#define s6_addr32 _S6_un._S6_u32
-#else
-#define s6_addr32 __u6_addr.__u6_addr32
-#endif /* SUNOS_5 */
-#endif /*s6_addr32*/
-
+addr6_cmp(struct in6_addr *A, struct in6_addr *B)
+{
 #define a(i) A->s6_addr32[i]
 #define b(i) B->s6_addr32[i]
 
-- 
2.3.6





More information about the Quagga-dev mailing list