From nobody Mon Jan 24 11:31:14 2022 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 3E3A2196E402 for ; Mon, 24 Jan 2022 11:31:14 +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 4Jj78y0CvSz4nRV for ; Mon, 24 Jan 2022 11:31:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) 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 DCBFC1560A for ; Mon, 24 Jan 2022 11:31:13 +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 20OBVDUJ098538 for ; Mon, 24 Jan 2022 11:31:13 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 20OBVDnu098537 for bugs@FreeBSD.org; Mon, 24 Jan 2022 11:31:13 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 260116] [sctp] POLLOUT/EVFILT_WRITE is always true for poll/kqueue Date: Mon, 24 Jan 2022 11:31:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: bjorn.a.svensson@est.tech X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643023874; 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: in-reply-to:in-reply-to:references:references; bh=2wKkUBaRYL6lAYlflR3NFOfAFM2z0oavz57VSjTR9Ac=; b=Gua2lTbQThc7M7m5+FuVI9rhyks5NRu4TXUqKNvX0C7ikIe6Znnlm/nhEf7aWO7ZkPP8bP LU5+sjDC9jRhOnqK9y383ghntxme6lWYn+ZzBN/D9wQDXiatVJ4KbPMi4LyZ/EkTBh/kOU rweGzJ07hMMlzXz29m2hk0MhRhVS1CxbQ+u5bVI7G8M38KcYaCGpWlhhOFKSSF0upL3EOK q/rfGWrAAR7gBlDW+782sN3zu7aDDXcgF0CQaVw05eJztTz6NWqy+EsxpxJOx2niwZQsQu tJ6acs++Z4diKMiDAsPQ8HcGTK5ZIezWHwvA4hxA8zY86Ray/SI/LdgAdKG1Cg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643023874; a=rsa-sha256; cv=none; b=qwINE/GgurWbyPCekHXs9ZX51sJ89nVk7B9Z1COLoOfs4QLDzJoRlpSjzwciRoTpjq49T9 Wnm76XhR+5I7ebY9RB6u0PLA66lbHlP4BzXCtw0QABXmH6ZBljeWEh4xtTSGPtRrExeN9R O4ogcGW/yZt4aWMBVFg2ACMS7rDc2EMW6tBs9iBKtaJQFCbfPtYFEtZ5XCKccOAXqlElJW RmkDLS0hZUj+TD+k1nu5isax5CPCEp283ps8ZRdRDPplK9P/tHmsvyvRgAQRAZ3bLzWWNW QlQ1fJV9VJP2g/flbYnBynJhEKwUaIxT5S+md2wteSTPExKZCEzFUVnnNeGLwQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260116 --- Comment #2 from Bj=C3=B6rn Svensson --- After some investigations we have seen that the introduction of "sendfile(2) system call' required some changes in the struct sockbuf. The field sb_cc was split into sb_ccc and sb_acc in commit: 0f9d0a73a495 For SCTP a macro was introduced to handle this change via commit: 4e88d37a2= a73 The change of using sb_ccc instead of sb_cc unfortunately seemed to trigger problems with SCTP sockets and select() so it was changed to use sb_acc ins= tead via commit: 975c975bf0f1 The problem we now see is that when POLLOUT/EVFILT_WRITE are handled in sopoll_generic() and filt_sowrite() they call sbspace(): https://github.com/freebsd/freebsd-src/blob/main/sys/kern/uipc_socket.c#L39= 52 https://github.com/freebsd/freebsd-src/blob/main/sys/kern/uipc_socket.c#L36= 30 https://github.com/freebsd/freebsd-src/blob/main/sys/sys/socketvar.h#L325 but sbspace() still uses sb->sb_ccc when calculating the space. https://github.com/freebsd/freebsd-src/blob/main/sys/sys/sockbuf.h#L239 This results in that the socket always seems writeable even when the sendbu= ffer is full. Some ideas to solve this would be to: - Change sbspace() to use sb_acc when sb_ccc is zero. * This might be a bit hacky * This might affect other users of the function. - Update both sb_acc and sb_ccc in SCTP Since SCTP already updates sb_acc to fit into the framework we can=20 double book the value to sb_ccc as well. The sb_acc field should be the owner of the information, but when changed it's copied to sb_ccc. * This only affects the SCTP code Any thoughts or other ideas? I will create a patchset for updating both sb_ccc and sb_acc and test this idea. --=20 You are receiving this mail because: You are the assignee for the bug.=