From nobody Thu May 18 15:24:44 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QMYgK27tkz4Bh8h; Thu, 18 May 2023 15:24:45 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QMYgK1XTlz4Ld5; Thu, 18 May 2023 15:24:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684423485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bV86ibr1pPq+J5vj25eLu77lqK+DnadqowEONN+y+qM=; b=IAq9RDi56TjD9WQAhUrbq2K/b1fkd8OKgjw8rOa09/B1VZoNfkOaaol6ajpv1cunBgKYcL zy+qtqwnyQT59gYQ46TifoJi4unHBVMPyihZftGTgR1fysj6AN/wpAr5vv4dUu63mHr0tj akIJPVRVlVEeXMx2sSWjxXqnEecJBFW0J4Vvpr3uhbVoxtAX1Ae4fCd1tNqL2FaS4JNseE HUac1uuWB5ZQH6EKeAb6NlsffvTwbbsUNM5hYvnGX0wrulNqA9tZmNwEF0GCKH9iQVIbu+ xd9b4nM7ZHZHdn3oYc+cIpxaXkuec2J3C+CkKNbk3E/670WEOEUzzu4btsyFVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684423485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bV86ibr1pPq+J5vj25eLu77lqK+DnadqowEONN+y+qM=; b=ZdweUx50wsUNVWKZMUHfMvyVaL4r5X2EWIxQ0XaeGpb3HwPoTSYMidQCrzjl1v1C1uuYkv wJxodeSBlTsy0CclhEYldMxvoDJ8PTj90xaBAmyXq5o6iQuYc/UAMqQ9hDUtfJ1IjoeUwe 9ongFmX7OF68IU4dCdsyU/k/2UYWGfijCzBdtUFkitAXEajbrMeOjxQbGxxzTPrFv3YfvD eoKX0iF6QqNp7/0tA9qtxyQg63vgFWCGdaPAJRGr7X+flQRUGxUHJQOzdny0AZ4PFCH3zw TdmUqe+yANawefLnot1L+8nBb3XoLA3ReZXeNn/qOeE5m1IMAJc1SPcKTLrUbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684423485; a=rsa-sha256; cv=none; b=dut/tXxEzGqlcuWamj+KhJ9WfmxBf/aGTOZfl4GIj364ZebwZX+Xk0T8LZp4+uzDsGEGdy zTM/3Cp/CYaSWkINyL4ReN4SiV8RjHLVXAT5xzRWF/X4YeutOFymqxnbyBYdKXUMxOv6hH ixqCCSn6kLd7ERVeUL9d4s6UPjPlu89WiItsLPtV5y8gsx9/Juyq+DZBCzY+iboXIOtHAA KS85A4oa97fiYEW++sMMqM3CXKRzbz7GGBLfqFNErrcsCif2GxF5CAviDDgqBaWJLZ+/yc y1MncAvfGcg788r53vsLTQHHnWTWLe1ttFiNfIHfCPdlWamw3t7rBrRFp9Vr5A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QMYgK0TQwzr5Z; Thu, 18 May 2023 15:24:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34IFOiEZ053762; Thu, 18 May 2023 15:24:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34IFOiLv053761; Thu, 18 May 2023 15:24:44 GMT (envelope-from git) Date: Thu, 18 May 2023 15:24:44 GMT Message-Id: <202305181524.34IFOiLv053761@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 2e6756b752e0 - main - ifconfig: improve trimming off interface number at end List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e6756b752e07878ae5f5e3e9b74934231f9fd17 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=2e6756b752e07878ae5f5e3e9b74934231f9fd17 commit 2e6756b752e07878ae5f5e3e9b74934231f9fd17 Author: Bjoern A. Zeeb AuthorDate: 2023-05-17 20:40:47 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-05-18 15:22:53 +0000 ifconfig: improve trimming off interface number at end When trying to auto-load a module, we trim the interface number off the end. Currently we stop at the first digit. For interfaces which have numbers in the driver name this does not work well. In the current example ifconfig ath10k0 would load ath(4) instead of ath10k(4). For module/interface names like rtw88[0] we never guess correctly. To improve for the case we can, start trimming off digits from the end rather than the front. Sponsored by: The FreeBSD Foundation Reported by: thierry MFC after: 20 days Reviewed by: melifaro, thierry Differential Revision: https://reviews.freebsd.org/D40137 --- sbin/ifconfig/ifconfig.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 7872c2b336a5..8c3a7b4c0007 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1752,11 +1752,13 @@ ifmaybeload(struct ifconfig_args *args, const char *name) /* trim the interface number off the end */ strlcpy(ifname, name, sizeof(ifname)); - for (dp = ifname; *dp != 0; dp++) - if (isdigit(*dp)) { - *dp = 0; + dp = ifname + strlen(ifname) - 1; + for (; dp > ifname; dp--) { + if (isdigit(*dp)) + *dp = '\0'; + else break; - } + } /* Either derive it from the map or guess otherwise */ *ifkind = '\0';