From nobody Sun Mar 26 09:00:20 2023 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 4PkqfD5Qq6z41X5h; Sun, 26 Mar 2023 09:00:20 +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 4PkqfD4vgpz4BYg; Sun, 26 Mar 2023 09:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679821220; 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=Mr9rdXWaeA1vv1JtEJ2HJPef1xbsmugQdzRTbgunz2E=; b=dqwJ0Yh214V3pSson2w9QQgPr+hts/jsWyl3trNZirpuGGYaJCNdLtegyHTLzewR+YCNJo Am2q4R+k5XYxTM1BW0oXQ7ZzVNeNjqZDBlgx4kAqXfD2J7agKfqRni0s8c5MNjItugJGc9 /PK8/HTHbxTDz1M1h4TEE5C4v8/f2YwTxoq58tz0y33+fjGwQDmKcMxlUgGvbf3M9678im pFZdNETFx49PGv0AwvqqsVJiSjufiiqihV9zKr/hIfalhvUUDUFWQQgueDTX612N43tow1 Hh2DuIfWrPPbSdUZpu+biB7fa6ri1gCqPIz+01BQUEiibsj1EdCWqXjqahrhgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679821220; 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=Mr9rdXWaeA1vv1JtEJ2HJPef1xbsmugQdzRTbgunz2E=; b=spWns9XhMM24uPSvP+snVUhr+V+b4lmJLPiRRtOsVEhMgxcoEAtBHBg/Mq9f7cSJlBT7bd dKnYfHpwSBZqRdMwrzVPe5ZlTRhHYGEow12URq3BbdMvdKMe9eVHThvry83xNy+4dU9dlH oTCIpWpsFRtJdpW1bEQvhxWZZqLY+2I9FFLzEPDI8cFlxkwlo0hgxcmpm8k5X9RcZcYAvs DqrD8LWOWToXsM896OcjzSJKZv1msYzrYRP3prak3oIlgM8QxHoQ3CNrhmBN/ugB0dWeey V0aknulMxd/8b66Yn7oT57encByneCw6qtTe74DQxISe2IyOHmgg0k6zX8n16g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679821220; a=rsa-sha256; cv=none; b=CdEn9ksvR7jGu8SyyrwJeF7h6mgaQoyWpgfyo++uZAEOINDszbqNjdMeUedmgh4ZRUoZY3 gH1tCH/R0TjoGzOPlGyRN+QsTNTjWeCj2YaeBnmOp6TYaBi/xgUZxTsukp9+5LkYQjPObO qYKI6DwlYJGbTmMdGwLfVqp+XMhN4bBa4yr/qm0ccvMSeaoz139qGoZLxcib7qAT2m2Sx/ Y2DCYTM2HCc5KbsoluL3qeib7aUCy8rKsr85m60CntHAat9pm3/Y0JsOTivZlBys3x0wq5 VmBBooSFdQll7mQme2UJGI+CVf/GIjLN2t/optjbYpK3n0uvgm2Ww+FsMhs4nQ== 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 4PkqfD3f1dzZDg; Sun, 26 Mar 2023 09:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32Q90K2A049917; Sun, 26 Mar 2023 09:00:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32Q90Kh0049916; Sun, 26 Mar 2023 09:00:20 GMT (envelope-from git) Date: Sun, 26 Mar 2023 09:00:20 GMT Message-Id: <202303260900.32Q90Kh0049916@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 64dfea86515e - main - netlink: add NETLINK/NETLINK_SUPPORT userland options. 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 64dfea86515e71af254cf90d6d5ceb689b8fbf5a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=64dfea86515e71af254cf90d6d5ceb689b8fbf5a commit 64dfea86515e71af254cf90d6d5ceb689b8fbf5a Author: Alexander V. Chernikov AuthorDate: 2023-03-26 08:56:49 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-03-26 08:59:58 +0000 netlink: add NETLINK/NETLINK_SUPPORT userland options. Make userland tools such as netstat, route, arp and ndp use either netlink or rtsock interfaces based on the NETLINK_SUPPORT options. Both NETLINK and NETLINK_SUPPORT options are turned on by default. Reviewed By: eugen Differential Revision: https://reviews.freebsd.org/D39148 --- share/mk/src.opts.mk | 2 ++ tools/build/options/WITHOUT_NETLINK_SUPPORT | 5 +++++ usr.bin/netstat/Makefile | 7 ++++++- usr.bin/netstat/route.c | 13 +++++++++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 880f1139843c..7c73e66aba18 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -145,6 +145,7 @@ __DEFAULT_YES_OPTIONS = \ MLX5TOOL \ NETCAT \ NETGRAPH \ + NETLINK \ NLS_CATALOGS \ NS_CACHING \ NTP \ @@ -233,6 +234,7 @@ __DEFAULT_DEPENDENT_OPTIONS= \ KERBEROS \ KVM \ NETGRAPH \ + NETLINK \ PAM \ TESTS \ WIRELESS diff --git a/tools/build/options/WITHOUT_NETLINK_SUPPORT b/tools/build/options/WITHOUT_NETLINK_SUPPORT new file mode 100644 index 000000000000..4a72d3f1e4d1 --- /dev/null +++ b/tools/build/options/WITHOUT_NETLINK_SUPPORT @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Make libraries and programs use rtsock and +.Xr sysctl 3 +interfaces instead of +.Xr snl 3 . diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index e2c9ca09eea5..92f8aa9c30fa 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -6,7 +6,6 @@ PROG= netstat SRCS= if.c inet.c main.c mbuf.c mroute.c netisr.c nl_symbols.c route.c \ unix.c mroute6.c ipsec.c bpf.c pfkey.c sctp.c common.c nhops.c nhgrp.c \ - route_netlink.c \ nl_defs.h nl_symbols.c: nlist_symbols @@ -64,4 +63,10 @@ LIBADD+= netgraph CFLAGS+=-DNETGRAPH .endif +.if ${MK_NETLINK_SUPPORT} != "no" +SRCS+= route_netlink.c +.else +CFLAGS+=-DWITHOUT_NETLINK +.endif + .include diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 5de683ebfe7a..c597f3632fa6 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -96,16 +96,20 @@ struct bits rt_bits[] = { { 0 , 0, NULL } }; +#ifdef WITHOUT_NETLINK static struct ifmap_entry *ifmap; static size_t ifmap_size; +#endif static struct timespec uptime; static const char *netname4(in_addr_t, in_addr_t); #ifdef INET6 static const char *netname6(struct sockaddr_in6 *, struct sockaddr_in6 *); #endif +#ifdef WITHOUT_NETLINK static void p_rtable_sysctl(int, int); static void p_rtentry_sysctl(const char *name, struct rt_msghdr *); +#endif static void domask(char *, size_t, u_long); const uint32_t rt_default_weight = RT_DEFAULT_WEIGHT; @@ -143,8 +147,11 @@ routepr(int fibnum, int af) if (fibnum) xo_emit(" ({L:fib}: {:fib/%d})", fibnum); xo_emit("\n"); - if (!p_rtable_netlink(fibnum, af)) - p_rtable_sysctl(fibnum, af); +#ifdef WITHOUT_NETLINK + p_rtable_sysctl(fibnum, af); +#else + p_rtable_netlink(fibnum, af); +#endif xo_close_container("route-information"); } @@ -240,6 +247,7 @@ set_wid(int fam) wid.expire = 6; } +#ifdef WITHOUT_NETLINK static void p_rtable_sysctl(int fibnum, int af) { @@ -365,6 +373,7 @@ p_rtentry_sysctl(const char *name, struct rt_msghdr *rtm) xo_emit("\n"); xo_close_instance(name); } +#endif int p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask,