From nobody Thu Mar 09 17:45:50 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 4PXc6g0F60z3xBdS; Thu, 9 Mar 2023 17:46:03 +0000 (UTC) (envelope-from melifaro@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PXc6f6sWwz4J1j; Thu, 9 Mar 2023 17:46:02 +0000 (UTC) (envelope-from melifaro@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678383963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c2GdjxeffgwH+R4c65WhQ4lKjjZWimpMe66Dm69bXYU=; b=rmjU/opelrUvTUo9rxlRs2W+PKKmox+UXDBon+TukMZohi20cnesuB8nMqrSw+TmwtFdOd uc6q5UnYGNCKPNh5T4hgUwe36NtfCWheSG5S/53HOom26DBEBGkmbcqtdjqc9Ocy/kuOuA Y1zm3SYNPYZ+UvzrgfBsF7fJsxJ8cvzvjGDWxspAQ/c0Kw8SZ577QT8Jx5BtRsPNOS8k4B 7lmrNKY/yc9D9UN6hAd2TLo9aivMuT8Ww8jq3AzE2nUkvFjUfWSXMzjMTZyqIW2GzBZf+V 42WAolEtysmAqLREw1xo+eHz5Lc2VBgTAoJJGIaWdataEXFFFlJRPpBKL3CDXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678383963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c2GdjxeffgwH+R4c65WhQ4lKjjZWimpMe66Dm69bXYU=; b=cQX1CgecdUx56Od98EupVnJAx4Ap/Ob97Y9OpeawTIFOVkHkoiLdHtn6VaieXfkQNXGHuK cqRbsVx374+xY+KAZe3Rt+n6bOD8ii2DCcJJhkD0boutaWjYuafmmrEHSUV5Y0veFaIWGj LLKQDhQbmb1cNGJS/JfJyLMDBUW8HTpVybliLoXLYRiA0s/EiXvfj2QgSy93Cms6R5rYQC 0TzgtYMrH3tRJqcf/+Alh5FU1xIJ525L7xZobcUHugZUYDVtMcO9iiK51mf7MmJZBqPfSR mjvowR5rTqACI25chy2+NyQiD14f5UjpKY5+tlab2Dv+Vcb9DNQgW1LWgaHyOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678383963; a=rsa-sha256; cv=none; b=X0VGfBgKTzSi1uNqLQ7mNNC2RgMDIE0mkRZpZQM9aGx8qVG7fB6o0IQcbAiRNsB3AoG+qb 5hOIchXcWIEi1zqYgfzGpkyRqCMoMXjD86wFhmVUNLALZ6eBfpjRk9o6ju/lsjEi6q2evG ahY/6Ke2culb5EA4S56qqBmPVOzimjCV4Yy4aLG3BaX6u6MoRb9lPUuFz9H4n01rPwnqWE ftI0AkJyc6gArtGvdr8Id3WtBuaPvvKDOONizBDxnnJJPzku60AKEleFFtxZE7rt20jimx XWPmyM8/7ZB0S1/2x9Lxn1TUc2AQ40RWxBEz8Z6YKsxgodN2nMgSD2+UFfzGbw== Received: from smtpclient.apple (unknown [IPv6:2a02:8084:d6bb:510:c420:e3c1:facc:fd2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: melifaro/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PXc6f1sxCzYVc; Thu, 9 Mar 2023 17:46:02 +0000 (UTC) (envelope-from melifaro@freebsd.org) From: Alexander Chernikov Message-Id: <2F410705-A141-49B4-8395-3B39D3EF1C3E@freebsd.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_A2EEFF9C-084E-4E8A-B454-E60796315F2B" 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 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Subject: Re: git: 7e5bf68495cc - main - netlink: add netlink support Date: Thu, 9 Mar 2023 17:45:50 +0000 In-Reply-To: <3D3095AE-60CC-4CCD-8C8A-A6E53EEB6A8A@FreeBSD.org> Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" To: Kristof Provost References: <202210011419.291EJ3aa000309@gitrepo.freebsd.org> <3D3095AE-60CC-4CCD-8C8A-A6E53EEB6A8A@FreeBSD.org> X-Mailer: Apple Mail (2.3731.400.51.1.1) X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_A2EEFF9C-084E-4E8A-B454-E60796315F2B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 9 Mar 2023, at 15:38, Kristof Provost wrote: >=20 > On 1 Oct 2022, at 16:19, Alexander V. Chernikov wrote: >=20 > The branch main has been updated by melifaro: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D7e5bf68495cc0a8c9793a338a8a02009= a7f6dbb6 = > commit 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6=20 > Author: Alexander V. Chernikov =20 > AuthorDate: 2022-01-20 21:39:21 +0000=20 > Commit: Alexander V. Chernikov =20 > CommitDate: 2022-10-01 14:15:35 +0000 >=20 > netlink: add netlink support >=20 ... > +=20 > +/*=20 > + * Defition of numbers assigned to the netlink subsystems.=20 > + */=20 > +#define NETLINK_ROUTE 0 /* Routing/device hook */=20 > +#define NETLINK_UNUSED 1 /* not supported */=20 > +#define NETLINK_USERSOCK 2 /* not supported */=20 > +#define NETLINK_FIREWALL 3 /* not supported */=20 > +#define NETLINK_SOCK_DIAG 4 /* not supported */=20 > +#define NETLINK_NFLOG 5 /* not supported */=20 > +#define NETLINK_XFRM 6 /* (not supported) PF_SETKEY */=20 > +#define NETLINK_SELINUX 7 /* not supported */=20 > +#define NETLINK_ISCSI 8 /* not supported */=20 > +#define NETLINK_AUDIT 9 /* not supported */=20 > +#define NETLINK_FIB_LOOKUP 10 /* not supported */=20 > +#define NETLINK_CONNECTOR 11 /* not supported */=20 > +#define NETLINK_NETFILTER 12 /* not supported */=20 > +#define NETLINK_IP6_FW 13 /* not supported */=20 > +#define NETLINK_DNRTMSG 14 /* not supported */=20 > +#define NETLINK_KOBJECT_UEVENT 15 /* not supported */=20 > +#define NETLINK_GENERIC 16 /* Generic netlink (dynamic families) */=20= > + >=20 > So, really fun thing here, we also have #define NETLINK_GENERIC 0 in = sys/net/if_mib.h. (And that=E2=80=99s exposed to userspace, and used = there, so we can=E2=80=99t just change that.) >=20 Wow. Thanks for pointing it out - it wasn=E2=80=99t defined in the = kernel headers so I missed it. That looks like something FreeBSD-specific. Both NetBSD / OpenBSD = doesn=E2=80=99t have it. It seem to provide: - iteration over the list of the interfaces - some basic interface traffic statistics - copy of the =E2=80=99struct ifdata=E2=80=99 (basic interface = properties and some interface traffic statistics) - Link-specific data (IFDATA_LINKSPECIFIC), not used by anything in base - Original =E2=80=9Cdriver name=E2=80=9D (IFDATA_DRIVERNAME) Most of this is already provided by either getifaddr(3) or netlink or = even rtsock. I=E2=80=99m thinking of deprecating it in mid-term in = favour of Netlink. I see the following options: 1) Remove usage of if_mib.h from ifconfig 2) Add compat layer: *) Rename NETLINK_GENERIC to NET_LINK_GENERIC (which is the right name = de-facto) *) Add conditional define for NETLINK_GENERIC to if_mib and set it to 16 *) Define another tree in if_mib.c under net.link = .generic16 with value 16 Personally I=E2=80=99m more thinking of starting from (1), then slowly = replace the remaining bsnmp usages, and then declare it deprecated after = 14.0. /Alexander > Which leads to much fun if we decided to do something like including = the netlink_generic header in other headers, so we can define messages = that contain the genlmsghdr struct. >=20 > I ran into that experimenting with netlink for carp(4). I think I can = work around it by adding a separate ip_carp_nl.h header for the netlink = stuff, but sooner or later this is going to bite us. >=20 > Kristof >=20 --Apple-Mail=_A2EEFF9C-084E-4E8A-B454-E60796315F2B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8


On 9 Mar 2023, at 15:38, Kristof Provost = <kp@FreeBSD.org> wrote:

=

On 1 Oct 2022, at 16:19, = Alexander V. Chernikov wrote:

The = branch main has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=3D7e5bf68495cc0a= 8c9793a338a8a02009a7f6dbb6

commit = 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6
Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-01-20 21:39:21 +0000
Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2022-10-01 14:15:35 +0000

netlink: = add netlink = support

...

+
+/*
+ * Defition of numbers assigned to the netlink subsystems.
+ */
+#define NETLINK_ROUTE 0 /* Routing/device hook */
+#define NETLINK_UNUSED 1 /* not supported */
+#define NETLINK_USERSOCK 2 /* not supported */
+#define NETLINK_FIREWALL 3 /* not supported */
+#define NETLINK_SOCK_DIAG 4 /* not supported */
+#define NETLINK_NFLOG 5 /* not supported */
+#define NETLINK_XFRM 6 /* (not supported) PF_SETKEY */
+#define NETLINK_SELINUX 7 /* not supported */
+#define NETLINK_ISCSI 8 /* not supported */
+#define NETLINK_AUDIT 9 /* not supported */
+#define NETLINK_FIB_LOOKUP 10 /* not supported */
+#define NETLINK_CONNECTOR 11 /* not supported */
+#define NETLINK_NETFILTER 12 /* not supported */
+#define NETLINK_IP6_FW 13 /* not supported */
+#define NETLINK_DNRTMSG 14 /* not supported */
+#define NETLINK_KOBJECT_UEVENT 15 /* not supported */
+#define NETLINK_GENERIC 16 /* Generic netlink = (dynamic families) */
+

So,= really fun thing here, we also have #define NETLINK_GENERIC 0 in = sys/net/if_mib.h. (And that=E2=80=99s exposed to userspace, and used = there, so we can=E2=80=99t just change = that.)

Wow. Thanks for = pointing it out - it wasn=E2=80=99t defined in the kernel headers so I = missed it.
That looks like something FreeBSD-specific. Both NetBSD = / OpenBSD doesn=E2=80=99t have it.
It seem to = provide:
- iteration over the list of the = interfaces
- some basic interface traffic = statistics
- copy of the =E2=80=99struct ifdata=E2=80=99 = (basic interface properties and some interface traffic = statistics)
- Link-specific data (IFDATA_LINKSPECIFIC), not = used by anything in base
- Original =E2=80=9Cdriver name=E2=80=9D= (IFDATA_DRIVERNAME)

Most of this is already = provided by either getifaddr(3) or netlink or even rtsock. I=E2=80=99m = thinking of deprecating it in mid-term in favour of = Netlink.

I see the following = options:
1) Remove usage of if_mib.h from = ifconfig

2) Add compat layer:
*) = Rename NETLINK_GENERIC to NET_LINK_GENERIC (which is the right name = de-facto)
*) Add conditional define for NETLINK_GENERIC to = if_mib and set it to 16
*) Define another tree in if_mib.c = under net.link.generic16 with = value 16

Personally I=E2=80=99m more thinking = of starting from (1), then slowly replace the remaining bsnmp usages, = and then declare it deprecated after = 14.0.
/Alexander

Which = leads to much fun if we decided to do something like including the = netlink_generic header in other headers, so we can define messages that = contain the genlmsghdr struct.

I ran into that = experimenting with netlink for carp(4). I think I can work around it by = adding a separate ip_carp_nl.h header for the netlink stuff, but sooner = or later this is going to bite us.

Kristof


= --Apple-Mail=_A2EEFF9C-084E-4E8A-B454-E60796315F2B--