[PATCH] autoload if_vlan.ko on vlan creation

Niki Denev nike_d at cytexbg.com
Wed Apr 30 18:29:56 UTC 2008


Hi,

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.

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.

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

-    /* trim the interface number off the end */
+    /* locate interface number beginning */
     strlcpy(ifname, name, sizeof(ifname));
     for (dp = ifname; *dp != 0; dp++)
-        if (isdigit(*dp)) {
-            *dp = 0;
+        if (isdigit(*dp))
             break;
-        }

-    /* 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);
+    }

     /* scan files in kernel */
     mstat.version = sizeof(struct module_stat);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifconfig-vlan_create.patch
Type: text/x-patch
Size: 912 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20080430/6c62825f/ifconfig-vlan_create.bin


More information about the freebsd-net mailing list