Bug 129169 - [linux] [patch] Linux Emulation ENOTCONN error using non-blocking TCP
Summary: [linux] [patch] Linux Emulation ENOTCONN error using non-blocking TCP
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dmitry Chagin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-25 11:00 UTC by Steven Hartland
Modified: 2021-03-16 06:40 UTC (History)
3 users (show)

See Also:


Attachments
file.diff (887 bytes, patch)
2008-11-25 11:00 UTC, Steven Hartland
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Hartland 2008-11-25 11:00:13 UTC
In the Linux ABI a send() in a socket that is set non-blocking after a connect can produce ENOTCONN. This is caused by the underlying FreeBSD kernel call sendto() which checks for a connected end point, as this is still in progress, due to socket being non-blocking.

The fix is to check this condition in the Linux ABI and instead return EAGAIN which is what linux applications are expecting.

N.B. This currently breaks running Call of Duty World at War servers, specifically the server fails to authenticate with the global master server.

Fix: Apply the attached patch or derivative there of.

Patch attached with submission follows:
How-To-Repeat: In a linux application
1. Create a tcp socket
2. Set socket non-blocking
3. Connect to an end point
4. Perform a non-blocking send
5. ENOTCONN is returned.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2008-11-27 04:59:02 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-emulation

Over to maintainer(s).
Comment 2 Steven Hartland & 2012-02-07 09:23:44 UTC
Any update on this?
Comment 3 Steven Hartland freebsd_committer freebsd_triage 2012-12-13 22:16:57 UTC
Responsible Changed
From-To: freebsd-emulation->smh

I'll take it.
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:32 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 5 Dmitry Chagin freebsd_committer freebsd_triage 2019-05-16 15:53:26 UTC
(In reply to Steven Hartland from comment #3)
Hi, do you have a test program?
Comment 6 Steven Hartland freebsd_committer freebsd_triage 2019-05-16 17:14:09 UTC
I'm afraid I don't its been so many years :(
Comment 7 Dmitry Chagin freebsd_committer freebsd_triage 2019-05-19 08:40:47 UTC
np, I'll fix this
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-05-19 09:23:48 UTC
A commit references this bug:

Author: dchagin
Date: Sun May 19 09:23:20 UTC 2019
New revision: 347969
URL: https://svnweb.freebsd.org/changeset/base/347969

Log:
  Linux send() call returns EAGAIN instead of ENOTCONN in case when the
  socket is non-blocking and connect() is not finished yet.

  Initial patch developed by Steven Hartland in 2008 and adopted by me.

  PR:		129169
  Reported by:	smh@
  MFC after:	2 weeks

Changes:
  head/sys/compat/linux/linux_socket.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-08-24 15:51:09 UTC
A commit references this bug:

Author: trasz
Date: Mon Aug 24 15:50:58 UTC 2020
New revision: 364695
URL: https://svnweb.freebsd.org/changeset/base/364695

Log:
  MFC r347969 by dchagin:

  Linux send() call returns EAGAIN instead of ENOTCONN in case when the
  socket is non-blocking and connect() is not finished yet.

  Initial patch developed by Steven Hartland in 2008 and adopted by me.

  PR:		129169

Changes:
_U  stable/12/
  stable/12/sys/compat/linux/linux_socket.c