From nobody Sun Jan 15 13:09:51 2023 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NvwVq110Tz2ssch for ; Sun, 15 Jan 2023 13:10:11 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from forward501c.mail.yandex.net (forward501c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d501]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4NvwVp2ZJvz4ShL for ; Sun, 15 Jan 2023 13:10:10 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Authentication-Results: mx1.freebsd.org; none Received: from iva5-344f444591f3.qloud-c.yandex.net (iva5-344f444591f3.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:687:0:640:344f:4445]) by forward501c.mail.yandex.net (Yandex) with ESMTP id 42CE85EA98; Sun, 15 Jan 2023 16:10:04 +0300 (MSK) Received: by iva5-344f444591f3.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 1AiNPMMZPa61-Ke9HpYlN; Sun, 15 Jan 2023 16:10:03 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfw.ru; s=mail; t=1673788203; bh=OAhULRT9yIobrcFR7Z6hjsEfg0SaSjqco/QH7vrng9o=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=JEdKtaZRPJXG6dsmk6edHoQuAvdQNs3G1/56Y1RO/KxXblWv8XEZ/w5ZYfRQT93RZ lHrlOu+VtKGb4mmSlW3/eIq9vHYkGdhRAQVyoCG4DePWXALtnPgAig8hv3EAJyoD3l JrSh/TBH4yCYE4tlwzx9UNcrlwOSaoaWgToq+wz8= Content-Type: text/plain; charset=utf-8 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.200.110.1.12\)) Subject: Re: netlink socket does not accept SOCK_DGRAM From: "Alexander V. Chernikov" In-Reply-To: <92a63166-b3c3-228b-cda0-0cf769dfd364@antonovs.family> Date: Sun, 15 Jan 2023 13:09:51 +0000 Cc: freebsd-current Content-Transfer-Encoding: quoted-printable Message-Id: References: <92a63166-b3c3-228b-cda0-0cf769dfd364@antonovs.family> To: User Ngor X-Mailer: Apple Mail (2.3731.200.110.1.12) X-Rspamd-Queue-Id: 4NvwVp2ZJvz4ShL X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:208722, ipnet:2a02:6b8::/32, country:FI] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N > On 15 Jan 2023, at 02:26, User Ngor 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. 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 >=20 >=20