Skip to content

Commit

Permalink
Merge tag 'net-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/netdev/net

Pull networking fixes from Jakub Kicinski:
 "We have a few fixes for long standing issues, in particular Eric's fix
  to not underestimate the skb sizes, and my fix for brokenness of
  register_netdevice() error path. They may uncover other bugs so we
  will keep an eye on them. Also included are Willem's fixes for
  kmap(_atomic).

  Looking at the "current release" fixes, it seems we are about one rc
  behind a normal cycle. We've previously seen an uptick of "people had
  run their test suites" / "humans actually tried to use new features"
  fixes between rc2 and rc3.

  Summary:

  Current release - regressions:

   - fix feature enforcement to allow NETIF_F_HW_TLS_TX if IP_CSUM &&
     IPV6_CSUM

   - dcb: accept RTM_GETDCB messages carrying set-like DCB commands if
     user is admin for backward-compatibility

   - selftests/tls: fix selftests build after adding ChaCha20-Poly1305

  Current release - always broken:

   - ppp: fix refcount underflow on channel unbridge

   - bnxt_en: clear DEFRAG flag in firmware message when retry flashing

   - smc: fix out of bound access in the new netlink interface

  Previous releases - regressions:

   - fix use-after-free with UDP GRO by frags

   - mptcp: better msk-level shutdown

   - rndis_host: set proper input size for OID_GEN_PHYSICAL_MEDIUM
     request

   - i40e: xsk: fix potential NULL pointer dereferencing

  Previous releases - always broken:

   - skb frag: kmap_atomic fixes

   - avoid 32 x truesize under-estimation for tiny skbs

   - fix issues around register_netdevice() failures

   - udp: prevent reuseport_select_sock from reading uninitialized socks

   - dsa: unbind all switches from tree when DSA master unbinds

   - dsa: clear devlink port type before unregistering slave netdevs

   - can: isotp: isotp_getname(): fix kernel information leak

   - mlxsw: core: Thermal control fixes

   - ipv6: validate GSO SKB against MTU before finish IPv6 processing

   - stmmac: use __napi_schedule() for PREEMPT_RT

   - net: mvpp2: remove Pause and Asym_Pause support

  Misc:

   - remove from MAINTAINERS folks who had been inactive for >5yrs"

* tag 'net-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (58 commits)
  mptcp: fix locking in mptcp_disconnect()
  net: Allow NETIF_F_HW_TLS_TX if IP_CSUM && IPV6_CSUM
  MAINTAINERS: dccp: move Gerrit Renker to CREDITS
  MAINTAINERS: ipvs: move Wensong Zhang to CREDITS
  MAINTAINERS: tls: move Aviad to CREDITS
  MAINTAINERS: ena: remove Zorik Machulsky from reviewers
  MAINTAINERS: vrf: move Shrijeet to CREDITS
  MAINTAINERS: net: move Alexey Kuznetsov to CREDITS
  MAINTAINERS: altx: move Jay Cliburn to CREDITS
  net: avoid 32 x truesize under-estimation for tiny skbs
  nt: usb: USB_RTL8153_ECM should not default to y
  net: stmmac: fix taprio configuration when base_time is in the past
  net: stmmac: fix taprio schedule configuration
  net: tip: fix a couple kernel-doc markups
  net: sit: unregister_netdevice on newlink's error path
  net: stmmac: Fixed mtu channged by cache aligned
  cxgb4/chtls: Fix tid stuck due to wrong update of qid
  i40e: fix potential NULL pointer dereferencing
  net: stmmac: use __napi_schedule() for PREEMPT_RT
  can: mcp251xfd: mcp251xfd_handle_rxif_one(): fix wrong NULL pointer check
  ...
  • Loading branch information
torvalds committed Jan 14, 2021
2 parents 2bbe17a + 13a9499 commit e8c13a6
Show file tree
Hide file tree
Showing 54 changed files with 569 additions and 223 deletions.
24 changes: 24 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ S: Las Cuevas 2385 - Bo Guemes
S: Las Heras, Mendoza CP 5539
S: Argentina

N: Jay Cliburn
E: [email protected]
D: ATLX Ethernet drivers

