From owner-freebsd-net@FreeBSD.ORG Thu Sep 20 23:54:30 2007 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B22B16A417 for ; Thu, 20 Sep 2007 23:54:30 +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 A6F2513C458 for ; Thu, 20 Sep 2007 23:54:29 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: by heff.fud.org.nz (Postfix, from userid 1001) id B39921CC26; Fri, 21 Sep 2007 11:54:27 +1200 (NZST) Date: Fri, 21 Sep 2007 11:54:27 +1200 From: Andrew Thompson To: FreeBSD-net Message-ID: <20070920235427.GA46172@heff.fud.org.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: ifconfig patch X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Sep 2007 23:54:30 -0000 --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I have been digging into why the edsc module wasnt being loaded by ifconfig and now have a patch. A few printfs showed the problem. # ifconfig edsc0 create ifmaybeload(edsc0) trying to find if_edsc or edsc0 found @ ed Its comparing using the string length of the module name so any partial matches are going through. I have changed it so it strips the number from the interface name and uses the full string to match. I want to ask re@ soon so any feedback would be great. Andrew --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ifconfig_kldload.diff" Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.133 diff -u -p -r1.133 ifconfig.c --- ifconfig.c 13 Jun 2007 18:07:59 -0000 1.133 +++ ifconfig.c 20 Sep 2007 23:47:28 -0000 @@ -897,7 +897,7 @@ ifmaybeload(const char *name) { struct module_stat mstat; int fileid, modid; - char ifkind[35], *dp; + char ifkind[35], ifname[32], *dp; const char *cp; /* loading suppressed by the user */ @@ -911,6 +911,12 @@ ifmaybeload(const char *name) *dp = *cp; *dp = 0; + /* trim the interface number off the end */ + strcpy(ifname, name); + for (dp = ifname; *dp != 0; dp++) + if (isdigit(*dp)) + *dp = '\0'; + /* scan files in kernel */ mstat.version = sizeof(struct module_stat); for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { @@ -926,8 +932,8 @@ ifmaybeload(const char *name) cp = mstat.name; } /* already loaded? */ - if (strncmp(name, cp, strlen(cp)) == 0 || - strncmp(ifkind, cp, strlen(cp)) == 0) + if (strncmp(ifname, cp, strlen(ifname)) == 0 || + strncmp(ifkind, cp, strlen(ifkind)) == 0) return; } } --fdj2RfSjLxBAspz7--