Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'net-5.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Jakub Kicinski:
"Networking fixes, including fixes from bpf, wireless, netfilter and
wireguard trees.

The bpf vs lockdown+audit fix is the most notable.

Things haven't slowed down just yet, both in terms of regressions in
current release and largish fixes for older code, but we usually see a
slowdown only after -rc5.

Current release - regressions:

- virtio-net: fix page faults and crashes when XDP is enabled

- mlx5e: fix HW timestamping with CQE compression, and make sure they
are only allowed to coexist with capable devices

- stmmac:
- fix kernel panic due to NULL pointer dereference of
mdio_bus_data
- fix double clk unprepare when no PHY device is connected

Current release - new code bugs:

- mt76: a few fixes for the recent MT7921 devices and runtime power
management

Previous releases - regressions:

- ice:
- track AF_XDP ZC enabled queues in bitmap to fix copy mode Tx
- fix allowing VF to request more/less queues via virtchnl
- correct supported and advertised autoneg by using PHY
capabilities
- allow all LLDP packets from PF to Tx

- kbuild: quote OBJCOPY var to avoid a pahole call break the build

Previous releases - always broken:

- bpf, lockdown, audit: fix buggy SELinux lockdown permission checks

- mt76: address the recent FragAttack vulnerabilities not covered by
generic fixes

- ipv6: fix KASAN: slab-out-of-bounds Read in
fib6_nh_flush_exceptions

- Bluetooth:
- fix the erroneous flush_work() order, to avoid double free
- use correct lock to prevent UAF of hdev object

- nfc: fix NULL ptr dereference in llcp_sock_getname() after failed
connect

- ieee802154: multiple fixes to error checking and return values

- igb: fix XDP with PTP enabled

- intel: add correct exception tracing for XDP

- tls: fix use-after-free when TLS offload device goes down and back
up

- ipvs: ignore IP_VS_SVC_F_HASHED flag when adding service

- netfilter: nft_ct: skip expectations for confirmed conntrack

- mptcp: fix falling back to TCP in presence of out of order packets
early in connection lifetime

- wireguard: switch from O(n) to a O(1) algorithm for maintaining
peers, fixing stalls and a large memory leak in the process

Misc:

- devlink: correct VIRTUAL port to not have phys_port attributes

- Bluetooth: fix VIRTIO_ID_BT assigned number

- net: return the correct errno code ENOBUF -> ENOMEM

- wireguard:
- peer: allocate in kmem_cache saving 25% on peer memory
- do not use -O3"

* tag 'net-5.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (91 commits)
cxgb4: avoid link re-train during TC-MQPRIO configuration
sch_htb: fix refcount leak in htb_parent_to_leaf_offload
wireguard: allowedips: free empty intermediate nodes when removing single node
wireguard: allowedips: allocate nodes in kmem_cache
wireguard: allowedips: remove nodes in O(1)
wireguard: allowedips: initialize list head in selftest
wireguard: peer: allocate in kmem_cache
wireguard: use synchronize_net rather than synchronize_rcu
wireguard: do not use -O3
wireguard: selftests: make sure rp_filter is disabled on vethc
wireguard: selftests: remove old conntrack kconfig value
virtchnl: Add missing padding to virtchnl_proto_hdrs
ice: Allow all LLDP packets from PF to Tx
ice: report supported and advertised autoneg using PHY capabilities
ice: handle the VF VSI rebuild failure
ice: Fix VFR issues for AVF drivers that expect ATQLEN cleared
ice: Fix allowing VF to request more/less queues via virtchnl
virtio-net: fix for skb_over_panic inside big mode
ipv6: Fix KASAN: slab-out-of-bounds Read in fib6_nh_flush_exceptions
fib: Return the correct errno code
...

