Page MenuHomeFreeBSD

arp: fix arp -s/-S
ClosedPublic

Authored by glebius on Feb 20 2024, 2:27 AM.
Tags
None
Referenced Files
F102076854: D43983.diff
Thu, Nov 7, 8:18 AM
Unknown Object (File)
Fri, Nov 1, 2:42 PM
Unknown Object (File)
Fri, Nov 1, 5:25 AM
Unknown Object (File)
Fri, Oct 25, 9:44 AM
Unknown Object (File)
Sat, Oct 19, 10:08 PM
Unknown Object (File)
Wed, Oct 16, 4:48 AM
Unknown Object (File)
Tue, Oct 15, 1:49 PM
Unknown Object (File)
Fri, Oct 11, 11:25 PM
Subscribers

Details

Summary

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.

PR: 277063
Fixes: 6ad73dbf65048b0950a1ba6ff25607f6708c8954

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 56123
Build 53011: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Feb 20 2024, 6:15 AM
usr.sbin/arp/arp_netlink.c
405

what about RTF_STATIC use here?

usr.sbin/arp/arp_netlink.c
405

Thanks for noticing. Of course it is a nop with my change, since RTF_STATIC is never ever set. But we may be seeing a second bug here. Let me dig in a bit...

usr.sbin/arp/arp_netlink.c
405

Okay. So NUD_PERMANENT is actually a correct flag to create a permanent entry. It is defined in Netlink RFC. But our kernel ignores it. What I'm going to do is to finalize this review to consistency, and then create a new one, that will remove NTF_STICKY and will make kernel look at NUD_PERMANENT. The latter review won't be MFCed.

Also correct NUD_PERMANENT logic.

This revision now requires review to proceed.Feb 20 2024, 6:07 PM
This revision is now accepted and ready to land.Feb 20 2024, 6:13 PM
This revision was automatically updated to reflect the committed changes.