X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/83969adf9cd9857e454f4279f3215e30d1220959..3f1d78415e324b577aa30b313aed7777952a87fe:/usr/src/sys/deprecated/netimp/if_imphost.c diff --git a/usr/src/sys/deprecated/netimp/if_imphost.c b/usr/src/sys/deprecated/netimp/if_imphost.c index 78755124a8..23ead64916 100644 --- a/usr/src/sys/deprecated/netimp/if_imphost.c +++ b/usr/src/sys/deprecated/netimp/if_imphost.c @@ -1,18 +1,30 @@ -/* if_imphost.c 4.11 82/05/10 */ +/* + * Copyright (c) 1982 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)if_imphost.c 6.7 (Berkeley) %G% + */ #include "imp.h" #if NIMP > 0 /* * Host table manipulation routines. * Only needed when shipping stuff through an IMP. + * + * Everything in here is called at splimp from + * from the IMP protocol code (if_imp.c), or + * interlocks with the code at splimp. */ +#include "param.h" +#include "mbuf.h" +#include "syslog.h" -#include "../h/param.h" -#include "../h/mbuf.h" -#include "../net/in.h" -#include "../net/in_systm.h" -#include "../net/if_imp.h" -#include "../net/if_imphost.h" +#include "../netinet/in.h" +#include "../netinet/in_systm.h" + +#include "if_imp.h" +#include "if_imphost.h" /* * Head of host table hash chains. @@ -30,20 +42,15 @@ hostlookup(addr) register struct host *hp; register struct mbuf *m; register int hash = HOSTHASH(addr); - int s = splnet(); -COUNT(HOSTLOOKUP); for (m = hosts; m; m = m->m_next) { hp = &mtod(m, struct hmbuf *)->hm_hosts[hash]; if (hp->h_addr.s_addr == addr.s_addr) { hp->h_flags |= HF_INUSE; - goto found; + return (hp); } } - hp = 0; -found: - splx(s); - return (hp); + return ((struct host *)0); } /* @@ -58,9 +65,7 @@ hostenter(addr) register struct mbuf *m, **mprev; register struct host *hp, *hp0 = 0; register int hash = HOSTHASH(addr); - int s = splnet(); -COUNT(HOSTENTER); mprev = &hosts; while (m = *mprev) { mprev = &m->m_next; @@ -82,13 +87,10 @@ COUNT(HOSTENTER); * chain of mbuf's, allocate another. */ if (hp0 == 0) { - m = m_getclr(M_DONTWAIT); - if (m == 0) { - splx(s); - return (0); - } + m = m_getclr(M_DONTWAIT, MT_HTABLE); + if (m == NULL) + return ((struct host *)0); *mprev = m; - m->m_off = MMINOFF; hp0 = &mtod(m, struct hmbuf *)->hm_hosts[hash]; } mtod(dtom(hp0), struct hmbuf *)->hm_count++; @@ -99,7 +101,6 @@ COUNT(HOSTENTER); foundhost: hp->h_flags |= HF_INUSE; - splx(s); return (hp); } @@ -110,53 +111,47 @@ foundhost: hostfree(hp) register struct host *hp; { - int s = splnet(); -COUNT(HOSTFREE); hp->h_flags &= ~HF_INUSE; hp->h_timer = HOSTTIMER; hp->h_rfnm = 0; - splx(s); } /* * Reset a given network's host entries. */ hostreset(net) - int net; + u_long net; { register struct mbuf *m; register struct host *hp, *lp; struct hmbuf *hm; - int s = splnet(); + struct mbuf *mnext; -COUNT(HOSTRESET); - for (m = hosts; m; m = m->m_next) { + for (m = hosts; m; m = mnext) { + mnext = m->m_next; hm = mtod(m, struct hmbuf *); hp = hm->hm_hosts; lp = hp + HPMBUF; while (hm->hm_count > 0 && hp < lp) { - if (hp->h_addr.s_net == net) { + if (in_netof(hp->h_addr) == net) { hp->h_flags &= ~HF_INUSE; hostrelease(hp); } hp++; } } - splx(s); } /* * Remove a host structure and release * any resources it's accumulated. - * This routine is always called at splnet. */ hostrelease(hp) register struct host *hp; { register struct mbuf *m, **mprev, *mh = dtom(hp); -COUNT(HOSTRELEASE); /* * Discard any packets left on the waiting q */ @@ -171,6 +166,7 @@ COUNT(HOSTRELEASE); hp->h_q = 0; } hp->h_flags = 0; + hp->h_rfnm = 0; if (--mtod(mh, struct hmbuf *)->hm_count) return; mprev = &hosts; @@ -210,20 +206,24 @@ hostslowtimo() register struct mbuf *m; register struct host *hp, *lp; struct hmbuf *hm; - int s = splnet(); + struct mbuf *mnext; + int s = splimp(); -COUNT(HOSTSLOWTIMO); - for (m = hosts; m; m = m->m_next) { + for (m = hosts; m; m = mnext) { + mnext = m->m_next; hm = mtod(m, struct hmbuf *); hp = hm->hm_hosts; lp = hp + HPMBUF; - while (hm->hm_count > 0 && hp < lp) { - if (hp->h_flags & HF_INUSE) - continue; - if (hp->h_timer && --hp->h_timer == 0) + for (; hm->hm_count > 0 && hp < lp; hp++) { + if (hp->h_timer && --hp->h_timer == 0) { + if (hp->h_rfnm) + log(LOG_WARNING, + "imp?: host %x, lost %d rfnms\n", + ntohl(hp->h_addr.s_addr), hp->h_rfnm); hostrelease(hp); - hp++; + } } } splx(s); } +#endif