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 memory leak in iwlwifi, from Matti Gottlieb.

2) Add missing registration of netfilter arp_tables into initial
namespace, from Florian Westphal.

3) Fix potential NULL deref in DecNET routing code.

4) Restrict NETLINK_URELEASE to truly bound sockets only, from Dmitry
Ivanov.

5) Fix dst ref counting in VRF, from David Ahern.

6) Fix TSO segmenting limits in i40e driver, from Alexander Duyck.

7) Fix heap leak in PACKET_DIAG_MCLIST, from Mathias Krause.

8) Ravalidate IPV6 datagram socket cached routes properly, particularly
with UDP, from Martin KaFai Lau.

9) Fix endian bug in RDS dp_ack_seq handling, from Qing Huang.

10) Fix stats typing in bcmgenet driver, from Eric Dumazet.

11) Openvswitch needs to orphan SKBs before ipv6 fragmentation handing,
from Joe Stringer.

12) SPI device reference leak in spi_ks8895 PHY driver, from Mark Brown.

13) atl2 doesn't actually support scatter-gather, so don't advertise the
feature. From Ben Hucthings.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (72 commits)
openvswitch: use flow protocol when recalculating ipv6 checksums
Driver: Vmxnet3: set CHECKSUM_UNNECESSARY for IPv6 packets
atl2: Disable unimplemented scatter/gather feature
net/mlx4_en: Split SW RX dropped counter per RX ring
net/mlx4_core: Don't allow to VF change global pause settings
net/mlx4_core: Avoid repeated calls to pci enable/disable
net/mlx4_core: Implement pci_resume callback
net: phy: spi_ks8895: Don't leak references to SPI devices
net: ethernet: davinci_emac: Fix platform_data overwrite
net: ethernet: davinci_emac: Fix Unbalanced pm_runtime_enable
qede: Fix single MTU sized packet from firmware GRO flow
qede: Fix setting Skb network header
qede: Fix various memory allocation error flows for fastpath
tcp: Merge tx_flags and tskey in tcp_shifted_skb
tcp: Merge tx_flags and tskey in tcp_collapse_retrans
drivers: net: cpsw: fix wrong regs access in cpsw_ndo_open
tcp: Fix SOF_TIMESTAMPING_TX_ACK when handling dup acks
openvswitch: Orphan skbs before IPv6 defrag
Revert "Prevent NUll pointer dereference with two PHYs on cpsw"
VSOCK: Only check error on skb_recv_datagram when skb is NULL
...

