Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Apr 2008 13:50:21 -0500
From:      Brooks Davis <brooks@freebsd.org>
To:        Niki Denev <nike_d@cytexbg.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: [PATCH] autoload if_vlan.ko on vlan creation
Message-ID:  <20080430185021.GA99435@lor.one-eyed-alien.net>
In-Reply-To: <2e77fc10804301101i57c73a32n8273f7a8a96b7e6f@mail.gmail.com>
References:  <2e77fc10804301101i57c73a32n8273f7a8a96b7e6f@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080430185021.GA99435>