Browse Source

finish deanonymizing ip locking.

Boots and works but test if you can.

Change-Id: I3887f0b0f42ca705404a8f7b109d7eb6ea5693bb
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
39c53253f8

+ 23 - 23
sys/src/9/ip/arp.c

@@ -42,7 +42,7 @@ char *arpstate[] =
  */
 struct Arp
 {
-	QLock;
+	QLock ql;
 	Fs	*f;
 	Arpent	*hash[NHASH];
 	Arpent	cache[NCACHE];
@@ -225,7 +225,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uint8_t *ip, uint8_t *mac)
 		ip = v6ip;
 	}
 
-	qlock(arp);
+	qlock(&arp->ql);
 	hash = haship(ip);
 	for(a = arp->hash[hash]; a; a = a->hash){
 		if(memcmp(ip, a->ip, sizeof(a->ip)) == 0)
@@ -256,7 +256,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uint8_t *ip, uint8_t *mac)
 	if(NOW - a->ctime > 15*60*1000)
 		cleanarpent(arp, a);
 
-	qunlock(arp);
+	qunlock(&arp->ql);
 	return nil;
 }
 
@@ -266,7 +266,7 @@ arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uint8_t *ip, uint8_t *mac)
 void
 arprelease(Arp *arp, Arpent *arpen)
 {
-	qunlock(arp);
+	qunlock(&arp->ql);
 }
 
 /*
@@ -298,7 +298,7 @@ arpresolve(Arp *arp, Arpent *a, Medium *type, uint8_t *mac)
 	a->utime = NOW;
 	bp = a->hold;
 	a->hold = nil;
-	qunlock(arp);
+	qunlock(&arp->ql);
 
 	return bp;
 }
@@ -344,7 +344,7 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh)
 	ifc = r->ifc;
 	type = ifc->medium;
 
-	qlock(arp);
+	qlock(&arp->ql);
 	for(a = arp->hash[haship(ip)]; a; a = a->hash){
 		if(a->type != type || (a->state != AWAIT && a->state != AOK))
 			continue;
@@ -373,21 +373,21 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh)
 				ip += IPv4off;
 			a->utime = NOW;
 			a->ctime = a->utime;
-			qunlock(arp);
+			qunlock(&arp->ql);
 
 			while(bp){
 				next = bp->list;
 				if(ifc != nil){
 					if(waserror()){
-						runlock(ifc);
+						runlock(&ifc->rwl);
 						nexterror();
 					}
-					rlock(ifc);
+					rlock(&ifc->rwl);
 					if(ifc->medium != nil)
 						ifc->medium->bwrite(ifc, bp, version, ip);
 					else
 						freeb(bp);
-					runlock(ifc);
+					runlock(&ifc->rwl);
 					poperror();
 				} else
 					freeb(bp);
@@ -405,7 +405,7 @@ arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n, int refresh)
 		memmove(a->mac, mac, type->maclen);
 	}
 
-	qunlock(arp);
+	qunlock(&arp->ql);
 }
 
 int
@@ -433,7 +433,7 @@ arpwrite(Fs *fs, char *s, int len)
 
 	n = getfields(buf, f, 4, 1, " ");
 	if(strcmp(f[0], "flush") == 0){
-		qlock(arp);
+		qlock(&arp->ql);
 		for(a = arp->cache; a < &arp->cache[NCACHE]; a++){
 			memset(a->ip, 0, sizeof(a->ip));
 			memset(a->mac, 0, sizeof(a->mac));
@@ -451,7 +451,7 @@ arpwrite(Fs *fs, char *s, int len)
 		arp->rxmt = nil;
 		arp->dropf = nil;
 		arp->dropl = nil;
-		qunlock(arp);
+		qunlock(&arp->ql);
 	} else if(strcmp(f[0], "add") == 0){
 		switch(n){
 		default:
@@ -488,7 +488,7 @@ arpwrite(Fs *fs, char *s, int len)
 
 		if (parseip(ip, f[1]) == -1)
 			error(Ebadip);
-		qlock(arp);
+		qlock(&arp->ql);
 
 		l = &arp->hash[haship(ip)];
 		for(a = *l; a; a = a->hash){
@@ -518,7 +518,7 @@ arpwrite(Fs *fs, char *s, int len)
 			memset(a->ip, 0, sizeof(a->ip));
 			memset(a->mac, 0, sizeof(a->mac));
 		}
-		qunlock(arp);
+		qunlock(&arp->ql);
 	} else
 		error(Ebadarp);
 
@@ -561,11 +561,11 @@ arpread(Arp *arp, char *p, uint32_t offset, int len)
 			continue;
 		}
 		len--;
-		qlock(arp);
+		qlock(&arp->ql);
 		convmac(mac, &mac[sizeof mac], a->mac, a->type->maclen);
 		n += snprint(p+n, Alinelen+1, aformat, a->type->name,
 			arpstate[a->state], a->ip, mac);	/* +1 for NUL */
-		qunlock(arp);
+		qunlock(&arp->ql);
 	}
 
 	return n;
@@ -582,7 +582,7 @@ rxmitsols(Arp *arp)
 	Ipifc *ifc = nil;
 	int32_t nrxt;
 
-	qlock(arp);
+	qlock(&arp->ql);
 	f = arp->f;
 
 	a = arp->rxmt;
