From nobody Thu Nov 07 04:08:50 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 4XkT8g69N3z5cJbQ; Thu, 07 Nov 2024 04:08:51 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XkT8g19Znz4wp5; Thu, 7 Nov 2024 04:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730952531; 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=FMmAj520sf2H/GSkySS34SPqXYNF787lPxABrsHgT7g=; b=dApJy7ffsUV0CuJQ9FiMIDg6jGoUJCakBSUZ/yntfLYJdPVAs+1HWRxZO6Yu5Y74OHvHAX OpEhdgVoqSQrYtsRaz2HsRgx+Rvl0X+TnZIKwA+yFs6lxoVDRKiXrLF0bqWJIbgK5w0/5z 1YgJlrTElygErevJ7jaHGu8JYqKjH93VYD65++1Zo8qySqu2txJBERNNtssDFbGIiNTBl4 KWKA8HEEpkdr9LwYz175MoY80EgyFHtfpb5EHGjN6VT9CuMJtT/e9GW3/28mkSdku7JEFA fb3SkXID9+jQZA34fvMHHTSwyJsLKbTP6cq5grlXu9GHNBgIgYyuy16xoCoZKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730952531; 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=FMmAj520sf2H/GSkySS34SPqXYNF787lPxABrsHgT7g=; b=fZ8zZ8rzoiGGFPg+yptxb8AKZfr/eAKYLQ9zCtkjgLwAgAS5VWNiEVZu6Z07ZIguRJU/mg eotgD5AxTo6ivS7wyKluIDxO1Fv3gzI3A3CDSjZSsbZDpbya9cqy+unZ8j59nVTiFZAbl0 vC3wU/7B3xrYmRqMU0aJ3wpH35XbU94JTZ42HLp/K6NMkMm9QRxVOMb6JxBxZtGde6dIGi mr+/NSS1pJkE5CAI1w2ftReDChYTzwyhK4bSkE/cS5Zn50c6DAc9pHnRDpghTY8sHsCQIk 29TeVjTiUFBL8O1U0e1U5vt6NwNk11h0nyk6bzp54FRvUYYip6QNrJkXrqLDQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730952531; a=rsa-sha256; cv=none; b=aKjw3BciPOPbQApahR3jIuBkyJm4xmR/h8vihj3FFyCQ83HwPn+++UB8M3OyTIFC+Zb0KY CIA8VAaVV1bIxo4ctOVHMSAo52zSoPQQZ9hE+XFbpm8nj8hE5TctO7mZavsaHfFqo1+kXN sf0GRJJR+H6NemoUYHAPlyB8hxdS15Bv/vwcnrGiW2ghHezi8J0u9Qp23Z36Ihd8oEU7aY 2q5/rfIkl3lnuLxW/RmFNx4yZoMCn1yQkjSp+Y8waMP55gzdzZa0qvSzIpTtchawb+xaKF KRqWj3lx8vMcNPoh/mPJsawYCRngYIOWokk9pwBx2exDmth8DYSaJWlIlajYtg== 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 4XkT8f6BMZzW02; Thu, 7 Nov 2024 04:08:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A748oCH075784; Thu, 7 Nov 2024 04:08:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A748orG075781; Thu, 7 Nov 2024 04:08:50 GMT (envelope-from git) Date: Thu, 7 Nov 2024 04:08:50 GMT Message-Id: <202411070408.4A748orG075781@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 0de672a59481 - stable/14 - ndp: Bring back the -A option for the netlink implementation 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0de672a59481d48dd5e4667c597d66e1b042a683 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=0de672a59481d48dd5e4667c597d66e1b042a683 commit 0de672a59481d48dd5e4667c597d66e1b042a683 Author: Zhenlei Huang AuthorDate: 2024-10-31 16:32:14 +0000 Commit: Zhenlei Huang CommitDate: 2024-11-07 04:08:09 +0000 ndp: Bring back the -A option for the netlink implementation This was lost during the conversion to netlink. Reviewed by: kp Fixes: 91fbe0819bb9 ndp: convert ndp(8) to netlink MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47234 (cherry picked from commit b6d4e3bee350b881b5efea03068c1247985b12fe) --- usr.sbin/ndp/ndp_netlink.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/usr.sbin/ndp/ndp_netlink.c b/usr.sbin/ndp/ndp_netlink.c index 179d715c8ded..94dca0f9d4a4 100644 --- a/usr.sbin/ndp/ndp_netlink.c +++ b/usr.sbin/ndp/ndp_netlink.c @@ -316,12 +316,24 @@ print_entries_nl(uint32_t ifindex, struct sockaddr_in6 *addr, bool cflag) struct snl_state ss_req = {}, ss_cmd = {}; struct snl_parsed_link_simple link = {}; struct snl_writer nw; + struct nlmsghdr *hdr; + struct ndmsg *ndmsg; nl_init_socket(&ss_req); snl_init_writer(&ss_req, &nw); - struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETNEIGH); - struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg); + /* Print header */ + if (!opts.tflag && !cflag) { + char xobuf[200]; + snprintf(xobuf, sizeof(xobuf), + "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} {T:/%%1s} {T:/%%5s}\n", + W_ADDR, W_ADDR, W_LL, W_LL, W_IF, W_IF); + xo_emit(xobuf, "Neighbor", "Linklayer Address", "Netif", "Expire", "S", "Flags"); + } + +again: + hdr = snl_create_msg_request(&nw, RTM_GETNEIGH); + ndmsg = snl_reserve_msg_object(&nw, struct ndmsg); if (ndmsg != NULL) { ndmsg->ndm_family = AF_INET6; ndmsg->ndm_ifindex = ifindex; @@ -337,14 +349,6 @@ print_entries_nl(uint32_t ifindex, struct sockaddr_in6 *addr, bool cflag) int count = 0; nl_init_socket(&ss_cmd); - /* Print header */ - if (!opts.tflag && !cflag) { - char xobuf[200]; - snprintf(xobuf, sizeof(xobuf), - "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} {T:/%%1s} {T:/%%5s}\n", - W_ADDR, W_ADDR, W_LL, W_LL, W_IF, W_IF); - xo_emit(xobuf, "Neighbor", "Linklayer Address", "Netif", "Expire", "S", "Flags"); - } xo_open_list("neighbor-cache"); while ((hdr = snl_read_reply_multi(&ss_req, nlmsg_seq, &e)) != NULL) { @@ -382,6 +386,12 @@ print_entries_nl(uint32_t ifindex, struct sockaddr_in6 *addr, bool cflag) count++; snl_clear_lb(&ss_req); } + if (opts.repeat) { + xo_emit("\n"); + xo_flush(); + sleep(opts.repeat); + goto again; + } xo_close_list("neighbor-cache"); snl_free(&ss_req);