01 Feb, 2008

40 commits

  • Constify data tables (predominantly in nf_conntrack_h323_types.c, but
    also a few in nf_conntrack_h323_asn1.c) and use const qualifiers on
    variables where possible in the h323 sources.

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

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

    Alexey Dobriyan
     
  • Propagate netns together with AF down to ->start/->next/->stop
    iterators. Choose table based on netns and AF for showing.

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

    Alexey Dobriyan
     
  • There are many small but still wrong things with /proc/net/*_tables_*
    so I decided to do overhaul simultaneously making it more suitable for
    per-netns /proc/net/*_tables_* implementation.

    Fix
    a) xt_get_idx() duplicating now standard seq_list_start/seq_list_next
    iterators
    b) tables/matches/targets list was chosen again and again on every ->next
    c) multiple useless "af >= NPROTO" checks -- we simple don't supply invalid
    AFs there and registration function should BUG_ON instead.

    Regardless, the one in ->next() is the most useless -- ->next doesn't
    run at all if ->start fails.
    d) Don't use mutex_lock_interruptible() -- it can fail and ->stop is
    executed even if ->start failed, so unlock without lock is possible.

    As side effect, streamline code by splitting xt_tgt_ops into xt_target_ops,
    xt_matches_ops, xt_tables_ops.

    xt_tables_ops hooks will be changed by per-netns code. Code of
    xt_matches_ops, xt_target_ops is identical except the list chosen for
    iterating, but I think consolidating code for two files not worth it
    given "<< 16" hacks needed for it.

    [Patrick: removed unused enum in x_tables.c]

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

    Alexey Dobriyan
     
  • Introduces the xt_hashlimit match revision 1. It adds support for
    kernel-level inversion and grouping source and/or destination IP
    addresses, allowing to limit on a per-subnet basis. While this would
    technically obsolete xt_limit, xt_hashlimit is a more expensive due
    to the hashbucketing.

    Kernel-level inversion: Previously you had to do user-level inversion:

    iptables -N foo
    iptables -A foo -m hashlimit --hashlimit(-upto) 5/s -j RETURN
    iptables -A foo -j DROP
    iptables -A INPUT -j foo

    now it is simpler:

    iptables -A INPUT -m hashlimit --hashlimit-over 5/s -j DROP

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

    Jan Engelhardt
     
  • Signed-off-by: Ilpo Järvinen
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Ilpo Järvinen
     
  • It's unused static inline.

    Signed-off-by: Ilpo Järvinen
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Ilpo Järvinen
     
  • The following feature was submitted some months ago. It forces the dump
    of mark during the connection destruction event. The induced load is
    quiet small and the patch is usefull to provide an easy way to filter
    event on user side without having to keep an hash in userspace.

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

    Eric Leblond
     
  • -total: 81 errors, 3 warnings, 876 lines checked
    +total: 44 errors, 3 warnings, 876 lines checked

    There is still work to be done, but that's for another patch.

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

    Jan Engelhardt
     
  • Since we're using RCU, all users of nf_nat_lock take a write_lock.
    Switch it to a spinlock.

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

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

    Patrick McHardy
     
  • Rename all "conntrack" variables to "ct" for more consistency and
    avoiding some overly long lines.

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

    Patrick McHardy
     
  • early_drop() is only called *very* rarely, unfortunately gcc inlines it
    into the hotpath because there is only a single caller. Explicitly mark
    it noinline.

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

    Patrick McHardy
     
  • Reorder struct nf_conntrack_l4proto so all members used during packet
    processing are in the same cacheline.

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

    Patrick McHardy
     
  • Avoid calling jhash three times and hash the entire tuple in one go.

    __hash_conntrack | -485 # 760 -> 275, # inlines: 3 -> 1, size inlines: 717 -> 252
    1 function changed, 485 bytes removed

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

    Patrick McHardy
     
  • nf_ct_tuple_src_equal() and nf_ct_tuple_dst_equal() both compare the protocol
    numbers. Unfortunately gcc doesn't optimize out the second comparison, so
    remove it and prefix both functions with __ to indicate that they should not
    be used directly.

    Saves another 16 byte of text in __nf_conntrack_find() on x86_64:

    nf_conntrack_tuple_taken | -20 # 320 -> 300, size inlines: 181 -> 161
    __nf_conntrack_find | -16 # 267 -> 251, size inlines: 127 -> 115
    __nf_conntrack_confirm | -40 # 875 -> 835, size inlines: 570 -> 537
    3 functions changed, 76 bytes removed

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

    Patrick McHardy
     
  • Ignoring specific entries in __nf_conntrack_find() is only needed by NAT
    for nf_conntrack_tuple_taken(). Remove it from __nf_conntrack_find()
    and make nf_conntrack_tuple_taken() search the hash itself.

    Saves 54 bytes of text in the hotpath on x86_64:

    __nf_conntrack_find | -54 # 321 -> 267, # inlines: 3 -> 2, size inlines: 181 -> 127
    nf_conntrack_tuple_taken | +305 # 15 -> 320, lexblocks: 0 -> 3, # inlines: 0 -> 3, size inlines: 0 -> 181
    nf_conntrack_find_get | -2 # 90 -> 88
    3 functions changed, 305 bytes added, 56 bytes removed, diff: +249

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

    Patrick McHardy
     
  • 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
     
  • 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
     
  • The conntrack is unconfirmed, so we have an exclusive reference, which
    means that the write_lock is definitely unneeded. A read_lock used to
    be needed for the helper lookup, but since we're using RCU for helpers
    now rcu_read_lock is enough.

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

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

    Patrick McHardy
     
  • Don't skip accounting for conntracks with the FIXED_TIMEOUT bit.

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

    Patrick McHardy
     
  • Properly drop nf_conntrack_lock on tuple parsing error.

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

    Patrick McHardy
     
  • CHECK net/ipv6/netfilter/nf_conntrack_reasm.c
    net/ipv6/netfilter/nf_conntrack_reasm.c:77:18: warning: symbol 'nf_ct_ipv6_sysctl_table' was not declared. Should it be static?
    net/ipv6/netfilter/nf_conntrack_reasm.c:586:16: warning: symbol 'nf_ct_frag6_gather' was not declared. Should it be static?
    net/ipv6/netfilter/nf_conntrack_reasm.c:662:6: warning: symbol 'nf_ct_frag6_output' was not declared. Should it be static?
    net/ipv6/netfilter/nf_conntrack_reasm.c:683:5: warning: symbol 'nf_ct_frag6_kfree_frags' was not declared. Should it be static?
    net/ipv6/netfilter/nf_conntrack_reasm.c:698:5: warning: symbol 'nf_ct_frag6_init' was not declared. Should it be static?
    net/ipv6/netfilter/nf_conntrack_reasm.c:717:6: warning: symbol 'nf_ct_frag6_cleanup' was not declared. Should it be static?

    Based on patch by Stephen Hemminger with suggestions by Yasuyuki KOZAKAI.

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

    Patrick McHardy
     
  • CHECK net/ipv4/netfilter/ip_tables.c
    net/ipv4/netfilter/ip_tables.c:1453:8: warning: incorrect type in argument 3 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1453:8: expected int *size
    net/ipv4/netfilter/ip_tables.c:1453:8: got unsigned int [usertype] *size
    net/ipv4/netfilter/ip_tables.c:1458:44: warning: incorrect type in argument 3 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1458:44: expected int *size
    net/ipv4/netfilter/ip_tables.c:1458:44: got unsigned int [usertype] *size
    net/ipv4/netfilter/ip_tables.c:1603:2: warning: incorrect type in argument 2 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1603:2: expected unsigned int *i
    net/ipv4/netfilter/ip_tables.c:1603:2: got int *
    net/ipv4/netfilter/ip_tables.c:1627:8: warning: incorrect type in argument 3 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1627:8: expected int *size
    net/ipv4/netfilter/ip_tables.c:1627:8: got unsigned int *size
    net/ipv4/netfilter/ip_tables.c:1634:40: warning: incorrect type in argument 3 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1634:40: expected int *size
    net/ipv4/netfilter/ip_tables.c:1634:40: got unsigned int *size
    net/ipv4/netfilter/ip_tables.c:1653:8: warning: incorrect type in argument 5 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1653:8: expected unsigned int *i
    net/ipv4/netfilter/ip_tables.c:1653:8: got int *
    net/ipv4/netfilter/ip_tables.c:1666:2: warning: incorrect type in argument 2 (different signedness)
    net/ipv4/netfilter/ip_tables.c:1666:2: expected unsigned int *i
    net/ipv4/netfilter/ip_tables.c:1666:2: got int *
    CHECK net/ipv4/netfilter/arp_tables.c
    net/ipv4/netfilter/arp_tables.c:1285:40: warning: incorrect type in argument 3 (different signedness)
    net/ipv4/netfilter/arp_tables.c:1285:40: expected int *size
    net/ipv4/netfilter/arp_tables.c:1285:40: got unsigned int *size
    net/ipv4/netfilter/arp_tables.c:1543:44: warning: incorrect type in argument 3 (different signedness)
    net/ipv4/netfilter/arp_tables.c:1543:44: expected int *size
    net/ipv4/netfilter/arp_tables.c:1543:44: got unsigned int [usertype] *size
    CHECK net/ipv6/netfilter/ip6_tables.c
    net/ipv6/netfilter/ip6_tables.c:1481:8: warning: incorrect type in argument 3 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1481:8: expected int *size
    net/ipv6/netfilter/ip6_tables.c:1481:8: got unsigned int [usertype] *size
    net/ipv6/netfilter/ip6_tables.c:1486:44: warning: incorrect type in argument 3 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1486:44: expected int *size
    net/ipv6/netfilter/ip6_tables.c:1486:44: got unsigned int [usertype] *size
    net/ipv6/netfilter/ip6_tables.c:1631:2: warning: incorrect type in argument 2 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1631:2: expected unsigned int *i
    net/ipv6/netfilter/ip6_tables.c:1631:2: got int *
    net/ipv6/netfilter/ip6_tables.c:1655:8: warning: incorrect type in argument 3 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1655:8: expected int *size
    net/ipv6/netfilter/ip6_tables.c:1655:8: got unsigned int *size
    net/ipv6/netfilter/ip6_tables.c:1662:40: warning: incorrect type in argument 3 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1662:40: expected int *size
    net/ipv6/netfilter/ip6_tables.c:1662:40: got unsigned int *size
    net/ipv6/netfilter/ip6_tables.c:1680:8: warning: incorrect type in argument 5 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1680:8: expected unsigned int *i
    net/ipv6/netfilter/ip6_tables.c:1680:8: got int *
    net/ipv6/netfilter/ip6_tables.c:1693:2: warning: incorrect type in argument 2 (different signedness)
    net/ipv6/netfilter/ip6_tables.c:1693:2: expected unsigned int *i
    net/ipv6/netfilter/ip6_tables.c:1693:2: got int *

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

    Patrick McHardy
     
  • net/ipv4/netfilter/ipt_recent.c:215:17: warning: symbol 't' shadows an earlier one
    net/ipv4/netfilter/ipt_recent.c:179:22: originally declared here
    net/ipv4/netfilter/ipt_recent.c:322:13: warning: context imbalance in 'recent_seq_start' - wrong count at exit
    net/ipv4/netfilter/ipt_recent.c:354:13: warning: context imbalance in 'recent_seq_stop' - unexpected unlock

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

    Patrick McHardy
     
  • Sparse complains when a function is not really static. Putting static
    on the function prototype is not enough.

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

    Stephen Hemminger
     
  • Some lock annotations, and make initializers static.

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

    Stephen Hemminger
     
  • Teach sparse about locking here, and fix signed/unsigned warnings.

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

    Stephen Hemminger
     
  • Signed-off-by: Stephen Hemminger
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Stephen Hemminger
     
  • The hashtable size is really unsigned so sparse complains when you pass
    a signed integer. Change all uses to make it consistent.

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

    Stephen Hemminger
     
  • Signed-off-by: Stephen Hemminger
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Stephen Hemminger
     
  • Add support for ranges to the new revision. This doesn't affect
    compatibility since the new revision was not released yet.

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

    Jan Engelhardt
     
  • The TCPMSS target in Xtables should consider the MTU of the reverse
    route on forwarded packets as part of the path MTU.

    Point in case: IN=ppp0, OUT=eth0. MSS set to 1460 in spite of MTU of
    ppp0 being 1392.

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

    Jan Engelhardt
     
  • When number of entries exceeds number of initial entries, foo-tables code
    will pin table module. But during table unregister on netns stop,
    that additional pin was forgotten.

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

    Alexey Dobriyan
     
  • Signed-off-by: Alexey Dobriyan
    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     
  • * Propagate netns from userspace.
    * arpt_register_table() registers table in supplied netns.

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

    Alexey Dobriyan
     
  • Now it's possible to list and manipulate per-netns ip6tables rules.
    Filtering decisions are based on init_net's table so far.

    P.S.: remove init_net check in inet6_create() to see the effect

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

    Alexey Dobriyan
     
  • * Propagate netns from userspace down to xt_find_table_lock()
    * Register ip6 tables in netns (modules still use init_net)

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

    Alexey Dobriyan