udp: Don't propagate connect error, as long as the inpcb has local port.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 22 Nov 2016 02:57:13 +0000 (10:57 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 22 Nov 2016 03:01:42 +0000 (11:01 +0800)
This fixes the UDP socket disconnect->[read/write] support; before this
fix, the immediate read/write after disconnect will get EAFNOTSUPPORT.

sys/netinet/udp_usrreq.c

index 807a12c..103a5f8 100644 (file)
@@ -1591,7 +1591,13 @@ out:
        if (msg->connect.nm_flags & PRUC_HELDTD)
                lwkt_rele(td);
        if (error && (msg->connect.nm_flags & PRUC_ASYNC)) {
-               so->so_error = error;
+               if (inp->inp_lport == 0) {
+                       /*
+                        * As long as we have the local port, it is fine
+                        * for connect to fail, e.g. disconnect.
+                        */
+                       so->so_error = error;
+               }
                soclrstate(so, SS_ISCONNECTED);
                /*
                 * Wake up callers blocked on this socket to make sure