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 git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from David Miller:

1) Restore previous behavior of CAP_SYS_ADMIN wrt loading networking
BPF programs, from Maciej Żenczykowski.

2) Fix dropped broadcasts in mac80211 code, from Seevalamuthu
Mariappan.

3) Slay memory leak in nl80211 bss color attribute parsing code, from
Luca Coelho.

4) Get route from skb properly in ip_route_use_hint(), from Miaohe Lin.

5) Don't allow anything other than ARPHRD_ETHER in llc code, from Eric
Dumazet.

6) xsk code dips too deeply into DMA mapping implementation internals.
Add dma_need_sync and use it. From Christoph Hellwig

7) Enforce power-of-2 for BPF ringbuf sizes. From Andrii Nakryiko.

8) Check for disallowed attributes when loading flow dissector BPF
programs. From Lorenz Bauer.

9) Correct packet injection to L3 tunnel devices via AF_PACKET, from
Jason A. Donenfeld.

10) Don't advertise checksum offload on ipa devices that don't support
it. From Alex Elder.

11) Resolve several issues in TCP MD5 signature support. Missing memory
barriers, bogus options emitted when using syncookies, and failure
to allow md5 key changes in established states. All from Eric
Dumazet.

12) Fix interface leak in hsr code, from Taehee Yoo.

13) VF reset fixes in hns3 driver, from Huazhong Tan.

14) Make loopback work again with ipv6 anycast, from David Ahern.

15) Fix TX starvation under high load in fec driver, from Tobias
Waldekranz.

16) MLD2 payload lengths not checked properly in bridge multicast code,
from Linus Lüssing.

17) Packet scheduler code that wants to find the inner protocol
currently only works for one level of VLAN encapsulation. Allow
Q-in-Q situations to work properly here, from Toke
Høiland-Jørgensen.

18) Fix route leak in l2tp, from Xin Long.

19) Resolve conflict between the sk->sk_user_data usage of bpf reuseport
support and various protocols. From Martin KaFai Lau.

20) Fix socket cgroup v2 reference counting in some situations, from
Cong Wang.

21) Cure memory leak in mlx5 connection tracking offload support, from
Eli Britstein.

* git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (146 commits)
mlxsw: pci: Fix use-after-free in case of failed devlink reload
mlxsw: spectrum_router: Remove inappropriate usage of WARN_ON()
net: macb: fix call to pm_runtime in the suspend/resume functions
net: macb: fix macb_suspend() by removing call to netif_carrier_off()
net: macb: fix macb_get/set_wol() when moving to phylink
net: macb: mark device wake capable when "magic-packet" property present
net: macb: fix wakeup test in runtime suspend/resume routines
bnxt_en: fix NULL dereference in case SR-IOV configuration fails
libbpf: Fix libbpf hashmap on (I)LP32 architectures
net/mlx5e: CT: Fix memory leak in cleanup
net/mlx5e: Fix port buffers cell size value
net/mlx5e: Fix 50G per lane indication
net/mlx5e: Fix CPU mapping after function reload to avoid aRFS RX crash
net/mlx5e: Fix VXLAN configuration restore after function reload
net/mlx5e: Fix usage of rcu-protected pointer
net/mxl5e: Verify that rpriv is not NULL
net/mlx5: E-Switch, Fix vlan or qos setting in legacy mode
net/mlx5: Fix eeprom support for SFP module
cgroup: Fix sock_cgroup_data on big-endian.
selftests: bpf: Fix detach from sockmap tests
...

