Skip to content

ifconfig issue - #4

Open
WajeehJ wants to merge 1 commit into
open-power-sdk:masterfrom
WajeehJ:issue_ifconfig
Open

ifconfig issue#4
WajeehJ wants to merge 1 commit into
open-power-sdk:masterfrom
WajeehJ:issue_ifconfig

Conversation

@WajeehJ

@WajeehJ WajeehJ commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

ifconfig deprecation — cross-distro network interface collection

Problem:
LPCPU called ifconfig -a directly and unconditionally in both the before and after
snapshot blocks. ifconfig comes from the net-tools package which is deprecated and
not installed by default on modern distributions such as SLES 15 and newer RHEL/UBI
images, causing those collection steps to silently fail.

Goal:
Keep ifconfig as the preferred tool for backwards compatibility with older users who
have it installed, while automatically falling back to ip -s -s link show (iproute2)
on distributions where ifconfig is absent. The script must never hard-exit if neither
tool is available.

Changes: lpcpu/lpcpu.sh

  1. New helper functions — tool detection

Two boolean helper functions were added to probe for tool availability at runtime:

has_iproute2() {
command -v ip >/dev/null 2>&1 && ip -V >/dev/null 2>&1
}

has_ifconfig() {
command -v ifconfig >/dev/null 2>&1
}
Note: has_iproute2() checks both that the binary exists AND that it responds to
ip -V, ensuring it is a functional iproute2 installation and not a stub.

  1. New function — collect_network_stats()

Replaces the bare ifconfig -a calls. Prefers ifconfig -a for backwards
compatibility; falls back to ip -s -s link show if ifconfig is not installed;
writes a message to the output file if neither is available (no exit 1).

collect_network_stats() {
local output_file="$1"

if has_ifconfig; then
    # Prefer ifconfig for backwards compatibility
    ifconfig -a > "$output_file" 2>&1
elif has_iproute2; then
    # Fallback to iproute2's ip command
    ip -s -s link show > "$output_file" 2>&1
else
    # Neither tool available - create empty file with note
    echo "# Network interface tools (ip/ifconfig) not available" > "$output_file"
fi

}
3. Call sites updated — before/after snapshot blocks

The two direct ifconfig -a calls were replaced with calls to the new function.
Output filenames are unchanged so existing post-processing scripts are unaffected.

  • ifconfig -a > $LOGDIR/ifconfig.before 2>&1
  • collect_network_stats "$LOGDIR/ifconfig.before"
  • ifconfig -a > $LOGDIR/ifconfig.after 2>&1
  • collect_network_stats "$LOGDIR/ifconfig.after"

@WajeehJ WajeehJ changed the title finished ifconfig issue ifconfig issue Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant