Date: Fri, 9 Apr 2010 05:23:03 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/145553: [patch] [sysinstall] fix default route Message-ID: <201004090523.o395N37B032573@www.freebsd.org> Resent-Message-ID: <201004090531.o395VQKY043812@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 145553 >Category: bin >Synopsis: [patch] [sysinstall] fix default route >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Apr 09 05:31:26 UTC 2010 >Closed-Date: >Last-Modified: >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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004090523.o395N37B032573>