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) If the timing is wrong we can indefinitely stop generating new ipv6
temporary addresses, from Marcus Huewe.

2) Don't double free per-cpu stats in ipv6 SIT tunnel driver, from Cong
Wang.

3) Put protections in place so that AF_PACKET is not able to submit
packets which don't even have a link level header to drivers. From
Willem de Bruijn.

4) Fix memory leaks in ipv4 and ipv6 multicast code, from Hangbin Liu.

5) Don't use udp_ioctl() in l2tp code, UDP version expects a UDP socket
and that doesn't go over very well when it is passed an L2TP one.
Fix from Eric Dumazet.

6) Don't crash on NULL pointer in phy_attach_direct(), from Florian
Fainelli.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net:
l2tp: do not use udp_ioctl()
xen-netfront: Delete rx_refill_timer in xennet_disconnect_backend()
NET: mkiss: Fix panic
net: hns: Fix the device being used for dma mapping during TX
net: phy: Initialize mdio clock at probe function
igmp, mld: Fix memory leak in igmpv3/mld_del_delrec()
xen-netfront: Improve error handling during initialization
sierra_net: Skip validating irrelevant fields for IDLE LSIs
sierra_net: Add support for IPv6 and Dual-Stack Link Sense Indications
kcm: fix 0-length case for kcm_sendmsg()
xen-netfront: Rework the fix for Rx stall during OOM and network stress
net: phy: Fix PHY module checks and NULL deref in phy_attach_direct()
net: thunderx: Fix PHY autoneg for SGMII QLM mode
net: dsa: Do not destroy invalid network devices
ping: fix a null pointer dereference
packet: round up linear to header len
net: introduce device min_header_len
sit: fix a double free on error path
lwtunnel: valid encap attr check should return 0 when lwtunnel is disabled
ipv6: addrconf: fix generation of new temporary addresses

