]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
IO: Workaround for broken FreeBSD behavior
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 18 Dec 2018 18:16:23 +0000 (19:16 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 18 Dec 2018 18:17:17 +0000 (19:17 +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 8c9052a3e57f79df6ee3ccf1735a751edad8e44a..a511e88ede3fea5163d9fd8963eda5af6c661f39 100644 (file)
@@ -1566,7 +1566,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