Re: [Qemu-devel] [PATCH 3/4] qemu:virtio-net: Add support for qemu_vlan_rxfilter

Jamie Lokier
2009-02-13T16:46:08Z

Paul Brook wrote:
> > Well, you do need some way to notify a client that the filter which
> > used to work has been removed because it's no longer available, for
> > example when migrating between host kernels.
>
> This is actually more evidence that the "add" and "remove" callbacks are
> bogus.

I agree, "add" and "remove" are misnamed among other bogosities.

> My point is that we're allowing the filter to fail for arbitrary
> reasons. Once you assume this, trying to be clever is just going to
> catch you out when we encounter a case you didn't think of.

Yes.

> A simple "Something changed, please try your filter again" callback
> automatically covers all these cases.

It doesn't, if tap has no memory of how many clients require a filter.

If tap just answers "YES and installs the kernel filter" or "NO and
doesn't install the kernel filter" and doesn't remember how many
clients need a filter, then:

1. Client A requests filter A
-> tap says YES, installs kernel filter.
2. Client B requests filter B
-> tap can't do both, so deinstalls kernel filter.
-> tap says NO to client B.
-> tap notifies client A "there's been a change".
3. Client A requests filter A
-> tap doesn't remember that client B wants a filter, so
-> tap says YES.
-> tap notifies client B "there's been a change".
4. Goto 2
-> endless loop.

In other words, tap needs to distinguish three states:

"1 filter requested and installed in the kernel"
">1 filter requested, none installed in the kernel"
"0 filters requested, none installed in the kernel"

The interface to clients needs to keep that state updated in tap
somehow. Just requesting a filter and reverting to software filtering
when the request failed doesn't do that.

Note this has nothing to do with the software filtering fallback.
Even if qemu internal filtering is always done, you still need the
above to keep the kernel filter correct.

Imho, since there needs to be software filter code for fallback
_anyway_, a better place to put that fallback is in the
client-independent plumbing which relays packets to each client. And
if it's there, you can have a different software fallback filter for
each client anyway, so clients can assume filters are always installed
and working perfectly.

The interface between the plumbing and the tap driver still needs to
handle the issues described above.

-- Jamie