@@ -597,7 +597,7 @@ rxmitsols(Arp *arp)
 	for(; a; a = a->nextrxt){
 		ifc = a->ifc;
 		assert(ifc != nil);
-		if((a->rxtsrem <= 0) || !(canrlock(ifc)) || (a->ifcid != ifc->ifcid)){
+		if((a->rxtsrem <= 0) || !(canrlock(&ifc->rwl)) || (a->ifcid != ifc->ifcid)){
 			xp = a->hold;
 			a->hold = nil;
 
@@ -617,12 +617,12 @@ rxmitsols(Arp *arp)
 		goto dodrops;
 
 
-	qunlock(arp);	/* for icmpns */
+	qunlock(&arp->ql);	/* for icmpns */
 	if((sflag = ipv6anylocal(ifc, ipsrc)) != SRC_UNSPEC)
 		icmpns(f, ipsrc, sflag, a->ip, TARG_MULTI, ifc->mac);
 
-	runlock(ifc);
-	qlock(arp);
+	runlock(&ifc->rwl);
+	qlock(&arp->ql);
 
 	/* put to the end of re-transmit chain */
 	l = &arp->rxmt;
@@ -651,7 +651,7 @@ dodrops:
 	xp = arp->dropf;
 	arp->dropf = nil;
 	arp->dropl = nil;
-	qunlock(arp);
+	qunlock(&arp->ql);
 
 	for(; xp; xp = next){
 		next = xp->list;

+ 12 - 12
sys/src/9/ip/devip.c

@@ -418,13 +418,13 @@ ipopen(Chan* c, int omode)
 		break;
 	case Qclone:
 		p = f->p[PROTO(c->qid)];
-		qlock(p);
+		qlock(&p->ql);
 		if(waserror()){
-			qunlock(p);
+			qunlock(&p->ql);
 			nexterror();
 		}
 		cv = Fsprotoclone(p, ATTACHER(c));
-		qunlock(p);
+		qunlock(&p->ql);
 		poperror();
 		if(cv == nil) {
 			error(Enodev);
@@ -436,12 +436,12 @@ ipopen(Chan* c, int omode)
 	case Qctl:
 	case Qerr:
 		p = f->p[PROTO(c->qid)];
-		qlock(p);
+		qlock(&p->ql);
 		cv = p->conv[CONV(c->qid)];
 		qlock(&cv->ql);
 		if(waserror()) {
 			qunlock(&cv->ql);
-			qunlock(p);
+			qunlock(&p->ql);
 			nexterror();
 		}
 		if((perm & (cv->perm>>6)) != perm) {
@@ -457,7 +457,7 @@ ipopen(Chan* c, int omode)
 			cv->perm = 0660;
 		}
 		qunlock(&cv->ql);
-		qunlock(p);
+		qunlock(&p->ql);
 		poperror();
 		break;
 	case Qlisten:
@@ -757,7 +757,7 @@ setluniqueport(Conv* c, int lport)
 
 	p = c->p;
 
-	qlock(p);
+	qlock(&p->ql);
 	for(x = 0; x < p->nc; x++){
 		xp = p->conv[x];
 		if(xp == nil)
@@ -769,12 +769,12 @@ setluniqueport(Conv* c, int lport)
 		&& xp->rport == c->rport
 		&& ipcmp(xp->raddr, c->raddr) == 0
 		&& ipcmp(xp->laddr, c->laddr) == 0){
-			qunlock(p);
+			qunlock(&p->ql);
 			return "address in use";
 		}
 	}
 	c->lport = lport;
-	qunlock(p);
+	qunlock(&p->ql);
 	return nil;
 }
 
@@ -802,7 +802,7 @@ setlport(Conv* c)
 	int i, port;
 
 	p = c->p;
-	qlock(p);
+	qlock(&p->ql);
 	if(c->restricted){
 		/* Restricted ports cycle between 600 and 1024. */
 		for(i=0; i<1024-600; i++){
@@ -829,7 +829,7 @@ setlport(Conv* c)
 				goto chosen;
 		}
 	}
-	qunlock(p);
+	qunlock(&p->ql);
 	/*
 	 * debugging: let's see if we ever get this.
 	 * if we do (and we're a cpu server), we might as well restart
@@ -840,7 +840,7 @@ setlport(Conv* c)
 
 chosen:
 	c->lport = port;
-	qunlock(p);
+	qunlock(&p->ql);
 	return nil;
 }
 

+ 6 - 6
sys/src/9/ip/ethermedium.c

@@ -357,12 +357,12 @@ etherread4(void *a)
 	}
 	for(;;){
 		bp = er->mchan4->dev->bread(er->mchan4, ifc->maxtu, 0);
-		if(!canrlock(ifc)){
+		if(!canrlock(&ifc->rwl)){
 			freeb(bp);
 			continue;
 		}
 		if(waserror()){
-			runlock(ifc);
+			runlock(&ifc->rwl);
 			nexterror();
 		}
 		ifc->in++;
@@ -371,7 +371,7 @@ etherread4(void *a)
 			freeb(bp);
 		else
 			ipiput4(er->f, ifc, bp);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		poperror();
 	}
 }
@@ -397,12 +397,12 @@ etherread6(void *a)
 	}
 	for(;;){
 		bp = er->mchan6->dev->bread(er->mchan6, ifc->maxtu, 0);
-		if(!canrlock(ifc)){
+		if(!canrlock(&ifc->rwl)){
 			freeb(bp);
 			continue;
 		}
 		if(waserror()){
-			runlock(ifc);
+			runlock(&ifc->rwl);
 			nexterror();
 		}
 		ifc->in++;
@@ -411,7 +411,7 @@ etherread6(void *a)
 			freeb(bp);
 		else
 			ipiput6(er->f, ifc, bp);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		poperror();
 	}
 }

+ 6 - 6
sys/src/9/ip/gre.c

@@ -190,7 +190,7 @@ greconnect(Conv *c, char **argv, int argc)
 
 	/* make sure noone's already connected to this other sys */
 	p = c->p;
-	qlock(p);
+	qlock(&p->ql);
 	ecp = &p->conv[p->nc];
 	for(cp = p->conv; cp < ecp; cp++){
 		tc = *cp;
@@ -205,7 +205,7 @@ greconnect(Conv *c, char **argv, int argc)
 			break;
 		}
 	}
-	qunlock(p);
+	qunlock(&p->ql);
 
 	if(err != nil)
 		return err;
@@ -587,7 +587,7 @@ greiput(Proto *proto, Ipifc *ipifc, Block *bp)
 	}
 	ip = (Ip4hdr *)(bp->rp + hdrlen);
 
-	qlock(proto);
+	qlock(&proto->ql);
 	/*
 	 * Look for a conversation structure for this port and address, or
 	 * match the retunnel part, or match on the raw flag.
@@ -607,7 +607,7 @@ greiput(Proto *proto, Ipifc *ipifc, Block *bp)
 			grepdin++;
 			grebdin += BLEN(bp);
 			gredownlink(c, bp);
-			qunlock(proto);
+			qunlock(&proto->ql);
 			return;
 		}
 
@@ -615,7 +615,7 @@ greiput(Proto *proto, Ipifc *ipifc, Block *bp)
 			grepuin++;
 			grebuin += BLEN(bp);
 			greuplink(c, bp);
-			qunlock(proto);
+			qunlock(&proto->ql);
 			return;
 		}
 	}
@@ -640,7 +640,7 @@ greiput(Proto *proto, Ipifc *ipifc, Block *bp)
 			break;
 	}
 
-	qunlock(proto);
+	qunlock(&proto->ql);
 
 	if(*p == nil){
 		freeb(bp);

+ 8 - 8
sys/src/9/ip/icmp6.c

@@ -128,7 +128,7 @@ typedef struct Icmppriv6
 
 typedef struct Icmpcb6
 {
-	QLock;
+	QLock ql;
 	uint8_t	headers;
 } Icmpcb6;
 
@@ -448,11 +448,11 @@ icmphostunr(Fs *f, Ipifc *ifc, Block *bp, int code, int free)
 	nbp = newIPICMP(sz);
 	np = (IPICMP *)nbp->rp;
 
-	rlock(ifc);
+	rlock(&ifc->rwl);
 	if(!ipv6anylocal(ifc, np->src)){
 		netlog(f, Logicmp, "icmphostunr fail -> src %I dst %I\n",
 			p->src, p->dst);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		freeblist(nbp);
 		goto freebl;
 	}
@@ -471,7 +471,7 @@ icmphostunr(Fs *f, Ipifc *ifc, Block *bp, int code, int free)
 		ipiput6(f, ifc, nbp);
 	else
 		ipoput6(f, nbp, 0, MAXTTL, DFLTTOS, nil);
-	runlock(ifc);
+	runlock(&ifc->rwl);
 freebl:
 	if(free)
 		freeblist(bp);
@@ -684,20 +684,20 @@ targettype(Fs *f, Ipifc *ifc, uint8_t *target)
 	Iplifc *lifc;
 	int t;
 
-	rlock(ifc);
+	rlock(&ifc->rwl);
 	if(ipproxyifc(f, ifc, target)) {
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		return Tuniproxy;
 	}
 
 	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
 		if(ipcmp(lifc->local, target) == 0) {
 			t = (lifc->tentative)? Tunitent: Tunirany;
-			runlock(ifc);
+			runlock(&ifc->rwl);
 			return t;
 		}
 
-	runlock(ifc);
+	runlock(&ifc->rwl);
 	return 0;
 }
 

+ 1 - 1
sys/src/9/ip/igmp.c

@@ -74,7 +74,7 @@ struct IGMPrep
 typedef struct IGMP IGMP;
 struct IGMP
 {
-	Lock;
+	Lock l;
 	Rendez	r;
 	IGMPrep	*reports;
 };

+ 4 - 4
sys/src/9/ip/ip.c

@@ -193,10 +193,10 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 	if(!gating)
 		eh->tos = tos;
 
-	if(!canrlock(ifc))
+	if(!canrlock(&ifc->rwl))
 		goto free;
 	if(waserror()){
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		nexterror();
 	}
 	if(ifc->medium == nil)
@@ -220,7 +220,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 		hnputs(eh->cksum, ipcsum(&eh->vihl));
 		assert(bp->next == nil);
 		ifc->medium->bwrite(ifc, bp, V4, gate);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		poperror();
 		return 0;
 	}
@@ -309,7 +309,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 	}
 	ip->stats[FragOKs]++;
 raise:
-	runlock(ifc);
+	runlock(&ifc->rwl);
 	poperror();
 free:
 	freeblist(bp);

+ 4 - 4
sys/src/9/ip/ip.h

@@ -318,7 +318,7 @@ struct Hostparams {
 
 struct Ipifc
 {
-	RWlock;
+	RWlock rwl;
 
 	Conv	*conv;		/* link to its conversation structure */
 	char	dev[64];	/* device we're attached to */
@@ -380,7 +380,7 @@ struct Iphash
 };
 struct Ipht
 {
-	Lock;
+	Lock l;
 	Iphash	*tab[Nipht];
 };
 void iphtadd(Ipht*, Conv*);
