Bug 22185

Summary: Identical IP addresses on two broadcast interfaces
Product: Base System Reporter: Yar Tikhiy <yar>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   

Description Yar Tikhiy 2000-10-21 15:10:01 UTC
	It's possible to add two absolutely identical IP addresses
	to two different broadcast interfaces.

	I guess it would be possible to add different addresses from
	the same network, too.

	The problem arises from in_control()/in_ifinit() leaving the
	address installed even if adding the link-layer route fails.

Fix: 

Maybe, the code should try to add the link layer route first,
	and assign the address to the interface only if adding
	the route succeeded?
How-To-Repeat: 
yar# ifconfig fxp0 10.1.1.1
yar# ifconfig fxp1 10.1.1.1
ifconfig: ioctl (SIOCAIFADDR): File exists
yar# ifconfig fxp0 
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 10.1.1.1 netmask 0xff000000 broadcast 10.255.255.255
        ether 00:d0:b7:60:63:da 
        media: autoselect (100baseTX) status: active
        supported media: autoselect 100baseTX <full-duplex> 100baseTX 10baseT/UT
P <full-duplex> 10baseT/UTP
yar# ifconfig fxp1 
fxp1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 10.1.1.1 netmask 0xff000000 broadcast 10.255.255.255
        ether 00:a0:c9:66:67:4d 
        media: autoselect (100baseTX) status: active
        supported media: autoselect 100baseTX <full-duplex> 100baseTX 10baseT/UT
P <full-duplex> 10baseT/UTP
Comment 1 Garrett A. Wollman 2000-10-27 18:00:27 UTC
<<On Sat, 21 Oct 2000 17:59:52 +0400 (MSD), yar@comp.chem.msu.su said:

> 	Maybe, the code should try to add the link layer route first,
> 	and assign the address to the interface only if adding
> 	the route succeeded?

This can't be done, because in order to add the route, the ifaddr must
already be present.

The trouble is that sometimes this error does not indicate a problem
(even though it usually does).  I think the right thing is probably to
compare the new (A1, M1) against all the existing ifaddrs and fail the
request if any (A2, M2) is present such that M1 == M2 and (A1 & M1) ==
(A2 & M2).  There may be other conditions which should fail as well.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
wollman@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
Comment 2 Jonathan Chen freebsd_committer freebsd_triage 2002-07-14 09:23:11 UTC
State Changed
From-To: open->closed

fixed, see bin/21292 [src/sys/netinet/in.c 1.44.2.8]