[PATCH] Netlink on FreeBSD support

Alexander Chernikov melifaro at freebsd.org
Sat Dec 17 14:27:23 CET 2022



> On 16 Dec 2022, at 18:59, Ondrej Zajicek via Bird-users <bird-users at trubka.network.cz> wrote:
> 
> On Thu, Dec 15, 2022 at 08:22:02PM +0000, Alexander Chernikov wrote:
>> 
>> A bit more patches (some bundled in net/bird already [1]).
>> * 0001-FreeBSD-fix-netlink-build.patch  adds missed bsd-netlink Makefile, that actually builds the target
> 
> Hmm, seems like i forgot to add the Makefile from your previous patch,
> but it didn't work properly anyways.
> 
> I do not like to redefine make rules like in this Makefile, seems to me
I didn’t like it either, symlink indeed looks cleaner.
> that the simplest solution is to put symlinks referencing linux/netlink*
> to sysdep/bsd-netlink dir.
> 
> See https://gitlab.nic.cz/labs/bird/-/commit/7b6c9649775b288653b0d61df6004d79f0d83ccf
Works for me! 
> 
> 
>> * 0002-FreeBSD-use-interface-index-instead-of-IP-address-wh.patch switches multicast interface specification from ip address to interface index. That allows to avoid iface->sysdep value, which is not filled by netlink.
> 
> Nice. Is this supported since long ago, or does it require some recent BSD version?
> Do you know whether it is supported also in other BSD flavors?
It’s a bit complicated :-)

FreeBSD:
IP_MULTICAST_IF - ip_mreqn support was added in [1] @ 2007.
IP_<ADD|DEL>_MEMBERSHIP - ip_mreqn support was added in [2] @ 2019 / FreeBSD 12.1. All currently supported FreeBSD versions have this functionality in place

OpenBSD:
IP_MULTICAST_IF - ip_mreqn support was added in [3] @ 2021
IP_<ADD|DEL>_MEMBERSHIP - ip_mreqn support was added in [4] @ 2021

NetBSD:
IP_MULTICAST_IF,  IP_<ADD|DEL>_MEMBERSHIP uses old API hack, treating 0/8 IPv4 addresses as ifindex. It was added in [5] @ 2001

> 
> I just modified it to use feature-specific #define.
Yep, it looks better, thank you!
> 
> See https://gitlab.nic.cz/labs/bird/-/commit/6825f94570b05f933f09ae1bd7e520954d903e6a
> 
> 
>> * 0003-netlink-move-OS-specific-headers-and-defines-to-sysd.patch introduces netlink OS-specific header to put all defines/includes/inlines
> 
> OK, moved netlink-sys.h to sysdep/bsd-netlink, that makes more sense to
> me. If we later merge bsd-netlink to bsd under one target, we can move it
> back.
> 
> Also removed netlink-nosup.h, it is not included anyways.
> 
> See https://gitlab.nic.cz/labs/bird/-/commit/176fc68aed32a5675aa643e3b7c6f65ff9ad13d0
Looks good.
> 
> 
> Hopefully these changes are okay for you.
Of course!
> 
> 
> BTW, are BSD Netlink constants (e.g. RTA_*) the same as Linux ones?
> Or it is just compatible on C macro/enum name level?
They are the same and the intent is to keep having them the same.
> 
> -- 
> Elen sila lumenn' omentielvo
> 
> Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
> OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
> "To err is human -- to blame it on a computer is even more so.”



[1] [Import rewrite of IPv4 socket multicast layer to support source-specific · freebsd/freebsd-src at 71498f3 · GitHub] https://github.com/freebsd/freebsd-src/commit/71498f308b2324dbd94e94fd8c4ae41bf4bd663b
[2] [Support struct ip_mreqn as argument for IP_ADD_MEMBERSHIP. Legacy sup… · freebsd/freebsd-src at 0dfc145 · GitHub] https://github.com/freebsd/freebsd-src/commit/0dfc145abe244443bb38ee81617462992bf21cf2
[3] [Extend IP_MULTICAST_IF to take either an address (struct in_addr), a · openbsd/src at 7f4b9fd · GitHub] https://github.com/openbsd/src/commit/7f4b9fd65d60b886b9f4ba05f8da3bd613db0526
[4] [Extend IP_ADD_MEMBERSHIP to also support struct ip_mreqn. · openbsd/src at c0ba2d2 · GitHub] https://github.com/openbsd/src/commit/c0ba2d2f58a32a98b4fcfb612bda013f1d51bd26
[5] [allow IP_MULTICAST_IF and IP_ADD/DROP_MEMBERSHIP to specify interface · NetBSD/src at 42bede7 · GitHub] https://github.com/NetBSD/src/commit/42bede79daa3e7cf4f0902d2bf96e1f548b6a01b






More information about the Bird-users mailing list