Project

General

Profile

Actions

Bug #2965

closed

read(2), etc. return EAFNOSUPPORT after UDP disconnect

Added by cmusser over 7 years ago. Updated over 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Networking
Target version:
-
Start date:
11/07/2016
Due date:
% Done:

0%

Estimated time:

Description

I ran into an unexpected return code from read(2)-like functions after unconnecting a connected UDP socket.

From what I've gleaned (from Stevens' "UNP", man pages, testing on other systems). unconnecting a connected UDP socket is done by passing a "null address" to connect(2). In response, it unconnects the socket and returns success (0) or EAFNOSUPPORT

On DragonFly, connect(2) returns success and unconnects the socket, but then the next read from the socket returns EAFNOSUPPORT. It seems as if EAFNOSUPPORT should come from `connect(2) instead. Neither read(2), recvfrom(2) or recvmsg(2) are documented as returning EAFNOSUPPORT.

I have a Github project at https://github.com/cmusser/udp_disconnect that demonstrates this behavior.

Actions #1

Updated by cmusser over 7 years ago

Turns out that the kern.ipc.soconnect_async sysctl flag affects this. When disabled, the behavior is similar to the other BSDs: disconnecting a connected UDP socket returns EAFNOSUPPORT from connect(2), not read(2). Not sure if the soconnect_async flag is supposed to affect UDP sockets, but it does.

Actions #2

Updated by sepherosa over 7 years ago

OK, I see. I think the main issue is returning connect(2) error from
read(2) in async mode.

On Tue, Nov 22, 2016 at 9:29 AM,
<> wrote:

Issue #2965 has been updated by cmusser.

Turns out that the kern.ipc.soconnect_async sysctl flag affects this. When disabled, the behavior is similar to the other BSDs: disconnecting a connected UDP socket returns EAFNOSUPPORT from connect(2), not read(2). Not sure if the soconnect_async flag is supposed to affect UDP sockets, but it does.

----------------------------------------
Bug #2965: read(2), etc. return EAFNOSUPPORT after UDP disconnect
http://bugs.dragonflybsd.org/issues/2965#change-13034

  • Author: cmusser
  • Status: New
  • Priority: Normal
  • Assignee:
  • Category: Networking
  • Target version:
    ----------------------------------------
    I ran into an unexpected return code from read(2)-like functions after unconnecting a connected UDP socket.

From what I've gleaned (from Stevens' "UNP", man pages, testing on other systems). unconnecting a connected UDP socket is done by passing a "null address" to connect(2). In response, it unconnects the socket and returns success (0) or EAFNOSUPPORT

On DragonFly, connect(2) returns success and unconnects the socket, but then the next read from the socket returns EAFNOSUPPORT. It seems as if EAFNOSUPPORT should come from `connect(2) instead. Neither read(2), recvfrom(2) or recvmsg(2) are documented as returning EAFNOSUPPORT.

I have a Github project at https://github.com/cmusser/udp_disconnect that demonstrates this behavior.

--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

--
Tomorrow Will Never Die

Actions #3

Updated by sepherosa over 7 years ago

The read error issue is fixed by
219503cf61ebf0aa6c01e49f6b073f0a40e0f1ec on the latest master. I
believe it should be adequate to fix your issue for asynchronous
connect.

On Tue, Nov 22, 2016 at 10:21 AM, Sepherosa Ziehau <> wrote:

OK, I see. I think the main issue is returning connect(2) error from
read(2) in async mode.

On Tue, Nov 22, 2016 at 9:29 AM,
<> wrote:

Issue #2965 has been updated by cmusser.

Turns out that the kern.ipc.soconnect_async sysctl flag affects this. When disabled, the behavior is similar to the other BSDs: disconnecting a connected UDP socket returns EAFNOSUPPORT from connect(2), not read(2). Not sure if the soconnect_async flag is supposed to affect UDP sockets, but it does.

----------------------------------------
Bug #2965: read(2), etc. return EAFNOSUPPORT after UDP disconnect
http://bugs.dragonflybsd.org/issues/2965#change-13034

  • Author: cmusser
  • Status: New
  • Priority: Normal
  • Assignee:
  • Category: Networking
  • Target version:
    ----------------------------------------
    I ran into an unexpected return code from read(2)-like functions after unconnecting a connected UDP socket.

From what I've gleaned (from Stevens' "UNP", man pages, testing on other systems). unconnecting a connected UDP socket is done by passing a "null address" to connect(2). In response, it unconnects the socket and returns success (0) or EAFNOSUPPORT

On DragonFly, connect(2) returns success and unconnects the socket, but then the next read from the socket returns EAFNOSUPPORT. It seems as if EAFNOSUPPORT should come from `connect(2) instead. Neither read(2), recvfrom(2) or recvmsg(2) are documented as returning EAFNOSUPPORT.

I have a Github project at https://github.com/cmusser/udp_disconnect that demonstrates this behavior.

--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

--
Tomorrow Will Never Die

--
Tomorrow Will Never Die

Actions #4

Updated by cmusser over 7 years ago

Yes, that change does prevent the subsequent read(2) (after the disconnect) from returning EAFNOSUPPORT.

Observations:

if soconnect_async = 1, the connect(2) to the null address (the disconnect) returns 0 (no error).
if soconnect_async = 0, the connect(2) to the null address -1 and sets errno to EAFNOSUPPORT.

Either one of these seems reasonable (Linux acts like case 1, the other BSDs act like case 2). The standard advice is to consider either of these cases to mean success, so the way it works is probably OK. Might want to document it though.

Actions #5

Updated by sepherosa over 7 years ago

Yeah :)

On Tue, Nov 22, 2016 at 12:32 PM,
<> wrote:

Issue #2965 has been updated by cmusser.

Yes, that change does prevent the subsequent read(2) (after the disconnect) from returning EAFNOSUPPORT.

Observations:

if soconnect_async = 1, the connect(2) to the null address (the disconnect) returns 0 (no error).
if soconnect_async = 0, the connect(2) to the null address -1 and sets errno to EAFNOSUPPORT.

Either one of these seems reasonable (Linux acts like case 1, the other BSDs act like case 2). The standard advice is to consider either of these cases to mean success, so the way it works is probably OK. Might want to document it though.

----------------------------------------
Bug #2965: read(2), etc. return EAFNOSUPPORT after UDP disconnect
http://bugs.dragonflybsd.org/issues/2965#change-13037

  • Author: cmusser
  • Status: New
  • Priority: Normal
  • Assignee:
  • Category: Networking
  • Target version:
    ----------------------------------------
    I ran into an unexpected return code from read(2)-like functions after unconnecting a connected UDP socket.

From what I've gleaned (from Stevens' "UNP", man pages, testing on other systems). unconnecting a connected UDP socket is done by passing a "null address" to connect(2). In response, it unconnects the socket and returns success (0) or EAFNOSUPPORT

On DragonFly, connect(2) returns success and unconnects the socket, but then the next read from the socket returns EAFNOSUPPORT. It seems as if EAFNOSUPPORT should come from `connect(2) instead. Neither read(2), recvfrom(2) or recvmsg(2) are documented as returning EAFNOSUPPORT.

I have a Github project at https://github.com/cmusser/udp_disconnect that demonstrates this behavior.

--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

--
Tomorrow Will Never Die

Actions #6

Updated by cmusser over 6 years ago

  • Status changed from New to Resolved

This was fixed a while back.

Actions

Also available in: Atom PDF