1. 09 Sep, 2024 2 commits
  2. 28 Aug, 2024 2 commits
  3. 27 Aug, 2024 2 commits
    • wangfe's avatar
      xfrm: add SA information to the offloaded packet · e7cd191f
      wangfe authored
      In packet offload mode, append Security Association (SA) information
      to each packet, replicating the crypto offload implementation.
      The XFRM_XMIT flag is set to enable packet to be returned immediately
      from the validate_xmit_xfrm function, thus aligning with the existing
      code path for packet offload mode.
      
      This SA info helps HW offload match packets to their correct security
      policies. The XFRM interface ID is included, which is crucial in setups
      with multiple XFRM interfaces where source/destination addresses alone
      can't pinpoint the right policy.
      Signed-off-by: default avatarwangfe <wangfe@google.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      e7cd191f
    • Steffen Klassert's avatar
      Merge branch 'xfrm: speed up policy insertions' · 5ce90c84
      Steffen Klassert authored
      Florian Westphal says:
      
      ====================
      Policy insertions do not scale well, due to both a lienar list walk
      to find the insertion spot and another list walk to set the 'pos' value
      (a tie-breaker to detect which policy is older when there is ambiguity
      as to which one should be matched).
      
      First patch gets rid of the second list walk on insert.
      Rest of the patches get rid of the insertion walk.
      
      This list walk was only needed because when I moved the policy db
      implementation to rbtree I retained the old insertion method for the
      sake of XFRM_MIGRATE.
      
      Switching that to tree-based lookup avoids the need for the full
      list search.
      
      After this, insertion of a policy is largely independent of the number
      of pre-existing policies as long as they do not share the same source/
      destination networks.
      
      Note that this is compile tested only as I did not find any
      tests for XFRM_MIGRATE.
      ====================
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      5ce90c84
  4. 24 Aug, 2024 4 commits
    • Florian Westphal's avatar
      xfrm: policy: remove remaining use of inexact list · a54ad727
      Florian Westphal authored
      No consumers anymore, remove it.  After this, insertion of policies
      no longer require list walk of all inexact policies but only those
      that are reachable via the candidate sets.
      
      This gives almost linear insertion speeds provided the inserted
      policies are for non-overlapping networks.
      
      Before:
      Inserted 1000   policies in 70 ms
      Inserted 10000  policies in 1155 ms
      Inserted 100000 policies in 216848 ms
      
      After:
      Inserted 1000   policies in 56 ms
      Inserted 10000  policies in 478 ms
      Inserted 100000 policies in 4580 ms
      
      Insertion of 1m entries takes about ~40s after this change
      on my test vm.
      
      Cc: Noel Kuntze <noel@familie-kuntze.de>
      Cc: Tobias Brunner <tobias@strongswan.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      a54ad727
    • Florian Westphal's avatar
      xfrm: switch migrate to xfrm_policy_lookup_bytype · 563d5ca9
      Florian Westphal authored
      XFRM_MIGRATE still uses the old lookup method:
      first check the bydst hash table, then search the list of all the other
      policies.
      
      Switch MIGRATE to use the same lookup function as the packetpath.
      
      This is done to remove the last remaining users of the pernet
      xfrm.policy_inexact lists with the intent of removing this list.
      
      After this patch, policies are still added to the list on insertion
      and they are rehashed as-needed but no single API makes use of these
      anymore.
      
      This change is compile tested only.
      
      Cc: Tobias Brunner <tobias@strongswan.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      563d5ca9
    • Florian Westphal's avatar
      xfrm: policy: don't iterate inexact policies twice at insert time · 33f611cf
      Florian Westphal authored
      Since commit
      6be3b0db ("xfrm: policy: add inexact policy search tree infrastructure")
      policy lookup no longer walks a list but has a set of candidate lists.
      
      This set has to be searched for the best match.
      In case there are several matches, the priority wins.
      
      If the priority is also the same, then the historic behaviour with
      a single list was to return the first match (first-in-list).
      
      With introduction of serval lists, this doesn't work and a new
      'pos' member was added that reflects the xfrm_policy structs position
      in the list.
      
      This value is not exported to userspace and it does not need to be
      the 'position in the list', it just needs to make sure that
      a->pos < b->pos means that a was added to the lists more recently
      than b.
      
      This re-walk is expensive when many inexact policies are in use.
      
      Speed this up: when appending the policy to the end of the walker list,
      then just take the ->pos value of the last entry made and add 1.
      
      Add a slowpath version to prevent overflow, if we'd assign UINT_MAX
      then iterate the entire list and fix the ordering.
      
      While this speeds up insertion considerably finding the insertion spot
      in the inexact list still requires a partial list walk.
      
      This is addressed in followup patches.
      
      Before:
      ./xfrm_policy_add_speed.sh
      Inserted 1000   policies in 72 ms
      Inserted 10000  policies in 1540 ms
      Inserted 100000 policies in 334780 ms
      
      After:
      Inserted 1000   policies in 68 ms
      Inserted 10000  policies in 1137 ms
      Inserted 100000 policies in 157307 ms
      Reported-by: default avatarNoel Kuntze <noel@familie-kuntze.de>
      Cc: Tobias Brunner <tobias@strongswan.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      33f611cf
    • Florian Westphal's avatar
      selftests: add xfrm policy insertion speed test script · 9c5b6d4e
      Florian Westphal authored
      Nothing special, just test how long insertion of x policies takes.
      This should ideally show linear insertion speeds.
      
      Do not run this by default, it has little value, but it can be useful to
      check for insertion speed chahnges when altering the xfrm policy db
      implementation.
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      9c5b6d4e
  5. 23 Aug, 2024 1 commit
  6. 20 Aug, 2024 1 commit
  7. 16 Aug, 2024 1 commit
  8. 01 Aug, 2024 17 commits
  9. 31 Jul, 2024 10 commits