From nobody Mon Jan 16 15:13:56 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 4NwbCV6hK3z2scr7 for ; Mon, 16 Jan 2023 15:14:14 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from forward502b.mail.yandex.net (forward502b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d502]) (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 4NwbCT1m1Bz4P1W for ; Mon, 16 Jan 2023 15:14:12 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ipfw.ru header.s=mail header.b=NcdyOlsa; spf=pass (mx1.freebsd.org: domain of melifaro@ipfw.ru designates 2a02:6b8:c02:900:1:45:d181:d502 as permitted sender) smtp.mailfrom=melifaro@ipfw.ru; dmarc=none Received: from iva5-b9ce8295c822.qloud-c.yandex.net (iva5-b9ce8295c822.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:7f93:0:640:b9ce:8295]) by forward502b.mail.yandex.net (Yandex) with ESMTP id 065F15EBF7; Mon, 16 Jan 2023 18:14:08 +0300 (MSK) Received: by iva5-b9ce8295c822.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 6ElTEB3fGGk1-Ic3kPN2i; Mon, 16 Jan 2023 18:14:08 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfw.ru; s=mail; t=1673882048; bh=knaVqxyf5FB6CD98r8LcH4auPp7uNCL0c6PO4KMC/OE=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=NcdyOlsa6qF7pQQNmdHAQuULsVjYfVuLLJOHQl2ydrdq8p1ngnOYqUJ6oXBiNraFd ezhXJ11SuLfVF9g41SRlzCvFNKkd4RSOFuHpH4JmeK+5WWm7ZpfG7MEFdV5aK6QJIy pAHTB9jf957bknRehyAAcWaw0a0YF5ZF7Thndews= 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: Date: Mon, 16 Jan 2023 15:13:56 +0000 Cc: freebsd-current Content-Transfer-Encoding: quoted-printable Message-Id: <2EB1B277-F2AC-429D-901E-01766B534A3C@ipfw.ru> References: <92a63166-b3c3-228b-cda0-0cf769dfd364@antonovs.family> 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: 4NwbCT1m1Bz4P1W X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N > 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. > 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