From: Alan T. DeKok Date: Sun, 26 Feb 2023 23:12:37 +0000 (-0500) Subject: set TTL to 255, as suggested by RFC 5881 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4ddb7cb2759bfb7f5b36dc3ea7ffbd7f2976fd4;p=thirdparty%2Ffreeradius-server.git set TTL to 255, as suggested by RFC 5881 We likely want to have this configurable, so that the BFD links can go slightly further. --- diff --git a/src/modules/proto_bfd/proto_bfd.c b/src/modules/proto_bfd/proto_bfd.c index a15509f74fd..290904a733c 100644 --- a/src/modules/proto_bfd/proto_bfd.c +++ b/src/modules/proto_bfd/proto_bfd.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * @copyright 2012 Network RADIUS SAS (legal@networkradius.com) + * + * Check on RFC 5881 for BFD over IP issues. */ #include @@ -1732,6 +1734,7 @@ static int bfd_socket_parse(CONF_SECTION *cs, rad_listen_t *this) static int bfd_socket_open(CONF_SECTION *cs, rad_listen_t *this) { int rcode; + int ttl = 255; uint16_t port; bfd_socket_t *sock = this->data; @@ -1747,6 +1750,8 @@ static int bfd_socket_open(CONF_SECTION *cs, rad_listen_t *this) return -1; } + if (setsockopt(this->fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)) < 0) goto fail; + rad_suid_up(); rcode = fr_socket_bind(this->fd, &sock->my_ipaddr, &port, sock->interface); rad_suid_down(); @@ -1754,6 +1759,8 @@ static int bfd_socket_open(CONF_SECTION *cs, rad_listen_t *this) if (rcode < 0) { char buffer[256]; + + fail: close(this->fd); this->print(this, buffer, sizeof(buffer));