From nobody@FreeBSD.org  Sat Sep 11 01:38:19 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4C491106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 11 Sep 2010 01:38:19 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 3C3C88FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 11 Sep 2010 01:38:19 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8B1cIaE019882
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 11 Sep 2010 01:38:18 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o8B1cIsw019881;
	Sat, 11 Sep 2010 01:38:18 GMT
	(envelope-from nobody)
Message-Id: <201009110138.o8B1cIsw019881@www.freebsd.org>
Date: Sat, 11 Sep 2010 01:38:18 GMT
From: Ingo Flaschberger <if@xip.at>
To: freebsd-gnats-submit@FreeBSD.org
Subject: freebsd 8.1 - ifdown - ifup - loopback route keeps
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         150481
>Category:       kern
>Synopsis:       IFA_RTSELF: freebsd 8.1 - ifdown - ifup - loopback route keeps
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    qingli
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 11 01:40:03 UTC 2010
>Closed-Date:    Tue Apr 12 12:54:20 UTC 2011
>Last-Modified:  Tue Apr 12 12:54:20 UTC 2011
>Originator:     Ingo Flaschberger
>Release:        8.1 stable
>Organization:
crossip communications gmbh
>Environment:
FreeBSD xxx 8.1-STABLE FreeBSD 8.1-STABLE
>Description:
in raw_ip.c when a interface comes up with IFF_UP at the new added loopback interface the IFA_RTSELF is not set.
(13 year old bug!)


>How-To-Repeat:
without multipath:
ifconfig em3 10.40.40.3/24
ifconfig down em3
# all ok
ifconfig up em4 
# all ok
ifconfig down em4
# loopback route not deleted (not tested)

with multipath:
ifconfig em3 10.40.40.3/24
ifconfig down em3
# all ok
ifconfig up em4 
# all ok
ifconfig down em4
# loopback route not deleted 
ifconfig up em4
# 2 loopback routes
..

and when setting only a /32 ost route at the interface,
freebsd crashes after the 2nd ifconfig up
>Fix:
see attached patch

Patch attached with submission follows:

--- /usr/src/sys/netinet/raw_ip.c	2010-05-02 16:36:15.000000000 +0000
+++ /router/usr/src/sys/netinet/raw_ip.c	2010-09-11 01:28:24.000000000 +0000
@@ -755,6 +755,8 @@
 		if (err == 0)
 			ia->ia_flags |= IFA_ROUTE;
 		err = ifa_add_loopback_route((struct ifaddr *)ia, sa);
+		if (err == 0)
+		        ia->ia_flags |= IFA_RTSELF;
 		ifa_free(&ia->ia_ifa);
 		break;
 	}


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: remko 
Responsible-Changed-When: Sat Sep 11 09:22:40 UTC 2010 
Responsible-Changed-Why:  
reassign to networking team 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150481 
Responsible-Changed-From-To: freebsd-net->qingli 
Responsible-Changed-By: qingli 
Responsible-Changed-When: Sun Sep 12 17:50:30 UTC 2010 
Responsible-Changed-Why:  
Take ownership of this bug. The bug was introduced in 9/2009. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=150481 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/150481: commit references a PR
Date: Sun, 12 Sep 2010 18:04:52 +0000 (UTC)

 Author: qingli
 Date: Sun Sep 12 18:04:47 2010
 New Revision: 212502
 URL: http://svn.freebsd.org/changeset/base/212502
 
 Log:
   Adding an address on an interface also requires the loopback route to
   that address be installed.
   
   PR:		kern/150481
   Submitted by:	Ingo Flaschberger <if at xip.at>
   MFC after:	5 days
 
 Modified:
   head/sys/netinet/raw_ip.c
 
 Modified: head/sys/netinet/raw_ip.c
 ==============================================================================
 --- head/sys/netinet/raw_ip.c	Sun Sep 12 17:55:56 2010	(r212501)
 +++ head/sys/netinet/raw_ip.c	Sun Sep 12 18:04:47 2010	(r212502)
 @@ -741,6 +741,8 @@ rip_ctlinput(int cmd, struct sockaddr *s
  		if (err == 0)
  			ia->ia_flags |= IFA_ROUTE;
  		err = ifa_add_loopback_route((struct ifaddr *)ia, sa);
 +		if (err == 0)
 +			ia->ia_flags |= IFA_RTSELF;
  		ifa_free(&ia->ia_ifa);
  		break;
  	}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: eadler 
State-Changed-When: Tue Mar 1 10:14:15 EST 2011 
State-Changed-Why:  
committed in head 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150481 

From: Ingo Flaschberger <if@freebsd.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/150481: IFA_RTSELF: freebsd 8.1 - ifdown - ifup - loopback
 route keeps
Date: Sat, 2 Apr 2011 16:42:04 +0200 (CEST)

 Hi,
 
 why is this patch not in FreeBSD 8.2 Release?
 
 Kind regards,
  	Ingo Flaschberger
 

From: Ingo Flaschberger <if@xip.at>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/150481: IFA_RTSELF: freebsd 8.1 - ifdown - ifup - loopback
 route keeps
Date: Sat, 2 Apr 2011 16:52:45 +0200 (CEST)

 Hi,
 
 why is this patch not in FreeBSD 8.2 Release?
 
 Kind regards,
  	Ingo Flaschberger

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/150481: commit references a PR
Date: Tue, 12 Apr 2011 11:17:58 +0000 (UTC)

 Author: bz
 Date: Tue Apr 12 11:17:46 2011
 New Revision: 220564
 URL: http://svn.freebsd.org/changeset/base/220564
 
 Log:
   MFC r212502 (qingli):
   
     Adding an address on an interface also requires the loopback route to
     that address be installed.
   
     Submitted by:	Ingo Flaschberger <if at xip.at>
   PR:		kern/150481
 
 Modified:
   stable/8/sys/netinet/raw_ip.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
 
 Modified: stable/8/sys/netinet/raw_ip.c
 ==============================================================================
 --- stable/8/sys/netinet/raw_ip.c	Tue Apr 12 09:55:24 2011	(r220563)
 +++ stable/8/sys/netinet/raw_ip.c	Tue Apr 12 11:17:46 2011	(r220564)
 @@ -755,6 +755,8 @@ rip_ctlinput(int cmd, struct sockaddr *s
  		if (err == 0)
  			ia->ia_flags |= IFA_ROUTE;
  		err = ifa_add_loopback_route((struct ifaddr *)ia, sa);
 +		if (err == 0)
 +			ia->ia_flags |= IFA_RTSELF;
  		ifa_free(&ia->ia_ifa);
  		break;
  	}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: bz 
State-Changed-When: Tue Apr 12 12:53:16 UTC 2011 
State-Changed-Why:  
I merged it to stable/8 now.  Not sure why it was not done before. 
Thanks a lot for reporting. 

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