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

Configure Feed

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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller:

1) GTP fixes from Andreas Schultz (missing genl module alias, clear IP
DF on transmit).

2) Netfilter needs to reflect the fwmark when sending resets, from Pau
Espin Pedrol.

3) nftable dump OOPS fix from Liping Zhang.

4) Fix erroneous setting of VIRTIO_NET_HDR_F_DATA_VALID on transmit,
from Rolf Neugebauer.

5) Fix build error of ipt_CLUSTERIP when procfs is disabled, from Arnd
Bergmann.

6) Fix regression in handling of NETIF_F_SG in harmonize_features(),
from Eric Dumazet.

7) Fix RTNL deadlock wrt. lwtunnel module loading, from David Ahern.

8) tcp_fastopen_create_child() needs to setup tp->max_window, from
Alexey Kodanev.

9) Missing kmemdup() failure check in ipv6 segment routing code, from
Eric Dumazet.

10) Don't execute unix_bind() under the bindlock, otherwise we deadlock
with splice. From WANG Cong.

11) ip6_tnl_parse_tlv_enc_lim() potentially reallocates the skb buffer,
therefore callers must reload cached header pointers into that skb.
Fix from Eric Dumazet.

12) Fix various bugs in legacy IRQ fallback handling in alx driver, from
Tobias Regnery.

13) Do not allow lwtunnel drivers to be unloaded while they are
referenced by active instances, from Robert Shearman.

14) Fix truncated PHY LED trigger names, from Geert Uytterhoeven.

15) Fix a few regressions from virtio_net XDP support, from John
Fastabend and Jakub Kicinski.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (102 commits)
ISDN: eicon: silence misleading array-bounds warning
net: phy: micrel: add support for KSZ8795
gtp: fix cross netns recv on gtp socket
gtp: clear DF bit on GTP packet tx
gtp: add genl family modules alias
tcp: don't annotate mark on control socket from tcp_v6_send_response()
ravb: unmap descriptors when freeing rings
virtio_net: reject XDP programs using header adjustment
virtio_net: use dev_kfree_skb for small buffer XDP receive
r8152: check rx after napi is enabled
r8152: re-schedule napi for tx
r8152: avoid start_xmit to schedule napi when napi is disabled
r8152: avoid start_xmit to call napi_schedule during autosuspend
net: dsa: Bring back device detaching in dsa_slave_suspend()
net: phy: leds: Fix truncated LED trigger names
net: phy: leds: Break dependency of phy.h on phy_led_triggers.h
net: phy: leds: Clear phy_num_led_triggers on failure to avoid crash
net-next: ethernet: mediatek: change the compatible string
Documentation: devicetree: change the mediatek ethernet compatible string
bnxt_en: Fix RTNL lock usage on bnxt_get_port_module_status().
...

