From nobody Sat Jan 21 18:08:25 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 4NzkrV6pgNz2sq19 for ; Sat, 21 Jan 2023 18:08:42 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from forward500c.mail.yandex.net (forward500c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d500]) (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 4NzkrT2GF3z4TPM for ; Sat, 21 Jan 2023 18:08:40 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ipfw.ru header.s=mail header.b=t7W2n7Zd; spf=pass (mx1.freebsd.org: domain of melifaro@ipfw.ru designates 2a02:6b8:c03:500:1:45:d181:d500 as permitted sender) smtp.mailfrom=melifaro@ipfw.ru; dmarc=none Received: from sas8-92ddc00f49ef.qloud-c.yandex.net (sas8-92ddc00f49ef.qloud-c.yandex.net [IPv6:2a02:6b8:c1b:2988:0:640:92dd:c00f]) by forward500c.mail.yandex.net (Yandex) with ESMTP id 90B205E8D2; Sat, 21 Jan 2023 21:08:37 +0300 (MSK) Received: by sas8-92ddc00f49ef.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id Z8tsM8leNKo1-AEfC8jjr; Sat, 21 Jan 2023 21:08:37 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfw.ru; s=mail; t=1674324517; bh=VcsGYjl4Q+hxCR/nukwt5IQIvFCB1SeKRaISNh1db8U=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=t7W2n7Zd0D5Td72rrRZ/MN761EAEWX/Sc8eKIjI6xQgpSfIQ5XDgC08yxkPxBSBw4 QFEjp4Cf4ocik7/jqZLZf9uh2RVBUW2nMSmC6mJyG8me4HtA/8Y1h1qc2aFUxwyY7h s6+ZqD9Zr+GV8Bf/F+TT5a9fymIGrKpwEIRiTOkQ= 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: <2EB1B277-F2AC-429D-901E-01766B534A3C@ipfw.ru> Date: Sat, 21 Jan 2023 18:08:25 +0000 Cc: freebsd-current Content-Transfer-Encoding: quoted-printable Message-Id: <0CA1F023-A461-4878-96A9-58C2D1F17A09@ipfw.ru> References: <92a63166-b3c3-228b-cda0-0cf769dfd364@antonovs.family> <2EB1B277-F2AC-429D-901E-01766B534A3C@ipfw.ru> To: User Ngor X-Mailer: Apple Mail (2.3731.200.110.1.12) X-Spamd-Result: default: False [-3.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip6:2a02:6b8:c00::/40]; R_DKIM_ALLOW(-0.20)[ipfw.ru:s=mail]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[freebsd-current@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[ipfw.ru:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ASN(0.00)[asn:208722, ipnet:2a02:6b8::/32, country:FI]; FREEFALL_USER(0.00)[melifaro]; ARC_NA(0.00)[]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[ipfw.ru]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Queue-Id: 4NzkrT2GF3z4TPM X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N > On 16 Jan 2023, at 15:13, Alexander V. Chernikov = wrote: >=20 >=20 >=20 >> On 15 Jan 2023, at 13:09, Alexander V. Chernikov = wrote: >>=20 >>>=20 >>> 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. > 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