HomeFreeBSD

arp: fix arp -s/-S

Description

arp: fix arp -s/-S

When setting a permanent ARP entry, the route(4) would use
rtm->rtm_rmx.rmx_expire == 0 as a flag for installing a static entry, but
netlink(4) is looking for explicit NTF_STICKY flag in the request. The
arp(8) utility was adopted to use netlink(4) by default, but it has lots
of route-era guts internally. Specifically there is global variable 'opts'
that shares configuration for both protocols, and it is still initialized
with route(4) specific RTF_xxx flags. In set_nl() these flags are
translated to netlink(4) parameters. However, RTF_STATIC is a flag that is
never set by default, so attempt to use it as a proxy flag manifesting
-s/-S results in losing it. Use zero opts.expire_time as a manifest of
-s/-S operation. This is a minimal fix. A better one would be to fully
get rid of route(4) legacy.

The change also corrects the logic to set NUD_PERMANENT flag for
consistency. This flag is ignored by our kernel (now).

Reviewed by: melifaro, tuexen, emaste
PR: 277063
Fixes: 6ad73dbf65048b0950a1ba6ff25607f6708c8954
Differential Revision: https://reviews.freebsd.org/D43983

(cherry picked from commit 6a3e87e1306d5058d63f7552a25ed6376422f658)

Details

Provenance
glebiusAuthored on Feb 20 2024, 6:31 PM
Reviewer
rG6ad73dbf6504: arp: convert arp(8) to netlink.
Differential Revision
D43983: arp: fix arp -s/-S
Parents
rGff9794844f86: umcs(4): Fix two typos in source code comments
Branches
Unknown
Tags
Unknown