From nobody Sun Feb 25 18:03:36 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TjWp11PQZz5Bj2B; Sun, 25 Feb 2024 18:03:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TjWp10rpXz464Z; Sun, 25 Feb 2024 18:03:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708884217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U5empYguDYoQyMlqk26YnrnFfqCGjFkaamViCxaDtF8=; b=h9uGoViLO+cbUJQK+PmIxT+oVbUcquviKv2taOUWohhbtBAuARsK5brFuoa4CKtU+3BgG6 yeytPuKlwigajWw6tezW9zMt6h4yLLyzf/7EW0Dh3HZMXtngz9Ibb++45PquluY/E+Dlpf XCK7touO0nDs7QymK+xSKPxLip90Ke2I1JyLFkoRs76OInGOj77C0XI4Rx7Zq3F/mbvPaV DfTk4u1dqjth+0R+G7zWJcj976ruLXdIflbQlJSOLjOUMWBdET+wnEf9Ap3usmVS3mAXHj VjEPqktyRfUK7+tiTMumN7XRbGHRxMzpRiAcxorFQByVOtMRjXRfs1mLsrX0Rw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708884217; a=rsa-sha256; cv=none; b=nKkvWQ2pM0j2iVIeLjK4fZeJI0WHogQZOVGkKwo9SX3pMXWW6Uonh0wb3Gtlm+VZhwhAtA 1xcPxQQPKioDGdgtlCEuL5EoUnBqQFor41/UMcbUV3nqRbOSCiUb3YmaI/BOOL+2pya1eL dbRMPX/ksNGqjDKr2B4uX0rrmdpI+QOsqb7EP9Q5UvUZzr6//fQAWigI1VgY1QpFLCHeZY atY+Fa1VVLpBOgDpk0/5H325dKhLkwzH4kkI/KlKw679TiyVtY+dsWWJHnHxoEiynxorbZ aFPbQ1UK17VTNINzAO63hfIIIVmUEaDuHG2IGhFY4EF9Lme+PhOUKNmf73BrYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708884217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U5empYguDYoQyMlqk26YnrnFfqCGjFkaamViCxaDtF8=; b=naOdhxiDEqWoGZupdg3xFVSEcGmRcRbGQzGkNQb6Rk7VUrwHAUnU4r9x1SNxhpQQhiznkY m9XUQ4pl7uwin/1NokbXIBp090cz0+0SvoxG7lRTzwU3MXej96+hYS+4wrmhlmHRa0OLV2 XapnX6e1ZHWi8GK+bCAEOkQWBSz0rl8E1rNTnpQI4bKR0P9e91AhBHnoM2TRAQ6DhrjISN AtFLfePgJwQxeg8Iqu/e5CrB4+84gb5wFWCMUMhzWvk1TuM2WOOHppB3YlUgGnsSqo24vs WLPVO+IR5Z0cIriD7P7JqlVUU3+L2fTP6SVDLVBxehshaEJEObAY01b8/wWoYg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TjWp071NdztX4; Sun, 25 Feb 2024 18:03:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41PI3aFZ034640; Sun, 25 Feb 2024 18:03:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41PI3aAq034637; Sun, 25 Feb 2024 18:03:36 GMT (envelope-from git) Date: Sun, 25 Feb 2024 18:03:36 GMT Message-Id: <202402251803.41PI3aAq034637@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gleb Smirnoff Subject: git: 1e74fc950419 - stable/14 - arp: fix arp -s/-S List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1e74fc950419f2b2482d313fc664cc03aa46f13c Auto-Submitted: auto-generated The branch stable/14 has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=1e74fc950419f2b2482d313fc664cc03aa46f13c commit 1e74fc950419f2b2482d313fc664cc03aa46f13c Author: Gleb Smirnoff AuthorDate: 2024-02-20 18:31:05 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-25 18:03:17 +0000 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) --- usr.sbin/arp/arp_netlink.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/usr.sbin/arp/arp_netlink.c b/usr.sbin/arp/arp_netlink.c index d78f380af04b..8644f3722aed 100644 --- a/usr.sbin/arp/arp_netlink.c +++ b/usr.sbin/arp/arp_netlink.c @@ -390,9 +390,6 @@ set_nl(uint32_t ifindex, struct sockaddr_in *dst, struct sockaddr_dl *sdl, char return (0); } - if (opts.expire_time != 0) - opts.flags &= ~RTF_STATIC; - snl_init_writer(&ss, &nw); struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_NEWNEIGH); hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE; @@ -402,11 +399,12 @@ set_nl(uint32_t ifindex, struct sockaddr_in *dst, struct sockaddr_dl *sdl, char ndmsg->ndm_family = AF_INET; ndmsg->ndm_ifindex = ifindex; - ndmsg->ndm_state = (opts.flags & RTF_STATIC) ? NUD_PERMANENT : NUD_NONE; + ndmsg->ndm_state = (opts.expire_time == 0) ? \ + NUD_PERMANENT : NUD_NONE; if (opts.flags & RTF_ANNOUNCE) nl_flags |= NTF_PROXY; - if (opts.flags & RTF_STATIC) + if (opts.expire_time == 0) nl_flags |= NTF_STICKY; ndmsg->ndm_flags = nl_flags; }