Date: Thu, 25 Aug 2005 13:38:19 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 82531 for review Message-ID: <200508251338.j7PDcJYL053378@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=82531 Change 82531 by rwatson@rwatson_paprika on 2005/08/25 13:37:31 Add backlog to the arguments passed to the protocol via pru_listen, and then back to the socket layer via solisten_proto(). This allows the update to the socket backlog to be updated properly while holding the socket lock, and completes the move of control during the socket listen transition from the socket layer to the protocol layer using the socket layer as a service. Affected files ... .. //depot/projects/netsmp/src/sys/kern/uipc_socket.c#3 edit .. //depot/projects/netsmp/src/sys/kern/uipc_socket2.c#2 edit .. //depot/projects/netsmp/src/sys/kern/uipc_usrreq.c#2 edit .. //depot/projects/netsmp/src/sys/netatm/atm_aal5.c#2 edit .. //depot/projects/netsmp/src/sys/netatm/atm_cm.c#2 edit .. //depot/projects/netsmp/src/sys/netatm/atm_socket.c#2 edit .. //depot/projects/netsmp/src/sys/netatm/atm_var.h#2 edit .. //depot/projects/netsmp/src/sys/netatm/ipatm/ipatm_if.c#2 edit .. //depot/projects/netsmp/src/sys/netatm/ipatm/ipatm_load.c#2 edit .. //depot/projects/netsmp/src/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h#2 edit .. //depot/projects/netsmp/src/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h#2 edit .. //depot/projects/netsmp/src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c#2 edit .. //depot/projects/netsmp/src/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c#2 edit .. //depot/projects/netsmp/src/sys/netinet/tcp_usrreq.c#4 edit .. //depot/projects/netsmp/src/sys/netipx/spx_usrreq.c#2 edit .. //depot/projects/netsmp/src/sys/sys/protosw.h#3 edit .. //depot/projects/netsmp/src/sys/sys/socketvar.h#2 edit Differences ... ==== //depot/projects/netsmp/src/sys/kern/uipc_socket.c#3 (text+ko) ==== @@ -275,7 +275,7 @@ * existing listen socket. The protocol will call back into the sockets * layer using solisten_proto_check() and solisten_proto() to check and set * socket-layer listen state. Call backs are used so that the protocol can - * acquire both protocol and socket layer locks in whatever order is reuiqred + * acquire both protocol and socket layer locks in whatever order is required * by the protocol. * * Protocol implementors are advised to hold the socket lock across the @@ -287,21 +287,8 @@ int backlog; struct thread *td; { - int error; - error = (*so->so_proto->pr_usrreqs->pru_listen)(so, td); - if (error) - return (error); - - /* - * XXXRW: The following state adjustment should occur in - * solisten_proto(), but we don't currently pass the backlog request - * to the protocol via pru_listen(). - */ - if (backlog < 0 || backlog > somaxconn) - backlog = somaxconn; - so->so_qlimit = backlog; - return (0); + return ((*so->so_proto->pr_usrreqs->pru_listen)(so, backlog, td)); } int @@ -318,12 +305,16 @@ } void -solisten_proto(so) +solisten_proto(so, backlog) struct socket *so; + int backlog; { SOCK_LOCK_ASSERT(so); + if (backlog < 0 || backlog > somaxconn) + backlog = somaxconn; + so->so_qlimit = backlog; so->so_options |= SO_ACCEPTCONN; } ==== //depot/projects/netsmp/src/sys/kern/uipc_socket2.c#2 (text+ko) ==== @@ -1327,7 +1327,7 @@ } int -pru_listen_notsupp(struct socket *so, struct thread *td) +pru_listen_notsupp(struct socket *so, int backlog, struct thread *td) { return EOPNOTSUPP; } ==== //depot/projects/netsmp/src/sys/kern/uipc_usrreq.c#2 (text+ko) ==== @@ -125,7 +125,8 @@ static void unp_discard(struct file *); static void unp_freerights(struct file **, int); static int unp_internalize(struct mbuf **, struct thread *); -static int unp_listen(struct socket *, struct unpcb *, struct thread *); +static int unp_listen(struct socket *, struct unpcb *, int, + struct thread *); static int uipc_abort(struct socket *so) @@ -274,7 +275,7 @@ } static int -uipc_listen(struct socket *so, struct thread *td) +uipc_listen(struct socket *so, int backlog, struct thread *td) { struct unpcb *unp; int error; @@ -285,7 +286,7 @@ UNP_UNLOCK(); return (EINVAL); } - error = unp_listen(so, unp, td); + error = unp_listen(so, unp, backlog, td); UNP_UNLOCK(); return (error); } @@ -1802,7 +1803,8 @@ } static int -unp_listen(struct socket *so, struct unpcb *unp, struct thread *td) +unp_listen(struct socket *so, struct unpcb *unp, int backlog, + struct thread *td) { int error; @@ -1813,7 +1815,7 @@ if (error == 0) { cru2x(td->td_ucred, &unp->unp_peercred); unp->unp_flags |= UNP_HAVEPCCACHED; - solisten_proto(so); + solisten_proto(so, backlog); } SOCK_UNLOCK(so); return (error); ==== //depot/projects/netsmp/src/sys/netatm/atm_aal5.c#2 (text+ko) ==== @@ -69,7 +69,8 @@ static int atm_aal5_detach(struct socket *); static int atm_aal5_bind(struct socket *, struct sockaddr *, struct thread *td); -static int atm_aal5_listen(struct socket *, struct thread *td); +static int atm_aal5_listen(struct socket *, int backlog, + struct thread *td); static int atm_aal5_connect(struct socket *, struct sockaddr *, struct thread *td); static int atm_aal5_accept(struct socket *, struct sockaddr **); @@ -328,13 +329,14 @@ * */ static int -atm_aal5_listen(so, td) +atm_aal5_listen(so, backlog, td) struct socket *so; + int backlog; struct thread *td; { ATM_INTRO("listen"); - err = atm_sock_listen(so, &atm_aal5_endpt); + err = atm_sock_listen(so, &atm_aal5_endpt, backlog); ATM_OUTRO(); } ==== //depot/projects/netsmp/src/sys/netatm/atm_cm.c#2 (text+ko) ==== @@ -536,12 +536,13 @@ * */ int -atm_cm_listen(so, epp, token, ap, copp) +atm_cm_listen(so, epp, token, ap, copp, backlog) struct socket *so; Atm_endpoint *epp; void *token; Atm_attributes *ap; Atm_connection **copp; + int backlog; { Atm_connection *cop; int s, err = 0; @@ -737,7 +738,7 @@ cop->co_state = COS_LISTEN; LINK2TAIL(cop, Atm_connection, atm_listen_queue, co_next); if (so != NULL) - solisten_proto(so); + solisten_proto(so, backlog); donex: (void) splx(s); ==== //depot/projects/netsmp/src/sys/netatm/atm_socket.c#2 (text+ko) ==== @@ -335,9 +335,10 @@ * */ int -atm_sock_listen(so, epp) +atm_sock_listen(so, epp, backlog) struct socket *so; Atm_endpoint *epp; + int backlog; { Atm_pcb *atp = sotoatmpcb(so); @@ -350,7 +351,8 @@ /* * Start listening for incoming calls */ - return (atm_cm_listen(so, epp, atp, &atp->atp_attr, &atp->atp_conn)); + return (atm_cm_listen(so, epp, atp, &atp->atp_attr, &atp->atp_conn, + backlog)); } ==== //depot/projects/netsmp/src/sys/netatm/atm_var.h#2 (text+ko) ==== @@ -82,7 +82,7 @@ int atm_cm_connect(Atm_endpoint *, void *, Atm_attributes *, Atm_connection **); int atm_cm_listen(struct socket *, Atm_endpoint *, void *, - Atm_attributes *, Atm_connection **); + Atm_attributes *, Atm_connection **, int); int atm_cm_addllc(Atm_endpoint *, void *, struct attr_llc *, Atm_connection *, Atm_connection **); int atm_cm_addparty(Atm_connection *, int, struct t_atm_sap *); @@ -152,7 +152,7 @@ int atm_sock_attach(struct socket *, u_long, u_long); int atm_sock_detach(struct socket *); int atm_sock_bind(struct socket *, struct sockaddr *); -int atm_sock_listen(struct socket *, Atm_endpoint *); +int atm_sock_listen(struct socket *, Atm_endpoint *, int); int atm_sock_connect(struct socket *, struct sockaddr *, Atm_endpoint *); int atm_sock_disconnect(struct socket *); ==== //depot/projects/netsmp/src/sys/netatm/ipatm/ipatm_if.c#2 (text+ko) ==== @@ -60,7 +60,7 @@ #include <netatm/ipatm/ipatm_var.h> #include <netatm/ipatm/ipatm_serv.h> -static MALLOC_DEFINE(M_IPATM_NIF, "ipatm nif", "IP/ATM network interfaces"); +static MALLOC_DEFINE(M_IPATM_NIF, "ipatm_nif", "IP/ATM network interfaces"); /* * Local functions ==== //depot/projects/netsmp/src/sys/netatm/ipatm/ipatm_load.c#2 (text+ko) ==== @@ -524,7 +524,7 @@ */ if ((err = atm_cm_listen(NULL, &ipatm_endpt, (void *)(intptr_t)i, &ipatm_listeners[i].attr, - &ipatm_listeners[i].conn)) != 0) + &ipatm_listeners[i].conn, -1)) != 0) goto done; } ==== //depot/projects/netsmp/src/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h#2 (text+ko) ==== @@ -195,7 +195,7 @@ int ng_btsocket_l2cap_ctloutput (struct socket *, struct sockopt *); int ng_btsocket_l2cap_detach (struct socket *); int ng_btsocket_l2cap_disconnect (struct socket *); -int ng_btsocket_l2cap_listen (struct socket *, struct thread *); +int ng_btsocket_l2cap_listen (struct socket *, int, struct thread *); int ng_btsocket_l2cap_peeraddr (struct socket *, struct sockaddr **); int ng_btsocket_l2cap_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, ==== //depot/projects/netsmp/src/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h#2 (text+ko) ==== @@ -326,7 +326,7 @@ int ng_btsocket_rfcomm_ctloutput (struct socket *, struct sockopt *); int ng_btsocket_rfcomm_detach (struct socket *); int ng_btsocket_rfcomm_disconnect (struct socket *); -int ng_btsocket_rfcomm_listen (struct socket *, struct thread *); +int ng_btsocket_rfcomm_listen (struct socket *, int, struct thread *); int ng_btsocket_rfcomm_peeraddr (struct socket *, struct sockaddr **); int ng_btsocket_rfcomm_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, ==== //depot/projects/netsmp/src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c#2 (text+ko) ==== @@ -2406,7 +2406,7 @@ */ int -ng_btsocket_l2cap_listen(struct socket *so, struct thread *td) +ng_btsocket_l2cap_listen(struct socket *so, int backlog, struct thread *td) { ng_btsocket_l2cap_pcb_p pcb = so2l2cap_pcb(so); int error; @@ -2427,7 +2427,7 @@ error = EDESTADDRREQ; goto out; } - solisten_proto(so); + solisten_proto(so, backlog); out: SOCK_UNLOCK(so); return (error); ==== //depot/projects/netsmp/src/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c#2 (text+ko) ==== @@ -794,7 +794,7 @@ */ int -ng_btsocket_rfcomm_listen(struct socket *so, struct thread *td) +ng_btsocket_rfcomm_listen(struct socket *so, int backlog, struct thread *td) { ng_btsocket_rfcomm_pcb_p pcb = so2rfcomm_pcb(so); ng_btsocket_rfcomm_session_p s = NULL; @@ -858,7 +858,7 @@ goto out; l2so = NULL; } - solisten_proto(so); + solisten_proto(so, backlog); out: SOCK_UNLOCK(so); mtx_unlock(&ng_btsocket_rfcomm_sessions_mtx); ==== //depot/projects/netsmp/src/sys/netinet/tcp_usrreq.c#4 (text+ko) ==== @@ -290,7 +290,7 @@ * Prepare to accept connections. */ static int -tcp_usr_listen(struct socket *so, struct thread *td) +tcp_usr_listen(struct socket *so, int backlog, struct thread *td) { int error = 0; struct inpcb *inp; @@ -304,7 +304,7 @@ error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); if (error == 0) { tp->t_state = TCPS_LISTEN; - solisten_proto(so); + solisten_proto(so, backlog); } SOCK_UNLOCK(so); COMMON_END(PRU_LISTEN); @@ -312,7 +312,7 @@ #ifdef INET6 static int -tcp6_usr_listen(struct socket *so, struct thread *td) +tcp6_usr_listen(struct socket *so, int backlog, struct thread *td) { int error = 0; struct inpcb *inp; @@ -330,7 +330,7 @@ } if (error == 0) { tp->t_state = TCPS_LISTEN; - solisten_proto(so); + solisten_proto(so, backlog); } SOCK_UNLOCK(so); COMMON_END(PRU_LISTEN); ==== //depot/projects/netsmp/src/sys/netipx/spx_usrreq.c#2 (text+ko) ==== @@ -99,7 +99,7 @@ struct thread *td); static int spx_detach(struct socket *so); static int spx_usr_disconnect(struct socket *so); -static int spx_listen(struct socket *so, struct thread *td); +static int spx_listen(struct socket *so, int backlog, struct thread *td); static int spx_rcvd(struct socket *so, int flags); static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags); static int spx_send(struct socket *so, int flags, struct mbuf *m, @@ -1518,8 +1518,9 @@ } static int -spx_listen(so, td) +spx_listen(so, backlog, td) struct socket *so; + int backlog; struct thread *td; { int error; @@ -1538,7 +1539,7 @@ error = ipx_pcbbind(ipxp, NULL, td); if (error == 0) { cb->s_state = TCPS_LISTEN; - solisten_proto(so); + solisten_proto(so, backlog); } SOCK_UNLOCK(so); IPX_UNLOCK(ipxp); ==== //depot/projects/netsmp/src/sys/sys/protosw.h#3 (text+ko) ==== @@ -208,7 +208,8 @@ struct ifnet *ifp, struct thread *td); int (*pru_detach)(struct socket *so); int (*pru_disconnect)(struct socket *so); - int (*pru_listen)(struct socket *so, struct thread *td); + int (*pru_listen)(struct socket *so, int backlog, + struct thread *td); int (*pru_peeraddr)(struct socket *so, struct sockaddr **nam); int (*pru_rcvd)(struct socket *so, int flags); int (*pru_rcvoob)(struct socket *so, struct mbuf *m, int flags); @@ -257,7 +258,7 @@ struct ifnet *ifp, struct thread *td); int pru_detach_notsupp(struct socket *so); int pru_disconnect_notsupp(struct socket *so); -int pru_listen_notsupp(struct socket *so, struct thread *td); +int pru_listen_notsupp(struct socket *so, int backlog, struct thread *td); int pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam); int pru_rcvd_notsupp(struct socket *so, int flags); int pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags); ==== //depot/projects/netsmp/src/sys/sys/socketvar.h#2 (text+ko) ==== @@ -514,7 +514,7 @@ void soisdisconnected(struct socket *so); void soisdisconnecting(struct socket *so); int solisten(struct socket *so, int backlog, struct thread *td); -void solisten_proto(struct socket *so); +void solisten_proto(struct socket *so, int backlog); int solisten_proto_check(struct socket *so); struct socket * sonewconn(struct socket *head, int connstatus);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508251338.j7PDcJYL053378>