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
--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 <kp@FreeBSD.org> 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 = <https://cgit.freebsd.org/src/commit/?id=3D7e5bf68495cc0a8c9793a338a8a0200= 9a7f6dbb6> > commit 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6=20 > Author: Alexander V. Chernikov <melifaro@FreeBSD.org>=20 > AuthorDate: 2022-01-20 21:39:21 +0000=20 > Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>=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 = <http://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 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;"><meta = http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8"><div = style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; = line-break: after-white-space;"><br><div><br><blockquote = type=3D"cite"><div>On 9 Mar 2023, at 15:38, Kristof Provost = <kp@FreeBSD.org> wrote:</div><br = class=3D"Apple-interchange-newline"><div> <meta http-equiv=3D"Content-Type" content=3D"text/xhtml; charset=3Dutf-8">= <div><div style=3D"font-family: sans-serif;"><div class=3D"markdown" = style=3D"white-space: normal;"><p dir=3D"auto">On 1 Oct 2022, at 16:19, = Alexander V. Chernikov wrote:</p> </div><div class=3D"plaintext" style=3D"white-space: = normal;"><blockquote style=3D"margin: 0 0 5px; padding-left: 5px; = border-left: 2px solid #136BCE; color: #136BCE;"><p dir=3D"auto">The = branch main has been updated by melifaro:</p><p dir=3D"auto">URL: <a = href=3D"https://cgit.freebsd.org/src/commit/?id=3D7e5bf68495cc0a8c9793a338= a8a02009a7f6dbb6">https://cgit.FreeBSD.org/src/commit/?id=3D7e5bf68495cc0a= 8c9793a338a8a02009a7f6dbb6</a></p><p dir=3D"auto">commit = 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6 <br> Author: Alexander V. Chernikov <melifaro@FreeBSD.org> <br> AuthorDate: 2022-01-20 21:39:21 +0000 <br> Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> <br> CommitDate: 2022-10-01 14:15:35 +0000</p><p dir=3D"auto"> netlink: = add netlink = support</p></blockquote></div></div></div></div></blockquote>...<br><block= quote type=3D"cite"><div><div><div style=3D"font-family: = sans-serif;"><div class=3D"plaintext" style=3D"white-space: = normal;"><blockquote style=3D"margin: 0 0 5px; padding-left: 5px; = border-left: 2px solid #136BCE; color: #136BCE;"><p dir=3D"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=3D"markdown" style=3D"white-space: normal;"><p dir=3D"auto">So,= really fun thing here, we also have <code style=3D"padding: 0 0.25em; = background-color: #E4E4E4;">#define NETLINK_GENERIC 0</code> 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.)</p></div></div></div></div></blockquote><div>Wow. Thanks for = pointing it out - it wasn=E2=80=99t defined in the kernel headers so I = missed it.</div>That looks like something FreeBSD-specific. Both NetBSD = / OpenBSD doesn=E2=80=99t 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 =E2=80=99struct ifdata=E2=80=99 = (basic interface properties and some interface traffic = statistics)</div><div>- Link-specific data (IFDATA_LINKSPECIFIC), not = used by anything in base</div><div>- Original =E2=80=9Cdriver name=E2=80=9D= (IFDATA_DRIVERNAME)</div><div><br></div><div>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.</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 <a href=3D"http://net.link/">net.link</a>.generic16 with = value 16</div><div><br></div><div>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.</div><div>/Alexander</div><div><blockquote = type=3D"cite"><div><div><div style=3D"font-family: sans-serif;"><div = class=3D"markdown" style=3D"white-space: normal;"><p dir=3D"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=3D"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=3D"auto">Kristof</p> </div> </div> </div> </div></blockquote></div><br></div></body></html>= --Apple-Mail=_A2EEFF9C-084E-4E8A-B454-E60796315F2B--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2F410705-A141-49B4-8395-3B39D3EF1C3E>