git: 9front

Download patch

ref: 21908a438cb561d360214780b0d37500f85d2f2e
parent: c3d9e585578bdfec2211f5008fe458392e51e706
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 11 21:20:21 EDT 2019

devip: do not lock selftab in ipselftabread(), remove unused fields from Ipself

the Ipselftab is designed to not require locking on read
operation. locking the selftab in ipselftabread() risks
deadlock when accessing the user buffer creates a fault.

remove unused fields from the Ipself struct.

--- a/sys/src/9/ip/ip.h
+++ b/sys/src/9/ip/ip.h
@@ -274,9 +274,9 @@
 	Ipself	*self;
 	Iplifc	*lifc;
 	Iplink	*selflink;	/* next link for this local address */
-	Iplink	*lifclink;	/* next link for this ifc */
-	ulong	expire;
+	Iplink	*lifclink;	/* next link for this lifc */
 	Iplink	*next;		/* free list */
+	ulong	expire;
 	int	ref;
 };
 
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -26,12 +26,10 @@
 struct Ipself
 {
 	uchar	a[IPaddrlen];
-	Ipself	*hnext;		/* next address in the hash table */
+	Ipself	*next;		/* next address in the hash table */
 	Iplink	*link;		/* binding twixt Ipself and Ipifc */
 	ulong	expire;
 	uchar	type;		/* type of address */
-	int	ref;
-	Ipself	*next;		/* free list */
 };
 
 struct Ipselftab
@@ -1100,7 +1098,6 @@
 
 	m = 0;
 	off = offset;
-	qlock(f->self);
 	for(i = 0; i < NHASH && m < n; i++){
 		for(p = f->self->hash[i]; p != nil && m < n; p = p->next){
 			nifc = 0;
@@ -1115,7 +1112,6 @@
 			}
 		}
 	}
-	qunlock(f->self);
 	return m;
 }
 
--