Add support for e1000 NIC (#6575)
This commit is contained in:
parent
99837db81a
commit
0863d080a4
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Creates a systemd service to disable NIC offloading features for Intel e1000e interfaces
|
||||
# Creates a systemd service to disable NIC offloading features for Intel e1000e and e1000 interfaces
|
||||
# Author: rcastley
|
||||
# License: MIT
|
||||
|
||||
@ -19,8 +19,8 @@ INFO="${TAB}ℹ️${TAB}${CL}"
|
||||
WARN="${TAB}⚠️${TAB}${CL}"
|
||||
|
||||
function header_info {
|
||||
clear
|
||||
cat <<"EOF"
|
||||
clear
|
||||
cat <<"EOF"
|
||||
|
||||
_ ____________ ____ __________ ___ ____ _ __ __
|
||||
/ | / / _/ ____/ / __ \/ __/ __/ /___ ____ _____/ (_)___ ____ _ / __ \(_)________ _/ /_ / /__ _____
|
||||
@ -28,6 +28,7 @@ function header_info {
|
||||
/ /| // // /___ / /_/ / __/ __/ / /_/ / /_/ / /_/ / / / / / /_/ / / /_/ / (__ ) /_/ / /_/ / / __/ /
|
||||
/_/ |_/___/\____/ \____/_/ /_/ /_/\____/\__,_/\__,_/_/_/ /_/\__, / /_____/_/____/\__,_/_.___/_/\___/_/
|
||||
/____/
|
||||
Enhanced version supporting both e1000e and e1000 drivers
|
||||
|
||||
EOF
|
||||
}
|
||||
@ -52,36 +53,36 @@ if ! command -v ethtool >/dev/null 2>&1; then
|
||||
msg_ok "ethtool installed successfully"
|
||||
fi
|
||||
|
||||
# Get list of network interfaces using Intel e1000e driver
|
||||
# Get list of network interfaces using Intel e1000e or e1000 drivers
|
||||
INTERFACES=()
|
||||
COUNT=0
|
||||
|
||||
msg_info "Searching for Intel e1000e interfaces"
|
||||
msg_info "Searching for Intel e1000e and e1000 interfaces"
|
||||
|
||||
for device in /sys/class/net/*; do
|
||||
interface="$(basename "$device")" # or adjust the rest of the usages below, as mostly you'll use the path anyway
|
||||
# Skip loopback interface and virtual interfaces
|
||||
if [[ "$interface" != "lo" ]] && [[ ! "$interface" =~ ^(tap|fwbr|veth|vmbr|bonding_masters) ]]; then
|
||||
# Check if the interface uses the e1000e driver
|
||||
# Check if the interface uses the e1000e or e1000 driver
|
||||
driver=$(basename $(readlink -f /sys/class/net/$interface/device/driver 2>/dev/null) 2>/dev/null)
|
||||
|
||||
if [[ "$driver" == "e1000e" ]]; then
|
||||
if [[ "$driver" == "e1000e" ]] || [[ "$driver" == "e1000" ]]; then
|
||||
# Get MAC address for additional identification
|
||||
mac=$(cat /sys/class/net/$interface/address 2>/dev/null)
|
||||
INTERFACES+=("$interface" "Intel e1000e NIC ($mac)")
|
||||
INTERFACES+=("$interface" "Intel $driver NIC ($mac)")
|
||||
((COUNT++))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if any Intel e1000e interfaces were found
|
||||
# Check if any Intel e1000e/e1000 interfaces were found
|
||||
if [ ${#INTERFACES[@]} -eq 0 ]; then
|
||||
whiptail --title "Error" --msgbox "No Intel e1000e network interfaces found!" 10 60
|
||||
msg_error "No Intel e1000e network interfaces found! Exiting."
|
||||
whiptail --title "Error" --msgbox "No Intel e1000e or e1000 network interfaces found!" 10 60
|
||||
msg_error "No Intel e1000e or e1000 network interfaces found! Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg_ok "Found ${BL}$COUNT${GN} Intel e1000e interfaces"
|
||||
msg_ok "Found ${BL}$COUNT${GN} Intel e1000e/e1000 interfaces"
|
||||
|
||||
# Create a checklist for interface selection with all interfaces initially checked
|
||||
INTERFACES_CHECKLIST=()
|
||||
@ -90,8 +91,8 @@ for ((i=0; i<${#INTERFACES[@]}; i+=2)); do
|
||||
done
|
||||
|
||||
# Show interface selection checklist
|
||||
SELECTED_INTERFACES=$(whiptail --backtitle "Intel e1000e NIC Offloading Disabler" --title "Network Interfaces" \
|
||||
--separate-output --checklist "Select Intel e1000e network interfaces\n(Space to toggle, Enter to confirm):" 15 80 6 \
|
||||
SELECTED_INTERFACES=$(whiptail --backtitle "Intel e1000e/e1000 NIC Offloading Disabler" --title "Network Interfaces" \
|
||||
--separate-output --checklist "Select Intel e1000e/e1000 network interfaces\n(Space to toggle, Enter to confirm):" 15 80 6 \
|
||||
"${INTERFACES_CHECKLIST[@]}" 3>&1 1>&2 2>&3)
|
||||
|
||||
exitstatus=$?
|
||||
@ -112,21 +113,23 @@ readarray -t INTERFACE_ARRAY <<< "$SELECTED_INTERFACES"
|
||||
# Show the number of selected interfaces
|
||||
INTERFACE_COUNT=${#INTERFACE_ARRAY[@]}
|
||||
|
||||
# Print selected interfaces
|
||||
# Print selected interfaces with their driver types
|
||||
for iface in "${INTERFACE_ARRAY[@]}"; do
|
||||
msg_ok "Selected interface: ${BL}$iface${CL}"
|
||||
driver=$(basename $(readlink -f /sys/class/net/$iface/device/driver 2>/dev/null) 2>/dev/null)
|
||||
msg_ok "Selected interface: ${BL}$iface${GN} (${BL}$driver${GN})"
|
||||
done
|
||||
|
||||
# Ask for confirmation with the list of selected interfaces
|
||||
CONFIRMATION_MSG="You have selected the following interface(s):\n\n"
|
||||
for iface in "${INTERFACE_ARRAY[@]}"; do
|
||||
SPEED=$(cat /sys/class/net/$iface/speed 2>/dev/null)
|
||||
SPEED=$(cat /sys/class/net/$iface/speed 2>/dev/null || echo "Unknown")
|
||||
MAC=$(cat /sys/class/net/$iface/address 2>/dev/null)
|
||||
CONFIRMATION_MSG+="- $iface (MAC: $MAC, Speed: ${SPEED}Mbps)\n"
|
||||
DRIVER=$(basename $(readlink -f /sys/class/net/$iface/device/driver 2>/dev/null) 2>/dev/null)
|
||||
CONFIRMATION_MSG+="- $iface (Driver: $DRIVER, MAC: $MAC, Speed: ${SPEED}Mbps)\n"
|
||||
done
|
||||
CONFIRMATION_MSG+="\nThis will create systemd service(s) to disable offloading features.\n\nProceed?"
|
||||
|
||||
if ! whiptail --backtitle "Intel e1000e NIC Offloading Disabler" --title "Confirmation" \
|
||||
if ! whiptail --backtitle "Intel e1000e/e1000 NIC Offloading Disabler" --title "Confirmation" \
|
||||
--yesno "$CONFIRMATION_MSG" 20 80; then
|
||||
msg_info "User canceled. Exiting."
|
||||
exit 0
|
||||
@ -134,22 +137,25 @@ fi
|
||||
|
||||
# Loop through all selected interfaces and create services for each
|
||||
for SELECTED_INTERFACE in "${INTERFACE_ARRAY[@]}"; do
|
||||
# Get the driver type for this specific interface
|
||||
DRIVER=$(basename $(readlink -f /sys/class/net/$SELECTED_INTERFACE/device/driver 2>/dev/null) 2>/dev/null)
|
||||
|
||||
# Create service name for this interface
|
||||
SERVICE_NAME="disable-nic-offload-$SELECTED_INTERFACE.service"
|
||||
SERVICE_PATH="/etc/systemd/system/$SERVICE_NAME"
|
||||
|
||||
# Create the service file with e1000e specific optimizations
|
||||
msg_info "Creating systemd service for interface: ${BL}$SELECTED_INTERFACE${YW}"
|
||||
# Create the service file with driver-specific optimizations
|
||||
msg_info "Creating systemd service for interface: ${BL}$SELECTED_INTERFACE${YW} (${BL}$DRIVER${YW})"
|
||||
|
||||
# Start with the common part of the service file
|
||||
cat > "$SERVICE_PATH" << EOF
|
||||
[Unit]
|
||||
Description=Disable NIC offloading for Intel e1000e interface $SELECTED_INTERFACE
|
||||
Description=Disable NIC offloading for Intel $DRIVER interface $SELECTED_INTERFACE
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
# Disable all offloading features for Intel e1000e
|
||||
# Disable all offloading features for Intel $DRIVER
|
||||
ExecStart=/sbin/ethtool -K $SELECTED_INTERFACE gso off gro off tso off tx off rx off rxvlan off txvlan off sg off
|
||||
RemainAfterExit=true
|
||||
|
||||
@ -176,7 +182,7 @@ EOF
|
||||
# Enable the service to start on boot
|
||||
systemctl enable "$SERVICE_NAME"
|
||||
echo "100"; sleep 0.2
|
||||
} | whiptail --backtitle "Intel e1000e NIC Offloading Disabler" --gauge "Configuring service for $SELECTED_INTERFACE..." 10 80 0
|
||||
} | whiptail --backtitle "Intel e1000e/e1000 NIC Offloading Disabler" --gauge "Configuring service for $SELECTED_INTERFACE..." 10 80 0
|
||||
|
||||
# Individual service status
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
@ -192,7 +198,7 @@ EOF
|
||||
fi
|
||||
|
||||
# Show individual service results
|
||||
msg_ok "Service for ${BL}$SELECTED_INTERFACE${GN} created and enabled!"
|
||||
msg_ok "Service for ${BL}$SELECTED_INTERFACE${GN} (${BL}$DRIVER${GN}) created and enabled!"
|
||||
msg_info "${TAB}Service: ${BL}$SERVICE_NAME${YW}"
|
||||
msg_info "${TAB}Status: ${BL}$SERVICE_STATUS${YW}"
|
||||
msg_info "${TAB}Start on boot: ${BL}$BOOT_STATUS${YW}"
|
||||
@ -204,6 +210,8 @@ SUMMARY_MSG+="Configured Interfaces:\n"
|
||||
|
||||
for iface in "${INTERFACE_ARRAY[@]}"; do
|
||||
SERVICE_NAME="disable-nic-offload-$iface.service"
|
||||
DRIVER=$(basename $(readlink -f /sys/class/net/$iface/device/driver 2>/dev/null) 2>/dev/null)
|
||||
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
SVC_STATUS="Active"
|
||||
else
|
||||
@ -216,12 +224,20 @@ for iface in "${INTERFACE_ARRAY[@]}"; do
|
||||
BOOT_SVC_STATUS="Disabled"
|
||||
fi
|
||||
|
||||
SUMMARY_MSG+="- $iface: $SVC_STATUS, Boot: $BOOT_SVC_STATUS\n"
|
||||
SUMMARY_MSG+="- $iface ($DRIVER): $SVC_STATUS, Boot: $BOOT_SVC_STATUS\n"
|
||||
done
|
||||
|
||||
# Show summary results
|
||||
whiptail --backtitle "Intel e1000e NIC Offloading Disabler" --title "Success" --msgbox "$SUMMARY_MSG" 20 80
|
||||
whiptail --backtitle "Intel e1000e/e1000 NIC Offloading Disabler" --title "Success" --msgbox "$SUMMARY_MSG" 22 80
|
||||
|
||||
msg_ok "Intel e1000e optimization complete for ${#INTERFACE_ARRAY[@]} interface(s)!"
|
||||
msg_ok "Intel e1000e/e1000 optimization complete for ${#INTERFACE_ARRAY[@]} interface(s)!"
|
||||
|
||||
# Show verification commands
|
||||
echo ""
|
||||
msg_info "Verification commands:"
|
||||
for iface in "${INTERFACE_ARRAY[@]}"; do
|
||||
echo -e "${TAB}${BL}ethtool -k $iface${CL} ${YW}# Check offloading status${CL}"
|
||||
echo -e "${TAB}${BL}systemctl status disable-nic-offload-$iface.service${CL} ${YW}# Check service status${CL}"
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user