]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
minor tweaks and clarifications
authorAlan T. DeKok <aland@freeradius.org>
Tue, 24 Dec 2024 12:39:09 +0000 (07:39 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 24 Dec 2024 12:42:32 +0000 (07:42 -0500)
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.

src/lib/bio/fd_open.c
src/lib/bio/fd_priv.h

index 55a0b922635484693a544fa4dae3ac11f6ff4c1c..059163f8343fc12f8c829460ee27856a8c0494a7 100644 (file)
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <libgen.h>
 #include <netinet/tcp.h>
+#include <netinet/in.h>
 
 /** 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)
index def9c60b8288f670135185fce3b390545151b60b..a59d2a5b7749521b720e6f21ac811f1659b5985b 100644 (file)
@@ -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;