From nobody@FreeBSD.org  Tue Mar 28 09:14:51 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4D2AC16A401
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Mar 2006 09:14:51 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id F2E3C43D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Mar 2006 09:14:50 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k2S9Eorm031885
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 28 Mar 2006 09:14:50 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k2S9Eomk031884;
	Tue, 28 Mar 2006 09:14:50 GMT
	(envelope-from nobody)
Message-Id: <200603280914.k2S9Eomk031884@www.freebsd.org>
Date: Tue, 28 Mar 2006 09:14:50 GMT
From: "Bart&#322;omiej Leszak" <fixer@2a.pl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] routing table doesn't update corectly while adding new interface address
X-Send-Pr-Version: www-2.3

>Number:         95031
>Category:       kern
>Synopsis:       [netinet] [patch] routing table doesn't update corectly while adding new interface address
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 28 09:20:16 GMT 2006
>Closed-Date:    Thu Sep 28 08:39:49 GMT 2006
>Last-Modified:  Thu Sep 28 08:39:49 GMT 2006
>Originator:     Bart&#322;omiej Leszak
>Release:        6.0
>Organization:
>Environment:
FreeBSD six.2a.pl 6.0-RELEASE-p4 FreeBSD 6.0-RELEASE-p4 #3: Tue Mar 28 08:41:50 CEST 2006     root@six.2a.pl:/usr/obj/usr/src/sys/SIX  i386
>Description:
While adding new address to the interface the routing table doesn't update
if the network address has the same prefix as the existing route. It's not
a problem if it's the same interface, but could be really annoying with
machines with many interfaces. Problem occurred in 5.4 and later.
>How-To-Repeat:
Add to rc.conf:

ifconfig_em0="inet 10.0.0.91  netmask 255.255.0.0"
ifconfig_em1="inet 10.1.0.1 netmask 255.0.0.0"

reboot, and look at "netstat -nr"
>Fix:
Down the interface and up it again with: ifconfig em0 down && ifconfig em0
up or change your network configuration in the way, that none of the networks
will have the same prefixes in the routing table:

ifconfig_em0="inet 10.2.0.91  netmask 255.255.0.0"
ifconfig_em1="inet 10.1.0.1 netmask 255.0.0.0"

for the above.

The problem is that layout of /usr/src/sys/netinet/in.c changed in 5.4.
While adding new address to the interace the in_addprefix() function is
invoked to update routing table. This function checks only the prefixes
in routing table which is correct in most cases.

The code that does it is like this:

From line 809 in /usr/src/sys/netinet/in.c:
                if (rtinitflags(ia))
                        p = ia->ia_dstaddr.sin_addr;
                else {
                        p = ia->ia_addr.sin_addr;
                        p.s_addr &= ia->ia_sockmask.sin_addr.s_addr;
                }

                if (prefix.s_addr != p.s_addr)
                        continue;

To make it working the check "if (prefix.s_addr != p.s_addr)" needs to be
changed to something like this: 

"if ((prefix.s_addr != p.s_addr) | (!((prefix.s_addr == p.s_addr) &&(mask.s_addr == ia->ia_sockmask.sin_addr.s_addr))))"
 to make sure we really don't have the same route.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Mon Sep 25 19:15:41 UTC 2006 
Responsible-Changed-Why:  
I'll take this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95031 
State-Changed-From-To: open->feedback 
State-Changed-By: bms 
State-Changed-When: Wed Sep 27 23:00:07 UTC 2006 
State-Changed-Why:  
It looks like this was fixed in rev 1.91 of src/sys/netinet.in.c. 
Can you confirm? This rev was integrated in RELENG_6 and later 
from rev 1.85.2.5. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95031 
State-Changed-From-To: feedback->closed 
State-Changed-By: bms 
State-Changed-When: Thu Sep 28 08:39:30 UTC 2006 
State-Changed-Why:  
Submitter confirms the issue has been fixed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95031 
>Unformatted:
