From nobody Fri May 31 22:10:39 2024 X-Original-To: bugs@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 4Vrckm1wbkz5LVx8 for ; Fri, 31 May 2024 22:10:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vrckl74XGz4gZ4 for ; Fri, 31 May 2024 22:10:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717193440; a=rsa-sha256; cv=none; b=ylitaFVyh51QVujU2AaMGI0kTQu7m8A1q56GXsET1SlBEepUiehmsQ1clhaSCvV++y3nDq eHHyX0sxkm0po7gLj+ewScBvTk0GFmQgUd5nw9d4ba6foy3LWSIxKo+WHuIGNqJ+jKp2AB uBiyAZHo7kEas2JkphLoUKyoEhqxU4BdVNEq2KwnpCdUYrVF70k08QMqRMAo++yfYrt+u7 DjhRXFFkVT1Fj3KceGxPLKIG2FbBJXO0inybLTZC+tB4zjaqOqCHIA0UeVyJA7WXjnTcry D5BMHA4uLxzyBc/r8gyvZzCTzqW02YyRyinFMXV+NnrZonx1IFF/zVsopppd8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717193440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Sy7AyRV5l/uCNsyrod2/w47393z8SiGWjZWgsLkXTao=; b=qUFXJlr7C6P5ERKUuTYQtW/HkbUO54LmVjiJrPbMn3BuaKI/lS4uyWe95kknzDdt0dXyw5 KqcPOpyCCth1jmUoxnC1EBI9yIYyKgPNtMDWD7J3DgEbbbgfxRb8BbB/3j/hMQ6KtCY35T gYVSj8/8gTruW2gNbGNaJ/mVFyMQGX9j9G7hUiRpUYf/5McrmbvernzJTUdIKTX2NRv77H rRhfruaub+9H9xYqTuIPnU1Ke73AZ5FcCluRIoJGEemgpKpcoSnXfbSWD14JNApHp3Ruj+ PHZwNtA2M+6rK785Uy6GtDpWpb2PoNSrSbtO879njDDnuz2jIaEnEcybHj65pQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Vrckl6h9vzhnZ for ; Fri, 31 May 2024 22:10:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 44VMAdGT094734 for ; Fri, 31 May 2024 22:10:39 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 44VMAd6b094729 for bugs@FreeBSD.org; Fri, 31 May 2024 22:10:39 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 279444] rtnetlink: recv(4) with MSG_DONTWAIT returns EAGAIN. Date: Fri, 31 May 2024 22:10:39 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: gnats@duck.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279444 Bug ID: 279444 Summary: rtnetlink: recv(4) with MSG_DONTWAIT returns EAGAIN. Product: Base System Version: 14.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: gnats@duck.com When reading the title, you're probably thinking, =E2=80=9Cwell, yeah, that= 's how it should work.=E2=80=9D and while I agree with you, the musl developers don't= ! [1] (Though, it's really not their fault.) While testing the glibc netlink shenanigans bug #279012, I also decided to test musl. In which, I found that because musl does a recv(2) (which is technically a recvfrom(2)) with MSG_DONTWAIT on a netlink socket, it always returns -1 (EAGAIN or EWOULDBLO= CK). [1] That said, you can actually get it to work intermittently if you supply some latency (e.g., strace); however, like mentioned, this tends to be unpredictable. I imagine that the Linux kernel is not faster than us here, = but rather doing something clever, and we have yet to implement such trickery as well. I'll attach some code that reproduces the issue. This can be compiled= on the linuxulator and freebsd to the same effect, which implies this problem resides in the base netlink code. #include #include #ifdef __FreeBSD__ #include #include #else #include #endif #include int main(void) { int fd; fd =3D socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); if (fd < 0) return -1; unsigned int seq =3D 1; int type =3D RTM_GETLINK; int af =3D AF_UNSPEC; struct nlmsghdr * h; union { uint8_t buf[8192]; struct { struct nlmsghdr nlh; struct rtgenmsg g; } req; struct nlmsghdr reply; } u; int r, ret; memset( & u.req, 0, sizeof(u.req)); u.req.nlh.nlmsg_len =3D sizeof(u.req); u.req.nlh.nlmsg_type =3D type; u.req.nlh.nlmsg_flags =3D NLM_F_DUMP | NLM_F_REQUEST; u.req.nlh.nlmsg_seq =3D seq; u.req.g.rtgen_family =3D af; r =3D send(fd, & u.req, sizeof(u.req), 0); if (r < 0) return r; do { r =3D recv(fd, u.buf, sizeof(u.buf), MSG_DONTWAIT); if (r <=3D 0) printf("bad recv: %d\n", r); else printf("good recv: %d\n", r); } while (r <=3D 0); return 0; } [1] https://elixir.bootlin.com/musl/latest/source/src/network/netlink.c#L31 --=20 You are receiving this mail because: You are the assignee for the bug.=