Skip to content
  1. Aug 10, 2021
  2. Aug 09, 2021
    • Hangbin Liu's avatar
      net: sched: act_mirred: Reset ct info when mirror/redirect skb · d09c548d
      Hangbin Liu authored
      When mirror/redirect a skb to a different port, the ct info should be reset
      for reclassification. Or the pkts will match unexpected rules. For example,
      with following topology and commands:
      
          -----------
                    |
             veth0 -+-------
                    |
             veth1 -+-------
                    |
         ------------
      
       tc qdisc add dev veth0 clsact
       # The same with "action mirred egress mirror dev veth1" or "action mirred ingress redirect dev veth1"
       tc filter add dev veth0 egress chain 1 protocol ip flower ct_state +trk action mirred ingress mirror dev veth1
       tc filter add dev veth0 egress chain 0 protocol ip flower ct_state -inv action ct commit action goto chain 1
       tc qdisc add dev veth1 clsact
       tc filter add dev veth1 ingress chain 0 protocol ip flower ct_state +trk action drop
      
       ping <remove ip via veth0> &
       tc -s filter show dev veth1 ingress
      
      With command 'tc -s filter show', we can find the pkts were dropped on
      veth1.
      
      Fixes: b57dc7c1
      
       ("net/sched: Introduce action ct")
      Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d09c548d
    • David S. Miller's avatar
      Merge branch 'smc-fixes' · 605bb443
      David S. Miller authored
      
      
      Guvenc Gulce says:
      
      ====================
      net/smc: fixes 2021-08-09
      
      please apply the following patch series for smc to netdev's net tree.
      One patch fixes invalid connection counting for links and the other
      one fixes an access to an already cleared link.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      605bb443
    • Guvenc Gulce's avatar
      net/smc: Correct smc link connection counter in case of smc client · 64513d26
      Guvenc Gulce authored
      SMC clients may be assigned to a different link after the initial
      connection between two peers was established. In such a case,
      the connection counter was not correctly set.
      
      Update the connection counter correctly when a smc client connection
      is assigned to a different smc link.
      
      Fixes: 07d51580
      
       ("net/smc: Add connection counters for links")
      Signed-off-by: default avatarGuvenc Gulce <guvenc@linux.ibm.com>
      Tested-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      64513d26
    • Karsten Graul's avatar
      net/smc: fix wait on already cleared link · 8f3d65c1
      Karsten Graul authored
      There can be a race between the waiters for a tx work request buffer
      and the link down processing that finally clears the link. Although
      all waiters are woken up before the link is cleared there might be
      waiters which did not yet get back control and are still waiting.
      This results in an access to a cleared wait queue head.
      
      Fix this by introducing atomic reference counting around the wait calls,
      and wait with the link clear processing until all waiters have finished.
      Move the work request layer related calls into smc_wr.c and set the
      link state to INACTIVE before calling smcr_link_clear() in
      smc_llc_srv_add_link().
      
      Fixes: 15e1b99a
      
       ("net/smc: no WR buffer wait for terminating link group")
      Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarGuvenc Gulce <guvenc@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8f3d65c1
    • Grygorii Strashko's avatar
      net: ethernet: ti: cpsw: fix min eth packet size for non-switch use-cases · acc68b8d
      Grygorii Strashko authored
      The CPSW switchdev driver inherited fix from commit 9421c901 ("net:
      ethernet: ti: cpsw: fix min eth packet size") which changes min TX packet
      size to 64bytes (VLAN_ETH_ZLEN, excluding ETH_FCS). It was done to fix HW
      packed drop issue when packets are sent from Host to the port with PVID and
      un-tagging enabled. Unfortunately this breaks some other non-switch
      specific use-cases, like:
      - [1] CPSW port as DSA CPU port with DSA-tag applied at the end of the
      packet
      - [2] Some industrial protocols, which expects min TX packet size 60Bytes
      (excluding FCS).
      
      Fix it by configuring min TX packet size depending on driver mode
       - 60Bytes (ETH_ZLEN) for multi mac (dual-mac) mode
       - 64Bytes (VLAN_ETH_ZLEN) for switch mode
      and update it during driver mode change and annotate with
      READ_ONCE()/WRITE_ONCE() as it can be read by napi while writing.
      
      [1] https://lore.kernel.org/netdev/20210531124051.GA15218@cephalopod/
      [2] https://e2e.ti.com/support/arm/sitara_arm/f/791/t/701669
      
      Cc: stable@vger.kernel.org
      Fixes: ed3525ed
      
       ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac")
      Reported-by: default avatarBen Hutchings <ben.hutchings@essensium.com>
      Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      acc68b8d
    • Yunsheng Lin's avatar
      page_pool: mask the page->signature before the checking · 0fa32ca4
      Yunsheng Lin authored
      As mentioned in commit c07aea3e ("mm: add a signature in
      struct page"):
      "The page->signature field is aliased to page->lru.next and
      page->compound_head."
      
      And as the comment in page_is_pfmemalloc():
      "lru.next has bit 1 set if the page is allocated from the
      pfmemalloc reserves. Callers may simply overwrite it if they
      do not need to preserve that information."
      
      The page->signature is OR’ed with PP_SIGNATURE when a page is
      allocated in page pool, see __page_pool_alloc_pages_slow(),
      and page->signature is checked directly with PP_SIGNATURE in
      page_pool_return_skb_page(), which might cause resoure leaking
      problem for a page from page pool if bit 1 of lru.next is set
      for a pfmemalloc page. What happens here is that the original
      pp->signature is OR'ed with PP_SIGNATURE after the allocation
      in order to preserve any existing bits(such as the bit 1, used
      to indicate a pfmemalloc page), so when those bits are present,
      those page is not considered to be from page pool and the DMA
      mapping of those pages will be left stale.
      
      As bit 0 is for page->compound_head, So mask both bit 0/1 before
      the checking in page_pool_return_skb_page(). And we will return
      those pfmemalloc pages back to the page allocator after cleaning
      up the DMA mapping.
      
      Fixes: 6a5bcd84
      
       ("page_pool: Allow drivers to hint on SKB recycling")
      Reviewed-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0fa32ca4
    • Randy Dunlap's avatar
      dccp: add do-while-0 stubs for dccp_pr_debug macros · 86aab09a
      Randy Dunlap authored
      GCC complains about empty macros in an 'if' statement, so convert
      them to 'do {} while (0)' macros.
      
      Fixes these build warnings:
      
      net/dccp/output.c: In function 'dccp_xmit_packet':
      ../net/dccp/output.c:283:71: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
        283 |                 dccp_pr_debug("transmit_skb() returned err=%d\n", err);
      net/dccp/ackvec.c: In function 'dccp_ackvec_update_old':
      ../net/dccp/ackvec.c:163:80: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
        163 |                                               (unsigned long long)seqno, state);
      
      Fixes: dc841e30 ("dccp: Extend CCID packet dequeueing interface")
      Fixes: 38024086
      
       ("dccp ccid-2: Update code for the Ack Vector input/registration routine")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: dccp@vger.kernel.org
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Gerrit Renker <gerrit@erg.abdn.ac.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      86aab09a
  3. Aug 08, 2021
    • Pali Rohár's avatar
      ppp: Fix generating ppp unit id when ifname is not specified · 3125f26c
      Pali Rohár authored
      
      
      When registering new ppp interface via PPPIOCNEWUNIT ioctl then kernel has
      to choose interface name as this ioctl API does not support specifying it.
      
      Kernel in this case register new interface with name "ppp<id>" where <id>
      is the ppp unit id, which can be obtained via PPPIOCGUNIT ioctl. This
      applies also in the case when registering new ppp interface via rtnl
      without supplying IFLA_IFNAME.
      
      PPPIOCNEWUNIT ioctl allows to specify own ppp unit id which will kernel
      assign to ppp interface, in case this ppp id is not already used by other
      ppp interface.
      
      In case user does not specify ppp unit id then kernel choose the first free
      ppp unit id. This applies also for case when creating ppp interface via
      rtnl method as it does not provide a way for specifying own ppp unit id.
      
      If some network interface (does not have to be ppp) has name "ppp<id>"
      with this first free ppp id then PPPIOCNEWUNIT ioctl or rtnl call fails.
      
      And registering new ppp interface is not possible anymore, until interface
      which holds conflicting name is renamed. Or when using rtnl method with
      custom interface name in IFLA_IFNAME.
      
      As list of allocated / used ppp unit ids is not possible to retrieve from
      kernel to userspace, userspace has no idea what happens nor which interface
      is doing this conflict.
      
      So change the algorithm how ppp unit id is generated. And choose the first
      number which is not neither used as ppp unit id nor in some network
      interface with pattern "ppp<id>".
      
      This issue can be simply reproduced by following pppd call when there is no
      ppp interface registered and also no interface with name pattern "ppp<id>":
      
          pppd ifname ppp1 +ipv6 noip noauth nolock local nodetach pty "pppd +ipv6 noip noauth nolock local nodetach notty"
      
      Or by creating the one ppp interface (which gets assigned ppp unit id 0),
      renaming it to "ppp1" and then trying to create a new ppp interface (which
      will always fails as next free ppp unit id is 1, but network interface with
      name "ppp1" exists).
      
      This patch fixes above described issue by generating new and new ppp unit
      id until some non-conflicting id with network interfaces is generated.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3125f26c
    • Pali Rohár's avatar
      ppp: Fix generating ifname when empty IFLA_IFNAME is specified · 2459dcb9
      Pali Rohár authored
      
      
      IFLA_IFNAME is nul-term string which means that IFLA_IFNAME buffer can be
      larger than length of string which contains.
      
      Function __rtnl_newlink() generates new own ifname if either IFLA_IFNAME
      was not specified at all or userspace passed empty nul-term string.
      
      It is expected that if userspace does not specify ifname for new ppp netdev
      then kernel generates one in format "ppp<id>" where id matches to the ppp
      unit id which can be later obtained by PPPIOCGUNIT ioctl.
      
      And it works in this way if IFLA_IFNAME is not specified at all. But it
      does not work when IFLA_IFNAME is specified with empty string.
      
      So fix this logic also for empty IFLA_IFNAME in ppp_nl_newlink() function
      and correctly generates ifname based on ppp unit identifier if userspace
      did not provided preferred ifname.
      
      Without this patch when IFLA_IFNAME was specified with empty string then
      kernel created a new ppp interface in format "ppp<id>" but id did not
      match ppp unit id returned by PPPIOCGUNIT ioctl. In this case id was some
      number generated by __rtnl_newlink() function.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Fixes: bb8082f6
      
       ("ppp: build ifname using unit identifier for rtnl based devices")
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2459dcb9
    • David S. Miller's avatar
      Merge branch 'bnxt_en-ptp-fixes' · 2f5501a8
      David S. Miller authored
      
      
      Michael Chan says:
      
      ====================
      bnxt_en: PTP fixes
      
      This series includes 2 fixes for the PTP feature.  Update to the new
      firmware interface so that the driver can pass the PTP sequence number
      header offset of TX packets to the firmware.  This is needed for all
      PTP packet types (v1, v2, with or without VLAN) to work.  The 2nd
      fix is to use a different register window to read the PHC to avoid
      conflict with an older Broadcom tool.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2f5501a8
    • Michael Chan's avatar
      bnxt_en: Use register window 6 instead of 5 to read the PHC · 92529df7
      Michael Chan authored
      Some older Broadcom debug tools use window 5 and may conflict, so switch
      to use window 6 instead.
      
      Fixes: 118612d5
      
       ("bnxt_en: Add PTP clock APIs, ioctls, and ethtool methods")
      Reviewed-by: default avatarAndy Gospodarek <gospo@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      92529df7
    • Michael Chan's avatar
      bnxt_en: Update firmware call to retrieve TX PTP timestamp · 9e266807
      Michael Chan authored
      New firmware interface requires the PTP sequence ID header offset to
      be passed to the firmware to properly find the matching timestamp
      for all protocols.
      
      Fixes: 83bb623c
      
       ("bnxt_en: Transmit and retrieve packet timestamps")
      Reviewed-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9e266807
    • Michael Chan's avatar
      bnxt_en: Update firmware interface to 1.10.2.52 · fbfee257
      Michael Chan authored
      
      
      The key change is the firmware call to retrieve the PTP TX timestamp.
      The header offset for the PTP sequence number field is now added.
      
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fbfee257
    • Kefeng Wang's avatar
      once: Fix panic when module unload · 1027b96e
      Kefeng Wang authored
      DO_ONCE
      DEFINE_STATIC_KEY_TRUE(___once_key);
      __do_once_done
        once_disable_jump(once_key);
          INIT_WORK(&w->work, once_deferred);
          struct once_work *w;
          w->key = key;
          schedule_work(&w->work);                     module unload
                                                         //*the key is
      destroy*
      process_one_work
        once_deferred
          BUG_ON(!static_key_enabled(work->key));
             static_key_count((struct static_key *)x)    //*access key, crash*
      
      When module uses DO_ONCE mechanism, it could crash due to the above
      concurrency problem, we could reproduce it with link[1].
      
      Fix it by add/put module refcount in the once work process.
      
      [1] https://lore.kernel.org/netdev/eaa6c371-465e-57eb-6be9-f4b16b9d7cbf@huawei.com/
      
      
      
      Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Reported-by: default avatarMinmin chen <chenmingmin@huawei.com>
      Signed-off-by: Kefeng W...
      1027b96e
    • Vinicius Costa Gomes's avatar
      ptp: Fix possible memory leak caused by invalid cast · d329e41a
      Vinicius Costa Gomes authored
      Fixes possible leak of PTP virtual clocks.
      
      The number of PTP virtual clocks to be unregistered is passed as
      'u32', but the function that unregister the devices handles that as
      'u8'.
      
      Fixes: 73f37068
      
       ("ptp: support ptp physical/virtual clocks conversion")
      Signed-off-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d329e41a
    • Ben Hutchings's avatar
      net: phy: micrel: Fix link detection on ksz87xx switch" · 2383cb94
      Ben Hutchings authored
      Commit a5e63c7d "net: phy: micrel: Fix detection of ksz87xx
      switch" broke link detection on the external ports of the KSZ8795.
      
      The previously unused phy_driver structure for these devices specifies
      config_aneg and read_status functions that appear to be designed for a
      fixed link and do not work with the embedded PHYs in the KSZ8795.
      
      Delete the use of these functions in favour of the generic PHY
      implementations which were used previously.
      
      Fixes: a5e63c7d
      
       ("net: phy: micrel: Fix detection of ksz87xx switch")
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@mind.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2383cb94
  4. Aug 07, 2021
  5. Aug 06, 2021
    • Jakub Kicinski's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf · cc4e5eec
      Jakub Kicinski authored
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter fixes for net
      
      The following patchset contains Netfilter fixes for net:
      
      1) Restrict range element expansion in ipset to avoid soft lockup,
         from Jozsef Kadlecsik.
      
      2) Memleak in error path for nf_conntrack_bridge for IPv4 packets,
         from Yajun Deng.
      
      3) Simplify conntrack garbage collection strategy to avoid frequent
         wake-ups, from Florian Westphal.
      
      4) Fix NFNLA_HOOK_FUNCTION_NAME string, do not include module name.
      
      5) Missing chain family netlink attribute in chain description
         in nfnetlink_hook.
      
      6) Incorrect sequence number on nfnetlink_hook dumps.
      
      7) Use netlink request family in reply message for consistency.
      
      8) Remove offload_pickup sysctl, use conntrack for established state
         instead, from Florian Westphal.
      
      9) Translate NFPROTO_INET/ingress to NFPROTO_NETDEV/ingress, since
         NFPROTO_INET is not exposed through nfnetlink_hook.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf:
        netfilter: nfnetlink_hook: translate inet ingress to netdev
        netfilter: conntrack: remove offload_pickup sysctl again
        netfilter: nfnetlink_hook: Use same family as request message
        netfilter: nfnetlink_hook: use the sequence number of the request message
        netfilter: nfnetlink_hook: missing chain family
        netfilter: nfnetlink_hook: strip off module name from hookfn
        netfilter: conntrack: collect all entries in one cycle
        netfilter: nf_conntrack_bridge: Fix memory leak when error
        netfilter: ipset: Limit the maximal range of consecutive elements to add/delete
      ====================
      
      Link: https://lore.kernel.org/r/20210806151149.6356-1-pablo@netfilter.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      cc4e5eec
    • Pablo Neira Ayuso's avatar
      netfilter: nfnetlink_hook: translate inet ingress to netdev · 269fc695
      Pablo Neira Ayuso authored
      The NFPROTO_INET pseudofamily is not exposed through this new netlink
      interface. The netlink dump either shows NFPROTO_IPV4 or NFPROTO_IPV6
      for NFPROTO_INET prerouting/input/forward/output/postrouting hooks.
      The NFNLA_CHAIN_FAMILY attribute provides the family chain, which
      specifies if this hook applies to inet traffic only (either IPv4 or
      IPv6).
      
      Translate the inet/ingress hook to netdev/ingress to fully hide the
      NFPROTO_INET implementation details.
      
      Fixes: e2cf17d3
      
       ("netfilter: add new hook nfnl subsystem")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      269fc695
    • Florian Westphal's avatar
      netfilter: conntrack: remove offload_pickup sysctl again · 4592ee7f
      Florian Westphal authored
      
      
      These two sysctls were added because the hardcoded defaults (2 minutes,
      tcp, 30 seconds, udp) turned out to be too low for some setups.
      
      They appeared in 5.14-rc1 so it should be fine to remove it again.
      
      Marcelo convinced me that there should be no difference between a flow
      that was offloaded vs. a flow that was not wrt. timeout handling.
      Thus the default is changed to those for TCP established and UDP stream,
      5 days and 120 seconds, respectively.
      
      Marcelo also suggested to account for the timeout value used for the
      offloading, this avoids increase beyond the value in the conntrack-sysctl
      and will also instantly expire the conntrack entry with altered sysctls.
      
      Example:
         nf_conntrack_udp_timeout_stream=60
         nf_flowtable_udp_timeout=60
      
      This will remove offloaded udp flows after one minute, rather than two.
      
      An earlier version of this patch also cleared the ASSURED bit to
      allow nf_conntrack to evict the entry via early_drop (i.e., table full).
      However, it looks like we can safely assume that connection timed out
      via HW is still in established state, so this isn't needed.
      
      Quoting Oz:
       [..] the hardware sends all packets with a set FIN flags to sw.
       [..] Connections that are aged in hardware are expected to be in the
       established state.
      
      In case it turns out that back-to-sw-path transition can occur for
      'dodgy' connections too (e.g., one side disappeared while software-path
      would have been in RETRANS timeout), we can adjust this later.
      
      Cc: Oz Shlomo <ozsh@nvidia.com>
      Cc: Paul Blakey <paulb@nvidia.com>
      Suggested-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Reviewed-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Reviewed-by: default avatarOz Shlomo <ozsh@nvidia.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      4592ee7f
    • Pablo Neira Ayuso's avatar
      netfilter: nfnetlink_hook: Use same family as request message · 69311e7c
      Pablo Neira Ayuso authored
      Use the same family as the request message, for consistency. The
      netlink payload provides sufficient information to describe the hook
      object, including the family.
      
      This makes it easier to userspace to correlate the hooks are that
      visited by the packets for a certain family.
      
      Fixes: e2cf17d3
      
       ("netfilter: add new hook nfnl subsystem")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      69311e7c