From nobody Sun Jul 13 15:46:16 2025 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 4bg8tw57V3z617rl; Sun, 13 Jul 2025 15:46:16 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bg8tw1l0tz45B2; Sun, 13 Jul 2025 15:46:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752421576; 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=Vb6Mig0hCPg7zmImDguDxXkUyTEILL1iIqC0JQOTY78=; b=l1MERIaxG8q7CSOUNF5eP5Md6d17CHN5xQi0Je7TDcbYP0lsqjb3ahvaieBpskSkFWee5j UpAB7pWLVTAK/u+f/7YOz3nWWGs0qCHs1bra3RjDCnXDLkVj8t0kJdI/j0F0hM8y40fzux s1FIMqbbMfGEzm96z1ApIWb//bhjwRjWwGGHfbG79v//ivhiKUKm/MgZvGkYMzK2cNsOPn H0tcuvJoB4YyKKxED/3PlC4dVzmJ+LbNWmr057kW7Sl+sHpo5hN6eOZbBL90yzPgaKUdhB XUjVnH+zz3Xe0MjloCaNIi6JG7yLLdbKqrdxo2u84Bk1RKWB3nYoihZcAnMUjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752421576; 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=Vb6Mig0hCPg7zmImDguDxXkUyTEILL1iIqC0JQOTY78=; b=mqgqCQpdspCj1pojox9vKIUNHv5LGnXtrqo+Ot5FaoPHDzsdFhRl8ErpjcAG1Gze96+g5m fqeXkyCZe8oOEjvaJ835sY8VaUF7Nb/X1NpD3gRQOABnTFB42eyzQEKK2M1EnPaFf32jcM ZQEb0+7lNuVL00QqaalnGYqTAM5+y2iJ6xCXhDIHLych7oCORtCZy7mZuYtOLjQnPR3Ytl AzpZJAHpm1d4LeLgQNKGVsaC91CM+AbGnKmAN8YLLXRz7pMpGTqVz7ksqiZpcCMnqKZV/c yw+K4pQTj1qySZmZyW+HZ8qTYrVWdrKOBB5m2XV4IpJPEsY8DrPypMHCxMNAXA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752421576; a=rsa-sha256; cv=none; b=uDExggq7LtMkygiiELZv9adhp3CyAv2QvCIiIebI67oVHuvBuyGUgtsUuOGRN4sniSf5mO 3EvL9kNBzBkTJHo4O3sBTv+Y307nNtO8n64RtyRINuZz5H4LvoUFD/YOX/UCQdL2GTrN0E C2gVbDihLWVd30IEDxjI0LWcY2BKbvvFffmhC9y5ufufinmAePeuBWr993S9EWYaO/UBiP 7tD3L/b2czuoraFPK2M33jWks9t3DYUIGKmAwc+RsbojhupDR1szYvXYQJgS2p8ZBX1t3r IsAs5zHVppFkg7x8vicizLbs68dBBzC+B9jsBd3lqC9oL/xsd2/k2+uvCpkFhw== 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 4bg8tw15SCz1CmB; Sun, 13 Jul 2025 15:46:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56DFkGTt042424; Sun, 13 Jul 2025 15:46:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56DFkGlF042421; Sun, 13 Jul 2025 15:46:16 GMT (envelope-from git) Date: Sun, 13 Jul 2025 15:46:16 GMT Message-Id: <202507131546.56DFkGlF042421@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eugene Grosbein Subject: git: a5b6a029eb5e - stable/14 - libexec/rc: MFC: improve performance of pccard_ether script 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a5b6a029eb5ea6cfd5d285f7a5c08cb2c3b7b052 Auto-Submitted: auto-generated The branch stable/14 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=a5b6a029eb5ea6cfd5d285f7a5c08cb2c3b7b052 commit a5b6a029eb5ea6cfd5d285f7a5c08cb2c3b7b052 Author: Eugene Grosbein AuthorDate: 2025-07-01 14:13:10 +0000 Commit: Eugene Grosbein CommitDate: 2025-07-13 15:44:07 +0000 libexec/rc: MFC: improve performance of pccard_ether script Replace "ifconfig -ul" with "ifconfig -n" because netlink-enabled /sbin/ifconfig utility has sub-optimal performance for listing. Combined with the commit b1b17432aa1be670564161232d110461a5dde4ce, these changes mostly eliminate performance regression of the command "service devd start" for a system having hundreds of network interfaces created before devd starts, after FreeBSD 14+ switched /sbin/ifconfig to netlink(4) PR: 287872 (cherry picked from commit 6d3bc576abbd84f736d917f5bfec4e3fe7e6c125) --- libexec/rc/network.subr | 20 ++++++++++++++++++++ libexec/rc/pccard_ether | 17 +++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/libexec/rc/network.subr b/libexec/rc/network.subr index 931fbec19a60..2113a3f66f0f 100644 --- a/libexec/rc/network.subr +++ b/libexec/rc/network.subr @@ -653,6 +653,26 @@ ifexists() ${IFCONFIG_CMD} -n $1 > /dev/null 2>&1 } +# ifisup if +# Returns 0 if the interface exists and UP, +# returns 1 if the interface exists and not UP, +# returns 2 otherwise. +ifisup() +{ + local _if + + [ -z "$1" ] && return 1 + _if="$1" + + set -- $(${IFCONFIG_CMD} -n ${_if} 2>/dev/null) + case "$1$2" in + ${_if}:*']*) return 0 ;; + ${_if}:*) return 1 ;; + esac + + return 2 +} + # ipv4_up if # add IPv4 addresses to the interface $if ipv4_up() diff --git a/libexec/rc/pccard_ether b/libexec/rc/pccard_ether index 7ca58f210085..957983e55a8e 100755 --- a/libexec/rc/pccard_ether +++ b/libexec/rc/pccard_ether @@ -69,16 +69,17 @@ checkauto() pccard_ether_start() { - ifexists $ifn || exit 1 - - if [ -z "$rc_force" ]; then - for uif in `ifconfig -ul`; do - if [ "${uif}" = "${ifn}" ]; then - # Interface is already up, so ignore it. + ifisup $ifn + case $? in + 0) # Interface is already up, so ignore it. + if [ -z "$rc_force"]; then exit 0 fi - done - fi + ;; + 2) # Interface does not exist. + exit 1 + ;; + esac /etc/rc.d/netif quietstart $ifn