cvs commit: src/sys/kern subr_witness.c src/sys/netinet igmp.c
in.c in_var.h ip_input.c ip_output.c src/sys/netinet6 in6_var.h
emaste at FreeBSD.org
Wed Jan 18 15:36:50 PST 2006
emaste 2006-01-18 23:36:49 UTC
FreeBSD src repository
Modified files: (Branch: RELENG_5)
sys/netinet igmp.c in.c in_var.h ip_input.c
sys/netinet6 in6_var.h mld6.c
Merge IP multicast address list locking from HEAD to RELENG_5, with a
few changes to preserve ABI compatibility.
Add in_multi_mtx, igmp_mtx, and if_addr_mtx lock order to hard-coded
lock order in WITNESS, in that order.
in_var.h:1.54 in6_var.h:1.23 mld6.c:1.22:
Modify network protocol consumers of the ifnet multicast address lists
to lock if_addr_mtx.
igmp.c:1.49 in.c:1.86: in_var.h:1.55 ip_input.c:1.303 ip_output.c:1.243:
Introduce in_multi_mtx, which will protect IPv4-layer multicast address
lists, as well as accessor macros. For now, this is a recursive mutex
due code sequences where IPv4 multicast calls into IGMP calls into
ip_output(), which then tests for a multicast forwarding case.
For support macros in in_var.h to check multicast address lists, assert
that in_multi_mtx is held.
Acquire in_multi_mtx around iteration over the IPv4 multicast address
lists, such as in ip_input() and ip_output().
Acquire in_multi_mtx when manipulating the IPv4 layer multicast
addresses, as well as over the manipulation of ifnet multicast address
lists in order to keep the two layers in sync.
Lock down accesses to IPv4 multicast addresses in IGMP, or assert the
lock when performing IGMP join/leave events.
Eliminate spl's associated with IPv4 multicast addresses, portions of
IGMP that weren't previously expunged by IGMP locking.
Acquire Giant conditionally in in_addmulti() and in_delmulti() based on
whether the interface being accessed is IFF_NEEDSGIANT or not. This
avoids lock order reversals when calling into the interface ioctl
handler, which could potentially lead to deadlock.
The long term solution is to eliminate non-MPSAFE network drivers.
Discussed with: jhb
Unlock Giant symmetrically with respect to lock acquire order as that's
Spotted by: johan
Add helper function ip_findmoptions(), which accepts an inpcb, and attempts
to atomically return either an existing set of IP multicast options for the
PCB, or a newlly allocated set with default values. The inpcb is returned
locked. This function may sleep.
Call ip_moptions() to acquire a reference to a PCB's socket options, and
perform the update of the options while holding the PCB lock. Release the
lock before returning.
Remove garbage collection of multicast options when values return to the
default, as this complicates locking substantially. Most applications
allocate a socket either to be multicast, or not, and don't tend to keep
around sockets that have previously been used for multicast, then used for
This closes a number of race conditions involving multiple threads or
processes modifying the IP multicast state of a socket simultaenously.
Approved by: rwatson (mentor)
Revision Changes Path
126.96.36.199 +7 -0 src/sys/kern/subr_witness.c
188.8.131.52 +12 -8 src/sys/netinet/igmp.c
184.108.40.206 +27 -10 src/sys/netinet/in.c
220.127.116.11 +16 -0 src/sys/netinet/in_var.h
1.283.2.15 +2 -0 src/sys/netinet/ip_input.c
18.104.22.168 +61 -33 src/sys/netinet/ip_output.c
22.214.171.124 +2 -0 src/sys/netinet6/in6_var.h
126.96.36.199 +2 -0 src/sys/netinet6/mld6.c
More information about the cvs-src