From owner-freebsd-net Mon May 21 8:24:23 2001 Delivered-To: freebsd-net@freebsd.org Received: from mail.gmx.net (pop.gmx.net [194.221.183.20]) by hub.freebsd.org (Postfix) with SMTP id 1774437B42C for ; Mon, 21 May 2001 08:24:19 -0700 (PDT) (envelope-from tmoestl@gmx.net) Received: (qmail 32412 invoked by uid 0); 21 May 2001 15:24:17 -0000 Received: from p3e9e03cc.dip.t-dialin.net (HELO forge.local) (62.158.3.204) by mail.gmx.net (mp006-rz3) with SMTP; 21 May 2001 15:24:17 -0000 Received: from tmm by forge.local with local (Exim 3.20 #1) id 151rXf-0000Ds-00; Mon, 21 May 2001 17:24:19 +0200 Date: Mon, 21 May 2001 17:24:19 +0200 From: Thomas Moestl To: Ian Dowse Cc: Barney Wolff , freebsd-net@FreeBSD.ORG Subject: Re: Using connect() on UDP RPC client sockets. Message-ID: <20010521172419.A672@crow.dom2ip.de> Mail-Followup-To: Thomas Moestl , Ian Dowse , Barney Wolff , freebsd-net@FreeBSD.ORG References: <20010520184033.A83645@tp.databus.com> <200105211443.aa07793@salmon.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200105211443.aa07793@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Mon, May 21, 2001 at 02:43:09PM +0100 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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