Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Nov 2003 10:15:44 -0700
From:      John Giacomoni <John.Giacomoni@colorado.edu>
To:        freebsd-hackers@freebsd.org
Subject:   locking ifpromisc (struct ifnet)
Message-ID:  <DB2BFA16-107C-11D8-AFE9-0003930719D8@colorado.edu>

next in thread | raw e-mail | index | archive | help
Currently how should one lock a struct ifnet* so one can safely use
ifpromisc on it?

I'm writting a module similar to the bpf, however I am failing to
follow the correct way to safely establish locking.  Grabbing
[Giant does not seem correct as Giant is being removed]

my understanding is that one uses ifunit to convert
if_name -> struct ifnet *ifp
and then one uses the *ifp in the ifpromisc call.

the safety I'm referring to would be:
a) device deallocation in between  ifunit and ifpromisc.

b) simultaneous calls to ifpromisc

d) a simultaneous ifpromisc call and the device being removed and
deallocated.

my guess would be to grab IFNET_RLOCK or IFNET_WLOCK, then do the
ifunit name -> ifp translation, ifpromisc, then the IFNET_UN[RW]LOCK


is this correct?

for the present?

for the future?

is there a way to acquire a struct ifnet* and keep it around safely?
[perhaps some kind of notification system for when an ifp is no
  longer valid?]

thanks

John G


--

University of Colorado at Boulder          John.Giacomoni@colorado.edu
Department of Computer Science                     phone: 303.492.8115
Engineering Center, ECCS 121                              303.492.7906
430 UCB                                            fax:   303.492.2844
Boulder, CO 80303-0430
USA



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DB2BFA16-107C-11D8-AFE9-0003930719D8>