From nobody Thu Nov 07 23:26:41 2024 X-Original-To: dev-commits-src-branches@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 4Xkyrd561Dz5cqJy; Thu, 07 Nov 2024 23:26:41 +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 4Xkyrd3rb8z4N3D; Thu, 7 Nov 2024 23:26:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731022001; 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=3TCd3Vfj80NmYmhPfrVp0QchY/vYJKOG3XDlW/ypZYc=; b=nGJ/rgiQ0qPKdPyZY0lmjachoQRCpm8pb23FfpWt3WBuu5viTt5qIbUAMBNqaAnBfIQV+v 4c5i8mnN1X66zcHAgESwHwZnttgViE3N8GxRFM8WTSZclKXV8U2yXhOBTOrrF9vyuy+BxM SAmvFaWbTWVmwpOPg+KFcqNi95VpEajxfmpsj33q4lHNnNx2oakXv3kVfcmAJvjG/IMJR3 jajXlbLZK301r9oGVLywZGHuSXS+/VdbeEN9e1glv81u45Mh61mzK20GaOy8uczhL4eaHg l/FGe3S6nDQcuwyWix5p7ReKNEifE9Q8dDICoLDxbECtT0bPI0347yg5pIIRdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731022001; 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=3TCd3Vfj80NmYmhPfrVp0QchY/vYJKOG3XDlW/ypZYc=; b=ouXEXClxVRKYfD9EoCnxb+Lzablr1rvECHMEw6kfbfvq3VhhBEaNBPtKpr3qEYBguzO6vH AuNs0skRMnX0NDjb1xg8LSrcSg4QJ9HwEamT8u2qARhCCXaqt3SrCO9w2zFV0K11OW09B/ oDyOxrpDikI05TouUFTizvFepyncRWtSuRci+fDxWjCWy1lZsdU1mFJ9m9a3cwwQDp0UX9 EDAdo+Xw3cYDGDTevujEcoekMA/ms6OK1C9yit8NGgoPNlXS1YHrQ26k4MsQVXCbKVxWxG T5irh+wVA6J4BstwjfuV5Ej7ruKh1VdHIWKXk1lSeZKu5Y0LYxHUfpBV+KaH4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731022001; a=rsa-sha256; cv=none; b=UPBGTTDXSK9OoCHPUdI0pA5zEgbo/TuDKS37XVrVR7lS9gMkcRyX/1oq0uQrYAN94qSz7t +CDFagzf33tTwyKnBaZUx2eCP8ARbeXFPJBMtg+WEk7iQPuGikHqcKA/yphE0BimjJVkcr Bo4JsZWleF7dmQWKQRYjFf8rN3q/J13JXTQAmRSyQXfshP2wPezh7jnjlInUSKhNHqqDUM yacFwiZ81b3+kiJuUht8mmjXTE/RkPKoSCaF1VFNDVB0onKeMXVLRN0lH5DPZAI8ixyGrq wLOstOVFoOLEn/jl+PZ2AGgG+s3esDtnWz3Z/3rtcFYiqCCvZ7tRwr3n0o8W9Q== 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 4Xkyrd3STTz15Cx; Thu, 7 Nov 2024 23:26:41 +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 4A7NQf2D033742; Thu, 7 Nov 2024 23:26:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A7NQfTi033739; Thu, 7 Nov 2024 23:26:41 GMT (envelope-from git) Date: Thu, 7 Nov 2024 23:26:41 GMT Message-Id: <202411072326.4A7NQfTi033739@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: a30127914a3d - releng/14.2 - ndp: Bring back the -A option for the netlink implementation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/releng/14.2 X-Git-Reftype: branch X-Git-Commit: a30127914a3dc0c0f4c24274ee9d31aff79faca1 Auto-Submitted: auto-generated The branch releng/14.2 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=a30127914a3dc0c0f4c24274ee9d31aff79faca1 commit a30127914a3dc0c0f4c24274ee9d31aff79faca1 Author: Zhenlei Huang AuthorDate: 2024-10-31 16:32:14 +0000 Commit: Zhenlei Huang CommitDate: 2024-11-07 23:26:09 +0000 ndp: Bring back the -A option for the netlink implementation This was lost during the conversion to netlink. Reviewed by: kp Approved by: re (cperciva) Fixes: 91fbe0819bb9 ndp: convert ndp(8) to netlink MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47234 (cherry picked from commit b6d4e3bee350b881b5efea03068c1247985b12fe) (cherry picked from commit 0de672a59481d48dd5e4667c597d66e1b042a683) --- 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);