> On 15 Jan 2023, at 02:26, User Ngor <ihor@antonovs.family> wrote:
>
> man 4 rtnetlink says:
>
> int socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
>
>
>
> The following snippet fails
>
> int fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
> if (fd < 0) {
> perror("Failed to open netlink socket");
> return -1;
> }
> printf("all good\n");
> close(fd);
> return 0;
>
> I get: Failed to open netlink socket: Protocol wrong type for socket
>
>
> but if I change
> int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
>
> I get "all good"
>
> Am I doing something wrong or is this a bug?
It’s a bug. The manage should state SOCK_RAW, but both options should be
supported, which is not the case ATM.
I’ll fix it in a couple of days.
Meanwhile it may be worth looking into snl(3) which abstracts issues like this
one.
>
>
>
> $ uname -a FreeBSD zen.hq 14.0-CURRENT FreeBSD 14.0-CURRENT #0
> main-n259967-11b5b9e8a520: Sat Jan 7 16:39:30 UTC 2023
> r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
>
> $ kldstat | grep netl
> 39 1 0xffffffff839fc000 14af8 netlink.ko
>
>
> --
> Ihor Antonov
>
>