Subject: Re: cgroup matches in INPUT chain

From: Daniel Mack <[email-masked]>
Date: Fri, 20 Mar 2015 14:57:39 +0100

Hi,

On 03/19/2015 07:58 PM, Florian Westphal wrote:
> Daniel Mack <[email-masked]> wrote:
>> In my tests, however, NF_INET_LOCAL_IN is iterated before early_demux()
>> is called,
> 
> Early demux occurs after PRE_ROUTING but before LOCAL_IN.

Hmm, you're right, except it isn't in my case. I'm not familiar with
that code, so please bear with me :)

In my simple test setup, when skbs are dequeued by process_backlog(),
they have skb->_skb_refdst set, and hence ip_rcv_finish() does not call
into early_demux() prior to iterating the INPUT chain:

ip_rcv_finish()
    if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL)
        ...
        ipprot->early_demux(skb);
        ...

Therefore, cgroup_mt() in xt_cgroup.c will be called with skb->sk ==
NULL, which makes the match callback ineffective. From looking at the
code, I assume xt_owner has the same problem.

However, when the skb is processed directly from the NIC's interrupt
handler, early_demux() is called as expected, and the match succeeds.

Any pointers how this can be solved would be greatly appreciated.

Thanks,
Daniel