@@ -392,7 +392,7 @@ Conv* iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp);
  */
 struct Proto
 {
-	QLock;
+	QLock ql;
 	char*		name;		/* protocol name */
 	int		x;		/* protocol index */
 	int		ipproto;	/* ip protocol type */
@@ -429,7 +429,7 @@ struct Proto
  */
 struct Fs
 {
-	RWlock;
+	RWlock rwl;
 	int	dev;
 
 	int	np;

+ 11 - 11
sys/src/9/ip/ipaux.c

@@ -282,10 +282,10 @@ iphtadd(Ipht *ht, Conv *c)
 	}
 	h->c = c;
 
-	lock(ht);
+	lock(&ht->l);
 	h->next = ht->tab[hv];
 	ht->tab[hv] = h;
-	unlock(ht);
+	unlock(&ht->l);
 }
 
 void
@@ -295,7 +295,7 @@ iphtrem(Ipht *ht, Conv *c)
 	Iphash **l, *h;
 
 	hv = iphash(c->raddr, c->rport, c->laddr, c->lport);
-	lock(ht);
+	lock(&ht->l);
 	for(l = &ht->tab[hv]; (*l) != nil; l = &(*l)->next)
 		if((*l)->c == c){
 			h = *l;
@@ -303,7 +303,7 @@ iphtrem(Ipht *ht, Conv *c)
 			free(h);
 			break;
 		}