N: Steven P. Cole
E: [email protected]
E: [email protected]
Expand Down Expand Up @@ -1284,6 +1288,10 @@ D: Major kbuild rework during the 2.5 cycle
D: ISDN Maintainer
S: USA

N: Gerrit Renker
E: [email protected]
D: DCCP protocol support.

N: Philip Gladstone
E: [email protected]
D: Kernel / timekeeping stuff
Expand Down Expand Up @@ -2138,6 +2146,10 @@ E: [email protected]
E: [email protected]
D: Original author of software suspend

N: Alexey Kuznetsov
E: [email protected]
D: Author and maintainer of large parts of the networking stack

N: Jaroslav Kysela
E: [email protected]
W: https://www.perex.cz
Expand Down Expand Up @@ -2696,6 +2708,10 @@ N: Wolfgang Muees
E: [email protected]
D: Auerswald USB driver

N: Shrijeet Mukherjee
E: [email protected]
D: Network routing domains (VRF).

N: Paul Mundt
E: [email protected]
D: SuperH maintainer
Expand Down Expand Up @@ -4110,6 +4126,10 @@ S: B-1206 Jingmao Guojigongyu
S: 16 Baliqiao Nanjie, Beijing 101100
S: People's Repulic of China

N: Aviad Yehezkel
E: [email protected]
D: Kernel TLS implementation and offload support.

N: Victor Yodaiken
E: [email protected]
D: RTLinux (RealTime Linux)
Expand Down Expand Up @@ -4167,6 +4187,10 @@ S: 1507 145th Place SE #B5
S: Bellevue, Washington 98007
S: USA

N: Wensong Zhang
E: [email protected]
D: IP virtual server (IPVS).

N: Haojian Zhuang
E: [email protected]
D: MMP support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ allOf:
enum:
- renesas,etheravb-r8a774a1
- renesas,etheravb-r8a774b1
- renesas,etheravb-r8a774e1
- renesas,etheravb-r8a7795
- renesas,etheravb-r8a7796
- renesas,etheravb-r8a77961
Expand Down
8 changes: 6 additions & 2 deletions Documentation/devicetree/bindings/net/snps,dwmac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ properties:
* snps,route-dcbcp, DCB Control Packets
* snps,route-up, Untagged Packets
* snps,route-multi-broad, Multicast & Broadcast Packets
* snps,priority, RX queue priority (Range 0x0 to 0xF)
* snps,priority, bitmask of the tagged frames priorities assigned to
the queue

snps,mtl-tx-config:
$ref: /schemas/types.yaml#/definitions/phandle
Expand All @@ -188,7 +189,10 @@ properties:
* snps,idle_slope, unlock on WoL
* snps,high_credit, max write outstanding req. limit
* snps,low_credit, max read outstanding req. limit
* snps,priority, TX queue priority (Range 0x0 to 0xF)
* snps,priority, bitmask of the priorities assigned to the queue.
When a PFC frame is received with priorities matching the bitmask,
the queue is blocked from transmitting for the pause time specified
in the PFC frame.

snps,reset-gpio:
deprecated: true
Expand Down
171 changes: 165 additions & 6 deletions Documentation/networking/netdevices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,177 @@ Introduction
The following is a random collection of documentation regarding
network devices.

struct net_device allocation rules
==================================
struct net_device lifetime rules
================================
Network device structures need to persist even after module is unloaded and
must be allocated with alloc_netdev_mqs() and friends.
If device has registered successfully, it will be freed on last use
by free_netdev(). This is required to handle the pathologic case cleanly
(example: rmmod mydriver </sys/class/net/myeth/mtu )
by free_netdev(). This is required to handle the pathological case cleanly
(example: ``rmmod mydriver </sys/class/net/myeth/mtu``)

alloc_netdev_mqs()/alloc_netdev() reserve extra space for driver
alloc_netdev_mqs() / alloc_netdev() reserve extra space for driver
private data which gets freed when the network device is freed. If
separately allocated data is attached to the network device
(netdev_priv(dev)) then it is up to the module exit handler to free that.
(netdev_priv()) then it is up to the module exit handler to free that.

There are two groups of APIs for registering struct net_device.
First group can be used in normal contexts where ``rtnl_lock`` is not already
held: register_netdev(), unregister_netdev().
Second group can be used when ``rtnl_lock`` is already held:
register_netdevice(), unregister_netdevice(), free_netdevice().

