28 Dec, 2011

1 commit


23 Dec, 2011

1 commit

  • This partially reworks bc01befdcf3e40979eb518085a075cbf0aacede0
    which added userspace expectation support.

    This patch removes the nf_ct_userspace_expect_list since now we
    force to use the new iptables CT target feature to add the helper
    extension for conntracks that have attached expectations from
    userspace.

    A new version of the proof-of-concept code to implement userspace
    helpers from userspace is available at:

    http://people.netfilter.org/pablo/userspace-conntrack-helpers/nf-ftp-helper-POC.tar.bz2

    This patch also modifies the CT target to allow to set the
    conntrack's userspace helper status flags. This flag is used
    to tell the conntrack system to explicitly allocate the helper
    extension.

    This helper extension is useful to link the userspace expectations
    with the master conntrack that is being tracked from one userspace
    helper.

    This feature fixes a problem in the current approach of the
    userspace helper support. Basically, if the master conntrack that
    has got a userspace expectation vanishes, the expectations point to
    one invalid memory address. Thus, triggering an oops in the
    expectation deletion event path.

    I decided not to add a new revision of the CT target because
    I only needed to add a new flag for it. I'll document in this
    issue in the iptables manpage. I have also changed the return
    value from EINVAL to EOPNOTSUPP if one flag not supported is
    specified. Thus, in the future adding new features that only
    require a new flag can be added without a new revision.

    There is no official code using this in userspace (apart from
    the proof-of-concept) that uses this infrastructure but there
    will be some by beginning 2012.

    Reported-by: Sam Roberts
    Signed-off-by: Pablo Neira Ayuso

    Pablo Neira Ayuso
     

01 Nov, 2011

2 commits


14 Jan, 2011

1 commit


13 Jan, 2011

1 commit


07 Jan, 2011

1 commit


16 Nov, 2010

3 commits


19 Oct, 2010

1 commit


29 Sep, 2010

1 commit

  • This patch adds the basic infrastructure to support user-space
    expectation helpers via ctnetlink and the netfilter queuing
    infrastructure NFQUEUE. Basically, this patch:

    * adds NF_CT_EXPECT_USERSPACE flag to identify user-space
    created expectations. I have also added a sanity check in
    __nf_ct_expect_check() to avoid that kernel-space helpers
    may create an expectation if the master conntrack has no
    helper assigned.
    * adds some branches to check if the master conntrack helper
    exists, otherwise we skip the code that refers to kernel-space
    helper such as the local expectation list and the expectation
    policy.
    * allows to set the timeout for user-space expectations with
    no helper assigned.
    * a list of expectations created from user-space that depends
    on ctnetlink (if this module is removed, they are deleted).
    * includes USERSPACE in the /proc output for expectations
    that have been created by a user-space helper.

    This patch also modifies ctnetlink to skip including the helper
    name in the Netlink messages if no kernel-space helper is set
    (since no user-space expectation has not kernel-space kernel
    assigned).

    You can access an example user-space FTP conntrack helper at:
    http://people.netfilter.org/pablo/userspace-conntrack-helpers/nf-ftp-helper-userspace-POC.tar.bz

    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Patrick McHardy

    Pablo Neira Ayuso
     

16 Feb, 2010

1 commit


12 Feb, 2010

1 commit


11 Feb, 2010

1 commit


09 Feb, 2010

2 commits

  • As noticed by Jon Masters , the conntrack hash
    size is global and not per namespace, but modifiable at runtime through
    /sys/module/nf_conntrack/hashsize. Changing the hash size will only
    resize the hash in the current namespace however, so other namespaces
    will use an invalid hash size. This can cause crashes when enlarging
    the hashsize, or false negative lookups when shrinking it.

    Move the hash size into the per-namespace data and only use the global
    hash size to initialize the per-namespace value when instanciating a
    new namespace. Additionally restrict hash resizing to init_net for
    now as other namespaces are not handled currently.

    Cc: stable@kernel.org
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     
  • Expectation hashtable size was simply glued to a variable with no code
    to rehash expectations, so it was a bug to allow writing to it.
    Make "expect_hashsize" readonly.

    Signed-off-by: Alexey Dobriyan
    Cc: stable@kernel.org
    Signed-off-by: Patrick McHardy

    Alexey Dobriyan
     

30 Nov, 2009

1 commit


25 Jun, 2009

1 commit

  • RCU barriers, rcu_barrier(), is inserted two places.

    In nf_conntrack_expect.c nf_conntrack_expect_fini() before the
    kmem_cache_destroy(). Firstly to make sure the callback to the
    nf_ct_expect_free_rcu() code is still around. Secondly because I'm
    unsure about the consequence of having in flight
    nf_ct_expect_free_rcu/kmem_cache_free() calls while doing a
    kmem_cache_destroy() slab destroy.

    And in nf_conntrack_extend.c nf_ct_extend_unregister(), inorder to
    wait for completion of callbacks to __nf_ct_ext_free_rcu(), which is
    invoked by __nf_ct_ext_add(). It might be more efficient to call
    rcu_barrier() in nf_conntrack_core.c nf_conntrack_cleanup_net(), but
    thats make it more difficult to read the code (as the callback code
    in located in nf_conntrack_extend.c).

    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Patrick McHardy

    Jesper Dangaard Brouer
     