+1010 -530
+5 -2
Documentation/devicetree/bindings/net/mediatek-net.txt
··· 9 9 Required properties: 10 10 - compatible: Should be "mediatek,mt7623-eth" 11 11 - reg: Address and length of the register set for the device 12 - - interrupts: Should contain the frame engines interrupt 12 + - interrupts: Should contain the three frame engines interrupts in numeric 13 + order. These are fe_int0, fe_int1 and fe_int2. 13 14 - clocks: the clock used by the core 14 15 - clock-names: the names of the clock listed in the clocks property. These are 15 16 "ethif", "esw", "gp2", "gp1" ··· 43 42 <&ethsys CLK_ETHSYS_GP2>, 44 43 <&ethsys CLK_ETHSYS_GP1>; 45 44 clock-names = "ethif", "esw", "gp2", "gp1"; 46 - interrupts = <GIC_SPI 200 IRQ_TYPE_LEVEL_LOW>; 45 + interrupts = <GIC_SPI 200 IRQ_TYPE_LEVEL_LOW 46 + GIC_SPI 199 IRQ_TYPE_LEVEL_LOW 47 + GIC_SPI 198 IRQ_TYPE_LEVEL_LOW>; 47 48 power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>; 48 49 resets = <&ethsys MT2701_ETHSYS_ETH_RST>; 49 50 reset-names = "eth";
+4 -13
drivers/bcma/main.c
··· 136 136 return false; 137 137 } 138 138 139 - #if defined(CONFIG_OF) && defined(CONFIG_OF_ADDRESS) 140 139 static struct device_node *bcma_of_find_child_device(struct platform_device *parent, 141 140 struct bcma_device *core) 142 141 { ··· 183 184 struct of_phandle_args out_irq; 184 185 int ret; 185 186 186 - if (!parent || !parent->dev.of_node) 187 + if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent || !parent->dev.of_node) 187 188 return 0; 188 189 189 190 ret = bcma_of_irq_parse(parent, core, &out_irq, num); ··· 201 202 { 202 203 struct device_node *node; 203 204 205 + if (!IS_ENABLED(CONFIG_OF_IRQ)) 206 + return; 207 + 204 208 node = bcma_of_find_child_device(parent, core); 205 209 if (node) 206 210 core->dev.of_node = node; 207 211 208 212 core->irq = bcma_of_get_irq(parent, core, 0); 209 213 } 210 - #else 211 - static void bcma_of_fill_device(struct platform_device *parent, 212 - struct bcma_device *core) 213 - { 214 - } 215 - static inline unsigned int bcma_of_get_irq(struct platform_device *parent, 216 - struct bcma_device *core, int num) 217 - { 218 - return 0; 219 - } 220 - #endif /* CONFIG_OF */ 221 214 222 215 unsigned int bcma_core_irq(struct bcma_device *core, int num) 223 216 {
+3
drivers/isdn/mISDN/socket.c
··· 715 715 if (!maddr || maddr->family != AF_ISDN) 716 716 return -EINVAL; 717 717 718 + if (addr_len < sizeof(struct sockaddr_mISDN)) 719 + return -EINVAL; 720 + 718 721 lock_sock(sk); 719 722 720 723 if (_pms(sk)->dev) {
+1
drivers/net/Kconfig
··· 195 195 196 196 config MACSEC 197 197 tristate "IEEE 802.1AE MAC-level encryption (MACsec)" 198 + select CRYPTO 198 199 select CRYPTO_AES 199 200 select CRYPTO_GCM 200 201 ---help---
+5 -29
drivers/net/dsa/mv88e6xxx.c
··· 2181 2181 struct net_device *bridge) 2182 2182 { 2183 2183 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2184 - u16 fid; 2185 2184 int i, err; 2186 2185 2187 2186 mutex_lock(&ps->smi_mutex); 2188 - 2189 - /* Get or create the bridge FID and assign it to the port */ 2190 - for (i = 0; i < ps->num_ports; ++i) 2191 - if (ps->ports[i].bridge_dev == bridge) 2192 - break; 2193 - 2194 - if (i < ps->num_ports) 2195 - err = _mv88e6xxx_port_fid_get(ds, i, &fid); 2196 - else 2197 - err = _mv88e6xxx_fid_new(ds, &fid); 2198 - if (err) 2199 - goto unlock; 2200 - 2201 - err = _mv88e6xxx_port_fid_set(ds, port, fid); 2202 - if (err) 2203 - goto unlock; 2204 2187 2205 2188 /* Assign the bridge and remap each port's VLANTable */ 2206 2189 ps->ports[port].bridge_dev = bridge; ··· 2196 2213 } 2197 2214 } 2198 2215 2199 - unlock: 2200 2216 mutex_unlock(&ps->smi_mutex); 2201 2217 2202 2218 return err; ··· 2205 2223 { 2206 2224 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2207 2225 struct net_device *bridge = ps->ports[port].bridge_dev; 2208 - u16 fid; 2209 2226 int i; 2210 2227 2211 2228 mutex_lock(&ps->smi_mutex); 2212 - 2213 - /* Give the port a fresh Filtering Information Database */ 2214 - if (_mv88e6xxx_fid_new(ds, &fid) || 2215 - _mv88e6xxx_port_fid_set(ds, port, fid)) 2216 - netdev_warn(ds->ports[port], "failed to assign a new FID\n"); 2217 2229 2218 2230 /* Unassign the bridge and remap each port's VLANTable */ 2219 2231 ps->ports[port].bridge_dev = NULL; ··· 2452 2476 * the other bits clear. 2453 2477 */ 2454 2478 reg = 1 << port; 2455 - /* Disable learning for DSA and CPU ports */ 2456 - if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) 2457 - reg = PORT_ASSOC_VECTOR_LOCKED_PORT; 2479 + /* Disable learning for CPU port */ 2480 + if (dsa_is_cpu_port(ds, port)) 2481 + reg = 0; 2458 2482 2459 2483 ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_ASSOC_VECTOR, reg); 2460 2484 if (ret) ··· 2534 2558 if (ret) 2535 2559 goto abort; 2536 2560 2537 - /* Port based VLAN map: give each port its own address 2561 + /* Port based VLAN map: give each port the same default address 2538 2562 * database, and allow bidirectional communication between the 2539 2563 * CPU and DSA port(s), and the other ports. 2540 2564 */ 2541 - ret = _mv88e6xxx_port_fid_set(ds, port, port + 1); 2565 + ret = _mv88e6xxx_port_fid_set(ds, port, 0); 2542 2566 if (ret) 2543 2567 goto abort; 2544 2568
+1 -1
drivers/net/ethernet/atheros/atlx/atl2.c
··· 1412 1412 1413 1413 err = -EIO; 1414 1414 1415 - netdev->hw_features = NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_RX; 1415 + netdev->hw_features = NETIF_F_HW_VLAN_CTAG_RX; 1416 1416 netdev->features |= (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX); 1417 1417 1418 1418 /* Init PHY as early as possible due to power saving issue */
+5
drivers/net/ethernet/broadcom/bgmac.c
··· 1572 1572 dev_warn(&core->dev, "Using random MAC: %pM\n", mac); 1573 1573 } 1574 1574 1575 + /* This (reset &) enable is not preset in specs or reference driver but 1576 + * Broadcom does it in arch PCI code when enabling fake PCI device. 1577 + */ 1578 + bcma_core_enable(core, 0); 1579 + 1575 1580 /* Allocation and references */ 1576 1581 net_dev = alloc_etherdev(sizeof(*bgmac)); 1577 1582 if (!net_dev)
+3 -3
drivers/net/ethernet/broadcom/bgmac.h
··· 199 199 #define BGMAC_CMDCFG_TAI 0x00000200 200 200 #define BGMAC_CMDCFG_HD 0x00000400 /* Set if in half duplex mode */ 201 201 #define BGMAC_CMDCFG_HD_SHIFT 10 202 - #define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for other revs */ 203 - #define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, only for core rev 4 */ 204 - #define BGMAC_CMDCFG_SR(rev) ((rev == 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0) 202 + #define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */ 203 + #define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */ 204 + #define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0) 205 205 #define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */ 206 206 #define BGMAC_CMDCFG_AE 0x00400000 207 207 #define BGMAC_CMDCFG_CFE 0x00800000
+5 -1
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 878 878 else 879 879 p = (char *)priv; 880 880 p += s->stat_offset; 881 - data[i] = *(u32 *)p; 881 + if (sizeof(unsigned long) != sizeof(u32) && 882 + s->stat_sizeof == sizeof(unsigned long)) 883 + data[i] = *(unsigned long *)p; 884 + else 885 + data[i] = *(u32 *)p; 882 886 } 883 887 } 884 888
+3 -2
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 1011 1011 } 1012 1012 1013 1013 lmac++; 1014 - if (lmac == MAX_LMAC_PER_BGX) 1014 + if (lmac == MAX_LMAC_PER_BGX) { 1015 + of_node_put(node); 1015 1016 break; 1017 + } 1016 1018 } 1017 - of_node_put(node); 1018 1019 return 0; 1019 1020 1020 1021 defer:
+3
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
··· 1451 1451 unsigned int mmd, unsigned int reg, u16 *valp); 1452 1452 int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr, 1453 1453 unsigned int mmd, unsigned int reg, u16 val); 1454 + int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf, 1455 + unsigned int vf, unsigned int iqtype, unsigned int iqid, 1456 + unsigned int fl0id, unsigned int fl1id); 1454 1457 int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, 1455 1458 unsigned int vf, unsigned int iqtype, unsigned int iqid, 1456 1459 unsigned int fl0id, unsigned int fl1id);
+17 -3
drivers/net/ethernet/chelsio/cxgb4/sge.c
··· 2981 2981 void t4_free_sge_resources(struct adapter *adap) 2982 2982 { 2983 2983 int i; 2984 - struct sge_eth_rxq *eq = adap->sge.ethrxq; 2985 - struct sge_eth_txq *etq = adap->sge.ethtxq; 2984 + struct sge_eth_rxq *eq; 2985 + struct sge_eth_txq *etq; 2986 + 2987 + /* stop all Rx queues in order to start them draining */ 2988 + for (i = 0; i < adap->sge.ethqsets; i++) { 2989 + eq = &adap->sge.ethrxq[i]; 2990 + if (eq->rspq.desc) 2991 + t4_iq_stop(adap, adap->mbox, adap->pf, 0, 2992 + FW_IQ_TYPE_FL_INT_CAP, 2993 + eq->rspq.cntxt_id, 2994 + eq->fl.size ? eq->fl.cntxt_id : 0xffff, 2995 + 0xffff); 2996 + } 2986 2997 2987 2998 /* clean up Ethernet Tx/Rx queues */ 2988 - for (i = 0; i < adap->sge.ethqsets; i++, eq++, etq++) { 2999 + for (i = 0; i < adap->sge.ethqsets; i++) { 3000 + eq = &adap->sge.ethrxq[i]; 2989 3001 if (eq->rspq.desc) 2990 3002 free_rspq_fl(adap, &eq->rspq, 2991 3003 eq->fl.size ? &eq->fl : NULL); 3004 + 3005 + etq = &adap->sge.ethtxq[i]; 2992 3006 if (etq->q.desc) { 2993 3007 t4_eth_eq_free(adap, adap->mbox, adap->pf, 0, 2994 3008 etq->q.cntxt_id);
+33
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 6950 6950 } 6951 6951 6952 6952 /** 6953 + * t4_iq_stop - stop an ingress queue and its FLs 6954 + * @adap: the adapter 6955 + * @mbox: mailbox to use for the FW command 6956 + * @pf: the PF owning the queues 6957 + * @vf: the VF owning the queues 6958 + * @iqtype: the ingress queue type (FW_IQ_TYPE_FL_INT_CAP, etc.) 6959 + * @iqid: ingress queue id 6960 + * @fl0id: FL0 queue id or 0xffff if no attached FL0 6961 + * @fl1id: FL1 queue id or 0xffff if no attached FL1 6962 + * 6963 + * Stops an ingress queue and its associated FLs, if any. This causes 6964 + * any current or future data/messages destined for these queues to be 6965 + * tossed. 6966 + */ 6967 + int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf, 6968 + unsigned int vf, unsigned int iqtype, unsigned int iqid, 6969 + unsigned int fl0id, unsigned int fl1id) 6970 + { 6971 + struct fw_iq_cmd c; 6972 + 6973 + memset(&c, 0, sizeof(c)); 6974 + c.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_IQ_CMD) | FW_CMD_REQUEST_F | 6975 + FW_CMD_EXEC_F | FW_IQ_CMD_PFN_V(pf) | 6976 + FW_IQ_CMD_VFN_V(vf)); 6977 + c.alloc_to_len16 = cpu_to_be32(FW_IQ_CMD_IQSTOP_F | FW_LEN16(c)); 6978 + c.type_to_iqandstindex = cpu_to_be32(FW_IQ_CMD_TYPE_V(iqtype)); 6979 + c.iqid = cpu_to_be16(iqid); 6980 + c.fl0id = cpu_to_be16(fl0id); 6981 + c.fl1id = cpu_to_be16(fl1id); 6982 + return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); 6983 + } 6984 + 6985 + /** 6953 6986 * t4_iq_free - free an ingress queue and its FLs 6954 6987 * @adap: the adapter 6955 6988 * @mbox: mailbox to use for the FW command
+22 -8
drivers/net/ethernet/intel/fm10k/fm10k_pf.c
··· 1223 1223 if (err) 1224 1224 return err; 1225 1225 1226 - /* verify upper 16 bits are zero */ 1227 - if (vid >> 16) 1228 - return FM10K_ERR_PARAM; 1229 - 1230 1226 set = !(vid & FM10K_VLAN_CLEAR); 1231 1227 vid &= ~FM10K_VLAN_CLEAR; 1232 1228 1233 - err = fm10k_iov_select_vid(vf_info, (u16)vid); 1234 - if (err < 0) 1235 - return err; 1229 + /* if the length field has been set, this is a multi-bit 1230 + * update request. For multi-bit requests, simply disallow 1231 + * them when the pf_vid has been set. In this case, the PF 1232 + * should have already cleared the VLAN_TABLE, and if we 1233 + * allowed them, it could allow a rogue VF to receive traffic 1234 + * on a VLAN it was not assigned. In the single-bit case, we 1235 + * need to modify requests for VLAN 0 to use the default PF or 1236 + * SW vid when assigned. 1237 + */ 1236 1238 1237 - vid = err; 1239 + if (vid >> 16) { 1240 + /* prevent multi-bit requests when PF has 1241 + * administratively set the VLAN for this VF 1242 + */ 1243 + if (vf_info->pf_vid) 1244 + return FM10K_ERR_PARAM; 1245 + } else { 1246 + err = fm10k_iov_select_vid(vf_info, (u16)vid); 1247 + if (err < 0) 1248 + return err; 1249 + 1250 + vid = err; 1251 + } 1238 1252 1239 1253 /* update VSI info for VF in regards to VLAN table */ 1240 1254 err = hw->mac.ops.update_vlan(hw, vid, vf_info->vsi, set);
+24 -25
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 2594 2594 } 2595 2595 2596 2596 /** 2597 - * __i40e_chk_linearize - Check if there are more than 8 fragments per packet 2597 + * __i40e_chk_linearize - Check if there are more than 8 buffers per packet 2598 2598 * @skb: send buffer 2599 2599 * 2600 - * Note: Our HW can't scatter-gather more than 8 fragments to build 2601 - * a packet on the wire and so we need to figure out the cases where we 2602 - * need to linearize the skb. 2600 + * Note: Our HW can't DMA more than 8 buffers to build a packet on the wire 2601 + * and so we need to figure out the cases where we need to linearize the skb. 2602 + * 2603 + * For TSO we need to count the TSO header and segment payload separately. 2604 + * As such we need to check cases where we have 7 fragments or more as we 2605 + * can potentially require 9 DMA transactions, 1 for the TSO header, 1 for 2606 + * the segment payload in the first descriptor, and another 7 for the 2607 + * fragments. 2603 2608 **/ 2604 2609 bool __i40e_chk_linearize(struct sk_buff *skb) 2605 2610 { 2606 2611 const struct skb_frag_struct *frag, *stale; 2607 - int gso_size, nr_frags, sum; 2612 + int nr_frags, sum; 2608 2613 2609 - /* check to see if TSO is enabled, if so we may get a repreive */ 2610 - gso_size = skb_shinfo(skb)->gso_size; 2611 - if (unlikely(!gso_size)) 2612 - return true; 2613 - 2614 - /* no need to check if number of frags is less than 8 */ 2614 + /* no need to check if number of frags is less than 7 */ 2615 2615 nr_frags = skb_shinfo(skb)->nr_frags; 2616 - if (nr_frags < I40E_MAX_BUFFER_TXD) 2616 + if (nr_frags < (I40E_MAX_BUFFER_TXD - 1)) 2617 2617 return false; 2618 2618 2619 2619 /* We need to walk through the list and validate that each group 2620 2620 * of 6 fragments totals at least gso_size. However we don't need 2621 - * to perform such validation on the first or last 6 since the first 2622 - * 6 cannot inherit any data from a descriptor before them, and the 2623 - * last 6 cannot inherit any data from a descriptor after them. 2621 + * to perform such validation on the last 6 since the last 6 cannot 2622 + * inherit any data from a descriptor after them. 2624 2623 */ 2625 - nr_frags -= I40E_MAX_BUFFER_TXD - 1; 2624 + nr_frags -= I40E_MAX_BUFFER_TXD - 2; 2626 2625 frag = &skb_shinfo(skb)->frags[0]; 2627 2626 2628 2627 /* Initialize size to the negative value of gso_size minus 1. We ··· 2630 2631 * descriptors for a single transmit as the header and previous 2631 2632 * fragment are already consuming 2 descriptors. 2632 2633 */ 2633 - sum = 1 - gso_size; 2634 + sum = 1 - skb_shinfo(skb)->gso_size; 2634 2635 2635 - /* Add size of frags 1 through 5 to create our initial sum */ 2636 - sum += skb_frag_size(++frag); 2637 - sum += skb_frag_size(++frag); 2638 - sum += skb_frag_size(++frag); 2639 - sum += skb_frag_size(++frag); 2640 - sum += skb_frag_size(++frag); 2636 + /* Add size of frags 0 through 4 to create our initial sum */ 2637 + sum += skb_frag_size(frag++); 2638 + sum += skb_frag_size(frag++); 2639 + sum += skb_frag_size(frag++); 2640 + sum += skb_frag_size(frag++); 2641 + sum += skb_frag_size(frag++); 2641 2642 2642 2643 /* Walk through fragments adding latest fragment, testing it, and 2643 2644 * then removing stale fragments from the sum. 2644 2645 */ 2645 2646 stale = &skb_shinfo(skb)->frags[0]; 2646 2647 for (;;) { 2647 - sum += skb_frag_size(++frag); 2648 + sum += skb_frag_size(frag++); 2648 2649 2649 2650 /* if sum is negative we failed to make sufficient progress */ 2650 2651 if (sum < 0) ··· 2654 2655 if (!--nr_frags) 2655 2656 break; 2656 2657 2657 - sum -= skb_frag_size(++stale); 2658 + sum -= skb_frag_size(stale++); 2658 2659 } 2659 2660 2660 2661 return false;
+7 -3
drivers/net/ethernet/intel/i40e/i40e_txrx.h
··· 413 413 **/ 414 414 static inline bool i40e_chk_linearize(struct sk_buff *skb, int count) 415 415 { 416 - /* we can only support up to 8 data buffers for a single send */ 417 - if (likely(count <= I40E_MAX_BUFFER_TXD)) 416 + /* Both TSO and single send will work if count is less than 8 */ 417 + if (likely(count < I40E_MAX_BUFFER_TXD)) 418 418 return false; 419 419 420 - return __i40e_chk_linearize(skb); 420 + if (skb_is_gso(skb)) 421 + return __i40e_chk_linearize(skb); 422 + 423 + /* we can support up to 8 data buffers for a single send */ 424 + return count != I40E_MAX_BUFFER_TXD; 421 425 } 422 426 #endif /* _I40E_TXRX_H_ */
+24 -25
drivers/net/ethernet/intel/i40evf/i40e_txrx.c
··· 1796 1796 } 1797 1797 1798 1798 /** 1799 - * __i40evf_chk_linearize - Check if there are more than 8 fragments per packet 1799 + * __i40evf_chk_linearize - Check if there are more than 8 buffers per packet 1800 1800 * @skb: send buffer 1801 1801 * 1802 - * Note: Our HW can't scatter-gather more than 8 fragments to build 1803 - * a packet on the wire and so we need to figure out the cases where we 1804 - * need to linearize the skb. 1802 + * Note: Our HW can't DMA more than 8 buffers to build a packet on the wire 1803 + * and so we need to figure out the cases where we need to linearize the skb. 1804 + * 1805 + * For TSO we need to count the TSO header and segment payload separately. 1806 + * As such we need to check cases where we have 7 fragments or more as we 1807 + * can potentially require 9 DMA transactions, 1 for the TSO header, 1 for 1808 + * the segment payload in the first descriptor, and another 7 for the 1809 + * fragments. 1805 1810 **/ 1806 1811 bool __i40evf_chk_linearize(struct sk_buff *skb) 1807 1812 { 1808 1813 const struct skb_frag_struct *frag, *stale; 1809 - int gso_size, nr_frags, sum; 1814 + int nr_frags, sum; 1810 1815 1811 - /* check to see if TSO is enabled, if so we may get a repreive */ 1812 - gso_size = skb_shinfo(skb)->gso_size; 1813 - if (unlikely(!gso_size)) 1814 - return true; 1815 - 1816 - /* no need to check if number of frags is less than 8 */ 1816 + /* no need to check if number of frags is less than 7 */ 1817 1817 nr_frags = skb_shinfo(skb)->nr_frags; 1818 - if (nr_frags < I40E_MAX_BUFFER_TXD) 1818 + if (nr_frags < (I40E_MAX_BUFFER_TXD - 1)) 1819 1819 return false; 1820 1820 1821 1821 /* We need to walk through the list and validate that each group 1822 1822 * of 6 fragments totals at least gso_size. However we don't need 1823 - * to perform such validation on the first or last 6 since the first 1824 - * 6 cannot inherit any data from a descriptor before them, and the 1825 - * last 6 cannot inherit any data from a descriptor after them. 1823 + * to perform such validation on the last 6 since the last 6 cannot 1824 + * inherit any data from a descriptor after them. 1826 1825 */ 1827 - nr_frags -= I40E_MAX_BUFFER_TXD - 1; 1826 + nr_frags -= I40E_MAX_BUFFER_TXD - 2; 1828 1827 frag = &skb_shinfo(skb)->frags[0]; 1829 1828 1830 1829 /* Initialize size to the negative value of gso_size minus 1. We ··· 1832 1833 * descriptors for a single transmit as the header and previous 1833 1834 * fragment are already consuming 2 descriptors. 1834 1835 */ 1835 - sum = 1 - gso_size; 1836 + sum = 1 - skb_shinfo(skb)->gso_size; 1836 1837 1837 - /* Add size of frags 1 through 5 to create our initial sum */ 1838 - sum += skb_frag_size(++frag); 1839 - sum += skb_frag_size(++frag); 1840 - sum += skb_frag_size(++frag); 1841 - sum += skb_frag_size(++frag); 1842 - sum += skb_frag_size(++frag); 1838 + /* Add size of frags 0 through 4 to create our initial sum */ 1839 + sum += skb_frag_size(frag++); 1840 + sum += skb_frag_size(frag++); 1841 + sum += skb_frag_size(frag++); 1842 + sum += skb_frag_size(frag++); 1843 + sum += skb_frag_size(frag++); 1843 1844 1844 1845 /* Walk through fragments adding latest fragment, testing it, and 1845 1846 * then removing stale fragments from the sum. 1846 1847 */ 1847 1848 stale = &skb_shinfo(skb)->frags[0]; 1848 1849 for (;;) { 1849 - sum += skb_frag_size(++frag); 1850 + sum += skb_frag_size(frag++); 1850 1851 1851 1852 /* if sum is negative we failed to make sufficient progress */ 1852 1853 if (sum < 0) ··· 1856 1857 if (!--nr_frags) 1857 1858 break; 1858 1859 1859 - sum -= skb_frag_size(++stale); 1860 + sum -= skb_frag_size(stale++); 1860 1861 } 1861 1862 1862 1863 return false;
+7 -3
drivers/net/ethernet/intel/i40evf/i40e_txrx.h
··· 395 395 **/ 396 396 static inline bool i40e_chk_linearize(struct sk_buff *skb, int count) 397 397 { 398 - /* we can only support up to 8 data buffers for a single send */ 399 - if (likely(count <= I40E_MAX_BUFFER_TXD)) 398 + /* Both TSO and single send will work if count is less than 8 */ 399 + if (likely(count < I40E_MAX_BUFFER_TXD)) 400 400 return false; 401 401 402 - return __i40evf_chk_linearize(skb); 402 + if (skb_is_gso(skb)) 403 + return __i40evf_chk_linearize(skb); 404 + 405 + /* we can support up to 8 data buffers for a single send */ 406 + return count != I40E_MAX_BUFFER_TXD; 403 407 } 404 408 #endif /* _I40E_TXRX_H_ */
+4 -1
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
··· 337 337 case ETH_SS_STATS: 338 338 return bitmap_iterator_count(&it) + 339 339 (priv->tx_ring_num * 2) + 340 - (priv->rx_ring_num * 2); 340 + (priv->rx_ring_num * 3); 341 341 case ETH_SS_TEST: 342 342 return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags 343 343 & MLX4_DEV_CAP_FLAG_UC_LOOPBACK) * 2; ··· 404 404 for (i = 0; i < priv->rx_ring_num; i++) { 405 405 data[index++] = priv->rx_ring[i]->packets; 406 406 data[index++] = priv->rx_ring[i]->bytes; 407 + data[index++] = priv->rx_ring[i]->dropped; 407 408 } 408 409 spin_unlock_bh(&priv->stats_lock); 409 410 ··· 478 477 "rx%d_packets", i); 479 478 sprintf(data + (index++) * ETH_GSTRING_LEN, 480 479 "rx%d_bytes", i); 480 + sprintf(data + (index++) * ETH_GSTRING_LEN, 481 + "rx%d_dropped", i); 481 482 } 482 483 break; 483 484 case ETH_SS_PRIV_FLAGS:
+4 -1
drivers/net/ethernet/mellanox/mlx4/en_port.c
··· 158 158 u64 in_mod = reset << 8 | port; 159 159 int err; 160 160 int i, counter_index; 161 + unsigned long sw_rx_dropped = 0; 161 162 162 163 mailbox = mlx4_alloc_cmd_mailbox(mdev->dev); 163 164 if (IS_ERR(mailbox)) ··· 181 180 for (i = 0; i < priv->rx_ring_num; i++) { 182 181 stats->rx_packets += priv->rx_ring[i]->packets; 183 182 stats->rx_bytes += priv->rx_ring[i]->bytes; 183 + sw_rx_dropped += priv->rx_ring[i]->dropped; 184 184 priv->port_stats.rx_chksum_good += priv->rx_ring[i]->csum_ok; 185 185 priv->port_stats.rx_chksum_none += priv->rx_ring[i]->csum_none; 186 186 priv->port_stats.rx_chksum_complete += priv->rx_ring[i]->csum_complete; ··· 238 236 &mlx4_en_stats->MCAST_prio_1, 239 237 NUM_PRIORITIES); 240 238 stats->collisions = 0; 241 - stats->rx_dropped = be32_to_cpu(mlx4_en_stats->RDROP); 239 + stats->rx_dropped = be32_to_cpu(mlx4_en_stats->RDROP) + 240 + sw_rx_dropped; 242 241 stats->rx_length_errors = be32_to_cpu(mlx4_en_stats->RdropLength); 243 242 stats->rx_over_errors = 0; 244 243 stats->rx_crc_errors = be32_to_cpu(mlx4_en_stats->RCRC);
+8 -4
drivers/net/ethernet/mellanox/mlx4/en_rx.c
··· 61 61 gfp_t gfp = _gfp; 62 62 63 63 if (order) 64 - gfp |= __GFP_COMP | __GFP_NOWARN; 64 + gfp |= __GFP_COMP | __GFP_NOWARN | __GFP_NOMEMALLOC; 65 65 page = alloc_pages(gfp, order); 66 66 if (likely(page)) 67 67 break; ··· 126 126 dma_unmap_page(priv->ddev, page_alloc[i].dma, 127 127 page_alloc[i].page_size, PCI_DMA_FROMDEVICE); 128 128 page = page_alloc[i].page; 129 - set_page_count(page, 1); 129 + /* Revert changes done by mlx4_alloc_pages */ 130 + page_ref_sub(page, page_alloc[i].page_size / 131 + priv->frag_info[i].frag_stride - 1); 130 132 put_page(page); 131 133 } 132 134 } ··· 178 176 dma_unmap_page(priv->ddev, page_alloc->dma, 179 177 page_alloc->page_size, PCI_DMA_FROMDEVICE); 180 178 page = page_alloc->page; 181 - set_page_count(page, 1); 179 + /* Revert changes done by mlx4_alloc_pages */ 180 + page_ref_sub(page, page_alloc->page_size / 181 + priv->frag_info[i].frag_stride - 1); 182 182 put_page(page); 183 183 page_alloc->page = NULL; 184 184 } ··· 943 939 /* GRO not possible, complete processing here */ 944 940 skb = mlx4_en_rx_skb(priv, rx_desc, frags, length); 945 941 if (!skb) { 946 - priv->stats.rx_dropped++; 942 + ring->dropped++; 947 943 goto next; 948 944 } 949 945
+57 -19
drivers/net/ethernet/mellanox/mlx4/main.c
··· 3172 3172 return 0; 3173 3173 } 3174 3174 3175 + static int mlx4_pci_enable_device(struct mlx4_dev *dev) 3176 + { 3177 + struct pci_dev *pdev = dev->persist->pdev; 3178 + int err = 0; 3179 + 3180 + mutex_lock(&dev->persist->pci_status_mutex); 3181 + if (dev->persist->pci_status == MLX4_PCI_STATUS_DISABLED) { 3182 + err = pci_enable_device(pdev); 3183 + if (!err) 3184 + dev->persist->pci_status = MLX4_PCI_STATUS_ENABLED; 3185 + } 3186 + mutex_unlock(&dev->persist->pci_status_mutex); 3187 + 3188 + return err; 3189 + } 3190 + 3191 + static void mlx4_pci_disable_device(struct mlx4_dev *dev) 3192 + { 3193 + struct pci_dev *pdev = dev->persist->pdev; 3194 + 3195 + mutex_lock(&dev->persist->pci_status_mutex); 3196 + if (dev->persist->pci_status == MLX4_PCI_STATUS_ENABLED) { 3197 + pci_disable_device(pdev); 3198 + dev->persist->pci_status = MLX4_PCI_STATUS_DISABLED; 3199 + } 3200 + mutex_unlock(&dev->persist->pci_status_mutex); 3201 + } 3202 + 3175 3203 static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, 3176 3204 int total_vfs, int *nvfs, struct mlx4_priv *priv, 3177 3205 int reset_flow) ··· 3610 3582 3611 3583 pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev)); 3612 3584 3613 - err = pci_enable_device(pdev); 3585 + err = mlx4_pci_enable_device(&priv->dev); 3614 3586 if (err) { 3615 3587 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); 3616 3588 return err; ··· 3743 3715 pci_release_regions(pdev); 3744 3716 3745 3717 err_disable_pdev: 3746 - pci_disable_device(pdev); 3718 + mlx4_pci_disable_device(&priv->dev); 3747 3719 pci_set_drvdata(pdev, NULL); 3748 3720 return err; 3749 3721 } ··· 3803 3775 priv->pci_dev_data = id->driver_data; 3804 3776 mutex_init(&dev->persist->device_state_mutex); 3805 3777 mutex_init(&dev->persist->interface_state_mutex); 3778 + mutex_init(&dev->persist->pci_status_mutex); 3806 3779 3807 3780 ret = devlink_register(devlink, &pdev->dev); 3808 3781 if (ret) ··· 3952 3923 } 3953 3924 3954 3925 pci_release_regions(pdev); 3955 - pci_disable_device(pdev); 3926 + mlx4_pci_disable_device(dev); 3956 3927 devlink_unregister(devlink); 3957 3928 kfree(dev->persist); 3958 3929 devlink_free(devlink); ··· 4071 4042 if (state == pci_channel_io_perm_failure) 4072 4043 return PCI_ERS_RESULT_DISCONNECT; 4073 4044 4074 - pci_disable_device(pdev); 4045 + mlx4_pci_disable_device(persist->dev); 4075 4046 return PCI_ERS_RESULT_NEED_RESET; 4076 4047 } 4077 4048 ··· 4079 4050 { 4080 4051 struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); 4081 4052 struct mlx4_dev *dev = persist->dev; 4082 - struct mlx4_priv *priv = mlx4_priv(dev); 4083 - int ret; 4084 - int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0}; 4085 - int total_vfs; 4053 + int err; 4086 4054 4087 4055 mlx4_err(dev, "mlx4_pci_slot_reset was called\n"); 4088 - ret = pci_enable_device(pdev); 4089 - if (ret) { 4090 - mlx4_err(dev, "Can not re-enable device, ret=%d\n", ret); 4056 + err = mlx4_pci_enable_device(dev); 4057 + if (err) { 4058 + mlx4_err(dev, "Can not re-enable device, err=%d\n", err); 4091 4059 return PCI_ERS_RESULT_DISCONNECT; 4092 4060 } 4093 4061 4094 4062 pci_set_master(pdev); 4095 4063 pci_restore_state(pdev); 4096 4064 pci_save_state(pdev); 4065 + return PCI_ERS_RESULT_RECOVERED; 4066 + } 4097 4067 4068 + static void mlx4_pci_resume(struct pci_dev *pdev) 4069 + { 4070 + struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); 4071 + struct mlx4_dev *dev = persist->dev; 4072 + struct mlx4_priv *priv = mlx4_priv(dev); 4073 + int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0}; 4074 + int total_vfs; 4075 + int err; 4076 + 4077 + mlx4_err(dev, "%s was called\n", __func__); 4098 4078 total_vfs = dev->persist->num_vfs; 4099 4079 memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs)); 4100 4080 4101 4081 mutex_lock(&persist->interface_state_mutex); 4102 4082 if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) { 4103 - ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, nvfs, 4083 + err = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, nvfs, 4104 4084 priv, 1); 4105 - if (ret) { 4106 - mlx4_err(dev, "%s: mlx4_load_one failed, ret=%d\n", 4107 - __func__, ret); 4085 + if (err) { 4086 + mlx4_err(dev, "%s: mlx4_load_one failed, err=%d\n", 4087 + __func__, err); 4108 4088 goto end; 4109 4089 } 4110 4090 4111 - ret = restore_current_port_types(dev, dev->persist-> 4091 + err = restore_current_port_types(dev, dev->persist-> 4112 4092 curr_port_type, dev->persist-> 4113 4093 curr_port_poss_type); 4114 - if (ret) 4115 - mlx4_err(dev, "could not restore original port types (%d)\n", ret); 4094 + if (err) 4095 + mlx4_err(dev, "could not restore original port types (%d)\n", err); 4116 4096 } 4117 4097 end: 4118 4098 mutex_unlock(&persist->interface_state_mutex); 4119 4099 4120 - return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; 4121 4100 } 4122 4101 4123 4102 static void mlx4_shutdown(struct pci_dev *pdev) ··· 4142 4105 static const struct pci_error_handlers mlx4_err_handler = { 4143 4106 .error_detected = mlx4_pci_err_detected, 4144 4107 .slot_reset = mlx4_pci_slot_reset, 4108 + .resume = mlx4_pci_resume, 4145 4109 }; 4146 4110 4147 4111 static struct pci_driver mlx4_driver = {
+2
drivers/net/ethernet/mellanox/mlx4/mlx4.h
··· 586 586 struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1]; 587 587 int init_port_ref[MLX4_MAX_PORTS + 1]; 588 588 u16 max_mtu[MLX4_MAX_PORTS + 1]; 589 + u8 pptx; 590 + u8 pprx; 589 591 int disable_mcast_ref[MLX4_MAX_PORTS + 1]; 590 592 struct mlx4_resource_tracker res_tracker; 591 593 struct workqueue_struct *comm_wq;
+1
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
··· 323 323 unsigned long csum_ok; 324 324 unsigned long csum_none; 325 325 unsigned long csum_complete; 326 + unsigned long dropped; 326 327 int hwtstamp_rx_filter; 327 328 cpumask_var_t affinity_mask; 328 329 };
+13
drivers/net/ethernet/mellanox/mlx4/port.c
··· 1317 1317 } 1318 1318 1319 1319 gen_context->mtu = cpu_to_be16(master->max_mtu[port]); 1320 + /* Slave cannot change Global Pause configuration */ 1321 + if (slave != mlx4_master_func_num(dev) && 1322 + ((gen_context->pptx != master->pptx) || 1323 + (gen_context->pprx != master->pprx))) { 1324 + gen_context->pptx = master->pptx; 1325 + gen_context->pprx = master->pprx; 1326 + mlx4_warn(dev, 1327 + "denying Global Pause change for slave:%d\n", 1328 + slave); 1329 + } else { 1330 + master->pptx = gen_context->pptx; 1331 + master->pprx = gen_context->pprx; 1332 + } 1320 1333 break; 1321 1334 case MLX4_SET_PORT_GID_TABLE: 1322 1335 /* change to MULTIPLE entries: number of guest's gids
+101 -58
drivers/net/ethernet/qlogic/qede/qede_main.c
··· 750 750 return false; 751 751 } 752 752 753 + static inline void qede_rx_bd_ring_consume(struct qede_rx_queue *rxq) 754 + { 755 + qed_chain_consume(&rxq->rx_bd_ring); 756 + rxq->sw_rx_cons++; 757 + } 758 + 753 759 /* This function reuses the buffer(from an offset) from 754 760 * consumer index to producer index in the bd ring 755 761 */ ··· 779 773 curr_cons->data = NULL; 780 774 } 781 775 776 + /* In case of allocation failures reuse buffers 777 + * from consumer index to produce buffers for firmware 778 + */ 779 + static void qede_recycle_rx_bd_ring(struct qede_rx_queue *rxq, 780 + struct qede_dev *edev, u8 count) 781 + { 782 + struct sw_rx_data *curr_cons; 783 + 784 + for (; count > 0; count--) { 785 + curr_cons = &rxq->sw_rx_ring[rxq->sw_rx_cons & NUM_RX_BDS_MAX]; 786 + qede_reuse_page(edev, rxq, curr_cons); 787 + qede_rx_bd_ring_consume(rxq); 788 + } 789 + } 790 + 782 791 static inline int qede_realloc_rx_buffer(struct qede_dev *edev, 783 792 struct qede_rx_queue *rxq, 784 793 struct sw_rx_data *curr_cons) ··· 802 781 curr_cons->page_offset += rxq->rx_buf_seg_size; 803 782 804 783 if (curr_cons->page_offset == PAGE_SIZE) { 805 - if (unlikely(qede_alloc_rx_buffer(edev, rxq))) 784 + if (unlikely(qede_alloc_rx_buffer(edev, rxq))) { 785 + /* Since we failed to allocate new buffer 786 + * current buffer can be used again. 787 + */ 788 + curr_cons->page_offset -= rxq->rx_buf_seg_size; 789 + 806 790 return -ENOMEM; 791 + } 807 792 808 793 dma_unmap_page(&edev->pdev->dev, curr_cons->mapping, 809 794 PAGE_SIZE, DMA_FROM_DEVICE); ··· 928 901 len_on_bd); 929 902 930 903 if (unlikely(qede_realloc_rx_buffer(edev, rxq, current_bd))) { 931 - tpa_info->agg_state = QEDE_AGG_STATE_ERROR; 904 + /* Incr page ref count to reuse on allocation failure 905 + * so that it doesn't get freed while freeing SKB. 906 + */ 907 + atomic_inc(&current_bd->data->_count); 932 908 goto out; 933 909 } 934 910 ··· 945 915 return 0; 946 916 947 917 out: 918 + tpa_info->agg_state = QEDE_AGG_STATE_ERROR; 919 + qede_recycle_rx_bd_ring(rxq, edev, 1); 948 920 return -ENOMEM; 949 921 } 950 922 ··· 998 966 tpa_info->skb = netdev_alloc_skb(edev->ndev, 999 967 le16_to_cpu(cqe->len_on_first_bd)); 1000 968 if (unlikely(!tpa_info->skb)) { 969 + DP_NOTICE(edev, "Failed to allocate SKB for gro\n"); 1001 970 tpa_info->agg_state = QEDE_AGG_STATE_ERROR; 1002 - return; 971 + goto cons_buf; 1003 972 } 1004 973 1005 974 skb_put(tpa_info->skb, le16_to_cpu(cqe->len_on_first_bd)); ··· 1023 990 /* This is needed in order to enable forwarding support */ 1024 991 qede_set_gro_params(edev, tpa_info->skb, cqe); 1025 992 993 + cons_buf: /* We still need to handle bd_len_list to consume buffers */ 1026 994 if (likely(cqe->ext_bd_len_list[0])) 1027 995 qede_fill_frag_skb(edev, rxq, cqe->tpa_agg_index, 1028 996 le16_to_cpu(cqe->ext_bd_len_list[0])); ··· 1041 1007 const struct iphdr *iph = ip_hdr(skb); 1042 1008 struct tcphdr *th; 1043 1009 1044 - skb_set_network_header(skb, 0); 1045 1010 skb_set_transport_header(skb, sizeof(struct iphdr)); 1046 1011 th = tcp_hdr(skb); 1047 1012 ··· 1055 1022 struct ipv6hdr *iph = ipv6_hdr(skb); 1056 1023 struct tcphdr *th; 1057 1024 1058 - skb_set_network_header(skb, 0); 1059 1025 skb_set_transport_header(skb, sizeof(struct ipv6hdr)); 1060 1026 th = tcp_hdr(skb); 1061 1027 ··· 1069 1037 struct sk_buff *skb, 1070 1038 u16 vlan_tag) 1071 1039 { 1040 + /* FW can send a single MTU sized packet from gro flow 1041 + * due to aggregation timeout/last segment etc. which 1042 + * is not expected to be a gro packet. If a skb has zero 1043 + * frags then simply push it in the stack as non gso skb. 1044 + */ 1045 + if (unlikely(!skb->data_len)) { 1046 + skb_shinfo(skb)->gso_type = 0; 1047 + skb_shinfo(skb)->gso_size = 0; 1048 + goto send_skb; 1049 + } 1050 + 1072 1051 #ifdef CONFIG_INET 1073 1052 if (skb_shinfo(skb)->gso_size) { 1053 + skb_set_network_header(skb, 0); 1054 + 1074 1055 switch (skb->protocol) { 1075 1056 case htons(ETH_P_IP): 1076 1057 qede_gro_ip_csum(skb); ··· 1098 1053 } 1099 1054 } 1100 1055 #endif 1056 + 1057 + send_skb: 1101 1058 skb_record_rx_queue(skb, fp->rss_id); 1102 1059 qede_skb_receive(edev, fp, skb, vlan_tag); 1103 1060 } ··· 1291 1244 "CQE in CONS = %u has error, flags = %x, dropping incoming packet\n", 1292 1245 sw_comp_cons, parse_flag); 1293 1246 rxq->rx_hw_errors++; 1294 - qede_reuse_page(edev, rxq, sw_rx_data); 1295 - goto next_rx; 1247 + qede_recycle_rx_bd_ring(rxq, edev, fp_cqe->bd_num); 1248 + goto next_cqe; 1296 1249 } 1297 1250 1298 1251 skb = netdev_alloc_skb(edev->ndev, QEDE_RX_HDR_SIZE); 1299 1252 if (unlikely(!skb)) { 1300 1253 DP_NOTICE(edev, 1301 1254 "Build_skb failed, dropping incoming packet\n"); 1302 - qede_reuse_page(edev, rxq, sw_rx_data); 1255 + qede_recycle_rx_bd_ring(rxq, edev, fp_cqe->bd_num); 1303 1256 rxq->rx_alloc_errors++; 1304 - goto next_rx; 1257 + goto next_cqe; 1305 1258 } 1306 1259 1307 1260 /* Copy data into SKB */ ··· 1335 1288 if (unlikely(qede_realloc_rx_buffer(edev, rxq, 1336 1289 sw_rx_data))) { 1337 1290 DP_ERR(edev, "Failed to allocate rx buffer\n"); 1291 + /* Incr page ref count to reuse on allocation 1292 + * failure so that it doesn't get freed while 1293 + * freeing SKB. 1294 + */ 1295 + 1296 + atomic_inc(&sw_rx_data->data->_count); 1338 1297 rxq->rx_alloc_errors++; 1298 + qede_recycle_rx_bd_ring(rxq, edev, 1299 + fp_cqe->bd_num); 1300 + dev_kfree_skb_any(skb); 1339 1301 goto next_cqe; 1340 1302 } 1341 1303 } 1304 + 1305 + qede_rx_bd_ring_consume(rxq); 1342 1306 1343 1307 if (fp_cqe->bd_num != 1) { 1344 1308 u16 pkt_len = le16_to_cpu(fp_cqe->pkt_len); ··· 1361 1303 num_frags--) { 1362 1304 u16 cur_size = pkt_len > rxq->rx_buf_size ? 1363 1305 rxq->rx_buf_size : pkt_len; 1364 - 1365 - WARN_ONCE(!cur_size, 1366 - "Still got %d BDs for mapping jumbo, but length became 0\n", 1367 - num_frags); 1368 - 1369 - if (unlikely(qede_alloc_rx_buffer(edev, rxq))) 1306 + if (unlikely(!cur_size)) { 1307 + DP_ERR(edev, 1308 + "Still got %d BDs for mapping jumbo, but length became 0\n", 1309 + num_frags); 1310 + qede_recycle_rx_bd_ring(rxq, edev, 1311 + num_frags); 1312 + dev_kfree_skb_any(skb); 1370 1313 goto next_cqe; 1314 + } 1371 1315 1372 - rxq->sw_rx_cons++; 1316 + if (unlikely(qede_alloc_rx_buffer(edev, rxq))) { 1317 + qede_recycle_rx_bd_ring(rxq, edev, 1318 + num_frags); 1319 + dev_kfree_skb_any(skb); 1320 + goto next_cqe; 1321 + } 1322 + 1373 1323 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX; 1374 1324 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index]; 1375 - qed_chain_consume(&rxq->rx_bd_ring); 1325 + qede_rx_bd_ring_consume(rxq); 1326 + 1376 1327 dma_unmap_page(&edev->pdev->dev, 1377 1328 sw_rx_data->mapping, 1378 1329 PAGE_SIZE, DMA_FROM_DEVICE); ··· 1397 1330 pkt_len -= cur_size; 1398 1331 } 1399 1332 1400 - if (pkt_len) 1333 + if (unlikely(pkt_len)) 1401 1334 DP_ERR(edev, 1402 1335 "Mapped all BDs of jumbo, but still have %d bytes\n", 1403 1336 pkt_len); ··· 1416 1349 skb_record_rx_queue(skb, fp->rss_id); 1417 1350 1418 1351 qede_skb_receive(edev, fp, skb, le16_to_cpu(fp_cqe->vlan_tag)); 1419 - 1420 - qed_chain_consume(&rxq->rx_bd_ring); 1421 - next_rx: 1422 - rxq->sw_rx_cons++; 1423 1352 next_rx_only: 1424 1353 rx_pkt++; 1425 1354 ··· 2320 2257 struct qede_agg_info *tpa_info = &rxq->tpa_info[i]; 2321 2258 struct sw_rx_data *replace_buf = &tpa_info->replace_buf; 2322 2259 2323 - if (replace_buf) { 2260 + if (replace_buf->data) { 2324 2261 dma_unmap_page(&edev->pdev->dev, 2325 2262 dma_unmap_addr(replace_buf, mapping), 2326 2263 PAGE_SIZE, DMA_FROM_DEVICE); ··· 2440 2377 static int qede_alloc_mem_rxq(struct qede_dev *edev, 2441 2378 struct qede_rx_queue *rxq) 2442 2379 { 2443 - int i, rc, size, num_allocated; 2380 + int i, rc, size; 2444 2381 2445 2382 rxq->num_rx_buffers = edev->q_num_rx_buffers; 2446 2383 ··· 2457 2394 rxq->sw_rx_ring = kzalloc(size, GFP_KERNEL); 2458 2395 if (!rxq->sw_rx_ring) { 2459 2396 DP_ERR(edev, "Rx buffers ring allocation failed\n"); 2397 + rc = -ENOMEM; 2460 2398 goto err; 2461 2399 } 2462 2400 ··· 2485 2421 /* Allocate buffers for the Rx ring */ 2486 2422 for (i = 0; i < rxq->num_rx_buffers; i++) { 2487 2423 rc = qede_alloc_rx_buffer(edev, rxq); 2488 - if (rc) 2489 - break; 2490 - } 2491 - num_allocated = i; 2492 - if (!num_allocated) { 2493 - DP_ERR(edev, "Rx buffers allocation failed\n"); 2494 - goto err; 2495 - } else if (num_allocated < rxq->num_rx_buffers) { 2496 - DP_NOTICE(edev, 2497 - "Allocated less buffers than desired (%d allocated)\n", 2498 - num_allocated); 2424 + if (rc) { 2425 + DP_ERR(edev, 2426 + "Rx buffers allocation failed at index %d\n", i); 2427 + goto err; 2428 + } 2499 2429 } 2500 2430 2501 - qede_alloc_sge_mem(edev, rxq); 2502 - 2503 - return 0; 2504 - 2431 + rc = qede_alloc_sge_mem(edev, rxq); 2505 2432 err: 2506 - qede_free_mem_rxq(edev, rxq); 2507 - return -ENOMEM; 2433 + return rc; 2508 2434 } 2509 2435 2510 2436 static void qede_free_mem_txq(struct qede_dev *edev, ··· 2577 2523 } 2578 2524 2579 2525 return 0; 2580 - 2581 2526 err: 2582 - qede_free_mem_fp(edev, fp); 2583 - return -ENOMEM; 2527 + return rc; 2584 2528 } 2585 2529 2586 2530 static void qede_free_mem_load(struct qede_dev *edev) ··· 2601 2549 struct qede_fastpath *fp = &edev->fp_array[rss_id]; 2602 2550 2603 2551 rc = qede_alloc_mem_fp(edev, fp); 2604 - if (rc) 2605 - break; 2606 - } 2607 - 2608 - if (rss_id != QEDE_RSS_CNT(edev)) { 2609 - /* Failed allocating memory for all the queues */ 2610 - if (!rss_id) { 2552 + if (rc) { 2611 2553 DP_ERR(edev, 2612 - "Failed to allocate memory for the leading queue\n"); 2613 - rc = -ENOMEM; 2614 - } else { 2615 - DP_NOTICE(edev, 2616 - "Failed to allocate memory for all of RSS queues\n Desired: %d queues, allocated: %d queues\n", 2617 - QEDE_RSS_CNT(edev), rss_id); 2554 + "Failed to allocate memory for fastpath - rss id = %d\n", 2555 + rss_id); 2556 + qede_free_mem_load(edev); 2557 + return rc; 2618 2558 } 2619 - edev->num_rss = rss_id; 2620 2559 } 2621 2560 2622 2561 return 0;
+3
drivers/net/ethernet/renesas/ravb_main.c
··· 1691 1691 rate = clk_get_rate(clk); 1692 1692 clk_put(clk); 1693 1693 1694 + if (!rate) 1695 + return -EINVAL; 1696 + 1694 1697 inc = 1000000000ULL << 20; 1695 1698 do_div(inc, rate); 1696 1699
+1 -5
drivers/net/ethernet/renesas/sh_eth.c
··· 2194 2194 __func__); 2195 2195 return ret; 2196 2196 } 2197 - ret = sh_eth_dev_init(ndev, false); 2197 + ret = sh_eth_dev_init(ndev, true); 2198 2198 if (ret < 0) { 2199 2199 netdev_err(ndev, "%s: sh_eth_dev_init failed.\n", 2200 2200 __func__); 2201 2201 return ret; 2202 2202 } 2203 2203 2204 - mdp->irq_enabled = true; 2205 - sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR); 2206 - /* Setting the Rx mode will start the Rx process. */ 2207 - sh_eth_write(ndev, EDRRR_R, EDRRR); 2208 2204 netif_device_attach(ndev); 2209 2205 } 2210 2206
+13 -3
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
··· 34 34 #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK 0x00000003 35 35 #define SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK 0x00000010 36 36 37 + #define SYSMGR_FPGAGRP_MODULE_REG 0x00000028 38 + #define SYSMGR_FPGAGRP_MODULE_EMAC 0x00000004 39 + 37 40 #define EMAC_SPLITTER_CTRL_REG 0x0 38 41 #define EMAC_SPLITTER_CTRL_SPEED_MASK 0x3 39 42 #define EMAC_SPLITTER_CTRL_SPEED_10 0x2 ··· 151 148 int phymode = dwmac->interface; 152 149 u32 reg_offset = dwmac->reg_offset; 153 150 u32 reg_shift = dwmac->reg_shift; 154 - u32 ctrl, val; 151 + u32 ctrl, val, module; 155 152 156 153 switch (phymode) { 157 154 case PHY_INTERFACE_MODE_RGMII: ··· 178 175 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift); 179 176 ctrl |= val << reg_shift; 180 177 181 - if (dwmac->f2h_ptp_ref_clk) 178 + if (dwmac->f2h_ptp_ref_clk) { 182 179 ctrl |= SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2); 183 - else 180 + regmap_read(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG, 181 + &module); 182 + module |= (SYSMGR_FPGAGRP_MODULE_EMAC << (reg_shift / 2)); 183 + regmap_write(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG, 184 + module); 185 + } else { 184 186 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2)); 187 + } 185 188 186 189 regmap_write(sys_mgr_base_addr, reg_offset, ctrl); 190 + 187 191 return 0; 188 192 } 189 193
+2 -2
drivers/net/ethernet/ti/cpsw.c
··· 1251 1251 int i, ret; 1252 1252 u32 reg; 1253 1253 1254 + pm_runtime_get_sync(&priv->pdev->dev); 1255 + 1254 1256 if (!cpsw_common_res_usage_state(priv)) 1255 1257 cpsw_intr_disable(priv); 1256 1258 netif_carrier_off(ndev); 1257 - 1258 - pm_runtime_get_sync(&priv->pdev->dev); 1259 1259 1260 1260 reg = priv->version; 1261 1261
+1 -2
drivers/net/ethernet/ti/davinci_emac.c
··· 1878 1878 pdata->hw_ram_addr = auxdata->hw_ram_addr; 1879 1879 } 1880 1880 1881 - pdev->dev.platform_data = pdata; 1882 - 1883 1881 return pdata; 1884 1882 } 1885 1883 ··· 2099 2101 cpdma_ctlr_destroy(priv->dma); 2100 2102 2101 2103 unregister_netdev(ndev); 2104 + pm_runtime_disable(&pdev->dev); 2102 2105 free_netdev(ndev); 2103 2106 2104 2107 return 0;
+1 -1
drivers/net/phy/spi_ks8995.c
··· 441 441 return -ENOMEM; 442 442 443 443 mutex_init(&ks->lock); 444 - ks->spi = spi_dev_get(spi); 444 + ks->spi = spi; 445 445 ks->chip = &ks8995_chip[variant]; 446 446 447 447 if (ks->spi->dev.of_node) {
+7 -2
drivers/net/usb/cdc_mbim.c
··· 617 617 { USB_VENDOR_AND_INTERFACE_INFO(0x0bdb, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 618 618 .driver_info = (unsigned long)&cdc_mbim_info, 619 619 }, 620 - /* Huawei E3372 fails unless NDP comes after the IP packets */ 621 - { USB_DEVICE_AND_INTERFACE_INFO(0x12d1, 0x157d, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 620 + 621 + /* Some Huawei devices, ME906s-158 (12d1:15c1) and E3372 622 + * (12d1:157d), are known to fail unless the NDP is placed 623 + * after the IP packets. Applying the quirk to all Huawei 624 + * devices is broader than necessary, but harmless. 625 + */ 626 + { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 622 627 .driver_info = (unsigned long)&cdc_mbim_info_ndp_to_end, 623 628 }, 624 629 /* default entry */
+8 -4
drivers/net/vmxnet3/vmxnet3_drv.c
··· 1152 1152 union Vmxnet3_GenericDesc *gdesc) 1153 1153 { 1154 1154 if (!gdesc->rcd.cnc && adapter->netdev->features & NETIF_F_RXCSUM) { 1155 - /* typical case: TCP/UDP over IP and both csums are correct */ 1156 - if ((le32_to_cpu(gdesc->dword[3]) & VMXNET3_RCD_CSUM_OK) == 1157 - VMXNET3_RCD_CSUM_OK) { 1155 + if (gdesc->rcd.v4 && 1156 + (le32_to_cpu(gdesc->dword[3]) & 1157 + VMXNET3_RCD_CSUM_OK) == VMXNET3_RCD_CSUM_OK) { 1158 1158 skb->ip_summed = CHECKSUM_UNNECESSARY; 1159 1159 BUG_ON(!(gdesc->rcd.tcp || gdesc->rcd.udp)); 1160 - BUG_ON(!(gdesc->rcd.v4 || gdesc->rcd.v6)); 1160 + BUG_ON(gdesc->rcd.frg); 1161 + } else if (gdesc->rcd.v6 && (le32_to_cpu(gdesc->dword[3]) & 1162 + (1 << VMXNET3_RCD_TUC_SHIFT))) { 1163 + skb->ip_summed = CHECKSUM_UNNECESSARY; 1164 + BUG_ON(!(gdesc->rcd.tcp || gdesc->rcd.udp)); 1161 1165 BUG_ON(gdesc->rcd.frg); 1162 1166 } else { 1163 1167 if (gdesc->rcd.csum) {
+2 -2
drivers/net/vmxnet3/vmxnet3_int.h
··· 69 69 /* 70 70 * Version numbers 71 71 */ 72 - #define VMXNET3_DRIVER_VERSION_STRING "1.4.6.0-k" 72 + #define VMXNET3_DRIVER_VERSION_STRING "1.4.7.0-k" 73 73 74 74 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ 75 - #define VMXNET3_DRIVER_VERSION_NUM 0x01040600 75 + #define VMXNET3_DRIVER_VERSION_NUM 0x01040700 76 76 77 77 #if defined(CONFIG_PCI_MSI) 78 78 /* RSS only makes sense if MSI-X is supported. */
+16 -161
drivers/net/vrf.c
··· 60 60 struct u64_stats_sync syncp; 61 61 }; 62 62 63 - static struct dst_entry *vrf_ip_check(struct dst_entry *dst, u32 cookie) 64 - { 65 - return dst; 66 - } 67 - 68 - static int vrf_ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) 69 - { 70 - return ip_local_out(net, sk, skb); 71 - } 72 - 73 - static unsigned int vrf_v4_mtu(const struct dst_entry *dst) 74 - { 75 - /* TO-DO: return max ethernet size? */ 76 - return dst->dev->mtu; 77 - } 78 - 79 - static void vrf_dst_destroy(struct dst_entry *dst) 80 - { 81 - /* our dst lives forever - or until the device is closed */ 82 - } 83 - 84 - static unsigned int vrf_default_advmss(const struct dst_entry *dst) 85 - { 86 - return 65535 - 40; 87 - } 88 - 89 - static struct dst_ops vrf_dst_ops = { 90 - .family = AF_INET, 91 - .local_out = vrf_ip_local_out, 92 - .check = vrf_ip_check, 93 - .mtu = vrf_v4_mtu, 94 - .destroy = vrf_dst_destroy, 95 - .default_advmss = vrf_default_advmss, 96 - }; 97 - 98 63 /* neighbor handling is done with actual device; do not want 99 64 * to flip skb->dev for those ndisc packets. This really fails 100 65 * for multiple next protocols (e.g., NEXTHDR_HOP). But it is ··· 314 349 } 315 350 316 351 #if IS_ENABLED(CONFIG_IPV6) 317 - static struct dst_entry *vrf_ip6_check(struct dst_entry *dst, u32 cookie) 318 - { 319 - return dst; 320 - } 321 - 322 - static struct dst_ops vrf_dst_ops6 = { 323 - .family = AF_INET6, 324 - .local_out = ip6_local_out, 325 - .check = vrf_ip6_check, 326 - .mtu = vrf_v4_mtu, 327 - .destroy = vrf_dst_destroy, 328 - .default_advmss = vrf_default_advmss, 329 - }; 330 - 331 - static int init_dst_ops6_kmem_cachep(void) 332 - { 333 - vrf_dst_ops6.kmem_cachep = kmem_cache_create("vrf_ip6_dst_cache", 334 - sizeof(struct rt6_info), 335 - 0, 336 - SLAB_HWCACHE_ALIGN, 337 - NULL); 338 - 339 - if (!vrf_dst_ops6.kmem_cachep) 340 - return -ENOMEM; 341 - 342 - return 0; 343 - } 344 - 345 - static void free_dst_ops6_kmem_cachep(void) 346 - { 347 - kmem_cache_destroy(vrf_dst_ops6.kmem_cachep); 348 - } 349 - 350 - static int vrf_input6(struct sk_buff *skb) 351 - { 352 - skb->dev->stats.rx_errors++; 353 - kfree_skb(skb); 354 - return 0; 355 - } 356 - 357 352 /* modelled after ip6_finish_output2 */ 358 353 static int vrf_finish_output6(struct net *net, struct sock *sk, 359 354 struct sk_buff *skb) ··· 354 429 !(IP6CB(skb)->flags & IP6SKB_REROUTED)); 355 430 } 356 431 357 - static void vrf_rt6_destroy(struct net_vrf *vrf) 432 + static void vrf_rt6_release(struct net_vrf *vrf) 358 433 { 359 - dst_destroy(&vrf->rt6->dst); 360 - free_percpu(vrf->rt6->rt6i_pcpu); 434 + dst_release(&vrf->rt6->dst); 361 435 vrf->rt6 = NULL; 362 436 } 363 437 364 438 static int vrf_rt6_create(struct net_device *dev) 365 439 { 366 440 struct net_vrf *vrf = netdev_priv(dev); 367 - struct dst_entry *dst; 441 + struct net *net = dev_net(dev); 368 442 struct rt6_info *rt6; 369 - int cpu; 370 443 int rc = -ENOMEM; 371 444 372 - rt6 = dst_alloc(&vrf_dst_ops6, dev, 0, 373 - DST_OBSOLETE_NONE, 374 - (DST_HOST | DST_NOPOLICY | DST_NOXFRM)); 445 + rt6 = ip6_dst_alloc(net, dev, 446 + DST_HOST | DST_NOPOLICY | DST_NOXFRM | DST_NOCACHE); 375 447 if (!rt6) 376 448 goto out; 377 449 378 - dst = &rt6->dst; 379 - 380 - rt6->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, GFP_KERNEL); 381 - if (!rt6->rt6i_pcpu) { 382 - dst_destroy(dst); 383 - goto out; 384 - } 385 - for_each_possible_cpu(cpu) { 386 - struct rt6_info **p = per_cpu_ptr(rt6->rt6i_pcpu, cpu); 387 - *p = NULL; 388 - } 389 - 390 - memset(dst + 1, 0, sizeof(*rt6) - sizeof(*dst)); 391 - 392 - INIT_LIST_HEAD(&rt6->rt6i_siblings); 393 - INIT_LIST_HEAD(&rt6->rt6i_uncached); 394 - 395 - rt6->dst.input = vrf_input6; 396 450 rt6->dst.output = vrf_output6; 397 - 398 - rt6->rt6i_table = fib6_get_table(dev_net(dev), vrf->tb_id); 399 - 400 - atomic_set(&rt6->dst.__refcnt, 2); 401 - 451 + rt6->rt6i_table = fib6_get_table(net, vrf->tb_id); 452 + dst_hold(&rt6->dst); 402 453 vrf->rt6 = rt6; 403 454 rc = 0; 404 455 out: 405 456 return rc; 406 457 } 407 458 #else 408 - static int init_dst_ops6_kmem_cachep(void) 409 - { 410 - return 0; 411 - } 412 - 413 - static void free_dst_ops6_kmem_cachep(void) 414 - { 415 - } 416 - 417 - static void vrf_rt6_destroy(struct net_vrf *vrf) 459 + static void vrf_rt6_release(struct net_vrf *vrf) 418 460 { 419 461 } 420 462 ··· 449 557 !(IPCB(skb)->flags & IPSKB_REROUTED)); 450 558 } 451 559 452 - static void vrf_rtable_destroy(struct net_vrf *vrf) 560 + static void vrf_rtable_release(struct net_vrf *vrf) 453 561 { 454 562 struct dst_entry *dst = (struct dst_entry *)vrf->rth; 455 563 456 - dst_destroy(dst); 564 + dst_release(dst); 457 565 vrf->rth = NULL; 458 566 } 459 567 ··· 462 570 struct net_vrf *vrf = netdev_priv(dev); 463 571 struct rtable *rth; 464 572 465 - rth = dst_alloc(&vrf_dst_ops, dev, 2, 466 - DST_OBSOLETE_NONE, 467 - (DST_HOST | DST_NOPOLICY | DST_NOXFRM)); 573 + rth = rt_dst_alloc(dev, 0, RTN_UNICAST, 1, 1, 0); 468 574 if (rth) { 469 575 rth->dst.output = vrf_output; 470 - rth->rt_genid = rt_genid_ipv4(dev_net(dev)); 471 - rth->rt_flags = 0; 472 - rth->rt_type = RTN_UNICAST; 473 - rth->rt_is_input = 0; 474 - rth->rt_iif = 0; 475 - rth->rt_pmtu = 0; 476 - rth->rt_gateway = 0; 477 - rth->rt_uses_gateway = 0; 478 576 rth->rt_table_id = vrf->tb_id; 479 - INIT_LIST_HEAD(&rth->rt_uncached); 480 - rth->rt_uncached_list = NULL; 481 577 } 482 578 483 579 return rth; ··· 553 673 struct net_device *port_dev; 554 674 struct list_head *iter; 555 675 556 - vrf_rtable_destroy(vrf); 557 - vrf_rt6_destroy(vrf); 676 + vrf_rtable_release(vrf); 677 + vrf_rt6_release(vrf); 558 678 559 679 netdev_for_each_lower_dev(dev, port_dev, iter) 560 680 vrf_del_slave(dev, port_dev); ··· 584 704 return 0; 585 705 586 706 out_rth: 587 - vrf_rtable_destroy(vrf); 707 + vrf_rtable_release(vrf); 588 708 out_stats: 589 709 free_percpu(dev->dstats); 590 710 dev->dstats = NULL; ··· 617 737 struct net_vrf *vrf = netdev_priv(dev); 618 738 619 739 rth = vrf->rth; 620 - atomic_inc(&rth->dst.__refcnt); 740 + dst_hold(&rth->dst); 621 741 } 622 742 623 743 return rth; ··· 668 788 struct net_vrf *vrf = netdev_priv(dev); 669 789 670 790 rt = vrf->rt6; 671 - atomic_inc(&rt->dst.__refcnt); 791 + dst_hold(&rt->dst); 672 792 } 673 793 674 794 return (struct dst_entry *)rt; ··· 826 946 { 827 947 int rc; 828 948 829 - vrf_dst_ops.kmem_cachep = 830 - kmem_cache_create("vrf_ip_dst_cache", 831 - sizeof(struct rtable), 0, 832 - SLAB_HWCACHE_ALIGN, 833 - NULL); 834 - 835 - if (!vrf_dst_ops.kmem_cachep) 836 - return -ENOMEM; 837 - 838 - rc = init_dst_ops6_kmem_cachep(); 839 - if (rc != 0) 840 - goto error2; 841 - 842 949 register_netdevice_notifier(&vrf_notifier_block); 843 950 844 951 rc = rtnl_link_register(&vrf_link_ops); ··· 836 969 837 970 error: 838 971 unregister_netdevice_notifier(&vrf_notifier_block); 839 - free_dst_ops6_kmem_cachep(); 840 - error2: 841 - kmem_cache_destroy(vrf_dst_ops.kmem_cachep); 842 972 return rc; 843 973 } 844 974 845 - static void __exit vrf_cleanup_module(void) 846 - { 847 - rtnl_link_unregister(&vrf_link_ops); 848 - unregister_netdevice_notifier(&vrf_notifier_block); 849 - kmem_cache_destroy(vrf_dst_ops.kmem_cachep); 850 - free_dst_ops6_kmem_cachep(); 851 - } 852 - 853 975 module_init(vrf_init_module); 854 - module_exit(vrf_cleanup_module); 855 976 MODULE_AUTHOR("Shrijeet Mukherjee, David Ahern"); 856 977 MODULE_DESCRIPTION("Device driver to instantiate VRF domains"); 857 978 MODULE_LICENSE("GPL");
+4 -2
drivers/net/wireless/broadcom/b43/main.c
··· 5680 5680 INIT_WORK(&wl->firmware_load, b43_request_firmware); 5681 5681 schedule_work(&wl->firmware_load); 5682 5682 5683 - bcma_out: 5684 5683 return err; 5685 5684 5686 5685 bcma_err_wireless_exit: 5687 5686 ieee80211_free_hw(wl->hw); 5687 + bcma_out: 5688 + kfree(dev); 5688 5689 return err; 5689 5690 } 5690 5691 ··· 5713 5712 b43_rng_exit(wl); 5714 5713 5715 5714 b43_leds_unregister(wl); 5716 - 5717 5715 ieee80211_free_hw(wl->hw); 5716 + kfree(wldev->dev); 5718 5717 } 5719 5718 5720 5719 static struct bcma_driver b43_bcma_driver = { ··· 5797 5796 5798 5797 b43_leds_unregister(wl); 5799 5798 b43_wireless_exit(dev, wl); 5799 + kfree(dev); 5800 5800 } 5801 5801 5802 5802 static struct ssb_driver b43_ssb_driver = {
+2
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
··· 1147 1147 /* the fw is stopped, the aux sta is dead: clean up driver state */ 1148 1148 iwl_mvm_del_aux_sta(mvm); 1149 1149 1150 + iwl_free_fw_paging(mvm); 1151 + 1150 1152 /* 1151 1153 * Clear IN_HW_RESTART flag when stopping the hw (as restart_complete() 1152 1154 * won't be called in this case).
-2
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
··· 761 761 for (i = 0; i < NVM_MAX_NUM_SECTIONS; i++) 762 762 kfree(mvm->nvm_sections[i].data); 763 763 764 - iwl_free_fw_paging(mvm); 765 - 766 764 iwl_mvm_tof_clean(mvm); 767 765 768 766 ieee80211_free_hw(mvm->hw);
+2 -2
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
··· 732 732 */ 733 733 val = iwl_read_prph(trans, PREG_AUX_BUS_WPROT_0); 734 734 if (val & (BIT(1) | BIT(17))) { 735 - IWL_INFO(trans, 736 - "can't access the RSA semaphore it is write protected\n"); 735 + IWL_DEBUG_INFO(trans, 736 + "can't access the RSA semaphore it is write protected\n"); 737 737 return 0; 738 738 } 739 739
+3 -3
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c
··· 2488 2488 for (p = RF90_PATH_A; p < MAX_PATH_NUM_8821A; p++) 2489 2489 rtldm->swing_idx_ofdm_base[p] = rtldm->swing_idx_ofdm[p]; 2490 2490 2491 - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 2492 - "pDM_Odm->RFCalibrateInfo.ThermalValue = %d ThermalValue= %d\n", 2493 - rtldm->thermalvalue, thermal_value); 2491 + RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 2492 + "pDM_Odm->RFCalibrateInfo.ThermalValue = %d ThermalValue= %d\n", 2493 + rtldm->thermalvalue, thermal_value); 2494 2494 /*Record last Power Tracking Thermal Value*/ 2495 2495 rtldm->thermalvalue = thermal_value; 2496 2496 }
+7
include/linux/mlx4/device.h
··· 828 828 u8 n_ports; 829 829 }; 830 830 831 + enum mlx4_pci_status { 832 + MLX4_PCI_STATUS_DISABLED, 833 + MLX4_PCI_STATUS_ENABLED, 834 + }; 835 + 831 836 struct mlx4_dev_persistent { 832 837 struct pci_dev *pdev; 833 838 struct mlx4_dev *dev; ··· 846 841 u8 state; 847 842 struct mutex interface_state_mutex; /* protect SW state */ 848 843 u8 interface_state; 844 + struct mutex pci_status_mutex; /* sync pci state */ 845 + enum mlx4_pci_status pci_status; 849 846 }; 850 847 851 848 struct mlx4_dev {
+39
include/linux/rculist_nulls.h
··· 98 98 if (!is_a_nulls(first)) 99 99 first->pprev = &n->next; 100 100 } 101 + 102 + /** 103 + * hlist_nulls_add_tail_rcu 104 + * @n: the element to add to the hash list. 105 + * @h: the list to add to. 106 + * 107 + * Description: 108 + * Adds the specified element to the end of the specified hlist_nulls, 109 + * while permitting racing traversals. NOTE: tail insertion requires 110 + * list traversal. 111 + * 112 + * The caller must take whatever precautions are necessary 113 + * (such as holding appropriate locks) to avoid racing 114 + * with another list-mutation primitive, such as hlist_nulls_add_head_rcu() 115 + * or hlist_nulls_del_rcu(), running on this same list. 116 + * However, it is perfectly legal to run concurrently with 117 + * the _rcu list-traversal primitives, such as 118 + * hlist_nulls_for_each_entry_rcu(), used to prevent memory-consistency 119 + * problems on Alpha CPUs. Regardless of the type of CPU, the 120 + * list-traversal primitive must be guarded by rcu_read_lock(). 121 + */ 122 + static inline void hlist_nulls_add_tail_rcu(struct hlist_nulls_node *n, 123 + struct hlist_nulls_head *h) 124 + { 125 + struct hlist_nulls_node *i, *last = NULL; 126 + 127 + for (i = hlist_nulls_first_rcu(h); !is_a_nulls(i); 128 + i = hlist_nulls_next_rcu(i)) 129 + last = i; 130 + 131 + if (last) { 132 + n->next = last->next; 133 + n->pprev = &last->next; 134 + rcu_assign_pointer(hlist_nulls_next_rcu(last), n); 135 + } else { 136 + hlist_nulls_add_head_rcu(n, h); 137 + } 138 + } 139 + 101 140 /** 102 141 * hlist_nulls_for_each_entry_rcu - iterate over rcu list of given type 103 142 * @tpos: the type * to use as a loop cursor.
+5 -2
include/net/cls_cgroup.h
··· 17 17 #include <linux/hardirq.h> 18 18 #include <linux/rcupdate.h> 19 19 #include <net/sock.h> 20 + #include <net/inet_sock.h> 20 21 21 22 #ifdef CONFIG_CGROUP_NET_CLASSID 22 23 struct cgroup_cls_state { ··· 64 63 * softirqs always disables bh. 65 64 */ 66 65 if (in_serving_softirq()) { 66 + struct sock *sk = skb_to_full_sk(skb); 67 + 67 68 /* If there is an sock_cgroup_classid we'll use that. */ 68 - if (!skb->sk) 69 + if (!sk || !sk_fullsock(sk)) 69 70 return 0; 70 71 71 - classid = sock_cgroup_classid(&skb->sk->sk_cgrp_data); 72 + classid = sock_cgroup_classid(&sk->sk_cgrp_data); 72 73 } 73 74 74 75 return classid;
+3
include/net/ip6_route.h
··· 101 101 struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, 102 102 const struct in6_addr *addr, bool anycast); 103 103 104 + struct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev, 105 + int flags); 106 + 104 107 /* 105 108 * support functions for ND 106 109 *
+2
include/net/ipv6.h
··· 959 959 int ip6_datagram_connect(struct sock *sk, struct sockaddr *addr, int addr_len); 960 960 int ip6_datagram_connect_v6_only(struct sock *sk, struct sockaddr *addr, 961 961 int addr_len); 962 + int ip6_datagram_dst_update(struct sock *sk, bool fix_sk_saddr); 963 + void ip6_datagram_release_cb(struct sock *sk); 962 964 963 965 int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, 964 966 int *addr_len);
+3
include/net/route.h
··· 209 209 void ip_rt_multicast_event(struct in_device *); 210 210 int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); 211 211 void ip_rt_get_source(u8 *src, struct sk_buff *skb, struct rtable *rt); 212 + struct rtable *rt_dst_alloc(struct net_device *dev, 213 + unsigned int flags, u16 type, 214 + bool nopolicy, bool noxfrm, bool will_cache); 212 215 213 216 struct in_ifaddr; 214 217 void fib_add_ifaddr(struct in_ifaddr *);
+7 -1
include/net/sctp/structs.h
··· 847 847 */ 848 848 ktime_t last_time_heard; 849 849 850 + /* When was the last time that we sent a chunk using this 851 + * transport? We use this to check for idle transports 852 + */ 853 + unsigned long last_time_sent; 854 + 850 855 /* Last time(in jiffies) when cwnd is reduced due to the congestion 851 856 * indication based on ECNE chunk. 852 857 */ ··· 957 952 struct sctp_sock *); 958 953 void sctp_transport_pmtu(struct sctp_transport *, struct sock *sk); 959 954 void sctp_transport_free(struct sctp_transport *); 960 - void sctp_transport_reset_timers(struct sctp_transport *); 955 + void sctp_transport_reset_t3_rtx(struct sctp_transport *); 956 + void sctp_transport_reset_hb_timer(struct sctp_transport *); 961 957 int sctp_transport_hold(struct sctp_transport *); 962 958 void sctp_transport_put(struct sctp_transport *); 963 959 void sctp_transport_update_rto(struct sctp_transport *, __u32);
+5 -1
include/net/sock.h
··· 630 630 631 631 static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) 632 632 { 633 - hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); 633 + if (IS_ENABLED(CONFIG_IPV6) && sk->sk_reuseport && 634 + sk->sk_family == AF_INET6) 635 + hlist_nulls_add_tail_rcu(&sk->sk_nulls_node, list); 636 + else 637 + hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); 634 638 } 635 639 636 640 static inline void sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
+2
include/net/tcp.h
··· 552 552 void tcp_send_delayed_ack(struct sock *sk); 553 553 void tcp_send_loss_probe(struct sock *sk); 554 554 bool tcp_schedule_loss_probe(struct sock *sk); 555 + void tcp_skb_collapse_tstamp(struct sk_buff *skb, 556 + const struct sk_buff *next_skb); 555 557 556 558 /* tcp_input.c */ 557 559 void tcp_resume_early_retransmit(struct sock *sk);
+1
include/uapi/linux/Kbuild
··· 96 96 header-y += cycx_cfm.h 97 97 header-y += dcbnl.h 98 98 header-y += dccp.h 99 + header-y += devlink.h 99 100 header-y += dlmconstants.h 100 101 header-y += dlm_device.h 101 102 header-y += dlm.h
+1
kernel/bpf/verifier.c
··· 1374 1374 } 1375 1375 1376 1376 if (insn->dst_reg != BPF_REG_0 || insn->off != 0 || 1377 + BPF_SIZE(insn->code) == BPF_DW || 1377 1378 (mode == BPF_ABS && insn->src_reg != BPF_REG_0)) { 1378 1379 verbose("BPF_LD_ABS uses reserved fields\n"); 1379 1380 return -EINVAL;
+5 -1
net/bridge/netfilter/ebtables.c
··· 370 370 left - sizeof(struct ebt_entry_match) < m->match_size) 371 371 return -EINVAL; 372 372 373 - match = xt_request_find_match(NFPROTO_BRIDGE, m->u.name, 0); 373 + match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0); 374 + if (IS_ERR(match) || match->family != NFPROTO_BRIDGE) { 375 + request_module("ebt_%s", m->u.name); 376 + match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0); 377 + } 374 378 if (IS_ERR(match)) 375 379 return PTR_ERR(match); 376 380 m->u.match = match;
+5 -2
net/core/skbuff.c
··· 4502 4502 __skb_push(skb, offset); 4503 4503 err = __vlan_insert_tag(skb, skb->vlan_proto, 4504 4504 skb_vlan_tag_get(skb)); 4505 - if (err) 4505 + if (err) { 4506 + __skb_pull(skb, offset); 4506 4507 return err; 4508 + } 4509 + 4507 4510 skb->protocol = skb->vlan_proto; 4508 4511 skb->mac_len += VLAN_HLEN; 4509 - __skb_pull(skb, offset); 4510 4512 4511 4513 skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN); 4514 + __skb_pull(skb, offset); 4512 4515 } 4513 4516 __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci); 4514 4517 return 0;
+8 -1
net/decnet/dn_route.c
··· 1034 1034 if (!fld.daddr) { 1035 1035 fld.daddr = fld.saddr; 1036 1036 1037 - err = -EADDRNOTAVAIL; 1038 1037 if (dev_out) 1039 1038 dev_put(dev_out); 1039 + err = -EINVAL; 1040 1040 dev_out = init_net.loopback_dev; 1041 + if (!dev_out->dn_ptr) 1042 + goto out; 1043 + err = -EADDRNOTAVAIL; 1041 1044 dev_hold(dev_out); 1042 1045 if (!fld.daddr) { 1043 1046 fld.daddr = ··· 1113 1110 if (dev_out == NULL) 1114 1111 goto out; 1115 1112 dn_db = rcu_dereference_raw(dev_out->dn_ptr); 1113 + if (!dn_db) 1114 + goto e_inval; 1116 1115 /* Possible improvement - check all devices for local addr */ 1117 1116 if (dn_dev_islocal(dev_out, fld.daddr)) { 1118 1117 dev_put(dev_out); ··· 1156 1151 dev_put(dev_out); 1157 1152 dev_out = init_net.loopback_dev; 1158 1153 dev_hold(dev_out); 1154 + if (!dev_out->dn_ptr) 1155 + goto e_inval; 1159 1156 fld.flowidn_oif = dev_out->ifindex; 1160 1157 if (res.fi) 1161 1158 dn_fib_info_put(res.fi);
+6
net/ipv4/netfilter/arptable_filter.c
··· 81 81 return ret; 82 82 } 83 83 84 + ret = arptable_filter_table_init(&init_net); 85 + if (ret) { 86 + unregister_pernet_subsys(&arptable_filter_net_ops); 87 + kfree(arpfilter_ops); 88 + } 89 + 84 90 return ret; 85 91 } 86 92
+16 -3
net/ipv4/route.c
··· 1438 1438 #endif 1439 1439 } 1440 1440 1441 - static struct rtable *rt_dst_alloc(struct net_device *dev, 1442 - unsigned int flags, u16 type, 1443 - bool nopolicy, bool noxfrm, bool will_cache) 1441 + struct rtable *rt_dst_alloc(struct net_device *dev, 1442 + unsigned int flags, u16 type, 1443 + bool nopolicy, bool noxfrm, bool will_cache) 1444 1444 { 1445 1445 struct rtable *rt; 1446 1446 ··· 1468 1468 1469 1469 return rt; 1470 1470 } 1471 + EXPORT_SYMBOL(rt_dst_alloc); 1471 1472 1472 1473 /* called in rcu_read_lock() section */ 1473 1474 static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, ··· 2046 2045 */ 2047 2046 if (fi && res->prefixlen < 4) 2048 2047 fi = NULL; 2048 + } else if ((type == RTN_LOCAL) && (orig_oif != 0) && 2049 + (orig_oif != dev_out->ifindex)) { 2050 + /* For local routes that require a particular output interface 2051 + * we do not want to cache the result. Caching the result 2052 + * causes incorrect behaviour when there are multiple source 2053 + * addresses on the interface, the end result being that if the 2054 + * intended recipient is waiting on that interface for the 2055 + * packet he won't receive it because it will be delivered on 2056 + * the loopback interface and the IP_PKTINFO ipi_ifindex will 2057 + * be set to the loopback interface as well. 2058 + */ 2059 + fi = NULL; 2049 2060 } 2050 2061 2051 2062 fnhe = NULL;
+3 -1
net/ipv4/tcp_input.c
··· 1309 1309 if (skb == tcp_highest_sack(sk)) 1310 1310 tcp_advance_highest_sack(sk, skb); 1311 1311 1312 + tcp_skb_collapse_tstamp(prev, skb); 1312 1313 tcp_unlink_write_queue(skb, sk); 1313 1314 sk_wmem_free_skb(sk, skb); 1314 1315 ··· 3099 3098 3100 3099 shinfo = skb_shinfo(skb); 3101 3100 if ((shinfo->tx_flags & SKBTX_ACK_TSTAMP) && 3102 - between(shinfo->tskey, prior_snd_una, tcp_sk(sk)->snd_una - 1)) 3101 + !before(shinfo->tskey, prior_snd_una) && 3102 + before(shinfo->tskey, tcp_sk(sk)->snd_una)) 3103 3103 __skb_tstamp_tx(skb, NULL, sk, SCM_TSTAMP_ACK); 3104 3104 } 3105 3105
+16
net/ipv4/tcp_output.c
··· 2441 2441 return window; 2442 2442 } 2443 2443 2444 + void tcp_skb_collapse_tstamp(struct sk_buff *skb, 2445 + const struct sk_buff *next_skb) 2446 + { 2447 + const struct skb_shared_info *next_shinfo = skb_shinfo(next_skb); 2448 + u8 tsflags = next_shinfo->tx_flags & SKBTX_ANY_TSTAMP; 2449 + 2450 + if (unlikely(tsflags)) { 2451 + struct skb_shared_info *shinfo = skb_shinfo(skb); 2452 + 2453 + shinfo->tx_flags |= tsflags; 2454 + shinfo->tskey = next_shinfo->tskey; 2455 + } 2456 + } 2457 + 2444 2458 /* Collapses two adjacent SKB's during retransmission. */ 2445 2459 static void tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb) 2446 2460 { ··· 2497 2483 tp->retransmit_skb_hint = skb; 2498 2484 2499 2485 tcp_adjust_pcount(sk, next_skb, tcp_skb_pcount(next_skb)); 2486 + 2487 + tcp_skb_collapse_tstamp(skb, next_skb); 2500 2488 2501 2489 sk_wmem_free_skb(sk, next_skb); 2502 2490 }
+7 -2
net/ipv4/udp.c
··· 339 339 340 340 hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash); 341 341 spin_lock(&hslot2->lock); 342 - hlist_nulls_add_head_rcu(&udp_sk(sk)->udp_portaddr_node, 343 - &hslot2->head); 342 + if (IS_ENABLED(CONFIG_IPV6) && sk->sk_reuseport && 343 + sk->sk_family == AF_INET6) 344 + hlist_nulls_add_tail_rcu(&udp_sk(sk)->udp_portaddr_node, 345 + &hslot2->head); 346 + else 347 + hlist_nulls_add_head_rcu(&udp_sk(sk)->udp_portaddr_node, 348 + &hslot2->head); 344 349 hslot2->count++; 345 350 spin_unlock(&hslot2->lock); 346 351 }
+20 -2
net/ipv6/addrconf.c
··· 3255 3255 void *ptr) 3256 3256 { 3257 3257 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 3258 + struct netdev_notifier_changeupper_info *info; 3258 3259 struct inet6_dev *idev = __in6_dev_get(dev); 3259 3260 int run_pending = 0; 3260 3261 int err; ··· 3414 3413 if (idev) 3415 3414 addrconf_type_change(dev, event); 3416 3415 break; 3416 + 3417 + case NETDEV_CHANGEUPPER: 3418 + info = ptr; 3419 + 3420 + /* flush all routes if dev is linked to or unlinked from 3421 + * an L3 master device (e.g., VRF) 3422 + */ 3423 + if (info->upper_dev && netif_is_l3_master(info->upper_dev)) 3424 + addrconf_ifdown(dev, 0); 3417 3425 } 3418 3426 3419 3427 return NOTIFY_OK; ··· 3446 3436 ipv6_mc_remap(idev); 3447 3437 else if (event == NETDEV_PRE_TYPE_CHANGE) 3448 3438 ipv6_mc_unmap(idev); 3439 + } 3440 + 3441 + static bool addr_is_local(const struct in6_addr *addr) 3442 + { 3443 + return ipv6_addr_type(addr) & 3444 + (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); 3449 3445 } 3450 3446 3451 3447 static int addrconf_ifdown(struct net_device *dev, int how) ··· 3511 3495 * address is retained on a down event 3512 3496 */ 3513 3497 if (!keep_addr || 3514 - !(ifa->flags & IFA_F_PERMANENT)) { 3498 + !(ifa->flags & IFA_F_PERMANENT) || 3499 + addr_is_local(&ifa->addr)) { 3515 3500 hlist_del_init_rcu(&ifa->addr_lst); 3516 3501 goto restart; 3517 3502 } ··· 3561 3544 write_unlock_bh(&idev->lock); 3562 3545 spin_lock_bh(&ifa->lock); 3563 3546 3564 - if (keep_addr && (ifa->flags & IFA_F_PERMANENT)) { 3547 + if (keep_addr && (ifa->flags & IFA_F_PERMANENT) && 3548 + !addr_is_local(&ifa->addr)) { 3565 3549 /* set state to skip the notifier below */ 3566 3550 state = INET6_IFADDR_STATE_DEAD; 3567 3551 ifa->state = 0;
+106 -63
net/ipv6/datagram.c
··· 40 40 return ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0); 41 41 } 42 42 43 + static void ip6_datagram_flow_key_init(struct flowi6 *fl6, struct sock *sk) 44 + { 45 + struct inet_sock *inet = inet_sk(sk); 46 + struct ipv6_pinfo *np = inet6_sk(sk); 47 + 48 + memset(fl6, 0, sizeof(*fl6)); 49 + fl6->flowi6_proto = sk->sk_protocol; 50 + fl6->daddr = sk->sk_v6_daddr; 51 + fl6->saddr = np->saddr; 52 + fl6->flowi6_oif = sk->sk_bound_dev_if; 53 + fl6->flowi6_mark = sk->sk_mark; 54 + fl6->fl6_dport = inet->inet_dport; 55 + fl6->fl6_sport = inet->inet_sport; 56 + fl6->flowlabel = np->flow_label; 57 + 58 + if (!fl6->flowi6_oif) 59 + fl6->flowi6_oif = np->sticky_pktinfo.ipi6_ifindex; 60 + 61 + if (!fl6->flowi6_oif && ipv6_addr_is_multicast(&fl6->daddr)) 62 + fl6->flowi6_oif = np->mcast_oif; 63 + 64 + security_sk_classify_flow(sk, flowi6_to_flowi(fl6)); 65 + } 66 + 67 + int ip6_datagram_dst_update(struct sock *sk, bool fix_sk_saddr) 68 + { 69 + struct ip6_flowlabel *flowlabel = NULL; 70 + struct in6_addr *final_p, final; 71 + struct ipv6_txoptions *opt; 72 + struct dst_entry *dst; 73 + struct inet_sock *inet = inet_sk(sk); 74 + struct ipv6_pinfo *np = inet6_sk(sk); 75 + struct flowi6 fl6; 76 + int err = 0; 77 + 78 + if (np->sndflow && (np->flow_label & IPV6_FLOWLABEL_MASK)) { 79 + flowlabel = fl6_sock_lookup(sk, np->flow_label); 80 + if (!flowlabel) 81 + return -EINVAL; 82 + } 83 + ip6_datagram_flow_key_init(&fl6, sk); 84 + 85 + rcu_read_lock(); 86 + opt = flowlabel ? flowlabel->opt : rcu_dereference(np->opt); 87 + final_p = fl6_update_dst(&fl6, opt, &final); 88 + rcu_read_unlock(); 89 + 90 + dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 91 + if (IS_ERR(dst)) { 92 + err = PTR_ERR(dst); 93 + goto out; 94 + } 95 + 96 + if (fix_sk_saddr) { 97 + if (ipv6_addr_any(&np->saddr)) 98 + np->saddr = fl6.saddr; 99 + 100 + if (ipv6_addr_any(&sk->sk_v6_rcv_saddr)) { 101 + sk->sk_v6_rcv_saddr = fl6.saddr; 102 + inet->inet_rcv_saddr = LOOPBACK4_IPV6; 103 + if (sk->sk_prot->rehash) 104 + sk->sk_prot->rehash(sk); 105 + } 106 + } 107 + 108 + ip6_dst_store(sk, dst, 109 + ipv6_addr_equal(&fl6.daddr, &sk->sk_v6_daddr) ? 110 + &sk->sk_v6_daddr : NULL, 111 + #ifdef CONFIG_IPV6_SUBTREES 112 + ipv6_addr_equal(&fl6.saddr, &np->saddr) ? 113 + &np->saddr : 114 + #endif 115 + NULL); 116 + 117 + out: 118 + fl6_sock_release(flowlabel); 119 + return err; 120 + } 121 + 122 + void ip6_datagram_release_cb(struct sock *sk) 123 + { 124 + struct dst_entry *dst; 125 + 126 + if (ipv6_addr_v4mapped(&sk->sk_v6_daddr)) 127 + return; 128 + 129 + rcu_read_lock(); 130 + dst = __sk_dst_get(sk); 131 + if (!dst || !dst->obsolete || 132 + dst->ops->check(dst, inet6_sk(sk)->dst_cookie)) { 133 + rcu_read_unlock(); 134 + return; 135 + } 136 + rcu_read_unlock(); 137 + 138 + ip6_datagram_dst_update(sk, false); 139 + } 140 + EXPORT_SYMBOL_GPL(ip6_datagram_release_cb); 141 + 43 142 static int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) 44 143 { 45 144 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; 46 145 struct inet_sock *inet = inet_sk(sk); 47 146 struct ipv6_pinfo *np = inet6_sk(sk); 48 - struct in6_addr *daddr, *final_p, final; 49 - struct dst_entry *dst; 50 - struct flowi6 fl6; 51 - struct ip6_flowlabel *flowlabel = NULL; 52 - struct ipv6_txoptions *opt; 147 + struct in6_addr *daddr; 53 148 int addr_type; 54 149 int err; 150 + __be32 fl6_flowlabel = 0; 55 151 56 152 if (usin->sin6_family == AF_INET) { 57 153 if (__ipv6_only_sock(sk)) ··· 162 66 if (usin->sin6_family != AF_INET6) 163 67 return -EAFNOSUPPORT; 164 68 165 - memset(&fl6, 0, sizeof(fl6)); 166 - if (np->sndflow) { 167 - fl6.flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK; 168 - if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) { 169 - flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 170 - if (!flowlabel) 171 - return -EINVAL; 172 - } 173 - } 69 + if (np->sndflow) 70 + fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK; 174 71 175 72 addr_type = ipv6_addr_type(&usin->sin6_addr); 176 73 ··· 234 145 } 235 146 236 147 sk->sk_v6_daddr = *daddr; 237 - np->flow_label = fl6.flowlabel; 148 + np->flow_label = fl6_flowlabel; 238 149 239 150 inet->inet_dport = usin->sin6_port; 240 151 ··· 243 154 * destination cache for it. 244 155 */ 245 156 246 - fl6.flowi6_proto = sk->sk_protocol; 247 - fl6.daddr = sk->sk_v6_daddr; 248 - fl6.saddr = np->saddr; 249 - fl6.flowi6_oif = sk->sk_bound_dev_if; 250 - fl6.flowi6_mark = sk->sk_mark; 251 - fl6.fl6_dport = inet->inet_dport; 252 - fl6.fl6_sport = inet->inet_sport; 253 - 254 - if (!fl6.flowi6_oif) 255 - fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex; 256 - 257 - if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST)) 258 - fl6.flowi6_oif = np->mcast_oif; 259 - 260 - security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 261 - 262 - rcu_read_lock(); 263 - opt = flowlabel ? flowlabel->opt : rcu_dereference(np->opt); 264 - final_p = fl6_update_dst(&fl6, opt, &final); 265 - rcu_read_unlock(); 266 - 267 - dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 268 - err = 0; 269 - if (IS_ERR(dst)) { 270 - err = PTR_ERR(dst); 157 + err = ip6_datagram_dst_update(sk, true); 158 + if (err) 271 159 goto out; 272 - } 273 - 274 - /* source address lookup done in ip6_dst_lookup */ 275 - 276 - if (ipv6_addr_any(&np->saddr)) 277 - np->saddr = fl6.saddr; 278 - 279 - if (ipv6_addr_any(&sk->sk_v6_rcv_saddr)) { 280 - sk->sk_v6_rcv_saddr = fl6.saddr; 281 - inet->inet_rcv_saddr = LOOPBACK4_IPV6; 282 - if (sk->sk_prot->rehash) 283 - sk->sk_prot->rehash(sk); 284 - } 285 - 286 - ip6_dst_store(sk, dst, 287 - ipv6_addr_equal(&fl6.daddr, &sk->sk_v6_daddr) ? 288 - &sk->sk_v6_daddr : NULL, 289 - #ifdef CONFIG_IPV6_SUBTREES 290 - ipv6_addr_equal(&fl6.saddr, &np->saddr) ? 291 - &np->saddr : 292 - #endif 293 - NULL); 294 160 295 161 sk->sk_state = TCP_ESTABLISHED; 296 162 sk_set_txhash(sk); 297 163 out: 298 - fl6_sock_release(flowlabel); 299 164 return err; 300 165 } 301 166
+16 -3
net/ipv6/route.c
··· 338 338 return rt; 339 339 } 340 340 341 - static struct rt6_info *ip6_dst_alloc(struct net *net, 342 - struct net_device *dev, 343 - int flags) 341 + struct rt6_info *ip6_dst_alloc(struct net *net, 342 + struct net_device *dev, 343 + int flags) 344 344 { 345 345 struct rt6_info *rt = __ip6_dst_alloc(net, dev, flags); 346 346 ··· 364 364 365 365 return rt; 366 366 } 367 + EXPORT_SYMBOL(ip6_dst_alloc); 367 368 368 369 static void ip6_dst_destroy(struct dst_entry *dst) 369 370 { ··· 1418 1417 1419 1418 void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu) 1420 1419 { 1420 + struct dst_entry *dst; 1421 + 1421 1422 ip6_update_pmtu(skb, sock_net(sk), mtu, 1422 1423 sk->sk_bound_dev_if, sk->sk_mark); 1424 + 1425 + dst = __sk_dst_get(sk); 1426 + if (!dst || !dst->obsolete || 1427 + dst->ops->check(dst, inet6_sk(sk)->dst_cookie)) 1428 + return; 1429 + 1430 + bh_lock_sock(sk); 1431 + if (!sock_owned_by_user(sk) && !ipv6_addr_v4mapped(&sk->sk_v6_daddr)) 1432 + ip6_datagram_dst_update(sk, false); 1433 + bh_unlock_sock(sk); 1423 1434 } 1424 1435 EXPORT_SYMBOL_GPL(ip6_sk_update_pmtu); 1425 1436
+1
net/ipv6/udp.c
··· 1539 1539 .sendmsg = udpv6_sendmsg, 1540 1540 .recvmsg = udpv6_recvmsg, 1541 1541 .backlog_rcv = __udpv6_queue_rcv_skb, 1542 + .release_cb = ip6_datagram_release_cb, 1542 1543 .hash = udp_lib_hash, 1543 1544 .unhash = udp_lib_unhash, 1544 1545 .rehash = udp_v6_rehash,
+4
net/netfilter/nf_conntrack_proto_tcp.c
··· 410 410 length--; 411 411 continue; 412 412 default: 413 + if (length < 2) 414 + return; 413 415 opsize=*ptr++; 414 416 if (opsize < 2) /* "silly options" */ 415 417 return; ··· 472 470 length--; 473 471 continue; 474 472 default: 473 + if (length < 2) 474 + return; 475 475 opsize = *ptr++; 476 476 if (opsize < 2) /* "silly options" */ 477 477 return;
+1 -1
net/netlink/af_netlink.c
··· 688 688 689 689 skb_queue_purge(&sk->sk_write_queue); 690 690 691 - if (nlk->portid) { 691 + if (nlk->portid && nlk->bound) { 692 692 struct netlink_notify n = { 693 693 .net = sock_net(sk), 694 694 .protocol = sk->sk_protocol,
+2 -2
net/openvswitch/actions.c
··· 461 461 mask_ipv6_addr(saddr, key->ipv6_src, mask->ipv6_src, masked); 462 462 463 463 if (unlikely(memcmp(saddr, masked, sizeof(masked)))) { 464 - set_ipv6_addr(skb, key->ipv6_proto, saddr, masked, 464 + set_ipv6_addr(skb, flow_key->ip.proto, saddr, masked, 465 465 true); 466 466 memcpy(&flow_key->ipv6.addr.src, masked, 467 467 sizeof(flow_key->ipv6.addr.src)); ··· 483 483 NULL, &flags) 484 484 != NEXTHDR_ROUTING); 485 485 486 - set_ipv6_addr(skb, key->ipv6_proto, daddr, masked, 486 + set_ipv6_addr(skb, flow_key->ip.proto, daddr, masked, 487 487 recalc_csum); 488 488 memcpy(&flow_key->ipv6.addr.dst, masked, 489 489 sizeof(flow_key->ipv6.addr.dst));
+1
net/openvswitch/conntrack.c
··· 367 367 } else if (key->eth.type == htons(ETH_P_IPV6)) { 368 368 enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone; 369 369 370 + skb_orphan(skb); 370 371 memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm)); 371 372 err = nf_ct_frag6_gather(net, skb, user); 372 373 if (err)
+1
net/packet/af_packet.c
··· 3521 3521 i->ifindex = mreq->mr_ifindex; 3522 3522 i->alen = mreq->mr_alen; 3523 3523 memcpy(i->addr, mreq->mr_address, i->alen); 3524 + memset(i->addr + i->alen, 0, sizeof(i->addr) - i->alen); 3524 3525 i->count = 1; 3525 3526 i->next = po->mclist; 3526 3527 po->mclist = i;
+2 -2
net/rds/cong.c
··· 299 299 i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS; 300 300 off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS; 301 301 302 - __set_bit_le(off, (void *)map->m_page_addrs[i]); 302 + set_bit_le(off, (void *)map->m_page_addrs[i]); 303 303 } 304 304 305 305 void rds_cong_clear_bit(struct rds_cong_map *map, __be16 port) ··· 313 313 i = be16_to_cpu(port) / RDS_CONG_MAP_PAGE_BITS; 314 314 off = be16_to_cpu(port) % RDS_CONG_MAP_PAGE_BITS; 315 315 316 - __clear_bit_le(off, (void *)map->m_page_addrs[i]); 316 + clear_bit_le(off, (void *)map->m_page_addrs[i]); 317 317 } 318 318 319 319 static int rds_cong_test_bit(struct rds_cong_map *map, __be16 port)
+1 -1
net/rds/ib_cm.c
··· 194 194 dp->dp_protocol_major = RDS_PROTOCOL_MAJOR(protocol_version); 195 195 dp->dp_protocol_minor = RDS_PROTOCOL_MINOR(protocol_version); 196 196 dp->dp_protocol_minor_mask = cpu_to_be16(RDS_IB_SUPPORTED_PROTOCOLS); 197 - dp->dp_ack_seq = rds_ib_piggyb_ack(ic); 197 + dp->dp_ack_seq = cpu_to_be64(rds_ib_piggyb_ack(ic)); 198 198 199 199 /* Advertise flow control */ 200 200 if (ic->i_flowctl) {
+4 -1
net/sched/sch_generic.c
··· 159 159 if (validate) 160 160 skb = validate_xmit_skb_list(skb, dev); 161 161 162 - if (skb) { 162 + if (likely(skb)) { 163 163 HARD_TX_LOCK(dev, txq, smp_processor_id()); 164 164 if (!netif_xmit_frozen_or_stopped(txq)) 165 165 skb = dev_hard_start_xmit(skb, dev, txq, &ret); 166 166 167 167 HARD_TX_UNLOCK(dev, txq); 168 + } else { 169 + spin_lock(root_lock); 170 + return qdisc_qlen(q); 168 171 } 169 172 spin_lock(root_lock); 170 173
+10 -5
net/sctp/outqueue.c
··· 866 866 * sender MUST assure that at least one T3-rtx 867 867 * timer is running. 868 868 */ 869 - if (chunk->chunk_hdr->type == SCTP_CID_FWD_TSN) 870 - sctp_transport_reset_timers(transport); 869 + if (chunk->chunk_hdr->type == SCTP_CID_FWD_TSN) { 870 + sctp_transport_reset_t3_rtx(transport); 871 + transport->last_time_sent = jiffies; 872 + } 871 873 } 872 874 break; 873 875 ··· 926 924 error = sctp_outq_flush_rtx(q, packet, 927 925 rtx_timeout, &start_timer); 928 926 929 - if (start_timer) 930 - sctp_transport_reset_timers(transport); 927 + if (start_timer) { 928 + sctp_transport_reset_t3_rtx(transport); 929 + transport->last_time_sent = jiffies; 930 + } 931 931 932 932 /* This can happen on COOKIE-ECHO resend. Only 933 933 * one chunk can get bundled with a COOKIE-ECHO. ··· 1066 1062 list_add_tail(&chunk->transmitted_list, 1067 1063 &transport->transmitted); 1068 1064 1069 - sctp_transport_reset_timers(transport); 1065 + sctp_transport_reset_t3_rtx(transport); 1066 + transport->last_time_sent = jiffies; 1070 1067 1071 1068 /* Only let one DATA chunk get bundled with a 1072 1069 * COOKIE-ECHO chunk.
+1 -2
net/sctp/sm_make_chunk.c
··· 3080 3080 return SCTP_ERROR_RSRC_LOW; 3081 3081 3082 3082 /* Start the heartbeat timer. */ 3083 - if (!mod_timer(&peer->hb_timer, sctp_transport_timeout(peer))) 3084 - sctp_transport_hold(peer); 3083 + sctp_transport_reset_hb_timer(peer); 3085 3084 asoc->new_transport = peer; 3086 3085 break; 3087 3086 case SCTP_PARAM_DEL_IP:
+16 -20
net/sctp/sm_sideeffect.c
··· 69 69 sctp_cmd_seq_t *commands, 70 70 gfp_t gfp); 71 71 72 - static void sctp_cmd_hb_timer_update(sctp_cmd_seq_t *cmds, 73 - struct sctp_transport *t); 74 72 /******************************************************************** 75 73 * Helper functions 76 74 ********************************************************************/ ··· 365 367 struct sctp_association *asoc = transport->asoc; 366 368 struct sock *sk = asoc->base.sk; 367 369 struct net *net = sock_net(sk); 370 + u32 elapsed, timeout; 368 371 369 372 bh_lock_sock(sk); 370 373 if (sock_owned_by_user(sk)) { ··· 373 374 374 375 /* Try again later. */ 375 376 if (!mod_timer(&transport->hb_timer, jiffies + (HZ/20))) 377 + sctp_transport_hold(transport); 378 + goto out_unlock; 379 + } 380 + 381 + /* Check if we should still send the heartbeat or reschedule */ 382 + elapsed = jiffies - transport->last_time_sent; 383 + timeout = sctp_transport_timeout(transport); 384 + if (elapsed < timeout) { 385 + elapsed = timeout - elapsed; 386 + if (!mod_timer(&transport->hb_timer, jiffies + elapsed)) 376 387 sctp_transport_hold(transport); 377 388 goto out_unlock; 378 389 } ··· 516 507 0); 517 508 518 509 /* Update the hb timer to resend a heartbeat every rto */ 519 - sctp_cmd_hb_timer_update(commands, transport); 510 + sctp_transport_reset_hb_timer(transport); 520 511 } 521 512 522 513 if (transport->state != SCTP_INACTIVE && ··· 643 634 * hold a reference on the transport to make sure none of 644 635 * the needed data structures go away. 645 636 */ 646 - list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) { 647 - 648 - if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t))) 649 - sctp_transport_hold(t); 650 - } 637 + list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) 638 + sctp_transport_reset_hb_timer(t); 651 639 } 652 640 653 641 static void sctp_cmd_hb_timers_stop(sctp_cmd_seq_t *cmds, ··· 674 668 } 675 669 } 676 670 677 - 678 - /* Helper function to update the heartbeat timer. */ 679 - static void sctp_cmd_hb_timer_update(sctp_cmd_seq_t *cmds, 680 - struct sctp_transport *t) 681 - { 682 - /* Update the heartbeat timer. */ 683 - if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t))) 684 - sctp_transport_hold(t); 685 - } 686 671 687 672 /* Helper function to handle the reception of an HEARTBEAT ACK. */ 688 673 static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds, ··· 739 742 sctp_transport_update_rto(t, (jiffies - hbinfo->sent_at)); 740 743 741 744 /* Update the heartbeat timer. */ 742 - if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t))) 743 - sctp_transport_hold(t); 745 + sctp_transport_reset_hb_timer(t); 744 746 745 747 if (was_unconfirmed && asoc->peer.transport_count == 1) 746 748 sctp_transport_immediate_rtx(t); ··· 1610 1614 1611 1615 case SCTP_CMD_HB_TIMER_UPDATE: 1612 1616 t = cmd->obj.transport; 1613 - sctp_cmd_hb_timer_update(commands, t); 1617 + sctp_transport_reset_hb_timer(t); 1614 1618 break; 1615 1619 1616 1620 case SCTP_CMD_HB_TIMERS_STOP:
+13 -6
net/sctp/transport.c
··· 183 183 /* Start T3_rtx timer if it is not already running and update the heartbeat 184 184 * timer. This routine is called every time a DATA chunk is sent. 185 185 */ 186 - void sctp_transport_reset_timers(struct sctp_transport *transport) 186 + void sctp_transport_reset_t3_rtx(struct sctp_transport *transport) 187 187 { 188 188 /* RFC 2960 6.3.2 Retransmission Timer Rules 189 189 * ··· 197 197 if (!mod_timer(&transport->T3_rtx_timer, 198 198 jiffies + transport->rto)) 199 199 sctp_transport_hold(transport); 200 + } 201 + 202 + void sctp_transport_reset_hb_timer(struct sctp_transport *transport) 203 + { 204 + unsigned long expires; 200 205 201 206 /* When a data chunk is sent, reset the heartbeat interval. */ 202 - if (!mod_timer(&transport->hb_timer, 203 - sctp_transport_timeout(transport))) 204 - sctp_transport_hold(transport); 207 + expires = jiffies + sctp_transport_timeout(transport); 208 + if (time_before(transport->hb_timer.expires, expires) && 209 + !mod_timer(&transport->hb_timer, 210 + expires + prandom_u32_max(transport->rto))) 211 + sctp_transport_hold(transport); 205 212 } 206 213 207 214 /* This transport has been assigned to an association. ··· 602 595 unsigned long sctp_transport_timeout(struct sctp_transport *trans) 603 596 { 604 597 /* RTO + timer slack +/- 50% of RTO */ 605 - unsigned long timeout = (trans->rto >> 1) + prandom_u32_max(trans->rto); 598 + unsigned long timeout = trans->rto >> 1; 606 599 607 600 if (trans->state != SCTP_UNCONFIRMED && 608 601 trans->state != SCTP_PF) 609 602 timeout += trans->hbinterval; 610 603 611 - return timeout + jiffies; 604 + return timeout; 612 605 } 613 606 614 607 /* Reset transport variables to their initial values */
+1
net/tipc/core.c
··· 69 69 if (err) 70 70 goto out_nametbl; 71 71 72 + INIT_LIST_HEAD(&tn->dist_queue); 72 73 err = tipc_topsrv_start(net); 73 74 if (err) 74 75 goto out_subscr;
+3
net/tipc/core.h
··· 103 103 spinlock_t nametbl_lock; 104 104 struct name_table *nametbl; 105 105 106 + /* Name dist queue */ 107 + struct list_head dist_queue; 108 + 106 109 /* Topology subscription server */ 107 110 struct tipc_server *topsrv; 108 111 atomic_t subscription_count;
+26 -9
net/tipc/name_distr.c
··· 40 40 41 41 int sysctl_tipc_named_timeout __read_mostly = 2000; 42 42 43 - /** 44 - * struct tipc_dist_queue - queue holding deferred name table updates 45 - */ 46 - static struct list_head tipc_dist_queue = LIST_HEAD_INIT(tipc_dist_queue); 47 - 48 43 struct distr_queue_item { 49 44 struct distr_item i; 50 45 u32 dtype; ··· 224 229 kfree_rcu(p, rcu); 225 230 } 226 231 232 + /** 233 + * tipc_dist_queue_purge - remove deferred updates from a node that went down 234 + */ 235 + static void tipc_dist_queue_purge(struct net *net, u32 addr) 236 + { 237 + struct tipc_net *tn = net_generic(net, tipc_net_id); 238 + struct distr_queue_item *e, *tmp; 239 + 240 + spin_lock_bh(&tn->nametbl_lock); 241 + list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) { 242 + if (e->node != addr) 243 + continue; 244 + list_del(&e->next); 245 + kfree(e); 246 + } 247 + spin_unlock_bh(&tn->nametbl_lock); 248 + } 249 + 227 250 void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr) 228 251 { 229 252 struct publication *publ, *tmp; 230 253 231 254 list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list) 232 255 tipc_publ_purge(net, publ, addr); 256 + tipc_dist_queue_purge(net, addr); 233 257 } 234 258 235 259 /** ··· 293 279 * tipc_named_add_backlog - add a failed name table update to the backlog 294 280 * 295 281 */ 296 - static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node) 282 + static void tipc_named_add_backlog(struct net *net, struct distr_item *i, 283 + u32 type, u32 node) 297 284 { 298 285 struct distr_queue_item *e; 286 + struct tipc_net *tn = net_generic(net, tipc_net_id); 299 287 unsigned long now = get_jiffies_64(); 300 288 301 289 e = kzalloc(sizeof(*e), GFP_ATOMIC); ··· 307 291 e->node = node; 308 292 e->expires = now + msecs_to_jiffies(sysctl_tipc_named_timeout); 309 293 memcpy(e, i, sizeof(*i)); 310 - list_add_tail(&e->next, &tipc_dist_queue); 294 + list_add_tail(&e->next, &tn->dist_queue); 311 295 } 312 296 313 297 /** ··· 317 301 void tipc_named_process_backlog(struct net *net) 318 302 { 319 303 struct distr_queue_item *e, *tmp; 304 + struct tipc_net *tn = net_generic(net, tipc_net_id); 320 305 char addr[16]; 321 306 unsigned long now = get_jiffies_64(); 322 307 323 - list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) { 308 + list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) { 324 309 if (time_after(e->expires, now)) { 325 310 if (!tipc_update_nametbl(net, &e->i, e->node, e->dtype)) 326 311 continue; ··· 361 344 node = msg_orignode(msg); 362 345 while (count--) { 363 346 if (!tipc_update_nametbl(net, item, node, mtype)) 364 - tipc_named_add_backlog(item, mtype, node); 347 + tipc_named_add_backlog(net, item, mtype, node); 365 348 item++; 366 349 } 367 350 kfree_skb(skb);
+2 -5
net/vmw_vsock/vmci_transport.c
··· 1735 1735 /* Retrieve the head sk_buff from the socket's receive queue. */ 1736 1736 err = 0; 1737 1737 skb = skb_recv_datagram(&vsk->sk, flags, noblock, &err); 1738 - if (err) 1739 - return err; 1740 - 1741 1738 if (!skb) 1742 - return -EAGAIN; 1739 + return err; 1743 1740 1744 1741 dg = (struct vmci_datagram *)skb->data; 1745 1742 if (!dg) ··· 2151 2154 2152 2155 MODULE_AUTHOR("VMware, Inc."); 2153 2156 MODULE_DESCRIPTION("VMCI transport for Virtual Sockets"); 2154 - MODULE_VERSION("1.0.3.0-k"); 2157 + MODULE_VERSION("1.0.4.0-k"); 2155 2158 MODULE_LICENSE("GPL v2"); 2156 2159 MODULE_ALIAS("vmware_vsock"); 2157 2160 MODULE_ALIAS_NETPROTO(PF_VSOCK);
+1 -1
net/wireless/nl80211.c
··· 13216 13216 struct wireless_dev *wdev; 13217 13217 struct cfg80211_beacon_registration *reg, *tmp; 13218 13218 13219 - if (state != NETLINK_URELEASE) 13219 + if (state != NETLINK_URELEASE || notify->protocol != NETLINK_GENERIC) 13220 13220 return NOTIFY_DONE; 13221 13221 13222 13222 rcu_read_lock();
+1
tools/testing/selftests/net/.gitignore
··· 3 3 psock_tpacket 4 4 reuseport_bpf 5 5 reuseport_bpf_cpu 6 + reuseport_dualstack
+1 -1
tools/testing/selftests/net/Makefile
··· 4 4 5 5 CFLAGS += -I../../../../usr/include/ 6 6 7 - NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu 7 + NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack 8 8 9 9 all: $(NET_PROGS) 10 10 %: %.c
+208
tools/testing/selftests/net/reuseport_dualstack.c
··· 1 + /* 2 + * It is possible to use SO_REUSEPORT to open multiple sockets bound to 3 + * equivalent local addresses using AF_INET and AF_INET6 at the same time. If 4 + * the AF_INET6 socket has IPV6_V6ONLY set, it's clear which socket should 5 + * receive a given incoming packet. However, when it is not set, incoming v4 6 + * packets should prefer the AF_INET socket(s). This behavior was defined with 7 + * the original SO_REUSEPORT implementation, but broke with 8 + * e32ea7e74727 ("soreuseport: fast reuseport UDP socket selection") 9 + * This test creates these mixed AF_INET/AF_INET6 sockets and asserts the 10 + * AF_INET preference for v4 packets. 11 + */ 12 + 13 + #define _GNU_SOURCE 14 + 15 + #include <arpa/inet.h> 16 + #include <errno.h> 17 + #include <error.h> 18 + #include <linux/in.h> 19 + #include <linux/unistd.h> 20 + #include <stdio.h> 21 + #include <stdlib.h> 22 + #include <string.h> 23 + #include <sys/epoll.h> 24 + #include <sys/types.h> 25 + #include <sys/socket.h> 26 + #include <unistd.h> 27 + 28 + static const int PORT = 8888; 29 + 30 + static void build_rcv_fd(int family, int proto, int *rcv_fds, int count) 31 + { 32 + struct sockaddr_storage addr; 33 + struct sockaddr_in *addr4; 34 + struct sockaddr_in6 *addr6; 35 + int opt, i; 36 + 37 + switch (family) { 38 + case AF_INET: 39 + addr4 = (struct sockaddr_in *)&addr; 40 + addr4->sin_family = AF_INET; 41 + addr4->sin_addr.s_addr = htonl(INADDR_ANY); 42 + addr4->sin_port = htons(PORT); 43 + break; 44 + case AF_INET6: 45 + addr6 = (struct sockaddr_in6 *)&addr; 46 + addr6->sin6_family = AF_INET6; 47 + addr6->sin6_addr = in6addr_any; 48 + addr6->sin6_port = htons(PORT); 49 + break; 50 + default: 51 + error(1, 0, "Unsupported family %d", family); 52 + } 53 + 54 + for (i = 0; i < count; ++i) { 55 + rcv_fds[i] = socket(family, proto, 0); 56 + if (rcv_fds[i] < 0) 57 + error(1, errno, "failed to create receive socket"); 58 + 59 + opt = 1; 60 + if (setsockopt(rcv_fds[i], SOL_SOCKET, SO_REUSEPORT, &opt, 61 + sizeof(opt))) 62 + error(1, errno, "failed to set SO_REUSEPORT"); 63 + 64 + if (bind(rcv_fds[i], (struct sockaddr *)&addr, sizeof(addr))) 65 + error(1, errno, "failed to bind receive socket"); 66 + 67 + if (proto == SOCK_STREAM && listen(rcv_fds[i], 10)) 68 + error(1, errno, "failed to listen on receive port"); 69 + } 70 + } 71 + 72 + static void send_from_v4(int proto) 73 + { 74 + struct sockaddr_in saddr, daddr; 75 + int fd; 76 + 77 + saddr.sin_family = AF_INET; 78 + saddr.sin_addr.s_addr = htonl(INADDR_ANY); 79 + saddr.sin_port = 0; 80 + 81 + daddr.sin_family = AF_INET; 82 + daddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 83 + daddr.sin_port = htons(PORT); 84 + 85 + fd = socket(AF_INET, proto, 0); 86 + if (fd < 0) 87 + error(1, errno, "failed to create send socket"); 88 + 89 + if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr))) 90 + error(1, errno, "failed to bind send socket"); 91 + 92 + if (connect(fd, (struct sockaddr *)&daddr, sizeof(daddr))) 93 + error(1, errno, "failed to connect send socket"); 94 + 95 + if (send(fd, "a", 1, 0) < 0) 96 + error(1, errno, "failed to send message"); 97 + 98 + close(fd); 99 + } 100 + 101 + static int receive_once(int epfd, int proto) 102 + { 103 + struct epoll_event ev; 104 + int i, fd; 105 + char buf[8]; 106 + 107 + i = epoll_wait(epfd, &ev, 1, -1); 108 + if (i < 0) 109 + error(1, errno, "epoll_wait failed"); 110 + 111 + if (proto == SOCK_STREAM) { 112 + fd = accept(ev.data.fd, NULL, NULL); 113 + if (fd < 0) 114 + error(1, errno, "failed to accept"); 115 + i = recv(fd, buf, sizeof(buf), 0); 116 + close(fd); 117 + } else { 118 + i = recv(ev.data.fd, buf, sizeof(buf), 0); 119 + } 120 + 121 + if (i < 0) 122 + error(1, errno, "failed to recv"); 123 + 124 + return ev.data.fd; 125 + } 126 + 127 + static void test(int *rcv_fds, int count, int proto) 128 + { 129 + struct epoll_event ev; 130 + int epfd, i, test_fd; 131 + uint16_t test_family; 132 + socklen_t len; 133 + 134 + epfd = epoll_create(1); 135 + if (epfd < 0) 136 + error(1, errno, "failed to create epoll"); 137 + 138 + ev.events = EPOLLIN; 139 + for (i = 0; i < count; ++i) { 140 + ev.data.fd = rcv_fds[i]; 141 + if (epoll_ctl(epfd, EPOLL_CTL_ADD, rcv_fds[i], &ev)) 142 + error(1, errno, "failed to register sock epoll"); 143 + } 144 + 145 + send_from_v4(proto); 146 + 147 + test_fd = receive_once(epfd, proto); 148 + if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len)) 149 + error(1, errno, "failed to read socket domain"); 150 + if (test_family != AF_INET) 151 + error(1, 0, "expected to receive on v4 socket but got v6 (%d)", 152 + test_family); 153 + 154 + close(epfd); 155 + } 156 + 157 + int main(void) 158 + { 159 + int rcv_fds[32], i; 160 + 161 + fprintf(stderr, "---- UDP IPv4 created before IPv6 ----\n"); 162 + build_rcv_fd(AF_INET, SOCK_DGRAM, rcv_fds, 5); 163 + build_rcv_fd(AF_INET6, SOCK_DGRAM, &(rcv_fds[5]), 5); 164 + test(rcv_fds, 10, SOCK_DGRAM); 165 + for (i = 0; i < 10; ++i) 166 + close(rcv_fds[i]); 167 + 168 + fprintf(stderr, "---- UDP IPv6 created before IPv4 ----\n"); 169 + build_rcv_fd(AF_INET6, SOCK_DGRAM, rcv_fds, 5); 170 + build_rcv_fd(AF_INET, SOCK_DGRAM, &(rcv_fds[5]), 5); 171 + test(rcv_fds, 10, SOCK_DGRAM); 172 + for (i = 0; i < 10; ++i) 173 + close(rcv_fds[i]); 174 + 175 + /* NOTE: UDP socket lookups traverse a different code path when there 176 + * are > 10 sockets in a group. 177 + */ 178 + fprintf(stderr, "---- UDP IPv4 created before IPv6 (large) ----\n"); 179 + build_rcv_fd(AF_INET, SOCK_DGRAM, rcv_fds, 16); 180 + build_rcv_fd(AF_INET6, SOCK_DGRAM, &(rcv_fds[16]), 16); 181 + test(rcv_fds, 32, SOCK_DGRAM); 182 + for (i = 0; i < 32; ++i) 183 + close(rcv_fds[i]); 184 + 185 + fprintf(stderr, "---- UDP IPv6 created before IPv4 (large) ----\n"); 186 + build_rcv_fd(AF_INET6, SOCK_DGRAM, rcv_fds, 16); 187 + build_rcv_fd(AF_INET, SOCK_DGRAM, &(rcv_fds[16]), 16); 188 + test(rcv_fds, 32, SOCK_DGRAM); 189 + for (i = 0; i < 32; ++i) 190 + close(rcv_fds[i]); 191 + 192 + fprintf(stderr, "---- TCP IPv4 created before IPv6 ----\n"); 193 + build_rcv_fd(AF_INET, SOCK_STREAM, rcv_fds, 5); 194 + build_rcv_fd(AF_INET6, SOCK_STREAM, &(rcv_fds[5]), 5); 195 + test(rcv_fds, 10, SOCK_STREAM); 196 + for (i = 0; i < 10; ++i) 197 + close(rcv_fds[i]); 198 + 199 + fprintf(stderr, "---- TCP IPv6 created before IPv4 ----\n"); 200 + build_rcv_fd(AF_INET6, SOCK_STREAM, rcv_fds, 5); 201 + build_rcv_fd(AF_INET, SOCK_STREAM, &(rcv_fds[5]), 5); 202 + test(rcv_fds, 10, SOCK_STREAM); 203 + for (i = 0; i < 10; ++i) 204 + close(rcv_fds[i]); 205 + 206 + fprintf(stderr, "SUCCESS\n"); 207 + return 0; 208 + }