From nobody Sun Jul 13 15:49:17 2025 X-Original-To: dev-commits-src-branches@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 4bg8yQ2w11z617mK; Sun, 13 Jul 2025 15:49:18 +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 4bg8yP3sNGz46qH; Sun, 13 Jul 2025 15:49:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752421757; 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=+xULdIiDagW9gW0u3fF/2vF+tR/xuWTdMo7V4hMj9lU=; b=I3EwC7xeGpBKXS0EfijNI8UyuEPRIc3A56pQ1LzEhz7WiDjsQFvSWx3NhpfZmdv+QDrski Ft/2341B9dTolrv76J3kyzibqmbW/Rrm6V6/KERgujs9B2tCTZx6XV8mqK+zkE2COaVJOu jLWum5eM6WriJevfAoHpro63WY2VzF5sO6Yjg9X5jj4VIIZT2d13j0skIqP/Diroguh/9u xvNA0tPJdSbtd7VJ+xj8G2K4PDvef1wPYsYFvrNgBebo8X5eRkkSe5rd/yaqb970rtNyZ9 PFP7NG3g6gONfk2D+3jVMxV+jSVjvplQmH3F5uhHImZpvyqfWkIcoWF8xErsmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752421757; 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=+xULdIiDagW9gW0u3fF/2vF+tR/xuWTdMo7V4hMj9lU=; b=SJQcEPS35wqXp5AJXnM4BlWT4PMLZytX/INWq6Nmkim2En9RUh/yYe/GGfmf9yQPa/NkwS PFUuBVTVHzTRNKW9fGKWn72elZJc7bL1gD21fuuaeC2mOvCBzfnNVzfSMCzr7S59UScT9K MtJY3AiPk23vcSQ0FZhUjOrBmwvjQY7Sl0GtthXgGixkxOHf/AWpbP9l7Aof1ewJduDwWD aG4yXxtXeBAShwVHlve3RoOqI9hwhMAGEbjhmf+d3gVCpuK3dMGcsh0sPSUm6/OqBpzNV2 i1NhZ52B2JFEbdsPU3emt+NWrI1zlk3okAOxqJQ+zCSYHW66z9Ayq0suTMh3aQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752421757; a=rsa-sha256; cv=none; b=G2Aq1N6O95wzT3GcaKarn0AqfzkahkdslrkFJkd3bRlgKxV1/2R7KWFazmAikce7zDoBE+ 5NLyAPDYf9G+l1deobEGPvuHTL9Tams4msn9GS4Hw0uYmlE6rdHUp2W7UbKnbuBrF17fMy x++zDJamORmMcnRGlBUFP4JUR6NsHU/ZKDcCqgD6YtK0AzBOT9wTZZZmX37fVXItwQRt5P dTAwXXC7wPNChKaIR4TJCzps57sTjSf72G9tZ5WRc3aV3MSefBInmwQISBgk3EoWcaBDUD gH0DOjwci5wVWH3FbiWH8U+wnlhPkIdagmUjvpM0kRsL7wrZMp2xzPVINz0wuw== 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 4bg8yP2shtz9p; Sun, 13 Jul 2025 15:49:17 +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 56DFnHlM043477; Sun, 13 Jul 2025 15:49:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56DFnHBR043474; Sun, 13 Jul 2025 15:49:17 GMT (envelope-from git) Date: Sun, 13 Jul 2025 15:49:17 GMT Message-Id: <202507131549.56DFnHBR043474@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: 5d15e09a26c6 - stable/13 - libexec/rc: MFC: improve performance of pccard_ether script List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: 5d15e09a26c6b08fc0d5cd7deca082ba5b9cabd4 Auto-Submitted: auto-generated The branch stable/13 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=5d15e09a26c6b08fc0d5cd7deca082ba5b9cabd4 commit 5d15e09a26c6b08fc0d5cd7deca082ba5b9cabd4 Author: Eugene Grosbein AuthorDate: 2025-07-01 14:13:10 +0000 Commit: Eugene Grosbein CommitDate: 2025-07-13 15:48:37 +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) (cherry picked from commit 24e8ed535ff673b9ea751c3d3b2a68ef0a29b0e2) --- 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..5e4f2c1f39a0 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 2 + _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