1. 18 May, 2021 9 commits
    • Ido Schimmel's avatar
      selftests: forwarding: Add test for custom multipath hash with IPv4 GRE · 185b0c19
      Ido Schimmel authored
      Test that when the hash policy is set to custom, traffic is distributed
      only according to the inner fields set in the fib_multipath_hash_fields
      sysctl.
      
      Each time set a different field and make sure traffic is only
      distributed when the field is changed in the packet stream.
      
      The test only verifies the behavior of IPv4/IPv6 overlays on top of an
      IPv4 underlay network. A subsequent patch will do the same with an IPv6
      underlay network.
      
      Example output:
      
       # ./gre_custom_multipath_hash.sh
       TEST: ping                                                          [ OK ]
       TEST: ping6                                                         [ OK ]
       INFO: Running IPv4 overlay custom multipath hash tests
       TEST: Multipath hash field: Inner source IP (balanced)              [ OK ]
       INFO: Packets sent on path1 / path2: 6601 / 6001
       TEST: Multipath hash field: Inner source IP (unbalanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 12600
       TEST: Multipath hash field: Inner destination IP (balanced)         [ OK ]
       INFO: Packets sent on path1 / path2: 6802 / 5802
       TEST: Multipath hash field: Inner destination IP (unbalanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 12601 / 1
       TEST: Multipath hash field: Inner source port (balanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 16430 / 16344
       TEST: Multipath hash field: Inner source port (unbalanced)          [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 32772
       TEST: Multipath hash field: Inner destination port (balanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 16430 / 16343
       TEST: Multipath hash field: Inner destination port (unbalanced)     [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 32772
       INFO: Running IPv6 overlay custom multipath hash tests
       TEST: Multipath hash field: Inner source IP (balanced)              [ OK ]
       INFO: Packets sent on path1 / path2: 6702 / 5900
       TEST: Multipath hash field: Inner source IP (unbalanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 12601
       TEST: Multipath hash field: Inner destination IP (balanced)         [ OK ]
       INFO: Packets sent on path1 / path2: 5751 / 6851
       TEST: Multipath hash field: Inner destination IP (unbalanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 12602 / 1
       TEST: Multipath hash field: Inner flowlabel (balanced)              [ OK ]
       INFO: Packets sent on path1 / path2: 8364 / 8065
       TEST: Multipath hash field: Inner flowlabel (unbalanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 12601 / 0
       TEST: Multipath hash field: Inner source port (balanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 16425 / 16349
       TEST: Multipath hash field: Inner source port (unbalanced)          [ OK ]
       INFO: Packets sent on path1 / path2: 1 / 32770
       TEST: Multipath hash field: Inner destination port (balanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 16425 / 16349
       TEST: Multipath hash field: Inner destination port (unbalanced)     [ OK ]
       INFO: Packets sent on path1 / path2: 2 / 32770
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Acked-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      185b0c19
    • Ido Schimmel's avatar
      selftests: forwarding: Add test for custom multipath hash · 511e8db5
      Ido Schimmel authored
      Test that when the hash policy is set to custom, traffic is distributed
      only according to the outer fields set in the fib_multipath_hash_fields
      sysctl.
      
      Each time set a different field and make sure traffic is only
      distributed when the field is changed in the packet stream.
      
      The test only verifies the behavior with non-encapsulated IPv4 and IPv6
      packets. Subsequent patches will add tests for IPv4/IPv6 overlays on top
      of IPv4/IPv6 underlay networks.
      
      Example output:
      
       # ./custom_multipath_hash.sh
       TEST: ping                                                          [ OK ]
       TEST: ping6                                                         [ OK ]
       INFO: Running IPv4 custom multipath hash tests
       TEST: Multipath hash field: Source IP (balanced)                    [ OK ]
       INFO: Packets sent on path1 / path2: 6353 / 6254
       TEST: Multipath hash field: Source IP (unbalanced)                  [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 12600
       TEST: Multipath hash field: Destination IP (balanced)               [ OK ]
       INFO: Packets sent on path1 / path2: 6102 / 6502
       TEST: Multipath hash field: Destination IP (unbalanced)             [ OK ]
       INFO: Packets sent on path1 / path2: 1 / 12601
       TEST: Multipath hash field: Source port (balanced)                  [ OK ]
       INFO: Packets sent on path1 / path2: 16428 / 16345
       TEST: Multipath hash field: Source port (unbalanced)                [ OK ]
       INFO: Packets sent on path1 / path2: 32770 / 2
       TEST: Multipath hash field: Destination port (balanced)             [ OK ]
       INFO: Packets sent on path1 / path2: 16428 / 16345
       TEST: Multipath hash field: Destination port (unbalanced)           [ OK ]
       INFO: Packets sent on path1 / path2: 32770 / 2
       INFO: Running IPv6 custom multipath hash tests
       TEST: Multipath hash field: Source IP (balanced)                    [ OK ]
       INFO: Packets sent on path1 / path2: 6704 / 5903
       TEST: Multipath hash field: Source IP (unbalanced)                  [ OK ]
       INFO: Packets sent on path1 / path2: 12600 / 0
       TEST: Multipath hash field: Destination IP (balanced)               [ OK ]
       INFO: Packets sent on path1 / path2: 5551 / 7052
       TEST: Multipath hash field: Destination IP (unbalanced)             [ OK ]
       INFO: Packets sent on path1 / path2: 12603 / 0
       TEST: Multipath hash field: Flowlabel (balanced)                    [ OK ]
       INFO: Packets sent on path1 / path2: 8378 / 8080
       TEST: Multipath hash field: Flowlabel (unbalanced)                  [ OK ]
       INFO: Packets sent on path1 / path2: 2 / 12603
       TEST: Multipath hash field: Source port (balanced)                  [ OK ]
       INFO: Packets sent on path1 / path2: 16385 / 16388
       TEST: Multipath hash field: Source port (unbalanced)                [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 32774
       TEST: Multipath hash field: Destination port (balanced)             [ OK ]
       INFO: Packets sent on path1 / path2: 16386 / 16390
       TEST: Multipath hash field: Destination port (unbalanced)           [ OK ]
       INFO: Packets sent on path1 / path2: 32771 / 2
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      511e8db5
    • Ido Schimmel's avatar
      ipv6: Add custom multipath hash policy · 73c2c5cb
      Ido Schimmel authored
      Add a new multipath hash policy where the packet fields used for hash
      calculation are determined by user space via the
      fib_multipath_hash_fields sysctl that was introduced in the previous
      patch.
      
      The current set of available packet fields includes both outer and inner
      fields, which requires two invocations of the flow dissector. Avoid
      unnecessary dissection of the outer or inner flows by skipping
      dissection if none of the outer or inner fields are required.
      
      In accordance with the existing policies, when an skb is not available,
      packet fields are extracted from the provided flow key. In which case,
      only outer fields are considered.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      73c2c5cb
    • Ido Schimmel's avatar
      ipv6: Add a sysctl to control multipath hash fields · ed13923f
      Ido Schimmel authored
      A subsequent patch will add a new multipath hash policy where the packet
      fields used for multipath hash calculation are determined by user space.
      This patch adds a sysctl that allows user space to set these fields.
      
      The packet fields are represented using a bitmask and are common between
      IPv4 and IPv6 to allow user space to use the same numbering across both
      protocols. For example, to hash based on standard 5-tuple:
      
       # sysctl -w net.ipv6.fib_multipath_hash_fields=0x0037
       net.ipv6.fib_multipath_hash_fields = 0x0037
      
      To avoid introducing holes in 'struct netns_sysctl_ipv6', move the
      'bindv6only' field after the multipath hash fields.
      
      The kernel rejects unknown fields, for example:
      
       # sysctl -w net.ipv6.fib_multipath_hash_fields=0x1000
       sysctl: setting key "net.ipv6.fib_multipath_hash_fields": Invalid argument
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ed13923f
    • Ido Schimmel's avatar
      ipv6: Calculate multipath hash inside switch statement · b95b6e07
      Ido Schimmel authored
      A subsequent patch will add another multipath hash policy where the
      multipath hash is calculated directly by the policy specific code and
      not outside of the switch statement.
      
      Prepare for this change by moving the multipath hash calculation inside
      the switch statement.
      
      No functional changes intended.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b95b6e07
    • Ido Schimmel's avatar
      ipv6: Use a more suitable label name · 67db5ca7
      Ido Schimmel authored
      The 'out_timer' label was added in commit 63152fc0 ("[NETNS][IPV6]
      ip6_fib - gc timer per namespace") when the timer was allocated on the
      heap.
      
      Commit 417f28bb ("netns: dont alloc ipv6 fib timer list") removed
      the allocation, but kept the label name.
      
      Rename it to a more suitable name.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      67db5ca7
    • Ido Schimmel's avatar
      ipv4: Add custom multipath hash policy · 4253b498
      Ido Schimmel authored
      Add a new multipath hash policy where the packet fields used for hash
      calculation are determined by user space via the
      fib_multipath_hash_fields sysctl that was introduced in the previous
      patch.
      
      The current set of available packet fields includes both outer and inner
      fields, which requires two invocations of the flow dissector. Avoid
      unnecessary dissection of the outer or inner flows by skipping
      dissection if none of the outer or inner fields are required.
      
      In accordance with the existing policies, when an skb is not available,
      packet fields are extracted from the provided flow key. In which case,
      only outer fields are considered.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4253b498
    • Ido Schimmel's avatar
      ipv4: Add a sysctl to control multipath hash fields · ce5c9c20
      Ido Schimmel authored
      A subsequent patch will add a new multipath hash policy where the packet
      fields used for multipath hash calculation are determined by user space.
      This patch adds a sysctl that allows user space to set these fields.
      
      The packet fields are represented using a bitmask and are common between
      IPv4 and IPv6 to allow user space to use the same numbering across both
      protocols. For example, to hash based on standard 5-tuple:
      
       # sysctl -w net.ipv4.fib_multipath_hash_fields=0x0037
       net.ipv4.fib_multipath_hash_fields = 0x0037
      
      The kernel rejects unknown fields, for example:
      
       # sysctl -w net.ipv4.fib_multipath_hash_fields=0x1000
       sysctl: setting key "net.ipv4.fib_multipath_hash_fields": Invalid argument
      
      More fields can be added in the future, if needed.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ce5c9c20
    • Ido Schimmel's avatar
      ipv4: Calculate multipath hash inside switch statement · 2e68ea92
      Ido Schimmel authored
      A subsequent patch will add another multipath hash policy where the
      multipath hash is calculated directly by the policy specific code and
      not outside of the switch statement.
      
      Prepare for this change by moving the multipath hash calculation inside
      the switch statement.
      
      No functional changes intended.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2e68ea92
  2. 17 May, 2021 31 commits