]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
IO: Workaround for broken FreeBSD behavior
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 19 Dec 2018 17:10:39 +0000 (18:10 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 19 Dec 2018 17:10:39 +0000 (18:10 +0100)
FreeBSD silently changes TTL to 1 when MSG_DONTROUTE is used, even when
it is explicitly set to another value. That breaks TTL security sockets,
including BFD which always uses TTL 255. Bad FreeBSD!

sysdep/unix/io.c

index f7a9e29f05a89080b4bdcebb27a36324536e2e52..a90ddffd736cd88449d1c8721e1e6ed165ac1e9f 100644 (file)
@@ -1614,7 +1614,9 @@ sk_sendmsg(sock *s)
   };
 
 #ifdef CONFIG_DONTROUTE_UNICAST
-  if (ipa_is_ip4(s->daddr) && ip4_is_unicast(ipa_to_ip4(s->daddr)))
+  /* FreeBSD silently changes TTL to 1 when MSG_DONTROUTE is used, therefore we
+     cannot use it for other cases (e.g. when TTL security is used). */
+  if (ipa_is_ip4(s->daddr) && ip4_is_unicast(ipa_to_ip4(s->daddr)) && (s->ttl == 1))
     flags = MSG_DONTROUTE;
 #endif