Date: Mon, 21 May 2001 17:24:19 +0200 From: Thomas Moestl <tmoestl@gmx.net> To: Ian Dowse <iedowse@maths.tcd.ie> Cc: Barney Wolff <barney@databus.com>, freebsd-net@FreeBSD.ORG Subject: Re: Using connect() on UDP RPC client sockets. Message-ID: <20010521172419.A672@crow.dom2ip.de> In-Reply-To: <200105211443.aa07793@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Mon, May 21, 2001 at 02:43:09PM %2B0100 References: <20010520184033.A83645@tp.databus.com> <200105211443.aa07793@salmon.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2001/05/21 at 14:43:09 +0100, Ian Dowse wrote: > In message <20010520184033.A83645@tp.databus.com>, Barney Wolff writes: > >1. Multi-homed hosts are in fact very common, especially in > > corporate environments. To get the right source addr in > > its reply, the server must open separate sockets on each > > of its host's addresses - as named and ntpd do. And then > > it has to detect changes in the set of addresses. Hard > > work for not a lot of gain. > > An alternative to this approach on the server side, which has been > discussed before, is a mechanism to set the source address of > individual outgoing UDP datagrams. There is already the IP_RECVDSTADDR > socket option which can be used to determine the source address of > the incoming packet: > > If the IP_RECVDSTADDR option is enabled on a SOCK_DGRAM > socket, the recvmsg(2) call will return the destination IP > address for a UDP datagram. The msg_control field in the > msghdr structure points to a buffer that contains a cmsghdr > structure followed by the IP address. The cmsghdr fields > have the following values: > > cmsg_len = sizeof(struct in_addr) > cmsg_level = IPPROTO_IP > cmsg_type = IP_RECVDSTADDR > > If an IP_SENDSRCADDR control message was implemented, servers could > use it to reply from the address to which the request was sent. > This would not require opening additional sockets, and it would > not need to detect interface address changes. I have a patch that does just that (although it just overloads IP_RECVDSTADDR for sendmsg instead of creating a new flag). I wrote it some time ago for a DNS server (the standard requires the source address to be the address the packet went to). It may need some resynching, but if you want, I can dig it out and prepare it for committing. I anyway wanted to do this some time... - thomas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010521172419.A672>