06 Apr, 2009

1 commit

  • This patch fixes a regression (introduced by myself in commit 19abb7b:
    netfilter: ctnetlink: deliver events for conntracks changed from
    userspace) that results in an expectation re-insertion since
    __nf_ct_expect_check() may return 0 for expectation timer refreshing.

    This patch also removes a unnecessary refcount bump that
    pretended to avoid a possible race condition with event delivery
    and expectation timers (as said, not needed since we hold a
    reference to the object since until we finish the expectation
    setup). This also merges nf_ct_expect_related_report() and
    nf_ct_expect_related() which look basically the same.

    Reported-by: Patrick McHardy
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Patrick McHardy

    Pablo Neira Ayuso
     

26 Mar, 2009

1 commit

  • Use "hlist_nulls" infrastructure we added in 2.6.29 for RCUification of UDP & TCP.

    This permits an easy conversion from call_rcu() based hash lists to a
    SLAB_DESTROY_BY_RCU one.

    Avoiding call_rcu() delay at nf_conn freeing time has numerous gains.

    First, it doesnt fill RCU queues (up to 10000 elements per cpu).
    This reduces OOM possibility, if queued elements are not taken into account
    This reduces latency problems when RCU queue size hits hilimit and triggers
    emergency mode.

    - It allows fast reuse of just freed elements, permitting better use of
    CPU cache.

    - We delete rcu_head from "struct nf_conn", shrinking size of this structure
    by 8 or 16 bytes.

    This patch only takes care of "struct nf_conn".
    call_rcu() is still used for less critical conntrack parts, that may
    be converted later if necessary.

    Signed-off-by: Eric Dumazet
    Signed-off-by: Patrick McHardy

    Eric Dumazet
     

20 Feb, 2009

1 commit


18 Nov, 2008

1 commit

  • As for now, the creation and update of conntracks via ctnetlink do not
    propagate an event to userspace. This can result in inconsistent situations
    if several userspace processes modify the connection tracking table by means
    of ctnetlink at the same time. Specifically, using the conntrack command
    line tool and conntrackd at the same time can trigger unconsistencies.

    This patch also modifies the event cache infrastructure to pass the
    process PID and the ECHO flag to nfnetlink_send() to report back
    to userspace if the process that triggered the change needs so.
    Based on a suggestion from Patrick McHardy.

    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Patrick McHardy

    Pablo Neira Ayuso
     

08 Oct, 2008

6 commits


29 May, 2008

1 commit


26 Mar, 2008

4 commits


11 Mar, 2008

1 commit


01 Feb, 2008

3 commits

  • With the RCU conversion only write_lock usages of nf_conntrack_lock are
    left (except one read_lock that should actually use write_lock in the
    H.323 helper). Switch to a spinlock.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     
  • Use RCU for expectation hash. This doesn't buy much for conntrack
    runtime performance, but allows to reduce the use of nf_conntrack_lock
    for /proc and nf_netlink_conntrack.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     
  • CHECK net/netfilter/nf_conntrack_expect.c
    net/netfilter/nf_conntrack_expect.c:429:13: warning: context imbalance in 'exp_seq_start' - wrong count at exit
    net/netfilter/nf_conntrack_expect.c:441:13: warning: context imbalance in 'exp_seq_stop' - unexpected unlock
    CHECK net/netfilter/nf_log.c
    net/netfilter/nf_log.c:105:13: warning: context imbalance in 'seq_start' - wrong count at exit
    net/netfilter/nf_log.c:125:13: warning: context imbalance in 'seq_stop' - unexpected unlock
    CHECK net/netfilter/nfnetlink_queue.c
    net/netfilter/nfnetlink_queue.c:363:7: warning: symbol 'size' shadows an earlier one
    net/netfilter/nfnetlink_queue.c:217:9: originally declared here
    net/netfilter/nfnetlink_queue.c:847:13: warning: context imbalance in 'seq_start' - wrong count at exit
    net/netfilter/nfnetlink_queue.c:859:13: warning: context imbalance in 'seq_stop' - unexpected unlock

    Signed-off-by: Eric Dumazet
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Eric Dumazet
     

29 Jan, 2008

2 commits

  • Apply Eric Dumazet's jhash optimizations where applicable. Quoting Eric:

    Thanks to jhash, hash value uses full 32 bits. Instead of returning
    hash % size (implying a divide) we return the high 32 bits of the
    (hash * size) that will give results between [0 and size-1] and same
    hash distribution.

    On most cpus, a multiply is less expensive than a divide, by an order
    of magnitude.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     
  • A few netfilter modules provide their own union of IPv4 and IPv6
    address storage. Will unify that in this patch series.

    (1/4): Rename union nf_conntrack_address to union nf_inet_addr and
    move it to x_tables.h.

    Signed-off-by: Jan Engelhardt
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Jan Engelhardt