From ee0a5eb928ae5ccdf1a0e619b4ba6e93d19db5fb Mon Sep 17 00:00:00 2001 From: ups Date: Tue, 18 Jul 2006 22:34:27 +0000 Subject: Fix race conditions on enumerating pcb lists by moving the initialization ( and where appropriate the destruction) of the pcb mutex to the init/finit functions of the pcb zones. This allows locking of the pcb entries and race condition free comparison of the generation count. Rearrange locking a bit to avoid extra locking operation to update the generation count in in_pcballoc(). (in_pcballoc now returns the pcb locked) I am planning to convert pcb list handling from a type safe to a reference count model soon. ( As this allows really freeing the PCBs) Reviewed by: rwatson@, mohans@ MFC after: 1 week --- sys/netinet6/udp6_usrreq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sys/netinet6/udp6_usrreq.c') diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 18f0c81..f031b96 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -503,13 +503,12 @@ udp6_attach(struct socket *so, int proto, struct thread *td) return error; } INP_INFO_WLOCK(&udbinfo); - error = in_pcballoc(so, &udbinfo, "udp6inp"); + error = in_pcballoc(so, &udbinfo); if (error) { INP_INFO_WUNLOCK(&udbinfo); return error; } inp = (struct inpcb *)so->so_pcb; - INP_LOCK(inp); INP_INFO_WUNLOCK(&udbinfo); inp->inp_vflag |= INP_IPV6; if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) -- cgit v1.1