Bug 24629

Summary: ng_socket failes to declare connected data sockets as connected.
Product: Base System Reporter: brandt <brandt>
Component: kernAssignee: Hartmut Brandt <harti>
Status: Closed FIXED    
Severity: Affects Only Me CC: eugen
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description brandt 2001-01-25 09:00:00 UTC
According to the ng_socket man page it should be possible to use naive
programs with ng_socket data sockets. This requires, that read() and
write() should work on these sockets. When using write(), the error
code EDESTADDRREQ is returned.

An inspection of the libnetgraph code shows, that connect() is called on
the data socket. That means the kernel should know the destination.
There are only two places in /sys/kern and /sys/netgraph where the 
EDESTADDRREQ is retured: in the generic sosend() and in ng_socket. A
further inspection shows, that the error in this case is returned by
the generic layer, because it thinks, that the socket is not connected.

Fix: 

ng_connect_data should set the SS_CONNECTED flag on the socket. Either
by calling soisconnected() or by directly setting the flag.
How-To-Repeat: Create a socket node and connected it to ONE arbitrary netgraph hook, that
accepts data. Use write(2) to write to the data socket. Observe the 
returned error code.
Comment 1 Tilman Keskinoz freebsd_committer freebsd_triage 2004-08-25 17:13:08 UTC
Responsible Changed
From-To: freebsd-bugs->harti

A very old PR from harti, who probably knows best if this is still a  
problem.
Comment 2 K. Macy freebsd_committer freebsd_triage 2007-11-16 04:13:12 UTC
State Changed
From-To: open->feedback


Need to confirm that this is still a problem.
Comment 3 Eugene Grosbein freebsd_committer freebsd_triage 2017-08-09 20:51:35 UTC
Solved 16 years ago (r72053).