From owner-freebsd-bugs@FreeBSD.ORG Fri Jun 17 18:10:20 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 18EAE16A41C for ; Fri, 17 Jun 2005 18:10:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E532443D53 for ; Fri, 17 Jun 2005 18:10:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j5HIAJt7030729 for ; Fri, 17 Jun 2005 18:10:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j5HIAJum030728; Fri, 17 Jun 2005 18:10:19 GMT (envelope-from gnats) Resent-Date: Fri, 17 Jun 2005 18:10:19 GMT Resent-Message-Id: <200506171810.j5HIAJum030728@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nuno Antunes Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 71AB516A427 for ; Fri, 17 Jun 2005 18:05:16 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 38A0643D66 for ; Fri, 17 Jun 2005 18:05:09 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j5HI58hR062663 for ; Fri, 17 Jun 2005 18:05:08 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j5HI58hv062662; Fri, 17 Jun 2005 18:05:08 GMT (envelope-from nobody) Message-Id: <200506171805.j5HI58hv062662@www.freebsd.org> Date: Fri, 17 Jun 2005 18:05:08 GMT From: Nuno Antunes To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: bin/82367: [PATCH] ifconfig ifname.tag does not automatically load if_vlan module X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2005 18:10:20 -0000 >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 . 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: