1. 18 May, 2021 21 commits
    • Yang Yingliang's avatar
      net: dcb: Remove unnecessary INIT_LIST_HEAD() · e2bd6bad
      Yang Yingliang authored
      The list_head dcb_app_list is initialized statically.
      It is unnecessary to initialize by INIT_LIST_HEAD().
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e2bd6bad
    • Yang Yingliang's avatar
      cxgb4: clip_tbl: use list_del_init instead of list_del/INIT_LIST_HEAD · 44e261c7
      Yang Yingliang authored
      Using list_del_init() instead of list_del() + INIT_LIST_HEAD()
      to simpify the code.
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      44e261c7
    • David S. Miller's avatar
      Merge branch 'wan-cleanups' · 46212b69
      David S. Miller authored
      Guangbin Huang says:
      
      ====================
      net: wan: clean up some code style issues
      
      This patchset clean up some code style issues.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      46212b69
    • Peng Li's avatar
      net: wan: fix variable definition style · a3f3e831
      Peng Li authored
      Fix the checkpatch error: "foo* bar" should be "foo *bar".
      Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a3f3e831
    • Peng Li's avatar
      net: wan: remove redundant space · da8e6fdd
      Peng Li authored
      Space prohibited before that close parenthesis ')',
      so removes the redundant space.
      Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      da8e6fdd
    • Peng Li's avatar
      net: wan: remove redundant braces {} · a4e59147
      Peng Li authored
      Braces {} are not necessary for single statement blocks,
      this patch removes redundant braces {}.
      Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a4e59147
    • Peng Li's avatar
      net: wan: add some required spaces · 23c23541
      Peng Li authored
      Add space required before the open parenthesis '(',
      and add spaces required around that '<', '>' and '!='.
      Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      23c23541
    • Peng Li's avatar
      net: wan: remove redundant blank lines · 78524c01
      Peng Li authored
      This patch removes some redundant blank lines.
      Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      78524c01
    • Wei Yongjun's avatar
      net: dsa: qca8k: fix missing unlock on error in qca8k_vlan_(add|del) · 0d56e5c1
      Wei Yongjun authored
      Add the missing unlock before return from function qca8k_vlan_add()
      and qca8k_vlan_del() in the error handling case.
      
      Fixes: 028f5f8e ("net: dsa: qca8k: handle error with qca8k_read operation")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0d56e5c1
    • Zheng Yejian's avatar
      cipso: correct comments of cipso_v4_cache_invalidate() · 4ac9e23c
      Zheng Yejian authored
      Since cipso_v4_cache_invalidate() has no return value, so drop
      related descriptions in its comments.
      
      Fixes: 446fda4f ("[NetLabel]: CIPSOv4 engine")
      Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
      Acked-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4ac9e23c
    • David S. Miller's avatar
      Merge branch 'custom-multipath-hash' · 22ba9d0d
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      Add support for custom multipath hash
      
      This patchset adds support for custom multipath hash policy for both
      IPv4 and IPv6 traffic. The new policy allows user space to control the
      outer and inner packet fields used for the hash computation.
      
      Motivation
      ==========
      
      Linux currently supports different multipath hash policies for IPv4 and
      IPv6 traffic:
      
      * Layer 3
      * Layer 4
      * Layer 3 or inner layer 3, if present
      
      These policies hash on a fixed set of fields, which is inflexible and
      against operators' requirements to control the hash input: "The ability
      to control the inputs to the hash function should be a consideration in
      any load-balancing RFP" [1].
      
      An example of this inflexibility can be seen by the fact that none of
      the current policies allows operators to use the standard 5-tuple and
      the flow label for multipath hash computation. Such a policy is useful
      in the following real-world example of a data center with the following
      types of traffic:
      
      * Anycast IPv6 TCP traffic towards layer 4 load balancers. Flow label is
      constant (zero) to avoid breaking established connections
      
      * Non-encapsulated IPv6 traffic. Flow label is used to re-route flows
      around problematic (congested / failed) paths [2]
      
      * IPv6 encapsulated traffic (IPv4-in-IPv6 or IPv6-in-IPv6). Outer flow
      label is generated from encapsulated packet
      
      * UDP encapsulated traffic. Outer source port is generated from
      encapsulated packet
      
      In the above example, using the inner flow information for hash
      computation in addition to the outer flow information is useful during
      failures of the BPF agent that selectively generates the flow label
      based on the traffic type. In such cases, the self-healing properties of
      the flow label are lost, but encapsulated flows are still load balanced.
      
      Control over the inner fields is even more critical when encapsulation
      is performed by hardware routers. For example, the Spectrum ASIC can
      only encode 8 bits of entropy in the outer flow label / outer UDP source
      port when performing IP / UDP encapsulation. In the case of IPv4 GRE
      encapsulation there is no outer field to encode the inner hash in.
      
      User interface
      ==============
      
      In accordance with existing multipath hash configuration, the new custom
      policy is added as a new option (3) to the
      net.ipv{4,6}.fib_multipath_hash_policy sysctls. When the new policy is
      used, the packet fields used for hash computation are determined by the
      net.ipv{4,6}.fib_multipath_hash_fields sysctls. These sysctls accept a
      bitmask according to the following table (from ip-sysctl.rst):
      
      	====== ============================
      	0x0001 Source IP address
      	0x0002 Destination IP address
      	0x0004 IP protocol
      	0x0008 Flow Label
      	0x0010 Source port
      	0x0020 Destination port
      	0x0040 Inner source IP address
      	0x0080 Inner destination IP address
      	0x0100 Inner IP protocol
      	0x0200 Inner Flow Label
      	0x0400 Inner source port
      	0x0800 Inner destination port
      	====== ============================
      
      For example, to allow IPv6 traffic to be hashed based on standard
      5-tuple and flow label:
      
       # sysctl -wq net.ipv6.fib_multipath_hash_fields=0x0037
       # sysctl -wq net.ipv6.fib_multipath_hash_policy=3
      
      Implementation
      ==============
      
      As with existing policies, the new policy relies on the flow dissector
      to extract the packet fields for the hash computation. However, unlike
      existing policies that either use the outer or inner flow, the new
      policy might require both flows to be dissected.
      
      To avoid unnecessary invocations of the flow dissector, the data path
      skips dissection of the outer or inner flows if none of the outer or
      inner fields are required.
      
      In addition, inner flow dissection is not performed when no
      encapsulation was encountered (i.e., 'FLOW_DIS_ENCAPSULATION' not set by
      flow dissector) during dissection of the outer flow.
      
      Testing
      =======
      
      Three new selftests are added with three different topologies that allow
      testing of following traffic combinations:
      
      * Non-encapsulated IPv4 / IPv6 traffic
      * IPv4 / IPv6 overlay over IPv4 underlay
      * IPv4 / IPv6 overlay over IPv6 underlay
      
      All three tests follow the same pattern. Each time a different packet
      field is used for hash computation. When the field changes in the packet
      stream, traffic is expected to be balanced across the two paths. When
      the field does not change, traffic is expected to be unbalanced across
      the two paths.
      
      Patchset overview
      =================
      
      Patches #1-#3 add custom multipath hash support for IPv4 traffic
      Patches #4-#7 do the same for IPv6
      Patches #8-#10 add selftests
      
      Future work
      ===========
      
      mlxsw support can be found here [3].
      
      Changes since RFC v2 [4]:
      
      * Patch #2: Document that 0x0008 is used for Flow Label
      * Patch #2: Do not allow the bitmask to be zero
      * Patch #6: Do not allow the bitmask to be zero
      
      Changes since RFC v1 [5]:
      
      * Use a bitmask instead of a bitmap
      
      [1] https://blog.apnic.net/2018/01/11/ipv6-flow-label-misuse-hashing/
      [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3acf3ec3f4b0fd4263989f2e4227bbd1c42b5fe1
      [3] https://github.com/idosch/linux/tree/submit/custom_hash_mlxsw_v2
      [4] https://lore.kernel.org/netdev/20210509151615.200608-1-idosch@idosch.org/
      [5] https://lore.kernel.org/netdev/20210502162257.3472453-1-idosch@idosch.org/
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      22ba9d0d
    • Ido Schimmel's avatar
      selftests: forwarding: Add test for custom multipath hash with IPv6 GRE · b7715acb
      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
      IPv6 underlay network. The previous patch verified the same with an IPv4
      underlay network.
      
      Example output:
      
       # ./ip6gre_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: 6602 / 6002
       TEST: Multipath hash field: Inner source IP (unbalanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 1 / 12601
       TEST: Multipath hash field: Inner destination IP (balanced)         [ OK ]
       INFO: Packets sent on path1 / path2: 6802 / 5801
       TEST: Multipath hash field: Inner destination IP (unbalanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 12602 / 3
       TEST: Multipath hash field: Inner source port (balanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 16431 / 16344
       TEST: Multipath hash field: Inner source port (unbalanced)          [ OK ]
       INFO: Packets sent on path1 / path2: 0 / 32773
       TEST: Multipath hash field: Inner destination port (balanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 16431 / 16344
       TEST: Multipath hash field: Inner destination port (unbalanced)     [ OK ]
       INFO: Packets sent on path1 / path2: 2 / 32772
       INFO: Running IPv6 overlay custom multipath hash tests
       TEST: Multipath hash field: Inner source IP (balanced)              [ OK ]
       INFO: Packets sent on path1 / path2: 6704 / 5902
       TEST: Multipath hash field: Inner source IP (unbalanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 1 / 12600
       TEST: Multipath hash field: Inner destination IP (balanced)         [ OK ]
       INFO: Packets sent on path1 / path2: 5751 / 6852
       TEST: Multipath hash field: Inner destination IP (unbalanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 12602 / 0
       TEST: Multipath hash field: Inner flowlabel (balanced)              [ OK ]
       INFO: Packets sent on path1 / path2: 8272 / 8181
       TEST: Multipath hash field: Inner flowlabel (unbalanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 3 / 12602
       TEST: Multipath hash field: Inner source port (balanced)            [ OK ]
       INFO: Packets sent on path1 / path2: 16424 / 16351
       TEST: Multipath hash field: Inner source port (unbalanced)          [ OK ]
       INFO: Packets sent on path1 / path2: 3 / 32774
       TEST: Multipath hash field: Inner destination port (balanced)       [ OK ]
       INFO: Packets sent on path1 / path2: 16425 / 16350
       TEST: Multipath hash field: Inner destination port (unbalanced)     [ OK ]
       INFO: Packets sent on path1 / path2: 2 / 32773
      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>
      b7715acb
    • 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 19 commits