Subject: bin/9629: ifconfig media option may have unintended side effects
To: None <gnats-bugs@gnats.netbsd.org>
From: Castor Fu <castor@swamp.sfo.geocast.net>
List: netbsd-bugs
Date: 03/17/2000 11:30:42
>Number: 9629
>Category: bin
>Synopsis: ifconfig media option may have unintended side effects
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 17 11:24:00 2000
>Last-Modified:
>Originator: Castor Fu
>Organization:
Geocast Network Systems
>Release: current 2000-01-25
>Environment:
Dell Precision 610, Intel Xeon 450 MHz processor,
NetBSD-current, Sohoware NDC100 nic, rev B4.
System: NetBSD foo.sfo.geocast.net 1.4P NetBSD 1.4P (GEO_STANDARD) #63: Fri Mar 17 02:27:55 PST 2000 castor@foo.sfo.geocast.net:/usr/src/sys/arch/i386/compile/GEO_STANDARD i386
>Description:
The interface flags can get scrambled by ifconfig when
using the media options.
>How-To-Repeat:
ifconfig tlp0 media 100BaseTX-FDX 10.1.1.1 up
>Fix:
Index: ifconfig.c
===================================================================
RCS file: /d2/cvsroot/nb/usr/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 ifconfig.c
--- ifconfig.c 2000/02/16 05:20:45 1.1.1.7
+++ ifconfig.c 2000/03/17 19:04:53
@@ -121,7 +121,7 @@
#include <string.h>
#include <unistd.h>
-struct ifreq ifr, ridreq;
+struct ifreq ifr, ridreq, ifflags;
struct ifaliasreq addreq __attribute__((aligned(4)));
#ifdef INET6
struct in6_ifreq ifr6;
@@ -550,7 +550,7 @@
if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
warn("SIOCAIFADDR");
}
- if (reset_if_flags && ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
+ if (reset_if_flags && ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifflags) < 0)
err(1, "SIOCSIFFLAGS");
exit(0);
}
@@ -835,6 +835,7 @@
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
err(1, "SIOCSIFFLAGS");
+ ifflags = ifr;
reset_if_flags = 1;
}
>Audit-Trail:
>Unformatted: