Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kdump fix, initializing network interface on crash kernel boot over master release #18833

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
7 changes: 7 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,13 @@ sudo mkdir -p $FILESYSTEM_ROOT/var/lib/docker
sudo rm -f $FILESYSTEM_ROOT/etc/resolvconf/resolv.conf.d/original
sudo cp files/image_config/resolv-config/resolv.conf.head $FILESYSTEM_ROOT/etc/resolvconf/resolv.conf.d/head


# Required for kdump_remote_ssh_dump: Initialize network interfaces and enable DHCP.
# Currently used on crash kernel boot only
sudo cp files/scripts/network-interface-state-init.sh $FILESYSTEM_ROOT/usr/sbin/network-interface-state-init.sh
sudo chmod +x $FILESYSTEM_ROOT/usr/sbin/network-interface-state-init.sh


## Optimize filesystem size
if [ "$BUILD_REDUCE_IMAGE_SIZE" = "y" ]; then
sudo scripts/build-optimize-fs-size.py "$FILESYSTEM_ROOT" \
Expand Down
8 changes: 8 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ for kernel_release in $(ls $FILESYSTEM_ROOT/lib/modules/); do
done
fi


# Install python-swss-common package and all its dependent packages
{% if python_swss_debs.strip() -%}
{% for deb in python_swss_debs.strip().split(' ') -%}
Expand Down Expand Up @@ -1057,3 +1058,10 @@ sudo rm -rf $FILESYSTEM_ROOT/tmp/mask_disabled_services.py


sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install python3-dbus


# Edit the kdump-tools package script to call a custom one, which shall enable ethernet interfaces in the crash kernel environment
sudo sed -i "/PATH=\/bin:\/usr\/bin:\/sbin:\/usr\/sbin/a NET_INTERFACE_INIT=/usr/sbin/network-interface-state-init.sh" $FILESYSTEM_ROOT/usr/sbin/kdump-config
sudo sed -i "/Network not reachable/a . $NET_INTERFACE_INIT" $FILESYSTEM_ROOT/usr/sbin/kdump-config


16 changes: 16 additions & 0 deletions files/scripts/network-interface-state-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Get list of Ethernet interfaces excluding Docker interfaces
interfaces=$(ip -o link show | awk -F': ' '$2 ~ /^e/ && $2 !~ /^docker/ {print $2}')

# Loop through each Ethernet interface
for interface in $interfaces; do
# Check if the interface is already up
if ! ip link show dev $interface | grep -q 'state UP'; then
# Bring up the interface if it's not already up
ip link set dev $interface up || { echo "Failed to bring up interface $interface"; continue; }
fi

# Configure the interface to use DHCP
dhclient $interface || echo "Failed to configure DHCP for interface $interface"
done
Loading