+1645 -933
+8
Documentation/core-api/dma-api.rst
··· 206 206 207 207 :: 208 208 209 + bool 210 + dma_need_sync(struct device *dev, dma_addr_t dma_addr); 211 + 212 + Returns %true if dma_sync_single_for_{device,cpu} calls are required to 213 + transfer memory ownership. Returns %false if those calls can be skipped. 214 + 215 + :: 216 + 209 217 unsigned long 210 218 dma_get_merge_boundary(struct device *dev); 211 219
+1 -1
Documentation/networking/arcnet.rst
··· 434 434 ifconfig arc0 insight 435 435 route add insight arc0 436 436 route add freedom arc0 /* I would use the subnet here (like I said 437 - to to in "single protocol" above), 437 + to in "single protocol" above), 438 438 but the rest of the subnet 439 439 unfortunately lies across the PPP 440 440 link on freedom, which confuses
+1 -1
Documentation/networking/ax25.rst
··· 6 6 7 7 To use the amateur radio protocols within Linux you will need to get a 8 8 suitable copy of the AX.25 Utilities. More detailed information about 9 - AX.25, NET/ROM and ROSE, associated programs and and utilities can be 9 + AX.25, NET/ROM and ROSE, associated programs and utilities can be 10 10 found on http://www.linux-ax25.org. 11 11 12 12 There is an active mailing list for discussing Linux amateur radio matters
+2 -2
Documentation/networking/can_ucan_protocol.rst
··· 144 144 145 145 *Host2Dev; mandatory* 146 146 147 - Setup bittiming by sending the the structure 147 + Setup bittiming by sending the structure 148 148 ``ucan_ctl_payload_t.cmd_set_bittiming`` (see ``struct bittiming`` for 149 149 details) 150 150 ··· 232 232 zero 233 233 234 234 The CAN device has sent a message to the CAN bus. It answers with a 235 - list of of tuples <echo-ids, flags>. 235 + list of tuples <echo-ids, flags>. 236 236 237 237 The echo-id identifies the frame from (echos the id from a previous 238 238 UCAN_OUT_TX message). The flag indicates the result of the
+1 -1
Documentation/networking/dsa/dsa.rst
··· 95 95 Networking stack hooks 96 96 ---------------------- 97 97 98 - When a master netdev is used with DSA, a small hook is placed in in the 98 + When a master netdev is used with DSA, a small hook is placed in the 99 99 networking stack is in order to have the DSA subsystem process the Ethernet 100 100 switch specific tagging protocol. DSA accomplishes this by registering a 101 101 specific (and fake) Ethernet type (later becoming ``skb->protocol``) with the
+1 -1
Documentation/networking/ip-sysctl.rst
··· 741 741 742 742 Default: 0x1 743 743 744 - Note that that additional client or server features are only 744 + Note that additional client or server features are only 745 745 effective if the basic support (0x1 and 0x2) are enabled respectively. 746 746 747 747 tcp_fastopen_blackhole_timeout_sec - INTEGER
+1 -1
Documentation/networking/ipvs-sysctl.rst
··· 114 114 modes (when there is no enough available memory, the strategy 115 115 is enabled and the variable is automatically set to 2, 116 116 otherwise the strategy is disabled and the variable is set to 117 - 1), and 3 means that that the strategy is always enabled. 117 + 1), and 3 means that the strategy is always enabled. 118 118 119 119 drop_packet - INTEGER 120 120 - 0 - disabled (default)
+1 -1
Documentation/networking/rxrpc.rst
··· 186 186 time [tunable] after the last connection using it discarded, in case a new 187 187 connection is made that could use it. 188 188 189 - (#) A client-side connection is only shared between calls if they have have 189 + (#) A client-side connection is only shared between calls if they have 190 190 the same key struct describing their security (and assuming the calls 191 191 would otherwise share the connection). Non-secured calls would also be 192 192 able to share connections with each other.
+1
MAINTAINERS
··· 2929 2929 2930 2930 ATMEL MACB ETHERNET DRIVER 2931 2931 M: Nicolas Ferre <nicolas.ferre@microchip.com> 2932 + M: Claudiu Beznea <claudiu.beznea@microchip.com> 2932 2933 S: Supported 2933 2934 F: drivers/net/ethernet/cadence/ 2934 2935
+3
drivers/net/dsa/microchip/ksz8795.c
··· 1268 1268 return -ENOMEM; 1269 1269 } 1270 1270 1271 + /* set the real number of ports */ 1272 + dev->ds->num_ports = dev->port_cnt; 1273 + 1271 1274 return 0; 1272 1275 } 1273 1276
+3
drivers/net/dsa/microchip/ksz9477.c
··· 1588 1588 return -ENOMEM; 1589 1589 } 1590 1590 1591 + /* set the real number of ports */ 1592 + dev->ds->num_ports = dev->port_cnt; 1593 + 1591 1594 return 0; 1592 1595 } 1593 1596
+1
drivers/net/dsa/microchip/ksz9477_i2c.c
··· 79 79 static const struct of_device_id ksz9477_dt_ids[] = { 80 80 { .compatible = "microchip,ksz9477" }, 81 81 { .compatible = "microchip,ksz9897" }, 82 + { .compatible = "microchip,ksz9893" }, 82 83 { .compatible = "microchip,ksz9567" }, 83 84 {}, 84 85 };
+2 -2
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c
··· 1700 1700 for (i = 0; i < 4; ++i) 1701 1701 aq_hw_write_reg(aq_hw, 1702 1702 HW_ATL_RPF_L3_SRCA_ADR(location + i), 1703 - ipv6_src[i]); 1703 + ipv6_src[3 - i]); 1704 1704 } 1705 1705 1706 1706 void hw_atl_rpfl3l4_ipv6_dest_addr_set(struct aq_hw_s *aq_hw, u8 location, ··· 1711 1711 for (i = 0; i < 4; ++i) 1712 1712 aq_hw_write_reg(aq_hw, 1713 1713 HW_ATL_RPF_L3_DSTA_ADR(location + i), 1714 - ipv6_dest[i]); 1714 + ipv6_dest[3 - i]); 1715 1715 } 1716 1716 1717 1717 u32 hw_atl_sem_ram_get(struct aq_hw_s *self)
+1 -1
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h
··· 1360 1360 */ 1361 1361 1362 1362 /* Register address for bitfield pif_rpf_l3_da0_i[31:0] */ 1363 - #define HW_ATL_RPF_L3_DSTA_ADR(filter) (0x000053B0 + (filter) * 0x4) 1363 + #define HW_ATL_RPF_L3_DSTA_ADR(filter) (0x000053D0 + (filter) * 0x4) 1364 1364 /* Bitmask for bitfield l3_da0[1F:0] */ 1365 1365 #define HW_ATL_RPF_L3_DSTA_MSK 0xFFFFFFFFu 1366 1366 /* Inverted bitmask for bitfield l3_da0[1F:0] */
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
··· 396 396 } 397 397 } 398 398 399 + bp->pf.active_vfs = 0; 399 400 kfree(bp->pf.vf); 400 401 bp->pf.vf = NULL; 401 402 } ··· 836 835 837 836 bnxt_free_vf_resources(bp); 838 837 839 - bp->pf.active_vfs = 0; 840 838 /* Reclaim all resources for the PF. */ 841 839 rtnl_lock(); 842 840 bnxt_restore_pf_fw_resources(bp);
+19 -12
drivers/net/ethernet/cadence/macb_main.c
··· 2821 2821 { 2822 2822 struct macb *bp = netdev_priv(netdev); 2823 2823 2824 - wol->supported = 0; 2825 - wol->wolopts = 0; 2826 - 2827 - if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) 2824 + if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) { 2828 2825 phylink_ethtool_get_wol(bp->phylink, wol); 2826 + wol->supported |= WAKE_MAGIC; 2827 + 2828 + if (bp->wol & MACB_WOL_ENABLED) 2829 + wol->wolopts |= WAKE_MAGIC; 2830 + } 2829 2831 } 2830 2832 2831 2833 static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) ··· 2835 2833 struct macb *bp = netdev_priv(netdev); 2836 2834 int ret; 2837 2835 2836 + /* Pass the order to phylink layer */ 2838 2837 ret = phylink_ethtool_set_wol(bp->phylink, wol); 2839 - if (!ret) 2840 - return 0; 2838 + /* Don't manage WoL on MAC if handled by the PHY 2839 + * or if there's a failure in talking to the PHY 2840 + */ 2841 + if (!ret || ret != -EOPNOTSUPP) 2842 + return ret; 2841 2843 2842 2844 if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) || 2843 2845 (wol->wolopts & ~WAKE_MAGIC)) ··· 4428 4422 bp->wol = 0; 4429 4423 if (of_get_property(np, "magic-packet", NULL)) 4430 4424 bp->wol |= MACB_WOL_HAS_MAGIC_PACKET; 4431 - device_init_wakeup(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET); 4425 + device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET); 4432 4426 4433 4427 spin_lock_init(&bp->lock); 4434 4428 ··· 4604 4598 bp->pm_data.scrt2 = gem_readl_n(bp, ETHT, SCRT2_ETHT); 4605 4599 } 4606 4600 4607 - netif_carrier_off(netdev); 4608 4601 if (bp->ptp_info) 4609 4602 bp->ptp_info->ptp_remove(netdev); 4610 - pm_runtime_force_suspend(dev); 4603 + if (!device_may_wakeup(dev)) 4604 + pm_runtime_force_suspend(dev); 4611 4605 4612 4606 return 0; 4613 4607 } ··· 4622 4616 if (!netif_running(netdev)) 4623 4617 return 0; 4624 4618 4625 - pm_runtime_force_resume(dev); 4619 + if (!device_may_wakeup(dev)) 4620 + pm_runtime_force_resume(dev); 4626 4621 4627 4622 if (bp->wol & MACB_WOL_ENABLED) { 4628 4623 macb_writel(bp, IDR, MACB_BIT(WOL)); ··· 4661 4654 struct net_device *netdev = dev_get_drvdata(dev); 4662 4655 struct macb *bp = netdev_priv(netdev); 4663 4656 4664 - if (!(device_may_wakeup(&bp->dev->dev))) { 4657 + if (!(device_may_wakeup(dev))) { 4665 4658 clk_disable_unprepare(bp->tx_clk); 4666 4659 clk_disable_unprepare(bp->hclk); 4667 4660 clk_disable_unprepare(bp->pclk); ··· 4677 4670 struct net_device *netdev = dev_get_drvdata(dev); 4678 4671 struct macb *bp = netdev_priv(netdev); 4679 4672 4680 - if (!(device_may_wakeup(&bp->dev->dev))) { 4673 + if (!(device_may_wakeup(dev))) { 4681 4674 clk_prepare_enable(bp->pclk); 4682 4675 clk_prepare_enable(bp->hclk); 4683 4676 clk_prepare_enable(bp->tx_clk);
+5 -5
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
··· 1112 1112 struct in_addr *addr; 1113 1113 1114 1114 addr = (struct in_addr *)ipmask; 1115 - if (ntohl(addr->s_addr) == 0xffffffff) 1115 + if (addr->s_addr == htonl(0xffffffff)) 1116 1116 return true; 1117 1117 } else if (family == AF_INET6) { 1118 1118 struct in6_addr *addr6; 1119 1119 1120 1120 addr6 = (struct in6_addr *)ipmask; 1121 - if (ntohl(addr6->s6_addr32[0]) == 0xffffffff && 1122 - ntohl(addr6->s6_addr32[1]) == 0xffffffff && 1123 - ntohl(addr6->s6_addr32[2]) == 0xffffffff && 1124 - ntohl(addr6->s6_addr32[3]) == 0xffffffff) 1121 + if (addr6->s6_addr32[0] == htonl(0xffffffff) && 1122 + addr6->s6_addr32[1] == htonl(0xffffffff) && 1123 + addr6->s6_addr32[2] == htonl(0xffffffff) && 1124 + addr6->s6_addr32[3] == htonl(0xffffffff)) 1125 1125 return true; 1126 1126 } 1127 1127 return false;
+4 -4
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 3493 3493 drv_fw = &fw_info->fw_hdr; 3494 3494 3495 3495 /* Read the header of the firmware on the card */ 3496 - ret = -t4_read_flash(adap, FLASH_FW_START, 3496 + ret = t4_read_flash(adap, FLASH_FW_START, 3497 3497 sizeof(*card_fw) / sizeof(uint32_t), 3498 3498 (uint32_t *)card_fw, 1); 3499 3499 if (ret == 0) { ··· 3522 3522 should_install_fs_fw(adap, card_fw_usable, 3523 3523 be32_to_cpu(fs_fw->fw_ver), 3524 3524 be32_to_cpu(card_fw->fw_ver))) { 3525 - ret = -t4_fw_upgrade(adap, adap->mbox, fw_data, 3526 - fw_size, 0); 3525 + ret = t4_fw_upgrade(adap, adap->mbox, fw_data, 3526 + fw_size, 0); 3527 3527 if (ret != 0) { 3528 3528 dev_err(adap->pdev_dev, 3529 3529 "failed to install firmware: %d\n", ret); ··· 3554 3554 FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c), 3555 3555 FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k), 3556 3556 FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k)); 3557 - ret = EINVAL; 3557 + ret = -EINVAL; 3558 3558 goto bye; 3559 3559 } 3560 3560
+2 -2
drivers/net/ethernet/freescale/enetc/enetc.c
··· 266 266 /* disable interrupts */ 267 267 enetc_wr_reg(v->rbier, 0); 268 268 269 - for_each_set_bit(i, &v->tx_rings_map, v->count_tx_rings) 269 + for_each_set_bit(i, &v->tx_rings_map, ENETC_MAX_NUM_TXQS) 270 270 enetc_wr_reg(v->tbier_base + ENETC_BDR_OFF(i), 0); 271 271 272 272 napi_schedule_irqoff(&v->napi); ··· 302 302 /* enable interrupts */ 303 303 enetc_wr_reg(v->rbier, ENETC_RBIER_RXTIE); 304 304 305 - for_each_set_bit(i, &v->tx_rings_map, v->count_tx_rings) 305 + for_each_set_bit(i, &v->tx_rings_map, ENETC_MAX_NUM_TXQS) 306 306 enetc_wr_reg(v->tbier_base + ENETC_BDR_OFF(i), 307 307 ENETC_TBIER_TXTIE); 308 308
-5
drivers/net/ethernet/freescale/fec.h
··· 525 525 unsigned int total_tx_ring_size; 526 526 unsigned int total_rx_ring_size; 527 527 528 - unsigned long work_tx; 529 - unsigned long work_rx; 530 - unsigned long work_ts; 531 - unsigned long work_mdio; 532 - 533 528 struct platform_device *pdev; 534 529 535 530 int dev_id;
+34 -66
drivers/net/ethernet/freescale/fec_main.c
··· 75 75 76 76 #define DRIVER_NAME "fec" 77 77 78 - #define FEC_ENET_GET_QUQUE(_x) ((_x == 0) ? 1 : ((_x == 1) ? 2 : 0)) 79 - 80 78 /* Pause frame feild and FIFO threshold */ 81 79 #define FEC_ENET_FCE (1 << 5) 82 80 #define FEC_ENET_RSEM_V 0x84 ··· 1246 1248 1247 1249 fep = netdev_priv(ndev); 1248 1250 1249 - queue_id = FEC_ENET_GET_QUQUE(queue_id); 1250 - 1251 1251 txq = fep->tx_queue[queue_id]; 1252 1252 /* get next bdp of dirty_tx */ 1253 1253 nq = netdev_get_tx_queue(ndev, queue_id); ··· 1336 1340 writel(0, txq->bd.reg_desc_active); 1337 1341 } 1338 1342 1339 - static void 1340 - fec_enet_tx(struct net_device *ndev) 1343 + static void fec_enet_tx(struct net_device *ndev) 1341 1344 { 1342 1345 struct fec_enet_private *fep = netdev_priv(ndev); 1343 - u16 queue_id; 1344 - /* First process class A queue, then Class B and Best Effort queue */ 1345 - for_each_set_bit(queue_id, &fep->work_tx, FEC_ENET_MAX_TX_QS) { 1346 - clear_bit(queue_id, &fep->work_tx); 1347 - fec_enet_tx_queue(ndev, queue_id); 1348 - } 1349 - return; 1346 + int i; 1347 + 1348 + /* Make sure that AVB queues are processed first. */ 1349 + for (i = fep->num_tx_queues - 1; i >= 0; i--) 1350 + fec_enet_tx_queue(ndev, i); 1350 1351 } 1351 1352 1352 1353 static int ··· 1419 1426 #ifdef CONFIG_M532x 1420 1427 flush_cache_all(); 1421 1428 #endif 1422 - queue_id = FEC_ENET_GET_QUQUE(queue_id); 1423 1429 rxq = fep->rx_queue[queue_id]; 1424 1430 1425 1431 /* First, grab all of the stats for the incoming packet. ··· 1542 1550 htons(ETH_P_8021Q), 1543 1551 vlan_tag); 1544 1552 1553 + skb_record_rx_queue(skb, queue_id); 1545 1554 napi_gro_receive(&fep->napi, skb); 1546 1555 1547 1556 if (is_copybreak) { ··· 1588 1595 return pkt_received; 1589 1596 } 1590 1597 1591 - static int 1592 - fec_enet_rx(struct net_device *ndev, int budget) 1598 + static int fec_enet_rx(struct net_device *ndev, int budget) 1593 1599 { 1594 - int pkt_received = 0; 1595 - u16 queue_id; 1596 1600 struct fec_enet_private *fep = netdev_priv(ndev); 1601 + int i, done = 0; 1597 1602 1598 - for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS) { 1599 - int ret; 1603 + /* Make sure that AVB queues are processed first. */ 1604 + for (i = fep->num_rx_queues - 1; i >= 0; i--) 1605 + done += fec_enet_rx_queue(ndev, budget - done, i); 1600 1606 1601 - ret = fec_enet_rx_queue(ndev, 1602 - budget - pkt_received, queue_id); 1603 - 1604 - if (ret < budget - pkt_received) 1605 - clear_bit(queue_id, &fep->work_rx); 1606 - 1607 - pkt_received += ret; 1608 - } 1609 - return pkt_received; 1607 + return done; 1610 1608 } 1611 1609 1612 - static bool 1613 - fec_enet_collect_events(struct fec_enet_private *fep, uint int_events) 1610 + static bool fec_enet_collect_events(struct fec_enet_private *fep) 1614 1611 { 1615 - if (int_events == 0) 1616 - return false; 1617 - 1618 - if (int_events & FEC_ENET_RXF_0) 1619 - fep->work_rx |= (1 << 2); 1620 - if (int_events & FEC_ENET_RXF_1) 1621 - fep->work_rx |= (1 << 0); 1622 - if (int_events & FEC_ENET_RXF_2) 1623 - fep->work_rx |= (1 << 1); 1624 - 1625 - if (int_events & FEC_ENET_TXF_0) 1626 - fep->work_tx |= (1 << 2); 1627 - if (int_events & FEC_ENET_TXF_1) 1628 - fep->work_tx |= (1 << 0); 1629 - if (int_events & FEC_ENET_TXF_2) 1630 - fep->work_tx |= (1 << 1); 1631 - 1632 - return true; 1633 - } 1634 - 1635 - static irqreturn_t 1636 - fec_enet_interrupt(int irq, void *dev_id) 1637 - { 1638 - struct net_device *ndev = dev_id; 1639 - struct fec_enet_private *fep = netdev_priv(ndev); 1640 1612 uint int_events; 1641 - irqreturn_t ret = IRQ_NONE; 1642 1613 1643 1614 int_events = readl(fep->hwp + FEC_IEVENT); 1644 1615 ··· 1610 1653 int_events &= ~FEC_ENET_MII; 1611 1654 1612 1655 writel(int_events, fep->hwp + FEC_IEVENT); 1613 - fec_enet_collect_events(fep, int_events); 1614 1656 1615 - if ((fep->work_tx || fep->work_rx) && fep->link) { 1657 + return int_events != 0; 1658 + } 1659 + 1660 + static irqreturn_t 1661 + fec_enet_interrupt(int irq, void *dev_id) 1662 + { 1663 + struct net_device *ndev = dev_id; 1664 + struct fec_enet_private *fep = netdev_priv(ndev); 1665 + irqreturn_t ret = IRQ_NONE; 1666 + 1667 + if (fec_enet_collect_events(fep) && fep->link) { 1616 1668 ret = IRQ_HANDLED; 1617 1669 1618 1670 if (napi_schedule_prep(&fep->napi)) { ··· 1638 1672 { 1639 1673 struct net_device *ndev = napi->dev; 1640 1674 struct fec_enet_private *fep = netdev_priv(ndev); 1641 - int pkts; 1675 + int done = 0; 1642 1676 1643 - pkts = fec_enet_rx(ndev, budget); 1677 + do { 1678 + done += fec_enet_rx(ndev, budget - done); 1679 + fec_enet_tx(ndev); 1680 + } while ((done < budget) && fec_enet_collect_events(fep)); 1644 1681 1645 - fec_enet_tx(ndev); 1646 - 1647 - if (pkts < budget) { 1648 - napi_complete_done(napi, pkts); 1682 + if (done < budget) { 1683 + napi_complete_done(napi, done); 1649 1684 writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); 1650 1685 } 1651 - return pkts; 1686 + 1687 + return done; 1652 1688 } 1653 1689 1654 1690 /* ------------------------------------------------------------------------- */
+1 -2
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 4127 4127 4128 4128 hns3_put_ring_config(priv); 4129 4129 4130 - hns3_dbg_uninit(handle); 4131 - 4132 4130 out_netdev_free: 4131 + hns3_dbg_uninit(handle); 4133 4132 free_netdev(netdev); 4134 4133 } 4135 4134
+6 -3
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 180 180 { 181 181 struct hns3_enet_tqp_vector *tqp_vector = ring->tqp_vector; 182 182 unsigned char *packet = skb->data; 183 + u32 len = skb_headlen(skb); 183 184 u32 i; 184 185 185 - for (i = 0; i < skb->len; i++) 186 + len = min_t(u32, len, HNS3_NIC_LB_TEST_PACKET_SIZE); 187 + 188 + for (i = 0; i < len; i++) 186 189 if (packet[i] != (unsigned char)(i & 0xff)) 187 190 break; 188 191 189 192 /* The packet is correctly received */ 190 - if (i == skb->len) 193 + if (i == HNS3_NIC_LB_TEST_PACKET_SIZE) 191 194 tqp_vector->rx_group.total_packets++; 192 195 else 193 196 print_hex_dump(KERN_ERR, "selftest:", DUMP_PREFIX_OFFSET, 16, 1, 194 - skb->data, skb->len, true); 197 + skb->data, len, true); 195 198 196 199 dev_kfree_skb_any(skb); 197 200 }
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 9859 9859 set_bit(HCLGE_STATE_RST_HANDLING, &hdev->state); 9860 9860 hdev->reset_type = HNAE3_FLR_RESET; 9861 9861 ret = hclge_reset_prepare(hdev); 9862 - if (ret) { 9862 + if (ret || hdev->reset_pending) { 9863 9863 dev_err(&hdev->pdev->dev, "fail to prepare FLR, ret=%d\n", 9864 9864 ret); 9865 9865 if (hdev->reset_pending ||
+5
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 1793 1793 if (hdev->reset_type == HNAE3_VF_FUNC_RESET) { 1794 1794 hclgevf_build_send_msg(&send_msg, HCLGE_MBX_RESET, 0); 1795 1795 ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0); 1796 + if (ret) { 1797 + dev_err(&hdev->pdev->dev, 1798 + "failed to assert VF reset, ret = %d\n", ret); 1799 + return ret; 1800 + } 1796 1801 hdev->rst_stats.vf_func_rst_cnt++; 1797 1802 } 1798 1803
+2
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
··· 814 814 err_init_msix: 815 815 err_pfhwdev_alloc: 816 816 hinic_free_hwif(hwif); 817 + if (err > 0) 818 + err = -EIO; 817 819 return ERR_PTR(err); 818 820 } 819 821
+81 -28
drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
··· 370 370 MSG_NOT_RESP, timeout); 371 371 } 372 372 373 + static void recv_mgmt_msg_work_handler(struct work_struct *work) 374 + { 375 + struct hinic_mgmt_msg_handle_work *mgmt_work = 376 + container_of(work, struct hinic_mgmt_msg_handle_work, work); 377 + struct hinic_pf_to_mgmt *pf_to_mgmt = mgmt_work->pf_to_mgmt; 378 + struct pci_dev *pdev = pf_to_mgmt->hwif->pdev; 379 + u8 *buf_out = pf_to_mgmt->mgmt_ack_buf; 380 + struct hinic_mgmt_cb *mgmt_cb; 381 + unsigned long cb_state; 382 + u16 out_size = 0; 383 + 384 + memset(buf_out, 0, MAX_PF_MGMT_BUF_SIZE); 385 + 386 + if (mgmt_work->mod >= HINIC_MOD_MAX) { 387 + dev_err(&pdev->dev, "Unknown MGMT MSG module = %d\n", 388 + mgmt_work->mod); 389 + kfree(mgmt_work->msg); 390 + kfree(mgmt_work); 391 + return; 392 + } 393 + 394 + mgmt_cb = &pf_to_mgmt->mgmt_cb[mgmt_work->mod]; 395 + 396 + cb_state = cmpxchg(&mgmt_cb->state, 397 + HINIC_MGMT_CB_ENABLED, 398 + HINIC_MGMT_CB_ENABLED | HINIC_MGMT_CB_RUNNING); 399 + 400 + if ((cb_state == HINIC_MGMT_CB_ENABLED) && (mgmt_cb->cb)) 401 + mgmt_cb->cb(mgmt_cb->handle, mgmt_work->cmd, 402 + mgmt_work->msg, mgmt_work->msg_len, 403 + buf_out, &out_size); 404 + else 405 + dev_err(&pdev->dev, "No MGMT msg handler, mod: %d, cmd: %d\n", 406 + mgmt_work->mod, mgmt_work->cmd); 407 + 408 + mgmt_cb->state &= ~HINIC_MGMT_CB_RUNNING; 409 + 410 + if (!mgmt_work->async_mgmt_to_pf) 411 + /* MGMT sent sync msg, send the response */ 412 + msg_to_mgmt_async(pf_to_mgmt, mgmt_work->mod, mgmt_work->cmd, 413 + buf_out, out_size, MGMT_RESP, 414 + mgmt_work->msg_id); 415 + 416 + kfree(mgmt_work->msg); 417 + kfree(mgmt_work); 418 + } 419 + 373 420 /** 374 421 * mgmt_recv_msg_handler - handler for message from mgmt cpu 375 422 * @pf_to_mgmt: PF to MGMT channel ··· 425 378 static void mgmt_recv_msg_handler(struct hinic_pf_to_mgmt *pf_to_mgmt, 426 379 struct hinic_recv_msg *recv_msg) 427 380 { 428 - struct hinic_hwif *hwif = pf_to_mgmt->hwif; 429 - struct pci_dev *pdev = hwif->pdev; 430 - u8 *buf_out = recv_msg->buf_out; 431 - struct hinic_mgmt_cb *mgmt_cb; 432 - unsigned long cb_state; 433 - u16 out_size = 0; 381 + struct hinic_mgmt_msg_handle_work *mgmt_work = NULL; 382 + struct pci_dev *pdev = pf_to_mgmt->hwif->pdev; 434 383 435 - if (recv_msg->mod >= HINIC_MOD_MAX) { 436 - dev_err(&pdev->dev, "Unknown MGMT MSG module = %d\n", 437 - recv_msg->mod); 384 + mgmt_work = kzalloc(sizeof(*mgmt_work), GFP_KERNEL); 385 + if (!mgmt_work) { 386 + dev_err(&pdev->dev, "Allocate mgmt work memory failed\n"); 438 387 return; 439 388 } 440 389 441 - mgmt_cb = &pf_to_mgmt->mgmt_cb[recv_msg->mod]; 390 + if (recv_msg->msg_len) { 391 + mgmt_work->msg = kzalloc(recv_msg->msg_len, GFP_KERNEL); 392 + if (!mgmt_work->msg) { 393 + dev_err(&pdev->dev, "Allocate mgmt msg memory failed\n"); 394 + kfree(mgmt_work); 395 + return; 396 + } 397 + } 442 398 443 - cb_state = cmpxchg(&mgmt_cb->state, 444 - HINIC_MGMT_CB_ENABLED, 445 - HINIC_MGMT_CB_ENABLED | HINIC_MGMT_CB_RUNNING); 399 + mgmt_work->pf_to_mgmt = pf_to_mgmt; 400 + mgmt_work->msg_len = recv_msg->msg_len; 401 + memcpy(mgmt_work->msg, recv_msg->msg, recv_msg->msg_len); 402 + mgmt_work->msg_id = recv_msg->msg_id; 403 + mgmt_work->mod = recv_msg->mod; 404 + mgmt_work->cmd = recv_msg->cmd; 405 + mgmt_work->async_mgmt_to_pf = recv_msg->async_mgmt_to_pf; 446 406 447 - if ((cb_state == HINIC_MGMT_CB_ENABLED) && (mgmt_cb->cb)) 448 - mgmt_cb->cb(mgmt_cb->handle, recv_msg->cmd, 449 - recv_msg->msg, recv_msg->msg_len, 450 - buf_out, &out_size); 451 - else 452 - dev_err(&pdev->dev, "No MGMT msg handler, mod: %d, cmd: %d\n", 453 - recv_msg->mod, recv_msg->cmd); 454 - 455 - mgmt_cb->state &= ~HINIC_MGMT_CB_RUNNING; 456 - 457 - if (!recv_msg->async_mgmt_to_pf) 458 - /* MGMT sent sync msg, send the response */ 459 - msg_to_mgmt_async(pf_to_mgmt, recv_msg->mod, recv_msg->cmd, 460 - buf_out, out_size, MGMT_RESP, 461 - recv_msg->msg_id); 407 + INIT_WORK(&mgmt_work->work, recv_mgmt_msg_work_handler); 408 + queue_work(pf_to_mgmt->workq, &mgmt_work->work); 462 409 } 463 410 464 411 /** ··· 587 546 if (!pf_to_mgmt->sync_msg_buf) 588 547 return -ENOMEM; 589 548 549 + pf_to_mgmt->mgmt_ack_buf = devm_kzalloc(&pdev->dev, 550 + MAX_PF_MGMT_BUF_SIZE, 551 + GFP_KERNEL); 552 + if (!pf_to_mgmt->mgmt_ack_buf) 553 + return -ENOMEM; 554 + 590 555 return 0; 591 556 } 592 557 ··· 618 571 return 0; 619 572 620 573 sema_init(&pf_to_mgmt->sync_msg_lock, 1); 574 + pf_to_mgmt->workq = create_singlethread_workqueue("hinic_mgmt"); 575 + if (!pf_to_mgmt->workq) { 576 + dev_err(&pdev->dev, "Failed to initialize MGMT workqueue\n"); 577 + return -ENOMEM; 578 + } 621 579 pf_to_mgmt->sync_msg_id = 0; 622 580 623 581 err = alloc_msg_buf(pf_to_mgmt); ··· 657 605 658 606 hinic_aeq_unregister_hw_cb(&hwdev->aeqs, HINIC_MSG_FROM_MGMT_CPU); 659 607 hinic_api_cmd_free(pf_to_mgmt->cmd_chain); 608 + destroy_workqueue(pf_to_mgmt->workq); 660 609 }
+16
drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.h
··· 119 119 struct semaphore sync_msg_lock; 120 120 u16 sync_msg_id; 121 121 u8 *sync_msg_buf; 122 + void *mgmt_ack_buf; 122 123 123 124 struct hinic_recv_msg recv_resp_msg_from_mgmt; 124 125 struct hinic_recv_msg recv_msg_from_mgmt; ··· 127 126 struct hinic_api_cmd_chain *cmd_chain[HINIC_API_CMD_MAX]; 128 127 129 128 struct hinic_mgmt_cb mgmt_cb[HINIC_MOD_MAX]; 129 + 130 + struct workqueue_struct *workq; 131 + }; 132 + 133 + struct hinic_mgmt_msg_handle_work { 134 + struct work_struct work; 135 + struct hinic_pf_to_mgmt *pf_to_mgmt; 136 + 137 + void *msg; 138 + u16 msg_len; 139 + 140 + enum hinic_mod_type mod; 141 + u8 cmd; 142 + u16 msg_id; 143 + int async_mgmt_to_pf; 130 144 }; 131 145 132 146 void hinic_register_mgmt_msg_cb(struct hinic_pf_to_mgmt *pf_to_mgmt,
+1 -1
drivers/net/ethernet/marvell/mvneta.c
··· 3959 3959 /* When at 2.5G, the link partner can send frames with shortened 3960 3960 * preambles. 3961 3961 */ 3962 - if (state->speed == SPEED_2500) 3962 + if (state->interface == PHY_INTERFACE_MODE_2500BASEX) 3963 3963 new_ctrl4 |= MVNETA_GMAC4_SHORT_PREAMBLE_ENABLE; 3964 3964 3965 3965 if (pp->phy_interface != state->interface) {
+1 -1
drivers/net/ethernet/marvell/sky2.c
··· 203 203 204 204 static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) 205 205 { 206 - u16 v; 206 + u16 v = 0; 207 207 __gm_phy_read(hw, port, reg, &v); 208 208 return v; 209 209 }
+1
drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h
··· 29 29 bool manual_buffer; 30 30 u32 cable_len; 31 31 u32 xoff; 32 + u16 port_buff_cell_sz; 32 33 }; 33 34 34 35 #define MLX5E_MAX_DSCP (64)
+18 -3
drivers/net/ethernet/mellanox/mlx5/core/en/port.c
··· 78 78 [MLX5E_400GAUI_8] = 400000, 79 79 }; 80 80 81 + bool mlx5e_ptys_ext_supported(struct mlx5_core_dev *mdev) 82 + { 83 + struct mlx5e_port_eth_proto eproto; 84 + int err; 85 + 86 + if (MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet)) 87 + return true; 88 + 89 + err = mlx5_port_query_eth_proto(mdev, 1, true, &eproto); 90 + if (err) 91 + return false; 92 + 93 + return !!eproto.cap; 94 + } 95 + 81 96 static void mlx5e_port_get_speed_arr(struct mlx5_core_dev *mdev, 82 97 const u32 **arr, u32 *size, 83 98 bool force_legacy) 84 99 { 85 - bool ext = force_legacy ? false : MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 100 + bool ext = force_legacy ? false : mlx5e_ptys_ext_supported(mdev); 86 101 87 102 *size = ext ? ARRAY_SIZE(mlx5e_ext_link_speed) : 88 103 ARRAY_SIZE(mlx5e_link_speed); ··· 192 177 bool ext; 193 178 int err; 194 179 195 - ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 180 + ext = mlx5e_ptys_ext_supported(mdev); 196 181 err = mlx5_port_query_eth_proto(mdev, 1, ext, &eproto); 197 182 if (err) 198 183 goto out; ··· 220 205 int err; 221 206 int i; 222 207 223 - ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 208 + ext = mlx5e_ptys_ext_supported(mdev); 224 209 err = mlx5_port_query_eth_proto(mdev, 1, ext, &eproto); 225 210 if (err) 226 211 return err;
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en/port.h
··· 54 54 int mlx5e_port_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed); 55 55 u32 mlx5e_port_speed2linkmodes(struct mlx5_core_dev *mdev, u32 speed, 56 56 bool force_legacy); 57 - 57 + bool mlx5e_ptys_ext_supported(struct mlx5_core_dev *mdev); 58 58 int mlx5e_port_query_pbmc(struct mlx5_core_dev *mdev, void *out); 59 59 int mlx5e_port_set_pbmc(struct mlx5_core_dev *mdev, void *in); 60 60 int mlx5e_port_query_priority2buffer(struct mlx5_core_dev *mdev, u8 *buffer);
+28 -23
drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
··· 34 34 int mlx5e_port_query_buffer(struct mlx5e_priv *priv, 35 35 struct mlx5e_port_buffer *port_buffer) 36 36 { 37 + u16 port_buff_cell_sz = priv->dcbx.port_buff_cell_sz; 37 38 struct mlx5_core_dev *mdev = priv->mdev; 38 39 int sz = MLX5_ST_SZ_BYTES(pbmc_reg); 39 40 u32 total_used = 0; ··· 58 57 port_buffer->buffer[i].epsb = 59 58 MLX5_GET(bufferx_reg, buffer, epsb); 60 59 port_buffer->buffer[i].size = 61 - MLX5_GET(bufferx_reg, buffer, size) << MLX5E_BUFFER_CELL_SHIFT; 60 + MLX5_GET(bufferx_reg, buffer, size) * port_buff_cell_sz; 62 61 port_buffer->buffer[i].xon = 63 - MLX5_GET(bufferx_reg, buffer, xon_threshold) << MLX5E_BUFFER_CELL_SHIFT; 62 + MLX5_GET(bufferx_reg, buffer, xon_threshold) * port_buff_cell_sz; 64 63 port_buffer->buffer[i].xoff = 65 - MLX5_GET(bufferx_reg, buffer, xoff_threshold) << MLX5E_BUFFER_CELL_SHIFT; 64 + MLX5_GET(bufferx_reg, buffer, xoff_threshold) * port_buff_cell_sz; 66 65 total_used += port_buffer->buffer[i].size; 67 66 68 67 mlx5e_dbg(HW, priv, "buffer %d: size=%d, xon=%d, xoff=%d, epsb=%d, lossy=%d\n", i, ··· 74 73 } 75 74 76 75 port_buffer->port_buffer_size = 77 - MLX5_GET(pbmc_reg, out, port_buffer_size) << MLX5E_BUFFER_CELL_SHIFT; 76 + MLX5_GET(pbmc_reg, out, port_buffer_size) * port_buff_cell_sz; 78 77 port_buffer->spare_buffer_size = 79 78 port_buffer->port_buffer_size - total_used; 80 79 ··· 89 88 static int port_set_buffer(struct mlx5e_priv *priv, 90 89 struct mlx5e_port_buffer *port_buffer) 91 90 { 91 + u16 port_buff_cell_sz = priv->dcbx.port_buff_cell_sz; 92 92 struct mlx5_core_dev *mdev = priv->mdev; 93 93 int sz = MLX5_ST_SZ_BYTES(pbmc_reg); 94 - void *buffer; 95 94 void *in; 96 95 int err; 97 96 int i; ··· 105 104 goto out; 106 105 107 106 for (i = 0; i < MLX5E_MAX_BUFFER; i++) { 108 - buffer = MLX5_ADDR_OF(pbmc_reg, in, buffer[i]); 107 + void *buffer = MLX5_ADDR_OF(pbmc_reg, in, buffer[i]); 108 + u64 size = port_buffer->buffer[i].size; 109 + u64 xoff = port_buffer->buffer[i].xoff; 110 + u64 xon = port_buffer->buffer[i].xon; 109 111 110 - MLX5_SET(bufferx_reg, buffer, size, 111 - port_buffer->buffer[i].size >> MLX5E_BUFFER_CELL_SHIFT); 112 - MLX5_SET(bufferx_reg, buffer, lossy, 113 - port_buffer->buffer[i].lossy); 114 - MLX5_SET(bufferx_reg, buffer, xoff_threshold, 115 - port_buffer->buffer[i].xoff >> MLX5E_BUFFER_CELL_SHIFT); 116 - MLX5_SET(bufferx_reg, buffer, xon_threshold, 117 - port_buffer->buffer[i].xon >> MLX5E_BUFFER_CELL_SHIFT); 112 + do_div(size, port_buff_cell_sz); 113 + do_div(xoff, port_buff_cell_sz); 114 + do_div(xon, port_buff_cell_sz); 115 + MLX5_SET(bufferx_reg, buffer, size, size); 116 + MLX5_SET(bufferx_reg, buffer, lossy, port_buffer->buffer[i].lossy); 117 + MLX5_SET(bufferx_reg, buffer, xoff_threshold, xoff); 118 + MLX5_SET(bufferx_reg, buffer, xon_threshold, xon); 118 119 } 119 120 120 121 err = mlx5e_port_set_pbmc(mdev, in); ··· 146 143 } 147 144 148 145 static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, 149 - u32 xoff, unsigned int max_mtu) 146 + u32 xoff, unsigned int max_mtu, u16 port_buff_cell_sz) 150 147 { 151 148 int i; 152 149 ··· 158 155 } 159 156 160 157 if (port_buffer->buffer[i].size < 161 - (xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT))) { 158 + (xoff + max_mtu + port_buff_cell_sz)) { 162 159 pr_err("buffer_size[%d]=%d is not enough for lossless buffer\n", 163 160 i, port_buffer->buffer[i].size); 164 161 return -ENOMEM; ··· 178 175 * @pfc_en: <input> current pfc configuration 179 176 * @buffer: <input> current prio to buffer mapping 180 177 * @xoff: <input> xoff value 178 + * @port_buff_cell_sz: <input> port buffer cell_size 181 179 * @port_buffer: <output> port receive buffer configuration 182 180 * @change: <output> 183 181 * ··· 193 189 * sets change to true if buffer configuration was modified. 194 190 */ 195 191 static int update_buffer_lossy(unsigned int max_mtu, 196 - u8 pfc_en, u8 *buffer, u32 xoff, 192 + u8 pfc_en, u8 *buffer, u32 xoff, u16 port_buff_cell_sz, 197 193 struct mlx5e_port_buffer *port_buffer, 198 194 bool *change) 199 195 { ··· 229 225 } 230 226 231 227 if (changed) { 232 - err = update_xoff_threshold(port_buffer, xoff, max_mtu); 228 + err = update_xoff_threshold(port_buffer, xoff, max_mtu, port_buff_cell_sz); 233 229 if (err) 234 230 return err; 235 231 ··· 266 262 u32 *buffer_size, 267 263 u8 *prio2buffer) 268 264 { 265 + u16 port_buff_cell_sz = priv->dcbx.port_buff_cell_sz; 269 266 struct mlx5e_port_buffer port_buffer; 270 267 u32 xoff = calculate_xoff(priv, mtu); 271 268 bool update_prio2buffer = false; ··· 287 282 288 283 if (change & MLX5E_PORT_BUFFER_CABLE_LEN) { 289 284 update_buffer = true; 290 - err = update_xoff_threshold(&port_buffer, xoff, max_mtu); 285 + err = update_xoff_threshold(&port_buffer, xoff, max_mtu, port_buff_cell_sz); 291 286 if (err) 292 287 return err; 293 288 } ··· 297 292 if (err) 298 293 return err; 299 294 300 - err = update_buffer_lossy(max_mtu, pfc->pfc_en, buffer, xoff, 295 + err = update_buffer_lossy(max_mtu, pfc->pfc_en, buffer, xoff, port_buff_cell_sz, 301 296 &port_buffer, &update_buffer); 302 297 if (err) 303 298 return err; ··· 309 304 if (err) 310 305 return err; 311 306 312 - err = update_buffer_lossy(max_mtu, curr_pfc_en, prio2buffer, 307 + err = update_buffer_lossy(max_mtu, curr_pfc_en, prio2buffer, port_buff_cell_sz, 313 308 xoff, &port_buffer, &update_buffer); 314 309 if (err) 315 310 return err; ··· 334 329 return -EINVAL; 335 330 336 331 update_buffer = true; 337 - err = update_xoff_threshold(&port_buffer, xoff, max_mtu); 332 + err = update_xoff_threshold(&port_buffer, xoff, max_mtu, port_buff_cell_sz); 338 333 if (err) 339 334 return err; 340 335 } ··· 342 337 /* Need to update buffer configuration if xoff value is changed */ 343 338 if (!update_buffer && xoff != priv->dcbx.xoff) { 344 339 update_buffer = true; 345 - err = update_xoff_threshold(&port_buffer, xoff, max_mtu); 340 + err = update_xoff_threshold(&port_buffer, xoff, max_mtu, port_buff_cell_sz); 346 341 if (err) 347 342 return err; 348 343 }
-1
drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.h
··· 36 36 #include "port.h" 37 37 38 38 #define MLX5E_MAX_BUFFER 8 39 - #define MLX5E_BUFFER_CELL_SHIFT 7 40 39 #define MLX5E_DEFAULT_CABLE_LEN 7 /* 7 meters */ 41 40 42 41 #define MLX5_BUFFER_SUPPORTED(mdev) (MLX5_CAP_GEN(mdev, pcam_reg) && \
-1
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
··· 6 6 #include <linux/rculist.h> 7 7 #include <linux/rtnetlink.h> 8 8 #include <linux/workqueue.h> 9 - #include <linux/rwlock.h> 10 9 #include <linux/spinlock.h> 11 10 #include <linux/notifier.h> 12 11 #include <net/netevent.h>
+1
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
··· 1097 1097 struct mlx5_ct_entry *entry = ptr; 1098 1098 1099 1099 mlx5_tc_ct_entry_del_rules(ct_priv, entry); 1100 + kfree(entry); 1100 1101 } 1101 1102 1102 1103 static void
+19
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 1217 1217 return 0; 1218 1218 } 1219 1219 1220 + #define MLX5E_BUFFER_CELL_SHIFT 7 1221 + 1222 + static u16 mlx5e_query_port_buffers_cell_size(struct mlx5e_priv *priv) 1223 + { 1224 + struct mlx5_core_dev *mdev = priv->mdev; 1225 + u32 out[MLX5_ST_SZ_DW(sbcam_reg)] = {}; 1226 + u32 in[MLX5_ST_SZ_DW(sbcam_reg)] = {}; 1227 + 1228 + if (!MLX5_CAP_GEN(mdev, sbcam_reg)) 1229 + return (1 << MLX5E_BUFFER_CELL_SHIFT); 1230 + 1231 + if (mlx5_core_access_reg(mdev, in, sizeof(in), out, sizeof(out), 1232 + MLX5_REG_SBCAM, 0, 0)) 1233 + return (1 << MLX5E_BUFFER_CELL_SHIFT); 1234 + 1235 + return MLX5_GET(sbcam_reg, out, cap_cell_size); 1236 + } 1237 + 1220 1238 void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv) 1221 1239 { 1222 1240 struct mlx5e_dcbx *dcbx = &priv->dcbx; ··· 1252 1234 if (priv->dcbx.mode == MLX5E_DCBX_PARAM_VER_OPER_HOST) 1253 1235 priv->dcbx.cap |= DCB_CAP_DCBX_HOST; 1254 1236 1237 + priv->dcbx.port_buff_cell_sz = mlx5e_query_port_buffers_cell_size(priv); 1255 1238 priv->dcbx.manual_buffer = false; 1256 1239 priv->dcbx.cable_len = MLX5E_DEFAULT_CABLE_LEN; 1257 1240
+4 -4
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 200 200 struct ptys2ethtool_config **arr, 201 201 u32 *size) 202 202 { 203 - bool ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 203 + bool ext = mlx5e_ptys_ext_supported(mdev); 204 204 205 205 *arr = ext ? ptys2ext_ethtool_table : ptys2legacy_ethtool_table; 206 206 *size = ext ? ARRAY_SIZE(ptys2ext_ethtool_table) : ··· 883 883 struct ethtool_link_ksettings *link_ksettings) 884 884 { 885 885 unsigned long *lp_advertising = link_ksettings->link_modes.lp_advertising; 886 - bool ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 886 + bool ext = mlx5e_ptys_ext_supported(mdev); 887 887 888 888 ptys2ethtool_adver_link(lp_advertising, eth_proto_lp, ext); 889 889 } ··· 913 913 __func__, err); 914 914 goto err_query_regs; 915 915 } 916 - ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 916 + ext = !!MLX5_GET_ETH_PROTO(ptys_reg, out, true, eth_proto_capability); 917 917 eth_proto_cap = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, 918 918 eth_proto_capability); 919 919 eth_proto_admin = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, ··· 1066 1066 autoneg = link_ksettings->base.autoneg; 1067 1067 speed = link_ksettings->base.speed; 1068 1068 1069 - ext_supported = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); 1069 + ext_supported = mlx5e_ptys_ext_supported(mdev); 1070 1070 ext = ext_requested(autoneg, adver, ext_supported); 1071 1071 if (!ext_supported && ext) 1072 1072 return -EOPNOTSUPP;
+8 -7
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 3104 3104 mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP); 3105 3105 mutex_unlock(&priv->state_lock); 3106 3106 3107 - if (mlx5_vxlan_allowed(priv->mdev->vxlan)) 3108 - udp_tunnel_get_rx_info(netdev); 3109 - 3110 3107 return err; 3111 3108 } 3112 3109 ··· 5118 5121 if (err) 5119 5122 goto err_destroy_flow_steering; 5120 5123 5124 + #ifdef CONFIG_MLX5_EN_ARFS 5125 + priv->netdev->rx_cpu_rmap = mlx5_eq_table_get_rmap(priv->mdev); 5126 + #endif 5127 + 5121 5128 return 0; 5122 5129 5123 5130 err_destroy_flow_steering: ··· 5203 5202 rtnl_lock(); 5204 5203 if (netif_running(netdev)) 5205 5204 mlx5e_open(netdev); 5205 + if (mlx5_vxlan_allowed(priv->mdev->vxlan)) 5206 + udp_tunnel_get_rx_info(netdev); 5206 5207 netif_device_attach(netdev); 5207 5208 rtnl_unlock(); 5208 5209 } ··· 5219 5216 rtnl_lock(); 5220 5217 if (netif_running(priv->netdev)) 5221 5218 mlx5e_close(priv->netdev); 5219 + if (mlx5_vxlan_allowed(priv->mdev->vxlan)) 5220 + udp_tunnel_drop_rx_info(priv->netdev); 5222 5221 netif_device_detach(priv->netdev); 5223 5222 rtnl_unlock(); 5224 5223 ··· 5292 5287 5293 5288 /* netdev init */ 5294 5289 netif_carrier_off(netdev); 5295 - 5296 - #ifdef CONFIG_MLX5_EN_ARFS 5297 - netdev->rx_cpu_rmap = mlx5_eq_table_get_rmap(mdev); 5298 - #endif 5299 5290 5300 5291 return 0; 5301 5292
+9 -5
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 4670 4670 struct mlx5e_rep_priv *rpriv) 4671 4671 { 4672 4672 /* Offloaded flow rule is allowed to duplicate on non-uplink representor 4673 - * sharing tc block with other slaves of a lag device. 4673 + * sharing tc block with other slaves of a lag device. Rpriv can be NULL if this 4674 + * function is called from NIC mode. 4674 4675 */ 4675 - return netif_is_lag_port(dev) && rpriv->rep->vport != MLX5_VPORT_UPLINK; 4676 + return netif_is_lag_port(dev) && rpriv && rpriv->rep->vport != MLX5_VPORT_UPLINK; 4676 4677 } 4677 4678 4678 4679 int mlx5e_configure_flower(struct net_device *dev, struct mlx5e_priv *priv, ··· 4687 4686 4688 4687 rcu_read_lock(); 4689 4688 flow = rhashtable_lookup(tc_ht, &f->cookie, tc_ht_params); 4690 - rcu_read_unlock(); 4691 4689 if (flow) { 4692 4690 /* Same flow rule offloaded to non-uplink representor sharing tc block, 4693 4691 * just return 0. 4694 4692 */ 4695 4693 if (is_flow_rule_duplicate_allowed(dev, rpriv) && flow->orig_dev != dev) 4696 - goto out; 4694 + goto rcu_unlock; 4697 4695 4698 4696 NL_SET_ERR_MSG_MOD(extack, 4699 4697 "flow cookie already exists, ignoring"); ··· 4700 4700 "flow cookie %lx already exists, ignoring\n", 4701 4701 f->cookie); 4702 4702 err = -EEXIST; 4703 - goto out; 4703 + goto rcu_unlock; 4704 4704 } 4705 + rcu_unlock: 4706 + rcu_read_unlock(); 4707 + if (flow) 4708 + goto out; 4705 4709 4706 4710 trace_mlx5e_configure_flower(f); 4707 4711 err = mlx5e_tc_add_flow(priv, f, flags, dev, &flow);
-1
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c
··· 217 217 } 218 218 219 219 /* Create ingress allow rule */ 220 - memset(spec, 0, sizeof(*spec)); 221 220 spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS; 222 221 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW; 223 222 vport->ingress.allow_rule = mlx5_add_flow_rules(vport->ingress.acl, spec,
+77 -16
drivers/net/ethernet/mellanox/mlx5/core/port.c
··· 293 293 return 0; 294 294 } 295 295 296 - static int mlx5_eeprom_page(int offset) 296 + static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num, 297 + u8 *module_id) 298 + { 299 + u32 in[MLX5_ST_SZ_DW(mcia_reg)] = {}; 300 + u32 out[MLX5_ST_SZ_DW(mcia_reg)]; 301 + int err, status; 302 + u8 *ptr; 303 + 304 + MLX5_SET(mcia_reg, in, i2c_device_address, MLX5_I2C_ADDR_LOW); 305 + MLX5_SET(mcia_reg, in, module, module_num); 306 + MLX5_SET(mcia_reg, in, device_address, 0); 307 + MLX5_SET(mcia_reg, in, page_number, 0); 308 + MLX5_SET(mcia_reg, in, size, 1); 309 + MLX5_SET(mcia_reg, in, l, 0); 310 + 311 + err = mlx5_core_access_reg(dev, in, sizeof(in), out, 312 + sizeof(out), MLX5_REG_MCIA, 0, 0); 313 + if (err) 314 + return err; 315 + 316 + status = MLX5_GET(mcia_reg, out, status); 317 + if (status) { 318 + mlx5_core_err(dev, "query_mcia_reg failed: status: 0x%x\n", 319 + status); 320 + return -EIO; 321 + } 322 + ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0); 323 + 324 + *module_id = ptr[0]; 325 + 326 + return 0; 327 + } 328 + 329 + static int mlx5_qsfp_eeprom_page(u16 offset) 297 330 { 298 331 if (offset < MLX5_EEPROM_PAGE_LENGTH) 299 332 /* Addresses between 0-255 - page 00 */ ··· 340 307 MLX5_EEPROM_HIGH_PAGE_LENGTH); 341 308 } 342 309 343 - static int mlx5_eeprom_high_page_offset(int page_num) 310 + static int mlx5_qsfp_eeprom_high_page_offset(int page_num) 344 311 { 345 312 if (!page_num) /* Page 0 always start from low page */ 346 313 return 0; ··· 349 316 return page_num * MLX5_EEPROM_HIGH_PAGE_LENGTH; 350 317 } 351 318 319 + static void mlx5_qsfp_eeprom_params_set(u16 *i2c_addr, int *page_num, u16 *offset) 320 + { 321 + *i2c_addr = MLX5_I2C_ADDR_LOW; 322 + *page_num = mlx5_qsfp_eeprom_page(*offset); 323 + *offset -= mlx5_qsfp_eeprom_high_page_offset(*page_num); 324 + } 325 + 326 + static void mlx5_sfp_eeprom_params_set(u16 *i2c_addr, int *page_num, u16 *offset) 327 + { 328 + *i2c_addr = MLX5_I2C_ADDR_LOW; 329 + *page_num = 0; 330 + 331 + if (*offset < MLX5_EEPROM_PAGE_LENGTH) 332 + return; 333 + 334 + *i2c_addr = MLX5_I2C_ADDR_HIGH; 335 + *offset -= MLX5_EEPROM_PAGE_LENGTH; 336 + } 337 + 352 338 int mlx5_query_module_eeprom(struct mlx5_core_dev *dev, 353 339 u16 offset, u16 size, u8 *data) 354 340 { 355 - int module_num, page_num, status, err; 341 + int module_num, status, err, page_num = 0; 342 + u32 in[MLX5_ST_SZ_DW(mcia_reg)] = {}; 356 343 u32 out[MLX5_ST_SZ_DW(mcia_reg)]; 357 - u32 in[MLX5_ST_SZ_DW(mcia_reg)]; 358 - u16 i2c_addr; 359 - void *ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0); 344 + u16 i2c_addr = 0; 345 + u8 module_id; 346 + void *ptr; 360 347 361 348 err = mlx5_query_module_num(dev, &module_num); 362 349 if (err) 363 350 return err; 364 351 365 - memset(in, 0, sizeof(in)); 366 - size = min_t(int, size, MLX5_EEPROM_MAX_BYTES); 352 + err = mlx5_query_module_id(dev, module_num, &module_id); 353 + if (err) 354 + return err; 367 355 368 - /* Get the page number related to the given offset */ 369 - page_num = mlx5_eeprom_page(offset); 370 - 371 - /* Set the right offset according to the page number, 372 - * For page_num > 0, relative offset is always >= 128 (high page). 373 - */ 374 - offset -= mlx5_eeprom_high_page_offset(page_num); 356 + switch (module_id) { 357 + case MLX5_MODULE_ID_SFP: 358 + mlx5_sfp_eeprom_params_set(&i2c_addr, &page_num, &offset); 359 + break; 360 + case MLX5_MODULE_ID_QSFP: 361 + case MLX5_MODULE_ID_QSFP_PLUS: 362 + case MLX5_MODULE_ID_QSFP28: 363 + mlx5_qsfp_eeprom_params_set(&i2c_addr, &page_num, &offset); 364 + break; 365 + default: 366 + mlx5_core_err(dev, "Module ID not recognized: 0x%x\n", module_id); 367 + return -EINVAL; 368 + } 375 369 376 370 if (offset + size > MLX5_EEPROM_PAGE_LENGTH) 377 371 /* Cross pages read, read until offset 256 in low page */ 378 372 size -= offset + size - MLX5_EEPROM_PAGE_LENGTH; 379 373 380 - i2c_addr = MLX5_I2C_ADDR_LOW; 374 + size = min_t(int, size, MLX5_EEPROM_MAX_BYTES); 381 375 382 376 MLX5_SET(mcia_reg, in, l, 0); 383 377 MLX5_SET(mcia_reg, in, module, module_num); ··· 425 365 return -EIO; 426 366 } 427 367 368 + ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0); 428 369 memcpy(data, ptr, size); 429 370 430 371 return size;
+38 -16
drivers/net/ethernet/mellanox/mlxsw/pci.c
··· 1414 1414 u16 num_pages; 1415 1415 int err; 1416 1416 1417 - mutex_init(&mlxsw_pci->cmd.lock); 1418 - init_waitqueue_head(&mlxsw_pci->cmd.wait); 1419 - 1420 1417 mlxsw_pci->core = mlxsw_core; 1421 1418 1422 1419 mbox = mlxsw_cmd_mbox_alloc(); 1423 1420 if (!mbox) 1424 1421 return -ENOMEM; 1425 - 1426 - err = mlxsw_pci_mbox_alloc(mlxsw_pci, &mlxsw_pci->cmd.in_mbox); 1427 - if (err) 1428 - goto mbox_put; 1429 - 1430 - err = mlxsw_pci_mbox_alloc(mlxsw_pci, &mlxsw_pci->cmd.out_mbox); 1431 - if (err) 1432 - goto err_out_mbox_alloc; 1433 1422 1434 1423 err = mlxsw_pci_sw_reset(mlxsw_pci, mlxsw_pci->id); 1435 1424 if (err) ··· 1526 1537 mlxsw_pci_free_irq_vectors(mlxsw_pci); 1527 1538 err_alloc_irq: 1528 1539 err_sw_reset: 1529 - mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.out_mbox); 1530 - err_out_mbox_alloc: 1531 - mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.in_mbox); 1532 1540 mbox_put: 1533 1541 mlxsw_cmd_mbox_free(mbox); 1534 1542 return err; ··· 1539 1553 mlxsw_pci_aqs_fini(mlxsw_pci); 1540 1554 mlxsw_pci_fw_area_fini(mlxsw_pci); 1541 1555 mlxsw_pci_free_irq_vectors(mlxsw_pci); 1542 - mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.out_mbox); 1543 - mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.in_mbox); 1544 1556 } 1545 1557 1546 1558 static struct mlxsw_pci_queue * ··· 1760 1776 .features = MLXSW_BUS_F_TXRX | MLXSW_BUS_F_RESET, 1761 1777 }; 1762 1778 1779 + static int mlxsw_pci_cmd_init(struct mlxsw_pci *mlxsw_pci) 1780 + { 1781 + int err; 1782 + 1783 + mutex_init(&mlxsw_pci->cmd.lock); 1784 + init_waitqueue_head(&mlxsw_pci->cmd.wait); 1785 + 1786 + err = mlxsw_pci_mbox_alloc(mlxsw_pci, &mlxsw_pci->cmd.in_mbox); 1787 + if (err) 1788 + goto err_in_mbox_alloc; 1789 + 1790 + err = mlxsw_pci_mbox_alloc(mlxsw_pci, &mlxsw_pci->cmd.out_mbox); 1791 + if (err) 1792 + goto err_out_mbox_alloc; 1793 + 1794 + return 0; 1795 + 1796 + err_out_mbox_alloc: 1797 + mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.in_mbox); 1798 + err_in_mbox_alloc: 1799 + mutex_destroy(&mlxsw_pci->cmd.lock); 1800 + return err; 1801 + } 1802 + 1803 + static void mlxsw_pci_cmd_fini(struct mlxsw_pci *mlxsw_pci) 1804 + { 1805 + mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.out_mbox); 1806 + mlxsw_pci_mbox_free(mlxsw_pci, &mlxsw_pci->cmd.in_mbox); 1807 + mutex_destroy(&mlxsw_pci->cmd.lock); 1808 + } 1809 + 1763 1810 static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1764 1811 { 1765 1812 const char *driver_name = pdev->driver->name; ··· 1846 1831 mlxsw_pci->pdev = pdev; 1847 1832 pci_set_drvdata(pdev, mlxsw_pci); 1848 1833 1834 + err = mlxsw_pci_cmd_init(mlxsw_pci); 1835 + if (err) 1836 + goto err_pci_cmd_init; 1837 + 1849 1838 mlxsw_pci->bus_info.device_kind = driver_name; 1850 1839 mlxsw_pci->bus_info.device_name = pci_name(mlxsw_pci->pdev); 1851 1840 mlxsw_pci->bus_info.dev = &pdev->dev; ··· 1867 1848 return 0; 1868 1849 1869 1850 err_bus_device_register: 1851 + mlxsw_pci_cmd_fini(mlxsw_pci); 1852 + err_pci_cmd_init: 1870 1853 iounmap(mlxsw_pci->hw_addr); 1871 1854 err_ioremap: 1872 1855 err_pci_resource_len_check: ··· 1886 1865 struct mlxsw_pci *mlxsw_pci = pci_get_drvdata(pdev); 1887 1866 1888 1867 mlxsw_core_bus_device_unregister(mlxsw_pci->core, false); 1868 + mlxsw_pci_cmd_fini(mlxsw_pci); 1889 1869 iounmap(mlxsw_pci->hw_addr); 1890 1870 pci_release_regions(mlxsw_pci->pdev); 1891 1871 pci_disable_device(mlxsw_pci->pdev);
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 6262 6262 } 6263 6263 6264 6264 fib_work = kzalloc(sizeof(*fib_work), GFP_ATOMIC); 6265 - if (WARN_ON(!fib_work)) 6265 + if (!fib_work) 6266 6266 return NOTIFY_BAD; 6267 6267 6268 6268 fib_work->mlxsw_sp = router->mlxsw_sp;
+17 -35
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
··· 468 468 ring->rx_pending = lif->nrxq_descs; 469 469 } 470 470 471 + static void ionic_set_ringsize(struct ionic_lif *lif, void *arg) 472 + { 473 + struct ethtool_ringparam *ring = arg; 474 + 475 + lif->ntxq_descs = ring->tx_pending; 476 + lif->nrxq_descs = ring->rx_pending; 477 + } 478 + 471 479 static int ionic_set_ringparam(struct net_device *netdev, 472 480 struct ethtool_ringparam *ring) 473 481 { 474 482 struct ionic_lif *lif = netdev_priv(netdev); 475 - bool running; 476 - int err; 477 483 478 484 if (ring->rx_mini_pending || ring->rx_jumbo_pending) { 479 485 netdev_info(netdev, "Changing jumbo or mini descriptors not supported\n"); ··· 497 491 ring->rx_pending == lif->nrxq_descs) 498 492 return 0; 499 493 500 - err = ionic_wait_for_bit(lif, IONIC_LIF_F_QUEUE_RESET); 501 - if (err) 502 - return err; 503 - 504 - running = test_bit(IONIC_LIF_F_UP, lif->state); 505 - if (running) 506 - ionic_stop(netdev); 507 - 508 - lif->ntxq_descs = ring->tx_pending; 509 - lif->nrxq_descs = ring->rx_pending; 510 - 511 - if (running) 512 - ionic_open(netdev); 513 - clear_bit(IONIC_LIF_F_QUEUE_RESET, lif->state); 514 - 515 - return 0; 494 + return ionic_reset_queues(lif, ionic_set_ringsize, ring); 516 495 } 517 496 518 497 static void ionic_get_channels(struct net_device *netdev, ··· 512 521 ch->combined_count = lif->nxqs; 513 522 } 514 523 524 + static void ionic_set_queuecount(struct ionic_lif *lif, void *arg) 525 + { 526 + struct ethtool_channels *ch = arg; 527 + 528 + lif->nxqs = ch->combined_count; 529 + } 530 + 515 531 static int ionic_set_channels(struct net_device *netdev, 516 532 struct ethtool_channels *ch) 517 533 { 518 534 struct ionic_lif *lif = netdev_priv(netdev); 519 - bool running; 520 - int err; 521 535 522 536 if (!ch->combined_count || ch->other_count || 523 537 ch->rx_count || ch->tx_count) ··· 531 535 if (ch->combined_count == lif->nxqs) 532 536 return 0; 533 537 534 - err = ionic_wait_for_bit(lif, IONIC_LIF_F_QUEUE_RESET); 535 - if (err) 536 - return err; 537 - 538 - running = test_bit(IONIC_LIF_F_UP, lif->state); 539 - if (running) 540 - ionic_stop(netdev); 541 - 542 - lif->nxqs = ch->combined_count; 543 - 544 - if (running) 545 - ionic_open(netdev); 546 - clear_bit(IONIC_LIF_F_QUEUE_RESET, lif->state); 547 - 548 - return 0; 538 + return ionic_reset_queues(lif, ionic_set_queuecount, ch); 549 539 } 550 540 551 541 static u32 ionic_get_priv_flags(struct net_device *netdev)
+20 -5
drivers/net/ethernet/pensando/ionic/ionic_lif.c
··· 1313 1313 return err; 1314 1314 1315 1315 netdev->mtu = new_mtu; 1316 - err = ionic_reset_queues(lif); 1316 + err = ionic_reset_queues(lif, NULL, NULL); 1317 1317 1318 1318 return err; 1319 1319 } ··· 1325 1325 netdev_info(lif->netdev, "Tx Timeout recovery\n"); 1326 1326 1327 1327 rtnl_lock(); 1328 - ionic_reset_queues(lif); 1328 + ionic_reset_queues(lif, NULL, NULL); 1329 1329 rtnl_unlock(); 1330 1330 } 1331 1331 ··· 1673 1673 if (err) 1674 1674 goto err_out; 1675 1675 1676 + err = netif_set_real_num_tx_queues(netdev, lif->nxqs); 1677 + if (err) 1678 + goto err_txrx_deinit; 1679 + 1680 + err = netif_set_real_num_rx_queues(netdev, lif->nxqs); 1681 + if (err) 1682 + goto err_txrx_deinit; 1683 + 1676 1684 /* don't start the queues until we have link */ 1677 1685 if (netif_carrier_ok(netdev)) { 1678 1686 err = ionic_start_queues(lif); ··· 1988 1980 .ndo_get_vf_stats = ionic_get_vf_stats, 1989 1981 }; 1990 1982 1991 - int ionic_reset_queues(struct ionic_lif *lif) 1983 + int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg) 1992 1984 { 1993 1985 bool running; 1994 1986 int err = 0; ··· 2001 1993 if (running) { 2002 1994 netif_device_detach(lif->netdev); 2003 1995 err = ionic_stop(lif->netdev); 1996 + if (err) 1997 + goto reset_out; 2004 1998 } 2005 - if (!err && running) { 2006 - ionic_open(lif->netdev); 1999 + 2000 + if (cb) 2001 + cb(lif, arg); 2002 + 2003 + if (running) { 2004 + err = ionic_open(lif->netdev); 2007 2005 netif_device_attach(lif->netdev); 2008 2006 } 2009 2007 2008 + reset_out: 2010 2009 clear_bit(IONIC_LIF_F_QUEUE_RESET, lif->state); 2011 2010 2012 2011 return err;
+3 -1
drivers/net/ethernet/pensando/ionic/ionic_lif.h
··· 248 248 return (units * div) / mult; 249 249 } 250 250 251 + typedef void (*ionic_reset_cb)(struct ionic_lif *lif, void *arg); 252 + 251 253 void ionic_link_status_check_request(struct ionic_lif *lif); 252 254 void ionic_get_stats64(struct net_device *netdev, 253 255 struct rtnl_link_stats64 *ns); ··· 269 267 270 268 int ionic_open(struct net_device *netdev); 271 269 int ionic_stop(struct net_device *netdev); 272 - int ionic_reset_queues(struct ionic_lif *lif); 270 + int ionic_reset_queues(struct ionic_lif *lif, ionic_reset_cb cb, void *arg); 273 271 274 272 static inline void debug_stats_txq_post(struct ionic_qcq *qcq, 275 273 struct ionic_txq_desc *desc, bool dbell)
+2
drivers/net/ethernet/qlogic/qed/qed.h
··· 876 876 struct qed_dbg_feature dbg_features[DBG_FEATURE_NUM]; 877 877 u8 engine_for_debug; 878 878 bool disable_ilt_dump; 879 + bool dbg_bin_dump; 880 + 879 881 DECLARE_HASHTABLE(connections, 10); 880 882 const struct firmware *firmware; 881 883
+16 -1
drivers/net/ethernet/qlogic/qed/qed_debug.c
··· 7506 7506 if (p_hwfn->cdev->print_dbg_data) 7507 7507 qed_dbg_print_feature(text_buf, text_size_bytes); 7508 7508 7509 + /* Just return the original binary buffer if requested */ 7510 + if (p_hwfn->cdev->dbg_bin_dump) { 7511 + vfree(text_buf); 7512 + return DBG_STATUS_OK; 7513 + } 7514 + 7509 7515 /* Free the old dump_buf and point the dump_buf to the newly allocagted 7510 7516 * and formatted text buffer. 7511 7517 */ ··· 7739 7733 #define REGDUMP_HEADER_SIZE_SHIFT 0 7740 7734 #define REGDUMP_HEADER_SIZE_MASK 0xffffff 7741 7735 #define REGDUMP_HEADER_FEATURE_SHIFT 24 7742 - #define REGDUMP_HEADER_FEATURE_MASK 0x3f 7736 + #define REGDUMP_HEADER_FEATURE_MASK 0x1f 7737 + #define REGDUMP_HEADER_BIN_DUMP_SHIFT 29 7738 + #define REGDUMP_HEADER_BIN_DUMP_MASK 0x1 7743 7739 #define REGDUMP_HEADER_OMIT_ENGINE_SHIFT 30 7744 7740 #define REGDUMP_HEADER_OMIT_ENGINE_MASK 0x1 7745 7741 #define REGDUMP_HEADER_ENGINE_SHIFT 31 ··· 7779 7771 feature, feature_size); 7780 7772 7781 7773 SET_FIELD(res, REGDUMP_HEADER_FEATURE, feature); 7774 + SET_FIELD(res, REGDUMP_HEADER_BIN_DUMP, 1); 7782 7775 SET_FIELD(res, REGDUMP_HEADER_OMIT_ENGINE, omit_engine); 7783 7776 SET_FIELD(res, REGDUMP_HEADER_ENGINE, engine); 7784 7777 ··· 7803 7794 omit_engine = 1; 7804 7795 7805 7796 mutex_lock(&qed_dbg_lock); 7797 + cdev->dbg_bin_dump = true; 7806 7798 7807 7799 org_engine = qed_get_debug_engine(cdev); 7808 7800 for (cur_engine = 0; cur_engine < cdev->num_hwfns; cur_engine++) { ··· 7941 7931 DP_ERR(cdev, "qed_dbg_mcp_trace failed. rc = %d\n", rc); 7942 7932 } 7943 7933 7934 + /* Re-populate nvm attribute info */ 7935 + qed_mcp_nvm_info_free(p_hwfn); 7936 + qed_mcp_nvm_info_populate(p_hwfn); 7937 + 7944 7938 /* nvm cfg1 */ 7945 7939 rc = qed_dbg_nvm_image(cdev, 7946 7940 (u8 *)buffer + offset + ··· 8007 7993 QED_NVM_IMAGE_MDUMP, "QED_NVM_IMAGE_MDUMP", rc); 8008 7994 } 8009 7995 7996 + cdev->dbg_bin_dump = false; 8010 7997 mutex_unlock(&qed_dbg_lock); 8011 7998 8012 7999 return 0;
+3 -9
drivers/net/ethernet/qlogic/qed/qed_dev.c
··· 4472 4472 return 0; 4473 4473 } 4474 4474 4475 - static void qed_nvm_info_free(struct qed_hwfn *p_hwfn) 4476 - { 4477 - kfree(p_hwfn->nvm_info.image_att); 4478 - p_hwfn->nvm_info.image_att = NULL; 4479 - } 4480 - 4481 4475 static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn, 4482 4476 void __iomem *p_regview, 4483 4477 void __iomem *p_doorbells, ··· 4556 4562 return rc; 4557 4563 err3: 4558 4564 if (IS_LEAD_HWFN(p_hwfn)) 4559 - qed_nvm_info_free(p_hwfn); 4565 + qed_mcp_nvm_info_free(p_hwfn); 4560 4566 err2: 4561 4567 if (IS_LEAD_HWFN(p_hwfn)) 4562 4568 qed_iov_free_hw_info(p_hwfn->cdev); ··· 4617 4623 if (rc) { 4618 4624 if (IS_PF(cdev)) { 4619 4625 qed_init_free(p_hwfn); 4620 - qed_nvm_info_free(p_hwfn); 4626 + qed_mcp_nvm_info_free(p_hwfn); 4621 4627 qed_mcp_free(p_hwfn); 4622 4628 qed_hw_hwfn_free(p_hwfn); 4623 4629 } ··· 4651 4657 4652 4658 qed_iov_free_hw_info(cdev); 4653 4659 4654 - qed_nvm_info_free(p_hwfn); 4660 + qed_mcp_nvm_info_free(p_hwfn); 4655 4661 } 4656 4662 4657 4663 static void qed_chain_free_next_ptr(struct qed_dev *cdev,
+7
drivers/net/ethernet/qlogic/qed/qed_mcp.c
··· 3280 3280 return rc; 3281 3281 } 3282 3282 3283 + void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn) 3284 + { 3285 + kfree(p_hwfn->nvm_info.image_att); 3286 + p_hwfn->nvm_info.image_att = NULL; 3287 + p_hwfn->nvm_info.valid = false; 3288 + } 3289 + 3283 3290 int 3284 3291 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn, 3285 3292 enum qed_nvm_images image_id,
+7
drivers/net/ethernet/qlogic/qed/qed_mcp.h
··· 1221 1221 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn); 1222 1222 1223 1223 /** 1224 + * @brief Delete nvm info shadow in the given hardware function 1225 + * 1226 + * @param p_hwfn 1227 + */ 1228 + void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn); 1229 + 1230 + /** 1224 1231 * @brief Get the engine affinity configuration. 1225 1232 * 1226 1233 * @param p_hwfn
+13 -5
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
··· 47 47 return 0; 48 48 } 49 49 50 - static int rmnet_register_real_device(struct net_device *real_dev) 50 + static int rmnet_register_real_device(struct net_device *real_dev, 51 + struct netlink_ext_ack *extack) 51 52 { 52 53 struct rmnet_port *port; 53 54 int rc, entry; 54 55 55 56 ASSERT_RTNL(); 56 57 57 - if (rmnet_is_real_dev_registered(real_dev)) 58 + if (rmnet_is_real_dev_registered(real_dev)) { 59 + port = rmnet_get_port_rtnl(real_dev); 60 + if (port->rmnet_mode != RMNET_EPMODE_VND) { 61 + NL_SET_ERR_MSG_MOD(extack, "bridge device already exists"); 62 + return -EINVAL; 63 + } 64 + 58 65 return 0; 66 + } 59 67 60 68 port = kzalloc(sizeof(*port), GFP_KERNEL); 61 69 if (!port) ··· 141 133 142 134 mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]); 143 135 144 - err = rmnet_register_real_device(real_dev); 136 + err = rmnet_register_real_device(real_dev, extack); 145 137 if (err) 146 138 goto err0; 147 139 ··· 430 422 } 431 423 432 424 if (port->rmnet_mode != RMNET_EPMODE_VND) { 433 - NL_SET_ERR_MSG_MOD(extack, "bridge device already exists"); 425 + NL_SET_ERR_MSG_MOD(extack, "more than one bridge dev attached"); 434 426 return -EINVAL; 435 427 } 436 428 ··· 441 433 return -EBUSY; 442 434 } 443 435 444 - err = rmnet_register_real_device(slave_dev); 436 + err = rmnet_register_real_device(slave_dev, extack); 445 437 if (err) 446 438 return -EBUSY; 447 439
+7 -9
drivers/net/ipa/gsi.c
··· 500 500 int ret; 501 501 502 502 state = gsi_channel_state(channel); 503 + 504 + /* Channel could have entered STOPPED state since last call 505 + * if it timed out. If so, we're done. 506 + */ 507 + if (state == GSI_CHANNEL_STATE_STOPPED) 508 + return 0; 509 + 503 510 if (state != GSI_CHANNEL_STATE_STARTED && 504 511 state != GSI_CHANNEL_STATE_STOP_IN_PROC) 505 512 return -EINVAL; ··· 796 789 int gsi_channel_stop(struct gsi *gsi, u32 channel_id) 797 790 { 798 791 struct gsi_channel *channel = &gsi->channel[channel_id]; 799 - enum gsi_channel_state state; 800 792 u32 retries; 801 793 int ret; 802 794 803 795 gsi_channel_freeze(channel); 804 - 805 - /* Channel could have entered STOPPED state since last call if the 806 - * STOP command timed out. We won't stop a channel if stopping it 807 - * was successful previously (so we still want the freeze above). 808 - */ 809 - state = gsi_channel_state(channel); 810 - if (state == GSI_CHANNEL_STATE_STOPPED) 811 - return 0; 812 796 813 797 /* RX channels might require a little time to enter STOPPED state */ 814 798 retries = channel->toward_ipa ? 0 : GSI_CHANNEL_STOP_RX_RETRIES;
+15
drivers/net/ipa/ipa_cmd.c
··· 586 586 return 4; 587 587 } 588 588 589 + void ipa_cmd_tag_process(struct ipa *ipa) 590 + { 591 + u32 count = ipa_cmd_tag_process_count(); 592 + struct gsi_trans *trans; 593 + 594 + trans = ipa_cmd_trans_alloc(ipa, count); 595 + if (trans) { 596 + ipa_cmd_tag_process_add(trans); 597 + gsi_trans_commit_wait(trans); 598 + } else { 599 + dev_err(&ipa->pdev->dev, 600 + "error allocating %u entry tag transaction\n", count); 601 + } 602 + } 603 + 589 604 static struct ipa_cmd_info * 590 605 ipa_cmd_info_alloc(struct ipa_endpoint *endpoint, u32 tre_count) 591 606 {
+8
drivers/net/ipa/ipa_cmd.h
··· 172 172 u32 ipa_cmd_tag_process_count(void); 173 173 174 174 /** 175 + * ipa_cmd_tag_process() - Perform a tag process 176 + * 177 + * @Return: The number of elements to allocate in a transaction 178 + * to hold tag process commands 179 + */ 180 + void ipa_cmd_tag_process(struct ipa *ipa); 181 + 182 + /** 175 183 * ipa_cmd_trans_alloc() - Allocate a transaction for the command TX endpoint 176 184 * @ipa: IPA pointer 177 185 * @tre_count: Number of elements in the transaction
-1
drivers/net/ipa/ipa_data-sdm845.c
··· 44 44 .endpoint = { 45 45 .seq_type = IPA_SEQ_INVALID, 46 46 .config = { 47 - .checksum = true, 48 47 .aggregation = true, 49 48 .status_enable = true, 50 49 .rx = {
+2
drivers/net/ipa/ipa_endpoint.c
··· 1450 1450 if (ipa->modem_netdev) 1451 1451 ipa_modem_suspend(ipa->modem_netdev); 1452 1452 1453 + ipa_cmd_tag_process(ipa); 1454 + 1453 1455 ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]); 1454 1456 ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]); 1455 1457 }
+1
drivers/net/ipa/ipa_gsi.c
··· 6 6 7 7 #include <linux/types.h> 8 8 9 + #include "ipa_gsi.h" 9 10 #include "gsi_trans.h" 10 11 #include "ipa.h" 11 12 #include "ipa_endpoint.h"
+2
drivers/net/ipa/ipa_gsi.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 + struct gsi; 11 12 struct gsi_trans; 13 + struct ipa_gsi_endpoint_data; 12 14 13 15 /** 14 16 * ipa_gsi_trans_complete() - GSI transaction completion callback
+3 -3
drivers/net/ipa/ipa_qmi_msg.c
··· 119 119 sizeof_field(struct ipa_driver_init_complete_rsp, 120 120 rsp), 121 121 .tlv_type = 0x02, 122 - .elem_size = offsetof(struct ipa_driver_init_complete_rsp, 122 + .offset = offsetof(struct ipa_driver_init_complete_rsp, 123 123 rsp), 124 124 .ei_array = qmi_response_type_v01_ei, 125 125 }, ··· 137 137 sizeof_field(struct ipa_init_complete_ind, 138 138 status), 139 139 .tlv_type = 0x02, 140 - .elem_size = offsetof(struct ipa_init_complete_ind, 140 + .offset = offsetof(struct ipa_init_complete_ind, 141 141 status), 142 142 .ei_array = qmi_response_type_v01_ei, 143 143 }, ··· 218 218 sizeof_field(struct ipa_init_modem_driver_req, 219 219 platform_type_valid), 220 220 .tlv_type = 0x10, 221 - .elem_size = offsetof(struct ipa_init_modem_driver_req, 221 + .offset = offsetof(struct ipa_init_modem_driver_req, 222 222 platform_type_valid), 223 223 }, 224 224 {
+2 -3
drivers/net/macsec.c
··· 4052 4052 return err; 4053 4053 4054 4054 netdev_lockdep_set_classes(dev); 4055 - lockdep_set_class_and_subclass(&dev->addr_list_lock, 4056 - &macsec_netdev_addr_lock_key, 4057 - dev->lower_level); 4055 + lockdep_set_class(&dev->addr_list_lock, 4056 + &macsec_netdev_addr_lock_key); 4058 4057 4059 4058 err = netdev_upper_dev_link(real_dev, dev, extack); 4060 4059 if (err < 0)
+2 -3
drivers/net/macvlan.c
··· 880 880 static void macvlan_set_lockdep_class(struct net_device *dev) 881 881 { 882 882 netdev_lockdep_set_classes(dev); 883 - lockdep_set_class_and_subclass(&dev->addr_list_lock, 884 - &macvlan_netdev_addr_lock_key, 885 - dev->lower_level); 883 + lockdep_set_class(&dev->addr_list_lock, 884 + &macvlan_netdev_addr_lock_key); 886 885 } 887 886 888 887 static int macvlan_init(struct net_device *dev)
+2
drivers/net/tun.c
··· 62 62 #include <net/rtnetlink.h> 63 63 #include <net/sock.h> 64 64 #include <net/xdp.h> 65 + #include <net/ip_tunnels.h> 65 66 #include <linux/seq_file.h> 66 67 #include <linux/uio.h> 67 68 #include <linux/skb_array.h> ··· 1352 1351 switch (tun->flags & TUN_TYPE_MASK) { 1353 1352 case IFF_TUN: 1354 1353 dev->netdev_ops = &tun_netdev_ops; 1354 + dev->header_ops = &ip_tunnel_header_ops; 1355 1355 1356 1356 /* Point-to-Point TUN Device */ 1357 1357 dev->hard_header_len = 0;
+1
drivers/net/usb/qmi_wwan.c
··· 1370 1370 {QMI_QUIRK_SET_DTR(0x1e0e, 0x9001, 5)}, /* SIMCom 7100E, 7230E, 7600E ++ */ 1371 1371 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */ 1372 1372 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0191, 4)}, /* Quectel EG91 */ 1373 + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0195, 4)}, /* Quectel EG95 */ 1373 1374 {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */ 1374 1375 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */ 1375 1376 {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */
+8 -1
drivers/net/usb/smsc95xx.c
··· 1287 1287 1288 1288 /* Init all registers */ 1289 1289 ret = smsc95xx_reset(dev); 1290 + if (ret) 1291 + goto free_pdata; 1290 1292 1291 1293 /* detect device revision as different features may be available */ 1292 1294 ret = smsc95xx_read_reg(dev, ID_REV, &val); 1293 1295 if (ret < 0) 1294 - return ret; 1296 + goto free_pdata; 1297 + 1295 1298 val >>= 16; 1296 1299 pdata->chip_id = val; 1297 1300 pdata->mdix_ctrl = get_mdix_status(dev->net); ··· 1320 1317 schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); 1321 1318 1322 1319 return 0; 1320 + 1321 + free_pdata: 1322 + kfree(pdata); 1323 + return ret; 1323 1324 } 1324 1325 1325 1326 static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf)
+8 -1
drivers/net/wan/lapbether.c
··· 303 303 dev->netdev_ops = &lapbeth_netdev_ops; 304 304 dev->needs_free_netdev = true; 305 305 dev->type = ARPHRD_X25; 306 - dev->hard_header_len = 3; 307 306 dev->mtu = 1000; 308 307 dev->addr_len = 0; 309 308 } ··· 322 323 lapbeth_setup); 323 324 if (!ndev) 324 325 goto out; 326 + 327 + /* When transmitting data: 328 + * first this driver removes a pseudo header of 1 byte, 329 + * then the lapb module prepends an LAPB header of at most 3 bytes, 330 + * then this driver prepends a length field of 2 bytes, 331 + * then the underlying Ethernet device prepends its own header. 332 + */ 333 + ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len; 325 334 326 335 lapbeth = netdev_priv(ndev); 327 336 lapbeth->axdev = ndev;
+1
drivers/net/wireguard/device.c
··· 262 262 max(sizeof(struct ipv6hdr), sizeof(struct iphdr)); 263 263 264 264 dev->netdev_ops = &netdev_ops; 265 + dev->header_ops = &ip_tunnel_header_ops; 265 266 dev->hard_header_len = 0; 266 267 dev->addr_len = 0; 267 268 dev->needed_headroom = DATA_PACKET_HEAD_ROOM;
+2 -17
drivers/net/wireguard/queueing.h
··· 11 11 #include <linux/skbuff.h> 12 12 #include <linux/ip.h> 13 13 #include <linux/ipv6.h> 14 + #include <net/ip_tunnels.h> 14 15 15 16 struct wg_device; 16 17 struct wg_peer; ··· 66 65 #define PACKET_CB(skb) ((struct packet_cb *)((skb)->cb)) 67 66 #define PACKET_PEER(skb) (PACKET_CB(skb)->keypair->entry.peer) 68 67 69 - /* Returns either the correct skb->protocol value, or 0 if invalid. */ 70 - static inline __be16 wg_examine_packet_protocol(struct sk_buff *skb) 71 - { 72 - if (skb_network_header(skb) >= skb->head && 73 - (skb_network_header(skb) + sizeof(struct iphdr)) <= 74 - skb_tail_pointer(skb) && 75 - ip_hdr(skb)->version == 4) 76 - return htons(ETH_P_IP); 77 - if (skb_network_header(skb) >= skb->head && 78 - (skb_network_header(skb) + sizeof(struct ipv6hdr)) <= 79 - skb_tail_pointer(skb) && 80 - ipv6_hdr(skb)->version == 6) 81 - return htons(ETH_P_IPV6); 82 - return 0; 83 - } 84 - 85 68 static inline bool wg_check_packet_protocol(struct sk_buff *skb) 86 69 { 87 - __be16 real_protocol = wg_examine_packet_protocol(skb); 70 + __be16 real_protocol = ip_tunnel_parse_protocol(skb); 88 71 return real_protocol && skb->protocol == real_protocol; 89 72 } 90 73
+1 -1
drivers/net/wireguard/receive.c
··· 387 387 */ 388 388 skb->ip_summed = CHECKSUM_UNNECESSARY; 389 389 skb->csum_level = ~0; /* All levels */ 390 - skb->protocol = wg_examine_packet_protocol(skb); 390 + skb->protocol = ip_tunnel_parse_protocol(skb); 391 391 if (skb->protocol == htons(ETH_P_IP)) { 392 392 len = ntohs(ip_hdr(skb)->tot_len); 393 393 if (unlikely(len < sizeof(struct iphdr)))
+3 -2
include/linux/bpf-netns.h
··· 33 33 union bpf_attr __user *uattr); 34 34 int netns_bpf_prog_attach(const union bpf_attr *attr, 35 35 struct bpf_prog *prog); 36 - int netns_bpf_prog_detach(const union bpf_attr *attr); 36 + int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype); 37 37 int netns_bpf_link_create(const union bpf_attr *attr, 38 38 struct bpf_prog *prog); 39 39 #else ··· 49 49 return -EOPNOTSUPP; 50 50 } 51 51 52 - static inline int netns_bpf_prog_detach(const union bpf_attr *attr) 52 + static inline int netns_bpf_prog_detach(const union bpf_attr *attr, 53 + enum bpf_prog_type ptype) 53 54 { 54 55 return -EOPNOTSUPP; 55 56 }
+11 -2
include/linux/bpf.h
··· 1543 1543 #endif /* CONFIG_NET && CONFIG_BPF_SYSCALL */ 1544 1544 1545 1545 #if defined(CONFIG_BPF_STREAM_PARSER) 1546 - int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog, u32 which); 1546 + int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog, 1547 + struct bpf_prog *old, u32 which); 1547 1548 int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog); 1549 + int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype); 1548 1550 void sock_map_unhash(struct sock *sk); 1549 1551 void sock_map_close(struct sock *sk, long timeout); 1550 1552 #else 1551 1553 static inline int sock_map_prog_update(struct bpf_map *map, 1552 - struct bpf_prog *prog, u32 which) 1554 + struct bpf_prog *prog, 1555 + struct bpf_prog *old, u32 which) 1553 1556 { 1554 1557 return -EOPNOTSUPP; 1555 1558 } ··· 1561 1558 struct bpf_prog *prog) 1562 1559 { 1563 1560 return -EINVAL; 1561 + } 1562 + 1563 + static inline int sock_map_prog_detach(const union bpf_attr *attr, 1564 + enum bpf_prog_type ptype) 1565 + { 1566 + return -EOPNOTSUPP; 1564 1567 } 1565 1568 #endif /* CONFIG_BPF_STREAM_PARSER */ 1566 1569
+5
include/linux/btf.h
··· 82 82 return BTF_INFO_KIND(t->info) == BTF_KIND_INT; 83 83 } 84 84 85 + static inline bool btf_type_is_small_int(const struct btf_type *t) 86 + { 87 + return btf_type_is_int(t) && t->size <= sizeof(u64); 88 + } 89 + 85 90 static inline bool btf_type_is_enum(const struct btf_type *t) 86 91 { 87 92 return BTF_INFO_KIND(t->info) == BTF_KIND_ENUM;
+6 -2
include/linux/cgroup-defs.h
··· 790 790 union { 791 791 #ifdef __LITTLE_ENDIAN 792 792 struct { 793 - u8 is_data; 793 + u8 is_data : 1; 794 + u8 no_refcnt : 1; 795 + u8 unused : 6; 794 796 u8 padding; 795 797 u16 prioidx; 796 798 u32 classid; ··· 802 800 u32 classid; 803 801 u16 prioidx; 804 802 u8 padding; 805 - u8 is_data; 803 + u8 unused : 6; 804 + u8 no_refcnt : 1; 805 + u8 is_data : 1; 806 806 } __packed; 807 807 #endif 808 808 u64 val;
+3 -1
include/linux/cgroup.h
··· 822 822 823 823 void cgroup_sk_alloc_disable(void); 824 824 void cgroup_sk_alloc(struct sock_cgroup_data *skcd); 825 + void cgroup_sk_clone(struct sock_cgroup_data *skcd); 825 826 void cgroup_sk_free(struct sock_cgroup_data *skcd); 826 827 827 828 static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd) ··· 836 835 */ 837 836 v = READ_ONCE(skcd->val); 838 837 839 - if (v & 1) 838 + if (v & 3) 840 839 return &cgrp_dfl_root.cgrp; 841 840 842 841 return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp; ··· 848 847 #else /* CONFIG_CGROUP_DATA */ 849 848 850 849 static inline void cgroup_sk_alloc(struct sock_cgroup_data *skcd) {} 850 + static inline void cgroup_sk_clone(struct sock_cgroup_data *skcd) {} 851 851 static inline void cgroup_sk_free(struct sock_cgroup_data *skcd) {} 852 852 853 853 #endif /* CONFIG_CGROUP_DATA */
+1
include/linux/dma-direct.h
··· 85 85 void *cpu_addr, dma_addr_t dma_addr, size_t size, 86 86 unsigned long attrs); 87 87 int dma_direct_supported(struct device *dev, u64 mask); 88 + bool dma_direct_need_sync(struct device *dev, dma_addr_t dma_addr); 88 89 #endif /* _LINUX_DMA_DIRECT_H */
+5
include/linux/dma-mapping.h
··· 461 461 int dma_set_coherent_mask(struct device *dev, u64 mask); 462 462 u64 dma_get_required_mask(struct device *dev); 463 463 size_t dma_max_mapping_size(struct device *dev); 464 + bool dma_need_sync(struct device *dev, dma_addr_t dma_addr); 464 465 unsigned long dma_get_merge_boundary(struct device *dev); 465 466 #else /* CONFIG_HAS_DMA */ 466 467 static inline dma_addr_t dma_map_page_attrs(struct device *dev, ··· 571 570 static inline size_t dma_max_mapping_size(struct device *dev) 572 571 { 573 572 return 0; 573 + } 574 + static inline bool dma_need_sync(struct device *dev, dma_addr_t dma_addr) 575 + { 576 + return false; 574 577 } 575 578 static inline unsigned long dma_get_merge_boundary(struct device *dev) 576 579 {
+4
include/linux/ieee80211.h
··· 3333 3333 #define WLAN_AKM_SUITE_TDLS SUITE(0x000FAC, 7) 3334 3334 #define WLAN_AKM_SUITE_SAE SUITE(0x000FAC, 8) 3335 3335 #define WLAN_AKM_SUITE_FT_OVER_SAE SUITE(0x000FAC, 9) 3336 + #define WLAN_AKM_SUITE_AP_PEER_KEY SUITE(0x000FAC, 10) 3336 3337 #define WLAN_AKM_SUITE_8021X_SUITE_B SUITE(0x000FAC, 11) 3337 3338 #define WLAN_AKM_SUITE_8021X_SUITE_B_192 SUITE(0x000FAC, 12) 3339 + #define WLAN_AKM_SUITE_FT_8021X_SHA384 SUITE(0x000FAC, 13) 3338 3340 #define WLAN_AKM_SUITE_FILS_SHA256 SUITE(0x000FAC, 14) 3339 3341 #define WLAN_AKM_SUITE_FILS_SHA384 SUITE(0x000FAC, 15) 3340 3342 #define WLAN_AKM_SUITE_FT_FILS_SHA256 SUITE(0x000FAC, 16) 3341 3343 #define WLAN_AKM_SUITE_FT_FILS_SHA384 SUITE(0x000FAC, 17) 3342 3344 #define WLAN_AKM_SUITE_OWE SUITE(0x000FAC, 18) 3345 + #define WLAN_AKM_SUITE_FT_PSK_SHA384 SUITE(0x000FAC, 19) 3346 + #define WLAN_AKM_SUITE_PSK_SHA384 SUITE(0x000FAC, 20) 3343 3347 3344 3348 #define WLAN_MAX_KEY_LEN 32 3345 3349
+22 -7
include/linux/if_vlan.h
··· 25 25 #define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */ 26 26 #define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */ 27 27 28 + #define VLAN_MAX_DEPTH 8 /* Max. number of nested VLAN tags parsed */ 29 + 28 30 /* 29 31 * struct vlan_hdr - vlan header 30 32 * @h_vlan_TCI: priority and VLAN ID ··· 579 577 * Returns the EtherType of the packet, regardless of whether it is 580 578 * vlan encapsulated (normal or hardware accelerated) or not. 581 579 */ 582 - static inline __be16 __vlan_get_protocol(struct sk_buff *skb, __be16 type, 580 + static inline __be16 __vlan_get_protocol(const struct sk_buff *skb, __be16 type, 583 581 int *depth) 584 582 { 585 - unsigned int vlan_depth = skb->mac_len; 583 + unsigned int vlan_depth = skb->mac_len, parse_depth = VLAN_MAX_DEPTH; 586 584 587 585 /* if type is 802.1Q/AD then the header should already be 588 586 * present at mac_len - VLAN_HLEN (if mac_len > 0), or at ··· 597 595 vlan_depth = ETH_HLEN; 598 596 } 599 597 do { 600 - struct vlan_hdr *vh; 598 + struct vlan_hdr vhdr, *vh; 601 599 602 - if (unlikely(!pskb_may_pull(skb, 603 - vlan_depth + VLAN_HLEN))) 600 + vh = skb_header_pointer(skb, vlan_depth, sizeof(vhdr), &vhdr); 601 + if (unlikely(!vh || !--parse_depth)) 604 602 return 0; 605 603 606 - vh = (struct vlan_hdr *)(skb->data + vlan_depth); 607 604 type = vh->h_vlan_encapsulated_proto; 608 605 vlan_depth += VLAN_HLEN; 609 606 } while (eth_type_vlan(type)); ··· 621 620 * Returns the EtherType of the packet, regardless of whether it is 622 621 * vlan encapsulated (normal or hardware accelerated) or not. 623 622 */ 624 - static inline __be16 vlan_get_protocol(struct sk_buff *skb) 623 + static inline __be16 vlan_get_protocol(const struct sk_buff *skb) 625 624 { 626 625 return __vlan_get_protocol(skb, skb->protocol, NULL); 626 + } 627 + 628 + /* A getter for the SKB protocol field which will handle VLAN tags consistently 629 + * whether VLAN acceleration is enabled or not. 630 + */ 631 + static inline __be16 skb_protocol(const struct sk_buff *skb, bool skip_vlan) 632 + { 633 + if (!skip_vlan) 634 + /* VLAN acceleration strips the VLAN header from the skb and 635 + * moves it to skb->vlan_proto 636 + */ 637 + return skb_vlan_tag_present(skb) ? skb->vlan_proto : skb->protocol; 638 + 639 + return vlan_get_protocol(skb); 627 640 } 628 641 629 642 static inline void vlan_set_encap_proto(struct sk_buff *skb,
+1
include/linux/mlx5/driver.h
··· 147 147 MLX5_REG_MCDA = 0x9063, 148 148 MLX5_REG_MCAM = 0x907f, 149 149 MLX5_REG_MIRC = 0x9162, 150 + MLX5_REG_SBCAM = 0xB01F, 150 151 MLX5_REG_RESOURCE_DUMP = 0xC000, 151 152 }; 152 153
+28
include/linux/mlx5/mlx5_ifc.h
··· 9960 9960 u8 untagged_buff[0x4]; 9961 9961 }; 9962 9962 9963 + struct mlx5_ifc_sbcam_reg_bits { 9964 + u8 reserved_at_0[0x8]; 9965 + u8 feature_group[0x8]; 9966 + u8 reserved_at_10[0x8]; 9967 + u8 access_reg_group[0x8]; 9968 + 9969 + u8 reserved_at_20[0x20]; 9970 + 9971 + u8 sb_access_reg_cap_mask[4][0x20]; 9972 + 9973 + u8 reserved_at_c0[0x80]; 9974 + 9975 + u8 sb_feature_cap_mask[4][0x20]; 9976 + 9977 + u8 reserved_at_1c0[0x40]; 9978 + 9979 + u8 cap_total_buffer_size[0x20]; 9980 + 9981 + u8 cap_cell_size[0x10]; 9982 + u8 cap_max_pg_buffers[0x8]; 9983 + u8 cap_num_pool_supported[0x8]; 9984 + 9985 + u8 reserved_at_240[0x8]; 9986 + u8 cap_sbsr_stat_size[0x8]; 9987 + u8 cap_max_tclass_data[0x8]; 9988 + u8 cap_max_cpu_ingress_tclass_sb[0x8]; 9989 + }; 9990 + 9963 9991 struct mlx5_ifc_pbmc_reg_bits { 9964 9992 u8 reserved_at_0[0x8]; 9965 9993 u8 local_port[0x8];
+13
include/linux/skmsg.h
··· 430 430 bpf_prog_put(prog); 431 431 } 432 432 433 + static inline int psock_replace_prog(struct bpf_prog **pprog, 434 + struct bpf_prog *prog, 435 + struct bpf_prog *old) 436 + { 437 + if (cmpxchg(pprog, old, prog) != old) 438 + return -ENOENT; 439 + 440 + if (old) 441 + bpf_prog_put(old); 442 + 443 + return 0; 444 + } 445 + 433 446 static inline void psock_progs_drop(struct sk_psock_progs *progs) 434 447 { 435 448 psock_set_prog(&progs->msg_parser, NULL);
+9 -1
include/net/dst.h
··· 400 400 static inline struct neighbour *dst_neigh_lookup_skb(const struct dst_entry *dst, 401 401 struct sk_buff *skb) 402 402 { 403 - struct neighbour *n = dst->ops->neigh_lookup(dst, skb, NULL); 403 + struct neighbour *n = NULL; 404 + 405 + /* The packets from tunnel devices (eg bareudp) may have only 406 + * metadata in the dst pointer of skb. Hence a pointer check of 407 + * neigh_lookup is needed. 408 + */ 409 + if (dst->ops->neigh_lookup) 410 + n = dst->ops->neigh_lookup(dst, skb, NULL); 411 + 404 412 return IS_ERR(n) ? NULL : n; 405 413 } 406 414
+2 -1
include/net/flow_dissector.h
··· 372 372 } 373 373 374 374 #ifdef CONFIG_BPF_SYSCALL 375 - int flow_dissector_bpf_prog_attach(struct net *net, struct bpf_prog *prog); 375 + int flow_dissector_bpf_prog_attach_check(struct net *net, 376 + struct bpf_prog *prog); 376 377 #endif /* CONFIG_BPF_SYSCALL */ 377 378 378 379 #endif
-10
include/net/genetlink.h
··· 35 35 * do additional, common, filtering and return an error 36 36 * @post_doit: called after an operation's doit callback, it may 37 37 * undo operations done by pre_doit, for example release locks 38 - * @mcast_bind: a socket bound to the given multicast group (which 39 - * is given as the offset into the groups array) 40 - * @mcast_unbind: a socket was unbound from the given multicast group. 41 - * Note that unbind() will not be called symmetrically if the 42 - * generic netlink family is removed while there are still open 43 - * sockets. 44 - * @attrbuf: buffer to store parsed attributes (private) 45 38 * @mcgrps: multicast groups used by this family 46 39 * @n_mcgrps: number of multicast groups 47 40 * @mcgrp_offset: starting number of multicast group IDs in this family ··· 57 64 void (*post_doit)(const struct genl_ops *ops, 58 65 struct sk_buff *skb, 59 66 struct genl_info *info); 60 - int (*mcast_bind)(struct net *net, int group); 61 - void (*mcast_unbind)(struct net *net, int group); 62 - struct nlattr ** attrbuf; /* private */ 63 67 const struct genl_ops * ops; 64 68 const struct genl_multicast_group *mcgrps; 65 69 unsigned int n_ops;
+17 -8
include/net/inet_ecn.h
··· 4 4 5 5 #include <linux/ip.h> 6 6 #include <linux/skbuff.h> 7 + #include <linux/if_vlan.h> 7 8 8 9 #include <net/inet_sock.h> 9 10 #include <net/dsfield.h> ··· 173 172 174 173 static inline int INET_ECN_set_ce(struct sk_buff *skb) 175 174 { 176 - switch (skb->protocol) { 175 + switch (skb_protocol(skb, true)) { 177 176 case cpu_to_be16(ETH_P_IP): 178 177 if (skb_network_header(skb) + sizeof(struct iphdr) <= 179 178 skb_tail_pointer(skb)) ··· 192 191 193 192 static inline int INET_ECN_set_ect1(struct sk_buff *skb) 194 193 { 195 - switch (skb->protocol) { 194 + switch (skb_protocol(skb, true)) { 196 195 case cpu_to_be16(ETH_P_IP): 197 196 if (skb_network_header(skb) + sizeof(struct iphdr) <= 198 197 skb_tail_pointer(skb)) ··· 273 272 { 274 273 __u8 inner; 275 274 276 - if (skb->protocol == htons(ETH_P_IP)) 275 + switch (skb_protocol(skb, true)) { 276 + case htons(ETH_P_IP): 277 277 inner = ip_hdr(skb)->tos; 278 - else if (skb->protocol == htons(ETH_P_IPV6)) 278 + break; 279 + case htons(ETH_P_IPV6): 279 280 inner = ipv6_get_dsfield(ipv6_hdr(skb)); 280 - else 281 + break; 282 + default: 281 283 return 0; 284 + } 282 285 283 286 return INET_ECN_decapsulate(skb, oiph->tos, inner); 284 287 } ··· 292 287 { 293 288 __u8 inner; 294 289 295 - if (skb->protocol == htons(ETH_P_IP)) 290 + switch (skb_protocol(skb, true)) { 291 + case htons(ETH_P_IP): 296 292 inner = ip_hdr(skb)->tos; 297 - else if (skb->protocol == htons(ETH_P_IPV6)) 293 + break; 294 + case htons(ETH_P_IPV6): 298 295 inner = ipv6_get_dsfield(ipv6_hdr(skb)); 299 - else 296 + break; 297 + default: 300 298 return 0; 299 + } 301 300 302 301 return INET_ECN_decapsulate(skb, ipv6_get_dsfield(oipv6h), inner); 303 302 }
+3
include/net/ip_tunnels.h
··· 290 290 struct ip_tunnel_parm *p, __u32 fwmark); 291 291 void ip_tunnel_setup(struct net_device *dev, unsigned int net_id); 292 292 293 + extern const struct header_ops ip_tunnel_header_ops; 294 + __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb); 295 + 293 296 struct ip_tunnel_encap_ops { 294 297 size_t (*encap_hlen)(struct ip_tunnel_encap *e); 295 298 int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e,
+5 -2
include/net/netns/bpf.h
··· 9 9 #include <linux/bpf-netns.h> 10 10 11 11 struct bpf_prog; 12 + struct bpf_prog_array; 12 13 13 14 struct netns_bpf { 14 - struct bpf_prog __rcu *progs[MAX_NETNS_BPF_ATTACH_TYPE]; 15 - struct bpf_link *links[MAX_NETNS_BPF_ATTACH_TYPE]; 15 + /* Array of programs to run compiled from progs or links */ 16 + struct bpf_prog_array __rcu *run_array[MAX_NETNS_BPF_ATTACH_TYPE]; 17 + struct bpf_prog *progs[MAX_NETNS_BPF_ATTACH_TYPE]; 18 + struct list_head links[MAX_NETNS_BPF_ATTACH_TYPE]; 16 19 }; 17 20 18 21 #endif /* __NETNS_BPF_H__ */
-11
include/net/pkt_sched.h
··· 136 136 } 137 137 } 138 138 139 - static inline __be16 tc_skb_protocol(const struct sk_buff *skb) 140 - { 141 - /* We need to take extra care in case the skb came via 142 - * vlan accelerated path. In that case, use skb->vlan_proto 143 - * as the original vlan header was already stripped. 144 - */ 145 - if (skb_vlan_tag_present(skb)) 146 - return skb->vlan_proto; 147 - return skb->protocol; 148 - } 149 - 150 139 /* Calculate maximal size of packet seen by hard_start_xmit 151 140 routine of this device. 152 141 */
+2 -1
include/net/sock.h
··· 533 533 * be copied. 534 534 */ 535 535 #define SK_USER_DATA_NOCOPY 1UL 536 - #define SK_USER_DATA_PTRMASK ~(SK_USER_DATA_NOCOPY) 536 + #define SK_USER_DATA_BPF 2UL /* Managed by BPF */ 537 + #define SK_USER_DATA_PTRMASK ~(SK_USER_DATA_NOCOPY | SK_USER_DATA_BPF) 537 538 538 539 /** 539 540 * sk_user_data_is_nocopy - Test if sk_user_data pointer must not be copied
+3 -3
include/net/xsk_buff_pool.h
··· 40 40 u32 headroom; 41 41 u32 chunk_size; 42 42 u32 frame_len; 43 - bool cheap_dma; 43 + bool dma_need_sync; 44 44 bool unaligned; 45 45 void *addrs; 46 46 struct device *dev; ··· 80 80 void xp_dma_sync_for_cpu_slow(struct xdp_buff_xsk *xskb); 81 81 static inline void xp_dma_sync_for_cpu(struct xdp_buff_xsk *xskb) 82 82 { 83 - if (xskb->pool->cheap_dma) 83 + if (!xskb->pool->dma_need_sync) 84 84 return; 85 85 86 86 xp_dma_sync_for_cpu_slow(xskb); ··· 91 91 static inline void xp_dma_sync_for_device(struct xsk_buff_pool *pool, 92 92 dma_addr_t dma, size_t size) 93 93 { 94 - if (pool->cheap_dma) 94 + if (!pool->dma_need_sync) 95 95 return; 96 96 97 97 xp_dma_sync_for_device_slow(pool, dma, size);
+21 -20
include/uapi/linux/bpf.h
··· 3171 3171 * int bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) 3172 3172 * Description 3173 3173 * Copy *size* bytes from *data* into a ring buffer *ringbuf*. 3174 - * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of 3175 - * new data availability is sent. 3176 - * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of 3177 - * new data availability is sent unconditionally. 3174 + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 3175 + * of new data availability is sent. 3176 + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 3177 + * of new data availability is sent unconditionally. 3178 3178 * Return 3179 - * 0, on success; 3180 - * < 0, on error. 3179 + * 0 on success, or a negative error in case of failure. 3181 3180 * 3182 3181 * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags) 3183 3182 * Description ··· 3188 3189 * void bpf_ringbuf_submit(void *data, u64 flags) 3189 3190 * Description 3190 3191 * Submit reserved ring buffer sample, pointed to by *data*. 3191 - * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of 3192 - * new data availability is sent. 3193 - * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of 3194 - * new data availability is sent unconditionally. 3192 + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 3193 + * of new data availability is sent. 3194 + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 3195 + * of new data availability is sent unconditionally. 3195 3196 * Return 3196 3197 * Nothing. Always succeeds. 3197 3198 * 3198 3199 * void bpf_ringbuf_discard(void *data, u64 flags) 3199 3200 * Description 3200 3201 * Discard reserved ring buffer sample, pointed to by *data*. 3201 - * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of 3202 - * new data availability is sent. 3203 - * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of 3204 - * new data availability is sent unconditionally. 3202 + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 3203 + * of new data availability is sent. 3204 + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 3205 + * of new data availability is sent unconditionally. 3205 3206 * Return 3206 3207 * Nothing. Always succeeds. 3207 3208 * ··· 3209 3210 * Description 3210 3211 * Query various characteristics of provided ring buffer. What 3211 3212 * exactly is queries is determined by *flags*: 3212 - * - BPF_RB_AVAIL_DATA - amount of data not yet consumed; 3213 - * - BPF_RB_RING_SIZE - the size of ring buffer; 3214 - * - BPF_RB_CONS_POS - consumer position (can wrap around); 3215 - * - BPF_RB_PROD_POS - producer(s) position (can wrap around); 3216 - * Data returned is just a momentary snapshots of actual values 3213 + * 3214 + * * **BPF_RB_AVAIL_DATA**: Amount of data not yet consumed. 3215 + * * **BPF_RB_RING_SIZE**: The size of ring buffer. 3216 + * * **BPF_RB_CONS_POS**: Consumer position (can wrap around). 3217 + * * **BPF_RB_PROD_POS**: Producer(s) position (can wrap around). 3218 + * 3219 + * Data returned is just a momentary snapshot of actual values 3217 3220 * and could be inaccurate, so this facility should be used to 3218 3221 * power heuristics and for reporting, not to make 100% correct 3219 3222 * calculation. 3220 3223 * Return 3221 - * Requested value, or 0, if flags are not recognized. 3224 + * Requested value, or 0, if *flags* are not recognized. 3222 3225 * 3223 3226 * int bpf_csum_level(struct sk_buff *skb, u64 level) 3224 3227 * Description
+2 -2
kernel/bpf/btf.c
··· 3746 3746 return false; 3747 3747 3748 3748 t = btf_type_skip_modifiers(btf, t->type, NULL); 3749 - if (!btf_type_is_int(t)) { 3749 + if (!btf_type_is_small_int(t)) { 3750 3750 bpf_log(log, 3751 3751 "ret type %s not allowed for fmod_ret\n", 3752 3752 btf_kind_str[BTF_INFO_KIND(t->info)]); ··· 3768 3768 /* skip modifiers */ 3769 3769 while (btf_type_is_modifier(t)) 3770 3770 t = btf_type_by_id(btf, t->type); 3771 - if (btf_type_is_int(t) || btf_type_is_enum(t)) 3771 + if (btf_type_is_small_int(t) || btf_type_is_enum(t)) 3772 3772 /* accessing a scalar */ 3773 3773 return true; 3774 3774 if (!btf_type_is_ptr(t)) {
+134 -60
kernel/bpf/net_namespace.c
··· 19 19 * with netns_bpf_mutex held. 20 20 */ 21 21 struct net *net; 22 + struct list_head node; /* node in list of links attached to net */ 22 23 }; 23 24 24 25 /* Protects updates to netns_bpf */ 25 26 DEFINE_MUTEX(netns_bpf_mutex); 26 27 27 28 /* Must be called with netns_bpf_mutex held. */ 28 - static void __net_exit bpf_netns_link_auto_detach(struct bpf_link *link) 29 + static void netns_bpf_run_array_detach(struct net *net, 30 + enum netns_bpf_attach_type type) 29 31 { 30 - struct bpf_netns_link *net_link = 31 - container_of(link, struct bpf_netns_link, link); 32 + struct bpf_prog_array *run_array; 32 33 33 - net_link->net = NULL; 34 + run_array = rcu_replace_pointer(net->bpf.run_array[type], NULL, 35 + lockdep_is_held(&netns_bpf_mutex)); 36 + bpf_prog_array_free(run_array); 34 37 } 35 38 36 39 static void bpf_netns_link_release(struct bpf_link *link) ··· 43 40 enum netns_bpf_attach_type type = net_link->netns_type; 44 41 struct net *net; 45 42 46 - /* Link auto-detached by dying netns. */ 47 - if (!net_link->net) 48 - return; 49 - 50 43 mutex_lock(&netns_bpf_mutex); 51 44 52 - /* Recheck after potential sleep. We can race with cleanup_net 53 - * here, but if we see a non-NULL struct net pointer pre_exit 54 - * has not happened yet and will block on netns_bpf_mutex. 45 + /* We can race with cleanup_net, but if we see a non-NULL 46 + * struct net pointer, pre_exit has not run yet and wait for 47 + * netns_bpf_mutex. 55 48 */ 56 49 net = net_link->net; 57 50 if (!net) 58 51 goto out_unlock; 59 52 60 - net->bpf.links[type] = NULL; 61 - RCU_INIT_POINTER(net->bpf.progs[type], NULL); 53 + netns_bpf_run_array_detach(net, type); 54 + list_del(&net_link->node); 62 55 63 56 out_unlock: 64 57 mutex_unlock(&netns_bpf_mutex); ··· 75 76 struct bpf_netns_link *net_link = 76 77 container_of(link, struct bpf_netns_link, link); 77 78 enum netns_bpf_attach_type type = net_link->netns_type; 79 + struct bpf_prog_array *run_array; 78 80 struct net *net; 79 81 int ret = 0; 80 82 ··· 93 93 goto out_unlock; 94 94 } 95 95 96 + run_array = rcu_dereference_protected(net->bpf.run_array[type], 97 + lockdep_is_held(&netns_bpf_mutex)); 98 + WRITE_ONCE(run_array->items[0].prog, new_prog); 99 + 96 100 old_prog = xchg(&link->prog, new_prog); 97 - rcu_assign_pointer(net->bpf.progs[type], new_prog); 98 101 bpf_prog_put(old_prog); 99 102 100 103 out_unlock: ··· 145 142 .show_fdinfo = bpf_netns_link_show_fdinfo, 146 143 }; 147 144 145 + /* Must be called with netns_bpf_mutex held. */ 146 + static int __netns_bpf_prog_query(const union bpf_attr *attr, 147 + union bpf_attr __user *uattr, 148 + struct net *net, 149 + enum netns_bpf_attach_type type) 150 + { 151 + __u32 __user *prog_ids = u64_to_user_ptr(attr->query.prog_ids); 152 + struct bpf_prog_array *run_array; 153 + u32 prog_cnt = 0, flags = 0; 154 + 155 + run_array = rcu_dereference_protected(net->bpf.run_array[type], 156 + lockdep_is_held(&netns_bpf_mutex)); 157 + if (run_array) 158 + prog_cnt = bpf_prog_array_length(run_array); 159 + 160 + if (copy_to_user(&uattr->query.attach_flags, &flags, sizeof(flags))) 161 + return -EFAULT; 162 + if (copy_to_user(&uattr->query.prog_cnt, &prog_cnt, sizeof(prog_cnt))) 163 + return -EFAULT; 164 + if (!attr->query.prog_cnt || !prog_ids || !prog_cnt) 165 + return 0; 166 + 167 + return bpf_prog_array_copy_to_user(run_array, prog_ids, 168 + attr->query.prog_cnt); 169 + } 170 + 148 171 int netns_bpf_prog_query(const union bpf_attr *attr, 149 172 union bpf_attr __user *uattr) 150 173 { 151 - __u32 __user *prog_ids = u64_to_user_ptr(attr->query.prog_ids); 152 - u32 prog_id, prog_cnt = 0, flags = 0; 153 174 enum netns_bpf_attach_type type; 154 - struct bpf_prog *attached; 155 175 struct net *net; 176 + int ret; 156 177 157 178 if (attr->query.query_flags) 158 179 return -EINVAL; ··· 189 162 if (IS_ERR(net)) 190 163 return PTR_ERR(net); 191 164 192 - rcu_read_lock(); 193 - attached = rcu_dereference(net->bpf.progs[type]); 194 - if (attached) { 195 - prog_cnt = 1; 196 - prog_id = attached->aux->id; 197 - } 198 - rcu_read_unlock(); 165 + mutex_lock(&netns_bpf_mutex); 166 + ret = __netns_bpf_prog_query(attr, uattr, net, type); 167 + mutex_unlock(&netns_bpf_mutex); 199 168 200 169 put_net(net); 201 - 202 - if (copy_to_user(&uattr->query.attach_flags, &flags, sizeof(flags))) 203 - return -EFAULT; 204 - if (copy_to_user(&uattr->query.prog_cnt, &prog_cnt, sizeof(prog_cnt))) 205 - return -EFAULT; 206 - 207 - if (!attr->query.prog_cnt || !prog_ids || !prog_cnt) 208 - return 0; 209 - 210 - if (copy_to_user(prog_ids, &prog_id, sizeof(u32))) 211 - return -EFAULT; 212 - 213 - return 0; 170 + return ret; 214 171 } 215 172 216 173 int netns_bpf_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog) 217 174 { 175 + struct bpf_prog_array *run_array; 218 176 enum netns_bpf_attach_type type; 177 + struct bpf_prog *attached; 219 178 struct net *net; 220 179 int ret; 180 + 181 + if (attr->target_fd || attr->attach_flags || attr->replace_bpf_fd) 182 + return -EINVAL; 221 183 222 184 type = to_netns_bpf_attach_type(attr->attach_type); 223 185 if (type < 0) ··· 216 200 mutex_lock(&netns_bpf_mutex); 217 201 218 202 /* Attaching prog directly is not compatible with links */ 219 - if (net->bpf.links[type]) { 203 + if (!list_empty(&net->bpf.links[type])) { 220 204 ret = -EEXIST; 221 205 goto out_unlock; 222 206 } 223 207 224 208 switch (type) { 225 209 case NETNS_BPF_FLOW_DISSECTOR: 226 - ret = flow_dissector_bpf_prog_attach(net, prog); 210 + ret = flow_dissector_bpf_prog_attach_check(net, prog); 227 211 break; 228 212 default: 229 213 ret = -EINVAL; 230 214 break; 231 215 } 216 + if (ret) 217 + goto out_unlock; 218 + 219 + attached = net->bpf.progs[type]; 220 + if (attached == prog) { 221 + /* The same program cannot be attached twice */ 222 + ret = -EINVAL; 223 + goto out_unlock; 224 + } 225 + 226 + run_array = rcu_dereference_protected(net->bpf.run_array[type], 227 + lockdep_is_held(&netns_bpf_mutex)); 228 + if (run_array) { 229 + WRITE_ONCE(run_array->items[0].prog, prog); 230 + } else { 231 + run_array = bpf_prog_array_alloc(1, GFP_KERNEL); 232 + if (!run_array) { 233 + ret = -ENOMEM; 234 + goto out_unlock; 235 + } 236 + run_array->items[0].prog = prog; 237 + rcu_assign_pointer(net->bpf.run_array[type], run_array); 238 + } 239 + 240 + net->bpf.progs[type] = prog; 241 + if (attached) 242 + bpf_prog_put(attached); 243 + 232 244 out_unlock: 233 245 mutex_unlock(&netns_bpf_mutex); 234 246 ··· 265 221 266 222 /* Must be called with netns_bpf_mutex held. */ 267 223 static int __netns_bpf_prog_detach(struct net *net, 268 - enum netns_bpf_attach_type type) 224 + enum netns_bpf_attach_type type, 225 + struct bpf_prog *old) 269 226 { 270 227 struct bpf_prog *attached; 271 228 272 229 /* Progs attached via links cannot be detached */ 273 - if (net->bpf.links[type]) 230 + if (!list_empty(&net->bpf.links[type])) 274 231 return -EINVAL; 275 232 276 - attached = rcu_dereference_protected(net->bpf.progs[type], 277 - lockdep_is_held(&netns_bpf_mutex)); 278 - if (!attached) 233 + attached = net->bpf.progs[type]; 234 + if (!attached || attached != old) 279 235 return -ENOENT; 280 - RCU_INIT_POINTER(net->bpf.progs[type], NULL); 236 + netns_bpf_run_array_detach(net, type); 237 + net->bpf.progs[type] = NULL; 281 238 bpf_prog_put(attached); 282 239 return 0; 283 240 } 284 241 285 - int netns_bpf_prog_detach(const union bpf_attr *attr) 242 + int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype) 286 243 { 287 244 enum netns_bpf_attach_type type; 245 + struct bpf_prog *prog; 288 246 int ret; 247 + 248 + if (attr->target_fd) 249 + return -EINVAL; 289 250 290 251 type = to_netns_bpf_attach_type(attr->attach_type); 291 252 if (type < 0) 292 253 return -EINVAL; 293 254 255 + prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype); 256 + if (IS_ERR(prog)) 257 + return PTR_ERR(prog); 258 + 294 259 mutex_lock(&netns_bpf_mutex); 295 - ret = __netns_bpf_prog_detach(current->nsproxy->net_ns, type); 260 + ret = __netns_bpf_prog_detach(current->nsproxy->net_ns, type, prog); 296 261 mutex_unlock(&netns_bpf_mutex); 262 + 263 + bpf_prog_put(prog); 297 264 298 265 return ret; 299 266 } ··· 312 257 static int netns_bpf_link_attach(struct net *net, struct bpf_link *link, 313 258 enum netns_bpf_attach_type type) 314 259 { 315 - struct bpf_prog *prog; 260 + struct bpf_netns_link *net_link = 261 + container_of(link, struct bpf_netns_link, link); 262 + struct bpf_prog_array *run_array; 316 263 int err; 317 264 318 265 mutex_lock(&netns_bpf_mutex); 319 266 320 267 /* Allow attaching only one prog or link for now */ 321 - if (net->bpf.links[type]) { 268 + if (!list_empty(&net->bpf.links[type])) { 322 269 err = -E2BIG; 323 270 goto out_unlock; 324 271 } 325 272 /* Links are not compatible with attaching prog directly */ 326 - prog = rcu_dereference_protected(net->bpf.progs[type], 327 - lockdep_is_held(&netns_bpf_mutex)); 328 - if (prog) { 273 + if (net->bpf.progs[type]) { 329 274 err = -EEXIST; 330 275 goto out_unlock; 331 276 } 332 277 333 278 switch (type) { 334 279 case NETNS_BPF_FLOW_DISSECTOR: 335 - err = flow_dissector_bpf_prog_attach(net, link->prog); 280 + err = flow_dissector_bpf_prog_attach_check(net, link->prog); 336 281 break; 337 282 default: 338 283 err = -EINVAL; ··· 341 286 if (err) 342 287 goto out_unlock; 343 288 344 - net->bpf.links[type] = link; 289 + run_array = bpf_prog_array_alloc(1, GFP_KERNEL); 290 + if (!run_array) { 291 + err = -ENOMEM; 292 + goto out_unlock; 293 + } 294 + run_array->items[0].prog = link->prog; 295 + rcu_assign_pointer(net->bpf.run_array[type], run_array); 296 + 297 + list_add_tail(&net_link->node, &net->bpf.links[type]); 345 298 346 299 out_unlock: 347 300 mutex_unlock(&netns_bpf_mutex); ··· 408 345 return err; 409 346 } 410 347 348 + static int __net_init netns_bpf_pernet_init(struct net *net) 349 + { 350 + int type; 351 + 352 + for (type = 0; type < MAX_NETNS_BPF_ATTACH_TYPE; type++) 353 + INIT_LIST_HEAD(&net->bpf.links[type]); 354 + 355 + return 0; 356 + } 357 + 411 358 static void __net_exit netns_bpf_pernet_pre_exit(struct net *net) 412 359 { 413 360 enum netns_bpf_attach_type type; 414 - struct bpf_link *link; 361 + struct bpf_netns_link *net_link; 415 362 416 363 mutex_lock(&netns_bpf_mutex); 417 364 for (type = 0; type < MAX_NETNS_BPF_ATTACH_TYPE; type++) { 418 - link = net->bpf.links[type]; 419 - if (link) 420 - bpf_netns_link_auto_detach(link); 421 - else 422 - __netns_bpf_prog_detach(net, type); 365 + netns_bpf_run_array_detach(net, type); 366 + list_for_each_entry(net_link, &net->bpf.links[type], node) 367 + net_link->net = NULL; /* auto-detach link */ 368 + if (net->bpf.progs[type]) 369 + bpf_prog_put(net->bpf.progs[type]); 423 370 } 424 371 mutex_unlock(&netns_bpf_mutex); 425 372 } 426 373 427 374 static struct pernet_operations netns_bpf_pernet_ops __net_initdata = { 375 + .init = netns_bpf_pernet_init, 428 376 .pre_exit = netns_bpf_pernet_pre_exit, 429 377 }; 430 378
+10 -4
kernel/bpf/reuseport_array.c
··· 20 20 /* The caller must hold the reuseport_lock */ 21 21 void bpf_sk_reuseport_detach(struct sock *sk) 22 22 { 23 - struct sock __rcu **socks; 23 + uintptr_t sk_user_data; 24 24 25 25 write_lock_bh(&sk->sk_callback_lock); 26 - socks = sk->sk_user_data; 27 - if (socks) { 26 + sk_user_data = (uintptr_t)sk->sk_user_data; 27 + if (sk_user_data & SK_USER_DATA_BPF) { 28 + struct sock __rcu **socks; 29 + 30 + socks = (void *)(sk_user_data & SK_USER_DATA_PTRMASK); 28 31 WRITE_ONCE(sk->sk_user_data, NULL); 29 32 /* 30 33 * Do not move this NULL assignment outside of ··· 255 252 struct sock *free_osk = NULL, *osk, *nsk; 256 253 struct sock_reuseport *reuse; 257 254 u32 index = *(u32 *)key; 255 + uintptr_t sk_user_data; 258 256 struct socket *socket; 259 257 int err, fd; 260 258 ··· 309 305 if (err) 310 306 goto put_file_unlock; 311 307 312 - WRITE_ONCE(nsk->sk_user_data, &array->ptrs[index]); 308 + sk_user_data = (uintptr_t)&array->ptrs[index] | SK_USER_DATA_NOCOPY | 309 + SK_USER_DATA_BPF; 310 + WRITE_ONCE(nsk->sk_user_data, (void *)sk_user_data); 313 311 rcu_assign_pointer(array->ptrs[index], nsk); 314 312 free_osk = osk; 315 313 err = 0;
+8 -10
kernel/bpf/ringbuf.c
··· 132 132 { 133 133 struct bpf_ringbuf *rb; 134 134 135 - if (!data_sz || !PAGE_ALIGNED(data_sz)) 136 - return ERR_PTR(-EINVAL); 137 - 138 - #ifdef CONFIG_64BIT 139 - /* on 32-bit arch, it's impossible to overflow record's hdr->pgoff */ 140 - if (data_sz > RINGBUF_MAX_DATA_SZ) 141 - return ERR_PTR(-E2BIG); 142 - #endif 143 - 144 135 rb = bpf_ringbuf_area_alloc(data_sz, numa_node); 145 136 if (!rb) 146 137 return ERR_PTR(-ENOMEM); ··· 157 166 return ERR_PTR(-EINVAL); 158 167 159 168 if (attr->key_size || attr->value_size || 160 - attr->max_entries == 0 || !PAGE_ALIGNED(attr->max_entries)) 169 + !is_power_of_2(attr->max_entries) || 170 + !PAGE_ALIGNED(attr->max_entries)) 161 171 return ERR_PTR(-EINVAL); 172 + 173 + #ifdef CONFIG_64BIT 174 + /* on 32-bit arch, it's impossible to overflow record's hdr->pgoff */ 175 + if (attr->max_entries > RINGBUF_MAX_DATA_SZ) 176 + return ERR_PTR(-E2BIG); 177 + #endif 162 178 163 179 rb_map = kzalloc(sizeof(*rb_map), GFP_USER); 164 180 if (!rb_map)
+3 -5
kernel/bpf/syscall.c
··· 2121 2121 !bpf_capable()) 2122 2122 return -EPERM; 2123 2123 2124 - if (is_net_admin_prog_type(type) && !capable(CAP_NET_ADMIN)) 2124 + if (is_net_admin_prog_type(type) && !capable(CAP_NET_ADMIN) && !capable(CAP_SYS_ADMIN)) 2125 2125 return -EPERM; 2126 2126 if (is_perfmon_prog_type(type) && !perfmon_capable()) 2127 2127 return -EPERM; ··· 2893 2893 switch (ptype) { 2894 2894 case BPF_PROG_TYPE_SK_MSG: 2895 2895 case BPF_PROG_TYPE_SK_SKB: 2896 - return sock_map_get_from_fd(attr, NULL); 2896 + return sock_map_prog_detach(attr, ptype); 2897 2897 case BPF_PROG_TYPE_LIRC_MODE2: 2898 2898 return lirc_prog_detach(attr); 2899 2899 case BPF_PROG_TYPE_FLOW_DISSECTOR: 2900 - if (!capable(CAP_NET_ADMIN)) 2901 - return -EPERM; 2902 - return netns_bpf_prog_detach(attr); 2900 + return netns_bpf_prog_detach(attr, ptype); 2903 2901 case BPF_PROG_TYPE_CGROUP_DEVICE: 2904 2902 case BPF_PROG_TYPE_CGROUP_SKB: 2905 2903 case BPF_PROG_TYPE_CGROUP_SOCK:
+10 -3
kernel/bpf/verifier.c
··· 399 399 return type == PTR_TO_SOCKET || 400 400 type == PTR_TO_TCP_SOCK || 401 401 type == PTR_TO_MAP_VALUE || 402 - type == PTR_TO_SOCK_COMMON || 403 - type == PTR_TO_BTF_ID; 402 + type == PTR_TO_SOCK_COMMON; 404 403 } 405 404 406 405 static bool reg_type_may_be_null(enum bpf_reg_type type) ··· 9800 9801 int i, j, subprog_start, subprog_end = 0, len, subprog; 9801 9802 struct bpf_insn *insn; 9802 9803 void *old_bpf_func; 9803 - int err; 9804 + int err, num_exentries; 9804 9805 9805 9806 if (env->subprog_cnt <= 1) 9806 9807 return 0; ··· 9875 9876 func[i]->aux->nr_linfo = prog->aux->nr_linfo; 9876 9877 func[i]->aux->jited_linfo = prog->aux->jited_linfo; 9877 9878 func[i]->aux->linfo_idx = env->subprog_info[i].linfo_idx; 9879 + num_exentries = 0; 9880 + insn = func[i]->insnsi; 9881 + for (j = 0; j < func[i]->len; j++, insn++) { 9882 + if (BPF_CLASS(insn->code) == BPF_LDX && 9883 + BPF_MODE(insn->code) == BPF_PROBE_MEM) 9884 + num_exentries++; 9885 + } 9886 + func[i]->aux->num_exentries = num_exentries; 9878 9887 func[i] = bpf_int_jit_compile(func[i]); 9879 9888 if (!func[i]->jited) { 9880 9889 err = -ENOTSUPP;
+19 -12
kernel/cgroup/cgroup.c
··· 6439 6439 6440 6440 void cgroup_sk_alloc(struct sock_cgroup_data *skcd) 6441 6441 { 6442 - if (cgroup_sk_alloc_disabled) 6443 - return; 6444 - 6445 - /* Socket clone path */ 6446 - if (skcd->val) { 6447 - /* 6448 - * We might be cloning a socket which is left in an empty 6449 - * cgroup and the cgroup might have already been rmdir'd. 6450 - * Don't use cgroup_get_live(). 6451 - */ 6452 - cgroup_get(sock_cgroup_ptr(skcd)); 6453 - cgroup_bpf_get(sock_cgroup_ptr(skcd)); 6442 + if (cgroup_sk_alloc_disabled) { 6443 + skcd->no_refcnt = 1; 6454 6444 return; 6455 6445 } 6456 6446 ··· 6465 6475 rcu_read_unlock(); 6466 6476 } 6467 6477 6478 + void cgroup_sk_clone(struct sock_cgroup_data *skcd) 6479 + { 6480 + if (skcd->val) { 6481 + if (skcd->no_refcnt) 6482 + return; 6483 + /* 6484 + * We might be cloning a socket which is left in an empty 6485 + * cgroup and the cgroup might have already been rmdir'd. 6486 + * Don't use cgroup_get_live(). 6487 + */ 6488 + cgroup_get(sock_cgroup_ptr(skcd)); 6489 + cgroup_bpf_get(sock_cgroup_ptr(skcd)); 6490 + } 6491 + } 6492 + 6468 6493 void cgroup_sk_free(struct sock_cgroup_data *skcd) 6469 6494 { 6470 6495 struct cgroup *cgrp = sock_cgroup_ptr(skcd); 6471 6496 6497 + if (skcd->no_refcnt) 6498 + return; 6472 6499 cgroup_bpf_put(cgrp); 6473 6500 cgroup_put(cgrp); 6474 6501 }
+6
kernel/dma/direct.c
··· 539 539 return swiotlb_max_mapping_size(dev); 540 540 return SIZE_MAX; 541 541 } 542 + 543 + bool dma_direct_need_sync(struct device *dev, dma_addr_t dma_addr) 544 + { 545 + return !dev_is_dma_coherent(dev) || 546 + is_swiotlb_buffer(dma_to_phys(dev, dma_addr)); 547 + }
+10
kernel/dma/mapping.c
··· 397 397 } 398 398 EXPORT_SYMBOL_GPL(dma_max_mapping_size); 399 399 400 + bool dma_need_sync(struct device *dev, dma_addr_t dma_addr) 401 + { 402 + const struct dma_map_ops *ops = get_dma_ops(dev); 403 + 404 + if (dma_is_direct(ops)) 405 + return dma_direct_need_sync(dev, dma_addr); 406 + return ops->sync_single_for_cpu || ops->sync_single_for_device; 407 + } 408 + EXPORT_SYMBOL_GPL(dma_need_sync); 409 + 400 410 unsigned long dma_get_merge_boundary(struct device *dev) 401 411 { 402 412 const struct dma_map_ops *ops = get_dma_ops(dev);
+1
lib/packing.c
··· 73 73 * @endbit: The index (in logical notation, compensated for quirks) where 74 74 * the packed value ends within pbuf. Must be smaller than, or equal 75 75 * to, startbit. 76 + * @pbuflen: The length in bytes of the packed buffer pointed to by @pbuf. 76 77 * @op: If PACK, then uval will be treated as const pointer and copied (packed) 77 78 * into pbuf, between startbit and endbit. 78 79 * If UNPACK, then pbuf will be treated as const pointer and the logical
+4 -5
net/8021q/vlan_dev.c
··· 503 503 lockdep_set_class(&txq->_xmit_lock, &vlan_netdev_xmit_lock_key); 504 504 } 505 505 506 - static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass) 506 + static void vlan_dev_set_lockdep_class(struct net_device *dev) 507 507 { 508 - lockdep_set_class_and_subclass(&dev->addr_list_lock, 509 - &vlan_netdev_addr_lock_key, 510 - subclass); 508 + lockdep_set_class(&dev->addr_list_lock, 509 + &vlan_netdev_addr_lock_key); 511 510 netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, NULL); 512 511 } 513 512 ··· 600 601 601 602 SET_NETDEV_DEVTYPE(dev, &vlan_type); 602 603 603 - vlan_dev_set_lockdep_class(dev, dev->lower_level); 604 + vlan_dev_set_lockdep_class(dev); 604 605 605 606 vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); 606 607 if (!vlan->vlan_pcpu_stats)
+18 -1
net/bpf/test_run.c
··· 147 147 return a + (long)b + c + d + (long)e + f; 148 148 } 149 149 150 + struct bpf_fentry_test_t { 151 + struct bpf_fentry_test_t *a; 152 + }; 153 + 154 + int noinline bpf_fentry_test7(struct bpf_fentry_test_t *arg) 155 + { 156 + return (long)arg; 157 + } 158 + 159 + int noinline bpf_fentry_test8(struct bpf_fentry_test_t *arg) 160 + { 161 + return (long)arg->a; 162 + } 163 + 150 164 int noinline bpf_modify_return_test(int a, int *b) 151 165 { 152 166 *b += 1; ··· 199 185 const union bpf_attr *kattr, 200 186 union bpf_attr __user *uattr) 201 187 { 188 + struct bpf_fentry_test_t arg = {}; 202 189 u16 side_effect = 0, ret = 0; 203 190 int b = 2, err = -EFAULT; 204 191 u32 retval = 0; ··· 212 197 bpf_fentry_test3(4, 5, 6) != 15 || 213 198 bpf_fentry_test4((void *)7, 8, 9, 10) != 34 || 214 199 bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 || 215 - bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111) 200 + bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111 || 201 + bpf_fentry_test7((struct bpf_fentry_test_t *)0) != 0 || 202 + bpf_fentry_test8(&arg) != 0) 216 203 goto out; 217 204 break; 218 205 case BPF_MODIFY_RETURN:
+1 -1
net/bridge/br_mrp.c
··· 86 86 { 87 87 struct ethhdr *eth_hdr; 88 88 struct sk_buff *skb; 89 - u16 *version; 89 + __be16 *version; 90 90 91 91 skb = dev_alloc_skb(MRP_MAX_FRAME_LENGTH); 92 92 if (!skb)
+1 -1
net/bridge/br_multicast.c
··· 1007 1007 nsrcs_offset = len + offsetof(struct mld2_grec, grec_nsrcs); 1008 1008 1009 1009 if (skb_transport_offset(skb) + ipv6_transport_len(skb) < 1010 - nsrcs_offset + sizeof(_nsrcs)) 1010 + nsrcs_offset + sizeof(__nsrcs)) 1011 1011 return -EINVAL; 1012 1012 1013 1013 _nsrcs = skb_header_pointer(skb, nsrcs_offset,
+1 -1
net/bridge/br_private.h
··· 430 430 struct hlist_head fdb_list; 431 431 432 432 #if IS_ENABLED(CONFIG_BRIDGE_MRP) 433 - struct list_head __rcu mrp_list; 433 + struct list_head mrp_list; 434 434 #endif 435 435 }; 436 436
+1 -1
net/bridge/br_private_mrp.h
··· 8 8 9 9 struct br_mrp { 10 10 /* list of mrp instances */ 11 - struct list_head __rcu list; 11 + struct list_head list; 12 12 13 13 struct net_bridge_port __rcu *p_port; 14 14 struct net_bridge_port __rcu *s_port;
+10
net/core/dev_addr_lists.c
··· 690 690 if (to->addr_len != from->addr_len) 691 691 return; 692 692 693 + /* netif_addr_lock_bh() uses lockdep subclass 0, this is okay for two 694 + * reasons: 695 + * 1) This is always called without any addr_list_lock, so as the 696 + * outermost one here, it must be 0. 697 + * 2) This is called by some callers after unlinking the upper device, 698 + * so the dev->lower_level becomes 1 again. 699 + * Therefore, the subclass for 'from' is 0, for 'to' is either 1 or 700 + * larger. 701 + */ 693 702 netif_addr_lock_bh(from); 694 703 netif_addr_lock_nested(to); 695 704 __hw_addr_unsync(&to->uc, &from->uc, to->addr_len); ··· 920 911 if (to->addr_len != from->addr_len) 921 912 return; 922 913 914 + /* See the above comments inside dev_uc_unsync(). */ 923 915 netif_addr_lock_bh(from); 924 916 netif_addr_lock_nested(to); 925 917 __hw_addr_unsync(&to->mc, &from->mc, to->addr_len);
+7 -3
net/core/filter.c
··· 5853 5853 { 5854 5854 unsigned int iphdr_len; 5855 5855 5856 - if (skb->protocol == cpu_to_be16(ETH_P_IP)) 5856 + switch (skb_protocol(skb, true)) { 5857 + case cpu_to_be16(ETH_P_IP): 5857 5858 iphdr_len = sizeof(struct iphdr); 5858 - else if (skb->protocol == cpu_to_be16(ETH_P_IPV6)) 5859 + break; 5860 + case cpu_to_be16(ETH_P_IPV6): 5859 5861 iphdr_len = sizeof(struct ipv6hdr); 5860 - else 5862 + break; 5863 + default: 5861 5864 return 0; 5865 + } 5862 5866 5863 5867 if (skb_headlen(skb) < iphdr_len) 5864 5868 return 0;
+12 -20
net/core/flow_dissector.c
··· 70 70 EXPORT_SYMBOL(skb_flow_dissector_init); 71 71 72 72 #ifdef CONFIG_BPF_SYSCALL 73 - int flow_dissector_bpf_prog_attach(struct net *net, struct bpf_prog *prog) 73 + int flow_dissector_bpf_prog_attach_check(struct net *net, 74 + struct bpf_prog *prog) 74 75 { 75 76 enum netns_bpf_attach_type type = NETNS_BPF_FLOW_DISSECTOR; 76 - struct bpf_prog *attached; 77 77 78 78 if (net == &init_net) { 79 79 /* BPF flow dissector in the root namespace overrides ··· 86 86 for_each_net(ns) { 87 87 if (ns == &init_net) 88 88 continue; 89 - if (rcu_access_pointer(ns->bpf.progs[type])) 89 + if (rcu_access_pointer(ns->bpf.run_array[type])) 90 90 return -EEXIST; 91 91 } 92 92 } else { 93 93 /* Make sure root flow dissector is not attached 94 94 * when attaching to the non-root namespace. 95 95 */ 96 - if (rcu_access_pointer(init_net.bpf.progs[type])) 96 + if (rcu_access_pointer(init_net.bpf.run_array[type])) 97 97 return -EEXIST; 98 98 } 99 99 100 - attached = rcu_dereference_protected(net->bpf.progs[type], 101 - lockdep_is_held(&netns_bpf_mutex)); 102 - if (attached == prog) 103 - /* The same program cannot be attached twice */ 104 - return -EINVAL; 105 - 106 - rcu_assign_pointer(net->bpf.progs[type], prog); 107 - if (attached) 108 - bpf_prog_put(attached); 109 100 return 0; 110 101 } 111 102 #endif /* CONFIG_BPF_SYSCALL */ ··· 894 903 struct flow_dissector_key_addrs *key_addrs; 895 904 struct flow_dissector_key_tags *key_tags; 896 905 struct flow_dissector_key_vlan *key_vlan; 897 - struct bpf_prog *attached = NULL; 898 906 enum flow_dissect_ret fdret; 899 907 enum flow_dissector_key_id dissector_vlan = FLOW_DISSECTOR_KEY_MAX; 900 908 bool mpls_el = false; ··· 950 960 WARN_ON_ONCE(!net); 951 961 if (net) { 952 962 enum netns_bpf_attach_type type = NETNS_BPF_FLOW_DISSECTOR; 963 + struct bpf_prog_array *run_array; 953 964 954 965 rcu_read_lock(); 955 - attached = rcu_dereference(init_net.bpf.progs[type]); 966 + run_array = rcu_dereference(init_net.bpf.run_array[type]); 967 + if (!run_array) 968 + run_array = rcu_dereference(net->bpf.run_array[type]); 956 969 957 - if (!attached) 958 - attached = rcu_dereference(net->bpf.progs[type]); 959 - 960 - if (attached) { 970 + if (run_array) { 961 971 struct bpf_flow_keys flow_keys; 962 972 struct bpf_flow_dissector ctx = { 963 973 .flow_keys = &flow_keys, ··· 965 975 .data_end = data + hlen, 966 976 }; 967 977 __be16 n_proto = proto; 978 + struct bpf_prog *prog; 968 979 969 980 if (skb) { 970 981 ctx.skb = skb; ··· 976 985 n_proto = skb->protocol; 977 986 } 978 987 979 - ret = bpf_flow_dissect(attached, &ctx, n_proto, nhoff, 988 + prog = READ_ONCE(run_array->items[0].prog); 989 + ret = bpf_flow_dissect(prog, &ctx, n_proto, nhoff, 980 990 hlen, flags); 981 991 __skb_flow_bpf_to_target(&flow_keys, flow_dissector, 982 992 target_container);
+15 -8
net/core/skmsg.c
··· 683 683 return container_of(parser, struct sk_psock, parser); 684 684 } 685 685 686 - static void sk_psock_skb_redirect(struct sk_psock *psock, struct sk_buff *skb) 686 + static void sk_psock_skb_redirect(struct sk_buff *skb) 687 687 { 688 688 struct sk_psock *psock_other; 689 689 struct sock *sk_other; ··· 715 715 } 716 716 } 717 717 718 - static void sk_psock_tls_verdict_apply(struct sk_psock *psock, 719 - struct sk_buff *skb, int verdict) 718 + static void sk_psock_tls_verdict_apply(struct sk_buff *skb, int verdict) 720 719 { 721 720 switch (verdict) { 722 721 case __SK_REDIRECT: 723 - sk_psock_skb_redirect(psock, skb); 722 + sk_psock_skb_redirect(skb); 724 723 break; 725 724 case __SK_PASS: 726 725 case __SK_DROP: ··· 740 741 ret = sk_psock_bpf_run(psock, prog, skb); 741 742 ret = sk_psock_map_verd(ret, tcp_skb_bpf_redirect_fetch(skb)); 742 743 } 744 + sk_psock_tls_verdict_apply(skb, ret); 743 745 rcu_read_unlock(); 744 - sk_psock_tls_verdict_apply(psock, skb, ret); 745 746 return ret; 746 747 } 747 748 EXPORT_SYMBOL_GPL(sk_psock_tls_strp_read); ··· 769 770 } 770 771 goto out_free; 771 772 case __SK_REDIRECT: 772 - sk_psock_skb_redirect(psock, skb); 773 + sk_psock_skb_redirect(skb); 773 774 break; 774 775 case __SK_DROP: 775 776 /* fall-through */ ··· 781 782 782 783 static void sk_psock_strp_read(struct strparser *strp, struct sk_buff *skb) 783 784 { 784 - struct sk_psock *psock = sk_psock_from_strp(strp); 785 + struct sk_psock *psock; 785 786 struct bpf_prog *prog; 786 787 int ret = __SK_DROP; 788 + struct sock *sk; 787 789 788 790 rcu_read_lock(); 791 + sk = strp->sk; 792 + psock = sk_psock(sk); 793 + if (unlikely(!psock)) { 794 + kfree_skb(skb); 795 + goto out; 796 + } 789 797 prog = READ_ONCE(psock->progs.skb_verdict); 790 798 if (likely(prog)) { 791 799 skb_orphan(skb); ··· 800 794 ret = sk_psock_bpf_run(psock, prog, skb); 801 795 ret = sk_psock_map_verd(ret, tcp_skb_bpf_redirect_fetch(skb)); 802 796 } 803 - rcu_read_unlock(); 804 797 sk_psock_verdict_apply(psock, skb, ret); 798 + out: 799 + rcu_read_unlock(); 805 800 } 806 801 807 802 static int sk_psock_strp_read_done(struct strparser *strp, int err)
+1 -1
net/core/sock.c
··· 1926 1926 /* sk->sk_memcg will be populated at accept() time */ 1927 1927 newsk->sk_memcg = NULL; 1928 1928 1929 - cgroup_sk_alloc(&newsk->sk_cgrp_data); 1929 + cgroup_sk_clone(&newsk->sk_cgrp_data); 1930 1930 1931 1931 rcu_read_lock(); 1932 1932 filter = rcu_dereference(sk->sk_filter);
+48 -5
net/core/sock_map.c
··· 70 70 struct fd f; 71 71 int ret; 72 72 73 + if (attr->attach_flags || attr->replace_bpf_fd) 74 + return -EINVAL; 75 + 73 76 f = fdget(ufd); 74 77 map = __bpf_map_get(f); 75 78 if (IS_ERR(map)) 76 79 return PTR_ERR(map); 77 - ret = sock_map_prog_update(map, prog, attr->attach_type); 80 + ret = sock_map_prog_update(map, prog, NULL, attr->attach_type); 81 + fdput(f); 82 + return ret; 83 + } 84 + 85 + int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype) 86 + { 87 + u32 ufd = attr->target_fd; 88 + struct bpf_prog *prog; 89 + struct bpf_map *map; 90 + struct fd f; 91 + int ret; 92 + 93 + if (attr->attach_flags || attr->replace_bpf_fd) 94 + return -EINVAL; 95 + 96 + f = fdget(ufd); 97 + map = __bpf_map_get(f); 98 + if (IS_ERR(map)) 99 + return PTR_ERR(map); 100 + 101 + prog = bpf_prog_get(attr->attach_bpf_fd); 102 + if (IS_ERR(prog)) { 103 + ret = PTR_ERR(prog); 104 + goto put_map; 105 + } 106 + 107 + if (prog->type != ptype) { 108 + ret = -EINVAL; 109 + goto put_prog; 110 + } 111 + 112 + ret = sock_map_prog_update(map, NULL, prog, attr->attach_type); 113 + put_prog: 114 + bpf_prog_put(prog); 115 + put_map: 78 116 fdput(f); 79 117 return ret; 80 118 } ··· 1241 1203 } 1242 1204 1243 1205 int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog, 1244 - u32 which) 1206 + struct bpf_prog *old, u32 which) 1245 1207 { 1246 1208 struct sk_psock_progs *progs = sock_map_progs(map); 1209 + struct bpf_prog **pprog; 1247 1210 1248 1211 if (!progs) 1249 1212 return -EOPNOTSUPP; 1250 1213 1251 1214 switch (which) { 1252 1215 case BPF_SK_MSG_VERDICT: 1253 - psock_set_prog(&progs->msg_parser, prog); 1216 + pprog = &progs->msg_parser; 1254 1217 break; 1255 1218 case BPF_SK_SKB_STREAM_PARSER: 1256 - psock_set_prog(&progs->skb_parser, prog); 1219 + pprog = &progs->skb_parser; 1257 1220 break; 1258 1221 case BPF_SK_SKB_STREAM_VERDICT: 1259 - psock_set_prog(&progs->skb_verdict, prog); 1222 + pprog = &progs->skb_verdict; 1260 1223 break; 1261 1224 default: 1262 1225 return -EOPNOTSUPP; 1263 1226 } 1264 1227 1228 + if (old) 1229 + return psock_replace_prog(pprog, prog, old); 1230 + 1231 + psock_set_prog(pprog, prog); 1265 1232 return 0; 1266 1233 } 1267 1234
+13 -14
net/ethtool/netlink.c
··· 376 376 } 377 377 378 378 static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev, 379 - const struct ethnl_dump_ctx *ctx) 379 + const struct ethnl_dump_ctx *ctx, 380 + struct netlink_callback *cb) 380 381 { 382 + void *ehdr; 381 383 int ret; 384 + 385 + ehdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 386 + &ethtool_genl_family, 0, ctx->ops->reply_cmd); 387 + if (!ehdr) 388 + return -EMSGSIZE; 382 389 383 390 ethnl_init_reply_data(ctx->reply_data, ctx->ops, dev); 384 391 rtnl_lock(); ··· 402 395 if (ctx->ops->cleanup_data) 403 396 ctx->ops->cleanup_data(ctx->reply_data); 404 397 ctx->reply_data->dev = NULL; 398 + if (ret < 0) 399 + genlmsg_cancel(skb, ehdr); 400 + else 401 + genlmsg_end(skb, ehdr); 405 402 return ret; 406 403 } 407 404 ··· 422 411 int s_idx = ctx->pos_idx; 423 412 int h, idx = 0; 424 413 int ret = 0; 425 - void *ehdr; 426 414 427 415 rtnl_lock(); 428 416 for (h = ctx->pos_hash; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { ··· 441 431 dev_hold(dev); 442 432 rtnl_unlock(); 443 433 444 - ehdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, 445 - cb->nlh->nlmsg_seq, 446 - &ethtool_genl_family, 0, 447 - ctx->ops->reply_cmd); 448 - if (!ehdr) { 449 - dev_put(dev); 450 - ret = -EMSGSIZE; 451 - goto out; 452 - } 453 - ret = ethnl_default_dump_one(skb, dev, ctx); 434 + ret = ethnl_default_dump_one(skb, dev, ctx, cb); 454 435 dev_put(dev); 455 436 if (ret < 0) { 456 - genlmsg_cancel(skb, ehdr); 457 437 if (ret == -EOPNOTSUPP) 458 438 goto lock_and_cont; 459 439 if (likely(skb->len)) 460 440 ret = skb->len; 461 441 goto out; 462 442 } 463 - genlmsg_end(skb, ehdr); 464 443 lock_and_cont: 465 444 rtnl_lock(); 466 445 if (net->dev_base_seq != seq) {
+7 -4
net/hsr/hsr_device.c
··· 415 415 unsigned char multicast_spec, u8 protocol_version, 416 416 struct netlink_ext_ack *extack) 417 417 { 418 + bool unregister = false; 418 419 struct hsr_priv *hsr; 419 420 int res; 420 421 ··· 467 466 if (res) 468 467 goto err_unregister; 469 468 469 + unregister = true; 470 + 470 471 res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A, extack); 471 472 if (res) 472 - goto err_add_slaves; 473 + goto err_unregister; 473 474 474 475 res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B, extack); 475 476 if (res) 476 - goto err_add_slaves; 477 + goto err_unregister; 477 478 478 479 hsr_debugfs_init(hsr, hsr_dev); 479 480 mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD)); 480 481 481 482 return 0; 482 483 483 - err_add_slaves: 484 - unregister_netdevice(hsr_dev); 485 484 err_unregister: 486 485 hsr_del_ports(hsr); 487 486 err_add_master: 488 487 hsr_del_self_node(hsr); 489 488 489 + if (unregister) 490 + unregister_netdevice(hsr_dev); 490 491 return res; 491 492 }
+2 -2
net/ipv4/icmp.c
··· 427 427 428 428 ipcm_init(&ipc); 429 429 inet->tos = ip_hdr(skb)->tos; 430 - sk->sk_mark = mark; 430 + ipc.sockc.mark = mark; 431 431 daddr = ipc.addr = ip_hdr(skb)->saddr; 432 432 saddr = fib_compute_spec_dst(skb); 433 433 ··· 710 710 icmp_param.skb = skb_in; 711 711 icmp_param.offset = skb_network_offset(skb_in); 712 712 inet_sk(sk)->tos = tos; 713 - sk->sk_mark = mark; 714 713 ipcm_init(&ipc); 715 714 ipc.addr = iph->saddr; 716 715 ipc.opt = &icmp_param.replyopts.opt; 716 + ipc.sockc.mark = mark; 717 717 718 718 rt = icmp_route_lookup(net, &fl4, skb_in, iph, saddr, tos, mark, 719 719 type, code, &icmp_param);
+1 -1
net/ipv4/ip_output.c
··· 1702 1702 sk->sk_protocol = ip_hdr(skb)->protocol; 1703 1703 sk->sk_bound_dev_if = arg->bound_dev_if; 1704 1704 sk->sk_sndbuf = sysctl_wmem_default; 1705 - sk->sk_mark = fl4.flowi4_mark; 1705 + ipc.sockc.mark = fl4.flowi4_mark; 1706 1706 err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, 1707 1707 len, 0, &ipc, &rt, MSG_DONTWAIT); 1708 1708 if (unlikely(err)) {
+18
net/ipv4/ip_tunnel_core.c
··· 844 844 static_branch_dec(&ip_tunnel_metadata_cnt); 845 845 } 846 846 EXPORT_SYMBOL_GPL(ip_tunnel_unneed_metadata); 847 + 848 + /* Returns either the correct skb->protocol value, or 0 if invalid. */ 849 + __be16 ip_tunnel_parse_protocol(const struct sk_buff *skb) 850 + { 851 + if (skb_network_header(skb) >= skb->head && 852 + (skb_network_header(skb) + sizeof(struct iphdr)) <= skb_tail_pointer(skb) && 853 + ip_hdr(skb)->version == 4) 854 + return htons(ETH_P_IP); 855 + if (skb_network_header(skb) >= skb->head && 856 + (skb_network_header(skb) + sizeof(struct ipv6hdr)) <= skb_tail_pointer(skb) && 857 + ipv6_hdr(skb)->version == 6) 858 + return htons(ETH_P_IPV6); 859 + return 0; 860 + } 861 + EXPORT_SYMBOL(ip_tunnel_parse_protocol); 862 + 863 + const struct header_ops ip_tunnel_header_ops = { .parse_protocol = ip_tunnel_parse_protocol }; 864 + EXPORT_SYMBOL(ip_tunnel_header_ops);
+1
net/ipv4/ip_vti.c
··· 441 441 static void vti_tunnel_setup(struct net_device *dev) 442 442 { 443 443 dev->netdev_ops = &vti_netdev_ops; 444 + dev->header_ops = &ip_tunnel_header_ops; 444 445 dev->type = ARPHRD_TUNNEL; 445 446 ip_tunnel_setup(dev, vti_net_id); 446 447 }
+1
net/ipv4/ipip.c
··· 361 361 static void ipip_tunnel_setup(struct net_device *dev) 362 362 { 363 363 dev->netdev_ops = &ipip_netdev_ops; 364 + dev->header_ops = &ip_tunnel_header_ops; 364 365 365 366 dev->type = ARPHRD_TUNNEL; 366 367 dev->flags = IFF_NOARP;
+3
net/ipv4/ping.c
··· 786 786 inet_sk_flowi_flags(sk), faddr, saddr, 0, 0, 787 787 sk->sk_uid); 788 788 789 + fl4.fl4_icmp_type = user_icmph.type; 790 + fl4.fl4_icmp_code = user_icmph.code; 791 + 789 792 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 790 793 rt = ip_route_output_flow(net, &fl4, sk); 791 794 if (IS_ERR(rt)) {
+1 -1
net/ipv4/route.c
··· 2027 2027 const struct sk_buff *hint) 2028 2028 { 2029 2029 struct in_device *in_dev = __in_dev_get_rcu(dev); 2030 - struct rtable *rt = (struct rtable *)hint; 2030 + struct rtable *rt = skb_rtable(hint); 2031 2031 struct net *net = dev_net(dev); 2032 2032 int err = -EINVAL; 2033 2033 u32 tag = 0;
+10 -7
net/ipv4/tcp.c
··· 2691 2691 tp->window_clamp = 0; 2692 2692 tp->delivered = 0; 2693 2693 tp->delivered_ce = 0; 2694 + if (icsk->icsk_ca_ops->release) 2695 + icsk->icsk_ca_ops->release(sk); 2696 + memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); 2694 2697 tcp_set_ca_state(sk, TCP_CA_Open); 2695 2698 tp->is_sack_reneg = 0; 2696 2699 tcp_clear_retrans(tp); ··· 3249 3246 #ifdef CONFIG_TCP_MD5SIG 3250 3247 case TCP_MD5SIG: 3251 3248 case TCP_MD5SIG_EXT: 3252 - if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) 3253 - err = tp->af_specific->md5_parse(sk, optname, optval, optlen); 3254 - else 3255 - err = -EINVAL; 3249 + err = tp->af_specific->md5_parse(sk, optname, optval, optlen); 3256 3250 break; 3257 3251 #endif 3258 3252 case TCP_USER_TIMEOUT: ··· 4033 4033 4034 4034 int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key) 4035 4035 { 4036 + u8 keylen = READ_ONCE(key->keylen); /* paired with WRITE_ONCE() in tcp_md5_do_add */ 4036 4037 struct scatterlist sg; 4037 4038 4038 - sg_init_one(&sg, key->key, key->keylen); 4039 - ahash_request_set_crypt(hp->md5_req, &sg, NULL, key->keylen); 4040 - return crypto_ahash_update(hp->md5_req); 4039 + sg_init_one(&sg, key->key, keylen); 4040 + ahash_request_set_crypt(hp->md5_req, &sg, NULL, keylen); 4041 + 4042 + /* We use data_race() because tcp_md5_do_add() might change key->key under us */ 4043 + return data_race(crypto_ahash_update(hp->md5_req)); 4041 4044 } 4042 4045 EXPORT_SYMBOL(tcp_md5_hash_key); 4043 4046
+1 -1
net/ipv4/tcp_cong.c
··· 197 197 icsk->icsk_ca_setsockopt = 1; 198 198 memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); 199 199 200 - if (sk->sk_state != TCP_CLOSE) 200 + if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) 201 201 tcp_init_congestion_control(sk); 202 202 } 203 203
+2
net/ipv4/tcp_input.c
··· 4582 4582 4583 4583 if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) { 4584 4584 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP); 4585 + sk->sk_data_ready(sk); 4585 4586 tcp_drop(sk, skb); 4586 4587 return; 4587 4588 } ··· 4829 4828 sk_forced_mem_schedule(sk, skb->truesize); 4830 4829 else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { 4831 4830 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); 4831 + sk->sk_data_ready(sk); 4832 4832 goto drop; 4833 4833 } 4834 4834
+16 -4
net/ipv4/tcp_ipv4.c
··· 1111 1111 1112 1112 key = tcp_md5_do_lookup_exact(sk, addr, family, prefixlen, l3index); 1113 1113 if (key) { 1114 - /* Pre-existing entry - just update that one. */ 1115 - memcpy(key->key, newkey, newkeylen); 1116 - key->keylen = newkeylen; 1114 + /* Pre-existing entry - just update that one. 1115 + * Note that the key might be used concurrently. 1116 + * data_race() is telling kcsan that we do not care of 1117 + * key mismatches, since changing MD5 key on live flows 1118 + * can lead to packet drops. 1119 + */ 1120 + data_race(memcpy(key->key, newkey, newkeylen)); 1121 + 1122 + /* Pairs with READ_ONCE() in tcp_md5_hash_key(). 1123 + * Also note that a reader could catch new key->keylen value 1124 + * but old key->key[], this is the reason we use __GFP_ZERO 1125 + * at sock_kmalloc() time below these lines. 1126 + */ 1127 + WRITE_ONCE(key->keylen, newkeylen); 1128 + 1117 1129 return 0; 1118 1130 } 1119 1131 ··· 1141 1129 rcu_assign_pointer(tp->md5sig_info, md5sig); 1142 1130 } 1143 1131 1144 - key = sock_kmalloc(sk, sizeof(*key), gfp); 1132 + key = sock_kmalloc(sk, sizeof(*key), gfp | __GFP_ZERO); 1145 1133 if (!key) 1146 1134 return -ENOMEM; 1147 1135 if (!tcp_alloc_md5sig_pool()) {
+5 -3
net/ipv4/tcp_output.c
··· 700 700 unsigned int mss, struct sk_buff *skb, 701 701 struct tcp_out_options *opts, 702 702 const struct tcp_md5sig_key *md5, 703 - struct tcp_fastopen_cookie *foc) 703 + struct tcp_fastopen_cookie *foc, 704 + enum tcp_synack_type synack_type) 704 705 { 705 706 struct inet_request_sock *ireq = inet_rsk(req); 706 707 unsigned int remaining = MAX_TCP_OPTION_SPACE; ··· 716 715 * rather than TS in order to fit in better with old, 717 716 * buggy kernels, but that was deemed to be unnecessary. 718 717 */ 719 - ireq->tstamp_ok &= !ireq->sack_ok; 718 + if (synack_type != TCP_SYNACK_COOKIE) 719 + ireq->tstamp_ok &= !ireq->sack_ok; 720 720 } 721 721 #endif 722 722 ··· 3396 3394 #endif 3397 3395 skb_set_hash(skb, tcp_rsk(req)->txhash, PKT_HASH_TYPE_L4); 3398 3396 tcp_header_size = tcp_synack_options(sk, req, mss, skb, &opts, md5, 3399 - foc) + sizeof(*th); 3397 + foc, synack_type) + sizeof(*th); 3400 3398 3401 3399 skb_push(skb, tcp_header_size); 3402 3400 skb_reset_transport_header(skb);
+2 -2
net/ipv6/icmp.c
··· 566 566 fl6.mp_hash = rt6_multipath_hash(net, &fl6, skb, NULL); 567 567 security_skb_classify_flow(skb, flowi6_to_flowi(&fl6)); 568 568 569 - sk->sk_mark = mark; 570 569 np = inet6_sk(sk); 571 570 572 571 if (!icmpv6_xrlim_allow(sk, type, &fl6)) ··· 582 583 fl6.flowi6_oif = np->ucast_oif; 583 584 584 585 ipcm6_init_sk(&ipc6, np); 586 + ipc6.sockc.mark = mark; 585 587 fl6.flowlabel = ip6_make_flowinfo(ipc6.tclass, fl6.flowlabel); 586 588 587 589 dst = icmpv6_route_lookup(net, skb, sk, &fl6); ··· 751 751 sk = icmpv6_xmit_lock(net); 752 752 if (!sk) 753 753 goto out_bh_enable; 754 - sk->sk_mark = mark; 755 754 np = inet6_sk(sk); 756 755 757 756 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) ··· 778 779 ipcm6_init_sk(&ipc6, np); 779 780 ipc6.hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst); 780 781 ipc6.tclass = ipv6_get_dsfield(ipv6_hdr(skb)); 782 + ipc6.sockc.mark = mark; 781 783 782 784 if (ip6_append_data(sk, icmpv6_getfrag, &msg, 783 785 skb->len + sizeof(struct icmp6hdr),
+1
net/ipv6/ip6_tunnel.c
··· 1846 1846 static void ip6_tnl_dev_setup(struct net_device *dev) 1847 1847 { 1848 1848 dev->netdev_ops = &ip6_tnl_netdev_ops; 1849 + dev->header_ops = &ip_tunnel_header_ops; 1849 1850 dev->needs_free_netdev = true; 1850 1851 dev->priv_destructor = ip6_dev_free; 1851 1852
+1
net/ipv6/ip6_vti.c
··· 905 905 static void vti6_dev_setup(struct net_device *dev) 906 906 { 907 907 dev->netdev_ops = &vti6_netdev_ops; 908 + dev->header_ops = &ip_tunnel_header_ops; 908 909 dev->needs_free_netdev = true; 909 910 dev->priv_destructor = vti6_dev_free; 910 911
+5 -2
net/ipv6/route.c
··· 431 431 struct fib6_info *sibling, *next_sibling; 432 432 struct fib6_info *match = res->f6i; 433 433 434 - if ((!match->fib6_nsiblings && !match->nh) || have_oif_match) 434 + if (!match->nh && (!match->fib6_nsiblings || have_oif_match)) 435 435 goto out; 436 + 437 + if (match->nh && have_oif_match && res->nh) 438 + return; 436 439 437 440 /* We might have already computed the hash for ICMPv6 errors. In such 438 441 * case it will always be non-zero. Otherwise now is the time to do it. ··· 3405 3402 if ((flags & RTF_REJECT) || 3406 3403 (dev && (dev->flags & IFF_LOOPBACK) && 3407 3404 !(addr_type & IPV6_ADDR_LOOPBACK) && 3408 - !(flags & RTF_LOCAL))) 3405 + !(flags & (RTF_ANYCAST | RTF_LOCAL)))) 3409 3406 return true; 3410 3407 3411 3408 return false;
+1
net/ipv6/sit.c
··· 1421 1421 int t_hlen = tunnel->hlen + sizeof(struct iphdr); 1422 1422 1423 1423 dev->netdev_ops = &ipip6_netdev_ops; 1424 + dev->header_ops = &ip_tunnel_header_ops; 1424 1425 dev->needs_free_netdev = true; 1425 1426 dev->priv_destructor = ipip6_dev_free; 1426 1427
+1 -4
net/l2tp/l2tp_core.c
··· 1028 1028 1029 1029 /* Queue the packet to IP for output */ 1030 1030 skb->ignore_df = 1; 1031 + skb_dst_drop(skb); 1031 1032 #if IS_ENABLED(CONFIG_IPV6) 1032 1033 if (l2tp_sk_is_v6(tunnel->sock)) 1033 1034 error = inet6_csk_xmit(tunnel->sock, skb, NULL); ··· 1099 1098 ret = NET_XMIT_DROP; 1100 1099 goto out_unlock; 1101 1100 } 1102 - 1103 - /* Get routing info from the tunnel socket */ 1104 - skb_dst_drop(skb); 1105 - skb_dst_set(skb, sk_dst_check(sk, 0)); 1106 1101 1107 1102 inet = inet_sk(sk); 1108 1103 fl = &inet->cork.fl;
+7 -3
net/llc/af_llc.c
··· 273 273 274 274 if (!sock_flag(sk, SOCK_ZAPPED)) 275 275 goto out; 276 + if (!addr->sllc_arphrd) 277 + addr->sllc_arphrd = ARPHRD_ETHER; 278 + if (addr->sllc_arphrd != ARPHRD_ETHER) 279 + goto out; 276 280 rc = -ENODEV; 277 281 if (sk->sk_bound_dev_if) { 278 282 llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); ··· 332 328 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr))) 333 329 goto out; 334 330 rc = -EAFNOSUPPORT; 335 - if (unlikely(addr->sllc_family != AF_LLC)) 331 + if (!addr->sllc_arphrd) 332 + addr->sllc_arphrd = ARPHRD_ETHER; 333 + if (unlikely(addr->sllc_family != AF_LLC || addr->sllc_arphrd != ARPHRD_ETHER)) 336 334 goto out; 337 335 dprintk("%s: binding %02X\n", __func__, addr->sllc_sap); 338 336 rc = -ENODEV; ··· 342 336 if (sk->sk_bound_dev_if) { 343 337 llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if); 344 338 if (llc->dev) { 345 - if (!addr->sllc_arphrd) 346 - addr->sllc_arphrd = llc->dev->type; 347 339 if (is_zero_ether_addr(addr->sllc_mac)) 348 340 memcpy(addr->sllc_mac, llc->dev->dev_addr, 349 341 IFHWADDRLEN);
+2 -5
net/mac80211/mesh_hwmp.c
··· 1105 1105 ttl, lifetime, 0, ifmsh->preq_id++, sdata); 1106 1106 1107 1107 spin_lock_bh(&mpath->state_lock); 1108 - if (mpath->flags & MESH_PATH_DELETED) { 1109 - spin_unlock_bh(&mpath->state_lock); 1110 - goto enddiscovery; 1111 - } 1112 - mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); 1108 + if (!(mpath->flags & MESH_PATH_DELETED)) 1109 + mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); 1113 1110 spin_unlock_bh(&mpath->state_lock); 1114 1111 1115 1112 enddiscovery:
+26
net/mac80211/rx.c
··· 2396 2396 2397 2397 static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) 2398 2398 { 2399 + struct ieee80211_hdr *hdr = (void *)rx->skb->data; 2399 2400 struct sk_buff *skb = rx->skb; 2400 2401 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 2401 2402 ··· 2407 2406 if (status->flag & RX_FLAG_DECRYPTED) 2408 2407 return 0; 2409 2408 2409 + /* check mesh EAPOL frames first */ 2410 + if (unlikely(rx->sta && ieee80211_vif_is_mesh(&rx->sdata->vif) && 2411 + ieee80211_is_data(fc))) { 2412 + struct ieee80211s_hdr *mesh_hdr; 2413 + u16 hdr_len = ieee80211_hdrlen(fc); 2414 + u16 ethertype_offset; 2415 + __be16 ethertype; 2416 + 2417 + if (!ether_addr_equal(hdr->addr1, rx->sdata->vif.addr)) 2418 + goto drop_check; 2419 + 2420 + /* make sure fixed part of mesh header is there, also checks skb len */ 2421 + if (!pskb_may_pull(rx->skb, hdr_len + 6)) 2422 + goto drop_check; 2423 + 2424 + mesh_hdr = (struct ieee80211s_hdr *)(skb->data + hdr_len); 2425 + ethertype_offset = hdr_len + ieee80211_get_mesh_hdrlen(mesh_hdr) + 2426 + sizeof(rfc1042_header); 2427 + 2428 + if (skb_copy_bits(rx->skb, ethertype_offset, &ethertype, 2) == 0 && 2429 + ethertype == rx->sdata->control_port_protocol) 2430 + return 0; 2431 + } 2432 + 2433 + drop_check: 2410 2434 /* Drop unencrypted frames if key is set. */ 2411 2435 if (unlikely(!ieee80211_has_protected(fc) && 2412 2436 !ieee80211_is_any_nullfunc(fc) &&
+15 -7
net/mac80211/status.c
··· 639 639 u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie; 640 640 struct ieee80211_sub_if_data *sdata; 641 641 struct ieee80211_hdr *hdr = (void *)skb->data; 642 + __be16 ethertype = 0; 643 + 644 + if (skb->len >= ETH_HLEN && skb->protocol == cpu_to_be16(ETH_P_802_3)) 645 + skb_copy_bits(skb, 2 * ETH_ALEN, &ethertype, ETH_TLEN); 642 646 643 647 rcu_read_lock(); 644 648 sdata = ieee80211_sdata_from_skb(local, skb); 645 649 if (sdata) { 646 - if (ieee80211_is_any_nullfunc(hdr->frame_control)) 650 + if (ethertype == sdata->control_port_protocol || 651 + ethertype == cpu_to_be16(ETH_P_PREAUTH)) 652 + cfg80211_control_port_tx_status(&sdata->wdev, 653 + cookie, 654 + skb->data, 655 + skb->len, 656 + acked, 657 + GFP_ATOMIC); 658 + else if (ieee80211_is_any_nullfunc(hdr->frame_control)) 647 659 cfg80211_probe_status(sdata->dev, hdr->addr1, 648 660 cookie, acked, 649 661 info->status.ack_signal, ··· 666 654 skb->data, skb->len, 667 655 acked, GFP_ATOMIC); 668 656 else 669 - cfg80211_control_port_tx_status(&sdata->wdev, 670 - cookie, 671 - skb->data, 672 - skb->len, 673 - acked, 674 - GFP_ATOMIC); 657 + pr_warn("Unknown status report in ack skb\n"); 658 + 675 659 } 676 660 rcu_read_unlock(); 677 661
+6 -2
net/mac80211/tx.c
··· 3996 3996 skb_list_walk_safe(skb, skb, next) { 3997 3997 skb_mark_not_on_list(skb); 3998 3998 3999 + if (skb->protocol == sdata->control_port_protocol) 4000 + ctrl_flags |= IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP; 4001 + 3999 4002 skb = ieee80211_build_hdr(sdata, skb, info_flags, 4000 4003 sta, ctrl_flags, cookie); 4001 4004 if (IS_ERR(skb)) { ··· 4209 4206 (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER))) 4210 4207 ra = sdata->u.mgd.bssid; 4211 4208 4212 - if (!is_valid_ether_addr(ra)) 4209 + if (is_zero_ether_addr(ra)) 4213 4210 goto out_free; 4214 4211 4215 4212 multicast = is_multicast_ether_addr(ra); ··· 5374 5371 return -EINVAL; 5375 5372 5376 5373 if (proto == sdata->control_port_protocol) 5377 - ctrl_flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; 5374 + ctrl_flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO | 5375 + IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP; 5378 5376 5379 5377 if (unencrypted) 5380 5378 flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
+3 -3
net/mptcp/options.c
··· 449 449 } 450 450 451 451 static void mptcp_write_data_fin(struct mptcp_subflow_context *subflow, 452 - struct mptcp_ext *ext) 452 + struct sk_buff *skb, struct mptcp_ext *ext) 453 453 { 454 - if (!ext->use_map) { 454 + if (!ext->use_map || !skb->len) { 455 455 /* RFC6824 requires a DSS mapping with specific values 456 456 * if DATA_FIN is set but no data payload is mapped 457 457 */ ··· 503 503 opts->ext_copy = *mpext; 504 504 505 505 if (skb && tcp_fin && subflow->data_fin_tx_enable) 506 - mptcp_write_data_fin(subflow, &opts->ext_copy); 506 + mptcp_write_data_fin(subflow, skb, &opts->ext_copy); 507 507 ret = true; 508 508 } 509 509
+1 -1
net/netfilter/ipset/ip_set_bitmap_ip.c
··· 326 326 set->variant = &bitmap_ip; 327 327 if (!init_map_ip(set, map, first_ip, last_ip, 328 328 elements, hosts, netmask)) { 329 - kfree(map); 329 + ip_set_free(map); 330 330 return -ENOMEM; 331 331 } 332 332 if (tb[IPSET_ATTR_TIMEOUT]) {
+1 -1
net/netfilter/ipset/ip_set_bitmap_ipmac.c
··· 363 363 map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long); 364 364 set->variant = &bitmap_ipmac; 365 365 if (!init_map_ipmac(set, map, first_ip, last_ip, elements)) { 366 - kfree(map); 366 + ip_set_free(map); 367 367 return -ENOMEM; 368 368 } 369 369 if (tb[IPSET_ATTR_TIMEOUT]) {
+1 -1
net/netfilter/ipset/ip_set_bitmap_port.c
··· 274 274 map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long); 275 275 set->variant = &bitmap_port; 276 276 if (!init_map_port(set, map, first_port, last_port)) { 277 - kfree(map); 277 + ip_set_free(map); 278 278 return -ENOMEM; 279 279 } 280 280 if (tb[IPSET_ATTR_TIMEOUT]) {
+2 -2
net/netfilter/ipset/ip_set_hash_gen.h
··· 682 682 } 683 683 t->hregion = ip_set_alloc(ahash_sizeof_regions(htable_bits)); 684 684 if (!t->hregion) { 685 - kfree(t); 685 + ip_set_free(t); 686 686 ret = -ENOMEM; 687 687 goto out; 688 688 } ··· 1533 1533 } 1534 1534 t->hregion = ip_set_alloc(ahash_sizeof_regions(hbits)); 1535 1535 if (!t->hregion) { 1536 - kfree(t); 1536 + ip_set_free(t); 1537 1537 kfree(h); 1538 1538 return -ENOMEM; 1539 1539 }
+2
net/netfilter/nf_conntrack_core.c
··· 2158 2158 err = __nf_conntrack_update(net, skb, ct, ctinfo); 2159 2159 if (err < 0) 2160 2160 return err; 2161 + 2162 + ct = nf_ct_get(skb, &ctinfo); 2161 2163 } 2162 2164 2163 2165 return nf_confirm_cthelper(skb, ct, ctinfo);
+13 -84
net/netlink/genetlink.c
··· 351 351 start = end = GENL_ID_VFS_DQUOT; 352 352 } 353 353 354 - if (family->maxattr && !family->parallel_ops) { 355 - family->attrbuf = kmalloc_array(family->maxattr + 1, 356 - sizeof(struct nlattr *), 357 - GFP_KERNEL); 358 - if (family->attrbuf == NULL) { 359 - err = -ENOMEM; 360 - goto errout_locked; 361 - } 362 - } else 363 - family->attrbuf = NULL; 364 - 365 354 family->id = idr_alloc_cyclic(&genl_fam_idr, family, 366 355 start, end + 1, GFP_KERNEL); 367 356 if (family->id < 0) { 368 357 err = family->id; 369 - goto errout_free; 358 + goto errout_locked; 370 359 } 371 360 372 361 err = genl_validate_assign_mc_groups(family); ··· 374 385 375 386 errout_remove: 376 387 idr_remove(&genl_fam_idr, family->id); 377 - errout_free: 378 - kfree(family->attrbuf); 379 388 errout_locked: 380 389 genl_unlock_all(); 381 390 return err; ··· 405 418 wait_event(genl_sk_destructing_waitq, 406 419 atomic_read(&genl_sk_destructing_cnt) == 0); 407 420 genl_unlock(); 408 - 409 - kfree(family->attrbuf); 410 421 411 422 genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL, 0); 412 423 ··· 470 485 if (!family->maxattr) 471 486 return NULL; 472 487 473 - if (family->parallel_ops) { 474 - attrbuf = kmalloc_array(family->maxattr + 1, 475 - sizeof(struct nlattr *), GFP_KERNEL); 476 - if (!attrbuf) 477 - return ERR_PTR(-ENOMEM); 478 - } else { 479 - attrbuf = family->attrbuf; 480 - } 488 + attrbuf = kmalloc_array(family->maxattr + 1, 489 + sizeof(struct nlattr *), GFP_KERNEL); 490 + if (!attrbuf) 491 + return ERR_PTR(-ENOMEM); 481 492 482 493 err = __nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr, 483 494 family->policy, validate, extack); 484 495 if (err) { 485 - if (family->parallel_ops) 486 - kfree(attrbuf); 496 + kfree(attrbuf); 487 497 return ERR_PTR(err); 488 498 } 489 499 return attrbuf; 490 500 } 491 501 492 - static void genl_family_rcv_msg_attrs_free(const struct genl_family *family, 493 - struct nlattr **attrbuf) 502 + static void genl_family_rcv_msg_attrs_free(struct nlattr **attrbuf) 494 503 { 495 - if (family->parallel_ops) 496 - kfree(attrbuf); 504 + kfree(attrbuf); 497 505 } 498 506 499 507 struct genl_start_context { ··· 520 542 no_attrs: 521 543 info = genl_dumpit_info_alloc(); 522 544 if (!info) { 523 - genl_family_rcv_msg_attrs_free(ctx->family, attrs); 545 + genl_family_rcv_msg_attrs_free(attrs); 524 546 return -ENOMEM; 525 547 } 526 548 info->family = ctx->family; ··· 537 559 } 538 560 539 561 if (rc) { 540 - genl_family_rcv_msg_attrs_free(info->family, info->attrs); 562 + genl_family_rcv_msg_attrs_free(info->attrs); 541 563 genl_dumpit_info_free(info); 542 564 cb->data = NULL; 543 565 } ··· 566 588 rc = ops->done(cb); 567 589 genl_unlock(); 568 590 } 569 - genl_family_rcv_msg_attrs_free(info->family, info->attrs); 591 + genl_family_rcv_msg_attrs_free(info->attrs); 570 592 genl_dumpit_info_free(info); 571 593 return rc; 572 594 } ··· 579 601 580 602 if (ops->done) 581 603 rc = ops->done(cb); 582 - genl_family_rcv_msg_attrs_free(info->family, info->attrs); 604 + genl_family_rcv_msg_attrs_free(info->attrs); 583 605 genl_dumpit_info_free(info); 584 606 return rc; 585 607 } ··· 672 694 family->post_doit(ops, skb, &info); 673 695 674 696 out: 675 - genl_family_rcv_msg_attrs_free(family, attrbuf); 697 + genl_family_rcv_msg_attrs_free(attrbuf); 676 698 677 699 return err; 678 700 } ··· 1144 1166 .netnsok = true, 1145 1167 }; 1146 1168 1147 - static int genl_bind(struct net *net, int group) 1148 - { 1149 - struct genl_family *f; 1150 - int err = -ENOENT; 1151 - unsigned int id; 1152 - 1153 - down_read(&cb_lock); 1154 - 1155 - idr_for_each_entry(&genl_fam_idr, f, id) { 1156 - if (group >= f->mcgrp_offset && 1157 - group < f->mcgrp_offset + f->n_mcgrps) { 1158 - int fam_grp = group - f->mcgrp_offset; 1159 - 1160 - if (!f->netnsok && net != &init_net) 1161 - err = -ENOENT; 1162 - else if (f->mcast_bind) 1163 - err = f->mcast_bind(net, fam_grp); 1164 - else 1165 - err = 0; 1166 - break; 1167 - } 1168 - } 1169 - up_read(&cb_lock); 1170 - 1171 - return err; 1172 - } 1173 - 1174 - static void genl_unbind(struct net *net, int group) 1175 - { 1176 - struct genl_family *f; 1177 - unsigned int id; 1178 - 1179 - down_read(&cb_lock); 1180 - 1181 - idr_for_each_entry(&genl_fam_idr, f, id) { 1182 - if (group >= f->mcgrp_offset && 1183 - group < f->mcgrp_offset + f->n_mcgrps) { 1184 - int fam_grp = group - f->mcgrp_offset; 1185 - 1186 - if (f->mcast_unbind) 1187 - f->mcast_unbind(net, fam_grp); 1188 - break; 1189 - } 1190 - } 1191 - up_read(&cb_lock); 1192 - } 1193 - 1194 1169 static int __net_init genl_pernet_init(struct net *net) 1195 1170 { 1196 1171 struct netlink_kernel_cfg cfg = { 1197 1172 .input = genl_rcv, 1198 1173 .flags = NL_CFG_F_NONROOT_RECV, 1199 - .bind = genl_bind, 1200 - .unbind = genl_unbind, 1201 1174 }; 1202 1175 1203 1176 /* we'll bump the group number right afterwards */
+8 -2
net/qrtr/qrtr.c
··· 166 166 { 167 167 struct qrtr_node *node = container_of(kref, struct qrtr_node, ref); 168 168 struct radix_tree_iter iter; 169 + struct qrtr_tx_flow *flow; 169 170 unsigned long flags; 170 171 void __rcu **slot; 171 172 ··· 182 181 183 182 /* Free tx flow counters */ 184 183 radix_tree_for_each_slot(slot, &node->qrtr_tx_flow, &iter, 0) { 184 + flow = *slot; 185 185 radix_tree_iter_delete(&node->qrtr_tx_flow, &iter, slot); 186 - kfree(*slot); 186 + kfree(flow); 187 187 } 188 188 kfree(node); 189 189 } ··· 429 427 unsigned int ver; 430 428 size_t hdrlen; 431 429 432 - if (len & 3) 430 + if (len == 0 || len & 3) 433 431 return -EINVAL; 434 432 435 433 skb = netdev_alloc_skb(NULL, len); ··· 443 441 444 442 switch (ver) { 445 443 case QRTR_PROTO_VER_1: 444 + if (len < sizeof(*v1)) 445 + goto err; 446 446 v1 = data; 447 447 hdrlen = sizeof(*v1); 448 448 ··· 458 454 size = le32_to_cpu(v1->size); 459 455 break; 460 456 case QRTR_PROTO_VER_2: 457 + if (len < sizeof(*v2)) 458 + goto err; 461 459 v2 = data; 462 460 hdrlen = sizeof(*v2) + v2->optlen; 463 461
+11
net/rds/connection.c
··· 905 905 } 906 906 EXPORT_SYMBOL_GPL(rds_conn_path_connect_if_down); 907 907 908 + /* Check connectivity of all paths 909 + */ 910 + void rds_check_all_paths(struct rds_connection *conn) 911 + { 912 + int i = 0; 913 + 914 + do { 915 + rds_conn_path_connect_if_down(&conn->c_path[i]); 916 + } while (++i < conn->c_npaths); 917 + } 918 + 908 919 void rds_conn_connect_if_down(struct rds_connection *conn) 909 920 { 910 921 WARN_ON(conn->c_trans->t_mp_capable);
+7
net/rds/rds.h
··· 778 778 void rds_conn_path_drop(struct rds_conn_path *cpath, bool destroy); 779 779 void rds_conn_connect_if_down(struct rds_connection *conn); 780 780 void rds_conn_path_connect_if_down(struct rds_conn_path *cp); 781 + void rds_check_all_paths(struct rds_connection *conn); 781 782 void rds_for_each_conn_info(struct socket *sock, unsigned int len, 782 783 struct rds_info_iterator *iter, 783 784 struct rds_info_lengths *lens, ··· 821 820 rds_conn_path_up(struct rds_conn_path *cp) 822 821 { 823 822 return atomic_read(&cp->cp_state) == RDS_CONN_UP; 823 + } 824 + 825 + static inline int 826 + rds_conn_path_down(struct rds_conn_path *cp) 827 + { 828 + return atomic_read(&cp->cp_state) == RDS_CONN_DOWN; 824 829 } 825 830 826 831 static inline int
+2 -1
net/rds/send.c
··· 1340 1340 goto out; 1341 1341 } 1342 1342 1343 - rds_conn_path_connect_if_down(cpath); 1343 + if (rds_conn_path_down(cpath)) 1344 + rds_check_all_paths(conn); 1344 1345 1345 1346 ret = rds_cong_wait(conn->c_fcong, dport, nonblock, rs); 1346 1347 if (ret) {
+6 -3
net/sched/act_connmark.c
··· 43 43 tcf_lastuse_update(&ca->tcf_tm); 44 44 bstats_update(&ca->tcf_bstats, skb); 45 45 46 - if (skb->protocol == htons(ETH_P_IP)) { 46 + switch (skb_protocol(skb, true)) { 47 + case htons(ETH_P_IP): 47 48 if (skb->len < sizeof(struct iphdr)) 48 49 goto out; 49 50 50 51 proto = NFPROTO_IPV4; 51 - } else if (skb->protocol == htons(ETH_P_IPV6)) { 52 + break; 53 + case htons(ETH_P_IPV6): 52 54 if (skb->len < sizeof(struct ipv6hdr)) 53 55 goto out; 54 56 55 57 proto = NFPROTO_IPV6; 56 - } else { 58 + break; 59 + default: 57 60 goto out; 58 61 } 59 62
+1 -1
net/sched/act_csum.c
··· 587 587 goto drop; 588 588 589 589 update_flags = params->update_flags; 590 - protocol = tc_skb_protocol(skb); 590 + protocol = skb_protocol(skb, false); 591 591 again: 592 592 switch (protocol) { 593 593 case cpu_to_be16(ETH_P_IP):
+6 -5
net/sched/act_ct.c
··· 624 624 { 625 625 u8 family = NFPROTO_UNSPEC; 626 626 627 - switch (skb->protocol) { 627 + switch (skb_protocol(skb, true)) { 628 628 case htons(ETH_P_IP): 629 629 family = NFPROTO_IPV4; 630 630 break; ··· 748 748 const struct nf_nat_range2 *range, 749 749 enum nf_nat_manip_type maniptype) 750 750 { 751 + __be16 proto = skb_protocol(skb, true); 751 752 int hooknum, err = NF_ACCEPT; 752 753 753 754 /* See HOOK2MANIP(). */ ··· 760 759 switch (ctinfo) { 761 760 case IP_CT_RELATED: 762 761 case IP_CT_RELATED_REPLY: 763 - if (skb->protocol == htons(ETH_P_IP) && 762 + if (proto == htons(ETH_P_IP) && 764 763 ip_hdr(skb)->protocol == IPPROTO_ICMP) { 765 764 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo, 766 765 hooknum)) 767 766 err = NF_DROP; 768 767 goto out; 769 - } else if (IS_ENABLED(CONFIG_IPV6) && 770 - skb->protocol == htons(ETH_P_IPV6)) { 768 + } else if (IS_ENABLED(CONFIG_IPV6) && proto == htons(ETH_P_IPV6)) { 771 769 __be16 frag_off; 772 770 u8 nexthdr = ipv6_hdr(skb)->nexthdr; 773 771 int hdrlen = ipv6_skip_exthdr(skb, ··· 924 924 clear = p->ct_action & TCA_CT_ACT_CLEAR; 925 925 force = p->ct_action & TCA_CT_ACT_FORCE; 926 926 tmpl = p->tmpl; 927 + 928 + tcf_lastuse_update(&c->tcf_tm); 927 929 928 930 if (clear) { 929 931 ct = nf_ct_get(skb, &ctinfo); ··· 1552 1550 MODULE_AUTHOR("Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>"); 1553 1551 MODULE_DESCRIPTION("Connection tracking action"); 1554 1552 MODULE_LICENSE("GPL v2"); 1555 -
+6 -3
net/sched/act_ctinfo.c
··· 96 96 action = READ_ONCE(ca->tcf_action); 97 97 98 98 wlen = skb_network_offset(skb); 99 - if (tc_skb_protocol(skb) == htons(ETH_P_IP)) { 99 + switch (skb_protocol(skb, true)) { 100 + case htons(ETH_P_IP): 100 101 wlen += sizeof(struct iphdr); 101 102 if (!pskb_may_pull(skb, wlen)) 102 103 goto out; 103 104 104 105 proto = NFPROTO_IPV4; 105 - } else if (tc_skb_protocol(skb) == htons(ETH_P_IPV6)) { 106 + break; 107 + case htons(ETH_P_IPV6): 106 108 wlen += sizeof(struct ipv6hdr); 107 109 if (!pskb_may_pull(skb, wlen)) 108 110 goto out; 109 111 110 112 proto = NFPROTO_IPV6; 111 - } else { 113 + break; 114 + default: 112 115 goto out; 113 116 } 114 117
+1 -1
net/sched/act_mpls.c
··· 82 82 goto drop; 83 83 break; 84 84 case TCA_MPLS_ACT_PUSH: 85 - new_lse = tcf_mpls_get_lse(NULL, p, !eth_p_mpls(skb->protocol)); 85 + new_lse = tcf_mpls_get_lse(NULL, p, !eth_p_mpls(skb_protocol(skb, true))); 86 86 if (skb_mpls_push(skb, new_lse, p->tcfm_proto, mac_len, 87 87 skb->dev && skb->dev->type == ARPHRD_ETHER)) 88 88 goto drop;
+1 -1
net/sched/act_skbedit.c
··· 41 41 if (params->flags & SKBEDIT_F_INHERITDSFIELD) { 42 42 int wlen = skb_network_offset(skb); 43 43 44 - switch (tc_skb_protocol(skb)) { 44 + switch (skb_protocol(skb, true)) { 45 45 case htons(ETH_P_IP): 46 46 wlen += sizeof(struct iphdr); 47 47 if (!pskb_may_pull(skb, wlen))
+1 -1
net/sched/cls_api.c
··· 1538 1538 reclassify: 1539 1539 #endif 1540 1540 for (; tp; tp = rcu_dereference_bh(tp->next)) { 1541 - __be16 protocol = tc_skb_protocol(skb); 1541 + __be16 protocol = skb_protocol(skb, false); 1542 1542 int err; 1543 1543 1544 1544 if (tp->protocol != protocol &&
+4 -4
net/sched/cls_flow.c
··· 80 80 if (dst) 81 81 return ntohl(dst); 82 82 83 - return addr_fold(skb_dst(skb)) ^ (__force u16) tc_skb_protocol(skb); 83 + return addr_fold(skb_dst(skb)) ^ (__force u16)skb_protocol(skb, true); 84 84 } 85 85 86 86 static u32 flow_get_proto(const struct sk_buff *skb, ··· 104 104 if (flow->ports.ports) 105 105 return ntohs(flow->ports.dst); 106 106 107 - return addr_fold(skb_dst(skb)) ^ (__force u16) tc_skb_protocol(skb); 107 + return addr_fold(skb_dst(skb)) ^ (__force u16)skb_protocol(skb, true); 108 108 } 109 109 110 110 static u32 flow_get_iif(const struct sk_buff *skb) ··· 151 151 static u32 flow_get_nfct_src(const struct sk_buff *skb, 152 152 const struct flow_keys *flow) 153 153 { 154 - switch (tc_skb_protocol(skb)) { 154 + switch (skb_protocol(skb, true)) { 155 155 case htons(ETH_P_IP): 156 156 return ntohl(CTTUPLE(skb, src.u3.ip)); 157 157 case htons(ETH_P_IPV6): ··· 164 164 static u32 flow_get_nfct_dst(const struct sk_buff *skb, 165 165 const struct flow_keys *flow) 166 166 { 167 - switch (tc_skb_protocol(skb)) { 167 + switch (skb_protocol(skb, true)) { 168 168 case htons(ETH_P_IP): 169 169 return ntohl(CTTUPLE(skb, dst.u3.ip)); 170 170 case htons(ETH_P_IPV6):
+1 -1
net/sched/cls_flower.c
··· 313 313 /* skb_flow_dissect() does not set n_proto in case an unknown 314 314 * protocol, so do it rather here. 315 315 */ 316 - skb_key.basic.n_proto = skb->protocol; 316 + skb_key.basic.n_proto = skb_protocol(skb, false); 317 317 skb_flow_dissect_tunnel_info(skb, &mask->dissector, &skb_key); 318 318 skb_flow_dissect_ct(skb, &mask->dissector, &skb_key, 319 319 fl_ct_info_to_flower_map,
+1 -1
net/sched/em_ipset.c
··· 59 59 }; 60 60 int ret, network_offset; 61 61 62 - switch (tc_skb_protocol(skb)) { 62 + switch (skb_protocol(skb, true)) { 63 63 case htons(ETH_P_IP): 64 64 state.pf = NFPROTO_IPV4; 65 65 if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
+1 -1
net/sched/em_ipt.c
··· 212 212 struct nf_hook_state state; 213 213 int ret; 214 214 215 - switch (tc_skb_protocol(skb)) { 215 + switch (skb_protocol(skb, true)) { 216 216 case htons(ETH_P_IP): 217 217 if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) 218 218 return 0;
+1 -1
net/sched/em_meta.c
··· 195 195 META_COLLECTOR(int_protocol) 196 196 { 197 197 /* Let userspace take care of the byte ordering */ 198 - dst->value = tc_skb_protocol(skb); 198 + dst->value = skb_protocol(skb, false); 199 199 } 200 200 201 201 META_COLLECTOR(int_pkttype)
+4 -4
net/sched/sch_atm.c
··· 553 553 if (!p->link.q) 554 554 p->link.q = &noop_qdisc; 555 555 pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q); 556 + p->link.vcc = NULL; 557 + p->link.sock = NULL; 558 + p->link.common.classid = sch->handle; 559 + p->link.ref = 1; 556 560 557 561 err = tcf_block_get(&p->link.block, &p->link.filter_list, sch, 558 562 extack); 559 563 if (err) 560 564 return err; 561 565 562 - p->link.vcc = NULL; 563 - p->link.sock = NULL; 564 - p->link.common.classid = sch->handle; 565 - p->link.ref = 1; 566 566 tasklet_init(&p->task, sch_atm_dequeue, (unsigned long)sch); 567 567 return 0; 568 568 }
+2 -2
net/sched/sch_cake.c
··· 592 592 bool rev = !skb->_nfct, upd = false; 593 593 __be32 ip; 594 594 595 - if (tc_skb_protocol(skb) != htons(ETH_P_IP)) 595 + if (skb_protocol(skb, true) != htons(ETH_P_IP)) 596 596 return false; 597 597 598 598 if (!nf_ct_get_tuple_skb(&tuple, skb)) ··· 1557 1557 u16 *buf, buf_; 1558 1558 u8 dscp; 1559 1559 1560 - switch (tc_skb_protocol(skb)) { 1560 + switch (skb_protocol(skb, true)) { 1561 1561 case htons(ETH_P_IP): 1562 1562 buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); 1563 1563 if (unlikely(!buf))
+3 -3
net/sched/sch_dsmark.c
··· 210 210 if (p->set_tc_index) { 211 211 int wlen = skb_network_offset(skb); 212 212 213 - switch (tc_skb_protocol(skb)) { 213 + switch (skb_protocol(skb, true)) { 214 214 case htons(ETH_P_IP): 215 215 wlen += sizeof(struct iphdr); 216 216 if (!pskb_may_pull(skb, wlen) || ··· 303 303 index = skb->tc_index & (p->indices - 1); 304 304 pr_debug("index %d->%d\n", skb->tc_index, index); 305 305 306 - switch (tc_skb_protocol(skb)) { 306 + switch (skb_protocol(skb, true)) { 307 307 case htons(ETH_P_IP): 308 308 ipv4_change_dsfield(ip_hdr(skb), p->mv[index].mask, 309 309 p->mv[index].value); ··· 320 320 */ 321 321 if (p->mv[index].mask != 0xff || p->mv[index].value) 322 322 pr_warn("%s: unsupported protocol %d\n", 323 - __func__, ntohs(tc_skb_protocol(skb))); 323 + __func__, ntohs(skb_protocol(skb, true))); 324 324 break; 325 325 } 326 326
+1 -1
net/sched/sch_teql.c
··· 239 239 char haddr[MAX_ADDR_LEN]; 240 240 241 241 neigh_ha_snapshot(haddr, n, dev); 242 - err = dev_hard_header(skb, dev, ntohs(tc_skb_protocol(skb)), 242 + err = dev_hard_header(skb, dev, ntohs(skb_protocol(skb, false)), 243 243 haddr, NULL, skb->len); 244 244 245 245 if (err < 0)
+32 -13
net/smc/smc_clc.c
··· 27 27 28 28 #define SMCR_CLC_ACCEPT_CONFIRM_LEN 68 29 29 #define SMCD_CLC_ACCEPT_CONFIRM_LEN 48 30 + #define SMC_CLC_RECV_BUF_LEN 100 30 31 31 32 /* eye catcher "SMCR" EBCDIC for CLC messages */ 32 33 static const char SMC_EYECATCHER[4] = {'\xe2', '\xd4', '\xc3', '\xd9'}; ··· 37 36 /* check if received message has a correct header length and contains valid 38 37 * heading and trailing eyecatchers 39 38 */ 40 - static bool smc_clc_msg_hdr_valid(struct smc_clc_msg_hdr *clcm) 39 + static bool smc_clc_msg_hdr_valid(struct smc_clc_msg_hdr *clcm, bool check_trl) 41 40 { 42 41 struct smc_clc_msg_proposal_prefix *pclc_prfx; 43 42 struct smc_clc_msg_accept_confirm *clc; ··· 50 49 return false; 51 50 switch (clcm->type) { 52 51 case SMC_CLC_PROPOSAL: 53 - if (clcm->path != SMC_TYPE_R && clcm->path != SMC_TYPE_D && 54 - clcm->path != SMC_TYPE_B) 55 - return false; 56 52 pclc = (struct smc_clc_msg_proposal *)clcm; 57 53 pclc_prfx = smc_clc_proposal_get_prefix(pclc); 58 - if (ntohs(pclc->hdr.length) != 54 + if (ntohs(pclc->hdr.length) < 59 55 sizeof(*pclc) + ntohs(pclc->iparea_offset) + 60 56 sizeof(*pclc_prfx) + 61 57 pclc_prfx->ipv6_prefixes_cnt * ··· 84 86 default: 85 87 return false; 86 88 } 87 - if (memcmp(trl->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)) && 89 + if (check_trl && 90 + memcmp(trl->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)) && 88 91 memcmp(trl->eyecatcher, SMCD_EYECATCHER, sizeof(SMCD_EYECATCHER))) 89 92 return false; 90 93 return true; ··· 275 276 struct msghdr msg = {NULL, 0}; 276 277 int reason_code = 0; 277 278 struct kvec vec = {buf, buflen}; 278 - int len, datlen; 279 + int len, datlen, recvlen; 280 + bool check_trl = true; 279 281 int krflags; 280 282 281 283 /* peek the first few bytes to determine length of data to receive ··· 320 320 } 321 321 datlen = ntohs(clcm->length); 322 322 if ((len < sizeof(struct smc_clc_msg_hdr)) || 323 - (datlen > buflen) || 324 - (clcm->version != SMC_CLC_V1) || 325 - (clcm->path != SMC_TYPE_R && clcm->path != SMC_TYPE_D && 326 - clcm->path != SMC_TYPE_B) || 323 + (clcm->version < SMC_CLC_V1) || 327 324 ((clcm->type != SMC_CLC_DECLINE) && 328 325 (clcm->type != expected_type))) { 329 326 smc->sk.sk_err = EPROTO; ··· 328 331 goto out; 329 332 } 330 333 334 + if (clcm->type == SMC_CLC_PROPOSAL && clcm->path == SMC_TYPE_N) 335 + reason_code = SMC_CLC_DECL_VERSMISMAT; /* just V2 offered */ 336 + 331 337 /* receive the complete CLC message */ 332 338 memset(&msg, 0, sizeof(struct msghdr)); 333 - iov_iter_kvec(&msg.msg_iter, READ, &vec, 1, datlen); 339 + if (datlen > buflen) { 340 + check_trl = false; 341 + recvlen = buflen; 342 + } else { 343 + recvlen = datlen; 344 + } 345 + iov_iter_kvec(&msg.msg_iter, READ, &vec, 1, recvlen); 334 346 krflags = MSG_WAITALL; 335 347 len = sock_recvmsg(smc->clcsock, &msg, krflags); 336 - if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) { 348 + if (len < recvlen || !smc_clc_msg_hdr_valid(clcm, check_trl)) { 337 349 smc->sk.sk_err = EPROTO; 338 350 reason_code = -EPROTO; 339 351 goto out; 352 + } 353 + datlen -= len; 354 + while (datlen) { 355 + u8 tmp[SMC_CLC_RECV_BUF_LEN]; 356 + 357 + vec.iov_base = &tmp; 358 + vec.iov_len = SMC_CLC_RECV_BUF_LEN; 359 + /* receive remaining proposal message */ 360 + recvlen = datlen > SMC_CLC_RECV_BUF_LEN ? 361 + SMC_CLC_RECV_BUF_LEN : datlen; 362 + iov_iter_kvec(&msg.msg_iter, READ, &vec, 1, recvlen); 363 + len = sock_recvmsg(smc->clcsock, &msg, krflags); 364 + datlen -= len; 340 365 } 341 366 if (clcm->type == SMC_CLC_DECLINE) { 342 367 struct smc_clc_msg_decline *dclc;
+2
net/smc/smc_clc.h
··· 25 25 #define SMC_CLC_V1 0x1 /* SMC version */ 26 26 #define SMC_TYPE_R 0 /* SMC-R only */ 27 27 #define SMC_TYPE_D 1 /* SMC-D only */ 28 + #define SMC_TYPE_N 2 /* neither SMC-R nor SMC-D */ 28 29 #define SMC_TYPE_B 3 /* SMC-R and SMC-D */ 29 30 #define CLC_WAIT_TIME (6 * HZ) /* max. wait time on clcsock */ 30 31 #define CLC_WAIT_TIME_SHORT HZ /* short wait time on clcsock */ ··· 47 46 #define SMC_CLC_DECL_ISMVLANERR 0x03090000 /* err to reg vlan id on ism dev */ 48 47 #define SMC_CLC_DECL_NOACTLINK 0x030a0000 /* no active smc-r link in lgr */ 49 48 #define SMC_CLC_DECL_NOSRVLINK 0x030b0000 /* SMC-R link from srv not found */ 49 + #define SMC_CLC_DECL_VERSMISMAT 0x030c0000 /* SMC version mismatch */ 50 50 #define SMC_CLC_DECL_SYNCERR 0x04000000 /* synchronization error */ 51 51 #define SMC_CLC_DECL_PEERDECL 0x05000000 /* peer declined during handshake */ 52 52 #define SMC_CLC_DECL_INTERR 0x09990000 /* internal error */
+29 -22
net/smc/smc_core.c
··· 15 15 #include <linux/workqueue.h> 16 16 #include <linux/wait.h> 17 17 #include <linux/reboot.h> 18 + #include <linux/mutex.h> 18 19 #include <net/tcp.h> 19 20 #include <net/sock.h> 20 21 #include <rdma/ib_verbs.h> ··· 248 247 if (smc_link_usable(lnk)) 249 248 lnk->state = SMC_LNK_INACTIVE; 250 249 } 251 - wake_up_interruptible_all(&lgr->llc_waiter); 250 + wake_up_all(&lgr->llc_msg_waiter); 251 + wake_up_all(&lgr->llc_flow_waiter); 252 252 } 253 253 254 254 static void smc_lgr_free(struct smc_link_group *lgr); ··· 1132 1130 return; 1133 1131 if (lgr->llc_flow_lcl.type != SMC_LLC_FLOW_NONE) { 1134 1132 /* some other llc task is ongoing */ 1135 - wait_event_interruptible_timeout(lgr->llc_waiter, 1136 - (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_NONE), 1133 + wait_event_timeout(lgr->llc_flow_waiter, 1134 + (list_empty(&lgr->list) || 1135 + lgr->llc_flow_lcl.type == SMC_LLC_FLOW_NONE), 1137 1136 SMC_LLC_WAIT_TIME); 1138 1137 } 1139 - if (list_empty(&lgr->list) || 1140 - !smc_ib_port_active(smcibdev, ibport)) 1141 - return; /* lgr or device no longer active */ 1142 - link = smc_llc_usable_link(lgr); 1143 - if (!link) 1144 - return; 1145 - smc_llc_send_add_link(link, smcibdev->mac[ibport - 1], gid, 1146 - NULL, SMC_LLC_REQ); 1138 + /* lgr or device no longer active? */ 1139 + if (!list_empty(&lgr->list) && 1140 + smc_ib_port_active(smcibdev, ibport)) 1141 + link = smc_llc_usable_link(lgr); 1142 + if (link) 1143 + smc_llc_send_add_link(link, smcibdev->mac[ibport - 1], 1144 + gid, NULL, SMC_LLC_REQ); 1145 + wake_up(&lgr->llc_flow_waiter); /* wake up next waiter */ 1147 1146 } 1148 1147 } 1149 1148 ··· 1198 1195 if (lgr->llc_flow_lcl.type != SMC_LLC_FLOW_NONE) { 1199 1196 /* another llc task is ongoing */ 1200 1197 mutex_unlock(&lgr->llc_conf_mutex); 1201 - wait_event_interruptible_timeout(lgr->llc_waiter, 1202 - (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_NONE), 1198 + wait_event_timeout(lgr->llc_flow_waiter, 1199 + (list_empty(&lgr->list) || 1200 + lgr->llc_flow_lcl.type == SMC_LLC_FLOW_NONE), 1203 1201 SMC_LLC_WAIT_TIME); 1204 1202 mutex_lock(&lgr->llc_conf_mutex); 1205 1203 } 1206 - smc_llc_send_delete_link(to_lnk, del_link_id, SMC_LLC_REQ, true, 1207 - SMC_LLC_DEL_LOST_PATH); 1204 + if (!list_empty(&lgr->list)) 1205 + smc_llc_send_delete_link(to_lnk, del_link_id, 1206 + SMC_LLC_REQ, true, 1207 + SMC_LLC_DEL_LOST_PATH); 1208 + wake_up(&lgr->llc_flow_waiter); /* wake up next waiter */ 1208 1209 } 1209 1210 } 1210 1211 ··· 1269 1262 1270 1263 if (list_empty(&lgr->list)) 1271 1264 return; 1272 - wake_up_interruptible_all(&lgr->llc_waiter); 1265 + wake_up_all(&lgr->llc_msg_waiter); 1273 1266 mutex_lock(&lgr->llc_conf_mutex); 1274 1267 smcr_link_down(link); 1275 1268 mutex_unlock(&lgr->llc_conf_mutex); ··· 1962 1955 struct smc_ib_device *smcibdev; 1963 1956 struct smcd_dev *smcd; 1964 1957 1965 - spin_lock(&smc_ib_devices.lock); 1958 + mutex_lock(&smc_ib_devices.mutex); 1966 1959 list_for_each_entry(smcibdev, &smc_ib_devices.list, list) { 1967 1960 int i; 1968 1961 1969 1962 for (i = 0; i < SMC_MAX_PORTS; i++) 1970 1963 set_bit(i, smcibdev->ports_going_away); 1971 1964 } 1972 - spin_unlock(&smc_ib_devices.lock); 1965 + mutex_unlock(&smc_ib_devices.mutex); 1973 1966 1974 - spin_lock(&smcd_dev_list.lock); 1967 + mutex_lock(&smcd_dev_list.mutex); 1975 1968 list_for_each_entry(smcd, &smcd_dev_list.list, list) { 1976 1969 smcd->going_away = 1; 1977 1970 } 1978 - spin_unlock(&smcd_dev_list.lock); 1971 + mutex_unlock(&smcd_dev_list.mutex); 1979 1972 } 1980 1973 1981 1974 /* Clean up all SMC link groups */ ··· 1987 1980 1988 1981 smc_smcr_terminate_all(NULL); 1989 1982 1990 - spin_lock(&smcd_dev_list.lock); 1983 + mutex_lock(&smcd_dev_list.mutex); 1991 1984 list_for_each_entry(smcd, &smcd_dev_list.list, list) 1992 1985 smc_smcd_terminate_all(smcd); 1993 - spin_unlock(&smcd_dev_list.lock); 1986 + mutex_unlock(&smcd_dev_list.mutex); 1994 1987 } 1995 1988 1996 1989 static int smc_core_reboot_event(struct notifier_block *this,
+3 -1
net/smc/smc_core.h
··· 262 262 struct work_struct llc_del_link_work; 263 263 struct work_struct llc_event_work; 264 264 /* llc event worker */ 265 - wait_queue_head_t llc_waiter; 265 + wait_queue_head_t llc_flow_waiter; 266 266 /* w4 next llc event */ 267 + wait_queue_head_t llc_msg_waiter; 268 + /* w4 next llc msg */ 267 269 struct smc_llc_flow llc_flow_lcl; 268 270 /* llc local control field */ 269 271 struct smc_llc_flow llc_flow_rmt;
+6 -5
net/smc/smc_ib.c
··· 16 16 #include <linux/workqueue.h> 17 17 #include <linux/scatterlist.h> 18 18 #include <linux/wait.h> 19 + #include <linux/mutex.h> 19 20 #include <rdma/ib_verbs.h> 20 21 #include <rdma/ib_cache.h> 21 22 ··· 34 33 #define SMC_QP_RNR_RETRY 7 /* 7: infinite */ 35 34 36 35 struct smc_ib_devices smc_ib_devices = { /* smc-registered ib devices */ 37 - .lock = __SPIN_LOCK_UNLOCKED(smc_ib_devices.lock), 36 + .mutex = __MUTEX_INITIALIZER(smc_ib_devices.mutex), 38 37 .list = LIST_HEAD_INIT(smc_ib_devices.list), 39 38 }; 40 39 ··· 566 565 INIT_WORK(&smcibdev->port_event_work, smc_ib_port_event_work); 567 566 atomic_set(&smcibdev->lnk_cnt, 0); 568 567 init_waitqueue_head(&smcibdev->lnks_deleted); 569 - spin_lock(&smc_ib_devices.lock); 568 + mutex_lock(&smc_ib_devices.mutex); 570 569 list_add_tail(&smcibdev->list, &smc_ib_devices.list); 571 - spin_unlock(&smc_ib_devices.lock); 570 + mutex_unlock(&smc_ib_devices.mutex); 572 571 ib_set_client_data(ibdev, &smc_ib_client, smcibdev); 573 572 INIT_IB_EVENT_HANDLER(&smcibdev->event_handler, smcibdev->ibdev, 574 573 smc_ib_global_event_handler); ··· 603 602 { 604 603 struct smc_ib_device *smcibdev = client_data; 605 604 606 - spin_lock(&smc_ib_devices.lock); 605 + mutex_lock(&smc_ib_devices.mutex); 607 606 list_del_init(&smcibdev->list); /* remove from smc_ib_devices */ 608 - spin_unlock(&smc_ib_devices.lock); 607 + mutex_unlock(&smc_ib_devices.mutex); 609 608 pr_warn_ratelimited("smc: removing ib device %s\n", 610 609 smcibdev->ibdev->name); 611 610 smc_smcr_terminate_all(smcibdev);
+2 -1
net/smc/smc_ib.h
··· 14 14 15 15 #include <linux/interrupt.h> 16 16 #include <linux/if_ether.h> 17 + #include <linux/mutex.h> 17 18 #include <linux/wait.h> 18 19 #include <rdma/ib_verbs.h> 19 20 #include <net/smc.h> ··· 26 25 27 26 struct smc_ib_devices { /* list of smc ib devices definition */ 28 27 struct list_head list; 29 - spinlock_t lock; /* protects list of smc ib devices */ 28 + struct mutex mutex; /* protects list of smc ib devices */ 30 29 }; 31 30 32 31 extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */
+6 -5
net/smc/smc_ism.c
··· 7 7 */ 8 8 9 9 #include <linux/spinlock.h> 10 + #include <linux/mutex.h> 10 11 #include <linux/slab.h> 11 12 #include <asm/page.h> 12 13 ··· 18 17 19 18 struct smcd_dev_list smcd_dev_list = { 20 19 .list = LIST_HEAD_INIT(smcd_dev_list.list), 21 - .lock = __SPIN_LOCK_UNLOCKED(smcd_dev_list.lock) 20 + .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex) 22 21 }; 23 22 24 23 /* Test if an ISM communication is possible. */ ··· 318 317 319 318 int smcd_register_dev(struct smcd_dev *smcd) 320 319 { 321 - spin_lock(&smcd_dev_list.lock); 320 + mutex_lock(&smcd_dev_list.mutex); 322 321 list_add_tail(&smcd->list, &smcd_dev_list.list); 323 - spin_unlock(&smcd_dev_list.lock); 322 + mutex_unlock(&smcd_dev_list.mutex); 324 323 325 324 pr_warn_ratelimited("smc: adding smcd device %s with pnetid %.16s%s\n", 326 325 dev_name(&smcd->dev), smcd->pnetid, ··· 334 333 { 335 334 pr_warn_ratelimited("smc: removing smcd device %s\n", 336 335 dev_name(&smcd->dev)); 337 - spin_lock(&smcd_dev_list.lock); 336 + mutex_lock(&smcd_dev_list.mutex); 338 337 list_del_init(&smcd->list); 339 - spin_unlock(&smcd_dev_list.lock); 338 + mutex_unlock(&smcd_dev_list.mutex); 340 339 smcd->going_away = 1; 341 340 smc_smcd_terminate_all(smcd); 342 341 flush_workqueue(smcd->event_wq);
+2 -1
net/smc/smc_ism.h
··· 10 10 #define SMCD_ISM_H 11 11 12 12 #include <linux/uio.h> 13 + #include <linux/mutex.h> 13 14 14 15 #include "smc.h" 15 16 16 17 struct smcd_dev_list { /* List of SMCD devices */ 17 18 struct list_head list; 18 - spinlock_t lock; /* Protects list of devices */ 19 + struct mutex mutex; /* Protects list of devices */ 19 20 }; 20 21 21 22 extern struct smcd_dev_list smcd_dev_list; /* list of smcd devices */
+56 -35
net/smc/smc_llc.c
··· 186 186 flow->qentry = qentry; 187 187 } 188 188 189 + static void smc_llc_flow_parallel(struct smc_link_group *lgr, u8 flow_type, 190 + struct smc_llc_qentry *qentry) 191 + { 192 + u8 msg_type = qentry->msg.raw.hdr.common.type; 193 + 194 + if ((msg_type == SMC_LLC_ADD_LINK || msg_type == SMC_LLC_DELETE_LINK) && 195 + flow_type != msg_type && !lgr->delayed_event) { 196 + lgr->delayed_event = qentry; 197 + return; 198 + } 199 + /* drop parallel or already-in-progress llc requests */ 200 + if (flow_type != msg_type) 201 + pr_warn_once("smc: SMC-R lg %*phN dropped parallel " 202 + "LLC msg: msg %d flow %d role %d\n", 203 + SMC_LGR_ID_SIZE, &lgr->id, 204 + qentry->msg.raw.hdr.common.type, 205 + flow_type, lgr->role); 206 + kfree(qentry); 207 + } 208 + 189 209 /* try to start a new llc flow, initiated by an incoming llc msg */ 190 210 static bool smc_llc_flow_start(struct smc_llc_flow *flow, 191 211 struct smc_llc_qentry *qentry) ··· 215 195 spin_lock_bh(&lgr->llc_flow_lock); 216 196 if (flow->type) { 217 197 /* a flow is already active */ 218 - if ((qentry->msg.raw.hdr.common.type == SMC_LLC_ADD_LINK || 219 - qentry->msg.raw.hdr.common.type == SMC_LLC_DELETE_LINK) && 220 - !lgr->delayed_event) { 221 - lgr->delayed_event = qentry; 222 - } else { 223 - /* forget this llc request */ 224 - kfree(qentry); 225 - } 198 + smc_llc_flow_parallel(lgr, flow->type, qentry); 226 199 spin_unlock_bh(&lgr->llc_flow_lock); 227 200 return false; 228 201 } ··· 235 222 } 236 223 if (qentry == lgr->delayed_event) 237 224 lgr->delayed_event = NULL; 238 - spin_unlock_bh(&lgr->llc_flow_lock); 239 225 smc_llc_flow_qentry_set(flow, qentry); 226 + spin_unlock_bh(&lgr->llc_flow_lock); 240 227 return true; 241 228 } 242 229 ··· 264 251 return 0; 265 252 } 266 253 spin_unlock_bh(&lgr->llc_flow_lock); 267 - rc = wait_event_interruptible_timeout(lgr->llc_waiter, 268 - (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_NONE && 269 - (lgr->llc_flow_rmt.type == SMC_LLC_FLOW_NONE || 270 - lgr->llc_flow_rmt.type == allowed_remote)), 271 - SMC_LLC_WAIT_TIME); 254 + rc = wait_event_timeout(lgr->llc_flow_waiter, (list_empty(&lgr->list) || 255 + (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_NONE && 256 + (lgr->llc_flow_rmt.type == SMC_LLC_FLOW_NONE || 257 + lgr->llc_flow_rmt.type == allowed_remote))), 258 + SMC_LLC_WAIT_TIME * 10); 272 259 if (!rc) 273 260 return -ETIMEDOUT; 274 261 goto again; ··· 285 272 flow == &lgr->llc_flow_lcl) 286 273 schedule_work(&lgr->llc_event_work); 287 274 else 288 - wake_up_interruptible(&lgr->llc_waiter); 275 + wake_up(&lgr->llc_flow_waiter); 289 276 } 290 277 291 278 /* lnk is optional and used for early wakeup when link goes down, useful in ··· 296 283 int time_out, u8 exp_msg) 297 284 { 298 285 struct smc_llc_flow *flow = &lgr->llc_flow_lcl; 286 + u8 rcv_msg; 299 287 300 - wait_event_interruptible_timeout(lgr->llc_waiter, 301 - (flow->qentry || 302 - (lnk && !smc_link_usable(lnk)) || 303 - list_empty(&lgr->list)), 304 - time_out); 288 + wait_event_timeout(lgr->llc_msg_waiter, 289 + (flow->qentry || 290 + (lnk && !smc_link_usable(lnk)) || 291 + list_empty(&lgr->list)), 292 + time_out); 305 293 if (!flow->qentry || 306 294 (lnk && !smc_link_usable(lnk)) || list_empty(&lgr->list)) { 307 295 smc_llc_flow_qentry_del(flow); 308 296 goto out; 309 297 } 310 - if (exp_msg && flow->qentry->msg.raw.hdr.common.type != exp_msg) { 298 + rcv_msg = flow->qentry->msg.raw.hdr.common.type; 299 + if (exp_msg && rcv_msg != exp_msg) { 311 300 if (exp_msg == SMC_LLC_ADD_LINK && 312 - flow->qentry->msg.raw.hdr.common.type == 313 - SMC_LLC_DELETE_LINK) { 301 + rcv_msg == SMC_LLC_DELETE_LINK) { 314 302 /* flow_start will delay the unexpected msg */ 315 303 smc_llc_flow_start(&lgr->llc_flow_lcl, 316 304 smc_llc_flow_qentry_clr(flow)); 317 305 return NULL; 318 306 } 307 + pr_warn_once("smc: SMC-R lg %*phN dropped unexpected LLC msg: " 308 + "msg %d exp %d flow %d role %d flags %x\n", 309 + SMC_LGR_ID_SIZE, &lgr->id, rcv_msg, exp_msg, 310 + flow->type, lgr->role, 311 + flow->qentry->msg.raw.hdr.flags); 319 312 smc_llc_flow_qentry_del(flow); 320 313 } 321 314 out: ··· 1241 1222 smc_llc_send_message(lnk, &qentry->msg); /* response */ 1242 1223 1243 1224 if (smc_link_downing(&lnk_del->state)) { 1244 - smc_switch_conns(lgr, lnk_del, false); 1245 - smc_wr_tx_wait_no_pending_sends(lnk_del); 1225 + if (smc_switch_conns(lgr, lnk_del, false)) 1226 + smc_wr_tx_wait_no_pending_sends(lnk_del); 1246 1227 } 1247 1228 smcr_link_clear(lnk_del, true); 1248 1229 ··· 1316 1297 goto out; /* asymmetric link already deleted */ 1317 1298 1318 1299 if (smc_link_downing(&lnk_del->state)) { 1319 - smc_switch_conns(lgr, lnk_del, false); 1320 - smc_wr_tx_wait_no_pending_sends(lnk_del); 1300 + if (smc_switch_conns(lgr, lnk_del, false)) 1301 + smc_wr_tx_wait_no_pending_sends(lnk_del); 1321 1302 } 1322 1303 if (!list_empty(&lgr->list)) { 1323 1304 /* qentry is either a request from peer (send it back to ··· 1478 1459 /* a flow is waiting for this message */ 1479 1460 smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, 1480 1461 qentry); 1481 - wake_up_interruptible(&lgr->llc_waiter); 1462 + wake_up(&lgr->llc_msg_waiter); 1482 1463 } else if (smc_llc_flow_start(&lgr->llc_flow_lcl, 1483 1464 qentry)) { 1484 1465 schedule_work(&lgr->llc_add_link_work); ··· 1493 1474 if (lgr->llc_flow_lcl.type != SMC_LLC_FLOW_NONE) { 1494 1475 /* a flow is waiting for this message */ 1495 1476 smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, qentry); 1496 - wake_up_interruptible(&lgr->llc_waiter); 1477 + wake_up(&lgr->llc_msg_waiter); 1497 1478 return; 1498 1479 } 1499 1480 break; ··· 1504 1485 /* DEL LINK REQ during ADD LINK SEQ */ 1505 1486 smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, 1506 1487 qentry); 1507 - wake_up_interruptible(&lgr->llc_waiter); 1488 + wake_up(&lgr->llc_msg_waiter); 1508 1489 } else if (smc_llc_flow_start(&lgr->llc_flow_lcl, 1509 1490 qentry)) { 1510 1491 schedule_work(&lgr->llc_del_link_work); ··· 1515 1496 /* DEL LINK REQ during ADD LINK SEQ */ 1516 1497 smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, 1517 1498 qentry); 1518 - wake_up_interruptible(&lgr->llc_waiter); 1499 + wake_up(&lgr->llc_msg_waiter); 1519 1500 } else if (smc_llc_flow_start(&lgr->llc_flow_lcl, 1520 1501 qentry)) { 1521 1502 schedule_work(&lgr->llc_del_link_work); ··· 1600 1581 case SMC_LLC_DELETE_RKEY: 1601 1582 /* assign responses to the local flow, we requested them */ 1602 1583 smc_llc_flow_qentry_set(&link->lgr->llc_flow_lcl, qentry); 1603 - wake_up_interruptible(&link->lgr->llc_waiter); 1584 + wake_up(&link->lgr->llc_msg_waiter); 1604 1585 return; 1605 1586 case SMC_LLC_CONFIRM_RKEY_CONT: 1606 1587 /* not used because max links is 3 */ ··· 1635 1616 spin_lock_irqsave(&lgr->llc_event_q_lock, flags); 1636 1617 list_add_tail(&qentry->list, &lgr->llc_event_q); 1637 1618 spin_unlock_irqrestore(&lgr->llc_event_q_lock, flags); 1638 - schedule_work(&link->lgr->llc_event_work); 1619 + schedule_work(&lgr->llc_event_work); 1639 1620 } 1640 1621 1641 1622 /* copy received msg and add it to the event queue */ ··· 1696 1677 INIT_LIST_HEAD(&lgr->llc_event_q); 1697 1678 spin_lock_init(&lgr->llc_event_q_lock); 1698 1679 spin_lock_init(&lgr->llc_flow_lock); 1699 - init_waitqueue_head(&lgr->llc_waiter); 1680 + init_waitqueue_head(&lgr->llc_flow_waiter); 1681 + init_waitqueue_head(&lgr->llc_msg_waiter); 1700 1682 mutex_init(&lgr->llc_conf_mutex); 1701 1683 lgr->llc_testlink_time = net->ipv4.sysctl_tcp_keepalive_time; 1702 1684 } ··· 1706 1686 void smc_llc_lgr_clear(struct smc_link_group *lgr) 1707 1687 { 1708 1688 smc_llc_event_flush(lgr); 1709 - wake_up_interruptible_all(&lgr->llc_waiter); 1689 + wake_up_all(&lgr->llc_flow_waiter); 1690 + wake_up_all(&lgr->llc_msg_waiter); 1710 1691 cancel_work_sync(&lgr->llc_event_work); 1711 1692 cancel_work_sync(&lgr->llc_add_link_work); 1712 1693 cancel_work_sync(&lgr->llc_del_link_work);
+19 -18
net/smc/smc_pnet.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/list.h> 14 14 #include <linux/ctype.h> 15 + #include <linux/mutex.h> 15 16 #include <net/netlink.h> 16 17 #include <net/genetlink.h> 17 18 ··· 130 129 return rc; 131 130 132 131 /* remove ib devices */ 133 - spin_lock(&smc_ib_devices.lock); 132 + mutex_lock(&smc_ib_devices.mutex); 134 133 list_for_each_entry(ibdev, &smc_ib_devices.list, list) { 135 134 for (ibport = 0; ibport < SMC_MAX_PORTS; ibport++) { 136 135 if (ibdev->pnetid_by_user[ibport] && ··· 150 149 } 151 150 } 152 151 } 153 - spin_unlock(&smc_ib_devices.lock); 152 + mutex_unlock(&smc_ib_devices.mutex); 154 153 /* remove smcd devices */ 155 - spin_lock(&smcd_dev_list.lock); 154 + mutex_lock(&smcd_dev_list.mutex); 156 155 list_for_each_entry(smcd_dev, &smcd_dev_list.list, list) { 157 156 if (smcd_dev->pnetid_by_user && 158 157 (!pnet_name || ··· 166 165 rc = 0; 167 166 } 168 167 } 169 - spin_unlock(&smcd_dev_list.lock); 168 + mutex_unlock(&smcd_dev_list.mutex); 170 169 return rc; 171 170 } 172 171 ··· 241 240 u8 pnet_null[SMC_MAX_PNETID_LEN] = {0}; 242 241 bool applied = false; 243 242 244 - spin_lock(&smc_ib_devices.lock); 243 + mutex_lock(&smc_ib_devices.mutex); 245 244 if (smc_pnet_match(ib_dev->pnetid[ib_port - 1], pnet_null)) { 246 245 memcpy(ib_dev->pnetid[ib_port - 1], pnet_name, 247 246 SMC_MAX_PNETID_LEN); 248 247 ib_dev->pnetid_by_user[ib_port - 1] = true; 249 248 applied = true; 250 249 } 251 - spin_unlock(&smc_ib_devices.lock); 250 + mutex_unlock(&smc_ib_devices.mutex); 252 251 return applied; 253 252 } 254 253 ··· 259 258 u8 pnet_null[SMC_MAX_PNETID_LEN] = {0}; 260 259 bool applied = false; 261 260 262 - spin_lock(&smcd_dev_list.lock); 261 + mutex_lock(&smcd_dev_list.mutex); 263 262 if (smc_pnet_match(smcd_dev->pnetid, pnet_null)) { 264 263 memcpy(smcd_dev->pnetid, pnet_name, SMC_MAX_PNETID_LEN); 265 264 smcd_dev->pnetid_by_user = true; 266 265 applied = true; 267 266 } 268 - spin_unlock(&smcd_dev_list.lock); 267 + mutex_unlock(&smcd_dev_list.mutex); 269 268 return applied; 270 269 } 271 270 ··· 301 300 { 302 301 struct smc_ib_device *ibdev; 303 302 304 - spin_lock(&smc_ib_devices.lock); 303 + mutex_lock(&smc_ib_devices.mutex); 305 304 list_for_each_entry(ibdev, &smc_ib_devices.list, list) { 306 305 if (!strncmp(ibdev->ibdev->name, ib_name, 307 306 sizeof(ibdev->ibdev->name)) || ··· 312 311 } 313 312 ibdev = NULL; 314 313 out: 315 - spin_unlock(&smc_ib_devices.lock); 314 + mutex_unlock(&smc_ib_devices.mutex); 316 315 return ibdev; 317 316 } 318 317 ··· 321 320 { 322 321 struct smcd_dev *smcd_dev; 323 322 324 - spin_lock(&smcd_dev_list.lock); 323 + mutex_lock(&smcd_dev_list.mutex); 325 324 list_for_each_entry(smcd_dev, &smcd_dev_list.list, list) { 326 325 if (!strncmp(dev_name(&smcd_dev->dev), smcd_name, 327 326 IB_DEVICE_NAME_MAX - 1)) ··· 329 328 } 330 329 smcd_dev = NULL; 331 330 out: 332 - spin_unlock(&smcd_dev_list.lock); 331 + mutex_unlock(&smcd_dev_list.mutex); 333 332 return smcd_dev; 334 333 } 335 334 ··· 826 825 int i; 827 826 828 827 ini->ib_dev = NULL; 829 - spin_lock(&smc_ib_devices.lock); 828 + mutex_lock(&smc_ib_devices.mutex); 830 829 list_for_each_entry(ibdev, &smc_ib_devices.list, list) { 831 830 if (ibdev == known_dev) 832 831 continue; ··· 845 844 } 846 845 } 847 846 out: 848 - spin_unlock(&smc_ib_devices.lock); 847 + mutex_unlock(&smc_ib_devices.mutex); 849 848 } 850 849 851 850 /* find alternate roce device with same pnet_id and vlan_id */ ··· 864 863 { 865 864 struct smc_ib_device *ibdev; 866 865 867 - spin_lock(&smc_ib_devices.lock); 866 + mutex_lock(&smc_ib_devices.mutex); 868 867 list_for_each_entry(ibdev, &smc_ib_devices.list, list) { 869 868 struct net_device *ndev; 870 869 int i; ··· 889 888 } 890 889 } 891 890 } 892 - spin_unlock(&smc_ib_devices.lock); 891 + mutex_unlock(&smc_ib_devices.mutex); 893 892 } 894 893 895 894 /* Determine the corresponding IB device port based on the hardware PNETID. ··· 925 924 smc_pnet_find_ndev_pnetid_by_table(ndev, ndev_pnetid)) 926 925 return; /* pnetid could not be determined */ 927 926 928 - spin_lock(&smcd_dev_list.lock); 927 + mutex_lock(&smcd_dev_list.mutex); 929 928 list_for_each_entry(ismdev, &smcd_dev_list.list, list) { 930 929 if (smc_pnet_match(ismdev->pnetid, ndev_pnetid) && 931 930 !ismdev->going_away) { ··· 933 932 break; 934 933 } 935 934 } 936 - spin_unlock(&smcd_dev_list.lock); 935 + mutex_unlock(&smcd_dev_list.mutex); 937 936 } 938 937 939 938 /* PNET table analysis for a given sock:
+6 -4
net/smc/smc_wr.c
··· 169 169 static inline int smc_wr_tx_get_free_slot_index(struct smc_link *link, u32 *idx) 170 170 { 171 171 *idx = link->wr_tx_cnt; 172 + if (!smc_link_usable(link)) 173 + return -ENOLINK; 172 174 for_each_clear_bit(*idx, link->wr_tx_mask, link->wr_tx_cnt) { 173 175 if (!test_and_set_bit(*idx, link->wr_tx_mask)) 174 176 return 0; ··· 562 560 { 563 561 struct ib_device *ibdev; 564 562 563 + if (!lnk->smcibdev) 564 + return; 565 + ibdev = lnk->smcibdev->ibdev; 566 + 565 567 if (smc_wr_tx_wait_no_pending_sends(lnk)) 566 568 memset(lnk->wr_tx_mask, 0, 567 569 BITS_TO_LONGS(SMC_WR_BUF_CNT) * 568 570 sizeof(*lnk->wr_tx_mask)); 569 - 570 - if (!lnk->smcibdev) 571 - return; 572 - ibdev = lnk->smcibdev->ibdev; 573 571 574 572 if (lnk->wr_rx_dma_addr) { 575 573 ib_dma_unmap_single(ibdev, lnk->wr_rx_dma_addr,
+18 -8
net/tipc/link.c
··· 921 921 922 922 } 923 923 924 + /** 925 + * tipc_link_set_skb_retransmit_time - set the time at which retransmission of 926 + * the given skb should be next attempted 927 + * @skb: skb to set a future retransmission time for 928 + * @l: link the skb will be transmitted on 929 + */ 930 + static void tipc_link_set_skb_retransmit_time(struct sk_buff *skb, 931 + struct tipc_link *l) 932 + { 933 + if (link_is_bc_sndlink(l)) 934 + TIPC_SKB_CB(skb)->nxt_retr = TIPC_BC_RETR_LIM; 935 + else 936 + TIPC_SKB_CB(skb)->nxt_retr = TIPC_UC_RETR_TIME; 937 + } 938 + 924 939 void tipc_link_reset(struct tipc_link *l) 925 940 { 926 941 struct sk_buff_head list; ··· 1051 1036 return -ENOBUFS; 1052 1037 } 1053 1038 __skb_queue_tail(transmq, skb); 1054 - /* next retransmit attempt */ 1055 - if (link_is_bc_sndlink(l)) 1056 - TIPC_SKB_CB(skb)->nxt_retr = TIPC_BC_RETR_LIM; 1039 + tipc_link_set_skb_retransmit_time(skb, l); 1057 1040 __skb_queue_tail(xmitq, _skb); 1058 1041 TIPC_SKB_CB(skb)->ackers = l->ackers; 1059 1042 l->rcv_unacked = 0; ··· 1152 1139 if (unlikely(skb == l->backlog[imp].target_bskb)) 1153 1140 l->backlog[imp].target_bskb = NULL; 1154 1141 __skb_queue_tail(&l->transmq, skb); 1155 - /* next retransmit attempt */ 1156 - if (link_is_bc_sndlink(l)) 1157 - TIPC_SKB_CB(skb)->nxt_retr = TIPC_BC_RETR_LIM; 1142 + tipc_link_set_skb_retransmit_time(skb, l); 1158 1143 1159 1144 __skb_queue_tail(xmitq, _skb); 1160 1145 TIPC_SKB_CB(skb)->ackers = l->ackers; ··· 1595 1584 /* retransmit skb if unrestricted*/ 1596 1585 if (time_before(jiffies, TIPC_SKB_CB(skb)->nxt_retr)) 1597 1586 continue; 1598 - TIPC_SKB_CB(skb)->nxt_retr = (is_uc) ? 1599 - TIPC_UC_RETR_TIME : TIPC_BC_RETR_LIM; 1587 + tipc_link_set_skb_retransmit_time(skb, l); 1600 1588 _skb = pskb_copy(skb, GFP_ATOMIC); 1601 1589 if (!_skb) 1602 1590 continue;
+3 -2
net/wireless/nl80211.c
··· 5016 5016 err = nl80211_parse_he_obss_pd( 5017 5017 info->attrs[NL80211_ATTR_HE_OBSS_PD], 5018 5018 &params.he_obss_pd); 5019 - goto out; 5019 + if (err) 5020 + goto out; 5020 5021 } 5021 5022 5022 5023 if (info->attrs[NL80211_ATTR_HE_BSS_COLOR]) { ··· 5025 5024 info->attrs[NL80211_ATTR_HE_BSS_COLOR], 5026 5025 &params.he_bss_color); 5027 5026 if (err) 5028 - return err; 5027 + goto out; 5029 5028 } 5030 5029 5031 5030 nl80211_calculate_ap_params(&params);
+4 -50
net/xdp/xsk_buff_pool.c
··· 2 2 3 3 #include <net/xsk_buff_pool.h> 4 4 #include <net/xdp_sock.h> 5 - #include <linux/dma-direct.h> 6 - #include <linux/dma-noncoherent.h> 7 - #include <linux/swiotlb.h> 8 5 9 6 #include "xsk_queue.h" 10 7 ··· 52 55 pool->free_heads_cnt = chunks; 53 56 pool->headroom = headroom; 54 57 pool->chunk_size = chunk_size; 55 - pool->cheap_dma = true; 56 58 pool->unaligned = unaligned; 57 59 pool->frame_len = chunk_size - headroom - XDP_PACKET_HEADROOM; 58 60 INIT_LIST_HEAD(&pool->free_list); ··· 121 125 } 122 126 } 123 127 124 - static bool __maybe_unused xp_check_swiotlb_dma(struct xsk_buff_pool *pool) 125 - { 126 - #if defined(CONFIG_SWIOTLB) 127 - phys_addr_t paddr; 128 - u32 i; 129 - 130 - for (i = 0; i < pool->dma_pages_cnt; i++) { 131 - paddr = dma_to_phys(pool->dev, pool->dma_pages[i]); 132 - if (is_swiotlb_buffer(paddr)) 133 - return false; 134 - } 135 - #endif 136 - return true; 137 - } 138 - 139 - static bool xp_check_cheap_dma(struct xsk_buff_pool *pool) 140 - { 141 - #if defined(CONFIG_HAS_DMA) 142 - const struct dma_map_ops *ops = get_dma_ops(pool->dev); 143 - 144 - if (ops) { 145 - return !ops->sync_single_for_cpu && 146 - !ops->sync_single_for_device; 147 - } 148 - 149 - if (!dma_is_direct(ops)) 150 - return false; 151 - 152 - if (!xp_check_swiotlb_dma(pool)) 153 - return false; 154 - 155 - if (!dev_is_dma_coherent(pool->dev)) { 156 - #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ 157 - defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) || \ 158 - defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) 159 - return false; 160 - #endif 161 - } 162 - #endif 163 - return true; 164 - } 165 - 166 128 int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev, 167 129 unsigned long attrs, struct page **pages, u32 nr_pages) 168 130 { ··· 134 180 135 181 pool->dev = dev; 136 182 pool->dma_pages_cnt = nr_pages; 183 + pool->dma_need_sync = false; 137 184 138 185 for (i = 0; i < pool->dma_pages_cnt; i++) { 139 186 dma = dma_map_page_attrs(dev, pages[i], 0, PAGE_SIZE, ··· 143 188 xp_dma_unmap(pool, attrs); 144 189 return -ENOMEM; 145 190 } 191 + if (dma_need_sync(dev, dma)) 192 + pool->dma_need_sync = true; 146 193 pool->dma_pages[i] = dma; 147 194 } 148 195 149 196 if (pool->unaligned) 150 197 xp_check_dma_contiguity(pool); 151 - 152 - pool->dev = dev; 153 - pool->cheap_dma = xp_check_cheap_dma(pool); 154 198 return 0; 155 199 } 156 200 EXPORT_SYMBOL(xp_dma_map); ··· 234 280 xskb->xdp.data = xskb->xdp.data_hard_start + XDP_PACKET_HEADROOM; 235 281 xskb->xdp.data_meta = xskb->xdp.data; 236 282 237 - if (!pool->cheap_dma) { 283 + if (pool->dma_need_sync) { 238 284 dma_sync_single_range_for_device(pool->dev, xskb->dma, 0, 239 285 pool->frame_len, 240 286 DMA_BIDIRECTIONAL);
+2
net/xfrm/xfrm_interface.c
··· 37 37 #include <net/ip.h> 38 38 #include <net/ipv6.h> 39 39 #include <net/ip6_route.h> 40 + #include <net/ip_tunnels.h> 40 41 #include <net/addrconf.h> 41 42 #include <net/xfrm.h> 42 43 #include <net/net_namespace.h> ··· 582 581 static void xfrmi_dev_setup(struct net_device *dev) 583 582 { 584 583 dev->netdev_ops = &xfrmi_netdev_ops; 584 + dev->header_ops = &ip_tunnel_header_ops; 585 585 dev->type = ARPHRD_NONE; 586 586 dev->mtu = ETH_DATA_LEN; 587 587 dev->min_mtu = ETH_MIN_MTU;
+21 -20
tools/include/uapi/linux/bpf.h
··· 3171 3171 * int bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) 3172 3172 * Description 3173 3173 * Copy *size* bytes from *data* into a ring buffer *ringbuf*. 3174 - * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of 3175 - * new data availability is sent. 3176 - * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of 3177 - * new data availability is sent unconditionally. 3174 + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 3175 + * of new data availability is sent. 3176 + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 3177 + * of new data availability is sent unconditionally. 3178 3178 * Return 3179 - * 0, on success; 3180 - * < 0, on error. 3179 + * 0 on success, or a negative error in case of failure. 3181 3180 * 3182 3181 * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags) 3183 3182 * Description ··· 3188 3189 * void bpf_ringbuf_submit(void *data, u64 flags) 3189 3190 * Description 3190 3191 * Submit reserved ring buffer sample, pointed to by *data*. 3191 - * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of 3192 - * new data availability is sent. 3193 - * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of 3194 - * new data availability is sent unconditionally. 3192 + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 3193 + * of new data availability is sent. 3194 + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 3195 + * of new data availability is sent unconditionally. 3195 3196 * Return 3196 3197 * Nothing. Always succeeds. 3197 3198 * 3198 3199 * void bpf_ringbuf_discard(void *data, u64 flags) 3199 3200 * Description 3200 3201 * Discard reserved ring buffer sample, pointed to by *data*. 3201 - * If BPF_RB_NO_WAKEUP is specified in *flags*, no notification of 3202 - * new data availability is sent. 3203 - * IF BPF_RB_FORCE_WAKEUP is specified in *flags*, notification of 3204 - * new data availability is sent unconditionally. 3202 + * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification 3203 + * of new data availability is sent. 3204 + * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification 3205 + * of new data availability is sent unconditionally. 3205 3206 * Return 3206 3207 * Nothing. Always succeeds. 3207 3208 * ··· 3209 3210 * Description 3210 3211 * Query various characteristics of provided ring buffer. What 3211 3212 * exactly is queries is determined by *flags*: 3212 - * - BPF_RB_AVAIL_DATA - amount of data not yet consumed; 3213 - * - BPF_RB_RING_SIZE - the size of ring buffer; 3214 - * - BPF_RB_CONS_POS - consumer position (can wrap around); 3215 - * - BPF_RB_PROD_POS - producer(s) position (can wrap around); 3216 - * Data returned is just a momentary snapshots of actual values 3213 + * 3214 + * * **BPF_RB_AVAIL_DATA**: Amount of data not yet consumed. 3215 + * * **BPF_RB_RING_SIZE**: The size of ring buffer. 3216 + * * **BPF_RB_CONS_POS**: Consumer position (can wrap around). 3217 + * * **BPF_RB_PROD_POS**: Producer(s) position (can wrap around). 3218 + * 3219 + * Data returned is just a momentary snapshot of actual values 3217 3220 * and could be inaccurate, so this facility should be used to 3218 3221 * power heuristics and for reporting, not to make 100% correct 3219 3222 * calculation. 3220 3223 * Return 3221 - * Requested value, or 0, if flags are not recognized. 3224 + * Requested value, or 0, if *flags* are not recognized. 3222 3225 * 3223 3226 * int bpf_csum_level(struct sk_buff *skb, u64 level) 3224 3227 * Description
+2
tools/lib/bpf/bpf.h
··· 233 233 LIBBPF_API int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, 234 234 __u32 *buf_len, __u32 *prog_id, __u32 *fd_type, 235 235 __u64 *probe_offset, __u64 *probe_addr); 236 + 237 + enum bpf_stats_type; /* defined in up-to-date linux/bpf.h */ 236 238 LIBBPF_API int bpf_enable_stats(enum bpf_stats_type type); 237 239 238 240 #ifdef __cplusplus
+8 -4
tools/lib/bpf/hashmap.h
··· 11 11 #include <stdbool.h> 12 12 #include <stddef.h> 13 13 #include <limits.h> 14 - #ifndef __WORDSIZE 15 - #define __WORDSIZE (__SIZEOF_LONG__ * 8) 16 - #endif 17 14 18 15 static inline size_t hash_bits(size_t h, int bits) 19 16 { 20 17 /* shuffle bits and return requested number of upper bits */ 21 - return (h * 11400714819323198485llu) >> (__WORDSIZE - bits); 18 + #if (__SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__) 19 + /* LP64 case */ 20 + return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits); 21 + #elif (__SIZEOF_SIZE_T__ <= __SIZEOF_LONG__) 22 + return (h * 2654435769lu) >> (__SIZEOF_LONG__ * 8 - bits); 23 + #else 24 + # error "Unsupported size_t size" 25 + #endif 22 26 } 23 27 24 28 typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx);
+8 -2
tools/lib/bpf/libbpf.c
··· 4818 4818 err = -EINVAL; 4819 4819 goto out; 4820 4820 } 4821 - prog = bpf_object__find_program_by_title(obj, sec_name); 4821 + prog = NULL; 4822 + for (i = 0; i < obj->nr_programs; i++) { 4823 + if (!strcmp(obj->programs[i].section_name, sec_name)) { 4824 + prog = &obj->programs[i]; 4825 + break; 4826 + } 4827 + } 4822 4828 if (!prog) { 4823 4829 pr_warn("failed to find program '%s' for CO-RE offset relocation\n", 4824 4830 sec_name); ··· 6659 6653 .expected_attach_type = BPF_TRACE_ITER, 6660 6654 .is_attach_btf = true, 6661 6655 .attach_fn = attach_iter), 6662 - BPF_EAPROG_SEC("xdp_devmap", BPF_PROG_TYPE_XDP, 6656 + BPF_EAPROG_SEC("xdp_devmap/", BPF_PROG_TYPE_XDP, 6663 6657 BPF_XDP_DEVMAP), 6664 6658 BPF_PROG_SEC("xdp", BPF_PROG_TYPE_XDP), 6665 6659 BPF_PROG_SEC("perf_event", BPF_PROG_TYPE_PERF_EVENT),
+1 -1
tools/testing/selftests/bpf/prog_tests/fentry_fexit.c
··· 36 36 fentry_res = (__u64 *)fentry_skel->bss; 37 37 fexit_res = (__u64 *)fexit_skel->bss; 38 38 printf("%lld\n", fentry_skel->bss->test1_result); 39 - for (i = 0; i < 6; i++) { 39 + for (i = 0; i < 8; i++) { 40 40 CHECK(fentry_res[i] != 1, "result", 41 41 "fentry_test%d failed err %lld\n", i + 1, fentry_res[i]); 42 42 CHECK(fexit_res[i] != 1, "result",
+2 -2
tools/testing/selftests/bpf/prog_tests/flow_dissector.c
··· 527 527 528 528 run_tests_skb_less(tap_fd, skel->maps.last_dissection); 529 529 530 - err = bpf_prog_detach(prog_fd, BPF_FLOW_DISSECTOR); 531 - CHECK(err, "bpf_prog_detach", "err %d errno %d\n", err, errno); 530 + err = bpf_prog_detach2(prog_fd, 0, BPF_FLOW_DISSECTOR); 531 + CHECK(err, "bpf_prog_detach2", "err %d errno %d\n", err, errno); 532 532 } 533 533 534 534 static void test_skb_less_link_create(struct bpf_flow *skel, int tap_fd)
+34 -10
tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Test that the flow_dissector program can be updated with a single 4 - * syscall by attaching a new program that replaces the existing one. 5 - * 6 - * Corner case - the same program cannot be attached twice. 3 + * Tests for attaching, detaching, and replacing flow_dissector BPF program. 7 4 */ 8 5 9 6 #define _GNU_SOURCE ··· 113 116 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog2)); 114 117 115 118 out_detach: 116 - err = bpf_prog_detach(0, BPF_FLOW_DISSECTOR); 119 + err = bpf_prog_detach2(prog2, 0, BPF_FLOW_DISSECTOR); 117 120 if (CHECK_FAIL(err)) 118 121 perror("bpf_prog_detach"); 119 122 CHECK_FAIL(prog_is_attached(netns)); ··· 149 152 DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts); 150 153 int err, link; 151 154 152 - err = bpf_prog_attach(prog1, -1, BPF_FLOW_DISSECTOR, 0); 155 + err = bpf_prog_attach(prog1, 0, BPF_FLOW_DISSECTOR, 0); 153 156 if (CHECK_FAIL(err)) { 154 157 perror("bpf_prog_attach(prog1)"); 155 158 return; ··· 165 168 close(link); 166 169 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); 167 170 168 - err = bpf_prog_detach(-1, BPF_FLOW_DISSECTOR); 171 + err = bpf_prog_detach2(prog1, 0, BPF_FLOW_DISSECTOR); 169 172 if (CHECK_FAIL(err)) 170 173 perror("bpf_prog_detach"); 171 174 CHECK_FAIL(prog_is_attached(netns)); ··· 185 188 186 189 /* Expect failure attaching prog when link exists */ 187 190 errno = 0; 188 - err = bpf_prog_attach(prog2, -1, BPF_FLOW_DISSECTOR, 0); 191 + err = bpf_prog_attach(prog2, 0, BPF_FLOW_DISSECTOR, 0); 189 192 if (CHECK_FAIL(!err || errno != EEXIST)) 190 193 perror("bpf_prog_attach(prog2) expected EEXIST"); 191 194 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); ··· 208 211 209 212 /* Expect failure detaching prog when link exists */ 210 213 errno = 0; 211 - err = bpf_prog_detach(-1, BPF_FLOW_DISSECTOR); 214 + err = bpf_prog_detach2(prog1, 0, BPF_FLOW_DISSECTOR); 212 215 if (CHECK_FAIL(!err || errno != EINVAL)) 213 216 perror("bpf_prog_detach expected EINVAL"); 214 217 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); ··· 228 231 } 229 232 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); 230 233 231 - err = bpf_prog_detach(0, BPF_FLOW_DISSECTOR); 234 + err = bpf_prog_detach2(prog1, 0, BPF_FLOW_DISSECTOR); 232 235 if (CHECK_FAIL(err)) { 233 236 perror("bpf_prog_detach"); 234 237 return; ··· 300 303 if (CHECK_FAIL(err)) 301 304 perror("bpf_link_update"); 302 305 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog2)); 306 + 307 + close(link); 308 + CHECK_FAIL(prog_is_attached(netns)); 309 + } 310 + 311 + static void test_link_update_same_prog(int netns, int prog1, int prog2) 312 + { 313 + DECLARE_LIBBPF_OPTS(bpf_link_create_opts, create_opts); 314 + DECLARE_LIBBPF_OPTS(bpf_link_update_opts, update_opts); 315 + int err, link; 316 + 317 + link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); 318 + if (CHECK_FAIL(link < 0)) { 319 + perror("bpf_link_create(prog1)"); 320 + return; 321 + } 322 + CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); 323 + 324 + /* Expect success updating the prog with the same one */ 325 + update_opts.flags = 0; 326 + update_opts.old_prog_fd = 0; 327 + err = bpf_link_update(link, prog1, &update_opts); 328 + if (CHECK_FAIL(err)) 329 + perror("bpf_link_update"); 330 + CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); 303 331 304 332 close(link); 305 333 CHECK_FAIL(prog_is_attached(netns)); ··· 593 571 test_link_update_no_old_prog }, 594 572 { "link update with replace old prog", 595 573 test_link_update_replace_old_prog }, 574 + { "link update with same prog", 575 + test_link_update_same_prog }, 596 576 { "link update invalid opts", 597 577 test_link_update_invalid_opts }, 598 578 { "link update invalid prog",
+1 -1
tools/testing/selftests/bpf/progs/bpf_iter_netlink.c
··· 25 25 struct netlink_sock *sk; 26 26 } __attribute__((preserve_access_index)); 27 27 28 - static inline struct inode *SOCK_INODE(struct socket *socket) 28 + static __attribute__((noinline)) struct inode *SOCK_INODE(struct socket *socket) 29 29 { 30 30 return &container_of(socket, struct socket_alloc, socket)->vfs_inode; 31 31 }
+22
tools/testing/selftests/bpf/progs/fentry_test.c
··· 55 55 e == (void *)20 && f == 21; 56 56 return 0; 57 57 } 58 + 59 + struct bpf_fentry_test_t { 60 + struct bpf_fentry_test_t *a; 61 + }; 62 + 63 + __u64 test7_result = 0; 64 + SEC("fentry/bpf_fentry_test7") 65 + int BPF_PROG(test7, struct bpf_fentry_test_t *arg) 66 + { 67 + if (arg == 0) 68 + test7_result = 1; 69 + return 0; 70 + } 71 + 72 + __u64 test8_result = 0; 73 + SEC("fentry/bpf_fentry_test8") 74 + int BPF_PROG(test8, struct bpf_fentry_test_t *arg) 75 + { 76 + if (arg->a == 0) 77 + test8_result = 1; 78 + return 0; 79 + }
+22
tools/testing/selftests/bpf/progs/fexit_test.c
··· 56 56 e == (void *)20 && f == 21 && ret == 111; 57 57 return 0; 58 58 } 59 + 60 + struct bpf_fentry_test_t { 61 + struct bpf_fentry_test *a; 62 + }; 63 + 64 + __u64 test7_result = 0; 65 + SEC("fexit/bpf_fentry_test7") 66 + int BPF_PROG(test7, struct bpf_fentry_test_t *arg) 67 + { 68 + if (arg == 0) 69 + test7_result = 1; 70 + return 0; 71 + } 72 + 73 + __u64 test8_result = 0; 74 + SEC("fexit/bpf_fentry_test8") 75 + int BPF_PROG(test8, struct bpf_fentry_test_t *arg) 76 + { 77 + if (arg->a == 0) 78 + test8_result = 1; 79 + return 0; 80 + }
+7 -1
tools/testing/selftests/bpf/progs/test_sockmap_kern.h
··· 79 79 80 80 struct { 81 81 __uint(type, BPF_MAP_TYPE_ARRAY); 82 - __uint(max_entries, 2); 82 + __uint(max_entries, 3); 83 83 __type(key, int); 84 84 __type(value, int); 85 85 } sock_skb_opts SEC(".maps"); ··· 94 94 SEC("sk_skb1") 95 95 int bpf_prog1(struct __sk_buff *skb) 96 96 { 97 + int *f, two = 2; 98 + 99 + f = bpf_map_lookup_elem(&sock_skb_opts, &two); 100 + if (f && *f) { 101 + return *f; 102 + } 97 103 return skb->len; 98 104 } 99 105
+1 -1
tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c
··· 27 27 /* valid program on DEVMAP entry via SEC name; 28 28 * has access to egress and ingress ifindex 29 29 */ 30 - SEC("xdp_devmap") 30 + SEC("xdp_devmap/map_prog") 31 31 int xdp_dummy_dm(struct xdp_md *ctx) 32 32 { 33 33 char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n";
+6 -6
tools/testing/selftests/bpf/test_maps.c
··· 789 789 } 790 790 791 791 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER); 792 - if (err) { 792 + if (!err) { 793 793 printf("Failed empty parser prog detach\n"); 794 794 goto out_sockmap; 795 795 } 796 796 797 797 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT); 798 - if (err) { 798 + if (!err) { 799 799 printf("Failed empty verdict prog detach\n"); 800 800 goto out_sockmap; 801 801 } 802 802 803 803 err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT); 804 - if (err) { 804 + if (!err) { 805 805 printf("Failed empty msg verdict prog detach\n"); 806 806 goto out_sockmap; 807 807 } ··· 1090 1090 assert(status == 0); 1091 1091 } 1092 1092 1093 - err = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE); 1093 + err = bpf_prog_detach2(parse_prog, map_fd_rx, __MAX_BPF_ATTACH_TYPE); 1094 1094 if (!err) { 1095 1095 printf("Detached an invalid prog type.\n"); 1096 1096 goto out_sockmap; 1097 1097 } 1098 1098 1099 - err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER); 1099 + err = bpf_prog_detach2(parse_prog, map_fd_rx, BPF_SK_SKB_STREAM_PARSER); 1100 1100 if (err) { 1101 1101 printf("Failed parser prog detach\n"); 1102 1102 goto out_sockmap; 1103 1103 } 1104 1104 1105 - err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT); 1105 + err = bpf_prog_detach2(verdict_prog, map_fd_rx, BPF_SK_SKB_STREAM_VERDICT); 1106 1106 if (err) { 1107 1107 printf("Failed parser prog detach\n"); 1108 1108 goto out_sockmap;
+18
tools/testing/selftests/bpf/test_sockmap.c
··· 85 85 int txmsg_ktls_skb_redir; 86 86 int ktls; 87 87 int peek_flag; 88 + int skb_use_parser; 88 89 89 90 static const struct option long_options[] = { 90 91 {"help", no_argument, NULL, 'h' }, ··· 175 174 txmsg_apply = txmsg_cork = 0; 176 175 txmsg_ingress = txmsg_redir_skb = 0; 177 176 txmsg_ktls_skb = txmsg_ktls_skb_drop = txmsg_ktls_skb_redir = 0; 177 + skb_use_parser = 0; 178 178 } 179 179 180 180 static int test_start_subtest(const struct _test *t, struct sockmap_options *o) ··· 1213 1211 } 1214 1212 } 1215 1213 1214 + if (skb_use_parser) { 1215 + i = 2; 1216 + err = bpf_map_update_elem(map_fd[7], &i, &skb_use_parser, BPF_ANY); 1217 + } 1218 + 1216 1219 if (txmsg_drop) 1217 1220 options->drop_expected = true; 1218 1221 ··· 1657 1650 test_send(opt, cgrp); 1658 1651 } 1659 1652 1653 + static void test_txmsg_ingress_parser(int cgrp, struct sockmap_options *opt) 1654 + { 1655 + txmsg_pass = 1; 1656 + skb_use_parser = 512; 1657 + opt->iov_length = 256; 1658 + opt->iov_count = 1; 1659 + opt->rate = 2; 1660 + test_exec(cgrp, opt); 1661 + } 1662 + 1660 1663 char *map_names[] = { 1661 1664 "sock_map", 1662 1665 "sock_map_txmsg", ··· 1765 1748 {"txmsg test pull-data", test_txmsg_pull}, 1766 1749 {"txmsg test pop-data", test_txmsg_pop}, 1767 1750 {"txmsg test push/pop data", test_txmsg_push_pop}, 1751 + {"txmsg text ingress parser", test_txmsg_ingress_parser}, 1768 1752 }; 1769 1753 1770 1754 static int check_whitelist(struct _test *t, struct sockmap_options *opt)
+13
tools/testing/selftests/net/fib_nexthops.sh
··· 747 747 run_cmd "$IP nexthop add id 86 via 2001:db8:91::2 dev veth1" 748 748 run_cmd "$IP ro add 2001:db8:101::1/128 nhid 81" 749 749 750 + # rpfilter and default route 751 + $IP nexthop flush >/dev/null 2>&1 752 + run_cmd "ip netns exec me ip6tables -t mangle -I PREROUTING 1 -m rpfilter --invert -j DROP" 753 + run_cmd "$IP nexthop add id 91 via 2001:db8:91::2 dev veth1" 754 + run_cmd "$IP nexthop add id 92 via 2001:db8:92::2 dev veth3" 755 + run_cmd "$IP nexthop add id 93 group 91/92" 756 + run_cmd "$IP -6 ro add default nhid 91" 757 + run_cmd "ip netns exec me ping -c1 -w1 2001:db8:101::1" 758 + log_test $? 0 "Nexthop with default route and rpfilter" 759 + run_cmd "$IP -6 ro replace default nhid 93" 760 + run_cmd "ip netns exec me ping -c1 -w1 2001:db8:101::1" 761 + log_test $? 0 "Nexthop with multipath default route and rpfilter" 762 + 750 763 # TO-DO: 751 764 # existing route with old nexthop; append route with new nexthop 752 765 # existing route with old nexthop; replace route with new