From owner-svn-src-all@freebsd.org Wed Dec 9 20:13:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E73D24AE614; Wed, 9 Dec 2020 20:13:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CrpBw6Fpxz3pVF; Wed, 9 Dec 2020 20:13:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BF2373E66; Wed, 9 Dec 2020 20:13:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0B9KDCgd083176; Wed, 9 Dec 2020 20:13:12 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0B9KDCAg083174; Wed, 9 Dec 2020 20:13:12 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202012092013.0B9KDCAg083174@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 9 Dec 2020 20:13:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368492 - head/sbin/ifconfig X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sbin/ifconfig X-SVN-Commit-Revision: 368492 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2020 20:13:13 -0000 Author: hselasky Date: Wed Dec 9 20:13:12 2020 New Revision: 368492 URL: https://svnweb.freebsd.org/changeset/base/368492 Log: Fix bug in ifconfig preventing proper VLAN creation. Detection of interface type by filter must happen before detection of interface type by prefix. Else the following sequence of commands will try to create a LAGG interface instead of a VLAN interface, which accidentially worked previously, because the date pointed to by the ifr_data pointer was not parsed by VLAN create ioctl(2). This is a regression after r368229, because the VLAN creation now parses the ifr_data field. How to reproduce: # ifconfig lagg0 create # ifconfig lagg0.256 create Differential Revision: https://reviews.freebsd.org/D27521 Reviewed by: kib@ and kevans@ Reported by: raul.munoz@custos.es Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sbin/ifconfig/ifclone.c Modified: head/sbin/ifconfig/ifclone.c ============================================================================== --- head/sbin/ifconfig/ifclone.c Wed Dec 9 20:06:37 2020 (r368491) +++ head/sbin/ifconfig/ifclone.c Wed Dec 9 20:13:12 2020 (r368492) @@ -128,32 +128,32 @@ ifclonecreate(int s, void *arg) { struct ifreq ifr; struct clone_defcb *dcp; - clone_callback_func *clone_cb = NULL; memset(&ifr, 0, sizeof(ifr)); (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (clone_cb == NULL) { - /* Try to find a default callback */ + /* Try to find a default callback by filter */ + SLIST_FOREACH(dcp, &clone_defcbh, next) { + if (dcp->clone_mt == MT_FILTER && + dcp->ifmatch(ifr.ifr_name) != 0) + break; + } + + if (dcp == NULL) { + /* Try to find a default callback by prefix */ SLIST_FOREACH(dcp, &clone_defcbh, next) { - if ((dcp->clone_mt == MT_PREFIX) && - (strncmp(dcp->ifprefix, ifr.ifr_name, - strlen(dcp->ifprefix)) == 0)) { - clone_cb = dcp->clone_cb; + if (dcp->clone_mt == MT_PREFIX && + strncmp(dcp->ifprefix, ifr.ifr_name, + strlen(dcp->ifprefix)) == 0) break; - } - if ((dcp->clone_mt == MT_FILTER) && - dcp->ifmatch(ifr.ifr_name)) { - clone_cb = dcp->clone_cb; - break; - } } } - if (clone_cb == NULL) { + + if (dcp == NULL || dcp->clone_cb == NULL) { /* NB: no parameters */ ioctl_ifcreate(s, &ifr); } else { - clone_cb(s, &ifr); + dcp->clone_cb(s, &ifr); } /*