+995 -580
+5 -5
MAINTAINERS
··· 12905 12905 12906 12906 NFC SUBSYSTEM 12907 12907 M: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 12908 - L: linux-nfc@lists.01.org (moderated for non-subscribers) 12908 + L: linux-nfc@lists.01.org (subscribers-only) 12909 12909 L: netdev@vger.kernel.org 12910 12910 S: Maintained 12911 12911 F: Documentation/devicetree/bindings/net/nfc/ ··· 12918 12918 NFC VIRTUAL NCI DEVICE DRIVER 12919 12919 M: Bongsu Jeon <bongsu.jeon@samsung.com> 12920 12920 L: netdev@vger.kernel.org 12921 - L: linux-nfc@lists.01.org (moderated for non-subscribers) 12921 + L: linux-nfc@lists.01.org (subscribers-only) 12922 12922 S: Supported 12923 12923 F: drivers/nfc/virtual_ncidev.c 12924 12924 F: tools/testing/selftests/nci/ ··· 13216 13216 13217 13217 NXP-NCI NFC DRIVER 13218 13218 R: Charles Gorand <charles.gorand@effinnov.com> 13219 - L: linux-nfc@lists.01.org (moderated for non-subscribers) 13219 + L: linux-nfc@lists.01.org (subscribers-only) 13220 13220 S: Supported 13221 13221 F: drivers/nfc/nxp-nci 13222 13222 ··· 16147 16147 SAMSUNG S3FWRN5 NFC DRIVER 16148 16148 M: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 16149 16149 M: Krzysztof Opasiak <k.opasiak@samsung.com> 16150 - L: linux-nfc@lists.01.org (moderated for non-subscribers) 16150 + L: linux-nfc@lists.01.org (subscribers-only) 16151 16151 S: Maintained 16152 16152 F: Documentation/devicetree/bindings/net/nfc/samsung,s3fwrn5.yaml 16153 16153 F: drivers/nfc/s3fwrn5 ··· 18337 18337 TI TRF7970A NFC DRIVER 18338 18338 M: Mark Greer <mgreer@animalcreek.com> 18339 18339 L: linux-wireless@vger.kernel.org 18340 - L: linux-nfc@lists.01.org (moderated for non-subscribers) 18340 + L: linux-nfc@lists.01.org (subscribers-only) 18341 18341 S: Supported 18342 18342 F: Documentation/devicetree/bindings/net/nfc/trf7970a.txt 18343 18343 F: drivers/nfc/trf7970a.c
+21 -2
drivers/bluetooth/btusb.c
··· 2529 2529 } 2530 2530 2531 2531 btusb_setup_intel_newgen_get_fw_name(ver, fwname, sizeof(fwname), "sfi"); 2532 - err = request_firmware(&fw, fwname, &hdev->dev); 2532 + err = firmware_request_nowarn(&fw, fwname, &hdev->dev); 2533 2533 if (err < 0) { 2534 + if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) { 2535 + /* Firmware has already been loaded */ 2536 + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); 2537 + return 0; 2538 + } 2539 + 2534 2540 bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)", 2535 2541 fwname, err); 2542 + 2536 2543 return err; 2537 2544 } 2538 2545 ··· 2689 2682 err = btusb_setup_intel_new_get_fw_name(ver, params, fwname, 2690 2683 sizeof(fwname), "sfi"); 2691 2684 if (err < 0) { 2685 + if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) { 2686 + /* Firmware has already been loaded */ 2687 + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); 2688 + return 0; 2689 + } 2690 + 2692 2691 bt_dev_err(hdev, "Unsupported Intel firmware naming"); 2693 2692 return -EINVAL; 2694 2693 } 2695 2694 2696 - err = request_firmware(&fw, fwname, &hdev->dev); 2695 + err = firmware_request_nowarn(&fw, fwname, &hdev->dev); 2697 2696 if (err < 0) { 2697 + if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) { 2698 + /* Firmware has already been loaded */ 2699 + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); 2700 + return 0; 2701 + } 2702 + 2698 2703 bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)", 2699 2704 fwname, err); 2700 2705 return err;
-2
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
··· 2177 2177 bool persistent, u8 *smt_idx); 2178 2178 int cxgb4_get_msix_idx_from_bmap(struct adapter *adap); 2179 2179 void cxgb4_free_msix_idx_in_bmap(struct adapter *adap, u32 msix_idx); 2180 - int cxgb_open(struct net_device *dev); 2181 - int cxgb_close(struct net_device *dev); 2182 2180 void cxgb4_enable_rx(struct adapter *adap, struct sge_rspq *q); 2183 2181 void cxgb4_quiesce_rx(struct sge_rspq *q); 2184 2182 int cxgb4_port_mirror_alloc(struct net_device *dev);
+2 -2
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
··· 2834 2834 /* 2835 2835 * net_device operations 2836 2836 */ 2837 - int cxgb_open(struct net_device *dev) 2837 + static int cxgb_open(struct net_device *dev) 2838 2838 { 2839 2839 struct port_info *pi = netdev_priv(dev); 2840 2840 struct adapter *adapter = pi->adapter; ··· 2882 2882 return err; 2883 2883 } 2884 2884 2885 - int cxgb_close(struct net_device *dev) 2885 + static int cxgb_close(struct net_device *dev) 2886 2886 { 2887 2887 struct port_info *pi = netdev_priv(dev); 2888 2888 struct adapter *adapter = pi->adapter;
+5 -9
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
··· 997 997 if (!ch_flower) 998 998 return -ENOENT; 999 999 1000 + rhashtable_remove_fast(&adap->flower_tbl, &ch_flower->node, 1001 + adap->flower_ht_params); 1002 + 1000 1003 ret = cxgb4_flow_rule_destroy(dev, ch_flower->fs.tc_prio, 1001 1004 &ch_flower->fs, ch_flower->filter_id); 1002 1005 if (ret) 1003 - goto err; 1006 + netdev_err(dev, "Flow rule destroy failed for tid: %u, ret: %d", 1007 + ch_flower->filter_id, ret); 1004 1008 1005 - ret = rhashtable_remove_fast(&adap->flower_tbl, &ch_flower->node, 1006 - adap->flower_ht_params); 1007 - if (ret) { 1008 - netdev_err(dev, "Flow remove from rhashtable failed"); 1009 - goto err; 1010 - } 1011 1009 kfree_rcu(ch_flower, rcu); 1012 - 1013 - err: 1014 1010 return ret; 1015 1011 } 1016 1012
+6 -3
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c
··· 589 589 * down before configuring tc params. 590 590 */ 591 591 if (netif_running(dev)) { 592 - cxgb_close(dev); 592 + netif_tx_stop_all_queues(dev); 593 + netif_carrier_off(dev); 593 594 needs_bring_up = true; 594 595 } 595 596 ··· 616 615 } 617 616 618 617 out: 619 - if (needs_bring_up) 620 - cxgb_open(dev); 618 + if (needs_bring_up) { 619 + netif_tx_start_all_queues(dev); 620 + netif_carrier_on(dev); 621 + } 621 622 622 623 mutex_unlock(&adap->tc_mqprio->mqprio_mutex); 623 624 return ret;
+6
drivers/net/ethernet/chelsio/cxgb4/sge.c
··· 2556 2556 if (!eosw_txq) 2557 2557 return -ENOMEM; 2558 2558 2559 + if (!(adap->flags & CXGB4_FW_OK)) { 2560 + /* Don't stall caller when access to FW is lost */ 2561 + complete(&eosw_txq->completion); 2562 + return -EIO; 2563 + } 2564 + 2559 2565 skb = alloc_skb(len, GFP_KERNEL); 2560 2566 if (!skb) 2561 2567 return -ENOMEM;
+6 -1
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 2313 2313 case XDP_TX: 2314 2314 xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->queue_index]; 2315 2315 result = i40e_xmit_xdp_tx_ring(xdp, xdp_ring); 2316 + if (result == I40E_XDP_CONSUMED) 2317 + goto out_failure; 2316 2318 break; 2317 2319 case XDP_REDIRECT: 2318 2320 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); 2319 - result = !err ? I40E_XDP_REDIR : I40E_XDP_CONSUMED; 2321 + if (err) 2322 + goto out_failure; 2323 + result = I40E_XDP_REDIR; 2320 2324 break; 2321 2325 default: 2322 2326 bpf_warn_invalid_xdp_action(act); 2323 2327 fallthrough; 2324 2328 case XDP_ABORTED: 2329 + out_failure: 2325 2330 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 2326 2331 fallthrough; /* handle aborts by dropping packet */ 2327 2332 case XDP_DROP:
+6 -2
drivers/net/ethernet/intel/i40e/i40e_xsk.c
··· 162 162 163 163 if (likely(act == XDP_REDIRECT)) { 164 164 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); 165 - result = !err ? I40E_XDP_REDIR : I40E_XDP_CONSUMED; 165 + if (err) 166 + goto out_failure; 166 167 rcu_read_unlock(); 167 - return result; 168 + return I40E_XDP_REDIR; 168 169 } 169 170 170 171 switch (act) { ··· 174 173 case XDP_TX: 175 174 xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->queue_index]; 176 175 result = i40e_xmit_xdp_tx_ring(xdp, xdp_ring); 176 + if (result == I40E_XDP_CONSUMED) 177 + goto out_failure; 177 178 break; 178 179 default: 179 180 bpf_warn_invalid_xdp_action(act); 180 181 fallthrough; 181 182 case XDP_ABORTED: 183 + out_failure: 182 184 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 183 185 fallthrough; /* handle aborts by dropping packet */ 184 186 case XDP_DROP:
+5 -3
drivers/net/ethernet/intel/ice/ice.h
··· 335 335 struct ice_tc_cfg tc_cfg; 336 336 struct bpf_prog *xdp_prog; 337 337 struct ice_ring **xdp_rings; /* XDP ring array */ 338 + unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */ 338 339 u16 num_xdp_txq; /* Used XDP queues */ 339 340 u8 xdp_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */ 340 341 ··· 548 547 */ 549 548 static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_ring *ring) 550 549 { 550 + struct ice_vsi *vsi = ring->vsi; 551 551 u16 qid = ring->q_index; 552 552 553 553 if (ice_ring_is_xdp(ring)) 554 - qid -= ring->vsi->num_xdp_txq; 554 + qid -= vsi->num_xdp_txq; 555 555 556 - if (!ice_is_xdp_ena_vsi(ring->vsi)) 556 + if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps)) 557 557 return NULL; 558 558 559 - return xsk_get_pool_from_qid(ring->vsi->netdev, qid); 559 + return xsk_get_pool_from_qid(vsi->netdev, qid); 560 560 } 561 561 562 562 /**
+6 -45
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 1773 1773 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB, 1774 1774 100000baseKR4_Full); 1775 1775 } 1776 - 1777 - /* Autoneg PHY types */ 1778 - if (phy_types_low & ICE_PHY_TYPE_LOW_100BASE_TX || 1779 - phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_T || 1780 - phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_KX || 1781 - phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_T || 1782 - phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_KX || 1783 - phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_T || 1784 - phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_KR || 1785 - phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_T || 1786 - phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_KR_CR1 || 1787 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_T || 1788 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR || 1789 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR_S || 1790 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR1 || 1791 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR || 1792 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR_S || 1793 - phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR1 || 1794 - phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_CR4 || 1795 - phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_KR4) { 1796 - ethtool_link_ksettings_add_link_mode(ks, supported, 1797 - Autoneg); 1798 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1799 - Autoneg); 1800 - } 1801 - if (phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_CR2 || 1802 - phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_KR2 || 1803 - phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_CP || 1804 - phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4) { 1805 - ethtool_link_ksettings_add_link_mode(ks, supported, 1806 - Autoneg); 1807 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1808 - Autoneg); 1809 - } 1810 - if (phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_CR4 || 1811 - phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_KR4 || 1812 - phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4 || 1813 - phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_CP2) { 1814 - ethtool_link_ksettings_add_link_mode(ks, supported, 1815 - Autoneg); 1816 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1817 - Autoneg); 1818 - } 1819 1776 } 1820 1777 1821 1778 #define TEST_SET_BITS_TIMEOUT 50 ··· 1929 1972 ks->base.port = PORT_TP; 1930 1973 break; 1931 1974 case ICE_MEDIA_BACKPLANE: 1932 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1933 1975 ethtool_link_ksettings_add_link_mode(ks, supported, Backplane); 1934 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1935 1976 ethtool_link_ksettings_add_link_mode(ks, advertising, 1936 1977 Backplane); 1937 1978 ks->base.port = PORT_NONE; ··· 2003 2048 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); 2004 2049 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) 2005 2050 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); 2051 + 2052 + /* Set supported and advertised autoneg */ 2053 + if (ice_is_phy_caps_an_enabled(caps)) { 2054 + ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 2055 + ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 2056 + } 2006 2057 2007 2058 done: 2008 2059 kfree(caps);
+1
drivers/net/ethernet/intel/ice/ice_hw_autogen.h
··· 31 31 #define PF_FW_ATQLEN_ATQOVFL_M BIT(29) 32 32 #define PF_FW_ATQLEN_ATQCRIT_M BIT(30) 33 33 #define VF_MBX_ARQLEN(_VF) (0x0022BC00 + ((_VF) * 4)) 34 + #define VF_MBX_ATQLEN(_VF) (0x0022A800 + ((_VF) * 4)) 34 35 #define PF_FW_ATQLEN_ATQENABLE_M BIT(31) 35 36 #define PF_FW_ATQT 0x00080400 36 37 #define PF_MBX_ARQBAH 0x0022E400
+12
drivers/net/ethernet/intel/ice/ice_lib.c
··· 105 105 if (!vsi->q_vectors) 106 106 goto err_vectors; 107 107 108 + vsi->af_xdp_zc_qps = bitmap_zalloc(max_t(int, vsi->alloc_txq, vsi->alloc_rxq), GFP_KERNEL); 109 + if (!vsi->af_xdp_zc_qps) 110 + goto err_zc_qps; 111 + 108 112 return 0; 109 113 114 + err_zc_qps: 115 + devm_kfree(dev, vsi->q_vectors); 110 116 err_vectors: 111 117 devm_kfree(dev, vsi->rxq_map); 112 118 err_rxq_map: ··· 200 194 break; 201 195 case ICE_VSI_VF: 202 196 vf = &pf->vf[vsi->vf_id]; 197 + if (vf->num_req_qs) 198 + vf->num_vf_qs = vf->num_req_qs; 203 199 vsi->alloc_txq = vf->num_vf_qs; 204 200 vsi->alloc_rxq = vf->num_vf_qs; 205 201 /* pf->num_msix_per_vf includes (VF miscellaneous vector + ··· 296 288 297 289 dev = ice_pf_to_dev(pf); 298 290 291 + if (vsi->af_xdp_zc_qps) { 292 + bitmap_free(vsi->af_xdp_zc_qps); 293 + vsi->af_xdp_zc_qps = NULL; 294 + } 299 295 /* free the ring and vector containers */ 300 296 if (vsi->q_vectors) { 301 297 devm_kfree(dev, vsi->q_vectors);
+13 -4
drivers/net/ethernet/intel/ice/ice_txrx.c
··· 523 523 struct bpf_prog *xdp_prog) 524 524 { 525 525 struct ice_ring *xdp_ring; 526 - int err; 526 + int err, result; 527 527 u32 act; 528 528 529 529 act = bpf_prog_run_xdp(xdp_prog, xdp); ··· 532 532 return ICE_XDP_PASS; 533 533 case XDP_TX: 534 534 xdp_ring = rx_ring->vsi->xdp_rings[smp_processor_id()]; 535 - return ice_xmit_xdp_buff(xdp, xdp_ring); 535 + result = ice_xmit_xdp_buff(xdp, xdp_ring); 536 + if (result == ICE_XDP_CONSUMED) 537 + goto out_failure; 538 + return result; 536 539 case XDP_REDIRECT: 537 540 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); 538 - return !err ? ICE_XDP_REDIR : ICE_XDP_CONSUMED; 541 + if (err) 542 + goto out_failure; 543 + return ICE_XDP_REDIR; 539 544 default: 540 545 bpf_warn_invalid_xdp_action(act); 541 546 fallthrough; 542 547 case XDP_ABORTED: 548 + out_failure: 543 549 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 544 550 fallthrough; 545 551 case XDP_DROP: ··· 2149 2143 struct ice_tx_offload_params offload = { 0 }; 2150 2144 struct ice_vsi *vsi = tx_ring->vsi; 2151 2145 struct ice_tx_buf *first; 2146 + struct ethhdr *eth; 2152 2147 unsigned int count; 2153 2148 int tso, csum; 2154 2149 ··· 2196 2189 goto out_drop; 2197 2190 2198 2191 /* allow CONTROL frames egress from main VSI if FW LLDP disabled */ 2199 - if (unlikely(skb->priority == TC_PRIO_CONTROL && 2192 + eth = (struct ethhdr *)skb_mac_header(skb); 2193 + if (unlikely((skb->priority == TC_PRIO_CONTROL || 2194 + eth->h_proto == htons(ETH_P_LLDP)) && 2200 2195 vsi->type == ICE_VSI_PF && 2201 2196 vsi->port_info->qos_cfg.is_sw_lldp)) 2202 2197 offload.cd_qw1 |= (u64)(ICE_TX_DESC_DTYPE_CTX |
+13 -6
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
··· 713 713 */ 714 714 clear_bit(ICE_VF_STATE_INIT, vf->vf_states); 715 715 716 - /* VF_MBX_ARQLEN is cleared by PFR, so the driver needs to clear it 717 - * in the case of VFR. If this is done for PFR, it can mess up VF 718 - * resets because the VF driver may already have started cleanup 719 - * by the time we get here. 716 + /* VF_MBX_ARQLEN and VF_MBX_ATQLEN are cleared by PFR, so the driver 717 + * needs to clear them in the case of VFR/VFLR. If this is done for 718 + * PFR, it can mess up VF resets because the VF driver may already 719 + * have started cleanup by the time we get here. 720 720 */ 721 - if (!is_pfr) 721 + if (!is_pfr) { 722 722 wr32(hw, VF_MBX_ARQLEN(vf->vf_id), 0); 723 + wr32(hw, VF_MBX_ATQLEN(vf->vf_id), 0); 724 + } 723 725 724 726 /* In the case of a VFLR, the HW has already reset the VF and we 725 727 * just need to clean up, so don't hit the VFRTRIG register. ··· 1700 1698 ice_vf_ctrl_vsi_release(vf); 1701 1699 1702 1700 ice_vf_pre_vsi_rebuild(vf); 1703 - ice_vf_rebuild_vsi_with_release(vf); 1701 + 1702 + if (ice_vf_rebuild_vsi_with_release(vf)) { 1703 + dev_err(dev, "Failed to release and setup the VF%u's VSI\n", vf->vf_id); 1704 + return false; 1705 + } 1706 + 1704 1707 ice_vf_post_vsi_rebuild(vf); 1705 1708 1706 1709 /* if the VF has been reset allow it to come up again */
+9 -2
drivers/net/ethernet/intel/ice/ice_xsk.c
··· 270 270 if (!pool) 271 271 return -EINVAL; 272 272 273 + clear_bit(qid, vsi->af_xdp_zc_qps); 273 274 xsk_pool_dma_unmap(pool, ICE_RX_DMA_ATTR); 274 275 275 276 return 0; ··· 300 299 ICE_RX_DMA_ATTR); 301 300 if (err) 302 301 return err; 302 + 303 + set_bit(qid, vsi->af_xdp_zc_qps); 303 304 304 305 return 0; 305 306 } ··· 476 473 477 474 if (likely(act == XDP_REDIRECT)) { 478 475 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); 479 - result = !err ? ICE_XDP_REDIR : ICE_XDP_CONSUMED; 476 + if (err) 477 + goto out_failure; 480 478 rcu_read_unlock(); 481 - return result; 479 + return ICE_XDP_REDIR; 482 480 } 483 481 484 482 switch (act) { ··· 488 484 case XDP_TX: 489 485 xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index]; 490 486 result = ice_xmit_xdp_buff(xdp, xdp_ring); 487 + if (result == ICE_XDP_CONSUMED) 488 + goto out_failure; 491 489 break; 492 490 default: 493 491 bpf_warn_invalid_xdp_action(act); 494 492 fallthrough; 495 493 case XDP_ABORTED: 494 + out_failure: 496 495 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 497 496 fallthrough; 498 497 case XDP_DROP:
+1 -1
drivers/net/ethernet/intel/igb/igb.h
··· 749 749 void igb_ptp_tx_hang(struct igb_adapter *adapter); 750 750 void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb); 751 751 int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, 752 - struct sk_buff *skb); 752 + ktime_t *timestamp); 753 753 int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr); 754 754 int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr); 755 755 void igb_set_flag_queue_pairs(struct igb_adapter *, const u32);
+32 -23
drivers/net/ethernet/intel/igb/igb_main.c
··· 8280 8280 static struct sk_buff *igb_construct_skb(struct igb_ring *rx_ring, 8281 8281 struct igb_rx_buffer *rx_buffer, 8282 8282 struct xdp_buff *xdp, 8283 - union e1000_adv_rx_desc *rx_desc) 8283 + ktime_t timestamp) 8284 8284 { 8285 8285 #if (PAGE_SIZE < 8192) 8286 8286 unsigned int truesize = igb_rx_pg_size(rx_ring) / 2; ··· 8300 8300 if (unlikely(!skb)) 8301 8301 return NULL; 8302 8302 8303 - if (unlikely(igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))) { 8304 - if (!igb_ptp_rx_pktstamp(rx_ring->q_vector, xdp->data, skb)) { 8305 - xdp->data += IGB_TS_HDR_LEN; 8306 - size -= IGB_TS_HDR_LEN; 8307 - } 8308 - } 8303 + if (timestamp) 8304 + skb_hwtstamps(skb)->hwtstamp = timestamp; 8309 8305 8310 8306 /* Determine available headroom for copy */ 8311 8307 headlen = size; ··· 8332 8336 static struct sk_buff *igb_build_skb(struct igb_ring *rx_ring, 8333 8337 struct igb_rx_buffer *rx_buffer, 8334 8338 struct xdp_buff *xdp, 8335 - union e1000_adv_rx_desc *rx_desc) 8339 + ktime_t timestamp) 8336 8340 { 8337 8341 #if (PAGE_SIZE < 8192) 8338 8342 unsigned int truesize = igb_rx_pg_size(rx_ring) / 2; ··· 8359 8363 if (metasize) 8360 8364 skb_metadata_set(skb, metasize); 8361 8365 8362 - /* pull timestamp out of packet data */ 8363 - if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) { 8364 - if (!igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb)) 8365 - __skb_pull(skb, IGB_TS_HDR_LEN); 8366 - } 8366 + if (timestamp) 8367 + skb_hwtstamps(skb)->hwtstamp = timestamp; 8367 8368 8368 8369 /* update buffer offset */ 8369 8370 #if (PAGE_SIZE < 8192) ··· 8394 8401 break; 8395 8402 case XDP_TX: 8396 8403 result = igb_xdp_xmit_back(adapter, xdp); 8404 + if (result == IGB_XDP_CONSUMED) 8405 + goto out_failure; 8397 8406 break; 8398 8407 case XDP_REDIRECT: 8399 8408 err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); 8400 - if (!err) 8401 - result = IGB_XDP_REDIR; 8402 - else 8403 - result = IGB_XDP_CONSUMED; 8409 + if (err) 8410 + goto out_failure; 8411 + result = IGB_XDP_REDIR; 8404 8412 break; 8405 8413 default: 8406 8414 bpf_warn_invalid_xdp_action(act); 8407 8415 fallthrough; 8408 8416 case XDP_ABORTED: 8417 + out_failure: 8409 8418 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 8410 8419 fallthrough; 8411 8420 case XDP_DROP: ··· 8677 8682 while (likely(total_packets < budget)) { 8678 8683 union e1000_adv_rx_desc *rx_desc; 8679 8684 struct igb_rx_buffer *rx_buffer; 8685 + ktime_t timestamp = 0; 8686 + int pkt_offset = 0; 8680 8687 unsigned int size; 8688 + void *pktbuf; 8681 8689 8682 8690 /* return some buffers to hardware, one at a time is too slow */ 8683 8691 if (cleaned_count >= IGB_RX_BUFFER_WRITE) { ··· 8700 8702 dma_rmb(); 8701 8703 8702 8704 rx_buffer = igb_get_rx_buffer(rx_ring, size, &rx_buf_pgcnt); 8705 + pktbuf = page_address(rx_buffer->page) + rx_buffer->page_offset; 8706 + 8707 + /* pull rx packet timestamp if available and valid */ 8708 + if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) { 8709 + int ts_hdr_len; 8710 + 8711 + ts_hdr_len = igb_ptp_rx_pktstamp(rx_ring->q_vector, 8712 + pktbuf, &timestamp); 8713 + 8714 + pkt_offset += ts_hdr_len; 8715 + size -= ts_hdr_len; 8716 + } 8703 8717 8704 8718 /* retrieve a buffer from the ring */ 8705 8719 if (!skb) { 8706 - unsigned int offset = igb_rx_offset(rx_ring); 8707 - unsigned char *hard_start; 8720 + unsigned char *hard_start = pktbuf - igb_rx_offset(rx_ring); 8721 + unsigned int offset = pkt_offset + igb_rx_offset(rx_ring); 8708 8722 8709 - hard_start = page_address(rx_buffer->page) + 8710 - rx_buffer->page_offset - offset; 8711 8723 xdp_prepare_buff(&xdp, hard_start, offset, size, true); 8712 8724 #if (PAGE_SIZE > 4096) 8713 8725 /* At larger PAGE_SIZE, frame_sz depend on len size */ ··· 8740 8732 } else if (skb) 8741 8733 igb_add_rx_frag(rx_ring, rx_buffer, skb, size); 8742 8734 else if (ring_uses_build_skb(rx_ring)) 8743 - skb = igb_build_skb(rx_ring, rx_buffer, &xdp, rx_desc); 8735 + skb = igb_build_skb(rx_ring, rx_buffer, &xdp, 8736 + timestamp); 8744 8737 else 8745 8738 skb = igb_construct_skb(rx_ring, rx_buffer, 8746 - &xdp, rx_desc); 8739 + &xdp, timestamp); 8747 8740 8748 8741 /* exit if we failed to retrieve a buffer */ 8749 8742 if (!skb) {
+10 -13
drivers/net/ethernet/intel/igb/igb_ptp.c
··· 856 856 dev_kfree_skb_any(skb); 857 857 } 858 858 859 - #define IGB_RET_PTP_DISABLED 1 860 - #define IGB_RET_PTP_INVALID 2 861 - 862 859 /** 863 860 * igb_ptp_rx_pktstamp - retrieve Rx per packet timestamp 864 861 * @q_vector: Pointer to interrupt specific structure 865 862 * @va: Pointer to address containing Rx buffer 866 - * @skb: Buffer containing timestamp and packet 863 + * @timestamp: Pointer where timestamp will be stored 867 864 * 868 865 * This function is meant to retrieve a timestamp from the first buffer of an 869 866 * incoming frame. The value is stored in little endian format starting on 870 867 * byte 8 871 868 * 872 - * Returns: 0 if success, nonzero if failure 869 + * Returns: The timestamp header length or 0 if not available 873 870 **/ 874 871 int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, 875 - struct sk_buff *skb) 872 + ktime_t *timestamp) 876 873 { 877 874 struct igb_adapter *adapter = q_vector->adapter; 875 + struct skb_shared_hwtstamps ts; 878 876 __le64 *regval = (__le64 *)va; 879 877 int adjust = 0; 880 878 881 879 if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) 882 - return IGB_RET_PTP_DISABLED; 880 + return 0; 883 881 884 882 /* The timestamp is recorded in little endian format. 885 883 * DWORD: 0 1 2 3 ··· 886 888 887 889 /* check reserved dwords are zero, be/le doesn't matter for zero */ 888 890 if (regval[0]) 889 - return IGB_RET_PTP_INVALID; 891 + return 0; 890 892 891 - igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), 892 - le64_to_cpu(regval[1])); 893 + igb_ptp_systim_to_hwtstamp(adapter, &ts, le64_to_cpu(regval[1])); 893 894 894 895 /* adjust timestamp for the RX latency based on link speed */ 895 896 if (adapter->hw.mac.type == e1000_i210) { ··· 904 907 break; 905 908 } 906 909 } 907 - skb_hwtstamps(skb)->hwtstamp = 908 - ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp, adjust); 909 910 910 - return 0; 911 + *timestamp = ktime_sub_ns(ts.hwtstamp, adjust); 912 + 913 + return IGB_TS_HDR_LEN; 911 914 } 912 915 913 916 /**
+5 -6
drivers/net/ethernet/intel/igc/igc_main.c
··· 2047 2047 break; 2048 2048 case XDP_TX: 2049 2049 if (igc_xdp_xmit_back(adapter, xdp) < 0) 2050 - res = IGC_XDP_CONSUMED; 2051 - else 2052 - res = IGC_XDP_TX; 2050 + goto out_failure; 2051 + res = IGC_XDP_TX; 2053 2052 break; 2054 2053 case XDP_REDIRECT: 2055 2054 if (xdp_do_redirect(adapter->netdev, xdp, prog) < 0) 2056 - res = IGC_XDP_CONSUMED; 2057 - else 2058 - res = IGC_XDP_REDIRECT; 2055 + goto out_failure; 2056 + res = IGC_XDP_REDIRECT; 2059 2057 break; 2060 2058 default: 2061 2059 bpf_warn_invalid_xdp_action(act); 2062 2060 fallthrough; 2063 2061 case XDP_ABORTED: 2062 + out_failure: 2064 2063 trace_xdp_exception(adapter->netdev, prog, act); 2065 2064 fallthrough; 2066 2065 case XDP_DROP:
+8 -8
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 2213 2213 break; 2214 2214 case XDP_TX: 2215 2215 xdpf = xdp_convert_buff_to_frame(xdp); 2216 - if (unlikely(!xdpf)) { 2217 - result = IXGBE_XDP_CONSUMED; 2218 - break; 2219 - } 2216 + if (unlikely(!xdpf)) 2217 + goto out_failure; 2220 2218 result = ixgbe_xmit_xdp_ring(adapter, xdpf); 2219 + if (result == IXGBE_XDP_CONSUMED) 2220 + goto out_failure; 2221 2221 break; 2222 2222 case XDP_REDIRECT: 2223 2223 err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); 2224 - if (!err) 2225 - result = IXGBE_XDP_REDIR; 2226 - else 2227 - result = IXGBE_XDP_CONSUMED; 2224 + if (err) 2225 + goto out_failure; 2226 + result = IXGBE_XDP_REDIR; 2228 2227 break; 2229 2228 default: 2230 2229 bpf_warn_invalid_xdp_action(act); 2231 2230 fallthrough; 2232 2231 case XDP_ABORTED: 2232 + out_failure: 2233 2233 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 2234 2234 fallthrough; /* handle aborts by dropping packet */ 2235 2235 case XDP_DROP:
+8 -6
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
··· 106 106 107 107 if (likely(act == XDP_REDIRECT)) { 108 108 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); 109 - result = !err ? IXGBE_XDP_REDIR : IXGBE_XDP_CONSUMED; 109 + if (err) 110 + goto out_failure; 110 111 rcu_read_unlock(); 111 - return result; 112 + return IXGBE_XDP_REDIR; 112 113 } 113 114 114 115 switch (act) { ··· 117 116 break; 118 117 case XDP_TX: 119 118 xdpf = xdp_convert_buff_to_frame(xdp); 120 - if (unlikely(!xdpf)) { 121 - result = IXGBE_XDP_CONSUMED; 122 - break; 123 - } 119 + if (unlikely(!xdpf)) 120 + goto out_failure; 124 121 result = ixgbe_xmit_xdp_ring(adapter, xdpf); 122 + if (result == IXGBE_XDP_CONSUMED) 123 + goto out_failure; 125 124 break; 126 125 default: 127 126 bpf_warn_invalid_xdp_action(act); 128 127 fallthrough; 129 128 case XDP_ABORTED: 129 + out_failure: 130 130 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 131 131 fallthrough; /* handle aborts by dropping packet */ 132 132 case XDP_DROP:
+3
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
··· 1067 1067 case XDP_TX: 1068 1068 xdp_ring = adapter->xdp_ring[rx_ring->queue_index]; 1069 1069 result = ixgbevf_xmit_xdp_ring(xdp_ring, xdp); 1070 + if (result == IXGBEVF_XDP_CONSUMED) 1071 + goto out_failure; 1070 1072 break; 1071 1073 default: 1072 1074 bpf_warn_invalid_xdp_action(act); 1073 1075 fallthrough; 1074 1076 case XDP_ABORTED: 1077 + out_failure: 1075 1078 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); 1076 1079 fallthrough; /* handle aborts by dropping packet */ 1077 1080 case XDP_DROP:
+10 -2
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 1624 1624 { 1625 1625 struct mlx5e_priv *priv = netdev_priv(netdev); 1626 1626 struct mlx5_core_dev *mdev = priv->mdev; 1627 + unsigned long fec_bitmap; 1627 1628 u16 fec_policy = 0; 1628 1629 int mode; 1629 1630 int err; 1630 1631 1631 - if (bitmap_weight((unsigned long *)&fecparam->fec, 1632 - ETHTOOL_FEC_LLRS_BIT + 1) > 1) 1632 + bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE); 1633 + if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1) 1633 1634 return -EOPNOTSUPP; 1634 1635 1635 1636 for (mode = 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) { ··· 1893 1892 1894 1893 if (curr_val == new_val) 1895 1894 return 0; 1895 + 1896 + if (new_val && !priv->profile->rx_ptp_support && 1897 + priv->tstamp.rx_filter != HWTSTAMP_FILTER_NONE) { 1898 + netdev_err(priv->netdev, 1899 + "Profile doesn't support enabling of CQE compression while hardware time-stamping is enabled.\n"); 1900 + return -EINVAL; 1901 + } 1896 1902 1897 1903 new_params = priv->channels.params; 1898 1904 MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_RX_CQE_COMPRESS, new_val);
+62 -15
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 3858 3858 netdev_warn(netdev, "Disabling rxhash, not supported when CQE compress is active\n"); 3859 3859 } 3860 3860 3861 + if (mlx5e_is_uplink_rep(priv)) { 3862 + features &= ~NETIF_F_HW_TLS_RX; 3863 + if (netdev->features & NETIF_F_HW_TLS_RX) 3864 + netdev_warn(netdev, "Disabling hw_tls_rx, not supported in switchdev mode\n"); 3865 + 3866 + features &= ~NETIF_F_HW_TLS_TX; 3867 + if (netdev->features & NETIF_F_HW_TLS_TX) 3868 + netdev_warn(netdev, "Disabling hw_tls_tx, not supported in switchdev mode\n"); 3869 + } 3870 + 3861 3871 mutex_unlock(&priv->state_lock); 3862 3872 3863 3873 return features; ··· 3984 3974 return mlx5e_ptp_rx_manage_fs(priv, set); 3985 3975 } 3986 3976 3987 - int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) 3977 + static int mlx5e_hwstamp_config_no_ptp_rx(struct mlx5e_priv *priv, bool rx_filter) 3978 + { 3979 + bool rx_cqe_compress_def = priv->channels.params.rx_cqe_compress_def; 3980 + int err; 3981 + 3982 + if (!rx_filter) 3983 + /* Reset CQE compression to Admin default */ 3984 + return mlx5e_modify_rx_cqe_compression_locked(priv, rx_cqe_compress_def); 3985 + 3986 + if (!MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS)) 3987 + return 0; 3988 + 3989 + /* Disable CQE compression */ 3990 + netdev_warn(priv->netdev, "Disabling RX cqe compression\n"); 3991 + err = mlx5e_modify_rx_cqe_compression_locked(priv, false); 3992 + if (err) 3993 + netdev_err(priv->netdev, "Failed disabling cqe compression err=%d\n", err); 3994 + 3995 + return err; 3996 + } 3997 + 3998 + static int mlx5e_hwstamp_config_ptp_rx(struct mlx5e_priv *priv, bool ptp_rx) 3988 3999 { 3989 4000 struct mlx5e_params new_params; 4001 + 4002 + if (ptp_rx == priv->channels.params.ptp_rx) 4003 + return 0; 4004 + 4005 + new_params = priv->channels.params; 4006 + new_params.ptp_rx = ptp_rx; 4007 + return mlx5e_safe_switch_params(priv, &new_params, mlx5e_ptp_rx_manage_fs_ctx, 4008 + &new_params.ptp_rx, true); 4009 + } 4010 + 4011 + int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) 4012 + { 3990 4013 struct hwtstamp_config config; 3991 4014 bool rx_cqe_compress_def; 4015 + bool ptp_rx; 3992 4016 int err; 3993 4017 3994 4018 if (!MLX5_CAP_GEN(priv->mdev, device_frequency_khz) || ··· 4042 3998 } 4043 3999 4044 4000 mutex_lock(&priv->state_lock); 4045 - new_params = priv->channels.params; 4046 4001 rx_cqe_compress_def = priv->channels.params.rx_cqe_compress_def; 4047 4002 4048 4003 /* RX HW timestamp */ 4049 4004 switch (config.rx_filter) { 4050 4005 case HWTSTAMP_FILTER_NONE: 4051 - new_params.ptp_rx = false; 4006 + ptp_rx = false; 4052 4007 break; 4053 4008 case HWTSTAMP_FILTER_ALL: 4054 4009 case HWTSTAMP_FILTER_SOME: ··· 4064 4021 case HWTSTAMP_FILTER_PTP_V2_SYNC: 4065 4022 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 4066 4023 case HWTSTAMP_FILTER_NTP_ALL: 4067 - new_params.ptp_rx = rx_cqe_compress_def; 4068 4024 config.rx_filter = HWTSTAMP_FILTER_ALL; 4025 + /* ptp_rx is set if both HW TS is set and CQE 4026 + * compression is set 4027 + */ 4028 + ptp_rx = rx_cqe_compress_def; 4069 4029 break; 4070 4030 default: 4071 - mutex_unlock(&priv->state_lock); 4072 - return -ERANGE; 4031 + err = -ERANGE; 4032 + goto err_unlock; 4073 4033 } 4074 4034 4075 - if (new_params.ptp_rx == priv->channels.params.ptp_rx) 4076 - goto out; 4035 + if (!priv->profile->rx_ptp_support) 4036 + err = mlx5e_hwstamp_config_no_ptp_rx(priv, 4037 + config.rx_filter != HWTSTAMP_FILTER_NONE); 4038 + else 4039 + err = mlx5e_hwstamp_config_ptp_rx(priv, ptp_rx); 4040 + if (err) 4041 + goto err_unlock; 4077 4042 4078 - err = mlx5e_safe_switch_params(priv, &new_params, mlx5e_ptp_rx_manage_fs_ctx, 4079 - &new_params.ptp_rx, true); 4080 - if (err) { 4081 - mutex_unlock(&priv->state_lock); 4082 - return err; 4083 - } 4084 - out: 4085 4043 memcpy(&priv->tstamp, &config, sizeof(config)); 4086 4044 mutex_unlock(&priv->state_lock); 4087 4045 ··· 4091 4047 4092 4048 return copy_to_user(ifr->ifr_data, &config, 4093 4049 sizeof(config)) ? -EFAULT : 0; 4050 + err_unlock: 4051 + mutex_unlock(&priv->state_lock); 4052 + return err; 4094 4053 } 4095 4054 4096 4055 int mlx5e_hwstamp_get(struct mlx5e_priv *priv, struct ifreq *ifr)
+9
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 2015 2015 misc_parameters_3); 2016 2016 struct flow_rule *rule = flow_cls_offload_flow_rule(f); 2017 2017 struct flow_dissector *dissector = rule->match.dissector; 2018 + enum fs_flow_table_type fs_type; 2018 2019 u16 addr_type = 0; 2019 2020 u8 ip_proto = 0; 2020 2021 u8 *match_level; 2021 2022 int err; 2022 2023 2024 + fs_type = mlx5e_is_eswitch_flow(flow) ? FS_FT_FDB : FS_FT_NIC_RX; 2023 2025 match_level = outer_match_level; 2024 2026 2025 2027 if (dissector->used_keys & ··· 2147 2145 if (match.mask->vlan_id || 2148 2146 match.mask->vlan_priority || 2149 2147 match.mask->vlan_tpid) { 2148 + if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev, ft_field_support.outer_second_vid, 2149 + fs_type)) { 2150 + NL_SET_ERR_MSG_MOD(extack, 2151 + "Matching on CVLAN is not supported"); 2152 + return -EOPNOTSUPP; 2153 + } 2154 + 2150 2155 if (match.key->vlan_tpid == htons(ETH_P_8021AD)) { 2151 2156 MLX5_SET(fte_match_set_misc, misc_c, 2152 2157 outer_second_svlan_tag, 1);
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 219 219 struct mlx5_fs_chains *chains, 220 220 int i) 221 221 { 222 - flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL; 222 + if (mlx5_chains_ignore_flow_level_supported(chains)) 223 + flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL; 223 224 dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; 224 225 dest[i].ft = mlx5_chains_get_tc_end_ft(chains); 225 226 }
+3
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
··· 349 349 reset_abort_work); 350 350 struct mlx5_core_dev *dev = fw_reset->dev; 351 351 352 + if (!test_bit(MLX5_FW_RESET_FLAGS_RESET_REQUESTED, &fw_reset->reset_flags)) 353 + return; 354 + 352 355 mlx5_sync_reset_clear_reset_requested(dev, true); 353 356 mlx5_core_warn(dev, "PCI Sync FW Update Reset Aborted.\n"); 354 357 }
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
··· 107 107 return chains->flags & MLX5_CHAINS_AND_PRIOS_SUPPORTED; 108 108 } 109 109 110 - static bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains) 110 + bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains) 111 111 { 112 112 return chains->flags & MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED; 113 113 }
+5
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.h
··· 28 28 29 29 bool 30 30 mlx5_chains_prios_supported(struct mlx5_fs_chains *chains); 31 + bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains); 31 32 bool 32 33 mlx5_chains_backwards_supported(struct mlx5_fs_chains *chains); 33 34 u32 ··· 70 69 struct mlx5_flow_table *ft); 71 70 72 71 #else /* CONFIG_MLX5_CLS_ACT */ 72 + 73 + static inline bool 74 + mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains) 75 + { return false; } 73 76 74 77 static inline struct mlx5_flow_table * 75 78 mlx5_chains_get_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio,
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c
··· 112 112 int ret; 113 113 114 114 ft_attr.table_type = MLX5_FLOW_TABLE_TYPE_FDB; 115 - ft_attr.level = dmn->info.caps.max_ft_level - 2; 115 + ft_attr.level = min_t(int, dmn->info.caps.max_ft_level - 2, 116 + MLX5_FT_MAX_MULTIPATH_LEVEL); 116 117 ft_attr.reformat_en = reformat_req; 117 118 ft_attr.decap_en = reformat_req; 118 119
+1
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
··· 3815 3815 dev_err(&pdev->dev, 3816 3816 "invalid sram_size %dB or board span %ldB\n", 3817 3817 mgp->sram_size, mgp->board_span); 3818 + status = -EINVAL; 3818 3819 goto abort_with_ioremap; 3819 3820 } 3820 3821 memcpy_fromio(mgp->eeprom_strings,
+3 -3
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1240 1240 priv->phylink_config.dev = &priv->dev->dev; 1241 1241 priv->phylink_config.type = PHYLINK_NETDEV; 1242 1242 priv->phylink_config.pcs_poll = true; 1243 - priv->phylink_config.ovr_an_inband = 1244 - priv->plat->mdio_bus_data->xpcs_an_inband; 1243 + if (priv->plat->mdio_bus_data) 1244 + priv->phylink_config.ovr_an_inband = 1245 + priv->plat->mdio_bus_data->xpcs_an_inband; 1245 1246 1246 1247 if (!fwnode) 1247 1248 fwnode = dev_fwnode(priv->device); ··· 7049 7048 stmmac_napi_del(ndev); 7050 7049 error_hw_init: 7051 7050 destroy_workqueue(priv->wq); 7052 - stmmac_bus_clks_config(priv, false); 7053 7051 bitmap_free(priv->af_xdp_zc_qps); 7054 7052 7055 7053 return ret;
+2 -2
drivers/net/ieee802154/mrf24j40.c
··· 8 8 9 9 #include <linux/spi/spi.h> 10 10 #include <linux/interrupt.h> 11 + #include <linux/mod_devicetable.h> 11 12 #include <linux/module.h> 12 - #include <linux/of.h> 13 13 #include <linux/regmap.h> 14 14 #include <linux/ieee802154.h> 15 15 #include <linux/irq.h> ··· 1388 1388 1389 1389 static struct spi_driver mrf24j40_driver = { 1390 1390 .driver = { 1391 - .of_match_table = of_match_ptr(mrf24j40_of_match), 1391 + .of_match_table = mrf24j40_of_match, 1392 1392 .name = "mrf24j40", 1393 1393 }, 1394 1394 .id_table = mrf24j40_ids,
+8 -12
drivers/net/virtio_net.c
··· 401 401 /* If headroom is not 0, there is an offset between the beginning of the 402 402 * data and the allocated space, otherwise the data and the allocated 403 403 * space are aligned. 404 + * 405 + * Buffers with headroom use PAGE_SIZE as alloc size, see 406 + * add_recvbuf_mergeable() + get_mergeable_buf_len() 404 407 */ 405 - if (headroom) { 406 - /* Buffers with headroom use PAGE_SIZE as alloc size, 407 - * see add_recvbuf_mergeable() + get_mergeable_buf_len() 408 - */ 409 - truesize = PAGE_SIZE; 410 - tailroom = truesize - len - offset; 411 - buf = page_address(page); 412 - } else { 413 - tailroom = truesize - len; 414 - buf = p; 415 - } 408 + truesize = headroom ? PAGE_SIZE : truesize; 409 + tailroom = truesize - len - headroom - (hdr_padded_len - hdr_len); 410 + buf = p - headroom; 416 411 417 412 len -= hdr_len; 418 413 offset += hdr_padded_len; ··· 953 958 put_page(page); 954 959 head_skb = page_to_skb(vi, rq, xdp_page, offset, 955 960 len, PAGE_SIZE, false, 956 - metasize, headroom); 961 + metasize, 962 + VIRTIO_XDP_HEADROOM); 957 963 return head_skb; 958 964 } 959 965 break;
+1 -2
drivers/net/wireguard/Makefile
··· 1 - ccflags-y := -O3 2 - ccflags-y += -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' 1 + ccflags-y := -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' 3 2 ccflags-$(CONFIG_WIREGUARD_DEBUG) += -DDEBUG 4 3 wireguard-y := main.o 5 4 wireguard-y += noise.o
+100 -91
drivers/net/wireguard/allowedips.c
··· 6 6 #include "allowedips.h" 7 7 #include "peer.h" 8 8 9 + static struct kmem_cache *node_cache; 10 + 9 11 static void swap_endian(u8 *dst, const u8 *src, u8 bits) 10 12 { 11 13 if (bits == 32) { ··· 30 28 node->bitlen = bits; 31 29 memcpy(node->bits, src, bits / 8U); 32 30 } 33 - #define CHOOSE_NODE(parent, key) \ 34 - parent->bit[(key[parent->bit_at_a] >> parent->bit_at_b) & 1] 31 + 32 + static inline u8 choose(struct allowedips_node *node, const u8 *key) 33 + { 34 + return (key[node->bit_at_a] >> node->bit_at_b) & 1; 35 + } 35 36 36 37 static void push_rcu(struct allowedips_node **stack, 37 38 struct allowedips_node __rcu *p, unsigned int *len) ··· 43 38 WARN_ON(IS_ENABLED(DEBUG) && *len >= 128); 44 39 stack[(*len)++] = rcu_dereference_raw(p); 45 40 } 41 + } 42 + 43 + static void node_free_rcu(struct rcu_head *rcu) 44 + { 45 + kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); 46 46 } 47 47 48 48 static void root_free_rcu(struct rcu_head *rcu) ··· 59 49 while (len > 0 && (node = stack[--len])) { 60 50 push_rcu(stack, node->bit[0], &len); 61 51 push_rcu(stack, node->bit[1], &len); 62 - kfree(node); 52 + kmem_cache_free(node_cache, node); 63 53 } 64 54 } 65 55 ··· 74 64 if (rcu_access_pointer(node->peer)) 75 65 list_del(&node->peer_list); 76 66 } 77 - } 78 - 79 - static void walk_remove_by_peer(struct allowedips_node __rcu **top, 80 - struct wg_peer *peer, struct mutex *lock) 81 - { 82 - #define REF(p) rcu_access_pointer(p) 83 - #define DEREF(p) rcu_dereference_protected(*(p), lockdep_is_held(lock)) 84 - #define PUSH(p) ({ \ 85 - WARN_ON(IS_ENABLED(DEBUG) && len >= 128); \ 86 - stack[len++] = p; \ 87 - }) 88 - 89 - struct allowedips_node __rcu **stack[128], **nptr; 90 - struct allowedips_node *node, *prev; 91 - unsigned int len; 92 - 93 - if (unlikely(!peer || !REF(*top))) 94 - return; 95 - 96 - for (prev = NULL, len = 0, PUSH(top); len > 0; prev = node) { 97 - nptr = stack[len - 1]; 98 - node = DEREF(nptr); 99 - if (!node) { 100 - --len; 101 - continue; 102 - } 103 - if (!prev || REF(prev->bit[0]) == node || 104 - REF(prev->bit[1]) == node) { 105 - if (REF(node->bit[0])) 106 - PUSH(&node->bit[0]); 107 - else if (REF(node->bit[1])) 108 - PUSH(&node->bit[1]); 109 - } else if (REF(node->bit[0]) == prev) { 110 - if (REF(node->bit[1])) 111 - PUSH(&node->bit[1]); 112 - } else { 113 - if (rcu_dereference_protected(node->peer, 114 - lockdep_is_held(lock)) == peer) { 115 - RCU_INIT_POINTER(node->peer, NULL); 116 - list_del_init(&node->peer_list); 117 - if (!node->bit[0] || !node->bit[1]) { 118 - rcu_assign_pointer(*nptr, DEREF( 119 - &node->bit[!REF(node->bit[0])])); 120 - kfree_rcu(node, rcu); 121 - node = DEREF(nptr); 122 - } 123 - } 124 - --len; 125 - } 126 - } 127 - 128 - #undef REF 129 - #undef DEREF 130 - #undef PUSH 131 67 } 132 68 133 69 static unsigned int fls128(u64 a, u64 b) ··· 115 159 found = node; 116 160 if (node->cidr == bits) 117 161 break; 118 - node = rcu_dereference_bh(CHOOSE_NODE(node, key)); 162 + node = rcu_dereference_bh(node->bit[choose(node, key)]); 119 163 } 120 164 return found; 121 165 } ··· 147 191 u8 cidr, u8 bits, struct allowedips_node **rnode, 148 192 struct mutex *lock) 149 193 { 150 - struct allowedips_node *node = rcu_dereference_protected(trie, 151 - lockdep_is_held(lock)); 194 + struct allowedips_node *node = rcu_dereference_protected(trie, lockdep_is_held(lock)); 152 195 struct allowedips_node *parent = NULL; 153 196 bool exact = false; 154 197 ··· 157 202 exact = true; 158 203 break; 159 204 } 160 - node = rcu_dereference_protected(CHOOSE_NODE(parent, key), 161 - lockdep_is_held(lock)); 205 + node = rcu_dereference_protected(parent->bit[choose(parent, key)], lockdep_is_held(lock)); 162 206 } 163 207 *rnode = parent; 164 208 return exact; 209 + } 210 + 211 + static inline void connect_node(struct allowedips_node **parent, u8 bit, struct allowedips_node *node) 212 + { 213 + node->parent_bit_packed = (unsigned long)parent | bit; 214 + rcu_assign_pointer(*parent, node); 215 + } 216 + 217 + static inline void choose_and_connect_node(struct allowedips_node *parent, struct allowedips_node *node) 218 + { 219 + u8 bit = choose(parent, node->bits); 220 + connect_node(&parent->bit[bit], bit, node); 165 221 } 166 222 167 223 static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, ··· 184 218 return -EINVAL; 185 219 186 220 if (!rcu_access_pointer(*trie)) { 187 - node = kzalloc(sizeof(*node), GFP_KERNEL); 221 + node = kmem_cache_zalloc(node_cache, GFP_KERNEL); 188 222 if (unlikely(!node)) 189 223 return -ENOMEM; 190 224 RCU_INIT_POINTER(node->peer, peer); 191 225 list_add_tail(&node->peer_list, &peer->allowedips_list); 192 226 copy_and_assign_cidr(node, key, cidr, bits); 193 - rcu_assign_pointer(*trie, node); 227 + connect_node(trie, 2, node); 194 228 return 0; 195 229 } 196 230 if (node_placement(*trie, key, cidr, bits, &node, lock)) { ··· 199 233 return 0; 200 234 } 201 235 202 - newnode = kzalloc(sizeof(*newnode), GFP_KERNEL); 236 + newnode = kmem_cache_zalloc(node_cache, GFP_KERNEL); 203 237 if (unlikely(!newnode)) 204 238 return -ENOMEM; 205 239 RCU_INIT_POINTER(newnode->peer, peer); ··· 209 243 if (!node) { 210 244 down = rcu_dereference_protected(*trie, lockdep_is_held(lock)); 211 245 } else { 212 - down = rcu_dereference_protected(CHOOSE_NODE(node, key), 213 - lockdep_is_held(lock)); 246 + const u8 bit = choose(node, key); 247 + down = rcu_dereference_protected(node->bit[bit], lockdep_is_held(lock)); 214 248 if (!down) { 215 - rcu_assign_pointer(CHOOSE_NODE(node, key), newnode); 249 + connect_node(&node->bit[bit], bit, newnode); 216 250 return 0; 217 251 } 218 252 } ··· 220 254 parent = node; 221 255 222 256 if (newnode->cidr == cidr) { 223 - rcu_assign_pointer(CHOOSE_NODE(newnode, down->bits), down); 257 + choose_and_connect_node(newnode, down); 224 258 if (!parent) 225 - rcu_assign_pointer(*trie, newnode); 259 + connect_node(trie, 2, newnode); 226 260 else 227 - rcu_assign_pointer(CHOOSE_NODE(parent, newnode->bits), 228 - newnode); 229 - } else { 230 - node = kzalloc(sizeof(*node), GFP_KERNEL); 231 - if (unlikely(!node)) { 232 - list_del(&newnode->peer_list); 233 - kfree(newnode); 234 - return -ENOMEM; 235 - } 236 - INIT_LIST_HEAD(&node->peer_list); 237 - copy_and_assign_cidr(node, newnode->bits, cidr, bits); 238 - 239 - rcu_assign_pointer(CHOOSE_NODE(node, down->bits), down); 240 - rcu_assign_pointer(CHOOSE_NODE(node, newnode->bits), newnode); 241 - if (!parent) 242 - rcu_assign_pointer(*trie, node); 243 - else 244 - rcu_assign_pointer(CHOOSE_NODE(parent, node->bits), 245 - node); 261 + choose_and_connect_node(parent, newnode); 262 + return 0; 246 263 } 264 + 265 + node = kmem_cache_zalloc(node_cache, GFP_KERNEL); 266 + if (unlikely(!node)) { 267 + list_del(&newnode->peer_list); 268 + kmem_cache_free(node_cache, newnode); 269 + return -ENOMEM; 270 + } 271 + INIT_LIST_HEAD(&node->peer_list); 272 + copy_and_assign_cidr(node, newnode->bits, cidr, bits); 273 + 274 + choose_and_connect_node(node, down); 275 + choose_and_connect_node(node, newnode); 276 + if (!parent) 277 + connect_node(trie, 2, node); 278 + else 279 + choose_and_connect_node(parent, node); 247 280 return 0; 248 281 } 249 282 ··· 300 335 void wg_allowedips_remove_by_peer(struct allowedips *table, 301 336 struct wg_peer *peer, struct mutex *lock) 302 337 { 338 + struct allowedips_node *node, *child, **parent_bit, *parent, *tmp; 339 + bool free_parent; 340 + 341 + if (list_empty(&peer->allowedips_list)) 342 + return; 303 343 ++table->seq; 304 - walk_remove_by_peer(&table->root4, peer, lock); 305 - walk_remove_by_peer(&table->root6, peer, lock); 344 + list_for_each_entry_safe(node, tmp, &peer->allowedips_list, peer_list) { 345 + list_del_init(&node->peer_list); 346 + RCU_INIT_POINTER(node->peer, NULL); 347 + if (node->bit[0] && node->bit[1]) 348 + continue; 349 + child = rcu_dereference_protected(node->bit[!rcu_access_pointer(node->bit[0])], 350 + lockdep_is_held(lock)); 351 + if (child) 352 + child->parent_bit_packed = node->parent_bit_packed; 353 + parent_bit = (struct allowedips_node **)(node->parent_bit_packed & ~3UL); 354 + *parent_bit = child; 355 + parent = (void *)parent_bit - 356 + offsetof(struct allowedips_node, bit[node->parent_bit_packed & 1]); 357 + free_parent = !rcu_access_pointer(node->bit[0]) && 358 + !rcu_access_pointer(node->bit[1]) && 359 + (node->parent_bit_packed & 3) <= 1 && 360 + !rcu_access_pointer(parent->peer); 361 + if (free_parent) 362 + child = rcu_dereference_protected( 363 + parent->bit[!(node->parent_bit_packed & 1)], 364 + lockdep_is_held(lock)); 365 + call_rcu(&node->rcu, node_free_rcu); 366 + if (!free_parent) 367 + continue; 368 + if (child) 369 + child->parent_bit_packed = parent->parent_bit_packed; 370 + *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; 371 + call_rcu(&parent->rcu, node_free_rcu); 372 + } 306 373 } 307 374 308 375 int wg_allowedips_read_node(struct allowedips_node *node, u8 ip[16], u8 *cidr) ··· 369 372 else if (skb->protocol == htons(ETH_P_IPV6)) 370 373 return lookup(table->root6, 128, &ipv6_hdr(skb)->saddr); 371 374 return NULL; 375 + } 376 + 377 + int __init wg_allowedips_slab_init(void) 378 + { 379 + node_cache = KMEM_CACHE(allowedips_node, 0); 380 + return node_cache ? 0 : -ENOMEM; 381 + } 382 + 383 + void wg_allowedips_slab_uninit(void) 384 + { 385 + rcu_barrier(); 386 + kmem_cache_destroy(node_cache); 372 387 } 373 388 374 389 #include "selftest/allowedips.c"
+7 -7
drivers/net/wireguard/allowedips.h
··· 15 15 struct allowedips_node { 16 16 struct wg_peer __rcu *peer; 17 17 struct allowedips_node __rcu *bit[2]; 18 - /* While it may seem scandalous that we waste space for v4, 19 - * we're alloc'ing to the nearest power of 2 anyway, so this 20 - * doesn't actually make a difference. 21 - */ 22 - u8 bits[16] __aligned(__alignof(u64)); 23 18 u8 cidr, bit_at_a, bit_at_b, bitlen; 19 + u8 bits[16] __aligned(__alignof(u64)); 24 20 25 - /* Keep rarely used list at bottom to be beyond cache line. */ 21 + /* Keep rarely used members at bottom to be beyond cache line. */ 22 + unsigned long parent_bit_packed; 26 23 union { 27 24 struct list_head peer_list; 28 25 struct rcu_head rcu; ··· 30 33 struct allowedips_node __rcu *root4; 31 34 struct allowedips_node __rcu *root6; 32 35 u64 seq; 33 - }; 36 + } __aligned(4); /* We pack the lower 2 bits of &root, but m68k only gives 16-bit alignment. */ 34 37 35 38 void wg_allowedips_init(struct allowedips *table); 36 39 void wg_allowedips_free(struct allowedips *table, struct mutex *mutex); ··· 52 55 #ifdef DEBUG 53 56 bool wg_allowedips_selftest(void); 54 57 #endif 58 + 59 + int wg_allowedips_slab_init(void); 60 + void wg_allowedips_slab_uninit(void); 55 61 56 62 #endif /* _WG_ALLOWEDIPS_H */
+16 -1
drivers/net/wireguard/main.c
··· 21 21 { 22 22 int ret; 23 23 24 + ret = wg_allowedips_slab_init(); 25 + if (ret < 0) 26 + goto err_allowedips; 27 + 24 28 #ifdef DEBUG 29 + ret = -ENOTRECOVERABLE; 25 30 if (!wg_allowedips_selftest() || !wg_packet_counter_selftest() || 26 31 !wg_ratelimiter_selftest()) 27 - return -ENOTRECOVERABLE; 32 + goto err_peer; 28 33 #endif 29 34 wg_noise_init(); 35 + 36 + ret = wg_peer_init(); 37 + if (ret < 0) 38 + goto err_peer; 30 39 31 40 ret = wg_device_init(); 32 41 if (ret < 0) ··· 53 44 err_netlink: 54 45 wg_device_uninit(); 55 46 err_device: 47 + wg_peer_uninit(); 48 + err_peer: 49 + wg_allowedips_slab_uninit(); 50 + err_allowedips: 56 51 return ret; 57 52 } 58 53 ··· 64 51 { 65 52 wg_genetlink_uninit(); 66 53 wg_device_uninit(); 54 + wg_peer_uninit(); 55 + wg_allowedips_slab_uninit(); 67 56 } 68 57 69 58 module_init(mod_init);
+20 -7
drivers/net/wireguard/peer.c
··· 15 15 #include <linux/rcupdate.h> 16 16 #include <linux/list.h> 17 17 18 + static struct kmem_cache *peer_cache; 18 19 static atomic64_t peer_counter = ATOMIC64_INIT(0); 19 20 20 21 struct wg_peer *wg_peer_create(struct wg_device *wg, ··· 30 29 if (wg->num_peers >= MAX_PEERS_PER_DEVICE) 31 30 return ERR_PTR(ret); 32 31 33 - peer = kzalloc(sizeof(*peer), GFP_KERNEL); 32 + peer = kmem_cache_zalloc(peer_cache, GFP_KERNEL); 34 33 if (unlikely(!peer)) 35 34 return ERR_PTR(ret); 36 - if (dst_cache_init(&peer->endpoint_cache, GFP_KERNEL)) 35 + if (unlikely(dst_cache_init(&peer->endpoint_cache, GFP_KERNEL))) 37 36 goto err; 38 37 39 38 peer->device = wg; ··· 65 64 return peer; 66 65 67 66 err: 68 - kfree(peer); 67 + kmem_cache_free(peer_cache, peer); 69 68 return ERR_PTR(ret); 70 69 } 71 70 ··· 89 88 /* Mark as dead, so that we don't allow jumping contexts after. */ 90 89 WRITE_ONCE(peer->is_dead, true); 91 90 92 - /* The caller must now synchronize_rcu() for this to take effect. */ 91 + /* The caller must now synchronize_net() for this to take effect. */ 93 92 } 94 93 95 94 static void peer_remove_after_dead(struct wg_peer *peer) ··· 161 160 lockdep_assert_held(&peer->device->device_update_lock); 162 161 163 162 peer_make_dead(peer); 164 - synchronize_rcu(); 163 + synchronize_net(); 165 164 peer_remove_after_dead(peer); 166 165 } 167 166 ··· 179 178 peer_make_dead(peer); 180 179 list_add_tail(&peer->peer_list, &dead_peers); 181 180 } 182 - synchronize_rcu(); 181 + synchronize_net(); 183 182 list_for_each_entry_safe(peer, temp, &dead_peers, peer_list) 184 183 peer_remove_after_dead(peer); 185 184 } ··· 194 193 /* The final zeroing takes care of clearing any remaining handshake key 195 194 * material and other potentially sensitive information. 196 195 */ 197 - kfree_sensitive(peer); 196 + memzero_explicit(peer, sizeof(*peer)); 197 + kmem_cache_free(peer_cache, peer); 198 198 } 199 199 200 200 static void kref_release(struct kref *refcount) ··· 226 224 if (unlikely(!peer)) 227 225 return; 228 226 kref_put(&peer->refcount, kref_release); 227 + } 228 + 229 + int __init wg_peer_init(void) 230 + { 231 + peer_cache = KMEM_CACHE(wg_peer, 0); 232 + return peer_cache ? 0 : -ENOMEM; 233 + } 234 + 235 + void wg_peer_uninit(void) 236 + { 237 + kmem_cache_destroy(peer_cache); 229 238 }
+3
drivers/net/wireguard/peer.h
··· 80 80 void wg_peer_remove(struct wg_peer *peer); 81 81 void wg_peer_remove_all(struct wg_device *wg); 82 82 83 + int wg_peer_init(void); 84 + void wg_peer_uninit(void); 85 + 83 86 #endif /* _WG_PEER_H */
+80 -87
drivers/net/wireguard/selftest/allowedips.c
··· 19 19 20 20 #include <linux/siphash.h> 21 21 22 - static __init void swap_endian_and_apply_cidr(u8 *dst, const u8 *src, u8 bits, 23 - u8 cidr) 24 - { 25 - swap_endian(dst, src, bits); 26 - memset(dst + (cidr + 7) / 8, 0, bits / 8 - (cidr + 7) / 8); 27 - if (cidr) 28 - dst[(cidr + 7) / 8 - 1] &= ~0U << ((8 - (cidr % 8)) % 8); 29 - } 30 - 31 22 static __init void print_node(struct allowedips_node *node, u8 bits) 32 23 { 33 24 char *fmt_connection = KERN_DEBUG "\t\"%p/%d\" -> \"%p/%d\";\n"; 34 - char *fmt_declaration = KERN_DEBUG 35 - "\t\"%p/%d\"[style=%s, color=\"#%06x\"];\n"; 25 + char *fmt_declaration = KERN_DEBUG "\t\"%p/%d\"[style=%s, color=\"#%06x\"];\n"; 26 + u8 ip1[16], ip2[16], cidr1, cidr2; 36 27 char *style = "dotted"; 37 - u8 ip1[16], ip2[16]; 38 28 u32 color = 0; 39 29 30 + if (node == NULL) 31 + return; 40 32 if (bits == 32) { 41 33 fmt_connection = KERN_DEBUG "\t\"%pI4/%d\" -> \"%pI4/%d\";\n"; 42 - fmt_declaration = KERN_DEBUG 43 - "\t\"%pI4/%d\"[style=%s, color=\"#%06x\"];\n"; 34 + fmt_declaration = KERN_DEBUG "\t\"%pI4/%d\"[style=%s, color=\"#%06x\"];\n"; 44 35 } else if (bits == 128) { 45 36 fmt_connection = KERN_DEBUG "\t\"%pI6/%d\" -> \"%pI6/%d\";\n"; 46 - fmt_declaration = KERN_DEBUG 47 - "\t\"%pI6/%d\"[style=%s, color=\"#%06x\"];\n"; 37 + fmt_declaration = KERN_DEBUG "\t\"%pI6/%d\"[style=%s, color=\"#%06x\"];\n"; 48 38 } 49 39 if (node->peer) { 50 40 hsiphash_key_t key = { { 0 } }; ··· 45 55 hsiphash_1u32(0xabad1dea, &key) % 200; 46 56 style = "bold"; 47 57 } 48 - swap_endian_and_apply_cidr(ip1, node->bits, bits, node->cidr); 49 - printk(fmt_declaration, ip1, node->cidr, style, color); 58 + wg_allowedips_read_node(node, ip1, &cidr1); 59 + printk(fmt_declaration, ip1, cidr1, style, color); 50 60 if (node->bit[0]) { 51 - swap_endian_and_apply_cidr(ip2, 52 - rcu_dereference_raw(node->bit[0])->bits, bits, 53 - node->cidr); 54 - printk(fmt_connection, ip1, node->cidr, ip2, 55 - rcu_dereference_raw(node->bit[0])->cidr); 56 - print_node(rcu_dereference_raw(node->bit[0]), bits); 61 + wg_allowedips_read_node(rcu_dereference_raw(node->bit[0]), ip2, &cidr2); 62 + printk(fmt_connection, ip1, cidr1, ip2, cidr2); 57 63 } 58 64 if (node->bit[1]) { 59 - swap_endian_and_apply_cidr(ip2, 60 - rcu_dereference_raw(node->bit[1])->bits, 61 - bits, node->cidr); 62 - printk(fmt_connection, ip1, node->cidr, ip2, 63 - rcu_dereference_raw(node->bit[1])->cidr); 64 - print_node(rcu_dereference_raw(node->bit[1]), bits); 65 + wg_allowedips_read_node(rcu_dereference_raw(node->bit[1]), ip2, &cidr2); 66 + printk(fmt_connection, ip1, cidr1, ip2, cidr2); 65 67 } 68 + if (node->bit[0]) 69 + print_node(rcu_dereference_raw(node->bit[0]), bits); 70 + if (node->bit[1]) 71 + print_node(rcu_dereference_raw(node->bit[1]), bits); 66 72 } 67 73 68 74 static __init void print_tree(struct allowedips_node __rcu *top, u8 bits) ··· 107 121 { 108 122 union nf_inet_addr mask; 109 123 110 - memset(&mask, 0x00, 128 / 8); 111 - memset(&mask, 0xff, cidr / 8); 124 + memset(&mask, 0, sizeof(mask)); 125 + memset(&mask.all, 0xff, cidr / 8); 112 126 if (cidr % 32) 113 127 mask.all[cidr / 32] = (__force u32)htonl( 114 128 (0xFFFFFFFFUL << (32 - (cidr % 32))) & 0xFFFFFFFFUL); ··· 135 149 } 136 150 137 151 static __init inline bool 138 - horrible_match_v4(const struct horrible_allowedips_node *node, 139 - struct in_addr *ip) 152 + horrible_match_v4(const struct horrible_allowedips_node *node, struct in_addr *ip) 140 153 { 141 154 return (ip->s_addr & node->mask.ip) == node->ip.ip; 142 155 } 143 156 144 157 static __init inline bool 145 - horrible_match_v6(const struct horrible_allowedips_node *node, 146 - struct in6_addr *ip) 158 + horrible_match_v6(const struct horrible_allowedips_node *node, struct in6_addr *ip) 147 159 { 148 - return (ip->in6_u.u6_addr32[0] & node->mask.ip6[0]) == 149 - node->ip.ip6[0] && 150 - (ip->in6_u.u6_addr32[1] & node->mask.ip6[1]) == 151 - node->ip.ip6[1] && 152 - (ip->in6_u.u6_addr32[2] & node->mask.ip6[2]) == 153 - node->ip.ip6[2] && 160 + return (ip->in6_u.u6_addr32[0] & node->mask.ip6[0]) == node->ip.ip6[0] && 161 + (ip->in6_u.u6_addr32[1] & node->mask.ip6[1]) == node->ip.ip6[1] && 162 + (ip->in6_u.u6_addr32[2] & node->mask.ip6[2]) == node->ip.ip6[2] && 154 163 (ip->in6_u.u6_addr32[3] & node->mask.ip6[3]) == node->ip.ip6[3]; 155 164 } 156 165 157 166 static __init void 158 - horrible_insert_ordered(struct horrible_allowedips *table, 159 - struct horrible_allowedips_node *node) 167 + horrible_insert_ordered(struct horrible_allowedips *table, struct horrible_allowedips_node *node) 160 168 { 161 169 struct horrible_allowedips_node *other = NULL, *where = NULL; 162 170 u8 my_cidr = horrible_mask_to_cidr(node->mask); 163 171 164 172 hlist_for_each_entry(other, &table->head, table) { 165 - if (!memcmp(&other->mask, &node->mask, 166 - sizeof(union nf_inet_addr)) && 167 - !memcmp(&other->ip, &node->ip, 168 - sizeof(union nf_inet_addr)) && 169 - other->ip_version == node->ip_version) { 173 + if (other->ip_version == node->ip_version && 174 + !memcmp(&other->mask, &node->mask, sizeof(union nf_inet_addr)) && 175 + !memcmp(&other->ip, &node->ip, sizeof(union nf_inet_addr))) { 170 176 other->value = node->value; 171 177 kfree(node); 172 178 return; 173 179 } 180 + } 181 + hlist_for_each_entry(other, &table->head, table) { 174 182 where = other; 175 183 if (horrible_mask_to_cidr(other->mask) <= my_cidr) 176 184 break; ··· 181 201 horrible_allowedips_insert_v4(struct horrible_allowedips *table, 182 202 struct in_addr *ip, u8 cidr, void *value) 183 203 { 184 - struct horrible_allowedips_node *node = kzalloc(sizeof(*node), 185 - GFP_KERNEL); 204 + struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); 186 205 187 206 if (unlikely(!node)) 188 207 return -ENOMEM; ··· 198 219 horrible_allowedips_insert_v6(struct horrible_allowedips *table, 199 220 struct in6_addr *ip, u8 cidr, void *value) 200 221 { 201 - struct horrible_allowedips_node *node = kzalloc(sizeof(*node), 202 - GFP_KERNEL); 222 + struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); 203 223 204 224 if (unlikely(!node)) 205 225 return -ENOMEM; ··· 212 234 } 213 235 214 236 static __init void * 215 - horrible_allowedips_lookup_v4(struct horrible_allowedips *table, 216 - struct in_addr *ip) 237 + horrible_allowedips_lookup_v4(struct horrible_allowedips *table, struct in_addr *ip) 217 238 { 218 239 struct horrible_allowedips_node *node; 219 - void *ret = NULL; 220 240 221 241 hlist_for_each_entry(node, &table->head, table) { 222 - if (node->ip_version != 4) 223 - continue; 224 - if (horrible_match_v4(node, ip)) { 225 - ret = node->value; 226 - break; 227 - } 242 + if (node->ip_version == 4 && horrible_match_v4(node, ip)) 243 + return node->value; 228 244 } 229 - return ret; 245 + return NULL; 230 246 } 231 247 232 248 static __init void * 233 - horrible_allowedips_lookup_v6(struct horrible_allowedips *table, 234 - struct in6_addr *ip) 249 + horrible_allowedips_lookup_v6(struct horrible_allowedips *table, struct in6_addr *ip) 235 250 { 236 251 struct horrible_allowedips_node *node; 237 - void *ret = NULL; 238 252 239 253 hlist_for_each_entry(node, &table->head, table) { 240 - if (node->ip_version != 6) 241 - continue; 242 - if (horrible_match_v6(node, ip)) { 243 - ret = node->value; 244 - break; 245 - } 254 + if (node->ip_version == 6 && horrible_match_v6(node, ip)) 255 + return node->value; 246 256 } 247 - return ret; 257 + return NULL; 258 + } 259 + 260 + 261 + static __init void 262 + horrible_allowedips_remove_by_value(struct horrible_allowedips *table, void *value) 263 + { 264 + struct horrible_allowedips_node *node; 265 + struct hlist_node *h; 266 + 267 + hlist_for_each_entry_safe(node, h, &table->head, table) { 268 + if (node->value != value) 269 + continue; 270 + hlist_del(&node->table); 271 + kfree(node); 272 + } 273 + 248 274 } 249 275 250 276 static __init bool randomized_test(void) ··· 278 296 goto free; 279 297 } 280 298 kref_init(&peers[i]->refcount); 299 + INIT_LIST_HEAD(&peers[i]->allowedips_list); 281 300 } 282 301 283 302 mutex_lock(&mutex); ··· 316 333 if (wg_allowedips_insert_v4(&t, 317 334 (struct in_addr *)mutated, 318 335 cidr, peer, &mutex) < 0) { 319 - pr_err("allowedips random malloc: FAIL\n"); 336 + pr_err("allowedips random self-test malloc: FAIL\n"); 320 337 goto free_locked; 321 338 } 322 339 if (horrible_allowedips_insert_v4(&h, ··· 379 396 print_tree(t.root6, 128); 380 397 } 381 398 382 - for (i = 0; i < NUM_QUERIES; ++i) { 383 - prandom_bytes(ip, 4); 384 - if (lookup(t.root4, 32, ip) != 385 - horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip)) { 386 - pr_err("allowedips random self-test: FAIL\n"); 387 - goto free; 399 + for (j = 0;; ++j) { 400 + for (i = 0; i < NUM_QUERIES; ++i) { 401 + prandom_bytes(ip, 4); 402 + if (lookup(t.root4, 32, ip) != horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip)) { 403 + horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip); 404 + pr_err("allowedips random v4 self-test: FAIL\n"); 405 + goto free; 406 + } 407 + prandom_bytes(ip, 16); 408 + if (lookup(t.root6, 128, ip) != horrible_allowedips_lookup_v6(&h, (struct in6_addr *)ip)) { 409 + pr_err("allowedips random v6 self-test: FAIL\n"); 410 + goto free; 411 + } 388 412 } 413 + if (j >= NUM_PEERS) 414 + break; 415 + mutex_lock(&mutex); 416 + wg_allowedips_remove_by_peer(&t, peers[j], &mutex); 417 + mutex_unlock(&mutex); 418 + horrible_allowedips_remove_by_value(&h, peers[j]); 389 419 } 390 420 391 - for (i = 0; i < NUM_QUERIES; ++i) { 392 - prandom_bytes(ip, 16); 393 - if (lookup(t.root6, 128, ip) != 394 - horrible_allowedips_lookup_v6(&h, (struct in6_addr *)ip)) { 395 - pr_err("allowedips random self-test: FAIL\n"); 396 - goto free; 397 - } 421 + if (t.root4 || t.root6) { 422 + pr_err("allowedips random self-test removal: FAIL\n"); 423 + goto free; 398 424 } 425 + 399 426 ret = true; 400 427 401 428 free:
+1 -1
drivers/net/wireguard/socket.c
··· 430 430 if (new4) 431 431 wg->incoming_port = ntohs(inet_sk(new4)->inet_sport); 432 432 mutex_unlock(&wg->socket_update_lock); 433 - synchronize_rcu(); 433 + synchronize_net(); 434 434 sock_free(old4); 435 435 sock_free(old6); 436 436 }
+26
drivers/net/wireless/mediatek/mt76/mac80211.c
··· 514 514 static void mt76_rx_release_amsdu(struct mt76_phy *phy, enum mt76_rxq_id q) 515 515 { 516 516 struct sk_buff *skb = phy->rx_amsdu[q].head; 517 + struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; 517 518 struct mt76_dev *dev = phy->dev; 518 519 519 520 phy->rx_amsdu[q].head = NULL; 520 521 phy->rx_amsdu[q].tail = NULL; 522 + 523 + /* 524 + * Validate if the amsdu has a proper first subframe. 525 + * A single MSDU can be parsed as A-MSDU when the unauthenticated A-MSDU 526 + * flag of the QoS header gets flipped. In such cases, the first 527 + * subframe has a LLC/SNAP header in the location of the destination 528 + * address. 529 + */ 530 + if (skb_shinfo(skb)->frag_list) { 531 + int offset = 0; 532 + 533 + if (!(status->flag & RX_FLAG_8023)) { 534 + offset = ieee80211_get_hdrlen_from_skb(skb); 535 + 536 + if ((status->flag & 537 + (RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED)) == 538 + RX_FLAG_DECRYPTED) 539 + offset += 8; 540 + } 541 + 542 + if (ether_addr_equal(skb->data + offset, rfc1042_header)) { 543 + dev_kfree_skb(skb); 544 + return; 545 + } 546 + } 521 547 __skb_queue_tail(&dev->rx_skb[q], skb); 522 548 } 523 549
-1
drivers/net/wireless/mediatek/mt76/mt7615/init.c
··· 510 510 mutex_init(&dev->pm.mutex); 511 511 init_waitqueue_head(&dev->pm.wait); 512 512 spin_lock_init(&dev->pm.txq_lock); 513 - set_bit(MT76_STATE_PM, &dev->mphy.state); 514 513 INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work); 515 514 INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work); 516 515 INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work);
+3 -2
drivers/net/wireless/mediatek/mt76/mt7615/mac.c
··· 1912 1912 napi_schedule(&dev->mt76.napi[i]); 1913 1913 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); 1914 1914 mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], false); 1915 - ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, 1916 - MT7615_WATCHDOG_TIME); 1915 + if (test_bit(MT76_STATE_RUNNING, &mphy->state)) 1916 + ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, 1917 + MT7615_WATCHDOG_TIME); 1917 1918 } 1918 1919 1919 1920 ieee80211_wake_queues(mphy->hw);
+12 -7
drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
··· 51 51 return ret; 52 52 } 53 53 54 - static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) 54 + static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) 55 55 { 56 56 struct sdio_func *func = dev->mt76.sdio.func; 57 57 struct mt76_phy *mphy = &dev->mt76.phy; 58 58 u32 status; 59 59 int ret; 60 - 61 - if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state)) 62 - goto out; 63 60 64 61 sdio_claim_host(func); 65 62 ··· 73 76 } 74 77 75 78 sdio_release_host(func); 76 - 77 - out: 78 79 dev->pm.last_activity = jiffies; 80 + 81 + return 0; 82 + } 83 + 84 + static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) 85 + { 86 + struct mt76_phy *mphy = &dev->mt76.phy; 87 + 88 + if (test_and_clear_bit(MT76_STATE_PM, &mphy->state)) 89 + return __mt7663s_mcu_drv_pmctrl(dev); 79 90 80 91 return 0; 81 92 } ··· 128 123 struct mt7615_mcu_ops *mcu_ops; 129 124 int ret; 130 125 131 - ret = mt7663s_mcu_drv_pmctrl(dev); 126 + ret = __mt7663s_mcu_drv_pmctrl(dev); 132 127 if (ret) 133 128 return ret; 134 129
-3
drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
··· 55 55 56 56 dev->mt76.mcu_ops = &mt7663u_mcu_ops, 57 57 58 - /* usb does not support runtime-pm */ 59 - clear_bit(MT76_STATE_PM, &dev->mphy.state); 60 58 mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN); 61 - 62 59 if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) { 63 60 mt7615_mcu_restart(&dev->mt76); 64 61 if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
+4
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
··· 721 721 phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta); 722 722 phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates); 723 723 phy->rcpi = rcpi; 724 + phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR, 725 + sta->ht_cap.ampdu_factor) | 726 + FIELD_PREP(IEEE80211_HT_AMPDU_PARM_DENSITY, 727 + sta->ht_cap.ampdu_density); 724 728 725 729 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info)); 726 730 ra_info = (struct sta_rec_ra_info *)tlv;
+77 -4
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
··· 87 87 .reconfig_complete = mt76x02_reconfig_complete, 88 88 }; 89 89 90 - static int mt76x0e_register_device(struct mt76x02_dev *dev) 90 + static int mt76x0e_init_hardware(struct mt76x02_dev *dev, bool resume) 91 91 { 92 92 int err; 93 93 ··· 100 100 if (err < 0) 101 101 return err; 102 102 103 - err = mt76x02_dma_init(dev); 104 - if (err < 0) 105 - return err; 103 + if (!resume) { 104 + err = mt76x02_dma_init(dev); 105 + if (err < 0) 106 + return err; 107 + } 106 108 107 109 err = mt76x0_init_hardware(dev); 108 110 if (err < 0) ··· 124 122 125 123 mt76_clear(dev, 0x110, BIT(9)); 126 124 mt76_set(dev, MT_MAX_LEN_CFG, BIT(13)); 125 + 126 + return 0; 127 + } 128 + 129 + static int mt76x0e_register_device(struct mt76x02_dev *dev) 130 + { 131 + int err; 132 + 133 + err = mt76x0e_init_hardware(dev, false); 134 + if (err < 0) 135 + return err; 127 136 128 137 err = mt76x0_register_device(dev); 129 138 if (err < 0) ··· 179 166 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 180 167 if (ret) 181 168 return ret; 169 + 170 + mt76_pci_disable_aspm(pdev); 182 171 183 172 mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x0e_ops, 184 173 &drv_ops); ··· 235 220 mt76_free_device(mdev); 236 221 } 237 222 223 + #ifdef CONFIG_PM 224 + static int mt76x0e_suspend(struct pci_dev *pdev, pm_message_t state) 225 + { 226 + struct mt76_dev *mdev = pci_get_drvdata(pdev); 227 + struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); 228 + int i; 229 + 230 + mt76_worker_disable(&mdev->tx_worker); 231 + for (i = 0; i < ARRAY_SIZE(mdev->phy.q_tx); i++) 232 + mt76_queue_tx_cleanup(dev, mdev->phy.q_tx[i], true); 233 + for (i = 0; i < ARRAY_SIZE(mdev->q_mcu); i++) 234 + mt76_queue_tx_cleanup(dev, mdev->q_mcu[i], true); 235 + napi_disable(&mdev->tx_napi); 236 + 237 + mt76_for_each_q_rx(mdev, i) 238 + napi_disable(&mdev->napi[i]); 239 + 240 + mt76x02_dma_disable(dev); 241 + mt76x02_mcu_cleanup(dev); 242 + mt76x0_chip_onoff(dev, false, false); 243 + 244 + pci_enable_wake(pdev, pci_choose_state(pdev, state), true); 245 + pci_save_state(pdev); 246 + 247 + return pci_set_power_state(pdev, pci_choose_state(pdev, state)); 248 + } 249 + 250 + static int mt76x0e_resume(struct pci_dev *pdev) 251 + { 252 + struct mt76_dev *mdev = pci_get_drvdata(pdev); 253 + struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); 254 + int err, i; 255 + 256 + err = pci_set_power_state(pdev, PCI_D0); 257 + if (err) 258 + return err; 259 + 260 + pci_restore_state(pdev); 261 + 262 + mt76_worker_enable(&mdev->tx_worker); 263 + 264 + mt76_for_each_q_rx(mdev, i) { 265 + mt76_queue_rx_reset(dev, i); 266 + napi_enable(&mdev->napi[i]); 267 + napi_schedule(&mdev->napi[i]); 268 + } 269 + 270 + napi_enable(&mdev->tx_napi); 271 + napi_schedule(&mdev->tx_napi); 272 + 273 + return mt76x0e_init_hardware(dev, true); 274 + } 275 + #endif /* CONFIG_PM */ 276 + 238 277 static const struct pci_device_id mt76x0e_device_table[] = { 239 278 { PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7610) }, 240 279 { PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7630) }, ··· 306 237 .id_table = mt76x0e_device_table, 307 238 .probe = mt76x0e_probe, 308 239 .remove = mt76x0e_remove, 240 + #ifdef CONFIG_PM 241 + .suspend = mt76x0e_suspend, 242 + .resume = mt76x0e_resume, 243 + #endif /* CONFIG_PM */ 309 244 }; 310 245 311 246 module_pci_driver(mt76x0e_driver);
+2 -2
drivers/net/wireless/mediatek/mt76/mt7921/init.c
··· 76 76 struct wiphy *wiphy = hw->wiphy; 77 77 78 78 hw->queues = 4; 79 - hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; 80 - hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; 79 + hw->max_rx_aggregation_subframes = 64; 80 + hw->max_tx_aggregation_subframes = 128; 81 81 82 82 hw->radiotap_timestamp.units_pos = 83 83 IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
+3 -2
drivers/net/wireless/mediatek/mt76/mt7921/mac.c
··· 1404 1404 napi_schedule(&dev->mt76.napi[i]); 1405 1405 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); 1406 1406 mt7921_tx_cleanup(dev); 1407 - ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, 1408 - MT7921_WATCHDOG_TIME); 1407 + if (test_bit(MT76_STATE_RUNNING, &mphy->state)) 1408 + ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, 1409 + MT7921_WATCHDOG_TIME); 1409 1410 } 1410 1411 1411 1412 ieee80211_wake_queues(mphy->hw);
+1 -2
drivers/net/wireless/mediatek/mt76/mt7921/main.c
··· 74 74 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; 75 75 else if (band == NL80211_BAND_5GHZ) 76 76 he_cap_elem->phy_cap_info[0] = 77 - IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G | 78 - IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; 77 + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G; 79 78 80 79 he_cap_elem->phy_cap_info[1] = 81 80 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
+10 -7
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
··· 402 402 mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb, 403 403 u16 wlan_idx) 404 404 { 405 - struct mt7921_mcu_wlan_info_event *wtbl_info = 406 - (struct mt7921_mcu_wlan_info_event *)(skb->data); 407 - struct rate_info rate = {}; 408 - u8 curr_idx = wtbl_info->rate_info.rate_idx; 409 - u16 curr = le16_to_cpu(wtbl_info->rate_info.rate[curr_idx]); 410 - struct mt7921_mcu_peer_cap peer = wtbl_info->peer_cap; 405 + struct mt7921_mcu_wlan_info_event *wtbl_info; 411 406 struct mt76_phy *mphy = &dev->mphy; 412 407 struct mt7921_sta_stats *stats; 408 + struct rate_info rate = {}; 413 409 struct mt7921_sta *msta; 414 410 struct mt76_wcid *wcid; 411 + u8 idx; 415 412 416 413 if (wlan_idx >= MT76_N_WCIDS) 414 + return; 415 + 416 + wtbl_info = (struct mt7921_mcu_wlan_info_event *)skb->data; 417 + idx = wtbl_info->rate_info.rate_idx; 418 + if (idx >= ARRAY_SIZE(wtbl_info->rate_info.rate)) 417 419 return; 418 420 419 421 rcu_read_lock(); ··· 428 426 stats = &msta->stats; 429 427 430 428 /* current rate */ 431 - mt7921_mcu_tx_rate_parse(mphy, &peer, &rate, curr); 429 + mt7921_mcu_tx_rate_parse(mphy, &wtbl_info->peer_cap, &rate, 430 + le16_to_cpu(wtbl_info->rate_info.rate[idx])); 432 431 stats->tx_rate = rate; 433 432 out: 434 433 rcu_read_unlock();
+1
include/linux/avf/virtchnl.h
··· 830 830 831 831 struct virtchnl_proto_hdrs { 832 832 u8 tunnel_level; 833 + u8 pad[3]; 833 834 /** 834 835 * specify where protocol header start from. 835 836 * 0 - from the outer layer
+2
include/linux/mlx5/mlx5_ifc.h
··· 1289 1289 1290 1290 #define MLX5_FC_BULK_NUM_FCS(fc_enum) (MLX5_FC_BULK_SIZE_FACTOR * (fc_enum)) 1291 1291 1292 + #define MLX5_FT_MAX_MULTIPATH_LEVEL 63 1293 + 1292 1294 enum { 1293 1295 MLX5_STEERING_FORMAT_CONNECTX_5 = 0, 1294 1296 MLX5_STEERING_FORMAT_CONNECTX_6DX = 1,
+1 -1
include/net/caif/caif_dev.h
··· 119 119 * The link_support layer is used to add any Link Layer specific 120 120 * framing. 121 121 */ 122 - void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, 122 + int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, 123 123 struct cflayer *link_support, int head_room, 124 124 struct cflayer **layer, int (**rcv_func)( 125 125 struct sk_buff *, struct net_device *,
+1 -1
include/net/caif/cfcnfg.h
··· 62 62 * @fcs: Specify if checksum is used in CAIF Framing Layer. 63 63 * @head_room: Head space needed by link specific protocol. 64 64 */ 65 - void 65 + int 66 66 cfcnfg_add_phy_layer(struct cfcnfg *cnfg, 67 67 struct net_device *dev, struct cflayer *phy_layer, 68 68 enum cfcnfg_phy_preference pref,
+1
include/net/caif/cfserl.h
··· 9 9 #include <net/caif/caif_layer.h> 10 10 11 11 struct cflayer *cfserl_create(int instance, bool use_stx); 12 + void cfserl_release(struct cflayer *layer); 12 13 #endif
-6
include/net/netfilter/nf_tables.h
··· 1506 1506 1507 1507 struct nft_trans_table { 1508 1508 bool update; 1509 - u8 state; 1510 - u32 flags; 1511 1509 }; 1512 1510 1513 1511 #define nft_trans_table_update(trans) \ 1514 1512 (((struct nft_trans_table *)trans->data)->update) 1515 - #define nft_trans_table_state(trans) \ 1516 - (((struct nft_trans_table *)trans->data)->state) 1517 - #define nft_trans_table_flags(trans) \ 1518 - (((struct nft_trans_table *)trans->data)->flags) 1519 1513 1520 1514 struct nft_trans_elem { 1521 1515 struct nft_set *set;
+9 -1
include/net/tls.h
··· 193 193 (sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX) 194 194 195 195 enum tls_context_flags { 196 - TLS_RX_SYNC_RUNNING = 0, 196 + /* tls_device_down was called after the netdev went down, device state 197 + * was released, and kTLS works in software, even though rx_conf is 198 + * still TLS_HW (needed for transition). 199 + */ 200 + TLS_RX_DEV_DEGRADED = 0, 197 201 /* Unlike RX where resync is driven entirely by the core in TX only 198 202 * the driver knows when things went out of sync, so we need the flag 199 203 * to be atomic. ··· 270 266 271 267 /* cache cold stuff */ 272 268 struct proto *sk_proto; 269 + struct sock *sk; 273 270 274 271 void (*sk_destruct)(struct sock *sk); 275 272 ··· 453 448 struct sk_buff * 454 449 tls_validate_xmit_skb(struct sock *sk, struct net_device *dev, 455 450 struct sk_buff *skb); 451 + struct sk_buff * 452 + tls_validate_xmit_skb_sw(struct sock *sk, struct net_device *dev, 453 + struct sk_buff *skb); 456 454 457 455 static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk) 458 456 {
+1 -1
include/uapi/linux/virtio_ids.h
··· 54 54 #define VIRTIO_ID_SOUND 25 /* virtio sound */ 55 55 #define VIRTIO_ID_FS 26 /* virtio filesystem */ 56 56 #define VIRTIO_ID_PMEM 27 /* virtio pmem */ 57 - #define VIRTIO_ID_BT 28 /* virtio bluetooth */ 58 57 #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ 58 + #define VIRTIO_ID_BT 40 /* virtio bluetooth */ 59 59 60 60 #endif /* _LINUX_VIRTIO_IDS_H */
+5 -2
kernel/bpf/helpers.c
··· 14 14 #include <linux/jiffies.h> 15 15 #include <linux/pid_namespace.h> 16 16 #include <linux/proc_ns.h> 17 + #include <linux/security.h> 17 18 18 19 #include "../../lib/kstrtox.h" 19 20 ··· 1070 1069 case BPF_FUNC_probe_read_user: 1071 1070 return &bpf_probe_read_user_proto; 1072 1071 case BPF_FUNC_probe_read_kernel: 1073 - return &bpf_probe_read_kernel_proto; 1072 + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? 1073 + NULL : &bpf_probe_read_kernel_proto; 1074 1074 case BPF_FUNC_probe_read_user_str: 1075 1075 return &bpf_probe_read_user_str_proto; 1076 1076 case BPF_FUNC_probe_read_kernel_str: 1077 - return &bpf_probe_read_kernel_str_proto; 1077 + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? 1078 + NULL : &bpf_probe_read_kernel_str_proto; 1078 1079 case BPF_FUNC_snprintf_btf: 1079 1080 return &bpf_snprintf_btf_proto; 1080 1081 case BPF_FUNC_snprintf:
+12 -20
kernel/trace/bpf_trace.c
··· 215 215 static __always_inline int 216 216 bpf_probe_read_kernel_common(void *dst, u32 size, const void *unsafe_ptr) 217 217 { 218 - int ret = security_locked_down(LOCKDOWN_BPF_READ); 218 + int ret; 219 219 220 - if (unlikely(ret < 0)) 221 - goto fail; 222 220 ret = copy_from_kernel_nofault(dst, unsafe_ptr, size); 223 221 if (unlikely(ret < 0)) 224 - goto fail; 225 - return ret; 226 - fail: 227 - memset(dst, 0, size); 222 + memset(dst, 0, size); 228 223 return ret; 229 224 } 230 225 ··· 241 246 static __always_inline int 242 247 bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr) 243 248 { 244 - int ret = security_locked_down(LOCKDOWN_BPF_READ); 245 - 246 - if (unlikely(ret < 0)) 247 - goto fail; 249 + int ret; 248 250 249 251 /* 250 252 * The strncpy_from_kernel_nofault() call will likely not fill the ··· 254 262 */ 255 263 ret = strncpy_from_kernel_nofault(dst, unsafe_ptr, size); 256 264 if (unlikely(ret < 0)) 257 - goto fail; 258 - 259 - return ret; 260 - fail: 261 - memset(dst, 0, size); 265 + memset(dst, 0, size); 262 266 return ret; 263 267 } 264 268 ··· 999 1011 case BPF_FUNC_probe_read_user: 1000 1012 return &bpf_probe_read_user_proto; 1001 1013 case BPF_FUNC_probe_read_kernel: 1002 - return &bpf_probe_read_kernel_proto; 1014 + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? 1015 + NULL : &bpf_probe_read_kernel_proto; 1003 1016 case BPF_FUNC_probe_read_user_str: 1004 1017 return &bpf_probe_read_user_str_proto; 1005 1018 case BPF_FUNC_probe_read_kernel_str: 1006 - return &bpf_probe_read_kernel_str_proto; 1019 + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? 1020 + NULL : &bpf_probe_read_kernel_str_proto; 1007 1021 #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE 1008 1022 case BPF_FUNC_probe_read: 1009 - return &bpf_probe_read_compat_proto; 1023 + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? 1024 + NULL : &bpf_probe_read_compat_proto; 1010 1025 case BPF_FUNC_probe_read_str: 1011 - return &bpf_probe_read_compat_str_proto; 1026 + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? 1027 + NULL : &bpf_probe_read_compat_str_proto; 1012 1028 #endif 1013 1029 #ifdef CONFIG_CGROUPS 1014 1030 case BPF_FUNC_get_current_cgroup_id:
+6 -1
net/bluetooth/hci_core.c
··· 1610 1610 } else { 1611 1611 /* Init failed, cleanup */ 1612 1612 flush_work(&hdev->tx_work); 1613 - flush_work(&hdev->cmd_work); 1613 + 1614 + /* Since hci_rx_work() is possible to awake new cmd_work 1615 + * it should be flushed first to avoid unexpected call of 1616 + * hci_cmd_work() 1617 + */ 1614 1618 flush_work(&hdev->rx_work); 1619 + flush_work(&hdev->cmd_work); 1615 1620 1616 1621 skb_queue_purge(&hdev->cmd_q); 1617 1622 skb_queue_purge(&hdev->rx_q);
+2 -2
net/bluetooth/hci_sock.c
··· 762 762 /* Detach sockets from device */ 763 763 read_lock(&hci_sk_list.lock); 764 764 sk_for_each(sk, &hci_sk_list.head) { 765 - bh_lock_sock_nested(sk); 765 + lock_sock(sk); 766 766 if (hci_pi(sk)->hdev == hdev) { 767 767 hci_pi(sk)->hdev = NULL; 768 768 sk->sk_err = EPIPE; ··· 771 771 772 772 hci_dev_put(hdev); 773 773 } 774 - bh_unlock_sock(sk); 774 + release_sock(sk); 775 775 } 776 776 read_unlock(&hci_sk_list.lock); 777 777 }
+9 -4
net/caif/caif_dev.c
··· 308 308 caifd_put(caifd); 309 309 } 310 310 311 - void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, 311 + int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, 312 312 struct cflayer *link_support, int head_room, 313 313 struct cflayer **layer, 314 314 int (**rcv_func)(struct sk_buff *, struct net_device *, ··· 319 319 enum cfcnfg_phy_preference pref; 320 320 struct cfcnfg *cfg = get_cfcnfg(dev_net(dev)); 321 321 struct caif_device_entry_list *caifdevs; 322 + int res; 322 323 323 324 caifdevs = caif_device_list(dev_net(dev)); 324 325 caifd = caif_device_alloc(dev); 325 326 if (!caifd) 326 - return; 327 + return -ENOMEM; 327 328 *layer = &caifd->layer; 328 329 spin_lock_init(&caifd->flow_lock); 329 330 ··· 345 344 strlcpy(caifd->layer.name, dev->name, 346 345 sizeof(caifd->layer.name)); 347 346 caifd->layer.transmit = transmit; 348 - cfcnfg_add_phy_layer(cfg, 347 + res = cfcnfg_add_phy_layer(cfg, 349 348 dev, 350 349 &caifd->layer, 351 350 pref, ··· 355 354 mutex_unlock(&caifdevs->lock); 356 355 if (rcv_func) 357 356 *rcv_func = receive; 357 + return res; 358 358 } 359 359 EXPORT_SYMBOL(caif_enroll_dev); 360 360 ··· 370 368 struct cflayer *layer, *link_support; 371 369 int head_room = 0; 372 370 struct caif_device_entry_list *caifdevs; 371 + int res; 373 372 374 373 cfg = get_cfcnfg(dev_net(dev)); 375 374 caifdevs = caif_device_list(dev_net(dev)); ··· 396 393 break; 397 394 } 398 395 } 399 - caif_enroll_dev(dev, caifdev, link_support, head_room, 396 + res = caif_enroll_dev(dev, caifdev, link_support, head_room, 400 397 &layer, NULL); 398 + if (res) 399 + cfserl_release(link_support); 401 400 caifdev->flowctrl = dev_flowctrl; 402 401 break; 403 402
+13 -1
net/caif/caif_usb.c
··· 115 115 return (struct cflayer *) this; 116 116 } 117 117 118 + static void cfusbl_release(struct cflayer *layer) 119 + { 120 + kfree(layer); 121 + } 122 + 118 123 static struct packet_type caif_usb_type __read_mostly = { 119 124 .type = cpu_to_be16(ETH_P_802_EX1), 120 125 }; ··· 132 127 struct cflayer *layer, *link_support; 133 128 struct usbnet *usbnet; 134 129 struct usb_device *usbdev; 130 + int res; 135 131 136 132 /* Check whether we have a NCM device, and find its VID/PID. */ 137 133 if (!(dev->dev.parent && dev->dev.parent->driver && ··· 175 169 if (dev->num_tx_queues > 1) 176 170 pr_warn("USB device uses more than one tx queue\n"); 177 171 178 - caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN, 172 + res = caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN, 179 173 &layer, &caif_usb_type.func); 174 + if (res) 175 + goto err; 176 + 180 177 if (!pack_added) 181 178 dev_add_pack(&caif_usb_type); 182 179 pack_added = true; ··· 187 178 strlcpy(layer->name, dev->name, sizeof(layer->name)); 188 179 189 180 return 0; 181 + err: 182 + cfusbl_release(link_support); 183 + return res; 190 184 } 191 185 192 186 static struct notifier_block caif_device_notifier = {
+11 -5
net/caif/cfcnfg.c
··· 450 450 rcu_read_unlock(); 451 451 } 452 452 453 - void 453 + int 454 454 cfcnfg_add_phy_layer(struct cfcnfg *cnfg, 455 455 struct net_device *dev, struct cflayer *phy_layer, 456 456 enum cfcnfg_phy_preference pref, ··· 459 459 { 460 460 struct cflayer *frml; 461 461 struct cfcnfg_phyinfo *phyinfo = NULL; 462 - int i; 462 + int i, res = 0; 463 463 u8 phyid; 464 464 465 465 mutex_lock(&cnfg->lock); ··· 473 473 goto got_phyid; 474 474 } 475 475 pr_warn("Too many CAIF Link Layers (max 6)\n"); 476 + res = -EEXIST; 476 477 goto out; 477 478 478 479 got_phyid: 479 480 phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC); 480 - if (!phyinfo) 481 + if (!phyinfo) { 482 + res = -ENOMEM; 481 483 goto out_err; 484 + } 482 485 483 486 phy_layer->id = phyid; 484 487 phyinfo->pref = pref; ··· 495 492 496 493 frml = cffrml_create(phyid, fcs); 497 494 498 - if (!frml) 495 + if (!frml) { 496 + res = -ENOMEM; 499 497 goto out_err; 498 + } 500 499 phyinfo->frm_layer = frml; 501 500 layer_set_up(frml, cnfg->mux); 502 501 ··· 516 511 list_add_rcu(&phyinfo->node, &cnfg->phys); 517 512 out: 518 513 mutex_unlock(&cnfg->lock); 519 - return; 514 + return res; 520 515 521 516 out_err: 522 517 kfree(phyinfo); 523 518 mutex_unlock(&cnfg->lock); 519 + return res; 524 520 } 525 521 EXPORT_SYMBOL(cfcnfg_add_phy_layer); 526 522
+5
net/caif/cfserl.c
··· 31 31 static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, 32 32 int phyid); 33 33 34 + void cfserl_release(struct cflayer *layer) 35 + { 36 + kfree(layer); 37 + } 38 + 34 39 struct cflayer *cfserl_create(int instance, bool use_stx) 35 40 { 36 41 struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
+1 -1
net/compat.c
··· 177 177 if (kcmlen > stackbuf_size) 178 178 kcmsg_base = kcmsg = sock_kmalloc(sk, kcmlen, GFP_KERNEL); 179 179 if (kcmsg == NULL) 180 - return -ENOBUFS; 180 + return -ENOMEM; 181 181 182 182 /* Now copy them over neatly. */ 183 183 memset(kcmsg, 0, kcmlen);
+2 -2
net/core/devlink.c
··· 705 705 case DEVLINK_PORT_FLAVOUR_PHYSICAL: 706 706 case DEVLINK_PORT_FLAVOUR_CPU: 707 707 case DEVLINK_PORT_FLAVOUR_DSA: 708 - case DEVLINK_PORT_FLAVOUR_VIRTUAL: 709 708 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER, 710 709 attrs->phys.port_number)) 711 710 return -EMSGSIZE; ··· 8630 8631 8631 8632 switch (attrs->flavour) { 8632 8633 case DEVLINK_PORT_FLAVOUR_PHYSICAL: 8633 - case DEVLINK_PORT_FLAVOUR_VIRTUAL: 8634 8634 if (!attrs->split) 8635 8635 n = snprintf(name, len, "p%u", attrs->phys.port_number); 8636 8636 else ··· 8677 8679 n = snprintf(name, len, "pf%usf%u", attrs->pci_sf.pf, 8678 8680 attrs->pci_sf.sf); 8679 8681 break; 8682 + case DEVLINK_PORT_FLAVOUR_VIRTUAL: 8683 + return -EOPNOTSUPP; 8680 8684 } 8681 8685 8682 8686 if (n >= len)
+1 -1
net/core/fib_rules.c
··· 1168 1168 { 1169 1169 struct net *net; 1170 1170 struct sk_buff *skb; 1171 - int err = -ENOBUFS; 1171 + int err = -ENOMEM; 1172 1172 1173 1173 net = ops->fro_net; 1174 1174 skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
+3 -1
net/core/rtnetlink.c
··· 4842 4842 if (err < 0) 4843 4843 goto errout; 4844 4844 4845 - if (!skb->len) 4845 + if (!skb->len) { 4846 + err = -EINVAL; 4846 4847 goto errout; 4848 + } 4847 4849 4848 4850 rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); 4849 4851 return 0;
+12 -4
net/core/sock.c
··· 815 815 } 816 816 EXPORT_SYMBOL(sock_set_rcvbuf); 817 817 818 + static void __sock_set_mark(struct sock *sk, u32 val) 819 + { 820 + if (val != sk->sk_mark) { 821 + sk->sk_mark = val; 822 + sk_dst_reset(sk); 823 + } 824 + } 825 + 818 826 void sock_set_mark(struct sock *sk, u32 val) 819 827 { 820 828 lock_sock(sk); 821 - sk->sk_mark = val; 829 + __sock_set_mark(sk, val); 822 830 release_sock(sk); 823 831 } 824 832 EXPORT_SYMBOL(sock_set_mark); ··· 1134 1126 case SO_MARK: 1135 1127 if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { 1136 1128 ret = -EPERM; 1137 - } else if (val != sk->sk_mark) { 1138 - sk->sk_mark = val; 1139 - sk_dst_reset(sk); 1129 + break; 1140 1130 } 1131 + 1132 + __sock_set_mark(sk, val); 1141 1133 break; 1142 1134 1143 1135 case SO_RXQ_OVFL:
+1 -1
net/dsa/tag_8021q.c
··· 64 64 #define DSA_8021Q_SUBVLAN_HI_SHIFT 9 65 65 #define DSA_8021Q_SUBVLAN_HI_MASK GENMASK(9, 9) 66 66 #define DSA_8021Q_SUBVLAN_LO_SHIFT 4 67 - #define DSA_8021Q_SUBVLAN_LO_MASK GENMASK(4, 3) 67 + #define DSA_8021Q_SUBVLAN_LO_MASK GENMASK(5, 4) 68 68 #define DSA_8021Q_SUBVLAN_HI(x) (((x) & GENMASK(2, 2)) >> 2) 69 69 #define DSA_8021Q_SUBVLAN_LO(x) ((x) & GENMASK(1, 0)) 70 70 #define DSA_8021Q_SUBVLAN(x) \
+6 -4
net/ieee802154/nl-mac.c
··· 680 680 nla_put_u8(msg, IEEE802154_ATTR_LLSEC_SECLEVEL, params.out_level) || 681 681 nla_put_u32(msg, IEEE802154_ATTR_LLSEC_FRAME_COUNTER, 682 682 be32_to_cpu(params.frame_counter)) || 683 - ieee802154_llsec_fill_key_id(msg, &params.out_key)) 683 + ieee802154_llsec_fill_key_id(msg, &params.out_key)) { 684 + rc = -ENOBUFS; 684 685 goto out_free; 686 + } 685 687 686 688 dev_put(dev); 687 689 ··· 1186 1184 { 1187 1185 struct ieee802154_llsec_device *dpos; 1188 1186 struct ieee802154_llsec_device_key *kpos; 1189 - int rc = 0, idx = 0, idx2; 1187 + int idx = 0, idx2; 1190 1188 1191 1189 list_for_each_entry(dpos, &data->table->devices, list) { 1192 1190 if (idx++ < data->s_idx) ··· 1202 1200 data->nlmsg_seq, 1203 1201 dpos->hwaddr, kpos, 1204 1202 data->dev)) { 1205 - return rc = -EMSGSIZE; 1203 + return -EMSGSIZE; 1206 1204 } 1207 1205 1208 1206 data->s_idx2++; ··· 1211 1209 data->s_idx++; 1212 1210 } 1213 1211 1214 - return rc; 1212 + return 0; 1215 1213 } 1216 1214 1217 1215 int ieee802154_llsec_dump_devkeys(struct sk_buff *skb,
+3 -1
net/ieee802154/nl-phy.c
··· 241 241 } 242 242 243 243 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || 244 - nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) 244 + nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) { 245 + rc = -EMSGSIZE; 245 246 goto nla_put_failure; 247 + } 246 248 dev_put(dev); 247 249 248 250 wpan_phy_put(phy);
+5 -4
net/ieee802154/nl802154.c
··· 1298 1298 if (!nla || nla_parse_nested_deprecated(attrs, NL802154_DEV_ADDR_ATTR_MAX, nla, nl802154_dev_addr_policy, NULL)) 1299 1299 return -EINVAL; 1300 1300 1301 - if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || 1302 - !attrs[NL802154_DEV_ADDR_ATTR_MODE] || 1303 - !(attrs[NL802154_DEV_ADDR_ATTR_SHORT] || 1304 - attrs[NL802154_DEV_ADDR_ATTR_EXTENDED])) 1301 + if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || !attrs[NL802154_DEV_ADDR_ATTR_MODE]) 1305 1302 return -EINVAL; 1306 1303 1307 1304 addr->pan_id = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_PAN_ID]); 1308 1305 addr->mode = nla_get_u32(attrs[NL802154_DEV_ADDR_ATTR_MODE]); 1309 1306 switch (addr->mode) { 1310 1307 case NL802154_DEV_ADDR_SHORT: 1308 + if (!attrs[NL802154_DEV_ADDR_ATTR_SHORT]) 1309 + return -EINVAL; 1311 1310 addr->short_addr = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_SHORT]); 1312 1311 break; 1313 1312 case NL802154_DEV_ADDR_EXTENDED: 1313 + if (!attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]) 1314 + return -EINVAL; 1314 1315 addr->extended_addr = nla_get_le64(attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]); 1315 1316 break; 1316 1317 default:
+8 -5
net/ipv4/ipconfig.c
··· 886 886 887 887 888 888 /* 889 - * Copy BOOTP-supplied string if not already set. 889 + * Copy BOOTP-supplied string 890 890 */ 891 891 static int __init ic_bootp_string(char *dest, char *src, int len, int max) 892 892 { ··· 935 935 } 936 936 break; 937 937 case 12: /* Host name */ 938 - ic_bootp_string(utsname()->nodename, ext+1, *ext, 939 - __NEW_UTS_LEN); 940 - ic_host_name_set = 1; 938 + if (!ic_host_name_set) { 939 + ic_bootp_string(utsname()->nodename, ext+1, *ext, 940 + __NEW_UTS_LEN); 941 + ic_host_name_set = 1; 942 + } 941 943 break; 942 944 case 15: /* Domain name (DNS) */ 943 - ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); 945 + if (!ic_domain[0]) 946 + ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); 944 947 break; 945 948 case 17: /* Root path */ 946 949 if (!root_server_path[0])
+6 -2
net/ipv6/route.c
··· 3673 3673 if (nh) { 3674 3674 if (rt->fib6_src.plen) { 3675 3675 NL_SET_ERR_MSG(extack, "Nexthops can not be used with source routing"); 3676 - goto out; 3676 + goto out_free; 3677 3677 } 3678 3678 if (!nexthop_get(nh)) { 3679 3679 NL_SET_ERR_MSG(extack, "Nexthop has been deleted"); 3680 - goto out; 3680 + goto out_free; 3681 3681 } 3682 3682 rt->nh = nh; 3683 3683 fib6_nh = nexthop_fib6_nh(rt->nh); ··· 3713 3713 return rt; 3714 3714 out: 3715 3715 fib6_info_release(rt); 3716 + return ERR_PTR(err); 3717 + out_free: 3718 + ip_fib_metrics_put(rt->fib6_metrics); 3719 + kfree(rt); 3716 3720 return ERR_PTR(err); 3717 3721 } 3718 3722
+3
net/ipv6/sit.c
··· 271 271 if (ipip6_tunnel_create(dev) < 0) 272 272 goto failed_free; 273 273 274 + if (!parms->name[0]) 275 + strcpy(parms->name, dev->name); 276 + 274 277 return nt; 275 278 276 279 failed_free:
+5
net/kcm/kcmsock.c
··· 1066 1066 goto partial_message; 1067 1067 } 1068 1068 1069 + if (skb_has_frag_list(head)) { 1070 + kfree_skb_list(skb_shinfo(head)->frag_list); 1071 + skb_shinfo(head)->frag_list = NULL; 1072 + } 1073 + 1069 1074 if (head != kcm->seq_skb) 1070 1075 kfree_skb(head); 1071 1076
+15 -1
net/mptcp/protocol.c
··· 947 947 { 948 948 struct mptcp_sock *msk = mptcp_sk(sk); 949 949 950 + #ifdef CONFIG_LOCKDEP 951 + WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock)); 952 + #endif 953 + 950 954 if (!msk->wmem_reserved) 951 955 return; 952 956 ··· 1089 1085 1090 1086 static void __mptcp_clean_una_wakeup(struct sock *sk) 1091 1087 { 1088 + #ifdef CONFIG_LOCKDEP 1089 + WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock)); 1090 + #endif 1092 1091 __mptcp_clean_una(sk); 1093 1092 mptcp_write_space(sk); 1093 + } 1094 + 1095 + static void mptcp_clean_una_wakeup(struct sock *sk) 1096 + { 1097 + mptcp_data_lock(sk); 1098 + __mptcp_clean_una_wakeup(sk); 1099 + mptcp_data_unlock(sk); 1094 1100 } 1095 1101 1096 1102 static void mptcp_enter_memory_pressure(struct sock *sk) ··· 2313 2299 struct sock *ssk; 2314 2300 int ret; 2315 2301 2316 - __mptcp_clean_una_wakeup(sk); 2302 + mptcp_clean_una_wakeup(sk); 2317 2303 dfrag = mptcp_rtx_head(sk); 2318 2304 if (!dfrag) { 2319 2305 if (mptcp_data_fin_enabled(msk)) {
+40 -39
net/mptcp/subflow.c
··· 630 630 631 631 /* if the sk is MP_CAPABLE, we try to fetch the client key */ 632 632 if (subflow_req->mp_capable) { 633 - if (TCP_SKB_CB(skb)->seq != subflow_req->ssn_offset + 1) { 634 - /* here we can receive and accept an in-window, 635 - * out-of-order pkt, which will not carry the MP_CAPABLE 636 - * opt even on mptcp enabled paths 637 - */ 638 - goto create_msk; 639 - } 640 - 633 + /* we can receive and accept an in-window, out-of-order pkt, 634 + * which may not carry the MP_CAPABLE opt even on mptcp enabled 635 + * paths: always try to extract the peer key, and fallback 636 + * for packets missing it. 637 + * Even OoO DSS packets coming legitly after dropped or 638 + * reordered MPC will cause fallback, but we don't have other 639 + * options. 640 + */ 641 641 mptcp_get_options(skb, &mp_opt); 642 642 if (!mp_opt.mp_capable) { 643 643 fallback = true; 644 644 goto create_child; 645 645 } 646 646 647 - create_msk: 648 647 new_msk = mptcp_sk_clone(listener->conn, &mp_opt, req); 649 648 if (!new_msk) 650 649 fallback = true; ··· 1011 1012 1012 1013 status = get_mapping_status(ssk, msk); 1013 1014 trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); 1014 - if (status == MAPPING_INVALID) { 1015 - ssk->sk_err = EBADMSG; 1016 - goto fatal; 1017 - } 1018 - if (status == MAPPING_DUMMY) { 1019 - __mptcp_do_fallback(msk); 1020 - skb = skb_peek(&ssk->sk_receive_queue); 1021 - subflow->map_valid = 1; 1022 - subflow->map_seq = READ_ONCE(msk->ack_seq); 1023 - subflow->map_data_len = skb->len; 1024 - subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - 1025 - subflow->ssn_offset; 1026 - subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; 1027 - return true; 1028 - } 1015 + if (unlikely(status == MAPPING_INVALID)) 1016 + goto fallback; 1017 + 1018 + if (unlikely(status == MAPPING_DUMMY)) 1019 + goto fallback; 1029 1020 1030 1021 if (status != MAPPING_OK) 1031 1022 goto no_data; ··· 1028 1039 * MP_CAPABLE-based mapping 1029 1040 */ 1030 1041 if (unlikely(!READ_ONCE(msk->can_ack))) { 1031 - if (!subflow->mpc_map) { 1032 - ssk->sk_err = EBADMSG; 1033 - goto fatal; 1034 - } 1042 + if (!subflow->mpc_map) 1043 + goto fallback; 1035 1044 WRITE_ONCE(msk->remote_key, subflow->remote_key); 1036 1045 WRITE_ONCE(msk->ack_seq, subflow->map_seq); 1037 1046 WRITE_ONCE(msk->can_ack, true); ··· 1057 1070 no_data: 1058 1071 subflow_sched_work_if_closed(msk, ssk); 1059 1072 return false; 1060 - fatal: 1061 - /* fatal protocol error, close the socket */ 1062 - /* This barrier is coupled with smp_rmb() in tcp_poll() */ 1063 - smp_wmb(); 1064 - ssk->sk_error_report(ssk); 1065 - tcp_set_state(ssk, TCP_CLOSE); 1066 - subflow->reset_transient = 0; 1067 - subflow->reset_reason = MPTCP_RST_EMPTCP; 1068 - tcp_send_active_reset(ssk, GFP_ATOMIC); 1069 - subflow->data_avail = 0; 1070 - return false; 1073 + 1074 + fallback: 1075 + /* RFC 8684 section 3.7. */ 1076 + if (subflow->mp_join || subflow->fully_established) { 1077 + /* fatal protocol error, close the socket. 1078 + * subflow_error_report() will introduce the appropriate barriers 1079 + */ 1080 + ssk->sk_err = EBADMSG; 1081 + ssk->sk_error_report(ssk); 1082 + tcp_set_state(ssk, TCP_CLOSE); 1083 + subflow->reset_transient = 0; 1084 + subflow->reset_reason = MPTCP_RST_EMPTCP; 1085 + tcp_send_active_reset(ssk, GFP_ATOMIC); 1086 + subflow->data_avail = 0; 1087 + return false; 1088 + } 1089 + 1090 + __mptcp_do_fallback(msk); 1091 + skb = skb_peek(&ssk->sk_receive_queue); 1092 + subflow->map_valid = 1; 1093 + subflow->map_seq = READ_ONCE(msk->ack_seq); 1094 + subflow->map_data_len = skb->len; 1095 + subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; 1096 + subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; 1097 + return true; 1071 1098 } 1072 1099 1073 1100 bool mptcp_subflow_data_available(struct sock *sk)
+1 -1
net/netfilter/ipvs/ip_vs_ctl.c
··· 1367 1367 ip_vs_addr_copy(svc->af, &svc->addr, &u->addr); 1368 1368 svc->port = u->port; 1369 1369 svc->fwmark = u->fwmark; 1370 - svc->flags = u->flags; 1370 + svc->flags = u->flags & ~IP_VS_SVC_F_HASHED; 1371 1371 svc->timeout = u->timeout * HZ; 1372 1372 svc->netmask = u->netmask; 1373 1373 svc->ipvs = ipvs;
+1 -1
net/netfilter/nf_conntrack_proto.c
··· 664 664 665 665 #if IS_ENABLED(CONFIG_IPV6) 666 666 cleanup_sockopt: 667 - nf_unregister_sockopt(&so_getorigdst6); 667 + nf_unregister_sockopt(&so_getorigdst); 668 668 #endif 669 669 return ret; 670 670 }
+58 -28
net/netfilter/nf_tables_api.c
··· 736 736 goto nla_put_failure; 737 737 738 738 if (nla_put_string(skb, NFTA_TABLE_NAME, table->name) || 739 - nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags)) || 739 + nla_put_be32(skb, NFTA_TABLE_FLAGS, 740 + htonl(table->flags & NFT_TABLE_F_MASK)) || 740 741 nla_put_be32(skb, NFTA_TABLE_USE, htonl(table->use)) || 741 742 nla_put_be64(skb, NFTA_TABLE_HANDLE, cpu_to_be64(table->handle), 742 743 NFTA_TABLE_PAD)) ··· 948 947 949 948 static void nf_tables_table_disable(struct net *net, struct nft_table *table) 950 949 { 950 + table->flags &= ~NFT_TABLE_F_DORMANT; 951 951 nft_table_disable(net, table, 0); 952 + table->flags |= NFT_TABLE_F_DORMANT; 952 953 } 953 954 954 - enum { 955 - NFT_TABLE_STATE_UNCHANGED = 0, 956 - NFT_TABLE_STATE_DORMANT, 957 - NFT_TABLE_STATE_WAKEUP 958 - }; 955 + #define __NFT_TABLE_F_INTERNAL (NFT_TABLE_F_MASK + 1) 956 + #define __NFT_TABLE_F_WAS_DORMANT (__NFT_TABLE_F_INTERNAL << 0) 957 + #define __NFT_TABLE_F_WAS_AWAKEN (__NFT_TABLE_F_INTERNAL << 1) 958 + #define __NFT_TABLE_F_UPDATE (__NFT_TABLE_F_WAS_DORMANT | \ 959 + __NFT_TABLE_F_WAS_AWAKEN) 959 960 960 961 static int nf_tables_updtable(struct nft_ctx *ctx) 961 962 { 962 963 struct nft_trans *trans; 963 964 u32 flags; 964 - int ret = 0; 965 + int ret; 965 966 966 967 if (!ctx->nla[NFTA_TABLE_FLAGS]) 967 968 return 0; ··· 988 985 989 986 if ((flags & NFT_TABLE_F_DORMANT) && 990 987 !(ctx->table->flags & NFT_TABLE_F_DORMANT)) { 991 - nft_trans_table_state(trans) = NFT_TABLE_STATE_DORMANT; 988 + ctx->table->flags |= NFT_TABLE_F_DORMANT; 989 + if (!(ctx->table->flags & __NFT_TABLE_F_UPDATE)) 990 + ctx->table->flags |= __NFT_TABLE_F_WAS_AWAKEN; 992 991 } else if (!(flags & NFT_TABLE_F_DORMANT) && 993 992 ctx->table->flags & NFT_TABLE_F_DORMANT) { 994 - ret = nf_tables_table_enable(ctx->net, ctx->table); 995 - if (ret >= 0) 996 - nft_trans_table_state(trans) = NFT_TABLE_STATE_WAKEUP; 997 - } 998 - if (ret < 0) 999 - goto err; 993 + ctx->table->flags &= ~NFT_TABLE_F_DORMANT; 994 + if (!(ctx->table->flags & __NFT_TABLE_F_UPDATE)) { 995 + ret = nf_tables_table_enable(ctx->net, ctx->table); 996 + if (ret < 0) 997 + goto err_register_hooks; 1000 998 1001 - nft_trans_table_flags(trans) = flags; 999 + ctx->table->flags |= __NFT_TABLE_F_WAS_DORMANT; 1000 + } 1001 + } 1002 + 1002 1003 nft_trans_table_update(trans) = true; 1003 1004 nft_trans_commit_list_add_tail(ctx->net, trans); 1005 + 1004 1006 return 0; 1005 - err: 1007 + 1008 + err_register_hooks: 1006 1009 nft_trans_destroy(trans); 1007 1010 return ret; 1008 1011 } ··· 1914 1905 static int nft_chain_parse_hook(struct net *net, 1915 1906 const struct nlattr * const nla[], 1916 1907 struct nft_chain_hook *hook, u8 family, 1917 - bool autoload) 1908 + struct netlink_ext_ack *extack, bool autoload) 1918 1909 { 1919 1910 struct nftables_pernet *nft_net = nft_pernet(net); 1920 1911 struct nlattr *ha[NFTA_HOOK_MAX + 1]; ··· 1944 1935 if (nla[NFTA_CHAIN_TYPE]) { 1945 1936 type = nf_tables_chain_type_lookup(net, nla[NFTA_CHAIN_TYPE], 1946 1937 family, autoload); 1947 - if (IS_ERR(type)) 1938 + if (IS_ERR(type)) { 1939 + NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_TYPE]); 1948 1940 return PTR_ERR(type); 1941 + } 1949 1942 } 1950 1943 if (hook->num >= NFT_MAX_HOOKS || !(type->hook_mask & (1 << hook->num))) 1951 1944 return -EOPNOTSUPP; ··· 1956 1945 hook->priority <= NF_IP_PRI_CONNTRACK) 1957 1946 return -EOPNOTSUPP; 1958 1947 1959 - if (!try_module_get(type->owner)) 1948 + if (!try_module_get(type->owner)) { 1949 + if (nla[NFTA_CHAIN_TYPE]) 1950 + NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_TYPE]); 1960 1951 return -ENOENT; 1952 + } 1961 1953 1962 1954 hook->type = type; 1963 1955 ··· 2071 2057 static u64 chain_id; 2072 2058 2073 2059 static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, 2074 - u8 policy, u32 flags) 2060 + u8 policy, u32 flags, 2061 + struct netlink_ext_ack *extack) 2075 2062 { 2076 2063 const struct nlattr * const *nla = ctx->nla; 2077 2064 struct nft_table *table = ctx->table; ··· 2094 2079 if (flags & NFT_CHAIN_BINDING) 2095 2080 return -EOPNOTSUPP; 2096 2081 2097 - err = nft_chain_parse_hook(net, nla, &hook, family, true); 2082 + err = nft_chain_parse_hook(net, nla, &hook, family, extack, 2083 + true); 2098 2084 if (err < 0) 2099 2085 return err; 2100 2086 ··· 2250 2234 return -EEXIST; 2251 2235 } 2252 2236 err = nft_chain_parse_hook(ctx->net, nla, &hook, ctx->family, 2253 - false); 2237 + extack, false); 2254 2238 if (err < 0) 2255 2239 return err; 2256 2240 ··· 2463 2447 extack); 2464 2448 } 2465 2449 2466 - return nf_tables_addchain(&ctx, family, genmask, policy, flags); 2450 + return nf_tables_addchain(&ctx, family, genmask, policy, flags, extack); 2467 2451 } 2468 2452 2469 2453 static int nf_tables_delchain(struct sk_buff *skb, const struct nfnl_info *info, ··· 3344 3328 if (n == NFT_RULE_MAXEXPRS) 3345 3329 goto err1; 3346 3330 err = nf_tables_expr_parse(&ctx, tmp, &expr_info[n]); 3347 - if (err < 0) 3331 + if (err < 0) { 3332 + NL_SET_BAD_ATTR(extack, tmp); 3348 3333 goto err1; 3334 + } 3349 3335 size += expr_info[n].ops->size; 3350 3336 n++; 3351 3337 } ··· 8565 8547 switch (trans->msg_type) { 8566 8548 case NFT_MSG_NEWTABLE: 8567 8549 if (nft_trans_table_update(trans)) { 8568 - if (nft_trans_table_state(trans) == NFT_TABLE_STATE_DORMANT) 8550 + if (!(trans->ctx.table->flags & __NFT_TABLE_F_UPDATE)) { 8551 + nft_trans_destroy(trans); 8552 + break; 8553 + } 8554 + if (trans->ctx.table->flags & NFT_TABLE_F_DORMANT) 8569 8555 nf_tables_table_disable(net, trans->ctx.table); 8570 8556 8571 - trans->ctx.table->flags = nft_trans_table_flags(trans); 8557 + trans->ctx.table->flags &= ~__NFT_TABLE_F_UPDATE; 8572 8558 } else { 8573 8559 nft_clear(net, trans->ctx.table); 8574 8560 } ··· 8790 8768 switch (trans->msg_type) { 8791 8769 case NFT_MSG_NEWTABLE: 8792 8770 if (nft_trans_table_update(trans)) { 8793 - if (nft_trans_table_state(trans) == NFT_TABLE_STATE_WAKEUP) 8771 + if (!(trans->ctx.table->flags & __NFT_TABLE_F_UPDATE)) { 8772 + nft_trans_destroy(trans); 8773 + break; 8774 + } 8775 + if (trans->ctx.table->flags & __NFT_TABLE_F_WAS_DORMANT) { 8794 8776 nf_tables_table_disable(net, trans->ctx.table); 8795 - 8777 + trans->ctx.table->flags |= NFT_TABLE_F_DORMANT; 8778 + } else if (trans->ctx.table->flags & __NFT_TABLE_F_WAS_AWAKEN) { 8779 + trans->ctx.table->flags &= ~NFT_TABLE_F_DORMANT; 8780 + } 8781 + trans->ctx.table->flags &= ~__NFT_TABLE_F_UPDATE; 8796 8782 nft_trans_destroy(trans); 8797 8783 } else { 8798 8784 list_del_rcu(&trans->ctx.table->list);
+1 -1
net/netfilter/nft_ct.c
··· 1217 1217 struct nf_conn *ct; 1218 1218 1219 1219 ct = nf_ct_get(pkt->skb, &ctinfo); 1220 - if (!ct || ctinfo == IP_CT_UNTRACKED) { 1220 + if (!ct || nf_ct_is_confirmed(ct) || nf_ct_is_template(ct)) { 1221 1221 regs->verdict.code = NFT_BREAK; 1222 1222 return; 1223 1223 }
+2
net/nfc/llcp_sock.c
··· 110 110 if (!llcp_sock->service_name) { 111 111 nfc_llcp_local_put(llcp_sock->local); 112 112 llcp_sock->local = NULL; 113 + llcp_sock->dev = NULL; 113 114 ret = -ENOMEM; 114 115 goto put_dev; 115 116 } ··· 120 119 llcp_sock->local = NULL; 121 120 kfree(llcp_sock->service_name); 122 121 llcp_sock->service_name = NULL; 122 + llcp_sock->dev = NULL; 123 123 ret = -EADDRINUSE; 124 124 goto put_dev; 125 125 }
+4 -6
net/sched/act_ct.c
··· 984 984 */ 985 985 cached = tcf_ct_skb_nfct_cached(net, skb, p->zone, force); 986 986 if (!cached) { 987 - if (!commit && tcf_ct_flow_table_lookup(p, skb, family)) { 987 + if (tcf_ct_flow_table_lookup(p, skb, family)) { 988 988 skip_add = true; 989 989 goto do_nat; 990 990 } ··· 1022 1022 * even if the connection is already confirmed. 1023 1023 */ 1024 1024 nf_conntrack_confirm(skb); 1025 - } else if (!skip_add) { 1026 - tcf_ct_flow_table_process_conn(p->ct_ft, ct, ctinfo); 1027 1025 } 1026 + 1027 + if (!skip_add) 1028 + tcf_ct_flow_table_process_conn(p->ct_ft, ct, ctinfo); 1028 1029 1029 1030 out_push: 1030 1031 skb_push_rcsum(skb, nh_ofs); ··· 1202 1201 NULL, TCA_CT_UNSPEC, 1203 1202 sizeof(p->zone)); 1204 1203 } 1205 - 1206 - if (p->zone == NF_CT_DEFAULT_ZONE_ID) 1207 - return 0; 1208 1204 1209 1205 nf_ct_zone_init(&zone, p->zone, NF_CT_DEFAULT_ZONE_DIR, 0); 1210 1206 tmpl = nf_ct_tmpl_alloc(net, &zone, GFP_KERNEL);
+4 -4
net/sched/sch_htb.c
··· 1488 1488 struct Qdisc *old_q; 1489 1489 1490 1490 /* One ref for cl->leaf.q, the other for dev_queue->qdisc. */ 1491 - qdisc_refcount_inc(new_q); 1491 + if (new_q) 1492 + qdisc_refcount_inc(new_q); 1492 1493 old_q = htb_graft_helper(dev_queue, new_q); 1493 1494 WARN_ON(!(old_q->flags & TCQ_F_BUILTIN)); 1494 1495 } ··· 1676 1675 cl->parent->common.classid, 1677 1676 NULL); 1678 1677 if (q->offload) { 1679 - if (new_q) { 1678 + if (new_q) 1680 1679 htb_set_lockdep_class_child(new_q); 1681 - htb_parent_to_leaf_offload(sch, dev_queue, new_q); 1682 - } 1680 + htb_parent_to_leaf_offload(sch, dev_queue, new_q); 1683 1681 } 1684 1682 } 1685 1683
+50 -12
net/tls/tls_device.c
··· 50 50 static DECLARE_WORK(tls_device_gc_work, tls_device_gc_task); 51 51 static LIST_HEAD(tls_device_gc_list); 52 52 static LIST_HEAD(tls_device_list); 53 + static LIST_HEAD(tls_device_down_list); 53 54 static DEFINE_SPINLOCK(tls_device_lock); 54 55 55 56 static void tls_device_free_ctx(struct tls_context *ctx) ··· 681 680 struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx); 682 681 struct net_device *netdev; 683 682 684 - if (WARN_ON(test_and_set_bit(TLS_RX_SYNC_RUNNING, &tls_ctx->flags))) 685 - return; 686 - 687 683 trace_tls_device_rx_resync_send(sk, seq, rcd_sn, rx_ctx->resync_type); 684 + rcu_read_lock(); 688 685 netdev = READ_ONCE(tls_ctx->netdev); 689 686 if (netdev) 690 687 netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, rcd_sn, 691 688 TLS_OFFLOAD_CTX_DIR_RX); 692 - clear_bit_unlock(TLS_RX_SYNC_RUNNING, &tls_ctx->flags); 689 + rcu_read_unlock(); 693 690 TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXDEVICERESYNC); 694 691 } 695 692 ··· 759 760 u32 req_seq; 760 761 761 762 if (tls_ctx->rx_conf != TLS_HW) 763 + return; 764 + if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) 762 765 return; 763 766 764 767 prot = &tls_ctx->prot_info; ··· 963 962 is_encrypted, is_decrypted); 964 963 965 964 ctx->sw.decrypted |= is_decrypted; 965 + 966 + if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) { 967 + if (likely(is_encrypted || is_decrypted)) 968 + return 0; 969 + 970 + /* After tls_device_down disables the offload, the next SKB will 971 + * likely have initial fragments decrypted, and final ones not 972 + * decrypted. We need to reencrypt that single SKB. 973 + */ 974 + return tls_device_reencrypt(sk, skb); 975 + } 966 976 967 977 /* Return immediately if the record is either entirely plaintext or 968 978 * entirely ciphertext. Otherwise handle reencrypt partially decrypted ··· 1304 1292 spin_unlock_irqrestore(&tls_device_lock, flags); 1305 1293 1306 1294 list_for_each_entry_safe(ctx, tmp, &list, list) { 1295 + /* Stop offloaded TX and switch to the fallback. 1296 + * tls_is_sk_tx_device_offloaded will return false. 1297 + */ 1298 + WRITE_ONCE(ctx->sk->sk_validate_xmit_skb, tls_validate_xmit_skb_sw); 1299 + 1300 + /* Stop the RX and TX resync. 1301 + * tls_dev_resync must not be called after tls_dev_del. 1302 + */ 1303 + WRITE_ONCE(ctx->netdev, NULL); 1304 + 1305 + /* Start skipping the RX resync logic completely. */ 1306 + set_bit(TLS_RX_DEV_DEGRADED, &ctx->flags); 1307 + 1308 + /* Sync with inflight packets. After this point: 1309 + * TX: no non-encrypted packets will be passed to the driver. 1310 + * RX: resync requests from the driver will be ignored. 1311 + */ 1312 + synchronize_net(); 1313 + 1314 + /* Release the offload context on the driver side. */ 1307 1315 if (ctx->tx_conf == TLS_HW) 1308 1316 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, 1309 1317 TLS_OFFLOAD_CTX_DIR_TX); ··· 1331 1299 !test_bit(TLS_RX_DEV_CLOSED, &ctx->flags)) 1332 1300 netdev->tlsdev_ops->tls_dev_del(netdev, ctx, 1333 1301 TLS_OFFLOAD_CTX_DIR_RX); 1334 - WRITE_ONCE(ctx->netdev, NULL); 1335 - smp_mb__before_atomic(); /* pairs with test_and_set_bit() */ 1336 - while (test_bit(TLS_RX_SYNC_RUNNING, &ctx->flags)) 1337 - usleep_range(10, 200); 1338 - dev_put(netdev); 1339 - list_del_init(&ctx->list); 1340 1302 1341 - if (refcount_dec_and_test(&ctx->refcount)) 1342 - tls_device_free_ctx(ctx); 1303 + dev_put(netdev); 1304 + 1305 + /* Move the context to a separate list for two reasons: 1306 + * 1. When the context is deallocated, list_del is called. 1307 + * 2. It's no longer an offloaded context, so we don't want to 1308 + * run offload-specific code on this context. 1309 + */ 1310 + spin_lock_irqsave(&tls_device_lock, flags); 1311 + list_move_tail(&ctx->list, &tls_device_down_list); 1312 + spin_unlock_irqrestore(&tls_device_lock, flags); 1313 + 1314 + /* Device contexts for RX and TX will be freed in on sk_destruct 1315 + * by tls_device_free_ctx. rx_conf and tx_conf stay in TLS_HW. 1316 + */ 1343 1317 } 1344 1318 1345 1319 up_write(&device_offload_lock);
+7
net/tls/tls_device_fallback.c
··· 431 431 } 432 432 EXPORT_SYMBOL_GPL(tls_validate_xmit_skb); 433 433 434 + struct sk_buff *tls_validate_xmit_skb_sw(struct sock *sk, 435 + struct net_device *dev, 436 + struct sk_buff *skb) 437 + { 438 + return tls_sw_fallback(sk, skb); 439 + } 440 + 434 441 struct sk_buff *tls_encrypt_skb(struct sk_buff *skb) 435 442 { 436 443 return tls_sw_fallback(skb->sk, skb);
+1
net/tls/tls_main.c
··· 636 636 mutex_init(&ctx->tx_lock); 637 637 rcu_assign_pointer(icsk->icsk_ulp_data, ctx); 638 638 ctx->sk_proto = READ_ONCE(sk->sk_prot); 639 + ctx->sk = sk; 639 640 return ctx; 640 641 } 641 642
+1 -1
net/x25/af_x25.c
··· 536 536 if (protocol) 537 537 goto out; 538 538 539 - rc = -ENOBUFS; 539 + rc = -ENOMEM; 540 540 if ((sk = x25_alloc_socket(net, kern)) == NULL) 541 541 goto out; 542 542
+1 -1
scripts/Makefile.modfinal
··· 59 59 quiet_cmd_btf_ko = BTF [M] $@ 60 60 cmd_btf_ko = \ 61 61 if [ -f vmlinux ]; then \ 62 - LLVM_OBJCOPY=$(OBJCOPY) $(PAHOLE) -J --btf_base vmlinux $@; \ 62 + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J --btf_base vmlinux $@; \ 63 63 else \ 64 64 printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \ 65 65 fi;
+9 -4
tools/testing/selftests/net/mptcp/mptcp_connect.sh
··· 501 501 local stat_ackrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX") 502 502 local stat_cookietx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent") 503 503 local stat_cookierx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv") 504 + local stat_ooo_now=$(get_mib_counter "${listener_ns}" "TcpExtTCPOFOQueue") 504 505 505 506 expect_synrx=$((stat_synrx_last_l)) 506 507 expect_ackrx=$((stat_ackrx_last_l)) ··· 519 518 "${stat_synrx_now_l}" "${expect_synrx}" 1>&2 520 519 retc=1 521 520 fi 522 - if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ]; then 523 - printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ 524 - "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 525 - rets=1 521 + if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} -a ${stat_ooo_now} -eq 0 ]; then 522 + if [ ${stat_ooo_now} -eq 0 ]; then 523 + printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ 524 + "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 525 + rets=1 526 + else 527 + printf "[ Note ] fallback due to TCP OoO" 528 + fi 526 529 fi 527 530 528 531 if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
+1
tools/testing/selftests/wireguard/netns.sh
··· 363 363 ip1 -4 route add default dev wg0 table 51820 364 364 ip1 -4 rule add not fwmark 51820 table 51820 365 365 ip1 -4 rule add table main suppress_prefixlength 0 366 + n1 bash -c 'printf 0 > /proc/sys/net/ipv4/conf/vethc/rp_filter' 366 367 # Flood the pings instead of sending just one, to trigger routing table reference counting bugs. 367 368 n1 ping -W 1 -c 100 -f 192.168.99.7 368 369 n1 ping -W 1 -c 100 -f abab::1111
-1
tools/testing/selftests/wireguard/qemu/kernel.config
··· 19 19 CONFIG_NETFILTER_XT_NAT=y 20 20 CONFIG_NETFILTER_XT_MATCH_LENGTH=y 21 21 CONFIG_NETFILTER_XT_MARK=y 22 - CONFIG_NF_CONNTRACK_IPV4=y 23 22 CONFIG_NF_NAT_IPV4=y 24 23 CONFIG_IP_NF_IPTABLES=y 25 24 CONFIG_IP_NF_FILTER=y