PERFORCE change 68159 for review
Robert Watson
rwatson at FreeBSD.org
Sun Jan 2 16:06:56 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=68159
Change 68159 by rwatson at rwatson_zoo on 2005/01/02 16:06:37
Integrate netperf_socket from FreeBSD CVS HEAD:
Loop back towards rwatson_netperf:
- Whitespace/style fixes for netipx.
- Use M_WAITOK in ipx_setpeeraddr() so that it can't fail.
- Remove extraneous ipxpcb list head extern left over from the
previous world order.
- Clean up ipx_input() return case for sbappendaddr() failing.
- Use __packed for SPX packet headers.
- Use KASSERT() in preference to if()panic().
- Compare pointers with NULL, not 0.
- Hold the socket buffer locks over longer periods of time in various
SPX routines, increasing atomicity and reducing the number of
locking operations. Particularly, in spx_reass() and spx_rcvoob().
- Clearly mark the call to spx_close() in spx_reass() as broken.
- Don't cast NULL.
- Fix bug relating to spx_timers() returning NULL due to an SPX
connection timing out.
Affected files ...
.. //depot/projects/netperf_socket/sys/netipx/README#2 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx.c#3 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_cksum.c#3 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_if.h#2 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_input.c#4 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_ip.c#3 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_pcb.c#8 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_pcb.h#3 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_proto.c#2 integrate
.. //depot/projects/netperf_socket/sys/netipx/ipx_usrreq.c#7 integrate
.. //depot/projects/netperf_socket/sys/netipx/spx.h#2 integrate
.. //depot/projects/netperf_socket/sys/netipx/spx_usrreq.c#11 integrate
Differences ...
==== //depot/projects/netperf_socket/sys/netipx/README#2 (text+ko) ====
@@ -1,4 +1,4 @@
-$FreeBSD: src/sys/netipx/README,v 1.2 2000/05/01 20:14:29 peter Exp $
+$FreeBSD: src/sys/netipx/README,v 1.3 2005/01/02 15:10:02 rwatson Exp $
This protocol implements IPX/SPX over Ethernet_II frame type 0x8137.
Please note: the SPX implementation may require further work and testing
@@ -19,5 +19,6 @@
Copyright (c) 1984, 1985, 1986, 1987, 1993
The Regents of the University of California. All rights reserved.
+Modifications Copyright (c) 2004, Robert N. M. Watson
Modifications Copyright (c) 1995, Mike Mitchell
Modifications Copyright (c) 1995, John Hay
==== //depot/projects/netperf_socket/sys/netipx/ipx.c#3 (text+ko) ====
@@ -30,12 +30,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* @(#)ipx.c
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx.c,v 1.27 2004/08/28 15:24:53 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx.c,v 1.28 2005/01/02 15:13:59 rwatson Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -204,7 +204,7 @@
}
IFAFREE((&oia->ia_ifa));
return (0);
-
+
case SIOCAIFADDR:
dstIsNew = 0;
hostIsNew = 1;
@@ -241,7 +241,7 @@
static void
ipx_ifscrub(ifp, ia)
register struct ifnet *ifp;
- register struct ipx_ifaddr *ia;
+ register struct ipx_ifaddr *ia;
{
if (ia->ia_flags & IFA_ROUTE) {
if (ifp->if_flags & IFF_POINTOPOINT) {
==== //depot/projects/netperf_socket/sys/netipx/ipx_cksum.c#3 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx_cksum.c,v 1.11 2004/07/28 06:58:23 kan Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx_cksum.c,v 1.12 2005/01/02 15:13:59 rwatson Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@@ -100,7 +100,7 @@
w++;
if (--len == 0)
break;
- }
+ }
}
ipx->ipx_tc = oldtc;
==== //depot/projects/netperf_socket/sys/netipx/ipx_if.h#2 (text+ko) ====
@@ -30,10 +30,10 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* @(#)ipx_if.h
*
- * $FreeBSD: src/sys/netipx/ipx_if.h,v 1.13 2003/03/04 23:19:53 jlemon Exp $
+ * $FreeBSD: src/sys/netipx/ipx_if.h,v 1.14 2005/01/02 15:13:59 rwatson Exp $
*/
#ifndef _NETIPX_IPX_IF_H_
==== //depot/projects/netperf_socket/sys/netipx/ipx_input.c#4 (text+ko) ====
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx_input.c,v 1.40 2005/01/02 01:39:37 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx_input.c,v 1.41 2005/01/02 15:13:59 rwatson Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -215,7 +215,7 @@
*/
for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next)
if((ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) &&
- ipx_neteq(ia->ia_addr.sipx_addr,
+ ipx_neteq(ia->ia_addr.sipx_addr,
ipx->ipx_dna))
goto ours;
@@ -484,8 +484,8 @@
if (ifp == ia->ia_ifp)
break;
if (ia == NULL)
- ipx->ipx_sna.x_host = ipx_zerohost;
- else
+ ipx->ipx_sna.x_host = ipx_zerohost;
+ else
ipx->ipx_sna.x_host =
ia->ia_addr.sipx_addr.x_host;
==== //depot/projects/netperf_socket/sys/netipx/ipx_ip.c#3 (text+ko) ====
@@ -30,12 +30,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* @(#)ipx_ip.c
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx_ip.c,v 1.37 2005/01/02 01:39:38 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx_ip.c,v 1.38 2005/01/02 15:13:59 rwatson Exp $");
/*
* Software interface driver for encapsulating IPX in IP.
@@ -346,7 +346,7 @@
register struct in_ifaddr *ia;
struct ifnet *ifp = ro.ro_rt->rt_ifp;
- for (ia = TAILQ_FIRST(&in_ifaddrhead); ia != NULL;
+ for (ia = TAILQ_FIRST(&in_ifaddrhead); ia != NULL;
ia = TAILQ_NEXT(ia, ia_link))
if (ia->ia_ifp == ifp)
break;
@@ -385,7 +385,7 @@
(struct ifnet *)ifn, sopt->sopt_td);
/* use any of our addresses */
- satoipx_addr(ifr_ipxip.ifr_addr).x_host =
+ satoipx_addr(ifr_ipxip.ifr_addr).x_host =
ipx_ifaddr->ia_addr.sipx_addr.x_host;
return (ipx_control(so, (int)SIOCSIFADDR, (caddr_t)&ifr_ipxip,
==== //depot/projects/netperf_socket/sys/netipx/ipx_pcb.c#8 (text+ko) ====
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx_pcb.c,v 1.37 2005/01/02 01:51:18 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx_pcb.c,v 1.39 2005/01/02 15:25:59 rwatson Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -53,7 +53,7 @@
#include <netipx/ipx_var.h>
static struct ipx_addr zeroipx_addr;
-static u_short ipxpcb_lport_cache;
+static u_short ipxpcb_lport_cache;
int
ipx_pcballoc(so, head, td)
@@ -73,7 +73,7 @@
so->so_pcb = (caddr_t)ipxp;
return (0);
}
-
+
int
ipx_pcbbind(ipxp, nam, td)
register struct ipxpcb *ipxp;
@@ -185,7 +185,7 @@
rtalloc_ign(ro, 0);
}
if (ipx_neteqnn(ipxp->ipxp_laddr.x_net, ipx_zeronet)) {
- /*
+ /*
* If route is known or can be allocated now,
* our src addr is taken from the i/f, else punt.
*/
@@ -214,7 +214,7 @@
ipxp->ipxp_laddr.x_net = satoipx_addr(ia->ia_addr).x_net;
}
if (ipx_nullhost(ipxp->ipxp_laddr)) {
- /*
+ /*
* If route is known or can be allocated now,
* our src addr is taken from the i/f, else punt.
*/
@@ -286,7 +286,7 @@
struct sockaddr **nam;
{
struct sockaddr_ipx *sipx, ssipx;
-
+
sipx = &ssipx;
bzero((caddr_t)sipx, sizeof(*sipx));
sipx->sipx_len = sizeof(*sipx);
@@ -303,11 +303,11 @@
struct sockaddr_ipx *sipx, ssipx;
sipx = &ssipx;
- bzero((caddr_t)sipx, sizeof(*sipx));
+ bzero(sipx, sizeof(*sipx));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_faddr;
- *nam = sodupsockaddr((struct sockaddr *)sipx, M_NOWAIT);
+ *nam = sodupsockaddr((struct sockaddr *)sipx, M_WAITOK);
}
struct ipxpcb *
==== //depot/projects/netperf_socket/sys/netipx/ipx_pcb.h#3 (text+ko) ====
@@ -34,7 +34,7 @@
*
* @(#)ipx_pcb.h
*
- * $FreeBSD: src/sys/netipx/ipx_pcb.h,v 1.20 2004/12/30 17:49:40 rwatson Exp $
+ * $FreeBSD: src/sys/netipx/ipx_pcb.h,v 1.21 2005/01/02 15:16:35 rwatson Exp $
*/
#ifndef _NETIPX_IPX_PCB_H_
@@ -85,8 +85,6 @@
#define IPXRCVQ 40960
#ifdef _KERNEL
-extern struct ipxpcb ipxpcb; /* head of list */
-
int ipx_pcballoc(struct socket *so, struct ipxpcbhead *head,
struct thread *p);
int ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam,
==== //depot/projects/netperf_socket/sys/netipx/ipx_proto.c#2 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx_proto.c,v 1.17 2003/06/11 05:25:14 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx_proto.c,v 1.18 2005/01/02 15:13:59 rwatson Exp $");
#include "opt_ipx.h"
@@ -94,7 +94,7 @@
};
static struct domain ipxdomain =
- { AF_IPX, "network systems", 0, 0, 0,
+ { AF_IPX, "network systems", 0, 0, 0,
ipxsw, &ipxsw[sizeof(ipxsw)/sizeof(ipxsw[0])], 0,
rn_inithead, 16, sizeof(struct sockaddr_ipx)};
==== //depot/projects/netperf_socket/sys/netipx/ipx_usrreq.c#7 (text+ko) ====
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/ipx_usrreq.c,v 1.44 2004/12/31 17:05:37 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/ipx_usrreq.c,v 1.48 2005/01/02 15:29:29 rwatson Exp $");
#include "opt_ipx.h"
@@ -82,7 +82,7 @@
static int ipx_detach(struct socket *so);
static int ipx_disconnect(struct socket *so);
static int ipx_send(struct socket *so, int flags, struct mbuf *m,
- struct sockaddr *addr, struct mbuf *control,
+ struct sockaddr *addr, struct mbuf *control,
struct thread *td);
static int ipx_shutdown(struct socket *so);
static int ripx_attach(struct socket *so, int proto, struct thread *td);
@@ -128,8 +128,7 @@
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct sockaddr_ipx ipx_ipx;
- if (ipxp == NULL)
- panic("No ipxpcb");
+ KASSERT(ipxp != NULL, ("ipx_input: NUL ipxpcb"));
/*
* Construct sockaddr format source address.
* Stuff source address and datagram in user buffer.
@@ -142,7 +141,7 @@
if (ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet) && ifp != NULL) {
register struct ifaddr *ifa;
- for (ifa = TAILQ_FIRST(&ifp->if_addrhead); ifa != NULL;
+ for (ifa = TAILQ_FIRST(&ifp->if_addrhead); ifa != NULL;
ifa = TAILQ_NEXT(ifa, ifa_link)) {
if (ifa->ifa_addr->sa_family == AF_IPX) {
ipx_ipx.sipx_addr.x_net =
@@ -152,18 +151,16 @@
}
}
ipxp->ipxp_rpt = ipx->ipx_pt;
- if (!(ipxp->ipxp_flags & IPXP_RAWIN) ) {
+ if ((ipxp->ipxp_flags & IPXP_RAWIN) == 0) {
m->m_len -= sizeof(struct ipx);
m->m_pkthdr.len -= sizeof(struct ipx);
m->m_data += sizeof(struct ipx);
}
- if (sbappendaddr(&ipxp->ipxp_socket->so_rcv, (struct sockaddr *)&ipx_ipx,
- m, (struct mbuf *)NULL) == 0)
- goto bad;
- sorwakeup(ipxp->ipxp_socket);
- return;
-bad:
- m_freem(m);
+ if (sbappendaddr(&ipxp->ipxp_socket->so_rcv,
+ (struct sockaddr *)&ipx_ipx, m, NULL) == 0)
+ m_freem(m);
+ else
+ sorwakeup(ipxp->ipxp_socket);
}
void
@@ -225,7 +222,7 @@
/*
* Make sure packet is actually of even length.
*/
-
+
if (len & 1) {
m = mprev;
if ((m->m_flags & M_EXT) == 0 &&
@@ -308,7 +305,7 @@
&satoipx_addr(ro->ro_dst);
dst->x_host = ipx->ipx_dna.x_host;
}
- /*
+ /*
* Otherwise, we go through the same gateway
* and dst is already set up.
*/
@@ -351,7 +348,7 @@
case SO_IPX_CHECKSUM:
mask = IPXP_CHECKSUM;
goto get_flags;
-
+
case SO_HEADERS_ON_OUTPUT:
mask = IPXP_RAWOUT;
get_flags:
@@ -370,7 +367,7 @@
break;
case SO_SEQNO:
- error = sooptcopyout(sopt, &ipx_pexseq,
+ error = sooptcopyout(sopt, &ipx_pexseq,
sizeof ipx_pexseq);
ipx_pexseq++;
break;
@@ -532,7 +529,7 @@
{
struct ipxpcb *ipxp = sotoipxpcb(so);
- ipx_setpeeraddr(ipxp, nam); /* XXX what if alloc fails? */
+ ipx_setpeeraddr(ipxp, nam);
return (0);
}
@@ -600,7 +597,7 @@
{
struct ipxpcb *ipxp = sotoipxpcb(so);
- ipx_setsockaddr(ipxp, nam); /* XXX what if alloc fails? */
+ ipx_setsockaddr(ipxp, nam);
return (0);
}
==== //depot/projects/netperf_socket/sys/netipx/spx.h#2 (text+ko) ====
@@ -33,7 +33,7 @@
*
* @(#)spx.h
*
- * $FreeBSD: src/sys/netipx/spx.h,v 1.17 2002/03/20 02:39:13 alfred Exp $
+ * $FreeBSD: src/sys/netipx/spx.h,v 1.18 2005/01/02 15:06:47 rwatson Exp $
*/
#ifndef _NETIPX_SPX_H_
@@ -55,7 +55,7 @@
u_short spx_seq; /* sequence number */
u_short spx_ack; /* acknowledge number */
u_short spx_alo; /* allocation number */
-};
+} __packed;
/*
* Definitions for NS(tm) Internet Datagram Protocol
@@ -64,7 +64,7 @@
struct spx {
struct ipx si_i;
struct spxhdr si_s;
-};
+} __packed;
struct spx_q {
struct spx_q *si_next;
struct spx_q *si_prev;
==== //depot/projects/netperf_socket/sys/netipx/spx_usrreq.c#11 (text+ko) ====
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netipx/spx_usrreq.c,v 1.50 2004/12/31 17:05:37 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netipx/spx_usrreq.c,v 1.58 2005/01/02 15:38:47 rwatson Exp $");
#include <sys/param.h>
#include <sys/lock.h>
@@ -74,9 +74,9 @@
static struct spx_istat spx_istat;
/* Following was struct spxstat spxstat; */
-#ifndef spxstat
+#ifndef spxstat
#define spxstat spx_istat.newstats
-#endif
+#endif
static const int spx_backoff[SPX_MAXRXTSHIFT+1] =
{ 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
@@ -103,7 +103,7 @@
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,
- struct sockaddr *addr, struct mbuf *control,
+ struct sockaddr *addr, struct mbuf *control,
struct thread *td);
static int spx_shutdown(struct socket *so);
static int spx_sp_attach(struct socket *so, int proto, struct thread *td);
@@ -163,10 +163,7 @@
short ostate = 0;
spxstat.spxs_rcvtotal++;
- if (ipxp == NULL) {
- panic("No ipxpcb in spx_input\n");
- return;
- }
+ KASSERT(ipxp != NULL, ("spx_input: NULL ipxpcb"));
cb = ipxtospxpcb(ipxp);
if (cb == NULL)
@@ -330,7 +327,7 @@
m_freem(m);
}
if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
cb->s_flags &= ~(SF_WIN|SF_RXT);
return;
@@ -358,7 +355,7 @@
drop:
bad:
- if (cb == 0 || cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG ||
+ if (cb == NULL || cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG ||
traceallspxs)
spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
m_freem(m);
@@ -411,7 +408,7 @@
cb->s_snxt = si->si_ack;
cb->s_cwnd = CUNIT;
cb->s_force = 1 + SPXT_REXMT;
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
cb->s_rtt = 0;
if (cwnd >= 4 * CUNIT)
@@ -489,13 +486,14 @@
/*
* Trim Acked data from output queue.
*/
+ SOCKBUF_LOCK(&so->so_snd);
while ((m = so->so_snd.sb_mb) != NULL) {
if (SSEQ_LT((mtod(m, struct spx *))->si_seq, si->si_ack))
- sbdroprecord(&so->so_snd);
+ sbdroprecord_locked(&so->so_snd);
else
break;
}
- sowwakeup(so);
+ sowwakeup_locked(so);
cb->s_rack = si->si_ack;
update_window:
if (SSEQ_LT(cb->s_snxt, cb->s_rack))
@@ -533,11 +531,19 @@
return (0);
} /* else queue this packet; */
} else {
+#ifdef BROKEN
+ /*
+ * XXXRW: This is broken on at least one count:
+ * spx_close() will free the ipxp and related parts,
+ * which are then touched by spx_input() after the
+ * return from spx_reass().
+ */
/*register struct socket *so = cb->s_ipxpcb->ipxp_socket;
if (so->so_state && SS_NOFDREF) {
spx_close(cb);
} else
would crash system*/
+#endif
spx_istat.notyet++;
m_freem(dtom(si));
return (0);
@@ -585,6 +591,7 @@
}
present:
#define SPINC sizeof(struct spxhdr)
+ SOCKBUF_LOCK(&so->so_rcv);
/*
* Loop through all packets queued up to update acknowledge
* number, and present all acknowledged data to user;
@@ -596,12 +603,10 @@
m = dtom(q);
if (SI(q)->si_cc & SPX_OB) {
cb->s_oobflags &= ~SF_IOOB;
- SOCKBUF_LOCK(&so->so_rcv);
if (so->so_rcv.sb_cc)
so->so_oobmark = so->so_rcv.sb_cc;
else
so->so_rcv.sb_state |= SBS_RCVATMARK;
- SOCKBUF_UNLOCK(&so->so_rcv);
}
q = q->si_prev;
remque(q->si_next);
@@ -624,16 +629,14 @@
s[0] = 5;
s[1] = 1;
*(u_char *)(&s[2]) = dt;
- sbappend(&so->so_rcv, mm);
+ sbappend_locked(&so->so_rcv, mm);
}
}
if (sp->spx_cc & SPX_OB) {
MCHTYPE(m, MT_OOBDATA);
spx_newchecks[1]++;
- SOCKBUF_LOCK(&so->so_rcv);
so->so_oobmark = 0;
so->so_rcv.sb_state &= ~SBS_RCVATMARK;
- SOCKBUF_UNLOCK(&so->so_rcv);
}
if (packetp == 0) {
m->m_data += SPINC;
@@ -641,26 +644,28 @@
m->m_pkthdr.len -= SPINC;
}
if ((sp->spx_cc & SPX_EM) || packetp) {
- sbappendrecord(&so->so_rcv, m);
+ sbappendrecord_locked(&so->so_rcv, m);
spx_newchecks[9]++;
} else
- sbappend(&so->so_rcv, m);
+ sbappend_locked(&so->so_rcv, m);
} else
#endif
if (packetp) {
- sbappendrecord(&so->so_rcv, m);
+ sbappendrecord_locked(&so->so_rcv, m);
} else {
cb->s_rhdr = *mtod(m, struct spxhdr *);
m->m_data += SPINC;
m->m_len -= SPINC;
m->m_pkthdr.len -= SPINC;
- sbappend(&so->so_rcv, m);
+ sbappend_locked(&so->so_rcv, m);
}
} else
break;
}
if (wakeup)
- sorwakeup(so);
+ sorwakeup_locked(so);
+ else
+ SOCKBUF_UNLOCK(&so->so_rcv);
return (0);
}
@@ -703,7 +708,7 @@
{
struct socket *so = cb->s_ipxpcb->ipxp_socket;
register struct mbuf *m;
- register struct spx *si = (struct spx *)NULL;
+ register struct spx *si = NULL;
register struct sockbuf *sb = &so->so_snd;
int len = 0, win, rcv_win;
short span, off, recordp = 0;
@@ -916,7 +921,7 @@
if (rcv_win > 0) {
u_short delta = 1 + cb->s_alo - cb->s_ack;
int adv = rcv_win - (delta * cb->s_mtu);
-
+
if ((so->so_rcv.sb_cc == 0 && adv >= (2 * cb->s_mtu)) ||
(100 * adv / so->so_rcv.sb_hiwat >= 35)) {
spxstat.spxs_sndwinup++;
@@ -971,7 +976,7 @@
if (rcv_win < 0)
rcv_win = 0;
alo = cb->s_ack - 1 + (rcv_win / ((short)cb->s_mtu));
- if (SSEQ_LT(alo, cb->s_alo))
+ if (SSEQ_LT(alo, cb->s_alo))
alo = cb->s_alo;
if (si != NULL) {
@@ -1025,7 +1030,7 @@
if (cb->s_force != (1 + SPXT_PERSIST) ||
cb->s_timer[SPXT_PERSIST] == 0) {
/*
- * If this is a new packet and we are not currently
+ * If this is a new packet and we are not currently
* timing anything, time this one.
*/
if (SSEQ_LT(cb->s_smax, si->si_seq)) {
@@ -1081,7 +1086,7 @@
spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
if (so->so_options & SO_DONTROUTE)
- error = ipx_outputfl(m, (struct route *)NULL, IPX_ROUTETOIF);
+ error = ipx_outputfl(m, NULL, IPX_ROUTETOIF);
else
error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0);
}
@@ -1169,12 +1174,12 @@
break;
case SO_LAST_HEADER:
- error = sooptcopyout(sopt, &cb->s_rhdr,
+ error = sooptcopyout(sopt, &cb->s_rhdr,
sizeof cb->s_rhdr);
break;
case SO_DEFAULT_HEADERS:
- error = sooptcopyout(sopt, &cb->s_shdr,
+ error = sooptcopyout(sopt, &cb->s_shdr,
sizeof cb->s_shdr);
break;
@@ -1352,7 +1357,7 @@
SPXT_RANGESET(cb->s_rxtcur,
((SPXTV_SRTTBASE >> 2) + (SPXTV_SRTTDFLT << 2)) >> 1,
SPXTV_MIN, SPXTV_REXMTMAX);
- ipxp->ipxp_pcb = (caddr_t)cb;
+ ipxp->ipxp_pcb = (caddr_t)cb;
spx_attach_end:
splx(s);
return (error);
@@ -1363,14 +1368,14 @@
struct socket *so;
struct sockaddr *nam;
struct thread *td;
-{
+{
struct ipxpcb *ipxp;
ipxp = sotoipxpcb(so);
return (ipx_pcbbind(ipxp, nam, td));
-}
-
+}
+
/*
* Initiate connection to peer.
* Enter SYN_SENT state, and mark socket as connecting.
@@ -1393,7 +1398,7 @@
s = splnet();
if (ipxp->ipxp_lport == 0) {
- error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td);
+ error = ipx_pcbbind(ipxp, NULL, td);
if (error)
goto spx_connect_end;
}
@@ -1416,7 +1421,7 @@
* cb->s_dport.
*/
ipxp->ipxp_fport = 0;
- error = spx_output(cb, (struct mbuf *)NULL);
+ error = spx_output(cb, NULL);
spx_connect_end:
splx(s);
return (error);
@@ -1480,7 +1485,7 @@
cb = ipxtospxpcb(ipxp);
if (ipxp->ipxp_lport == 0)
- error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td);
+ error = ipx_pcbbind(ipxp, NULL, td);
if (error == 0)
cb->s_state = TCPS_LISTEN;
return (error);
@@ -1504,7 +1509,7 @@
s = splnet();
cb->s_flags |= SF_RVD;
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
cb->s_flags &= ~SF_RVD;
splx(s);
return (0);
@@ -1522,12 +1527,15 @@
ipxp = sotoipxpcb(so);
cb = ipxtospxpcb(ipxp);
+ SOCKBUF_LOCK(&so->so_rcv);
if ((cb->s_oobflags & SF_IOOB) || so->so_oobmark ||
(so->so_rcv.sb_state & SBS_RCVATMARK)) {
+ SOCKBUF_UNLOCK(&so->so_rcv);
m->m_len = 1;
*mtod(m, caddr_t) = cb->s_iobc;
return (0);
}
+ SOCKBUF_UNLOCK(&so->so_rcv);
return (EINVAL);
}
@@ -1580,7 +1588,7 @@
static int
spx_shutdown(so)
- struct socket *so;
+ struct socket *so;
{
int error;
int s;
@@ -1595,7 +1603,7 @@
socantsendmore(so);
cb = spx_usrclosed(cb);
if (cb != NULL)
- error = spx_output(cb, (struct mbuf *)NULL);
+ error = spx_output(cb, NULL);
splx(s);
return (error);
}
@@ -1670,11 +1678,11 @@
}
m_free(dtom(cb->s_ipx));
FREE(cb, M_PCB);
- ipxp->ipxp_pcb = 0;
+ ipxp->ipxp_pcb = NULL;
soisdisconnected(so);
ipx_pcbdetach(ipxp);
spxstat.spxs_closed++;
- return ((struct spxpcb *)NULL);
+ return (NULL);
}
/*
@@ -1738,7 +1746,7 @@
cb->s_flags &= ~SF_DELACK;
cb->s_flags |= SF_ACKNOW;
spxstat.spxs_delack++;
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
}
}
@@ -1772,13 +1780,16 @@
* spx_timers() returns (NULL) if it free'd
* the pcb.
*/
- if (spx_timers(cb, i) == NULL)
- continue;
+ cb = spx_timers(cb, i);
+ if (cb == NULL)
+ break;
}
}
- cb->s_idle++;
- if (cb->s_rtt)
- cb->s_rtt++;
+ if (cb != NULL) {
+ cb->s_idle++;
+ if (cb->s_rtt)
+ cb->s_rtt++;
+ }
}
spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
splx(s);
@@ -1849,7 +1860,7 @@
win = 2;
cb->s_cwnd = CUNIT;
cb->s_ssthresh = win * CUNIT;
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
break;
/*
@@ -1859,7 +1870,7 @@
case SPXT_PERSIST:
spxstat.spxs_persisttimeo++;
spx_setpersist(cb);
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
break;
/*
@@ -1874,7 +1885,7 @@
if (cb->s_idle >= SPXTV_MAXIDLE)
goto dropit;
spxstat.spxs_keepprobe++;
- spx_output(cb, (struct mbuf *)NULL);
+ spx_output(cb, NULL);
} else
cb->s_idle = 0;
cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
More information about the p4-projects
mailing list