Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 2023 15:13:56 +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:  <2EB1B277-F2AC-429D-901E-01766B534A3C@ipfw.ru>
In-Reply-To: <B5579CB7-C470-4C23-A8B3-657AA11FDB97@ipfw.ru>
References:  <92a63166-b3c3-228b-cda0-0cf769dfd364@antonovs.family> <B5579CB7-C470-4C23-A8B3-657AA11FDB97@ipfw.ru>

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



> On 15 Jan 2023, at 13:09, Alexander V. Chernikov <melifaro@ipfw.ru> wrote:
> 
>> 
>> 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.
Raised https://reviews.freebsd.org/D38075 with a fix.
> 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 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
>> 
>> $ kldstat | grep netl
>> 39    1 0xffffffff839fc000    14af8 netlink.ko
>> 
>> 
>> -- 
>> Ihor Antonov




help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2EB1B277-F2AC-429D-901E-01766B534A3C>