1. 18 1月, 2011 2 次提交
    • F
      netfilter: allow NFQUEUE bypass if no listener is available · 94b27cc3
      Florian Westphal 提交于
      If an skb is to be NF_QUEUE'd, but no program has opened the queue, the
      packet is dropped.
      
      This adds a v2 target revision of xt_NFQUEUE that allows packets to
      continue through the ruleset instead.
      
      Because the actual queueing happens outside of the target context, the
      'bypass' flag has to be communicated back to the netfilter core.
      
      Unfortunately the only choice to do this without adding a new function
      argument is to use the target function return value (i.e. the verdict).
      
      In the NF_QUEUE case, the upper 16bit already contain the queue number
      to use.  The previous patch reduced NF_VERDICT_MASK to 0xff, i.e.
      we now have extra room for a new flag.
      
      If a hook issued a NF_QUEUE verdict, then the netfilter core will
      continue packet processing if the queueing hook
      returns -ESRCH (== "this queue does not exist") and the new
      NF_VERDICT_FLAG_QUEUE_BYPASS flag is set in the verdict value.
      
      Note: If the queue exists, but userspace does not consume packets fast
      enough, the skb will still be dropped.
      Signed-off-by: NFlorian Westphal <fwestphal@astaro.com>
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      94b27cc3
    • F
      netfilter: reduce NF_VERDICT_MASK to 0xff · f615df76
      Florian Westphal 提交于
      NF_VERDICT_MASK is currently 0xffff. This is because the upper
      16 bits are used to store errno (for NF_DROP) or the queue number
      (NF_QUEUE verdict).
      
      As there are up to 0xffff different queues available, there is no more
      room to store additional flags.
      
      At the moment there are only 6 different verdicts, i.e. we can reduce
      NF_VERDICT_MASK to 0xff to allow storing additional flags in the 0xff00 space.
      
      NF_VERDICT_BITS would then be reduced to 8, but because the value is
      exported to userspace, this might cause breakage; e.g.:
      
      e.g. 'queuenr = (1 << NF_VERDICT_BITS) | NF_QUEUE'  would now break.
      
      Thus, remove NF_VERDICT_BITS usage in the kernel and move the old value
      to the 'userspace compat' section.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      f615df76
  2. 18 11月, 2010 1 次提交
  3. 16 11月, 2010 1 次提交
  4. 12 11月, 2010 1 次提交
    • E
      netfilter: NF_HOOK_COND has wrong conditional · ac5aa2e3
      Eric Paris 提交于
      The NF_HOOK_COND returns 0 when it shouldn't due to what I believe to be an
      error in the code as the order of operations is not what was intended.  C will
      evalutate == before =.  Which means ret is getting set to the bool result,
      rather than the return value of the function call.  The code says
      
      if (ret = function() == 1)
      when it meant to say:
      if ((ret = function()) == 1)
      
      Normally the compiler would warn, but it doesn't notice it because its
      a actually complex conditional and so the wrong code is wrapped in an explict
      set of () [exactly what the compiler wants you to do if this was intentional].
      Fixing this means that errors when netfilter denies a packet get propagated
      back up the stack rather than lost.
      
      Problem introduced by commit 2249065f (netfilter: get rid of the grossness
      in netfilter.h).
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Cc: stable@kernel.org
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      ac5aa2e3
  5. 19 2月, 2010 1 次提交
  6. 15 2月, 2010 2 次提交
  7. 02 2月, 2010 1 次提交
  8. 05 11月, 2009 1 次提交
  9. 01 10月, 2009 1 次提交
  10. 08 10月, 2008 3 次提交
  11. 22 5月, 2008 1 次提交
  12. 14 4月, 2008 2 次提交
    • P
      [NETFILTER]: Add partial checksum validation helper · d63a6507
      Patrick McHardy 提交于
      Move the UDP-Lite conntrack checksum validation to a generic helper
      similar to nf_checksum() and make it fall back to nf_checksum()
      in case the full packet is to be checksummed and hardware checksums
      are available. This is to be used by DCCP conntrack, which also
      needs to verify partial checksums.
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      d63a6507
    • A
      [NETFILTER]: ip_tables: per-netns FILTER/MANGLE/RAW tables for real · 666953df
      Alexey Dobriyan 提交于
      Commit 9335f047 aka
      "[NETFILTER]: ip_tables: per-netns FILTER, MANGLE, RAW"
      added per-netns _view_ of iptables rules. They were shown to user, but
      ignored by filtering code. Now that it's possible to at least ping loopback,
      per-netns tables can affect filtering decisions.
      
      netns is taken in case of
      	PRE_ROUTING, LOCAL_IN -- from in device,
      	POST_ROUTING, LOCAL_OUT -- from out device,
      	FORWARD -- from in device which should be equal to out device's netns.
      		   This code is relatively new, so BUG_ON was plugged.
      
      Wrappers were added to a) keep code the same from CONFIG_NET_NS=n users
      (overwhelming majority), b) consolidate code in one place -- similar
      changes will be done in ipv6 and arp netfilter code.
      Signed-off-by: NAlexey Dobriyan <adobriyan@sw.ru>
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      666953df
  13. 26 3月, 2008 1 次提交
  14. 28 2月, 2008 1 次提交
  15. 20 2月, 2008 1 次提交
  16. 29 1月, 2008 15 次提交
  17. 16 10月, 2007 2 次提交
  18. 11 9月, 2007 1 次提交
    • N
      [NETFILTER]: Fix/improve deadlock condition on module removal netfilter · 16fcec35
      Neil Horman 提交于
      So I've had a deadlock reported to me.  I've found that the sequence of
      events goes like this:
      
      1) process A (modprobe) runs to remove ip_tables.ko
      
      2) process B (iptables-restore) runs and calls setsockopt on a netfilter socket,
      increasing the ip_tables socket_ops use count
      
      3) process A acquires a file lock on the file ip_tables.ko, calls remove_module
      in the kernel, which in turn executes the ip_tables module cleanup routine,
      which calls nf_unregister_sockopt
      
      4) nf_unregister_sockopt, seeing that the use count is non-zero, puts the
      calling process into uninterruptible sleep, expecting the process using the
      socket option code to wake it up when it exits the kernel
      
      4) the user of the socket option code (process B) in do_ipt_get_ctl, calls
      ipt_find_table_lock, which in this case calls request_module to load
      ip_tables_nat.ko
      
      5) request_module forks a copy of modprobe (process C) to load the module and
      blocks until modprobe exits.
      
      6) Process C. forked by request_module process the dependencies of
      ip_tables_nat.ko, of which ip_tables.ko is one.
      
      7) Process C attempts to lock the request module and all its dependencies, it
      blocks when it attempts to lock ip_tables.ko (which was previously locked in
      step 3)
      
      Theres not really any great permanent solution to this that I can see, but I've
      developed a two part solution that corrects the problem
      
      Part 1) Modifies the nf_sockopt registration code so that, instead of using a
      use counter internal to the nf_sockopt_ops structure, we instead use a pointer
      to the registering modules owner to do module reference counting when nf_sockopt
      calls a modules set/get routine.  This prevents the deadlock by preventing set 4
      from happening.
      
      Part 2) Enhances the modprobe utilty so that by default it preforms non-blocking
      remove operations (the same way rmmod does), and add an option to explicity
      request blocking operation.  So if you select blocking operation in modprobe you
      can still cause the above deadlock, but only if you explicity try (and since
      root can do any old stupid thing it would like....  :)  ).
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      16fcec35
  19. 11 7月, 2007 1 次提交
  20. 26 4月, 2007 1 次提交