Skip to content

network.arp: fall back to ip neigh when net-tools is absent (refs #57541) - #69621

Merged
dwoz merged 4 commits into
saltstack:masterfrom
ggiesen:fix-arp-iproute2-fallback
Jul 3, 2026
Merged

dwoz merged 4 commits into
saltstack:masterfrom
ggiesen:fix-arp-iproute2-fallback

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

network.arp() was guarded by @salt.utils.decorators.path.which("arp"), which raises CommandNotFoundError when the net-tools arp command is not installed. net-tools has been deprecated since 2011 and is absent by default on modern distributions (e.g. EL8/9/10, current Debian/Ubuntu), so network.arp broke on those systems with no fallback.

PR #64351 migrated network.netstat/network.routes to iproute2 with a which()-based fallback (ss / ip route) and added network.ip_neighs, but left the public network.arp() on net-tools. This completes that work: on Linux, when the arp command is unavailable, arp() dispatches to ip_neighs() (ip neigh show), which returns the same {mac: ip} mapping. Non-Linux kernels (SunOS/OpenBSD/AIX) keep using their native arp command, mirroring how network.netstat() is structured.

What issues does this PR fix or reference?

Refs #57541, #64351.

#64351 closed #57541 (the net-tools deprecation tech-debt issue) but the public network.arp() was only guarded, not migrated. This is the follow-up that completes it. An audit of the remaining net-tools commands in scope (ifconfig, netstat, route, iwconfig, iptunnel, nameif) found network.arp() to be the only remaining Linux code path that hard-fails without net-tools; the others are already migrated (#64351), platform-native (BSD/macOS/Solaris/AIX), or gated to unavailable (iwtools).

Previous Behavior

On a Linux minion with iproute2 but no net-tools, salt-call network.arp raised:

CommandNotFoundError: The 'arp' binary was not found in $PATH.

New Behavior

network.arp returns the neighbour table via ip neigh when net-tools arp is absent; behavior is unchanged when arp is present or on non-Linux kernels.

Tests written?

Yes. Replaced test_arp with explicit coverage of all three branches (Linux + net-tools arp, Linux fallback to ip neigh, and non-Linux using the native arp command). Full test_network.py passes (39 tests).

Validated on real AlmaLinux 8, 9, and 10 VMs: net-tools is absent by default on all three, and network.arp returns the neighbour table via the ip neigh fallback.

Out of scope

ps.netstat also carries an @path.which("netstat") decorator, but it degrades to unavailable (not a crash) and already has a companion ps.ss, so it is left as-is to keep this change surgical.

network.arp() was guarded by @salt.utils.decorators.path.which("arp"),
which raises CommandNotFoundError when the net-tools arp command is not
installed. net-tools is deprecated (since 2011) and absent by default on
modern distributions, so network.arp broke on those systems with no
fallback.

PR saltstack#64351 migrated network.netstat/network.routes to iproute2 with a
which()-based fallback (ss / ip route) and added network.ip_neighs, but
left the public network.arp() on net-tools. This completes that work:
on Linux, when the arp command is unavailable, arp() now dispatches to
ip_neighs() (ip neigh show), which returns the same {mac: ip} mapping.
Non-Linux kernels (SunOS/OpenBSD/AIX) keep using their native arp
command, mirroring how network.netstat() is structured.

Refs saltstack#57541, saltstack#64351.

Validated on AlmaLinux 8, 9 and 10: net-tools is absent by default, and
network.arp returns the neighbour table via the ip neigh fallback.
@ggiesen
ggiesen requested a review from a team as a code owner July 1, 2026 03:37
@dwoz dwoz added the test:full Run the full test suite label Jul 1, 2026
Every test in tests/unit/modules/test_network.py already has a
same-named twin in tests/pytests/unit/modules/test_network.py with
identical mocks, inputs, and expected values, under equivalent loader
wiring. Keeping both copies means fixes only land in one, which is
exactly how test_arp broke on this branch: arp() gained the ip neigh
fallback and only the pytest copy was updated.

The one gap was test___virtual__is_windows_false, whose pytest twin had
been weakened from assertEqual(result, True) to a bare truthiness
assert that would also pass for the (False, reason) failure tuple.
Restore the strict check and remove the legacy file, leaving a single
canonical home for these tests.
@dwoz
dwoz merged commit e97b3c4 into saltstack:master Jul 3, 2026
951 of 954 checks passed

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tech-Debt] Avoid use of deprecated net-tools

2 participants