+923 -569
+1 -1
Documentation/devicetree/bindings/net/mediatek-net.txt
··· 7 7 * Ethernet controller node 8 8 9 9 Required properties: 10 - - compatible: Should be "mediatek,mt7623-eth" 10 + - compatible: Should be "mediatek,mt2701-eth" 11 11 - reg: Address and length of the register set for the device 12 12 - interrupts: Should contain the three frame engines interrupts in numeric 13 13 order. These are fe_int0, fe_int1 and fe_int2.
+3 -2
Documentation/devicetree/bindings/net/phy.txt
··· 19 19 specifications. If neither of these are specified, the default is to 20 20 assume clause 22. 21 21 22 - If the phy's identifier is known then the list may contain an entry 23 - of the form: "ethernet-phy-idAAAA.BBBB" where 22 + If the PHY reports an incorrect ID (or none at all) then the 23 + "compatible" list may contain an entry with the correct PHY ID in the 24 + form: "ethernet-phy-idAAAA.BBBB" where 24 25 AAAA - The value of the 16 bit Phy Identifier 1 register as 25 26 4 hex digits. This is the chip vendor OUI bits 3:18 26 27 BBBB - The value of the 16 bit Phy Identifier 2 register as
+1 -1
MAINTAINERS
··· 3567 3567 F: include/uapi/rdma/cxgb3-abi.h 3568 3568 3569 3569 CXGB4 ETHERNET DRIVER (CXGB4) 3570 - M: Hariprasad S <hariprasad@chelsio.com> 3570 + M: Ganesh Goudar <ganeshgr@chelsio.com> 3571 3571 L: netdev@vger.kernel.org 3572 3572 W: http://www.chelsio.com 3573 3573 S: Supported
+2 -1
drivers/isdn/hardware/eicon/message.c
··· 11297 11297 ((CAPI_MSG *) msg)->header.ncci = 0; 11298 11298 ((CAPI_MSG *) msg)->info.facility_req.Selector = SELECTOR_LINE_INTERCONNECT; 11299 11299 ((CAPI_MSG *) msg)->info.facility_req.structs[0] = 3; 11300 - PUT_WORD(&(((CAPI_MSG *) msg)->info.facility_req.structs[1]), LI_REQ_SILENT_UPDATE); 11300 + ((CAPI_MSG *) msg)->info.facility_req.structs[1] = LI_REQ_SILENT_UPDATE & 0xff; 11301 + ((CAPI_MSG *) msg)->info.facility_req.structs[2] = LI_REQ_SILENT_UPDATE >> 8; 11301 11302 ((CAPI_MSG *) msg)->info.facility_req.structs[3] = 0; 11302 11303 w = api_put(notify_plci->appl, (CAPI_MSG *) msg); 11303 11304 if (w != _QUEUE_FULL)
+1
drivers/net/can/c_can/c_can_pci.c
··· 161 161 162 162 dev->irq = pdev->irq; 163 163 priv->base = addr; 164 + priv->device = &pdev->dev; 164 165 165 166 if (!c_can_pci_data->freq) { 166 167 dev_err(&pdev->dev, "no clock frequency defined\n");
+12 -4
drivers/net/can/ti_hecc.c
··· 948 948 netif_napi_add(ndev, &priv->napi, ti_hecc_rx_poll, 949 949 HECC_DEF_NAPI_WEIGHT); 950 950 951 - clk_enable(priv->clk); 951 + err = clk_prepare_enable(priv->clk); 952 + if (err) { 953 + dev_err(&pdev->dev, "clk_prepare_enable() failed\n"); 954 + goto probe_exit_clk; 955 + } 956 + 952 957 err = register_candev(ndev); 953 958 if (err) { 954 959 dev_err(&pdev->dev, "register_candev() failed\n"); ··· 986 981 struct ti_hecc_priv *priv = netdev_priv(ndev); 987 982 988 983 unregister_candev(ndev); 989 - clk_disable(priv->clk); 984 + clk_disable_unprepare(priv->clk); 990 985 clk_put(priv->clk); 991 986 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 992 987 iounmap(priv->base); ··· 1011 1006 hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_PDR); 1012 1007 priv->can.state = CAN_STATE_SLEEPING; 1013 1008 1014 - clk_disable(priv->clk); 1009 + clk_disable_unprepare(priv->clk); 1015 1010 1016 1011 return 0; 1017 1012 } ··· 1020 1015 { 1021 1016 struct net_device *dev = platform_get_drvdata(pdev); 1022 1017 struct ti_hecc_priv *priv = netdev_priv(dev); 1018 + int err; 1023 1019 1024 - clk_enable(priv->clk); 1020 + err = clk_prepare_enable(priv->clk); 1021 + if (err) 1022 + return err; 1025 1023 1026 1024 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_PDR); 1027 1025 priv->can.state = CAN_STATE_ERROR_ACTIVE;
+2
drivers/net/ethernet/amd/xgbe/xgbe-common.h
··· 891 891 #define PCS_V1_WINDOW_SELECT 0x03fc 892 892 #define PCS_V2_WINDOW_DEF 0x9060 893 893 #define PCS_V2_WINDOW_SELECT 0x9064 894 + #define PCS_V2_RV_WINDOW_DEF 0x1060 895 + #define PCS_V2_RV_WINDOW_SELECT 0x1064 894 896 895 897 /* PCS register entry bit positions and sizes */ 896 898 #define PCS_V2_WINDOW_DEF_OFFSET_INDEX 6
+5 -3
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
··· 1151 1151 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask); 1152 1152 1153 1153 spin_lock_irqsave(&pdata->xpcs_lock, flags); 1154 - XPCS32_IOWRITE(pdata, PCS_V2_WINDOW_SELECT, index); 1154 + XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index); 1155 1155 mmd_data = XPCS16_IOREAD(pdata, offset); 1156 1156 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); 1157 1157 ··· 1183 1183 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask); 1184 1184 1185 1185 spin_lock_irqsave(&pdata->xpcs_lock, flags); 1186 - XPCS32_IOWRITE(pdata, PCS_V2_WINDOW_SELECT, index); 1186 + XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index); 1187 1187 XPCS16_IOWRITE(pdata, offset, mmd_data); 1188 1188 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); 1189 1189 } ··· 3407 3407 3408 3408 /* Flush Tx queues */ 3409 3409 ret = xgbe_flush_tx_queues(pdata); 3410 - if (ret) 3410 + if (ret) { 3411 + netdev_err(pdata->netdev, "error flushing TX queues\n"); 3411 3412 return ret; 3413 + } 3412 3414 3413 3415 /* 3414 3416 * Initialize DMA related features
+3 -1
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
··· 1070 1070 1071 1071 DBGPR("-->xgbe_start\n"); 1072 1072 1073 - hw_if->init(pdata); 1073 + ret = hw_if->init(pdata); 1074 + if (ret) 1075 + return ret; 1074 1076 1075 1077 xgbe_napi_enable(pdata, 1); 1076 1078
+14 -1
drivers/net/ethernet/amd/xgbe/xgbe-pci.c
··· 265 265 struct xgbe_prv_data *pdata; 266 266 struct device *dev = &pdev->dev; 267 267 void __iomem * const *iomap_table; 268 + struct pci_dev *rdev; 268 269 unsigned int ma_lo, ma_hi; 269 270 unsigned int reg; 270 271 int bar_mask; ··· 327 326 if (netif_msg_probe(pdata)) 328 327 dev_dbg(dev, "xpcs_regs = %p\n", pdata->xpcs_regs); 329 328 329 + /* Set the PCS indirect addressing definition registers */ 330 + rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0)); 331 + if (rdev && 332 + (rdev->vendor == PCI_VENDOR_ID_AMD) && (rdev->device == 0x15d0)) { 333 + pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF; 334 + pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT; 335 + } else { 336 + pdata->xpcs_window_def_reg = PCS_V2_WINDOW_DEF; 337 + pdata->xpcs_window_sel_reg = PCS_V2_WINDOW_SELECT; 338 + } 339 + pci_dev_put(rdev); 340 + 330 341 /* Configure the PCS indirect addressing support */ 331 - reg = XPCS32_IOREAD(pdata, PCS_V2_WINDOW_DEF); 342 + reg = XPCS32_IOREAD(pdata, pdata->xpcs_window_def_reg); 332 343 pdata->xpcs_window = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, OFFSET); 333 344 pdata->xpcs_window <<= 6; 334 345 pdata->xpcs_window_size = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, SIZE);
+2
drivers/net/ethernet/amd/xgbe/xgbe.h
··· 955 955 956 956 /* XPCS indirect addressing lock */ 957 957 spinlock_t xpcs_lock; 958 + unsigned int xpcs_window_def_reg; 959 + unsigned int xpcs_window_sel_reg; 958 960 unsigned int xpcs_window; 959 961 unsigned int xpcs_window_size; 960 962 unsigned int xpcs_window_mask;
+8 -3
drivers/net/ethernet/atheros/alx/main.c
··· 685 685 return -ENOMEM; 686 686 } 687 687 688 - alx_reinit_rings(alx); 689 - 690 688 return 0; 691 689 } 692 690 ··· 701 703 if (alx->qnapi[0] && alx->qnapi[0]->rxq) 702 704 kfree(alx->qnapi[0]->rxq->bufs); 703 705 704 - if (!alx->descmem.virt) 706 + if (alx->descmem.virt) 705 707 dma_free_coherent(&alx->hw.pdev->dev, 706 708 alx->descmem.size, 707 709 alx->descmem.virt, ··· 982 984 alx_free_rings(alx); 983 985 alx_free_napis(alx); 984 986 alx_disable_advanced_intr(alx); 987 + alx_init_intr(alx, false); 985 988 986 989 err = alx_alloc_napis(alx); 987 990 if (err) ··· 1239 1240 err = alx_request_irq(alx); 1240 1241 if (err) 1241 1242 goto out_free_rings; 1243 + 1244 + /* must be called after alx_request_irq because the chip stops working 1245 + * if we copy the dma addresses in alx_init_ring_ptrs twice when 1246 + * requesting msi-x interrupts failed 1247 + */ 1248 + alx_reinit_rings(alx); 1242 1249 1243 1250 netif_set_real_num_tx_queues(alx->dev, alx->num_txq); 1244 1251 netif_set_real_num_rx_queues(alx->dev, alx->num_rxq);
+4 -2
drivers/net/ethernet/broadcom/bcm63xx_enet.c
··· 913 913 priv->old_link = 0; 914 914 priv->old_duplex = -1; 915 915 priv->old_pause = -1; 916 + } else { 917 + phydev = NULL; 916 918 } 917 919 918 920 /* mask all interrupts and request them */ ··· 1085 1083 enet_dmac_writel(priv, priv->dma_chan_int_mask, 1086 1084 ENETDMAC_IRMASK, priv->tx_chan); 1087 1085 1088 - if (priv->has_phy) 1086 + if (phydev) 1089 1087 phy_start(phydev); 1090 1088 else 1091 1089 bcm_enet_adjust_link(dev); ··· 1128 1126 free_irq(dev->irq, dev); 1129 1127 1130 1128 out_phy_disconnect: 1131 - if (priv->has_phy) 1129 + if (phydev) 1132 1130 phy_disconnect(phydev); 1133 1131 1134 1132 return ret;
+47 -33
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 1099 1099 { 1100 1100 #ifdef CONFIG_INET 1101 1101 struct tcphdr *th; 1102 - int len, nw_off, tcp_opt_len; 1102 + int len, nw_off, tcp_opt_len = 0; 1103 1103 1104 1104 if (tcp_ts) 1105 1105 tcp_opt_len = 12; ··· 5314 5314 if ((link_info->support_auto_speeds | diff) != 5315 5315 link_info->support_auto_speeds) { 5316 5316 /* An advertised speed is no longer supported, so we need to 5317 - * update the advertisement settings. See bnxt_reset() for 5318 - * comments about the rtnl_lock() sequence below. 5317 + * update the advertisement settings. Caller holds RTNL 5318 + * so we can modify link settings. 5319 5319 */ 5320 - clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 5321 - rtnl_lock(); 5322 5320 link_info->advertising = link_info->support_auto_speeds; 5323 - if (test_bit(BNXT_STATE_OPEN, &bp->state) && 5324 - (link_info->autoneg & BNXT_AUTONEG_SPEED)) 5321 + if (link_info->autoneg & BNXT_AUTONEG_SPEED) 5325 5322 bnxt_hwrm_set_link_setting(bp, true, false); 5326 - set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 5327 - rtnl_unlock(); 5328 5323 } 5329 5324 return 0; 5330 5325 } ··· 6195 6200 mod_timer(&bp->timer, jiffies + bp->current_interval); 6196 6201 } 6197 6202 6198 - /* Only called from bnxt_sp_task() */ 6199 - static void bnxt_reset(struct bnxt *bp, bool silent) 6203 + static void bnxt_rtnl_lock_sp(struct bnxt *bp) 6200 6204 { 6201 - /* bnxt_reset_task() calls bnxt_close_nic() which waits 6202 - * for BNXT_STATE_IN_SP_TASK to clear. 6203 - * If there is a parallel dev_close(), bnxt_close() may be holding 6205 + /* We are called from bnxt_sp_task which has BNXT_STATE_IN_SP_TASK 6206 + * set. If the device is being closed, bnxt_close() may be holding 6204 6207 * rtnl() and waiting for BNXT_STATE_IN_SP_TASK to clear. So we 6205 6208 * must clear BNXT_STATE_IN_SP_TASK before holding rtnl(). 6206 6209 */ 6207 6210 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6208 6211 rtnl_lock(); 6209 - if (test_bit(BNXT_STATE_OPEN, &bp->state)) 6210 - bnxt_reset_task(bp, silent); 6212 + } 6213 + 6214 + static void bnxt_rtnl_unlock_sp(struct bnxt *bp) 6215 + { 6211 6216 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6212 6217 rtnl_unlock(); 6218 + } 6219 + 6220 + /* Only called from bnxt_sp_task() */ 6221 + static void bnxt_reset(struct bnxt *bp, bool silent) 6222 + { 6223 + bnxt_rtnl_lock_sp(bp); 6224 + if (test_bit(BNXT_STATE_OPEN, &bp->state)) 6225 + bnxt_reset_task(bp, silent); 6226 + bnxt_rtnl_unlock_sp(bp); 6213 6227 } 6214 6228 6215 6229 static void bnxt_cfg_ntp_filters(struct bnxt *); ··· 6226 6222 static void bnxt_sp_task(struct work_struct *work) 6227 6223 { 6228 6224 struct bnxt *bp = container_of(work, struct bnxt, sp_task); 6229 - int rc; 6230 6225 6231 6226 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6232 6227 smp_mb__after_atomic(); ··· 6239 6236 6240 6237 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) 6241 6238 bnxt_cfg_ntp_filters(bp); 6242 - if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { 6243 - if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, 6244 - &bp->sp_event)) 6245 - bnxt_hwrm_phy_qcaps(bp); 6246 - 6247 - rc = bnxt_update_link(bp, true); 6248 - if (rc) 6249 - netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", 6250 - rc); 6251 - } 6252 6239 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) 6253 6240 bnxt_hwrm_exec_fwd_req(bp); 6254 6241 if (test_and_clear_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event)) { ··· 6259 6266 bnxt_hwrm_tunnel_dst_port_free( 6260 6267 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE); 6261 6268 } 6269 + if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) 6270 + bnxt_hwrm_port_qstats(bp); 6271 + 6272 + /* These functions below will clear BNXT_STATE_IN_SP_TASK. They 6273 + * must be the last functions to be called before exiting. 6274 + */ 6275 + if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { 6276 + int rc = 0; 6277 + 6278 + if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, 6279 + &bp->sp_event)) 6280 + bnxt_hwrm_phy_qcaps(bp); 6281 + 6282 + bnxt_rtnl_lock_sp(bp); 6283 + if (test_bit(BNXT_STATE_OPEN, &bp->state)) 6284 + rc = bnxt_update_link(bp, true); 6285 + bnxt_rtnl_unlock_sp(bp); 6286 + if (rc) 6287 + netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", 6288 + rc); 6289 + } 6290 + if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { 6291 + bnxt_rtnl_lock_sp(bp); 6292 + if (test_bit(BNXT_STATE_OPEN, &bp->state)) 6293 + bnxt_get_port_module_status(bp); 6294 + bnxt_rtnl_unlock_sp(bp); 6295 + } 6262 6296 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) 6263 6297 bnxt_reset(bp, false); 6264 6298 6265 6299 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) 6266 6300 bnxt_reset(bp, true); 6267 - 6268 - if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) 6269 - bnxt_get_port_module_status(bp); 6270 - 6271 - if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) 6272 - bnxt_hwrm_port_qstats(bp); 6273 6301 6274 6302 smp_mb__before_atomic(); 6275 6303 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+1 -1
drivers/net/ethernet/freescale/gianfar.c
··· 2948 2948 } 2949 2949 2950 2950 /* try reuse page */ 2951 - if (unlikely(page_count(page) != 1)) 2951 + if (unlikely(page_count(page) != 1 || page_is_pfmemalloc(page))) 2952 2952 return false; 2953 2953 2954 2954 /* change offset to the other half */
+5 -2
drivers/net/ethernet/ibm/ibmveth.c
··· 1601 1601 netdev->netdev_ops = &ibmveth_netdev_ops; 1602 1602 netdev->ethtool_ops = &netdev_ethtool_ops; 1603 1603 SET_NETDEV_DEV(netdev, &dev->dev); 1604 - netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | 1605 - NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; 1604 + netdev->hw_features = NETIF_F_SG; 1605 + if (vio_get_attribute(dev, "ibm,illan-options", NULL) != NULL) { 1606 + netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 1607 + NETIF_F_RXCSUM; 1608 + } 1606 1609 1607 1610 netdev->features |= netdev->hw_features; 1608 1611
+1 -1
drivers/net/ethernet/mediatek/mtk_eth_soc.c
··· 2517 2517 } 2518 2518 2519 2519 const struct of_device_id of_mtk_match[] = { 2520 - { .compatible = "mediatek,mt7623-eth" }, 2520 + { .compatible = "mediatek,mt2701-eth" }, 2521 2521 {}, 2522 2522 }; 2523 2523 MODULE_DEVICE_TABLE(of, of_mtk_match);
+1 -6
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
··· 1732 1732 { 1733 1733 struct mlx4_en_priv *priv = netdev_priv(dev); 1734 1734 1735 - memset(channel, 0, sizeof(*channel)); 1736 - 1737 1735 channel->max_rx = MAX_RX_RINGS; 1738 1736 channel->max_tx = MLX4_EN_MAX_TX_RING_P_UP; 1739 1737 ··· 1750 1752 int xdp_count; 1751 1753 int err = 0; 1752 1754 1753 - if (channel->other_count || channel->combined_count || 1754 - channel->tx_count > MLX4_EN_MAX_TX_RING_P_UP || 1755 - channel->rx_count > MAX_RX_RINGS || 1756 - !channel->tx_count || !channel->rx_count) 1755 + if (!channel->tx_count || !channel->rx_count) 1757 1756 return -EINVAL; 1758 1757 1759 1758 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
-11
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 543 543 struct ethtool_channels *ch) 544 544 { 545 545 struct mlx5e_priv *priv = netdev_priv(dev); 546 - int ncv = mlx5e_get_max_num_channels(priv->mdev); 547 546 unsigned int count = ch->combined_count; 548 547 bool arfs_enabled; 549 548 bool was_opened; ··· 551 552 if (!count) { 552 553 netdev_info(dev, "%s: combined_count=0 not supported\n", 553 554 __func__); 554 - return -EINVAL; 555 - } 556 - if (ch->rx_count || ch->tx_count) { 557 - netdev_info(dev, "%s: separate rx/tx count not supported\n", 558 - __func__); 559 - return -EINVAL; 560 - } 561 - if (count > ncv) { 562 - netdev_info(dev, "%s: count (%d) > max (%d)\n", 563 - __func__, count, ncv); 564 555 return -EINVAL; 565 556 } 566 557
+3
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 193 193 return false; 194 194 } 195 195 196 + if (unlikely(page_is_pfmemalloc(dma_info->page))) 197 + return false; 198 + 196 199 cache->page_cache[cache->tail] = *dma_info; 197 200 cache->tail = tail_next; 198 201 return true;
+6 -4
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 1172 1172 1173 1173 static int 1174 1174 mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp, 1175 - struct mlxsw_sp_nexthop_group *nh_grp) 1175 + struct mlxsw_sp_nexthop_group *nh_grp, 1176 + bool reallocate) 1176 1177 { 1177 1178 u32 adj_index = nh_grp->adj_index; /* base */ 1178 1179 struct mlxsw_sp_nexthop *nh; ··· 1188 1187 continue; 1189 1188 } 1190 1189 1191 - if (nh->update) { 1190 + if (nh->update || reallocate) { 1192 1191 err = mlxsw_sp_nexthop_mac_update(mlxsw_sp, 1193 1192 adj_index, nh); 1194 1193 if (err) ··· 1249 1248 /* Nothing was added or removed, so no need to reallocate. Just 1250 1249 * update MAC on existing adjacency indexes. 1251 1250 */ 1252 - err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp); 1251 + err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp, 1252 + false); 1253 1253 if (err) { 1254 1254 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n"); 1255 1255 goto set_trap; ··· 1278 1276 nh_grp->adj_index_valid = 1; 1279 1277 nh_grp->adj_index = adj_index; 1280 1278 nh_grp->ecmp_size = ecmp_size; 1281 - err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp); 1279 + err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp, true); 1282 1280 if (err) { 1283 1281 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n"); 1284 1282 goto set_trap;
+37 -49
drivers/net/ethernet/qlogic/qed/qed_ll2.c
··· 297 297 list_del(&p_pkt->list_entry); 298 298 b_last_packet = list_empty(&p_tx->active_descq); 299 299 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); 300 - if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) { 300 + if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO) { 301 301 struct qed_ooo_buffer *p_buffer; 302 302 303 303 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; ··· 309 309 b_last_frag = 310 310 p_tx->cur_completing_bd_idx == p_pkt->bd_used; 311 311 tx_frag = p_pkt->bds_set[0].tx_frag; 312 - if (p_ll2_conn->gsi_enable) 312 + if (p_ll2_conn->conn.gsi_enable) 313 313 qed_ll2b_release_tx_gsi_packet(p_hwfn, 314 314 p_ll2_conn-> 315 315 my_id, ··· 378 378 379 379 spin_unlock_irqrestore(&p_tx->lock, flags); 380 380 tx_frag = p_pkt->bds_set[0].tx_frag; 381 - if (p_ll2_conn->gsi_enable) 381 + if (p_ll2_conn->conn.gsi_enable) 382 382 qed_ll2b_complete_tx_gsi_packet(p_hwfn, 383 383 p_ll2_conn->my_id, 384 384 p_pkt->cookie, ··· 550 550 551 551 list_move_tail(&p_pkt->list_entry, &p_rx->free_descq); 552 552 553 - if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) { 553 + if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO) { 554 554 struct qed_ooo_buffer *p_buffer; 555 555 556 556 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; ··· 738 738 rc = qed_ll2_prepare_tx_packet(p_hwfn, p_ll2_conn->my_id, 1, 739 739 p_buffer->vlan, bd_flags, 740 740 l4_hdr_offset_w, 741 - p_ll2_conn->tx_dest, 0, 741 + p_ll2_conn->conn.tx_dest, 0, 742 742 first_frag, 743 743 p_buffer->packet_length, 744 744 p_buffer, true); ··· 858 858 u16 buf_idx; 859 859 int rc = 0; 860 860 861 - if (p_ll2_info->conn_type != QED_LL2_TYPE_ISCSI_OOO) 861 + if (p_ll2_info->conn.conn_type != QED_LL2_TYPE_ISCSI_OOO) 862 862 return rc; 863 863 864 864 if (!rx_num_ooo_buffers) ··· 901 901 qed_ll2_establish_connection_ooo(struct qed_hwfn *p_hwfn, 902 902 struct qed_ll2_info *p_ll2_conn) 903 903 { 904 - if (p_ll2_conn->conn_type != QED_LL2_TYPE_ISCSI_OOO) 904 + if (p_ll2_conn->conn.conn_type != QED_LL2_TYPE_ISCSI_OOO) 905 905 return; 906 906 907 907 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); ··· 913 913 { 914 914 struct qed_ooo_buffer *p_buffer; 915 915 916 - if (p_ll2_conn->conn_type != QED_LL2_TYPE_ISCSI_OOO) 916 + if (p_ll2_conn->conn.conn_type != QED_LL2_TYPE_ISCSI_OOO) 917 917 return; 918 918 919 919 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); ··· 945 945 { 946 946 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); 947 947 u8 *handle = &hwfn->pf_params.iscsi_pf_params.ll2_ooo_queue_id; 948 - struct qed_ll2_info *ll2_info; 948 + struct qed_ll2_conn ll2_info; 949 949 int rc; 950 950 951 - ll2_info = kzalloc(sizeof(*ll2_info), GFP_KERNEL); 952 - if (!ll2_info) 953 - return -ENOMEM; 954 - ll2_info->conn_type = QED_LL2_TYPE_ISCSI_OOO; 955 - ll2_info->mtu = params->mtu; 956 - ll2_info->rx_drop_ttl0_flg = params->drop_ttl0_packets; 957 - ll2_info->rx_vlan_removal_en = params->rx_vlan_stripping; 958 - ll2_info->tx_tc = OOO_LB_TC; 959 - ll2_info->tx_dest = CORE_TX_DEST_LB; 951 + ll2_info.conn_type = QED_LL2_TYPE_ISCSI_OOO; 952 + ll2_info.mtu = params->mtu; 953 + ll2_info.rx_drop_ttl0_flg = params->drop_ttl0_packets; 954 + ll2_info.rx_vlan_removal_en = params->rx_vlan_stripping; 955 + ll2_info.tx_tc = OOO_LB_TC; 956 + ll2_info.tx_dest = CORE_TX_DEST_LB; 960 957 961 - rc = qed_ll2_acquire_connection(hwfn, ll2_info, 958 + rc = qed_ll2_acquire_connection(hwfn, &ll2_info, 962 959 QED_LL2_RX_SIZE, QED_LL2_TX_SIZE, 963 960 handle); 964 - kfree(ll2_info); 965 961 if (rc) { 966 962 DP_INFO(cdev, "Failed to acquire LL2 OOO connection\n"); 967 963 goto out; ··· 1002 1006 struct qed_ll2_info *p_ll2_conn, 1003 1007 u8 action_on_error) 1004 1008 { 1005 - enum qed_ll2_conn_type conn_type = p_ll2_conn->conn_type; 1009 + enum qed_ll2_conn_type conn_type = p_ll2_conn->conn.conn_type; 1006 1010 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; 1007 1011 struct core_rx_start_ramrod_data *p_ramrod = NULL; 1008 1012 struct qed_spq_entry *p_ent = NULL; ··· 1028 1032 p_ramrod->sb_index = p_rx->rx_sb_index; 1029 1033 p_ramrod->complete_event_flg = 1; 1030 1034 1031 - p_ramrod->mtu = cpu_to_le16(p_ll2_conn->mtu); 1035 + p_ramrod->mtu = cpu_to_le16(p_ll2_conn->conn.mtu); 1032 1036 DMA_REGPAIR_LE(p_ramrod->bd_base, 1033 1037 p_rx->rxq_chain.p_phys_addr); 1034 1038 cqe_pbl_size = (u16)qed_chain_get_page_cnt(&p_rx->rcq_chain); ··· 1036 1040 DMA_REGPAIR_LE(p_ramrod->cqe_pbl_addr, 1037 1041 qed_chain_get_pbl_phys(&p_rx->rcq_chain)); 1038 1042 1039 - p_ramrod->drop_ttl0_flg = p_ll2_conn->rx_drop_ttl0_flg; 1040 - p_ramrod->inner_vlan_removal_en = p_ll2_conn->rx_vlan_removal_en; 1043 + p_ramrod->drop_ttl0_flg = p_ll2_conn->conn.rx_drop_ttl0_flg; 1044 + p_ramrod->inner_vlan_removal_en = p_ll2_conn->conn.rx_vlan_removal_en; 1041 1045 p_ramrod->queue_id = p_ll2_conn->queue_id; 1042 1046 p_ramrod->main_func_queue = (conn_type == QED_LL2_TYPE_ISCSI_OOO) ? 0 1043 1047 : 1; ··· 1052 1056 } 1053 1057 1054 1058 p_ramrod->action_on_error.error_type = action_on_error; 1055 - p_ramrod->gsi_offload_flag = p_ll2_conn->gsi_enable; 1059 + p_ramrod->gsi_offload_flag = p_ll2_conn->conn.gsi_enable; 1056 1060 return qed_spq_post(p_hwfn, p_ent, NULL); 1057 1061 } 1058 1062 1059 1063 static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn, 1060 1064 struct qed_ll2_info *p_ll2_conn) 1061 1065 { 1062 - enum qed_ll2_conn_type conn_type = p_ll2_conn->conn_type; 1066 + enum qed_ll2_conn_type conn_type = p_ll2_conn->conn.conn_type; 1063 1067 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; 1064 1068 struct core_tx_start_ramrod_data *p_ramrod = NULL; 1065 1069 struct qed_spq_entry *p_ent = NULL; ··· 1071 1075 if (!QED_LL2_TX_REGISTERED(p_ll2_conn)) 1072 1076 return 0; 1073 1077 1074 - if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) 1078 + if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO) 1075 1079 p_ll2_conn->tx_stats_en = 0; 1076 1080 else 1077 1081 p_ll2_conn->tx_stats_en = 1; ··· 1092 1096 1093 1097 p_ramrod->sb_id = cpu_to_le16(qed_int_get_sp_sb_id(p_hwfn)); 1094 1098 p_ramrod->sb_index = p_tx->tx_sb_index; 1095 - p_ramrod->mtu = cpu_to_le16(p_ll2_conn->mtu); 1099 + p_ramrod->mtu = cpu_to_le16(p_ll2_conn->conn.mtu); 1096 1100 p_ramrod->stats_en = p_ll2_conn->tx_stats_en; 1097 1101 p_ramrod->stats_id = p_ll2_conn->tx_stats_id; 1098 1102 ··· 1102 1106 p_ramrod->pbl_size = cpu_to_le16(pbl_size); 1103 1107 1104 1108 memset(&pq_params, 0, sizeof(pq_params)); 1105 - pq_params.core.tc = p_ll2_conn->tx_tc; 1109 + pq_params.core.tc = p_ll2_conn->conn.tx_tc; 1106 1110 pq_id = qed_get_qm_pq(p_hwfn, PROTOCOLID_CORE, &pq_params); 1107 1111 p_ramrod->qm_pq_id = cpu_to_le16(pq_id); 1108 1112 ··· 1119 1123 DP_NOTICE(p_hwfn, "Unknown connection type: %d\n", conn_type); 1120 1124 } 1121 1125 1122 - p_ramrod->gsi_offload_flag = p_ll2_conn->gsi_enable; 1126 + p_ramrod->gsi_offload_flag = p_ll2_conn->conn.gsi_enable; 1123 1127 return qed_spq_post(p_hwfn, p_ent, NULL); 1124 1128 } 1125 1129 ··· 1220 1224 1221 1225 DP_VERBOSE(p_hwfn, QED_MSG_LL2, 1222 1226 "Allocated LL2 Rxq [Type %08x] with 0x%08x buffers\n", 1223 - p_ll2_info->conn_type, rx_num_desc); 1227 + p_ll2_info->conn.conn_type, rx_num_desc); 1224 1228 1225 1229 out: 1226 1230 return rc; ··· 1258 1262 1259 1263 DP_VERBOSE(p_hwfn, QED_MSG_LL2, 1260 1264 "Allocated LL2 Txq [Type %08x] with 0x%08x buffers\n", 1261 - p_ll2_info->conn_type, tx_num_desc); 1265 + p_ll2_info->conn.conn_type, tx_num_desc); 1262 1266 1263 1267 out: 1264 1268 if (rc) ··· 1269 1273 } 1270 1274 1271 1275 int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn, 1272 - struct qed_ll2_info *p_params, 1276 + struct qed_ll2_conn *p_params, 1273 1277 u16 rx_num_desc, 1274 1278 u16 tx_num_desc, 1275 1279 u8 *p_connection_handle) ··· 1298 1302 if (!p_ll2_info) 1299 1303 return -EBUSY; 1300 1304 1301 - p_ll2_info->conn_type = p_params->conn_type; 1302 - p_ll2_info->mtu = p_params->mtu; 1303 - p_ll2_info->rx_drop_ttl0_flg = p_params->rx_drop_ttl0_flg; 1304 - p_ll2_info->rx_vlan_removal_en = p_params->rx_vlan_removal_en; 1305 - p_ll2_info->tx_tc = p_params->tx_tc; 1306 - p_ll2_info->tx_dest = p_params->tx_dest; 1307 - p_ll2_info->ai_err_packet_too_big = p_params->ai_err_packet_too_big; 1308 - p_ll2_info->ai_err_no_buf = p_params->ai_err_no_buf; 1309 - p_ll2_info->gsi_enable = p_params->gsi_enable; 1305 + p_ll2_info->conn = *p_params; 1310 1306 1311 1307 rc = qed_ll2_acquire_connection_rx(p_hwfn, p_ll2_info, rx_num_desc); 1312 1308 if (rc) ··· 1359 1371 1360 1372 SET_FIELD(action_on_error, 1361 1373 CORE_RX_ACTION_ON_ERROR_PACKET_TOO_BIG, 1362 - p_ll2_conn->ai_err_packet_too_big); 1374 + p_ll2_conn->conn.ai_err_packet_too_big); 1363 1375 SET_FIELD(action_on_error, 1364 - CORE_RX_ACTION_ON_ERROR_NO_BUFF, p_ll2_conn->ai_err_no_buf); 1376 + CORE_RX_ACTION_ON_ERROR_NO_BUFF, p_ll2_conn->conn.ai_err_no_buf); 1365 1377 1366 1378 return qed_sp_ll2_rx_queue_start(p_hwfn, p_ll2_conn, action_on_error); 1367 1379 } ··· 1588 1600 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Tx Producer at [0x%04x] - set with a %04x bytes %02x BDs buffer at %08x:%08x\n", 1589 1601 p_ll2->queue_id, 1590 1602 p_ll2->cid, 1591 - p_ll2->conn_type, 1603 + p_ll2->conn.conn_type, 1592 1604 prod_idx, 1593 1605 first_frag_len, 1594 1606 num_of_bds, ··· 1664 1676 (NETIF_MSG_TX_QUEUED | QED_MSG_LL2), 1665 1677 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Doorbelled [producer 0x%04x]\n", 1666 1678 p_ll2_conn->queue_id, 1667 - p_ll2_conn->cid, p_ll2_conn->conn_type, db_msg.spq_prod); 1679 + p_ll2_conn->cid, p_ll2_conn->conn.conn_type, db_msg.spq_prod); 1668 1680 } 1669 1681 1670 1682 int qed_ll2_prepare_tx_packet(struct qed_hwfn *p_hwfn, ··· 1805 1817 qed_ll2_rxq_flush(p_hwfn, connection_handle); 1806 1818 } 1807 1819 1808 - if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) 1820 + if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO) 1809 1821 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); 1810 1822 1811 1823 return rc; ··· 1981 1993 1982 1994 static int qed_ll2_start(struct qed_dev *cdev, struct qed_ll2_params *params) 1983 1995 { 1984 - struct qed_ll2_info ll2_info; 1996 + struct qed_ll2_conn ll2_info; 1985 1997 struct qed_ll2_buffer *buffer, *tmp_buffer; 1986 1998 enum qed_ll2_conn_type conn_type; 1987 1999 struct qed_ptt *p_ptt; ··· 2029 2041 2030 2042 /* Prepare the temporary ll2 information */ 2031 2043 memset(&ll2_info, 0, sizeof(ll2_info)); 2044 + 2032 2045 ll2_info.conn_type = conn_type; 2033 2046 ll2_info.mtu = params->mtu; 2034 2047 ll2_info.rx_drop_ttl0_flg = params->drop_ttl0_packets; ··· 2109 2120 } 2110 2121 2111 2122 ether_addr_copy(cdev->ll2_mac_address, params->ll2_mac_address); 2112 - 2113 2123 return 0; 2114 2124 2115 2125 release_terminate_all:
+14 -10
drivers/net/ethernet/qlogic/qed/qed_ll2.h
··· 112 112 bool b_completing_packet; 113 113 }; 114 114 115 - struct qed_ll2_info { 116 - /* Lock protecting the state of LL2 */ 117 - struct mutex mutex; 115 + struct qed_ll2_conn { 118 116 enum qed_ll2_conn_type conn_type; 119 - u32 cid; 120 - u8 my_id; 121 - u8 queue_id; 122 - u8 tx_stats_id; 123 - bool b_active; 124 117 u16 mtu; 125 118 u8 rx_drop_ttl0_flg; 126 119 u8 rx_vlan_removal_en; ··· 121 128 enum core_tx_dest tx_dest; 122 129 enum core_error_handle ai_err_packet_too_big; 123 130 enum core_error_handle ai_err_no_buf; 131 + u8 gsi_enable; 132 + }; 133 + 134 + struct qed_ll2_info { 135 + /* Lock protecting the state of LL2 */ 136 + struct mutex mutex; 137 + struct qed_ll2_conn conn; 138 + u32 cid; 139 + u8 my_id; 140 + u8 queue_id; 141 + u8 tx_stats_id; 142 + bool b_active; 124 143 u8 tx_stats_en; 125 144 struct qed_ll2_rx_queue rx_queue; 126 145 struct qed_ll2_tx_queue tx_queue; 127 - u8 gsi_enable; 128 146 }; 129 147 130 148 /** ··· 153 149 * @return 0 on success, failure otherwise 154 150 */ 155 151 int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn, 156 - struct qed_ll2_info *p_params, 152 + struct qed_ll2_conn *p_params, 157 153 u16 rx_num_desc, 158 154 u16 tx_num_desc, 159 155 u8 *p_connection_handle);
+1 -1
drivers/net/ethernet/qlogic/qed/qed_roce.c
··· 2632 2632 { 2633 2633 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); 2634 2634 struct qed_roce_ll2_info *roce_ll2; 2635 - struct qed_ll2_info ll2_params; 2635 + struct qed_ll2_conn ll2_params; 2636 2636 int rc; 2637 2637 2638 2638 if (!params) {
+64 -48
drivers/net/ethernet/renesas/ravb_main.c
··· 179 179 .get_mdio_data = ravb_get_mdio_data, 180 180 }; 181 181 182 + /* Free TX skb function for AVB-IP */ 183 + static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only) 184 + { 185 + struct ravb_private *priv = netdev_priv(ndev); 186 + struct net_device_stats *stats = &priv->stats[q]; 187 + struct ravb_tx_desc *desc; 188 + int free_num = 0; 189 + int entry; 190 + u32 size; 191 + 192 + for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) { 193 + bool txed; 194 + 195 + entry = priv->dirty_tx[q] % (priv->num_tx_ring[q] * 196 + NUM_TX_DESC); 197 + desc = &priv->tx_ring[q][entry]; 198 + txed = desc->die_dt == DT_FEMPTY; 199 + if (free_txed_only && !txed) 200 + break; 201 + /* Descriptor type must be checked before all other reads */ 202 + dma_rmb(); 203 + size = le16_to_cpu(desc->ds_tagl) & TX_DS; 204 + /* Free the original skb. */ 205 + if (priv->tx_skb[q][entry / NUM_TX_DESC]) { 206 + dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr), 207 + size, DMA_TO_DEVICE); 208 + /* Last packet descriptor? */ 209 + if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) { 210 + entry /= NUM_TX_DESC; 211 + dev_kfree_skb_any(priv->tx_skb[q][entry]); 212 + priv->tx_skb[q][entry] = NULL; 213 + if (txed) 214 + stats->tx_packets++; 215 + } 216 + free_num++; 217 + } 218 + if (txed) 219 + stats->tx_bytes += size; 220 + desc->die_dt = DT_EEMPTY; 221 + } 222 + return free_num; 223 + } 224 + 182 225 /* Free skb's and DMA buffers for Ethernet AVB */ 183 226 static void ravb_ring_free(struct net_device *ndev, int q) 184 227 { ··· 237 194 kfree(priv->rx_skb[q]); 238 195 priv->rx_skb[q] = NULL; 239 196 240 - /* Free TX skb ringbuffer */ 241 - if (priv->tx_skb[q]) { 242 - for (i = 0; i < priv->num_tx_ring[q]; i++) 243 - dev_kfree_skb(priv->tx_skb[q][i]); 244 - } 245 - kfree(priv->tx_skb[q]); 246 - priv->tx_skb[q] = NULL; 247 - 248 197 /* Free aligned TX buffers */ 249 198 kfree(priv->tx_align[q]); 250 199 priv->tx_align[q] = NULL; 251 200 252 201 if (priv->rx_ring[q]) { 202 + for (i = 0; i < priv->num_rx_ring[q]; i++) { 203 + struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i]; 204 + 205 + if (!dma_mapping_error(ndev->dev.parent, 206 + le32_to_cpu(desc->dptr))) 207 + dma_unmap_single(ndev->dev.parent, 208 + le32_to_cpu(desc->dptr), 209 + PKT_BUF_SZ, 210 + DMA_FROM_DEVICE); 211 + } 253 212 ring_size = sizeof(struct ravb_ex_rx_desc) * 254 213 (priv->num_rx_ring[q] + 1); 255 214 dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q], ··· 260 215 } 261 216 262 217 if (priv->tx_ring[q]) { 218 + ravb_tx_free(ndev, q, false); 219 + 263 220 ring_size = sizeof(struct ravb_tx_desc) * 264 221 (priv->num_tx_ring[q] * NUM_TX_DESC + 1); 265 222 dma_free_coherent(ndev->dev.parent, ring_size, priv->tx_ring[q], 266 223 priv->tx_desc_dma[q]); 267 224 priv->tx_ring[q] = NULL; 268 225 } 226 + 227 + /* Free TX skb ringbuffer. 228 + * SKBs are freed by ravb_tx_free() call above. 229 + */ 230 + kfree(priv->tx_skb[q]); 231 + priv->tx_skb[q] = NULL; 269 232 } 270 233 271 234 /* Format skb and descriptor buffer for Ethernet AVB */ ··· 482 429 ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_OPERATION); 483 430 484 431 return 0; 485 - } 486 - 487 - /* Free TX skb function for AVB-IP */ 488 - static int ravb_tx_free(struct net_device *ndev, int q) 489 - { 490 - struct ravb_private *priv = netdev_priv(ndev); 491 - struct net_device_stats *stats = &priv->stats[q]; 492 - struct ravb_tx_desc *desc; 493 - int free_num = 0; 494 - int entry; 495 - u32 size; 496 - 497 - for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) { 498 - entry = priv->dirty_tx[q] % (priv->num_tx_ring[q] * 499 - NUM_TX_DESC); 500 - desc = &priv->tx_ring[q][entry]; 501 - if (desc->die_dt != DT_FEMPTY) 502 - break; 503 - /* Descriptor type must be checked before all other reads */ 504 - dma_rmb(); 505 - size = le16_to_cpu(desc->ds_tagl) & TX_DS; 506 - /* Free the original skb. */ 507 - if (priv->tx_skb[q][entry / NUM_TX_DESC]) { 508 - dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr), 509 - size, DMA_TO_DEVICE); 510 - /* Last packet descriptor? */ 511 - if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) { 512 - entry /= NUM_TX_DESC; 513 - dev_kfree_skb_any(priv->tx_skb[q][entry]); 514 - priv->tx_skb[q][entry] = NULL; 515 - stats->tx_packets++; 516 - } 517 - free_num++; 518 - } 519 - stats->tx_bytes += size; 520 - desc->die_dt = DT_EEMPTY; 521 - } 522 - return free_num; 523 432 } 524 433 525 434 static void ravb_get_tx_tstamp(struct net_device *ndev) ··· 917 902 spin_lock_irqsave(&priv->lock, flags); 918 903 /* Clear TX interrupt */ 919 904 ravb_write(ndev, ~mask, TIS); 920 - ravb_tx_free(ndev, q); 905 + ravb_tx_free(ndev, q, true); 921 906 netif_wake_subqueue(ndev, q); 922 907 mmiowb(); 923 908 spin_unlock_irqrestore(&priv->lock, flags); ··· 1582 1567 1583 1568 priv->cur_tx[q] += NUM_TX_DESC; 1584 1569 if (priv->cur_tx[q] - priv->dirty_tx[q] > 1585 - (priv->num_tx_ring[q] - 1) * NUM_TX_DESC && !ravb_tx_free(ndev, q)) 1570 + (priv->num_tx_ring[q] - 1) * NUM_TX_DESC && 1571 + !ravb_tx_free(ndev, q, true)) 1586 1572 netif_stop_subqueue(ndev, q); 1587 1573 1588 1574 exit:
+1
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 351 351 if (of_phy_is_fixed_link(np)) 352 352 of_phy_deregister_fixed_link(np); 353 353 of_node_put(plat->phy_node); 354 + of_node_put(plat->mdio_node); 354 355 } 355 356 #else 356 357 struct plat_stmmacenet_data *
+6 -7
drivers/net/gtp.c
··· 69 69 struct socket *sock0; 70 70 struct socket *sock1u; 71 71 72 - struct net *net; 73 72 struct net_device *dev; 74 73 75 74 unsigned int hash_size; ··· 315 316 316 317 netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk); 317 318 318 - xnet = !net_eq(gtp->net, dev_net(gtp->dev)); 319 + xnet = !net_eq(sock_net(sk), dev_net(gtp->dev)); 319 320 320 321 switch (udp_sk(sk)->encap_type) { 321 322 case UDP_ENCAP_GTP0: ··· 611 612 pktinfo.fl4.saddr, pktinfo.fl4.daddr, 612 613 pktinfo.iph->tos, 613 614 ip4_dst_hoplimit(&pktinfo.rt->dst), 614 - htons(IP_DF), 615 + 0, 615 616 pktinfo.gtph_port, pktinfo.gtph_port, 616 617 true, false); 617 618 break; ··· 657 658 static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize); 658 659 static void gtp_hashtable_free(struct gtp_dev *gtp); 659 660 static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp, 660 - int fd_gtp0, int fd_gtp1, struct net *src_net); 661 + int fd_gtp0, int fd_gtp1); 661 662 662 663 static int gtp_newlink(struct net *src_net, struct net_device *dev, 663 664 struct nlattr *tb[], struct nlattr *data[]) ··· 674 675 fd0 = nla_get_u32(data[IFLA_GTP_FD0]); 675 676 fd1 = nla_get_u32(data[IFLA_GTP_FD1]); 676 677 677 - err = gtp_encap_enable(dev, gtp, fd0, fd1, src_net); 678 + err = gtp_encap_enable(dev, gtp, fd0, fd1); 678 679 if (err < 0) 679 680 goto out_err; 680 681 ··· 820 821 } 821 822 822 823 static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp, 823 - int fd_gtp0, int fd_gtp1, struct net *src_net) 824 + int fd_gtp0, int fd_gtp1) 824 825 { 825 826 struct udp_tunnel_sock_cfg tuncfg = {NULL}; 826 827 struct socket *sock0, *sock1u; ··· 857 858 858 859 gtp->sock0 = sock0; 859 860 gtp->sock1u = sock1u; 860 - gtp->net = src_net; 861 861 862 862 tuncfg.sk_user_data = gtp; 863 863 tuncfg.encap_rcv = gtp_encap_recv; ··· 1374 1376 MODULE_AUTHOR("Harald Welte <hwelte@sysmocom.de>"); 1375 1377 MODULE_DESCRIPTION("Interface driver for GTP encapsulated traffic"); 1376 1378 MODULE_ALIAS_RTNL_LINK("gtp"); 1379 + MODULE_ALIAS_GENL_FAMILY("gtp");
+1 -1
drivers/net/macvtap.c
··· 825 825 return -EINVAL; 826 826 827 827 if (virtio_net_hdr_from_skb(skb, &vnet_hdr, 828 - macvtap_is_little_endian(q))) 828 + macvtap_is_little_endian(q), true)) 829 829 BUG(); 830 830 831 831 if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) !=
+19 -2
drivers/net/phy/bcm63xx.c
··· 21 21 MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); 22 22 MODULE_LICENSE("GPL"); 23 23 24 + static int bcm63xx_config_intr(struct phy_device *phydev) 25 + { 26 + int reg, err; 27 + 28 + reg = phy_read(phydev, MII_BCM63XX_IR); 29 + if (reg < 0) 30 + return reg; 31 + 32 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) 33 + reg &= ~MII_BCM63XX_IR_GMASK; 34 + else 35 + reg |= MII_BCM63XX_IR_GMASK; 36 + 37 + err = phy_write(phydev, MII_BCM63XX_IR, reg); 38 + return err; 39 + } 40 + 24 41 static int bcm63xx_config_init(struct phy_device *phydev) 25 42 { 26 43 int reg, err; ··· 72 55 .config_aneg = genphy_config_aneg, 73 56 .read_status = genphy_read_status, 74 57 .ack_interrupt = bcm_phy_ack_intr, 75 - .config_intr = bcm_phy_config_intr, 58 + .config_intr = bcm63xx_config_intr, 76 59 }, { 77 60 /* same phy as above, with just a different OUI */ 78 61 .phy_id = 0x002bdc00, ··· 84 67 .config_aneg = genphy_config_aneg, 85 68 .read_status = genphy_read_status, 86 69 .ack_interrupt = bcm_phy_ack_intr, 87 - .config_intr = bcm_phy_config_intr, 70 + .config_intr = bcm63xx_config_intr, 88 71 } }; 89 72 90 73 module_phy_driver(bcm63xx_driver);
+3
drivers/net/phy/dp83848.c
··· 17 17 #include <linux/phy.h> 18 18 19 19 #define TI_DP83848C_PHY_ID 0x20005ca0 20 + #define TI_DP83620_PHY_ID 0x20005ce0 20 21 #define NS_DP83848C_PHY_ID 0x20005c90 21 22 #define TLK10X_PHY_ID 0x2000a210 22 23 #define TI_DP83822_PHY_ID 0x2000a240 ··· 78 77 static struct mdio_device_id __maybe_unused dp83848_tbl[] = { 79 78 { TI_DP83848C_PHY_ID, 0xfffffff0 }, 80 79 { NS_DP83848C_PHY_ID, 0xfffffff0 }, 80 + { TI_DP83620_PHY_ID, 0xfffffff0 }, 81 81 { TLK10X_PHY_ID, 0xfffffff0 }, 82 82 { TI_DP83822_PHY_ID, 0xfffffff0 }, 83 83 { } ··· 108 106 static struct phy_driver dp83848_driver[] = { 109 107 DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"), 110 108 DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"), 109 + DP83848_PHY_DRIVER(TI_DP83620_PHY_ID, "TI DP83620 10/100 Mbps PHY"), 111 110 DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"), 112 111 DP83848_PHY_DRIVER(TI_DP83822_PHY_ID, "TI DP83822 10/100 Mbps PHY"), 113 112 };
+2
drivers/net/phy/marvell.c
··· 1679 1679 .ack_interrupt = &marvell_ack_interrupt, 1680 1680 .config_intr = &marvell_config_intr, 1681 1681 .did_interrupt = &m88e1121_did_interrupt, 1682 + .get_wol = &m88e1318_get_wol, 1683 + .set_wol = &m88e1318_set_wol, 1682 1684 .resume = &marvell_resume, 1683 1685 .suspend = &marvell_suspend, 1684 1686 .get_sset_count = marvell_get_sset_count,
+14
drivers/net/phy/micrel.c
··· 1008 1008 .get_stats = kszphy_get_stats, 1009 1009 .suspend = genphy_suspend, 1010 1010 .resume = genphy_resume, 1011 + }, { 1012 + .phy_id = PHY_ID_KSZ8795, 1013 + .phy_id_mask = MICREL_PHY_ID_MASK, 1014 + .name = "Micrel KSZ8795", 1015 + .features = (SUPPORTED_Pause | SUPPORTED_Asym_Pause), 1016 + .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 1017 + .config_init = kszphy_config_init, 1018 + .config_aneg = ksz8873mll_config_aneg, 1019 + .read_status = ksz8873mll_read_status, 1020 + .get_sset_count = kszphy_get_sset_count, 1021 + .get_strings = kszphy_get_strings, 1022 + .get_stats = kszphy_get_stats, 1023 + .suspend = genphy_suspend, 1024 + .resume = genphy_resume, 1011 1025 } }; 1012 1026 1013 1027 module_phy_driver(ksphy_driver);
+10 -5
drivers/net/phy/phy.c
··· 29 29 #include <linux/mii.h> 30 30 #include <linux/ethtool.h> 31 31 #include <linux/phy.h> 32 + #include <linux/phy_led_triggers.h> 32 33 #include <linux/timer.h> 33 34 #include <linux/workqueue.h> 34 35 #include <linux/mdio.h> ··· 650 649 * phy_trigger_machine - trigger the state machine to run 651 650 * 652 651 * @phydev: the phy_device struct 652 + * @sync: indicate whether we should wait for the workqueue cancelation 653 653 * 654 654 * Description: There has been a change in state which requires that the 655 655 * state machine runs. 656 656 */ 657 657 658 - static void phy_trigger_machine(struct phy_device *phydev) 658 + static void phy_trigger_machine(struct phy_device *phydev, bool sync) 659 659 { 660 - cancel_delayed_work_sync(&phydev->state_queue); 660 + if (sync) 661 + cancel_delayed_work_sync(&phydev->state_queue); 662 + else 663 + cancel_delayed_work(&phydev->state_queue); 661 664 queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0); 662 665 } 663 666 ··· 698 693 phydev->state = PHY_HALTED; 699 694 mutex_unlock(&phydev->lock); 700 695 701 - phy_trigger_machine(phydev); 696 + phy_trigger_machine(phydev, false); 702 697 } 703 698 704 699 /** ··· 845 840 } 846 841 847 842 /* reschedule state queue work to run as soon as possible */ 848 - phy_trigger_machine(phydev); 843 + phy_trigger_machine(phydev, true); 849 844 return; 850 845 851 846 ignore: ··· 947 942 if (do_resume) 948 943 phy_resume(phydev); 949 944 950 - phy_trigger_machine(phydev); 945 + phy_trigger_machine(phydev, true); 951 946 } 952 947 EXPORT_SYMBOL(phy_start); 953 948
+7 -2
drivers/net/phy/phy_led_triggers.c
··· 12 12 */ 13 13 #include <linux/leds.h> 14 14 #include <linux/phy.h> 15 + #include <linux/phy_led_triggers.h> 15 16 #include <linux/netdevice.h> 16 17 17 18 static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy, ··· 103 102 sizeof(struct phy_led_trigger) * 104 103 phy->phy_num_led_triggers, 105 104 GFP_KERNEL); 106 - if (!phy->phy_led_triggers) 107 - return -ENOMEM; 105 + if (!phy->phy_led_triggers) { 106 + err = -ENOMEM; 107 + goto out_clear; 108 + } 108 109 109 110 for (i = 0; i < phy->phy_num_led_triggers; i++) { 110 111 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], ··· 123 120 while (i--) 124 121 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); 125 122 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); 123 + out_clear: 124 + phy->phy_num_led_triggers = 0; 126 125 return err; 127 126 } 128 127 EXPORT_SYMBOL_GPL(phy_led_triggers_register);
+1 -1
drivers/net/tun.c
··· 1360 1360 return -EINVAL; 1361 1361 1362 1362 if (virtio_net_hdr_from_skb(skb, &gso, 1363 - tun_is_little_endian(tun))) { 1363 + tun_is_little_endian(tun), true)) { 1364 1364 struct skb_shared_info *sinfo = skb_shinfo(skb); 1365 1365 pr_err("unexpected GSO type: " 1366 1366 "0x%x, gso_size %d, hdr_len %d\n",
+8
drivers/net/usb/cdc_ether.c
··· 531 531 #define SAMSUNG_VENDOR_ID 0x04e8 532 532 #define LENOVO_VENDOR_ID 0x17ef 533 533 #define NVIDIA_VENDOR_ID 0x0955 534 + #define HP_VENDOR_ID 0x03f0 534 535 535 536 static const struct usb_device_id products[] = { 536 537 /* BLACKLIST !! ··· 675 674 { 676 675 USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0x9011, USB_CLASS_COMM, 677 676 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 677 + .driver_info = 0, 678 + }, 679 + 680 + /* HP lt2523 (Novatel E371) - handled by qmi_wwan */ 681 + { 682 + USB_DEVICE_AND_INTERFACE_INFO(HP_VENDOR_ID, 0x421d, USB_CLASS_COMM, 683 + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 678 684 .driver_info = 0, 679 685 }, 680 686
+7
drivers/net/usb/qmi_wwan.c
··· 654 654 USB_CDC_PROTO_NONE), 655 655 .driver_info = (unsigned long)&qmi_wwan_info, 656 656 }, 657 + { /* HP lt2523 (Novatel E371) */ 658 + USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d, 659 + USB_CLASS_COMM, 660 + USB_CDC_SUBCLASS_ETHERNET, 661 + USB_CDC_PROTO_NONE), 662 + .driver_info = (unsigned long)&qmi_wwan_info, 663 + }, 657 664 { /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */ 658 665 USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), 659 666 .driver_info = (unsigned long)&qmi_wwan_info,
+28 -6
drivers/net/usb/r8152.c
··· 32 32 #define NETNEXT_VERSION "08" 33 33 34 34 /* Information for net */ 35 - #define NET_VERSION "6" 35 + #define NET_VERSION "8" 36 36 37 37 #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION 38 38 #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" ··· 1936 1936 napi_complete(napi); 1937 1937 if (!list_empty(&tp->rx_done)) 1938 1938 napi_schedule(napi); 1939 + else if (!skb_queue_empty(&tp->tx_queue) && 1940 + !list_empty(&tp->tx_free)) 1941 + napi_schedule(napi); 1939 1942 } 1940 1943 1941 1944 return work_done; ··· 3158 3155 if (!netif_carrier_ok(netdev)) { 3159 3156 tp->rtl_ops.enable(tp); 3160 3157 set_bit(RTL8152_SET_RX_MODE, &tp->flags); 3158 + netif_stop_queue(netdev); 3161 3159 napi_disable(&tp->napi); 3162 3160 netif_carrier_on(netdev); 3163 3161 rtl_start_rx(tp); 3164 3162 napi_enable(&tp->napi); 3163 + netif_wake_queue(netdev); 3164 + netif_info(tp, link, netdev, "carrier on\n"); 3165 3165 } 3166 3166 } else { 3167 3167 if (netif_carrier_ok(netdev)) { ··· 3172 3166 napi_disable(&tp->napi); 3173 3167 tp->rtl_ops.disable(tp); 3174 3168 napi_enable(&tp->napi); 3169 + netif_info(tp, link, netdev, "carrier off\n"); 3175 3170 } 3176 3171 } 3177 3172 } ··· 3522 3515 if (!netif_running(netdev)) 3523 3516 return 0; 3524 3517 3518 + netif_stop_queue(netdev); 3525 3519 napi_disable(&tp->napi); 3526 3520 clear_bit(WORK_ENABLE, &tp->flags); 3527 3521 usb_kill_urb(tp->intr_urb); 3528 3522 cancel_delayed_work_sync(&tp->schedule); 3529 3523 if (netif_carrier_ok(netdev)) { 3530 - netif_stop_queue(netdev); 3531 3524 mutex_lock(&tp->control); 3532 3525 tp->rtl_ops.disable(tp); 3533 3526 mutex_unlock(&tp->control); ··· 3552 3545 if (netif_carrier_ok(netdev)) { 3553 3546 mutex_lock(&tp->control); 3554 3547 tp->rtl_ops.enable(tp); 3548 + rtl_start_rx(tp); 3555 3549 rtl8152_set_rx_mode(netdev); 3556 3550 mutex_unlock(&tp->control); 3557 - netif_wake_queue(netdev); 3558 3551 } 3559 3552 3560 3553 napi_enable(&tp->napi); 3554 + netif_wake_queue(netdev); 3555 + usb_submit_urb(tp->intr_urb, GFP_KERNEL); 3556 + 3557 + if (!list_empty(&tp->rx_done)) 3558 + napi_schedule(&tp->napi); 3561 3559 3562 3560 return 0; 3563 3561 } ··· 3584 3572 */ 3585 3573 if (!sw_linking && tp->rtl_ops.in_nway(tp)) 3586 3574 return true; 3575 + else if (!skb_queue_empty(&tp->tx_queue)) 3576 + return true; 3587 3577 else 3588 3578 return false; 3589 3579 } ··· 3595 3581 struct net_device *netdev = tp->netdev; 3596 3582 int ret = 0; 3597 3583 3584 + set_bit(SELECTIVE_SUSPEND, &tp->flags); 3585 + smp_mb__after_atomic(); 3586 + 3598 3587 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { 3599 3588 u32 rcr = 0; 3600 3589 3601 3590 if (delay_autosuspend(tp)) { 3591 + clear_bit(SELECTIVE_SUSPEND, &tp->flags); 3592 + smp_mb__after_atomic(); 3602 3593 ret = -EBUSY; 3603 3594 goto out1; 3604 3595 } ··· 3620 3601 if (!(ocp_data & RXFIFO_EMPTY)) { 3621 3602 rxdy_gated_en(tp, false); 3622 3603 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr); 3604 + clear_bit(SELECTIVE_SUSPEND, &tp->flags); 3605 + smp_mb__after_atomic(); 3623 3606 ret = -EBUSY; 3624 3607 goto out1; 3625 3608 } ··· 3640 3619 napi_enable(&tp->napi); 3641 3620 } 3642 3621 } 3643 - 3644 - set_bit(SELECTIVE_SUSPEND, &tp->flags); 3645 3622 3646 3623 out1: 3647 3624 return ret; ··· 3696 3677 if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) { 3697 3678 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3698 3679 tp->rtl_ops.autosuspend_en(tp, false); 3699 - clear_bit(SELECTIVE_SUSPEND, &tp->flags); 3700 3680 napi_disable(&tp->napi); 3701 3681 set_bit(WORK_ENABLE, &tp->flags); 3702 3682 if (netif_carrier_ok(tp->netdev)) 3703 3683 rtl_start_rx(tp); 3704 3684 napi_enable(&tp->napi); 3685 + clear_bit(SELECTIVE_SUSPEND, &tp->flags); 3686 + smp_mb__after_atomic(); 3687 + if (!list_empty(&tp->rx_done)) 3688 + napi_schedule(&tp->napi); 3705 3689 } else { 3706 3690 tp->rtl_ops.up(tp); 3707 3691 netif_carrier_off(tp->netdev);
+21 -4
drivers/net/virtio_net.c
··· 48 48 */ 49 49 DECLARE_EWMA(pkt_len, 1, 64) 50 50 51 + /* With mergeable buffers we align buffer address and use the low bits to 52 + * encode its true size. Buffer size is up to 1 page so we need to align to 53 + * square root of page size to ensure we reserve enough bits to encode the true 54 + * size. 55 + */ 56 + #define MERGEABLE_BUFFER_MIN_ALIGN_SHIFT ((PAGE_SHIFT + 1) / 2) 57 + 51 58 /* Minimum alignment for mergeable packet buffers. */ 52 - #define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256) 59 + #define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, \ 60 + 1 << MERGEABLE_BUFFER_MIN_ALIGN_SHIFT) 53 61 54 62 #define VIRTNET_DRIVER_VERSION "1.0.0" 55 63 ··· 1112 1104 hdr = skb_vnet_hdr(skb); 1113 1105 1114 1106 if (virtio_net_hdr_from_skb(skb, &hdr->hdr, 1115 - virtio_is_little_endian(vi->vdev))) 1107 + virtio_is_little_endian(vi->vdev), false)) 1116 1108 BUG(); 1117 1109 1118 1110 if (vi->mergeable_rx_bufs) ··· 1715 1707 u16 xdp_qp = 0, curr_qp; 1716 1708 int i, err; 1717 1709 1710 + if (prog && prog->xdp_adjust_head) { 1711 + netdev_warn(dev, "Does not support bpf_xdp_adjust_head()\n"); 1712 + return -EOPNOTSUPP; 1713 + } 1714 + 1718 1715 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) || 1719 1716 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || 1720 1717 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || ··· 1903 1890 put_page(vi->rq[i].alloc_frag.page); 1904 1891 } 1905 1892 1906 - static bool is_xdp_queue(struct virtnet_info *vi, int q) 1893 + static bool is_xdp_raw_buffer_queue(struct virtnet_info *vi, int q) 1907 1894 { 1895 + /* For small receive mode always use kfree_skb variants */ 1896 + if (!vi->mergeable_rx_bufs) 1897 + return false; 1898 + 1908 1899 if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) 1909 1900 return false; 1910 1901 else if (q < vi->curr_queue_pairs) ··· 1925 1908 for (i = 0; i < vi->max_queue_pairs; i++) { 1926 1909 struct virtqueue *vq = vi->sq[i].vq; 1927 1910 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { 1928 - if (!is_xdp_queue(vi, i)) 1911 + if (!is_xdp_raw_buffer_queue(vi, i)) 1929 1912 dev_kfree_skb(buf); 1930 1913 else 1931 1914 put_page(virt_to_head_page(buf));
+8 -4
drivers/net/vxlan.c
··· 2268 2268 = container_of(p, struct vxlan_fdb, hlist); 2269 2269 unsigned long timeout; 2270 2270 2271 - if (f->state & NUD_PERMANENT) 2271 + if (f->state & (NUD_PERMANENT | NUD_NOARP)) 2272 2272 continue; 2273 2273 2274 2274 timeout = f->used + vxlan->cfg.age_interval * HZ; ··· 2354 2354 } 2355 2355 2356 2356 /* Purge the forwarding table */ 2357 - static void vxlan_flush(struct vxlan_dev *vxlan) 2357 + static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) 2358 2358 { 2359 2359 unsigned int h; 2360 2360 ··· 2364 2364 hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) { 2365 2365 struct vxlan_fdb *f 2366 2366 = container_of(p, struct vxlan_fdb, hlist); 2367 + if (!do_all && (f->state & (NUD_PERMANENT | NUD_NOARP))) 2368 + continue; 2367 2369 /* the all_zeros_mac entry is deleted at vxlan_uninit */ 2368 2370 if (!is_zero_ether_addr(f->eth_addr)) 2369 2371 vxlan_fdb_destroy(vxlan, f); ··· 2387 2385 2388 2386 del_timer_sync(&vxlan->age_timer); 2389 2387 2390 - vxlan_flush(vxlan); 2388 + vxlan_flush(vxlan, false); 2391 2389 vxlan_sock_release(vxlan); 2392 2390 2393 2391 return ret; ··· 2892 2890 memcpy(&vxlan->cfg, conf, sizeof(*conf)); 2893 2891 if (!vxlan->cfg.dst_port) { 2894 2892 if (conf->flags & VXLAN_F_GPE) 2895 - vxlan->cfg.dst_port = 4790; /* IANA assigned VXLAN-GPE port */ 2893 + vxlan->cfg.dst_port = htons(4790); /* IANA VXLAN-GPE port */ 2896 2894 else 2897 2895 vxlan->cfg.dst_port = default_port; 2898 2896 } ··· 3059 3057 { 3060 3058 struct vxlan_dev *vxlan = netdev_priv(dev); 3061 3059 struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 3060 + 3061 + vxlan_flush(vxlan, true); 3062 3062 3063 3063 spin_lock(&vn->sock_lock); 3064 3064 if (!hlist_unhashed(&vxlan->hlist))
+4 -2
drivers/net/xen-netback/interface.c
··· 221 221 { 222 222 struct xenvif *vif = netdev_priv(dev); 223 223 struct xenvif_queue *queue = NULL; 224 - unsigned int num_queues = vif->num_queues; 225 224 unsigned long rx_bytes = 0; 226 225 unsigned long rx_packets = 0; 227 226 unsigned long tx_bytes = 0; 228 227 unsigned long tx_packets = 0; 229 228 unsigned int index; 230 229 230 + spin_lock(&vif->lock); 231 231 if (vif->queues == NULL) 232 232 goto out; 233 233 234 234 /* Aggregate tx and rx stats from each queue */ 235 - for (index = 0; index < num_queues; ++index) { 235 + for (index = 0; index < vif->num_queues; ++index) { 236 236 queue = &vif->queues[index]; 237 237 rx_bytes += queue->stats.rx_bytes; 238 238 rx_packets += queue->stats.rx_packets; ··· 241 241 } 242 242 243 243 out: 244 + spin_unlock(&vif->lock); 245 + 244 246 vif->dev->stats.rx_bytes = rx_bytes; 245 247 vif->dev->stats.rx_packets = rx_packets; 246 248 vif->dev->stats.tx_bytes = tx_bytes;
+13
drivers/net/xen-netback/xenbus.c
··· 493 493 static void backend_disconnect(struct backend_info *be) 494 494 { 495 495 if (be->vif) { 496 + unsigned int queue_index; 497 + 496 498 xen_unregister_watchers(be->vif); 497 499 #ifdef CONFIG_DEBUG_FS 498 500 xenvif_debugfs_delif(be->vif); 499 501 #endif /* CONFIG_DEBUG_FS */ 500 502 xenvif_disconnect_data(be->vif); 503 + for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index) 504 + xenvif_deinit_queue(&be->vif->queues[queue_index]); 505 + 506 + spin_lock(&be->vif->lock); 507 + vfree(be->vif->queues); 508 + be->vif->num_queues = 0; 509 + be->vif->queues = NULL; 510 + spin_unlock(&be->vif->lock); 511 + 501 512 xenvif_disconnect_ctrl(be->vif); 502 513 } 503 514 } ··· 1045 1034 err: 1046 1035 if (be->vif->num_queues > 0) 1047 1036 xenvif_disconnect_data(be->vif); /* Clean up existing queues */ 1037 + for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index) 1038 + xenvif_deinit_queue(&be->vif->queues[queue_index]); 1048 1039 vfree(be->vif->queues); 1049 1040 be->vif->queues = NULL; 1050 1041 be->vif->num_queues = 0;
+1 -1
drivers/net/xen-netfront.c
··· 321 321 queue->rx.req_prod_pvt = req_prod; 322 322 323 323 /* Not enough requests? Try again later. */ 324 - if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN) { 324 + if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) { 325 325 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10)); 326 326 return; 327 327 }
+2
include/linux/bpf.h
··· 247 247 void bpf_map_put_with_uref(struct bpf_map *map); 248 248 void bpf_map_put(struct bpf_map *map); 249 249 int bpf_map_precharge_memlock(u32 pages); 250 + void *bpf_map_area_alloc(size_t size); 251 + void bpf_map_area_free(void *base); 250 252 251 253 extern int sysctl_unprivileged_bpf_disabled; 252 254
+2
include/linux/micrel_phy.h
··· 35 35 #define PHY_ID_KSZ886X 0x00221430 36 36 #define PHY_ID_KSZ8863 0x00221435 37 37 38 + #define PHY_ID_KSZ8795 0x00221550 39 + 38 40 /* struct phy_device dev_flags definitions */ 39 41 #define MICREL_PHY_50MHZ_CLK 0x00000001 40 42 #define MICREL_PHY_FXEN 0x00000002
-1
include/linux/phy.h
··· 25 25 #include <linux/timer.h> 26 26 #include <linux/workqueue.h> 27 27 #include <linux/mod_devicetable.h> 28 - #include <linux/phy_led_triggers.h> 29 28 30 29 #include <linux/atomic.h> 31 30
+2 -2
include/linux/phy_led_triggers.h
··· 18 18 #ifdef CONFIG_LED_TRIGGER_PHY 19 19 20 20 #include <linux/leds.h> 21 + #include <linux/phy.h> 21 22 22 23 #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10 23 - #define PHY_MII_BUS_ID_SIZE (20 - 3) 24 24 25 - #define PHY_LINK_LED_TRIGGER_NAME_SIZE (PHY_MII_BUS_ID_SIZE + \ 25 + #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ 26 26 FIELD_SIZEOF(struct mdio_device, addr)+\ 27 27 PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE) 28 28
+4 -2
include/linux/virtio_net.h
··· 56 56 57 57 static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb, 58 58 struct virtio_net_hdr *hdr, 59 - bool little_endian) 59 + bool little_endian, 60 + bool has_data_valid) 60 61 { 61 62 memset(hdr, 0, sizeof(*hdr)); /* no info leak */ 62 63 ··· 92 91 skb_checksum_start_offset(skb)); 93 92 hdr->csum_offset = __cpu_to_virtio16(little_endian, 94 93 skb->csum_offset); 95 - } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 94 + } else if (has_data_valid && 95 + skb->ip_summed == CHECKSUM_UNNECESSARY) { 96 96 hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID; 97 97 } /* else everything is zero */ 98 98
+1 -1
include/net/ipv6.h
··· 871 871 * upper-layer output functions 872 872 */ 873 873 int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, 874 - struct ipv6_txoptions *opt, int tclass); 874 + __u32 mark, struct ipv6_txoptions *opt, int tclass); 875 875 876 876 int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr); 877 877
+13
include/net/lwtunnel.h
··· 44 44 int (*get_encap_size)(struct lwtunnel_state *lwtstate); 45 45 int (*cmp_encap)(struct lwtunnel_state *a, struct lwtunnel_state *b); 46 46 int (*xmit)(struct sk_buff *skb); 47 + 48 + struct module *owner; 47 49 }; 48 50 49 51 #ifdef CONFIG_LWTUNNEL ··· 107 105 unsigned int num); 108 106 int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op, 109 107 unsigned int num); 108 + int lwtunnel_valid_encap_type(u16 encap_type); 109 + int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len); 110 110 int lwtunnel_build_state(struct net_device *dev, u16 encap_type, 111 111 struct nlattr *encap, 112 112 unsigned int family, const void *cfg, ··· 168 164 169 165 static inline int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op, 170 166 unsigned int num) 167 + { 168 + return -EOPNOTSUPP; 169 + } 170 + 171 + static inline int lwtunnel_valid_encap_type(u16 encap_type) 172 + { 173 + return -EOPNOTSUPP; 174 + } 175 + static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len) 171 176 { 172 177 return -EOPNOTSUPP; 173 178 }
+3 -3
include/net/netfilter/nf_tables.h
··· 207 207 unsigned int skip; 208 208 int err; 209 209 int (*fn)(const struct nft_ctx *ctx, 210 - const struct nft_set *set, 210 + struct nft_set *set, 211 211 const struct nft_set_iter *iter, 212 - const struct nft_set_elem *elem); 212 + struct nft_set_elem *elem); 213 213 }; 214 214 215 215 /** ··· 301 301 void (*remove)(const struct nft_set *set, 302 302 const struct nft_set_elem *elem); 303 303 void (*walk)(const struct nft_ctx *ctx, 304 - const struct nft_set *set, 304 + struct nft_set *set, 305 305 struct nft_set_iter *iter); 306 306 307 307 unsigned int (*privsize)(const struct nlattr * const nla[]);
+6
include/net/netfilter/nft_fib.h
··· 9 9 10 10 extern const struct nla_policy nft_fib_policy[]; 11 11 12 + static inline bool 13 + nft_fib_is_loopback(const struct sk_buff *skb, const struct net_device *in) 14 + { 15 + return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK; 16 + } 17 + 12 18 int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr); 13 19 int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr, 14 20 const struct nlattr * const tb[]);
+2
include/uapi/linux/netfilter/nf_log.h
··· 9 9 #define NF_LOG_MACDECODE 0x20 /* Decode MAC header */ 10 10 #define NF_LOG_MASK 0x2f 11 11 12 + #define NF_LOG_PREFIXLEN 128 13 + 12 14 #endif /* _NETFILTER_NF_LOG_H */
+2 -2
include/uapi/linux/netfilter/nf_tables.h
··· 235 235 /** 236 236 * enum nft_rule_compat_attributes - nf_tables rule compat attributes 237 237 * 238 - * @NFTA_RULE_COMPAT_PROTO: numerice value of handled protocol (NLA_U32) 238 + * @NFTA_RULE_COMPAT_PROTO: numeric value of handled protocol (NLA_U32) 239 239 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32) 240 240 */ 241 241 enum nft_rule_compat_attributes { ··· 499 499 * enum nft_byteorder_ops - nf_tables byteorder operators 500 500 * 501 501 * @NFT_BYTEORDER_NTOH: network to host operator 502 - * @NFT_BYTEORDER_HTON: host to network opertaor 502 + * @NFT_BYTEORDER_HTON: host to network operator 503 503 */ 504 504 enum nft_byteorder_ops { 505 505 NFT_BYTEORDER_NTOH,
+7 -11
kernel/bpf/arraymap.c
··· 11 11 */ 12 12 #include <linux/bpf.h> 13 13 #include <linux/err.h> 14 - #include <linux/vmalloc.h> 15 14 #include <linux/slab.h> 16 15 #include <linux/mm.h> 17 16 #include <linux/filter.h> ··· 73 74 if (array_size >= U32_MAX - PAGE_SIZE) 74 75 return ERR_PTR(-ENOMEM); 75 76 76 - 77 77 /* allocate all map elements and zero-initialize them */ 78 - array = kzalloc(array_size, GFP_USER | __GFP_NOWARN); 79 - if (!array) { 80 - array = vzalloc(array_size); 81 - if (!array) 82 - return ERR_PTR(-ENOMEM); 83 - } 78 + array = bpf_map_area_alloc(array_size); 79 + if (!array) 80 + return ERR_PTR(-ENOMEM); 84 81 85 82 /* copy mandatory map attributes */ 86 83 array->map.map_type = attr->map_type; ··· 92 97 93 98 if (array_size >= U32_MAX - PAGE_SIZE || 94 99 elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) { 95 - kvfree(array); 100 + bpf_map_area_free(array); 96 101 return ERR_PTR(-ENOMEM); 97 102 } 98 103 out: ··· 257 262 if (array->map.map_type == BPF_MAP_TYPE_PERCPU_ARRAY) 258 263 bpf_array_free_percpu(array); 259 264 260 - kvfree(array); 265 + bpf_map_area_free(array); 261 266 } 262 267 263 268 static const struct bpf_map_ops array_ops = { ··· 314 319 /* make sure it's empty */ 315 320 for (i = 0; i < array->map.max_entries; i++) 316 321 BUG_ON(array->ptrs[i] != NULL); 317 - kvfree(array); 322 + 323 + bpf_map_area_free(array); 318 324 } 319 325 320 326 static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key)
+9 -13
kernel/bpf/hashtab.c
··· 13 13 #include <linux/bpf.h> 14 14 #include <linux/jhash.h> 15 15 #include <linux/filter.h> 16 - #include <linux/vmalloc.h> 17 16 #include "percpu_freelist.h" 18 17 #include "bpf_lru_list.h" 19 18 ··· 102 103 free_percpu(pptr); 103 104 } 104 105 free_elems: 105 - vfree(htab->elems); 106 + bpf_map_area_free(htab->elems); 106 107 } 107 108 108 109 static struct htab_elem *prealloc_lru_pop(struct bpf_htab *htab, void *key, ··· 124 125 { 125 126 int err = -ENOMEM, i; 126 127 127 - htab->elems = vzalloc(htab->elem_size * htab->map.max_entries); 128 + htab->elems = bpf_map_area_alloc(htab->elem_size * 129 + htab->map.max_entries); 128 130 if (!htab->elems) 129 131 return -ENOMEM; 130 132 ··· 320 320 goto free_htab; 321 321 322 322 err = -ENOMEM; 323 - htab->buckets = kmalloc_array(htab->n_buckets, sizeof(struct bucket), 324 - GFP_USER | __GFP_NOWARN); 325 - 326 - if (!htab->buckets) { 327 - htab->buckets = vmalloc(htab->n_buckets * sizeof(struct bucket)); 328 - if (!htab->buckets) 329 - goto free_htab; 330 - } 323 + htab->buckets = bpf_map_area_alloc(htab->n_buckets * 324 + sizeof(struct bucket)); 325 + if (!htab->buckets) 326 + goto free_htab; 331 327 332 328 for (i = 0; i < htab->n_buckets; i++) { 333 329 INIT_HLIST_HEAD(&htab->buckets[i].head); ··· 350 354 free_extra_elems: 351 355 free_percpu(htab->extra_elems); 352 356 free_buckets: 353 - kvfree(htab->buckets); 357 + bpf_map_area_free(htab->buckets); 354 358 free_htab: 355 359 kfree(htab); 356 360 return ERR_PTR(err); ··· 1010 1014 prealloc_destroy(htab); 1011 1015 1012 1016 free_percpu(htab->extra_elems); 1013 - kvfree(htab->buckets); 1017 + bpf_map_area_free(htab->buckets); 1014 1018 kfree(htab); 1015 1019 } 1016 1020
+8 -12
kernel/bpf/stackmap.c
··· 7 7 #include <linux/bpf.h> 8 8 #include <linux/jhash.h> 9 9 #include <linux/filter.h> 10 - #include <linux/vmalloc.h> 11 10 #include <linux/stacktrace.h> 12 11 #include <linux/perf_event.h> 13 12 #include "percpu_freelist.h" ··· 31 32 u32 elem_size = sizeof(struct stack_map_bucket) + smap->map.value_size; 32 33 int err; 33 34 34 - smap->elems = vzalloc(elem_size * smap->map.max_entries); 35 + smap->elems = bpf_map_area_alloc(elem_size * smap->map.max_entries); 35 36 if (!smap->elems) 36 37 return -ENOMEM; 37 38 ··· 44 45 return 0; 45 46 46 47 free_elems: 47 - vfree(smap->elems); 48 + bpf_map_area_free(smap->elems); 48 49 return err; 49 50 } 50 51 ··· 75 76 if (cost >= U32_MAX - PAGE_SIZE) 76 77 return ERR_PTR(-E2BIG); 77 78 78 - smap = kzalloc(cost, GFP_USER | __GFP_NOWARN); 79 - if (!smap) { 80 - smap = vzalloc(cost); 81 - if (!smap) 82 - return ERR_PTR(-ENOMEM); 83 - } 79 + smap = bpf_map_area_alloc(cost); 80 + if (!smap) 81 + return ERR_PTR(-ENOMEM); 84 82 85 83 err = -E2BIG; 86 84 cost += n_buckets * (value_size + sizeof(struct stack_map_bucket)); ··· 108 112 put_buffers: 109 113 put_callchain_buffers(); 110 114 free_smap: 111 - kvfree(smap); 115 + bpf_map_area_free(smap); 112 116 return ERR_PTR(err); 113 117 } 114 118 ··· 258 262 /* wait for bpf programs to complete before freeing stack map */ 259 263 synchronize_rcu(); 260 264 261 - vfree(smap->elems); 265 + bpf_map_area_free(smap->elems); 262 266 pcpu_freelist_destroy(&smap->freelist); 263 - kvfree(smap); 267 + bpf_map_area_free(smap); 264 268 put_callchain_buffers(); 265 269 } 266 270
+26
kernel/bpf/syscall.c
··· 12 12 #include <linux/bpf.h> 13 13 #include <linux/syscalls.h> 14 14 #include <linux/slab.h> 15 + #include <linux/vmalloc.h> 16 + #include <linux/mmzone.h> 15 17 #include <linux/anon_inodes.h> 16 18 #include <linux/file.h> 17 19 #include <linux/license.h> ··· 49 47 void bpf_register_map_type(struct bpf_map_type_list *tl) 50 48 { 51 49 list_add(&tl->list_node, &bpf_map_types); 50 + } 51 + 52 + void *bpf_map_area_alloc(size_t size) 53 + { 54 + /* We definitely need __GFP_NORETRY, so OOM killer doesn't 55 + * trigger under memory pressure as we really just want to 56 + * fail instead. 57 + */ 58 + const gfp_t flags = __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO; 59 + void *area; 60 + 61 + if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { 62 + area = kmalloc(size, GFP_USER | flags); 63 + if (area != NULL) 64 + return area; 65 + } 66 + 67 + return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | flags, 68 + PAGE_KERNEL); 69 + } 70 + 71 + void bpf_map_area_free(void *area) 72 + { 73 + kvfree(area); 52 74 } 53 75 54 76 int bpf_map_precharge_memlock(u32 pages)
+5 -5
net/batman-adv/fragmentation.c
··· 474 474 primary_if = batadv_primary_if_get_selected(bat_priv); 475 475 if (!primary_if) { 476 476 ret = -EINVAL; 477 - goto put_primary_if; 477 + goto free_skb; 478 478 } 479 479 480 480 /* Create one header to be copied to all fragments */ ··· 502 502 skb_fragment = batadv_frag_create(skb, &frag_header, mtu); 503 503 if (!skb_fragment) { 504 504 ret = -ENOMEM; 505 - goto free_skb; 505 + goto put_primary_if; 506 506 } 507 507 508 508 batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX); ··· 511 511 ret = batadv_send_unicast_skb(skb_fragment, neigh_node); 512 512 if (ret != NET_XMIT_SUCCESS) { 513 513 ret = NET_XMIT_DROP; 514 - goto free_skb; 514 + goto put_primary_if; 515 515 } 516 516 517 517 frag_header.no++; ··· 519 519 /* The initial check in this function should cover this case */ 520 520 if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) { 521 521 ret = -EINVAL; 522 - goto free_skb; 522 + goto put_primary_if; 523 523 } 524 524 } 525 525 ··· 527 527 if (batadv_skb_head_push(skb, header_size) < 0 || 528 528 pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) { 529 529 ret = -ENOMEM; 530 - goto free_skb; 530 + goto put_primary_if; 531 531 } 532 532 533 533 memcpy(skb->data, &frag_header, header_size);
+19 -14
net/bridge/br_netlink.c
··· 781 781 return 0; 782 782 } 783 783 784 - static int br_dev_newlink(struct net *src_net, struct net_device *dev, 785 - struct nlattr *tb[], struct nlattr *data[]) 786 - { 787 - struct net_bridge *br = netdev_priv(dev); 788 - 789 - if (tb[IFLA_ADDRESS]) { 790 - spin_lock_bh(&br->lock); 791 - br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS])); 792 - spin_unlock_bh(&br->lock); 793 - } 794 - 795 - return register_netdevice(dev); 796 - } 797 - 798 784 static int br_port_slave_changelink(struct net_device *brdev, 799 785 struct net_device *dev, 800 786 struct nlattr *tb[], ··· 1099 1113 #endif 1100 1114 1101 1115 return 0; 1116 + } 1117 + 1118 + static int br_dev_newlink(struct net *src_net, struct net_device *dev, 1119 + struct nlattr *tb[], struct nlattr *data[]) 1120 + { 1121 + struct net_bridge *br = netdev_priv(dev); 1122 + int err; 1123 + 1124 + if (tb[IFLA_ADDRESS]) { 1125 + spin_lock_bh(&br->lock); 1126 + br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS])); 1127 + spin_unlock_bh(&br->lock); 1128 + } 1129 + 1130 + err = br_changelink(dev, tb, data); 1131 + if (err) 1132 + return err; 1133 + 1134 + return register_netdevice(dev); 1102 1135 } 1103 1136 1104 1137 static size_t br_get_size(const struct net_device *brdev)
+2 -2
net/core/dev.c
··· 2795 2795 if (skb->ip_summed != CHECKSUM_NONE && 2796 2796 !can_checksum_protocol(features, type)) { 2797 2797 features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 2798 - } else if (illegal_highdma(skb->dev, skb)) { 2799 - features &= ~NETIF_F_SG; 2800 2798 } 2799 + if (illegal_highdma(skb->dev, skb)) 2800 + features &= ~NETIF_F_SG; 2801 2801 2802 2802 return features; 2803 2803 }
+1 -1
net/core/ethtool.c
··· 1712 1712 static noinline_for_stack int ethtool_set_channels(struct net_device *dev, 1713 1713 void __user *useraddr) 1714 1714 { 1715 - struct ethtool_channels channels, max; 1715 + struct ethtool_channels channels, max = { .cmd = ETHTOOL_GCHANNELS }; 1716 1716 u32 max_rx_in_use = 0; 1717 1717 1718 1718 if (!dev->ethtool_ops->set_channels || !dev->ethtool_ops->get_channels)
+1
net/core/lwt_bpf.c
··· 386 386 .fill_encap = bpf_fill_encap_info, 387 387 .get_encap_size = bpf_encap_nlsize, 388 388 .cmp_encap = bpf_encap_cmp, 389 + .owner = THIS_MODULE, 389 390 }; 390 391 391 392 static int __init bpf_lwt_init(void)
+67 -13
net/core/lwtunnel.c
··· 26 26 #include <net/lwtunnel.h> 27 27 #include <net/rtnetlink.h> 28 28 #include <net/ip6_fib.h> 29 + #include <net/nexthop.h> 29 30 30 31 #ifdef CONFIG_MODULES 31 32 ··· 115 114 ret = -EOPNOTSUPP; 116 115 rcu_read_lock(); 117 116 ops = rcu_dereference(lwtun_encaps[encap_type]); 118 - #ifdef CONFIG_MODULES 119 - if (!ops) { 120 - const char *encap_type_str = lwtunnel_encap_str(encap_type); 121 - 122 - if (encap_type_str) { 123 - rcu_read_unlock(); 124 - request_module("rtnl-lwt-%s", encap_type_str); 125 - rcu_read_lock(); 126 - ops = rcu_dereference(lwtun_encaps[encap_type]); 127 - } 128 - } 129 - #endif 130 - if (likely(ops && ops->build_state)) 117 + if (likely(ops && ops->build_state && try_module_get(ops->owner))) { 131 118 ret = ops->build_state(dev, encap, family, cfg, lws); 119 + if (ret) 120 + module_put(ops->owner); 121 + } 132 122 rcu_read_unlock(); 133 123 134 124 return ret; 135 125 } 136 126 EXPORT_SYMBOL(lwtunnel_build_state); 127 + 128 + int lwtunnel_valid_encap_type(u16 encap_type) 129 + { 130 + const struct lwtunnel_encap_ops *ops; 131 + int ret = -EINVAL; 132 + 133 + if (encap_type == LWTUNNEL_ENCAP_NONE || 134 + encap_type > LWTUNNEL_ENCAP_MAX) 135 + return ret; 136 + 137 + rcu_read_lock(); 138 + ops = rcu_dereference(lwtun_encaps[encap_type]); 139 + rcu_read_unlock(); 140 + #ifdef CONFIG_MODULES 141 + if (!ops) { 142 + const char *encap_type_str = lwtunnel_encap_str(encap_type); 143 + 144 + if (encap_type_str) { 145 + __rtnl_unlock(); 146 + request_module("rtnl-lwt-%s", encap_type_str); 147 + rtnl_lock(); 148 + 149 + rcu_read_lock(); 150 + ops = rcu_dereference(lwtun_encaps[encap_type]); 151 + rcu_read_unlock(); 152 + } 153 + } 154 + #endif 155 + return ops ? 0 : -EOPNOTSUPP; 156 + } 157 + EXPORT_SYMBOL(lwtunnel_valid_encap_type); 158 + 159 + int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int remaining) 160 + { 161 + struct rtnexthop *rtnh = (struct rtnexthop *)attr; 162 + struct nlattr *nla_entype; 163 + struct nlattr *attrs; 164 + struct nlattr *nla; 165 + u16 encap_type; 166 + int attrlen; 167 + 168 + while (rtnh_ok(rtnh, remaining)) { 169 + attrlen = rtnh_attrlen(rtnh); 170 + if (attrlen > 0) { 171 + attrs = rtnh_attrs(rtnh); 172 + nla = nla_find(attrs, attrlen, RTA_ENCAP); 173 + nla_entype = nla_find(attrs, attrlen, RTA_ENCAP_TYPE); 174 + 175 + if (nla_entype) { 176 + encap_type = nla_get_u16(nla_entype); 177 + 178 + if (lwtunnel_valid_encap_type(encap_type) != 0) 179 + return -EOPNOTSUPP; 180 + } 181 + } 182 + rtnh = rtnh_next(rtnh, &remaining); 183 + } 184 + 185 + return 0; 186 + } 187 + EXPORT_SYMBOL(lwtunnel_valid_encap_type_attr); 137 188 138 189 void lwtstate_free(struct lwtunnel_state *lws) 139 190 { ··· 197 144 } else { 198 145 kfree(lws); 199 146 } 147 + module_put(ops->owner); 200 148 } 201 149 EXPORT_SYMBOL(lwtstate_free); 202 150
+2 -2
net/dccp/ipv6.c
··· 227 227 opt = ireq->ipv6_opt; 228 228 if (!opt) 229 229 opt = rcu_dereference(np->opt); 230 - err = ip6_xmit(sk, skb, &fl6, opt, np->tclass); 230 + err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass); 231 231 rcu_read_unlock(); 232 232 err = net_xmit_eval(err); 233 233 } ··· 281 281 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL); 282 282 if (!IS_ERR(dst)) { 283 283 skb_dst_set(skb, dst); 284 - ip6_xmit(ctl_sk, skb, &fl6, NULL, 0); 284 + ip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0); 285 285 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 286 286 DCCP_INC_STATS(DCCP_MIB_OUTRSTS); 287 287 return;
+4 -4
net/dsa/slave.c
··· 1105 1105 /* Use already configured phy mode */ 1106 1106 if (p->phy_interface == PHY_INTERFACE_MODE_NA) 1107 1107 p->phy_interface = p->phy->interface; 1108 - phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 1109 - p->phy_interface); 1110 - 1111 - return 0; 1108 + return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 1109 + p->phy_interface); 1112 1110 } 1113 1111 1114 1112 static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ··· 1200 1202 int dsa_slave_suspend(struct net_device *slave_dev) 1201 1203 { 1202 1204 struct dsa_slave_priv *p = netdev_priv(slave_dev); 1205 + 1206 + netif_device_detach(slave_dev); 1203 1207 1204 1208 if (p->phy) { 1205 1209 phy_stop(p->phy);
+8
net/ipv4/fib_frontend.c
··· 46 46 #include <net/rtnetlink.h> 47 47 #include <net/xfrm.h> 48 48 #include <net/l3mdev.h> 49 + #include <net/lwtunnel.h> 49 50 #include <trace/events/fib.h> 50 51 51 52 #ifndef CONFIG_IP_MULTIPLE_TABLES ··· 678 677 cfg->fc_mx_len = nla_len(attr); 679 678 break; 680 679 case RTA_MULTIPATH: 680 + err = lwtunnel_valid_encap_type_attr(nla_data(attr), 681 + nla_len(attr)); 682 + if (err < 0) 683 + goto errout; 681 684 cfg->fc_mp = nla_data(attr); 682 685 cfg->fc_mp_len = nla_len(attr); 683 686 break; ··· 696 691 break; 697 692 case RTA_ENCAP_TYPE: 698 693 cfg->fc_encap_type = nla_get_u16(attr); 694 + err = lwtunnel_valid_encap_type(cfg->fc_encap_type); 695 + if (err < 0) 696 + goto errout; 699 697 break; 700 698 } 701 699 }
+1
net/ipv4/ip_output.c
··· 1629 1629 sk->sk_protocol = ip_hdr(skb)->protocol; 1630 1630 sk->sk_bound_dev_if = arg->bound_dev_if; 1631 1631 sk->sk_sndbuf = sysctl_wmem_default; 1632 + sk->sk_mark = fl4.flowi4_mark; 1632 1633 err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, 1633 1634 len, 0, &ipc, &rt, MSG_DONTWAIT); 1634 1635 if (unlikely(err)) {
+2
net/ipv4/ip_tunnel_core.c
··· 313 313 .fill_encap = ip_tun_fill_encap_info, 314 314 .get_encap_size = ip_tun_encap_nlsize, 315 315 .cmp_encap = ip_tun_cmp_encap, 316 + .owner = THIS_MODULE, 316 317 }; 317 318 318 319 static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = { ··· 404 403 .fill_encap = ip6_tun_fill_encap_info, 405 404 .get_encap_size = ip6_tun_encap_nlsize, 406 405 .cmp_encap = ip_tun_cmp_encap, 406 + .owner = THIS_MODULE, 407 407 }; 408 408 409 409 void __init ip_tunnel_core_init(void)
+6 -1
net/ipv4/netfilter/ipt_CLUSTERIP.c
··· 144 144 rcu_read_lock_bh(); 145 145 c = __clusterip_config_find(net, clusterip); 146 146 if (c) { 147 - if (!c->pde || unlikely(!atomic_inc_not_zero(&c->refcount))) 147 + #ifdef CONFIG_PROC_FS 148 + if (!c->pde) 149 + c = NULL; 150 + else 151 + #endif 152 + if (unlikely(!atomic_inc_not_zero(&c->refcount))) 148 153 c = NULL; 149 154 else if (entry) 150 155 atomic_inc(&c->entries);
+4 -4
net/ipv4/netfilter/ipt_rpfilter.c
··· 63 63 return dev_match || flags & XT_RPFILTER_LOOSE; 64 64 } 65 65 66 - static bool rpfilter_is_local(const struct sk_buff *skb) 66 + static bool 67 + rpfilter_is_loopback(const struct sk_buff *skb, const struct net_device *in) 67 68 { 68 - const struct rtable *rt = skb_rtable(skb); 69 - return rt && (rt->rt_flags & RTCF_LOCAL); 69 + return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK; 70 70 } 71 71 72 72 static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) ··· 79 79 info = par->matchinfo; 80 80 invert = info->flags & XT_RPFILTER_INVERT; 81 81 82 - if (rpfilter_is_local(skb)) 82 + if (rpfilter_is_loopback(skb, xt_in(par))) 83 83 return true ^ invert; 84 84 85 85 iph = ip_hdr(skb);
+2
net/ipv4/netfilter/nf_reject_ipv4.c
··· 126 126 /* ip_route_me_harder expects skb->dst to be set */ 127 127 skb_dst_set_noref(nskb, skb_dst(oldskb)); 128 128 129 + nskb->mark = IP4_REPLY_MARK(net, oldskb->mark); 130 + 129 131 skb_reserve(nskb, LL_MAX_HEADER); 130 132 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP, 131 133 ip4_dst_hoplimit(skb_dst(nskb)));
+5 -10
net/ipv4/netfilter/nft_fib_ipv4.c
··· 26 26 return addr; 27 27 } 28 28 29 - static bool fib4_is_local(const struct sk_buff *skb) 30 - { 31 - const struct rtable *rt = skb_rtable(skb); 32 - 33 - return rt && (rt->rt_flags & RTCF_LOCAL); 34 - } 35 - 36 29 #define DSCP_BITS 0xfc 37 30 38 31 void nft_fib4_eval_type(const struct nft_expr *expr, struct nft_regs *regs, ··· 88 95 else 89 96 oif = NULL; 90 97 91 - if (nft_hook(pkt) == NF_INET_PRE_ROUTING && fib4_is_local(pkt->skb)) { 92 - nft_fib_store_result(dest, priv->result, pkt, LOOPBACK_IFINDEX); 98 + if (nft_hook(pkt) == NF_INET_PRE_ROUTING && 99 + nft_fib_is_loopback(pkt->skb, nft_in(pkt))) { 100 + nft_fib_store_result(dest, priv->result, pkt, 101 + nft_in(pkt)->ifindex); 93 102 return; 94 103 } 95 104 ··· 126 131 switch (res.type) { 127 132 case RTN_UNICAST: 128 133 break; 129 - case RTN_LOCAL: /* should not appear here, see fib4_is_local() above */ 134 + case RTN_LOCAL: /* Should not see RTN_LOCAL here */ 130 135 return; 131 136 default: 132 137 break;
+1
net/ipv4/tcp_fastopen.c
··· 205 205 * scaled. So correct it appropriately. 206 206 */ 207 207 tp->snd_wnd = ntohs(tcp_hdr(skb)->window); 208 + tp->max_window = tp->snd_wnd; 208 209 209 210 /* Activate the retrans timer so that SYNACK can be retransmitted. 210 211 * The request socket is not added to the ehash
+1 -1
net/ipv4/tcp_input.c
··· 5078 5078 if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) { 5079 5079 sock_reset_flag(sk, SOCK_QUEUE_SHRUNK); 5080 5080 /* pairs with tcp_poll() */ 5081 - smp_mb__after_atomic(); 5081 + smp_mb(); 5082 5082 if (sk->sk_socket && 5083 5083 test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { 5084 5084 tcp_new_space(sk);
+1 -3
net/ipv6/addrconf.c
··· 5540 5540 struct net_device *dev; 5541 5541 struct inet6_dev *idev; 5542 5542 5543 - rcu_read_lock(); 5544 - for_each_netdev_rcu(net, dev) { 5543 + for_each_netdev(net, dev) { 5545 5544 idev = __in6_dev_get(dev); 5546 5545 if (idev) { 5547 5546 int changed = (!idev->cnf.disable_ipv6) ^ (!newf); ··· 5549 5550 dev_disable_change(idev); 5550 5551 } 5551 5552 } 5552 - rcu_read_unlock(); 5553 5553 } 5554 5554 5555 5555 static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
+1
net/ipv6/ila/ila_lwt.c
··· 238 238 .fill_encap = ila_fill_encap_info, 239 239 .get_encap_size = ila_encap_nlsize, 240 240 .cmp_encap = ila_encap_cmp, 241 + .owner = THIS_MODULE, 241 242 }; 242 243 243 244 int ila_lwt_init(void)
+1 -1
net/ipv6/inet6_connection_sock.c
··· 176 176 /* Restore final destination back after routing done */ 177 177 fl6.daddr = sk->sk_v6_daddr; 178 178 179 - res = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt), 179 + res = ip6_xmit(sk, skb, &fl6, sk->sk_mark, rcu_dereference(np->opt), 180 180 np->tclass); 181 181 rcu_read_unlock(); 182 182 return res;
+3
net/ipv6/ip6_gre.c
··· 582 582 return -1; 583 583 584 584 offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb)); 585 + /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head */ 586 + ipv6h = ipv6_hdr(skb); 587 + 585 588 if (offset > 0) { 586 589 struct ipv6_tlv_tnl_enc_lim *tel; 587 590 tel = (struct ipv6_tlv_tnl_enc_lim *)&skb_network_header(skb)[offset];
+2 -2
net/ipv6/ip6_output.c
··· 172 172 * which are using proper atomic operations or spinlocks. 173 173 */ 174 174 int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, 175 - struct ipv6_txoptions *opt, int tclass) 175 + __u32 mark, struct ipv6_txoptions *opt, int tclass) 176 176 { 177 177 struct net *net = sock_net(sk); 178 178 const struct ipv6_pinfo *np = inet6_sk(sk); ··· 240 240 241 241 skb->protocol = htons(ETH_P_IPV6); 242 242 skb->priority = sk->sk_priority; 243 - skb->mark = sk->sk_mark; 243 + skb->mark = mark; 244 244 245 245 mtu = dst_mtu(dst); 246 246 if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) {
+24 -12
net/ipv6/ip6_tunnel.c
··· 400 400 401 401 __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw) 402 402 { 403 - const struct ipv6hdr *ipv6h = (const struct ipv6hdr *) raw; 404 - __u8 nexthdr = ipv6h->nexthdr; 405 - __u16 off = sizeof(*ipv6h); 403 + const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)raw; 404 + unsigned int nhoff = raw - skb->data; 405 + unsigned int off = nhoff + sizeof(*ipv6h); 406 + u8 next, nexthdr = ipv6h->nexthdr; 406 407 407 408 while (ipv6_ext_hdr(nexthdr) && nexthdr != NEXTHDR_NONE) { 408 - __u16 optlen = 0; 409 409 struct ipv6_opt_hdr *hdr; 410 - if (raw + off + sizeof(*hdr) > skb->data && 411 - !pskb_may_pull(skb, raw - skb->data + off + sizeof (*hdr))) 410 + u16 optlen; 411 + 412 + if (!pskb_may_pull(skb, off + sizeof(*hdr))) 412 413 break; 413 414 414 - hdr = (struct ipv6_opt_hdr *) (raw + off); 415 + hdr = (struct ipv6_opt_hdr *)(skb->data + off); 415 416 if (nexthdr == NEXTHDR_FRAGMENT) { 416 417 struct frag_hdr *frag_hdr = (struct frag_hdr *) hdr; 417 418 if (frag_hdr->frag_off) ··· 423 422 } else { 424 423 optlen = ipv6_optlen(hdr); 425 424 } 425 + /* cache hdr->nexthdr, since pskb_may_pull() might 426 + * invalidate hdr 427 + */ 428 + next = hdr->nexthdr; 426 429 if (nexthdr == NEXTHDR_DEST) { 427 - __u16 i = off + 2; 430 + u16 i = 2; 431 + 432 + /* Remember : hdr is no longer valid at this point. */ 433 + if (!pskb_may_pull(skb, off + optlen)) 434 + break; 435 + 428 436 while (1) { 429 437 struct ipv6_tlv_tnl_enc_lim *tel; 430 438 431 439 /* No more room for encapsulation limit */ 432 - if (i + sizeof (*tel) > off + optlen) 440 + if (i + sizeof(*tel) > optlen) 433 441 break; 434 442 435 - tel = (struct ipv6_tlv_tnl_enc_lim *) &raw[i]; 443 + tel = (struct ipv6_tlv_tnl_enc_lim *) skb->data + off + i; 436 444 /* return index of option if found and valid */ 437 445 if (tel->type == IPV6_TLV_TNL_ENCAP_LIMIT && 438 446 tel->length == 1) 439 - return i; 447 + return i + off - nhoff; 440 448 /* else jump to next option */ 441 449 if (tel->type) 442 450 i += tel->length + 2; ··· 453 443 i++; 454 444 } 455 445 } 456 - nexthdr = hdr->nexthdr; 446 + nexthdr = next; 457 447 off += optlen; 458 448 } 459 449 return 0; ··· 1313 1303 fl6.flowlabel = key->label; 1314 1304 } else { 1315 1305 offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb)); 1306 + /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head */ 1307 + ipv6h = ipv6_hdr(skb); 1316 1308 if (offset > 0) { 1317 1309 struct ipv6_tlv_tnl_enc_lim *tel; 1318 1310
+4 -4
net/ipv6/netfilter/ip6t_rpfilter.c
··· 72 72 return ret; 73 73 } 74 74 75 - static bool rpfilter_is_local(const struct sk_buff *skb) 75 + static bool 76 + rpfilter_is_loopback(const struct sk_buff *skb, const struct net_device *in) 76 77 { 77 - const struct rt6_info *rt = (const void *) skb_dst(skb); 78 - return rt && (rt->rt6i_flags & RTF_LOCAL); 78 + return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK; 79 79 } 80 80 81 81 static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) ··· 85 85 struct ipv6hdr *iph; 86 86 bool invert = info->flags & XT_RPFILTER_INVERT; 87 87 88 - if (rpfilter_is_local(skb)) 88 + if (rpfilter_is_loopback(skb, xt_in(par))) 89 89 return true ^ invert; 90 90 91 91 iph = ipv6_hdr(skb);
+3
net/ipv6/netfilter/nf_reject_ipv6.c
··· 157 157 fl6.fl6_sport = otcph->dest; 158 158 fl6.fl6_dport = otcph->source; 159 159 fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev); 160 + fl6.flowi6_mark = IP6_REPLY_MARK(net, oldskb->mark); 160 161 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6)); 161 162 dst = ip6_route_output(net, NULL, &fl6); 162 163 if (dst->error) { ··· 180 179 } 181 180 182 181 skb_dst_set(nskb, dst); 182 + 183 + nskb->mark = fl6.flowi6_mark; 183 184 184 185 skb_reserve(nskb, hh_len + dst->header_len); 185 186 ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
+4 -9
net/ipv6/netfilter/nft_fib_ipv6.c
··· 18 18 #include <net/ip6_fib.h> 19 19 #include <net/ip6_route.h> 20 20 21 - static bool fib6_is_local(const struct sk_buff *skb) 22 - { 23 - const struct rt6_info *rt = (const void *)skb_dst(skb); 24 - 25 - return rt && (rt->rt6i_flags & RTF_LOCAL); 26 - } 27 - 28 21 static int get_ifindex(const struct net_device *dev) 29 22 { 30 23 return dev ? dev->ifindex : 0; ··· 157 164 158 165 lookup_flags = nft_fib6_flowi_init(&fl6, priv, pkt, oif); 159 166 160 - if (nft_hook(pkt) == NF_INET_PRE_ROUTING && fib6_is_local(pkt->skb)) { 161 - nft_fib_store_result(dest, priv->result, pkt, LOOPBACK_IFINDEX); 167 + if (nft_hook(pkt) == NF_INET_PRE_ROUTING && 168 + nft_fib_is_loopback(pkt->skb, nft_in(pkt))) { 169 + nft_fib_store_result(dest, priv->result, pkt, 170 + nft_in(pkt)->ifindex); 162 171 return; 163 172 } 164 173
+11 -1
net/ipv6/route.c
··· 2896 2896 if (tb[RTA_MULTIPATH]) { 2897 2897 cfg->fc_mp = nla_data(tb[RTA_MULTIPATH]); 2898 2898 cfg->fc_mp_len = nla_len(tb[RTA_MULTIPATH]); 2899 + 2900 + err = lwtunnel_valid_encap_type_attr(cfg->fc_mp, 2901 + cfg->fc_mp_len); 2902 + if (err < 0) 2903 + goto errout; 2899 2904 } 2900 2905 2901 2906 if (tb[RTA_PREF]) { ··· 2914 2909 if (tb[RTA_ENCAP]) 2915 2910 cfg->fc_encap = tb[RTA_ENCAP]; 2916 2911 2917 - if (tb[RTA_ENCAP_TYPE]) 2912 + if (tb[RTA_ENCAP_TYPE]) { 2918 2913 cfg->fc_encap_type = nla_get_u16(tb[RTA_ENCAP_TYPE]); 2914 + 2915 + err = lwtunnel_valid_encap_type(cfg->fc_encap_type); 2916 + if (err < 0) 2917 + goto errout; 2918 + } 2919 2919 2920 2920 if (tb[RTA_EXPIRES]) { 2921 2921 unsigned long timeout = addrconf_timeout_fixup(nla_get_u32(tb[RTA_EXPIRES]), HZ);
+2
net/ipv6/seg6.c
··· 176 176 177 177 val = nla_data(info->attrs[SEG6_ATTR_DST]); 178 178 t_new = kmemdup(val, sizeof(*val), GFP_KERNEL); 179 + if (!t_new) 180 + return -ENOMEM; 179 181 180 182 mutex_lock(&sdata->lock); 181 183
+1
net/ipv6/seg6_iptunnel.c
··· 422 422 .fill_encap = seg6_fill_encap_info, 423 423 .get_encap_size = seg6_encap_nlsize, 424 424 .cmp_encap = seg6_encap_cmp, 425 + .owner = THIS_MODULE, 425 426 }; 426 427 427 428 int __init seg6_iptunnel_init(void)
+2 -2
net/ipv6/tcp_ipv6.c
··· 469 469 opt = ireq->ipv6_opt; 470 470 if (!opt) 471 471 opt = rcu_dereference(np->opt); 472 - err = ip6_xmit(sk, skb, fl6, opt, np->tclass); 472 + err = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass); 473 473 rcu_read_unlock(); 474 474 err = net_xmit_eval(err); 475 475 } ··· 840 840 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL); 841 841 if (!IS_ERR(dst)) { 842 842 skb_dst_set(buff, dst); 843 - ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass); 843 + ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass); 844 844 TCP_INC_STATS(net, TCP_MIB_OUTSEGS); 845 845 if (rst) 846 846 TCP_INC_STATS(net, TCP_MIB_OUTRSTS);
-2
net/mac80211/rate.c
··· 40 40 41 41 ieee80211_sta_set_rx_nss(sta); 42 42 43 - ieee80211_recalc_min_chandef(sta->sdata); 44 - 45 43 if (!ref) 46 44 return; 47 45
+25 -23
net/mpls/af_mpls.c
··· 98 98 } 99 99 EXPORT_SYMBOL_GPL(mpls_pkt_too_big); 100 100 101 - static u32 mpls_multipath_hash(struct mpls_route *rt, 102 - struct sk_buff *skb, bool bos) 101 + static u32 mpls_multipath_hash(struct mpls_route *rt, struct sk_buff *skb) 103 102 { 104 103 struct mpls_entry_decoded dec; 104 + unsigned int mpls_hdr_len = 0; 105 105 struct mpls_shim_hdr *hdr; 106 106 bool eli_seen = false; 107 107 int label_index; 108 108 u32 hash = 0; 109 109 110 - for (label_index = 0; label_index < MAX_MP_SELECT_LABELS && !bos; 110 + for (label_index = 0; label_index < MAX_MP_SELECT_LABELS; 111 111 label_index++) { 112 - if (!pskb_may_pull(skb, sizeof(*hdr) * label_index)) 112 + mpls_hdr_len += sizeof(*hdr); 113 + if (!pskb_may_pull(skb, mpls_hdr_len)) 113 114 break; 114 115 115 116 /* Read and decode the current label */ ··· 135 134 eli_seen = true; 136 135 } 137 136 138 - bos = dec.bos; 139 - if (bos && pskb_may_pull(skb, sizeof(*hdr) * label_index + 140 - sizeof(struct iphdr))) { 137 + if (!dec.bos) 138 + continue; 139 + 140 + /* found bottom label; does skb have room for a header? */ 141 + if (pskb_may_pull(skb, mpls_hdr_len + sizeof(struct iphdr))) { 141 142 const struct iphdr *v4hdr; 142 143 143 - v4hdr = (const struct iphdr *)(mpls_hdr(skb) + 144 - label_index); 144 + v4hdr = (const struct iphdr *)(hdr + 1); 145 145 if (v4hdr->version == 4) { 146 146 hash = jhash_3words(ntohl(v4hdr->saddr), 147 147 ntohl(v4hdr->daddr), 148 148 v4hdr->protocol, hash); 149 149 } else if (v4hdr->version == 6 && 150 - pskb_may_pull(skb, sizeof(*hdr) * label_index + 151 - sizeof(struct ipv6hdr))) { 150 + pskb_may_pull(skb, mpls_hdr_len + 151 + sizeof(struct ipv6hdr))) { 152 152 const struct ipv6hdr *v6hdr; 153 153 154 - v6hdr = (const struct ipv6hdr *)(mpls_hdr(skb) + 155 - label_index); 156 - 154 + v6hdr = (const struct ipv6hdr *)(hdr + 1); 157 155 hash = __ipv6_addr_jhash(&v6hdr->saddr, hash); 158 156 hash = __ipv6_addr_jhash(&v6hdr->daddr, hash); 159 157 hash = jhash_1word(v6hdr->nexthdr, hash); 160 158 } 161 159 } 160 + 161 + break; 162 162 } 163 163 164 164 return hash; 165 165 } 166 166 167 167 static struct mpls_nh *mpls_select_multipath(struct mpls_route *rt, 168 - struct sk_buff *skb, bool bos) 168 + struct sk_buff *skb) 169 169 { 170 170 int alive = ACCESS_ONCE(rt->rt_nhn_alive); 171 171 u32 hash = 0; ··· 182 180 if (alive <= 0) 183 181 return NULL; 184 182 185 - hash = mpls_multipath_hash(rt, skb, bos); 183 + hash = mpls_multipath_hash(rt, skb); 186 184 nh_index = hash % alive; 187 185 if (alive == rt->rt_nhn) 188 186 goto out; ··· 280 278 hdr = mpls_hdr(skb); 281 279 dec = mpls_entry_decode(hdr); 282 280 283 - /* Pop the label */ 284 - skb_pull(skb, sizeof(*hdr)); 285 - skb_reset_network_header(skb); 286 - 287 - skb_orphan(skb); 288 - 289 281 rt = mpls_route_input_rcu(net, dec.label); 290 282 if (!rt) 291 283 goto drop; 292 284 293 - nh = mpls_select_multipath(rt, skb, dec.bos); 285 + nh = mpls_select_multipath(rt, skb); 294 286 if (!nh) 295 287 goto drop; 296 288 ··· 292 296 out_dev = rcu_dereference(nh->nh_dev); 293 297 if (!mpls_output_possible(out_dev)) 294 298 goto drop; 299 + 300 + /* Pop the label */ 301 + skb_pull(skb, sizeof(*hdr)); 302 + skb_reset_network_header(skb); 303 + 304 + skb_orphan(skb); 295 305 296 306 if (skb_warn_if_lro(skb)) 297 307 goto drop;
+1
net/mpls/mpls_iptunnel.c
··· 215 215 .fill_encap = mpls_fill_encap_info, 216 216 .get_encap_size = mpls_encap_nlsize, 217 217 .cmp_encap = mpls_encap_cmp, 218 + .owner = THIS_MODULE, 218 219 }; 219 220 220 221 static int __init mpls_iptunnel_init(void)
+1 -1
net/netfilter/Kconfig
··· 494 494 depends on NF_CONNTRACK 495 495 tristate "Netfilter nf_tables conntrack module" 496 496 help 497 - This option adds the "meta" expression that you can use to match 497 + This option adds the "ct" expression that you can use to match 498 498 connection tracking information such as the flow state. 499 499 500 500 config NFT_SET_RBTREE
+21 -23
net/netfilter/nf_conntrack_core.c
··· 85 85 static __read_mostly bool nf_conntrack_locks_all; 86 86 87 87 /* every gc cycle scans at most 1/GC_MAX_BUCKETS_DIV part of table */ 88 - #define GC_MAX_BUCKETS_DIV 64u 89 - /* upper bound of scan intervals */ 90 - #define GC_INTERVAL_MAX (2 * HZ) 91 - /* maximum conntracks to evict per gc run */ 92 - #define GC_MAX_EVICTS 256u 88 + #define GC_MAX_BUCKETS_DIV 128u 89 + /* upper bound of full table scan */ 90 + #define GC_MAX_SCAN_JIFFIES (16u * HZ) 91 + /* desired ratio of entries found to be expired */ 92 + #define GC_EVICT_RATIO 50u 93 93 94 94 static struct conntrack_gc_work conntrack_gc_work; 95 95 ··· 938 938 939 939 static void gc_worker(struct work_struct *work) 940 940 { 941 + unsigned int min_interval = max(HZ / GC_MAX_BUCKETS_DIV, 1u); 941 942 unsigned int i, goal, buckets = 0, expired_count = 0; 942 943 struct conntrack_gc_work *gc_work; 943 944 unsigned int ratio, scanned = 0; ··· 980 979 */ 981 980 rcu_read_unlock(); 982 981 cond_resched_rcu_qs(); 983 - } while (++buckets < goal && 984 - expired_count < GC_MAX_EVICTS); 982 + } while (++buckets < goal); 985 983 986 984 if (gc_work->exiting) 987 985 return; ··· 997 997 * 1. Minimize time until we notice a stale entry 998 998 * 2. Maximize scan intervals to not waste cycles 999 999 * 1000 - * Normally, expired_count will be 0, this increases the next_run time 1001 - * to priorize 2) above. 1000 + * Normally, expire ratio will be close to 0. 1002 1001 * 1003 - * As soon as a timed-out entry is found, move towards 1) and increase 1004 - * the scan frequency. 1005 - * In case we have lots of evictions next scan is done immediately. 1002 + * As soon as a sizeable fraction of the entries have expired 1003 + * increase scan frequency. 1006 1004 */ 1007 1005 ratio = scanned ? expired_count * 100 / scanned : 0; 1008 - if (ratio >= 90 || expired_count == GC_MAX_EVICTS) { 1009 - gc_work->next_gc_run = 0; 1010 - next_run = 0; 1011 - } else if (expired_count) { 1012 - gc_work->next_gc_run /= 2U; 1013 - next_run = msecs_to_jiffies(1); 1006 + if (ratio > GC_EVICT_RATIO) { 1007 + gc_work->next_gc_run = min_interval; 1014 1008 } else { 1015 - if (gc_work->next_gc_run < GC_INTERVAL_MAX) 1016 - gc_work->next_gc_run += msecs_to_jiffies(1); 1009 + unsigned int max = GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV; 1017 1010 1018 - next_run = gc_work->next_gc_run; 1011 + BUILD_BUG_ON((GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV) == 0); 1012 + 1013 + gc_work->next_gc_run += min_interval; 1014 + if (gc_work->next_gc_run > max) 1015 + gc_work->next_gc_run = max; 1019 1016 } 1020 1017 1018 + next_run = gc_work->next_gc_run; 1021 1019 gc_work->last_bucket = i; 1022 1020 queue_delayed_work(system_long_wq, &gc_work->dwork, next_run); 1023 1021 } ··· 1023 1025 static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work) 1024 1026 { 1025 1027 INIT_DELAYED_WORK(&gc_work->dwork, gc_worker); 1026 - gc_work->next_gc_run = GC_INTERVAL_MAX; 1028 + gc_work->next_gc_run = HZ; 1027 1029 gc_work->exiting = false; 1028 1030 } 1029 1031 ··· 1915 1917 nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED); 1916 1918 1917 1919 conntrack_gc_work_init(&conntrack_gc_work); 1918 - queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, GC_INTERVAL_MAX); 1920 + queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, HZ); 1919 1921 1920 1922 return 0; 1921 1923
-1
net/netfilter/nf_log.c
··· 13 13 /* Internal logging interface, which relies on the real 14 14 LOG target modules */ 15 15 16 - #define NF_LOG_PREFIXLEN 128 17 16 #define NFLOGGER_NAME_LEN 64 18 17 19 18 static struct nf_logger __rcu *loggers[NFPROTO_NUMPROTO][NF_LOG_TYPE_MAX] __read_mostly;
+39 -28
net/netfilter/nf_tables_api.c
··· 928 928 } 929 929 930 930 static const struct nla_policy nft_chain_policy[NFTA_CHAIN_MAX + 1] = { 931 - [NFTA_CHAIN_TABLE] = { .type = NLA_STRING }, 931 + [NFTA_CHAIN_TABLE] = { .type = NLA_STRING, 932 + .len = NFT_TABLE_MAXNAMELEN - 1 }, 932 933 [NFTA_CHAIN_HANDLE] = { .type = NLA_U64 }, 933 934 [NFTA_CHAIN_NAME] = { .type = NLA_STRING, 934 935 .len = NFT_CHAIN_MAXNAMELEN - 1 }, ··· 1855 1854 } 1856 1855 1857 1856 static const struct nla_policy nft_rule_policy[NFTA_RULE_MAX + 1] = { 1858 - [NFTA_RULE_TABLE] = { .type = NLA_STRING }, 1857 + [NFTA_RULE_TABLE] = { .type = NLA_STRING, 1858 + .len = NFT_TABLE_MAXNAMELEN - 1 }, 1859 1859 [NFTA_RULE_CHAIN] = { .type = NLA_STRING, 1860 1860 .len = NFT_CHAIN_MAXNAMELEN - 1 }, 1861 1861 [NFTA_RULE_HANDLE] = { .type = NLA_U64 }, ··· 2445 2443 } 2446 2444 2447 2445 static const struct nla_policy nft_set_policy[NFTA_SET_MAX + 1] = { 2448 - [NFTA_SET_TABLE] = { .type = NLA_STRING }, 2446 + [NFTA_SET_TABLE] = { .type = NLA_STRING, 2447 + .len = NFT_TABLE_MAXNAMELEN - 1 }, 2449 2448 [NFTA_SET_NAME] = { .type = NLA_STRING, 2450 2449 .len = NFT_SET_MAXNAMELEN - 1 }, 2451 2450 [NFTA_SET_FLAGS] = { .type = NLA_U32 }, ··· 3087 3084 } 3088 3085 3089 3086 static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx, 3090 - const struct nft_set *set, 3087 + struct nft_set *set, 3091 3088 const struct nft_set_iter *iter, 3092 - const struct nft_set_elem *elem) 3089 + struct nft_set_elem *elem) 3093 3090 { 3094 3091 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv); 3095 3092 enum nft_registers dreg; ··· 3195 3192 }; 3196 3193 3197 3194 static const struct nla_policy nft_set_elem_list_policy[NFTA_SET_ELEM_LIST_MAX + 1] = { 3198 - [NFTA_SET_ELEM_LIST_TABLE] = { .type = NLA_STRING }, 3199 - [NFTA_SET_ELEM_LIST_SET] = { .type = NLA_STRING }, 3195 + [NFTA_SET_ELEM_LIST_TABLE] = { .type = NLA_STRING, 3196 + .len = NFT_TABLE_MAXNAMELEN - 1 }, 3197 + [NFTA_SET_ELEM_LIST_SET] = { .type = NLA_STRING, 3198 + .len = NFT_SET_MAXNAMELEN - 1 }, 3200 3199 [NFTA_SET_ELEM_LIST_ELEMENTS] = { .type = NLA_NESTED }, 3201 3200 [NFTA_SET_ELEM_LIST_SET_ID] = { .type = NLA_U32 }, 3202 3201 }; ··· 3308 3303 }; 3309 3304 3310 3305 static int nf_tables_dump_setelem(const struct nft_ctx *ctx, 3311 - const struct nft_set *set, 3306 + struct nft_set *set, 3312 3307 const struct nft_set_iter *iter, 3313 - const struct nft_set_elem *elem) 3308 + struct nft_set_elem *elem) 3314 3309 { 3315 3310 struct nft_set_dump_args *args; 3316 3311 ··· 3322 3317 { 3323 3318 struct net *net = sock_net(skb->sk); 3324 3319 u8 genmask = nft_genmask_cur(net); 3325 - const struct nft_set *set; 3320 + struct nft_set *set; 3326 3321 struct nft_set_dump_args args; 3327 3322 struct nft_ctx ctx; 3328 3323 struct nlattr *nla[NFTA_SET_ELEM_LIST_MAX + 1]; ··· 3745 3740 goto err5; 3746 3741 } 3747 3742 3743 + if (set->size && 3744 + !atomic_add_unless(&set->nelems, 1, set->size + set->ndeact)) { 3745 + err = -ENFILE; 3746 + goto err6; 3747 + } 3748 + 3748 3749 nft_trans_elem(trans) = elem; 3749 3750 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 3750 3751 return 0; 3751 3752 3753 + err6: 3754 + set->ops->remove(set, &elem); 3752 3755 err5: 3753 3756 kfree(trans); 3754 3757 err4: ··· 3803 3790 return -EBUSY; 3804 3791 3805 3792 nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) { 3806 - if (set->size && 3807 - !atomic_add_unless(&set->nelems, 1, set->size + set->ndeact)) 3808 - return -ENFILE; 3809 - 3810 3793 err = nft_add_set_elem(&ctx, set, attr, nlh->nlmsg_flags); 3811 - if (err < 0) { 3812 - atomic_dec(&set->nelems); 3794 + if (err < 0) 3813 3795 break; 3814 - } 3815 3796 } 3816 3797 return err; 3817 3798 } ··· 3890 3883 } 3891 3884 3892 3885 static int nft_flush_set(const struct nft_ctx *ctx, 3893 - const struct nft_set *set, 3886 + struct nft_set *set, 3894 3887 const struct nft_set_iter *iter, 3895 - const struct nft_set_elem *elem) 3888 + struct nft_set_elem *elem) 3896 3889 { 3897 3890 struct nft_trans *trans; 3898 3891 int err; ··· 3906 3899 err = -ENOENT; 3907 3900 goto err1; 3908 3901 } 3902 + set->ndeact++; 3909 3903 3910 - nft_trans_elem_set(trans) = (struct nft_set *)set; 3911 - nft_trans_elem(trans) = *((struct nft_set_elem *)elem); 3904 + nft_trans_elem_set(trans) = set; 3905 + nft_trans_elem(trans) = *elem; 3912 3906 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 3913 3907 3914 3908 return 0; ··· 4040 4032 EXPORT_SYMBOL_GPL(nf_tables_obj_lookup); 4041 4033 4042 4034 static const struct nla_policy nft_obj_policy[NFTA_OBJ_MAX + 1] = { 4043 - [NFTA_OBJ_TABLE] = { .type = NLA_STRING }, 4044 - [NFTA_OBJ_NAME] = { .type = NLA_STRING }, 4035 + [NFTA_OBJ_TABLE] = { .type = NLA_STRING, 4036 + .len = NFT_TABLE_MAXNAMELEN - 1 }, 4037 + [NFTA_OBJ_NAME] = { .type = NLA_STRING, 4038 + .len = NFT_OBJ_MAXNAMELEN - 1 }, 4045 4039 [NFTA_OBJ_TYPE] = { .type = NLA_U32 }, 4046 4040 [NFTA_OBJ_DATA] = { .type = NLA_NESTED }, 4047 4041 }; ··· 4272 4262 if (idx > s_idx) 4273 4263 memset(&cb->args[1], 0, 4274 4264 sizeof(cb->args) - sizeof(cb->args[0])); 4275 - if (filter->table[0] && 4265 + if (filter && filter->table[0] && 4276 4266 strcmp(filter->table, table->name)) 4277 4267 goto cont; 4278 - if (filter->type != NFT_OBJECT_UNSPEC && 4268 + if (filter && 4269 + filter->type != NFT_OBJECT_UNSPEC && 4279 4270 obj->type->type != filter->type) 4280 4271 goto cont; 4281 4272 ··· 5020 5009 const struct nft_chain *chain); 5021 5010 5022 5011 static int nf_tables_loop_check_setelem(const struct nft_ctx *ctx, 5023 - const struct nft_set *set, 5012 + struct nft_set *set, 5024 5013 const struct nft_set_iter *iter, 5025 - const struct nft_set_elem *elem) 5014 + struct nft_set_elem *elem) 5026 5015 { 5027 5016 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv); 5028 5017 const struct nft_data *data; ··· 5046 5035 { 5047 5036 const struct nft_rule *rule; 5048 5037 const struct nft_expr *expr, *last; 5049 - const struct nft_set *set; 5038 + struct nft_set *set; 5050 5039 struct nft_set_binding *binding; 5051 5040 struct nft_set_iter iter; 5052 5041
+2 -1
net/netfilter/nft_dynset.c
··· 98 98 } 99 99 100 100 static const struct nla_policy nft_dynset_policy[NFTA_DYNSET_MAX + 1] = { 101 - [NFTA_DYNSET_SET_NAME] = { .type = NLA_STRING }, 101 + [NFTA_DYNSET_SET_NAME] = { .type = NLA_STRING, 102 + .len = NFT_SET_MAXNAMELEN - 1 }, 102 103 [NFTA_DYNSET_SET_ID] = { .type = NLA_U32 }, 103 104 [NFTA_DYNSET_OP] = { .type = NLA_U32 }, 104 105 [NFTA_DYNSET_SREG_KEY] = { .type = NLA_U32 },
+2 -1
net/netfilter/nft_log.c
··· 39 39 40 40 static const struct nla_policy nft_log_policy[NFTA_LOG_MAX + 1] = { 41 41 [NFTA_LOG_GROUP] = { .type = NLA_U16 }, 42 - [NFTA_LOG_PREFIX] = { .type = NLA_STRING }, 42 + [NFTA_LOG_PREFIX] = { .type = NLA_STRING, 43 + .len = NF_LOG_PREFIXLEN - 1 }, 43 44 [NFTA_LOG_SNAPLEN] = { .type = NLA_U32 }, 44 45 [NFTA_LOG_QTHRESHOLD] = { .type = NLA_U16 }, 45 46 [NFTA_LOG_LEVEL] = { .type = NLA_U32 },
+2 -1
net/netfilter/nft_lookup.c
··· 49 49 } 50 50 51 51 static const struct nla_policy nft_lookup_policy[NFTA_LOOKUP_MAX + 1] = { 52 - [NFTA_LOOKUP_SET] = { .type = NLA_STRING }, 52 + [NFTA_LOOKUP_SET] = { .type = NLA_STRING, 53 + .len = NFT_SET_MAXNAMELEN - 1 }, 53 54 [NFTA_LOOKUP_SET_ID] = { .type = NLA_U32 }, 54 55 [NFTA_LOOKUP_SREG] = { .type = NLA_U32 }, 55 56 [NFTA_LOOKUP_DREG] = { .type = NLA_U32 },
+4 -2
net/netfilter/nft_objref.c
··· 193 193 } 194 194 195 195 static const struct nla_policy nft_objref_policy[NFTA_OBJREF_MAX + 1] = { 196 - [NFTA_OBJREF_IMM_NAME] = { .type = NLA_STRING }, 196 + [NFTA_OBJREF_IMM_NAME] = { .type = NLA_STRING, 197 + .len = NFT_OBJ_MAXNAMELEN - 1 }, 197 198 [NFTA_OBJREF_IMM_TYPE] = { .type = NLA_U32 }, 198 199 [NFTA_OBJREF_SET_SREG] = { .type = NLA_U32 }, 199 - [NFTA_OBJREF_SET_NAME] = { .type = NLA_STRING }, 200 + [NFTA_OBJREF_SET_NAME] = { .type = NLA_STRING, 201 + .len = NFT_SET_MAXNAMELEN - 1 }, 200 202 [NFTA_OBJREF_SET_ID] = { .type = NLA_U32 }, 201 203 }; 202 204
+1 -1
net/netfilter/nft_set_hash.c
··· 212 212 rhashtable_remove_fast(&priv->ht, &he->node, nft_hash_params); 213 213 } 214 214 215 - static void nft_hash_walk(const struct nft_ctx *ctx, const struct nft_set *set, 215 + static void nft_hash_walk(const struct nft_ctx *ctx, struct nft_set *set, 216 216 struct nft_set_iter *iter) 217 217 { 218 218 struct nft_hash *priv = nft_set_priv(set);
+1 -1
net/netfilter/nft_set_rbtree.c
··· 221 221 } 222 222 223 223 static void nft_rbtree_walk(const struct nft_ctx *ctx, 224 - const struct nft_set *set, 224 + struct nft_set *set, 225 225 struct nft_set_iter *iter) 226 226 { 227 227 const struct nft_rbtree *priv = nft_set_priv(set);
+2 -2
net/packet/af_packet.c
··· 1976 1976 return -EINVAL; 1977 1977 *len -= sizeof(vnet_hdr); 1978 1978 1979 - if (virtio_net_hdr_from_skb(skb, &vnet_hdr, vio_le())) 1979 + if (virtio_net_hdr_from_skb(skb, &vnet_hdr, vio_le(), true)) 1980 1980 return -EINVAL; 1981 1981 1982 1982 return memcpy_to_msg(msg, (void *)&vnet_hdr, sizeof(vnet_hdr)); ··· 2237 2237 if (po->has_vnet_hdr) { 2238 2238 if (virtio_net_hdr_from_skb(skb, h.raw + macoff - 2239 2239 sizeof(struct virtio_net_hdr), 2240 - vio_le())) { 2240 + vio_le(), true)) { 2241 2241 spin_lock(&sk->sk_receive_queue.lock); 2242 2242 goto drop_n_account; 2243 2243 }
+2 -1
net/sctp/ipv6.c
··· 222 222 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS); 223 223 224 224 rcu_read_lock(); 225 - res = ip6_xmit(sk, skb, fl6, rcu_dereference(np->opt), np->tclass); 225 + res = ip6_xmit(sk, skb, fl6, sk->sk_mark, rcu_dereference(np->opt), 226 + np->tclass); 226 227 rcu_read_unlock(); 227 228 return res; 228 229 }
+1 -1
net/sctp/offload.c
··· 68 68 goto out; 69 69 } 70 70 71 - segs = skb_segment(skb, features | NETIF_F_HW_CSUM); 71 + segs = skb_segment(skb, features | NETIF_F_HW_CSUM | NETIF_F_SG); 72 72 if (IS_ERR(segs)) 73 73 goto out; 74 74
+5 -1
net/sctp/socket.c
··· 235 235 sctp_assoc_t id) 236 236 { 237 237 struct sctp_association *addr_asoc = NULL, *id_asoc = NULL; 238 - struct sctp_transport *transport; 238 + struct sctp_af *af = sctp_get_af_specific(addr->ss_family); 239 239 union sctp_addr *laddr = (union sctp_addr *)addr; 240 + struct sctp_transport *transport; 241 + 242 + if (sctp_verify_addr(sk, laddr, af->sockaddr_len)) 243 + return NULL; 240 244 241 245 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep, 242 246 laddr,
+7 -2
net/tipc/node.c
··· 263 263 write_lock_bh(&n->lock); 264 264 } 265 265 266 + static void tipc_node_write_unlock_fast(struct tipc_node *n) 267 + { 268 + write_unlock_bh(&n->lock); 269 + } 270 + 266 271 static void tipc_node_write_unlock(struct tipc_node *n) 267 272 { 268 273 struct net *net = n->net; ··· 422 417 } 423 418 tipc_node_write_lock(n); 424 419 list_add_tail(subscr, &n->publ_list); 425 - tipc_node_write_unlock(n); 420 + tipc_node_write_unlock_fast(n); 426 421 tipc_node_put(n); 427 422 } 428 423 ··· 440 435 } 441 436 tipc_node_write_lock(n); 442 437 list_del_init(subscr); 443 - tipc_node_write_unlock(n); 438 + tipc_node_write_unlock_fast(n); 444 439 tipc_node_put(n); 445 440 } 446 441
+21 -27
net/tipc/server.c
··· 86 86 static void tipc_recv_work(struct work_struct *work); 87 87 static void tipc_send_work(struct work_struct *work); 88 88 static void tipc_clean_outqueues(struct tipc_conn *con); 89 - static void tipc_sock_release(struct tipc_conn *con); 90 89 91 90 static void tipc_conn_kref_release(struct kref *kref) 92 91 { 93 92 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref); 94 - struct sockaddr_tipc *saddr = con->server->saddr; 93 + struct tipc_server *s = con->server; 94 + struct sockaddr_tipc *saddr = s->saddr; 95 95 struct socket *sock = con->sock; 96 96 struct sock *sk; 97 97 ··· 103 103 } 104 104 saddr->scope = -TIPC_NODE_SCOPE; 105 105 kernel_bind(sock, (struct sockaddr *)saddr, sizeof(*saddr)); 106 - tipc_sock_release(con); 107 106 sock_release(sock); 108 107 con->sock = NULL; 108 + 109 + spin_lock_bh(&s->idr_lock); 110 + idr_remove(&s->conn_idr, con->conid); 111 + s->idr_in_use--; 112 + spin_unlock_bh(&s->idr_lock); 109 113 } 110 114 111 115 tipc_clean_outqueues(con); ··· 132 128 133 129 spin_lock_bh(&s->idr_lock); 134 130 con = idr_find(&s->conn_idr, conid); 135 - if (con) 131 + if (con && test_bit(CF_CONNECTED, &con->flags)) 136 132 conn_get(con); 133 + else 134 + con = NULL; 137 135 spin_unlock_bh(&s->idr_lock); 138 136 return con; 139 137 } ··· 192 186 write_unlock_bh(&sk->sk_callback_lock); 193 187 } 194 188 195 - static void tipc_sock_release(struct tipc_conn *con) 196 - { 197 - struct tipc_server *s = con->server; 198 - 199 - if (con->conid) 200 - s->tipc_conn_release(con->conid, con->usr_data); 201 - 202 - tipc_unregister_callbacks(con); 203 - } 204 - 205 189 static void tipc_close_conn(struct tipc_conn *con) 206 190 { 207 191 struct tipc_server *s = con->server; 208 192 209 193 if (test_and_clear_bit(CF_CONNECTED, &con->flags)) { 194 + tipc_unregister_callbacks(con); 210 195 211 - spin_lock_bh(&s->idr_lock); 212 - idr_remove(&s->conn_idr, con->conid); 213 - s->idr_in_use--; 214 - spin_unlock_bh(&s->idr_lock); 196 + if (con->conid) 197 + s->tipc_conn_release(con->conid, con->usr_data); 215 198 216 199 /* We shouldn't flush pending works as we may be in the 217 200 * thread. In fact the races with pending rx/tx work structs ··· 453 458 if (!con) 454 459 return -EINVAL; 455 460 461 + if (!test_bit(CF_CONNECTED, &con->flags)) { 462 + conn_put(con); 463 + return 0; 464 + } 465 + 456 466 e = tipc_alloc_entry(data, len); 457 467 if (!e) { 458 468 conn_put(con); ··· 471 471 list_add_tail(&e->list, &con->outqueue); 472 472 spin_unlock_bh(&con->outqueue_lock); 473 473 474 - if (test_bit(CF_CONNECTED, &con->flags)) { 475 - if (!queue_work(s->send_wq, &con->swork)) 476 - conn_put(con); 477 - } else { 474 + if (!queue_work(s->send_wq, &con->swork)) 478 475 conn_put(con); 479 - } 480 476 return 0; 481 477 } 482 478 ··· 496 500 int ret; 497 501 498 502 spin_lock_bh(&con->outqueue_lock); 499 - while (1) { 503 + while (test_bit(CF_CONNECTED, &con->flags)) { 500 504 e = list_entry(con->outqueue.next, struct outqueue_entry, 501 505 list); 502 506 if ((struct list_head *) e == &con->outqueue) ··· 619 623 void tipc_server_stop(struct tipc_server *s) 620 624 { 621 625 struct tipc_conn *con; 622 - int total = 0; 623 626 int id; 624 627 625 628 spin_lock_bh(&s->idr_lock); 626 - for (id = 0; total < s->idr_in_use; id++) { 629 + for (id = 0; s->idr_in_use; id++) { 627 630 con = idr_find(&s->conn_idr, id); 628 631 if (con) { 629 - total++; 630 632 spin_unlock_bh(&s->idr_lock); 631 633 tipc_close_conn(con); 632 634 spin_lock_bh(&s->idr_lock);
+71 -55
net/tipc/subscr.c
··· 54 54 55 55 static void tipc_subscrp_delete(struct tipc_subscription *sub); 56 56 static void tipc_subscrb_put(struct tipc_subscriber *subscriber); 57 + static void tipc_subscrp_put(struct tipc_subscription *subscription); 58 + static void tipc_subscrp_get(struct tipc_subscription *subscription); 57 59 58 60 /** 59 61 * htohl - convert value to endianness used by destination ··· 125 123 { 126 124 struct tipc_name_seq seq; 127 125 126 + tipc_subscrp_get(sub); 128 127 tipc_subscrp_convert_seq(&sub->evt.s.seq, sub->swap, &seq); 129 128 if (!tipc_subscrp_check_overlap(&seq, found_lower, found_upper)) 130 129 return; ··· 135 132 136 133 tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref, 137 134 node); 135 + tipc_subscrp_put(sub); 138 136 } 139 137 140 138 static void tipc_subscrp_timeout(unsigned long data) 141 139 { 142 140 struct tipc_subscription *sub = (struct tipc_subscription *)data; 143 - struct tipc_subscriber *subscriber = sub->subscriber; 144 141 145 142 /* Notify subscriber of timeout */ 146 143 tipc_subscrp_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, 147 144 TIPC_SUBSCR_TIMEOUT, 0, 0); 148 145 149 - spin_lock_bh(&subscriber->lock); 150 - tipc_subscrp_delete(sub); 151 - spin_unlock_bh(&subscriber->lock); 152 - 153 - tipc_subscrb_put(subscriber); 146 + tipc_subscrp_put(sub); 154 147 } 155 148 156 149 static void tipc_subscrb_kref_release(struct kref *kref) 157 150 { 158 - struct tipc_subscriber *subcriber = container_of(kref, 159 - struct tipc_subscriber, kref); 160 - 161 - kfree(subcriber); 151 + kfree(container_of(kref,struct tipc_subscriber, kref)); 162 152 } 163 153 164 154 static void tipc_subscrb_put(struct tipc_subscriber *subscriber) ··· 164 168 kref_get(&subscriber->kref); 165 169 } 166 170 171 + static void tipc_subscrp_kref_release(struct kref *kref) 172 + { 173 + struct tipc_subscription *sub = container_of(kref, 174 + struct tipc_subscription, 175 + kref); 176 + struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 177 + struct tipc_subscriber *subscriber = sub->subscriber; 178 + 179 + spin_lock_bh(&subscriber->lock); 180 + tipc_nametbl_unsubscribe(sub); 181 + list_del(&sub->subscrp_list); 182 + atomic_dec(&tn->subscription_count); 183 + spin_unlock_bh(&subscriber->lock); 184 + kfree(sub); 185 + tipc_subscrb_put(subscriber); 186 + } 187 + 188 + static void tipc_subscrp_put(struct tipc_subscription *subscription) 189 + { 190 + kref_put(&subscription->kref, tipc_subscrp_kref_release); 191 + } 192 + 193 + static void tipc_subscrp_get(struct tipc_subscription *subscription) 194 + { 195 + kref_get(&subscription->kref); 196 + } 197 + 198 + /* tipc_subscrb_subscrp_delete - delete a specific subscription or all 199 + * subscriptions for a given subscriber. 200 + */ 201 + static void tipc_subscrb_subscrp_delete(struct tipc_subscriber *subscriber, 202 + struct tipc_subscr *s) 203 + { 204 + struct list_head *subscription_list = &subscriber->subscrp_list; 205 + struct tipc_subscription *sub, *temp; 206 + 207 + spin_lock_bh(&subscriber->lock); 208 + list_for_each_entry_safe(sub, temp, subscription_list, subscrp_list) { 209 + if (s && memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) 210 + continue; 211 + 212 + tipc_subscrp_get(sub); 213 + spin_unlock_bh(&subscriber->lock); 214 + tipc_subscrp_delete(sub); 215 + tipc_subscrp_put(sub); 216 + spin_lock_bh(&subscriber->lock); 217 + 218 + if (s) 219 + break; 220 + } 221 + spin_unlock_bh(&subscriber->lock); 222 + } 223 + 167 224 static struct tipc_subscriber *tipc_subscrb_create(int conid) 168 225 { 169 226 struct tipc_subscriber *subscriber; ··· 226 177 pr_warn("Subscriber rejected, no memory\n"); 227 178 return NULL; 228 179 } 229 - kref_init(&subscriber->kref); 230 180 INIT_LIST_HEAD(&subscriber->subscrp_list); 181 + kref_init(&subscriber->kref); 231 182 subscriber->conid = conid; 232 183 spin_lock_init(&subscriber->lock); 233 184 ··· 236 187 237 188 static void tipc_subscrb_delete(struct tipc_subscriber *subscriber) 238 189 { 239 - struct tipc_subscription *sub, *temp; 240 - u32 timeout; 241 - 242 - spin_lock_bh(&subscriber->lock); 243 - /* Destroy any existing subscriptions for subscriber */ 244 - list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list, 245 - subscrp_list) { 246 - timeout = htohl(sub->evt.s.timeout, sub->swap); 247 - if ((timeout == TIPC_WAIT_FOREVER) || del_timer(&sub->timer)) { 248 - tipc_subscrp_delete(sub); 249 - tipc_subscrb_put(subscriber); 250 - } 251 - } 252 - spin_unlock_bh(&subscriber->lock); 253 - 190 + tipc_subscrb_subscrp_delete(subscriber, NULL); 254 191 tipc_subscrb_put(subscriber); 255 192 } 256 193 257 194 static void tipc_subscrp_delete(struct tipc_subscription *sub) 258 195 { 259 - struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 196 + u32 timeout = htohl(sub->evt.s.timeout, sub->swap); 260 197 261 - tipc_nametbl_unsubscribe(sub); 262 - list_del(&sub->subscrp_list); 263 - kfree(sub); 264 - atomic_dec(&tn->subscription_count); 198 + if (timeout == TIPC_WAIT_FOREVER || del_timer(&sub->timer)) 199 + tipc_subscrp_put(sub); 265 200 } 266 201 267 202 static void tipc_subscrp_cancel(struct tipc_subscr *s, 268 203 struct tipc_subscriber *subscriber) 269 204 { 270 - struct tipc_subscription *sub, *temp; 271 - u32 timeout; 272 - 273 - spin_lock_bh(&subscriber->lock); 274 - /* Find first matching subscription, exit if not found */ 275 - list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list, 276 - subscrp_list) { 277 - if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { 278 - timeout = htohl(sub->evt.s.timeout, sub->swap); 279 - if ((timeout == TIPC_WAIT_FOREVER) || 280 - del_timer(&sub->timer)) { 281 - tipc_subscrp_delete(sub); 282 - tipc_subscrb_put(subscriber); 283 - } 284 - break; 285 - } 286 - } 287 - spin_unlock_bh(&subscriber->lock); 205 + tipc_subscrb_subscrp_delete(subscriber, s); 288 206 } 289 207 290 208 static struct tipc_subscription *tipc_subscrp_create(struct net *net, ··· 288 272 sub->swap = swap; 289 273 memcpy(&sub->evt.s, s, sizeof(*s)); 290 274 atomic_inc(&tn->subscription_count); 275 + kref_init(&sub->kref); 291 276 return sub; 292 277 } 293 278 ··· 305 288 306 289 spin_lock_bh(&subscriber->lock); 307 290 list_add(&sub->subscrp_list, &subscriber->subscrp_list); 308 - tipc_subscrb_get(subscriber); 309 291 sub->subscriber = subscriber; 310 292 tipc_nametbl_subscribe(sub); 293 + tipc_subscrb_get(subscriber); 311 294 spin_unlock_bh(&subscriber->lock); 312 295 313 - timeout = htohl(sub->evt.s.timeout, swap); 314 - if (timeout == TIPC_WAIT_FOREVER) 315 - return; 316 - 317 296 setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub); 318 - mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)); 297 + timeout = htohl(sub->evt.s.timeout, swap); 298 + 299 + if (timeout != TIPC_WAIT_FOREVER) 300 + mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)); 319 301 } 320 302 321 303 /* Handle one termination request for the subscriber */
+1
net/tipc/subscr.h
··· 57 57 * @evt: template for events generated by subscription 58 58 */ 59 59 struct tipc_subscription { 60 + struct kref kref; 60 61 struct tipc_subscriber *subscriber; 61 62 struct net *net; 62 63 struct timer_list timer;
+16 -11
net/unix/af_unix.c
··· 995 995 unsigned int hash; 996 996 struct unix_address *addr; 997 997 struct hlist_head *list; 998 + struct path path = { NULL, NULL }; 998 999 999 1000 err = -EINVAL; 1000 1001 if (sunaddr->sun_family != AF_UNIX) ··· 1011 1010 goto out; 1012 1011 addr_len = err; 1013 1012 1013 + if (sun_path[0]) { 1014 + umode_t mode = S_IFSOCK | 1015 + (SOCK_INODE(sock)->i_mode & ~current_umask()); 1016 + err = unix_mknod(sun_path, mode, &path); 1017 + if (err) { 1018 + if (err == -EEXIST) 1019 + err = -EADDRINUSE; 1020 + goto out; 1021 + } 1022 + } 1023 + 1014 1024 err = mutex_lock_interruptible(&u->bindlock); 1015 1025 if (err) 1016 - goto out; 1026 + goto out_put; 1017 1027 1018 1028 err = -EINVAL; 1019 1029 if (u->addr) ··· 1041 1029 atomic_set(&addr->refcnt, 1); 1042 1030 1043 1031 if (sun_path[0]) { 1044 - struct path path; 1045 - umode_t mode = S_IFSOCK | 1046 - (SOCK_INODE(sock)->i_mode & ~current_umask()); 1047 - err = unix_mknod(sun_path, mode, &path); 1048 - if (err) { 1049 - if (err == -EEXIST) 1050 - err = -EADDRINUSE; 1051 - unix_release_addr(addr); 1052 - goto out_up; 1053 - } 1054 1032 addr->hash = UNIX_HASH_SIZE; 1055 1033 hash = d_backing_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1); 1056 1034 spin_lock(&unix_table_lock); ··· 1067 1065 spin_unlock(&unix_table_lock); 1068 1066 out_up: 1069 1067 mutex_unlock(&u->bindlock); 1068 + out_put: 1069 + if (err) 1070 + path_put(&path); 1070 1071 out: 1071 1072 return err; 1072 1073 }
+1
samples/bpf/tc_l2_redirect_kern.c
··· 4 4 * modify it under the terms of version 2 of the GNU General Public 5 5 * License as published by the Free Software Foundation. 6 6 */ 7 + #define KBUILD_MODNAME "foo" 7 8 #include <uapi/linux/bpf.h> 8 9 #include <uapi/linux/if_ether.h> 9 10 #include <uapi/linux/if_packet.h>
+1
samples/bpf/xdp_tx_iptunnel_kern.c
··· 8 8 * encapsulating the incoming packet in an IPv4/v6 header 9 9 * and then XDP_TX it out. 10 10 */ 11 + #define KBUILD_MODNAME "foo" 11 12 #include <uapi/linux/bpf.h> 12 13 #include <linux/in.h> 13 14 #include <linux/if_ether.h>
+27 -26
tools/testing/selftests/bpf/test_lru_map.c
··· 67 67 return map_subset(lru_map, expected) && map_subset(expected, lru_map); 68 68 } 69 69 70 - static int sched_next_online(int pid, int next_to_try) 70 + static int sched_next_online(int pid, int *next_to_try) 71 71 { 72 72 cpu_set_t cpuset; 73 + int next = *next_to_try; 74 + int ret = -1; 73 75 74 - if (next_to_try == nr_cpus) 75 - return -1; 76 - 77 - while (next_to_try < nr_cpus) { 76 + while (next < nr_cpus) { 78 77 CPU_ZERO(&cpuset); 79 - CPU_SET(next_to_try++, &cpuset); 80 - if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) 78 + CPU_SET(next++, &cpuset); 79 + if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) { 80 + ret = 0; 81 81 break; 82 + } 82 83 } 83 84 84 - return next_to_try; 85 + *next_to_try = next; 86 + return ret; 85 87 } 86 88 87 89 /* Size of the LRU amp is 2 ··· 98 96 { 99 97 unsigned long long key, value[nr_cpus]; 100 98 int lru_map_fd, expected_map_fd; 99 + int next_cpu = 0; 101 100 102 101 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 103 102 map_flags); 104 103 105 - assert(sched_next_online(0, 0) != -1); 104 + assert(sched_next_online(0, &next_cpu) != -1); 106 105 107 106 if (map_flags & BPF_F_NO_COMMON_LRU) 108 107 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus); ··· 186 183 int lru_map_fd, expected_map_fd; 187 184 unsigned int batch_size; 188 185 unsigned int map_size; 186 + int next_cpu = 0; 189 187 190 188 if (map_flags & BPF_F_NO_COMMON_LRU) 191 189 /* Ther percpu lru list (i.e each cpu has its own LRU ··· 200 196 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 201 197 map_flags); 202 198 203 - assert(sched_next_online(0, 0) != -1); 199 + assert(sched_next_online(0, &next_cpu) != -1); 204 200 205 201 batch_size = tgt_free / 2; 206 202 assert(batch_size * 2 == tgt_free); ··· 266 262 int lru_map_fd, expected_map_fd; 267 263 unsigned int batch_size; 268 264 unsigned int map_size; 265 + int next_cpu = 0; 269 266 270 267 if (map_flags & BPF_F_NO_COMMON_LRU) 271 268 /* Ther percpu lru list (i.e each cpu has its own LRU ··· 280 275 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 281 276 map_flags); 282 277 283 - assert(sched_next_online(0, 0) != -1); 278 + assert(sched_next_online(0, &next_cpu) != -1); 284 279 285 280 batch_size = tgt_free / 2; 286 281 assert(batch_size * 2 == tgt_free); ··· 375 370 int lru_map_fd, expected_map_fd; 376 371 unsigned int batch_size; 377 372 unsigned int map_size; 373 + int next_cpu = 0; 378 374 379 375 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 380 376 map_flags); 381 377 382 - assert(sched_next_online(0, 0) != -1); 378 + assert(sched_next_online(0, &next_cpu) != -1); 383 379 384 380 batch_size = tgt_free / 2; 385 381 assert(batch_size * 2 == tgt_free); ··· 436 430 int lru_map_fd, expected_map_fd; 437 431 unsigned long long key, value[nr_cpus]; 438 432 unsigned long long end_key; 433 + int next_cpu = 0; 439 434 440 435 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 441 436 map_flags); 442 437 443 - assert(sched_next_online(0, 0) != -1); 438 + assert(sched_next_online(0, &next_cpu) != -1); 444 439 445 440 if (map_flags & BPF_F_NO_COMMON_LRU) 446 441 lru_map_fd = create_map(map_type, map_flags, ··· 509 502 static void test_lru_sanity5(int map_type, int map_flags) 510 503 { 511 504 unsigned long long key, value[nr_cpus]; 512 - int next_sched_cpu = 0; 505 + int next_cpu = 0; 513 506 int map_fd; 514 - int i; 515 507 516 508 if (map_flags & BPF_F_NO_COMMON_LRU) 517 509 return; ··· 525 519 key = 0; 526 520 assert(!bpf_map_update(map_fd, &key, value, BPF_NOEXIST)); 527 521 528 - for (i = 0; i < nr_cpus; i++) { 522 + while (sched_next_online(0, &next_cpu) != -1) { 529 523 pid_t pid; 530 524 531 525 pid = fork(); 532 526 if (pid == 0) { 533 - next_sched_cpu = sched_next_online(0, next_sched_cpu); 534 - if (next_sched_cpu != -1) 535 - do_test_lru_sanity5(key, map_fd); 527 + do_test_lru_sanity5(key, map_fd); 536 528 exit(0); 537 529 } else if (pid == -1) { 538 - printf("couldn't spawn #%d process\n", i); 530 + printf("couldn't spawn process to test key:%llu\n", 531 + key); 539 532 exit(1); 540 533 } else { 541 534 int status; 542 - 543 - /* It is mostly redundant and just allow the parent 544 - * process to update next_shced_cpu for the next child 545 - * process 546 - */ 547 - next_sched_cpu = sched_next_online(pid, next_sched_cpu); 548 535 549 536 assert(waitpid(pid, &status, 0) == pid); 550 537 assert(status == 0); ··· 546 547 } 547 548 548 549 close(map_fd); 550 + /* At least one key should be tested */ 551 + assert(key > 0); 549 552 550 553 printf("Pass\n"); 551 554 }