1. 24 Jun, 2019 25 commits
    • Stefano Brivio's avatar
      selftests: pmtu: Make list_flush_ipv6_exception test more demanding · b964641e
      Stefano Brivio authored
      Instead of just listing and flushing two cached exceptions, create
      a relatively big number of them, and count how many are listed. Single
      netlink dump messages contain approximately 25 entries each, and this
      way we can make sure the partial dump tracking mechanism is working
      properly.
      
      While at it, also ensure that no cached routes can be listed after
      flush, and remove 'sleep 1' calls, they are not actually needed.
      
      v7: No changes
      
      v6:
        - Merge this patch into series including fix, as it's also targeted
          for net-next. No actual changes
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b964641e
    • Stefano Brivio's avatar
      selftests: pmtu: Introduce list_flush_ipv4_exception test case · de755a85
      Stefano Brivio authored
      This test checks that route exceptions can be successfully listed and
      flushed using ip -6 route {list,flush} cache.
      
      v7: No changes
      
      v6:
        - Merge this patch into series including fix, as it's also targeted
          for net-next
        - Drop left-over print of 'ip route list cache | wc -l'
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      de755a85
    • Stefano Brivio's avatar
      ip6_fib: Don't discard nodes with valid routing information in fib6_locate_1() · 40cb35d5
      Stefano Brivio authored
      When we perform an inexact match on FIB nodes via fib6_locate_1(), longer
      prefixes will be preferred to shorter ones. However, it might happen that
      a node, with higher fn_bit value than some other, has no valid routing
      information.
      
      In this case, we'll pick that node, but it will be discarded by the check
      on RTN_RTINFO in fib6_locate(), and we might miss nodes with valid routing
      information but with lower fn_bit value.
      
      This is apparent when a routing exception is created for a default route:
       # ip -6 route list
       fc00:1::/64 dev veth_A-R1 proto kernel metric 256 pref medium
       fc00:2::/64 dev veth_A-R2 proto kernel metric 256 pref medium
       fc00:4::1 via fc00:2::2 dev veth_A-R2 metric 1024 pref medium
       fe80::/64 dev veth_A-R1 proto kernel metric 256 pref medium
       fe80::/64 dev veth_A-R2 proto kernel metric 256 pref medium
       default via fc00:1::2 dev veth_A-R1 metric 1024 pref medium
       # ip -6 route list cache
       fc00:4::1 via fc00:2::2 dev veth_A-R2 metric 1024 expires 593sec mtu 1500 pref medium
       fc00:3::1 via fc00:1::2 dev veth_A-R1 metric 1024 expires 593sec mtu 1500 pref medium
       # ip -6 route flush cache    # node for default route is discarded
       Failed to send flush request: No such process
       # ip -6 route list cache
       fc00:3::1 via fc00:1::2 dev veth_A-R1 metric 1024 expires 586sec mtu 1500 pref medium
      
      Check right away if the node has a RTN_RTINFO flag, before replacing the
      'prev' pointer, that indicates the longest matching prefix found so far.
      
      Fixes: 38fbeeee ("ipv6: prepare fib6_locate() for exception table")
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      40cb35d5
    • Stefano Brivio's avatar
      ipv6: Dump route exceptions if requested · 1e47b483
      Stefano Brivio authored
      Since commit 2b760fcf ("ipv6: hook up exception table to store dst
      cache"), route exceptions reside in a separate hash table, and won't be
      found by walking the FIB, so they won't be dumped to userspace on a
      RTM_GETROUTE message.
      
      This causes 'ip -6 route list cache' and 'ip -6 route flush cache' to
      have no function anymore:
      
       # ip -6 route get fc00:3::1
       fc00:3::1 via fc00:1::2 dev veth_A-R1 src fc00:1::1 metric 1024 expires 539sec mtu 1400 pref medium
       # ip -6 route get fc00:4::1
       fc00:4::1 via fc00:2::2 dev veth_A-R2 src fc00:2::1 metric 1024 expires 536sec mtu 1500 pref medium
       # ip -6 route list cache
       # ip -6 route flush cache
       # ip -6 route get fc00:3::1
       fc00:3::1 via fc00:1::2 dev veth_A-R1 src fc00:1::1 metric 1024 expires 520sec mtu 1400 pref medium
       # ip -6 route get fc00:4::1
       fc00:4::1 via fc00:2::2 dev veth_A-R2 src fc00:2::1 metric 1024 expires 519sec mtu 1500 pref medium
      
      because iproute2 lists cached routes using RTM_GETROUTE, and flushes them
      by listing all the routes, and deleting them with RTM_DELROUTE one by one.
      
      If cached routes are requested using the RTM_F_CLONED flag together with
      strict checking, or if no strict checking is requested (and hence we can't
      consistently apply filters), look up exceptions in the hash table
      associated with the current fib6_info in rt6_dump_route(), and, if present
      and not expired, add them to the dump.
      
      We might be unable to dump all the entries for a given node in a single
      message, so keep track of how many entries were handled for the current
      node in fib6_walker, and skip that amount in case we start from the same
      partially dumped node.
      
      When a partial dump restarts, as the starting node might change when
      'sernum' changes, we have no guarantee that we need to skip the same
      amount of in-node entries. Therefore, we need two counters, and we need to
      zero the in-node counter if the node from which the dump is resumed
      differs.
      
      Note that, with the current version of iproute2, this only fixes the
      'ip -6 route list cache': on a flush command, iproute2 doesn't pass
      RTM_F_CLONED and, due to this inconsistency, 'ip -6 route flush cache' is
      still unable to fetch the routes to be flushed. This will be addressed in
      a patch for iproute2.
      
      To flush cached routes, a procfs entry could be introduced instead: that's
      how it works for IPv4. We already have a rt6_flush_exception() function
      ready to be wired to it. However, this would not solve the issue for
      listing.
      
      Versions of iproute2 and kernel tested:
      
                          iproute2
      kernel             4.14.0   4.15.0   4.19.0   5.0.0   5.1.0    5.1.0, patched
       3.18    list        +        +        +        +       +            +
               flush       +        +        +        +       +            +
       4.4     list        +        +        +        +       +            +
               flush       +        +        +        +       +            +
       4.9     list        +        +        +        +       +            +
               flush       +        +        +        +       +            +
       4.14    list        +        +        +        +       +            +
               flush       +        +        +        +       +            +
       4.15    list
               flush
       4.19    list
               flush
       5.0     list
               flush
       5.1     list
               flush
       with    list        +        +        +        +       +            +
       fix     flush       +        +        +                             +
      
      v7:
        - Explain usage of "skip" counters in commit message (suggested by
          David Ahern)
      
      v6:
        - Rebase onto net-next, use recently introduced nexthop walker
        - Make rt6_nh_dump_exceptions() a separate function (suggested by David
          Ahern)
      
      v5:
        - Use dump_routes and dump_exceptions from filter, ignore NLM_F_MATCH,
          update test results (flushing works with iproute2 < 5.0.0 now)
      
      v4:
        - Split NLM_F_MATCH and strict check handling in separate patches
        - Filter routes using RTM_F_CLONED: if it's not set, only return
          non-cached routes, and if it's set, only return cached routes:
          change requested by David Ahern and Martin Lau. This implies that
          iproute2 needs a separate patch to be able to flush IPv6 cached
          routes. This is not ideal because we can't fix the breakage caused
          by 2b760fcf entirely in kernel. However, two years have passed
          since then, and this makes it more tolerable
      
      v3:
        - More descriptive comment about expired exceptions in rt6_dump_route()
        - Swap return values of rt6_dump_route() (suggested by Martin Lau)
        - Don't zero skip_in_node in case we don't dump anything in a given pass
          (also suggested by Martin Lau)
        - Remove check on RTM_F_CLONED altogether: in the current UAPI semantic,
          it's just a flag to indicate the route was cloned, not to filter on
          routes
      
      v2: Add tracking of number of entries to be skipped in current node after
          a partial dump. As we restart from the same node, if not all the
          exceptions for a given node fit in a single message, the dump will
          not terminate, as suggested by Martin Lau. This is a concrete
          possibility, setting up a big number of exceptions for the same route
          actually causes the issue, suggested by David Ahern.
      Reported-by: default avatarJianlin Shi <jishi@redhat.com>
      Fixes: 2b760fcf ("ipv6: hook up exception table to store dst cache")
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1e47b483
    • Stefano Brivio's avatar
      ipv6/route: Change return code of rt6_dump_route() for partial node dumps · bf9a8a06
      Stefano Brivio authored
      In the next patch, we are going to add optional dump of exceptions to
      rt6_dump_route().
      
      Change the return code of rt6_dump_route() to accomodate partial node
      dumps: we might dump multiple routes per node, and might be able to dump
      only a given number of them, so fib6_dump_node() will need to know how
      many routes have been dumped on partial dump, to restart the dump from the
      point where it was interrupted.
      
      Note that fib6_dump_node() is the only caller and already handles all
      non-negative return codes as success: those become -1 to signal that we're
      done with the node. If we fail, return 0, as we were unable to dump the
      single route in the node, but we're not done with it.
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bf9a8a06
    • Stefano Brivio's avatar
      ipv6/route: Don't match on fc_nh_id if not set in ip6_route_del() · 3401bfb1
      Stefano Brivio authored
      If fc_nh_id isn't set, we shouldn't try to match against it. This
      actually matters just for the RTF_CACHE below (where this case is
      already handled): if iproute2 gets a route exception and tries to
      delete it, it won't reference it by fc_nh_id, even if a nexthop
      object might be associated to the originating route.
      
      Fixes: 5b98324e ("ipv6: Allow routes to use nexthop objects")
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3401bfb1
    • Stefano Brivio's avatar
      Revert "net/ipv6: Bail early if user only wants cloned entries" · ef11209d
      Stefano Brivio authored
      This reverts commit 08e814c9: as we
      are preparing to fix listing and dumping of IPv6 cached routes, we
      need to allow RTM_F_CLONED as a flag to match routes against while
      dumping them.
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ef11209d
    • Stefano Brivio's avatar
      ipv4: Dump route exceptions if requested · ee28906f
      Stefano Brivio authored
      Since commit 4895c771 ("ipv4: Add FIB nexthop exceptions."), cached
      exception routes are stored as a separate entity, so they are not dumped
      on a FIB dump, even if the RTM_F_CLONED flag is passed.
      
      This implies that the command 'ip route list cache' doesn't return any
      result anymore.
      
      If the RTM_F_CLONED is passed, and strict checking requested, retrieve
      nexthop exception routes and dump them. If no strict checking is
      requested, filtering can't be performed consistently: dump everything in
      that case.
      
      With this, we need to add an argument to the netlink callback in order to
      track how many entries were already dumped for the last leaf included in
      a partial netlink dump.
      
      A single additional argument is sufficient, even if we traverse logically
      nested structures (nexthop objects, hash table buckets, bucket chains): it
      doesn't matter if we stop in the middle of any of those, because they are
      always traversed the same way. As an example, s_i values in [], s_fa
      values in ():
      
        node (fa) #1 [1]
          nexthop #1
          bucket #1 -> #0 in chain (1)
          bucket #2 -> #0 in chain (2) -> #1 in chain (3) -> #2 in chain (4)
          bucket #3 -> #0 in chain (5) -> #1 in chain (6)
      
          nexthop #2
          bucket #1 -> #0 in chain (7) -> #1 in chain (8)
          bucket #2 -> #0 in chain (9)
        --
        node (fa) #2 [2]
          nexthop #1
          bucket #1 -> #0 in chain (1) -> #1 in chain (2)
          bucket #2 -> #0 in chain (3)
      
      it doesn't matter if we stop at (3), (4), (7) for "node #1", or at (2)
      for "node #2": walking flattens all that.
      
      It would even be possible to drop the distinction between the in-tree
      (s_i) and in-node (s_fa) counter, but a further improvement might
      advise against this. This is only as accurate as the existing tracking
      mechanism for leaves: if a partial dump is restarted after exceptions
      are removed or expired, we might skip some non-dumped entries.
      
      To improve this, we could attach a 'sernum' attribute (similar to the
      one used for IPv6) to nexthop entities, and bump this counter whenever
      exceptions change: having a distinction between the two counters would
      make this more convenient.
      
      Listing of exception routes (modified routes pre-3.5) was tested against
      these versions of kernel and iproute2:
      
                          iproute2
      kernel         4.14.0   4.15.0   4.19.0   5.0.0   5.1.0
       3.5-rc4         +        +        +        +       +
       4.4
       4.9
       4.14
       4.15
       4.19
       5.0
       5.1
       fixed           +        +        +        +       +
      
      v7:
         - Move loop over nexthop objects to route.c, and pass struct fib_info
           and table ID to it, not a struct fib_alias (suggested by David Ahern)
         - While at it, note that the NULL check on fa->fa_info is redundant,
           and the check on RTNH_F_DEAD is also not consistent with what's done
           with regular route listing: just keep it for nhc_flags
         - Rename entry point function for dumping exceptions to
           fib_dump_info_fnhe(), and rearrange arguments for consistency with
           fib_dump_info()
         - Rename fnhe_dump_buckets() to fnhe_dump_bucket() and make it handle
           one bucket at a time
         - Expand commit message to describe why we can have a single "skip"
           counter for all exceptions stored in bucket chains in nexthop objects
           (suggested by David Ahern)
      
      v6:
         - Rebased onto net-next
         - Loop over nexthop paths too. Move loop over fnhe buckets to route.c,
           avoids need to export rt_fill_info() and to touch exceptions from
           fib_trie.c. Pass NULL as flow to rt_fill_info(), it now allows that
           (suggested by David Ahern)
      
      Fixes: 4895c771 ("ipv4: Add FIB nexthop exceptions.")
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ee28906f
    • Stefano Brivio's avatar
      ipv4/route: Allow NULL flowinfo in rt_fill_info() · d948974c
      Stefano Brivio authored
      In the next patch, we're going to use rt_fill_info() to dump exception
      routes upon RTM_GETROUTE with NLM_F_ROOT, meaning userspace is requesting
      a dump and not a specific route selection, which in turn implies the input
      interface is not relevant. Update rt_fill_info() to handle a NULL
      flowinfo.
      
      v7: If fl4 is NULL, explicitly set r->rtm_tos to 0: it's not initialised
          otherwise (spotted by David Ahern)
      
      v6: New patch
      Suggested-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d948974c
    • Stefano Brivio's avatar
      ipv4/fib_frontend: Allow RTM_F_CLONED flag to be used for filtering · b597ca6e
      Stefano Brivio authored
      This functionally reverts the check introduced by commit
      e8ba330a ("rtnetlink: Update fib dumps for strict data checking")
      as modified by commit e4e92fb1 ("net/ipv4: Bail early if user only
      wants prefix entries").
      
      As we are preparing to fix listing of IPv4 cached routes, we need to
      give userspace a way to request them.
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b597ca6e
    • Stefano Brivio's avatar
      fib_frontend, ip6_fib: Select routes or exceptions dump from RTM_F_CLONED · 564c91f7
      Stefano Brivio authored
      The following patches add back the ability to dump IPv4 and IPv6 exception
      routes, and we need to allow selection of regular routes or exceptions.
      
      Use RTM_F_CLONED as filter to decide whether to dump routes or exceptions:
      iproute2 passes it in dump requests (except for IPv6 cache flush requests,
      this will be fixed in iproute2) and this used to work as long as
      exceptions were stored directly in the FIB, for both IPv4 and IPv6.
      
      Caveat: if strict checking is not requested (that is, if the dump request
      doesn't go through ip_valid_fib_dump_req()), we can't filter on protocol,
      tables or route types.
      
      In this case, filtering on RTM_F_CLONED would be inconsistent: we would
      fix 'ip route list cache' by returning exception routes and at the same
      time introduce another bug in case another selector is present, e.g. on
      'ip route list cache table main' we would return all exception routes,
      without filtering on tables.
      
      Keep this consistent by applying no filters at all, and dumping both
      routes and exceptions, if strict checking is not requested. iproute2
      currently filters results anyway, and no unwanted results will be
      presented to the user. The kernel will just dump more data than needed.
      
      v7: No changes
      
      v6: Rebase onto net-next, no changes
      
      v5: New patch: add dump_routes and dump_exceptions flags in filter and
          simply clear the unwanted one if strict checking is enabled, don't
          ignore NLM_F_MATCH and don't set filter_set if NLM_F_MATCH is set.
          Skip filtering altogether if no strict checking is requested:
          selecting routes or exceptions only would be inconsistent with the
          fact we can't filter on tables.
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      564c91f7
    • Antoine Tenart's avatar
      net: macb: use GRO · 97236cda
      Antoine Tenart authored
      This patch updates the macb driver to use NAPI GRO helpers when
      receiving SKBs. This improves performances.
      Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      97236cda
    • Antoine Tenart's avatar
      net: macb: use NAPI_POLL_WEIGHT · 760a3c1a
      Antoine Tenart authored
      Use NAPI_POLL_WEIGHT, the default NAPI poll() weight instead of
      redefining our own value (which turns out to be 64 as well).
      Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      760a3c1a
    • David S. Miller's avatar
      Merge branch 'ipv4-fix-bugs-when-enable-route_localnet' · 38a3889f
      David S. Miller authored
      Shijie Luo says:
      
      ====================
      ipv4: fix bugs when enable route_localnet
      
      When enable route_localnet, route of the 127/8 address is enabled.
      But in some situations like arp_announce=2, ARP requests or reply
      work abnormally.
      
      This patchset fix some bugs when enable route_localnet.
      
      Change History:
      V2:
      - Change a single patch to a patchset.
      - Add bug fix for arp_ignore = 3.
      - Add a couple of test for enabling route_localnet in selftests.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      38a3889f
    • Shijie Luo's avatar
      selftests: add route_localnet test script · 58ade67b
      Shijie Luo authored
      Add a simple scripts to exercise several situations when enable
      route_localnet.
      Signed-off-by: default avatarShijie Luo <luoshijie1@huawei.com>
      Signed-off-by: default avatarZhiqiang liu <liuzhiqiang26@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      58ade67b
    • Shijie Luo's avatar
      ipv4: fix confirm_addr_indev() when enable route_localnet · 650638a7
      Shijie Luo authored
      When arp_ignore=3, the NIC won't reply for scope host addresses, but
      if enable route_locanet, we need to reply ip address with head 127 and
      scope RT_SCOPE_HOST.
      
      Fixes: d0daebc3 ("ipv4: Add interface option to enable routing of 127.0.0.0/8")
      Signed-off-by: default avatarShijie Luo <luoshijie1@huawei.com>
      Signed-off-by: default avatarZhiqiang Liu <liuzhiqiang26@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      650638a7
    • Shijie Luo's avatar
      ipv4: fix inet_select_addr() when enable route_localnet · d8c444d5
      Shijie Luo authored
      Suppose we have two interfaces eth0 and eth1 in two hosts, follow
      the same steps in the two hosts:
       # sysctl -w net.ipv4.conf.eth1.route_localnet=1
       # sysctl -w net.ipv4.conf.eth1.arp_announce=2
       # ip route del 127.0.0.0/8 dev lo table local
      and then set ip to eth1 in host1 like:
       # ifconfig eth1 127.25.3.4/24
      set ip to eth2 in host2 and ping host1:
       # ifconfig eth1 127.25.3.14/24
       # ping -I eth1 127.25.3.4
      Well, host2 cannot connect to host1.
      
      When set a ip address with head 127, the scope of the address defaults
      to RT_SCOPE_HOST. In this situation, host2 will use arp_solicit() to
      send a arp request for the mac address of host1 with ip
      address 127.25.3.14. When arp_announce=2, inet_select_addr() cannot
      select a correct saddr with condition ifa->ifa_scope > scope, because
      ifa_scope is RT_SCOPE_HOST and scope is RT_SCOPE_LINK. Then,
      inet_select_addr() will go to no_in_dev to lookup all interfaces to find
      a primary ip and finally get the primary ip of eth0.
      
      Here I add a localnet_scope defaults to RT_SCOPE_HOST, and when
      route_localnet is enabled, this value changes to RT_SCOPE_LINK to make
      inet_select_addr() find a correct primary ip as saddr of arp request.
      
      Fixes: d0daebc3 ("ipv4: Add interface option to enable routing of 127.0.0.0/8")
      Signed-off-by: default avatarShijie Luo <luoshijie1@huawei.com>
      Signed-off-by: default avatarZhiqiang Liu <liuzhiqiang26@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d8c444d5
    • Xin Long's avatar
      tipc: remove the unnecessary msg->req check from tipc_nl_compat_bearer_set · 8bc81c57
      Xin Long authored
      tipc_nl_compat_bearer_set() is only called by tipc_nl_compat_link_set()
      which already does the check for msg->req check, so remove it from
      tipc_nl_compat_bearer_set(), and do the same in tipc_nl_compat_media_set().
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8bc81c57
    • David S. Miller's avatar
      Merge branch 'mlxsw-Thermal-and-hwmon-extensions' · 18f3896d
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      mlxsw: Thermal and hwmon extensions
      
      This patchset from Vadim includes various enhancements to thermal and
      hwmon code in mlxsw.
      
      Patch #1 adds a thermal zone for each inter-connect device (gearbox).
      These devices are present in SN3800 systems and code to expose their
      temperature via hwmon was added in commit 2e265a8b ("mlxsw: core:
      Extend hwmon interface with inter-connect temperature attributes").
      
      Currently, there are multiple thermal zones in mlxsw and only a few
      cooling devices. Patch #2 detects the hottest thermal zone and the
      cooling devices are switched to follow its trends. RFC was sent last
      month [1].
      
      Patch #3 allows to read and report negative temperature of the sensors
      mlxsw exposes via hwmon and thermal subsystems.
      
      v2 (Andrew Lunn):
      * In patch #3, replace '%u' with '%d' in mlxsw_hwmon_module_temp_show()
      
      [1] https://patchwork.ozlabs.org/patch/1107161/
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      18f3896d
    • Vadim Pasternak's avatar
      mlxsw: core: Add support for negative temperature readout · f485cc36
      Vadim Pasternak authored
      Extend macros MLXSW_REG_MTMP_TEMP_TO_MC() to allow support of negative
      temperature readout, since chip and others thermal components are
      capable of operating within the negative temperature.
      With no such support negative temperature will be consider as very high
      temperature and it will cause wrong readout and thermal shutdown.
      For negative values 2`s complement is used.
      Tested in chamber.
      Example of chip ambient temperature readout with chamber temperature:
      -10 Celsius:
      temp1:             -6.0C  (highest =  -5.0C)
      -5 Celsius:
      temp1:             -1.0C  (highest =  -1.0C)
      
      v2 (Andrew Lunn):
      * Replace '%u' with '%d' in mlxsw_hwmon_module_temp_show()
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f485cc36
    • Vadim Pasternak's avatar
      mlxsw: core: Add the hottest thermal zone detection · 6f73862f
      Vadim Pasternak authored
      When multiple sensors are mapped to the same cooling device, the
      cooling device should be set according the worst sensor from the
      sensors associated with this cooling device.
      
      Provide the hottest thermal zone detection and enforce cooling device
      to follow the temperature trends of the hottest zone only.
      Prevent competition for the cooling device control from others zones,
      by "stable trend" indication. A cooling device will not perform any
      actions associated with a zone with a "stable trend".
      
      When other thermal zone is detected as a hottest, a cooling device is
      to be switched to following temperature trends of new hottest zone.
      
      Thermal zone score is represented by 32 bits unsigned integer and
      calculated according to the next formula:
      For T < TZ<t><i>, where t from {normal trip = 0, high trip = 1, hot
      trip = 2, critical = 3}:
      TZ<i> score = (T + (TZ<t><i> - T) / 2) / (TZ<t><i> - T) * 256 ** j;
      Highest thermal zone score s is set as MAX(TZ<i>score);
      Following this formula, if TZ<i> is in trip point higher than TZ<k>,
      the higher score is to be always assigned to TZ<i>.
      
      For two thermal zones located at the same kind of trip point, the higher
      score will be assigned to the zone which is closer to the next trip
      point. Thus, the highest score will always be assigned objectively to
      the hottest thermal zone.
      
      All the thermal zones initially are to be configured with mode
      "enabled" with the "step_wise" governor.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6f73862f
    • Vadim Pasternak's avatar
      mlxsw: core: Extend thermal core with per inter-connect device thermal zones · f14f4e62
      Vadim Pasternak authored
      Add a dedicated thermal zone for each inter-connect device. The
      current temperature is obtained from inter-connect temperature sensor
      and the default trip points are set to the same values as default ASIC
      trip points. These settings could be changed from the user space.
      A cooling device (fan) is bound to all inter-connect devices.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f14f4e62
    • john.rutherford@dektech.com.au's avatar
      tipc: fix missing indentation in source code · c04b6ea4
      john.rutherford@dektech.com.au authored
      Fix misalignment of policy statement in netlink.c due to automatic
      spatch code transformation.
      
      Fixes: 3b0f31f2 ("genetlink: make policy common to family")
      Acked-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarJohn Rutherford <john.rutherford@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c04b6ea4
    • Keerthy's avatar
      net: ethernet: ti: cpsw: Fix suspend/resume break · 2f9b0d93
      Keerthy authored
      Commit bfe59032 ("net: ethernet:
      ti: cpsw: use cpsw as drv data")changes
      the driver data to struct cpsw_common *cpsw. This is done
      only in probe/remove but the suspend/resume functions are
      still left with struct net_device *ndev. Hence fix both
      suspend & resume also to fetch the updated driver data.
      
      Fixes: bfe59032 ("net: ethernet: ti: cpsw: use cpsw as drv data")
      Signed-off-by: default avatarKeerthy <j-keerthy@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2f9b0d93
    • Xue Chaojing's avatar
      hinic: implement the statistical interface of ethtool · e54fbbdf
      Xue Chaojing authored
      This patch implement the statistical interface of ethtool, user can use
      ethtool -S to show hinic statistics.
      Signed-off-by: default avatarXue Chaojing <xuechaojing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e54fbbdf
  2. 23 Jun, 2019 11 commits
    • David S. Miller's avatar
      Merge branch 'ipv6-avoid-taking-refcnt-on-dst-during-route-lookup' · 7d30a7f6
      David S. Miller authored
      Wei Wang says:
      
      ====================
      ipv6: avoid taking refcnt on dst during route lookup
      
      Ipv6 route lookup code always grabs refcnt on the dst for the caller.
      But for certain cases, grabbing refcnt is not always necessary if the
      call path is rcu protected and the caller does not cache the dst.
      Another issue in the route lookup logic is:
      When there are multiple custom rules, we have to do the lookup into
      each table associated to each rule individually. And when we can't
      find the route in one table, we grab and release refcnt on
      net->ipv6.ip6_null_entry before going to the next table.
      This operation is completely redundant, and causes false issue because
      net->ipv6.ip6_null_entry is a shared object.
      
      This patch set introduces a new flag RT6_LOOKUP_F_DST_NOREF for route
      lookup callers to set, to avoid any manipulation on the dst refcnt. And
      it converts the major input and output path to use it.
      
      The performance gain is noticable.
      I ran synflood tests between 2 hosts under the same switch. Both hosts
      have 20G mlx NIC, and 8 tx/rx queues.
      Sender sends pure SYN flood with random src IPs and ports using trafgen.
      Receiver has a simple TCP listener on the target port.
      Both hosts have multiple custom rules:
      - For incoming packets, only local table is traversed.
      - For outgoing packets, 3 tables are traversed to find the route.
      The packet processing rate on the receiver is as follows:
      - Before the fix: 3.78Mpps
      - After the fix:  5.50Mpps
      
      v2->v3:
      - Handled fib6_rule_lookup() when CONFIG_IPV6_MULTIPLE_TABLES is not
        configured in patch 03 (suggested by David Ahern)
      - Removed the renaming of l3mdev_link_scope_lookup() in patch 05
        (suggested by David Ahern)
      - Moved definition of ip6_route_output_flags() from an inline function
        in /net/ipv6/route.c to net/ipv6/route.c in order to address kbuild
        error in patch 05
      
      v1->v2:
      - Added a helper ip6_rt_put_flags() in patch 3 suggested by David Miller
      ====================
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7d30a7f6
    • Wei Wang's avatar
      ipv6: convert major tx path to use RT6_LOOKUP_F_DST_NOREF · 7d9e5f42
      Wei Wang authored
      For tx path, in most cases, we still have to take refcnt on the dst
      cause the caller is caching the dst somewhere. But it still is
      beneficial to make use of RT6_LOOKUP_F_DST_NOREF flag while doing the
      route lookup. It is cause this flag prevents manipulating refcnt on
      net->ipv6.ip6_null_entry when doing fib6_rule_lookup() to traverse each
      routing table. The null_entry is a shared object and constant updates on
      it cause false sharing.
      
      We converted the current major lookup function ip6_route_output_flags()
      to make use of RT6_LOOKUP_F_DST_NOREF.
      
      Together with the change in the rx path, we see noticable performance
      boost:
      I ran synflood tests between 2 hosts under the same switch. Both hosts
      have 20G mlx NIC, and 8 tx/rx queues.
      Sender sends pure SYN flood with random src IPs and ports using trafgen.
      Receiver has a simple TCP listener on the target port.
      Both hosts have multiple custom rules:
      - For incoming packets, only local table is traversed.
      - For outgoing packets, 3 tables are traversed to find the route.
      The packet processing rate on the receiver is as follows:
      - Before the fix: 3.78Mpps
      - After the fix:  5.50Mpps
      Signed-off-by: default avatarWei Wang <weiwan@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7d9e5f42
    • Wei Wang's avatar
      ipv6: convert rx data path to not take refcnt on dst · 67f415dd
      Wei Wang authored
      ip6_route_input() is the key function to do the route lookup in the
      rx data path. All the callers to this function are already holding rcu
      lock. So it is fairly easy to convert it to not take refcnt on the dst:
      We pass in flag RT6_LOOKUP_F_DST_NOREF and do skb_dst_set_noref().
      This saves a few atomic inc or dec operations and should boost
      performance overall.
      This also makes the logic more aligned with v4.
      Signed-off-by: default avatarWei Wang <weiwan@google.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      67f415dd
    • Wei Wang's avatar
      ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic · d64a1f57
      Wei Wang authored
      This patch specifically converts the rule lookup logic to honor this
      flag and not release refcnt when traversing each rule and calling
      lookup() on each routing table.
      Similar to previous patch, we also need some special handling of dst
      entries in uncached list because there is always 1 refcnt taken for them
      even if RT6_LOOKUP_F_DST_NOREF flag is set.
      Signed-off-by: default avatarWei Wang <weiwan@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d64a1f57
    • Wei Wang's avatar
      ipv6: initialize rt6->rt6i_uncached in all pre-allocated dst entries · 74109218
      Wei Wang authored
      Initialize rt6->rt6i_uncached on the following pre-allocated dsts:
      net->ipv6.ip6_null_entry
      net->ipv6.ip6_prohibit_entry
      net->ipv6.ip6_blk_hole_entry
      
      This is a preparation patch for later commits to be able to distinguish
      dst entries in uncached list by doing:
      !list_empty(rt6->rt6i_uncached)
      Signed-off-by: default avatarWei Wang <weiwan@google.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      74109218
    • Wei Wang's avatar
      ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route() · 0e09edcc
      Wei Wang authored
      This new flag is to instruct the route lookup function to not take
      refcnt on the dst entry. The user which does route lookup with this flag
      must properly use rcu protection.
      ip6_pol_route() is the major route lookup function for both tx and rx
      path.
      In this function:
      Do not take refcnt on dst if RT6_LOOKUP_F_DST_NOREF flag is set, and
      directly return the route entry. The caller should be holding rcu lock
      when using this flag, and decide whether to take refcnt or not.
      
      One note on the dst cache in the uncached_list:
      As uncached_list does not consume refcnt, one refcnt is always returned
      back to the caller even if RT6_LOOKUP_F_DST_NOREF flag is set.
      Uncached dst is only possible in the output path. So in such call path,
      caller MUST check if the dst is in the uncached_list before assuming
      that there is no refcnt taken on the returned dst.
      Signed-off-by: default avatarWei Wang <weiwan@google.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0e09edcc
    • Russell King's avatar
      doc: phy: document some PHY_INTERFACE_MODE_xxx settings · 8c25c0cb
      Russell King authored
      There seems to be some confusion surrounding three PHY interface modes,
      specifically 1000BASE-X, 2500BASE-X and SGMII.  Add some documentation
      to phylib detailing precisely what these interface modes refer to.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8c25c0cb
    • Qian Cai's avatar
      inet: fix compilation warnings in fqdir_pre_exit() · 08003d0b
      Qian Cai authored
      The linux-next commit "inet: fix various use-after-free in defrags
      units" [1] introduced compilation warnings,
      
      ./include/net/inet_frag.h:117:1: warning: 'inline' is not at beginning
      of declaration [-Wold-style-declaration]
       static void inline fqdir_pre_exit(struct fqdir *fqdir)
       ^~~~~~
      In file included from ./include/net/netns/ipv4.h:10,
                       from ./include/net/net_namespace.h:20,
                       from ./include/linux/netdevice.h:38,
                       from ./include/linux/icmpv6.h:13,
                       from ./include/linux/ipv6.h:86,
                       from ./include/net/ipv6.h:12,
                       from ./include/rdma/ib_verbs.h:51,
                       from ./include/linux/mlx5/device.h:37,
                       from ./include/linux/mlx5/driver.h:51,
                       from
      drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c:37:
      
      [1] https://lore.kernel.org/netdev/20190618180900.88939-3-edumazet@google.com/Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      08003d0b
    • Rasmus Villemoes's avatar
      net: dsa: mv88e6xxx: introduce helpers for handling chip->reg_lock · c9acece0
      Rasmus Villemoes authored
      This is a no-op that simply moves all locking and unlocking of
      ->reg_lock into trivial helpers. I did that to be able to easily add
      some ad hoc instrumentation to those helpers to get some information
      on contention and hold times of the mutex. Perhaps others want to do
      something similar at some point, so this frees them from doing the
      'sed -i' yoga, and have a much smaller 'git diff' while fiddling.
      Signed-off-by: default avatarRasmus Villemoes <rasmus.villemoes@prevas.dk>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c9acece0
    • Sameeh Jubran's avatar
      net: ena: Fix bug where ring allocation backoff stopped too late · 3e5bfb18
      Sameeh Jubran authored
      The current code of create_queues_with_size_backoff() allows the ring size
      to become as small as ENA_MIN_RING_SIZE/2. This is a bug since we don't
      want the queue ring to be smaller than ENA_MIN_RING_SIZE
      
      In this commit we change the loop's termination condition to look at the
      queue size of the next iteration instead of that of the current one,
      so that the minimal queue size again becomes ENA_MIN_RING_SIZE.
      
      Fixes: eece4d2a ("net: ena: add ethtool function for changing io queue sizes")
      Signed-off-by: default avatarArthur Kiyanovski <akiyano@amazon.com>
      Signed-off-by: default avatarSameeh Jubran <sameehj@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3e5bfb18
    • Colin Ian King's avatar
      hinic: fix dereference of pointer hwdev before it is null checked · 137e4e1a
      Colin Ian King authored
      Currently pointer hwdev is dereferenced when assigning hwif before
      hwdev is null checked.  Fix this by only derefencing hwdev after the
      null check.
      
      Addresses-Coverity: ("Dereference before null check")
      Fixes: 4fdc51bb ("hinic: add support for rss parameters with ethtool")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      137e4e1a
  3. 22 Jun, 2019 4 commits