From 040eca7b0448d76144600bb716f46ac83d2ea2b8 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 25 May 2009 10:25:41 +0000 Subject: [PATCH] Pull SPX reassembly queue init and flush into spx_reass.c. MFC after: 1 month --- sys/netipx/spx_reass.c | 30 +++++++++++++++++++++++++++++- sys/netipx/spx_usrreq.c | 14 +++----------- sys/netipx/spx_var.h | 2 ++ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/sys/netipx/spx_reass.c b/sys/netipx/spx_reass.c index 2e69f5e0343e..05961053fab5 100644 --- a/sys/netipx/spx_reass.c +++ b/sys/netipx/spx_reass.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. - * Copyright (c) 2004-2006 Robert N. M. Watson + * Copyright (c) 2004-2009 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,6 +111,34 @@ spx_remque(struct spx_q *element) element->si_prev = NULL; } +/* + * Flesh pending queued segments on SPX close. + */ +void +spx_reass_flush(struct spxpcb *cb) +{ + struct spx_q *s; + struct mbuf *m; + + s = cb->s_q.si_next; + while (s != &(cb->s_q)) { + s = s->si_next; + spx_remque(s); + m = dtom(s); + m_freem(m); + } +} + +/* + * Initialize SPX segment reassembly queue on SPX socket open. + */ +void +spx_reass_init(struct spxpcb *cb) +{ + + cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q; +} + /* * This is structurally similar to the tcp reassembly routine but its * function is somewhat different: it merely queues packets up, and diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c index 1b084a1ac276..67612f94b3fa 100644 --- a/sys/netipx/spx_usrreq.c +++ b/sys/netipx/spx_usrreq.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 1984, 1985, 1986, 1987, 1993 * The Regents of the University of California. - * Copyright (c) 2004-2006 Robert N. M. Watson + * Copyright (c) 2004-2009 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1091,7 +1091,7 @@ spx_attach(struct socket *so, int proto, struct thread *td) cb->s_state = TCPS_LISTEN; cb->s_smax = -1; cb->s_swl1 = -1; - cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q; + spx_reass_init(cb); cb->s_ipxpcb = ipxp; cb->s_mtu = 576 - sizeof(struct spx); sb = &so->so_snd; @@ -1117,21 +1117,13 @@ static void spx_pcbdetach(struct ipxpcb *ipxp) { struct spxpcb *cb; - struct spx_q *s; - struct mbuf *m; IPX_LOCK_ASSERT(ipxp); cb = ipxtospxpcb(ipxp); KASSERT(cb != NULL, ("spx_pcbdetach: cb == NULL")); - s = cb->s_q.si_next; - while (s != &(cb->s_q)) { - s = s->si_next; - spx_remque(s); - m = dtom(s); - m_freem(m); - } + spx_reass_flush(cb); m_free(dtom(cb->s_ipx)); free(cb, M_PCB); ipxp->ipxp_pcb = NULL; diff --git a/sys/netipx/spx_var.h b/sys/netipx/spx_var.h index be6714e953f5..cf599fac9b9c 100644 --- a/sys/netipx/spx_var.h +++ b/sys/netipx/spx_var.h @@ -153,6 +153,8 @@ extern u_short spx_newchecks[50]; int spx_output(struct spxpcb *cb, struct mbuf *m0); int spx_reass(struct spxpcb *cb, struct spx *si); +void spx_reass_flush(struct spxpcb *cb); +void spx_reass_init(struct spxpcb *cb); void spx_remque(struct spx_q *element); #endif