From nobody Mon Jun 26 12:08:24 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 4QqRSm3lZ3z4k6fd; Mon, 26 Jun 2023 12:08:24 +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 4QqRSm2n5lz3hL8; Mon, 26 Jun 2023 12:08:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687781304; 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=F4NVJPve5H524fydqi/XeKGR9QZ9su532Ey240aGoQo=; b=IrBDzsOaSfEaxgNk2x44DmbCQXUJuTtG6DCuJLsH8SR0g6/UfeO7ZQcCBN9ZCb07uzifkV mDWtVFz43BTvPbmkxP1hODZX2Z+dS1BvBiBXS8xTQ2qcmlpTrf07Zaw4Kz+skwdsmODrIX s26rFSW7QZxRhzSfs/hH60u5Xr8mVwnmgh1KJU2hOL+weVMtngPYSPsWC3hw/y8+bW8qVH xnphM/ZUsSspv2mWMjCnrkx0utzIVOqOrf40v+afEow/8iKWbiIi9JPNVgzs+Tn1SMiA9U n3MpH5bWl/PBu0E/05L+kvrwxBIwjQmh0LlxA7SnnMb5TsEM9PKBN1bJS8d3Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687781304; 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=F4NVJPve5H524fydqi/XeKGR9QZ9su532Ey240aGoQo=; b=rBQsRS9VZP0FdbJ+1WcW+O5wsSVn4piN+mrbrX6AcM5rO3HFp/VVYgFZVyUHm8MRmd6RN4 KrI6Wfkcai7pohh8mvRfT+dmDnkwUZub3T+HlS6CRYLz+T6uDudINebcfXEXEfKhjk9JM2 aw+z5sNfuyUJO+Yfe/D9fnEDXvSrurC/NTN7LeqPe23fsce9G2Iq28vnKbk9hZhRugjK6O +4H8P9rS8MzSLtRI+Ja01jnLV4GrO0ZKlT++V9B9mgRX4Cv/lUWZ6SlBzIS+6reQgJgZfN 5AvYdJTCA1fsz+bj5JNdjtwCd405BK7s2BOxJFwlwIe5nd62+w97v54chriAkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687781304; a=rsa-sha256; cv=none; b=KoM1zDmRq2ThRZKi4KMYjNYIloXGQ2/W+663RxnukLRyiBlMHGPv9hg0mKqnhEqwvq3DmX Ine7KtIj0+Dx5oE9nd8rEC7X9ddIrWs55GfyY2EcaHe3luvmFkzO2aZZQVABjq+gLI48CB V2Gm9R1gdprZcpvcwIrn4v/l3QMpGnbwSYZse3i+CW2EX1ECNVttfN6kBCqaO3A0wJrN8R HbuM1bGJ/MRy5B7FGeM/4UN6Whxz7m0gUtnmolNSyRwcJTvTweRoewgoKfClvAbQ0+Phti 3p3Pj14eMVMtfzs4sHs8IbB1dp5jE4GRd/wN7CNvxNnJmpBZaOMbFR/WKh/unw== 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 4QqRSm1tWrz17dV; Mon, 26 Jun 2023 12:08:24 +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 35QC8OBq082855; Mon, 26 Jun 2023 12:08:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35QC8OlM082854; Mon, 26 Jun 2023 12:08:24 GMT (envelope-from git) Date: Mon, 26 Jun 2023 12:08:24 GMT Message-Id: <202306261208.35QC8OlM082854@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: bacbebb16d84 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: bacbebb16d844100eefdb3b98007952272428e45 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=bacbebb16d844100eefdb3b98007952272428e45 commit bacbebb16d844100eefdb3b98007952272428e45 Author: Bjoern A. Zeeb AuthorDate: 2023-05-17 20:40:47 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-06-26 09:04:18 +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 Reviewed by: melifaro, thierry Differential Revision: https://reviews.freebsd.org/D40137 (cherry picked from commit 2e6756b752e07878ae5f5e3e9b74934231f9fd17) --- 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 f01f40e46a8b..6deeebba9f01 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1566,11 +1566,13 @@ ifmaybeload(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';