Simple drivers
--------------

Most drivers (especially device drivers) handle lifetime of struct net_device
in context where ``rtnl_lock`` is not held (e.g. driver probe and remove paths).

In that case the struct net_device registration is done using
the register_netdev(), and unregister_netdev() functions:

.. code-block:: c
int probe()
{
struct my_device_priv *priv;
int err;
dev = alloc_netdev_mqs(...);
if (!dev)
return -ENOMEM;
priv = netdev_priv(dev);
/* ... do all device setup before calling register_netdev() ...
*/
err = register_netdev(dev);
if (err)
goto err_undo;
/* net_device is visible to the user! */
err_undo:
/* ... undo the device setup ... */
free_netdev(dev);
return err;
}
void remove()
{
unregister_netdev(dev);
free_netdev(dev);
}
Note that after calling register_netdev() the device is visible in the system.
Users can open it and start sending / receiving traffic immediately,
or run any other callback, so all initialization must be done prior to
registration.

unregister_netdev() closes the device and waits for all users to be done
with it. The memory of struct net_device itself may still be referenced
by sysfs but all operations on that device will fail.

free_netdev() can be called after unregister_netdev() returns on when
register_netdev() failed.

Device management under RTNL
----------------------------

Registering struct net_device while in context which already holds
the ``rtnl_lock`` requires extra care. In those scenarios most drivers
will want to make use of struct net_device's ``needs_free_netdev``
and ``priv_destructor`` members for freeing of state.

Example flow of netdev handling under ``rtnl_lock``:

.. code-block:: c
static void my_setup(struct net_device *dev)
{
dev->needs_free_netdev = true;
}
static void my_destructor(struct net_device *dev)
{
some_obj_destroy(priv->obj);
some_uninit(priv);
}
int create_link()
{
struct my_device_priv *priv;
int err;
ASSERT_RTNL();
dev = alloc_netdev(sizeof(*priv), "net%d", NET_NAME_UNKNOWN, my_setup);
if (!dev)
return -ENOMEM;
priv = netdev_priv(dev);
/* Implicit constructor */
err = some_init(priv);
if (err)
goto err_free_dev;
priv->obj = some_obj_create();
if (!priv->obj) {
err = -ENOMEM;
goto err_some_uninit;
}
/* End of constructor, set the destructor: */
dev->priv_destructor = my_destructor;
err = register_netdevice(dev);
if (err)
/* register_netdevice() calls destructor on failure */
goto err_free_dev;
/* If anything fails now unregister_netdevice() (or unregister_netdev())
* will take care of calling my_destructor and free_netdev().
*/
return 0;
err_some_uninit:
some_uninit(priv);
err_free_dev:
free_netdev(dev);
return err;
}
If struct net_device.priv_destructor is set it will be called by the core
some time after unregister_netdevice(), it will also be called if
register_netdevice() fails. The callback may be invoked with or without
``rtnl_lock`` held.

There is no explicit constructor callback, driver "constructs" the private
netdev state after allocating it and before registration.

Setting struct net_device.needs_free_netdev makes core call free_netdevice()
automatically after unregister_netdevice() when all references to the device
are gone. It only takes effect after a successful call to register_netdevice()
so if register_netdevice() fails driver is responsible for calling
free_netdev().

free_netdev() is safe to call on error paths right after unregister_netdevice()
or when register_netdevice() fails. Parts of netdev (de)registration process
happen after ``rtnl_lock`` is released, therefore in those cases free_netdev()
will defer some of the processing until ``rtnl_lock`` is released.

Devices spawned from struct rtnl_link_ops should never free the
struct net_device directly.

.ndo_init and .ndo_uninit
~~~~~~~~~~~~~~~~~~~~~~~~~

``.ndo_init`` and ``.ndo_uninit`` callbacks are called during net_device
registration and de-registration, under ``rtnl_lock``. Drivers can use
those e.g. when parts of their init process need to run under ``rtnl_lock``.

``.ndo_init`` runs before device is visible in the system, ``.ndo_uninit``
runs during de-registering after device is closed but other subsystems
may still have outstanding references to the netdevice.

