summaryrefslogtreecommitdiff
path: root/sysdep
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-19 18:10:39 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-19 18:10:39 +0100
commit04edf8f2f251f0c2a133843b898cad84f9312880 (patch)
treef2324b75e30cb31c3943cae1a7c21a6c72413be8 /sysdep
parentc0ed32ee28cbeabf8d36f59765fe593baf39c788 (diff)
IO: Workaround for broken FreeBSD behavior
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!
Diffstat (limited to 'sysdep')
-rw-r--r--sysdep/unix/io.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index f7a9e29f..a90ddffd 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -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