-	unlock(ht);
+	unlock(&ht->l);
 }
 
 /* look for a matching conversation with the following precedence
@@ -322,14 +322,14 @@ iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 
 	/* exact 4 pair match (connection) */
 	hv = iphash(sa, sp, da, dp);
-	lock(ht);
+	lock(&ht->l);
 	for(h = ht->tab[hv]; h != nil; h = h->next){
 		if(h->match != IPmatchexact)
 			continue;
 		c = h->c;
 		if(sp == c->rport && dp == c->lport
 		&& ipcmp(sa, c->raddr) == 0 && ipcmp(da, c->laddr) == 0){
-			unlock(ht);
+			unlock(&ht->l);
 			return c;
 		}
 	}
@@ -341,7 +341,7 @@ iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 			continue;
 		c = h->c;
 		if(dp == c->lport && ipcmp(da, c->laddr) == 0){
-			unlock(ht);
+			unlock(&ht->l);
 			return c;
 		}
 	}
@@ -353,7 +353,7 @@ iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 			continue;
 		c = h->c;
 		if(dp == c->lport){
-			unlock(ht);
+			unlock(&ht->l);
 			return c;
 		}
 	}
@@ -365,7 +365,7 @@ iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 			continue;
 		c = h->c;
 		if(ipcmp(da, c->laddr) == 0){
-			unlock(ht);
+			unlock(&ht->l);
 			return c;
 		}
 	}
@@ -376,9 +376,9 @@ iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 		if(h->match != IPmatchany)
 			continue;
 		c = h->c;
-		unlock(ht);
+		unlock(&ht->l);
 		return c;
 	}
-	unlock(ht);
+	unlock(&ht->l);
 	return nil;
 }

+ 42 - 42
sys/src/9/ip/ipifc.c

@@ -46,7 +46,7 @@ struct Ipself
 
 struct Ipselftab
 {
-	QLock;
+	QLock ql;
 	int	inited;
 	int	acceptall;	/* true if an interface has the null address */
 	Ipself	*hash[NHASH];	/* hash chains */
@@ -126,13 +126,13 @@ ipifcbind(Conv *c, char **argv, int argc)
 	if(medium == nil)
 		return "unknown interface type";
 
-	wlock(ifc);
+	wlock(&ifc->rwl);
 	if(ifc->medium != nil){
-		wunlock(ifc);
+		wunlock(&ifc->rwl);
 		return "interface already bound";
 	}
 	if(waserror()){
-		wunlock(ifc);
+		wunlock(&ifc->rwl);
 		nexterror();
 	}
 
@@ -170,7 +170,7 @@ ipifcbind(Conv *c, char **argv, int argc)
 	qreopen(c->eq);
 	qreopen(c->sq);
 
-	wunlock(ifc);
+	wunlock(&ifc->rwl);
 	poperror();
 
 	return nil;
@@ -187,10 +187,10 @@ ipifcunbind(Ipifc *ifc)
 	char *err;
 
 	if(waserror()){
-		wunlock(ifc);
+		wunlock(&ifc->rwl);
 		nexterror();
 	}
-	wlock(ifc);
+	wlock(&ifc->rwl);
 
 	/* dissociate routes */
 	if(ifc->medium != nil && ifc->medium->unbindonclose == 0)
@@ -221,7 +221,7 @@ ipifcunbind(Ipifc *ifc)
 	qclose(ifc->conv->sq);
 
 	ifc->medium = nil;
-	wunlock(ifc);
+	wunlock(&ifc->rwl);
 	poperror();
 	return nil;
 }
@@ -247,13 +247,13 @@ ipifcstate(Conv *c, char *state, int n)
 		ifc->rp.rxmitra, ifc->rp.ttl, ifc->rp.routerlt,
 		ifc->in, ifc->out, ifc->inerr, ifc->outerr);
 
-	rlock(ifc);
+	rlock(&ifc->rwl);
 	for(lifc = ifc->lifc; lifc && n > m; lifc = lifc->next)
 		m += snprint(state+m, n - m, slineformat, lifc->local,
 			lifc->mask, lifc->remote, lifc->validlt, lifc->preflt);
 	if(ifc->lifc == nil)
 		m += snprint(state+m, n - m, "\n");
-	runlock(ifc);
+	runlock(&ifc->rwl);
 	return m;
 }
 
@@ -268,14 +268,14 @@ ipifclocal(Conv *c, char *state, int n)
 	ifc = (Ipifc*)c->ptcl;
 	m = 0;
 
-	rlock(ifc);
+	rlock(&ifc->rwl);
 	for(lifc = ifc->lifc; lifc; lifc = lifc->next){
 		m += snprint(state+m, n - m, "%-40.40I ->", lifc->local);
 		for(link = lifc->link; link; link = link->lifclink)
 			m += snprint(state+m, n - m, " %-40.40I", link->self->a);
 		m += snprint(state+m, n - m, "\n");
 	}
-	runlock(ifc);
+	runlock(&ifc->rwl);
 	return m;
 }
 
@@ -304,19 +304,19 @@ ipifckick(void *x)
 		return;
 
 	ifc = (Ipifc*)c->ptcl;
-	if(!canrlock(ifc)){
+	if(!canrlock(&ifc->rwl)){
 		freeb(bp);
 		return;
 	}
 	if(waserror()){
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		nexterror();
 	}
 	if(ifc->medium == nil || ifc->medium->pktin == nil)
 		freeb(bp);
 	else
 		(*ifc->medium->pktin)(c->p->f, ifc, bp);
-	runlock(ifc);
+	runlock(&ifc->rwl);
 	poperror();
 }
 
@@ -427,7 +427,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp)
 	}
 	if(isv4(ip))
 		tentative = 0;
-	wlock(ifc);
+	wlock(&ifc->rwl);
 
 	/* ignore if this is already a local address for this ifc */
 	for(lifc = ifc->lifc; lifc; lifc = lifc->next) {
@@ -541,7 +541,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp)
 		(*ifc->medium->areg)(ifc, ip);
 
 out:
