]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fix IP_HDRINCL usage on FreeBSD 11
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 17 Jan 2017 12:21:25 +0000 (13:21 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 17 Jan 2017 12:21:25 +0000 (13:21 +0100)
FreeBSD 11 changed endianity of ip_len field from host order to network
order. Also DragonFly BSD allegedly expects network order here.

Thanks to Olivier Cochard-LabbĂ© for the patch.

sysdep/bsd/sysio.h

index 2610a47b00a9d090a1bc4a30cbec87e60b332e46..9b10e6e82563bbf82f43d4263ed3f4324a1a33b2 100644 (file)
@@ -9,6 +9,7 @@
 #include <net/if_dl.h>
 #include <netinet/in_systm.h> // Workaround for some BSDs
 #include <netinet/ip.h>
+#include <sys/param.h>
 
 
 #ifdef __NetBSD__
@@ -179,8 +180,8 @@ sk_prepare_ip_header(sock *s, void *hdr, int dlen)
   ip->ip_src = ipa_to_in4(s->saddr);
   ip->ip_dst = ipa_to_in4(s->daddr);
 
-#ifdef __OpenBSD__
-  /* OpenBSD expects ip_len in network order, other BSDs expect host order */
+#if (defined __OpenBSD__) || (defined __DragonFly__) || (defined __FreeBSD__ && (__FreeBSD_version >= 1100030))
+  /* Different BSDs have different expectations of ip_len endianity */
   ip->ip_len = htons(ip->ip_len);
 #endif
 }