]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
notes on "connected" UDP sockets
authorAlan T. DeKok <aland@freeradius.org>
Tue, 11 Feb 2025 16:57:28 +0000 (11:57 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 11 Feb 2025 19:02:33 +0000 (14:02 -0500)
src/lib/bio/fd.c

index d9b6950acabb2d06ae7c9deef4ae37929cfdeb6a..40eb079a4eebf03cf71ec86432eedc37690ce00f 100644 (file)
@@ -168,6 +168,18 @@ retry:
  *  where a read of zero on a steam socket means "EOF".
  *
  *  Connected sockets do _not_ update per-packet contexts.
+ *
+ *  Note that for UDP, connect() only affects the sending path.  It
+ *  means that the application can call send() without specifying IP
+ *  addresses.  But when the application calls recv(), the OS will
+ *  deliver packets which have been sent from _any_ port, even ones
+ *  which don't match the address given in connect().
+ *
+ *  @todo - arguably this means that for connected UDP sockets, we
+ *  should _only_ use this function when we can't use the udpfromto
+ *  functionality.  And then if that's available, connected sockets
+ *  should have a special read function which discards packets which
+ *  are not from the connected source IP/port.
  */
 static ssize_t fr_bio_fd_read_connected_datagram(fr_bio_t *bio, UNUSED void *packet_ctx, void *buffer, size_t size)
 {