-	wunlock(ifc);
+	wunlock(&ifc->rwl);
 	if(tentative && sendnbrdisc)
 		icmpns(f, 0, SRC_UNSPEC, ip, TARG_MULTI, ifc->mac);
 	return nil;
@@ -614,7 +614,7 @@ ipifcrem(Ipifc *ifc, char **argv, int argc)
 		if (parseip(rem, argv[3]) == -1)
 			return Ebadip;
 
-	wlock(ifc);
+	wlock(&ifc->rwl);
 
 	/*
 	 *  find address on this interface and remove from chain.
@@ -629,7 +629,7 @@ ipifcrem(Ipifc *ifc, char **argv, int argc)
 	}
 
 	rv = ipifcremlifc(ifc, lifc);
-	wunlock(ifc);
+	wunlock(&ifc->rwl);
 	return rv;
 }
 
@@ -691,16 +691,16 @@ ipifcconnect(Conv* c, char **argv, int argc)
 		 return "ipifc not yet bound to device";
 
 	if(waserror()){
-		wunlock(ifc);
+		wunlock(&ifc->rwl);
 		nexterror();
 	}
-	wlock(ifc);
+	wlock(&ifc->rwl);
 	while(ifc->lifc){
 		err = ipifcremlifc(ifc, ifc->lifc);
 		if(err)
 			error(err);
 	}
-	wunlock(ifc);
+	wunlock(&ifc->rwl);
 	poperror();
 
 	err = ipifcadd(ifc, argv, argc, 0, nil);
@@ -850,7 +850,7 @@ addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a, int type)
 	Iplink *lp;
 	int h;
 
-	qlock(f->self);
+	qlock(&f->self->ql);
 
 	/* see if the address already exists */
 	h = hashipa(a);
@@ -899,7 +899,7 @@ addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a, int type)
 	} else
 		lp->ref++;
 
-	qunlock(f->self);
+	qunlock(&f->self->ql);
 }
 
 /*
@@ -962,7 +962,7 @@ remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a)
 	Ipself *p, **l;
 	Iplink *link, **l_self, **l_lifc;
 
-	qlock(f->self);
+	qlock(&f->self->ql);
 
 	/* find the unique selftab entry */
 	l = &f->self->hash[hashipa(a)];
@@ -1032,7 +1032,7 @@ remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a)
 		f->self->acceptall = 0;
 
 out:
-	qunlock(f->self);
+	qunlock(&f->self->ql);
 }
 
 static char *stformat = "%-44.44I %2.2d %4.4s\n";
@@ -1051,7 +1051,7 @@ ipselftabread(Fs *f, char *cp, uint32_t offset, int n)
 
 	m = 0;
 	off = offset;
-	qlock(f->self);
+	qlock(&f->self->ql);
 	for(i = 0; i < NHASH && m < n; i++){
 		for(p = f->self->hash[i]; p != nil && m < n; p = p->next){
 			nifc = 0;
@@ -1065,7 +1065,7 @@ ipselftabread(Fs *f, char *cp, uint32_t offset, int n)
 			}
 		}
 	}
-	qunlock(f->self);
+	qunlock(&f->self->ql);
 	return m;
 }
 
@@ -1247,7 +1247,7 @@ findlocalip(Fs *f, uint8_t *local, uint8_t *remote)
 
 	USED(atype);
 	USED(atypel);
-	qlock(f->ipifc);
+	qlock(&f->ipifc->ql);
 	r = v6lookup(f, remote, nil);
  	version = (memcmp(remote, v4prefix, IPv4off) == 0)? V4: V6;
 
@@ -1314,7 +1314,7 @@ findlocalip(Fs *f, uint8_t *local, uint8_t *remote)
 	}
 
 out:
-	qunlock(f->ipifc);
+	qunlock(&f->ipifc->ql);
 }
 
 /*
@@ -1462,14 +1462,14 @@ ipifcaddmulti(Conv *c, uint8_t *ma, uint8_t *ia)
 			continue;
 		ifc = (Ipifc*)(*p)->ptcl;
 		if(waserror()){
-			wunlock(ifc);
+			wunlock(&ifc->rwl);
 			nexterror();
 		}
-		wlock(ifc);
+		wlock(&ifc->rwl);
 		for(lifc = ifc->lifc; lifc; lifc = lifc->next)
 			if(ipcmp(ia, lifc->local) == 0)
 				addselfcache(f, ifc, lifc, ma, Rmulti);
-		wunlock(ifc);
+		wunlock(&ifc->rwl);
 		poperror();
 	}
 }
@@ -1506,14 +1506,14 @@ ipifcremmulti(Conv *c, uint8_t *ma, uint8_t *ia)
 
 		ifc = (Ipifc*)(*p)->ptcl;
 		if(waserror()){
-			wunlock(ifc);
+			wunlock(&ifc->rwl);
 			nexterror();
 		}
-		wlock(ifc);
+		wlock(&ifc->rwl);
 		for(lifc = ifc->lifc; lifc; lifc = lifc->next)
 			if(ipcmp(ia, lifc->local) == 0)
 				remselfcache(f, ifc, lifc, ma);
-		wunlock(ifc);
+		wunlock(&ifc->rwl);
 		poperror();
 	}
 
@@ -1553,10 +1553,10 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uint8_t *ip)
 		for(cp = f->ipifc->conv; cp < e; cp++){
 			if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc)
 				continue;
-			rlock(nifc);
+			rlock(&nifc->rwl);
 			m = nifc->medium;
 			if(m == nil || m->addmulti == nil) {
-				runlock(nifc);
+				runlock(&nifc->rwl);
 				continue;
 			}
 			for(lifc = nifc->lifc; lifc; lifc = lifc->next){
@@ -1570,17 +1570,17 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uint8_t *ip)
 					break;
 				}
 			}
-			runlock(nifc);
+			runlock(&nifc->rwl);
 		}
 	}
 	else {					/* V4 */
 		for(cp = f->ipifc->conv; cp < e; cp++){
 			if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc)
 				continue;
