Skip to content
Snippets Groups Projects
  1. May 10, 2024
    • Florian Westphal's avatar
      netfilter: nf_tables: allow clone callbacks to sleep · fa23e0d4
      Florian Westphal authored
      
      Sven Auhagen reports transaction failures with following error:
        ./main.nft:13:1-26: Error: Could not process rule: Cannot allocate memory
        percpu: allocation failed, size=16 align=8 atomic=1, atomic alloc failed, no space left
      
      This points to failing pcpu allocation with GFP_ATOMIC flag.
      However, transactions happen from user context and are allowed to sleep.
      
      One case where we can call into percpu allocator with GFP_ATOMIC is
      nft_counter expression.
      
      Normally this happens from control plane, so this could use GFP_KERNEL
      instead.  But one use case, element insertion from packet path,
      needs to use GFP_ATOMIC allocations (nft_dynset expression).
      
      At this time, .clone callbacks always use GFP_ATOMIC for this reason.
      
      Add gfp_t argument to the .clone function and pass GFP_KERNEL or
      GFP_ATOMIC flag depending on context, this allows all clone memory
      allocations to sleep for the normal (transaction) case.
      
      Cc: Sven Auhagen <sven.auhagen@voleatech.de>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      fa23e0d4
    • Florian Westphal's avatar
      selftests: netfilter: add packetdrill based conntrack tests · a8a388c2
      Florian Westphal authored
      
      Add a new test script that uses packetdrill tool to exercise conntrack
      state machine.
      
      Needs ip/ip6tables and conntrack tool (to check if we have an entry in
      the expected state).
      
      Test cases added here cover following scenarios:
      1. already-acked (retransmitted) packets are not tagged as INVALID
      2. RST packet coming when conntrack is already closing (FIN/CLOSE_WAIT)
        transitions conntrack to CLOSE even if the RST is not an exact match
      3. RST packets with out-of-window sequence numbers are marked as INVALID
      4. SYN+Challenge ACK: check that challenge ack is allowed to pass
      5. Old SYN/ACK: check conntrack handles the case where SYN is answered
        with SYN/ACK for an old, previous connection attempt
      6. Check SYN reception while in ESTABLISHED state generates a challenge
         ack, RST response clears 'outdated' state + next SYN retransmit gets
         us into 'SYN_RECV' conntrack state.
      
      Tests get run twice, once with ipv4 and once with ipv6.
      
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      a8a388c2
    • Florian Westphal's avatar
      netfilter: nft_set_pipapo: remove dirty flag · 532aec7e
      Florian Westphal authored
      
      After previous change:
       ->clone exists: ->dirty is always true
       ->clone == NULL ->dirty is always false
      
      So remove this flag.
      
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Reviewed-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      532aec7e
    • Florian Westphal's avatar
      netfilter: nft_set_pipapo: move cloning of match info to insert/removal path · 3f1d886c
      Florian Westphal authored
      
      This set type keeps two copies of the sets' content,
         priv->match (live version, used to match from packet path)
         priv->clone (work-in-progress version of the 'future' priv->match).
      
      All additions and removals are done on priv->clone.  When transaction
      completes, priv->clone becomes priv->match and a new clone is allocated
      for use by next transaction.
      
      Problem is that the cloning requires GFP_KERNEL allocations but we
      cannot fail at either commit or abort time.
      
      This patch defers the clone until we get an insertion or removal
      request.  This allows us to handle OOM situations correctly.
      
      This also allows to remove ->dirty in a followup change:
      
      If ->clone exists, ->dirty is always true
      If ->clone is NULL, ->dirty is always false, no elements were added
      or removed (except catchall elements which are external to the specific
      set backend).
      
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Reviewed-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      3f1d886c
    • Florian Westphal's avatar
      netfilter: nft_set_pipapo: prepare pipapo_get helper for on-demand clone · a2381067
      Florian Westphal authored
      
      The helper uses priv->clone unconditionally which will fail once we do
      the clone conditionally on first insert or removal.
      
      'nft get element' from userspace needs to use priv->match since this
      runs from rcu read side lock section.
      
      Prepare for this by passing the match backend data as argument.
      
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Reviewed-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      a2381067
  2. May 06, 2024
  3. May 05, 2024
  4. May 03, 2024
Loading