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) Fix two regressions in ipv6 route lookups, particularly wrt output
interface specifications in the lookup key. From David Ahern.

2) Fix checks in ipv6 IPSEC tunnel pre-encap fragmentation, from
Herbert Xu.

3) Fix mis-advertisement of 1000BASE-T on bcm63xx_enet, from Simon
Arlott.

4) Some smsc phys misbehave with energy detect mode enabled, so add a
DT property and disable it on such switches. From Heiko Schocher.

5) Fix TSO corruption on TX in mv643xx_eth, from Philipp Kirchhofer.

6) Fix regression added by removal of openvswitch vport stats, from
James Morse.

7) Vendor Kconfig options should be bool, not tristate, from Andreas
Schwab.

8) Use non-_BH() net stats bump in tcp_xmit_probe_skb(), otherwise we
barf during TCP REPAIR operations.

9) Fix various bugs in openvswitch conntrack support, from Joe
Stringer.

10) Fix NETLINK_LIST_MEMBERSHIPS locking, from David Herrmann.

11) Don't have VSOCK do sock_put() in interrupt context, from Jorgen
Hansen.

12) Fix skb_realloc_headroom() failures properly in ISDN, from Karsten
Keil.

13) Add some device IDs to qmi_wwan, from Bjorn Mork.

14) Fix ovs egress tunnel information when using lwtunnel devices, from
Pravin B Shelar.

15) Add missing NETIF_F_FRAGLIST to macvtab feature list, from Jason
Wang.

16) Fix incorrect handling of throw routes when the result of the throw
cannot find a match, from Xin Long.

17) Protect ipv6 MTU calculations from wrap-around, from Hannes Frederic
Sowa.

18) Fix failed autonegotiation on KSZ9031 micrel PHYs, from Nathan
Sullivan.

19) Add missing memory barries in descriptor accesses or xgbe driver,
from Thomas Lendacky.

20) Fix release conditon test in pppoe_release(), from Guillaume Nault.

21) Fix gianfar bugs wrt filter configuration, from Claudiu Manoil.

22) Fix violations of RX buffer alignment in sh_eth driver, from Sergei
Shtylyov.

23) Fixing missing of_node_put() calls in various places around the
networking, from Julia Lawall.

24) Fix incorrect leaf now walking in ipv4 routing tree, from Alexander
Duyck.

25) RDS doesn't check pskb_pull()/pskb_trim() return values, from
Sowmini Varadhan.

26) Fix VLAN configuration in mlx4 driver, from Jack Morgenstein.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (79 commits)
ipv6: protect mtu calculation of wrap-around and infinite loop by rounding issues
Revert "Merge branch 'ipv6-overflow-arith'"
net/mlx4: Copy/set only sizeof struct mlx4_eqe bytes
net/mlx4_en: Explicitly set no vlan tags in WQE ctrl segment when no vlan is present
vhost: fix performance on LE hosts
bpf: sample: define aarch64 specific registers
amd-xgbe: Fix race between access of desc and desc index
RDS-TCP: Recover correctly from pskb_pull()/pksb_trim() failure in rds_tcp_data_recv
forcedeth: fix unilateral interrupt disabling in netpoll path
openvswitch: Fix skb leak using IPv6 defrag
ipv6: Export nf_ct_frag6_consume_orig()
openvswitch: Fix double-free on ip_defrag() errors
fib_trie: leaf_walk_rcu should not compute key if key is less than pn->key
net: mv643xx_eth: add missing of_node_put
ath6kl: add missing of_node_put
net: phy: mdio: add missing of_node_put
netdev/phy: add missing of_node_put
net: netcp: add missing of_node_put
net: thunderx: add missing of_node_put
ipv6: gre: support SIT encapsulation
...

