1. 28 12月, 2011 4 次提交
  2. 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
  3. 24 12月, 2011 1 次提交
  4. 23 12月, 2011 4 次提交
    • F
      netfilter: xt_connbytes: handle negation correctly · 0354b48f
      Florian Westphal 提交于
      "! --connbytes 23:42" should match if the packet/byte count is not in range.
      
      As there is no explict "invert match" toggle in the match structure,
      userspace swaps the from and to arguments
      (i.e., as if "--connbytes 42:23" were given).
      
      However, "what <= 23 && what >= 42" will always be false.
      
      Change things so we use "||" in case "from" is larger than "to".
      
      This change may look like it breaks backwards compatibility when "to" is 0.
      However, older iptables binaries will refuse "connbytes 42:0",
      and current releases treat it to mean "! --connbytes 0:42",
      so we should be fine.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0354b48f
    • P
      netfilter: nf_nat: use hash random for bysource hash · 4d4e61c6
      Patrick McHardy 提交于
      Use nf_conntrack_hash_rnd in NAT bysource hash to avoid hash chain attacks.
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      4d4e61c6
    • P
      netfilter: nf_nat: export NAT definitions to userspace · cbc9f2f4
      Patrick McHardy 提交于
      Export the NAT definitions to userspace. So far userspace (specifically,
      iptables) has been copying the headers files from include/net. Also
      rename some structures and definitions in preparation for IPv6 NAT.
      Since these have never been officially exported, this doesn't affect
      existing userspace code.
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      cbc9f2f4
    • P
      netfilter: rework user-space expectation helper support · 3d058d7b
      Pablo Neira Ayuso 提交于
      This partially reworks bc01befd
      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: NSam Roberts <vieuxtech@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      3d058d7b
  5. 20 12月, 2011 3 次提交
  6. 18 12月, 2011 3 次提交
  7. 17 12月, 2011 1 次提交
  8. 13 12月, 2011 1 次提交
    • M
      IPVS: Modify the SH scheduler to use weights · 76ad94fc
      Michael Maxim 提交于
      Modify the algorithm to build the source hashing hash table to add
      extra slots for destinations with higher weight. This has the effect
      of allowing an IPVS SH user to give more connections to hosts that
      have been configured to have a higher weight.
      
      The reason for the Kconfig change is because the size of the hash table
      becomes more relevant/important if you decide to use the weights in the
      manner this patch lets you. It would be conceivable that someone might
      need to increase the size of that table to accommodate their
      configuration, so it will be handy to be able to do that through the
      regular configuration system instead of editing the source.
      Signed-off-by: NMichael Maxim <mike@okcupid.com>
      Signed-off-by: NSimon Horman <horms@verge.net.au>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      76ad94fc
  9. 12 12月, 2011 1 次提交
  10. 04 12月, 2011 1 次提交
  11. 02 12月, 2011 1 次提交
  12. 24 11月, 2011 1 次提交
  13. 23 11月, 2011 1 次提交
  14. 22 11月, 2011 3 次提交
    • P
      netfilter: nf_conntrack: make event callback registration per-netns · 70e9942f
      Pablo Neira Ayuso 提交于
      This patch fixes an oops that can be triggered following this recipe:
      
      0) make sure nf_conntrack_netlink and nf_conntrack_ipv4 are loaded.
      1) container is started.
      2) connect to it via lxc-console.
      3) generate some traffic with the container to create some conntrack
         entries in its table.
      4) stop the container: you hit one oops because the conntrack table
         cleanup tries to report the destroy event to user-space but the
         per-netns nfnetlink socket has already gone (as the nfnetlink
         socket is per-netns but event callback registration is global).
      
      To fix this situation, we make the ctnl_notifier per-netns so the
      callback is registered/unregistered if the container is
      created/destroyed.
      
      Alex Bligh and Alexey Dobriyan originally proposed one small patch to
      check if the nfnetlink socket is gone in nfnetlink_has_listeners,
      but this is a very visited path for events, thus, it may reduce
      performance and it looks a bit hackish to check for the nfnetlink
      socket only to workaround this situation. As a result, I decided
      to follow the bigger path choice, which seems to look nicer to me.
      
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Reported-by: NAlex Bligh <alex@alex.org.uk>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      70e9942f
    • E
      netfilter: use jump_label for nf_hooks · a2d7ec58
      Eric Dumazet 提交于
      On configs where CONFIG_JUMP_LABEL=y, we can replace in fast path a
      load/compare/conditional jump by a single jump with no dcache reference.
      
      Jump target is modified as soon as nf_hooks[pf][hook] switches from
      empty state to non empty states. jump_label state is kept outside of
      nf_hooks array so has no cost on cpu caches.
      
      This patch removes the test on CONFIG_NETFILTER_DEBUG : No need to call
      nf_hook_slow() at all if nf_hooks[pf][hook] is empty, this didnt give
      useful information, but slowed down things a lot.
      Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
      CC: Patrick McHardy <kaber@trash.net>
      CC: Pablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a2d7ec58
    • J
      netfilter: ipset: suppress compile-time warnings in ip_set_hash_ipport*.c · 648ae8e5
      Jozsef Kadlecsik 提交于
      warning: 'ip_to' may be used uninitialized in this function
      Signed-off-by: NJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      648ae8e5
  15. 01 11月, 2011 10 次提交
  16. 13 10月, 2011 1 次提交
  17. 06 10月, 2011 1 次提交
  18. 03 10月, 2011 1 次提交