changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: devip: do not lock selftab in ipselftabread(), remove unused fields from Ipself

changeset 7233: 24d21d7c0868
parent 7232: 654dc461dd91
child 7234: fc141b91ed8a
author: cinap_lenrek@felloff.net
date: Sun, 12 May 2019 01:20:21 +0200
files: sys/src/9/ip/ip.h sys/src/9/ip/ipifc.c
description: 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.
     1.1--- a/sys/src/9/ip/ip.h
     1.2+++ b/sys/src/9/ip/ip.h
     1.3@@ -274,9 +274,9 @@ struct Iplink
     1.4 	Ipself	*self;
     1.5 	Iplifc	*lifc;
     1.6 	Iplink	*selflink;	/* next link for this local address */
     1.7-	Iplink	*lifclink;	/* next link for this ifc */
     1.8+	Iplink	*lifclink;	/* next link for this lifc */
     1.9+	Iplink	*next;		/* free list */
    1.10 	ulong	expire;
    1.11-	Iplink	*next;		/* free list */
    1.12 	int	ref;
    1.13 };
    1.14 
     2.1--- a/sys/src/9/ip/ipifc.c
     2.2+++ b/sys/src/9/ip/ipifc.c
     2.3@@ -26,12 +26,10 @@ Medium *media[Maxmedia] = { 0 };
     2.4 struct Ipself
     2.5 {
     2.6 	uchar	a[IPaddrlen];
     2.7-	Ipself	*hnext;		/* next address in the hash table */
     2.8+	Ipself	*next;		/* next address in the hash table */
     2.9 	Iplink	*link;		/* binding twixt Ipself and Ipifc */
    2.10 	ulong	expire;
    2.11 	uchar	type;		/* type of address */
    2.12-	int	ref;
    2.13-	Ipself	*next;		/* free list */
    2.14 };
    2.15 
    2.16 struct Ipselftab
    2.17@@ -1100,7 +1098,6 @@ ipselftabread(Fs *f, char *cp, ulong off
    2.18 
    2.19 	m = 0;
    2.20 	off = offset;
    2.21-	qlock(f->self);
    2.22 	for(i = 0; i < NHASH && m < n; i++){
    2.23 		for(p = f->self->hash[i]; p != nil && m < n; p = p->next){
    2.24 			nifc = 0;
    2.25@@ -1115,7 +1112,6 @@ ipselftabread(Fs *f, char *cp, ulong off
    2.26 			}
    2.27 		}
    2.28 	}
    2.29-	qunlock(f->self);
    2.30 	return m;
    2.31 }
    2.32