udp: Disable direct detach, if multicast options are set.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 25 Feb 2015 03:17:35 +0000 (11:17 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 25 Feb 2015 03:28:23 +0000 (11:28 +0800)
Add additional comment about disabling direct detach when setting
multicast options.

Submitted-by: Romick
DragonFly-bug: http://bugs.dragonflybsd.org/issues/2792

sys/netinet/udp_usrreq.c

index bb11fb0..b588256 100644 (file)
@@ -268,14 +268,18 @@ udp_ctloutput(netmsg_t msg)
                case IP_MULTICAST_LOOP:
                case IP_ADD_MEMBERSHIP:
                case IP_DROP_MEMBERSHIP:
-                       if (&curthread->td_msgport != netisr_cpuport(0)) {
-                               /*
-                                * This pr_ctloutput msg will be forwarded
-                                * to netisr0 to run; we can't do direct
-                                * detaching anymore.
-                                */
-                               inp->inp_flags &= ~INP_DIRECT_DETACH;
-                       }
+                       /*
+                        * This pr_ctloutput msg will be forwarded
+                        * to netisr0 to run; we can't do direct
+                        * detaching anymore.
+                        *
+                        * NOTE:
+                        * Don't optimize for the sockets whose
+                        * current so_port is netisr0's msgport.
+                        * These sockets could be connect(2)'ed
+                        * later and the so_port will be changed.
+                        */
+                       inp->inp_flags &= ~INP_DIRECT_DETACH;
                        break;
                }
        }