mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
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 commitb1b17432aa, 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 commit6d3bc576ab) (cherry picked from commit24e8ed535f)
This commit is contained in:
1 parent
57c652dfa1
commit
5d15e09a26
2 files changed
+29
-8
No files matched your search
@@ -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}:*'<UP'[,\>]*) return 0 ;;
|
||||
${_if}:*) return 1 ;;
|
||||
esac
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
# ipv4_up if
|
||||
# add IPv4 addresses to the interface $if
|
||||
ipv4_up()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user