-			rlock(nifc);
+			rlock(&nifc->rwl);
 			m = nifc->medium;
 			if(m == nil || m->areg == nil){
-				runlock(nifc);
+				runlock(&nifc->rwl);
 				continue;
 			}
 			for(lifc = nifc->lifc; lifc; lifc = lifc->next){
@@ -1590,7 +1590,7 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uint8_t *ip)
 					break;
 				}
 			}
-			runlock(nifc);
+			runlock(&nifc->rwl);
 		}
 	}
 }

+ 8 - 8
sys/src/9/ip/ipmux.c

@@ -587,9 +587,9 @@ ipmuxconnect(Conv *c, char **argv, int argc)
 	r->chain = chain;
 
 	/* add the chain to the protocol demultiplexor tree */
-	wlock(f);
+	wlock(&f->rwl);
 	f->ipmux->priv = ipmuxmerge(f->ipmux->priv, mux);
-	wunlock(f);
+	wunlock(&f->rwl);
 
 	Fsconnected(c, nil);
 	return nil;
@@ -637,9 +637,9 @@ ipmuxclose(Conv *c)
 	c->lport = 0;
 	c->rport = 0;
 
-	wlock(f);
+	wlock(&f->rwl);
 	ipmuxremove((struct Ipmux **)&(c->p->priv), r->chain);
-	wunlock(f);
+	wunlock(&f->rwl);
 	ipmuxtreefree(r->chain);
 	r->chain = nil;
 }
@@ -686,7 +686,7 @@ ipmuxiput(Proto *p, Ipifc *ifc, Block *bp)
 	len = BLEN(bp);
 
 	/* run the v4 filter */
-	rlock(f);
+	rlock(&f->rwl);
 	c = nil;
 	mux = f->ipmux->priv;
 	while(mux != nil){
@@ -748,7 +748,7 @@ yes:
 			c = mux->conv;
 		mux = mux->yes;
 	}
-	runlock(f);
+	runlock(&f->rwl);
 
 	if(c != nil){
 		/* tack on interface address */
@@ -815,9 +815,9 @@ ipmuxstats(Proto *p, char *buf, int len)
 	int n;
 	Fs *f = p->f;
 
-	rlock(f);
+	rlock(&f->rwl);
 	n = ipmuxsprint(p->priv, 0, buf, len);
-	runlock(f);
+	runlock(&f->rwl);
 
 	return n;
 }

+ 4 - 4
sys/src/9/ip/ipv6.c

@@ -113,11 +113,11 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 		eh->vcf[1]  = tos << 4;
 	}
 
-	if(!canrlock(ifc))
+	if(!canrlock(&ifc->rwl))
 		goto free;
 
 	if(waserror()){
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		nexterror();
 	}
 
@@ -129,7 +129,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 	if(len <= medialen) {
 		hnputs(eh->ploadlen, len - IP6HDR);
 		ifc->medium->bwrite(ifc, bp, V6, gate);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		poperror();
 		return 0;
 	}
@@ -225,7 +225,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 	ip->stats[FragOKs]++;
 
 raise:
-	runlock(ifc);
+	runlock(&ifc->rwl);
 	poperror();
 free:
 	freeblist(bp);

+ 3 - 3
sys/src/9/ip/loopbackmedium.c

@@ -95,19 +95,19 @@ loopbackread(void *a)
 		if(bp == nil)
 			continue;
 		ifc->in++;
-		if(!canrlock(ifc)){
+		if(!canrlock(&ifc->rwl)){
 			freeb(bp);
 			continue;
 		}
 		if(waserror()){
-			runlock(ifc);
+			runlock(&ifc->rwl);
 			nexterror();
 		}
 		if(ifc->lifc == nil)
 			freeb(bp);
 		else
 			ipiput4(lb->f, ifc, bp);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		poperror();
 	}
 }

+ 3 - 3
sys/src/9/ip/netdevmedium.c

@@ -139,12 +139,12 @@ ZZZ is this a good idea?
 				ifc->conv->p->ctl(ifc->conv, argv, 1);
 			pexit("hangup", 1);
 		}
-		if(!canrlock(ifc)){
+		if(!canrlock(&ifc->rwl)){
 			freeb(bp);
 			continue;
 		}
 		if(waserror()){
-			runlock(ifc);
+			runlock(&ifc->rwl);
 			nexterror();
 		}
 		ifc->in++;
@@ -152,7 +152,7 @@ ZZZ is this a good idea?
 			freeb(bp);
 		else
 			ipiput4(er->f, ifc, bp);
-		runlock(ifc);
+		runlock(&ifc->rwl);
 		poperror();
 	}
 }

+ 11 - 12
sys/src/9/ip/netlog.c

@@ -34,7 +34,7 @@ struct Netlog {
 	uint8_t	iponly[IPaddrlen];		/* ip address to print debugging for */
 	int	iponlyset;
 
-	QLock;
+	QLock ql;
 	Rendez;
 };
 
@@ -87,9 +87,9 @@ void
 netlogopen(Fs *f)
 {
 	Proc *up = externup();
-	lock(f->alog);
+	lock(&f->alog->_lock);
 	if(waserror()){
-		unlock(f->alog);
+		unlock(&f->alog->_lock);
 		nexterror();
 	}
 	if(f->alog->opens == 0){
@@ -138,14 +138,14 @@ netlogread(Fs *f, void *a, uint32_t u, int32_t n)
 	int i, d;
 	char *p, *rptr;
 
-	qlock(f->alog);
+	qlock(&f->alog->ql);
 	if(waserror()){
-		qunlock(f->alog);
+		qunlock(&f->alog->ql);
 		nexterror();
 	}
 
 	for(;;){
-		lock(f->alog);
+		lock(&f->alog->_lock);
 		if(f->alog->len){
 			if(n > f->alog->len)
 				n = f->alog->len;
@@ -157,7 +157,7 @@ netlogread(Fs *f, void *a, uint32_t u, int32_t n)
 				f->alog->rptr = f->alog->buf + d;
 			}
 			f->alog->len -= n;
-			unlock(f->alog);
+			unlock(&f->alog->_lock);
 
 			i = n-d;
 			p = a;
@@ -166,12 +166,12 @@ netlogread(Fs *f, void *a, uint32_t u, int32_t n)
 			break;
 		}
 		else
-			unlock(f->alog);
+			unlock(&f->alog->_lock);
 
 		sleep(f->alog, netlogready, f);
 	}
 
-	qunlock(f->alog);
+	qunlock(&f->alog->ql);
 	poperror();
 
 	return n;
@@ -255,7 +255,7 @@ netlog(Fs *f, int mask, char *fmt, ...)
 	n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf;
 	va_end(arg);
 
-	lock(f->alog);
+	lock(&f->alog->_lock);
 	i = f->alog->len + n - Nlog;
 	if(i > 0){
 		f->alog->len -= i;
@@ -271,7 +271,6 @@ netlog(Fs *f, int mask, char *fmt, ...)
 			t = f->alog->buf + (t - f->alog->end);
 		*t++ = *fp++;
 	}
-	unlock(f->alog);
-
+	unlock(&f->alog->_lock);
 	wakeup(f->alog);
 }

