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

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

Pull networking fixes from Paolo Abeni:
"Including fixes from netfilter and bpf.

Current release - regressions:

- bpf: adjust size_index according to the value of KMALLOC_MIN_SIZE

- netfilter: fix entries val in rule reset audit log

- eth: stmmac: fix incorrect rxq|txq_stats reference

Previous releases - regressions:

- ipv4: fix null-deref in ipv4_link_failure

- netfilter:
- fix several GC related issues
- fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP

- eth: team: fix null-ptr-deref when team device type is changed

- eth: i40e: fix VF VLAN offloading when port VLAN is configured

- eth: ionic: fix 16bit math issue when PAGE_SIZE >= 64KB

Previous releases - always broken:

- core: fix ETH_P_1588 flow dissector

- mptcp: fix several connection hang-up conditions

- bpf:
- avoid deadlock when using queue and stack maps from NMI
- add override check to kprobe multi link attach

- hsr: properly parse HSRv1 supervisor frames.

- eth: igc: fix infinite initialization loop with early XDP redirect

- eth: octeon_ep: fix tx dma unmap len values in SG

- eth: hns3: fix GRE checksum offload issue"

* tag 'net-6.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (87 commits)
sfc: handle error pointers returned by rhashtable_lookup_get_insert_fast()
igc: Expose tx-usecs coalesce setting to user
octeontx2-pf: Do xdp_do_flush() after redirects.
bnxt_en: Flush XDP for bnxt_poll_nitroa0()'s NAPI
net: ena: Flush XDP packets on error.
net/handshake: Fix memory leak in __sock_create() and sock_alloc_file()
net: hinic: Fix warning-hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev'
netfilter: ipset: Fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP
netfilter: nf_tables: fix memleak when more than 255 elements expired
netfilter: nf_tables: disable toggling dormant table state more than once
vxlan: Add missing entries to vxlan_get_size()
net: rds: Fix possible NULL-pointer dereference
team: fix null-ptr-deref when team device type is changed
net: bridge: use DEV_STATS_INC()
net: hns3: add 5ms delay before clear firmware reset irq source
net: hns3: fix fail to delete tc flower rules during reset issue
net: hns3: only enable unicast promisc when mac table full
net: hns3: fix GRE checksum offload issue
net: hns3: add cmdq check for vf periodic service task
net: stmmac: fix incorrect rxq|txq_stats reference
...

