Bug 20785

Summary: changing IP address on an interface may not propagate properly
Product: Base System Reporter: Robert Watson <rwatson>
Component: kernAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.dat none

Description Robert Watson freebsd_committer freebsd_triage 2000-08-22 19:10:01 UTC
Changing the IP address of an interface may not necessarily cause new
sockets to make use of the new IP address, if the address is in the same
subnet as the previous address under IPv4.  This only seems to affect
outgoing packets to non-local addresses; the correct IP is used for outgoing
local packets on the subnet.

Fix: 

Work-around is to revert back to the old IP, or to delete and re-add the
default gateway route entry.  Presumably the outgoing IP address is tied
to the route entry somehow, so any use of that route forces use of the
old IP, which is no longer valid for that interface.  Given that the new IP
address is in the same subnet, ideally we could make use of the same route
entry.  In any case, continuing to make use of the now defunct IP address
is counter-intuitive (and misbehavior, in my view).  I have not tried this
with interfaces other than xl0.
How-To-Repeat: 
(terminal one)
ifconfig xl0 inet 192.168.11.200
route add default 192.168.11.1

(terminal two)
tcpdump -eni xl0

(terminal one)
ifconfig xl0 inet 192.168.11.100
ping -c 100 128.2.1.2

(terminal two output)
tcpdump: listening on xl0
14:00:24.529628 0:c0:4f:3b:cb:62 0:a0:cc:67:f6:fe 0800 98: 192.168.11.200 > 128.
2.1.2: icmp: echo request
14:00:24.568225 0:a0:cc:67:f6:fe 0:c0:4f:3b:cb:62 0800 98: 128.2.1.2 > 192.168.1
1.200: icmp: echo reply

And needless to say, the echo responses don't propagate back up the stack
to the ping application, as they are for the wrong IP.  A ping of 192.168.11.1
works fine.
Comment 1 ru freebsd_committer freebsd_triage 2000-08-30 16:00:07 UTC
On Tue, Aug 22, 2000 at 02:06:06PM -0400, rwatson@FreeBSD.org wrote:
> 
> Changing the IP address of an interface may not necessarily cause new
> sockets to make use of the new IP address, if the address is in the same
> subnet as the previous address under IPv4.  This only seems to affect
> outgoing packets to non-local addresses; the correct IP is used for outgoing
> local packets on the subnet.
> 
I recently experienced this bug (with exact the same workaround) when I was
playing with my libalias(3) ICMP fixes.  Yesterday, when I was playing with
my kernel ICMP error generation fixes, I noticed that a similar bug happens
with `-reject' static routes and thought that this might be related to this
bug.

1. Add the `-reject' route on your gateway machine:
	# route add -host 1.2.3.4 -iface lo0 -reject

2. From another box ping this host:
	$ ping -c1 1.2.3.4
   You will not see the ICMP unreachable message.

3. On the router box, re-add the default route:
	# route delete default
	# route add default $foo

4. From another box try to ping this host again:
	$ ping -c1 1.2.3.4
   Now you will see the ICMP unreachable message.


-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 2 ru freebsd_committer freebsd_triage 2000-10-11 17:21:04 UTC
As we now have a second complain (PR 21914), I feel I better let
the others know that I was working on resolving this issue.

Attached is the latest message from my private discussion with
Garrett on this topic.


-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 3 ru freebsd_committer freebsd_triage 2000-10-11 17:28:36 UTC
Responsible Changed
From-To: freebsd-bugs->ru

I am working on this issue.
Comment 4 ru freebsd_committer freebsd_triage 2001-03-15 14:53:54 UTC
State Changed
From-To: open->analyzed

The fix has been committed to 5.0-CURRENT: 

Revision  Changes    Path 
1.25      +9 -4      src/usr.bin/netstat/netstat.1 
1.47      +3 -3      src/usr.bin/netstat/route.c 
1.61      +5 -4      src/sys/net/route.c 
1.51      +12 -1     src/sys/netinet/in.c 
1.38      +9 -11     src/sys/netinet/in_rmx.c
Comment 5 ru freebsd_committer freebsd_triage 2001-05-14 09:31:36 UTC
State Changed
From-To: analyzed->closed

The fix (slightly evolved) has been MFCed into 4.3-STABLE.