diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
commit | d6434e1042f3b0a6dfe1b1f615af369486f9b1fa (patch) | |
tree | e2be02f33984c48ec019c654051d27964e42c441 /net/ipv4/protocol.c | |
parent | 609d1e803baf519487233b765eb487f9ec227a18 (diff) |
Merge with 2.3.19.
Diffstat (limited to 'net/ipv4/protocol.c')
-rw-r--r-- | net/ipv4/protocol.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c index b47480be5..2b61e6466 100644 --- a/net/ipv4/protocol.c +++ b/net/ipv4/protocol.c @@ -5,7 +5,7 @@ * * INET protocol dispatch tables. * - * Version: $Id: protocol.c,v 1.9 1997/10/29 20:27:34 kuznet Exp $ + * Version: $Id: protocol.c,v 1.10 1999/08/20 11:05:55 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -116,25 +116,7 @@ struct inet_protocol *inet_protos[MAX_INET_PROTOS] = NULL }; - -/* - * Find a protocol in the protocol tables given its - * IP type. - */ - -struct inet_protocol *inet_get_protocol(unsigned char prot) -{ - unsigned char hash; - struct inet_protocol *p; - - hash = prot & (MAX_INET_PROTOS - 1); - for (p = inet_protos[hash] ; p != NULL; p=p->next) - { - if (p->protocol == prot) - return((struct inet_protocol *) p); - } - return(NULL); -} +rwlock_t inet_protocol_lock = RW_LOCK_UNLOCKED; /* * Add a protocol handler to the hash tables @@ -146,6 +128,7 @@ void inet_add_protocol(struct inet_protocol *prot) struct inet_protocol *p2; hash = prot->protocol & (MAX_INET_PROTOS - 1); + write_lock_bh(&inet_protocol_lock); prot ->next = inet_protos[hash]; inet_protos[hash] = prot; prot->copy = 0; @@ -164,6 +147,7 @@ void inet_add_protocol(struct inet_protocol *prot) } p2 = (struct inet_protocol *) p2->next; } + write_unlock_bh(&inet_protocol_lock); } /* @@ -177,9 +161,11 @@ int inet_del_protocol(struct inet_protocol *prot) unsigned char hash; hash = prot->protocol & (MAX_INET_PROTOS - 1); + write_lock_bh(&inet_protocol_lock); if (prot == inet_protos[hash]) { inet_protos[hash] = (struct inet_protocol *) inet_protos[hash]->next; + write_unlock_bh(&inet_protocol_lock); return(0); } @@ -200,6 +186,7 @@ int inet_del_protocol(struct inet_protocol *prot) if (p->copy == 0 && lp != NULL) lp->copy = 0; p->next = prot->next; + write_unlock_bh(&inet_protocol_lock); return(0); } if (p->next != NULL && p->next->protocol == prot->protocol) @@ -207,5 +194,6 @@ int inet_del_protocol(struct inet_protocol *prot) p = (struct inet_protocol *) p->next; } + write_unlock_bh(&inet_protocol_lock); return(-1); } |