From owner-freebsd-net@FreeBSD.ORG Wed Apr 30 18:50:12 2008 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 36C431065673 for ; Wed, 30 Apr 2008 18:50:12 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (cl-162.ewr-01.us.sixxs.net [IPv6:2001:4830:1200:a1::2]) by mx1.freebsd.org (Postfix) with ESMTP id CAF268FC17 for ; Wed, 30 Apr 2008 18:50:11 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.2/8.14.2) with ESMTP id m3UIoMP1099579; Wed, 30 Apr 2008 13:50:22 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.2/8.14.2/Submit) id m3UIoM9h099578; Wed, 30 Apr 2008 13:50:22 -0500 (CDT) (envelope-from brooks) Date: Wed, 30 Apr 2008 13:50:21 -0500 From: Brooks Davis To: Niki Denev Message-ID: <20080430185021.GA99435@lor.one-eyed-alien.net> References: <2e77fc10804301101i57c73a32n8273f7a8a96b7e6f@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline In-Reply-To: <2e77fc10804301101i57c73a32n8273f7a8a96b7e6f@mail.gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (lor.one-eyed-alien.net [127.0.0.1]); Wed, 30 Apr 2008 13:50:22 -0500 (CDT) Cc: freebsd-net@freebsd.org Subject: Re: [PATCH] autoload if_vlan.ko on vlan creation 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: Wed, 30 Apr 2008 18:50:12 -0000 --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 30, 2008 at 02:01:21PM -0400, Niki Denev wrote: > Hi, >=20 > I've noticed that autoloading of if_vlan.ko on vlan creation does not > work in the case when the vlans are specified with the interface name. > i.e. : fxp0.5 And the problem is that ifmaybeload() in ifconfig.c > expects that all interfaces are in the format : if_${driver}${number}, > which is not the case for vlans created in the above mentioned way > (which is much more easier and intuitive IMHO) This patch fixes this > for me, and probably others may find it useful. What is the practical use of this feature? If you don't have the module loaded, the rc scripts won't even see the interface unless you manually set network_interfaces which has been documented as a deprecated configuration since 6.2 and will soon generate warnings in 7-stable. If you want to use an interface, why not add an appropriate entry to /boot/loader.conf and be done with it? -- Brooks > P.S.: Because of the assumption for the interface name that > ifmaybeload() does, this patch looks more like a hack and probably a > better way could be found for handling this case. P.S2: If "ifconfig > fxp0." is typed this will autoload if_vlan.ko because we have a dot > after the first number in the interface name (there is no check if > there are other digits after the dot). I'm not sure if a more strict > check is needed though because I can't imagine this can cause any real > problems. > >=20 > --- ifconfig.c.orig 2008-04-30 12:29:25.000000000 -0400 > +++ ifconfig.c 2008-04-30 12:44:50.000000000 -0400 > @@ -935,18 +935,21 @@ > if (noload) > return; >=20 > - /* trim the interface number off the end */ > + /* locate interface number beginning */ > strlcpy(ifname, name, sizeof(ifname)); > for (dp =3D ifname; *dp !=3D 0; dp++) > - if (isdigit(*dp)) { > - *dp =3D 0; > + if (isdigit(*dp)) > break; > - } >=20 > - /* turn interface and unit into module name */ > - strcpy(ifkind, "if_"); > - strlcpy(ifkind + MOD_PREFIX_LEN, ifname, > - sizeof(ifkind) - MOD_PREFIX_LEN); > + /* check the special case for vlan interfaces */ > + if (strchr(dp, '.')) { > + strcpy(ifkind, "if_vlan"); > + } else { > + /* turn interface and unit into module name */ > + strcpy(ifkind, "if_"); > + strlcpy(ifkind + MOD_PREFIX_LEN, ifname, > + sizeof(ifkind) - MOD_PREFIX_LEN); > + } >=20 > /* scan files in kernel */ > mstat.version =3D sizeof(struct module_stat); > --- ifconfig.c.orig 2008-04-30 12:29:25.000000000 -0400 > +++ ifconfig.c 2008-04-30 12:44:50.000000000 -0400 > @@ -935,18 +935,21 @@ > if (noload) > return; > =20 > - /* trim the interface number off the end */ > + /* locate interface number beginning */ > strlcpy(ifname, name, sizeof(ifname)); > for (dp =3D ifname; *dp !=3D 0; dp++) > - if (isdigit(*dp)) { > - *dp =3D 0; > + if (isdigit(*dp)) > break; > - } > =20 > - /* turn interface and unit into module name */ > - strcpy(ifkind, "if_"); > - strlcpy(ifkind + MOD_PREFIX_LEN, ifname, > - sizeof(ifkind) - MOD_PREFIX_LEN); > + /* check the special case for vlan interfaces */ > + if (strchr(dp, '.')) { > + strcpy(ifkind, "if_vlan"); > + } else { > + /* turn interface and unit into module name */ > + strcpy(ifkind, "if_"); > + strlcpy(ifkind + MOD_PREFIX_LEN, ifname, > + sizeof(ifkind) - MOD_PREFIX_LEN); > + } > =20 > /* scan files in kernel */ > mstat.version =3D sizeof(struct module_stat); > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iD8DBQFIGL9tXY6L6fI4GtQRAgm2AJ9iuk9gxNQv2KGYKWO12XhCPnqbhwCfW8+k n0CgByPsxk3xfMcl5cUwMQ8= =BiHs -----END PGP SIGNATURE----- --7JfCtLOvnd9MIVvH--