+ 19 - 19
sys/src/9/ip/rudp.c

@@ -180,7 +180,7 @@ static uint32_t generation = 0;
 typedef struct Rudpcb Rudpcb;
 struct Rudpcb
 {
-	QLock;
+	QLock ql;
 	uint8_t	headers;
 	uint8_t	randdrop;
 	Reliable *r;
@@ -245,11 +245,11 @@ rudpstate(Conv *c, char *state, int n)
 
 	m = snprint(state, n, "%s", c->inuse?"Open":"Closed");
 	ucb = (Rudpcb*)c->ptcl;
-	qlock(ucb);
+	qlock(&ucb->ql);
 	for(r = ucb->r; r; r = r->next)
 		m += snprint(state+m, n-m, " %I/%ld", r->addr, UNACKED(r));
 	m += snprint(state+m, n-m, "\n");
-	qunlock(ucb);
+	qunlock(&ucb->ql);
 	return m;
 }
 
@@ -289,12 +289,12 @@ rudpclose(Conv *c)
 
 	/* force out any delayed acks */
 	ucb = (Rudpcb*)c->ptcl;
-	qlock(ucb);
+	qlock(&ucb->ql);
 	for(r = ucb->r; r; r = r->next){
 		if(r->acksent != r->rcvseq)
 			relsendack(c, r, 0);
 	}
-	qunlock(ucb);
+	qunlock(&ucb->ql);
 
 	qclose(c->rq);
 	qclose(c->wq);
@@ -306,7 +306,7 @@ rudpclose(Conv *c)
 
 	ucb->headers = 0;
 	ucb->randdrop = 0;
-	qlock(ucb);
+	qlock(&ucb->ql);
 	for(r = ucb->r; r; r = nr){
 		if(r->acksent != r->rcvseq)
 			relsendack(c, r, 0);
@@ -316,7 +316,7 @@ rudpclose(Conv *c)
 	}
 	ucb->r = 0;
 
-	qunlock(ucb);
+	qunlock(&ucb->ql);
 }
 
 /*
@@ -428,7 +428,7 @@ rudpkick(void *x)
 	uh->udpcksum[0] = 0;
 	uh->udpcksum[1] = 0;
 
-	qlock(ucb);
+	qlock(&ucb->ql);
 	r = relstate(ucb, raddr, rport, "kick");
 	r->sndseq = NEXTSEQ(r->sndseq);
 	hnputl(rh->relseq, r->sndseq);
@@ -443,7 +443,7 @@ rudpkick(void *x)
 	hnputs(uh->udpcksum, ptclcsum(bp, UDP_IPHDR, dlen+UDP_RHDRSIZE));
 
 	relackq(r, bp);
-	qunlock(ucb);
+	qunlock(&ucb->ql);
 
 	upriv->ustats.rudpOutDatagrams++;
 
@@ -516,13 +516,13 @@ rudpiput(Proto *rudp, Ipifc *ifc, Block *bp)
 		}
 	}
 
-	qlock(rudp);
+	qlock(&rudp->ql);
 
 	c = iphtlook(&upriv->ht, raddr, rport, laddr, lport);
 	if(c == nil){
 		/* no conversation found */
 		upriv->ustats.rudpNoPorts++;
-		qunlock(rudp);
+		qunlock(&rudp->ql);
 		netlog(f, Logudp, "udp: no conv %I!%d -> %I!%d\n", raddr, rport,
 			laddr, lport);
 		uh->Unused = ottl;
@@ -532,11 +532,11 @@ rudpiput(Proto *rudp, Ipifc *ifc, Block *bp)
 		return;
 	}
 	ucb = (Rudpcb*)c->ptcl;
-	qlock(ucb);
-	qunlock(rudp);
+	qlock(&ucb->ql);
+	qunlock(&rudp->ql);
 
 	if(reliput(c, bp, raddr, rport) < 0){
-		qunlock(ucb);
+		qunlock(&ucb->ql);
 		freeb(bp);
 		return;
 	}
@@ -596,7 +596,7 @@ rudpiput(Proto *rudp, Ipifc *ifc, Block *bp)
 	else
 		qpass(c->rq, bp);
 
-	qunlock(ucb);
+	qunlock(&ucb->ql);
 }
 
 static char *rudpunknown = "unknown rudp ctl request";
@@ -621,9 +621,9 @@ rudpctl(Conv *c, char **f, int n)
 		if (parseip(ip, f[1]) == -1)
 			return Ebadip;
 		x = atoi(f[2]);
-		qlock(ucb);
+		qlock(&ucb->ql);
 		relforget(c, ip, x, 1);