+1486 -537
+2 -2
Documentation/networking/ax25.rst
··· 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 9 AX.25, NET/ROM and ROSE, associated programs and utilities can be 10 - found on http://www.linux-ax25.org. 10 + found on https://linux-ax25.in-berlin.de. 11 11 12 - There is an active mailing list for discussing Linux amateur radio matters 12 + There is a mailing list for discussing Linux amateur radio matters 13 13 called linux-hams@vger.kernel.org. To subscribe to it, send a message to 14 14 majordomo@vger.kernel.org with the words "subscribe linux-hams" in the body 15 15 of the message, the subject field is ignored. You don't need to be
+3 -3
MAINTAINERS
··· 3344 3344 M: Ralf Baechle <ralf@linux-mips.org> 3345 3345 L: linux-hams@vger.kernel.org 3346 3346 S: Maintained 3347 - W: http://www.linux-ax25.org/ 3347 + W: https://linux-ax25.in-berlin.de 3348 3348 F: include/net/ax25.h 3349 3349 F: include/uapi/linux/ax25.h 3350 3350 F: net/ax25/ ··· 14756 14756 M: Ralf Baechle <ralf@linux-mips.org> 14757 14757 L: linux-hams@vger.kernel.org 14758 14758 S: Maintained 14759 - W: http://www.linux-ax25.org/ 14759 + W: https://linux-ax25.in-berlin.de 14760 14760 F: include/net/netrom.h 14761 14761 F: include/uapi/linux/netrom.h 14762 14762 F: net/netrom/ ··· 18607 18607 M: Ralf Baechle <ralf@linux-mips.org> 18608 18608 L: linux-hams@vger.kernel.org 18609 18609 S: Maintained 18610 - W: http://www.linux-ax25.org/ 18610 + W: https://linux-ax25.in-berlin.de 18611 18611 F: include/net/rose.h 18612 18612 F: include/uapi/linux/rose.h 18613 18613 F: net/rose/
+3
drivers/net/ethernet/amazon/ena/ena_netdev.c
··· 1833 1833 return work_done; 1834 1834 1835 1835 error: 1836 + if (xdp_flags & ENA_XDP_REDIRECT) 1837 + xdp_do_flush(); 1838 + 1836 1839 adapter = netdev_priv(rx_ring->netdev); 1837 1840 1838 1841 if (rc == -ENOSPC) {
+5
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 2614 2614 struct rx_cmp_ext *rxcmp1; 2615 2615 u32 cp_cons, tmp_raw_cons; 2616 2616 u32 raw_cons = cpr->cp_raw_cons; 2617 + bool flush_xdp = false; 2617 2618 u32 rx_pkts = 0; 2618 2619 u8 event = 0; 2619 2620 ··· 2649 2648 rx_pkts++; 2650 2649 else if (rc == -EBUSY) /* partial completion */ 2651 2650 break; 2651 + if (event & BNXT_REDIRECT_EVENT) 2652 + flush_xdp = true; 2652 2653 } else if (unlikely(TX_CMP_TYPE(txcmp) == 2653 2654 CMPL_BASE_TYPE_HWRM_DONE)) { 2654 2655 bnxt_hwrm_handler(bp, txcmp); ··· 2670 2667 2671 2668 if (event & BNXT_AGG_EVENT) 2672 2669 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); 2670 + if (flush_xdp) 2671 + xdp_do_flush(); 2673 2672 2674 2673 if (!bnxt_has_work(bp, cpr) && rx_pkts < budget) { 2675 2674 napi_complete_done(napi, rx_pkts);
+2 -4
drivers/net/ethernet/engleder/tsnep_ethtool.c
··· 300 300 { 301 301 struct tsnep_adapter *adapter = netdev_priv(netdev); 302 302 303 - ch->max_rx = adapter->num_rx_queues; 304 - ch->max_tx = adapter->num_tx_queues; 305 - ch->rx_count = adapter->num_rx_queues; 306 - ch->tx_count = adapter->num_tx_queues; 303 + ch->max_combined = adapter->num_queues; 304 + ch->combined_count = adapter->num_queues; 307 305 } 308 306 309 307 static int tsnep_ethtool_get_ts_info(struct net_device *netdev,
+14 -4
drivers/net/ethernet/engleder/tsnep_main.c
··· 87 87 88 88 /* handle TX/RX queue 0 interrupt */ 89 89 if ((active & adapter->queue[0].irq_mask) != 0) { 90 - tsnep_disable_irq(adapter, adapter->queue[0].irq_mask); 91 - napi_schedule(&adapter->queue[0].napi); 90 + if (napi_schedule_prep(&adapter->queue[0].napi)) { 91 + tsnep_disable_irq(adapter, adapter->queue[0].irq_mask); 92 + /* schedule after masking to avoid races */ 93 + __napi_schedule(&adapter->queue[0].napi); 94 + } 92 95 } 93 96 94 97 return IRQ_HANDLED; ··· 102 99 struct tsnep_queue *queue = arg; 103 100 104 101 /* handle TX/RX queue interrupt */ 105 - tsnep_disable_irq(queue->adapter, queue->irq_mask); 106 - napi_schedule(&queue->napi); 102 + if (napi_schedule_prep(&queue->napi)) { 103 + tsnep_disable_irq(queue->adapter, queue->irq_mask); 104 + /* schedule after masking to avoid races */ 105 + __napi_schedule(&queue->napi); 106 + } 107 107 108 108 return IRQ_HANDLED; 109 109 } ··· 1733 1727 1734 1728 if (queue->tx) 1735 1729 complete = tsnep_tx_poll(queue->tx, budget); 1730 + 1731 + /* handle case where we are called by netpoll with a budget of 0 */ 1732 + if (unlikely(budget <= 0)) 1733 + return budget; 1736 1734 1737 1735 if (queue->rx) { 1738 1736 done = queue->rx->xsk_pool ?
+9
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 3353 3353 NETIF_F_HW_TC); 3354 3354 3355 3355 netdev->hw_enc_features |= netdev->vlan_features | NETIF_F_TSO_MANGLEID; 3356 + 3357 + /* The device_version V3 hardware can't offload the checksum for IP in 3358 + * GRE packets, but can do it for NvGRE. So default to disable the 3359 + * checksum and GSO offload for GRE. 3360 + */ 3361 + if (ae_dev->dev_version > HNAE3_DEVICE_VERSION_V2) { 3362 + netdev->features &= ~NETIF_F_GSO_GRE; 3363 + netdev->features &= ~NETIF_F_GSO_GRE_CSUM; 3364 + } 3356 3365 } 3357 3366 3358 3367 static int hns3_alloc_buffer(struct hns3_enet_ring *ring,
+12 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 3564 3564 static void hclge_clear_event_cause(struct hclge_dev *hdev, u32 event_type, 3565 3565 u32 regclr) 3566 3566 { 3567 + #define HCLGE_IMP_RESET_DELAY 5 3568 + 3567 3569 switch (event_type) { 3568 3570 case HCLGE_VECTOR0_EVENT_PTP: 3569 3571 case HCLGE_VECTOR0_EVENT_RST: 3572 + if (regclr == BIT(HCLGE_VECTOR0_IMPRESET_INT_B)) 3573 + mdelay(HCLGE_IMP_RESET_DELAY); 3574 + 3570 3575 hclge_write_dev(&hdev->hw, HCLGE_MISC_RESET_STS_REG, regclr); 3571 3576 break; 3572 3577 case HCLGE_VECTOR0_EVENT_MBX: ··· 7353 7348 ret = hclge_fd_tcam_config(hdev, HCLGE_FD_STAGE_1, true, rule->location, 7354 7349 NULL, false); 7355 7350 if (ret) { 7351 + /* if tcam config fail, set rule state to TO_DEL, 7352 + * so the rule will be deleted when periodic 7353 + * task being scheduled. 7354 + */ 7355 + hclge_update_fd_list(hdev, HCLGE_FD_TO_DEL, rule->location, NULL); 7356 + set_bit(HCLGE_STATE_FD_TBL_CHANGED, &hdev->state); 7356 7357 spin_unlock_bh(&hdev->fd_rule_lock); 7357 7358 return ret; 7358 7359 } ··· 8835 8824 if (mac_type == HCLGE_MAC_ADDR_UC) { 8836 8825 if (is_all_added) 8837 8826 vport->overflow_promisc_flags &= ~HNAE3_OVERFLOW_UPE; 8838 - else 8827 + else if (hclge_is_umv_space_full(vport, true)) 8839 8828 vport->overflow_promisc_flags |= HNAE3_OVERFLOW_UPE; 8840 8829 } else { 8841 8830 if (is_all_added)
+2 -1
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 1855 1855 unsigned long delta = round_jiffies_relative(HZ); 1856 1856 struct hnae3_handle *handle = &hdev->nic; 1857 1857 1858 - if (test_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state)) 1858 + if (test_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state) || 1859 + test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state)) 1859 1860 return; 1860 1861 1861 1862 if (time_is_after_jiffies(hdev->last_serv_processed + HZ)) {
-3
drivers/net/ethernet/huawei/hinic/hinic_port.c
··· 456 456 u16 out_size = sizeof(vlan_filter); 457 457 int err; 458 458 459 - if (!hwdev) 460 - return -EINVAL; 461 - 462 459 vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif); 463 460 vlan_filter.enable = en; 464 461
+5 -3
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
··· 4475 4475 goto error_pvid; 4476 4476 4477 4477 i40e_vlan_stripping_enable(vsi); 4478 - i40e_vc_reset_vf(vf, true); 4479 - /* During reset the VF got a new VSI, so refresh a pointer. */ 4480 - vsi = pf->vsi[vf->lan_vsi_idx]; 4478 + 4481 4479 /* Locked once because multiple functions below iterate list */ 4482 4480 spin_lock_bh(&vsi->mac_filter_hash_lock); 4483 4481 ··· 4560 4562 * default LAN MAC address. 4561 4563 */ 4562 4564 vf->port_vlan_id = le16_to_cpu(vsi->info.pvid); 4565 + 4566 + i40e_vc_reset_vf(vf, true); 4567 + /* During reset the VF got a new VSI, so refresh a pointer. */ 4568 + vsi = pf->vsi[vf->lan_vsi_idx]; 4563 4569 4564 4570 ret = i40e_config_vf_promiscuous_mode(vf, vsi->id, allmulti, alluni); 4565 4571 if (ret) {
+1 -1
drivers/net/ethernet/intel/iavf/iavf.h
··· 521 521 int iavf_process_config(struct iavf_adapter *adapter); 522 522 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter); 523 523 void iavf_schedule_reset(struct iavf_adapter *adapter, u64 flags); 524 - void iavf_schedule_request_stats(struct iavf_adapter *adapter); 524 + void iavf_schedule_aq_request(struct iavf_adapter *adapter, u64 flags); 525 525 void iavf_schedule_finish_config(struct iavf_adapter *adapter); 526 526 void iavf_reset(struct iavf_adapter *adapter); 527 527 void iavf_set_ethtool_ops(struct net_device *netdev);
+1 -1
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
··· 362 362 unsigned int i; 363 363 364 364 /* Explicitly request stats refresh */ 365 - iavf_schedule_request_stats(adapter); 365 + iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_REQUEST_STATS); 366 366 367 367 iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats); 368 368
+8 -9
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 314 314 } 315 315 316 316 /** 317 - * iavf_schedule_request_stats - Set the flags and schedule statistics request 317 + * iavf_schedule_aq_request - Set the flags and schedule aq request 318 318 * @adapter: board private structure 319 - * 320 - * Sets IAVF_FLAG_AQ_REQUEST_STATS flag so iavf_watchdog_task() will explicitly 321 - * request and refresh ethtool stats 319 + * @flags: requested aq flags 322 320 **/ 323 - void iavf_schedule_request_stats(struct iavf_adapter *adapter) 321 + void iavf_schedule_aq_request(struct iavf_adapter *adapter, u64 flags) 324 322 { 325 - adapter->aq_required |= IAVF_FLAG_AQ_REQUEST_STATS; 323 + adapter->aq_required |= flags; 326 324 mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); 327 325 } 328 326 ··· 821 823 list_add_tail(&f->list, &adapter->vlan_filter_list); 822 824 f->state = IAVF_VLAN_ADD; 823 825 adapter->num_vlan_filters++; 824 - adapter->aq_required |= IAVF_FLAG_AQ_ADD_VLAN_FILTER; 826 + iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER); 825 827 } 826 828 827 829 clearout: ··· 843 845 f = iavf_find_vlan(adapter, vlan); 844 846 if (f) { 845 847 f->state = IAVF_VLAN_REMOVE; 846 - adapter->aq_required |= IAVF_FLAG_AQ_DEL_VLAN_FILTER; 848 + iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DEL_VLAN_FILTER); 847 849 } 848 850 849 851 spin_unlock_bh(&adapter->mac_vlan_list_lock); ··· 1419 1421 iavf_clear_fdir_filters(adapter); 1420 1422 iavf_clear_adv_rss_conf(adapter); 1421 1423 1422 - if (!(adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)) { 1424 + if (!(adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) && 1425 + !(test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))) { 1423 1426 /* cancel any current operation */ 1424 1427 adapter->current_op = VIRTCHNL_OP_UNKNOWN; 1425 1428 /* Schedule operations to close down the HW. Don't wait
+19 -12
drivers/net/ethernet/intel/igc/igc_ethtool.c
··· 868 868 spin_unlock(&adapter->stats64_lock); 869 869 } 870 870 871 + static int igc_ethtool_get_previous_rx_coalesce(struct igc_adapter *adapter) 872 + { 873 + return (adapter->rx_itr_setting <= 3) ? 874 + adapter->rx_itr_setting : adapter->rx_itr_setting >> 2; 875 + } 876 + 877 + static int igc_ethtool_get_previous_tx_coalesce(struct igc_adapter *adapter) 878 + { 879 + return (adapter->tx_itr_setting <= 3) ? 880 + adapter->tx_itr_setting : adapter->tx_itr_setting >> 2; 881 + } 882 + 871 883 static int igc_ethtool_get_coalesce(struct net_device *netdev, 872 884 struct ethtool_coalesce *ec, 873 885 struct kernel_ethtool_coalesce *kernel_coal, ··· 887 875 { 888 876 struct igc_adapter *adapter = netdev_priv(netdev); 889 877 890 - if (adapter->rx_itr_setting <= 3) 891 - ec->rx_coalesce_usecs = adapter->rx_itr_setting; 892 - else 893 - ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2; 894 - 895 - if (!(adapter->flags & IGC_FLAG_QUEUE_PAIRS)) { 896 - if (adapter->tx_itr_setting <= 3) 897 - ec->tx_coalesce_usecs = adapter->tx_itr_setting; 898 - else 899 - ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2; 900 - } 878 + ec->rx_coalesce_usecs = igc_ethtool_get_previous_rx_coalesce(adapter); 879 + ec->tx_coalesce_usecs = igc_ethtool_get_previous_tx_coalesce(adapter); 901 880 902 881 return 0; 903 882 } ··· 913 910 ec->tx_coalesce_usecs == 2) 914 911 return -EINVAL; 915 912 916 - if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs) 913 + if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && 914 + ec->tx_coalesce_usecs != igc_ethtool_get_previous_tx_coalesce(adapter)) { 915 + NL_SET_ERR_MSG_MOD(extack, 916 + "Queue Pair mode enabled, both Rx and Tx coalescing controlled by rx-usecs"); 917 917 return -EINVAL; 918 + } 918 919 919 920 /* If ITR is disabled, disable DMAC */ 920 921 if (ec->rx_coalesce_usecs == 0) {
+1 -1
drivers/net/ethernet/intel/igc/igc_main.c
··· 6491 6491 struct igc_ring *ring; 6492 6492 int i, drops; 6493 6493 6494 - if (unlikely(test_bit(__IGC_DOWN, &adapter->state))) 6494 + if (unlikely(!netif_carrier_ok(dev))) 6495 6495 return -ENETDOWN; 6496 6496 6497 6497 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
+4 -4
drivers/net/ethernet/marvell/octeon_ep/octep_main.c
··· 734 734 dma_map_sg_err: 735 735 if (si > 0) { 736 736 dma_unmap_single(iq->dev, sglist[0].dma_ptr[0], 737 - sglist[0].len[0], DMA_TO_DEVICE); 738 - sglist[0].len[0] = 0; 737 + sglist[0].len[3], DMA_TO_DEVICE); 738 + sglist[0].len[3] = 0; 739 739 } 740 740 while (si > 1) { 741 741 dma_unmap_page(iq->dev, sglist[si >> 2].dma_ptr[si & 3], 742 - sglist[si >> 2].len[si & 3], DMA_TO_DEVICE); 743 - sglist[si >> 2].len[si & 3] = 0; 742 + sglist[si >> 2].len[3 - (si & 3)], DMA_TO_DEVICE); 743 + sglist[si >> 2].len[3 - (si & 3)] = 0; 744 744 si--; 745 745 } 746 746 tx_buffer->gather = 0;
+4 -4
drivers/net/ethernet/marvell/octeon_ep/octep_tx.c
··· 69 69 compl_sg++; 70 70 71 71 dma_unmap_single(iq->dev, tx_buffer->sglist[0].dma_ptr[0], 72 - tx_buffer->sglist[0].len[0], DMA_TO_DEVICE); 72 + tx_buffer->sglist[0].len[3], DMA_TO_DEVICE); 73 73 74 74 i = 1; /* entry 0 is main skb, unmapped above */ 75 75 while (frags--) { 76 76 dma_unmap_page(iq->dev, tx_buffer->sglist[i >> 2].dma_ptr[i & 3], 77 - tx_buffer->sglist[i >> 2].len[i & 3], DMA_TO_DEVICE); 77 + tx_buffer->sglist[i >> 2].len[3 - (i & 3)], DMA_TO_DEVICE); 78 78 i++; 79 79 } 80 80 ··· 131 131 132 132 dma_unmap_single(iq->dev, 133 133 tx_buffer->sglist[0].dma_ptr[0], 134 - tx_buffer->sglist[0].len[0], 134 + tx_buffer->sglist[0].len[3], 135 135 DMA_TO_DEVICE); 136 136 137 137 i = 1; /* entry 0 is main skb, unmapped above */ 138 138 while (frags--) { 139 139 dma_unmap_page(iq->dev, tx_buffer->sglist[i >> 2].dma_ptr[i & 3], 140 - tx_buffer->sglist[i >> 2].len[i & 3], DMA_TO_DEVICE); 140 + tx_buffer->sglist[i >> 2].len[3 - (i & 3)], DMA_TO_DEVICE); 141 141 i++; 142 142 } 143 143
+15 -1
drivers/net/ethernet/marvell/octeon_ep/octep_tx.h
··· 17 17 #define TX_BUFTYPE_NET_SG 2 18 18 #define NUM_TX_BUFTYPES 3 19 19 20 - /* Hardware format for Scatter/Gather list */ 20 + /* Hardware format for Scatter/Gather list 21 + * 22 + * 63 48|47 32|31 16|15 0 23 + * ----------------------------------------- 24 + * | Len 0 | Len 1 | Len 2 | Len 3 | 25 + * ----------------------------------------- 26 + * | Ptr 0 | 27 + * ----------------------------------------- 28 + * | Ptr 1 | 29 + * ----------------------------------------- 30 + * | Ptr 2 | 31 + * ----------------------------------------- 32 + * | Ptr 3 | 33 + * ----------------------------------------- 34 + */ 21 35 struct octep_tx_sglist_desc { 22 36 u16 len[4]; 23 37 dma_addr_t dma_ptr[4];
+13 -6
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
··· 29 29 static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf, 30 30 struct bpf_prog *prog, 31 31 struct nix_cqe_rx_s *cqe, 32 - struct otx2_cq_queue *cq); 32 + struct otx2_cq_queue *cq, 33 + bool *need_xdp_flush); 33 34 34 35 static int otx2_nix_cq_op_status(struct otx2_nic *pfvf, 35 36 struct otx2_cq_queue *cq) ··· 338 337 static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf, 339 338 struct napi_struct *napi, 340 339 struct otx2_cq_queue *cq, 341 - struct nix_cqe_rx_s *cqe) 340 + struct nix_cqe_rx_s *cqe, bool *need_xdp_flush) 342 341 { 343 342 struct nix_rx_parse_s *parse = &cqe->parse; 344 343 struct nix_rx_sg_s *sg = &cqe->sg; ··· 354 353 } 355 354 356 355 if (pfvf->xdp_prog) 357 - if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq)) 356 + if (otx2_xdp_rcv_pkt_handler(pfvf, pfvf->xdp_prog, cqe, cq, need_xdp_flush)) 358 357 return; 359 358 360 359 skb = napi_get_frags(napi); ··· 389 388 struct napi_struct *napi, 390 389 struct otx2_cq_queue *cq, int budget) 391 390 { 391 + bool need_xdp_flush = false; 392 392 struct nix_cqe_rx_s *cqe; 393 393 int processed_cqe = 0; 394 394 ··· 411 409 cq->cq_head++; 412 410 cq->cq_head &= (cq->cqe_cnt - 1); 413 411 414 - otx2_rcv_pkt_handler(pfvf, napi, cq, cqe); 412 + otx2_rcv_pkt_handler(pfvf, napi, cq, cqe, &need_xdp_flush); 415 413 416 414 cqe->hdr.cqe_type = NIX_XQE_TYPE_INVALID; 417 415 cqe->sg.seg_addr = 0x00; 418 416 processed_cqe++; 419 417 cq->pend_cqe--; 420 418 } 419 + if (need_xdp_flush) 420 + xdp_do_flush(); 421 421 422 422 /* Free CQEs to HW */ 423 423 otx2_write64(pfvf, NIX_LF_CQ_OP_DOOR, ··· 1358 1354 static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf, 1359 1355 struct bpf_prog *prog, 1360 1356 struct nix_cqe_rx_s *cqe, 1361 - struct otx2_cq_queue *cq) 1357 + struct otx2_cq_queue *cq, 1358 + bool *need_xdp_flush) 1362 1359 { 1363 1360 unsigned char *hard_start, *data; 1364 1361 int qidx = cq->cq_idx; ··· 1396 1391 1397 1392 otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize, 1398 1393 DMA_FROM_DEVICE); 1399 - if (!err) 1394 + if (!err) { 1395 + *need_xdp_flush = true; 1400 1396 return true; 1397 + } 1401 1398 put_page(page); 1402 1399 break; 1403 1400 default:
+54 -5
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
··· 243 243 } 244 244 245 245 /* Helper function to create a rule of a specific size */ 246 - static struct vcap_rule * 247 - test_vcap_xn_rule_creator(struct kunit *test, int cid, enum vcap_user user, 248 - u16 priority, 249 - int id, int size, int expected_addr) 246 + static void test_vcap_xn_rule_creator(struct kunit *test, int cid, 247 + enum vcap_user user, u16 priority, 248 + int id, int size, int expected_addr) 250 249 { 251 250 struct vcap_rule *rule; 252 251 struct vcap_rule_internal *ri; ··· 310 311 ret = vcap_add_rule(rule); 311 312 KUNIT_EXPECT_EQ(test, 0, ret); 312 313 KUNIT_EXPECT_EQ(test, expected_addr, ri->addr); 313 - return rule; 314 + vcap_free_rule(rule); 314 315 } 315 316 316 317 /* Prepare testing rule deletion */ ··· 994 995 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[11]); 995 996 } 996 997 998 + static void vcap_free_ckf(struct vcap_rule *rule) 999 + { 1000 + struct vcap_client_keyfield *ckf, *next_ckf; 1001 + 1002 + list_for_each_entry_safe(ckf, next_ckf, &rule->keyfields, ctrl.list) { 1003 + list_del(&ckf->ctrl.list); 1004 + kfree(ckf); 1005 + } 1006 + } 1007 + 997 1008 static void vcap_api_rule_add_keyvalue_test(struct kunit *test) 998 1009 { 999 1010 struct vcap_admin admin = { ··· 1036 1027 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, kf->ctrl.type); 1037 1028 KUNIT_EXPECT_EQ(test, 0x0, kf->data.u1.value); 1038 1029 KUNIT_EXPECT_EQ(test, 0x1, kf->data.u1.mask); 1030 + vcap_free_ckf(rule); 1039 1031 1040 1032 INIT_LIST_HEAD(&rule->keyfields); 1041 1033 ret = vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_1); ··· 1049 1039 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, kf->ctrl.type); 1050 1040 KUNIT_EXPECT_EQ(test, 0x1, kf->data.u1.value); 1051 1041 KUNIT_EXPECT_EQ(test, 0x1, kf->data.u1.mask); 1042 + vcap_free_ckf(rule); 1052 1043 1053 1044 INIT_LIST_HEAD(&rule->keyfields); 1054 1045 ret = vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, ··· 1063 1052 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, kf->ctrl.type); 1064 1053 KUNIT_EXPECT_EQ(test, 0x0, kf->data.u1.value); 1065 1054 KUNIT_EXPECT_EQ(test, 0x0, kf->data.u1.mask); 1055 + vcap_free_ckf(rule); 1066 1056 1067 1057 INIT_LIST_HEAD(&rule->keyfields); 1068 1058 ret = vcap_rule_add_key_u32(rule, VCAP_KF_TYPE, 0x98765432, 0xff00ffab); ··· 1076 1064 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U32, kf->ctrl.type); 1077 1065 KUNIT_EXPECT_EQ(test, 0x98765432, kf->data.u32.value); 1078 1066 KUNIT_EXPECT_EQ(test, 0xff00ffab, kf->data.u32.mask); 1067 + vcap_free_ckf(rule); 1079 1068 1080 1069 INIT_LIST_HEAD(&rule->keyfields); 1081 1070 ret = vcap_rule_add_key_u128(rule, VCAP_KF_L3_IP6_SIP, &dip); ··· 1091 1078 KUNIT_EXPECT_EQ(test, dip.value[idx], kf->data.u128.value[idx]); 1092 1079 for (idx = 0; idx < ARRAY_SIZE(dip.mask); ++idx) 1093 1080 KUNIT_EXPECT_EQ(test, dip.mask[idx], kf->data.u128.mask[idx]); 1081 + vcap_free_ckf(rule); 1082 + } 1083 + 1084 + static void vcap_free_caf(struct vcap_rule *rule) 1085 + { 1086 + struct vcap_client_actionfield *caf, *next_caf; 1087 + 1088 + list_for_each_entry_safe(caf, next_caf, 1089 + &rule->actionfields, ctrl.list) { 1090 + list_del(&caf->ctrl.list); 1091 + kfree(caf); 1092 + } 1094 1093 } 1095 1094 1096 1095 static void vcap_api_rule_add_actionvalue_test(struct kunit *test) ··· 1130 1105 KUNIT_EXPECT_EQ(test, VCAP_AF_POLICE_ENA, af->ctrl.action); 1131 1106 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, af->ctrl.type); 1132 1107 KUNIT_EXPECT_EQ(test, 0x0, af->data.u1.value); 1108 + vcap_free_caf(rule); 1133 1109 1134 1110 INIT_LIST_HEAD(&rule->actionfields); 1135 1111 ret = vcap_rule_add_action_bit(rule, VCAP_AF_POLICE_ENA, VCAP_BIT_1); ··· 1142 1116 KUNIT_EXPECT_EQ(test, VCAP_AF_POLICE_ENA, af->ctrl.action); 1143 1117 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, af->ctrl.type); 1144 1118 KUNIT_EXPECT_EQ(test, 0x1, af->data.u1.value); 1119 + vcap_free_caf(rule); 1145 1120 1146 1121 INIT_LIST_HEAD(&rule->actionfields); 1147 1122 ret = vcap_rule_add_action_bit(rule, VCAP_AF_POLICE_ENA, VCAP_BIT_ANY); ··· 1154 1127 KUNIT_EXPECT_EQ(test, VCAP_AF_POLICE_ENA, af->ctrl.action); 1155 1128 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, af->ctrl.type); 1156 1129 KUNIT_EXPECT_EQ(test, 0x0, af->data.u1.value); 1130 + vcap_free_caf(rule); 1157 1131 1158 1132 INIT_LIST_HEAD(&rule->actionfields); 1159 1133 ret = vcap_rule_add_action_u32(rule, VCAP_AF_TYPE, 0x98765432); ··· 1166 1138 KUNIT_EXPECT_EQ(test, VCAP_AF_TYPE, af->ctrl.action); 1167 1139 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U32, af->ctrl.type); 1168 1140 KUNIT_EXPECT_EQ(test, 0x98765432, af->data.u32.value); 1141 + vcap_free_caf(rule); 1169 1142 1170 1143 INIT_LIST_HEAD(&rule->actionfields); 1171 1144 ret = vcap_rule_add_action_u32(rule, VCAP_AF_MASK_MODE, 0xaabbccdd); ··· 1178 1149 KUNIT_EXPECT_EQ(test, VCAP_AF_MASK_MODE, af->ctrl.action); 1179 1150 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U32, af->ctrl.type); 1180 1151 KUNIT_EXPECT_EQ(test, 0xaabbccdd, af->data.u32.value); 1152 + vcap_free_caf(rule); 1181 1153 } 1182 1154 1183 1155 static void vcap_api_rule_find_keyset_basic_test(struct kunit *test) ··· 1438 1408 ret = list_empty(&is2_admin.rules); 1439 1409 KUNIT_EXPECT_EQ(test, false, ret); 1440 1410 KUNIT_EXPECT_EQ(test, 0, ret); 1411 + 1412 + vcap_enable_lookups(&test_vctrl, &test_netdev, 0, 0, 1413 + rule->cookie, false); 1414 + 1441 1415 vcap_free_rule(rule); 1442 1416 1443 1417 /* Check that the rule has been freed: tricky to access since this ··· 1452 1418 KUNIT_EXPECT_EQ(test, true, ret); 1453 1419 ret = list_empty(&rule->actionfields); 1454 1420 KUNIT_EXPECT_EQ(test, true, ret); 1421 + 1422 + vcap_del_rule(&test_vctrl, &test_netdev, id); 1455 1423 } 1456 1424 1457 1425 static void vcap_api_set_rule_counter_test(struct kunit *test) ··· 1597 1561 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 20, 400, 6, 774); 1598 1562 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 30, 300, 3, 771); 1599 1563 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 40, 200, 2, 768); 1564 + 1565 + vcap_del_rule(&test_vctrl, &test_netdev, 200); 1566 + vcap_del_rule(&test_vctrl, &test_netdev, 300); 1567 + vcap_del_rule(&test_vctrl, &test_netdev, 400); 1568 + vcap_del_rule(&test_vctrl, &test_netdev, 500); 1600 1569 } 1601 1570 1602 1571 static void vcap_api_rule_insert_reverse_order_test(struct kunit *test) ··· 1660 1619 ++idx; 1661 1620 } 1662 1621 KUNIT_EXPECT_EQ(test, 768, admin.last_used_addr); 1622 + 1623 + vcap_del_rule(&test_vctrl, &test_netdev, 500); 1624 + vcap_del_rule(&test_vctrl, &test_netdev, 400); 1625 + vcap_del_rule(&test_vctrl, &test_netdev, 300); 1626 + vcap_del_rule(&test_vctrl, &test_netdev, 200); 1663 1627 } 1664 1628 1665 1629 static void vcap_api_rule_remove_at_end_test(struct kunit *test) ··· 1865 1819 KUNIT_EXPECT_EQ(test, 786, test_init_start); 1866 1820 KUNIT_EXPECT_EQ(test, 8, test_init_count); 1867 1821 KUNIT_EXPECT_EQ(test, 794, admin.last_used_addr); 1822 + 1823 + vcap_del_rule(&test_vctrl, &test_netdev, 200); 1824 + vcap_del_rule(&test_vctrl, &test_netdev, 300); 1868 1825 } 1869 1826 1870 1827 static struct kunit_case vcap_api_rule_remove_test_cases[] = {
+1
drivers/net/ethernet/pensando/ionic/ionic_dev.h
··· 187 187 struct ionic_desc_info *desc_info, 188 188 struct ionic_cq_info *cq_info, void *cb_arg); 189 189 190 + #define IONIC_MAX_BUF_LEN ((u16)-1) 190 191 #define IONIC_PAGE_SIZE PAGE_SIZE 191 192 #define IONIC_PAGE_SPLIT_SZ (PAGE_SIZE / 2) 192 193 #define IONIC_PAGE_GFP_MASK (GFP_ATOMIC | __GFP_NOWARN |\
+7 -3
drivers/net/ethernet/pensando/ionic/ionic_txrx.c
··· 207 207 return NULL; 208 208 } 209 209 210 - frag_len = min_t(u16, len, IONIC_PAGE_SIZE - buf_info->page_offset); 210 + frag_len = min_t(u16, len, min_t(u32, IONIC_MAX_BUF_LEN, 211 + IONIC_PAGE_SIZE - buf_info->page_offset)); 211 212 len -= frag_len; 212 213 213 214 dma_sync_single_for_cpu(dev, ··· 453 452 454 453 /* fill main descriptor - buf[0] */ 455 454 desc->addr = cpu_to_le64(buf_info->dma_addr + buf_info->page_offset); 456 - frag_len = min_t(u16, len, IONIC_PAGE_SIZE - buf_info->page_offset); 455 + frag_len = min_t(u16, len, min_t(u32, IONIC_MAX_BUF_LEN, 456 + IONIC_PAGE_SIZE - buf_info->page_offset)); 457 457 desc->len = cpu_to_le16(frag_len); 458 458 remain_len -= frag_len; 459 459 buf_info++; ··· 473 471 } 474 472 475 473 sg_elem->addr = cpu_to_le64(buf_info->dma_addr + buf_info->page_offset); 476 - frag_len = min_t(u16, remain_len, IONIC_PAGE_SIZE - buf_info->page_offset); 474 + frag_len = min_t(u16, remain_len, min_t(u32, IONIC_MAX_BUF_LEN, 475 + IONIC_PAGE_SIZE - 476 + buf_info->page_offset)); 477 477 sg_elem->len = cpu_to_le16(frag_len); 478 478 remain_len -= frag_len; 479 479 buf_info++;
+18 -3
drivers/net/ethernet/sfc/tc.c
··· 136 136 if (old) { 137 137 /* don't need our new entry */ 138 138 kfree(ped); 139 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 140 + return ERR_CAST(old); 139 141 if (!refcount_inc_not_zero(&old->ref)) 140 142 return ERR_PTR(-EAGAIN); 141 143 /* existing entry found, ref taken */ ··· 604 602 kfree(encap); 605 603 if (pseudo) /* don't need our new pseudo either */ 606 604 efx_tc_flower_release_encap_match(efx, pseudo); 605 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 606 + return PTR_ERR(old); 607 607 /* check old and new em_types are compatible */ 608 608 switch (old->type) { 609 609 case EFX_TC_EM_DIRECT: ··· 704 700 if (old) { 705 701 /* don't need our new entry */ 706 702 kfree(rid); 703 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 704 + return ERR_CAST(old); 707 705 if (!refcount_inc_not_zero(&old->ref)) 708 706 return ERR_PTR(-EAGAIN); 709 707 /* existing entry found */ ··· 1488 1482 old = rhashtable_lookup_get_insert_fast(&efx->tc->match_action_ht, 1489 1483 &rule->linkage, 1490 1484 efx_tc_match_action_ht_params); 1491 - if (old) { 1485 + if (IS_ERR(old)) { 1486 + rc = PTR_ERR(old); 1487 + goto release; 1488 + } else if (old) { 1492 1489 netif_dbg(efx, drv, efx->net_dev, 1493 1490 "Ignoring already-offloaded rule (cookie %lx)\n", 1494 1491 tc->cookie); ··· 1706 1697 old = rhashtable_lookup_get_insert_fast(&efx->tc->lhs_rule_ht, 1707 1698 &rule->linkage, 1708 1699 efx_tc_lhs_rule_ht_params); 1709 - if (old) { 1700 + if (IS_ERR(old)) { 1701 + rc = PTR_ERR(old); 1702 + goto release; 1703 + } else if (old) { 1710 1704 netif_dbg(efx, drv, efx->net_dev, 1711 1705 "Already offloaded rule (cookie %lx)\n", tc->cookie); 1712 1706 rc = -EEXIST; ··· 1870 1858 old = rhashtable_lookup_get_insert_fast(&efx->tc->match_action_ht, 1871 1859 &rule->linkage, 1872 1860 efx_tc_match_action_ht_params); 1873 - if (old) { 1861 + if (IS_ERR(old)) { 1862 + rc = PTR_ERR(old); 1863 + goto release; 1864 + } else if (old) { 1874 1865 netif_dbg(efx, drv, efx->net_dev, 1875 1866 "Already offloaded rule (cookie %lx)\n", tc->cookie); 1876 1867 NL_SET_ERR_MSG_MOD(extack, "Rule already offloaded");
+6 -1
drivers/net/ethernet/sfc/tc_conntrack.c
··· 298 298 old = rhashtable_lookup_get_insert_fast(&efx->tc->ct_ht, 299 299 &conn->linkage, 300 300 efx_tc_ct_ht_params); 301 - if (old) { 301 + if (IS_ERR(old)) { 302 + rc = PTR_ERR(old); 303 + goto release; 304 + } else if (old) { 302 305 netif_dbg(efx, drv, efx->net_dev, 303 306 "Already offloaded conntrack (cookie %lx)\n", tc->cookie); 304 307 rc = -EEXIST; ··· 485 482 if (old) { 486 483 /* don't need our new entry */ 487 484 kfree(ct_zone); 485 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 486 + return ERR_CAST(old); 488 487 if (!refcount_inc_not_zero(&old->ref)) 489 488 return ERR_PTR(-EAGAIN); 490 489 /* existing entry found */
+2
drivers/net/ethernet/sfc/tc_counters.c
··· 236 236 if (old) { 237 237 /* don't need our new entry */ 238 238 kfree(ctr); 239 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 240 + return ERR_CAST(old); 239 241 if (!refcount_inc_not_zero(&old->ref)) 240 242 return ERR_PTR(-EAGAIN); 241 243 /* existing entry found */
+4
drivers/net/ethernet/sfc/tc_encap_actions.c
··· 132 132 /* don't need our new entry */ 133 133 put_net_track(neigh->net, &neigh->ns_tracker); 134 134 kfree(neigh); 135 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 136 + return PTR_ERR(old); 135 137 if (!refcount_inc_not_zero(&old->ref)) 136 138 return -EAGAIN; 137 139 /* existing entry found, ref taken */ ··· 642 640 if (old) { 643 641 /* don't need our new entry */ 644 642 kfree(encap); 643 + if (IS_ERR(old)) /* oh dear, it's actually an error */ 644 + return ERR_CAST(old); 645 645 if (!refcount_inc_not_zero(&old->ref)) 646 646 return ERR_PTR(-EAGAIN); 647 647 /* existing entry found, ref taken */
+5 -2
drivers/net/ethernet/stmicro/stmmac/common.h
··· 70 70 u64 tx_tso_frames; 71 71 u64 tx_tso_nfrags; 72 72 struct u64_stats_sync syncp; 73 - }; 73 + } ____cacheline_aligned_in_smp; 74 74 75 75 struct stmmac_rxq_stats { 76 76 u64 rx_bytes; ··· 79 79 u64 rx_normal_irq_n; 80 80 u64 napi_poll; 81 81 struct u64_stats_sync syncp; 82 - }; 82 + } ____cacheline_aligned_in_smp; 83 83 84 84 /* Extra statistic and debug information exposed by ethtool */ 85 85 struct stmmac_extra_stats { ··· 202 202 unsigned long mtl_est_hlbf; 203 203 unsigned long mtl_est_btre; 204 204 unsigned long mtl_est_btrlm; 205 + /* per queue statistics */ 206 + struct stmmac_txq_stats txq_stats[MTL_MAX_TX_QUEUES]; 207 + struct stmmac_rxq_stats rxq_stats[MTL_MAX_RX_QUEUES]; 205 208 unsigned long rx_dropped; 206 209 unsigned long rx_errors; 207 210 unsigned long tx_dropped;
+8 -8
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
··· 441 441 struct stmmac_extra_stats *x, u32 chan, 442 442 u32 dir) 443 443 { 444 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[chan]; 445 - struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan]; 444 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; 445 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan]; 446 446 int ret = 0; 447 447 u32 v; 448 448 ··· 455 455 456 456 if (v & EMAC_TX_INT) { 457 457 ret |= handle_tx; 458 - u64_stats_update_begin(&tx_q->txq_stats.syncp); 459 - tx_q->txq_stats.tx_normal_irq_n++; 460 - u64_stats_update_end(&tx_q->txq_stats.syncp); 458 + u64_stats_update_begin(&txq_stats->syncp); 459 + txq_stats->tx_normal_irq_n++; 460 + u64_stats_update_end(&txq_stats->syncp); 461 461 } 462 462 463 463 if (v & EMAC_TX_DMA_STOP_INT) ··· 479 479 480 480 if (v & EMAC_RX_INT) { 481 481 ret |= handle_rx; 482 - u64_stats_update_begin(&rx_q->rxq_stats.syncp); 483 - rx_q->rxq_stats.rx_normal_irq_n++; 484 - u64_stats_update_end(&rx_q->rxq_stats.syncp); 482 + u64_stats_update_begin(&rxq_stats->syncp); 483 + rxq_stats->rx_normal_irq_n++; 484 + u64_stats_update_end(&rxq_stats->syncp); 485 485 } 486 486 487 487 if (v & EMAC_RX_BUF_UA_INT)
+8 -8
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
··· 171 171 const struct dwmac4_addrs *dwmac4_addrs = priv->plat->dwmac4_addrs; 172 172 u32 intr_status = readl(ioaddr + DMA_CHAN_STATUS(dwmac4_addrs, chan)); 173 173 u32 intr_en = readl(ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan)); 174 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[chan]; 175 - struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan]; 174 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; 175 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan]; 176 176 int ret = 0; 177 177 178 178 if (dir == DMA_DIR_RX) ··· 201 201 } 202 202 /* TX/RX NORMAL interrupts */ 203 203 if (likely(intr_status & DMA_CHAN_STATUS_RI)) { 204 - u64_stats_update_begin(&rx_q->rxq_stats.syncp); 205 - rx_q->rxq_stats.rx_normal_irq_n++; 206 - u64_stats_update_end(&rx_q->rxq_stats.syncp); 204 + u64_stats_update_begin(&rxq_stats->syncp); 205 + rxq_stats->rx_normal_irq_n++; 206 + u64_stats_update_end(&rxq_stats->syncp); 207 207 ret |= handle_rx; 208 208 } 209 209 if (likely(intr_status & DMA_CHAN_STATUS_TI)) { 210 - u64_stats_update_begin(&tx_q->txq_stats.syncp); 211 - tx_q->txq_stats.tx_normal_irq_n++; 212 - u64_stats_update_end(&tx_q->txq_stats.syncp); 210 + u64_stats_update_begin(&txq_stats->syncp); 211 + txq_stats->tx_normal_irq_n++; 212 + u64_stats_update_end(&txq_stats->syncp); 213 213 ret |= handle_tx; 214 214 } 215 215
+8 -8
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c
··· 162 162 int dwmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, 163 163 struct stmmac_extra_stats *x, u32 chan, u32 dir) 164 164 { 165 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[chan]; 166 - struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan]; 165 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; 166 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan]; 167 167 int ret = 0; 168 168 /* read the status register (CSR5) */ 169 169 u32 intr_status = readl(ioaddr + DMA_STATUS); ··· 215 215 u32 value = readl(ioaddr + DMA_INTR_ENA); 216 216 /* to schedule NAPI on real RIE event. */ 217 217 if (likely(value & DMA_INTR_ENA_RIE)) { 218 - u64_stats_update_begin(&rx_q->rxq_stats.syncp); 219 - rx_q->rxq_stats.rx_normal_irq_n++; 220 - u64_stats_update_end(&rx_q->rxq_stats.syncp); 218 + u64_stats_update_begin(&rxq_stats->syncp); 219 + rxq_stats->rx_normal_irq_n++; 220 + u64_stats_update_end(&rxq_stats->syncp); 221 221 ret |= handle_rx; 222 222 } 223 223 } 224 224 if (likely(intr_status & DMA_STATUS_TI)) { 225 - u64_stats_update_begin(&tx_q->txq_stats.syncp); 226 - tx_q->txq_stats.tx_normal_irq_n++; 227 - u64_stats_update_end(&tx_q->txq_stats.syncp); 225 + u64_stats_update_begin(&txq_stats->syncp); 226 + txq_stats->tx_normal_irq_n++; 227 + u64_stats_update_end(&txq_stats->syncp); 228 228 ret |= handle_tx; 229 229 } 230 230 if (unlikely(intr_status & DMA_STATUS_ERI))
+8 -8
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
··· 337 337 struct stmmac_extra_stats *x, u32 chan, 338 338 u32 dir) 339 339 { 340 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[chan]; 341 - struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan]; 340 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; 341 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan]; 342 342 u32 intr_status = readl(ioaddr + XGMAC_DMA_CH_STATUS(chan)); 343 343 u32 intr_en = readl(ioaddr + XGMAC_DMA_CH_INT_EN(chan)); 344 344 int ret = 0; ··· 367 367 /* TX/RX NORMAL interrupts */ 368 368 if (likely(intr_status & XGMAC_NIS)) { 369 369 if (likely(intr_status & XGMAC_RI)) { 370 - u64_stats_update_begin(&rx_q->rxq_stats.syncp); 371 - rx_q->rxq_stats.rx_normal_irq_n++; 372 - u64_stats_update_end(&rx_q->rxq_stats.syncp); 370 + u64_stats_update_begin(&rxq_stats->syncp); 371 + rxq_stats->rx_normal_irq_n++; 372 + u64_stats_update_end(&rxq_stats->syncp); 373 373 ret |= handle_rx; 374 374 } 375 375 if (likely(intr_status & (XGMAC_TI | XGMAC_TBU))) { 376 - u64_stats_update_begin(&tx_q->txq_stats.syncp); 377 - tx_q->txq_stats.tx_normal_irq_n++; 378 - u64_stats_update_end(&tx_q->txq_stats.syncp); 376 + u64_stats_update_begin(&txq_stats->syncp); 377 + txq_stats->tx_normal_irq_n++; 378 + u64_stats_update_end(&txq_stats->syncp); 379 379 ret |= handle_tx; 380 380 } 381 381 }
-2
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 78 78 dma_addr_t dma_tx_phy; 79 79 dma_addr_t tx_tail_addr; 80 80 u32 mss; 81 - struct stmmac_txq_stats txq_stats; 82 81 }; 83 82 84 83 struct stmmac_rx_buffer { ··· 122 123 unsigned int len; 123 124 unsigned int error; 124 125 } state; 125 - struct stmmac_rxq_stats rxq_stats; 126 126 }; 127 127 128 128 struct stmmac_channel {
+16 -16
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
··· 548 548 549 549 pos = data; 550 550 for (q = 0; q < tx_cnt; q++) { 551 - struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[q]; 551 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[q]; 552 552 struct stmmac_txq_stats snapshot; 553 553 554 554 data = pos; 555 555 do { 556 - start = u64_stats_fetch_begin(&tx_q->txq_stats.syncp); 557 - snapshot = tx_q->txq_stats; 558 - } while (u64_stats_fetch_retry(&tx_q->txq_stats.syncp, start)); 556 + start = u64_stats_fetch_begin(&txq_stats->syncp); 557 + snapshot = *txq_stats; 558 + } while (u64_stats_fetch_retry(&txq_stats->syncp, start)); 559 559 560 560 p = (char *)&snapshot + offsetof(struct stmmac_txq_stats, tx_pkt_n); 561 561 for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) { ··· 566 566 567 567 pos = data; 568 568 for (q = 0; q < rx_cnt; q++) { 569 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[q]; 569 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[q]; 570 570 struct stmmac_rxq_stats snapshot; 571 571 572 572 data = pos; 573 573 do { 574 - start = u64_stats_fetch_begin(&rx_q->rxq_stats.syncp); 575 - snapshot = rx_q->rxq_stats; 576 - } while (u64_stats_fetch_retry(&rx_q->rxq_stats.syncp, start)); 574 + start = u64_stats_fetch_begin(&rxq_stats->syncp); 575 + snapshot = *rxq_stats; 576 + } while (u64_stats_fetch_retry(&rxq_stats->syncp, start)); 577 577 578 578 p = (char *)&snapshot + offsetof(struct stmmac_rxq_stats, rx_pkt_n); 579 579 for (stat = 0; stat < STMMAC_RXQ_STATS; stat++) { ··· 637 637 638 638 pos = j; 639 639 for (i = 0; i < rx_queues_count; i++) { 640 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[i]; 640 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[i]; 641 641 struct stmmac_rxq_stats snapshot; 642 642 643 643 j = pos; 644 644 do { 645 - start = u64_stats_fetch_begin(&rx_q->rxq_stats.syncp); 646 - snapshot = rx_q->rxq_stats; 647 - } while (u64_stats_fetch_retry(&rx_q->rxq_stats.syncp, start)); 645 + start = u64_stats_fetch_begin(&rxq_stats->syncp); 646 + snapshot = *rxq_stats; 647 + } while (u64_stats_fetch_retry(&rxq_stats->syncp, start)); 648 648 649 649 data[j++] += snapshot.rx_pkt_n; 650 650 data[j++] += snapshot.rx_normal_irq_n; ··· 654 654 655 655 pos = j; 656 656 for (i = 0; i < tx_queues_count; i++) { 657 - struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[i]; 657 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[i]; 658 658 struct stmmac_txq_stats snapshot; 659 659 660 660 j = pos; 661 661 do { 662 - start = u64_stats_fetch_begin(&tx_q->txq_stats.syncp); 663 - snapshot = tx_q->txq_stats; 664 - } while (u64_stats_fetch_retry(&tx_q->txq_stats.syncp, start)); 662 + start = u64_stats_fetch_begin(&txq_stats->syncp); 663 + snapshot = *txq_stats; 664 + } while (u64_stats_fetch_retry(&txq_stats->syncp, start)); 665 665 666 666 data[j++] += snapshot.tx_pkt_n; 667 667 data[j++] += snapshot.tx_normal_irq_n;
+67 -58
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 2426 2426 { 2427 2427 struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue); 2428 2428 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; 2429 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue]; 2429 2430 struct xsk_buff_pool *pool = tx_q->xsk_pool; 2430 2431 unsigned int entry = tx_q->cur_tx; 2431 2432 struct dma_desc *tx_desc = NULL; ··· 2506 2505 tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size); 2507 2506 entry = tx_q->cur_tx; 2508 2507 } 2509 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 2510 - tx_q->txq_stats.tx_set_ic_bit += tx_set_ic_bit; 2511 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 2508 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 2509 + txq_stats->tx_set_ic_bit += tx_set_ic_bit; 2510 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 2512 2511 2513 2512 if (tx_desc) { 2514 2513 stmmac_flush_tx_descriptors(priv, queue); ··· 2548 2547 static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue) 2549 2548 { 2550 2549 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; 2550 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue]; 2551 2551 unsigned int bytes_compl = 0, pkts_compl = 0; 2552 2552 unsigned int entry, xmits = 0, count = 0; 2553 2553 u32 tx_packets = 0, tx_errors = 0; ··· 2708 2706 if (tx_q->dirty_tx != tx_q->cur_tx) 2709 2707 stmmac_tx_timer_arm(priv, queue); 2710 2708 2711 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 2712 - tx_q->txq_stats.tx_packets += tx_packets; 2713 - tx_q->txq_stats.tx_pkt_n += tx_packets; 2714 - tx_q->txq_stats.tx_clean++; 2715 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 2709 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 2710 + txq_stats->tx_packets += tx_packets; 2711 + txq_stats->tx_pkt_n += tx_packets; 2712 + txq_stats->tx_clean++; 2713 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 2716 2714 2717 2715 priv->xstats.tx_errors += tx_errors; 2718 2716 ··· 4116 4114 int nfrags = skb_shinfo(skb)->nr_frags; 4117 4115 u32 queue = skb_get_queue_mapping(skb); 4118 4116 unsigned int first_entry, tx_packets; 4117 + struct stmmac_txq_stats *txq_stats; 4119 4118 int tmp_pay_len = 0, first_tx; 4120 4119 struct stmmac_tx_queue *tx_q; 4121 4120 bool has_vlan, set_ic; ··· 4127 4124 int i; 4128 4125 4129 4126 tx_q = &priv->dma_conf.tx_queue[queue]; 4127 + txq_stats = &priv->xstats.txq_stats[queue]; 4130 4128 first_tx = tx_q->cur_tx; 4131 4129 4132 4130 /* Compute header lengths */ ··· 4286 4282 netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, queue)); 4287 4283 } 4288 4284 4289 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 4290 - tx_q->txq_stats.tx_bytes += skb->len; 4291 - tx_q->txq_stats.tx_tso_frames++; 4292 - tx_q->txq_stats.tx_tso_nfrags += nfrags; 4285 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 4286 + txq_stats->tx_bytes += skb->len; 4287 + txq_stats->tx_tso_frames++; 4288 + txq_stats->tx_tso_nfrags += nfrags; 4293 4289 if (set_ic) 4294 - tx_q->txq_stats.tx_set_ic_bit++; 4295 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 4290 + txq_stats->tx_set_ic_bit++; 4291 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 4296 4292 4297 4293 if (priv->sarc_type) 4298 4294 stmmac_set_desc_sarc(priv, first, priv->sarc_type); ··· 4363 4359 u32 queue = skb_get_queue_mapping(skb); 4364 4360 int nfrags = skb_shinfo(skb)->nr_frags; 4365 4361 int gso = skb_shinfo(skb)->gso_type; 4362 + struct stmmac_txq_stats *txq_stats; 4366 4363 struct dma_edesc *tbs_desc = NULL; 4367 4364 struct dma_desc *desc, *first; 4368 4365 struct stmmac_tx_queue *tx_q; ··· 4373 4368 dma_addr_t des; 4374 4369 4375 4370 tx_q = &priv->dma_conf.tx_queue[queue]; 4371 + txq_stats = &priv->xstats.txq_stats[queue]; 4376 4372 first_tx = tx_q->cur_tx; 4377 4373 4378 4374 if (priv->tx_path_in_lpi_mode && priv->eee_sw_timer_en) ··· 4525 4519 netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, queue)); 4526 4520 } 4527 4521 4528 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 4529 - tx_q->txq_stats.tx_bytes += skb->len; 4522 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 4523 + txq_stats->tx_bytes += skb->len; 4530 4524 if (set_ic) 4531 - tx_q->txq_stats.tx_set_ic_bit++; 4532 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 4525 + txq_stats->tx_set_ic_bit++; 4526 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 4533 4527 4534 4528 if (priv->sarc_type) 4535 4529 stmmac_set_desc_sarc(priv, first, priv->sarc_type); ··· 4736 4730 static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue, 4737 4731 struct xdp_frame *xdpf, bool dma_map) 4738 4732 { 4733 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue]; 4739 4734 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; 4740 4735 unsigned int entry = tx_q->cur_tx; 4741 4736 struct dma_desc *tx_desc; ··· 4796 4789 unsigned long flags; 4797 4790 tx_q->tx_count_frames = 0; 4798 4791 stmmac_set_tx_ic(priv, tx_desc); 4799 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 4800 - tx_q->txq_stats.tx_set_ic_bit++; 4801 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 4792 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 4793 + txq_stats->tx_set_ic_bit++; 4794 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 4802 4795 } 4803 4796 4804 4797 stmmac_enable_dma_transmission(priv, priv->ioaddr); ··· 4943 4936 struct dma_desc *p, struct dma_desc *np, 4944 4937 struct xdp_buff *xdp) 4945 4938 { 4946 - struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[queue]; 4939 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue]; 4947 4940 struct stmmac_channel *ch = &priv->channel[queue]; 4948 4941 unsigned int len = xdp->data_end - xdp->data; 4949 4942 enum pkt_hash_types hash_type; ··· 4973 4966 skb_record_rx_queue(skb, queue); 4974 4967 napi_gro_receive(&ch->rxtx_napi, skb); 4975 4968 4976 - flags = u64_stats_update_begin_irqsave(&rx_q->rxq_stats.syncp); 4977 - rx_q->rxq_stats.rx_pkt_n++; 4978 - rx_q->rxq_stats.rx_bytes += len; 4979 - u64_stats_update_end_irqrestore(&rx_q->rxq_stats.syncp, flags); 4969 + flags = u64_stats_update_begin_irqsave(&rxq_stats->syncp); 4970 + rxq_stats->rx_pkt_n++; 4971 + rxq_stats->rx_bytes += len; 4972 + u64_stats_update_end_irqrestore(&rxq_stats->syncp, flags); 4980 4973 } 4981 4974 4982 4975 static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget) ··· 5049 5042 5050 5043 static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue) 5051 5044 { 5045 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue]; 5052 5046 struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[queue]; 5053 5047 unsigned int count = 0, error = 0, len = 0; 5054 5048 int dirty = stmmac_rx_dirty(priv, queue); ··· 5213 5205 5214 5206 stmmac_finalize_xdp_rx(priv, xdp_status); 5215 5207 5216 - flags = u64_stats_update_begin_irqsave(&rx_q->rxq_stats.syncp); 5217 - rx_q->rxq_stats.rx_pkt_n += count; 5218 - u64_stats_update_end_irqrestore(&rx_q->rxq_stats.syncp, flags); 5208 + flags = u64_stats_update_begin_irqsave(&rxq_stats->syncp); 5209 + rxq_stats->rx_pkt_n += count; 5210 + u64_stats_update_end_irqrestore(&rxq_stats->syncp, flags); 5219 5211 5220 5212 priv->xstats.rx_dropped += rx_dropped; 5221 5213 priv->xstats.rx_errors += rx_errors; ··· 5243 5235 static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) 5244 5236 { 5245 5237 u32 rx_errors = 0, rx_dropped = 0, rx_bytes = 0, rx_packets = 0; 5238 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue]; 5246 5239 struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[queue]; 5247 5240 struct stmmac_channel *ch = &priv->channel[queue]; 5248 5241 unsigned int count = 0, error = 0, len = 0; ··· 5505 5496 5506 5497 stmmac_rx_refill(priv, queue); 5507 5498 5508 - flags = u64_stats_update_begin_irqsave(&rx_q->rxq_stats.syncp); 5509 - rx_q->rxq_stats.rx_packets += rx_packets; 5510 - rx_q->rxq_stats.rx_bytes += rx_bytes; 5511 - rx_q->rxq_stats.rx_pkt_n += count; 5512 - u64_stats_update_end_irqrestore(&rx_q->rxq_stats.syncp, flags); 5499 + flags = u64_stats_update_begin_irqsave(&rxq_stats->syncp); 5500 + rxq_stats->rx_packets += rx_packets; 5501 + rxq_stats->rx_bytes += rx_bytes; 5502 + rxq_stats->rx_pkt_n += count; 5503 + u64_stats_update_end_irqrestore(&rxq_stats->syncp, flags); 5513 5504 5514 5505 priv->xstats.rx_dropped += rx_dropped; 5515 5506 priv->xstats.rx_errors += rx_errors; ··· 5522 5513 struct stmmac_channel *ch = 5523 5514 container_of(napi, struct stmmac_channel, rx_napi); 5524 5515 struct stmmac_priv *priv = ch->priv_data; 5525 - struct stmmac_rx_queue *rx_q; 5516 + struct stmmac_rxq_stats *rxq_stats; 5526 5517 u32 chan = ch->index; 5527 5518 unsigned long flags; 5528 5519 int work_done; 5529 5520 5530 - rx_q = &priv->dma_conf.rx_queue[chan]; 5531 - flags = u64_stats_update_begin_irqsave(&rx_q->rxq_stats.syncp); 5532 - rx_q->rxq_stats.napi_poll++; 5533 - u64_stats_update_end_irqrestore(&rx_q->rxq_stats.syncp, flags); 5521 + rxq_stats = &priv->xstats.rxq_stats[chan]; 5522 + flags = u64_stats_update_begin_irqsave(&rxq_stats->syncp); 5523 + rxq_stats->napi_poll++; 5524 + u64_stats_update_end_irqrestore(&rxq_stats->syncp, flags); 5534 5525 5535 5526 work_done = stmmac_rx(priv, budget, chan); 5536 5527 if (work_done < budget && napi_complete_done(napi, work_done)) { ··· 5549 5540 struct stmmac_channel *ch = 5550 5541 container_of(napi, struct stmmac_channel, tx_napi); 5551 5542 struct stmmac_priv *priv = ch->priv_data; 5552 - struct stmmac_tx_queue *tx_q; 5543 + struct stmmac_txq_stats *txq_stats; 5553 5544 u32 chan = ch->index; 5554 5545 unsigned long flags; 5555 5546 int work_done; 5556 5547 5557 - tx_q = &priv->dma_conf.tx_queue[chan]; 5558 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 5559 - tx_q->txq_stats.napi_poll++; 5560 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 5548 + txq_stats = &priv->xstats.txq_stats[chan]; 5549 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 5550 + txq_stats->napi_poll++; 5551 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 5561 5552 5562 5553 work_done = stmmac_tx_clean(priv, budget, chan); 5563 5554 work_done = min(work_done, budget); ··· 5579 5570 container_of(napi, struct stmmac_channel, rxtx_napi); 5580 5571 struct stmmac_priv *priv = ch->priv_data; 5581 5572 int rx_done, tx_done, rxtx_done; 5582 - struct stmmac_rx_queue *rx_q; 5583 - struct stmmac_tx_queue *tx_q; 5573 + struct stmmac_rxq_stats *rxq_stats; 5574 + struct stmmac_txq_stats *txq_stats; 5584 5575 u32 chan = ch->index; 5585 5576 unsigned long flags; 5586 5577 5587 - rx_q = &priv->dma_conf.rx_queue[chan]; 5588 - flags = u64_stats_update_begin_irqsave(&rx_q->rxq_stats.syncp); 5589 - rx_q->rxq_stats.napi_poll++; 5590 - u64_stats_update_end_irqrestore(&rx_q->rxq_stats.syncp, flags); 5578 + rxq_stats = &priv->xstats.rxq_stats[chan]; 5579 + flags = u64_stats_update_begin_irqsave(&rxq_stats->syncp); 5580 + rxq_stats->napi_poll++; 5581 + u64_stats_update_end_irqrestore(&rxq_stats->syncp, flags); 5591 5582 5592 - tx_q = &priv->dma_conf.tx_queue[chan]; 5593 - flags = u64_stats_update_begin_irqsave(&tx_q->txq_stats.syncp); 5594 - tx_q->txq_stats.napi_poll++; 5595 - u64_stats_update_end_irqrestore(&tx_q->txq_stats.syncp, flags); 5583 + txq_stats = &priv->xstats.txq_stats[chan]; 5584 + flags = u64_stats_update_begin_irqsave(&txq_stats->syncp); 5585 + txq_stats->napi_poll++; 5586 + u64_stats_update_end_irqrestore(&txq_stats->syncp, flags); 5596 5587 5597 5588 tx_done = stmmac_tx_clean(priv, budget, chan); 5598 5589 tx_done = min(tx_done, budget); ··· 6935 6926 int q; 6936 6927 6937 6928 for (q = 0; q < tx_cnt; q++) { 6938 - struct stmmac_txq_stats *txq_stats = &priv->dma_conf.tx_queue[q].txq_stats; 6929 + struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[q]; 6939 6930 u64 tx_packets; 6940 6931 u64 tx_bytes; 6941 6932 ··· 6950 6941 } 6951 6942 6952 6943 for (q = 0; q < rx_cnt; q++) { 6953 - struct stmmac_rxq_stats *rxq_stats = &priv->dma_conf.rx_queue[q].rxq_stats; 6944 + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[q]; 6954 6945 u64 rx_packets; 6955 6946 u64 rx_bytes; 6956 6947 ··· 7351 7342 priv->dev = ndev; 7352 7343 7353 7344 for (i = 0; i < MTL_MAX_RX_QUEUES; i++) 7354 - u64_stats_init(&priv->dma_conf.rx_queue[i].rxq_stats.syncp); 7345 + u64_stats_init(&priv->xstats.rxq_stats[i].syncp); 7355 7346 for (i = 0; i < MTL_MAX_TX_QUEUES; i++) 7356 - u64_stats_init(&priv->dma_conf.tx_queue[i].txq_stats.syncp); 7347 + u64_stats_init(&priv->xstats.txq_stats[i].syncp); 7357 7348 7358 7349 stmmac_set_ethtool_ops(ndev); 7359 7350 priv->pause = pause;
+1
drivers/net/ethernet/ti/Kconfig
··· 199 199 200 200 config TI_ICSS_IEP 201 201 tristate "TI PRU ICSS IEP driver" 202 + depends on PTP_1588_CLOCK_OPTIONAL 202 203 depends on TI_PRUSS 203 204 default TI_PRUSS 204 205 help
+9 -1
drivers/net/team/team.c
··· 2115 2115 static void team_setup_by_port(struct net_device *dev, 2116 2116 struct net_device *port_dev) 2117 2117 { 2118 - dev->header_ops = port_dev->header_ops; 2118 + struct team *team = netdev_priv(dev); 2119 + 2120 + if (port_dev->type == ARPHRD_ETHER) 2121 + dev->header_ops = team->header_ops_cache; 2122 + else 2123 + dev->header_ops = port_dev->header_ops; 2119 2124 dev->type = port_dev->type; 2120 2125 dev->hard_header_len = port_dev->hard_header_len; 2121 2126 dev->needed_headroom = port_dev->needed_headroom; ··· 2167 2162 2168 2163 static void team_setup(struct net_device *dev) 2169 2164 { 2165 + struct team *team = netdev_priv(dev); 2166 + 2170 2167 ether_setup(dev); 2171 2168 dev->max_mtu = ETH_MAX_MTU; 2169 + team->header_ops_cache = dev->header_ops; 2172 2170 2173 2171 dev->netdev_ops = &team_netdev_ops; 2174 2172 dev->ethtool_ops = &team_ethtool_ops;
+1 -2
drivers/net/thunderbolt/main.c
··· 1049 1049 *tucso = ~csum_tcpudp_magic(ip_hdr(skb)->saddr, 1050 1050 ip_hdr(skb)->daddr, 0, 1051 1051 ip_hdr(skb)->protocol, 0); 1052 - } else if (skb_is_gso_v6(skb)) { 1052 + } else if (skb_is_gso(skb) && skb_is_gso_v6(skb)) { 1053 1053 tucso = dest + ((void *)&(tcp_hdr(skb)->check) - data); 1054 1054 *tucso = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, 1055 1055 &ipv6_hdr(skb)->daddr, 0, 1056 1056 IPPROTO_TCP, 0); 1057 - return false; 1058 1057 } else if (protocol == htons(ETH_P_IPV6)) { 1059 1058 tucso = dest + skb_checksum_start_offset(skb) + skb->csum_offset; 1060 1059 *tucso = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
+4
drivers/net/vxlan/vxlan_core.c
··· 4331 4331 nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_REMCSUM_TX */ 4332 4332 nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_REMCSUM_RX */ 4333 4333 nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_LOCALBYPASS */ 4334 + nla_total_size(0) + /* IFLA_VXLAN_GBP */ 4335 + nla_total_size(0) + /* IFLA_VXLAN_GPE */ 4336 + nla_total_size(0) + /* IFLA_VXLAN_REMCSUM_NOPARTIAL */ 4337 + nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_VNIFILTER */ 4334 4338 0; 4335 4339 } 4336 4340
+4
drivers/scsi/iscsi_tcp.c
··· 724 724 return -EEXIST; 725 725 } 726 726 727 + err = -EINVAL; 728 + if (!sk_is_tcp(sock->sk)) 729 + goto free_socket; 730 + 727 731 err = iscsi_conn_bind(cls_session, cls_conn, is_leading); 728 732 if (err) 729 733 goto free_socket;
+1 -1
include/linux/btf_ids.h
··· 49 49 ____BTF_ID(symbol, word) 50 50 51 51 #define __ID(prefix) \ 52 - __PASTE(prefix, __COUNTER__) 52 + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__) 53 53 54 54 /* 55 55 * The BTF_ID defines unique symbol for each ID pointing
+2
include/linux/if_team.h
··· 189 189 struct net_device *dev; /* associated netdevice */ 190 190 struct team_pcpu_stats __percpu *pcpu_stats; 191 191 192 + const struct header_ops *header_ops_cache; 193 + 192 194 struct mutex lock; /* used for overall locking, e.g. port lists write */ 193 195 194 196 /*
+4 -3
include/net/netfilter/nf_tables.h
··· 1682 1682 struct net *net; 1683 1683 struct nft_set *set; 1684 1684 u32 seq; 1685 - u8 count; 1685 + u16 count; 1686 1686 void *priv[NFT_TRANS_GC_BATCHCOUNT]; 1687 1687 struct rcu_head rcu; 1688 1688 }; ··· 1700 1700 1701 1701 void nft_trans_gc_elem_add(struct nft_trans_gc *gc, void *priv); 1702 1702 1703 - struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc, 1704 - unsigned int gc_seq); 1703 + struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc, 1704 + unsigned int gc_seq); 1705 + struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc); 1705 1706 1706 1707 void nft_setelem_data_deactivate(const struct net *net, 1707 1708 const struct nft_set *set,
+3 -1
include/uapi/linux/bpf.h
··· 1962 1962 * performed again, if the helper is used in combination with 1963 1963 * direct packet access. 1964 1964 * Return 1965 - * 0 on success, or a negative error in case of failure. 1965 + * 0 on success, or a negative error in case of failure. Positive 1966 + * error indicates a potential drop or congestion in the target 1967 + * device. The particular positive error codes are not defined. 1966 1968 * 1967 1969 * u64 bpf_get_current_pid_tgid(void) 1968 1970 * Description
+1 -1
kernel/bpf/btf.c
··· 8501 8501 tname = btf_name_by_offset(btf, walk_type->name_off); 8502 8502 8503 8503 ret = snprintf(safe_tname, sizeof(safe_tname), "%s%s", tname, suffix); 8504 - if (ret < 0) 8504 + if (ret >= sizeof(safe_tname)) 8505 8505 return false; 8506 8506 8507 8507 safe_id = btf_find_by_name_kind(btf, safe_tname, BTF_INFO_KIND(walk_type->info));
+7 -6
kernel/bpf/cgroup.c
··· 785 785 * to descendants 786 786 * @cgrp: The cgroup which descendants to traverse 787 787 * @link: A link for which to replace BPF program 788 - * @type: Type of attach operation 788 + * @new_prog: &struct bpf_prog for the target BPF program with its refcnt 789 + * incremented 789 790 * 790 791 * Must be called with cgroup_mutex held. 791 792 */ ··· 1335 1334 * __cgroup_bpf_run_filter_skb() - Run a program for packet filtering 1336 1335 * @sk: The socket sending or receiving traffic 1337 1336 * @skb: The skb that is being sent or received 1338 - * @type: The type of program to be executed 1337 + * @atype: The type of program to be executed 1339 1338 * 1340 1339 * If no socket is passed, or the socket is not of type INET or INET6, 1341 1340 * this function does nothing and returns 0. ··· 1425 1424 /** 1426 1425 * __cgroup_bpf_run_filter_sk() - Run a program on a sock 1427 1426 * @sk: sock structure to manipulate 1428 - * @type: The type of program to be executed 1427 + * @atype: The type of program to be executed 1429 1428 * 1430 1429 * socket is passed is expected to be of type INET or INET6. 1431 1430 * ··· 1450 1449 * provided by user sockaddr 1451 1450 * @sk: sock struct that will use sockaddr 1452 1451 * @uaddr: sockaddr struct provided by user 1453 - * @type: The type of program to be executed 1452 + * @atype: The type of program to be executed 1454 1453 * @t_ctx: Pointer to attach type specific context 1455 1454 * @flags: Pointer to u32 which contains higher bits of BPF program 1456 1455 * return value (OR'ed together). ··· 1497 1496 * @sock_ops: bpf_sock_ops_kern struct to pass to program. Contains 1498 1497 * sk with connection information (IP addresses, etc.) May not contain 1499 1498 * cgroup info if it is a req sock. 1500 - * @type: The type of program to be executed 1499 + * @atype: The type of program to be executed 1501 1500 * 1502 1501 * socket passed is expected to be of type INET or INET6. 1503 1502 * ··· 1671 1670 * @ppos: value-result argument: value is position at which read from or write 1672 1671 * to sysctl is happening, result is new position if program overrode it, 1673 1672 * initial value otherwise 1674 - * @type: type of program to be executed 1673 + * @atype: type of program to be executed 1675 1674 * 1676 1675 * Program is run when sysctl is being accessed, either read or written, and 1677 1676 * can allow or deny such access.
+90 -4
kernel/bpf/memalloc.c
··· 459 459 * Typical case will be between 11K and 116K closer to 11K. 460 460 * bpf progs can and should share bpf_mem_cache when possible. 461 461 */ 462 - 463 - static void prefill_mem_cache(struct bpf_mem_cache *c, int cpu) 462 + static void init_refill_work(struct bpf_mem_cache *c) 464 463 { 465 464 init_irq_work(&c->refill_work, bpf_mem_refill); 466 465 if (c->unit_size <= 256) { ··· 475 476 c->high_watermark = max(96 * 256 / c->unit_size, 3); 476 477 } 477 478 c->batch = max((c->high_watermark - c->low_watermark) / 4 * 3, 1); 479 + } 478 480 481 + static void prefill_mem_cache(struct bpf_mem_cache *c, int cpu) 482 + { 479 483 /* To avoid consuming memory assume that 1st run of bpf 480 484 * prog won't be doing more than 4 map_update_elem from 481 485 * irq disabled region 482 486 */ 483 487 alloc_bulk(c, c->unit_size <= 256 ? 4 : 1, cpu_to_node(cpu), false); 488 + } 489 + 490 + static int check_obj_size(struct bpf_mem_cache *c, unsigned int idx) 491 + { 492 + struct llist_node *first; 493 + unsigned int obj_size; 494 + 495 + /* For per-cpu allocator, the size of free objects in free list doesn't 496 + * match with unit_size and now there is no way to get the size of 497 + * per-cpu pointer saved in free object, so just skip the checking. 498 + */ 499 + if (c->percpu_size) 500 + return 0; 501 + 502 + first = c->free_llist.first; 503 + if (!first) 504 + return 0; 505 + 506 + obj_size = ksize(first); 507 + if (obj_size != c->unit_size) { 508 + WARN_ONCE(1, "bpf_mem_cache[%u]: unexpected object size %u, expect %u\n", 509 + idx, obj_size, c->unit_size); 510 + return -EINVAL; 511 + } 512 + return 0; 484 513 } 485 514 486 515 /* When size != 0 bpf_mem_cache for each cpu. ··· 521 494 int bpf_mem_alloc_init(struct bpf_mem_alloc *ma, int size, bool percpu) 522 495 { 523 496 static u16 sizes[NUM_CACHES] = {96, 192, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096}; 497 + int cpu, i, err, unit_size, percpu_size = 0; 524 498 struct bpf_mem_caches *cc, __percpu *pcc; 525 499 struct bpf_mem_cache *c, __percpu *pc; 526 500 struct obj_cgroup *objcg = NULL; 527 - int cpu, i, unit_size, percpu_size = 0; 528 501 529 502 if (size) { 530 503 pc = __alloc_percpu_gfp(sizeof(*pc), 8, GFP_KERNEL); ··· 548 521 c->objcg = objcg; 549 522 c->percpu_size = percpu_size; 550 523 c->tgt = c; 524 + init_refill_work(c); 551 525 prefill_mem_cache(c, cpu); 552 526 } 553 527 ma->cache = pc; ··· 562 534 pcc = __alloc_percpu_gfp(sizeof(*cc), 8, GFP_KERNEL); 563 535 if (!pcc) 564 536 return -ENOMEM; 537 + err = 0; 565 538 #ifdef CONFIG_MEMCG_KMEM 566 539 objcg = get_obj_cgroup_from_current(); 567 540 #endif ··· 573 544 c->unit_size = sizes[i]; 574 545 c->objcg = objcg; 575 546 c->tgt = c; 547 + 548 + init_refill_work(c); 549 + /* Another bpf_mem_cache will be used when allocating 550 + * c->unit_size in bpf_mem_alloc(), so doesn't prefill 551 + * for the bpf_mem_cache because these free objects will 552 + * never be used. 553 + */ 554 + if (i != bpf_mem_cache_idx(c->unit_size)) 555 + continue; 576 556 prefill_mem_cache(c, cpu); 557 + err = check_obj_size(c, i); 558 + if (err) 559 + goto out; 577 560 } 578 561 } 562 + 563 + out: 579 564 ma->caches = pcc; 580 - return 0; 565 + /* refill_work is either zeroed or initialized, so it is safe to 566 + * call irq_work_sync(). 567 + */ 568 + if (err) 569 + bpf_mem_alloc_destroy(ma); 570 + return err; 581 571 } 582 572 583 573 static void drain_mem_cache(struct bpf_mem_cache *c) ··· 964 916 965 917 return !ret ? NULL : ret + LLIST_NODE_SZ; 966 918 } 919 + 920 + /* Most of the logic is taken from setup_kmalloc_cache_index_table() */ 921 + static __init int bpf_mem_cache_adjust_size(void) 922 + { 923 + unsigned int size, index; 924 + 925 + /* Normally KMALLOC_MIN_SIZE is 8-bytes, but it can be 926 + * up-to 256-bytes. 927 + */ 928 + size = KMALLOC_MIN_SIZE; 929 + if (size <= 192) 930 + index = size_index[(size - 1) / 8]; 931 + else 932 + index = fls(size - 1) - 1; 933 + for (size = 8; size < KMALLOC_MIN_SIZE && size <= 192; size += 8) 934 + size_index[(size - 1) / 8] = index; 935 + 936 + /* The minimal alignment is 64-bytes, so disable 96-bytes cache and 937 + * use 128-bytes cache instead. 938 + */ 939 + if (KMALLOC_MIN_SIZE >= 64) { 940 + index = size_index[(128 - 1) / 8]; 941 + for (size = 64 + 8; size <= 96; size += 8) 942 + size_index[(size - 1) / 8] = index; 943 + } 944 + 945 + /* The minimal alignment is 128-bytes, so disable 192-bytes cache and 946 + * use 256-bytes cache instead. 947 + */ 948 + if (KMALLOC_MIN_SIZE >= 128) { 949 + index = fls(256 - 1) - 1; 950 + for (size = 128 + 8; size <= 192; size += 8) 951 + size_index[(size - 1) / 8] = index; 952 + } 953 + 954 + return 0; 955 + } 956 + subsys_initcall(bpf_mem_cache_adjust_size);
+7 -5
kernel/bpf/offload.c
··· 199 199 offload->netdev = netdev; 200 200 201 201 ondev = bpf_offload_find_netdev(offload->netdev); 202 + /* When program is offloaded require presence of "true" 203 + * bpf_offload_netdev, avoid the one created for !ondev case below. 204 + */ 205 + if (bpf_prog_is_offloaded(prog->aux) && (!ondev || !ondev->offdev)) { 206 + err = -EINVAL; 207 + goto err_free; 208 + } 202 209 if (!ondev) { 203 - if (bpf_prog_is_offloaded(prog->aux)) { 204 - err = -EINVAL; 205 - goto err_free; 206 - } 207 - 208 210 /* When only binding to the device, explicitly 209 211 * create an entry in the hashtable. 210 212 */
+18 -3
kernel/bpf/queue_stack_maps.c
··· 98 98 int err = 0; 99 99 void *ptr; 100 100 101 - raw_spin_lock_irqsave(&qs->lock, flags); 101 + if (in_nmi()) { 102 + if (!raw_spin_trylock_irqsave(&qs->lock, flags)) 103 + return -EBUSY; 104 + } else { 105 + raw_spin_lock_irqsave(&qs->lock, flags); 106 + } 102 107 103 108 if (queue_stack_map_is_empty(qs)) { 104 109 memset(value, 0, qs->map.value_size); ··· 133 128 void *ptr; 134 129 u32 index; 135 130 136 - raw_spin_lock_irqsave(&qs->lock, flags); 131 + if (in_nmi()) { 132 + if (!raw_spin_trylock_irqsave(&qs->lock, flags)) 133 + return -EBUSY; 134 + } else { 135 + raw_spin_lock_irqsave(&qs->lock, flags); 136 + } 137 137 138 138 if (queue_stack_map_is_empty(qs)) { 139 139 memset(value, 0, qs->map.value_size); ··· 203 193 if (flags & BPF_NOEXIST || flags > BPF_EXIST) 204 194 return -EINVAL; 205 195 206 - raw_spin_lock_irqsave(&qs->lock, irq_flags); 196 + if (in_nmi()) { 197 + if (!raw_spin_trylock_irqsave(&qs->lock, irq_flags)) 198 + return -EBUSY; 199 + } else { 200 + raw_spin_lock_irqsave(&qs->lock, irq_flags); 201 + } 207 202 208 203 if (queue_stack_map_is_full(qs)) { 209 204 if (!replace) {
+19 -1
kernel/trace/bpf_trace.c
··· 2853 2853 return arr.mods_cnt; 2854 2854 } 2855 2855 2856 + static int addrs_check_error_injection_list(unsigned long *addrs, u32 cnt) 2857 + { 2858 + u32 i; 2859 + 2860 + for (i = 0; i < cnt; i++) { 2861 + if (!within_error_injection_list(addrs[i])) 2862 + return -EINVAL; 2863 + } 2864 + return 0; 2865 + } 2866 + 2856 2867 int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prog) 2857 2868 { 2858 2869 struct bpf_kprobe_multi_link *link = NULL; ··· 2939 2928 free_user_syms(&us); 2940 2929 if (err) 2941 2930 goto error; 2931 + } 2932 + 2933 + if (prog->kprobe_override && addrs_check_error_injection_list(addrs, cnt)) { 2934 + err = -EINVAL; 2935 + goto error; 2942 2936 } 2943 2937 2944 2938 link = kzalloc(sizeof(*link), GFP_KERNEL); ··· 3223 3207 rcu_read_lock(); 3224 3208 task = get_pid_task(find_vpid(pid), PIDTYPE_PID); 3225 3209 rcu_read_unlock(); 3226 - if (!task) 3210 + if (!task) { 3211 + err = -ESRCH; 3227 3212 goto error_path_put; 3213 + } 3228 3214 } 3229 3215 3230 3216 err = -ENOMEM;
+8 -8
net/ax25/Kconfig
··· 10 10 If you want to connect your Linux box to an amateur radio, answer Y 11 11 here. You want to read <https://www.tapr.org/> 12 12 and more specifically about AX.25 on Linux 13 - <http://www.linux-ax25.org/>. 13 + <https://linux-ax25.in-berlin.de>. 14 14 15 15 Note that the answer to this question won't directly affect the 16 16 kernel: saying N will just cause the configurator to skip all ··· 61 61 configuration. Linux cannot yet act as a DAMA server. This option 62 62 only compiles DAMA slave support into the kernel. It still needs to 63 63 be enabled at runtime. For more about DAMA see 64 - <http://www.linux-ax25.org>. If unsure, say Y. 64 + <https://linux-ax25.in-berlin.de>. If unsure, say Y. 65 65 66 66 # placeholder until implemented 67 67 config AX25_DAMA_MASTER ··· 87 87 A comprehensive listing of all the software for Linux amateur radio 88 88 users as well as information about how to configure an AX.25 port is 89 89 contained in the Linux Ham Wiki, available from 90 - <http://www.linux-ax25.org>. You also might want to check out the 91 - file <file:Documentation/networking/ax25.rst>. More information about 92 - digital amateur radio in general is on the WWW at 90 + <https://linux-ax25.in-berlin.de>. You also might want to check out 91 + the file <file:Documentation/networking/ax25.rst>. More information 92 + about digital amateur radio in general is on the WWW at 93 93 <https://www.tapr.org/>. 94 94 95 95 To compile this driver as a module, choose M here: the ··· 106 106 A comprehensive listing of all the software for Linux amateur radio 107 107 users as well as information about how to configure an AX.25 port is 108 108 contained in the Linux Ham Wiki, available from 109 - <http://www.linux-ax25.org>. You also might want to check out the 110 - file <file:Documentation/networking/ax25.rst>. More information about 111 - digital amateur radio in general is on the WWW at 109 + <https://linux-ax25.in-berlin.de>. You also might want to check out 110 + the file <file:Documentation/networking/ax25.rst>. More information 111 + about digital amateur radio in general is on the WWW at 112 112 <https://www.tapr.org/>. 113 113 114 114 To compile this driver as a module, choose M here: the
+2 -2
net/bridge/br_forward.c
··· 124 124 125 125 skb = skb_clone(skb, GFP_ATOMIC); 126 126 if (!skb) { 127 - dev->stats.tx_dropped++; 127 + DEV_STATS_INC(dev, tx_dropped); 128 128 return -ENOMEM; 129 129 } 130 130 ··· 268 268 269 269 skb = skb_copy(skb, GFP_ATOMIC); 270 270 if (!skb) { 271 - dev->stats.tx_dropped++; 271 + DEV_STATS_INC(dev, tx_dropped); 272 272 return; 273 273 } 274 274
+2 -2
net/bridge/br_input.c
··· 181 181 if ((mdst && mdst->host_joined) || 182 182 br_multicast_is_router(brmctx, skb)) { 183 183 local_rcv = true; 184 - br->dev->stats.multicast++; 184 + DEV_STATS_INC(br->dev, multicast); 185 185 } 186 186 mcast_hit = true; 187 187 } else { 188 188 local_rcv = true; 189 - br->dev->stats.multicast++; 189 + DEV_STATS_INC(br->dev, multicast); 190 190 } 191 191 break; 192 192 case BR_PKT_UNICAST:
+3 -3
net/core/dev.c
··· 69 69 */ 70 70 71 71 #include <linux/uaccess.h> 72 - #include <linux/bitops.h> 72 + #include <linux/bitmap.h> 73 73 #include <linux/capability.h> 74 74 #include <linux/cpu.h> 75 75 #include <linux/types.h> ··· 1080 1080 return -EINVAL; 1081 1081 1082 1082 /* Use one page as a bit array of possible slots */ 1083 - inuse = (unsigned long *) get_zeroed_page(GFP_ATOMIC); 1083 + inuse = bitmap_zalloc(max_netdevices, GFP_ATOMIC); 1084 1084 if (!inuse) 1085 1085 return -ENOMEM; 1086 1086 ··· 1109 1109 } 1110 1110 1111 1111 i = find_first_zero_bit(inuse, max_netdevices); 1112 - free_page((unsigned long) inuse); 1112 + bitmap_free(inuse); 1113 1113 } 1114 1114 1115 1115 snprintf(buf, IFNAMSIZ, name, i);
+1 -1
net/core/flow_dissector.c
··· 1446 1446 break; 1447 1447 } 1448 1448 1449 - nhoff += ntohs(hdr->message_length); 1449 + nhoff += sizeof(struct ptp_header); 1450 1450 fdret = FLOW_DISSECT_RET_OUT_GOOD; 1451 1451 break; 1452 1452 }
+2 -7
net/dccp/ipv4.c
··· 254 254 int err; 255 255 struct net *net = dev_net(skb->dev); 256 256 257 - /* For the first __dccp_basic_hdr_len() check, we only need dh->dccph_x, 258 - * which is in byte 7 of the dccp header. 259 - * Our caller (icmp_socket_deliver()) already pulled 8 bytes for us. 260 - * 261 - * Later on, we want to access the sequence number fields, which are 262 - * beyond 8 bytes, so we have to pskb_may_pull() ourselves. 263 - */ 257 + if (!pskb_may_pull(skb, offset + sizeof(*dh))) 258 + return -EINVAL; 264 259 dh = (struct dccp_hdr *)(skb->data + offset); 265 260 if (!pskb_may_pull(skb, offset + __dccp_basic_hdr_len(dh))) 266 261 return -EINVAL;
+2 -7
net/dccp/ipv6.c
··· 83 83 __u64 seq; 84 84 struct net *net = dev_net(skb->dev); 85 85 86 - /* For the first __dccp_basic_hdr_len() check, we only need dh->dccph_x, 87 - * which is in byte 7 of the dccp header. 88 - * Our caller (icmpv6_notify()) already pulled 8 bytes for us. 89 - * 90 - * Later on, we want to access the sequence number fields, which are 91 - * beyond 8 bytes, so we have to pskb_may_pull() ourselves. 92 - */ 86 + if (!pskb_may_pull(skb, offset + sizeof(*dh))) 87 + return -EINVAL; 93 88 dh = (struct dccp_hdr *)(skb->data + offset); 94 89 if (!pskb_may_pull(skb, offset + __dccp_basic_hdr_len(dh))) 95 90 return -EINVAL;
+7 -7
net/handshake/handshake-test.c
··· 235 235 KUNIT_EXPECT_PTR_EQ(test, req, result); 236 236 237 237 handshake_req_cancel(sock->sk); 238 - sock_release(sock); 238 + fput(filp); 239 239 } 240 240 241 241 static void handshake_req_submit_test5(struct kunit *test) ··· 272 272 /* Assert */ 273 273 KUNIT_EXPECT_EQ(test, err, -EAGAIN); 274 274 275 - sock_release(sock); 275 + fput(filp); 276 276 hn->hn_pending = saved; 277 277 } 278 278 ··· 306 306 KUNIT_EXPECT_EQ(test, err, -EBUSY); 307 307 308 308 handshake_req_cancel(sock->sk); 309 - sock_release(sock); 309 + fput(filp); 310 310 } 311 311 312 312 static void handshake_req_cancel_test1(struct kunit *test) ··· 340 340 /* Assert */ 341 341 KUNIT_EXPECT_TRUE(test, result); 342 342 343 - sock_release(sock); 343 + fput(filp); 344 344 } 345 345 346 346 static void handshake_req_cancel_test2(struct kunit *test) ··· 382 382 /* Assert */ 383 383 KUNIT_EXPECT_TRUE(test, result); 384 384 385 - sock_release(sock); 385 + fput(filp); 386 386 } 387 387 388 388 static void handshake_req_cancel_test3(struct kunit *test) ··· 427 427 /* Assert */ 428 428 KUNIT_EXPECT_FALSE(test, result); 429 429 430 - sock_release(sock); 430 + fput(filp); 431 431 } 432 432 433 433 static struct handshake_req *handshake_req_destroy_test; ··· 471 471 handshake_req_cancel(sock->sk); 472 472 473 473 /* Act */ 474 - sock_release(sock); 474 + fput(filp); 475 475 476 476 /* Assert */ 477 477 KUNIT_EXPECT_PTR_EQ(test, handshake_req_destroy_test, req);
+2 -2
net/hsr/hsr_framereg.c
··· 288 288 289 289 /* And leave the HSR tag. */ 290 290 if (ethhdr->h_proto == htons(ETH_P_HSR)) { 291 - pull_size = sizeof(struct ethhdr); 291 + pull_size = sizeof(struct hsr_tag); 292 292 skb_pull(skb, pull_size); 293 293 total_pull_size += pull_size; 294 294 } 295 295 296 296 /* And leave the HSR sup tag. */ 297 - pull_size = sizeof(struct hsr_tag); 297 + pull_size = sizeof(struct hsr_sup_tag); 298 298 skb_pull(skb, pull_size); 299 299 total_pull_size += pull_size; 300 300
+1 -1
net/hsr/hsr_main.h
··· 83 83 struct hsr_sup_tlv { 84 84 u8 HSR_TLV_type; 85 85 u8 HSR_TLV_length; 86 - }; 86 + } __packed; 87 87 88 88 /* HSR/PRP Supervision Frame data types. 89 89 * Field names as defined in the IEC:2010 standard for HSR.
+3 -1
net/ipv4/route.c
··· 1213 1213 1214 1214 static void ipv4_send_dest_unreach(struct sk_buff *skb) 1215 1215 { 1216 + struct net_device *dev; 1216 1217 struct ip_options opt; 1217 1218 int res; 1218 1219 ··· 1231 1230 opt.optlen = ip_hdr(skb)->ihl * 4 - sizeof(struct iphdr); 1232 1231 1233 1232 rcu_read_lock(); 1234 - res = __ip_options_compile(dev_net(skb->dev), &opt, skb, NULL); 1233 + dev = skb->dev ? skb->dev : skb_rtable(skb)->dst.dev; 1234 + res = __ip_options_compile(dev_net(dev), &opt, skb, NULL); 1235 1235 rcu_read_unlock(); 1236 1236 1237 1237 if (res)
+3 -2
net/mptcp/options.c
··· 1269 1269 1270 1270 if (rcv_wnd == rcv_wnd_old) 1271 1271 break; 1272 - if (before64(rcv_wnd_new, rcv_wnd)) { 1272 + 1273 + rcv_wnd_old = rcv_wnd; 1274 + if (before64(rcv_wnd_new, rcv_wnd_old)) { 1273 1275 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICTUPDATE); 1274 1276 goto raise_win; 1275 1277 } 1276 1278 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICT); 1277 - rcv_wnd_old = rcv_wnd; 1278 1279 } 1279 1280 return; 1280 1281 }
+102 -63
net/mptcp/protocol.c
··· 405 405 return false; 406 406 } 407 407 408 - static void mptcp_stop_timer(struct sock *sk) 408 + static void mptcp_stop_rtx_timer(struct sock *sk) 409 409 { 410 410 struct inet_connection_sock *icsk = inet_csk(sk); 411 411 ··· 770 770 return moved; 771 771 } 772 772 773 + static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk) 774 + { 775 + int err = sock_error(ssk); 776 + int ssk_state; 777 + 778 + if (!err) 779 + return false; 780 + 781 + /* only propagate errors on fallen-back sockets or 782 + * on MPC connect 783 + */ 784 + if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(mptcp_sk(sk))) 785 + return false; 786 + 787 + /* We need to propagate only transition to CLOSE state. 788 + * Orphaned socket will see such state change via 789 + * subflow_sched_work_if_closed() and that path will properly 790 + * destroy the msk as needed. 791 + */ 792 + ssk_state = inet_sk_state_load(ssk); 793 + if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) 794 + inet_sk_state_store(sk, ssk_state); 795 + WRITE_ONCE(sk->sk_err, -err); 796 + 797 + /* This barrier is coupled with smp_rmb() in mptcp_poll() */ 798 + smp_wmb(); 799 + sk_error_report(sk); 800 + return true; 801 + } 802 + 803 + void __mptcp_error_report(struct sock *sk) 804 + { 805 + struct mptcp_subflow_context *subflow; 806 + struct mptcp_sock *msk = mptcp_sk(sk); 807 + 808 + mptcp_for_each_subflow(msk, subflow) 809 + if (__mptcp_subflow_error_report(sk, mptcp_subflow_tcp_sock(subflow))) 810 + break; 811 + } 812 + 773 813 /* In most cases we will be able to lock the mptcp socket. If its already 774 814 * owned, we need to defer to the work queue to avoid ABBA deadlock. 775 815 */ ··· 892 852 mptcp_subflow_ctx(ssk)->subflow_id = msk->subflow_id++; 893 853 mptcp_sockopt_sync_locked(msk, ssk); 894 854 mptcp_subflow_joined(msk, ssk); 855 + mptcp_stop_tout_timer(sk); 895 856 return true; 896 857 } 897 858 ··· 912 871 } 913 872 } 914 873 915 - static bool mptcp_timer_pending(struct sock *sk) 874 + static bool mptcp_rtx_timer_pending(struct sock *sk) 916 875 { 917 876 return timer_pending(&inet_csk(sk)->icsk_retransmit_timer); 918 877 } 919 878 920 - static void mptcp_reset_timer(struct sock *sk) 879 + static void mptcp_reset_rtx_timer(struct sock *sk) 921 880 { 922 881 struct inet_connection_sock *icsk = inet_csk(sk); 923 882 unsigned long tout; ··· 1051 1010 out: 1052 1011 if (snd_una == READ_ONCE(msk->snd_nxt) && 1053 1012 snd_una == READ_ONCE(msk->write_seq)) { 1054 - if (mptcp_timer_pending(sk) && !mptcp_data_fin_enabled(msk)) 1055 - mptcp_stop_timer(sk); 1013 + if (mptcp_rtx_timer_pending(sk) && !mptcp_data_fin_enabled(msk)) 1014 + mptcp_stop_rtx_timer(sk); 1056 1015 } else { 1057 - mptcp_reset_timer(sk); 1016 + mptcp_reset_rtx_timer(sk); 1058 1017 } 1059 1018 } 1060 1019 ··· 1627 1586 mptcp_push_release(ssk, &info); 1628 1587 1629 1588 /* ensure the rtx timer is running */ 1630 - if (!mptcp_timer_pending(sk)) 1631 - mptcp_reset_timer(sk); 1589 + if (!mptcp_rtx_timer_pending(sk)) 1590 + mptcp_reset_rtx_timer(sk); 1632 1591 if (do_check_data_fin) 1633 1592 mptcp_check_send_data_fin(sk); 1634 1593 } ··· 1691 1650 if (copied) { 1692 1651 tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle, 1693 1652 info.size_goal); 1694 - if (!mptcp_timer_pending(sk)) 1695 - mptcp_reset_timer(sk); 1653 + if (!mptcp_rtx_timer_pending(sk)) 1654 + mptcp_reset_rtx_timer(sk); 1696 1655 1697 1656 if (msk->snd_data_fin_enable && 1698 1657 msk->snd_nxt + 1 == msk->write_seq) ··· 2261 2220 sock_put(sk); 2262 2221 } 2263 2222 2264 - static void mptcp_timeout_timer(struct timer_list *t) 2223 + static void mptcp_tout_timer(struct timer_list *t) 2265 2224 { 2266 2225 struct sock *sk = from_timer(sk, t, sk_timer); 2267 2226 ··· 2370 2329 bool dispose_it, need_push = false; 2371 2330 2372 2331 /* If the first subflow moved to a close state before accept, e.g. due 2373 - * to an incoming reset, mptcp either: 2374 - * - if either the subflow or the msk are dead, destroy the context 2375 - * (the subflow socket is deleted by inet_child_forget) and the msk 2376 - * - otherwise do nothing at the moment and take action at accept and/or 2377 - * listener shutdown - user-space must be able to accept() the closed 2378 - * socket. 2332 + * to an incoming reset or listener shutdown, the subflow socket is 2333 + * already deleted by inet_child_forget() and the mptcp socket can't 2334 + * survive too. 2379 2335 */ 2380 - if (msk->in_accept_queue && msk->first == ssk) { 2381 - if (!sock_flag(sk, SOCK_DEAD) && !sock_flag(ssk, SOCK_DEAD)) 2382 - return; 2383 - 2336 + if (msk->in_accept_queue && msk->first == ssk && 2337 + (sock_flag(sk, SOCK_DEAD) || sock_flag(ssk, SOCK_DEAD))) { 2384 2338 /* ensure later check in mptcp_worker() will dispose the msk */ 2339 + mptcp_set_close_tout(sk, tcp_jiffies32 - (TCP_TIMEWAIT_LEN + 1)); 2385 2340 sock_set_flag(sk, SOCK_DEAD); 2386 2341 lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); 2387 2342 mptcp_subflow_drop_ctx(ssk); ··· 2429 2392 } 2430 2393 2431 2394 out_release: 2395 + __mptcp_subflow_error_report(sk, ssk); 2432 2396 release_sock(ssk); 2433 2397 2434 2398 sock_put(ssk); ··· 2440 2402 out: 2441 2403 if (need_push) 2442 2404 __mptcp_push_pending(sk, 0); 2405 + 2406 + /* Catch every 'all subflows closed' scenario, including peers silently 2407 + * closing them, e.g. due to timeout. 2408 + * For established sockets, allow an additional timeout before closing, 2409 + * as the protocol can still create more subflows. 2410 + */ 2411 + if (list_is_singular(&msk->conn_list) && msk->first && 2412 + inet_sk_state_load(msk->first) == TCP_CLOSE) { 2413 + if (sk->sk_state != TCP_ESTABLISHED || 2414 + msk->in_accept_queue || sock_flag(sk, SOCK_DEAD)) { 2415 + inet_sk_state_store(sk, TCP_CLOSE); 2416 + mptcp_close_wake_up(sk); 2417 + } else { 2418 + mptcp_start_tout_timer(sk); 2419 + } 2420 + } 2443 2421 } 2444 2422 2445 2423 void mptcp_close_ssk(struct sock *sk, struct sock *ssk, ··· 2499 2445 2500 2446 } 2501 2447 2502 - static bool mptcp_should_close(const struct sock *sk) 2448 + static bool mptcp_close_tout_expired(const struct sock *sk) 2503 2449 { 2504 - s32 delta = tcp_jiffies32 - inet_csk(sk)->icsk_mtup.probe_timestamp; 2505 - struct mptcp_subflow_context *subflow; 2450 + if (!inet_csk(sk)->icsk_mtup.probe_timestamp || 2451 + sk->sk_state == TCP_CLOSE) 2452 + return false; 2506 2453 2507 - if (delta >= TCP_TIMEWAIT_LEN || mptcp_sk(sk)->in_accept_queue) 2508 - return true; 2509 - 2510 - /* if all subflows are in closed status don't bother with additional 2511 - * timeout 2512 - */ 2513 - mptcp_for_each_subflow(mptcp_sk(sk), subflow) { 2514 - if (inet_sk_state_load(mptcp_subflow_tcp_sock(subflow)) != 2515 - TCP_CLOSE) 2516 - return false; 2517 - } 2518 - return true; 2454 + return time_after32(tcp_jiffies32, 2455 + inet_csk(sk)->icsk_mtup.probe_timestamp + TCP_TIMEWAIT_LEN); 2519 2456 } 2520 2457 2521 2458 static void mptcp_check_fastclose(struct mptcp_sock *msk) ··· 2633 2588 reset_timer: 2634 2589 mptcp_check_and_set_pending(sk); 2635 2590 2636 - if (!mptcp_timer_pending(sk)) 2637 - mptcp_reset_timer(sk); 2591 + if (!mptcp_rtx_timer_pending(sk)) 2592 + mptcp_reset_rtx_timer(sk); 2638 2593 } 2639 2594 2640 2595 /* schedule the timeout timer for the relevant event: either close timeout 2641 2596 * or mp_fail timeout. The close timeout takes precedence on the mp_fail one 2642 2597 */ 2643 - void mptcp_reset_timeout(struct mptcp_sock *msk, unsigned long fail_tout) 2598 + void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout) 2644 2599 { 2645 2600 struct sock *sk = (struct sock *)msk; 2646 2601 unsigned long timeout, close_timeout; 2647 2602 2648 - if (!fail_tout && !sock_flag(sk, SOCK_DEAD)) 2603 + if (!fail_tout && !inet_csk(sk)->icsk_mtup.probe_timestamp) 2649 2604 return; 2650 2605 2651 - close_timeout = inet_csk(sk)->icsk_mtup.probe_timestamp - tcp_jiffies32 + jiffies + TCP_TIMEWAIT_LEN; 2606 + close_timeout = inet_csk(sk)->icsk_mtup.probe_timestamp - tcp_jiffies32 + jiffies + 2607 + TCP_TIMEWAIT_LEN; 2652 2608 2653 2609 /* the close timeout takes precedence on the fail one, and here at least one of 2654 2610 * them is active 2655 2611 */ 2656 - timeout = sock_flag(sk, SOCK_DEAD) ? close_timeout : fail_tout; 2612 + timeout = inet_csk(sk)->icsk_mtup.probe_timestamp ? close_timeout : fail_tout; 2657 2613 2658 2614 sk_reset_timer(sk, &sk->sk_timer, timeout); 2659 2615 } ··· 2673 2627 mptcp_subflow_reset(ssk); 2674 2628 WRITE_ONCE(mptcp_subflow_ctx(ssk)->fail_tout, 0); 2675 2629 unlock_sock_fast(ssk, slow); 2676 - 2677 - mptcp_reset_timeout(msk, 0); 2678 2630 } 2679 2631 2680 2632 static void mptcp_do_fastclose(struct sock *sk) ··· 2709 2665 if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) 2710 2666 __mptcp_close_subflow(sk); 2711 2667 2712 - /* There is no point in keeping around an orphaned sk timedout or 2713 - * closed, but we need the msk around to reply to incoming DATA_FIN, 2714 - * even if it is orphaned and in FIN_WAIT2 state 2715 - */ 2716 - if (sock_flag(sk, SOCK_DEAD)) { 2717 - if (mptcp_should_close(sk)) 2718 - mptcp_do_fastclose(sk); 2668 + if (mptcp_close_tout_expired(sk)) { 2669 + mptcp_do_fastclose(sk); 2670 + mptcp_close_wake_up(sk); 2671 + } 2719 2672 2720 - if (sk->sk_state == TCP_CLOSE) { 2721 - __mptcp_destroy_sock(sk); 2722 - goto unlock; 2723 - } 2673 + if (sock_flag(sk, SOCK_DEAD) && sk->sk_state == TCP_CLOSE) { 2674 + __mptcp_destroy_sock(sk); 2675 + goto unlock; 2724 2676 } 2725 2677 2726 2678 if (test_and_clear_bit(MPTCP_WORK_RTX, &msk->flags)) ··· 2757 2717 2758 2718 /* re-use the csk retrans timer for MPTCP-level retrans */ 2759 2719 timer_setup(&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer, 0); 2760 - timer_setup(&sk->sk_timer, mptcp_timeout_timer, 0); 2720 + timer_setup(&sk->sk_timer, mptcp_tout_timer, 0); 2761 2721 } 2762 2722 2763 2723 static void mptcp_ca_reset(struct sock *sk) ··· 2848 2808 } else { 2849 2809 pr_debug("Sending DATA_FIN on subflow %p", ssk); 2850 2810 tcp_send_ack(ssk); 2851 - if (!mptcp_timer_pending(sk)) 2852 - mptcp_reset_timer(sk); 2811 + if (!mptcp_rtx_timer_pending(sk)) 2812 + mptcp_reset_rtx_timer(sk); 2853 2813 } 2854 2814 break; 2855 2815 } ··· 2932 2892 2933 2893 might_sleep(); 2934 2894 2935 - mptcp_stop_timer(sk); 2895 + mptcp_stop_rtx_timer(sk); 2936 2896 sk_stop_timer(sk, &sk->sk_timer); 2937 2897 msk->pm.status = 0; 2938 2898 mptcp_release_sched(msk); ··· 3015 2975 3016 2976 cleanup: 3017 2977 /* orphan all the subflows */ 3018 - inet_csk(sk)->icsk_mtup.probe_timestamp = tcp_jiffies32; 3019 2978 mptcp_for_each_subflow(msk, subflow) { 3020 2979 struct sock *ssk = mptcp_subflow_tcp_sock(subflow); 3021 2980 bool slow = lock_sock_fast_nested(ssk); ··· 3051 3012 __mptcp_destroy_sock(sk); 3052 3013 do_cancel_work = true; 3053 3014 } else { 3054 - mptcp_reset_timeout(msk, 0); 3015 + mptcp_start_tout_timer(sk); 3055 3016 } 3056 3017 3057 3018 return do_cancel_work; ··· 3114 3075 mptcp_check_listen_stop(sk); 3115 3076 inet_sk_state_store(sk, TCP_CLOSE); 3116 3077 3117 - mptcp_stop_timer(sk); 3118 - sk_stop_timer(sk, &sk->sk_timer); 3078 + mptcp_stop_rtx_timer(sk); 3079 + mptcp_stop_tout_timer(sk); 3119 3080 3120 3081 if (msk->token) 3121 3082 mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL);
+23 -1
net/mptcp/protocol.h
··· 718 718 719 719 void mptcp_finish_connect(struct sock *sk); 720 720 void __mptcp_set_connected(struct sock *sk); 721 - void mptcp_reset_timeout(struct mptcp_sock *msk, unsigned long fail_tout); 721 + void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout); 722 + 723 + static inline void mptcp_stop_tout_timer(struct sock *sk) 724 + { 725 + if (!inet_csk(sk)->icsk_mtup.probe_timestamp) 726 + return; 727 + 728 + sk_stop_timer(sk, &sk->sk_timer); 729 + inet_csk(sk)->icsk_mtup.probe_timestamp = 0; 730 + } 731 + 732 + static inline void mptcp_set_close_tout(struct sock *sk, unsigned long tout) 733 + { 734 + /* avoid 0 timestamp, as that means no close timeout */ 735 + inet_csk(sk)->icsk_mtup.probe_timestamp = tout ? : 1; 736 + } 737 + 738 + static inline void mptcp_start_tout_timer(struct sock *sk) 739 + { 740 + mptcp_set_close_tout(sk, tcp_jiffies32); 741 + mptcp_reset_tout_timer(mptcp_sk(sk), 0); 742 + } 743 + 722 744 static inline bool mptcp_is_fully_established(struct sock *sk) 723 745 { 724 746 return inet_sk_state_load(sk) == TCP_ESTABLISHED &&
+2 -37
net/mptcp/subflow.c
··· 1226 1226 WRITE_ONCE(subflow->fail_tout, fail_tout); 1227 1227 tcp_send_ack(ssk); 1228 1228 1229 - mptcp_reset_timeout(msk, subflow->fail_tout); 1229 + mptcp_reset_tout_timer(msk, subflow->fail_tout); 1230 1230 } 1231 1231 1232 1232 static bool subflow_check_data_avail(struct sock *ssk) ··· 1360 1360 1361 1361 *space = __mptcp_space(sk); 1362 1362 *full_space = mptcp_win_from_space(sk, READ_ONCE(sk->sk_rcvbuf)); 1363 - } 1364 - 1365 - void __mptcp_error_report(struct sock *sk) 1366 - { 1367 - struct mptcp_subflow_context *subflow; 1368 - struct mptcp_sock *msk = mptcp_sk(sk); 1369 - 1370 - mptcp_for_each_subflow(msk, subflow) { 1371 - struct sock *ssk = mptcp_subflow_tcp_sock(subflow); 1372 - int err = sock_error(ssk); 1373 - int ssk_state; 1374 - 1375 - if (!err) 1376 - continue; 1377 - 1378 - /* only propagate errors on fallen-back sockets or 1379 - * on MPC connect 1380 - */ 1381 - if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(msk)) 1382 - continue; 1383 - 1384 - /* We need to propagate only transition to CLOSE state. 1385 - * Orphaned socket will see such state change via 1386 - * subflow_sched_work_if_closed() and that path will properly 1387 - * destroy the msk as needed. 1388 - */ 1389 - ssk_state = inet_sk_state_load(ssk); 1390 - if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) 1391 - inet_sk_state_store(sk, ssk_state); 1392 - WRITE_ONCE(sk->sk_err, -err); 1393 - 1394 - /* This barrier is coupled with smp_rmb() in mptcp_poll() */ 1395 - smp_wmb(); 1396 - sk_error_report(sk); 1397 - break; 1398 - } 1399 1363 } 1400 1364 1401 1365 static void subflow_error_report(struct sock *ssk) ··· 1552 1588 mptcp_sock_graft(ssk, sk->sk_socket); 1553 1589 iput(SOCK_INODE(sf)); 1554 1590 WRITE_ONCE(msk->allow_infinite_fallback, false); 1591 + mptcp_stop_tout_timer(sk); 1555 1592 return 0; 1556 1593 1557 1594 failed_unlink:
+5
net/ncsi/ncsi-aen.c
··· 89 89 if ((had_link == has_link) || chained) 90 90 return 0; 91 91 92 + if (had_link) 93 + netif_carrier_off(ndp->ndev.dev); 94 + else 95 + netif_carrier_on(ndp->ndev.dev); 96 + 92 97 if (!ndp->multi_package && !nc->package->multi_channel) { 93 98 if (had_link) { 94 99 ndp->flags |= NCSI_DEV_RESHUFFLE;
+10 -2
net/netfilter/ipset/ip_set_core.c
··· 683 683 * a separate reference counter 684 684 */ 685 685 static void 686 + __ip_set_get_netlink(struct ip_set *set) 687 + { 688 + write_lock_bh(&ip_set_ref_lock); 689 + set->ref_netlink++; 690 + write_unlock_bh(&ip_set_ref_lock); 691 + } 692 + 693 + static void 686 694 __ip_set_put_netlink(struct ip_set *set) 687 695 { 688 696 write_lock_bh(&ip_set_ref_lock); ··· 1701 1693 1702 1694 do { 1703 1695 if (retried) { 1704 - __ip_set_get(set); 1696 + __ip_set_get_netlink(set); 1705 1697 nfnl_unlock(NFNL_SUBSYS_IPSET); 1706 1698 cond_resched(); 1707 1699 nfnl_lock(NFNL_SUBSYS_IPSET); 1708 - __ip_set_put(set); 1700 + __ip_set_put_netlink(set); 1709 1701 } 1710 1702 1711 1703 ip_set_lock(set);
+2
net/netfilter/nf_conntrack_bpf.c
··· 381 381 struct nf_conn *nfct = (struct nf_conn *)nfct_i; 382 382 int err; 383 383 384 + if (!nf_ct_is_confirmed(nfct)) 385 + nfct->timeout += nfct_time_stamp; 384 386 nfct->status |= IPS_CONFIRMED; 385 387 err = nf_conntrack_hash_check_insert(nfct); 386 388 if (err < 0) {
+2 -2
net/netfilter/nf_conntrack_extend.c
··· 40 40 [NF_CT_EXT_ECACHE] = sizeof(struct nf_conntrack_ecache), 41 41 #endif 42 42 #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP 43 - [NF_CT_EXT_TSTAMP] = sizeof(struct nf_conn_acct), 43 + [NF_CT_EXT_TSTAMP] = sizeof(struct nf_conn_tstamp), 44 44 #endif 45 45 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT 46 - [NF_CT_EXT_TIMEOUT] = sizeof(struct nf_conn_tstamp), 46 + [NF_CT_EXT_TIMEOUT] = sizeof(struct nf_conn_timeout), 47 47 #endif 48 48 #ifdef CONFIG_NF_CONNTRACK_LABELS 49 49 [NF_CT_EXT_LABELS] = sizeof(struct nf_conn_labels),
+59 -20
net/netfilter/nf_tables_api.c
··· 1219 1219 flags & NFT_TABLE_F_OWNER)) 1220 1220 return -EOPNOTSUPP; 1221 1221 1222 + /* No dormant off/on/off/on games in single transaction */ 1223 + if (ctx->table->flags & __NFT_TABLE_F_UPDATE) 1224 + return -EINVAL; 1225 + 1222 1226 trans = nft_trans_alloc(ctx, NFT_MSG_NEWTABLE, 1223 1227 sizeof(struct nft_trans_table)); 1224 1228 if (trans == NULL) ··· 1436 1432 if (!nft_is_active_next(ctx->net, chain)) 1437 1433 continue; 1438 1434 1439 - if (nft_chain_is_bound(chain)) 1435 + if (nft_chain_binding(chain)) 1440 1436 continue; 1441 1437 1442 1438 ctx->chain = chain; ··· 1450 1446 if (!nft_is_active_next(ctx->net, set)) 1451 1447 continue; 1452 1448 1453 - if (nft_set_is_anonymous(set) && 1454 - !list_empty(&set->bindings)) 1449 + if (nft_set_is_anonymous(set)) 1455 1450 continue; 1456 1451 1457 1452 err = nft_delset(ctx, set); ··· 1480 1477 if (!nft_is_active_next(ctx->net, chain)) 1481 1478 continue; 1482 1479 1483 - if (nft_chain_is_bound(chain)) 1480 + if (nft_chain_binding(chain)) 1484 1481 continue; 1485 1482 1486 1483 ctx->chain = chain; ··· 2913 2910 return PTR_ERR(chain); 2914 2911 } 2915 2912 2913 + if (nft_chain_binding(chain)) 2914 + return -EOPNOTSUPP; 2915 + 2916 2916 nft_ctx_init(&ctx, net, skb, info->nlh, family, table, chain, nla); 2917 2917 2918 2918 if (nla[NFTA_CHAIN_HOOK]) { ··· 3455 3449 struct net *net = sock_net(skb->sk); 3456 3450 const struct nft_rule *rule, *prule; 3457 3451 unsigned int s_idx = cb->args[0]; 3452 + unsigned int entries = 0; 3453 + int ret = 0; 3458 3454 u64 handle; 3459 3455 3460 3456 prule = NULL; ··· 3479 3471 NFT_MSG_NEWRULE, 3480 3472 NLM_F_MULTI | NLM_F_APPEND, 3481 3473 table->family, 3482 - table, chain, rule, handle, reset) < 0) 3483 - return 1; 3484 - 3474 + table, chain, rule, handle, reset) < 0) { 3475 + ret = 1; 3476 + break; 3477 + } 3478 + entries++; 3485 3479 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 3486 3480 cont: 3487 3481 prule = rule; ··· 3491 3481 (*idx)++; 3492 3482 } 3493 3483 3494 - if (reset && *idx) 3495 - audit_log_rule_reset(table, cb->seq, *idx); 3484 + if (reset && entries) 3485 + audit_log_rule_reset(table, cb->seq, entries); 3496 3486 3497 - return 0; 3487 + return ret; 3498 3488 } 3499 3489 3500 3490 static int nf_tables_dump_rules(struct sk_buff *skb, ··· 3981 3971 } 3982 3972 3983 3973 if (info->nlh->nlmsg_flags & NLM_F_REPLACE) { 3974 + if (nft_chain_binding(chain)) { 3975 + err = -EOPNOTSUPP; 3976 + goto err_destroy_flow_rule; 3977 + } 3978 + 3984 3979 err = nft_delrule(&ctx, old_rule); 3985 3980 if (err < 0) 3986 3981 goto err_destroy_flow_rule; ··· 4093 4078 NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_CHAIN]); 4094 4079 return PTR_ERR(chain); 4095 4080 } 4096 - if (nft_chain_is_bound(chain)) 4081 + if (nft_chain_binding(chain)) 4097 4082 return -EOPNOTSUPP; 4098 4083 } 4099 4084 ··· 4127 4112 list_for_each_entry(chain, &table->chains, list) { 4128 4113 if (!nft_is_active_next(net, chain)) 4129 4114 continue; 4130 - if (nft_chain_is_bound(chain)) 4115 + if (nft_chain_binding(chain)) 4131 4116 continue; 4132 4117 4133 4118 ctx.chain = chain; ··· 7198 7183 if (IS_ERR(set)) 7199 7184 return PTR_ERR(set); 7200 7185 7201 - if (!list_empty(&set->bindings) && 7202 - (set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS))) 7186 + if (nft_set_is_anonymous(set)) 7187 + return -EOPNOTSUPP; 7188 + 7189 + if (!list_empty(&set->bindings) && (set->flags & NFT_SET_CONSTANT)) 7203 7190 return -EBUSY; 7204 7191 7205 7192 nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); ··· 9579 9562 struct nft_trans_gc *nft_trans_gc_queue_async(struct nft_trans_gc *gc, 9580 9563 unsigned int gc_seq, gfp_t gfp) 9581 9564 { 9565 + struct nft_set *set; 9566 + 9582 9567 if (nft_trans_gc_space(gc)) 9583 9568 return gc; 9584 9569 9570 + set = gc->set; 9585 9571 nft_trans_gc_queue_work(gc); 9586 9572 9587 - return nft_trans_gc_alloc(gc->set, gc_seq, gfp); 9573 + return nft_trans_gc_alloc(set, gc_seq, gfp); 9588 9574 } 9589 9575 9590 9576 void nft_trans_gc_queue_async_done(struct nft_trans_gc *trans) ··· 9602 9582 9603 9583 struct nft_trans_gc *nft_trans_gc_queue_sync(struct nft_trans_gc *gc, gfp_t gfp) 9604 9584 { 9585 + struct nft_set *set; 9586 + 9605 9587 if (WARN_ON_ONCE(!lockdep_commit_lock_is_held(gc->net))) 9606 9588 return NULL; 9607 9589 9608 9590 if (nft_trans_gc_space(gc)) 9609 9591 return gc; 9610 9592 9593 + set = gc->set; 9611 9594 call_rcu(&gc->rcu, nft_trans_gc_trans_free); 9612 9595 9613 - return nft_trans_gc_alloc(gc->set, 0, gfp); 9596 + return nft_trans_gc_alloc(set, 0, gfp); 9614 9597 } 9615 9598 9616 9599 void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans) ··· 9628 9605 call_rcu(&trans->rcu, nft_trans_gc_trans_free); 9629 9606 } 9630 9607 9631 - struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc, 9632 - unsigned int gc_seq) 9608 + static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc, 9609 + unsigned int gc_seq, 9610 + bool sync) 9633 9611 { 9634 9612 struct nft_set_elem_catchall *catchall; 9635 9613 const struct nft_set *set = gc->set; ··· 9646 9622 9647 9623 nft_set_elem_dead(ext); 9648 9624 dead_elem: 9649 - gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC); 9625 + if (sync) 9626 + gc = nft_trans_gc_queue_sync(gc, GFP_ATOMIC); 9627 + else 9628 + gc = nft_trans_gc_queue_async(gc, gc_seq, GFP_ATOMIC); 9629 + 9650 9630 if (!gc) 9651 9631 return NULL; 9652 9632 ··· 9658 9630 } 9659 9631 9660 9632 return gc; 9633 + } 9634 + 9635 + struct nft_trans_gc *nft_trans_gc_catchall_async(struct nft_trans_gc *gc, 9636 + unsigned int gc_seq) 9637 + { 9638 + return nft_trans_gc_catchall(gc, gc_seq, false); 9639 + } 9640 + 9641 + struct nft_trans_gc *nft_trans_gc_catchall_sync(struct nft_trans_gc *gc) 9642 + { 9643 + return nft_trans_gc_catchall(gc, 0, true); 9661 9644 } 9662 9645 9663 9646 static void nf_tables_module_autoload_cleanup(struct net *net) ··· 11093 11054 ctx.family = table->family; 11094 11055 ctx.table = table; 11095 11056 list_for_each_entry(chain, &table->chains, list) { 11096 - if (nft_chain_is_bound(chain)) 11057 + if (nft_chain_binding(chain)) 11097 11058 continue; 11098 11059 11099 11060 ctx.chain = chain;
+4 -7
net/netfilter/nft_set_hash.c
··· 338 338 339 339 while ((he = rhashtable_walk_next(&hti))) { 340 340 if (IS_ERR(he)) { 341 - if (PTR_ERR(he) != -EAGAIN) { 342 - nft_trans_gc_destroy(gc); 343 - gc = NULL; 344 - goto try_later; 345 - } 346 - continue; 341 + nft_trans_gc_destroy(gc); 342 + gc = NULL; 343 + goto try_later; 347 344 } 348 345 349 346 /* Ruleset has been updated, try later. */ ··· 369 372 nft_trans_gc_elem_add(gc, he); 370 373 } 371 374 372 - gc = nft_trans_gc_catchall(gc, gc_seq); 375 + gc = nft_trans_gc_catchall_async(gc, gc_seq); 373 376 374 377 try_later: 375 378 /* catchall list iteration requires rcu read side lock. */
+2 -2
net/netfilter/nft_set_pipapo.c
··· 1596 1596 1597 1597 gc = nft_trans_gc_queue_sync(gc, GFP_ATOMIC); 1598 1598 if (!gc) 1599 - break; 1599 + return; 1600 1600 1601 1601 nft_pipapo_gc_deactivate(net, set, e); 1602 1602 pipapo_drop(m, rulemap); ··· 1610 1610 } 1611 1611 } 1612 1612 1613 - gc = nft_trans_gc_catchall(gc, 0); 1613 + gc = nft_trans_gc_catchall_sync(gc); 1614 1614 if (gc) { 1615 1615 nft_trans_gc_queue_sync_done(gc); 1616 1616 priv->last_gc = jiffies;
+3 -5
net/netfilter/nft_set_rbtree.c
··· 622 622 if (!gc) 623 623 goto done; 624 624 625 - write_lock_bh(&priv->lock); 626 - write_seqcount_begin(&priv->count); 625 + read_lock_bh(&priv->lock); 627 626 for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) { 628 627 629 628 /* Ruleset has been updated, try later. */ ··· 669 670 nft_trans_gc_elem_add(gc, rbe); 670 671 } 671 672 672 - gc = nft_trans_gc_catchall(gc, gc_seq); 673 + gc = nft_trans_gc_catchall_async(gc, gc_seq); 673 674 674 675 try_later: 675 - write_seqcount_end(&priv->count); 676 - write_unlock_bh(&priv->lock); 676 + read_unlock_bh(&priv->lock); 677 677 678 678 if (gc) 679 679 nft_trans_gc_queue_async_done(gc);
+7 -5
net/rds/rdma_transport.c
··· 86 86 break; 87 87 88 88 case RDMA_CM_EVENT_ADDR_RESOLVED: 89 - rdma_set_service_type(cm_id, conn->c_tos); 90 - rdma_set_min_rnr_timer(cm_id, IB_RNR_TIMER_000_32); 91 - /* XXX do we need to clean up if this fails? */ 92 - ret = rdma_resolve_route(cm_id, 93 - RDS_RDMA_RESOLVE_TIMEOUT_MS); 89 + if (conn) { 90 + rdma_set_service_type(cm_id, conn->c_tos); 91 + rdma_set_min_rnr_timer(cm_id, IB_RNR_TIMER_000_32); 92 + /* XXX do we need to clean up if this fails? */ 93 + ret = rdma_resolve_route(cm_id, 94 + RDS_RDMA_RESOLVE_TIMEOUT_MS); 95 + } 94 96 break; 95 97 96 98 case RDMA_CM_EVENT_ROUTE_RESOLVED:
+1 -1
tools/include/linux/btf_ids.h
··· 38 38 ____BTF_ID(symbol) 39 39 40 40 #define __ID(prefix) \ 41 - __PASTE(prefix, __COUNTER__) 41 + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__) 42 42 43 43 /* 44 44 * The BTF_ID defines unique symbol for each ID pointing
+3 -1
tools/include/uapi/linux/bpf.h
··· 1962 1962 * performed again, if the helper is used in combination with 1963 1963 * direct packet access. 1964 1964 * Return 1965 - * 0 on success, or a negative error in case of failure. 1965 + * 0 on success, or a negative error in case of failure. Positive 1966 + * error indicates a potential drop or congestion in the target 1967 + * device. The particular positive error codes are not defined. 1966 1968 * 1967 1969 * u64 bpf_get_current_pid_tgid(void) 1968 1970 * Description
+2 -8
tools/testing/selftests/bpf/DENYLIST.aarch64
··· 1 1 bpf_cookie/multi_kprobe_attach_api # kprobe_multi_link_api_subtest:FAIL:fentry_raw_skel_load unexpected error: -3 2 2 bpf_cookie/multi_kprobe_link_api # kprobe_multi_link_api_subtest:FAIL:fentry_raw_skel_load unexpected error: -3 3 3 fexit_sleep # The test never returns. The remaining tests cannot start. 4 - kprobe_multi_bench_attach # bpf_program__attach_kprobe_multi_opts unexpected error: -95 5 - kprobe_multi_test/attach_api_addrs # bpf_program__attach_kprobe_multi_opts unexpected error: -95 6 - kprobe_multi_test/attach_api_pattern # bpf_program__attach_kprobe_multi_opts unexpected error: -95 7 - kprobe_multi_test/attach_api_syms # bpf_program__attach_kprobe_multi_opts unexpected error: -95 8 - kprobe_multi_test/bench_attach # bpf_program__attach_kprobe_multi_opts unexpected error: -95 9 - kprobe_multi_test/link_api_addrs # link_fd unexpected link_fd: actual -95 < expected 0 10 - kprobe_multi_test/link_api_syms # link_fd unexpected link_fd: actual -95 < expected 0 11 - kprobe_multi_test/skel_api # libbpf: failed to load BPF skeleton 'kprobe_multi': -3 4 + kprobe_multi_bench_attach # needs CONFIG_FPROBE 5 + kprobe_multi_test # needs CONFIG_FPROBE 12 6 module_attach # prog 'kprobe_multi': failed to auto-attach: -95 13 7 fentry_test/fentry_many_args # fentry_many_args:FAIL:fentry_many_args_attach unexpected error: -524 14 8 fexit_test/fexit_many_args # fexit_many_args:FAIL:fexit_many_args_attach unexpected error: -524
+1
tools/testing/selftests/bpf/config
··· 4 4 CONFIG_BPF=y 5 5 CONFIG_BPF_EVENTS=y 6 6 CONFIG_BPF_JIT=y 7 + CONFIG_BPF_KPROBE_OVERRIDE=y 7 8 CONFIG_BPF_LIRC_MODE2=y 8 9 CONFIG_BPF_LSM=y 9 10 CONFIG_BPF_STREAM_PARSER=y
-1
tools/testing/selftests/bpf/config.x86_64
··· 20 20 CONFIG_BONDING=y 21 21 CONFIG_BOOTTIME_TRACING=y 22 22 CONFIG_BPF_JIT_ALWAYS_ON=y 23 - CONFIG_BPF_KPROBE_OVERRIDE=y 24 23 CONFIG_BPF_PRELOAD=y 25 24 CONFIG_BPF_PRELOAD_UMD=y 26 25 CONFIG_BPFILTER=y
+10 -2
tools/testing/selftests/bpf/prog_tests/empty_skb.c
··· 24 24 int *ifindex; 25 25 int err; 26 26 int ret; 27 + int lwt_egress_ret; /* expected retval at lwt/egress */ 27 28 bool success_on_tc; 28 29 } tests[] = { 29 30 /* Empty packets are always rejected. */ ··· 58 57 .data_size_in = sizeof(eth_hlen), 59 58 .ifindex = &veth_ifindex, 60 59 .ret = -ERANGE, 60 + .lwt_egress_ret = -ERANGE, 61 61 .success_on_tc = true, 62 62 }, 63 63 { ··· 72 70 .data_size_in = sizeof(eth_hlen), 73 71 .ifindex = &ipip_ifindex, 74 72 .ret = -ERANGE, 73 + .lwt_egress_ret = -ERANGE, 75 74 }, 76 75 77 76 /* ETH_HLEN+1-sized packet should be redirected. */ ··· 82 79 .data_in = eth_hlen_pp, 83 80 .data_size_in = sizeof(eth_hlen_pp), 84 81 .ifindex = &veth_ifindex, 82 + .lwt_egress_ret = 1, /* veth_xmit NET_XMIT_DROP */ 85 83 }, 86 84 { 87 85 .msg = "ipip ETH_HLEN+1 packet ingress", ··· 112 108 113 109 for (i = 0; i < ARRAY_SIZE(tests); i++) { 114 110 bpf_object__for_each_program(prog, bpf_obj->obj) { 115 - char buf[128]; 111 + bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL; 116 112 bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2); 113 + int expected_ret; 114 + char buf[128]; 115 + 116 + expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret; 117 117 118 118 tattr.data_in = tests[i].data_in; 119 119 tattr.data_size_in = tests[i].data_size_in; ··· 136 128 if (at_tc && tests[i].success_on_tc) 137 129 ASSERT_GE(bpf_obj->bss->ret, 0, buf); 138 130 else 139 - ASSERT_EQ(bpf_obj->bss->ret, tests[i].ret, buf); 131 + ASSERT_EQ(bpf_obj->bss->ret, expected_ret, buf); 140 132 } 141 133 } 142 134
+37
tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
··· 3 3 #include "kprobe_multi.skel.h" 4 4 #include "trace_helpers.h" 5 5 #include "kprobe_multi_empty.skel.h" 6 + #include "kprobe_multi_override.skel.h" 6 7 #include "bpf/libbpf_internal.h" 7 8 #include "bpf/hashmap.h" 8 9 ··· 454 453 } 455 454 } 456 455 456 + static void test_attach_override(void) 457 + { 458 + struct kprobe_multi_override *skel = NULL; 459 + struct bpf_link *link = NULL; 460 + 461 + skel = kprobe_multi_override__open_and_load(); 462 + if (!ASSERT_OK_PTR(skel, "kprobe_multi_empty__open_and_load")) 463 + goto cleanup; 464 + 465 + /* The test_override calls bpf_override_return so it should fail 466 + * to attach to bpf_fentry_test1 function, which is not on error 467 + * injection list. 468 + */ 469 + link = bpf_program__attach_kprobe_multi_opts(skel->progs.test_override, 470 + "bpf_fentry_test1", NULL); 471 + if (!ASSERT_ERR_PTR(link, "override_attached_bpf_fentry_test1")) { 472 + bpf_link__destroy(link); 473 + goto cleanup; 474 + } 475 + 476 + /* The should_fail_bio function is on error injection list, 477 + * attach should succeed. 478 + */ 479 + link = bpf_program__attach_kprobe_multi_opts(skel->progs.test_override, 480 + "should_fail_bio", NULL); 481 + if (!ASSERT_OK_PTR(link, "override_attached_should_fail_bio")) 482 + goto cleanup; 483 + 484 + bpf_link__destroy(link); 485 + 486 + cleanup: 487 + kprobe_multi_override__destroy(skel); 488 + } 489 + 457 490 void serial_test_kprobe_multi_bench_attach(void) 458 491 { 459 492 if (test__start_subtest("kernel")) ··· 515 480 test_attach_api_syms(); 516 481 if (test__start_subtest("attach_api_fails")) 517 482 test_attach_api_fails(); 483 + if (test__start_subtest("attach_override")) 484 + test_attach_override(); 518 485 }
+50
tools/testing/selftests/bpf/prog_tests/test_bpf_ma.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (C) 2023. Huawei Technologies Co., Ltd */ 3 + #define _GNU_SOURCE 4 + #include <sched.h> 5 + #include <pthread.h> 6 + #include <stdbool.h> 7 + #include <bpf/btf.h> 8 + #include <test_progs.h> 9 + 10 + #include "test_bpf_ma.skel.h" 11 + 12 + void test_test_bpf_ma(void) 13 + { 14 + struct test_bpf_ma *skel; 15 + struct btf *btf; 16 + int i, err; 17 + 18 + skel = test_bpf_ma__open(); 19 + if (!ASSERT_OK_PTR(skel, "open")) 20 + return; 21 + 22 + btf = bpf_object__btf(skel->obj); 23 + if (!ASSERT_OK_PTR(btf, "btf")) 24 + goto out; 25 + 26 + for (i = 0; i < ARRAY_SIZE(skel->rodata->data_sizes); i++) { 27 + char name[32]; 28 + int id; 29 + 30 + snprintf(name, sizeof(name), "bin_data_%u", skel->rodata->data_sizes[i]); 31 + id = btf__find_by_name_kind(btf, name, BTF_KIND_STRUCT); 32 + if (!ASSERT_GT(id, 0, "bin_data")) 33 + goto out; 34 + skel->rodata->data_btf_ids[i] = id; 35 + } 36 + 37 + err = test_bpf_ma__load(skel); 38 + if (!ASSERT_OK(err, "load")) 39 + goto out; 40 + 41 + err = test_bpf_ma__attach(skel); 42 + if (!ASSERT_OK(err, "attach")) 43 + goto out; 44 + 45 + skel->bss->pid = getpid(); 46 + usleep(1); 47 + ASSERT_OK(skel->bss->err, "test error"); 48 + out: 49 + test_bpf_ma__destroy(skel); 50 + }
+61
tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <net/if.h> 3 + #include <test_progs.h> 4 + #include <network_helpers.h> 5 + 6 + #define LOCAL_NETNS "xdp_dev_bound_only_netns" 7 + 8 + static int load_dummy_prog(char *name, __u32 ifindex, __u32 flags) 9 + { 10 + struct bpf_insn insns[] = { BPF_MOV64_IMM(BPF_REG_0, 0), BPF_EXIT_INSN() }; 11 + LIBBPF_OPTS(bpf_prog_load_opts, opts); 12 + 13 + opts.prog_flags = flags; 14 + opts.prog_ifindex = ifindex; 15 + return bpf_prog_load(BPF_PROG_TYPE_XDP, name, "GPL", insns, ARRAY_SIZE(insns), &opts); 16 + } 17 + 18 + /* A test case for bpf_offload_netdev->offload handling bug: 19 + * - create a veth device (does not support offload); 20 + * - create a device bound XDP program with BPF_F_XDP_DEV_BOUND_ONLY flag 21 + * (such programs are not offloaded); 22 + * - create a device bound XDP program without flags (such programs are offloaded). 23 + * This might lead to 'BUG: kernel NULL pointer dereference'. 24 + */ 25 + void test_xdp_dev_bound_only_offdev(void) 26 + { 27 + struct nstoken *tok = NULL; 28 + __u32 ifindex; 29 + int fd1 = -1; 30 + int fd2 = -1; 31 + 32 + SYS(out, "ip netns add " LOCAL_NETNS); 33 + tok = open_netns(LOCAL_NETNS); 34 + if (!ASSERT_OK_PTR(tok, "open_netns")) 35 + goto out; 36 + SYS(out, "ip link add eth42 type veth"); 37 + ifindex = if_nametoindex("eth42"); 38 + if (!ASSERT_NEQ(ifindex, 0, "if_nametoindex")) { 39 + perror("if_nametoindex"); 40 + goto out; 41 + } 42 + fd1 = load_dummy_prog("dummy1", ifindex, BPF_F_XDP_DEV_BOUND_ONLY); 43 + if (!ASSERT_GE(fd1, 0, "load_dummy_prog #1")) { 44 + perror("load_dummy_prog #1"); 45 + goto out; 46 + } 47 + /* Program with ifindex is considered offloaded, however veth 48 + * does not support offload => error should be reported. 49 + */ 50 + fd2 = load_dummy_prog("dummy2", ifindex, 0); 51 + ASSERT_EQ(fd2, -EINVAL, "load_dummy_prog #2 (offloaded)"); 52 + 53 + out: 54 + close(fd1); 55 + close(fd2); 56 + close_netns(tok); 57 + /* eth42 was added inside netns, removing the netns will 58 + * also remove eth42 veth pair. 59 + */ 60 + SYS_NOFAIL("ip netns del " LOCAL_NETNS); 61 + }
+13
tools/testing/selftests/bpf/progs/kprobe_multi_override.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/bpf.h> 3 + #include <bpf/bpf_helpers.h> 4 + #include <bpf/bpf_tracing.h> 5 + 6 + char _license[] SEC("license") = "GPL"; 7 + 8 + SEC("kprobe.multi") 9 + int test_override(struct pt_regs *ctx) 10 + { 11 + bpf_override_return(ctx, 123); 12 + return 0; 13 + }
+123
tools/testing/selftests/bpf/progs/test_bpf_ma.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (C) 2023. Huawei Technologies Co., Ltd */ 3 + #include <vmlinux.h> 4 + #include <bpf/bpf_tracing.h> 5 + #include <bpf/bpf_helpers.h> 6 + 7 + #include "bpf_experimental.h" 8 + #include "bpf_misc.h" 9 + 10 + #ifndef ARRAY_SIZE 11 + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 12 + #endif 13 + 14 + struct generic_map_value { 15 + void *data; 16 + }; 17 + 18 + char _license[] SEC("license") = "GPL"; 19 + 20 + const unsigned int data_sizes[] = {8, 16, 32, 64, 96, 128, 192, 256, 512, 1024, 2048, 4096}; 21 + const volatile unsigned int data_btf_ids[ARRAY_SIZE(data_sizes)] = {}; 22 + 23 + int err = 0; 24 + int pid = 0; 25 + 26 + #define DEFINE_ARRAY_WITH_KPTR(_size) \ 27 + struct bin_data_##_size { \ 28 + char data[_size - sizeof(void *)]; \ 29 + }; \ 30 + struct map_value_##_size { \ 31 + struct bin_data_##_size __kptr * data; \ 32 + /* To emit BTF info for bin_data_xx */ \ 33 + struct bin_data_##_size not_used; \ 34 + }; \ 35 + struct { \ 36 + __uint(type, BPF_MAP_TYPE_ARRAY); \ 37 + __type(key, int); \ 38 + __type(value, struct map_value_##_size); \ 39 + __uint(max_entries, 128); \ 40 + } array_##_size SEC(".maps"); 41 + 42 + static __always_inline void batch_alloc_free(struct bpf_map *map, unsigned int batch, 43 + unsigned int idx) 44 + { 45 + struct generic_map_value *value; 46 + unsigned int i, key; 47 + void *old, *new; 48 + 49 + for (i = 0; i < batch; i++) { 50 + key = i; 51 + value = bpf_map_lookup_elem(map, &key); 52 + if (!value) { 53 + err = 1; 54 + return; 55 + } 56 + new = bpf_obj_new_impl(data_btf_ids[idx], NULL); 57 + if (!new) { 58 + err = 2; 59 + return; 60 + } 61 + old = bpf_kptr_xchg(&value->data, new); 62 + if (old) { 63 + bpf_obj_drop(old); 64 + err = 3; 65 + return; 66 + } 67 + } 68 + for (i = 0; i < batch; i++) { 69 + key = i; 70 + value = bpf_map_lookup_elem(map, &key); 71 + if (!value) { 72 + err = 4; 73 + return; 74 + } 75 + old = bpf_kptr_xchg(&value->data, NULL); 76 + if (!old) { 77 + err = 5; 78 + return; 79 + } 80 + bpf_obj_drop(old); 81 + } 82 + } 83 + 84 + #define CALL_BATCH_ALLOC_FREE(size, batch, idx) \ 85 + batch_alloc_free((struct bpf_map *)(&array_##size), batch, idx) 86 + 87 + DEFINE_ARRAY_WITH_KPTR(8); 88 + DEFINE_ARRAY_WITH_KPTR(16); 89 + DEFINE_ARRAY_WITH_KPTR(32); 90 + DEFINE_ARRAY_WITH_KPTR(64); 91 + DEFINE_ARRAY_WITH_KPTR(96); 92 + DEFINE_ARRAY_WITH_KPTR(128); 93 + DEFINE_ARRAY_WITH_KPTR(192); 94 + DEFINE_ARRAY_WITH_KPTR(256); 95 + DEFINE_ARRAY_WITH_KPTR(512); 96 + DEFINE_ARRAY_WITH_KPTR(1024); 97 + DEFINE_ARRAY_WITH_KPTR(2048); 98 + DEFINE_ARRAY_WITH_KPTR(4096); 99 + 100 + SEC("fentry/" SYS_PREFIX "sys_nanosleep") 101 + int test_bpf_mem_alloc_free(void *ctx) 102 + { 103 + if ((u32)bpf_get_current_pid_tgid() != pid) 104 + return 0; 105 + 106 + /* Alloc 128 8-bytes objects in batch to trigger refilling, 107 + * then free 128 8-bytes objects in batch to trigger freeing. 108 + */ 109 + CALL_BATCH_ALLOC_FREE(8, 128, 0); 110 + CALL_BATCH_ALLOC_FREE(16, 128, 1); 111 + CALL_BATCH_ALLOC_FREE(32, 128, 2); 112 + CALL_BATCH_ALLOC_FREE(64, 128, 3); 113 + CALL_BATCH_ALLOC_FREE(96, 128, 4); 114 + CALL_BATCH_ALLOC_FREE(128, 128, 5); 115 + CALL_BATCH_ALLOC_FREE(192, 128, 6); 116 + CALL_BATCH_ALLOC_FREE(256, 128, 7); 117 + CALL_BATCH_ALLOC_FREE(512, 64, 8); 118 + CALL_BATCH_ALLOC_FREE(1024, 32, 9); 119 + CALL_BATCH_ALLOC_FREE(2048, 16, 10); 120 + CALL_BATCH_ALLOC_FREE(4096, 8, 11); 121 + 122 + return 0; 123 + }
+1 -1
tools/testing/selftests/bpf/test_verifier.c
··· 1880 1880 } 1881 1881 } 1882 1882 1883 - get_unpriv_disabled(); 1883 + unpriv_disabled = get_unpriv_disabled(); 1884 1884 if (unpriv && unpriv_disabled) { 1885 1885 printf("Cannot run as unprivileged user with sysctl %s.\n", 1886 1886 UNPRIV_SYSCTL);
+140 -120
tools/testing/selftests/net/hsr/hsr_ping.sh
··· 41 41 done 42 42 } 43 43 44 - ip -Version > /dev/null 2>&1 45 - if [ $? -ne 0 ];then 46 - echo "SKIP: Could not run test without ip tool" 47 - exit $ksft_skip 48 - fi 49 - 50 - trap cleanup EXIT 51 - 52 - for i in "$ns1" "$ns2" "$ns3" ;do 53 - ip netns add $i || exit $ksft_skip 54 - ip -net $i link set lo up 55 - done 56 - 57 - echo "INFO: preparing interfaces." 58 - # Three HSR nodes. Each node has one link to each of its neighbour, two links in total. 59 - # 60 - # ns1eth1 ----- ns2eth1 61 - # hsr1 hsr2 62 - # ns1eth2 ns2eth2 63 - # | | 64 - # ns3eth1 ns3eth2 65 - # \ / 66 - # hsr3 67 - # 68 - # Interfaces 69 - ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2" 70 - ip link add ns1eth2 netns "$ns1" type veth peer name ns3eth1 netns "$ns3" 71 - ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2" 72 - 73 - # HSRv0. 74 - ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version 0 proto 0 75 - ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version 0 proto 0 76 - ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version 0 proto 0 77 - 78 - # IP for HSR 79 - ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1 80 - ip -net "$ns1" addr add dead:beef:1::1/64 dev hsr1 nodad 81 - ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2 82 - ip -net "$ns2" addr add dead:beef:1::2/64 dev hsr2 nodad 83 - ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3 84 - ip -net "$ns3" addr add dead:beef:1::3/64 dev hsr3 nodad 85 - 86 - # All Links up 87 - ip -net "$ns1" link set ns1eth1 up 88 - ip -net "$ns1" link set ns1eth2 up 89 - ip -net "$ns1" link set hsr1 up 90 - 91 - ip -net "$ns2" link set ns2eth1 up 92 - ip -net "$ns2" link set ns2eth2 up 93 - ip -net "$ns2" link set hsr2 up 94 - 95 - ip -net "$ns3" link set ns3eth1 up 96 - ip -net "$ns3" link set ns3eth2 up 97 - ip -net "$ns3" link set hsr3 up 98 - 99 44 # $1: IP address 100 45 is_v6() 101 46 { ··· 109 164 fi 110 165 } 111 166 167 + do_complete_ping_test() 168 + { 169 + echo "INFO: Initial validation ping." 170 + # Each node has to be able each one. 171 + do_ping "$ns1" 100.64.0.2 172 + do_ping "$ns2" 100.64.0.1 173 + do_ping "$ns3" 100.64.0.1 174 + stop_if_error "Initial validation failed." 112 175 113 - echo "INFO: Initial validation ping." 114 - # Each node has to be able each one. 115 - do_ping "$ns1" 100.64.0.2 116 - do_ping "$ns2" 100.64.0.1 117 - do_ping "$ns3" 100.64.0.1 118 - stop_if_error "Initial validation failed." 176 + do_ping "$ns1" 100.64.0.3 177 + do_ping "$ns2" 100.64.0.3 178 + do_ping "$ns3" 100.64.0.2 119 179 120 - do_ping "$ns1" 100.64.0.3 121 - do_ping "$ns2" 100.64.0.3 122 - do_ping "$ns3" 100.64.0.2 180 + do_ping "$ns1" dead:beef:1::2 181 + do_ping "$ns1" dead:beef:1::3 182 + do_ping "$ns2" dead:beef:1::1 183 + do_ping "$ns2" dead:beef:1::2 184 + do_ping "$ns3" dead:beef:1::1 185 + do_ping "$ns3" dead:beef:1::2 123 186 124 - do_ping "$ns1" dead:beef:1::2 125 - do_ping "$ns1" dead:beef:1::3 126 - do_ping "$ns2" dead:beef:1::1 127 - do_ping "$ns2" dead:beef:1::2 128 - do_ping "$ns3" dead:beef:1::1 129 - do_ping "$ns3" dead:beef:1::2 130 - 131 - stop_if_error "Initial validation failed." 187 + stop_if_error "Initial validation failed." 132 188 133 189 # Wait until supervisor all supervision frames have been processed and the node 134 190 # entries have been merged. Otherwise duplicate frames will be observed which is 135 191 # valid at this stage. 136 - WAIT=5 137 - while [ ${WAIT} -gt 0 ] 138 - do 139 - grep 00:00:00:00:00:00 /sys/kernel/debug/hsr/hsr*/node_table 140 - if [ $? -ne 0 ] 141 - then 142 - break 143 - fi 144 - sleep 1 145 - let WAIT = WAIT - 1 146 - done 192 + WAIT=5 193 + while [ ${WAIT} -gt 0 ] 194 + do 195 + grep 00:00:00:00:00:00 /sys/kernel/debug/hsr/hsr*/node_table 196 + if [ $? -ne 0 ] 197 + then 198 + break 199 + fi 200 + sleep 1 201 + let "WAIT = WAIT - 1" 202 + done 147 203 148 204 # Just a safety delay in case the above check didn't handle it. 149 - sleep 1 205 + sleep 1 150 206 151 - echo "INFO: Longer ping test." 152 - do_ping_long "$ns1" 100.64.0.2 153 - do_ping_long "$ns1" dead:beef:1::2 154 - do_ping_long "$ns1" 100.64.0.3 155 - do_ping_long "$ns1" dead:beef:1::3 207 + echo "INFO: Longer ping test." 208 + do_ping_long "$ns1" 100.64.0.2 209 + do_ping_long "$ns1" dead:beef:1::2 210 + do_ping_long "$ns1" 100.64.0.3 211 + do_ping_long "$ns1" dead:beef:1::3 156 212 157 - stop_if_error "Longer ping test failed." 213 + stop_if_error "Longer ping test failed." 158 214 159 - do_ping_long "$ns2" 100.64.0.1 160 - do_ping_long "$ns2" dead:beef:1::1 161 - do_ping_long "$ns2" 100.64.0.3 162 - do_ping_long "$ns2" dead:beef:1::2 163 - stop_if_error "Longer ping test failed." 215 + do_ping_long "$ns2" 100.64.0.1 216 + do_ping_long "$ns2" dead:beef:1::1 217 + do_ping_long "$ns2" 100.64.0.3 218 + do_ping_long "$ns2" dead:beef:1::2 219 + stop_if_error "Longer ping test failed." 164 220 165 - do_ping_long "$ns3" 100.64.0.1 166 - do_ping_long "$ns3" dead:beef:1::1 167 - do_ping_long "$ns3" 100.64.0.2 168 - do_ping_long "$ns3" dead:beef:1::2 169 - stop_if_error "Longer ping test failed." 221 + do_ping_long "$ns3" 100.64.0.1 222 + do_ping_long "$ns3" dead:beef:1::1 223 + do_ping_long "$ns3" 100.64.0.2 224 + do_ping_long "$ns3" dead:beef:1::2 225 + stop_if_error "Longer ping test failed." 170 226 171 - echo "INFO: Cutting one link." 172 - do_ping_long "$ns1" 100.64.0.3 & 227 + echo "INFO: Cutting one link." 228 + do_ping_long "$ns1" 100.64.0.3 & 173 229 174 - sleep 3 175 - ip -net "$ns3" link set ns3eth1 down 176 - wait 230 + sleep 3 231 + ip -net "$ns3" link set ns3eth1 down 232 + wait 177 233 178 - ip -net "$ns3" link set ns3eth1 up 234 + ip -net "$ns3" link set ns3eth1 up 179 235 180 - stop_if_error "Failed with one link down." 236 + stop_if_error "Failed with one link down." 181 237 182 - echo "INFO: Delay the link and drop a few packages." 183 - tc -net "$ns3" qdisc add dev ns3eth1 root netem delay 50ms 184 - tc -net "$ns2" qdisc add dev ns2eth1 root netem delay 5ms loss 25% 238 + echo "INFO: Delay the link and drop a few packages." 239 + tc -net "$ns3" qdisc add dev ns3eth1 root netem delay 50ms 240 + tc -net "$ns2" qdisc add dev ns2eth1 root netem delay 5ms loss 25% 185 241 186 - do_ping_long "$ns1" 100.64.0.2 187 - do_ping_long "$ns1" 100.64.0.3 242 + do_ping_long "$ns1" 100.64.0.2 243 + do_ping_long "$ns1" 100.64.0.3 188 244 189 - stop_if_error "Failed with delay and packetloss." 245 + stop_if_error "Failed with delay and packetloss." 190 246 191 - do_ping_long "$ns2" 100.64.0.1 192 - do_ping_long "$ns2" 100.64.0.3 247 + do_ping_long "$ns2" 100.64.0.1 248 + do_ping_long "$ns2" 100.64.0.3 193 249 194 - stop_if_error "Failed with delay and packetloss." 250 + stop_if_error "Failed with delay and packetloss." 195 251 196 - do_ping_long "$ns3" 100.64.0.1 197 - do_ping_long "$ns3" 100.64.0.2 198 - stop_if_error "Failed with delay and packetloss." 252 + do_ping_long "$ns3" 100.64.0.1 253 + do_ping_long "$ns3" 100.64.0.2 254 + stop_if_error "Failed with delay and packetloss." 199 255 200 - echo "INFO: All good." 256 + echo "INFO: All good." 257 + } 258 + 259 + setup_hsr_interfaces() 260 + { 261 + local HSRv="$1" 262 + 263 + echo "INFO: preparing interfaces for HSRv${HSRv}." 264 + # Three HSR nodes. Each node has one link to each of its neighbour, two links in total. 265 + # 266 + # ns1eth1 ----- ns2eth1 267 + # hsr1 hsr2 268 + # ns1eth2 ns2eth2 269 + # | | 270 + # ns3eth1 ns3eth2 271 + # \ / 272 + # hsr3 273 + # 274 + # Interfaces 275 + ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2" 276 + ip link add ns1eth2 netns "$ns1" type veth peer name ns3eth1 netns "$ns3" 277 + ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2" 278 + 279 + # HSRv0/1 280 + ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version $HSRv proto 0 281 + ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version $HSRv proto 0 282 + ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version $HSRv proto 0 283 + 284 + # IP for HSR 285 + ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1 286 + ip -net "$ns1" addr add dead:beef:1::1/64 dev hsr1 nodad 287 + ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2 288 + ip -net "$ns2" addr add dead:beef:1::2/64 dev hsr2 nodad 289 + ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3 290 + ip -net "$ns3" addr add dead:beef:1::3/64 dev hsr3 nodad 291 + 292 + # All Links up 293 + ip -net "$ns1" link set ns1eth1 up 294 + ip -net "$ns1" link set ns1eth2 up 295 + ip -net "$ns1" link set hsr1 up 296 + 297 + ip -net "$ns2" link set ns2eth1 up 298 + ip -net "$ns2" link set ns2eth2 up 299 + ip -net "$ns2" link set hsr2 up 300 + 301 + ip -net "$ns3" link set ns3eth1 up 302 + ip -net "$ns3" link set ns3eth2 up 303 + ip -net "$ns3" link set hsr3 up 304 + } 305 + 306 + ip -Version > /dev/null 2>&1 307 + if [ $? -ne 0 ];then 308 + echo "SKIP: Could not run test without ip tool" 309 + exit $ksft_skip 310 + fi 311 + 312 + trap cleanup EXIT 313 + 314 + for i in "$ns1" "$ns2" "$ns3" ;do 315 + ip netns add $i || exit $ksft_skip 316 + ip -net $i link set lo up 317 + done 318 + 319 + setup_hsr_interfaces 0 320 + do_complete_ping_test 321 + cleanup 322 + 323 + for i in "$ns1" "$ns2" "$ns3" ;do 324 + ip netns add $i || exit $ksft_skip 325 + ip -net $i link set lo up 326 + done 327 + 328 + setup_hsr_interfaces 1 329 + do_complete_ping_test 330 + 201 331 exit $ret
+4 -4
tools/testing/selftests/net/tls.c
··· 613 613 614 614 msg.msg_iov = &vec; 615 615 msg.msg_iovlen = 1; 616 - EXPECT_EQ(sendmsg(self->cfd, &msg, 0), send_len); 616 + EXPECT_EQ(sendmsg(self->fd, &msg, 0), send_len); 617 617 } 618 618 619 619 while (recvs++ < sends) { 620 - EXPECT_NE(recv(self->fd, mem, send_len, 0), -1); 620 + EXPECT_NE(recv(self->cfd, mem, send_len, 0), -1); 621 621 } 622 622 623 623 free(mem); ··· 646 646 msg.msg_iov = vec; 647 647 msg.msg_iovlen = iov_len; 648 648 649 - EXPECT_EQ(sendmsg(self->cfd, &msg, 0), total_len); 649 + EXPECT_EQ(sendmsg(self->fd, &msg, 0), total_len); 650 650 buf = malloc(total_len); 651 - EXPECT_NE(recv(self->fd, buf, total_len, 0), -1); 651 + EXPECT_NE(recv(self->cfd, buf, total_len, 0), -1); 652 652 for (i = 0; i < iov_len; i++) { 653 653 EXPECT_EQ(memcmp(test_strs[i], buf + len_cmp, 654 654 strlen(test_strs[i])),
+1
tools/testing/selftests/netfilter/.gitignore
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 nf-queue 3 3 connect_close 4 + audit_logread
+2 -2
tools/testing/selftests/netfilter/Makefile
··· 6 6 nft_concat_range.sh nft_conntrack_helper.sh \ 7 7 nft_queue.sh nft_meta.sh nf_nat_edemux.sh \ 8 8 ipip-conntrack-mtu.sh conntrack_tcp_unreplied.sh \ 9 - conntrack_vrf.sh nft_synproxy.sh rpath.sh 9 + conntrack_vrf.sh nft_synproxy.sh rpath.sh nft_audit.sh 10 10 11 11 HOSTPKG_CONFIG := pkg-config 12 12 13 13 CFLAGS += $(shell $(HOSTPKG_CONFIG) --cflags libmnl 2>/dev/null) 14 14 LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl) 15 15 16 - TEST_GEN_FILES = nf-queue connect_close 16 + TEST_GEN_FILES = nf-queue connect_close audit_logread 17 17 18 18 include ../lib.mk
+165
tools/testing/selftests/netfilter/audit_logread.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #define _GNU_SOURCE 4 + #include <errno.h> 5 + #include <fcntl.h> 6 + #include <poll.h> 7 + #include <signal.h> 8 + #include <stdint.h> 9 + #include <stdio.h> 10 + #include <stdlib.h> 11 + #include <string.h> 12 + #include <sys/socket.h> 13 + #include <unistd.h> 14 + #include <linux/audit.h> 15 + #include <linux/netlink.h> 16 + 17 + static int fd; 18 + 19 + #define MAX_AUDIT_MESSAGE_LENGTH 8970 20 + struct audit_message { 21 + struct nlmsghdr nlh; 22 + union { 23 + struct audit_status s; 24 + char data[MAX_AUDIT_MESSAGE_LENGTH]; 25 + } u; 26 + }; 27 + 28 + int audit_recv(int fd, struct audit_message *rep) 29 + { 30 + struct sockaddr_nl addr; 31 + socklen_t addrlen = sizeof(addr); 32 + int ret; 33 + 34 + do { 35 + ret = recvfrom(fd, rep, sizeof(*rep), 0, 36 + (struct sockaddr *)&addr, &addrlen); 37 + } while (ret < 0 && errno == EINTR); 38 + 39 + if (ret < 0 || 40 + addrlen != sizeof(addr) || 41 + addr.nl_pid != 0 || 42 + rep->nlh.nlmsg_type == NLMSG_ERROR) /* short-cut for now */ 43 + return -1; 44 + 45 + return ret; 46 + } 47 + 48 + int audit_send(int fd, uint16_t type, uint32_t key, uint32_t val) 49 + { 50 + static int seq = 0; 51 + struct audit_message msg = { 52 + .nlh = { 53 + .nlmsg_len = NLMSG_SPACE(sizeof(msg.u.s)), 54 + .nlmsg_type = type, 55 + .nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK, 56 + .nlmsg_seq = ++seq, 57 + }, 58 + .u.s = { 59 + .mask = key, 60 + .enabled = key == AUDIT_STATUS_ENABLED ? val : 0, 61 + .pid = key == AUDIT_STATUS_PID ? val : 0, 62 + } 63 + }; 64 + struct sockaddr_nl addr = { 65 + .nl_family = AF_NETLINK, 66 + }; 67 + int ret; 68 + 69 + do { 70 + ret = sendto(fd, &msg, msg.nlh.nlmsg_len, 0, 71 + (struct sockaddr *)&addr, sizeof(addr)); 72 + } while (ret < 0 && errno == EINTR); 73 + 74 + if (ret != (int)msg.nlh.nlmsg_len) 75 + return -1; 76 + return 0; 77 + } 78 + 79 + int audit_set(int fd, uint32_t key, uint32_t val) 80 + { 81 + struct audit_message rep = { 0 }; 82 + int ret; 83 + 84 + ret = audit_send(fd, AUDIT_SET, key, val); 85 + if (ret) 86 + return ret; 87 + 88 + ret = audit_recv(fd, &rep); 89 + if (ret < 0) 90 + return ret; 91 + return 0; 92 + } 93 + 94 + int readlog(int fd) 95 + { 96 + struct audit_message rep = { 0 }; 97 + int ret = audit_recv(fd, &rep); 98 + const char *sep = ""; 99 + char *k, *v; 100 + 101 + if (ret < 0) 102 + return ret; 103 + 104 + if (rep.nlh.nlmsg_type != AUDIT_NETFILTER_CFG) 105 + return 0; 106 + 107 + /* skip the initial "audit(...): " part */ 108 + strtok(rep.u.data, " "); 109 + 110 + while ((k = strtok(NULL, "="))) { 111 + v = strtok(NULL, " "); 112 + 113 + /* these vary and/or are uninteresting, ignore */ 114 + if (!strcmp(k, "pid") || 115 + !strcmp(k, "comm") || 116 + !strcmp(k, "subj")) 117 + continue; 118 + 119 + /* strip the varying sequence number */ 120 + if (!strcmp(k, "table")) 121 + *strchrnul(v, ':') = '\0'; 122 + 123 + printf("%s%s=%s", sep, k, v); 124 + sep = " "; 125 + } 126 + if (*sep) { 127 + printf("\n"); 128 + fflush(stdout); 129 + } 130 + return 0; 131 + } 132 + 133 + void cleanup(int sig) 134 + { 135 + audit_set(fd, AUDIT_STATUS_ENABLED, 0); 136 + close(fd); 137 + if (sig) 138 + exit(0); 139 + } 140 + 141 + int main(int argc, char **argv) 142 + { 143 + struct sigaction act = { 144 + .sa_handler = cleanup, 145 + }; 146 + 147 + fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT); 148 + if (fd < 0) { 149 + perror("Can't open netlink socket"); 150 + return -1; 151 + } 152 + 153 + if (sigaction(SIGTERM, &act, NULL) < 0 || 154 + sigaction(SIGINT, &act, NULL) < 0) { 155 + perror("Can't set signal handler"); 156 + close(fd); 157 + return -1; 158 + } 159 + 160 + audit_set(fd, AUDIT_STATUS_ENABLED, 1); 161 + audit_set(fd, AUDIT_STATUS_PID, getpid()); 162 + 163 + while (1) 164 + readlog(fd); 165 + }
+1
tools/testing/selftests/netfilter/config
··· 6 6 CONFIG_NFT_MASQ=m 7 7 CONFIG_NFT_FLOW_OFFLOAD=m 8 8 CONFIG_NF_CT_NETLINK=m 9 + CONFIG_AUDIT=y
+108
tools/testing/selftests/netfilter/nft_audit.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Check that audit logs generated for nft commands are as expected. 5 + 6 + SKIP_RC=4 7 + RC=0 8 + 9 + nft --version >/dev/null 2>&1 || { 10 + echo "SKIP: missing nft tool" 11 + exit $SKIP_RC 12 + } 13 + 14 + logfile=$(mktemp) 15 + echo "logging into $logfile" 16 + ./audit_logread >"$logfile" & 17 + logread_pid=$! 18 + trap 'kill $logread_pid; rm -f $logfile' EXIT 19 + exec 3<"$logfile" 20 + 21 + do_test() { # (cmd, log) 22 + echo -n "testing for cmd: $1 ... " 23 + cat <&3 >/dev/null 24 + $1 >/dev/null || exit 1 25 + sleep 0.1 26 + res=$(diff -a -u <(echo "$2") - <&3) 27 + [ $? -eq 0 ] && { echo "OK"; return; } 28 + echo "FAIL" 29 + echo "$res" 30 + ((RC++)) 31 + } 32 + 33 + nft flush ruleset 34 + 35 + for table in t1 t2; do 36 + do_test "nft add table $table" \ 37 + "table=$table family=2 entries=1 op=nft_register_table" 38 + 39 + do_test "nft add chain $table c1" \ 40 + "table=$table family=2 entries=1 op=nft_register_chain" 41 + 42 + do_test "nft add chain $table c2; add chain $table c3" \ 43 + "table=$table family=2 entries=2 op=nft_register_chain" 44 + 45 + cmd="add rule $table c1 counter" 46 + 47 + do_test "nft $cmd" \ 48 + "table=$table family=2 entries=1 op=nft_register_rule" 49 + 50 + do_test "nft $cmd; $cmd" \ 51 + "table=$table family=2 entries=2 op=nft_register_rule" 52 + 53 + cmd="" 54 + sep="" 55 + for chain in c2 c3; do 56 + for i in {1..3}; do 57 + cmd+="$sep add rule $table $chain counter" 58 + sep=";" 59 + done 60 + done 61 + do_test "nft $cmd" \ 62 + "table=$table family=2 entries=6 op=nft_register_rule" 63 + done 64 + 65 + do_test 'nft reset rules t1 c2' \ 66 + 'table=t1 family=2 entries=3 op=nft_reset_rule' 67 + 68 + do_test 'nft reset rules table t1' \ 69 + 'table=t1 family=2 entries=3 op=nft_reset_rule 70 + table=t1 family=2 entries=3 op=nft_reset_rule 71 + table=t1 family=2 entries=3 op=nft_reset_rule' 72 + 73 + do_test 'nft reset rules' \ 74 + 'table=t1 family=2 entries=3 op=nft_reset_rule 75 + table=t1 family=2 entries=3 op=nft_reset_rule 76 + table=t1 family=2 entries=3 op=nft_reset_rule 77 + table=t2 family=2 entries=3 op=nft_reset_rule 78 + table=t2 family=2 entries=3 op=nft_reset_rule 79 + table=t2 family=2 entries=3 op=nft_reset_rule' 80 + 81 + for ((i = 0; i < 500; i++)); do 82 + echo "add rule t2 c3 counter accept comment \"rule $i\"" 83 + done | do_test 'nft -f -' \ 84 + 'table=t2 family=2 entries=500 op=nft_register_rule' 85 + 86 + do_test 'nft reset rules t2 c3' \ 87 + 'table=t2 family=2 entries=189 op=nft_reset_rule 88 + table=t2 family=2 entries=188 op=nft_reset_rule 89 + table=t2 family=2 entries=126 op=nft_reset_rule' 90 + 91 + do_test 'nft reset rules t2' \ 92 + 'table=t2 family=2 entries=3 op=nft_reset_rule 93 + table=t2 family=2 entries=3 op=nft_reset_rule 94 + table=t2 family=2 entries=186 op=nft_reset_rule 95 + table=t2 family=2 entries=188 op=nft_reset_rule 96 + table=t2 family=2 entries=129 op=nft_reset_rule' 97 + 98 + do_test 'nft reset rules' \ 99 + 'table=t1 family=2 entries=3 op=nft_reset_rule 100 + table=t1 family=2 entries=3 op=nft_reset_rule 101 + table=t1 family=2 entries=3 op=nft_reset_rule 102 + table=t2 family=2 entries=3 op=nft_reset_rule 103 + table=t2 family=2 entries=3 op=nft_reset_rule 104 + table=t2 family=2 entries=180 op=nft_reset_rule 105 + table=t2 family=2 entries=188 op=nft_reset_rule 106 + table=t2 family=2 entries=135 op=nft_reset_rule' 107 + 108 + exit $RC