Date: Sat, 21 Jan 2023 18:08:25 +0000 From: "Alexander V. Chernikov" <melifaro@ipfw.ru> To: User Ngor <ihor@antonovs.family> Cc: freebsd-current <freebsd-current@freebsd.org> Subject: Re: netlink socket does not accept SOCK_DGRAM Message-ID: <0CA1F023-A461-4878-96A9-58C2D1F17A09@ipfw.ru> In-Reply-To: <2EB1B277-F2AC-429D-901E-01766B534A3C@ipfw.ru> References: <92a63166-b3c3-228b-cda0-0cf769dfd364@antonovs.family> <B5579CB7-C470-4C23-A8B3-657AA11FDB97@ipfw.ru> <2EB1B277-F2AC-429D-901E-01766B534A3C@ipfw.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
> On 16 Jan 2023, at 15:13, Alexander V. Chernikov <melifaro@ipfw.ru> = wrote: >=20 >=20 >=20 >> On 15 Jan 2023, at 13:09, Alexander V. Chernikov <melifaro@ipfw.ru> = wrote: >>=20 >>>=20 >>> On 15 Jan 2023, at 02:26, User Ngor <ihor@antonovs.family> wrote: >>>=20 >>> man 4 rtnetlink says: >>>=20 >>> int socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); >>>=20 >>>=20 >>>=20 >>> The following snippet fails >>>=20 >>> int fd =3D 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; >>>=20 >>> I get: Failed to open netlink socket: Protocol wrong type for socket >>>=20 >>>=20 >>> but if I change >>> int fd =3D socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); >>>=20 >>> I get "all good" >>>=20 >>> Am I doing something wrong or is this a bug? >> It=E2=80=99s a bug. The manage should state SOCK_RAW, but both = options should be supported, which is not the case ATM. >> I=E2=80=99ll fix it in a couple of days. > Raised https://reviews.freebsd.org/D38075 with a fix. Committed as 0079d177ab69. >> Meanwhile it may be worth looking into snl(3) which abstracts issues = like this one. >>>=20 >>>=20 >>>=20 >>> $ uname -a FreeBSD zen.hq 14.0-CURRENT FreeBSD 14.0-CURRENT #0 = main-n259967-11b5b9e8a520: Sat Jan 7 16:39:30 UTC 2023 = root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC = amd64 >>>=20 >>> $ kldstat | grep netl >>> 39 1 0xffffffff839fc000 14af8 netlink.ko >>>=20 >>>=20 >>> --=20 >>> Ihor Antonov
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0CA1F023-A461-4878-96A9-58C2D1F17A09>