Fix a sockbuf race. Currently the m_free*() path can block, due to
objcache_put() blocking when it must access the global depot. This breaks
the critical section *AND the BGL during a time when the sockbuf state is
inconsistent. Another process accessing the same sockbuf would then
corrupt it. Since depot access is fairly rare, this bug typically required
a number of hours to reproduce.
Delay the actual freeing of mbufs until after the sockbuf state has been
updated. Encapsulate common operations in a procedure, and add additional
assertions. NULL out sb_lastrecord when it becomes invalid, and add a
considerable amount of debugging code.
SOCKBUF_DEBUG has been added. Note that this is a VERY EXPENSIVE
kernel compile option which should only be used when specifically debugging
the networking subsystem.
This is a stabilization patch is rather hackish. A better cleanup will
occur once we are sure we've fixed all the bugs.
sbcheck provided by: Jeffrey Hsu
Reported-by: David Rhodus, Peter Avalos, YONETANI Tomokazu,
Tomaz Borstnar, and numerous other people.