+307 -123
+96 -12
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 31 31 u8 lmac_type; 32 32 u8 lane_to_sds; 33 33 bool use_training; 34 + bool autoneg; 34 35 bool link_up; 35 36 int lmacid; /* ID within BGX */ 36 37 int lmacid_bd; /* ID on board */ ··· 462 461 /* power down, reset autoneg, autoneg enable */ 463 462 cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MRX_CTL); 464 463 cfg &= ~PCS_MRX_CTL_PWR_DN; 465 - cfg |= (PCS_MRX_CTL_RST_AN | PCS_MRX_CTL_AN_EN); 464 + cfg |= PCS_MRX_CTL_RST_AN; 465 + if (lmac->phydev) { 466 + cfg |= PCS_MRX_CTL_AN_EN; 467 + } else { 468 + /* In scenarios where PHY driver is not present or it's a 469 + * non-standard PHY, FW sets AN_EN to inform Linux driver 470 + * to do auto-neg and link polling or not. 471 + */ 472 + if (cfg & PCS_MRX_CTL_AN_EN) 473 + lmac->autoneg = true; 474 + } 466 475 bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, cfg); 467 476 468 477 if (lmac->lmac_type == BGX_MODE_QSGMII) { ··· 483 472 return 0; 484 473 } 485 474 486 - if (lmac->lmac_type == BGX_MODE_SGMII) { 475 + if ((lmac->lmac_type == BGX_MODE_SGMII) && lmac->phydev) { 487 476 if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_STATUS, 488 477 PCS_MRX_STATUS_AN_CPT, false)) { 489 478 dev_err(&bgx->pdev->dev, "BGX AN_CPT not completed\n"); ··· 689 678 return -1; 690 679 } 691 680 681 + static void bgx_poll_for_sgmii_link(struct lmac *lmac) 682 + { 683 + u64 pcs_link, an_result; 684 + u8 speed; 685 + 686 + pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid, 687 + BGX_GMP_PCS_MRX_STATUS); 688 + 689 + /*Link state bit is sticky, read it again*/ 690 + if (!(pcs_link & PCS_MRX_STATUS_LINK)) 691 + pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid, 692 + BGX_GMP_PCS_MRX_STATUS); 693 + 694 + if (bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_GMP_PCS_MRX_STATUS, 695 + PCS_MRX_STATUS_AN_CPT, false)) { 696 + lmac->link_up = false; 697 + lmac->last_speed = SPEED_UNKNOWN; 698 + lmac->last_duplex = DUPLEX_UNKNOWN; 699 + goto next_poll; 700 + } 701 + 702 + lmac->link_up = ((pcs_link & PCS_MRX_STATUS_LINK) != 0) ? true : false; 703 + an_result = bgx_reg_read(lmac->bgx, lmac->lmacid, 704 + BGX_GMP_PCS_ANX_AN_RESULTS); 705 + 706 + speed = (an_result >> 3) & 0x3; 707 + lmac->last_duplex = (an_result >> 1) & 0x1; 708 + switch (speed) { 709 + case 0: 710 + lmac->last_speed = 10; 711 + break; 712 + case 1: 713 + lmac->last_speed = 100; 714 + break; 715 + case 2: 716 + lmac->last_speed = 1000; 717 + break; 718 + default: 719 + lmac->link_up = false; 720 + lmac->last_speed = SPEED_UNKNOWN; 721 + lmac->last_duplex = DUPLEX_UNKNOWN; 722 + break; 723 + } 724 + 725 + next_poll: 726 + 727 + if (lmac->last_link != lmac->link_up) { 728 + if (lmac->link_up) 729 + bgx_sgmii_change_link_state(lmac); 730 + lmac->last_link = lmac->link_up; 731 + } 732 + 733 + queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 3); 734 + } 735 + 692 736 static void bgx_poll_for_link(struct work_struct *work) 693 737 { 694 738 struct lmac *lmac; 695 739 u64 spu_link, smu_link; 696 740 697 741 lmac = container_of(work, struct lmac, dwork.work); 742 + if (lmac->is_sgmii) { 743 + bgx_poll_for_sgmii_link(lmac); 744 + return; 745 + } 698 746 699 747 /* Receive link is latching low. Force it high and verify it */ 700 748 bgx_reg_modify(lmac->bgx, lmac->lmacid, ··· 845 775 (lmac->lmac_type != BGX_MODE_XLAUI) && 846 776 (lmac->lmac_type != BGX_MODE_40G_KR) && 847 777 (lmac->lmac_type != BGX_MODE_10G_KR)) { 848 - if (!lmac->phydev) 849 - return -ENODEV; 850 - 778 + if (!lmac->phydev) { 779 + if (lmac->autoneg) { 780 + bgx_reg_write(bgx, lmacid, 781 + BGX_GMP_PCS_LINKX_TIMER, 782 + PCS_LINKX_TIMER_COUNT); 783 + goto poll; 784 + } else { 785 + /* Default to below link speed and duplex */ 786 + lmac->link_up = true; 787 + lmac->last_speed = 1000; 788 + lmac->last_duplex = 1; 789 + bgx_sgmii_change_link_state(lmac); 790 + return 0; 791 + } 792 + } 851 793 lmac->phydev->dev_flags = 0; 852 794 853 795 if (phy_connect_direct(&lmac->netdev, lmac->phydev, ··· 868 786 return -ENODEV; 869 787 870 788 phy_start_aneg(lmac->phydev); 871 - } else { 872 - lmac->check_link = alloc_workqueue("check_link", WQ_UNBOUND | 873 - WQ_MEM_RECLAIM, 1); 874 - if (!lmac->check_link) 875 - return -ENOMEM; 876 - INIT_DELAYED_WORK(&lmac->dwork, bgx_poll_for_link); 877 - queue_delayed_work(lmac->check_link, &lmac->dwork, 0); 789 + return 0; 878 790 } 791 + 792 + poll: 793 + lmac->check_link = alloc_workqueue("check_link", WQ_UNBOUND | 794 + WQ_MEM_RECLAIM, 1); 795 + if (!lmac->check_link) 796 + return -ENOMEM; 797 + INIT_DELAYED_WORK(&lmac->dwork, bgx_poll_for_link); 798 + queue_delayed_work(lmac->check_link, &lmac->dwork, 0); 879 799 880 800 return 0; 881 801 }
+5
drivers/net/ethernet/cavium/thunder/thunder_bgx.h
··· 153 153 #define PCS_MRX_CTL_LOOPBACK1 BIT_ULL(14) 154 154 #define PCS_MRX_CTL_RESET BIT_ULL(15) 155 155 #define BGX_GMP_PCS_MRX_STATUS 0x30008 156 + #define PCS_MRX_STATUS_LINK BIT_ULL(2) 156 157 #define PCS_MRX_STATUS_AN_CPT BIT_ULL(5) 158 + #define BGX_GMP_PCS_ANX_ADV 0x30010 157 159 #define BGX_GMP_PCS_ANX_AN_RESULTS 0x30020 160 + #define BGX_GMP_PCS_LINKX_TIMER 0x30040 161 + #define PCS_LINKX_TIMER_COUNT 0x1E84 158 162 #define BGX_GMP_PCS_SGM_AN_ADV 0x30068 159 163 #define BGX_GMP_PCS_MISCX_CTL 0x30078 164 + #define PCS_MISC_CTL_MODE BIT_ULL(8) 160 165 #define PCS_MISC_CTL_DISP_EN BIT_ULL(13) 161 166 #define PCS_MISC_CTL_GMX_ENO BIT_ULL(11) 162 167 #define PCS_MISC_CTL_SAMP_PT_MASK 0x7Full
+1 -1
drivers/net/ethernet/hisilicon/hns/hns_enet.c
··· 305 305 struct hns_nic_ring_data *ring_data) 306 306 { 307 307 struct hns_nic_priv *priv = netdev_priv(ndev); 308 - struct device *dev = priv->dev; 309 308 struct hnae_ring *ring = ring_data->ring; 309 + struct device *dev = ring_to_dev(ring); 310 310 struct netdev_queue *dev_queue; 311 311 struct skb_frag_struct *frag; 312 312 int buf_num;
+2 -2
drivers/net/hamradio/mkiss.c
··· 648 648 { 649 649 /* Finish setting up the DEVICE info. */ 650 650 dev->mtu = AX_MTU; 651 - dev->hard_header_len = 0; 652 - dev->addr_len = 0; 651 + dev->hard_header_len = AX25_MAX_HEADER_LEN; 652 + dev->addr_len = AX25_ADDR_LEN; 653 653 dev->type = ARPHRD_AX25; 654 654 dev->tx_queue_len = 10; 655 655 dev->header_ops = &ax25_header_ops;
+1
drivers/net/loopback.c
··· 164 164 { 165 165 dev->mtu = 64 * 1024; 166 166 dev->hard_header_len = ETH_HLEN; /* 14 */ 167 + dev->min_header_len = ETH_HLEN; /* 14 */ 167 168 dev->addr_len = ETH_ALEN; /* 6 */ 168 169 dev->type = ARPHRD_LOOPBACK; /* 0x0001*/ 169 170 dev->flags = IFF_LOOPBACK;
+2 -4
drivers/net/phy/mdio-bcm-iproc.c
··· 81 81 if (rc) 82 82 return rc; 83 83 84 - iproc_mdio_config_clk(priv->base); 85 - 86 84 /* Prepare the read operation */ 87 85 cmd = (MII_DATA_TA_VAL << MII_DATA_TA_SHIFT) | 88 86 (reg << MII_DATA_RA_SHIFT) | ··· 109 111 rc = iproc_mdio_wait_for_idle(priv->base); 110 112 if (rc) 111 113 return rc; 112 - 113 - iproc_mdio_config_clk(priv->base); 114 114 115 115 /* Prepare the write operation */ 116 116 cmd = (MII_DATA_TA_VAL << MII_DATA_TA_SHIFT) | ··· 158 162 bus->parent = &pdev->dev; 159 163 bus->read = iproc_mdio_read; 160 164 bus->write = iproc_mdio_write; 165 + 166 + iproc_mdio_config_clk(priv->base); 161 167 162 168 rc = of_mdiobus_register(bus, pdev->dev.of_node); 163 169 if (rc) {
+20 -8
drivers/net/phy/phy_device.c
··· 908 908 struct module *ndev_owner = dev->dev.parent->driver->owner; 909 909 struct mii_bus *bus = phydev->mdio.bus; 910 910 struct device *d = &phydev->mdio.dev; 911 + bool using_genphy = false; 911 912 int err; 912 913 913 914 /* For Ethernet device drivers that register their own MDIO bus, we ··· 918 917 */ 919 918 if (ndev_owner != bus->owner && !try_module_get(bus->owner)) { 920 919 dev_err(&dev->dev, "failed to get the bus module\n"); 921 - return -EIO; 922 - } 923 - 924 - if (!try_module_get(d->driver->owner)) { 925 - dev_err(&dev->dev, "failed to get the device driver module\n"); 926 920 return -EIO; 927 921 } 928 922 ··· 934 938 d->driver = 935 939 &genphy_driver[GENPHY_DRV_1G].mdiodrv.driver; 936 940 941 + using_genphy = true; 942 + } 943 + 944 + if (!try_module_get(d->driver->owner)) { 945 + dev_err(&dev->dev, "failed to get the device driver module\n"); 946 + err = -EIO; 947 + goto error_put_device; 948 + } 949 + 950 + if (using_genphy) { 937 951 err = d->driver->probe(d); 938 952 if (err >= 0) 939 953 err = device_bind_driver(d); 940 954 941 955 if (err) 942 - goto error; 956 + goto error_module_put; 943 957 } 944 958 945 959 if (phydev->attached_dev) { ··· 986 980 return err; 987 981 988 982 error: 983 + /* phy_detach() does all of the cleanup below */ 989 984 phy_detach(phydev); 990 - put_device(d); 985 + return err; 986 + 987 + error_module_put: 991 988 module_put(d->driver->owner); 989 + error_put_device: 990 + put_device(d); 992 991 if (ndev_owner != bus->owner) 993 992 module_put(bus->owner); 994 993 return err; ··· 1056 1045 1057 1046 phy_led_triggers_unregister(phydev); 1058 1047 1048 + module_put(phydev->mdio.dev.driver->owner); 1049 + 1059 1050 /* If the device had no specific driver before (i.e. - it 1060 1051 * was using the generic driver), we unbind the device 1061 1052 * from the generic driver so that there's a chance a ··· 1078 1065 bus = phydev->mdio.bus; 1079 1066 1080 1067 put_device(&phydev->mdio.dev); 1081 - module_put(phydev->mdio.dev.driver->owner); 1082 1068 if (ndev_owner != bus->owner) 1083 1069 module_put(bus->owner); 1084 1070 }
+80 -49
drivers/net/usb/sierra_net.c
··· 73 73 /* Private data structure */ 74 74 struct sierra_net_data { 75 75 76 - u8 ethr_hdr_tmpl[ETH_HLEN]; /* ethernet header template for rx'd pkts */ 77 - 78 76 u16 link_up; /* air link up or down */ 79 77 u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */ 80 78 ··· 120 122 121 123 /* LSI Protocol types */ 122 124 #define SIERRA_NET_PROTOCOL_UMTS 0x01 125 + #define SIERRA_NET_PROTOCOL_UMTS_DS 0x04 123 126 /* LSI Coverage */ 124 127 #define SIERRA_NET_COVERAGE_NONE 0x00 125 128 #define SIERRA_NET_COVERAGE_NOPACKET 0x01 ··· 128 129 /* LSI Session */ 129 130 #define SIERRA_NET_SESSION_IDLE 0x00 130 131 /* LSI Link types */ 131 - #define SIERRA_NET_AS_LINK_TYPE_IPv4 0x00 132 + #define SIERRA_NET_AS_LINK_TYPE_IPV4 0x00 133 + #define SIERRA_NET_AS_LINK_TYPE_IPV6 0x02 132 134 133 135 struct lsi_umts { 134 136 u8 protocol; ··· 137 137 __be16 length; 138 138 /* eventually use a union for the rest - assume umts for now */ 139 139 u8 coverage; 140 - u8 unused2[41]; 140 + u8 network_len; /* network name len */ 141 + u8 network[40]; /* network name (UCS2, bigendian) */ 141 142 u8 session_state; 142 143 u8 unused3[33]; 144 + } __packed; 145 + 146 + struct lsi_umts_single { 147 + struct lsi_umts lsi; 143 148 u8 link_type; 144 149 u8 pdp_addr_len; /* NW-supplied PDP address len */ 145 150 u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */ ··· 163 158 u8 reserved[8]; 164 159 } __packed; 165 160 161 + struct lsi_umts_dual { 162 + struct lsi_umts lsi; 163 + u8 pdp_addr4_len; /* NW-supplied PDP IPv4 address len */ 164 + u8 pdp_addr4[4]; /* NW-supplied PDP IPv4 address (bigendian)) */ 165 + u8 pdp_addr6_len; /* NW-supplied PDP IPv6 address len */ 166 + u8 pdp_addr6[16]; /* NW-supplied PDP IPv6 address (bigendian)) */ 167 + u8 unused4[23]; 168 + u8 dns1_addr4_len; /* NW-supplied 1st DNS v4 address len (bigendian) */ 169 + u8 dns1_addr4[4]; /* NW-supplied 1st DNS v4 address */ 170 + u8 dns1_addr6_len; /* NW-supplied 1st DNS v6 address len */ 171 + u8 dns1_addr6[16]; /* NW-supplied 1st DNS v6 address (bigendian)*/ 172 + u8 dns2_addr4_len; /* NW-supplied 2nd DNS v4 address len (bigendian) */ 173 + u8 dns2_addr4[4]; /* NW-supplied 2nd DNS v4 address */ 174 + u8 dns2_addr6_len; /* NW-supplied 2nd DNS v6 address len */ 175 + u8 dns2_addr6[16]; /* NW-supplied 2nd DNS v6 address (bigendian)*/ 176 + u8 unused5[68]; 177 + } __packed; 178 + 166 179 #define SIERRA_NET_LSI_COMMON_LEN 4 167 - #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts)) 180 + #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts_single)) 168 181 #define SIERRA_NET_LSI_UMTS_STATUS_LEN \ 169 182 (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN) 183 + #define SIERRA_NET_LSI_UMTS_DS_LEN (sizeof(struct lsi_umts_dual)) 184 + #define SIERRA_NET_LSI_UMTS_DS_STATUS_LEN \ 185 + (SIERRA_NET_LSI_UMTS_DS_LEN - SIERRA_NET_LSI_COMMON_LEN) 170 186 171 187 /* Forward definitions */ 172 188 static void sierra_sync_timer(unsigned long syncdata); ··· 216 190 dev->data[0] = (unsigned long)priv; 217 191 } 218 192 219 - /* is packet IPv4 */ 193 + /* is packet IPv4/IPv6 */ 220 194 static inline int is_ip(struct sk_buff *skb) 221 195 { 222 - return skb->protocol == cpu_to_be16(ETH_P_IP); 196 + return skb->protocol == cpu_to_be16(ETH_P_IP) || 197 + skb->protocol == cpu_to_be16(ETH_P_IPV6); 223 198 } 224 199 225 200 /* ··· 376 349 static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen) 377 350 { 378 351 struct lsi_umts *lsi = (struct lsi_umts *)data; 352 + u32 expected_length; 379 353 380 - if (datalen < sizeof(struct lsi_umts)) { 381 - netdev_err(dev->net, "%s: Data length %d, exp %Zu\n", 382 - __func__, datalen, 383 - sizeof(struct lsi_umts)); 354 + if (datalen < sizeof(struct lsi_umts_single)) { 355 + netdev_err(dev->net, "%s: Data length %d, exp >= %Zu\n", 356 + __func__, datalen, sizeof(struct lsi_umts_single)); 384 357 return -1; 385 - } 386 - 387 - if (lsi->length != cpu_to_be16(SIERRA_NET_LSI_UMTS_STATUS_LEN)) { 388 - netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n", 389 - __func__, be16_to_cpu(lsi->length), 390 - (u32)SIERRA_NET_LSI_UMTS_STATUS_LEN); 391 - return -1; 392 - } 393 - 394 - /* Validate the protocol - only support UMTS for now */ 395 - if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) { 396 - netdev_err(dev->net, "Protocol unsupported, 0x%02x\n", 397 - lsi->protocol); 398 - return -1; 399 - } 400 - 401 - /* Validate the link type */ 402 - if (lsi->link_type != SIERRA_NET_AS_LINK_TYPE_IPv4) { 403 - netdev_err(dev->net, "Link type unsupported: 0x%02x\n", 404 - lsi->link_type); 405 - return -1; 406 - } 407 - 408 - /* Validate the coverage */ 409 - if (lsi->coverage == SIERRA_NET_COVERAGE_NONE 410 - || lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) { 411 - netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage); 412 - return 0; 413 358 } 414 359 415 360 /* Validate the session state */ 416 361 if (lsi->session_state == SIERRA_NET_SESSION_IDLE) { 417 362 netdev_err(dev->net, "Session idle, 0x%02x\n", 418 - lsi->session_state); 363 + lsi->session_state); 364 + return 0; 365 + } 366 + 367 + /* Validate the protocol - only support UMTS for now */ 368 + if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS) { 369 + struct lsi_umts_single *single = (struct lsi_umts_single *)lsi; 370 + 371 + /* Validate the link type */ 372 + if (single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV4 && 373 + single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV6) { 374 + netdev_err(dev->net, "Link type unsupported: 0x%02x\n", 375 + single->link_type); 376 + return -1; 377 + } 378 + expected_length = SIERRA_NET_LSI_UMTS_STATUS_LEN; 379 + } else if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS_DS) { 380 + expected_length = SIERRA_NET_LSI_UMTS_DS_STATUS_LEN; 381 + } else { 382 + netdev_err(dev->net, "Protocol unsupported, 0x%02x\n", 383 + lsi->protocol); 384 + return -1; 385 + } 386 + 387 + if (be16_to_cpu(lsi->length) != expected_length) { 388 + netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n", 389 + __func__, be16_to_cpu(lsi->length), expected_length); 390 + return -1; 391 + } 392 + 393 + /* Validate the coverage */ 394 + if (lsi->coverage == SIERRA_NET_COVERAGE_NONE || 395 + lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) { 396 + netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage); 419 397 return 0; 420 398 } 421 399 ··· 684 652 u8 numendpoints; 685 653 u16 fwattr = 0; 686 654 int status; 687 - struct ethhdr *eth; 688 655 struct sierra_net_data *priv; 689 656 static const u8 sync_tmplate[sizeof(priv->sync_msg)] = { 690 657 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00}; ··· 720 689 /* change MAC addr to include, ifacenum, and to be unique */ 721 690 dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); 722 691 dev->net->dev_addr[ETH_ALEN-1] = ifacenum; 723 - 724 - /* we will have to manufacture ethernet headers, prepare template */ 725 - eth = (struct ethhdr *)priv->ethr_hdr_tmpl; 726 - memcpy(&eth->h_dest, dev->net->dev_addr, ETH_ALEN); 727 - eth->h_proto = cpu_to_be16(ETH_P_IP); 728 692 729 693 /* prepare shutdown message template */ 730 694 memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg)); ··· 850 824 851 825 skb_pull(skb, hh.hdrlen); 852 826 853 - /* We are going to accept this packet, prepare it */ 854 - memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl, 855 - ETH_HLEN); 827 + /* We are going to accept this packet, prepare it. 828 + * In case protocol is IPv6, keep it, otherwise force IPv4. 829 + */ 830 + skb_reset_mac_header(skb); 831 + if (eth_hdr(skb)->h_proto != cpu_to_be16(ETH_P_IPV6)) 832 + eth_hdr(skb)->h_proto = cpu_to_be16(ETH_P_IP); 833 + eth_zero_addr(eth_hdr(skb)->h_source); 834 + memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN); 856 835 857 836 /* Last packet in batch handled by usbnet */ 858 837 if (hh.payload_len.word == skb->len)
+24 -22
drivers/net/xen-netfront.c
··· 281 281 { 282 282 RING_IDX req_prod = queue->rx.req_prod_pvt; 283 283 int notify; 284 + int err = 0; 284 285 285 286 if (unlikely(!netif_carrier_ok(queue->info->netdev))) 286 287 return; ··· 296 295 struct xen_netif_rx_request *req; 297 296 298 297 skb = xennet_alloc_one_rx_buffer(queue); 299 - if (!skb) 298 + if (!skb) { 299 + err = -ENOMEM; 300 300 break; 301 + } 301 302 302 303 id = xennet_rxidx(req_prod); 303 304 ··· 323 320 324 321 queue->rx.req_prod_pvt = req_prod; 325 322 326 - /* Not enough requests? Try again later. */ 327 - if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) { 323 + /* Try again later if there are not enough requests or skb allocation 324 + * failed. 325 + * Enough requests is quantified as the sum of newly created slots and 326 + * the unconsumed slots at the backend. 327 + */ 328 + if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN || 329 + unlikely(err)) { 328 330 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10)); 329 331 return; 330 332 } ··· 1387 1379 for (i = 0; i < num_queues && info->queues; ++i) { 1388 1380 struct netfront_queue *queue = &info->queues[i]; 1389 1381 1382 + del_timer_sync(&queue->rx_refill_timer); 1383 + 1390 1384 if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) 1391 1385 unbind_from_irqhandler(queue->tx_irq, queue); 1392 1386 if (queue->tx_irq && (queue->tx_irq != queue->rx_irq)) { ··· 1743 1733 1744 1734 if (netif_running(info->netdev)) 1745 1735 napi_disable(&queue->napi); 1746 - del_timer_sync(&queue->rx_refill_timer); 1747 1736 netif_napi_del(&queue->napi); 1748 1737 } 1749 1738 ··· 1831 1822 xennet_destroy_queues(info); 1832 1823 1833 1824 err = xennet_create_queues(info, &num_queues); 1834 - if (err < 0) 1835 - goto destroy_ring; 1825 + if (err < 0) { 1826 + xenbus_dev_fatal(dev, err, "creating queues"); 1827 + kfree(info->queues); 1828 + info->queues = NULL; 1829 + goto out; 1830 + } 1836 1831 1837 1832 /* Create shared ring, alloc event channel -- for each queue */ 1838 1833 for (i = 0; i < num_queues; ++i) { 1839 1834 queue = &info->queues[i]; 1840 1835 err = setup_netfront(dev, queue, feature_split_evtchn); 1841 - if (err) { 1842 - /* setup_netfront() will tidy up the current 1843 - * queue on error, but we need to clean up 1844 - * those already allocated. 1845 - */ 1846 - if (i > 0) { 1847 - rtnl_lock(); 1848 - netif_set_real_num_tx_queues(info->netdev, i); 1849 - rtnl_unlock(); 1850 - goto destroy_ring; 1851 - } else { 1852 - goto out; 1853 - } 1854 - } 1836 + if (err) 1837 + goto destroy_ring; 1855 1838 } 1856 1839 1857 1840 again: ··· 1933 1932 xenbus_transaction_end(xbt, 1); 1934 1933 destroy_ring: 1935 1934 xennet_disconnect_backend(info); 1936 - kfree(info->queues); 1937 - info->queues = NULL; 1935 + xennet_destroy_queues(info); 1938 1936 out: 1937 + unregister_netdev(info->netdev); 1938 + xennet_free_netdev(info->netdev); 1939 1939 return err; 1940 1940 } 1941 1941
+4
include/linux/netdevice.h
··· 1511 1511 * @max_mtu: Interface Maximum MTU value 1512 1512 * @type: Interface hardware type 1513 1513 * @hard_header_len: Maximum hardware header length. 1514 + * @min_header_len: Minimum hardware header length 1514 1515 * 1515 1516 * @needed_headroom: Extra headroom the hardware may need, but not in all 1516 1517 * cases can this be guaranteed ··· 1729 1728 unsigned int max_mtu; 1730 1729 unsigned short type; 1731 1730 unsigned short hard_header_len; 1731 + unsigned short min_header_len; 1732 1732 1733 1733 unsigned short needed_headroom; 1734 1734 unsigned short needed_tailroom; ··· 2696 2694 { 2697 2695 if (likely(len >= dev->hard_header_len)) 2698 2696 return true; 2697 + if (len < dev->min_header_len) 2698 + return false; 2699 2699 2700 2700 if (capable(CAP_SYS_RAWIO)) { 2701 2701 memset(ll_header + len, 0, dev->hard_header_len - len);
+4 -1
include/net/lwtunnel.h
··· 178 178 } 179 179 static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len) 180 180 { 181 - return -EOPNOTSUPP; 181 + /* return 0 since we are not walking attr looking for 182 + * RTA_ENCAP_TYPE attribute on nexthops. 183 + */ 184 + return 0; 182 185 } 183 186 184 187 static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
+1
net/dsa/dsa2.c
··· 273 273 if (err) { 274 274 dev_warn(ds->dev, "Failed to create slave %d: %d\n", 275 275 index, err); 276 + ds->ports[index].netdev = NULL; 276 277 return err; 277 278 } 278 279
+1
net/ethernet/eth.c
··· 356 356 dev->header_ops = &eth_header_ops; 357 357 dev->type = ARPHRD_ETHER; 358 358 dev->hard_header_len = ETH_HLEN; 359 + dev->min_header_len = ETH_HLEN; 359 360 dev->mtu = ETH_DATA_LEN; 360 361 dev->min_mtu = ETH_MIN_MTU; 361 362 dev->max_mtu = ETH_DATA_LEN;
+1
net/ipv4/igmp.c
··· 1172 1172 psf->sf_crcount = im->crcount; 1173 1173 } 1174 1174 in_dev_put(pmc->interface); 1175 + kfree(pmc); 1175 1176 } 1176 1177 spin_unlock_bh(&im->lock); 1177 1178 }
+2
net/ipv4/ping.c
··· 642 642 { 643 643 struct sk_buff *skb = skb_peek(&sk->sk_write_queue); 644 644 645 + if (!skb) 646 + return 0; 645 647 pfh->wcheck = csum_partial((char *)&pfh->icmph, 646 648 sizeof(struct icmphdr), pfh->wcheck); 647 649 pfh->icmph.checksum = csum_fold(pfh->wcheck);
+6
net/ipv6/addrconf.c
··· 4015 4015 4016 4016 if (bump_id) 4017 4017 rt_genid_bump_ipv6(dev_net(dev)); 4018 + 4019 + /* Make sure that a new temporary address will be created 4020 + * before this temporary address becomes deprecated. 4021 + */ 4022 + if (ifp->flags & IFA_F_TEMPORARY) 4023 + addrconf_verify_rtnl(); 4018 4024 } 4019 4025 4020 4026 static void addrconf_dad_run(struct inet6_dev *idev)
+1
net/ipv6/mcast.c
··· 779 779 psf->sf_crcount = im->mca_crcount; 780 780 } 781 781 in6_dev_put(pmc->idev); 782 + kfree(pmc); 782 783 } 783 784 spin_unlock_bh(&im->mca_lock); 784 785 }
+1
net/ipv6/sit.c
··· 1380 1380 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); 1381 1381 if (err) { 1382 1382 free_percpu(dev->tstats); 1383 + dev->tstats = NULL; 1383 1384 return err; 1384 1385 } 1385 1386
+23 -19
net/kcm/kcmsock.c
··· 929 929 goto out_error; 930 930 } 931 931 932 - /* New message, alloc head skb */ 933 - head = alloc_skb(0, sk->sk_allocation); 934 - while (!head) { 935 - kcm_push(kcm); 936 - err = sk_stream_wait_memory(sk, &timeo); 937 - if (err) 938 - goto out_error; 939 - 932 + if (msg_data_left(msg)) { 933 + /* New message, alloc head skb */ 940 934 head = alloc_skb(0, sk->sk_allocation); 935 + while (!head) { 936 + kcm_push(kcm); 937 + err = sk_stream_wait_memory(sk, &timeo); 938 + if (err) 939 + goto out_error; 940 + 941 + head = alloc_skb(0, sk->sk_allocation); 942 + } 943 + 944 + skb = head; 945 + 946 + /* Set ip_summed to CHECKSUM_UNNECESSARY to avoid calling 947 + * csum_and_copy_from_iter from skb_do_copy_data_nocache. 948 + */ 949 + skb->ip_summed = CHECKSUM_UNNECESSARY; 941 950 } 942 - 943 - skb = head; 944 - 945 - /* Set ip_summed to CHECKSUM_UNNECESSARY to avoid calling 946 - * csum_and_copy_from_iter from skb_do_copy_data_nocache. 947 - */ 948 - skb->ip_summed = CHECKSUM_UNNECESSARY; 949 951 950 952 start: 951 953 while (msg_data_left(msg)) { ··· 1020 1018 if (eor) { 1021 1019 bool not_busy = skb_queue_empty(&sk->sk_write_queue); 1022 1020 1023 - /* Message complete, queue it on send buffer */ 1024 - __skb_queue_tail(&sk->sk_write_queue, head); 1025 - kcm->seq_skb = NULL; 1026 - KCM_STATS_INCR(kcm->stats.tx_msgs); 1021 + if (head) { 1022 + /* Message complete, queue it on send buffer */ 1023 + __skb_queue_tail(&sk->sk_write_queue, head); 1024 + kcm->seq_skb = NULL; 1025 + KCM_STATS_INCR(kcm->stats.tx_msgs); 1026 + } 1027 1027 1028 1028 if (msg->msg_flags & MSG_BATCH) { 1029 1029 kcm->tx_wait_more = true;
+1
net/l2tp/l2tp_core.h
··· 263 263 int l2tp_nl_register_ops(enum l2tp_pwtype pw_type, 264 264 const struct l2tp_nl_cmd_ops *ops); 265 265 void l2tp_nl_unregister_ops(enum l2tp_pwtype pw_type); 266 + int l2tp_ioctl(struct sock *sk, int cmd, unsigned long arg); 266 267 267 268 /* Session reference counts. Incremented when code obtains a reference 268 269 * to a session.
+26 -1
net/l2tp/l2tp_ip.c
··· 11 11 12 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13 13 14 + #include <asm/ioctls.h> 14 15 #include <linux/icmp.h> 15 16 #include <linux/module.h> 16 17 #include <linux/skbuff.h> ··· 554 553 return err ? err : copied; 555 554 } 556 555 556 + int l2tp_ioctl(struct sock *sk, int cmd, unsigned long arg) 557 + { 558 + struct sk_buff *skb; 559 + int amount; 560 + 561 + switch (cmd) { 562 + case SIOCOUTQ: 563 + amount = sk_wmem_alloc_get(sk); 564 + break; 565 + case SIOCINQ: 566 + spin_lock_bh(&sk->sk_receive_queue.lock); 567 + skb = skb_peek(&sk->sk_receive_queue); 568 + amount = skb ? skb->len : 0; 569 + spin_unlock_bh(&sk->sk_receive_queue.lock); 570 + break; 571 + 572 + default: 573 + return -ENOIOCTLCMD; 574 + } 575 + 576 + return put_user(amount, (int __user *)arg); 577 + } 578 + EXPORT_SYMBOL(l2tp_ioctl); 579 + 557 580 static struct proto l2tp_ip_prot = { 558 581 .name = "L2TP/IP", 559 582 .owner = THIS_MODULE, ··· 586 561 .bind = l2tp_ip_bind, 587 562 .connect = l2tp_ip_connect, 588 563 .disconnect = l2tp_ip_disconnect, 589 - .ioctl = udp_ioctl, 564 + .ioctl = l2tp_ioctl, 590 565 .destroy = l2tp_ip_destroy_sock, 591 566 .setsockopt = ip_setsockopt, 592 567 .getsockopt = ip_getsockopt,
+1 -1
net/l2tp/l2tp_ip6.c
··· 722 722 .bind = l2tp_ip6_bind, 723 723 .connect = l2tp_ip6_connect, 724 724 .disconnect = l2tp_ip6_disconnect, 725 - .ioctl = udp_ioctl, 725 + .ioctl = l2tp_ioctl, 726 726 .destroy = l2tp_ip6_destroy_sock, 727 727 .setsockopt = ipv6_setsockopt, 728 728 .getsockopt = ipv6_getsockopt,
+4 -3
net/packet/af_packet.c
··· 2755 2755 struct virtio_net_hdr vnet_hdr = { 0 }; 2756 2756 int offset = 0; 2757 2757 struct packet_sock *po = pkt_sk(sk); 2758 - int hlen, tlen; 2758 + int hlen, tlen, linear; 2759 2759 int extra_len = 0; 2760 2760 2761 2761 /* ··· 2816 2816 err = -ENOBUFS; 2817 2817 hlen = LL_RESERVED_SPACE(dev); 2818 2818 tlen = dev->needed_tailroom; 2819 - skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, 2820 - __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len), 2819 + linear = __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len); 2820 + linear = max(linear, min_t(int, len, dev->hard_header_len)); 2821 + skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, linear, 2821 2822 msg->msg_flags & MSG_DONTWAIT, &err); 2822 2823 if (skb == NULL) 2823 2824 goto out_unlock;