From nobody Thu Oct 31 16:34:03 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 4XfV1l4TBMz5c0Q0; Thu, 31 Oct 2024 16:34:03 +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 4XfV1l40L9z4g8s; Thu, 31 Oct 2024 16:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730392443; 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=cxOoa/ngKVxvbhPh6YVhHbC9b/XPjV0DRija4624Ke8=; b=HRBA9oUb+K3H8fQCxFKv3NVXQ+LQAIEYJnE8Vub53S2tVS2VZMKzdTu9at77AAwWK9u8Gz x16owM1uyW65QA9JhGrj0e5epK4qMRKAG35CIZtQpay9nY8wHC/LKZ/zqNQv6XZHhQvKKc R+ObIN16DiJcOTfmtsCMGIO8v9M23n+3P70jkp3KnsNcUNlB8/ypwbLKG6NCE2YOfoPta7 TVNfyU8NT6wNG82m15lHgVmVGjZlWN/gL9TQTNgvUJy+YFQLkxSPaQ7j0L1+cYc5xBuKu8 mC4Tkbd18i9J5GVK+FOavRaUXzV4lsXwnvkxlcx/RU4xyWDNLt1XOXCbgEPkag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730392443; 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=cxOoa/ngKVxvbhPh6YVhHbC9b/XPjV0DRija4624Ke8=; b=TnuPzBeSgpafVpRi35/bMDzHK9xMGn4xkGCpB1D/CYimFkstabxUc4J+7lOFK3LUOSZ4n1 u3TJaaul+LmNWz6CvDMFuiTt0Mj4cgb4R+WsS1hIDokc434Pa8e/Qun31OOoe9fM3RXm3H jgwKCdE5s8gTJoNW5QUsAyEd6lq628JCpdMmMTydQKbL7DK0JTuWJSekqDNObprCb21qpH P8GQJV0W9eAoLAwiJd39LCRwONigOoSZztZTkpu8vajJ6ZK6sQWF6s8Pm6CGXQE0Fx2s+k 5hzuSIFEPlqdgDuS5Ksq0Hvnb3e+7jykEX7EHxUeK8OBkyUY/Jp34mES51hoPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730392443; a=rsa-sha256; cv=none; b=CwNMbiImXCESjyGBiu8J4dlweCbodgo51wQ/70/X0iY/ZNk37NOS0Ah218d/MUoAQo27JY dFli2FxowbaWJB73IGgEQ2tVcGpQ8oIDu+lqtZVmhdOepFh38sMtGrV+vSSEFtbKrU7CCi XLkyGt3REcRRCrCHgl243KvzwSQU9GAXiYmqBX0DKiM9OJD1sVY9gqEhv1zKfA6/tZP++b IkgwklOMRN1/N6YsOG3TOAaplQ9IsSZeEfSwuXbkkoxJenO1eLJRYIkuXEgKcnbwLmG7cL DktMlw/YxmPIpvleCuvpjS3xcZEYoqxhWgE/pg4cBwOX4ZxZy7vjmMUCxAK57A== 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 4XfV1l3bSrzkVn; Thu, 31 Oct 2024 16:34:03 +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 49VGY3Pw032193; Thu, 31 Oct 2024 16:34:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VGY3O0032190; Thu, 31 Oct 2024 16:34:03 GMT (envelope-from git) Date: Thu, 31 Oct 2024 16:34:03 GMT Message-Id: <202410311634.49VGY3O0032190@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: b6d4e3bee350 - main - ndp: Bring back the -A option for the netlink implementation 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b6d4e3bee350b881b5efea03068c1247985b12fe Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=b6d4e3bee350b881b5efea03068c1247985b12fe commit b6d4e3bee350b881b5efea03068c1247985b12fe Author: Zhenlei Huang AuthorDate: 2024-10-31 16:32:14 +0000 Commit: Zhenlei Huang CommitDate: 2024-10-31 16:32:14 +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 --- 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 546057e5e552..7bd3252f0943 100644 --- a/usr.sbin/ndp/ndp_netlink.c +++ b/usr.sbin/ndp/ndp_netlink.c @@ -314,12 +314,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; @@ -335,14 +347,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) { @@ -381,6 +385,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);