From: Alan T. DeKok Date: Tue, 24 Dec 2024 12:39:09 +0000 (-0500) Subject: minor tweaks and clarifications X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7951b60afefd0fc1055da4e1e34a2a6f0d6815ff;p=thirdparty%2Ffreeradius-server.git minor tweaks and clarifications OSX has IP_BOUND_IF. *BSD has IP_RECVIF, but no IP_SENDIF. And IP_RECVIF is a socket option which is set, and then causes any _subsequent_ recvmsg() call to have another cmsg structure added, with the sockaddr_dl containing the interface. The application is then responsible for comparing the interface IDs, and discarding packets which don't match. --- diff --git a/src/lib/bio/fd_open.c b/src/lib/bio/fd_open.c index 55a0b922635..059163f8343 100644 --- a/src/lib/bio/fd_open.c +++ b/src/lib/bio/fd_open.c @@ -31,6 +31,7 @@ #include #include #include +#include /** Initialize common datagram information * @@ -600,6 +601,13 @@ static int fr_bio_fd_socket_bind_unix(fr_bio_fd_t *my, fr_bio_fd_config_t const return 0; } +/* + * Use the OSX native versions on OSX. + */ +#ifdef __APPLE__ +#undef SO_BINDTODEVICE +#endif + #ifdef SO_BINDTODEVICE /** Linux bind to device by name. * @@ -633,7 +641,7 @@ static int fr_bio_fd_socket_bind_to_device(fr_bio_fd_t *my, fr_bio_fd_config_t c } #elif defined(IP_BOUND_IF) || defined(IPV6_BOUND_IF) -/** *BSD bind to interface by index. +/** OSX bind to interface by index. * */ static int fr_bio_fd_socket_bind_to_device(fr_bio_fd_t *my, UNUSED fr_bio_fd_config_t const *cfg) diff --git a/src/lib/bio/fd_priv.h b/src/lib/bio/fd_priv.h index def9c60b828..a59d2a5b774 100644 --- a/src/lib/bio/fd_priv.h +++ b/src/lib/bio/fd_priv.h @@ -52,7 +52,7 @@ typedef struct fr_bio_fd_s { #if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) || defined(IPV6_PKTINFO) struct iovec iov; //!< for recvfromto struct msghdr msgh; //!< for recvfromto - uint8_t cbuf[256]; //!< for recvfromto + uint8_t cbuf[sizeof(struct cmsghdr) * 2]; //!< for recvfromto #endif } fr_bio_fd_t;