Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2005 18:05:08 GMT
From:      Nuno Antunes <nuno.antunes@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/82367: [PATCH] ifconfig ifname.tag does not automatically load if_vlan module
Message-ID:  <200506171805.j5HI58hv062662@www.freebsd.org>
Resent-Message-ID: <200506171810.j5HIAJum030728@freefall.freebsd.org>

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

>Number:         82367
>Category:       bin
>Synopsis:       [PATCH] ifconfig ifname.tag does not automatically load if_vlan module
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 17 18:10:19 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Nuno Antunes
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD Zuul 6.0-CURRENT FreeBSD 6.0-CURRENT #6: Wed Jun 8 17:48:16 WEST 2005 sdx@Zuul:/usr/obj/usr/src/sys/ZUUL i386
>Description:
      When creating a vlan interface using the ifname.tag syntax, ifconfig  does not automatically load the required if_vlan module.
>How-To-Repeat:
      Creating a a vlan interface using the ifconfig ifname.tag syntax whithout the if_vlan module loaded or statically compliled to the kernel will trigger this.

        # ifconfig rl0.10
        ifconfig: SIOCIFCREATE: Invalid argument
>Fix:
      I think the following patch solves the problem. (This is my first pr and patch, so please analyse code carefully as it might be wrong).

Please take special attention to the removed comparisson of the interface full name to the module name on the check for already loaded modules. This might break loading interface modules whose name ends in a digit (or others). But if the comparisson is kept it will prevent if_vlan from loading, because for example strncmp("rl0.10,  "rl0", 3) == 0 will make the function return prematurely. Is there a better way to prevent this?

Sorry for sending code via the web send-pr interface but I could not send it otherwise.



--- ifconfig.c.orig     Fri Jun 17 14:47:38 2005
+++ ifconfig.c  Fri Jun 17 16:08:19 2005
@@ -966,12 +966,18 @@
        int fileid, modid;
        char ifkind[35], *cp, *dp;

-       /* turn interface and unit into module name */
-       strcpy(ifkind, "if_");
-       for (cp = name, dp = ifkind + 3;
-           (*cp != 0) && !isdigit(*cp); cp++, dp++)
-               *dp = *cp;
-       *dp = 0;
+       /* is the interface name in the <ifname>.<tag> format? */
+       if (index(name, '.') != NULL) {
+               strcpy(ifkind, "if_vlan");
+       }
+       else {
+               /* turn interface and unit into module name */
+               strncpy(ifkind, "if_", sizeof(ifkind));
+               for (cp = name, dp = ifkind + 3;
+                   (*cp != 0) && !isdigit(*cp); cp++, dp++)
+                       *dp = *cp;
+               *dp = 0;
+       }

        /* scan files in kernel */
        mstat.version = sizeof(struct module_stat);
@@ -988,8 +994,7 @@
                                cp = mstat.name;
                        }
                        /* already loaded? */
-                       if (strncmp(name, cp, strlen(cp)) == 0 ||
-                           strncmp(ifkind, cp, strlen(cp)) == 0)
+                       if (strncmp(ifkind, cp, strlen(cp)) == 0)
                                return;
                }
        }

>Release-Note:
>Audit-Trail:
>Unformatted:



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