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

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

Merge 'net' into 'net-next' to get the AF_PACKET bug fix that
Daniel's direct transmit changes depend upon.

Signed-off-by: David S. Miller <davem@davemloft.net>

+310 -204
+1 -1
Documentation/devicetree/bindings/net/davinci_emac.txt
··· 4 4 for the davinci_emac interface contains. 5 5 6 6 Required properties: 7 - - compatible: "ti,davinci-dm6467-emac"; 7 + - compatible: "ti,davinci-dm6467-emac" or "ti,am3517-emac" 8 8 - reg: Offset and length of the register set for the device 9 9 - ti,davinci-ctrl-reg-offset: offset to control register 10 10 - ti,davinci-ctrl-mod-reg-offset: offset to control module register
+10
Documentation/networking/packet_mmap.txt
··· 123 123 [shutdown] close() --------> destruction of the transmission socket and 124 124 deallocation of all associated resources. 125 125 126 + Socket creation and destruction is also straight forward, and is done 127 + the same way as in capturing described in the previous paragraph: 128 + 129 + int fd = socket(PF_PACKET, mode, 0); 130 + 131 + The protocol can optionally be 0 in case we only want to transmit 132 + via this socket, which avoids an expensive call to packet_rcv(). 133 + In this case, you also need to bind(2) the TX_RING with sll_protocol = 0 134 + set. Otherwise, htons(ETH_P_ALL) or any other protocol, for example. 135 + 126 136 Binding the socket to your network interface is mandatory (with zero copy) to 127 137 know the header size of frames used in the circular buffer. 128 138
-2
MAINTAINERS
··· 4450 4450 M: Carolyn Wyborny <carolyn.wyborny@intel.com> 4451 4451 M: Don Skidmore <donald.c.skidmore@intel.com> 4452 4452 M: Greg Rose <gregory.v.rose@intel.com> 4453 - M: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> 4454 4453 M: Alex Duyck <alexander.h.duyck@intel.com> 4455 4454 M: John Ronciak <john.ronciak@intel.com> 4456 - M: Tushar Dave <tushar.n.dave@intel.com> 4457 4455 L: e1000-devel@lists.sourceforge.net 4458 4456 W: http://www.intel.com/support/feedback.htm 4459 4457 W: http://e1000.sourceforge.net/
+3 -3
drivers/net/bonding/bond_main.c
··· 4199 4199 (arp_ip_count < BOND_MAX_ARP_TARGETS) && arp_ip_target[i]; i++) { 4200 4200 /* not complete check, but should be good enough to 4201 4201 catch mistakes */ 4202 - __be32 ip = in_aton(arp_ip_target[i]); 4203 - if (!isdigit(arp_ip_target[i][0]) || ip == 0 || 4204 - ip == htonl(INADDR_BROADCAST)) { 4202 + __be32 ip; 4203 + if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || 4204 + IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) { 4205 4205 pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", 4206 4206 arp_ip_target[i]); 4207 4207 arp_interval = 0;
+2 -2
drivers/net/bonding/bond_sysfs.c
··· 1634 1634 char *buf) 1635 1635 { 1636 1636 struct bonding *bond = to_bond(d); 1637 - int packets_per_slave = bond->params.packets_per_slave; 1637 + unsigned int packets_per_slave = bond->params.packets_per_slave; 1638 1638 1639 1639 if (packets_per_slave > 1) 1640 1640 packets_per_slave = reciprocal_value(packets_per_slave); 1641 1641 1642 - return sprintf(buf, "%d\n", packets_per_slave); 1642 + return sprintf(buf, "%u\n", packets_per_slave); 1643 1643 } 1644 1644 1645 1645 static ssize_t bonding_store_packets_per_slave(struct device *d,
+5
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
··· 3114 3114 { 3115 3115 struct bnx2x *bp = netdev_priv(pci_get_drvdata(dev)); 3116 3116 3117 + if (!IS_SRIOV(bp)) { 3118 + BNX2X_ERR("failed to configure SR-IOV since vfdb was not allocated. Check dmesg for errors in probe stage\n"); 3119 + return -EINVAL; 3120 + } 3121 + 3117 3122 DP(BNX2X_MSG_IOV, "bnx2x_sriov_configure called with %d, BNX2X_NR_VIRTFN(bp) was %d\n", 3118 3123 num_vfs_param, BNX2X_NR_VIRTFN(bp)); 3119 3124
+3
drivers/net/ethernet/emulex/benet/be_hw.h
··· 64 64 #define SLIPORT_ERROR_NO_RESOURCE1 0x2 65 65 #define SLIPORT_ERROR_NO_RESOURCE2 0x9 66 66 67 + #define SLIPORT_ERROR_FW_RESET1 0x2 68 + #define SLIPORT_ERROR_FW_RESET2 0x0 69 + 67 70 /********* Memory BAR register ************/ 68 71 #define PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET 0xfc 69 72 /* Host Interrupt Enable, if set interrupts are enabled although "PCI Interrupt
+29 -12
drivers/net/ethernet/emulex/benet/be_main.c
··· 2464 2464 */ 2465 2465 if (sliport_status & SLIPORT_STATUS_ERR_MASK) { 2466 2466 adapter->hw_error = true; 2467 - dev_err(&adapter->pdev->dev, 2468 - "Error detected in the card\n"); 2467 + /* Do not log error messages if its a FW reset */ 2468 + if (sliport_err1 == SLIPORT_ERROR_FW_RESET1 && 2469 + sliport_err2 == SLIPORT_ERROR_FW_RESET2) { 2470 + dev_info(&adapter->pdev->dev, 2471 + "Firmware update in progress\n"); 2472 + return; 2473 + } else { 2474 + dev_err(&adapter->pdev->dev, 2475 + "Error detected in the card\n"); 2476 + } 2469 2477 } 2470 2478 2471 2479 if (sliport_status & SLIPORT_STATUS_ERR_MASK) { ··· 2940 2932 } 2941 2933 } 2942 2934 2943 - static int be_clear(struct be_adapter *adapter) 2935 + static void be_mac_clear(struct be_adapter *adapter) 2944 2936 { 2945 2937 int i; 2946 2938 2939 + if (adapter->pmac_id) { 2940 + for (i = 0; i < (adapter->uc_macs + 1); i++) 2941 + be_cmd_pmac_del(adapter, adapter->if_handle, 2942 + adapter->pmac_id[i], 0); 2943 + adapter->uc_macs = 0; 2944 + 2945 + kfree(adapter->pmac_id); 2946 + adapter->pmac_id = NULL; 2947 + } 2948 + } 2949 + 2950 + static int be_clear(struct be_adapter *adapter) 2951 + { 2947 2952 be_cancel_worker(adapter); 2948 2953 2949 2954 if (sriov_enabled(adapter)) 2950 2955 be_vf_clear(adapter); 2951 2956 2952 2957 /* delete the primary mac along with the uc-mac list */ 2953 - for (i = 0; i < (adapter->uc_macs + 1); i++) 2954 - be_cmd_pmac_del(adapter, adapter->if_handle, 2955 - adapter->pmac_id[i], 0); 2956 - adapter->uc_macs = 0; 2958 + be_mac_clear(adapter); 2957 2959 2958 2960 be_cmd_if_destroy(adapter, adapter->if_handle, 0); 2959 2961 2960 2962 be_clear_queues(adapter); 2961 - 2962 - kfree(adapter->pmac_id); 2963 - adapter->pmac_id = NULL; 2964 2963 2965 2964 be_msix_disable(adapter); 2966 2965 return 0; ··· 3827 3812 } 3828 3813 3829 3814 if (change_status == LANCER_FW_RESET_NEEDED) { 3815 + dev_info(&adapter->pdev->dev, 3816 + "Resetting adapter to activate new FW\n"); 3830 3817 status = lancer_physdev_ctrl(adapter, 3831 3818 PHYSDEV_CONTROL_FW_RESET_MASK); 3832 3819 if (status) { ··· 4380 4363 goto err; 4381 4364 } 4382 4365 4383 - dev_err(dev, "Error recovery successful\n"); 4366 + dev_err(dev, "Adapter recovery successful\n"); 4384 4367 return 0; 4385 4368 err: 4386 4369 if (status == -EAGAIN) 4387 4370 dev_err(dev, "Waiting for resource provisioning\n"); 4388 4371 else 4389 - dev_err(dev, "Error recovery failed\n"); 4372 + dev_err(dev, "Adapter recovery failed\n"); 4390 4373 4391 4374 return status; 4392 4375 }
+2 -2
drivers/net/ethernet/marvell/mvneta.c
··· 1378 1378 1379 1379 dev_kfree_skb_any(skb); 1380 1380 dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr, 1381 - rx_desc->data_size, DMA_FROM_DEVICE); 1381 + MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE); 1382 1382 } 1383 1383 1384 1384 if (rx_done) ··· 1424 1424 } 1425 1425 1426 1426 dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr, 1427 - rx_desc->data_size, DMA_FROM_DEVICE); 1427 + MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE); 1428 1428 1429 1429 rx_bytes = rx_desc->data_size - 1430 1430 (ETH_FCS_LEN + MVNETA_MH_SIZE);
+5 -3
drivers/net/ethernet/nvidia/forcedeth.c
··· 5149 5149 { 5150 5150 struct fe_priv *np = netdev_priv(dev); 5151 5151 u8 __iomem *base = get_hwbase(dev); 5152 - int result; 5153 - memset(buffer, 0, nv_get_sset_count(dev, ETH_SS_TEST)*sizeof(u64)); 5152 + int result, count; 5153 + 5154 + count = nv_get_sset_count(dev, ETH_SS_TEST); 5155 + memset(buffer, 0, count * sizeof(u64)); 5154 5156 5155 5157 if (!nv_link_test(dev)) { 5156 5158 test->flags |= ETH_TEST_FL_FAILED; ··· 5196 5194 return; 5197 5195 } 5198 5196 5199 - if (!nv_loopback_test(dev)) { 5197 + if (count > NV_TEST_COUNT_BASE && !nv_loopback_test(dev)) { 5200 5198 test->flags |= ETH_TEST_FL_FAILED; 5201 5199 buffer[3] = 1; 5202 5200 }
+1 -1
drivers/net/ethernet/qlogic/qlge/qlge.h
··· 18 18 */ 19 19 #define DRV_NAME "qlge" 20 20 #define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver " 21 - #define DRV_VERSION "1.00.00.33" 21 + #define DRV_VERSION "1.00.00.34" 22 22 23 23 #define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */ 24 24
+4
drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c
··· 181 181 }; 182 182 #define QLGE_TEST_LEN (sizeof(ql_gstrings_test) / ETH_GSTRING_LEN) 183 183 #define QLGE_STATS_LEN ARRAY_SIZE(ql_gstrings_stats) 184 + #define QLGE_RCV_MAC_ERR_STATS 7 184 185 185 186 static int ql_update_ring_coalescing(struct ql_adapter *qdev) 186 187 { ··· 280 279 *iter = data; 281 280 iter++; 282 281 } 282 + 283 + /* Update receive mac error statistics */ 284 + iter += QLGE_RCV_MAC_ERR_STATS; 283 285 284 286 /* 285 287 * Get Per-priority TX pause frame counter statistics.
-8
drivers/net/ethernet/qlogic/qlge/qlge_main.c
··· 2376 2376 netdev_features_t features) 2377 2377 { 2378 2378 int err; 2379 - /* 2380 - * Since there is no support for separate rx/tx vlan accel 2381 - * enable/disable make sure tx flag is always in same state as rx. 2382 - */ 2383 - if (features & NETIF_F_HW_VLAN_CTAG_RX) 2384 - features |= NETIF_F_HW_VLAN_CTAG_TX; 2385 - else 2386 - features &= ~NETIF_F_HW_VLAN_CTAG_TX; 2387 2379 2388 2380 /* Update the behavior of vlan accel in the adapter */ 2389 2381 err = qlge_update_hw_vlan_features(ndev, features);
+25 -1
drivers/net/ethernet/ti/davinci_emac.c
··· 61 61 #include <linux/davinci_emac.h> 62 62 #include <linux/of.h> 63 63 #include <linux/of_address.h> 64 + #include <linux/of_device.h> 64 65 #include <linux/of_irq.h> 65 66 #include <linux/of_net.h> 66 67 ··· 1753 1752 #endif 1754 1753 }; 1755 1754 1755 + static const struct of_device_id davinci_emac_of_match[]; 1756 + 1756 1757 static struct emac_platform_data * 1757 1758 davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) 1758 1759 { 1759 1760 struct device_node *np; 1761 + const struct of_device_id *match; 1762 + const struct emac_platform_data *auxdata; 1760 1763 struct emac_platform_data *pdata = NULL; 1761 1764 const u8 *mac_addr; 1762 1765 ··· 1798 1793 1799 1794 priv->phy_node = of_parse_phandle(np, "phy-handle", 0); 1800 1795 if (!priv->phy_node) 1801 - pdata->phy_id = ""; 1796 + pdata->phy_id = NULL; 1797 + 1798 + auxdata = pdev->dev.platform_data; 1799 + if (auxdata) { 1800 + pdata->interrupt_enable = auxdata->interrupt_enable; 1801 + pdata->interrupt_disable = auxdata->interrupt_disable; 1802 + } 1803 + 1804 + match = of_match_device(davinci_emac_of_match, &pdev->dev); 1805 + if (match && match->data) { 1806 + auxdata = match->data; 1807 + pdata->version = auxdata->version; 1808 + pdata->hw_ram_addr = auxdata->hw_ram_addr; 1809 + } 1802 1810 1803 1811 pdev->dev.platform_data = pdata; 1804 1812 ··· 2038 2020 }; 2039 2021 2040 2022 #if IS_ENABLED(CONFIG_OF) 2023 + static const struct emac_platform_data am3517_emac_data = { 2024 + .version = EMAC_VERSION_2, 2025 + .hw_ram_addr = 0x01e20000, 2026 + }; 2027 + 2041 2028 static const struct of_device_id davinci_emac_of_match[] = { 2042 2029 {.compatible = "ti,davinci-dm6467-emac", }, 2030 + {.compatible = "ti,am3517-emac", .data = &am3517_emac_data, }, 2043 2031 {}, 2044 2032 }; 2045 2033 MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
+2
drivers/net/macvtap.c
··· 872 872 873 873 ret = macvtap_do_read(q, iv, len, file->f_flags & O_NONBLOCK); 874 874 ret = min_t(ssize_t, ret, len); /* XXX copied from tun.c. Why? */ 875 + if (ret > 0) 876 + iocb->ki_pos = ret; 875 877 out: 876 878 return ret; 877 879 }
+2
drivers/net/tun.c
··· 1355 1355 ret = tun_do_read(tun, tfile, iv, len, 1356 1356 file->f_flags & O_NONBLOCK); 1357 1357 ret = min_t(ssize_t, ret, len); 1358 + if (ret > 0) 1359 + iocb->ki_pos = ret; 1358 1360 out: 1359 1361 tun_put(tun); 1360 1362 return ret;
+11 -6
drivers/net/virtio_net.c
··· 425 425 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { 426 426 pr_debug("%s: short packet %i\n", dev->name, len); 427 427 dev->stats.rx_length_errors++; 428 - if (vi->big_packets) 429 - give_pages(rq, buf); 430 - else if (vi->mergeable_rx_bufs) 428 + if (vi->mergeable_rx_bufs) 431 429 put_page(virt_to_head_page(buf)); 430 + else if (vi->big_packets) 431 + give_pages(rq, buf); 432 432 else 433 433 dev_kfree_skb(buf); 434 434 return; ··· 1366 1366 1367 1367 static void virtnet_free_queues(struct virtnet_info *vi) 1368 1368 { 1369 + int i; 1370 + 1371 + for (i = 0; i < vi->max_queue_pairs; i++) 1372 + netif_napi_del(&vi->rq[i].napi); 1373 + 1369 1374 kfree(vi->rq); 1370 1375 kfree(vi->sq); 1371 1376 } ··· 1400 1395 struct virtqueue *vq = vi->rq[i].vq; 1401 1396 1402 1397 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { 1403 - if (vi->big_packets) 1404 - give_pages(&vi->rq[i], buf); 1405 - else if (vi->mergeable_rx_bufs) 1398 + if (vi->mergeable_rx_bufs) 1406 1399 put_page(virt_to_head_page(buf)); 1400 + else if (vi->big_packets) 1401 + give_pages(&vi->rq[i], buf); 1407 1402 else 1408 1403 dev_kfree_skb(buf); 1409 1404 --vi->rq[i].num;
+133 -95
drivers/net/xen-netback/netback.c
··· 1149 1149 return 0; 1150 1150 } 1151 1151 1152 - static inline void maybe_pull_tail(struct sk_buff *skb, unsigned int len) 1152 + static inline int maybe_pull_tail(struct sk_buff *skb, unsigned int len, 1153 + unsigned int max) 1153 1154 { 1154 - if (skb_is_nonlinear(skb) && skb_headlen(skb) < len) { 1155 - /* If we need to pullup then pullup to the max, so we 1156 - * won't need to do it again. 1157 - */ 1158 - int target = min_t(int, skb->len, MAX_TCP_HEADER); 1159 - __pskb_pull_tail(skb, target - skb_headlen(skb)); 1160 - } 1155 + if (skb_headlen(skb) >= len) 1156 + return 0; 1157 + 1158 + /* If we need to pullup then pullup to the max, so we 1159 + * won't need to do it again. 1160 + */ 1161 + if (max > skb->len) 1162 + max = skb->len; 1163 + 1164 + if (__pskb_pull_tail(skb, max - skb_headlen(skb)) == NULL) 1165 + return -ENOMEM; 1166 + 1167 + if (skb_headlen(skb) < len) 1168 + return -EPROTO; 1169 + 1170 + return 0; 1161 1171 } 1172 + 1173 + /* This value should be large enough to cover a tagged ethernet header plus 1174 + * maximally sized IP and TCP or UDP headers. 1175 + */ 1176 + #define MAX_IP_HDR_LEN 128 1162 1177 1163 1178 static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, 1164 1179 int recalculate_partial_csum) 1165 1180 { 1166 - struct iphdr *iph = (void *)skb->data; 1167 - unsigned int header_size; 1168 1181 unsigned int off; 1169 - int err = -EPROTO; 1182 + bool fragment; 1183 + int err; 1170 1184 1171 - off = sizeof(struct iphdr); 1185 + fragment = false; 1172 1186 1173 - header_size = skb->network_header + off + MAX_IPOPTLEN; 1174 - maybe_pull_tail(skb, header_size); 1187 + err = maybe_pull_tail(skb, 1188 + sizeof(struct iphdr), 1189 + MAX_IP_HDR_LEN); 1190 + if (err < 0) 1191 + goto out; 1175 1192 1176 - off = iph->ihl * 4; 1193 + if (ip_hdr(skb)->frag_off & htons(IP_OFFSET | IP_MF)) 1194 + fragment = true; 1177 1195 1178 - switch (iph->protocol) { 1196 + off = ip_hdrlen(skb); 1197 + 1198 + err = -EPROTO; 1199 + 1200 + switch (ip_hdr(skb)->protocol) { 1179 1201 case IPPROTO_TCP: 1180 1202 if (!skb_partial_csum_set(skb, off, 1181 1203 offsetof(struct tcphdr, check))) 1182 1204 goto out; 1183 1205 1184 1206 if (recalculate_partial_csum) { 1185 - struct tcphdr *tcph = tcp_hdr(skb); 1207 + err = maybe_pull_tail(skb, 1208 + off + sizeof(struct tcphdr), 1209 + MAX_IP_HDR_LEN); 1210 + if (err < 0) 1211 + goto out; 1186 1212 1187 - header_size = skb->network_header + 1188 - off + 1189 - sizeof(struct tcphdr); 1190 - maybe_pull_tail(skb, header_size); 1191 - 1192 - tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 1193 - skb->len - off, 1194 - IPPROTO_TCP, 0); 1213 + tcp_hdr(skb)->check = 1214 + ~csum_tcpudp_magic(ip_hdr(skb)->saddr, 1215 + ip_hdr(skb)->daddr, 1216 + skb->len - off, 1217 + IPPROTO_TCP, 0); 1195 1218 } 1196 1219 break; 1197 1220 case IPPROTO_UDP: ··· 1223 1200 goto out; 1224 1201 1225 1202 if (recalculate_partial_csum) { 1226 - struct udphdr *udph = udp_hdr(skb); 1203 + err = maybe_pull_tail(skb, 1204 + off + sizeof(struct udphdr), 1205 + MAX_IP_HDR_LEN); 1206 + if (err < 0) 1207 + goto out; 1227 1208 1228 - header_size = skb->network_header + 1229 - off + 1230 - sizeof(struct udphdr); 1231 - maybe_pull_tail(skb, header_size); 1232 - 1233 - udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 1234 - skb->len - off, 1235 - IPPROTO_UDP, 0); 1209 + udp_hdr(skb)->check = 1210 + ~csum_tcpudp_magic(ip_hdr(skb)->saddr, 1211 + ip_hdr(skb)->daddr, 1212 + skb->len - off, 1213 + IPPROTO_UDP, 0); 1236 1214 } 1237 1215 break; 1238 1216 default: 1239 - if (net_ratelimit()) 1240 - netdev_err(vif->dev, 1241 - "Attempting to checksum a non-TCP/UDP packet, " 1242 - "dropping a protocol %d packet\n", 1243 - iph->protocol); 1244 1217 goto out; 1245 1218 } 1246 1219 ··· 1246 1227 return err; 1247 1228 } 1248 1229 1230 + /* This value should be large enough to cover a tagged ethernet header plus 1231 + * an IPv6 header, all options, and a maximal TCP or UDP header. 1232 + */ 1233 + #define MAX_IPV6_HDR_LEN 256 1234 + 1235 + #define OPT_HDR(type, skb, off) \ 1236 + (type *)(skb_network_header(skb) + (off)) 1237 + 1249 1238 static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, 1250 1239 int recalculate_partial_csum) 1251 1240 { 1252 - int err = -EPROTO; 1253 - struct ipv6hdr *ipv6h = (void *)skb->data; 1241 + int err; 1254 1242 u8 nexthdr; 1255 - unsigned int header_size; 1256 1243 unsigned int off; 1244 + unsigned int len; 1257 1245 bool fragment; 1258 1246 bool done; 1259 1247 1248 + fragment = false; 1260 1249 done = false; 1261 1250 1262 1251 off = sizeof(struct ipv6hdr); 1263 1252 1264 - header_size = skb->network_header + off; 1265 - maybe_pull_tail(skb, header_size); 1253 + err = maybe_pull_tail(skb, off, MAX_IPV6_HDR_LEN); 1254 + if (err < 0) 1255 + goto out; 1266 1256 1267 - nexthdr = ipv6h->nexthdr; 1257 + nexthdr = ipv6_hdr(skb)->nexthdr; 1268 1258 1269 - while ((off <= sizeof(struct ipv6hdr) + ntohs(ipv6h->payload_len)) && 1270 - !done) { 1259 + len = sizeof(struct ipv6hdr) + ntohs(ipv6_hdr(skb)->payload_len); 1260 + while (off <= len && !done) { 1271 1261 switch (nexthdr) { 1272 1262 case IPPROTO_DSTOPTS: 1273 1263 case IPPROTO_HOPOPTS: 1274 1264 case IPPROTO_ROUTING: { 1275 - struct ipv6_opt_hdr *hp = (void *)(skb->data + off); 1265 + struct ipv6_opt_hdr *hp; 1276 1266 1277 - header_size = skb->network_header + 1278 - off + 1279 - sizeof(struct ipv6_opt_hdr); 1280 - maybe_pull_tail(skb, header_size); 1267 + err = maybe_pull_tail(skb, 1268 + off + 1269 + sizeof(struct ipv6_opt_hdr), 1270 + MAX_IPV6_HDR_LEN); 1271 + if (err < 0) 1272 + goto out; 1281 1273 1274 + hp = OPT_HDR(struct ipv6_opt_hdr, skb, off); 1282 1275 nexthdr = hp->nexthdr; 1283 1276 off += ipv6_optlen(hp); 1284 1277 break; 1285 1278 } 1286 1279 case IPPROTO_AH: { 1287 - struct ip_auth_hdr *hp = (void *)(skb->data + off); 1280 + struct ip_auth_hdr *hp; 1288 1281 1289 - header_size = skb->network_header + 1290 - off + 1291 - sizeof(struct ip_auth_hdr); 1292 - maybe_pull_tail(skb, header_size); 1282 + err = maybe_pull_tail(skb, 1283 + off + 1284 + sizeof(struct ip_auth_hdr), 1285 + MAX_IPV6_HDR_LEN); 1286 + if (err < 0) 1287 + goto out; 1293 1288 1289 + hp = OPT_HDR(struct ip_auth_hdr, skb, off); 1294 1290 nexthdr = hp->nexthdr; 1295 - off += (hp->hdrlen+2)<<2; 1291 + off += ipv6_authlen(hp); 1296 1292 break; 1297 1293 } 1298 - case IPPROTO_FRAGMENT: 1299 - fragment = true; 1300 - /* fall through */ 1294 + case IPPROTO_FRAGMENT: { 1295 + struct frag_hdr *hp; 1296 + 1297 + err = maybe_pull_tail(skb, 1298 + off + 1299 + sizeof(struct frag_hdr), 1300 + MAX_IPV6_HDR_LEN); 1301 + if (err < 0) 1302 + goto out; 1303 + 1304 + hp = OPT_HDR(struct frag_hdr, skb, off); 1305 + 1306 + if (hp->frag_off & htons(IP6_OFFSET | IP6_MF)) 1307 + fragment = true; 1308 + 1309 + nexthdr = hp->nexthdr; 1310 + off += sizeof(struct frag_hdr); 1311 + break; 1312 + } 1301 1313 default: 1302 1314 done = true; 1303 1315 break; 1304 1316 } 1305 1317 } 1306 1318 1307 - if (!done) { 1308 - if (net_ratelimit()) 1309 - netdev_err(vif->dev, "Failed to parse packet header\n"); 1310 - goto out; 1311 - } 1319 + err = -EPROTO; 1312 1320 1313 - if (fragment) { 1314 - if (net_ratelimit()) 1315 - netdev_err(vif->dev, "Packet is a fragment!\n"); 1321 + if (!done || fragment) 1316 1322 goto out; 1317 - } 1318 1323 1319 1324 switch (nexthdr) { 1320 1325 case IPPROTO_TCP: ··· 1347 1304 goto out; 1348 1305 1349 1306 if (recalculate_partial_csum) { 1350 - struct tcphdr *tcph = tcp_hdr(skb); 1307 + err = maybe_pull_tail(skb, 1308 + off + sizeof(struct tcphdr), 1309 + MAX_IPV6_HDR_LEN); 1310 + if (err < 0) 1311 + goto out; 1351 1312 1352 - header_size = skb->network_header + 1353 - off + 1354 - sizeof(struct tcphdr); 1355 - maybe_pull_tail(skb, header_size); 1356 - 1357 - tcph->check = ~csum_ipv6_magic(&ipv6h->saddr, 1358 - &ipv6h->daddr, 1359 - skb->len - off, 1360 - IPPROTO_TCP, 0); 1313 + tcp_hdr(skb)->check = 1314 + ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, 1315 + &ipv6_hdr(skb)->daddr, 1316 + skb->len - off, 1317 + IPPROTO_TCP, 0); 1361 1318 } 1362 1319 break; 1363 1320 case IPPROTO_UDP: ··· 1366 1323 goto out; 1367 1324 1368 1325 if (recalculate_partial_csum) { 1369 - struct udphdr *udph = udp_hdr(skb); 1326 + err = maybe_pull_tail(skb, 1327 + off + sizeof(struct udphdr), 1328 + MAX_IPV6_HDR_LEN); 1329 + if (err < 0) 1330 + goto out; 1370 1331 1371 - header_size = skb->network_header + 1372 - off + 1373 - sizeof(struct udphdr); 1374 - maybe_pull_tail(skb, header_size); 1375 - 1376 - udph->check = ~csum_ipv6_magic(&ipv6h->saddr, 1377 - &ipv6h->daddr, 1378 - skb->len - off, 1379 - IPPROTO_UDP, 0); 1332 + udp_hdr(skb)->check = 1333 + ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, 1334 + &ipv6_hdr(skb)->daddr, 1335 + skb->len - off, 1336 + IPPROTO_UDP, 0); 1380 1337 } 1381 1338 break; 1382 1339 default: 1383 - if (net_ratelimit()) 1384 - netdev_err(vif->dev, 1385 - "Attempting to checksum a non-TCP/UDP packet, " 1386 - "dropping a protocol %d packet\n", 1387 - nexthdr); 1388 1340 goto out; 1389 1341 } 1390 1342
+1
include/linux/ipv6.h
··· 4 4 #include <uapi/linux/ipv6.h> 5 5 6 6 #define ipv6_optlen(p) (((p)->hdrlen+1) << 3) 7 + #define ipv6_authlen(p) (((p)->hdrlen+2) << 2) 7 8 /* 8 9 * This structure contains configuration options per IPv6 link. 9 10 */
+2 -1
include/net/ipv6.h
··· 110 110 __be32 identification; 111 111 }; 112 112 113 - #define IP6_MF 0x0001 113 + #define IP6_MF 0x0001 114 + #define IP6_OFFSET 0xFFF8 114 115 115 116 #include <net/sock.h> 116 117
+2 -4
include/net/sock.h
··· 1035 1035 }; 1036 1036 1037 1037 struct cg_proto { 1038 - void (*enter_memory_pressure)(struct sock *sk); 1039 1038 struct res_counter memory_allocated; /* Current allocated memory. */ 1040 1039 struct percpu_counter sockets_allocated; /* Current number of sockets. */ 1041 1040 int memory_pressure; ··· 1154 1155 struct proto *prot = sk->sk_prot; 1155 1156 1156 1157 for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) 1157 - if (cg_proto->memory_pressure) 1158 - cg_proto->memory_pressure = 0; 1158 + cg_proto->memory_pressure = 0; 1159 1159 } 1160 1160 1161 1161 } ··· 1169 1171 struct proto *prot = sk->sk_prot; 1170 1172 1171 1173 for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) 1172 - cg_proto->enter_memory_pressure(sk); 1174 + cg_proto->memory_pressure = 1; 1173 1175 } 1174 1176 1175 1177 sk->sk_prot->enter_memory_pressure(sk);
+10
net/bridge/br_private.h
··· 426 426 int br_handle_frame_finish(struct sk_buff *skb); 427 427 rx_handler_result_t br_handle_frame(struct sk_buff **pskb); 428 428 429 + static inline bool br_rx_handler_check_rcu(const struct net_device *dev) 430 + { 431 + return rcu_dereference(dev->rx_handler) == br_handle_frame; 432 + } 433 + 434 + static inline struct net_bridge_port *br_port_get_check_rcu(const struct net_device *dev) 435 + { 436 + return br_rx_handler_check_rcu(dev) ? br_port_get_rcu(dev) : NULL; 437 + } 438 + 429 439 /* br_ioctl.c */ 430 440 int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 431 441 int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd,
+1 -1
net/bridge/br_stp_bpdu.c
··· 153 153 if (buf[0] != 0 || buf[1] != 0 || buf[2] != 0) 154 154 goto err; 155 155 156 - p = br_port_get_rcu(dev); 156 + p = br_port_get_check_rcu(dev); 157 157 if (!p) 158 158 goto err; 159 159
+1
net/core/skbuff.c
··· 3584 3584 skb->tstamp.tv64 = 0; 3585 3585 skb->pkt_type = PACKET_HOST; 3586 3586 skb->skb_iif = 0; 3587 + skb->local_df = 0; 3587 3588 skb_dst_drop(skb); 3588 3589 skb->mark = 0; 3589 3590 secpath_reset(skb);
-7
net/ipv4/tcp_memcontrol.c
··· 6 6 #include <linux/memcontrol.h> 7 7 #include <linux/module.h> 8 8 9 - static void memcg_tcp_enter_memory_pressure(struct sock *sk) 10 - { 11 - if (sk->sk_cgrp->memory_pressure) 12 - sk->sk_cgrp->memory_pressure = 1; 13 - } 14 - EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure); 15 - 16 9 int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss) 17 10 { 18 11 /*
+40 -25
net/packet/af_packet.c
··· 237 237 static void __fanout_unlink(struct sock *sk, struct packet_sock *po); 238 238 static void __fanout_link(struct sock *sk, struct packet_sock *po); 239 239 240 + static struct net_device *packet_cached_dev_get(struct packet_sock *po) 241 + { 242 + struct net_device *dev; 243 + 244 + rcu_read_lock(); 245 + dev = rcu_dereference(po->cached_dev); 246 + if (likely(dev)) 247 + dev_hold(dev); 248 + rcu_read_unlock(); 249 + 250 + return dev; 251 + } 252 + 253 + static void packet_cached_dev_assign(struct packet_sock *po, 254 + struct net_device *dev) 255 + { 256 + rcu_assign_pointer(po->cached_dev, dev); 257 + } 258 + 259 + static void packet_cached_dev_reset(struct packet_sock *po) 260 + { 261 + RCU_INIT_POINTER(po->cached_dev, NULL); 262 + } 263 + 240 264 /* register_prot_hook must be invoked with the po->bind_lock held, 241 265 * or from a context in which asynchronous accesses to the packet 242 266 * socket is not possible (packet_create()). ··· 270 246 struct packet_sock *po = pkt_sk(sk); 271 247 272 248 if (!po->running) { 273 - if (po->fanout) { 249 + if (po->fanout) 274 250 __fanout_link(sk, po); 275 - } else { 251 + else 276 252 dev_add_pack(&po->prot_hook); 277 - rcu_assign_pointer(po->cached_dev, po->prot_hook.dev); 278 - } 279 253 280 254 sock_hold(sk); 281 255 po->running = 1; ··· 292 270 struct packet_sock *po = pkt_sk(sk); 293 271 294 272 po->running = 0; 295 - if (po->fanout) { 273 + 274 + if (po->fanout) 296 275 __fanout_unlink(sk, po); 297 - } else { 276 + else 298 277 __dev_remove_pack(&po->prot_hook); 299 - RCU_INIT_POINTER(po->cached_dev, NULL); 300 - } 301 278 302 279 __sock_put(sk); 303 280 ··· 2082 2061 return tp_len; 2083 2062 } 2084 2063 2085 - static struct net_device *packet_cached_dev_get(struct packet_sock *po) 2086 - { 2087 - struct net_device *dev; 2088 - 2089 - rcu_read_lock(); 2090 - dev = rcu_dereference(po->cached_dev); 2091 - if (dev) 2092 - dev_hold(dev); 2093 - rcu_read_unlock(); 2094 - 2095 - return dev; 2096 - } 2097 - 2098 2064 static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) 2099 2065 { 2100 2066 struct sk_buff *skb; ··· 2098 2090 2099 2091 mutex_lock(&po->pg_vec_lock); 2100 2092 2101 - if (saddr == NULL) { 2093 + if (likely(saddr == NULL)) { 2102 2094 dev = packet_cached_dev_get(po); 2103 2095 proto = po->num; 2104 2096 addr = NULL; ··· 2252 2244 * Get and verify the address. 2253 2245 */ 2254 2246 2255 - if (saddr == NULL) { 2247 + if (likely(saddr == NULL)) { 2256 2248 dev = packet_cached_dev_get(po); 2257 2249 proto = po->num; 2258 2250 addr = NULL; ··· 2461 2453 2462 2454 spin_lock(&po->bind_lock); 2463 2455 unregister_prot_hook(sk, false); 2456 + packet_cached_dev_reset(po); 2457 + 2464 2458 if (po->prot_hook.dev) { 2465 2459 dev_put(po->prot_hook.dev); 2466 2460 po->prot_hook.dev = NULL; ··· 2518 2508 2519 2509 spin_lock(&po->bind_lock); 2520 2510 unregister_prot_hook(sk, true); 2511 + 2521 2512 po->num = protocol; 2522 2513 po->prot_hook.type = protocol; 2523 2514 if (po->prot_hook.dev) 2524 2515 dev_put(po->prot_hook.dev); 2525 - po->prot_hook.dev = dev; 2526 2516 2517 + po->prot_hook.dev = dev; 2527 2518 po->ifindex = dev ? dev->ifindex : 0; 2519 + 2520 + packet_cached_dev_assign(po, dev); 2528 2521 2529 2522 if (protocol == 0) 2530 2523 goto out_unlock; ··· 2641 2628 po = pkt_sk(sk); 2642 2629 sk->sk_family = PF_PACKET; 2643 2630 po->num = proto; 2644 - RCU_INIT_POINTER(po->cached_dev, NULL); 2631 + 2632 + packet_cached_dev_reset(po); 2645 2633 2646 2634 sk->sk_destruct = packet_sock_destruct; 2647 2635 sk_refcnt_debug_inc(sk); ··· 3353 3339 sk->sk_error_report(sk); 3354 3340 } 3355 3341 if (msg == NETDEV_UNREGISTER) { 3342 + packet_cached_dev_reset(po); 3356 3343 po->ifindex = -1; 3357 3344 if (po->prot_hook.dev) 3358 3345 dev_put(po->prot_hook.dev);
+14 -12
net/sched/act_api.c
··· 270 270 { 271 271 struct tc_action_ops *a, **ap; 272 272 273 + /* Must supply act, dump, cleanup and init */ 274 + if (!act->act || !act->dump || !act->cleanup || !act->init) 275 + return -EINVAL; 276 + 277 + /* Supply defaults */ 278 + if (!act->lookup) 279 + act->lookup = tcf_hash_search; 280 + if (!act->walk) 281 + act->walk = tcf_generic_walker; 282 + 273 283 write_lock(&act_mod_lock); 274 284 for (ap = &act_base; (a = *ap) != NULL; ap = &a->next) { 275 285 if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) { ··· 391 381 } 392 382 while ((a = act) != NULL) { 393 383 repeat: 394 - if (a->ops && a->ops->act) { 384 + if (a->ops) { 395 385 ret = a->ops->act(skb, a, res); 396 386 if (TC_MUNGED & skb->tc_verd) { 397 387 /* copied already, allow trampling */ ··· 415 405 struct tc_action *a; 416 406 417 407 for (a = act; a; a = act) { 418 - if (a->ops && a->ops->cleanup) { 408 + if (a->ops) { 419 409 if (a->ops->cleanup(a, bind) == ACT_P_DELETED) 420 410 module_put(a->ops->owner); 421 411 act = act->next; ··· 434 424 { 435 425 int err = -EINVAL; 436 426 437 - if (a->ops == NULL || a->ops->dump == NULL) 427 + if (a->ops == NULL) 438 428 return err; 439 429 return a->ops->dump(skb, a, bind, ref); 440 430 } ··· 446 436 unsigned char *b = skb_tail_pointer(skb); 447 437 struct nlattr *nest; 448 438 449 - if (a->ops == NULL || a->ops->dump == NULL) 439 + if (a->ops == NULL) 450 440 return err; 451 441 452 442 if (nla_put_string(skb, TCA_KIND, a->ops->kind)) ··· 733 723 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]); 734 724 if (a->ops == NULL) 735 725 goto err_free; 736 - if (a->ops->lookup == NULL) 737 - goto err_mod; 738 726 err = -ENOENT; 739 727 if (a->ops->lookup(a, index) == 0) 740 728 goto err_mod; ··· 1091 1083 1092 1084 memset(&a, 0, sizeof(struct tc_action)); 1093 1085 a.ops = a_o; 1094 - 1095 - if (a_o->walk == NULL) { 1096 - WARN(1, "tc_dump_action: %s !capable of dumping table\n", 1097 - a_o->kind); 1098 - goto out_module_put; 1099 - } 1100 1086 1101 1087 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 1102 1088 cb->nlh->nlmsg_type, sizeof(*t), 0);
-2
net/sched/act_csum.c
··· 585 585 .act = tcf_csum, 586 586 .dump = tcf_csum_dump, 587 587 .cleanup = tcf_csum_cleanup, 588 - .lookup = tcf_hash_search, 589 588 .init = tcf_csum_init, 590 - .walk = tcf_generic_walker 591 589 }; 592 590 593 591 MODULE_DESCRIPTION("Checksum updating actions");
-2
net/sched/act_gact.c
··· 206 206 .act = tcf_gact, 207 207 .dump = tcf_gact_dump, 208 208 .cleanup = tcf_gact_cleanup, 209 - .lookup = tcf_hash_search, 210 209 .init = tcf_gact_init, 211 - .walk = tcf_generic_walker 212 210 }; 213 211 214 212 MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
-4
net/sched/act_ipt.c
··· 298 298 .act = tcf_ipt, 299 299 .dump = tcf_ipt_dump, 300 300 .cleanup = tcf_ipt_cleanup, 301 - .lookup = tcf_hash_search, 302 301 .init = tcf_ipt_init, 303 - .walk = tcf_generic_walker 304 302 }; 305 303 306 304 static struct tc_action_ops act_xt_ops = { ··· 310 312 .act = tcf_ipt, 311 313 .dump = tcf_ipt_dump, 312 314 .cleanup = tcf_ipt_cleanup, 313 - .lookup = tcf_hash_search, 314 315 .init = tcf_ipt_init, 315 - .walk = tcf_generic_walker 316 316 }; 317 317 318 318 MODULE_AUTHOR("Jamal Hadi Salim(2002-13)");
-2
net/sched/act_mirred.c
··· 271 271 .act = tcf_mirred, 272 272 .dump = tcf_mirred_dump, 273 273 .cleanup = tcf_mirred_cleanup, 274 - .lookup = tcf_hash_search, 275 274 .init = tcf_mirred_init, 276 - .walk = tcf_generic_walker 277 275 }; 278 276 279 277 MODULE_AUTHOR("Jamal Hadi Salim(2002)");
-2
net/sched/act_nat.c
··· 308 308 .act = tcf_nat, 309 309 .dump = tcf_nat_dump, 310 310 .cleanup = tcf_nat_cleanup, 311 - .lookup = tcf_hash_search, 312 311 .init = tcf_nat_init, 313 - .walk = tcf_generic_walker 314 312 }; 315 313 316 314 MODULE_DESCRIPTION("Stateless NAT actions");
-2
net/sched/act_pedit.c
··· 243 243 .act = tcf_pedit, 244 244 .dump = tcf_pedit_dump, 245 245 .cleanup = tcf_pedit_cleanup, 246 - .lookup = tcf_hash_search, 247 246 .init = tcf_pedit_init, 248 - .walk = tcf_generic_walker 249 247 }; 250 248 251 249 MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
-1
net/sched/act_police.c
··· 407 407 .act = tcf_act_police, 408 408 .dump = tcf_act_police_dump, 409 409 .cleanup = tcf_act_police_cleanup, 410 - .lookup = tcf_hash_search, 411 410 .init = tcf_act_police_locate, 412 411 .walk = tcf_act_police_walker 413 412 };
-1
net/sched/act_simple.c
··· 201 201 .dump = tcf_simp_dump, 202 202 .cleanup = tcf_simp_cleanup, 203 203 .init = tcf_simp_init, 204 - .walk = tcf_generic_walker, 205 204 }; 206 205 207 206 MODULE_AUTHOR("Jamal Hadi Salim(2005)");
-1
net/sched/act_skbedit.c
··· 202 202 .dump = tcf_skbedit_dump, 203 203 .cleanup = tcf_skbedit_cleanup, 204 204 .init = tcf_skbedit_init, 205 - .walk = tcf_generic_walker, 206 205 }; 207 206 208 207 MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>");
+1 -1
net/sctp/transport.c
··· 572 572 u32 old_cwnd = t->cwnd; 573 573 u32 max_burst_bytes; 574 574 575 - if (t->burst_limited) 575 + if (t->burst_limited || asoc->max_burst == 0) 576 576 return; 577 577 578 578 max_burst_bytes = t->flight_size + (asoc->max_burst * asoc->pathmtu);