1. 25 12月, 2011 2 次提交
    • P
      netfilter: xtables: add nfacct match to support extended accounting · ceb98d03
      Pablo Neira Ayuso 提交于
      This patch adds the match that allows to perform extended
      accounting. It requires the new nfnetlink_acct infrastructure.
      
       # iptables -I INPUT -p tcp --sport 80 -m nfacct --nfacct-name http-traffic
       # iptables -I OUTPUT -p tcp --dport 80 -m nfacct --nfacct-name http-traffic
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      ceb98d03
    • P
      netfilter: add extended accounting infrastructure over nfnetlink · 94139027
      Pablo Neira Ayuso 提交于
      We currently have two ways to account traffic in netfilter:
      
      - iptables chain and rule counters:
      
       # iptables -L -n -v
      Chain INPUT (policy DROP 3 packets, 867 bytes)
       pkts bytes target     prot opt in     out     source               destination
          8  1104 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0
      
      - use flow-based accounting provided by ctnetlink:
      
       # conntrack -L
      tcp      6 431999 ESTABLISHED src=192.168.1.130 dst=212.106.219.168 sport=58152 dport=80 packets=47 bytes=7654 src=212.106.219.168 dst=192.168.1.130 sport=80 dport=58152 packets=49 bytes=66340 [ASSURED] mark=0 use=1
      
      While trying to display real-time accounting statistics, we require
      to pool the kernel periodically to obtain this information. This is
      OK if the number of flows is relatively low. However, in case that
      the number of flows is huge, we can spend a considerable amount of
      cycles to iterate over the list of flows that have been obtained.
      
      Moreover, if we want to obtain the sum of the flow accounting results
      that match some criteria, we have to iterate over the whole list of
      existing flows, look for matchings and update the counters.
      
      This patch adds the extended accounting infrastructure for
      nfnetlink which aims to allow displaying real-time traffic accounting
      without the need of complicated and resource-consuming implementation
      in user-space. Basically, this new infrastructure allows you to create
      accounting objects. One accounting object is composed of packet and
      byte counters.
      
      In order to manipulate create accounting objects, you require the
      new libnetfilter_acct library. It contains several examples of use:
      
      libnetfilter_acct/examples# ./nfacct-add http-traffic
      libnetfilter_acct/examples# ./nfacct-get
      http-traffic = { pkts = 000000000000,   bytes = 000000000000 };
      
      Then, you can use one of this accounting objects in several iptables
      rules using the new nfacct match (which comes in a follow-up patch):
      
       # iptables -I INPUT -p tcp --sport 80 -m nfacct --nfacct-name http-traffic
       # iptables -I OUTPUT -p tcp --dport 80 -m nfacct --nfacct-name http-traffic
      
      The idea is simple: if one packet matches the rule, the nfacct match
      updates the counters.
      
      Thanks to Patrick McHardy, Eric Dumazet, Changli Gao for reviewing and
      providing feedback for this contribution.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      94139027
  2. 24 12月, 2011 1 次提交
  3. 23 12月, 2011 8 次提交
  4. 18 12月, 2011 3 次提交
  5. 13 12月, 2011 2 次提交
  6. 05 12月, 2011 5 次提交
    • F
      ipv6: add ip6_route_lookup · ea6e574e
      Florian Westphal 提交于
      like rt6_lookup, but allows caller to pass in flowi6 structure.
      Will be used by the upcoming ipv6 netfilter reverse path filter
      match.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      ea6e574e
    • F
      netfilter: add ipv4 reverse path filter match · 8f97339d
      Florian Westphal 提交于
      This tries to do the same thing as fib_validate_source(), but differs
      in several aspects.
      
      The most important difference is that the reverse path filter built into
      fib_validate_source uses the oif as iif when performing the reverse
      lookup.  We do not do this, as the oif is not yet known by the time the
      PREROUTING hook is invoked.
      
      We can't wait until FORWARD chain because by the time FORWARD is invoked
      ipv4 forward path may have already sent icmp messages is response
      to to-be-discarded-via-rpfilter packets.
      
      To avoid the such an additional lookup in PREROUTING, Patrick McHardy
      suggested to attach the path information directly in the match
      (i.e., just do what the standard ipv4 path does a bit earlier in PREROUTING).
      
      This works, but it also has a few caveats. Most importantly, when using
      marks in PREROUTING to re-route traffic based on the nfmark, -m rpfilter
      would have to be used after the nfmark has been set; otherwise the nfmark
      would have no effect (because the route is already attached).
      
      Another problem would be interaction with -j TPROXY, as this target sets an
      nfmark and uses ACCEPT instead of continue, i.e. such a version of
      -m rpfilter cannot be used for the initial to-be-intercepted packets.
      
      In case in turns out that the oif is required, we can add Patricks
      suggestion with a new match option (e.g. --rpf-use-oif) to keep ruleset
      compatibility.
      
      Another difference to current builtin ipv4 rpfilter is that packets subject to ipsec
      transformation are not automatically excluded. If you want this, simply
      combine -m rpfilter with the policy match.
      
      Packets arriving on loopback interfaces always match.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      8f97339d
    • F
      net: ipv4: export fib_lookup and fib_table_lookup · 6fc01438
      Florian Westphal 提交于
      The reverse path filter module will use fib_lookup.
      
      If CONFIG_IP_MULTIPLE_TABLES is not set, fib_lookup is
      only a static inline helper that calls fib_table_lookup,
      so export that too.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      6fc01438
    • E
      tcp: tcp_sendmsg() page recycling · 761965ea
      Eric Dumazet 提交于
      If our TCP_PAGE(sk) is not shared (page_count() == 1), we can set page
      offset to 0.
      
      This permits better filling of the pages on small to medium tcp writes.
      
      "tbench 16" results on my dev server (2x4x2 machine) :
      
      Before : 3072 MB/s
      After  : 3146 MB/s  (2.4 % gain)
      Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      761965ea
    • E
      tcp: take care of misalignments · 117632e6
      Eric Dumazet 提交于
      We discovered that TCP stack could retransmit misaligned skbs if a
      malicious peer acknowledged sub MSS frame. This currently can happen
      only if output interface is non SG enabled : If SG is enabled, tcp
      builds headless skbs (all payload is included in fragments), so the tcp
      trimming process only removes parts of skb fragments, header stay
      aligned.
      
      Some arches cant handle misalignments, so force a head reallocation and
      shrink headroom to MAX_TCP_HEADER.
      
      Dont care about misaligments on x86 and PPC (or other arches setting
      NET_IP_ALIGN to 0)
      
      This patch introduces __pskb_copy() which can specify the headroom of
      new head, and pskb_copy() becomes a wrapper on top of __pskb_copy()
      Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      117632e6
  7. 04 12月, 2011 15 次提交
  8. 03 12月, 2011 4 次提交