From nobody Tue Feb 20 18:33:22 2024 X-Original-To: dev-commits-src-main@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 4TfShg13Jxz55Nl9; Tue, 20 Feb 2024 18:33:23 +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 4TfShf3fWZz4QxY; Tue, 20 Feb 2024 18:33:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708454002; 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=C/AAOUZfzgsotptUlEf75zQEnAkQuU0KS5xs0RXnpzU=; b=iVTrxaT6Wm21vgwBn2XZv2xKKbUmdY5lnuBKM8JwMVOPDqlyybEccwavfMNJPiO7j7XAus INf2PmBt9B2vY3+D86ps3nUOezAYHIRP67BnfLE0hAZuASXGJ7qDqR7/cTTRVWoTsUT7DQ Gl472S9exI3J00E31x22WYwL2YsI0oZPUo5FDdmnyBRdugzWG1Xq8VCGOjoOBpT7SgqFxE sosKFJD9rknOgbjMooDPdBXhXydqvVhKpW19p78eoKOKo3aeLWr66icIC4lp+UtVrMQbt7 SQUsdZJfCsUccFInDDYq/JcGn1GAp1bifulXwFvphotnP0d2zBQuQGDtoI1EoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708454002; 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=C/AAOUZfzgsotptUlEf75zQEnAkQuU0KS5xs0RXnpzU=; b=ixVKtGkljMaqms3TNG1klLPoyWxlASrL08tQNHTi9OC+lqwEr9lTPqJqVbf2EM5Q3kQL3Y ZkE6TbcQ9zJA6UPsavo3ehO7oFrEk3TBKHh6xwGY4FMAsbddXta9kgPxMPfxgbHZlBh+px ACEpgOncQo7estkuLNOB37h5INUK1SL/f8A0+ByCMn62etdzZwUP1D9w8OxkKmck8lvdtt eRy5ujvl5jQJDWW18HoSEcOBOoz7yzAPYsAwfQwSyS/iXJtLz2hzeDa86LLoo4u1skETu3 RgSL3za3XQyZ55J7yfH4H3XPmBNMl15RkG7vr8T9HBXFODSTABKvV1dVOEag3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708454002; a=rsa-sha256; cv=none; b=FAx+HuCK7WyJ2M7/qTH8EFAiBR85h3ux4S5eD+U0vtA9I8jhAr6d2GCQAYOSR11Bq8Nw+g UUMr/3ND2ieAq80pNAOWqDy8HQgHh/EwUjnV+52Q6onqJ9c040bf/4XtbV01np4vH3myIX FDSWeTEr0uMBP7KXsouFYyoGMJa62GnB7CDuvm8D8WdwSkPf5Cjz+jntWIgPrQCquOxCWw ttABD9BxFRQHNjgZILwNld/XLFMO1cIZFwcIlemw6HiBkZfKHcp0ibnkqjbHd4Zmy30ve2 6+tGmqU6sGyI3sVzh5ORTzSJVKPNjgCAl8C4AkZqUu8T2voBHnN417Fih0M5VQ== 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 4TfShf2lGGzV3H; Tue, 20 Feb 2024 18:33:22 +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 41KIXMd1008723; Tue, 20 Feb 2024 18:33:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41KIXMoA008720; Tue, 20 Feb 2024 18:33:22 GMT (envelope-from git) Date: Tue, 20 Feb 2024 18:33:22 GMT Message-Id: <202402201833.41KIXMoA008720@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 6a3e87e1306d - main - arp: fix arp -s/-S List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 6a3e87e1306d5058d63f7552a25ed6376422f658 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=6a3e87e1306d5058d63f7552a25ed6376422f658 commit 6a3e87e1306d5058d63f7552a25ed6376422f658 Author: Gleb Smirnoff AuthorDate: 2024-02-20 18:31:05 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-20 18:31:05 +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 --- 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; }