From nobody@FreeBSD.org  Fri Apr  9 05:23:03 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 E2C07106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Apr 2010 05:23:03 +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 D28228FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Apr 2010 05:23:03 +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 o395N3PU032574
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 9 Apr 2010 05:23:03 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o395N37B032573;
	Fri, 9 Apr 2010 05:23:03 GMT
	(envelope-from nobody)
Message-Id: <201004090523.o395N37B032573@www.freebsd.org>
Date: Fri, 9 Apr 2010 05:23:03 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [sysinstall] fix default route
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145553
>Category:       bin
>Synopsis:       [patch] sysinstall(8): fix default route
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    brucec
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 09 05:31:26 UTC 2010
>Closed-Date:    Wed Jun 16 15:51:33 UTC 2010
>Last-Modified:  Sun Feb 03 22:28:36 UTC 2013
>Originator:     Garrett Cooper
>Release:        9-CURRENT
>Organization:
Cisco Systems, Inc.
>Environment:
FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #3 r206173M: Mon Apr  5 12:12:29 PDT 2010     root@bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA  amd64
>Description:
If a route has already been setup, and the network interface is `reinitialized', the old route won't be deleted beforehand like it should, causing networking problems.

This fixes that.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: network.c
===================================================================
--- network.c	(revision 206173)
+++ network.c	(working copy)
@@ -132,8 +132,7 @@
 	 */
 	if (strstr(cp, "DHCP") == NULL) {
 	    msgDebug("Not a DHCP interface.\n");
-	    i = vsystem("ifconfig %s %s", dev->name, cp);
-	    if (i) {
+	    if (vsystem("ifconfig %s %s", dev->name, cp) != 0) {
 		msgConfirm("Unable to configure the %s interface!\n"
 			   "This installation method cannot be used.",
 			   dev->name);
@@ -141,12 +140,22 @@
 	    }
 	    rp = variable_get(VAR_GATEWAY);
 	    if (!rp || *rp == '0') {
-		msgConfirm("No gateway has been set. You may be unable to access hosts\n"
+		msgConfirm("No gateway has been set. You will be unable to access hosts\n"
 			   "not on your local network");
 	    }
 	    else {
+		/* 
+		 * Explicitly flush all routes to get back to a known sane
+		 * state. We don't need to check this exit code because if
+		 * anything fails it will show up in the route add below.
+		 */
+		system("route -n flush");
 		msgDebug("Adding default route to %s.\n", rp);
-		vsystem("route -n add default %s", rp);
+		if (vsystem("route -n add default %s", rp) != 0) {
+		    msgConfirm("Failed to add a default route; please check "
+			       "your network configuration");
+		    return FALSE;
+		}
 	    }
 	} else {
 	    msgDebug("A DHCP interface.  Should already be up.\n");


>Release-Note:
>Audit-Trail:

From: Garrett Cooper <yaneurabeya@gmail.com>
To: bug-followup <bug-followup@freebsd.org>
Cc:  
Subject: Re: bin/145553: [patch] [sysinstall] fix default route
Date: Mon, 12 Apr 2010 01:22:31 -0700

 Just tested via qemu, and patch does indeed deliver as expected.
 
 Verified with the following steps:
 
 1. Booted cd image.
 2. Specified the following via loader(8):
 
 set init_path=/usr/sbin/sysinstall
 set vfs.root.mountfrom=cd9660:/dev/acd0
 
 3. Selected appropriate locale.
 4. Brought up FIXIT shell.
 5. Prepared necessary filesystems:
 
 for i in 0:256M 1:10M 2:10M; do
     mdconfig -a -t malloc -s ${i##*:}
     newfs /dev/md${i##%:*}
 done
 
 mount /dev/md0 /tmp
 mount /dev/md1 /var
 mount /dev/md2 /tmp
 cp -Rfp /etc/ /tmp
 umount /tmp
 mount /dev/md2 /etc
 
 6. Stepped through procedure as usual with partitioning and labeling.
 7. Chose minimum for the distribution.
 8. Set the medium to ftp.freebsd.org
 9. Provided bogus static IP for the first try.
 10. Switched to vty3 and noted default route (was bogus route).
 11. Pressed CTRL-C after it tried to connect to said address,
 restarted sysinstall.
 12. Repeated steps 5. - 11., but provided valid IP data to sysinstall.
 Interface came up and route changed as expected; route(8) didn't
 complain that the default route already existed (symptom of previous
 behavior). vty1 also reported the route change.
 
 Thanks,
 -Garrett

From: Garrett Cooper <yaneurabeya@gmail.com>
To: bug-followup <bug-followup@freebsd.org>
Cc: randi@freebsd.org
Subject: Re: bin/145553: [patch] [sysinstall] fix default route
Date: Mon, 12 Apr 2010 01:31:54 -0700

 On Mon, Apr 12, 2010 at 1:22 AM, Garrett Cooper <yaneurabeya@gmail.com> wrote=
 > 6. Stepped through procedure as usual with partitioning and labeling.
 > 7. Chose minimum for the distribution.
 > 8. Set the medium to ftp.freebsd.org
 > 9. Provided bogus static IP for the first try.
 > 10. Switched to vty3 and noted default route (was bogus route).
 > 11. Pressed CTRL-C after it tried to connect to said address,
 > restarted sysinstall.
 > 12. Repeated steps 5. - 11., but provided valid IP data to sysinstall.
 
 Correction: steps _6._ - 11.
 
 > Interface came up and route changed as expected; route(8) didn't
 > complain that the default route already existed (symptom of previous
 > behavior). vty1 also reported the route change.
 
 Thanks,
 -Garrett
Responsible-Changed-From-To: freebsd-bugs->brucec 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Fri Apr 30 18:56:21 UTC 2010 
Responsible-Changed-Why:  
Take. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/145553: commit references a PR
Date: Sat, 22 May 2010 00:43:25 +0000 (UTC)

 Author: randi
 Date: Sat May 22 00:43:14 2010
 New Revision: 208407
 URL: http://svn.freebsd.org/changeset/base/208407
 
 Log:
   Flush all routes before adding the default route in order to allow
   sysinstall to cleanly re-initialize the network.
   
   PR: bin/145553
   Submitted by: gcooper
   Approved by: cperciva (mentor)
   MFC after: 3 days
 
 Modified:
   head/usr.sbin/sysinstall/network.c
 
 Modified: head/usr.sbin/sysinstall/network.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/network.c	Fri May 21 23:08:53 2010	(r208406)
 +++ head/usr.sbin/sysinstall/network.c	Sat May 22 00:43:14 2010	(r208407)
 @@ -141,12 +141,22 @@ mediaInitNetwork(Device *dev)
  	    }
  	    rp = variable_get(VAR_GATEWAY);
  	    if (!rp || *rp == '0') {
 -		msgConfirm("No gateway has been set. You may be unable to access hosts\n"
 +		msgConfirm("No gateway has been set. You will be unable to access hosts\n"
  			   "not on your local network");
  	    }
  	    else {
 +		/* 
 +		 * Explicitly flush all routes to get back to a known sane
 +		 * state. We don't need to check this exit code because if
 +		 * anything fails it will show up in the route add below.
 +		 */
 +		system("route -n flush");
  		msgDebug("Adding default route to %s.\n", rp);
 -		vsystem("route -n add default %s", rp);
 +		if (vsystem("route -n add default %s", rp) != 0) {
 +		    msgConfirm("Failed to add a default route; please check "
 +			       "your network configuration");
 +		    return FALSE;
 +		}
  	    }
  	} else {
  	    msgDebug("A DHCP interface.  Should already be up.\n");
 _______________________________________________
 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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/145553: commit references a PR
Date: Tue, 25 May 2010 03:09:02 +0000 (UTC)

 Author: randi
 Date: Tue May 25 03:08:47 2010
 New Revision: 208529
 URL: http://svn.freebsd.org/changeset/base/208529
 
 Log:
   MFC r208407:
     Flush all routes before adding the default route in order to allow
     sysinstall to cleanly re-initialize the network.
   
   PR: bin/145553
   Submitted by: gcooper
   Approved by: cperciva (mentor)
 
 Modified:
   stable/8/usr.sbin/sysinstall/network.c
 Directory Properties:
   stable/8/usr.sbin/sysinstall/   (props changed)
 
 Modified: stable/8/usr.sbin/sysinstall/network.c
 ==============================================================================
 --- stable/8/usr.sbin/sysinstall/network.c	Tue May 25 02:52:10 2010	(r208528)
 +++ stable/8/usr.sbin/sysinstall/network.c	Tue May 25 03:08:47 2010	(r208529)
 @@ -141,12 +141,22 @@ mediaInitNetwork(Device *dev)
  	    }
  	    rp = variable_get(VAR_GATEWAY);
  	    if (!rp || *rp == '0') {
 -		msgConfirm("No gateway has been set. You may be unable to access hosts\n"
 +		msgConfirm("No gateway has been set. You will be unable to access hosts\n"
  			   "not on your local network");
  	    }
  	    else {
 +		/* 
 +		 * Explicitly flush all routes to get back to a known sane
 +		 * state. We don't need to check this exit code because if
 +		 * anything fails it will show up in the route add below.
 +		 */
 +		system("route -n flush");
  		msgDebug("Adding default route to %s.\n", rp);
 -		vsystem("route -n add default %s", rp);
 +		if (vsystem("route -n add default %s", rp) != 0) {
 +		    msgConfirm("Failed to add a default route; please check "
 +			       "your network configuration");
 +		    return FALSE;
 +		}
  	    }
  	} else {
  	    msgDebug("A DHCP interface.  Should already be up.\n");
 _______________________________________________
 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->closed  
State-Changed-By: brucec 
State-Changed-When: Wed Jun 16 15:51:07 UTC 2010 
State-Changed-Why:  
Fixed in head and stable/8. 

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