forked from QiuSimons/YAOF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
PATCH/files/etc/hotplug.d/net/01-maximize_nic_rx_tx_buffers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
[ "$ACTION" = add ] || exit | ||
|
||
# 遍历所有网口 | ||
for NIC in $(ls /sys/class/net/) | ||
do | ||
# 检查网口是否支持ethtool命令 | ||
if command -v ethtool &> /dev/null && ethtool $NIC &> /dev/null; then | ||
# 获取rx和tx缓存最大值 | ||
RX_MAX=$(ethtool -g $NIC 2>/dev/null | awk '/^RX:/ {print $2}' | awk 'NR==1') | ||
TX_MAX=$(ethtool -g $NIC 2>/dev/null | awk '/^TX:/ {print $2}' | awk 'NR==1') | ||
|
||
# 如果无法获取rx和tx缓存最大值,则跳过该网卡 | ||
if [ -z "$RX_MAX" ] || [ -z "$TX_MAX" ]; then | ||
continue | ||
fi | ||
|
||
# 调整rx和tx缓存为驱动支持的最大值 | ||
ethtool -G $NIC rx $RX_MAX | ||
ethtool -G $NIC tx $TX_MAX | ||
fi | ||
done |