From owner-freebsd-current@FreeBSD.ORG Mon May 21 21:23:12 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 11B0416A41F; Mon, 21 May 2007 21:23:12 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from heff.fud.org.nz (203-109-251-39.static.bliink.ihug.co.nz [203.109.251.39]) by mx1.freebsd.org (Postfix) with ESMTP id 36DC513C44C; Mon, 21 May 2007 21:23:11 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: by heff.fud.org.nz (Postfix, from userid 1001) id 28A191CC5A; Tue, 22 May 2007 09:23:09 +1200 (NZST) Date: Tue, 22 May 2007 09:23:09 +1200 From: Andrew Thompson To: Fredrik Lindberg Message-ID: <20070521212309.GA4320@heff.fud.org.nz> References: <4645E8A2.1040408@FreeBSD.org> <20070512202004.GA71624@heff.fud.org.nz> <46462CB2.9050008@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline In-Reply-To: <46462CB2.9050008@FreeBSD.org> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: yar@freebsd.org, freebsd-current@freebsd.org Subject: Re: Network interface modules keeps re-loading X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2007 21:23:12 -0000 --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, May 12, 2007 at 11:08:02PM +0200, Fredrik Lindberg wrote: > Andrew Thompson wrote: > > > >A similar solution to this was committed in rev1.129 of ifconfig.c but > >then backed out later as the module loading proved to be feature used by > >quite a few people. I think an example was being able to load and > >initialise an interface by just trying 'ifconfig foo0'. > > > >I think a different way to solve this is to add a argument to ifconfig > >to suppress the module loading and then use it at the appropriate places > >in rc. > > > > Oh, I should have read the commit logs first, sorry about that. > Either way, I think something should be done about it. It certainly > annoyed me today before I could figure out what as going on. > When somebody issues a kldunload, they shouldn't get the module > re-loaded right away. > > Clearly people want the current behavior (although I question it > myself), what would be an appropriate way to suppress loading? > ifconfig -n foo0, as in no-probe/load? Here is a patch to do this, i'll commit it unless there are any objections. Andrew --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ifconfig-load.diff" Index: ifconfig.8 =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.8,v retrieving revision 1.137 diff -u -p -r1.137 ifconfig.8 --- ifconfig.8 17 Apr 2007 00:35:09 -0000 1.137 +++ ifconfig.8 21 May 2007 21:15:18 -0000 @@ -1579,6 +1579,11 @@ For example, the values of 802.11 WEP ke the current user. This information is not printed by default, as it may be considered sensitive. +.Pp +If the network interface driver is not present in the kernel then the module +will be loaded, the +.Fl n +flag suppresses this. .Pp Only the super-user may modify the configuration of a network interface. .Sh NOTES Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.130 diff -u -p -r1.130 ifconfig.c --- ifconfig.c 24 Mar 2007 20:26:54 -0000 1.130 +++ ifconfig.c 21 May 2007 21:16:12 -0000 @@ -139,7 +139,7 @@ usage(void) int main(int argc, char *argv[]) { - int c, all, namesonly, downonly, uponly; + int c, all, namesonly, downonly, uponly, noload; const struct afswtch *afp = NULL; int ifindex; struct ifaddrs *ifap, *ifa; @@ -150,10 +150,10 @@ main(int argc, char *argv[]) struct option *p; size_t iflen; - all = downonly = uponly = namesonly = verbose = 0; + all = downonly = uponly = namesonly = noload = verbose = 0; /* Parse leading line options */ - strlcpy(options, "adklmuv", sizeof(options)); + strlcpy(options, "adklmnuv", sizeof(options)); for (p = opts; p != NULL; p = p->next) strlcat(options, p->opt, sizeof(options)); while ((c = getopt(argc, argv, options)) != -1) { @@ -173,6 +173,9 @@ main(int argc, char *argv[]) case 'm': /* show media choices in status */ supmedia = 1; break; + case 'n': /* suppress module loading */ + noload++; + break; case 'u': /* restrict scan to "up" interfaces */ uponly++; break; @@ -898,6 +901,10 @@ ifmaybeload(const char *name) char ifkind[35], *dp; const char *cp; + /* loading suppressed by the user */ + if (noload) + return; + /* turn interface and unit into module name */ strcpy(ifkind, "if_"); for (cp = name, dp = ifkind + 3; --C7zPtVaVf+AK4Oqc--