+895 -478
+1
Documentation/devicetree/bindings/net/cpsw.txt
··· 39 39 Optional properties: 40 40 - dual_emac_res_vlan : Specifies VID to be used to segregate the ports 41 41 - mac-address : See ethernet.txt file in the same directory 42 + - phy-handle : See ethernet.txt file in the same directory 42 43 43 44 Note: "ti,hwmods" field is used to fetch the base address and irq 44 45 resources from TI, omap hwmod data base during device registration.
+24
Documentation/devicetree/bindings/net/smsc-lan87xx.txt
··· 1 + SMSC LAN87xx Ethernet PHY 2 + 3 + Some boards require special tuning values. Configure them 4 + through an Ethernet OF device node. 5 + 6 + Optional properties: 7 + 8 + - smsc,disable-energy-detect: 9 + If set, do not enable energy detect mode for the SMSC phy. 10 + default: enable energy detect mode 11 + 12 + Examples: 13 + smsc phy with disabled energy detect mode on an am335x based board. 14 + &davinci_mdio { 15 + pinctrl-names = "default", "sleep"; 16 + pinctrl-0 = <&davinci_mdio_default>; 17 + pinctrl-1 = <&davinci_mdio_sleep>; 18 + status = "okay"; 19 + 20 + ethernetphy0: ethernet-phy@0 { 21 + reg = <0>; 22 + smsc,disable-energy-detect; 23 + }; 24 + };
+8
MAINTAINERS
··· 4428 4428 S: Maintained 4429 4429 F: drivers/net/ethernet/freescale/ucc_geth* 4430 4430 4431 + FREESCALE eTSEC ETHERNET DRIVER (GIANFAR) 4432 + M: Claudiu Manoil <claudiu.manoil@freescale.com> 4433 + L: netdev@vger.kernel.org 4434 + S: Maintained 4435 + F: drivers/net/ethernet/freescale/gianfar* 4436 + X: drivers/net/ethernet/freescale/gianfar_ptp.c 4437 + F: Documentation/devicetree/bindings/net/fsl-tsec-phy.txt 4438 + 4431 4439 FREESCALE QUICC ENGINE UCC UART DRIVER 4432 4440 M: Timur Tabi <timur@tabi.org> 4433 4441 L: linuxppc-dev@lists.ozlabs.org
+8 -12
drivers/isdn/hisax/isdnl2.c
··· 1247 1247 l2_pull_iqueue(struct FsmInst *fi, int event, void *arg) 1248 1248 { 1249 1249 struct PStack *st = fi->userdata; 1250 - struct sk_buff *skb; 1250 + struct sk_buff *skb, *nskb; 1251 1251 struct Layer2 *l2 = &st->l2; 1252 1252 u_char header[MAX_HEADER_LEN]; 1253 1253 int i, hdr_space_needed; ··· 1262 1262 return; 1263 1263 1264 1264 hdr_space_needed = l2headersize(l2, 0); 1265 - if (hdr_space_needed > skb_headroom(skb)) { 1266 - struct sk_buff *orig_skb = skb; 1267 - 1268 - skb = skb_realloc_headroom(skb, hdr_space_needed); 1269 - if (!skb) { 1270 - dev_kfree_skb(orig_skb); 1271 - return; 1272 - } 1265 + nskb = skb_realloc_headroom(skb, hdr_space_needed); 1266 + if (!nskb) { 1267 + skb_queue_head(&l2->i_queue, skb); 1268 + return; 1273 1269 } 1274 1270 spin_lock_irqsave(&l2->lock, flags); 1275 1271 if (test_bit(FLG_MOD128, &l2->flag)) ··· 1278 1282 p1); 1279 1283 dev_kfree_skb(l2->windowar[p1]); 1280 1284 } 1281 - l2->windowar[p1] = skb_clone(skb, GFP_ATOMIC); 1285 + l2->windowar[p1] = skb; 1282 1286 1283 1287 i = sethdraddr(&st->l2, header, CMD); 1284 1288 ··· 1291 1295 l2->vs = (l2->vs + 1) % 8; 1292 1296 } 1293 1297 spin_unlock_irqrestore(&l2->lock, flags); 1294 - memcpy(skb_push(skb, i), header, i); 1295 - st->l2.l2l1(st, PH_PULL | INDICATION, skb); 1298 + memcpy(skb_push(nskb, i), header, i); 1299 + st->l2.l2l1(st, PH_PULL | INDICATION, nskb); 1296 1300 test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag); 1297 1301 if (!test_and_set_bit(FLG_T200_RUN, &st->l2.flag)) { 1298 1302 FsmDelTimer(&st->l2.t203, 13);
+20 -34
drivers/isdn/mISDN/layer2.c
··· 1476 1476 l2_pull_iqueue(struct FsmInst *fi, int event, void *arg) 1477 1477 { 1478 1478 struct layer2 *l2 = fi->userdata; 1479 - struct sk_buff *skb, *nskb, *oskb; 1479 + struct sk_buff *skb, *nskb; 1480 1480 u_char header[MAX_L2HEADER_LEN]; 1481 1481 u_int i, p1; 1482 1482 ··· 1486 1486 skb = skb_dequeue(&l2->i_queue); 1487 1487 if (!skb) 1488 1488 return; 1489 - 1490 - if (test_bit(FLG_MOD128, &l2->flag)) 1489 + i = sethdraddr(l2, header, CMD); 1490 + if (test_bit(FLG_MOD128, &l2->flag)) { 1491 + header[i++] = l2->vs << 1; 1492 + header[i++] = l2->vr << 1; 1493 + } else 1494 + header[i++] = (l2->vr << 5) | (l2->vs << 1); 1495 + nskb = skb_realloc_headroom(skb, i); 1496 + if (!nskb) { 1497 + printk(KERN_WARNING "%s: no headroom(%d) copy for IFrame\n", 1498 + mISDNDevName4ch(&l2->ch), i); 1499 + skb_queue_head(&l2->i_queue, skb); 1500 + return; 1501 + } 1502 + if (test_bit(FLG_MOD128, &l2->flag)) { 1491 1503 p1 = (l2->vs - l2->va) % 128; 1492 - else 1504 + l2->vs = (l2->vs + 1) % 128; 1505 + } else { 1493 1506 p1 = (l2->vs - l2->va) % 8; 1507 + l2->vs = (l2->vs + 1) % 8; 1508 + } 1494 1509 p1 = (p1 + l2->sow) % l2->window; 1495 1510 if (l2->windowar[p1]) { 1496 1511 printk(KERN_WARNING "%s: l2 try overwrite ack queue entry %d\n", ··· 1513 1498 dev_kfree_skb(l2->windowar[p1]); 1514 1499 } 1515 1500 l2->windowar[p1] = skb; 1516 - i = sethdraddr(l2, header, CMD); 1517 - if (test_bit(FLG_MOD128, &l2->flag)) { 1518 - header[i++] = l2->vs << 1; 1519 - header[i++] = l2->vr << 1; 1520 - l2->vs = (l2->vs + 1) % 128; 1521 - } else { 1522 - header[i++] = (l2->vr << 5) | (l2->vs << 1); 1523 - l2->vs = (l2->vs + 1) % 8; 1524 - } 1525 - 1526 - nskb = skb_clone(skb, GFP_ATOMIC); 1527 - p1 = skb_headroom(nskb); 1528 - if (p1 >= i) 1529 - memcpy(skb_push(nskb, i), header, i); 1530 - else { 1531 - printk(KERN_WARNING 1532 - "%s: L2 pull_iqueue skb header(%d/%d) too short\n", 1533 - mISDNDevName4ch(&l2->ch), i, p1); 1534 - oskb = nskb; 1535 - nskb = mI_alloc_skb(oskb->len + i, GFP_ATOMIC); 1536 - if (!nskb) { 1537 - dev_kfree_skb(oskb); 1538 - printk(KERN_WARNING "%s: no skb mem in %s\n", 1539 - mISDNDevName4ch(&l2->ch), __func__); 1540 - return; 1541 - } 1542 - memcpy(skb_put(nskb, i), header, i); 1543 - memcpy(skb_put(nskb, oskb->len), oskb->data, oskb->len); 1544 - dev_kfree_skb(oskb); 1545 - } 1501 + memcpy(skb_push(nskb, i), header, i); 1546 1502 l2down(l2, PH_DATA_REQ, l2_newid(l2), nskb); 1547 1503 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); 1548 1504 if (!test_and_set_bit(FLG_T200_RUN, &l2->flag)) {
+16 -4
drivers/net/ethernet/allwinner/sun4i-emac.c
··· 847 847 if (ndev->irq == -ENXIO) { 848 848 netdev_err(ndev, "No irq resource\n"); 849 849 ret = ndev->irq; 850 - goto out; 850 + goto out_iounmap; 851 851 } 852 852 853 853 db->clk = devm_clk_get(&pdev->dev, NULL); 854 854 if (IS_ERR(db->clk)) { 855 855 ret = PTR_ERR(db->clk); 856 - goto out; 856 + goto out_iounmap; 857 857 } 858 858 859 - clk_prepare_enable(db->clk); 859 + ret = clk_prepare_enable(db->clk); 860 + if (ret) { 861 + dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret); 862 + goto out_iounmap; 863 + } 860 864 861 865 ret = sunxi_sram_claim(&pdev->dev); 862 866 if (ret) { 863 867 dev_err(&pdev->dev, "Error couldn't map SRAM to device\n"); 864 - goto out; 868 + goto out_clk_disable_unprepare; 865 869 } 866 870 867 871 db->phy_node = of_parse_phandle(np, "phy", 0); ··· 914 910 915 911 out_release_sram: 916 912 sunxi_sram_release(&pdev->dev); 913 + out_clk_disable_unprepare: 914 + clk_disable_unprepare(db->clk); 915 + out_iounmap: 916 + iounmap(db->membase); 917 917 out: 918 918 dev_err(db->dev, "not found (%d).\n", ret); 919 919 ··· 929 921 static int emac_remove(struct platform_device *pdev) 930 922 { 931 923 struct net_device *ndev = platform_get_drvdata(pdev); 924 + struct emac_board_info *db = netdev_priv(ndev); 932 925 933 926 unregister_netdev(ndev); 927 + sunxi_sram_release(&pdev->dev); 928 + clk_disable_unprepare(db->clk); 929 + iounmap(db->membase); 934 930 free_netdev(ndev); 935 931 936 932 dev_dbg(&pdev->dev, "released and freed device\n");
+1 -1
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
··· 1595 1595 packet->rdesc_count, 1); 1596 1596 1597 1597 /* Make sure ownership is written to the descriptor */ 1598 - dma_wmb(); 1598 + smp_wmb(); 1599 1599 1600 1600 ring->cur = cur_index + 1; 1601 1601 if (!packet->skb->xmit_more ||
+7 -1
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
··· 1807 1807 struct netdev_queue *txq; 1808 1808 int processed = 0; 1809 1809 unsigned int tx_packets = 0, tx_bytes = 0; 1810 + unsigned int cur; 1810 1811 1811 1812 DBGPR("-->xgbe_tx_poll\n"); 1812 1813 ··· 1815 1814 if (!ring) 1816 1815 return 0; 1817 1816 1817 + cur = ring->cur; 1818 + 1819 + /* Be sure we get ring->cur before accessing descriptor data */ 1820 + smp_rmb(); 1821 + 1818 1822 txq = netdev_get_tx_queue(netdev, channel->queue_index); 1819 1823 1820 1824 while ((processed < XGBE_TX_DESC_MAX_PROC) && 1821 - (ring->dirty != ring->cur)) { 1825 + (ring->dirty != cur)) { 1822 1826 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); 1823 1827 rdesc = rdata->rdesc; 1824 1828
+18 -13
drivers/net/ethernet/broadcom/bcm63xx_enet.c
··· 2049 2049 2050 2050 for (i = 0; i < priv->num_ports; i++) { 2051 2051 struct bcm63xx_enetsw_port *port; 2052 - int val, j, up, advertise, lpa, lpa2, speed, duplex, media; 2052 + int val, j, up, advertise, lpa, speed, duplex, media; 2053 2053 int external_phy = bcm_enet_port_is_rgmii(i); 2054 2054 u8 override; 2055 2055 ··· 2092 2092 lpa = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id, 2093 2093 MII_LPA); 2094 2094 2095 - lpa2 = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id, 2096 - MII_STAT1000); 2097 - 2098 2095 /* figure out media and duplex from advertise and LPA values */ 2099 2096 media = mii_nway_result(lpa & advertise); 2100 2097 duplex = (media & ADVERTISE_FULL) ? 1 : 0; 2101 - if (lpa2 & LPA_1000FULL) 2102 - duplex = 1; 2103 2098 2104 - if (lpa2 & (LPA_1000FULL | LPA_1000HALF)) 2105 - speed = 1000; 2106 - else { 2107 - if (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)) 2108 - speed = 100; 2109 - else 2110 - speed = 10; 2099 + if (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)) 2100 + speed = 100; 2101 + else 2102 + speed = 10; 2103 + 2104 + if (val & BMSR_ESTATEN) { 2105 + advertise = bcmenet_sw_mdio_read(priv, external_phy, 2106 + port->phy_id, MII_CTRL1000); 2107 + 2108 + lpa = bcmenet_sw_mdio_read(priv, external_phy, 2109 + port->phy_id, MII_STAT1000); 2110 + 2111 + if (advertise & (ADVERTISE_1000FULL | ADVERTISE_1000HALF) 2112 + && lpa & (LPA_1000FULL | LPA_1000HALF)) { 2113 + speed = 1000; 2114 + duplex = (lpa & LPA_1000FULL); 2115 + } 2111 2116 } 2112 2117 2113 2118 dev_info(&priv->pdev->dev,
+1 -1
drivers/net/ethernet/cavium/Kconfig
··· 3 3 # 4 4 5 5 config NET_VENDOR_CAVIUM 6 - tristate "Cavium ethernet drivers" 6 + bool "Cavium ethernet drivers" 7 7 depends on PCI 8 8 default y 9 9 ---help---
+29 -13
drivers/net/ethernet/cavium/thunder/nic_main.c
··· 22 22 23 23 struct nicpf { 24 24 struct pci_dev *pdev; 25 - u8 rev_id; 26 25 u8 node; 27 26 unsigned int flags; 28 27 u8 num_vf_en; /* No of VF enabled */ ··· 43 44 u8 duplex[MAX_LMAC]; 44 45 u32 speed[MAX_LMAC]; 45 46 u16 cpi_base[MAX_NUM_VFS_SUPPORTED]; 47 + u16 rssi_base[MAX_NUM_VFS_SUPPORTED]; 46 48 u16 rss_ind_tbl_size; 47 49 bool mbx_lock[MAX_NUM_VFS_SUPPORTED]; 48 50 ··· 53 53 struct msix_entry msix_entries[NIC_PF_MSIX_VECTORS]; 54 54 bool irq_allocated[NIC_PF_MSIX_VECTORS]; 55 55 }; 56 + 57 + static inline bool pass1_silicon(struct nicpf *nic) 58 + { 59 + return nic->pdev->revision < 8; 60 + } 56 61 57 62 /* Supported devices */ 58 63 static const struct pci_device_id nic_id_table[] = { ··· 122 117 * when PF writes to MBOX(1), in next revisions when 123 118 * PF writes to MBOX(0) 124 119 */ 125 - if (nic->rev_id == 0) { 120 + if (pass1_silicon(nic)) { 126 121 /* see the comment for nic_reg_write()/nic_reg_read() 127 122 * functions above 128 123 */ ··· 310 305 { 311 306 int i; 312 307 313 - /* Reset NIC, in case the driver is repeatedly inserted and removed */ 314 - nic_reg_write(nic, NIC_PF_SOFT_RESET, 1); 315 - 316 308 /* Enable NIC HW block */ 317 309 nic_reg_write(nic, NIC_PF_CFG, 0x3); 318 310 ··· 397 395 padd = cpi % 8; /* 3 bits CS out of 6bits DSCP */ 398 396 399 397 /* Leave RSS_SIZE as '0' to disable RSS */ 400 - nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3), 401 - (vnic << 24) | (padd << 16) | (rssi_base + rssi)); 398 + if (pass1_silicon(nic)) { 399 + nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3), 400 + (vnic << 24) | (padd << 16) | 401 + (rssi_base + rssi)); 402 + } else { 403 + /* Set MPI_ALG to '0' to disable MCAM parsing */ 404 + nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi << 3), 405 + (padd << 16)); 406 + /* MPI index is same as CPI if MPI_ALG is not enabled */ 407 + nic_reg_write(nic, NIC_PF_MPI_0_2047_CFG | (cpi << 3), 408 + (vnic << 24) | (rssi_base + rssi)); 409 + } 402 410 403 411 if ((rssi + 1) >= cfg->rq_cnt) 404 412 continue; ··· 421 409 rssi = ((cpi - cpi_base) & 0x38) >> 3; 422 410 } 423 411 nic->cpi_base[cfg->vf_id] = cpi_base; 412 + nic->rssi_base[cfg->vf_id] = rssi_base; 424 413 } 425 414 426 415 /* Responsds to VF with its RSS indirection table size */ ··· 447 434 { 448 435 u8 qset, idx = 0; 449 436 u64 cpi_cfg, cpi_base, rssi_base, rssi; 437 + u64 idx_addr; 450 438 451 - cpi_base = nic->cpi_base[cfg->vf_id]; 452 - cpi_cfg = nic_reg_read(nic, NIC_PF_CPI_0_2047_CFG | (cpi_base << 3)); 453 - rssi_base = (cpi_cfg & 0x0FFF) + cfg->tbl_offset; 439 + rssi_base = nic->rssi_base[cfg->vf_id] + cfg->tbl_offset; 454 440 455 441 rssi = rssi_base; 456 442 qset = cfg->vf_id; ··· 466 454 idx++; 467 455 } 468 456 457 + cpi_base = nic->cpi_base[cfg->vf_id]; 458 + if (pass1_silicon(nic)) 459 + idx_addr = NIC_PF_CPI_0_2047_CFG; 460 + else 461 + idx_addr = NIC_PF_MPI_0_2047_CFG; 462 + cpi_cfg = nic_reg_read(nic, idx_addr | (cpi_base << 3)); 469 463 cpi_cfg &= ~(0xFULL << 20); 470 464 cpi_cfg |= (cfg->hash_bits << 20); 471 - nic_reg_write(nic, NIC_PF_CPI_0_2047_CFG | (cpi_base << 3), cpi_cfg); 465 + nic_reg_write(nic, idx_addr | (cpi_base << 3), cpi_cfg); 472 466 } 473 467 474 468 /* 4 level transmit side scheduler configutation ··· 1018 1000 err = -ENOMEM; 1019 1001 goto err_release_regions; 1020 1002 } 1021 - 1022 - pci_read_config_byte(pdev, PCI_REVISION_ID, &nic->rev_id); 1023 1003 1024 1004 nic->node = nic_get_node_id(pdev); 1025 1005
+4
drivers/net/ethernet/cavium/thunder/nic_reg.h
··· 85 85 #define NIC_PF_ECC3_DBE_INT_W1S (0x2708) 86 86 #define NIC_PF_ECC3_DBE_ENA_W1C (0x2710) 87 87 #define NIC_PF_ECC3_DBE_ENA_W1S (0x2718) 88 + #define NIC_PF_MCAM_0_191_ENA (0x100000) 89 + #define NIC_PF_MCAM_0_191_M_0_5_DATA (0x110000) 90 + #define NIC_PF_MCAM_CTRL (0x120000) 88 91 #define NIC_PF_CPI_0_2047_CFG (0x200000) 92 + #define NIC_PF_MPI_0_2047_CFG (0x210000) 89 93 #define NIC_PF_RSSI_0_4097_RQ (0x220000) 90 94 #define NIC_PF_LMAC_0_7_CFG (0x240000) 91 95 #define NIC_PF_LMAC_0_7_SW_XOFF (0x242000)
+1 -1
drivers/net/ethernet/cavium/thunder/nicvf_main.c
··· 29 29 static const struct pci_device_id nicvf_id_table[] = { 30 30 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM, 31 31 PCI_DEVICE_ID_THUNDER_NIC_VF, 32 - PCI_VENDOR_ID_CAVIUM, 0xA11E) }, 32 + PCI_VENDOR_ID_CAVIUM, 0xA134) }, 33 33 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM, 34 34 PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF, 35 35 PCI_VENDOR_ID_CAVIUM, 0xA11E) },
+3 -1
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 977 977 SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); 978 978 bgx->lmac[lmac].lmacid = lmac; 979 979 lmac++; 980 - if (lmac == MAX_LMAC_PER_BGX) 980 + if (lmac == MAX_LMAC_PER_BGX) { 981 + of_node_put(np_child); 981 982 break; 983 + } 982 984 } 983 985 return 0; 984 986 }
+3 -5
drivers/net/ethernet/freescale/gianfar.c
··· 341 341 if (priv->ndev->features & (NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX)) 342 342 priv->uses_rxfcb = 1; 343 343 344 - if (priv->hwts_rx_en) 344 + if (priv->hwts_rx_en || priv->rx_filer_enable) 345 345 priv->uses_rxfcb = 1; 346 346 } 347 347 ··· 351 351 u32 rctrl = 0; 352 352 353 353 if (priv->rx_filer_enable) { 354 - rctrl |= RCTRL_FILREN; 354 + rctrl |= RCTRL_FILREN | RCTRL_PRSDEP_INIT; 355 355 /* Program the RIR0 reg with the required distribution */ 356 356 if (priv->poll_mode == GFAR_SQ_POLLING) 357 357 gfar_write(&regs->rir0, DEFAULT_2RXQ_RIR0); ··· 3462 3462 netif_dbg(priv, tx_err, dev, "Transmit Error\n"); 3463 3463 } 3464 3464 if (events & IEVENT_BSY) { 3465 - dev->stats.rx_errors++; 3465 + dev->stats.rx_over_errors++; 3466 3466 atomic64_inc(&priv->extra_stats.rx_bsy); 3467 - 3468 - gfar_receive(irq, grp_id); 3469 3467 3470 3468 netif_dbg(priv, rx_err, dev, "busy error (rstat: %x)\n", 3471 3469 gfar_read(&regs->rstat));
+2 -2
drivers/net/ethernet/freescale/gianfar_ethtool.c
··· 676 676 u32 fcr = 0x0, fpr = FPR_FILER_MASK; 677 677 678 678 if (ethflow & RXH_L2DA) { 679 - fcr = RQFCR_PID_DAH |RQFCR_CMP_NOMATCH | 679 + fcr = RQFCR_PID_DAH | RQFCR_CMP_NOMATCH | 680 680 RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0; 681 681 priv->ftp_rqfpr[priv->cur_filer_idx] = fpr; 682 682 priv->ftp_rqfcr[priv->cur_filer_idx] = fcr; 683 683 gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr); 684 684 priv->cur_filer_idx = priv->cur_filer_idx - 1; 685 685 686 - fcr = RQFCR_PID_DAL | RQFCR_AND | RQFCR_CMP_NOMATCH | 686 + fcr = RQFCR_PID_DAL | RQFCR_CMP_NOMATCH | 687 687 RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0; 688 688 priv->ftp_rqfpr[priv->cur_filer_idx] = fpr; 689 689 priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
+6
drivers/net/ethernet/intel/i40e/i40e_ethtool.c
··· 1344 1344 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat == 1345 1345 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; 1346 1346 } 1347 + for (j = 0; j < I40E_MAX_TRAFFIC_CLASS; j++) { 1348 + data[i++] = veb->tc_stats.tc_tx_packets[j]; 1349 + data[i++] = veb->tc_stats.tc_tx_bytes[j]; 1350 + data[i++] = veb->tc_stats.tc_rx_packets[j]; 1351 + data[i++] = veb->tc_stats.tc_rx_bytes[j]; 1352 + } 1347 1353 } 1348 1354 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) { 1349 1355 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
+1
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 7911 7911 if (pf->hw.func_caps.vmdq) { 7912 7912 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI; 7913 7913 pf->flags |= I40E_FLAG_VMDQ_ENABLED; 7914 + pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf); 7914 7915 } 7915 7916 7916 7917 #ifdef I40E_FCOE
+43 -9
drivers/net/ethernet/marvell/mv643xx_eth.c
··· 759 759 760 760 desc->l4i_chk = 0; 761 761 desc->byte_cnt = length; 762 - desc->buf_ptr = dma_map_single(dev->dev.parent, data, 763 - length, DMA_TO_DEVICE); 764 - if (unlikely(dma_mapping_error(dev->dev.parent, desc->buf_ptr))) { 765 - WARN(1, "dma_map_single failed!\n"); 766 - return -ENOMEM; 762 + 763 + if (length <= 8 && (uintptr_t)data & 0x7) { 764 + /* Copy unaligned small data fragment to TSO header data area */ 765 + memcpy(txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE, 766 + data, length); 767 + desc->buf_ptr = txq->tso_hdrs_dma 768 + + txq->tx_curr_desc * TSO_HEADER_SIZE; 769 + } else { 770 + /* Alignment is okay, map buffer and hand off to hardware */ 771 + txq->tx_desc_mapping[tx_index] = DESC_DMA_MAP_SINGLE; 772 + desc->buf_ptr = dma_map_single(dev->dev.parent, data, 773 + length, DMA_TO_DEVICE); 774 + if (unlikely(dma_mapping_error(dev->dev.parent, 775 + desc->buf_ptr))) { 776 + WARN(1, "dma_map_single failed!\n"); 777 + return -ENOMEM; 778 + } 767 779 } 768 780 769 781 cmd_sts = BUFFER_OWNED_BY_DMA; ··· 791 779 } 792 780 793 781 static inline void 794 - txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length) 782 + txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length, 783 + u32 *first_cmd_sts, bool first_desc) 795 784 { 796 785 struct mv643xx_eth_private *mp = txq_to_mp(txq); 797 786 int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); ··· 801 788 int ret; 802 789 u32 cmd_csum = 0; 803 790 u16 l4i_chk = 0; 791 + u32 cmd_sts; 804 792 805 793 tx_index = txq->tx_curr_desc; 806 794 desc = &txq->tx_desc_area[tx_index]; ··· 817 803 desc->byte_cnt = hdr_len; 818 804 desc->buf_ptr = txq->tso_hdrs_dma + 819 805 txq->tx_curr_desc * TSO_HEADER_SIZE; 820 - desc->cmd_sts = cmd_csum | BUFFER_OWNED_BY_DMA | TX_FIRST_DESC | 806 + cmd_sts = cmd_csum | BUFFER_OWNED_BY_DMA | TX_FIRST_DESC | 821 807 GEN_CRC; 808 + 809 + /* Defer updating the first command descriptor until all 810 + * following descriptors have been written. 811 + */ 812 + if (first_desc) 813 + *first_cmd_sts = cmd_sts; 814 + else 815 + desc->cmd_sts = cmd_sts; 822 816 823 817 txq->tx_curr_desc++; 824 818 if (txq->tx_curr_desc == txq->tx_ring_size) ··· 841 819 int desc_count = 0; 842 820 struct tso_t tso; 843 821 int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 822 + struct tx_desc *first_tx_desc; 823 + u32 first_cmd_sts = 0; 844 824 845 825 /* Count needed descriptors */ 846 826 if ((txq->tx_desc_count + tso_count_descs(skb)) >= txq->tx_ring_size) { ··· 850 826 return -EBUSY; 851 827 } 852 828 829 + first_tx_desc = &txq->tx_desc_area[txq->tx_curr_desc]; 830 + 853 831 /* Initialize the TSO handler, and prepare the first payload */ 854 832 tso_start(skb, &tso); 855 833 856 834 total_len = skb->len - hdr_len; 857 835 while (total_len > 0) { 836 + bool first_desc = (desc_count == 0); 858 837 char *hdr; 859 838 860 839 data_left = min_t(int, skb_shinfo(skb)->gso_size, total_len); ··· 867 840 /* prepare packet headers: MAC + IP + TCP */ 868 841 hdr = txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE; 869 842 tso_build_hdr(skb, hdr, &tso, data_left, total_len == 0); 870 - txq_put_hdr_tso(skb, txq, data_left); 843 + txq_put_hdr_tso(skb, txq, data_left, &first_cmd_sts, 844 + first_desc); 871 845 872 846 while (data_left > 0) { 873 847 int size; ··· 887 859 888 860 __skb_queue_tail(&txq->tx_skb, skb); 889 861 skb_tx_timestamp(skb); 862 + 863 + /* ensure all other descriptors are written before first cmd_sts */ 864 + wmb(); 865 + first_tx_desc->cmd_sts = first_cmd_sts; 890 866 891 867 /* clear TX_END status */ 892 868 mp->work_tx_end &= ~(1 << txq->index); ··· 2817 2785 2818 2786 for_each_available_child_of_node(np, pnp) { 2819 2787 ret = mv643xx_eth_shared_of_add_port(pdev, pnp); 2820 - if (ret) 2788 + if (ret) { 2789 + of_node_put(pnp); 2821 2790 return ret; 2791 + } 2822 2792 } 2823 2793 return 0; 2824 2794 }
+1 -1
drivers/net/ethernet/mellanox/mlx4/cmd.c
··· 2398 2398 } 2399 2399 } 2400 2400 2401 - memset(&priv->mfunc.master.cmd_eqe, 0, dev->caps.eqe_size); 2401 + memset(&priv->mfunc.master.cmd_eqe, 0, sizeof(struct mlx4_eqe)); 2402 2402 priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD; 2403 2403 INIT_WORK(&priv->mfunc.master.comm_work, 2404 2404 mlx4_master_comm_channel);
+2
drivers/net/ethernet/mellanox/mlx4/en_tx.c
··· 964 964 tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_SVLAN; 965 965 else if (vlan_proto == ETH_P_8021Q) 966 966 tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_CVLAN; 967 + else 968 + tx_desc->ctrl.ins_vlan = 0; 967 969 968 970 tx_desc->ctrl.fence_size = real_size; 969 971
+1 -1
drivers/net/ethernet/mellanox/mlx4/eq.c
··· 196 196 return; 197 197 } 198 198 199 - memcpy(s_eqe, eqe, dev->caps.eqe_size - 1); 199 + memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1); 200 200 s_eqe->slave_id = slave; 201 201 /* ensure all information is written before setting the ownersip bit */ 202 202 dma_wmb();
+11 -13
drivers/net/ethernet/nvidia/forcedeth.c
··· 4076 4076 struct fe_priv *np = netdev_priv(dev); 4077 4077 u8 __iomem *base = get_hwbase(dev); 4078 4078 u32 mask = 0; 4079 + unsigned long flags; 4080 + unsigned int irq = 0; 4079 4081 4080 4082 /* 4081 4083 * First disable irq(s) and then ··· 4087 4085 4088 4086 if (!using_multi_irqs(dev)) { 4089 4087 if (np->msi_flags & NV_MSI_X_ENABLED) 4090 - disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); 4088 + irq = np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector; 4091 4089 else 4092 - disable_irq_lockdep(np->pci_dev->irq); 4090 + irq = np->pci_dev->irq; 4093 4091 mask = np->irqmask; 4094 4092 } else { 4095 4093 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { 4096 - disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); 4094 + irq = np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector; 4097 4095 mask |= NVREG_IRQ_RX_ALL; 4098 4096 } 4099 4097 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) { 4100 - disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); 4098 + irq = np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector; 4101 4099 mask |= NVREG_IRQ_TX_ALL; 4102 4100 } 4103 4101 if (np->nic_poll_irq & NVREG_IRQ_OTHER) { 4104 - disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); 4102 + irq = np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector; 4105 4103 mask |= NVREG_IRQ_OTHER; 4106 4104 } 4107 4105 } 4108 - /* disable_irq() contains synchronize_irq, thus no irq handler can run now */ 4106 + 4107 + disable_irq_nosync_lockdep_irqsave(irq, &flags); 4108 + synchronize_irq(irq); 4109 4109 4110 4110 if (np->recover_error) { 4111 4111 np->recover_error = 0; ··· 4160 4156 nv_nic_irq_optimized(0, dev); 4161 4157 else 4162 4158 nv_nic_irq(0, dev); 4163 - if (np->msi_flags & NV_MSI_X_ENABLED) 4164 - enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); 4165 - else 4166 - enable_irq_lockdep(np->pci_dev->irq); 4167 4159 } else { 4168 4160 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { 4169 4161 np->nic_poll_irq &= ~NVREG_IRQ_RX_ALL; 4170 4162 nv_nic_irq_rx(0, dev); 4171 - enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); 4172 4163 } 4173 4164 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) { 4174 4165 np->nic_poll_irq &= ~NVREG_IRQ_TX_ALL; 4175 4166 nv_nic_irq_tx(0, dev); 4176 - enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); 4177 4167 } 4178 4168 if (np->nic_poll_irq & NVREG_IRQ_OTHER) { 4179 4169 np->nic_poll_irq &= ~NVREG_IRQ_OTHER; 4180 4170 nv_nic_irq_other(0, dev); 4181 - enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); 4182 4171 } 4183 4172 } 4184 4173 4174 + enable_irq_lockdep_irqrestore(irq, &flags); 4185 4175 } 4186 4176 4187 4177 #ifdef CONFIG_NET_POLL_CONTROLLER
+7 -7
drivers/net/ethernet/renesas/sh_eth.c
··· 1127 1127 struct sh_eth_txdesc *txdesc = NULL; 1128 1128 int rx_ringsize = sizeof(*rxdesc) * mdp->num_rx_ring; 1129 1129 int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring; 1130 - int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN - 1; 1130 + int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1; 1131 1131 dma_addr_t dma_addr; 1132 1132 1133 1133 mdp->cur_rx = 0; ··· 1148 1148 1149 1149 /* RX descriptor */ 1150 1150 rxdesc = &mdp->rx_ring[i]; 1151 - /* The size of the buffer is a multiple of 16 bytes. */ 1152 - rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); 1151 + /* The size of the buffer is a multiple of 32 bytes. */ 1152 + rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32); 1153 1153 dma_addr = dma_map_single(&ndev->dev, skb->data, 1154 1154 rxdesc->buffer_length, 1155 1155 DMA_FROM_DEVICE); ··· 1450 1450 struct sk_buff *skb; 1451 1451 u16 pkt_len = 0; 1452 1452 u32 desc_status; 1453 - int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN - 1; 1453 + int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1; 1454 1454 dma_addr_t dma_addr; 1455 1455 1456 1456 boguscnt = min(boguscnt, *quota); ··· 1506 1506 if (mdp->cd->rpadir) 1507 1507 skb_reserve(skb, NET_IP_ALIGN); 1508 1508 dma_unmap_single(&ndev->dev, rxdesc->addr, 1509 - ALIGN(mdp->rx_buf_sz, 16), 1509 + ALIGN(mdp->rx_buf_sz, 32), 1510 1510 DMA_FROM_DEVICE); 1511 1511 skb_put(skb, pkt_len); 1512 1512 skb->protocol = eth_type_trans(skb, ndev); ··· 1524 1524 for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) { 1525 1525 entry = mdp->dirty_rx % mdp->num_rx_ring; 1526 1526 rxdesc = &mdp->rx_ring[entry]; 1527 - /* The size of the buffer is 16 byte boundary. */ 1528 - rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); 1527 + /* The size of the buffer is 32 byte boundary. */ 1528 + rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32); 1529 1529 1530 1530 if (mdp->rx_skbuff[entry] == NULL) { 1531 1531 skb = netdev_alloc_skb(ndev, skbuff_size);
+11 -4
drivers/net/ethernet/ti/cpsw.c
··· 30 30 #include <linux/delay.h> 31 31 #include <linux/pm_runtime.h> 32 32 #include <linux/of.h> 33 + #include <linux/of_mdio.h> 33 34 #include <linux/of_net.h> 34 35 #include <linux/of_device.h> 35 36 #include <linux/if_vlan.h> ··· 366 365 spinlock_t lock; 367 366 struct platform_device *pdev; 368 367 struct net_device *ndev; 368 + struct device_node *phy_node; 369 369 struct napi_struct napi_rx; 370 370 struct napi_struct napi_tx; 371 371 struct device *dev; ··· 1147 1145 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1148 1146 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); 1149 1147 1150 - slave->phy = phy_connect(priv->ndev, slave->data->phy_id, 1148 + if (priv->phy_node) 1149 + slave->phy = of_phy_connect(priv->ndev, priv->phy_node, 1150 + &cpsw_adjust_link, 0, slave->data->phy_if); 1151 + else 1152 + slave->phy = phy_connect(priv->ndev, slave->data->phy_id, 1151 1153 &cpsw_adjust_link, slave->data->phy_if); 1152 1154 if (IS_ERR(slave->phy)) { 1153 1155 dev_err(priv->dev, "phy %s not found on slave %d\n", ··· 1940 1934 slave->port_vlan = data->dual_emac_res_vlan; 1941 1935 } 1942 1936 1943 - static int cpsw_probe_dt(struct cpsw_platform_data *data, 1937 + static int cpsw_probe_dt(struct cpsw_priv *priv, 1944 1938 struct platform_device *pdev) 1945 1939 { 1946 1940 struct device_node *node = pdev->dev.of_node; 1947 1941 struct device_node *slave_node; 1942 + struct cpsw_platform_data *data = &priv->data; 1948 1943 int i = 0, ret; 1949 1944 u32 prop; 1950 1945 ··· 2036 2029 if (strcmp(slave_node->name, "slave")) 2037 2030 continue; 2038 2031 2032 + priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); 2039 2033 parp = of_get_property(slave_node, "phy_id", &lenp); 2040 2034 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { 2041 2035 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i); ··· 2052 2044 } 2053 2045 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 2054 2046 PHY_ID_FMT, mdio->name, phyid); 2055 - 2056 2047 slave_data->phy_if = of_get_phy_mode(slave_node); 2057 2048 if (slave_data->phy_if < 0) { 2058 2049 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n", ··· 2247 2240 /* Select default pin state */ 2248 2241 pinctrl_pm_select_default_state(&pdev->dev); 2249 2242 2250 - if (cpsw_probe_dt(&priv->data, pdev)) { 2243 + if (cpsw_probe_dt(priv, pdev)) { 2251 2244 dev_err(&pdev->dev, "cpsw: platform data missing\n"); 2252 2245 ret = -ENODEV; 2253 2246 goto clean_runtime_disable_ret;
+6 -2
drivers/net/ethernet/ti/netcp_ethss.c
··· 2637 2637 mac_phy_link = true; 2638 2638 2639 2639 slave->open = true; 2640 - if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) 2640 + if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) { 2641 + of_node_put(port); 2641 2642 break; 2643 + } 2642 2644 } 2643 2645 2644 2646 /* of_phy_connect() is needed only for MAC-PHY interface */ ··· 3139 3137 continue; 3140 3138 } 3141 3139 gbe_dev->num_slaves++; 3142 - if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) 3140 + if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) { 3141 + of_node_put(interface); 3143 3142 break; 3143 + } 3144 3144 } 3145 3145 of_node_put(interfaces); 3146 3146
+33 -7
drivers/net/geneve.c
··· 594 594 rt = ip_route_output_key(geneve->net, fl4); 595 595 if (IS_ERR(rt)) { 596 596 netdev_dbg(dev, "no route to %pI4\n", &fl4->daddr); 597 - dev->stats.tx_carrier_errors++; 598 - return rt; 597 + return ERR_PTR(-ENETUNREACH); 599 598 } 600 599 if (rt->dst.dev == dev) { /* is this necessary? */ 601 600 netdev_dbg(dev, "circular route to %pI4\n", &fl4->daddr); 602 - dev->stats.collisions++; 603 601 ip_rt_put(rt); 604 - return ERR_PTR(-EINVAL); 602 + return ERR_PTR(-ELOOP); 605 603 } 606 604 return rt; 607 605 } ··· 625 627 struct ip_tunnel_info *info = NULL; 626 628 struct rtable *rt = NULL; 627 629 const struct iphdr *iip; /* interior IP header */ 630 + int err = -EINVAL; 628 631 struct flowi4 fl4; 629 632 __u8 tos, ttl; 630 633 __be16 sport; 631 634 bool udp_csum; 632 635 __be16 df; 633 - int err; 634 636 635 637 if (geneve->collect_md) { 636 638 info = skb_tunnel_info(skb); ··· 645 647 rt = geneve_get_rt(skb, dev, &fl4, info); 646 648 if (IS_ERR(rt)) { 647 649 netdev_dbg(dev, "no route to %pI4\n", &fl4.daddr); 648 - dev->stats.tx_carrier_errors++; 650 + err = PTR_ERR(rt); 649 651 goto tx_error; 650 652 } 651 653 ··· 697 699 tx_error: 698 700 dev_kfree_skb(skb); 699 701 err: 700 - dev->stats.tx_errors++; 702 + if (err == -ELOOP) 703 + dev->stats.collisions++; 704 + else if (err == -ENETUNREACH) 705 + dev->stats.tx_carrier_errors++; 706 + else 707 + dev->stats.tx_errors++; 701 708 return NETDEV_TX_OK; 709 + } 710 + 711 + static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) 712 + { 713 + struct ip_tunnel_info *info = skb_tunnel_info(skb); 714 + struct geneve_dev *geneve = netdev_priv(dev); 715 + struct rtable *rt; 716 + struct flowi4 fl4; 717 + 718 + if (ip_tunnel_info_af(info) != AF_INET) 719 + return -EINVAL; 720 + 721 + rt = geneve_get_rt(skb, dev, &fl4, info); 722 + if (IS_ERR(rt)) 723 + return PTR_ERR(rt); 724 + 725 + ip_rt_put(rt); 726 + info->key.u.ipv4.src = fl4.saddr; 727 + info->key.tp_src = udp_flow_src_port(geneve->net, skb, 728 + 1, USHRT_MAX, true); 729 + info->key.tp_dst = geneve->dst_port; 730 + return 0; 702 731 } 703 732 704 733 static const struct net_device_ops geneve_netdev_ops = { ··· 738 713 .ndo_change_mtu = eth_change_mtu, 739 714 .ndo_validate_addr = eth_validate_addr, 740 715 .ndo_set_mac_address = eth_mac_addr, 716 + .ndo_fill_metadata_dst = geneve_fill_metadata_dst, 741 717 }; 742 718 743 719 static void geneve_get_drvinfo(struct net_device *dev,
+1 -1
drivers/net/macvtap.c
··· 137 137 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \ 138 138 NETIF_F_TSO6 | NETIF_F_UFO) 139 139 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO) 140 - #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG) 140 + #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG | NETIF_F_FRAGLIST) 141 141 142 142 static struct macvlan_dev *macvtap_get_vlan_rcu(const struct net_device *dev) 143 143 {
+5
drivers/net/phy/Kconfig
··· 122 122 ---help--- 123 123 Supports the KSZ9021, VSC8201, KS8001 PHYs. 124 124 125 + config DP83848_PHY 126 + tristate "Driver for Texas Instruments DP83848 PHY" 127 + ---help--- 128 + Supports the DP83848 PHY. 129 + 125 130 config DP83867_PHY 126 131 tristate "Drivers for Texas Instruments DP83867 Gigabit PHY" 127 132 ---help---
+1
drivers/net/phy/Makefile
··· 24 24 obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o 25 25 obj-$(CONFIG_NATIONAL_PHY) += national.o 26 26 obj-$(CONFIG_DP83640_PHY) += dp83640.o 27 + obj-$(CONFIG_DP83848_PHY) += dp83848.o 27 28 obj-$(CONFIG_DP83867_PHY) += dp83867.o 28 29 obj-$(CONFIG_STE10XP) += ste10Xp.o 29 30 obj-$(CONFIG_MICREL_PHY) += micrel.o
+99
drivers/net/phy/dp83848.c
··· 1 + /* 2 + * Driver for the Texas Instruments DP83848 PHY 3 + * 4 + * Copyright (C) 2015 Texas Instruments Inc. 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/module.h> 17 + #include <linux/phy.h> 18 + 19 + #define DP83848_PHY_ID 0x20005c90 20 + 21 + /* Registers */ 22 + #define DP83848_MICR 0x11 23 + #define DP83848_MISR 0x12 24 + 25 + /* MICR Register Fields */ 26 + #define DP83848_MICR_INT_OE BIT(0) /* Interrupt Output Enable */ 27 + #define DP83848_MICR_INTEN BIT(1) /* Interrupt Enable */ 28 + 29 + /* MISR Register Fields */ 30 + #define DP83848_MISR_RHF_INT_EN BIT(0) /* Receive Error Counter */ 31 + #define DP83848_MISR_FHF_INT_EN BIT(1) /* False Carrier Counter */ 32 + #define DP83848_MISR_ANC_INT_EN BIT(2) /* Auto-negotiation complete */ 33 + #define DP83848_MISR_DUP_INT_EN BIT(3) /* Duplex Status */ 34 + #define DP83848_MISR_SPD_INT_EN BIT(4) /* Speed status */ 35 + #define DP83848_MISR_LINK_INT_EN BIT(5) /* Link status */ 36 + #define DP83848_MISR_ED_INT_EN BIT(6) /* Energy detect */ 37 + #define DP83848_MISR_LQM_INT_EN BIT(7) /* Link Quality Monitor */ 38 + 39 + static int dp83848_ack_interrupt(struct phy_device *phydev) 40 + { 41 + int err = phy_read(phydev, DP83848_MISR); 42 + 43 + return err < 0 ? err : 0; 44 + } 45 + 46 + static int dp83848_config_intr(struct phy_device *phydev) 47 + { 48 + int err; 49 + 50 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 51 + err = phy_write(phydev, DP83848_MICR, 52 + DP83848_MICR_INT_OE | 53 + DP83848_MICR_INTEN); 54 + if (err < 0) 55 + return err; 56 + 57 + return phy_write(phydev, DP83848_MISR, 58 + DP83848_MISR_ANC_INT_EN | 59 + DP83848_MISR_DUP_INT_EN | 60 + DP83848_MISR_SPD_INT_EN | 61 + DP83848_MISR_LINK_INT_EN); 62 + } 63 + 64 + return phy_write(phydev, DP83848_MICR, 0x0); 65 + } 66 + 67 + static struct mdio_device_id __maybe_unused dp83848_tbl[] = { 68 + { DP83848_PHY_ID, 0xfffffff0 }, 69 + { } 70 + }; 71 + MODULE_DEVICE_TABLE(mdio, dp83848_tbl); 72 + 73 + static struct phy_driver dp83848_driver[] = { 74 + { 75 + .phy_id = DP83848_PHY_ID, 76 + .phy_id_mask = 0xfffffff0, 77 + .name = "TI DP83848", 78 + .features = PHY_BASIC_FEATURES, 79 + .flags = PHY_HAS_INTERRUPT, 80 + 81 + .soft_reset = genphy_soft_reset, 82 + .config_init = genphy_config_init, 83 + .suspend = genphy_suspend, 84 + .resume = genphy_resume, 85 + .config_aneg = genphy_config_aneg, 86 + .read_status = genphy_read_status, 87 + 88 + /* IRQ related */ 89 + .ack_interrupt = dp83848_ack_interrupt, 90 + .config_intr = dp83848_config_intr, 91 + 92 + .driver = { .owner = THIS_MODULE, }, 93 + }, 94 + }; 95 + module_phy_driver(dp83848_driver); 96 + 97 + MODULE_DESCRIPTION("Texas Instruments DP83848 PHY driver"); 98 + MODULE_AUTHOR("Andrew F. Davis <afd@ti.com"); 99 + MODULE_LICENSE("GPL");
+2
drivers/net/phy/mdio-mux-mmioreg.c
··· 113 113 if (!iprop || len != sizeof(uint32_t)) { 114 114 dev_err(&pdev->dev, "mdio-mux child node %s is " 115 115 "missing a 'reg' property\n", np2->full_name); 116 + of_node_put(np2); 116 117 return -ENODEV; 117 118 } 118 119 if (be32_to_cpup(iprop) & ~s->mask) { 119 120 dev_err(&pdev->dev, "mdio-mux child node %s has " 120 121 "a 'reg' value with unmasked bits\n", 121 122 np2->full_name); 123 + of_node_put(np2); 122 124 return -ENODEV; 123 125 } 124 126 }
+1
drivers/net/phy/mdio-mux.c
··· 144 144 dev_err(dev, 145 145 "Error: Failed to allocate memory for child\n"); 146 146 ret_val = -ENOMEM; 147 + of_node_put(child_bus_node); 147 148 break; 148 149 } 149 150 cb->bus_number = v;
+22 -1
drivers/net/phy/micrel.c
··· 514 514 return 0; 515 515 } 516 516 517 + static int ksz9031_read_status(struct phy_device *phydev) 518 + { 519 + int err; 520 + int regval; 521 + 522 + err = genphy_read_status(phydev); 523 + if (err) 524 + return err; 525 + 526 + /* Make sure the PHY is not broken. Read idle error count, 527 + * and reset the PHY if it is maxed out. 528 + */ 529 + regval = phy_read(phydev, MII_STAT1000); 530 + if ((regval & 0xFF) == 0xFF) { 531 + phy_init_hw(phydev); 532 + phydev->link = 0; 533 + } 534 + 535 + return 0; 536 + } 537 + 517 538 static int ksz8873mll_config_aneg(struct phy_device *phydev) 518 539 { 519 540 return 0; ··· 793 772 .driver_data = &ksz9021_type, 794 773 .config_init = ksz9031_config_init, 795 774 .config_aneg = genphy_config_aneg, 796 - .read_status = genphy_read_status, 775 + .read_status = ksz9031_read_status, 797 776 .ack_interrupt = kszphy_ack_interrupt, 798 777 .config_intr = kszphy_config_intr, 799 778 .suspend = genphy_suspend,
+14 -5
drivers/net/phy/smsc.c
··· 43 43 44 44 static int smsc_phy_config_init(struct phy_device *phydev) 45 45 { 46 + int __maybe_unused len; 47 + struct device *dev __maybe_unused = &phydev->dev; 48 + struct device_node *of_node __maybe_unused = dev->of_node; 46 49 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); 50 + int enable_energy = 1; 47 51 48 52 if (rc < 0) 49 53 return rc; 50 54 51 - /* Enable energy detect mode for this SMSC Transceivers */ 52 - rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, 53 - rc | MII_LAN83C185_EDPWRDOWN); 54 - if (rc < 0) 55 - return rc; 55 + if (of_find_property(of_node, "smsc,disable-energy-detect", &len)) 56 + enable_energy = 0; 57 + 58 + if (enable_energy) { 59 + /* Enable energy detect mode for this SMSC Transceivers */ 60 + rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, 61 + rc | MII_LAN83C185_EDPWRDOWN); 62 + if (rc < 0) 63 + return rc; 64 + } 56 65 57 66 return smsc_phy_ack_interrupt(phydev); 58 67 }
+1 -1
drivers/net/ppp/pppoe.c
··· 589 589 590 590 po = pppox_sk(sk); 591 591 592 - if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) { 592 + if (po->pppoe_dev) { 593 593 dev_put(po->pppoe_dev); 594 594 po->pppoe_dev = NULL; 595 595 }
+4
drivers/net/usb/qmi_wwan.c
··· 765 765 {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */ 766 766 {QMI_FIXED_INTF(0x1199, 0x9057, 8)}, 767 767 {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */ 768 + {QMI_FIXED_INTF(0x1199, 0x9070, 8)}, /* Sierra Wireless MC74xx/EM74xx */ 769 + {QMI_FIXED_INTF(0x1199, 0x9070, 10)}, /* Sierra Wireless MC74xx/EM74xx */ 770 + {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx/EM74xx */ 771 + {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx/EM74xx */ 768 772 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ 769 773 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ 770 774 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
+41
drivers/net/vxlan.c
··· 2337 2337 return 0; 2338 2338 } 2339 2339 2340 + static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb, 2341 + struct ip_tunnel_info *info, 2342 + __be16 sport, __be16 dport) 2343 + { 2344 + struct vxlan_dev *vxlan = netdev_priv(dev); 2345 + struct rtable *rt; 2346 + struct flowi4 fl4; 2347 + 2348 + memset(&fl4, 0, sizeof(fl4)); 2349 + fl4.flowi4_tos = RT_TOS(info->key.tos); 2350 + fl4.flowi4_mark = skb->mark; 2351 + fl4.flowi4_proto = IPPROTO_UDP; 2352 + fl4.daddr = info->key.u.ipv4.dst; 2353 + 2354 + rt = ip_route_output_key(vxlan->net, &fl4); 2355 + if (IS_ERR(rt)) 2356 + return PTR_ERR(rt); 2357 + ip_rt_put(rt); 2358 + 2359 + info->key.u.ipv4.src = fl4.saddr; 2360 + info->key.tp_src = sport; 2361 + info->key.tp_dst = dport; 2362 + return 0; 2363 + } 2364 + 2365 + static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) 2366 + { 2367 + struct vxlan_dev *vxlan = netdev_priv(dev); 2368 + struct ip_tunnel_info *info = skb_tunnel_info(skb); 2369 + __be16 sport, dport; 2370 + 2371 + sport = udp_flow_src_port(dev_net(dev), skb, vxlan->cfg.port_min, 2372 + vxlan->cfg.port_max, true); 2373 + dport = info->key.tp_dst ? : vxlan->cfg.dst_port; 2374 + 2375 + if (ip_tunnel_info_af(info) == AF_INET) 2376 + return egress_ipv4_tun_info(dev, skb, info, sport, dport); 2377 + return -EINVAL; 2378 + } 2379 + 2340 2380 static const struct net_device_ops vxlan_netdev_ops = { 2341 2381 .ndo_init = vxlan_init, 2342 2382 .ndo_uninit = vxlan_uninit, ··· 2391 2351 .ndo_fdb_add = vxlan_fdb_add, 2392 2352 .ndo_fdb_del = vxlan_fdb_delete, 2393 2353 .ndo_fdb_dump = vxlan_fdb_dump, 2354 + .ndo_fill_metadata_dst = vxlan_fill_metadata_dst, 2394 2355 }; 2395 2356 2396 2357 /* Info for udev, that this is a virtual tunnel endpoint */
+1
drivers/net/wireless/ath/ath6kl/init.c
··· 715 715 board_filename, ret); 716 716 continue; 717 717 } 718 + of_node_put(node); 718 719 return true; 719 720 } 720 721 return false;
+7 -7
drivers/net/xen-netfront.c
··· 1706 1706 } 1707 1707 1708 1708 static int xennet_create_queues(struct netfront_info *info, 1709 - unsigned int num_queues) 1709 + unsigned int *num_queues) 1710 1710 { 1711 1711 unsigned int i; 1712 1712 int ret; 1713 1713 1714 - info->queues = kcalloc(num_queues, sizeof(struct netfront_queue), 1714 + info->queues = kcalloc(*num_queues, sizeof(struct netfront_queue), 1715 1715 GFP_KERNEL); 1716 1716 if (!info->queues) 1717 1717 return -ENOMEM; 1718 1718 1719 1719 rtnl_lock(); 1720 1720 1721 - for (i = 0; i < num_queues; i++) { 1721 + for (i = 0; i < *num_queues; i++) { 1722 1722 struct netfront_queue *queue = &info->queues[i]; 1723 1723 1724 1724 queue->id = i; ··· 1728 1728 if (ret < 0) { 1729 1729 dev_warn(&info->netdev->dev, 1730 1730 "only created %d queues\n", i); 1731 - num_queues = i; 1731 + *num_queues = i; 1732 1732 break; 1733 1733 } 1734 1734 ··· 1738 1738 napi_enable(&queue->napi); 1739 1739 } 1740 1740 1741 - netif_set_real_num_tx_queues(info->netdev, num_queues); 1741 + netif_set_real_num_tx_queues(info->netdev, *num_queues); 1742 1742 1743 1743 rtnl_unlock(); 1744 1744 1745 - if (num_queues == 0) { 1745 + if (*num_queues == 0) { 1746 1746 dev_err(&info->netdev->dev, "no queues\n"); 1747 1747 return -EINVAL; 1748 1748 } ··· 1788 1788 if (info->queues) 1789 1789 xennet_destroy_queues(info); 1790 1790 1791 - err = xennet_create_queues(info, num_queues); 1791 + err = xennet_create_queues(info, &num_queues); 1792 1792 if (err < 0) 1793 1793 goto destroy_ring; 1794 1794
+7
drivers/vhost/vhost.h
··· 183 183 return vq->acked_features & (1ULL << bit); 184 184 } 185 185 186 + #ifdef CONFIG_VHOST_CROSS_ENDIAN_LEGACY 186 187 static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq) 187 188 { 188 189 return vq->is_le; 189 190 } 191 + #else 192 + static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq) 193 + { 194 + return virtio_legacy_is_little_endian() || vq->is_le; 195 + } 196 + #endif 190 197 191 198 /* Memory accessors */ 192 199 static inline u16 vhost16_to_cpu(struct vhost_virtqueue *vq, __virtio16 val)
+7
include/linux/netdevice.h
··· 1054 1054 * This function is used to pass protocol port error state information 1055 1055 * to the switch driver. The switch driver can react to the proto_down 1056 1056 * by doing a phys down on the associated switch port. 1057 + * int (*ndo_fill_metadata_dst)(struct net_device *dev, struct sk_buff *skb); 1058 + * This function is used to get egress tunnel information for given skb. 1059 + * This is useful for retrieving outer tunnel header parameters while 1060 + * sampling packet. 1057 1061 * 1058 1062 */ 1059 1063 struct net_device_ops { ··· 1231 1227 int (*ndo_get_iflink)(const struct net_device *dev); 1232 1228 int (*ndo_change_proto_down)(struct net_device *dev, 1233 1229 bool proto_down); 1230 + int (*ndo_fill_metadata_dst)(struct net_device *dev, 1231 + struct sk_buff *skb); 1234 1232 }; 1235 1233 1236 1234 /** ··· 2209 2203 void dev_remove_offload(struct packet_offload *po); 2210 2204 2211 2205 int dev_get_iflink(const struct net_device *dev); 2206 + int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb); 2212 2207 struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, 2213 2208 unsigned short mask); 2214 2209 struct net_device *dev_get_by_name(struct net *net, const char *name);
+32
include/net/dst_metadata.h
··· 60 60 return tun_dst; 61 61 } 62 62 63 + static inline struct metadata_dst *tun_dst_unclone(struct sk_buff *skb) 64 + { 65 + struct metadata_dst *md_dst = skb_metadata_dst(skb); 66 + int md_size = md_dst->u.tun_info.options_len; 67 + struct metadata_dst *new_md; 68 + 69 + if (!md_dst) 70 + return ERR_PTR(-EINVAL); 71 + 72 + new_md = metadata_dst_alloc(md_size, GFP_ATOMIC); 73 + if (!new_md) 74 + return ERR_PTR(-ENOMEM); 75 + 76 + memcpy(&new_md->u.tun_info, &md_dst->u.tun_info, 77 + sizeof(struct ip_tunnel_info) + md_size); 78 + skb_dst_drop(skb); 79 + dst_hold(&new_md->dst); 80 + skb_dst_set(skb, &new_md->dst); 81 + return new_md; 82 + } 83 + 84 + static inline struct ip_tunnel_info *skb_tunnel_info_unclone(struct sk_buff *skb) 85 + { 86 + struct metadata_dst *dst; 87 + 88 + dst = tun_dst_unclone(skb); 89 + if (IS_ERR(dst)) 90 + return NULL; 91 + 92 + return &dst->u.tun_info; 93 + } 94 + 63 95 static inline struct metadata_dst *ip_tun_rx_dst(struct sk_buff *skb, 64 96 __be16 flags, 65 97 __be64 tunnel_id,
+2 -1
include/uapi/linux/openvswitch.h
··· 620 620 * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. 621 621 * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack 622 622 * table. This allows future packets for the same connection to be identified 623 - * as 'established' or 'related'. 623 + * as 'established' or 'related'. The flow key for the current packet will 624 + * retain the pre-commit connection state. 624 625 * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. 625 626 * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the 626 627 * mask, the corresponding bit in the value is copied to the connection
+27
net/core/dev.c
··· 99 99 #include <linux/rtnetlink.h> 100 100 #include <linux/stat.h> 101 101 #include <net/dst.h> 102 + #include <net/dst_metadata.h> 102 103 #include <net/pkt_sched.h> 103 104 #include <net/checksum.h> 104 105 #include <net/xfrm.h> ··· 681 680 return dev->ifindex; 682 681 } 683 682 EXPORT_SYMBOL(dev_get_iflink); 683 + 684 + /** 685 + * dev_fill_metadata_dst - Retrieve tunnel egress information. 686 + * @dev: targeted interface 687 + * @skb: The packet. 688 + * 689 + * For better visibility of tunnel traffic OVS needs to retrieve 690 + * egress tunnel information for a packet. Following API allows 691 + * user to get this info. 692 + */ 693 + int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) 694 + { 695 + struct ip_tunnel_info *info; 696 + 697 + if (!dev->netdev_ops || !dev->netdev_ops->ndo_fill_metadata_dst) 698 + return -EINVAL; 699 + 700 + info = skb_tunnel_info_unclone(skb); 701 + if (!info) 702 + return -ENOMEM; 703 + if (unlikely(!(info->mode & IP_TUNNEL_INFO_TX))) 704 + return -EINVAL; 705 + 706 + return dev->netdev_ops->ndo_fill_metadata_dst(dev, skb); 707 + } 708 + EXPORT_SYMBOL_GPL(dev_fill_metadata_dst); 684 709 685 710 /** 686 711 * __dev_get_by_name - find a device by its name
+1 -1
net/ipv4/fib_trie.c
··· 1569 1569 do { 1570 1570 /* record parent and next child index */ 1571 1571 pn = n; 1572 - cindex = key ? get_index(key, pn) : 0; 1572 + cindex = (key > pn->key) ? get_index(key, pn) : 0; 1573 1573 1574 1574 if (cindex >> pn->bits) 1575 1575 break;
+2 -1
net/ipv4/gre_offload.c
··· 36 36 SKB_GSO_TCP_ECN | 37 37 SKB_GSO_GRE | 38 38 SKB_GSO_GRE_CSUM | 39 - SKB_GSO_IPIP))) 39 + SKB_GSO_IPIP | 40 + SKB_GSO_SIT))) 40 41 goto out; 41 42 42 43 if (!skb->encapsulation)
+37 -9
net/ipv4/ip_gre.c
··· 498 498 csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE); 499 499 } 500 500 501 + static struct rtable *gre_get_rt(struct sk_buff *skb, 502 + struct net_device *dev, 503 + struct flowi4 *fl, 504 + const struct ip_tunnel_key *key) 505 + { 506 + struct net *net = dev_net(dev); 507 + 508 + memset(fl, 0, sizeof(*fl)); 509 + fl->daddr = key->u.ipv4.dst; 510 + fl->saddr = key->u.ipv4.src; 511 + fl->flowi4_tos = RT_TOS(key->tos); 512 + fl->flowi4_mark = skb->mark; 513 + fl->flowi4_proto = IPPROTO_GRE; 514 + 515 + return ip_route_output_key(net, fl); 516 + } 517 + 501 518 static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev) 502 519 { 503 520 struct ip_tunnel_info *tun_info; 504 - struct net *net = dev_net(dev); 505 521 const struct ip_tunnel_key *key; 506 522 struct flowi4 fl; 507 523 struct rtable *rt; ··· 532 516 goto err_free_skb; 533 517 534 518 key = &tun_info->key; 535 - memset(&fl, 0, sizeof(fl)); 536 - fl.daddr = key->u.ipv4.dst; 537 - fl.saddr = key->u.ipv4.src; 538 - fl.flowi4_tos = RT_TOS(key->tos); 539 - fl.flowi4_mark = skb->mark; 540 - fl.flowi4_proto = IPPROTO_GRE; 541 - 542 - rt = ip_route_output_key(net, &fl); 519 + rt = gre_get_rt(skb, dev, &fl, key); 543 520 if (IS_ERR(rt)) 544 521 goto err_free_skb; 545 522 ··· 573 564 err_free_skb: 574 565 kfree_skb(skb); 575 566 dev->stats.tx_dropped++; 567 + } 568 + 569 + static int gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) 570 + { 571 + struct ip_tunnel_info *info = skb_tunnel_info(skb); 572 + struct rtable *rt; 573 + struct flowi4 fl4; 574 + 575 + if (ip_tunnel_info_af(info) != AF_INET) 576 + return -EINVAL; 577 + 578 + rt = gre_get_rt(skb, dev, &fl4, &info->key); 579 + if (IS_ERR(rt)) 580 + return PTR_ERR(rt); 581 + 582 + ip_rt_put(rt); 583 + info->key.u.ipv4.src = fl4.saddr; 584 + return 0; 576 585 } 577 586 578 587 static netdev_tx_t ipgre_xmit(struct sk_buff *skb, ··· 1050 1023 .ndo_change_mtu = ip_tunnel_change_mtu, 1051 1024 .ndo_get_stats64 = ip_tunnel_get_stats64, 1052 1025 .ndo_get_iflink = ip_tunnel_get_iflink, 1026 + .ndo_fill_metadata_dst = gre_fill_metadata_dst, 1053 1027 }; 1054 1028 1055 1029 static void ipgre_tap_setup(struct net_device *dev)
+1
net/ipv4/netfilter/Kconfig
··· 75 75 76 76 config NF_DUP_IPV4 77 77 tristate "Netfilter IPv4 packet duplication to alternate destination" 78 + depends on !NF_CONNTRACK || NF_CONNTRACK 78 79 help 79 80 This option enables the nf_dup_ipv4 core, which duplicates an IPv4 80 81 packet to be rerouted to another destination.
+1 -3
net/ipv4/netfilter/ipt_rpfilter.c
··· 61 61 if (FIB_RES_DEV(res) == dev) 62 62 dev_match = true; 63 63 #endif 64 - if (dev_match || flags & XT_RPFILTER_LOOSE) 65 - return FIB_RES_NH(res).nh_scope <= RT_SCOPE_HOST; 66 - return dev_match; 64 + return dev_match || flags & XT_RPFILTER_LOOSE; 67 65 } 68 66 69 67 static bool rpfilter_is_local(const struct sk_buff *skb)
+1 -1
net/ipv4/tcp_dctcp.c
··· 209 209 210 210 /* alpha = (1 - g) * alpha + g * F */ 211 211 212 - alpha -= alpha >> dctcp_shift_g; 212 + alpha -= min_not_zero(alpha, alpha >> dctcp_shift_g); 213 213 if (bytes_ecn) { 214 214 /* If dctcp_shift_g == 1, a 32bit value would overflow 215 215 * after 8 Mbytes.
+1 -1
net/ipv4/tcp_output.c
··· 3405 3405 */ 3406 3406 tcp_init_nondata_skb(skb, tp->snd_una - !urgent, TCPHDR_ACK); 3407 3407 skb_mstamp_get(&skb->skb_mstamp); 3408 - NET_INC_STATS_BH(sock_net(sk), mib); 3408 + NET_INC_STATS(sock_net(sk), mib); 3409 3409 return tcp_transmit_skb(sk, skb, 0, GFP_ATOMIC); 3410 3410 } 3411 3411
+2
net/ipv4/xfrm4_output.c
··· 30 30 31 31 mtu = dst_mtu(skb_dst(skb)); 32 32 if (skb->len > mtu) { 33 + skb->protocol = htons(ETH_P_IP); 34 + 33 35 if (skb->sk) 34 36 xfrm_local_error(skb, mtu); 35 37 else
+15 -4
net/ipv6/fib6_rules.c
··· 32 32 struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6, 33 33 int flags, pol_lookup_t lookup) 34 34 { 35 + struct rt6_info *rt; 35 36 struct fib_lookup_arg arg = { 36 37 .lookup_ptr = lookup, 37 38 .flags = FIB_LOOKUP_NOREF, ··· 41 40 fib_rules_lookup(net->ipv6.fib6_rules_ops, 42 41 flowi6_to_flowi(fl6), flags, &arg); 43 42 44 - if (arg.result) 45 - return arg.result; 43 + rt = arg.result; 46 44 47 - dst_hold(&net->ipv6.ip6_null_entry->dst); 48 - return &net->ipv6.ip6_null_entry->dst; 45 + if (!rt) { 46 + dst_hold(&net->ipv6.ip6_null_entry->dst); 47 + return &net->ipv6.ip6_null_entry->dst; 48 + } 49 + 50 + if (rt->rt6i_flags & RTF_REJECT && 51 + rt->dst.error == -EAGAIN) { 52 + ip6_rt_put(rt); 53 + rt = net->ipv6.ip6_null_entry; 54 + dst_hold(&rt->dst); 55 + } 56 + 57 + return &rt->dst; 49 58 } 50 59 51 60 static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
+11 -1
net/ipv6/ip6_fib.c
··· 285 285 struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6, 286 286 int flags, pol_lookup_t lookup) 287 287 { 288 - return (struct dst_entry *) lookup(net, net->ipv6.fib6_main_tbl, fl6, flags); 288 + struct rt6_info *rt; 289 + 290 + rt = lookup(net, net->ipv6.fib6_main_tbl, fl6, flags); 291 + if (rt->rt6i_flags & RTF_REJECT && 292 + rt->dst.error == -EAGAIN) { 293 + ip6_rt_put(rt); 294 + rt = net->ipv6.ip6_null_entry; 295 + dst_hold(&rt->dst); 296 + } 297 + 298 + return &rt->dst; 289 299 } 290 300 291 301 static void __net_init fib6_tables_init(struct net *net)
+4 -1
net/ipv6/ip6_output.c
··· 584 584 if (np->frag_size) 585 585 mtu = np->frag_size; 586 586 } 587 + if (mtu < hlen + sizeof(struct frag_hdr) + 8) 588 + goto fail_toobig; 587 589 mtu -= hlen + sizeof(struct frag_hdr); 588 590 589 591 frag_id = ipv6_select_ident(net, &ipv6_hdr(skb)->daddr, ··· 879 877 #ifdef CONFIG_IPV6_SUBTREES 880 878 ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) || 881 879 #endif 882 - (fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) { 880 + (!(fl6->flowi6_flags & FLOWI_FLAG_SKIP_NH_OIF) && 881 + (fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex))) { 883 882 dst_release(dst); 884 883 dst = NULL; 885 884 }
+1
net/ipv6/netfilter/Kconfig
··· 58 58 59 59 config NF_DUP_IPV6 60 60 tristate "Netfilter IPv6 packet duplication to alternate destination" 61 + depends on !NF_CONNTRACK || NF_CONNTRACK 61 62 help 62 63 This option enables the nf_dup_ipv6 core, which duplicates an IPv6 63 64 packet to be rerouted to another destination.
+1
net/ipv6/netfilter/nf_conntrack_reasm.c
··· 646 646 s = s2; 647 647 } 648 648 } 649 + EXPORT_SYMBOL_GPL(nf_ct_frag6_consume_orig); 649 650 650 651 static int nf_ct_net_init(struct net *net) 651 652 {
+7 -2
net/ipv6/route.c
··· 1068 1068 fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); 1069 1069 saved_fn = fn; 1070 1070 1071 + if (fl6->flowi6_flags & FLOWI_FLAG_SKIP_NH_OIF) 1072 + oif = 0; 1073 + 1071 1074 redo_rt6_select: 1072 1075 rt = rt6_select(fn, oif, strict); 1073 1076 if (rt->rt6i_nsiblings) ··· 1193 1190 struct flowi6 *fl6) 1194 1191 { 1195 1192 int flags = 0; 1193 + bool any_src; 1196 1194 1197 1195 fl6->flowi6_iif = LOOPBACK_IFINDEX; 1198 1196 1197 + any_src = ipv6_addr_any(&fl6->saddr); 1199 1198 if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr) || 1200 - fl6->flowi6_oif) 1199 + (fl6->flowi6_oif && any_src)) 1201 1200 flags |= RT6_LOOKUP_F_IFACE; 1202 1201 1203 - if (!ipv6_addr_any(&fl6->saddr)) 1202 + if (!any_src) 1204 1203 flags |= RT6_LOOKUP_F_HAS_SADDR; 1205 1204 else if (sk) 1206 1205 flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs);
+12 -6
net/ipv6/xfrm6_output.c
··· 79 79 80 80 if (!skb->ignore_df && skb->len > mtu) { 81 81 skb->dev = dst->dev; 82 + skb->protocol = htons(ETH_P_IPV6); 82 83 83 84 if (xfrm6_local_dontfrag(skb)) 84 85 xfrm6_local_rxpmtu(skb, mtu); ··· 137 136 struct dst_entry *dst = skb_dst(skb); 138 137 struct xfrm_state *x = dst->xfrm; 139 138 int mtu; 139 + bool toobig; 140 140 141 141 #ifdef CONFIG_NETFILTER 142 142 if (!x) { ··· 146 144 } 147 145 #endif 148 146 147 + if (x->props.mode != XFRM_MODE_TUNNEL) 148 + goto skip_frag; 149 + 149 150 if (skb->protocol == htons(ETH_P_IPV6)) 150 151 mtu = ip6_skb_dst_mtu(skb); 151 152 else 152 153 mtu = dst_mtu(skb_dst(skb)); 153 154 154 - if (skb->len > mtu && xfrm6_local_dontfrag(skb)) { 155 + toobig = skb->len > mtu && !skb_is_gso(skb); 156 + 157 + if (toobig && xfrm6_local_dontfrag(skb)) { 155 158 xfrm6_local_rxpmtu(skb, mtu); 156 159 return -EMSGSIZE; 157 - } else if (!skb->ignore_df && skb->len > mtu && skb->sk) { 160 + } else if (!skb->ignore_df && toobig && skb->sk) { 158 161 xfrm_local_error(skb, mtu); 159 162 return -EMSGSIZE; 160 163 } 161 164 162 - if (x->props.mode == XFRM_MODE_TUNNEL && 163 - ((skb->len > mtu && !skb_is_gso(skb)) || 164 - dst_allfrag(skb_dst(skb)))) { 165 + if (toobig || dst_allfrag(skb_dst(skb))) 165 166 return ip6_fragment(sk, skb, 166 167 x->outer_mode->afinfo->output_finish); 167 - } 168 + 169 + skip_frag: 168 170 return x->outer_mode->afinfo->output_finish(sk, skb); 169 171 } 170 172
+4 -2
net/ipv6/xfrm6_policy.c
··· 179 179 return; 180 180 181 181 case IPPROTO_ICMPV6: 182 - if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) { 182 + if (!onlyproto && (nh + offset + 2 < skb->data || 183 + pskb_may_pull(skb, nh + offset + 2 - skb->data))) { 183 184 u8 *icmp; 184 185 185 186 nh = skb_network_header(skb); ··· 194 193 #if IS_ENABLED(CONFIG_IPV6_MIP6) 195 194 case IPPROTO_MH: 196 195 offset += ipv6_optlen(exthdr); 197 - if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) { 196 + if (!onlyproto && (nh + offset + 3 < skb->data || 197 + pskb_may_pull(skb, nh + offset + 3 - skb->data))) { 198 198 struct ip6_mh *mh; 199 199 200 200 nh = skb_network_header(skb);
+1 -1
net/irda/irlmp.c
··· 1839 1839 for (element = hashbin_get_first(iter->hashbin); 1840 1840 element != NULL; 1841 1841 element = hashbin_get_next(iter->hashbin)) { 1842 - if (!off || *off-- == 0) { 1842 + if (!off || (*off)-- == 0) { 1843 1843 /* NB: hashbin left locked */ 1844 1844 return element; 1845 1845 }
+1 -1
net/key/af_key.c
··· 261 261 262 262 err2 = pfkey_broadcast_one(skb, &skb2, GFP_ATOMIC, sk); 263 263 264 - /* Error is cleare after succecful sending to at least one 264 + /* Error is cleared after successful sending to at least one 265 265 * registered KM */ 266 266 if ((broadcast_flags & BROADCAST_REGISTERED) && err) 267 267 err = err2;
+2
net/netfilter/core.c
··· 152 152 #endif 153 153 synchronize_net(); 154 154 nf_queue_nf_hook_drop(net, &entry->ops); 155 + /* other cpu might still process nfqueue verdict that used reg */ 156 + synchronize_net(); 155 157 kfree(entry); 156 158 } 157 159 EXPORT_SYMBOL(nf_unregister_net_hook);
+1 -1
net/netfilter/ipset/ip_set_list_set.c
··· 297 297 ip_set_timeout_expired(ext_timeout(n, set)))) 298 298 n = NULL; 299 299 300 - e = kzalloc(set->dsize, GFP_KERNEL); 300 + e = kzalloc(set->dsize, GFP_ATOMIC); 301 301 if (!e) 302 302 return -ENOMEM; 303 303 e->id = d->id;
+2 -2
net/netlink/af_netlink.c
··· 2371 2371 int pos, idx, shift; 2372 2372 2373 2373 err = 0; 2374 - netlink_table_grab(); 2374 + netlink_lock_table(); 2375 2375 for (pos = 0; pos * 8 < nlk->ngroups; pos += sizeof(u32)) { 2376 2376 if (len - pos < sizeof(u32)) 2377 2377 break; ··· 2386 2386 } 2387 2387 if (put_user(ALIGN(nlk->ngroups / 8, sizeof(u32)), optlen)) 2388 2388 err = -EFAULT; 2389 - netlink_table_ungrab(); 2389 + netlink_unlock_table(); 2390 2390 break; 2391 2391 } 2392 2392 case NETLINK_CAP_ACK:
+5 -8
net/openvswitch/actions.c
··· 768 768 struct sw_flow_key *key, const struct nlattr *attr, 769 769 const struct nlattr *actions, int actions_len) 770 770 { 771 - struct ip_tunnel_info info; 772 771 struct dp_upcall_info upcall; 773 772 const struct nlattr *a; 774 773 int rem; ··· 795 796 if (vport) { 796 797 int err; 797 798 798 - upcall.egress_tun_info = &info; 799 - err = ovs_vport_get_egress_tun_info(vport, skb, 800 - &upcall); 801 - if (err) 802 - upcall.egress_tun_info = NULL; 799 + err = dev_fill_metadata_dst(vport->dev, skb); 800 + if (!err) 801 + upcall.egress_tun_info = skb_tunnel_info(skb); 803 802 } 804 803 805 804 break; ··· 1109 1112 nla_data(a)); 1110 1113 1111 1114 /* Hide stolen IP fragments from user space. */ 1112 - if (err == -EINPROGRESS) 1113 - return 0; 1115 + if (err) 1116 + return err == -EINPROGRESS ? 0 : err; 1114 1117 break; 1115 1118 } 1116 1119
+35 -13
net/openvswitch/conntrack.c
··· 151 151 ct = nf_ct_get(skb, &ctinfo); 152 152 if (ct) { 153 153 state = ovs_ct_get_state(ctinfo); 154 + if (!nf_ct_is_confirmed(ct)) 155 + state |= OVS_CS_F_NEW; 154 156 if (ct->master) 155 157 state |= OVS_CS_F_RELATED; 156 158 zone = nf_ct_zone(ct); ··· 224 222 struct nf_conn *ct; 225 223 int err; 226 224 227 - if (!IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS)) 228 - return -ENOTSUPP; 229 - 230 225 /* The connection could be invalid, in which case set_label is no-op.*/ 231 226 ct = nf_ct_get(skb, &ctinfo); 232 227 if (!ct) ··· 293 294 return helper->help(skb, protoff, ct, ctinfo); 294 295 } 295 296 297 + /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero 298 + * value if 'skb' is freed. 299 + */ 296 300 static int handle_fragments(struct net *net, struct sw_flow_key *key, 297 301 u16 zone, struct sk_buff *skb) 298 302 { ··· 311 309 return err; 312 310 313 311 ovs_cb.mru = IPCB(skb)->frag_max_size; 314 - } else if (key->eth.type == htons(ETH_P_IPV6)) { 315 312 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) 313 + } else if (key->eth.type == htons(ETH_P_IPV6)) { 316 314 enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone; 317 315 struct sk_buff *reasm; 318 316 ··· 321 319 if (!reasm) 322 320 return -EINPROGRESS; 323 321 324 - if (skb == reasm) 322 + if (skb == reasm) { 323 + kfree_skb(skb); 325 324 return -EINVAL; 325 + } 326 + 327 + /* Don't free 'skb' even though it is one of the original 328 + * fragments, as we're going to morph it into the head. 329 + */ 330 + skb_get(skb); 331 + nf_ct_frag6_consume_orig(reasm); 326 332 327 333 key->ip.proto = ipv6_hdr(reasm)->nexthdr; 328 334 skb_morph(skb, reasm); 335 + skb->next = reasm->next; 329 336 consume_skb(reasm); 330 337 ovs_cb.mru = IP6CB(skb)->frag_max_size; 331 - #else 332 - return -EPFNOSUPPORT; 333 338 #endif 334 339 } else { 340 + kfree_skb(skb); 335 341 return -EPFNOSUPPORT; 336 342 } 337 343 ··· 387 377 return true; 388 378 } 389 379 390 - static int __ovs_ct_lookup(struct net *net, const struct sw_flow_key *key, 380 + static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, 391 381 const struct ovs_conntrack_info *info, 392 382 struct sk_buff *skb) 393 383 { ··· 418 408 } 419 409 } 420 410 411 + ovs_ct_update_key(skb, key, true); 412 + 421 413 return 0; 422 414 } 423 415 ··· 442 430 err = __ovs_ct_lookup(net, key, info, skb); 443 431 if (err) 444 432 return err; 445 - 446 - ovs_ct_update_key(skb, key, true); 447 433 } 448 434 449 435 return 0; ··· 470 460 if (nf_conntrack_confirm(skb) != NF_ACCEPT) 471 461 return -EINVAL; 472 462 473 - ovs_ct_update_key(skb, key, true); 474 - 475 463 return 0; 476 464 } 477 465 ··· 484 476 return false; 485 477 } 486 478 479 + /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero 480 + * value if 'skb' is freed. 481 + */ 487 482 int ovs_ct_execute(struct net *net, struct sk_buff *skb, 488 483 struct sw_flow_key *key, 489 484 const struct ovs_conntrack_info *info) ··· 522 511 &info->labels.mask); 523 512 err: 524 513 skb_push(skb, nh_ofs); 514 + if (err) 515 + kfree_skb(skb); 525 516 return err; 526 517 } 527 518 ··· 600 587 case OVS_CT_ATTR_MARK: { 601 588 struct md_mark *mark = nla_data(a); 602 589 590 + if (!mark->mask) { 591 + OVS_NLERR(log, "ct_mark mask cannot be 0"); 592 + return -EINVAL; 593 + } 603 594 info->mark = *mark; 604 595 break; 605 596 } ··· 612 595 case OVS_CT_ATTR_LABELS: { 613 596 struct md_labels *labels = nla_data(a); 614 597 598 + if (!labels_nonzero(&labels->mask)) { 599 + OVS_NLERR(log, "ct_labels mask cannot be 0"); 600 + return -EINVAL; 601 + } 615 602 info->labels = *labels; 616 603 break; 617 604 } ··· 726 705 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && 727 706 nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id)) 728 707 return -EMSGSIZE; 729 - if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) && 708 + if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) && ct_info->mark.mask && 730 709 nla_put(skb, OVS_CT_ATTR_MARK, sizeof(ct_info->mark), 731 710 &ct_info->mark)) 732 711 return -EMSGSIZE; 733 712 if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && 713 + labels_nonzero(&ct_info->labels.mask) && 734 714 nla_put(skb, OVS_CT_ATTR_LABELS, sizeof(ct_info->labels), 735 715 &ct_info->labels)) 736 716 return -EMSGSIZE;
+6 -11
net/openvswitch/conntrack.h
··· 35 35 int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb); 36 36 void ovs_ct_free_action(const struct nlattr *a); 37 37 38 - static inline bool ovs_ct_state_supported(u32 state) 39 - { 40 - return !(state & ~(OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | 41 - OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | 42 - OVS_CS_F_INVALID | OVS_CS_F_TRACKED)); 43 - } 38 + #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \ 39 + OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \ 40 + OVS_CS_F_INVALID | OVS_CS_F_TRACKED) 44 41 #else 45 42 #include <linux/errno.h> 46 43 ··· 46 49 static inline void ovs_ct_exit(struct net *net) { } 47 50 48 51 static inline bool ovs_ct_verify(struct net *net, int attr) 49 - { 50 - return false; 51 - } 52 - 53 - static inline bool ovs_ct_state_supported(u32 state) 54 52 { 55 53 return false; 56 54 } ··· 67 75 struct sw_flow_key *key, 68 76 const struct ovs_conntrack_info *info) 69 77 { 78 + kfree_skb(skb); 70 79 return -ENOTSUPP; 71 80 } 72 81 ··· 87 94 } 88 95 89 96 static inline void ovs_ct_free_action(const struct nlattr *a) { } 97 + 98 + #define CT_SUPPORTED_MASK 0 90 99 #endif /* CONFIG_NF_CONNTRACK */ 91 100 #endif /* ovs_conntrack.h */
+2 -3
net/openvswitch/datapath.c
··· 490 490 491 491 if (upcall_info->egress_tun_info) { 492 492 nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_EGRESS_TUN_KEY); 493 - err = ovs_nla_put_egress_tunnel_key(user_skb, 494 - upcall_info->egress_tun_info, 495 - upcall_info->egress_tun_opts); 493 + err = ovs_nla_put_tunnel_info(user_skb, 494 + upcall_info->egress_tun_info); 496 495 BUG_ON(err); 497 496 nla_nest_end(user_skb, nla); 498 497 }
-1
net/openvswitch/datapath.h
··· 117 117 */ 118 118 struct dp_upcall_info { 119 119 struct ip_tunnel_info *egress_tun_info; 120 - const void *egress_tun_opts; 121 120 const struct nlattr *userdata; 122 121 const struct nlattr *actions; 123 122 int actions_len;
+11 -12
net/openvswitch/flow_netlink.c
··· 717 717 if ((output->tun_flags & TUNNEL_OAM) && 718 718 nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_OAM)) 719 719 return -EMSGSIZE; 720 - if (tun_opts) { 720 + if (swkey_tun_opts_len) { 721 721 if (output->tun_flags & TUNNEL_GENEVE_OPT && 722 722 nla_put(skb, OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS, 723 723 swkey_tun_opts_len, tun_opts)) ··· 749 749 return 0; 750 750 } 751 751 752 - int ovs_nla_put_egress_tunnel_key(struct sk_buff *skb, 753 - const struct ip_tunnel_info *egress_tun_info, 754 - const void *egress_tun_opts) 752 + int ovs_nla_put_tunnel_info(struct sk_buff *skb, 753 + struct ip_tunnel_info *tun_info) 755 754 { 756 - return __ipv4_tun_to_nlattr(skb, &egress_tun_info->key, 757 - egress_tun_opts, 758 - egress_tun_info->options_len); 755 + return __ipv4_tun_to_nlattr(skb, &tun_info->key, 756 + ip_tunnel_info_opts(tun_info), 757 + tun_info->options_len); 759 758 } 760 759 761 760 static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match, ··· 815 816 ovs_ct_verify(net, OVS_KEY_ATTR_CT_STATE)) { 816 817 u32 ct_state = nla_get_u32(a[OVS_KEY_ATTR_CT_STATE]); 817 818 818 - if (!is_mask && !ovs_ct_state_supported(ct_state)) { 819 + if (ct_state & ~CT_SUPPORTED_MASK) { 819 820 OVS_NLERR(log, "ct_state flags %08x unsupported", 820 821 ct_state); 821 822 return -EINVAL; ··· 1098 1099 } else { 1099 1100 memset(nla_data(nla), val, nla_len(nla)); 1100 1101 } 1102 + 1103 + if (nla_type(nla) == OVS_KEY_ATTR_CT_STATE) 1104 + *(u32 *)nla_data(nla) &= CT_SUPPORTED_MASK; 1101 1105 } 1102 1106 } 1103 1107 ··· 2382 2380 if (!start) 2383 2381 return -EMSGSIZE; 2384 2382 2385 - err = ipv4_tun_to_nlattr(skb, &tun_info->key, 2386 - tun_info->options_len ? 2387 - ip_tunnel_info_opts(tun_info) : NULL, 2388 - tun_info->options_len); 2383 + err = ovs_nla_put_tunnel_info(skb, tun_info); 2389 2384 if (err) 2390 2385 return err; 2391 2386 nla_nest_end(skb, start);
+3 -3
net/openvswitch/flow_netlink.h
··· 55 55 int ovs_nla_get_match(struct net *, struct sw_flow_match *, 56 56 const struct nlattr *key, const struct nlattr *mask, 57 57 bool log); 58 - int ovs_nla_put_egress_tunnel_key(struct sk_buff *, 59 - const struct ip_tunnel_info *, 60 - const void *egress_tun_opts); 58 + 59 + int ovs_nla_put_tunnel_info(struct sk_buff *skb, 60 + struct ip_tunnel_info *tun_info); 61 61 62 62 bool ovs_nla_get_ufid(struct sw_flow_id *, const struct nlattr *, bool log); 63 63 int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,
-13
net/openvswitch/vport-geneve.c
··· 52 52 return 0; 53 53 } 54 54 55 - static int geneve_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, 56 - struct dp_upcall_info *upcall) 57 - { 58 - struct geneve_port *geneve_port = geneve_vport(vport); 59 - struct net *net = ovs_dp_get_net(vport->dp); 60 - __be16 dport = htons(geneve_port->port_no); 61 - __be16 sport = udp_flow_src_port(net, skb, 1, USHRT_MAX, true); 62 - 63 - return ovs_tunnel_get_egress_info(upcall, ovs_dp_get_net(vport->dp), 64 - skb, IPPROTO_UDP, sport, dport); 65 - } 66 - 67 55 static struct vport *geneve_tnl_create(const struct vport_parms *parms) 68 56 { 69 57 struct net *net = ovs_dp_get_net(parms->dp); ··· 118 130 .get_options = geneve_get_options, 119 131 .send = ovs_netdev_send, 120 132 .owner = THIS_MODULE, 121 - .get_egress_tun_info = geneve_get_egress_tun_info, 122 133 }; 123 134 124 135 static int __init ovs_geneve_tnl_init(void)
-8
net/openvswitch/vport-gre.c
··· 84 84 return ovs_netdev_link(vport, parms->name); 85 85 } 86 86 87 - static int gre_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, 88 - struct dp_upcall_info *upcall) 89 - { 90 - return ovs_tunnel_get_egress_info(upcall, ovs_dp_get_net(vport->dp), 91 - skb, IPPROTO_GRE, 0, 0); 92 - } 93 - 94 87 static struct vport_ops ovs_gre_vport_ops = { 95 88 .type = OVS_VPORT_TYPE_GRE, 96 89 .create = gre_create, 97 90 .send = ovs_netdev_send, 98 - .get_egress_tun_info = gre_get_egress_tun_info, 99 91 .destroy = ovs_netdev_tunnel_destroy, 100 92 .owner = THIS_MODULE, 101 93 };
+43 -3
net/openvswitch/vport-internal_dev.c
··· 106 106 free_netdev(dev); 107 107 } 108 108 109 + static struct rtnl_link_stats64 * 110 + internal_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) 111 + { 112 + int i; 113 + 114 + memset(stats, 0, sizeof(*stats)); 115 + stats->rx_errors = dev->stats.rx_errors; 116 + stats->tx_errors = dev->stats.tx_errors; 117 + stats->tx_dropped = dev->stats.tx_dropped; 118 + stats->rx_dropped = dev->stats.rx_dropped; 119 + 120 + for_each_possible_cpu(i) { 121 + const struct pcpu_sw_netstats *percpu_stats; 122 + struct pcpu_sw_netstats local_stats; 123 + unsigned int start; 124 + 125 + percpu_stats = per_cpu_ptr(dev->tstats, i); 126 + 127 + do { 128 + start = u64_stats_fetch_begin_irq(&percpu_stats->syncp); 129 + local_stats = *percpu_stats; 130 + } while (u64_stats_fetch_retry_irq(&percpu_stats->syncp, start)); 131 + 132 + stats->rx_bytes += local_stats.rx_bytes; 133 + stats->rx_packets += local_stats.rx_packets; 134 + stats->tx_bytes += local_stats.tx_bytes; 135 + stats->tx_packets += local_stats.tx_packets; 136 + } 137 + 138 + return stats; 139 + } 140 + 109 141 static const struct net_device_ops internal_dev_netdev_ops = { 110 142 .ndo_open = internal_dev_open, 111 143 .ndo_stop = internal_dev_stop, 112 144 .ndo_start_xmit = internal_dev_xmit, 113 145 .ndo_set_mac_address = eth_mac_addr, 114 146 .ndo_change_mtu = internal_dev_change_mtu, 147 + .ndo_get_stats64 = internal_get_stats, 115 148 }; 116 149 117 150 static struct rtnl_link_ops internal_dev_link_ops __read_mostly = { ··· 194 161 err = -ENOMEM; 195 162 goto error_free_vport; 196 163 } 164 + vport->dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 165 + if (!vport->dev->tstats) { 166 + err = -ENOMEM; 167 + goto error_free_netdev; 168 + } 197 169 198 170 dev_net_set(vport->dev, ovs_dp_get_net(vport->dp)); 199 171 internal_dev = internal_dev_priv(vport->dev); ··· 211 173 rtnl_lock(); 212 174 err = register_netdevice(vport->dev); 213 175 if (err) 214 - goto error_free_netdev; 176 + goto error_unlock; 215 177 216 178 dev_set_promiscuity(vport->dev, 1); 217 179 rtnl_unlock(); ··· 219 181 220 182 return vport; 221 183 222 - error_free_netdev: 184 + error_unlock: 223 185 rtnl_unlock(); 186 + free_percpu(vport->dev->tstats); 187 + error_free_netdev: 224 188 free_netdev(vport->dev); 225 189 error_free_vport: 226 190 ovs_vport_free(vport); ··· 238 198 239 199 /* unregister_netdevice() waits for an RCU grace period. */ 240 200 unregister_netdevice(vport->dev); 241 - 201 + free_percpu(vport->dev->tstats); 242 202 rtnl_unlock(); 243 203 } 244 204
-19
net/openvswitch/vport-vxlan.c
··· 146 146 return ovs_netdev_link(vport, parms->name); 147 147 } 148 148 149 - static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, 150 - struct dp_upcall_info *upcall) 151 - { 152 - struct vxlan_dev *vxlan = netdev_priv(vport->dev); 153 - struct net *net = ovs_dp_get_net(vport->dp); 154 - __be16 dst_port = vxlan_dev_dst_port(vxlan); 155 - __be16 src_port; 156 - int port_min; 157 - int port_max; 158 - 159 - inet_get_local_port_range(net, &port_min, &port_max); 160 - src_port = udp_flow_src_port(net, skb, 0, 0, true); 161 - 162 - return ovs_tunnel_get_egress_info(upcall, net, 163 - skb, IPPROTO_UDP, 164 - src_port, dst_port); 165 - } 166 - 167 149 static struct vport_ops ovs_vxlan_netdev_vport_ops = { 168 150 .type = OVS_VPORT_TYPE_VXLAN, 169 151 .create = vxlan_create, 170 152 .destroy = ovs_netdev_tunnel_destroy, 171 153 .get_options = vxlan_get_options, 172 154 .send = ovs_netdev_send, 173 - .get_egress_tun_info = vxlan_get_egress_tun_info, 174 155 }; 175 156 176 157 static int __init ovs_vxlan_tnl_init(void)
-58
net/openvswitch/vport.c
··· 479 479 call_rcu(&vport->rcu, free_vport_rcu); 480 480 } 481 481 EXPORT_SYMBOL_GPL(ovs_vport_deferred_free); 482 - 483 - int ovs_tunnel_get_egress_info(struct dp_upcall_info *upcall, 484 - struct net *net, 485 - struct sk_buff *skb, 486 - u8 ipproto, 487 - __be16 tp_src, 488 - __be16 tp_dst) 489 - { 490 - struct ip_tunnel_info *egress_tun_info = upcall->egress_tun_info; 491 - const struct ip_tunnel_info *tun_info = skb_tunnel_info(skb); 492 - const struct ip_tunnel_key *tun_key; 493 - u32 skb_mark = skb->mark; 494 - struct rtable *rt; 495 - struct flowi4 fl; 496 - 497 - if (unlikely(!tun_info)) 498 - return -EINVAL; 499 - if (ip_tunnel_info_af(tun_info) != AF_INET) 500 - return -EINVAL; 501 - 502 - tun_key = &tun_info->key; 503 - 504 - /* Route lookup to get srouce IP address. 505 - * The process may need to be changed if the corresponding process 506 - * in vports ops changed. 507 - */ 508 - rt = ovs_tunnel_route_lookup(net, tun_key, skb_mark, &fl, ipproto); 509 - if (IS_ERR(rt)) 510 - return PTR_ERR(rt); 511 - 512 - ip_rt_put(rt); 513 - 514 - /* Generate egress_tun_info based on tun_info, 515 - * saddr, tp_src and tp_dst 516 - */ 517 - ip_tunnel_key_init(&egress_tun_info->key, 518 - fl.saddr, tun_key->u.ipv4.dst, 519 - tun_key->tos, 520 - tun_key->ttl, 521 - tp_src, tp_dst, 522 - tun_key->tun_id, 523 - tun_key->tun_flags); 524 - egress_tun_info->options_len = tun_info->options_len; 525 - egress_tun_info->mode = tun_info->mode; 526 - upcall->egress_tun_opts = ip_tunnel_info_opts(egress_tun_info); 527 - return 0; 528 - } 529 - EXPORT_SYMBOL_GPL(ovs_tunnel_get_egress_info); 530 - 531 - int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, 532 - struct dp_upcall_info *upcall) 533 - { 534 - /* get_egress_tun_info() is only implemented on tunnel ports. */ 535 - if (unlikely(!vport->ops->get_egress_tun_info)) 536 - return -EINVAL; 537 - 538 - return vport->ops->get_egress_tun_info(vport, skb, upcall); 539 - }
-35
net/openvswitch/vport.h
··· 27 27 #include <linux/skbuff.h> 28 28 #include <linux/spinlock.h> 29 29 #include <linux/u64_stats_sync.h> 30 - #include <net/route.h> 31 30 32 31 #include "datapath.h" 33 32 ··· 51 52 int ovs_vport_set_upcall_portids(struct vport *, const struct nlattr *pids); 52 53 int ovs_vport_get_upcall_portids(const struct vport *, struct sk_buff *); 53 54 u32 ovs_vport_find_upcall_portid(const struct vport *, struct sk_buff *); 54 - 55 - int ovs_tunnel_get_egress_info(struct dp_upcall_info *upcall, 56 - struct net *net, 57 - struct sk_buff *, 58 - u8 ipproto, 59 - __be16 tp_src, 60 - __be16 tp_dst); 61 - 62 - int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, 63 - struct dp_upcall_info *upcall); 64 55 65 56 /** 66 57 * struct vport_portids - array of netlink portids of a vport. ··· 129 140 * have any configuration. 130 141 * @send: Send a packet on the device. 131 142 * zero for dropped packets or negative for error. 132 - * @get_egress_tun_info: Get the egress tunnel 5-tuple and other info for 133 - * a packet. 134 143 */ 135 144 struct vport_ops { 136 145 enum ovs_vport_type type; ··· 141 154 int (*get_options)(const struct vport *, struct sk_buff *); 142 155 143 156 void (*send)(struct vport *, struct sk_buff *); 144 - int (*get_egress_tun_info)(struct vport *, struct sk_buff *, 145 - struct dp_upcall_info *upcall); 146 - 147 157 struct module *owner; 148 158 struct list_head list; 149 159 }; ··· 198 214 199 215 int ovs_vport_ops_register(struct vport_ops *ops); 200 216 void ovs_vport_ops_unregister(struct vport_ops *ops); 201 - 202 - static inline struct rtable *ovs_tunnel_route_lookup(struct net *net, 203 - const struct ip_tunnel_key *key, 204 - u32 mark, 205 - struct flowi4 *fl, 206 - u8 protocol) 207 - { 208 - struct rtable *rt; 209 - 210 - memset(fl, 0, sizeof(*fl)); 211 - fl->daddr = key->u.ipv4.dst; 212 - fl->saddr = key->u.ipv4.src; 213 - fl->flowi4_tos = RT_TOS(key->tos); 214 - fl->flowi4_mark = mark; 215 - fl->flowi4_proto = protocol; 216 - 217 - rt = ip_route_output_key(net, fl); 218 - return rt; 219 - } 220 217 221 218 static inline void ovs_vport_send(struct vport *vport, struct sk_buff *skb) 222 219 {
+9 -2
net/rds/tcp_recv.c
··· 214 214 } 215 215 216 216 to_copy = min(tc->t_tinc_data_rem, left); 217 - pskb_pull(clone, offset); 218 - pskb_trim(clone, to_copy); 217 + if (!pskb_pull(clone, offset) || 218 + pskb_trim(clone, to_copy)) { 219 + pr_warn("rds_tcp_data_recv: pull/trim failed " 220 + "left %zu data_rem %zu skb_len %d\n", 221 + left, tc->t_tinc_data_rem, skb->len); 222 + kfree_skb(clone); 223 + desc->error = -ENOMEM; 224 + goto out; 225 + } 219 226 skb_queue_tail(&tinc->ti_skb_list, clone); 220 227 221 228 rdsdebug("skb %p data %p len %d off %u to_copy %zu -> "
+5 -1
net/sysctl_net.c
··· 94 94 goto out; 95 95 ret = register_pernet_subsys(&sysctl_pernet_ops); 96 96 if (ret) 97 - goto out; 97 + goto out1; 98 98 register_sysctl_root(&net_sysctl_root); 99 99 out: 100 100 return ret; 101 + out1: 102 + unregister_sysctl_table(net_header); 103 + net_header = NULL; 104 + goto out; 101 105 } 102 106 103 107 struct ctl_table_header *register_net_sysctl(struct net *net,
+5 -3
net/tipc/bcast.c
··· 42 42 #include "core.h" 43 43 44 44 #define MAX_PKT_DEFAULT_MCAST 1500 /* bcast link max packet size (fixed) */ 45 - #define BCLINK_WIN_DEFAULT 20 /* bcast link window size (default) */ 45 + #define BCLINK_WIN_DEFAULT 50 /* bcast link window size (default) */ 46 + #define BCLINK_WIN_MIN 32 /* bcast minimum link window size */ 46 47 47 48 const char tipc_bclink_name[] = "broadcast-link"; 48 49 ··· 909 908 910 909 if (!bcl) 911 910 return -ENOPROTOOPT; 912 - if ((limit < TIPC_MIN_LINK_WIN) || (limit > TIPC_MAX_LINK_WIN)) 911 + if (limit < BCLINK_WIN_MIN) 912 + limit = BCLINK_WIN_MIN; 913 + if (limit > TIPC_MAX_LINK_WIN) 913 914 return -EINVAL; 914 - 915 915 tipc_bclink_lock(net); 916 916 tipc_link_set_queue_limits(bcl, limit); 917 917 tipc_bclink_unlock(net);
+9 -3
net/tipc/msg.c
··· 121 121 { 122 122 struct sk_buff *head = *headbuf; 123 123 struct sk_buff *frag = *buf; 124 - struct sk_buff *tail; 124 + struct sk_buff *tail = NULL; 125 125 struct tipc_msg *msg; 126 126 u32 fragid; 127 127 int delta; ··· 141 141 if (unlikely(skb_unclone(frag, GFP_ATOMIC))) 142 142 goto err; 143 143 head = *headbuf = frag; 144 - skb_frag_list_init(head); 145 - TIPC_SKB_CB(head)->tail = NULL; 146 144 *buf = NULL; 145 + TIPC_SKB_CB(head)->tail = NULL; 146 + if (skb_is_nonlinear(head)) { 147 + skb_walk_frags(head, tail) { 148 + TIPC_SKB_CB(head)->tail = tail; 149 + } 150 + } else { 151 + skb_frag_list_init(head); 152 + } 147 153 return 0; 148 154 } 149 155
+5
net/tipc/udp_media.c
··· 52 52 /* IANA assigned UDP port */ 53 53 #define UDP_PORT_DEFAULT 6118 54 54 55 + #define UDP_MIN_HEADROOM 28 56 + 55 57 static const struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = { 56 58 [TIPC_NLA_UDP_UNSPEC] = {.type = NLA_UNSPEC}, 57 59 [TIPC_NLA_UDP_LOCAL] = {.type = NLA_BINARY, ··· 157 155 struct udp_media_addr *src = (struct udp_media_addr *)&b->addr.value; 158 156 struct sk_buff *clone; 159 157 struct rtable *rt; 158 + 159 + if (skb_headroom(skb) < UDP_MIN_HEADROOM) 160 + pskb_expand_head(skb, UDP_MIN_HEADROOM, 0, GFP_ATOMIC); 160 161 161 162 clone = skb_clone(skb, GFP_ATOMIC); 162 163 skb_set_inner_protocol(clone, htons(ETH_P_TIPC));
+4 -3
net/vmw_vsock/af_vsock.c
··· 1948 1948 err = misc_register(&vsock_device); 1949 1949 if (err) { 1950 1950 pr_err("Failed to register misc device\n"); 1951 - return -ENOENT; 1951 + goto err_reset_transport; 1952 1952 } 1953 1953 1954 1954 err = proto_register(&vsock_proto, 1); /* we want our slab */ 1955 1955 if (err) { 1956 1956 pr_err("Cannot register vsock protocol\n"); 1957 - goto err_misc_deregister; 1957 + goto err_deregister_misc; 1958 1958 } 1959 1959 1960 1960 err = sock_register(&vsock_family_ops); ··· 1969 1969 1970 1970 err_unregister_proto: 1971 1971 proto_unregister(&vsock_proto); 1972 - err_misc_deregister: 1972 + err_deregister_misc: 1973 1973 misc_deregister(&vsock_device); 1974 + err_reset_transport: 1974 1975 transport = NULL; 1975 1976 err_busy: 1976 1977 mutex_unlock(&vsock_register_mutex);
+85 -92
net/vmw_vsock/vmci_transport.c
··· 40 40 41 41 static int vmci_transport_recv_dgram_cb(void *data, struct vmci_datagram *dg); 42 42 static int vmci_transport_recv_stream_cb(void *data, struct vmci_datagram *dg); 43 - static void vmci_transport_peer_attach_cb(u32 sub_id, 44 - const struct vmci_event_data *ed, 45 - void *client_data); 46 43 static void vmci_transport_peer_detach_cb(u32 sub_id, 47 44 const struct vmci_event_data *ed, 48 45 void *client_data); 49 46 static void vmci_transport_recv_pkt_work(struct work_struct *work); 47 + static void vmci_transport_cleanup(struct work_struct *work); 50 48 static int vmci_transport_recv_listen(struct sock *sk, 51 49 struct vmci_transport_packet *pkt); 52 50 static int vmci_transport_recv_connecting_server( ··· 72 74 struct sock *sk; 73 75 struct vmci_transport_packet pkt; 74 76 }; 77 + 78 + static LIST_HEAD(vmci_transport_cleanup_list); 79 + static DEFINE_SPINLOCK(vmci_transport_cleanup_lock); 80 + static DECLARE_WORK(vmci_transport_cleanup_work, vmci_transport_cleanup); 75 81 76 82 static struct vmci_handle vmci_transport_stream_handle = { VMCI_INVALID_ID, 77 83 VMCI_INVALID_ID }; ··· 793 791 return err; 794 792 } 795 793 796 - static void vmci_transport_peer_attach_cb(u32 sub_id, 797 - const struct vmci_event_data *e_data, 798 - void *client_data) 799 - { 800 - struct sock *sk = client_data; 801 - const struct vmci_event_payload_qp *e_payload; 802 - struct vsock_sock *vsk; 803 - 804 - e_payload = vmci_event_data_const_payload(e_data); 805 - 806 - vsk = vsock_sk(sk); 807 - 808 - /* We don't ask for delayed CBs when we subscribe to this event (we 809 - * pass 0 as flags to vmci_event_subscribe()). VMCI makes no 810 - * guarantees in that case about what context we might be running in, 811 - * so it could be BH or process, blockable or non-blockable. So we 812 - * need to account for all possible contexts here. 813 - */ 814 - local_bh_disable(); 815 - bh_lock_sock(sk); 816 - 817 - /* XXX This is lame, we should provide a way to lookup sockets by 818 - * qp_handle. 819 - */ 820 - if (vmci_handle_is_equal(vmci_trans(vsk)->qp_handle, 821 - e_payload->handle)) { 822 - /* XXX This doesn't do anything, but in the future we may want 823 - * to set a flag here to verify the attach really did occur and 824 - * we weren't just sent a datagram claiming it was. 825 - */ 826 - goto out; 827 - } 828 - 829 - out: 830 - bh_unlock_sock(sk); 831 - local_bh_enable(); 832 - } 833 - 834 794 static void vmci_transport_handle_detach(struct sock *sk) 835 795 { 836 796 struct vsock_sock *vsk; ··· 835 871 const struct vmci_event_data *e_data, 836 872 void *client_data) 837 873 { 838 - struct sock *sk = client_data; 874 + struct vmci_transport *trans = client_data; 839 875 const struct vmci_event_payload_qp *e_payload; 840 - struct vsock_sock *vsk; 841 876 842 877 e_payload = vmci_event_data_const_payload(e_data); 843 - vsk = vsock_sk(sk); 844 - if (vmci_handle_is_invalid(e_payload->handle)) 845 - return; 846 - 847 - /* Same rules for locking as for peer_attach_cb(). */ 848 - local_bh_disable(); 849 - bh_lock_sock(sk); 850 878 851 879 /* XXX This is lame, we should provide a way to lookup sockets by 852 880 * qp_handle. 853 881 */ 854 - if (vmci_handle_is_equal(vmci_trans(vsk)->qp_handle, 855 - e_payload->handle)) 856 - vmci_transport_handle_detach(sk); 882 + if (vmci_handle_is_invalid(e_payload->handle) || 883 + vmci_handle_is_equal(trans->qp_handle, e_payload->handle)) 884 + return; 857 885 858 - bh_unlock_sock(sk); 859 - local_bh_enable(); 886 + /* We don't ask for delayed CBs when we subscribe to this event (we 887 + * pass 0 as flags to vmci_event_subscribe()). VMCI makes no 888 + * guarantees in that case about what context we might be running in, 889 + * so it could be BH or process, blockable or non-blockable. So we 890 + * need to account for all possible contexts here. 891 + */ 892 + spin_lock_bh(&trans->lock); 893 + if (!trans->sk) 894 + goto out; 895 + 896 + /* Apart from here, trans->lock is only grabbed as part of sk destruct, 897 + * where trans->sk isn't locked. 898 + */ 899 + bh_lock_sock(trans->sk); 900 + 901 + vmci_transport_handle_detach(trans->sk); 902 + 903 + bh_unlock_sock(trans->sk); 904 + out: 905 + spin_unlock_bh(&trans->lock); 860 906 } 861 907 862 908 static void vmci_transport_qp_resumed_cb(u32 sub_id, ··· 1155 1181 */ 1156 1182 err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_DETACH, 1157 1183 vmci_transport_peer_detach_cb, 1158 - pending, &detach_sub_id); 1184 + vmci_trans(vpending), &detach_sub_id); 1159 1185 if (err < VMCI_SUCCESS) { 1160 1186 vmci_transport_send_reset(pending, pkt); 1161 1187 err = vmci_transport_error_to_vsock_error(err); ··· 1295 1321 || vmci_trans(vsk)->qpair 1296 1322 || vmci_trans(vsk)->produce_size != 0 1297 1323 || vmci_trans(vsk)->consume_size != 0 1298 - || vmci_trans(vsk)->attach_sub_id != VMCI_INVALID_ID 1299 1324 || vmci_trans(vsk)->detach_sub_id != VMCI_INVALID_ID) { 1300 1325 skerr = EPROTO; 1301 1326 err = -EINVAL; ··· 1362 1389 struct vsock_sock *vsk; 1363 1390 struct vmci_handle handle; 1364 1391 struct vmci_qp *qpair; 1365 - u32 attach_sub_id; 1366 1392 u32 detach_sub_id; 1367 1393 bool is_local; 1368 1394 u32 flags; ··· 1371 1399 1372 1400 vsk = vsock_sk(sk); 1373 1401 handle = VMCI_INVALID_HANDLE; 1374 - attach_sub_id = VMCI_INVALID_ID; 1375 1402 detach_sub_id = VMCI_INVALID_ID; 1376 1403 1377 1404 /* If we have gotten here then we should be past the point where old ··· 1415 1444 goto destroy; 1416 1445 } 1417 1446 1418 - /* Subscribe to attach and detach events first. 1447 + /* Subscribe to detach events first. 1419 1448 * 1420 1449 * XXX We attach once for each queue pair created for now so it is easy 1421 1450 * to find the socket (it's provided), but later we should only 1422 1451 * subscribe once and add a way to lookup sockets by queue pair handle. 1423 1452 */ 1424 - err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_ATTACH, 1425 - vmci_transport_peer_attach_cb, 1426 - sk, &attach_sub_id); 1427 - if (err < VMCI_SUCCESS) { 1428 - err = vmci_transport_error_to_vsock_error(err); 1429 - goto destroy; 1430 - } 1431 - 1432 1453 err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_DETACH, 1433 1454 vmci_transport_peer_detach_cb, 1434 - sk, &detach_sub_id); 1455 + vmci_trans(vsk), &detach_sub_id); 1435 1456 if (err < VMCI_SUCCESS) { 1436 1457 err = vmci_transport_error_to_vsock_error(err); 1437 1458 goto destroy; ··· 1459 1496 vmci_trans(vsk)->produce_size = vmci_trans(vsk)->consume_size = 1460 1497 pkt->u.size; 1461 1498 1462 - vmci_trans(vsk)->attach_sub_id = attach_sub_id; 1463 1499 vmci_trans(vsk)->detach_sub_id = detach_sub_id; 1464 1500 1465 1501 vmci_trans(vsk)->notify_ops->process_negotiate(sk); ··· 1466 1504 return 0; 1467 1505 1468 1506 destroy: 1469 - if (attach_sub_id != VMCI_INVALID_ID) 1470 - vmci_event_unsubscribe(attach_sub_id); 1471 - 1472 1507 if (detach_sub_id != VMCI_INVALID_ID) 1473 1508 vmci_event_unsubscribe(detach_sub_id); 1474 1509 ··· 1566 1607 vmci_trans(vsk)->qp_handle = VMCI_INVALID_HANDLE; 1567 1608 vmci_trans(vsk)->qpair = NULL; 1568 1609 vmci_trans(vsk)->produce_size = vmci_trans(vsk)->consume_size = 0; 1569 - vmci_trans(vsk)->attach_sub_id = vmci_trans(vsk)->detach_sub_id = 1570 - VMCI_INVALID_ID; 1610 + vmci_trans(vsk)->detach_sub_id = VMCI_INVALID_ID; 1571 1611 vmci_trans(vsk)->notify_ops = NULL; 1612 + INIT_LIST_HEAD(&vmci_trans(vsk)->elem); 1613 + vmci_trans(vsk)->sk = &vsk->sk; 1614 + spin_lock_init(&vmci_trans(vsk)->lock); 1572 1615 if (psk) { 1573 1616 vmci_trans(vsk)->queue_pair_size = 1574 1617 vmci_trans(psk)->queue_pair_size; ··· 1590 1629 return 0; 1591 1630 } 1592 1631 1632 + static void vmci_transport_free_resources(struct list_head *transport_list) 1633 + { 1634 + while (!list_empty(transport_list)) { 1635 + struct vmci_transport *transport = 1636 + list_first_entry(transport_list, struct vmci_transport, 1637 + elem); 1638 + list_del(&transport->elem); 1639 + 1640 + if (transport->detach_sub_id != VMCI_INVALID_ID) { 1641 + vmci_event_unsubscribe(transport->detach_sub_id); 1642 + transport->detach_sub_id = VMCI_INVALID_ID; 1643 + } 1644 + 1645 + if (!vmci_handle_is_invalid(transport->qp_handle)) { 1646 + vmci_qpair_detach(&transport->qpair); 1647 + transport->qp_handle = VMCI_INVALID_HANDLE; 1648 + transport->produce_size = 0; 1649 + transport->consume_size = 0; 1650 + } 1651 + 1652 + kfree(transport); 1653 + } 1654 + } 1655 + 1656 + static void vmci_transport_cleanup(struct work_struct *work) 1657 + { 1658 + LIST_HEAD(pending); 1659 + 1660 + spin_lock_bh(&vmci_transport_cleanup_lock); 1661 + list_replace_init(&vmci_transport_cleanup_list, &pending); 1662 + spin_unlock_bh(&vmci_transport_cleanup_lock); 1663 + vmci_transport_free_resources(&pending); 1664 + } 1665 + 1593 1666 static void vmci_transport_destruct(struct vsock_sock *vsk) 1594 1667 { 1595 - if (vmci_trans(vsk)->attach_sub_id != VMCI_INVALID_ID) { 1596 - vmci_event_unsubscribe(vmci_trans(vsk)->attach_sub_id); 1597 - vmci_trans(vsk)->attach_sub_id = VMCI_INVALID_ID; 1598 - } 1599 - 1600 - if (vmci_trans(vsk)->detach_sub_id != VMCI_INVALID_ID) { 1601 - vmci_event_unsubscribe(vmci_trans(vsk)->detach_sub_id); 1602 - vmci_trans(vsk)->detach_sub_id = VMCI_INVALID_ID; 1603 - } 1604 - 1605 - if (!vmci_handle_is_invalid(vmci_trans(vsk)->qp_handle)) { 1606 - vmci_qpair_detach(&vmci_trans(vsk)->qpair); 1607 - vmci_trans(vsk)->qp_handle = VMCI_INVALID_HANDLE; 1608 - vmci_trans(vsk)->produce_size = 0; 1609 - vmci_trans(vsk)->consume_size = 0; 1610 - } 1668 + /* Ensure that the detach callback doesn't use the sk/vsk 1669 + * we are about to destruct. 1670 + */ 1671 + spin_lock_bh(&vmci_trans(vsk)->lock); 1672 + vmci_trans(vsk)->sk = NULL; 1673 + spin_unlock_bh(&vmci_trans(vsk)->lock); 1611 1674 1612 1675 if (vmci_trans(vsk)->notify_ops) 1613 1676 vmci_trans(vsk)->notify_ops->socket_destruct(vsk); 1614 1677 1615 - kfree(vsk->trans); 1678 + spin_lock_bh(&vmci_transport_cleanup_lock); 1679 + list_add(&vmci_trans(vsk)->elem, &vmci_transport_cleanup_list); 1680 + spin_unlock_bh(&vmci_transport_cleanup_lock); 1681 + schedule_work(&vmci_transport_cleanup_work); 1682 + 1616 1683 vsk->trans = NULL; 1617 1684 } 1618 1685 ··· 2135 2146 2136 2147 static void __exit vmci_transport_exit(void) 2137 2148 { 2149 + cancel_work_sync(&vmci_transport_cleanup_work); 2150 + vmci_transport_free_resources(&vmci_transport_cleanup_list); 2151 + 2138 2152 if (!vmci_handle_is_invalid(vmci_transport_stream_handle)) { 2139 2153 if (vmci_datagram_destroy_handle( 2140 2154 vmci_transport_stream_handle) != VMCI_SUCCESS) ··· 2156 2164 2157 2165 MODULE_AUTHOR("VMware, Inc."); 2158 2166 MODULE_DESCRIPTION("VMCI transport for Virtual Sockets"); 2167 + MODULE_VERSION("1.0.2.0-k"); 2159 2168 MODULE_LICENSE("GPL v2"); 2160 2169 MODULE_ALIAS("vmware_vsock"); 2161 2170 MODULE_ALIAS_NETPROTO(PF_VSOCK);
+3 -1
net/vmw_vsock/vmci_transport.h
··· 119 119 u64 queue_pair_size; 120 120 u64 queue_pair_min_size; 121 121 u64 queue_pair_max_size; 122 - u32 attach_sub_id; 123 122 u32 detach_sub_id; 124 123 union vmci_transport_notify notify; 125 124 struct vmci_transport_notify_ops *notify_ops; 125 + struct list_head elem; 126 + struct sock *sk; 127 + spinlock_t lock; /* protects sk. */ 126 128 }; 127 129 128 130 int vmci_transport_register(void);
+3 -1
net/xfrm/xfrm_user.c
··· 1928 1928 struct nlattr *rp = attrs[XFRMA_REPLAY_VAL]; 1929 1929 struct nlattr *re = attrs[XFRMA_REPLAY_ESN_VAL]; 1930 1930 struct nlattr *lt = attrs[XFRMA_LTIME_VAL]; 1931 + struct nlattr *et = attrs[XFRMA_ETIMER_THRESH]; 1932 + struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH]; 1931 1933 1932 - if (!lt && !rp && !re) 1934 + if (!lt && !rp && !re && !et && !rt) 1933 1935 return err; 1934 1936 1935 1937 /* pedantic mode - thou shalt sayeth replaceth */
+12
samples/bpf/bpf_helpers.h
··· 86 86 #define PT_REGS_RC(x) ((x)->gprs[2]) 87 87 #define PT_REGS_SP(x) ((x)->gprs[15]) 88 88 89 + #elif defined(__aarch64__) 90 + 91 + #define PT_REGS_PARM1(x) ((x)->regs[0]) 92 + #define PT_REGS_PARM2(x) ((x)->regs[1]) 93 + #define PT_REGS_PARM3(x) ((x)->regs[2]) 94 + #define PT_REGS_PARM4(x) ((x)->regs[3]) 95 + #define PT_REGS_PARM5(x) ((x)->regs[4]) 96 + #define PT_REGS_RET(x) ((x)->regs[30]) 97 + #define PT_REGS_FP(x) ((x)->regs[29]) /* Works only with CONFIG_FRAME_POINTER */ 98 + #define PT_REGS_RC(x) ((x)->regs[0]) 99 + #define PT_REGS_SP(x) ((x)->sp) 100 + 89 101 #endif 90 102 #endif