convert pcb lists to CIRCLEQs, so that the end can be looked at more

easily, and so that the original (insque/remque) logic can be effectively
mimiced.  (This fixes a bug in the previous set of list changes.)
also (since terminator is no longer null) reinstate uninitted list checks,
but mark them XXX.
This commit is contained in:
cgd 1995-06-18 20:01:08 +00:00
parent 8f62c773e8
commit f90cf78fba
5 changed files with 42 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.c,v 1.20 1995/06/12 06:49:55 mycroft Exp $ */
/* $NetBSD: in_pcb.c,v 1.21 1995/06/18 20:01:08 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
@ -64,7 +64,7 @@ in_pcbinit(table)
struct inpcbtable *table;
{
LIST_INIT(&table->inpt_list);
CIRCLEQ_INIT(&table->inpt_queue);
table->inpt_lastport = 0;
}
@ -81,7 +81,7 @@ in_pcballoc(so, table)
bzero((caddr_t)inp, sizeof(*inp));
inp->inp_table = table;
inp->inp_socket = so;
LIST_INSERT_HEAD(&table->inpt_list, inp, inp_list);
CIRCLEQ_INSERT_HEAD(&table->inpt_queue, inp, inp_queue);
so->so_pcb = (caddr_t)inp;
return (0);
}
@ -306,7 +306,7 @@ in_pcbdetach(inp)
if (inp->inp_route.ro_rt)
rtfree(inp->inp_route.ro_rt);
ip_freemoptions(inp->inp_moptions);
LIST_REMOVE(inp, inp_list);
CIRCLEQ_REMOVE(&inp->inp_table->inpt_queue, inp, inp_queue);
FREE(inp, M_PCB);
}
@ -372,17 +372,18 @@ in_pcbnotify(table, dst, fport_arg, laddr, lport_arg, errno, notify)
if (faddr.s_addr == INADDR_ANY)
return;
for (inp = table->inpt_list.lh_first; inp != 0;) {
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;) {
if (inp->inp_faddr.s_addr != faddr.s_addr ||
inp->inp_socket == 0 ||
inp->inp_fport != fport ||
inp->inp_lport != lport ||
inp->inp_laddr.s_addr != laddr.s_addr) {
inp = inp->inp_list.le_next;
inp = inp->inp_queue.cqe_next;
continue;
}
oinp = inp;
inp = inp->inp_list.le_next;
inp = inp->inp_queue.cqe_next;
if (notify)
(*notify)(oinp, errno);
}
@ -404,14 +405,15 @@ in_pcbnotifyall(table, dst, errno, notify)
if (faddr.s_addr == INADDR_ANY)
return;
for (inp = table->inpt_list.lh_first; inp != 0;) {
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;) {
if (inp->inp_faddr.s_addr != faddr.s_addr ||
inp->inp_socket == 0) {
inp = inp->inp_list.le_next;
inp = inp->inp_queue.cqe_next;
continue;
}
oinp = inp;
inp = inp->inp_list.le_next;
inp = inp->inp_queue.cqe_next;
if (notify)
(*notify)(oinp, errno);
}
@ -480,8 +482,9 @@ in_pcblookup(table, faddr, fport_arg, laddr, lport_arg, flags)
int matchwild = 3, wildcard;
u_int16_t fport = fport_arg, lport = lport_arg;
for (inp = table->inpt_list.lh_first; inp != 0;
inp = inp->inp_list.le_next) {
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;
inp = inp->inp_queue.cqe_next) {
if (inp->inp_lport != lport)
continue;
wildcard = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.h,v 1.11 1995/06/12 06:49:56 mycroft Exp $ */
/* $NetBSD: in_pcb.h,v 1.12 1995/06/18 20:01:13 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -45,7 +45,7 @@
* control block.
*/
struct inpcb {
LIST_ENTRY(inpcb) inp_list;
CIRCLEQ_ENTRY(inpcb) inp_queue;
struct inpcbtable *inp_table;
struct in_addr inp_faddr; /* foreign host table entry */
struct in_addr inp_laddr; /* local host table entry */
@ -61,7 +61,7 @@ struct inpcb {
};
struct inpcbtable {
LIST_HEAD(inpcbhead, inpcb) inpt_list;
CIRCLEQ_HEAD(inpcbhead, inpcb) inpt_queue;
u_int16_t inpt_lastport;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: raw_ip.c,v 1.20 1995/06/12 00:47:49 mycroft Exp $ */
/* $NetBSD: raw_ip.c,v 1.21 1995/06/18 20:01:15 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@ -91,8 +91,9 @@ rip_input(m)
struct socket *last = 0;
ripsrc.sin_addr = ip->ip_src;
for (inp = rawcbtable.inpt_list.lh_first; inp != 0;
inp = inp->inp_list.le_next) {
for (inp = rawcbtable.inpt_queue.cqh_first;
inp != (struct inpcb *)&rawcbtable.inpt_queue;
inp = inp->inp_queue.cqe_next) {
if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != ip->ip_p)
continue;
if (inp->inp_laddr.s_addr &&

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_timer.c,v 1.11 1995/06/12 00:47:58 mycroft Exp $ */
/* $NetBSD: tcp_timer.c,v 1.12 1995/06/18 20:01:17 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@ -75,8 +75,10 @@ tcp_fasttimo()
int s;
s = splnet();
for (inp = tcbtable.inpt_list.lh_first; inp != 0;
inp = inp->inp_list.le_next) {
inp = tcbtable.inpt_queue.cqh_first;
if (inp) /* XXX */
for (; inp != (struct inpcb *)&tcbtable.inpt_queue;
inp = inp->inp_queue.cqe_next) {
if ((tp = (struct tcpcb *)inp->inp_ppcb) &&
(tp->t_flags & TF_DELACK)) {
tp->t_flags &= ~TF_DELACK;
@ -106,8 +108,13 @@ tcp_slowtimo()
/*
* Search through tcb's and update active timers.
*/
for (ip = tcbtable.inpt_list.lh_first; ip != 0; ip = ipnxt) {
ipnxt = ip->inp_list.le_next;
ip = tcbtable.inpt_queue.cqh_first;
if (ip == (struct inpcb *)0) { /* XXX */
splx(s);
return;
}
for (; ip != (struct inpcb *)&tcbtable.inpt_queue; ip = ipnxt) {
ipnxt = ip->inp_queue.cqe_next;
tp = intotcpcb(ip);
if (tp == 0)
continue;
@ -116,8 +123,10 @@ tcp_slowtimo()
(void) tcp_usrreq(tp->t_inpcb->inp_socket,
PRU_SLOWTIMO, (struct mbuf *)0,
(struct mbuf *)i, (struct mbuf *)0);
if (ipnxt->inp_list.le_prev !=
&ip->inp_list.le_next)
/* XXX NOT MP SAFE */
if ((ipnxt == (void *)&tcbtable.inpt_queue &&
tcbtable.inpt_queue.cqh_last != ip) ||
ipnxt->inp_queue.cqe_prev != ip)
goto tpgone;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp_usrreq.c,v 1.21 1995/06/12 06:48:56 mycroft Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.22 1995/06/18 20:01:19 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@ -184,8 +184,9 @@ udp_input(m, iphlen)
* (Algorithm copied from raw_intr().)
*/
last = NULL;
for (inp = udbtable.inpt_list.lh_first; inp != 0;
inp = inp->inp_list.le_next) {
for (inp = udbtable.inpt_queue.cqh_first;
inp != (struct inpcb *)&udbtable.inpt_queue;
inp = inp->inp_queue.cqe_next) {
if (inp->inp_lport != uh->uh_dport)
continue;
if (inp->inp_laddr.s_addr != INADDR_ANY) {