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

Network_Setup for Kdump Remote Mode. #19464

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6587eb8
Added network_setup.sh file for Kdump
Ghulam-Bahoo Jul 3, 2024
7e3e61a
Kdump Network setup
Ghulam-Bahoo Jul 3, 2024
3c1c04d
Kdump Network setup
Ghulam-Bahoo Jul 3, 2024
7edc987
Kdump Network setup
Ghulam-Bahoo Jul 3, 2024
b28aac3
Delete scripts/build_debian.sh
Ghulam-Bahoo Jul 3, 2024
4ad78d6
Kdump Network setup
Ghulam-Bahoo Jul 3, 2024
cfc5513
Corrected File Extension
Ghulam-Bahoo Jul 4, 2024
0fd9a0b
Sleep timer increased
Ghulam-Bahoo Jul 19, 2024
68ba502
Daemon added
muhammadalihussnain Jul 19, 2024
8bdebd1
Added Removal functionality
muhammadalihussnain Jul 24, 2024
f7d7220
Added Removal functionality
muhammadalihussnain Jul 24, 2024
c9a46a1
modi daemon acc to utility
muhammadalihussnain Jul 25, 2024
5e24c49
update daemon relative to utility
muhammadalihussnain Jul 25, 2024
81fd8d9
Merge branch 'sonic-net:master' into network_setup_kdump
muhammadalihussnain Jul 29, 2024
8a5bf5d
daemon path setting and added some logs why service is not updating i…
muhammadalihussnain Jul 29, 2024
f1ccb18
Changes to code
muhammadalihussnain Jul 29, 2024
2baa955
Update kdump-service.py
ridahanif96 Aug 2, 2024
3528322
removed kdump-features from build-image
muhammadalihussnain Sep 18, 2024
bc37486
erased lines in sonic-debian_externsion.j2
muhammadalihussnain Sep 19, 2024
2c1b3f0
remvoed lines
muhammadalihussnain Sep 19, 2024
7040b1c
Update sonic_debian_extension.j2
muhammadalihussnain Oct 1, 2024
278ee18
isolated kdump and static ip if dhcp not available
muhammadalihussnain Nov 27, 2024
1e4025f
testing
muhammadalihussnain Jan 9, 2025
e063e3e
retriggered pipelines
muhammadalihussnain Jan 9, 2025
9992c32
passing tests
muhammadalihussnain Jan 10, 2025
5f9c8a2
testing
muhammadalihussnain Jan 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,20 @@ sudo LANG=c chroot $FILESYSTEM_ROOT chmod 644 /etc/group
sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "mkdir -p /etc/initramfs-tools/conf.d"
sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo 'MODULES=most' >> /etc/initramfs-tools/conf.d/driver-policy"

# Ensure the relevant directories exist
sudo mkdir -p /etc/initramfs-tools/scripts/init-premount
sudo mkdir -p /etc/initramfs-tools/hooks

# Copy the network setup scriptgit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we need this change, as long as SSH works to the remote destination, it should be enough, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be impact for DUMP remote mode feature if we dont have this pull request?

Copy link

@muhammadalihussnain muhammadalihussnain Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally the kdump remote feature can be enabled simply by modifying the kdump-tools file. However, in the SONiC community version, when we enable the kdump remote mode, after kernel crash when it tries to send the crash report over ssh server it encounters an error of network unreachability. So we also need to bring up the network interfaces alongside ssh remote configurations. All these adjustments have been made specifically to bring up the "eth0" interface.

sudo cp files/scripts/network_setup.sh /etc/initramfs-tools/scripts/init-premount/network_setup.sh

# Copy the hook file
sudo cp files/scripts/network_setup /etc/initramfs-tools/hooks/network_setup

# Make the scripts executable
sudo chmod +x /etc/initramfs-tools/scripts/init-premount/network_setup.sh
sudo chmod +x /etc/initramfs-tools/hooks/network_setup

# Copy vmcore-sysctl.conf to add more vmcore dump flags to kernel
sudo cp files/image_config/kdump/vmcore-sysctl.conf $FILESYSTEM_ROOT/etc/sysctl.d/

Expand Down
22 changes: 22 additions & 0 deletions files/scripts/network_setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
PREREQ=""

prereqs() {
echo "$PREREQ"
}

case "$1" in
prereqs)
prereqs
exit 0
;;
esac

. /usr/share/initramfs-tools/hook-functions

# Add dhclient and its dependencies
copy_exec /sbin/dhclient /sbin
copy_exec /sbin/dhclient-script /sbin

# Add the necessary network modules
manual_add_modules e1000e
56 changes: 56 additions & 0 deletions files/scripts/network_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

# Read USE_KDUMP variable from /etc/default/kdump-tools
if [ -f /etc/default/kdump-tools ]; then
. /etc/default/kdump-tools
else
USE_KDUMP=0 # Default to 0 if the file doesn't exist
fi

# Check if USE_KDUMP is enabled
if [ "$USE_KDUMP" -ne 1 ]; then
echo "KDUMP is not enabled. Skipping network setup."
exit 0
fi

# Function to get the IP address of the eth0 interface
get_eth0_ip() {
ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1
}

# Function to get the default gateway
get_default_gateway() {
ip route | grep default | awk '{print $3}'
}

# Wait for the network interface to appear
for i in {1..10}; do
if ip link show eth0; then
break
fi
sleep 1
done

# Bring up the network interface
ip link set eth0 up

# Use DHCP to obtain IP address and default gateway
dhclient eth0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the DHCP server is not present in the network?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@venkatmahalingam
In the kdump-remote feature, network availability is crucial. If there's no DHCP server on the network, we'll provide a static IP address to the port instead. This way, when the DHCP server isn't available, we can rely on a static configuration as a fallback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need this change itself, SSH would work only if the network reachability is there for the remote destination.

Copy link

@muhammadalihussnain muhammadalihussnain Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re correct. But normally the kdump remote feature can be enabled simply by modifying the kdump-tools file. However, in the SONiC community version, when we enable the kdump remote mode, after kernel crash when it tries to send the crash report over ssh server it encounters an error of network unreachability. So we also need to bring up the network interfaces alongside ssh remote configurations. All these adjustments have been made specifically to bring up the "eth0" interface.

# Wait a few seconds to ensure the IP is assigned
sleep 6

ETH0_IP=$(get_eth0_ip)
DEFAULT_GW=$(get_default_gateway)

if [ -z "$ETH0_IP" ] || [ -z "$DEFAULT_GW" ]; then
echo "DHCP failed to assign IP. Please enter a static IP and gateway."

read -p "Enter static IP address: " STATIC_IP
read -p "Enter default gateway: " STATIC_GW

# Set the static IP and gateway
ip addr add $STATIC_IP/24 dev eth0
ip route add default via $STATIC_GW
else
echo "DHCP succeeded. IP: $ETH0_IP, Gateway: $DEFAULT_GW"
fi
Loading