git: 057bc783c67e - stable/14 - arp(8): allow -i with -s

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Thu, 16 Oct 2025 07:13:28 UTC
The branch stable/14 has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=057bc783c67e8196d0b8c8c60a7eee6f7dc05805

commit 057bc783c67e8196d0b8c8c60a7eee6f7dc05805
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2024-05-05 18:21:06 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2025-10-16 07:12:22 +0000

    arp(8): allow -i with -s
    
    arp(8) usually disallows adding a static ARP entry for an IP address
    which is not configured on a local interface.
    
    Change this to allow such ARP entries to be added if '-i' is provided to
    specify the interface the ARP entry relates to.
    
    Due to limitations in the kernel lltable, this still requires that a
    host route exists for the target address, but allows static ARP entries
    to be configured to proxy ARP for, e.g., local jails which use an IPv4
    address with a /32 route.
    
    Reviewed by: imp, zlei
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1220
    
    (cherry picked from commit 2356b60be7024b10ddc4361fc22f96205b55fbbb)
---
 usr.sbin/arp/arp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index fa2c595379d5..200912736137 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -156,7 +156,7 @@ main(int argc, char *argv[])
 	if (!func)
 		func = F_GET;
 	if (opts.rifname) {
-		if (func != F_GET && !(func == F_DELETE && opts.aflag))
+		if (func != F_GET && func != F_SET && !(func == F_DELETE && opts.aflag))
 			xo_errx(1, "-i not applicable to this operation");
 		if ((opts.rifindex = if_nametoindex(opts.rifname)) == 0) {
 			if (errno == ENXIO)
@@ -387,7 +387,7 @@ set(int argc, char **argv)
 		}
 	}
 #ifndef WITHOUT_NETLINK
-	return (set_nl(0, dst, &sdl_m, host));
+	return (set_nl(opts.rifindex, dst, &sdl_m, host));
 #else
 	return (set_rtsock(dst, &sdl_m, host));
 #endif