netlink socket does not accept SOCK_DGRAM
- Reply: Alexander V. Chernikov: "Re: netlink socket does not accept SOCK_DGRAM"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 15 Jan 2023 02:26:02 UTC
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? $ 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