aboutsummaryrefslogtreecommitdiffstats
path: root/sysdep
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-18 19:16:23 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-18 19:17:17 +0100
commitc2d29dd197cbff6c143a570576c81bee20fc06eb (patch)
treee1b775bc1b5ebb8e84da3507a75bd7174b8a4ff7 /sysdep
parent82b742533bdbf977ec95997fc0011a47a672bcc8 (diff)
downloadbird-c2d29dd197cbff6c143a570576c81bee20fc06eb.tar.gz
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 8c9052a3..a511e88e 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -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