Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Mar 2023 17:45:50 +0000
From:      Alexander Chernikov <melifaro@freebsd.org>
To:        Kristof Provost <kp@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: 7e5bf68495cc - main - netlink: add netlink support
Message-ID:  <2F410705-A141-49B4-8395-3B39D3EF1C3E@freebsd.org>
In-Reply-To: <3D3095AE-60CC-4CCD-8C8A-A6E53EEB6A8A@FreeBSD.org>
References:  <202210011419.291EJ3aa000309@gitrepo.freebsd.org> <3D3095AE-60CC-4CCD-8C8A-A6E53EEB6A8A@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]


> 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=7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6 <https://cgit.freebsd.org/src/commit/?id=7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6>;
> 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’s exposed to userspace, and used there, so we can’t just change that.)
> 
Wow. Thanks for pointing it out - it wasn’t defined in the kernel headers so I missed it.
That looks like something FreeBSD-specific. Both NetBSD / OpenBSD doesn’t have it.
It seem to provide:
- iteration over the list of the interfaces
- some basic interface traffic statistics
- copy of the ’struct ifdata’ (basic interface properties and some interface traffic statistics)
- Link-specific data (IFDATA_LINKSPECIFIC), not used by anything in base
- Original “driver name” (IFDATA_DRIVERNAME)

Most of this is already provided by either getifaddr(3) or netlink or even rtsock. I’m 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 <http://net.link/>.generic16 with value 16

Personally I’m 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
> 


[-- Attachment #2 --]
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br><div><br><blockquote type="cite"><div>On 9 Mar 2023, at 15:38, Kristof Provost &lt;kp@FreeBSD.org&gt; wrote:</div><br class="Apple-interchange-newline"><div>


<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">

<div><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;"><p dir="auto">On 1 Oct 2022, at 16:19, Alexander V. Chernikov wrote:</p>
</div><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; color: #136BCE;"><p dir="auto">The branch main has been updated by melifaro:</p><p dir="auto">URL: <a href="https://cgit.freebsd.org/src/commit/?id=7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6">https://cgit.FreeBSD.org/src/commit/?id=7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6</a></p><p dir="auto">commit 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6
<br>
Author:     Alexander V. Chernikov &lt;melifaro@FreeBSD.org&gt;
<br>
AuthorDate: 2022-01-20 21:39:21 +0000
<br>
Commit:     Alexander V. Chernikov &lt;melifaro@FreeBSD.org&gt;
<br>
CommitDate: 2022-10-01 14:15:35 +0000</p><p dir="auto">    netlink: add netlink support</p></blockquote></div></div></div></div></blockquote>...<br><blockquote type="cite"><div><div><div style="font-family: sans-serif;"><div class="plaintext" style="white-space: normal;"><blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; color: #136BCE;"><p dir="auto">
+
<br>
+/*
<br>
+ * Defition of numbers assigned to the netlink subsystems.
<br>
+ */
<br>
+#define NETLINK_ROUTE		0	/* Routing/device hook */
<br>
+#define NETLINK_UNUSED		1	/* not supported */
<br>
+#define NETLINK_USERSOCK	2	/* not supported */
<br>
+#define NETLINK_FIREWALL	3	/* not supported */
<br>
+#define NETLINK_SOCK_DIAG	4	/* not supported */
<br>
+#define NETLINK_NFLOG		5	/* not supported */
<br>
+#define NETLINK_XFRM		6	/* (not supported) PF_SETKEY */
<br>
+#define NETLINK_SELINUX		7	/* not supported */
<br>
+#define NETLINK_ISCSI		8	/* not supported */
<br>
+#define NETLINK_AUDIT		9	/* not supported */
<br>
+#define NETLINK_FIB_LOOKUP	10	/* not supported */
<br>
+#define NETLINK_CONNECTOR	11	/* not supported */
<br>
+#define NETLINK_NETFILTER	12	/* not supported */
<br>
+#define NETLINK_IP6_FW		13	/* not supported  */
<br>
+#define NETLINK_DNRTMSG		14	/* not supported */
<br>
+#define NETLINK_KOBJECT_UEVENT	15	/* not supported */
<br>
+#define NETLINK_GENERIC		16	/* Generic netlink (dynamic families) */
<br>
+</p>
</blockquote></div>
<div class="markdown" style="white-space: normal;"><p dir="auto">So, really fun thing here, we also have <code style="padding: 0 0.25em; background-color: #E4E4E4;">#define NETLINK_GENERIC 0</code> in sys/net/if_mib.h. (And that’s exposed to userspace, and used there, so we can’t just change that.)</p></div></div></div></div></blockquote><div>Wow. Thanks for pointing it out - it wasn’t defined in the kernel headers so I missed it.</div>That looks like something FreeBSD-specific. Both NetBSD / OpenBSD doesn’t have it.</div><div>It seem to provide:</div><div>- iteration over the list of the interfaces</div><div>- some basic interface traffic statistics</div><div>- copy of the ’struct ifdata’ (basic interface properties and some interface traffic statistics)</div><div>- Link-specific data (IFDATA_LINKSPECIFIC), not used by anything in base</div><div>- Original “driver name” (IFDATA_DRIVERNAME)</div><div><br></div><div>Most of this is already provided by either getifaddr(3) or netlink or even rtsock. I’m thinking of deprecating it in mid-term in favour of Netlink.</div><div><br></div><div>I see the following options:</div><div>1) Remove usage of if_mib.h from ifconfig</div><div><br></div><div>2) Add compat layer:</div><div>*) Rename NETLINK_GENERIC to NET_LINK_GENERIC (which is the right name de-facto)</div><div>*) Add conditional define for NETLINK_GENERIC to if_mib and set it to 16</div><div>*) Define another tree in if_mib.c under&nbsp;<a href="http://net.link/">net.link</a>.generic16 with value 16</div><div><br></div><div>Personally I’m more thinking of starting from (1), then slowly replace the remaining bsnmp usages, and then declare it deprecated after 14.0.</div><div>/Alexander</div><div><blockquote type="cite"><div><div><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;"><p dir="auto">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.</p><p dir="auto">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.</p><p dir="auto">Kristof</p>

</div>
</div>
</div>


</div></blockquote></div><br></div></body></html>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2F410705-A141-49B4-8395-3B39D3EF1C3E>