MTU
===
Expand Down
2 changes: 1 addition & 1 deletion Documentation/networking/tls-offload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ TLS device feature flags only control adding of new TLS connection
offloads, old connections will remain active after flags are cleared.

TLS encryption cannot be offloaded to devices without checksum calculation
offload. Hence, TLS TX device feature flag requires NETIF_F_HW_CSUM being set.
offload. Hence, TLS TX device feature flag requires TX csum offload being set.
Disabling the latter implies clearing the former. Disabling TX checksum offload
should not affect old connections, and drivers should make sure checksum
calculation does not break for them.
9 changes: 1 addition & 8 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ M: Netanel Belgazal <[email protected]>
M: Arthur Kiyanovski <[email protected]>
R: Guy Tzalik <[email protected]>
R: Saeed Bishara <[email protected]>
R: Zorik Machulsky <[email protected]>
L: [email protected]
S: Supported
F: Documentation/networking/device_drivers/ethernet/amazon/ena.rst
Expand Down Expand Up @@ -2942,7 +2941,6 @@ S: Maintained
F: drivers/hwmon/asus_atk0110.c

ATLX ETHERNET DRIVERS
M: Jay Cliburn <[email protected]>
M: Chris Snook <[email protected]>
L: [email protected]
S: Maintained
Expand Down Expand Up @@ -4922,9 +4920,8 @@ F: Documentation/scsi/dc395x.rst
F: drivers/scsi/dc395x.*

DCCP PROTOCOL
M: Gerrit Renker <[email protected]>
L: [email protected]
S: Maintained
S: Orphan
W: http://www.linuxfoundation.org/collaborate/workgroups/networking/dccp
F: include/linux/dccp.h
F: include/linux/tfrc.h
Expand Down Expand Up @@ -9326,7 +9323,6 @@ W: http://www.adaptec.com/
F: drivers/scsi/ips*

IPVS
M: Wensong Zhang <[email protected]>
M: Simon Horman <[email protected]>
M: Julian Anastasov <[email protected]>
L: [email protected]
Expand Down Expand Up @@ -12416,7 +12412,6 @@ F: tools/testing/selftests/net/ipsec.c

NETWORKING [IPv4/IPv6]
M: "David S. Miller" <[email protected]>
M: Alexey Kuznetsov <[email protected]>
M: Hideaki YOSHIFUJI <[email protected]>
L: [email protected]
S: Maintained
Expand Down Expand Up @@ -12473,7 +12468,6 @@ F: net/ipv6/tcp*.c

NETWORKING [TLS]
M: Boris Pismenny <[email protected]>
M: Aviad Yehezkel <[email protected]>
M: John Fastabend <[email protected]>
M: Daniel Borkmann <[email protected]>
M: Jakub Kicinski <[email protected]>
Expand Down Expand Up @@ -19071,7 +19065,6 @@ K: regulator_get_optional

VRF
M: David Ahern <[email protected]>
M: Shrijeet Mukherjee <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/networking/vrf.rst
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv,
else
skb = alloc_can_skb(priv->ndev, (struct can_frame **)&cfd);

if (!cfd) {
if (!skb) {
stats->rx_dropped++;
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2532,7 +2532,7 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware

if (rc && ((struct hwrm_err_output *)&resp)->cmd_err ==
NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) {
install.flags |=
install.flags =
cpu_to_le16(NVM_INSTALL_UPDATE_REQ_FLAGS_ALLOWED_TO_DEFRAG);

rc = _hwrm_send_message_silent(bp, &install,
Expand All @@ -2546,6 +2546,7 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
* UPDATE directory and try the flash again
*/
defrag_attempted = true;
install.flags = 0;
rc = __bnxt_flash_nvram(bp->dev,
BNX_DIR_TYPE_UPDATE,
BNX_DIR_ORDINAL_FIRST,
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ int bnxt_get_ulp_msix_base(struct bnxt *bp)

int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
{
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP))
return BNXT_MIN_ROCE_STAT_CTXS;
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
struct bnxt_en_dev *edev = bp->edev;

if (edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested)
return BNXT_MIN_ROCE_STAT_CTXS;
}

return 0;
}
Expand Down
Loading

0 comments on commit e8c13a6

Please sign in to comment.