Date: Tue, 26 Jul 2011 10:09:09 +0100 From: "Robert N. M. Watson" <rwatson@freebsd.org> To: Daan Vreeken <Daan@vitsch.nl> Cc: freebsd-net@freebsd.org, bz@freebsd.org, Ryan Stone <rysto32@gmail.com>, gnn@freebsd.org Subject: Re: m_pkthdr.rcvif dangling pointer problem Message-ID: <1836450A-72C5-4796-811E-91C3974C1932@freebsd.org> In-Reply-To: <201107251300.20832.Daan@vitsch.nl> References: <20110714154457.GI70776@FreeBSD.org> <CAFMmRNwBbxR-F7PjkwF8E4GjwFQy_0USKW-3u-ZRNxPMJSOQcA@mail.gmail.com> <E05FE767-1923-4D47-9759-FA040E403618@freebsd.org> <201107251300.20832.Daan@vitsch.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
On 25 Jul 2011, at 12:00, Daan Vreeken wrote: > Couldn't the dangling pointer problem be solved by adding a = 'generation' field=20 > to the mbuf structure? > The 'generation' could be a system-wide number that gets incremented = whenever=20 > an interface is removed. The mbuf* functions could keep a (per CPU?)=20= > reference count on the number of mbufs allocated/freed during=20 > that 'generation'. After interface removal, the ifnet structure could = be=20 > freed when all the reference counters of generations before the = current=20 > generation reach zero (whenever that happens). I think a hybrid approach makes sense, combining a number of the ideas = we've been kicking about: (1) Add per-CPU ifnet refcounts that don't imply cache-line misses on = each mbuf alloc/free (2) Add optional subsystem drain functions so that subsystems that may = have unbounded queueing times for mbufs deterministically ensure = reference release, perhaps by substituting a common deadif for = outstanding dying references. The former gives us actual correctness in terms of avoiding races, the = latter gives us deterministic freeing by subsystems that potentially = queue mbufs forever (i.e., TCP) but no longer require the ifnet = reference. Robert=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1836450A-72C5-4796-811E-91C3974C1932>