-		qunlock(ucb);
+		qunlock(&ucb->ql);
 		return nil;
 	} else if(strcmp(f[0], "randdrop") == 0){
 		x = 10;			/* default is 10% */
@@ -751,7 +751,7 @@ loop:
 	for(s = rudp->conv; *s; s++) {
 		c = *s;
 		ucb = (Rudpcb*)c->ptcl;
-		qlock(ucb);
+		qlock(&ucb->ql);
 
 		for(r = ucb->r; r; r = r->next) {
 			if(r->unacked != nil){
@@ -762,7 +762,7 @@ loop:
 			if(r->acksent != r->rcvseq)
 				relsendack(c, r, 0);
 		}
-		qunlock(ucb);
+		qunlock(&ucb->ql);
 	}
 	goto loop;
 }

+ 10 - 10
sys/src/9/ip/tcp.c

@@ -1621,7 +1621,7 @@ limborexmit(Proto *tcp)
 
 	tpriv = tcp->priv;
 
-	if(!canqlock(tcp))
+	if(!canqlock(&tcp->ql))
 		return;
 	seen = 0;
 	now = NOW;
@@ -1654,7 +1654,7 @@ limborexmit(Proto *tcp)
 			l = &lp->next;
 		}
 	}
-	qunlock(tcp);
+	qunlock(&tcp->ql);
 }
 
 /*
@@ -2186,7 +2186,7 @@ tcpiput(Proto *tcp, Ipifc *ipifc, Block *bp)
 	}
 
 	/* lock protocol while searching for a conversation */
-	qlock(tcp);
+	qlock(&tcp->ql);
 
 	/* Look for a matching conversation */
 	s = iphtlook(&tpriv->ht, source, seg.source, dest, seg.dest);
@@ -2194,7 +2194,7 @@ tcpiput(Proto *tcp, Ipifc *ipifc, Block *bp)
 		netlog(f, Logtcp, "iphtlook(src %I!%d, dst %I!%d) failed\n",
 			source, seg.source, dest, seg.dest);
 reset:
-		qunlock(tcp);
+		qunlock(&tcp->ql);
 		sndrst(tcp, source, dest, length, &seg, version, "no conversation");
 		freeblist(bp);
 		return;
@@ -2205,7 +2205,7 @@ reset:
 	if(tcb->state == Listen){
 		if(seg.flags & RST){
 			limborst(s, &seg, source, dest, version);
-			qunlock(tcp);
+			qunlock(&tcp->ql);
 			freeblist(bp);
 			return;
 		}
@@ -2213,7 +2213,7 @@ reset:
 		/* if this is a new SYN, put the call into limbo */
 		if((seg.flags & SYN) && (seg.flags & ACK) == 0){
 			limbo(s, source, dest, &seg, version);
-			qunlock(tcp);
+			qunlock(&tcp->ql);
 			freeblist(bp);
 			return;
 		}
@@ -2237,7 +2237,7 @@ reset:
 		nexterror();
 	}
 	qlock(&s->ql);
-	qunlock(tcp);
+	qunlock(&tcp->ql);
 
 	/* fix up window */
 	seg.wnd <<= tcb->rcv.scale;
@@ -3267,7 +3267,7 @@ tcpadvise(Proto *tcp, Block *bp, char *msg)
 	}
 
 	/* Look for a connection */
-	qlock(tcp);
+	qlock(&tcp->ql);
 	for(p = tcp->conv; *p; p++) {
 		s = *p;
 		tcb = (Tcpctl*)s->ptcl;
@@ -3277,7 +3277,7 @@ tcpadvise(Proto *tcp, Block *bp, char *msg)
 		if(ipcmp(s->raddr, dest) == 0)
 		if(ipcmp(s->laddr, source) == 0){
 			qlock(&s->ql);
-			qunlock(tcp);
+			qunlock(&tcp->ql);
 			switch(tcb->state){
 			case Syn_sent:
 				localclose(s, msg);
@@ -3288,7 +3288,7 @@ tcpadvise(Proto *tcp, Block *bp, char *msg)
 			return;
 		}
 	}
-	qunlock(tcp);
+	qunlock(&tcp->ql);
 	freeblist(bp);
 }
 

+ 8 - 8
sys/src/9/ip/udp.c

@@ -109,7 +109,7 @@ void udpkick(void *x, Block *bp);
 typedef struct Udpcb Udpcb;
 struct Udpcb
 {
-	QLock;
+	QLock ql;
 	uint8_t	headers;
 };
 
@@ -410,13 +410,13 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 		return;	/* to avoid a warning */
 	}
 
-	qlock(udp);
+	qlock(&udp->ql);
 
 	c = iphtlook(&upriv->ht, raddr, rport, laddr, lport);
 	if(c == nil){
 		/* no conversation found */
 		upriv->ustats.udpNoPorts++;
-		qunlock(udp);
+		qunlock(&udp->ql);
 		netlog(f, Logudp, "udp: no conv %I!%d -> %I!%d\n", raddr, rport,
 		       laddr, lport);
 
@@ -453,7 +453,7 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 			}
 			c = Fsnewcall(c, raddr, rport, laddr, lport, version);
 			if(c == nil){
-				qunlock(udp);
+				qunlock(&udp->ql);
 				freeblist(bp);
 				return;
 			}
@@ -463,7 +463,7 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 	}
 
 	qlock(&c->ql);
-	qunlock(udp);
+	qunlock(&udp->ql);
 
 	/*
 	 * Trim the packet down to data size
@@ -568,7 +568,7 @@ udpadvise(Proto *udp, Block *bp, char *msg)
 	}
 
 	/* Look for a connection */
-	qlock(udp);
+	qlock(&udp->ql);
 	for(p = udp->conv; *p; p++) {
 		s = *p;
 		if(s->rport == pdest)
@@ -578,7 +578,7 @@ udpadvise(Proto *udp, Block *bp, char *msg)
 			if(s->ignoreadvice)
 				break;
 			qlock(&s->ql);
-			qunlock(udp);
+			qunlock(&udp->ql);
 			qhangup(s->rq, msg);
 			qhangup(s->wq, msg);
 			qunlock(&s->ql);
@@ -586,7 +586,7 @@ udpadvise(Proto *udp, Block *bp, char *msg)
 			return;
 		}
 	}
-	qunlock(udp);
+	qunlock(&udp->ql);
 	freeblist(bp);
 }