tcp/ipv4 mapped address: Make sure that tcp_output is done on inpcb's owner CPU
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 22 Apr 2009 12:54:12 +0000 (20:54 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 22 Apr 2009 12:56:36 +0000 (20:56 +0800)
sys/netinet/tcp_usrreq.c

index 1756e83..a6159df 100644 (file)
@@ -453,6 +453,32 @@ tcp_output_dispatch(struct netmsg *nmsg)
 }
 #endif
 
+static int
+tcp_conn_output(struct tcpcb *tp)
+{
+       int error;
+#ifdef SMP
+       struct inpcb *inp = tp->t_inpcb;
+       lwkt_port_t port;
+
+       port = tcp_addrport(inp->inp_faddr.s_addr, inp->inp_fport,
+                           inp->inp_laddr.s_addr, inp->inp_lport);
+       if (port != &curthread->td_msgport) {
+               struct netmsg nmsg;
+               struct lwkt_msg *msg;
+
+               netmsg_init(&nmsg, &curthread->td_msgport, 0,
+                           tcp_output_dispatch);
+               msg = &nmsg.nm_lmsg;
+               msg->u.ms_resultp = tp;
+
+               error = lwkt_domsg(port, msg, 0);
+       } else
+#endif
+               error = tcp_output(tp);
+       return error;
+}
+
 /*
  * Initiate connection to peer.
  * Create a template for use in transmissions on this connection.
@@ -467,9 +493,6 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
        struct inpcb *inp;
        struct tcpcb *tp;
        struct sockaddr_in *sinp;
-#ifdef SMP
-       lwkt_port_t port;
-#endif
 
        COMMON_START(so, inp, 0);
 
@@ -491,22 +514,8 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
        if ((error = tcp_connect(tp, nam, td)) != 0)
                goto out;
 
-#ifdef SMP
-       port = tcp_addrport(inp->inp_faddr.s_addr, inp->inp_fport,
-                           inp->inp_laddr.s_addr, inp->inp_lport);
-       if (port != &curthread->td_msgport) {
-               struct netmsg nmsg;
-               struct lwkt_msg *msg;
-
-               netmsg_init(&nmsg, &curthread->td_msgport, 0,
-                           tcp_output_dispatch);
-               msg = &nmsg.nm_lmsg;
-               msg->u.ms_resultp = tp;
+       error = tcp_conn_output(tp);
 
-               error = lwkt_domsg(port, msg, 0);
-       } else
-#endif
-               error = tcp_output(tp);
        COMMON_END(PRU_CONNECT);
 }
 
@@ -549,7 +558,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
                inp->inp_vflag &= ~INP_IPV6;
                if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0)
                        goto out;
-               error = tcp_output(tp);
+               error = tcp_conn_output(tp);
                goto out;
        }
        inp->inp_vflag &= ~INP_IPV4;