Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Nov 2002 17:57:02 -0800 (PST)
From:      Archie Cobbs <archie@dellroad.org>
To:        Wes Peters <wes@softweyr.com>
Cc:        freebsd-net@FreeBSD.ORG
Subject:   Re: Sockets and changing IP addresses
Message-ID:  <200211220157.gAM1v2Ls068553@arch20m.dellroad.org>
In-Reply-To: <3DDD4D11.15376311@softweyr.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Wes Peters wrote:
> > I'm curious what -net's opinion is on PR kern/38544:
> > 
> >     http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/38554
> > 
> > In summary: if you have a connected socket whose local IP address
> > is X, and then change the interface IP address from X to Y, then
> > packets written out by the socket will continue to be transmitted
> > with source IP address X.
> > 
> > Do people agree that this is a bug and should be fixed?
> 
> Yes.  The other end can't possibly reply to address X, so the connection
> is broken at this point.

Now I've got a patch that fixes this problem for review, it's attached
to the PR (please review at the above URL if interested).

I chose EADDRNOTAVAIL as the error code because:

  (a) The phrase "Can't assign requested address" seems most appropriate
  (b) It's consistent with what happens when you try to use an IP address
      that never existed in the first place, e.g., with IP_SENDSRCADDR.
  (c) You don't normally get this error from a send/write, which is
      when you'll get it

The implementation simply keeps a pointer in the inet PCB to the
'struct in_ifaddr' associated with the local IP address (if any).
When this address is removed from the interface, we set the RTF_REJECT
flag on it, and this is detected by the TCP and UDP layers.
So the per-packet cost is the testing of one flag bit.

Note that 'struct in_ifaddr' structures are reference counted, so
they continue to exist even after being removed from the interface.

-Archie

__________________________________________________________________________
Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com

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?200211220157.gAM1v2Ls068553>