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

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

Pull networking fixes from David Miller:

1) Several netfilter fixes from Pablo and the crew:
- Handle fragmented packets properly in netfilter conntrack, from
Florian Westphal.
- Fix SCTP ICMP packet handling, from Ying Xue.
- Fix big-endian bug in nftables, from Liping Zhang.
- Fix alignment of fake conntrack entry, from Steven Rostedt.

2) Fix feature flags setting in fjes driver, from Taku Izumi.

3) Openvswitch ipv6 tunnel source address not set properly, from Or
Gerlitz.

4) Fix jumbo MTU handling in amd-xgbe driver, from Thomas Lendacky.

5) sk->sk_frag.page not released properly in some cases, from Eric
Dumazet.

6) Fix RTNL deadlocks in nl80211, from Johannes Berg.

7) Fix erroneous RTNL lockdep splat in crypto, from Herbert Xu.

8) Cure improper inflight handling during AF_UNIX GC, from Andrey
Ulanov.

9) sch_dsmark doesn't write to packet headers properly, from Eric
Dumazet.

10) Fix SCM_TIMESTAMPING_OPT_STATS handling in TCP, from Soheil Hassas
Yeganeh.

11) Add some IDs for Motorola qmi_wwan chips, from Tony Lindgren.

12) Fix nametbl deadlock in tipc, from Ying Xue.

13) GRO and LRO packets not counted correctly in mlx5 driver, from Gal
Pressman.

14) Fix reset of internal PHYs in bcmgenet, from Doug Berger.

15) Fix hashmap allocation handling, from Alexei Starovoitov.

16) nl_fib_input() needs stronger netlink message length checking, from
Eric Dumazet.

17) Fix double-free of sk->sk_filter during sock clone, from Daniel
Borkmann.

18) Fix RX checksum offloading in aquantia driver, from Pavel Belous.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (85 commits)
net:ethernet:aquantia: Fix for RX checksum offload.
amd-xgbe: Fix the ECC-related bit position definitions
sfc: cleanup a condition in efx_udp_tunnel_del()
Bluetooth: btqcomsmd: fix compile-test dependency
inet: frag: release spinlock before calling icmp_send()
tcp: initialize icsk_ack.lrcvtime at session start time
genetlink: fix counting regression on ctrl_dumpfamily()
socket, bpf: fix sk_filter use after free in sk_clone_lock
ipv4: provide stronger user input validation in nl_fib_input()
bpf: fix hashmap extra_elems logic
enic: update enic maintainers
net: bcmgenet: remove bcmgenet_internal_phy_setup()
ipv6: make sure to initialize sockc.tsflags before first use
fjes: Do not load fjes driver if extended socket device is not power on.
fjes: Do not load fjes driver if system does not have extended socket device.
net/mlx5e: Count LRO packets correctly
net/mlx5e: Count GSO packets correctly
net/mlx5: Increase number of max QPs in default profile
net/mlx5e: Avoid supporting udp tunnel port ndo for VF reps
net/mlx5e: Use the proper UAPI values when offloading TC vlan actions
...

+1085 -611
+2 -16
MAINTAINERS
··· 3216 3216 3217 3217 CISCO VIC ETHERNET NIC DRIVER 3218 3218 M: Christian Benvenuti <benve@cisco.com> 3219 - M: Sujith Sankar <ssujith@cisco.com> 3220 3219 M: Govindarajulu Varadarajan <_govind@gmx.com> 3221 3220 M: Neel Patel <neepatel@cisco.com> 3222 3221 S: Supported ··· 7773 7774 F: net/mac80211/ 7774 7775 F: drivers/net/wireless/mac80211_hwsim.[ch] 7775 7776 7776 - MACVLAN DRIVER 7777 - M: Patrick McHardy <kaber@trash.net> 7778 - L: netdev@vger.kernel.org 7779 - S: Maintained 7780 - F: drivers/net/macvlan.c 7781 - F: include/linux/if_macvlan.h 7782 - 7783 7777 MAILBOX API 7784 7778 M: Jassi Brar <jassisinghbrar@gmail.com> 7785 7779 L: linux-kernel@vger.kernel.org ··· 7845 7853 MARVELL MWIFIEX WIRELESS DRIVER 7846 7854 M: Amitkumar Karwar <akarwar@marvell.com> 7847 7855 M: Nishant Sarmukadam <nishants@marvell.com> 7856 + M: Ganapathi Bhat <gbhat@marvell.com> 7857 + M: Xinming Hu <huxm@marvell.com> 7848 7858 L: linux-wireless@vger.kernel.org 7849 7859 S: Maintained 7850 7860 F: drivers/net/wireless/marvell/mwifiex/ ··· 13376 13382 W: https://linuxtv.org 13377 13383 S: Maintained 13378 13384 F: drivers/media/platform/vivid/* 13379 - 13380 - VLAN (802.1Q) 13381 - M: Patrick McHardy <kaber@trash.net> 13382 - L: netdev@vger.kernel.org 13383 - S: Maintained 13384 - F: drivers/net/macvlan.c 13385 - F: include/linux/if_*vlan.h 13386 - F: net/8021q/ 13387 13385 13388 13386 VLYNQ BUS 13389 13387 M: Florian Fainelli <f.fainelli@gmail.com>
+2 -1
drivers/bluetooth/Kconfig
··· 344 344 345 345 config BT_QCOMSMD 346 346 tristate "Qualcomm SMD based HCI support" 347 - depends on (QCOM_SMD && QCOM_WCNSS_CTRL) || COMPILE_TEST 347 + depends on QCOM_SMD || (COMPILE_TEST && QCOM_SMD=n) 348 + depends on QCOM_WCNSS_CTRL || (COMPILE_TEST && QCOM_WCNSS_CTRL=n) 348 349 select BT_QCA 349 350 help 350 351 Qualcomm SMD based HCI driver.
+16 -14
drivers/net/ethernet/amd/xgbe/xgbe-common.h
··· 984 984 #define XP_ECC_CNT1_DESC_DED_WIDTH 8 985 985 #define XP_ECC_CNT1_DESC_SEC_INDEX 0 986 986 #define XP_ECC_CNT1_DESC_SEC_WIDTH 8 987 - #define XP_ECC_IER_DESC_DED_INDEX 0 987 + #define XP_ECC_IER_DESC_DED_INDEX 5 988 988 #define XP_ECC_IER_DESC_DED_WIDTH 1 989 - #define XP_ECC_IER_DESC_SEC_INDEX 1 989 + #define XP_ECC_IER_DESC_SEC_INDEX 4 990 990 #define XP_ECC_IER_DESC_SEC_WIDTH 1 991 - #define XP_ECC_IER_RX_DED_INDEX 2 991 + #define XP_ECC_IER_RX_DED_INDEX 3 992 992 #define XP_ECC_IER_RX_DED_WIDTH 1 993 - #define XP_ECC_IER_RX_SEC_INDEX 3 993 + #define XP_ECC_IER_RX_SEC_INDEX 2 994 994 #define XP_ECC_IER_RX_SEC_WIDTH 1 995 - #define XP_ECC_IER_TX_DED_INDEX 4 995 + #define XP_ECC_IER_TX_DED_INDEX 1 996 996 #define XP_ECC_IER_TX_DED_WIDTH 1 997 - #define XP_ECC_IER_TX_SEC_INDEX 5 997 + #define XP_ECC_IER_TX_SEC_INDEX 0 998 998 #define XP_ECC_IER_TX_SEC_WIDTH 1 999 - #define XP_ECC_ISR_DESC_DED_INDEX 0 999 + #define XP_ECC_ISR_DESC_DED_INDEX 5 1000 1000 #define XP_ECC_ISR_DESC_DED_WIDTH 1 1001 - #define XP_ECC_ISR_DESC_SEC_INDEX 1 1001 + #define XP_ECC_ISR_DESC_SEC_INDEX 4 1002 1002 #define XP_ECC_ISR_DESC_SEC_WIDTH 1 1003 - #define XP_ECC_ISR_RX_DED_INDEX 2 1003 + #define XP_ECC_ISR_RX_DED_INDEX 3 1004 1004 #define XP_ECC_ISR_RX_DED_WIDTH 1 1005 - #define XP_ECC_ISR_RX_SEC_INDEX 3 1005 + #define XP_ECC_ISR_RX_SEC_INDEX 2 1006 1006 #define XP_ECC_ISR_RX_SEC_WIDTH 1 1007 - #define XP_ECC_ISR_TX_DED_INDEX 4 1007 + #define XP_ECC_ISR_TX_DED_INDEX 1 1008 1008 #define XP_ECC_ISR_TX_DED_WIDTH 1 1009 - #define XP_ECC_ISR_TX_SEC_INDEX 5 1009 + #define XP_ECC_ISR_TX_SEC_INDEX 0 1010 1010 #define XP_ECC_ISR_TX_SEC_WIDTH 1 1011 1011 #define XP_I2C_MUTEX_BUSY_INDEX 31 1012 1012 #define XP_I2C_MUTEX_BUSY_WIDTH 1 ··· 1148 1148 #define RX_PACKET_ATTRIBUTES_CSUM_DONE_WIDTH 1 1149 1149 #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_INDEX 1 1150 1150 #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_WIDTH 1 1151 - #define RX_PACKET_ATTRIBUTES_INCOMPLETE_INDEX 2 1152 - #define RX_PACKET_ATTRIBUTES_INCOMPLETE_WIDTH 1 1151 + #define RX_PACKET_ATTRIBUTES_LAST_INDEX 2 1152 + #define RX_PACKET_ATTRIBUTES_LAST_WIDTH 1 1153 1153 #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_INDEX 3 1154 1154 #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_WIDTH 1 1155 1155 #define RX_PACKET_ATTRIBUTES_CONTEXT_INDEX 4 ··· 1158 1158 #define RX_PACKET_ATTRIBUTES_RX_TSTAMP_WIDTH 1 1159 1159 #define RX_PACKET_ATTRIBUTES_RSS_HASH_INDEX 6 1160 1160 #define RX_PACKET_ATTRIBUTES_RSS_HASH_WIDTH 1 1161 + #define RX_PACKET_ATTRIBUTES_FIRST_INDEX 7 1162 + #define RX_PACKET_ATTRIBUTES_FIRST_WIDTH 1 1161 1163 1162 1164 #define RX_NORMAL_DESC0_OVT_INDEX 0 1163 1165 #define RX_NORMAL_DESC0_OVT_WIDTH 16
+11 -9
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
··· 1896 1896 1897 1897 /* Get the header length */ 1898 1898 if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, FD)) { 1899 + XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, 1900 + FIRST, 1); 1899 1901 rdata->rx.hdr_len = XGMAC_GET_BITS_LE(rdesc->desc2, 1900 1902 RX_NORMAL_DESC2, HL); 1901 1903 if (rdata->rx.hdr_len) 1902 1904 pdata->ext_stats.rx_split_header_packets++; 1905 + } else { 1906 + XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, 1907 + FIRST, 0); 1903 1908 } 1904 1909 1905 1910 /* Get the RSS hash */ ··· 1927 1922 } 1928 1923 } 1929 1924 1930 - /* Get the packet length */ 1931 - rdata->rx.len = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, PL); 1932 - 1933 - if (!XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, LD)) { 1934 - /* Not all the data has been transferred for this packet */ 1935 - XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, 1936 - INCOMPLETE, 1); 1925 + /* Not all the data has been transferred for this packet */ 1926 + if (!XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, LD)) 1937 1927 return 0; 1938 - } 1939 1928 1940 1929 /* This is the last of the data for this packet */ 1941 1930 XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, 1942 - INCOMPLETE, 0); 1931 + LAST, 1); 1932 + 1933 + /* Get the packet length */ 1934 + rdata->rx.len = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, PL); 1943 1935 1944 1936 /* Set checksum done indicator as appropriate */ 1945 1937 if (netdev->features & NETIF_F_RXCSUM)
+63 -39
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
··· 1971 1971 { 1972 1972 struct sk_buff *skb; 1973 1973 u8 *packet; 1974 - unsigned int copy_len; 1975 1974 1976 1975 skb = napi_alloc_skb(napi, rdata->rx.hdr.dma_len); 1977 1976 if (!skb) 1978 1977 return NULL; 1979 1978 1980 - /* Start with the header buffer which may contain just the header 1979 + /* Pull in the header buffer which may contain just the header 1981 1980 * or the header plus data 1982 1981 */ 1983 1982 dma_sync_single_range_for_cpu(pdata->dev, rdata->rx.hdr.dma_base, ··· 1985 1986 1986 1987 packet = page_address(rdata->rx.hdr.pa.pages) + 1987 1988 rdata->rx.hdr.pa.pages_offset; 1988 - copy_len = (rdata->rx.hdr_len) ? rdata->rx.hdr_len : len; 1989 - copy_len = min(rdata->rx.hdr.dma_len, copy_len); 1990 - skb_copy_to_linear_data(skb, packet, copy_len); 1991 - skb_put(skb, copy_len); 1992 - 1993 - len -= copy_len; 1994 - if (len) { 1995 - /* Add the remaining data as a frag */ 1996 - dma_sync_single_range_for_cpu(pdata->dev, 1997 - rdata->rx.buf.dma_base, 1998 - rdata->rx.buf.dma_off, 1999 - rdata->rx.buf.dma_len, 2000 - DMA_FROM_DEVICE); 2001 - 2002 - skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, 2003 - rdata->rx.buf.pa.pages, 2004 - rdata->rx.buf.pa.pages_offset, 2005 - len, rdata->rx.buf.dma_len); 2006 - rdata->rx.buf.pa.pages = NULL; 2007 - } 1989 + skb_copy_to_linear_data(skb, packet, len); 1990 + skb_put(skb, len); 2008 1991 2009 1992 return skb; 1993 + } 1994 + 1995 + static unsigned int xgbe_rx_buf1_len(struct xgbe_ring_data *rdata, 1996 + struct xgbe_packet_data *packet) 1997 + { 1998 + /* Always zero if not the first descriptor */ 1999 + if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, FIRST)) 2000 + return 0; 2001 + 2002 + /* First descriptor with split header, return header length */ 2003 + if (rdata->rx.hdr_len) 2004 + return rdata->rx.hdr_len; 2005 + 2006 + /* First descriptor but not the last descriptor and no split header, 2007 + * so the full buffer was used 2008 + */ 2009 + if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST)) 2010 + return rdata->rx.hdr.dma_len; 2011 + 2012 + /* First descriptor and last descriptor and no split header, so 2013 + * calculate how much of the buffer was used 2014 + */ 2015 + return min_t(unsigned int, rdata->rx.hdr.dma_len, rdata->rx.len); 2016 + } 2017 + 2018 + static unsigned int xgbe_rx_buf2_len(struct xgbe_ring_data *rdata, 2019 + struct xgbe_packet_data *packet, 2020 + unsigned int len) 2021 + { 2022 + /* Always the full buffer if not the last descriptor */ 2023 + if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST)) 2024 + return rdata->rx.buf.dma_len; 2025 + 2026 + /* Last descriptor so calculate how much of the buffer was used 2027 + * for the last bit of data 2028 + */ 2029 + return rdata->rx.len - len; 2010 2030 } 2011 2031 2012 2032 static int xgbe_tx_poll(struct xgbe_channel *channel) ··· 2110 2092 struct napi_struct *napi; 2111 2093 struct sk_buff *skb; 2112 2094 struct skb_shared_hwtstamps *hwtstamps; 2113 - unsigned int incomplete, error, context_next, context; 2114 - unsigned int len, rdesc_len, max_len; 2095 + unsigned int last, error, context_next, context; 2096 + unsigned int len, buf1_len, buf2_len, max_len; 2115 2097 unsigned int received = 0; 2116 2098 int packet_count = 0; 2117 2099 ··· 2121 2103 if (!ring) 2122 2104 return 0; 2123 2105 2124 - incomplete = 0; 2106 + last = 0; 2125 2107 context_next = 0; 2126 2108 2127 2109 napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi; ··· 2155 2137 received++; 2156 2138 ring->cur++; 2157 2139 2158 - incomplete = XGMAC_GET_BITS(packet->attributes, 2159 - RX_PACKET_ATTRIBUTES, 2160 - INCOMPLETE); 2140 + last = XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, 2141 + LAST); 2161 2142 context_next = XGMAC_GET_BITS(packet->attributes, 2162 2143 RX_PACKET_ATTRIBUTES, 2163 2144 CONTEXT_NEXT); ··· 2165 2148 CONTEXT); 2166 2149 2167 2150 /* Earlier error, just drain the remaining data */ 2168 - if ((incomplete || context_next) && error) 2151 + if ((!last || context_next) && error) 2169 2152 goto read_again; 2170 2153 2171 2154 if (error || packet->errors) { ··· 2177 2160 } 2178 2161 2179 2162 if (!context) { 2180 - /* Length is cumulative, get this descriptor's length */ 2181 - rdesc_len = rdata->rx.len - len; 2182 - len += rdesc_len; 2163 + /* Get the data length in the descriptor buffers */ 2164 + buf1_len = xgbe_rx_buf1_len(rdata, packet); 2165 + len += buf1_len; 2166 + buf2_len = xgbe_rx_buf2_len(rdata, packet, len); 2167 + len += buf2_len; 2183 2168 2184 - if (rdesc_len && !skb) { 2169 + if (!skb) { 2185 2170 skb = xgbe_create_skb(pdata, napi, rdata, 2186 - rdesc_len); 2187 - if (!skb) 2171 + buf1_len); 2172 + if (!skb) { 2188 2173 error = 1; 2189 - } else if (rdesc_len) { 2174 + goto skip_data; 2175 + } 2176 + } 2177 + 2178 + if (buf2_len) { 2190 2179 dma_sync_single_range_for_cpu(pdata->dev, 2191 2180 rdata->rx.buf.dma_base, 2192 2181 rdata->rx.buf.dma_off, ··· 2202 2179 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, 2203 2180 rdata->rx.buf.pa.pages, 2204 2181 rdata->rx.buf.pa.pages_offset, 2205 - rdesc_len, 2182 + buf2_len, 2206 2183 rdata->rx.buf.dma_len); 2207 2184 rdata->rx.buf.pa.pages = NULL; 2208 2185 } 2209 2186 } 2210 2187 2211 - if (incomplete || context_next) 2188 + skip_data: 2189 + if (!last || context_next) 2212 2190 goto read_again; 2213 2191 2214 2192 if (!skb) ··· 2267 2243 } 2268 2244 2269 2245 /* Check if we need to save state before leaving */ 2270 - if (received && (incomplete || context_next)) { 2246 + if (received && (!last || context_next)) { 2271 2247 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); 2272 2248 rdata->state_saved = 1; 2273 2249 rdata->state.skb = skb;
+1
drivers/net/ethernet/aquantia/atlantic/aq_main.c
··· 98 98 99 99 if (err < 0) 100 100 goto err_exit; 101 + ndev->mtu = new_mtu; 101 102 102 103 if (netif_running(ndev)) { 103 104 aq_ndev_close(ndev);
+1
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0_internal.h
··· 137 137 .tx_rings = HW_ATL_A0_TX_RINGS, 138 138 .rx_rings = HW_ATL_A0_RX_RINGS, 139 139 .hw_features = NETIF_F_HW_CSUM | 140 + NETIF_F_RXCSUM | 140 141 NETIF_F_RXHASH | 141 142 NETIF_F_SG | 142 143 NETIF_F_TSO,
+1
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h
··· 188 188 .tx_rings = HW_ATL_B0_TX_RINGS, 189 189 .rx_rings = HW_ATL_B0_RX_RINGS, 190 190 .hw_features = NETIF_F_HW_CSUM | 191 + NETIF_F_RXCSUM | 191 192 NETIF_F_RXHASH | 192 193 NETIF_F_SG | 193 194 NETIF_F_TSO |
+4 -2
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 3481 3481 3482 3482 bcmgenet_netif_stop(dev); 3483 3483 3484 - phy_suspend(priv->phydev); 3484 + if (!device_may_wakeup(d)) 3485 + phy_suspend(priv->phydev); 3485 3486 3486 3487 netif_device_detach(dev); 3487 3488 ··· 3579 3578 3580 3579 netif_device_attach(dev); 3581 3580 3582 - phy_resume(priv->phydev); 3581 + if (!device_may_wakeup(d)) 3582 + phy_resume(priv->phydev); 3583 3583 3584 3584 if (priv->eee.eee_enabled) 3585 3585 bcmgenet_eee_enable_set(dev, true);
-15
drivers/net/ethernet/broadcom/genet/bcmmii.c
··· 220 220 udelay(60); 221 221 } 222 222 223 - static void bcmgenet_internal_phy_setup(struct net_device *dev) 224 - { 225 - struct bcmgenet_priv *priv = netdev_priv(dev); 226 - u32 reg; 227 - 228 - /* Power up PHY */ 229 - bcmgenet_phy_power_set(dev, true); 230 - /* enable APD */ 231 - reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); 232 - reg |= EXT_PWR_DN_EN_LD; 233 - bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); 234 - bcmgenet_mii_reset(dev); 235 - } 236 - 237 223 static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv) 238 224 { 239 225 u32 reg; ··· 267 281 268 282 if (priv->internal_phy) { 269 283 phy_name = "internal PHY"; 270 - bcmgenet_internal_phy_setup(dev); 271 284 } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) { 272 285 phy_name = "MoCA"; 273 286 bcmgenet_moca_phy_setup(priv);
+1 -1
drivers/net/ethernet/brocade/bna/bnad_debugfs.c
··· 325 325 return PTR_ERR(kern_buf); 326 326 327 327 rc = sscanf(kern_buf, "%x:%x", &addr, &len); 328 - if (rc < 2) { 328 + if (rc < 2 || len > UINT_MAX >> 2) { 329 329 netdev_warn(bnad->netdev, "failed to read user buffer\n"); 330 330 kfree(kern_buf); 331 331 return -EINVAL;
+2
drivers/net/ethernet/ibm/ibmvnic.c
··· 1257 1257 release_sub_crq_queue(adapter, 1258 1258 adapter->tx_scrq[i]); 1259 1259 } 1260 + kfree(adapter->tx_scrq); 1260 1261 adapter->tx_scrq = NULL; 1261 1262 } 1262 1263 ··· 1270 1269 release_sub_crq_queue(adapter, 1271 1270 adapter->rx_scrq[i]); 1272 1271 } 1272 + kfree(adapter->rx_scrq); 1273 1273 adapter->rx_scrq = NULL; 1274 1274 } 1275 1275 }
+11
drivers/net/ethernet/mellanox/mlx4/cmd.c
··· 2305 2305 rd_toggle = swab32(readl(&priv->mfunc.comm->slave_read)); 2306 2306 if (wr_toggle == 0xffffffff || rd_toggle == 0xffffffff) { 2307 2307 /* PCI might be offline */ 2308 + 2309 + /* If device removal has been requested, 2310 + * do not continue retrying. 2311 + */ 2312 + if (dev->persist->interface_state & 2313 + MLX4_INTERFACE_STATE_NOWAIT) { 2314 + mlx4_warn(dev, 2315 + "communication channel is offline\n"); 2316 + return -EIO; 2317 + } 2318 + 2308 2319 msleep(100); 2309 2320 wr_toggle = swab32(readl(&priv->mfunc.comm-> 2310 2321 slave_write));
+11
drivers/net/ethernet/mellanox/mlx4/main.c
··· 1940 1940 (u32)(1 << COMM_CHAN_OFFLINE_OFFSET)); 1941 1941 if (!offline_bit) 1942 1942 return 0; 1943 + 1944 + /* If device removal has been requested, 1945 + * do not continue retrying. 1946 + */ 1947 + if (dev->persist->interface_state & 1948 + MLX4_INTERFACE_STATE_NOWAIT) 1949 + break; 1950 + 1943 1951 /* There are cases as part of AER/Reset flow that PF needs 1944 1952 * around 100 msec to load. We therefore sleep for 100 msec 1945 1953 * to allow other tasks to make use of that CPU during this ··· 3962 3954 struct mlx4_priv *priv = mlx4_priv(dev); 3963 3955 struct devlink *devlink = priv_to_devlink(priv); 3964 3956 int active_vfs = 0; 3957 + 3958 + if (mlx4_is_slave(dev)) 3959 + persist->interface_state |= MLX4_INTERFACE_STATE_NOWAIT; 3965 3960 3966 3961 mutex_lock(&persist->interface_state_mutex); 3967 3962 persist->interface_state |= MLX4_INTERFACE_STATE_DELETION;
+4
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
··· 361 361 case MLX5_CMD_OP_QUERY_VPORT_COUNTER: 362 362 case MLX5_CMD_OP_ALLOC_Q_COUNTER: 363 363 case MLX5_CMD_OP_QUERY_Q_COUNTER: 364 + case MLX5_CMD_OP_SET_RATE_LIMIT: 365 + case MLX5_CMD_OP_QUERY_RATE_LIMIT: 364 366 case MLX5_CMD_OP_ALLOC_PD: 365 367 case MLX5_CMD_OP_ALLOC_UAR: 366 368 case MLX5_CMD_OP_CONFIG_INT_MODERATION: ··· 499 497 MLX5_COMMAND_STR_CASE(ALLOC_Q_COUNTER); 500 498 MLX5_COMMAND_STR_CASE(DEALLOC_Q_COUNTER); 501 499 MLX5_COMMAND_STR_CASE(QUERY_Q_COUNTER); 500 + MLX5_COMMAND_STR_CASE(SET_RATE_LIMIT); 501 + MLX5_COMMAND_STR_CASE(QUERY_RATE_LIMIT); 502 502 MLX5_COMMAND_STR_CASE(ALLOC_PD); 503 503 MLX5_COMMAND_STR_CASE(DEALLOC_PD); 504 504 MLX5_COMMAND_STR_CASE(ALLOC_UAR);
-4
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 928 928 int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev); 929 929 void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev); 930 930 u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout); 931 - void mlx5e_add_vxlan_port(struct net_device *netdev, 932 - struct udp_tunnel_info *ti); 933 - void mlx5e_del_vxlan_port(struct net_device *netdev, 934 - struct udp_tunnel_info *ti); 935 931 936 932 int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev, 937 933 void *sp);
+4 -4
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 3100 3100 vf_stats); 3101 3101 } 3102 3102 3103 - void mlx5e_add_vxlan_port(struct net_device *netdev, 3104 - struct udp_tunnel_info *ti) 3103 + static void mlx5e_add_vxlan_port(struct net_device *netdev, 3104 + struct udp_tunnel_info *ti) 3105 3105 { 3106 3106 struct mlx5e_priv *priv = netdev_priv(netdev); 3107 3107 ··· 3114 3114 mlx5e_vxlan_queue_work(priv, ti->sa_family, be16_to_cpu(ti->port), 1); 3115 3115 } 3116 3116 3117 - void mlx5e_del_vxlan_port(struct net_device *netdev, 3118 - struct udp_tunnel_info *ti) 3117 + static void mlx5e_del_vxlan_port(struct net_device *netdev, 3118 + struct udp_tunnel_info *ti) 3119 3119 { 3120 3120 struct mlx5e_priv *priv = netdev_priv(netdev); 3121 3121
-2
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 393 393 .ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name, 394 394 .ndo_setup_tc = mlx5e_rep_ndo_setup_tc, 395 395 .ndo_get_stats64 = mlx5e_rep_get_stats, 396 - .ndo_udp_tunnel_add = mlx5e_add_vxlan_port, 397 - .ndo_udp_tunnel_del = mlx5e_del_vxlan_port, 398 396 .ndo_has_offload_stats = mlx5e_has_offload_stats, 399 397 .ndo_get_offload_stats = mlx5e_get_offload_stats, 400 398 };
+4
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 601 601 if (lro_num_seg > 1) { 602 602 mlx5e_lro_update_hdr(skb, cqe, cqe_bcnt); 603 603 skb_shinfo(skb)->gso_size = DIV_ROUND_UP(cqe_bcnt, lro_num_seg); 604 + /* Subtract one since we already counted this as one 605 + * "regular" packet in mlx5e_complete_rx_cqe() 606 + */ 607 + rq->stats.packets += lro_num_seg - 1; 604 608 rq->stats.lro_packets++; 605 609 rq->stats.lro_bytes += cqe_bcnt; 606 610 }
+50 -24
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 133 133 return rule; 134 134 } 135 135 136 + static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv, 137 + struct mlx5e_tc_flow *flow) 138 + { 139 + struct mlx5_fc *counter = NULL; 140 + 141 + if (!IS_ERR(flow->rule)) { 142 + counter = mlx5_flow_rule_counter(flow->rule); 143 + mlx5_del_flow_rules(flow->rule); 144 + mlx5_fc_destroy(priv->mdev, counter); 145 + } 146 + 147 + if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) { 148 + mlx5_destroy_flow_table(priv->fs.tc.t); 149 + priv->fs.tc.t = NULL; 150 + } 151 + } 152 + 136 153 static struct mlx5_flow_handle * 137 154 mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, 138 155 struct mlx5_flow_spec *spec, ··· 166 149 } 167 150 168 151 static void mlx5e_detach_encap(struct mlx5e_priv *priv, 169 - struct mlx5e_tc_flow *flow) { 152 + struct mlx5e_tc_flow *flow); 153 + 154 + static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, 155 + struct mlx5e_tc_flow *flow) 156 + { 157 + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 158 + 159 + mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr); 160 + 161 + mlx5_eswitch_del_vlan_action(esw, flow->attr); 162 + 163 + if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP) 164 + mlx5e_detach_encap(priv, flow); 165 + } 166 + 167 + static void mlx5e_detach_encap(struct mlx5e_priv *priv, 168 + struct mlx5e_tc_flow *flow) 169 + { 170 170 struct list_head *next = flow->encap.next; 171 171 172 172 list_del(&flow->encap); ··· 207 173 static void mlx5e_tc_del_flow(struct mlx5e_priv *priv, 208 174 struct mlx5e_tc_flow *flow) 209 175 { 210 - struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 211 - struct mlx5_fc *counter = NULL; 212 - 213 - if (!IS_ERR(flow->rule)) { 214 - counter = mlx5_flow_rule_counter(flow->rule); 215 - mlx5_del_flow_rules(flow->rule); 216 - mlx5_fc_destroy(priv->mdev, counter); 217 - } 218 - 219 - if (flow->flags & MLX5E_TC_FLOW_ESWITCH) { 220 - mlx5_eswitch_del_vlan_action(esw, flow->attr); 221 - if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP) 222 - mlx5e_detach_encap(priv, flow); 223 - } 224 - 225 - if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) { 226 - mlx5_destroy_flow_table(priv->fs.tc.t); 227 - priv->fs.tc.t = NULL; 228 - } 176 + if (flow->flags & MLX5E_TC_FLOW_ESWITCH) 177 + mlx5e_tc_del_fdb_flow(priv, flow); 178 + else 179 + mlx5e_tc_del_nic_flow(priv, flow); 229 180 } 230 181 231 182 static void parse_vxlan_attr(struct mlx5_flow_spec *spec, ··· 267 248 skb_flow_dissector_target(f->dissector, 268 249 FLOW_DISSECTOR_KEY_ENC_PORTS, 269 250 f->mask); 251 + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 252 + struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw); 253 + struct mlx5e_priv *up_priv = netdev_priv(up_dev); 270 254 271 255 /* Full udp dst port must be given */ 272 256 if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst))) 273 257 goto vxlan_match_offload_err; 274 258 275 - if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->dst)) && 259 + if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->dst)) && 276 260 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) 277 261 parse_vxlan_attr(spec, f); 278 262 else { ··· 998 976 struct mlx5_esw_flow_attr *attr) 999 977 { 1000 978 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 979 + struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw); 980 + struct mlx5e_priv *up_priv = netdev_priv(up_dev); 1001 981 unsigned short family = ip_tunnel_info_af(tun_info); 1002 982 struct ip_tunnel_key *key = &tun_info->key; 1003 983 struct mlx5_encap_entry *e; ··· 1020 996 return -EOPNOTSUPP; 1021 997 } 1022 998 1023 - if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) && 999 + if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->tp_dst)) && 1024 1000 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) { 1025 1001 tunnel_type = MLX5_HEADER_TYPE_VXLAN; 1026 1002 } else { ··· 1136 1112 } 1137 1113 1138 1114 if (is_tcf_vlan(a)) { 1139 - if (tcf_vlan_action(a) == VLAN_F_POP) { 1115 + if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) { 1140 1116 attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; 1141 - } else if (tcf_vlan_action(a) == VLAN_F_PUSH) { 1117 + } else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) { 1142 1118 if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q)) 1143 1119 return -EOPNOTSUPP; 1144 1120 1145 1121 attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH; 1146 1122 attr->vlan = tcf_vlan_push_vid(a); 1123 + } else { /* action is TCA_VLAN_ACT_MODIFY */ 1124 + return -EOPNOTSUPP; 1147 1125 } 1148 1126 continue; 1149 1127 }
+3 -2
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
··· 274 274 sq->stats.tso_bytes += skb->len - ihs; 275 275 } 276 276 277 + sq->stats.packets += skb_shinfo(skb)->gso_segs; 277 278 num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs; 278 279 } else { 279 280 bf = sq->bf_budget && 280 281 !skb->xmit_more && 281 282 !skb_shinfo(skb)->nr_frags; 282 283 ihs = mlx5e_get_inline_hdr_size(sq, skb, bf); 284 + sq->stats.packets++; 283 285 num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN); 284 286 } 285 287 288 + sq->stats.bytes += num_bytes; 286 289 wi->num_bytes = num_bytes; 287 290 288 291 ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS; ··· 384 381 if (bf) 385 382 sq->bf_budget--; 386 383 387 - sq->stats.packets++; 388 - sq->stats.bytes += num_bytes; 389 384 return NETDEV_TX_OK; 390 385 391 386 dma_unmap_wqe_err:
+6
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 209 209 struct mlx5_eswitch_rep *vport_reps; 210 210 DECLARE_HASHTABLE(encap_tbl, 8); 211 211 u8 inline_mode; 212 + u64 num_flows; 212 213 }; 213 214 214 215 struct mlx5_eswitch { ··· 272 271 mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, 273 272 struct mlx5_flow_spec *spec, 274 273 struct mlx5_esw_flow_attr *attr); 274 + void 275 + mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw, 276 + struct mlx5_flow_handle *rule, 277 + struct mlx5_esw_flow_attr *attr); 278 + 275 279 struct mlx5_flow_handle * 276 280 mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn); 277 281
+22
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 93 93 spec, &flow_act, dest, i); 94 94 if (IS_ERR(rule)) 95 95 mlx5_fc_destroy(esw->dev, counter); 96 + else 97 + esw->offloads.num_flows++; 96 98 97 99 return rule; 100 + } 101 + 102 + void 103 + mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw, 104 + struct mlx5_flow_handle *rule, 105 + struct mlx5_esw_flow_attr *attr) 106 + { 107 + struct mlx5_fc *counter = NULL; 108 + 109 + if (!IS_ERR(rule)) { 110 + counter = mlx5_flow_rule_counter(rule); 111 + mlx5_del_flow_rules(rule); 112 + mlx5_fc_destroy(esw->dev, counter); 113 + esw->offloads.num_flows--; 114 + } 98 115 } 99 116 100 117 static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val) ··· 924 907 if (MLX5_CAP_ETH(dev, wqe_inline_mode) != 925 908 MLX5_CAP_INLINE_MODE_VPORT_CONTEXT) 926 909 return -EOPNOTSUPP; 910 + 911 + if (esw->offloads.num_flows > 0) { 912 + esw_warn(dev, "Can't set inline mode when flows are configured\n"); 913 + return -EOPNOTSUPP; 914 + } 927 915 928 916 err = esw_inline_mode_from_devlink(mode, &mlx5_mode); 929 917 if (err)
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 87 87 [2] = { 88 88 .mask = MLX5_PROF_MASK_QP_SIZE | 89 89 MLX5_PROF_MASK_MR_CACHE, 90 - .log_max_qp = 17, 90 + .log_max_qp = 18, 91 91 .mr_cache[0] = { 92 92 .size = 500, 93 93 .limit = 250
+1 -1
drivers/net/ethernet/sfc/efx.c
··· 2404 2404 tnl.type = (u16)efx_tunnel_type; 2405 2405 tnl.port = ti->port; 2406 2406 2407 - if (efx->type->udp_tnl_add_port) 2407 + if (efx->type->udp_tnl_del_port) 2408 2408 (void)efx->type->udp_tnl_del_port(efx, tnl); 2409 2409 } 2410 2410
+8 -2
drivers/net/ethernet/ti/Kconfig
··· 74 74 will be called cpsw. 75 75 76 76 config TI_CPTS 77 - tristate "TI Common Platform Time Sync (CPTS) Support" 77 + bool "TI Common Platform Time Sync (CPTS) Support" 78 78 depends on TI_CPSW || TI_KEYSTONE_NETCP 79 - imply PTP_1588_CLOCK 79 + depends on PTP_1588_CLOCK 80 80 ---help--- 81 81 This driver supports the Common Platform Time Sync unit of 82 82 the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem. 83 83 The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the 84 84 driver offers a PTP Hardware Clock. 85 + 86 + config TI_CPTS_MOD 87 + tristate 88 + depends on TI_CPTS 89 + default y if TI_CPSW=y || TI_KEYSTONE_NETCP=y 90 + default m 85 91 86 92 config TI_KEYSTONE_NETCP 87 93 tristate "TI Keystone NETCP Core Support"
+1 -1
drivers/net/ethernet/ti/Makefile
··· 12 12 obj-$(CONFIG_TI_DAVINCI_CPDMA) += davinci_cpdma.o 13 13 obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o 14 14 obj-$(CONFIG_TI_CPSW_ALE) += cpsw_ale.o 15 - obj-$(CONFIG_TI_CPTS) += cpts.o 15 + obj-$(CONFIG_TI_CPTS_MOD) += cpts.o 16 16 obj-$(CONFIG_TI_CPSW) += ti_cpsw.o 17 17 ti_cpsw-y := cpsw.o 18 18
+72 -6
drivers/net/fjes/fjes_main.c
··· 45 45 MODULE_LICENSE("GPL"); 46 46 MODULE_VERSION(DRV_VERSION); 47 47 48 + #define ACPI_MOTHERBOARD_RESOURCE_HID "PNP0C02" 49 + 48 50 static int fjes_request_irq(struct fjes_adapter *); 49 51 static void fjes_free_irq(struct fjes_adapter *); 50 52 ··· 80 78 static int fjes_poll(struct napi_struct *, int); 81 79 82 80 static const struct acpi_device_id fjes_acpi_ids[] = { 83 - {"PNP0C02", 0}, 81 + {ACPI_MOTHERBOARD_RESOURCE_HID, 0}, 84 82 {"", 0}, 85 83 }; 86 84 MODULE_DEVICE_TABLE(acpi, fjes_acpi_ids); ··· 117 115 }, 118 116 }; 119 117 120 - static int fjes_acpi_add(struct acpi_device *device) 118 + static bool is_extended_socket_device(struct acpi_device *device) 121 119 { 122 120 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; 123 121 char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1]; 124 - struct platform_device *plat_dev; 125 122 union acpi_object *str; 126 123 acpi_status status; 127 124 int result; 128 125 129 126 status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer); 130 127 if (ACPI_FAILURE(status)) 131 - return -ENODEV; 128 + return false; 132 129 133 130 str = buffer.pointer; 134 131 result = utf16s_to_utf8s((wchar_t *)str->string.pointer, ··· 137 136 138 137 if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) { 139 138 kfree(buffer.pointer); 140 - return -ENODEV; 139 + return false; 141 140 } 142 141 kfree(buffer.pointer); 142 + 143 + return true; 144 + } 145 + 146 + static int acpi_check_extended_socket_status(struct acpi_device *device) 147 + { 148 + unsigned long long sta; 149 + acpi_status status; 150 + 151 + status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); 152 + if (ACPI_FAILURE(status)) 153 + return -ENODEV; 154 + 155 + if (!((sta & ACPI_STA_DEVICE_PRESENT) && 156 + (sta & ACPI_STA_DEVICE_ENABLED) && 157 + (sta & ACPI_STA_DEVICE_UI) && 158 + (sta & ACPI_STA_DEVICE_FUNCTIONING))) 159 + return -ENODEV; 160 + 161 + return 0; 162 + } 163 + 164 + static int fjes_acpi_add(struct acpi_device *device) 165 + { 166 + struct platform_device *plat_dev; 167 + acpi_status status; 168 + 169 + if (!is_extended_socket_device(device)) 170 + return -ENODEV; 171 + 172 + if (acpi_check_extended_socket_status(device)) 173 + return -ENODEV; 143 174 144 175 status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, 145 176 fjes_get_acpi_resource, fjes_resource); ··· 1349 1316 netdev->min_mtu = fjes_support_mtu[0]; 1350 1317 netdev->max_mtu = fjes_support_mtu[3]; 1351 1318 netdev->flags |= IFF_BROADCAST; 1352 - netdev->features |= NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_FILTER; 1319 + netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 1353 1320 } 1354 1321 1355 1322 static void fjes_irq_watch_task(struct work_struct *work) ··· 1506 1473 } 1507 1474 } 1508 1475 1476 + static acpi_status 1477 + acpi_find_extended_socket_device(acpi_handle obj_handle, u32 level, 1478 + void *context, void **return_value) 1479 + { 1480 + struct acpi_device *device; 1481 + bool *found = context; 1482 + int result; 1483 + 1484 + result = acpi_bus_get_device(obj_handle, &device); 1485 + if (result) 1486 + return AE_OK; 1487 + 1488 + if (strcmp(acpi_device_hid(device), ACPI_MOTHERBOARD_RESOURCE_HID)) 1489 + return AE_OK; 1490 + 1491 + if (!is_extended_socket_device(device)) 1492 + return AE_OK; 1493 + 1494 + if (acpi_check_extended_socket_status(device)) 1495 + return AE_OK; 1496 + 1497 + *found = true; 1498 + return AE_CTRL_TERMINATE; 1499 + } 1500 + 1509 1501 /* fjes_init_module - Driver Registration Routine */ 1510 1502 static int __init fjes_init_module(void) 1511 1503 { 1504 + bool found = false; 1512 1505 int result; 1506 + 1507 + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1508 + acpi_find_extended_socket_device, NULL, &found, 1509 + NULL); 1510 + 1511 + if (!found) 1512 + return -ENODEV; 1513 1513 1514 1514 pr_info("%s - version %s - %s\n", 1515 1515 fjes_driver_string, fjes_driver_version, fjes_copyright);
+5 -2
drivers/net/hyperv/netvsc.c
··· 1231 1231 return; 1232 1232 1233 1233 net_device = net_device_to_netvsc_device(ndev); 1234 - if (unlikely(net_device->destroy) && 1235 - netvsc_channel_idle(net_device, q_idx)) 1234 + if (unlikely(!net_device)) 1235 + return; 1236 + 1237 + if (unlikely(net_device->destroy && 1238 + netvsc_channel_idle(net_device, q_idx))) 1236 1239 return; 1237 1240 1238 1241 /* commit_rd_index() -> hv_signal_on_read() needs this. */
+2
drivers/net/tun.c
··· 1931 1931 return -EINVAL; 1932 1932 1933 1933 tun->set_features = features; 1934 + tun->dev->wanted_features &= ~TUN_USER_FEATURES; 1935 + tun->dev->wanted_features |= features; 1934 1936 netdev_update_features(tun->dev); 1935 1937 1936 1938 return 0;
+6
drivers/net/usb/qmi_wwan.c
··· 580 580 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69), 581 581 .driver_info = (unsigned long)&qmi_wwan_info, 582 582 }, 583 + { /* Motorola Mapphone devices with MDM6600 */ 584 + USB_VENDOR_AND_INTERFACE_INFO(0x22b8, USB_CLASS_VENDOR_SPEC, 0xfb, 0xff), 585 + .driver_info = (unsigned long)&qmi_wwan_info, 586 + }, 583 587 584 588 /* 2. Combined interface devices matching on class+protocol */ 585 589 { /* Huawei E367 and possibly others in "Windows mode" */ ··· 929 925 {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ 930 926 {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ 931 927 {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ 928 + {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ 929 + {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ 932 930 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ 933 931 {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ 934 932 {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */
+17 -7
drivers/net/usb/r8152.c
··· 32 32 #define NETNEXT_VERSION "08" 33 33 34 34 /* Information for net */ 35 - #define NET_VERSION "8" 35 + #define NET_VERSION "9" 36 36 37 37 #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION 38 38 #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" ··· 501 501 #define RTL8153_RMS RTL8153_MAX_PACKET 502 502 #define RTL8152_TX_TIMEOUT (5 * HZ) 503 503 #define RTL8152_NAPI_WEIGHT 64 504 + #define rx_reserved_size(x) ((x) + VLAN_ETH_HLEN + CRC_SIZE + \ 505 + sizeof(struct rx_desc) + RX_ALIGN) 504 506 505 507 /* rtl8152 flags */ 506 508 enum rtl8152_flags { ··· 1364 1362 spin_lock_init(&tp->rx_lock); 1365 1363 spin_lock_init(&tp->tx_lock); 1366 1364 INIT_LIST_HEAD(&tp->tx_free); 1365 + INIT_LIST_HEAD(&tp->rx_done); 1367 1366 skb_queue_head_init(&tp->tx_queue); 1368 1367 skb_queue_head_init(&tp->rx_queue); 1369 1368 ··· 2255 2252 2256 2253 static void r8153_set_rx_early_size(struct r8152 *tp) 2257 2254 { 2258 - u32 mtu = tp->netdev->mtu; 2259 - u32 ocp_data = (agg_buf_sz - mtu - VLAN_ETH_HLEN - VLAN_HLEN) / 8; 2255 + u32 ocp_data = (agg_buf_sz - rx_reserved_size(tp->netdev->mtu)) / 4; 2260 2256 2261 2257 ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data); 2262 2258 } ··· 2900 2898 2901 2899 rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); 2902 2900 2903 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); 2901 + ocp_data = tp->netdev->mtu + VLAN_ETH_HLEN + CRC_SIZE; 2902 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, ocp_data); 2904 2903 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_JUMBO); 2905 2904 2906 2905 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); ··· 2953 2950 usleep_range(1000, 2000); 2954 2951 } 2955 2952 2956 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); 2953 + ocp_data = tp->netdev->mtu + VLAN_ETH_HLEN + CRC_SIZE; 2954 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, ocp_data); 2957 2955 2958 2956 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); 2959 2957 ocp_data &= ~TEREDO_WAKE_MASK; ··· 4204 4200 4205 4201 dev->mtu = new_mtu; 4206 4202 4207 - if (netif_running(dev) && netif_carrier_ok(dev)) 4208 - r8153_set_rx_early_size(tp); 4203 + if (netif_running(dev)) { 4204 + u32 rms = new_mtu + VLAN_ETH_HLEN + CRC_SIZE; 4205 + 4206 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, rms); 4207 + 4208 + if (netif_carrier_ok(dev)) 4209 + r8153_set_rx_early_size(tp); 4210 + } 4209 4211 4210 4212 mutex_unlock(&tp->control); 4211 4213
+3 -1
drivers/net/vrf.c
··· 462 462 } 463 463 464 464 if (rt6_local) { 465 - if (rt6_local->rt6i_idev) 465 + if (rt6_local->rt6i_idev) { 466 466 in6_dev_put(rt6_local->rt6i_idev); 467 + rt6_local->rt6i_idev = NULL; 468 + } 467 469 468 470 dst = &rt6_local->dst; 469 471 dev_put(dst->dev);
+1 -1
drivers/net/wireless/ath/ath10k/hw.c
··· 51 51 .rtc_soc_base_address = 0x00000800, 52 52 .rtc_wmac_base_address = 0x00001000, 53 53 .soc_core_base_address = 0x0003a000, 54 - .wlan_mac_base_address = 0x00020000, 54 + .wlan_mac_base_address = 0x00010000, 55 55 .ce_wrapper_base_address = 0x00034000, 56 56 .ce0_base_address = 0x00034400, 57 57 .ce1_base_address = 0x00034800,
+3 -2
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
··· 2319 2319 { 2320 2320 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 2321 2321 2322 - /* Called when we need to transmit (a) frame(s) from agg queue */ 2322 + /* Called when we need to transmit (a) frame(s) from agg or dqa queue */ 2323 2323 2324 2324 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, 2325 2325 tids, more_data, true); ··· 2338 2338 for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { 2339 2339 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; 2340 2340 2341 - if (tid_data->state != IWL_AGG_ON && 2341 + if (!iwl_mvm_is_dqa_supported(mvm) && 2342 + tid_data->state != IWL_AGG_ON && 2342 2343 tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA) 2343 2344 continue; 2344 2345
+6 -5
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
··· 3135 3135 struct ieee80211_sta *sta, 3136 3136 enum ieee80211_frame_release_type reason, 3137 3137 u16 cnt, u16 tids, bool more_data, 3138 - bool agg) 3138 + bool single_sta_queue) 3139 3139 { 3140 3140 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 3141 3141 struct iwl_mvm_add_sta_cmd cmd = { ··· 3155 3155 for_each_set_bit(tid, &_tids, IWL_MAX_TID_COUNT) 3156 3156 cmd.awake_acs |= BIT(tid_to_ucode_ac[tid]); 3157 3157 3158 - /* If we're releasing frames from aggregation queues then check if the 3159 - * all queues combined that we're releasing frames from have 3158 + /* If we're releasing frames from aggregation or dqa queues then check 3159 + * if all the queues that we're releasing frames from, combined, have: 3160 3160 * - more frames than the service period, in which case more_data 3161 3161 * needs to be set 3162 3162 * - fewer than 'cnt' frames, in which case we need to adjust the 3163 3163 * firmware command (but do that unconditionally) 3164 3164 */ 3165 - if (agg) { 3165 + if (single_sta_queue) { 3166 3166 int remaining = cnt; 3167 3167 int sleep_tx_count; 3168 3168 ··· 3172 3172 u16 n_queued; 3173 3173 3174 3174 tid_data = &mvmsta->tid_data[tid]; 3175 - if (WARN(tid_data->state != IWL_AGG_ON && 3175 + if (WARN(!iwl_mvm_is_dqa_supported(mvm) && 3176 + tid_data->state != IWL_AGG_ON && 3176 3177 tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA, 3177 3178 "TID %d state is %d\n", 3178 3179 tid, tid_data->state)) {
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/sta.h
··· 547 547 struct ieee80211_sta *sta, 548 548 enum ieee80211_frame_release_type reason, 549 549 u16 cnt, u16 tids, bool more_data, 550 - bool agg); 550 + bool single_sta_queue); 551 551 int iwl_mvm_drain_sta(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta, 552 552 bool drain); 553 553 void iwl_mvm_sta_modify_disable_tx(struct iwl_mvm *mvm,
+18 -23
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
··· 7 7 * 8 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 - * Copyright(c) 2016 Intel Deutschland GmbH 10 + * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 11 * 12 12 * This program is free software; you can redistribute it and/or modify 13 13 * it under the terms of version 2 of the GNU General Public License as ··· 34 34 * 35 35 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 36 36 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 37 + * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 37 38 * All rights reserved. 38 39 * 39 40 * Redistribution and use in source and binary forms, with or without ··· 629 628 * values. 630 629 * Note that we don't need to make sure it isn't agg'd, since we're 631 630 * TXing non-sta 631 + * For DQA mode - we shouldn't increase it though 632 632 */ 633 - atomic_inc(&mvm->pending_frames[sta_id]); 633 + if (!iwl_mvm_is_dqa_supported(mvm)) 634 + atomic_inc(&mvm->pending_frames[sta_id]); 634 635 635 636 return 0; 636 637 } ··· 1008 1005 1009 1006 spin_unlock(&mvmsta->lock); 1010 1007 1011 - /* Increase pending frames count if this isn't AMPDU */ 1012 - if ((iwl_mvm_is_dqa_supported(mvm) && 1013 - mvmsta->tid_data[tx_cmd->tid_tspec].state != IWL_AGG_ON && 1014 - mvmsta->tid_data[tx_cmd->tid_tspec].state != IWL_AGG_STARTING) || 1015 - (!iwl_mvm_is_dqa_supported(mvm) && !is_ampdu)) 1008 + /* Increase pending frames count if this isn't AMPDU or DQA queue */ 1009 + if (!iwl_mvm_is_dqa_supported(mvm) && !is_ampdu) 1016 1010 atomic_inc(&mvm->pending_frames[mvmsta->sta_id]); 1017 1011 1018 1012 return 0; ··· 1079 1079 lockdep_assert_held(&mvmsta->lock); 1080 1080 1081 1081 if ((tid_data->state == IWL_AGG_ON || 1082 - tid_data->state == IWL_EMPTYING_HW_QUEUE_DELBA) && 1082 + tid_data->state == IWL_EMPTYING_HW_QUEUE_DELBA || 1083 + iwl_mvm_is_dqa_supported(mvm)) && 1083 1084 iwl_mvm_tid_queued(tid_data) == 0) { 1084 1085 /* 1085 - * Now that this aggregation queue is empty tell mac80211 so it 1086 - * knows we no longer have frames buffered for the station on 1087 - * this TID (for the TIM bitmap calculation.) 1086 + * Now that this aggregation or DQA queue is empty tell 1087 + * mac80211 so it knows we no longer have frames buffered for 1088 + * the station on this TID (for the TIM bitmap calculation.) 1088 1089 */ 1089 1090 ieee80211_sta_set_buffered(sta, tid, false); 1090 1091 } ··· 1258 1257 u8 skb_freed = 0; 1259 1258 u16 next_reclaimed, seq_ctl; 1260 1259 bool is_ndp = false; 1261 - bool txq_agg = false; /* Is this TXQ aggregated */ 1262 1260 1263 1261 __skb_queue_head_init(&skbs); 1264 1262 ··· 1283 1283 info->flags |= IEEE80211_TX_STAT_ACK; 1284 1284 break; 1285 1285 case TX_STATUS_FAIL_DEST_PS: 1286 + /* In DQA, the FW should have stopped the queue and not 1287 + * return this status 1288 + */ 1289 + WARN_ON(iwl_mvm_is_dqa_supported(mvm)); 1286 1290 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 1287 1291 break; 1288 1292 default: ··· 1391 1387 bool send_eosp_ndp = false; 1392 1388 1393 1389 spin_lock_bh(&mvmsta->lock); 1394 - if (iwl_mvm_is_dqa_supported(mvm)) { 1395 - enum iwl_mvm_agg_state state; 1396 - 1397 - state = mvmsta->tid_data[tid].state; 1398 - txq_agg = (state == IWL_AGG_ON || 1399 - state == IWL_EMPTYING_HW_QUEUE_DELBA); 1400 - } else { 1401 - txq_agg = txq_id >= mvm->first_agg_queue; 1402 - } 1403 1390 1404 1391 if (!is_ndp) { 1405 1392 tid_data->next_reclaimed = next_reclaimed; ··· 1447 1452 * If the txq is not an AMPDU queue, there is no chance we freed 1448 1453 * several skbs. Check that out... 1449 1454 */ 1450 - if (txq_agg) 1455 + if (iwl_mvm_is_dqa_supported(mvm) || txq_id >= mvm->first_agg_queue) 1451 1456 goto out; 1452 1457 1453 1458 /* We can't free more than one frame at once on a shared queue */ 1454 - WARN_ON(!iwl_mvm_is_dqa_supported(mvm) && (skb_freed > 1)); 1459 + WARN_ON(skb_freed > 1); 1455 1460 1456 1461 /* If we have still frames for this STA nothing to do here */ 1457 1462 if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id]))
+7 -4
drivers/net/wireless/marvell/mwifiex/main.c
··· 57 57 * In case of any errors during inittialization, this function also ensures 58 58 * proper cleanup before exiting. 59 59 */ 60 - static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, 61 - void **padapter) 60 + static int mwifiex_register(void *card, struct device *dev, 61 + struct mwifiex_if_ops *if_ops, void **padapter) 62 62 { 63 63 struct mwifiex_adapter *adapter; 64 64 int i; ··· 68 68 return -ENOMEM; 69 69 70 70 *padapter = adapter; 71 + adapter->dev = dev; 71 72 adapter->card = card; 72 73 73 74 /* Save interface specific operations in adapter */ ··· 1569 1568 { 1570 1569 struct mwifiex_adapter *adapter; 1571 1570 1572 - if (mwifiex_register(card, if_ops, (void **)&adapter)) { 1571 + if (mwifiex_register(card, dev, if_ops, (void **)&adapter)) { 1573 1572 pr_err("%s: software init failed\n", __func__); 1574 1573 goto err_init_sw; 1575 1574 } 1576 1575 1577 - adapter->dev = dev; 1578 1576 mwifiex_probe_of(adapter); 1579 1577 1580 1578 adapter->iface_type = iface_type; ··· 1717 1717 1718 1718 wiphy_unregister(adapter->wiphy); 1719 1719 wiphy_free(adapter->wiphy); 1720 + 1721 + if (adapter->irq_wakeup >= 0) 1722 + device_init_wakeup(adapter->dev, false); 1720 1723 1721 1724 /* Unregister device */ 1722 1725 mwifiex_dbg(adapter, INFO,
+19 -19
drivers/net/wireless/marvell/mwifiex/pcie.c
··· 2739 2739 schedule_work(&card->work); 2740 2740 } 2741 2741 2742 + static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter) 2743 + { 2744 + struct pcie_service_card *card = adapter->card; 2745 + const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; 2746 + 2747 + if (reg->sleep_cookie) 2748 + mwifiex_pcie_delete_sleep_cookie_buf(adapter); 2749 + 2750 + mwifiex_pcie_delete_cmdrsp_buf(adapter); 2751 + mwifiex_pcie_delete_evtbd_ring(adapter); 2752 + mwifiex_pcie_delete_rxbd_ring(adapter); 2753 + mwifiex_pcie_delete_txbd_ring(adapter); 2754 + card->cmdrsp_buf = NULL; 2755 + } 2756 + 2742 2757 /* 2743 2758 * This function initializes the PCI-E host memory space, WCB rings, etc. 2744 2759 * ··· 2865 2850 2866 2851 /* 2867 2852 * This function cleans up the allocated card buffers. 2868 - * 2869 - * The following are freed by this function - 2870 - * - TXBD ring buffers 2871 - * - RXBD ring buffers 2872 - * - Event BD ring buffers 2873 - * - Command response ring buffer 2874 - * - Sleep cookie buffer 2875 2853 */ 2876 2854 static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter) 2877 2855 { ··· 2882 2874 mwifiex_dbg(adapter, ERROR, 2883 2875 "Failed to write driver not-ready signature\n"); 2884 2876 } 2877 + 2878 + mwifiex_pcie_free_buffers(adapter); 2885 2879 2886 2880 if (pdev) { 2887 2881 pci_iounmap(pdev, card->pci_mmap); ··· 3136 3126 pci_iounmap(pdev, card->pci_mmap1); 3137 3127 } 3138 3128 3139 - /* This function cleans up the PCI-E host memory space. 3140 - * Some code is extracted from mwifiex_unregister_dev() 3141 - * 3142 - */ 3129 + /* This function cleans up the PCI-E host memory space. */ 3143 3130 static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter) 3144 3131 { 3145 3132 struct pcie_service_card *card = adapter->card; ··· 3147 3140 3148 3141 adapter->seq_num = 0; 3149 3142 3150 - if (reg->sleep_cookie) 3151 - mwifiex_pcie_delete_sleep_cookie_buf(adapter); 3152 - 3153 - mwifiex_pcie_delete_cmdrsp_buf(adapter); 3154 - mwifiex_pcie_delete_evtbd_ring(adapter); 3155 - mwifiex_pcie_delete_rxbd_ring(adapter); 3156 - mwifiex_pcie_delete_txbd_ring(adapter); 3157 - card->cmdrsp_buf = NULL; 3143 + mwifiex_pcie_free_buffers(adapter); 3158 3144 } 3159 3145 3160 3146 static struct mwifiex_if_ops pcie_ops = {
+41
drivers/vhost/vsock.c
··· 223 223 return len; 224 224 } 225 225 226 + static int 227 + vhost_transport_cancel_pkt(struct vsock_sock *vsk) 228 + { 229 + struct vhost_vsock *vsock; 230 + struct virtio_vsock_pkt *pkt, *n; 231 + int cnt = 0; 232 + LIST_HEAD(freeme); 233 + 234 + /* Find the vhost_vsock according to guest context id */ 235 + vsock = vhost_vsock_get(vsk->remote_addr.svm_cid); 236 + if (!vsock) 237 + return -ENODEV; 238 + 239 + spin_lock_bh(&vsock->send_pkt_list_lock); 240 + list_for_each_entry_safe(pkt, n, &vsock->send_pkt_list, list) { 241 + if (pkt->vsk != vsk) 242 + continue; 243 + list_move(&pkt->list, &freeme); 244 + } 245 + spin_unlock_bh(&vsock->send_pkt_list_lock); 246 + 247 + list_for_each_entry_safe(pkt, n, &freeme, list) { 248 + if (pkt->reply) 249 + cnt++; 250 + list_del(&pkt->list); 251 + virtio_transport_free_pkt(pkt); 252 + } 253 + 254 + if (cnt) { 255 + struct vhost_virtqueue *tx_vq = &vsock->vqs[VSOCK_VQ_TX]; 256 + int new_cnt; 257 + 258 + new_cnt = atomic_sub_return(cnt, &vsock->queued_replies); 259 + if (new_cnt + cnt >= tx_vq->num && new_cnt < tx_vq->num) 260 + vhost_poll_queue(&tx_vq->poll); 261 + } 262 + 263 + return 0; 264 + } 265 + 226 266 static struct virtio_vsock_pkt * 227 267 vhost_vsock_alloc_pkt(struct vhost_virtqueue *vq, 228 268 unsigned int out, unsigned int in) ··· 715 675 .release = virtio_transport_release, 716 676 .connect = virtio_transport_connect, 717 677 .shutdown = virtio_transport_shutdown, 678 + .cancel_pkt = vhost_transport_cancel_pkt, 718 679 719 680 .dgram_enqueue = virtio_transport_dgram_enqueue, 720 681 .dgram_dequeue = virtio_transport_dgram_dequeue,
+2
include/linux/errqueue.h
··· 20 20 struct sock_extended_err ee; 21 21 u16 addr_offset; 22 22 __be16 port; 23 + u8 opt_stats:1, 24 + unused:7; 23 25 }; 24 26 25 27 #endif
+1
include/linux/mlx4/device.h
··· 476 476 enum { 477 477 MLX4_INTERFACE_STATE_UP = 1 << 0, 478 478 MLX4_INTERFACE_STATE_DELETION = 1 << 1, 479 + MLX4_INTERFACE_STATE_NOWAIT = 1 << 2, 479 480 }; 480 481 481 482 #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
+3
include/linux/virtio_vsock.h
··· 48 48 struct virtio_vsock_hdr hdr; 49 49 struct work_struct work; 50 50 struct list_head list; 51 + /* socket refcnt not held, only use for cancellation */ 52 + struct vsock_sock *vsk; 51 53 void *buf; 52 54 u32 len; 53 55 u32 off; ··· 58 56 59 57 struct virtio_vsock_pkt_info { 60 58 u32 remote_cid, remote_port; 59 + struct vsock_sock *vsk; 61 60 struct msghdr *msg; 62 61 u32 pkt_len; 63 62 u16 type;
+3
include/net/af_vsock.h
··· 100 100 void (*destruct)(struct vsock_sock *); 101 101 void (*release)(struct vsock_sock *); 102 102 103 + /* Cancel all pending packets sent on vsock. */ 104 + int (*cancel_pkt)(struct vsock_sock *vsk); 105 + 103 106 /* Connections. */ 104 107 int (*connect)(struct vsock_sock *); 105 108
+1 -1
include/net/netfilter/nf_conntrack.h
··· 244 244 u32 seq); 245 245 246 246 /* Fake conntrack entry for untracked connections */ 247 - DECLARE_PER_CPU(struct nf_conn, nf_conntrack_untracked); 247 + DECLARE_PER_CPU_ALIGNED(struct nf_conn, nf_conntrack_untracked); 248 248 static inline struct nf_conn *nf_ct_untracked_get(void) 249 249 { 250 250 return raw_cpu_ptr(&nf_conntrack_untracked);
+29 -1
include/net/netfilter/nf_tables.h
··· 103 103 }; 104 104 }; 105 105 106 + /* Store/load an u16 or u8 integer to/from the u32 data register. 107 + * 108 + * Note, when using concatenations, register allocation happens at 32-bit 109 + * level. So for store instruction, pad the rest part with zero to avoid 110 + * garbage values. 111 + */ 112 + 113 + static inline void nft_reg_store16(u32 *dreg, u16 val) 114 + { 115 + *dreg = 0; 116 + *(u16 *)dreg = val; 117 + } 118 + 119 + static inline void nft_reg_store8(u32 *dreg, u8 val) 120 + { 121 + *dreg = 0; 122 + *(u8 *)dreg = val; 123 + } 124 + 125 + static inline u16 nft_reg_load16(u32 *sreg) 126 + { 127 + return *(u16 *)sreg; 128 + } 129 + 130 + static inline u8 nft_reg_load8(u32 *sreg) 131 + { 132 + return *(u8 *)sreg; 133 + } 134 + 106 135 static inline void nft_data_copy(u32 *dst, const struct nft_data *src, 107 136 unsigned int len) 108 137 { ··· 232 203 struct nft_set; 233 204 struct nft_set_iter { 234 205 u8 genmask; 235 - bool flush; 236 206 unsigned int count; 237 207 unsigned int skip; 238 208 int err;
+4 -2
include/net/netfilter/nf_tables_ipv6.h
··· 9 9 struct sk_buff *skb, 10 10 const struct nf_hook_state *state) 11 11 { 12 + unsigned int flags = IP6_FH_F_AUTH; 12 13 int protohdr, thoff = 0; 13 14 unsigned short frag_off; 14 15 15 16 nft_set_pktinfo(pkt, skb, state); 16 17 17 - protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL); 18 + protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags); 18 19 if (protohdr < 0) { 19 20 nft_set_pktinfo_proto_unspec(pkt, skb); 20 21 return; ··· 33 32 const struct nf_hook_state *state) 34 33 { 35 34 #if IS_ENABLED(CONFIG_IPV6) 35 + unsigned int flags = IP6_FH_F_AUTH; 36 36 struct ipv6hdr *ip6h, _ip6h; 37 37 unsigned int thoff = 0; 38 38 unsigned short frag_off; ··· 52 50 if (pkt_len + sizeof(*ip6h) > skb->len) 53 51 return -1; 54 52 55 - protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL); 53 + protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags); 56 54 if (protohdr < 0) 57 55 return -1; 58 56
+3 -2
include/net/sctp/structs.h
··· 83 83 struct sctp_ulpq; 84 84 struct sctp_ep_common; 85 85 struct crypto_shash; 86 + struct sctp_stream; 86 87 87 88 88 89 #include <net/sctp/tsnmap.h> ··· 754 753 /* Is the Path MTU update pending on this tranport */ 755 754 pmtu_pending:1, 756 755 756 + dst_pending_confirm:1, /* need to confirm neighbour */ 757 + 757 758 /* Has this transport moved the ctsn since we last sacked */ 758 759 sack_generation:1; 759 760 u32 dst_cookie; ··· 808 805 __u32 flight_size; 809 806 810 807 __u32 burst_limited; /* Holds old cwnd when max.burst is applied */ 811 - 812 - __u32 dst_pending_confirm; /* need to confirm neighbour */ 813 808 814 809 /* Destination */ 815 810 struct dst_entry *dst;
+72 -74
kernel/bpf/hashtab.c
··· 30 30 struct pcpu_freelist freelist; 31 31 struct bpf_lru lru; 32 32 }; 33 - void __percpu *extra_elems; 33 + struct htab_elem *__percpu *extra_elems; 34 34 atomic_t count; /* number of elements in this hashtable */ 35 35 u32 n_buckets; /* number of hash buckets */ 36 36 u32 elem_size; /* size of each element in bytes */ 37 - }; 38 - 39 - enum extra_elem_state { 40 - HTAB_NOT_AN_EXTRA_ELEM = 0, 41 - HTAB_EXTRA_ELEM_FREE, 42 - HTAB_EXTRA_ELEM_USED 43 37 }; 44 38 45 39 /* each htab element is struct htab_elem + key + value */ ··· 50 56 }; 51 57 union { 52 58 struct rcu_head rcu; 53 - enum extra_elem_state state; 54 59 struct bpf_lru_node lru_node; 55 60 }; 56 61 u32 hash; ··· 68 75 { 69 76 return htab->map.map_type == BPF_MAP_TYPE_PERCPU_HASH || 70 77 htab->map.map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH; 78 + } 79 + 80 + static bool htab_is_prealloc(const struct bpf_htab *htab) 81 + { 82 + return !(htab->map.map_flags & BPF_F_NO_PREALLOC); 71 83 } 72 84 73 85 static inline void htab_elem_set_ptr(struct htab_elem *l, u32 key_size, ··· 126 128 127 129 static int prealloc_init(struct bpf_htab *htab) 128 130 { 131 + u32 num_entries = htab->map.max_entries; 129 132 int err = -ENOMEM, i; 130 133 131 - htab->elems = bpf_map_area_alloc(htab->elem_size * 132 - htab->map.max_entries); 134 + if (!htab_is_percpu(htab) && !htab_is_lru(htab)) 135 + num_entries += num_possible_cpus(); 136 + 137 + htab->elems = bpf_map_area_alloc(htab->elem_size * num_entries); 133 138 if (!htab->elems) 134 139 return -ENOMEM; 135 140 136 141 if (!htab_is_percpu(htab)) 137 142 goto skip_percpu_elems; 138 143 139 - for (i = 0; i < htab->map.max_entries; i++) { 144 + for (i = 0; i < num_entries; i++) { 140 145 u32 size = round_up(htab->map.value_size, 8); 141 146 void __percpu *pptr; 142 147 ··· 167 166 if (htab_is_lru(htab)) 168 167 bpf_lru_populate(&htab->lru, htab->elems, 169 168 offsetof(struct htab_elem, lru_node), 170 - htab->elem_size, htab->map.max_entries); 169 + htab->elem_size, num_entries); 171 170 else 172 171 pcpu_freelist_populate(&htab->freelist, 173 172 htab->elems + offsetof(struct htab_elem, fnode), 174 - htab->elem_size, htab->map.max_entries); 173 + htab->elem_size, num_entries); 175 174 176 175 return 0; 177 176 ··· 192 191 193 192 static int alloc_extra_elems(struct bpf_htab *htab) 194 193 { 195 - void __percpu *pptr; 194 + struct htab_elem *__percpu *pptr, *l_new; 195 + struct pcpu_freelist_node *l; 196 196 int cpu; 197 197 198 - pptr = __alloc_percpu_gfp(htab->elem_size, 8, GFP_USER | __GFP_NOWARN); 198 + pptr = __alloc_percpu_gfp(sizeof(struct htab_elem *), 8, 199 + GFP_USER | __GFP_NOWARN); 199 200 if (!pptr) 200 201 return -ENOMEM; 201 202 202 203 for_each_possible_cpu(cpu) { 203 - ((struct htab_elem *)per_cpu_ptr(pptr, cpu))->state = 204 - HTAB_EXTRA_ELEM_FREE; 204 + l = pcpu_freelist_pop(&htab->freelist); 205 + /* pop will succeed, since prealloc_init() 206 + * preallocated extra num_possible_cpus elements 207 + */ 208 + l_new = container_of(l, struct htab_elem, fnode); 209 + *per_cpu_ptr(pptr, cpu) = l_new; 205 210 } 206 211 htab->extra_elems = pptr; 207 212 return 0; ··· 349 342 raw_spin_lock_init(&htab->buckets[i].lock); 350 343 } 351 344 352 - if (!percpu && !lru) { 353 - /* lru itself can remove the least used element, so 354 - * there is no need for an extra elem during map_update. 355 - */ 356 - err = alloc_extra_elems(htab); 357 - if (err) 358 - goto free_buckets; 359 - } 360 - 361 345 if (prealloc) { 362 346 err = prealloc_init(htab); 363 347 if (err) 364 - goto free_extra_elems; 348 + goto free_buckets; 349 + 350 + if (!percpu && !lru) { 351 + /* lru itself can remove the least used element, so 352 + * there is no need for an extra elem during map_update. 353 + */ 354 + err = alloc_extra_elems(htab); 355 + if (err) 356 + goto free_prealloc; 357 + } 365 358 } 366 359 367 360 return &htab->map; 368 361 369 - free_extra_elems: 370 - free_percpu(htab->extra_elems); 362 + free_prealloc: 363 + prealloc_destroy(htab); 371 364 free_buckets: 372 365 bpf_map_area_free(htab->buckets); 373 366 free_htab: ··· 582 575 583 576 static void free_htab_elem(struct bpf_htab *htab, struct htab_elem *l) 584 577 { 585 - if (l->state == HTAB_EXTRA_ELEM_USED) { 586 - l->state = HTAB_EXTRA_ELEM_FREE; 587 - return; 588 - } 589 - 590 - if (!(htab->map.map_flags & BPF_F_NO_PREALLOC)) { 578 + if (htab_is_prealloc(htab)) { 591 579 pcpu_freelist_push(&htab->freelist, &l->fnode); 592 580 } else { 593 581 atomic_dec(&htab->count); ··· 612 610 static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key, 613 611 void *value, u32 key_size, u32 hash, 614 612 bool percpu, bool onallcpus, 615 - bool old_elem_exists) 613 + struct htab_elem *old_elem) 616 614 { 617 615 u32 size = htab->map.value_size; 618 - bool prealloc = !(htab->map.map_flags & BPF_F_NO_PREALLOC); 619 - struct htab_elem *l_new; 616 + bool prealloc = htab_is_prealloc(htab); 617 + struct htab_elem *l_new, **pl_new; 620 618 void __percpu *pptr; 621 - int err = 0; 622 619 623 620 if (prealloc) { 624 - struct pcpu_freelist_node *l; 625 - 626 - l = pcpu_freelist_pop(&htab->freelist); 627 - if (!l) 628 - err = -E2BIG; 629 - else 630 - l_new = container_of(l, struct htab_elem, fnode); 631 - } else { 632 - if (atomic_inc_return(&htab->count) > htab->map.max_entries) { 633 - atomic_dec(&htab->count); 634 - err = -E2BIG; 621 + if (old_elem) { 622 + /* if we're updating the existing element, 623 + * use per-cpu extra elems to avoid freelist_pop/push 624 + */ 625 + pl_new = this_cpu_ptr(htab->extra_elems); 626 + l_new = *pl_new; 627 + *pl_new = old_elem; 635 628 } else { 636 - l_new = kmalloc(htab->elem_size, 637 - GFP_ATOMIC | __GFP_NOWARN); 638 - if (!l_new) 639 - return ERR_PTR(-ENOMEM); 629 + struct pcpu_freelist_node *l; 630 + 631 + l = pcpu_freelist_pop(&htab->freelist); 632 + if (!l) 633 + return ERR_PTR(-E2BIG); 634 + l_new = container_of(l, struct htab_elem, fnode); 640 635 } 641 - } 642 - 643 - if (err) { 644 - if (!old_elem_exists) 645 - return ERR_PTR(err); 646 - 647 - /* if we're updating the existing element and the hash table 648 - * is full, use per-cpu extra elems 649 - */ 650 - l_new = this_cpu_ptr(htab->extra_elems); 651 - if (l_new->state != HTAB_EXTRA_ELEM_FREE) 652 - return ERR_PTR(-E2BIG); 653 - l_new->state = HTAB_EXTRA_ELEM_USED; 654 636 } else { 655 - l_new->state = HTAB_NOT_AN_EXTRA_ELEM; 637 + if (atomic_inc_return(&htab->count) > htab->map.max_entries) 638 + if (!old_elem) { 639 + /* when map is full and update() is replacing 640 + * old element, it's ok to allocate, since 641 + * old element will be freed immediately. 642 + * Otherwise return an error 643 + */ 644 + atomic_dec(&htab->count); 645 + return ERR_PTR(-E2BIG); 646 + } 647 + l_new = kmalloc(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN); 648 + if (!l_new) 649 + return ERR_PTR(-ENOMEM); 656 650 } 657 651 658 652 memcpy(l_new->key, key, key_size); ··· 729 731 goto err; 730 732 731 733 l_new = alloc_htab_elem(htab, key, value, key_size, hash, false, false, 732 - !!l_old); 734 + l_old); 733 735 if (IS_ERR(l_new)) { 734 736 /* all pre-allocated elements are in use or memory exhausted */ 735 737 ret = PTR_ERR(l_new); ··· 742 744 hlist_nulls_add_head_rcu(&l_new->hash_node, head); 743 745 if (l_old) { 744 746 hlist_nulls_del_rcu(&l_old->hash_node); 745 - free_htab_elem(htab, l_old); 747 + if (!htab_is_prealloc(htab)) 748 + free_htab_elem(htab, l_old); 746 749 } 747 750 ret = 0; 748 751 err: ··· 855 856 value, onallcpus); 856 857 } else { 857 858 l_new = alloc_htab_elem(htab, key, value, key_size, 858 - hash, true, onallcpus, false); 859 + hash, true, onallcpus, NULL); 859 860 if (IS_ERR(l_new)) { 860 861 ret = PTR_ERR(l_new); 861 862 goto err; ··· 1023 1024 1024 1025 hlist_nulls_for_each_entry_safe(l, n, head, hash_node) { 1025 1026 hlist_nulls_del_rcu(&l->hash_node); 1026 - if (l->state != HTAB_EXTRA_ELEM_USED) 1027 - htab_elem_free(htab, l); 1027 + htab_elem_free(htab, l); 1028 1028 } 1029 1029 } 1030 1030 } ··· 1043 1045 * not have executed. Wait for them. 1044 1046 */ 1045 1047 rcu_barrier(); 1046 - if (htab->map.map_flags & BPF_F_NO_PREALLOC) 1048 + if (!htab_is_prealloc(htab)) 1047 1049 delete_all_elements(htab); 1048 1050 else 1049 1051 prealloc_destroy(htab);
+11
net/batman-adv/bat_iv_ogm.c
··· 2477 2477 batadv_iv_ogm_schedule(hard_iface); 2478 2478 } 2479 2479 2480 + /** 2481 + * batadv_iv_init_sel_class - initialize GW selection class 2482 + * @bat_priv: the bat priv with all the soft interface information 2483 + */ 2484 + static void batadv_iv_init_sel_class(struct batadv_priv *bat_priv) 2485 + { 2486 + /* set default TQ difference threshold to 20 */ 2487 + atomic_set(&bat_priv->gw.sel_class, 20); 2488 + } 2489 + 2480 2490 static struct batadv_gw_node * 2481 2491 batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv) 2482 2492 { ··· 2833 2823 .del_if = batadv_iv_ogm_orig_del_if, 2834 2824 }, 2835 2825 .gw = { 2826 + .init_sel_class = batadv_iv_init_sel_class, 2836 2827 .get_best_gw_node = batadv_iv_gw_get_best_gw_node, 2837 2828 .is_eligible = batadv_iv_gw_is_eligible, 2838 2829 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
+11 -3
net/batman-adv/bat_v.c
··· 668 668 return ret; 669 669 } 670 670 671 + /** 672 + * batadv_v_init_sel_class - initialize GW selection class 673 + * @bat_priv: the bat priv with all the soft interface information 674 + */ 675 + static void batadv_v_init_sel_class(struct batadv_priv *bat_priv) 676 + { 677 + /* set default throughput difference threshold to 5Mbps */ 678 + atomic_set(&bat_priv->gw.sel_class, 50); 679 + } 680 + 671 681 static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv, 672 682 char *buff, size_t count) 673 683 { ··· 1062 1052 .dump = batadv_v_orig_dump, 1063 1053 }, 1064 1054 .gw = { 1055 + .init_sel_class = batadv_v_init_sel_class, 1065 1056 .store_sel_class = batadv_v_store_sel_class, 1066 1057 .show_sel_class = batadv_v_show_sel_class, 1067 1058 .get_best_gw_node = batadv_v_gw_get_best_gw_node, ··· 1102 1091 ret = batadv_v_ogm_init(bat_priv); 1103 1092 if (ret < 0) 1104 1093 return ret; 1105 - 1106 - /* set default throughput difference threshold to 5Mbps */ 1107 - atomic_set(&bat_priv->gw.sel_class, 50); 1108 1094 1109 1095 return 0; 1110 1096 }
+13 -7
net/batman-adv/fragmentation.c
··· 404 404 * batadv_frag_create - create a fragment from skb 405 405 * @skb: skb to create fragment from 406 406 * @frag_head: header to use in new fragment 407 - * @mtu: size of new fragment 407 + * @fragment_size: size of new fragment 408 408 * 409 409 * Split the passed skb into two fragments: A new one with size matching the 410 410 * passed mtu and the old one with the rest. The new skb contains data from the ··· 414 414 */ 415 415 static struct sk_buff *batadv_frag_create(struct sk_buff *skb, 416 416 struct batadv_frag_packet *frag_head, 417 - unsigned int mtu) 417 + unsigned int fragment_size) 418 418 { 419 419 struct sk_buff *skb_fragment; 420 420 unsigned int header_size = sizeof(*frag_head); 421 - unsigned int fragment_size = mtu - header_size; 421 + unsigned int mtu = fragment_size + header_size; 422 422 423 423 skb_fragment = netdev_alloc_skb(NULL, mtu + ETH_HLEN); 424 424 if (!skb_fragment) ··· 456 456 struct sk_buff *skb_fragment; 457 457 unsigned int mtu = neigh_node->if_incoming->net_dev->mtu; 458 458 unsigned int header_size = sizeof(frag_header); 459 - unsigned int max_fragment_size, max_packet_size; 459 + unsigned int max_fragment_size, num_fragments; 460 460 int ret; 461 461 462 462 /* To avoid merge and refragmentation at next-hops we never send ··· 464 464 */ 465 465 mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE); 466 466 max_fragment_size = mtu - header_size; 467 - max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS; 467 + 468 + if (skb->len == 0 || max_fragment_size == 0) 469 + return -EINVAL; 470 + 471 + num_fragments = (skb->len - 1) / max_fragment_size + 1; 472 + max_fragment_size = (skb->len - 1) / num_fragments + 1; 468 473 469 474 /* Don't even try to fragment, if we need more than 16 fragments */ 470 - if (skb->len > max_packet_size) { 475 + if (num_fragments > BATADV_FRAG_MAX_FRAGMENTS) { 471 476 ret = -EAGAIN; 472 477 goto free_skb; 473 478 } ··· 512 507 goto put_primary_if; 513 508 } 514 509 515 - skb_fragment = batadv_frag_create(skb, &frag_header, mtu); 510 + skb_fragment = batadv_frag_create(skb, &frag_header, 511 + max_fragment_size); 516 512 if (!skb_fragment) { 517 513 ret = -ENOMEM; 518 514 goto put_primary_if;
+5
net/batman-adv/gateway_common.c
··· 253 253 */ 254 254 void batadv_gw_init(struct batadv_priv *bat_priv) 255 255 { 256 + if (bat_priv->algo_ops->gw.init_sel_class) 257 + bat_priv->algo_ops->gw.init_sel_class(bat_priv); 258 + else 259 + atomic_set(&bat_priv->gw.sel_class, 1); 260 + 256 261 batadv_tvlv_handler_register(bat_priv, batadv_gw_tvlv_ogm_handler_v1, 257 262 NULL, BATADV_TVLV_GW, 1, 258 263 BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
-1
net/batman-adv/soft-interface.c
··· 819 819 atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0); 820 820 #endif 821 821 atomic_set(&bat_priv->gw.mode, BATADV_GW_MODE_OFF); 822 - atomic_set(&bat_priv->gw.sel_class, 20); 823 822 atomic_set(&bat_priv->gw.bandwidth_down, 100); 824 823 atomic_set(&bat_priv->gw.bandwidth_up, 20); 825 824 atomic_set(&bat_priv->orig_interval, 1000);
+2
net/batman-adv/types.h
··· 1489 1489 1490 1490 /** 1491 1491 * struct batadv_algo_gw_ops - mesh algorithm callbacks (GW specific) 1492 + * @init_sel_class: initialize GW selection class (optional) 1492 1493 * @store_sel_class: parse and stores a new GW selection class (optional) 1493 1494 * @show_sel_class: prints the current GW selection class (optional) 1494 1495 * @get_best_gw_node: select the best GW from the list of available nodes ··· 1500 1499 * @dump: dump gateways to a netlink socket (optional) 1501 1500 */ 1502 1501 struct batadv_algo_gw_ops { 1502 + void (*init_sel_class)(struct batadv_priv *bat_priv); 1503 1503 ssize_t (*store_sel_class)(struct batadv_priv *bat_priv, char *buff, 1504 1504 size_t count); 1505 1505 ssize_t (*show_sel_class)(struct batadv_priv *bat_priv, char *buff);
+1 -1
net/bridge/br_fdb.c
··· 106 106 struct hlist_head *head = &br->hash[br_mac_hash(addr, vid)]; 107 107 struct net_bridge_fdb_entry *fdb; 108 108 109 - WARN_ON_ONCE(!br_hash_lock_held(br)); 109 + lockdep_assert_held_once(&br->hash_lock); 110 110 111 111 rcu_read_lock(); 112 112 fdb = fdb_find_rcu(head, addr, vid);
+7 -5
net/bridge/br_netfilter_hooks.c
··· 706 706 707 707 static int br_nf_dev_queue_xmit(struct net *net, struct sock *sk, struct sk_buff *skb) 708 708 { 709 - struct nf_bridge_info *nf_bridge; 710 - unsigned int mtu_reserved; 709 + struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); 710 + unsigned int mtu, mtu_reserved; 711 711 712 712 mtu_reserved = nf_bridge_mtu_reduction(skb); 713 + mtu = skb->dev->mtu; 713 714 714 - if (skb_is_gso(skb) || skb->len + mtu_reserved <= skb->dev->mtu) { 715 + if (nf_bridge->frag_max_size && nf_bridge->frag_max_size < mtu) 716 + mtu = nf_bridge->frag_max_size; 717 + 718 + if (skb_is_gso(skb) || skb->len + mtu_reserved <= mtu) { 715 719 nf_bridge_info_free(skb); 716 720 return br_dev_queue_push_xmit(net, sk, skb); 717 721 } 718 - 719 - nf_bridge = nf_bridge_info_get(skb); 720 722 721 723 /* This is wrong! We should preserve the original fragment 722 724 * boundaries by preserving frag_list rather than refragmenting.
-9
net/bridge/br_private.h
··· 531 531 int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p, 532 532 const unsigned char *addr, u16 vid); 533 533 534 - static inline bool br_hash_lock_held(struct net_bridge *br) 535 - { 536 - #ifdef CONFIG_LOCKDEP 537 - return lockdep_is_held(&br->hash_lock); 538 - #else 539 - return true; 540 - #endif 541 - } 542 - 543 534 /* br_forward.c */ 544 535 enum br_pkt_type { 545 536 BR_PKT_UNICAST,
+18 -18
net/core/netclassid_cgroup.c
··· 71 71 return 0; 72 72 } 73 73 74 - static void update_classid(struct cgroup_subsys_state *css, void *v) 75 - { 76 - struct css_task_iter it; 77 - struct task_struct *p; 78 - 79 - css_task_iter_start(css, &it); 80 - while ((p = css_task_iter_next(&it))) { 81 - task_lock(p); 82 - iterate_fd(p->files, 0, update_classid_sock, v); 83 - task_unlock(p); 84 - } 85 - css_task_iter_end(&it); 86 - } 87 - 88 74 static void cgrp_attach(struct cgroup_taskset *tset) 89 75 { 90 76 struct cgroup_subsys_state *css; 77 + struct task_struct *p; 91 78 92 - cgroup_taskset_first(tset, &css); 93 - update_classid(css, 94 - (void *)(unsigned long)css_cls_state(css)->classid); 79 + cgroup_taskset_for_each(p, css, tset) { 80 + task_lock(p); 81 + iterate_fd(p->files, 0, update_classid_sock, 82 + (void *)(unsigned long)css_cls_state(css)->classid); 83 + task_unlock(p); 84 + } 95 85 } 96 86 97 87 static u64 read_classid(struct cgroup_subsys_state *css, struct cftype *cft) ··· 93 103 u64 value) 94 104 { 95 105 struct cgroup_cls_state *cs = css_cls_state(css); 106 + struct css_task_iter it; 107 + struct task_struct *p; 96 108 97 109 cgroup_sk_alloc_disable(); 98 110 99 111 cs->classid = (u32)value; 100 112 101 - update_classid(css, (void *)(unsigned long)cs->classid); 113 + css_task_iter_start(css, &it); 114 + while ((p = css_task_iter_next(&it))) { 115 + task_lock(p); 116 + iterate_fd(p->files, 0, update_classid_sock, 117 + (void *)(unsigned long)cs->classid); 118 + task_unlock(p); 119 + } 120 + css_task_iter_end(&it); 121 + 102 122 return 0; 103 123 } 104 124
+21 -6
net/core/skbuff.c
··· 3694 3694 atomic_sub(skb->truesize, &sk->sk_rmem_alloc); 3695 3695 } 3696 3696 3697 + static void skb_set_err_queue(struct sk_buff *skb) 3698 + { 3699 + /* pkt_type of skbs received on local sockets is never PACKET_OUTGOING. 3700 + * So, it is safe to (mis)use it to mark skbs on the error queue. 3701 + */ 3702 + skb->pkt_type = PACKET_OUTGOING; 3703 + BUILD_BUG_ON(PACKET_OUTGOING == 0); 3704 + } 3705 + 3697 3706 /* 3698 3707 * Note: We dont mem charge error packets (no sk_forward_alloc changes) 3699 3708 */ ··· 3716 3707 skb->sk = sk; 3717 3708 skb->destructor = sock_rmem_free; 3718 3709 atomic_add(skb->truesize, &sk->sk_rmem_alloc); 3710 + skb_set_err_queue(skb); 3719 3711 3720 3712 /* before exiting rcu section, make sure dst is refcounted */ 3721 3713 skb_dst_force(skb); ··· 3793 3783 3794 3784 static void __skb_complete_tx_timestamp(struct sk_buff *skb, 3795 3785 struct sock *sk, 3796 - int tstype) 3786 + int tstype, 3787 + bool opt_stats) 3797 3788 { 3798 3789 struct sock_exterr_skb *serr; 3799 3790 int err; 3791 + 3792 + BUILD_BUG_ON(sizeof(struct sock_exterr_skb) > sizeof(skb->cb)); 3800 3793 3801 3794 serr = SKB_EXT_ERR(skb); 3802 3795 memset(serr, 0, sizeof(*serr)); 3803 3796 serr->ee.ee_errno = ENOMSG; 3804 3797 serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING; 3805 3798 serr->ee.ee_info = tstype; 3799 + serr->opt_stats = opt_stats; 3806 3800 if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) { 3807 3801 serr->ee.ee_data = skb_shinfo(skb)->tskey; 3808 3802 if (sk->sk_protocol == IPPROTO_TCP && ··· 3847 3833 */ 3848 3834 if (likely(atomic_inc_not_zero(&sk->sk_refcnt))) { 3849 3835 *skb_hwtstamps(skb) = *hwtstamps; 3850 - __skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND); 3836 + __skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND, false); 3851 3837 sock_put(sk); 3852 3838 } 3853 3839 } ··· 3858 3844 struct sock *sk, int tstype) 3859 3845 { 3860 3846 struct sk_buff *skb; 3861 - bool tsonly; 3847 + bool tsonly, opt_stats = false; 3862 3848 3863 3849 if (!sk) 3864 3850 return; ··· 3871 3857 #ifdef CONFIG_INET 3872 3858 if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_STATS) && 3873 3859 sk->sk_protocol == IPPROTO_TCP && 3874 - sk->sk_type == SOCK_STREAM) 3860 + sk->sk_type == SOCK_STREAM) { 3875 3861 skb = tcp_get_timestamping_opt_stats(sk); 3876 - else 3862 + opt_stats = true; 3863 + } else 3877 3864 #endif 3878 3865 skb = alloc_skb(0, GFP_ATOMIC); 3879 3866 } else { ··· 3893 3878 else 3894 3879 skb->tstamp = ktime_get_real(); 3895 3880 3896 - __skb_complete_tx_timestamp(skb, sk, tstype); 3881 + __skb_complete_tx_timestamp(skb, sk, tstype, opt_stats); 3897 3882 } 3898 3883 EXPORT_SYMBOL_GPL(__skb_tstamp_tx); 3899 3884
+11 -5
net/core/sock.c
··· 1442 1442 pr_debug("%s: optmem leakage (%d bytes) detected\n", 1443 1443 __func__, atomic_read(&sk->sk_omem_alloc)); 1444 1444 1445 + if (sk->sk_frag.page) { 1446 + put_page(sk->sk_frag.page); 1447 + sk->sk_frag.page = NULL; 1448 + } 1449 + 1445 1450 if (sk->sk_peer_cred) 1446 1451 put_cred(sk->sk_peer_cred); 1447 1452 put_pid(sk->sk_peer_pid); ··· 1544 1539 is_charged = sk_filter_charge(newsk, filter); 1545 1540 1546 1541 if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk, sk))) { 1542 + /* We need to make sure that we don't uncharge the new 1543 + * socket if we couldn't charge it in the first place 1544 + * as otherwise we uncharge the parent's filter. 1545 + */ 1546 + if (!is_charged) 1547 + RCU_INIT_POINTER(newsk->sk_filter, NULL); 1547 1548 sk_free_unlock_clone(newsk); 1548 1549 newsk = NULL; 1549 1550 goto out; ··· 2797 2786 xfrm_sk_free_policy(sk); 2798 2787 2799 2788 sk_refcnt_debug_release(sk); 2800 - 2801 - if (sk->sk_frag.page) { 2802 - put_page(sk->sk_frag.page); 2803 - sk->sk_frag.page = NULL; 2804 - } 2805 2789 2806 2790 sock_put(sk); 2807 2791 }
+2 -1
net/ipv4/fib_frontend.c
··· 1083 1083 1084 1084 net = sock_net(skb->sk); 1085 1085 nlh = nlmsg_hdr(skb); 1086 - if (skb->len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len || 1086 + if (skb->len < nlmsg_total_size(sizeof(*frn)) || 1087 + skb->len < nlh->nlmsg_len || 1087 1088 nlmsg_len(nlh) < sizeof(*frn)) 1088 1089 return; 1089 1090
+17 -8
net/ipv4/ip_fragment.c
··· 198 198 qp = container_of((struct inet_frag_queue *) arg, struct ipq, q); 199 199 net = container_of(qp->q.net, struct net, ipv4.frags); 200 200 201 + rcu_read_lock(); 201 202 spin_lock(&qp->q.lock); 202 203 203 204 if (qp->q.flags & INET_FRAG_COMPLETE) ··· 208 207 __IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS); 209 208 210 209 if (!inet_frag_evicting(&qp->q)) { 211 - struct sk_buff *head = qp->q.fragments; 210 + struct sk_buff *clone, *head = qp->q.fragments; 212 211 const struct iphdr *iph; 213 212 int err; 214 213 ··· 217 216 if (!(qp->q.flags & INET_FRAG_FIRST_IN) || !qp->q.fragments) 218 217 goto out; 219 218 220 - rcu_read_lock(); 221 219 head->dev = dev_get_by_index_rcu(net, qp->iif); 222 220 if (!head->dev) 223 - goto out_rcu_unlock; 221 + goto out; 222 + 224 223 225 224 /* skb has no dst, perform route lookup again */ 226 225 iph = ip_hdr(head); 227 226 err = ip_route_input_noref(head, iph->daddr, iph->saddr, 228 227 iph->tos, head->dev); 229 228 if (err) 230 - goto out_rcu_unlock; 229 + goto out; 231 230 232 231 /* Only an end host needs to send an ICMP 233 232 * "Fragment Reassembly Timeout" message, per RFC792. 234 233 */ 235 234 if (frag_expire_skip_icmp(qp->user) && 236 235 (skb_rtable(head)->rt_type != RTN_LOCAL)) 237 - goto out_rcu_unlock; 236 + goto out; 237 + 238 + clone = skb_clone(head, GFP_ATOMIC); 238 239 239 240 /* Send an ICMP "Fragment Reassembly Timeout" message. */ 240 - icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); 241 - out_rcu_unlock: 242 - rcu_read_unlock(); 241 + if (clone) { 242 + spin_unlock(&qp->q.lock); 243 + icmp_send(clone, ICMP_TIME_EXCEEDED, 244 + ICMP_EXC_FRAGTIME, 0); 245 + consume_skb(clone); 246 + goto out_rcu_unlock; 247 + } 243 248 } 244 249 out: 245 250 spin_unlock(&qp->q.lock); 251 + out_rcu_unlock: 252 + rcu_read_unlock(); 246 253 ipq_put(qp); 247 254 } 248 255
+4
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
··· 165 165 if (skb->len < sizeof(struct iphdr) || 166 166 ip_hdrlen(skb) < sizeof(struct iphdr)) 167 167 return NF_ACCEPT; 168 + 169 + if (ip_is_fragment(ip_hdr(skb))) /* IP_NODEFRAG setsockopt set */ 170 + return NF_ACCEPT; 171 + 168 172 return nf_conntrack_in(state->net, PF_INET, state->hook, skb); 169 173 } 170 174
-5
net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
··· 255 255 /* maniptype == SRC for postrouting. */ 256 256 enum nf_nat_manip_type maniptype = HOOK2MANIP(state->hook); 257 257 258 - /* We never see fragments: conntrack defrags on pre-routing 259 - * and local-out, and nf_nat_out protects post-routing. 260 - */ 261 - NF_CT_ASSERT(!ip_is_fragment(ip_hdr(skb))); 262 - 263 258 ct = nf_ct_get(skb, &ctinfo); 264 259 /* Can't track? It's not due to stress, or conntrack would 265 260 * have dropped it. Hence it's the user's responsibilty to
+4 -4
net/ipv4/netfilter/nft_masq_ipv4.c
··· 26 26 memset(&range, 0, sizeof(range)); 27 27 range.flags = priv->flags; 28 28 if (priv->sreg_proto_min) { 29 - range.min_proto.all = 30 - *(__be16 *)&regs->data[priv->sreg_proto_min]; 31 - range.max_proto.all = 32 - *(__be16 *)&regs->data[priv->sreg_proto_max]; 29 + range.min_proto.all = (__force __be16)nft_reg_load16( 30 + &regs->data[priv->sreg_proto_min]); 31 + range.max_proto.all = (__force __be16)nft_reg_load16( 32 + &regs->data[priv->sreg_proto_max]); 33 33 } 34 34 regs->verdict.code = nf_nat_masquerade_ipv4(pkt->skb, nft_hook(pkt), 35 35 &range, nft_out(pkt));
+4 -4
net/ipv4/netfilter/nft_redir_ipv4.c
··· 26 26 27 27 memset(&mr, 0, sizeof(mr)); 28 28 if (priv->sreg_proto_min) { 29 - mr.range[0].min.all = 30 - *(__be16 *)&regs->data[priv->sreg_proto_min]; 31 - mr.range[0].max.all = 32 - *(__be16 *)&regs->data[priv->sreg_proto_max]; 29 + mr.range[0].min.all = (__force __be16)nft_reg_load16( 30 + &regs->data[priv->sreg_proto_min]); 31 + mr.range[0].max.all = (__force __be16)nft_reg_load16( 32 + &regs->data[priv->sreg_proto_max]); 33 33 mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED; 34 34 } 35 35
+2 -1
net/ipv4/tcp.c
··· 2770 2770 { 2771 2771 const struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */ 2772 2772 const struct inet_connection_sock *icsk = inet_csk(sk); 2773 - u32 now = tcp_time_stamp, intv; 2773 + u32 now, intv; 2774 2774 u64 rate64; 2775 2775 bool slow; 2776 2776 u32 rate; ··· 2839 2839 info->tcpi_retrans = tp->retrans_out; 2840 2840 info->tcpi_fackets = tp->fackets_out; 2841 2841 2842 + now = tcp_time_stamp; 2842 2843 info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime); 2843 2844 info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime); 2844 2845 info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);
+1 -1
net/ipv4/tcp_input.c
··· 5541 5541 struct inet_connection_sock *icsk = inet_csk(sk); 5542 5542 5543 5543 tcp_set_state(sk, TCP_ESTABLISHED); 5544 + icsk->icsk_ack.lrcvtime = tcp_time_stamp; 5544 5545 5545 5546 if (skb) { 5546 5547 icsk->icsk_af_ops->sk_rx_dst_set(sk, skb); ··· 5760 5759 * to stand against the temptation 8) --ANK 5761 5760 */ 5762 5761 inet_csk_schedule_ack(sk); 5763 - icsk->icsk_ack.lrcvtime = tcp_time_stamp; 5764 5762 tcp_enter_quickack_mode(sk); 5765 5763 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5766 5764 TCP_DELACK_MAX, TCP_RTO_MAX);
+1
net/ipv4/tcp_minisocks.c
··· 460 460 newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT); 461 461 minmax_reset(&newtp->rtt_min, tcp_time_stamp, ~0U); 462 462 newicsk->icsk_rto = TCP_TIMEOUT_INIT; 463 + newicsk->icsk_ack.lrcvtime = tcp_time_stamp; 463 464 464 465 newtp->packets_out = 0; 465 466 newtp->retrans_out = 0;
+4 -4
net/ipv6/netfilter/nft_masq_ipv6.c
··· 27 27 memset(&range, 0, sizeof(range)); 28 28 range.flags = priv->flags; 29 29 if (priv->sreg_proto_min) { 30 - range.min_proto.all = 31 - *(__be16 *)&regs->data[priv->sreg_proto_min]; 32 - range.max_proto.all = 33 - *(__be16 *)&regs->data[priv->sreg_proto_max]; 30 + range.min_proto.all = (__force __be16)nft_reg_load16( 31 + &regs->data[priv->sreg_proto_min]); 32 + range.max_proto.all = (__force __be16)nft_reg_load16( 33 + &regs->data[priv->sreg_proto_max]); 34 34 } 35 35 regs->verdict.code = nf_nat_masquerade_ipv6(pkt->skb, &range, 36 36 nft_out(pkt));
+4 -4
net/ipv6/netfilter/nft_redir_ipv6.c
··· 26 26 27 27 memset(&range, 0, sizeof(range)); 28 28 if (priv->sreg_proto_min) { 29 - range.min_proto.all = 30 - *(__be16 *)&regs->data[priv->sreg_proto_min], 31 - range.max_proto.all = 32 - *(__be16 *)&regs->data[priv->sreg_proto_max], 29 + range.min_proto.all = (__force __be16)nft_reg_load16( 30 + &regs->data[priv->sreg_proto_min]); 31 + range.max_proto.all = (__force __be16)nft_reg_load16( 32 + &regs->data[priv->sreg_proto_max]); 33 33 range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; 34 34 } 35 35
+2
net/ipv6/route.c
··· 3423 3423 } 3424 3424 else if (rt->rt6i_flags & RTF_LOCAL) 3425 3425 rtm->rtm_type = RTN_LOCAL; 3426 + else if (rt->rt6i_flags & RTF_ANYCAST) 3427 + rtm->rtm_type = RTN_ANYCAST; 3426 3428 else if (rt->dst.dev && (rt->dst.dev->flags & IFF_LOOPBACK)) 3427 3429 rtm->rtm_type = RTN_LOCAL; 3428 3430 else
+1 -1
net/ipv6/udp.c
··· 1035 1035 ipc6.hlimit = -1; 1036 1036 ipc6.tclass = -1; 1037 1037 ipc6.dontfrag = -1; 1038 + sockc.tsflags = sk->sk_tsflags; 1038 1039 1039 1040 /* destination address check */ 1040 1041 if (sin6) { ··· 1160 1159 1161 1160 fl6.flowi6_mark = sk->sk_mark; 1162 1161 fl6.flowi6_uid = sk->sk_uid; 1163 - sockc.tsflags = sk->sk_tsflags; 1164 1162 1165 1163 if (msg->msg_controllen) { 1166 1164 opt = &opt_space;
+10 -3
net/mpls/af_mpls.c
··· 1269 1269 { 1270 1270 struct mpls_route __rcu **platform_label; 1271 1271 struct net *net = dev_net(dev); 1272 + unsigned int nh_flags = RTNH_F_DEAD | RTNH_F_LINKDOWN; 1273 + unsigned int alive; 1272 1274 unsigned index; 1273 1275 1274 1276 platform_label = rtnl_dereference(net->mpls.platform_label); ··· 1280 1278 if (!rt) 1281 1279 continue; 1282 1280 1281 + alive = 0; 1283 1282 change_nexthops(rt) { 1284 1283 if (rtnl_dereference(nh->nh_dev) != dev) 1285 - continue; 1284 + goto next; 1285 + 1286 1286 switch (event) { 1287 1287 case NETDEV_DOWN: 1288 1288 case NETDEV_UNREGISTER: ··· 1292 1288 /* fall through */ 1293 1289 case NETDEV_CHANGE: 1294 1290 nh->nh_flags |= RTNH_F_LINKDOWN; 1295 - if (event != NETDEV_UNREGISTER) 1296 - ACCESS_ONCE(rt->rt_nhn_alive) = rt->rt_nhn_alive - 1; 1297 1291 break; 1298 1292 } 1299 1293 if (event == NETDEV_UNREGISTER) 1300 1294 RCU_INIT_POINTER(nh->nh_dev, NULL); 1295 + next: 1296 + if (!(nh->nh_flags & nh_flags)) 1297 + alive++; 1301 1298 } endfor_nexthops(rt); 1299 + 1300 + WRITE_ONCE(rt->rt_nhn_alive, alive); 1302 1301 } 1303 1302 } 1304 1303
+5 -1
net/netfilter/nf_conntrack_core.c
··· 181 181 unsigned int nf_conntrack_max __read_mostly; 182 182 seqcount_t nf_conntrack_generation __read_mostly; 183 183 184 - DEFINE_PER_CPU(struct nf_conn, nf_conntrack_untracked); 184 + /* nf_conn must be 8 bytes aligned, as the 3 LSB bits are used 185 + * for the nfctinfo. We cheat by (ab)using the PER CPU cache line 186 + * alignment to enforce this. 187 + */ 188 + DEFINE_PER_CPU_ALIGNED(struct nf_conn, nf_conntrack_untracked); 185 189 EXPORT_PER_CPU_SYMBOL(nf_conntrack_untracked); 186 190 187 191 static unsigned int nf_conntrack_hash_rnd __read_mostly;
+12 -1
net/netfilter/nf_nat_proto_sctp.c
··· 33 33 enum nf_nat_manip_type maniptype) 34 34 { 35 35 sctp_sctphdr_t *hdr; 36 + int hdrsize = 8; 36 37 37 - if (!skb_make_writable(skb, hdroff + sizeof(*hdr))) 38 + /* This could be an inner header returned in imcp packet; in such 39 + * cases we cannot update the checksum field since it is outside 40 + * of the 8 bytes of transport layer headers we are guaranteed. 41 + */ 42 + if (skb->len >= hdroff + sizeof(*hdr)) 43 + hdrsize = sizeof(*hdr); 44 + 45 + if (!skb_make_writable(skb, hdroff + hdrsize)) 38 46 return false; 39 47 40 48 hdr = (struct sctphdr *)(skb->data + hdroff); ··· 54 46 /* Get rid of dst port */ 55 47 hdr->dest = tuple->dst.u.sctp.port; 56 48 } 49 + 50 + if (hdrsize < sizeof(*hdr)) 51 + return true; 57 52 58 53 if (skb->ip_summed != CHECKSUM_PARTIAL) { 59 54 hdr->checksum = sctp_compute_cksum(skb, hdroff);
-4
net/netfilter/nf_tables_api.c
··· 3145 3145 iter.count = 0; 3146 3146 iter.err = 0; 3147 3147 iter.fn = nf_tables_bind_check_setelem; 3148 - iter.flush = false; 3149 3148 3150 3149 set->ops->walk(ctx, set, &iter); 3151 3150 if (iter.err < 0) ··· 3398 3399 args.iter.count = 0; 3399 3400 args.iter.err = 0; 3400 3401 args.iter.fn = nf_tables_dump_setelem; 3401 - args.iter.flush = false; 3402 3402 set->ops->walk(&ctx, set, &args.iter); 3403 3403 3404 3404 nla_nest_end(skb, nest); ··· 3961 3963 struct nft_set_iter iter = { 3962 3964 .genmask = genmask, 3963 3965 .fn = nft_flush_set, 3964 - .flush = true, 3965 3966 }; 3966 3967 set->ops->walk(&ctx, set, &iter); 3967 3968 ··· 5111 5114 iter.count = 0; 5112 5115 iter.err = 0; 5113 5116 iter.fn = nf_tables_loop_check_setelem; 5114 - iter.flush = false; 5115 5117 5116 5118 set->ops->walk(ctx, set, &iter); 5117 5119 if (iter.err < 0)
+12 -9
net/netfilter/nft_ct.c
··· 83 83 84 84 switch (priv->key) { 85 85 case NFT_CT_DIRECTION: 86 - *dest = CTINFO2DIR(ctinfo); 86 + nft_reg_store8(dest, CTINFO2DIR(ctinfo)); 87 87 return; 88 88 case NFT_CT_STATUS: 89 89 *dest = ct->status; ··· 151 151 return; 152 152 } 153 153 case NFT_CT_L3PROTOCOL: 154 - *dest = nf_ct_l3num(ct); 154 + nft_reg_store8(dest, nf_ct_l3num(ct)); 155 155 return; 156 156 case NFT_CT_PROTOCOL: 157 - *dest = nf_ct_protonum(ct); 157 + nft_reg_store8(dest, nf_ct_protonum(ct)); 158 158 return; 159 159 #ifdef CONFIG_NF_CONNTRACK_ZONES 160 160 case NFT_CT_ZONE: { 161 161 const struct nf_conntrack_zone *zone = nf_ct_zone(ct); 162 + u16 zoneid; 162 163 163 164 if (priv->dir < IP_CT_DIR_MAX) 164 - *dest = nf_ct_zone_id(zone, priv->dir); 165 + zoneid = nf_ct_zone_id(zone, priv->dir); 165 166 else 166 - *dest = zone->id; 167 + zoneid = zone->id; 167 168 169 + nft_reg_store16(dest, zoneid); 168 170 return; 169 171 } 170 172 #endif ··· 185 183 nf_ct_l3num(ct) == NFPROTO_IPV4 ? 4 : 16); 186 184 return; 187 185 case NFT_CT_PROTO_SRC: 188 - *dest = (__force __u16)tuple->src.u.all; 186 + nft_reg_store16(dest, (__force u16)tuple->src.u.all); 189 187 return; 190 188 case NFT_CT_PROTO_DST: 191 - *dest = (__force __u16)tuple->dst.u.all; 189 + nft_reg_store16(dest, (__force u16)tuple->dst.u.all); 192 190 return; 193 191 default: 194 192 break; ··· 207 205 const struct nft_ct *priv = nft_expr_priv(expr); 208 206 struct sk_buff *skb = pkt->skb; 209 207 enum ip_conntrack_info ctinfo; 210 - u16 value = regs->data[priv->sreg]; 208 + u16 value = nft_reg_load16(&regs->data[priv->sreg]); 211 209 struct nf_conn *ct; 212 210 213 211 ct = nf_ct_get(skb, &ctinfo); ··· 544 542 case IP_CT_DIR_REPLY: 545 543 break; 546 544 default: 547 - return -EINVAL; 545 + err = -EINVAL; 546 + goto err1; 548 547 } 549 548 } 550 549
+21 -19
net/netfilter/nft_meta.c
··· 45 45 *dest = skb->len; 46 46 break; 47 47 case NFT_META_PROTOCOL: 48 - *dest = 0; 49 - *(__be16 *)dest = skb->protocol; 48 + nft_reg_store16(dest, (__force u16)skb->protocol); 50 49 break; 51 50 case NFT_META_NFPROTO: 52 - *dest = nft_pf(pkt); 51 + nft_reg_store8(dest, nft_pf(pkt)); 53 52 break; 54 53 case NFT_META_L4PROTO: 55 54 if (!pkt->tprot_set) 56 55 goto err; 57 - *dest = pkt->tprot; 56 + nft_reg_store8(dest, pkt->tprot); 58 57 break; 59 58 case NFT_META_PRIORITY: 60 59 *dest = skb->priority; ··· 84 85 case NFT_META_IIFTYPE: 85 86 if (in == NULL) 86 87 goto err; 87 - *dest = 0; 88 - *(u16 *)dest = in->type; 88 + nft_reg_store16(dest, in->type); 89 89 break; 90 90 case NFT_META_OIFTYPE: 91 91 if (out == NULL) 92 92 goto err; 93 - *dest = 0; 94 - *(u16 *)dest = out->type; 93 + nft_reg_store16(dest, out->type); 95 94 break; 96 95 case NFT_META_SKUID: 97 96 sk = skb_to_full_sk(skb); ··· 139 142 #endif 140 143 case NFT_META_PKTTYPE: 141 144 if (skb->pkt_type != PACKET_LOOPBACK) { 142 - *dest = skb->pkt_type; 145 + nft_reg_store8(dest, skb->pkt_type); 143 146 break; 144 147 } 145 148 146 149 switch (nft_pf(pkt)) { 147 150 case NFPROTO_IPV4: 148 151 if (ipv4_is_multicast(ip_hdr(skb)->daddr)) 149 - *dest = PACKET_MULTICAST; 152 + nft_reg_store8(dest, PACKET_MULTICAST); 150 153 else 151 - *dest = PACKET_BROADCAST; 154 + nft_reg_store8(dest, PACKET_BROADCAST); 152 155 break; 153 156 case NFPROTO_IPV6: 154 - *dest = PACKET_MULTICAST; 157 + nft_reg_store8(dest, PACKET_MULTICAST); 155 158 break; 156 159 case NFPROTO_NETDEV: 157 160 switch (skb->protocol) { ··· 165 168 goto err; 166 169 167 170 if (ipv4_is_multicast(iph->daddr)) 168 - *dest = PACKET_MULTICAST; 171 + nft_reg_store8(dest, PACKET_MULTICAST); 169 172 else 170 - *dest = PACKET_BROADCAST; 173 + nft_reg_store8(dest, PACKET_BROADCAST); 171 174 172 175 break; 173 176 } 174 177 case htons(ETH_P_IPV6): 175 - *dest = PACKET_MULTICAST; 178 + nft_reg_store8(dest, PACKET_MULTICAST); 176 179 break; 177 180 default: 178 181 WARN_ON_ONCE(1); ··· 227 230 { 228 231 const struct nft_meta *meta = nft_expr_priv(expr); 229 232 struct sk_buff *skb = pkt->skb; 230 - u32 value = regs->data[meta->sreg]; 233 + u32 *sreg = &regs->data[meta->sreg]; 234 + u32 value = *sreg; 235 + u8 pkt_type; 231 236 232 237 switch (meta->key) { 233 238 case NFT_META_MARK: ··· 239 240 skb->priority = value; 240 241 break; 241 242 case NFT_META_PKTTYPE: 242 - if (skb->pkt_type != value && 243 - skb_pkt_type_ok(value) && skb_pkt_type_ok(skb->pkt_type)) 244 - skb->pkt_type = value; 243 + pkt_type = nft_reg_load8(sreg); 244 + 245 + if (skb->pkt_type != pkt_type && 246 + skb_pkt_type_ok(pkt_type) && 247 + skb_pkt_type_ok(skb->pkt_type)) 248 + skb->pkt_type = pkt_type; 245 249 break; 246 250 case NFT_META_NFTRACE: 247 251 skb->nf_trace = !!value;
+4 -4
net/netfilter/nft_nat.c
··· 65 65 } 66 66 67 67 if (priv->sreg_proto_min) { 68 - range.min_proto.all = 69 - *(__be16 *)&regs->data[priv->sreg_proto_min]; 70 - range.max_proto.all = 71 - *(__be16 *)&regs->data[priv->sreg_proto_max]; 68 + range.min_proto.all = (__force __be16)nft_reg_load16( 69 + &regs->data[priv->sreg_proto_min]); 70 + range.max_proto.all = (__force __be16)nft_reg_load16( 71 + &regs->data[priv->sreg_proto_max]); 72 72 range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; 73 73 } 74 74
+75 -82
net/netfilter/nft_set_bitmap.c
··· 15 15 #include <linux/netfilter/nf_tables.h> 16 16 #include <net/netfilter/nf_tables.h> 17 17 18 + struct nft_bitmap_elem { 19 + struct list_head head; 20 + struct nft_set_ext ext; 21 + }; 22 + 18 23 /* This bitmap uses two bits to represent one element. These two bits determine 19 24 * the element state in the current and the future generation. 20 25 * ··· 46 41 * restore its previous state. 47 42 */ 48 43 struct nft_bitmap { 49 - u16 bitmap_size; 50 - u8 bitmap[]; 44 + struct list_head list; 45 + u16 bitmap_size; 46 + u8 bitmap[]; 51 47 }; 52 48 53 - static inline void nft_bitmap_location(u32 key, u32 *idx, u32 *off) 49 + static inline void nft_bitmap_location(const struct nft_set *set, 50 + const void *key, 51 + u32 *idx, u32 *off) 54 52 { 55 - u32 k = (key << 1); 53 + u32 k; 54 + 55 + if (set->klen == 2) 56 + k = *(u16 *)key; 57 + else 58 + k = *(u8 *)key; 59 + k <<= 1; 56 60 57 61 *idx = k / BITS_PER_BYTE; 58 62 *off = k % BITS_PER_BYTE; ··· 83 69 u8 genmask = nft_genmask_cur(net); 84 70 u32 idx, off; 85 71 86 - nft_bitmap_location(*key, &idx, &off); 72 + nft_bitmap_location(set, key, &idx, &off); 87 73 88 74 return nft_bitmap_active(priv->bitmap, idx, off, genmask); 89 75 } 90 76 77 + static struct nft_bitmap_elem * 78 + nft_bitmap_elem_find(const struct nft_set *set, struct nft_bitmap_elem *this, 79 + u8 genmask) 80 + { 81 + const struct nft_bitmap *priv = nft_set_priv(set); 82 + struct nft_bitmap_elem *be; 83 + 84 + list_for_each_entry_rcu(be, &priv->list, head) { 85 + if (memcmp(nft_set_ext_key(&be->ext), 86 + nft_set_ext_key(&this->ext), set->klen) || 87 + !nft_set_elem_active(&be->ext, genmask)) 88 + continue; 89 + 90 + return be; 91 + } 92 + return NULL; 93 + } 94 + 91 95 static int nft_bitmap_insert(const struct net *net, const struct nft_set *set, 92 96 const struct nft_set_elem *elem, 93 - struct nft_set_ext **_ext) 97 + struct nft_set_ext **ext) 94 98 { 95 99 struct nft_bitmap *priv = nft_set_priv(set); 96 - struct nft_set_ext *ext = elem->priv; 100 + struct nft_bitmap_elem *new = elem->priv, *be; 97 101 u8 genmask = nft_genmask_next(net); 98 102 u32 idx, off; 99 103 100 - nft_bitmap_location(nft_set_ext_key(ext)->data[0], &idx, &off); 101 - if (nft_bitmap_active(priv->bitmap, idx, off, genmask)) 104 + be = nft_bitmap_elem_find(set, new, genmask); 105 + if (be) { 106 + *ext = &be->ext; 102 107 return -EEXIST; 108 + } 103 109 110 + nft_bitmap_location(set, nft_set_ext_key(&new->ext), &idx, &off); 104 111 /* Enter 01 state. */ 105 112 priv->bitmap[idx] |= (genmask << off); 113 + list_add_tail_rcu(&new->head, &priv->list); 106 114 107 115 return 0; 108 116 } ··· 134 98 const struct nft_set_elem *elem) 135 99 { 136 100 struct nft_bitmap *priv = nft_set_priv(set); 137 - struct nft_set_ext *ext = elem->priv; 101 + struct nft_bitmap_elem *be = elem->priv; 138 102 u8 genmask = nft_genmask_next(net); 139 103 u32 idx, off; 140 104 141 - nft_bitmap_location(nft_set_ext_key(ext)->data[0], &idx, &off); 105 + nft_bitmap_location(set, nft_set_ext_key(&be->ext), &idx, &off); 142 106 /* Enter 00 state. */ 143 107 priv->bitmap[idx] &= ~(genmask << off); 108 + list_del_rcu(&be->head); 144 109 } 145 110 146 111 static void nft_bitmap_activate(const struct net *net, ··· 149 112 const struct nft_set_elem *elem) 150 113 { 151 114 struct nft_bitmap *priv = nft_set_priv(set); 152 - struct nft_set_ext *ext = elem->priv; 115 + struct nft_bitmap_elem *be = elem->priv; 153 116 u8 genmask = nft_genmask_next(net); 154 117 u32 idx, off; 155 118 156 - nft_bitmap_location(nft_set_ext_key(ext)->data[0], &idx, &off); 119 + nft_bitmap_location(set, nft_set_ext_key(&be->ext), &idx, &off); 157 120 /* Enter 11 state. */ 158 121 priv->bitmap[idx] |= (genmask << off); 122 + nft_set_elem_change_active(net, set, &be->ext); 159 123 } 160 124 161 125 static bool nft_bitmap_flush(const struct net *net, 162 - const struct nft_set *set, void *ext) 126 + const struct nft_set *set, void *_be) 163 127 { 164 128 struct nft_bitmap *priv = nft_set_priv(set); 165 129 u8 genmask = nft_genmask_next(net); 130 + struct nft_bitmap_elem *be = _be; 166 131 u32 idx, off; 167 132 168 - nft_bitmap_location(nft_set_ext_key(ext)->data[0], &idx, &off); 133 + nft_bitmap_location(set, nft_set_ext_key(&be->ext), &idx, &off); 169 134 /* Enter 10 state, similar to deactivation. */ 170 135 priv->bitmap[idx] &= ~(genmask << off); 136 + nft_set_elem_change_active(net, set, &be->ext); 171 137 172 138 return true; 173 - } 174 - 175 - static struct nft_set_ext *nft_bitmap_ext_alloc(const struct nft_set *set, 176 - const struct nft_set_elem *elem) 177 - { 178 - struct nft_set_ext_tmpl tmpl; 179 - struct nft_set_ext *ext; 180 - 181 - nft_set_ext_prepare(&tmpl); 182 - nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY, set->klen); 183 - 184 - ext = kzalloc(tmpl.len, GFP_KERNEL); 185 - if (!ext) 186 - return NULL; 187 - 188 - nft_set_ext_init(ext, &tmpl); 189 - memcpy(nft_set_ext_key(ext), elem->key.val.data, set->klen); 190 - 191 - return ext; 192 139 } 193 140 194 141 static void *nft_bitmap_deactivate(const struct net *net, ··· 180 159 const struct nft_set_elem *elem) 181 160 { 182 161 struct nft_bitmap *priv = nft_set_priv(set); 162 + struct nft_bitmap_elem *this = elem->priv, *be; 183 163 u8 genmask = nft_genmask_next(net); 184 - struct nft_set_ext *ext; 185 - u32 idx, off, key = 0; 164 + u32 idx, off; 186 165 187 - memcpy(&key, elem->key.val.data, set->klen); 188 - nft_bitmap_location(key, &idx, &off); 166 + nft_bitmap_location(set, elem->key.val.data, &idx, &off); 189 167 190 - if (!nft_bitmap_active(priv->bitmap, idx, off, genmask)) 191 - return NULL; 192 - 193 - /* We have no real set extension since this is a bitmap, allocate this 194 - * dummy object that is released from the commit/abort path. 195 - */ 196 - ext = nft_bitmap_ext_alloc(set, elem); 197 - if (!ext) 168 + be = nft_bitmap_elem_find(set, this, genmask); 169 + if (!be) 198 170 return NULL; 199 171 200 172 /* Enter 10 state. */ 201 173 priv->bitmap[idx] &= ~(genmask << off); 174 + nft_set_elem_change_active(net, set, &be->ext); 202 175 203 - return ext; 176 + return be; 204 177 } 205 178 206 179 static void nft_bitmap_walk(const struct nft_ctx *ctx, ··· 202 187 struct nft_set_iter *iter) 203 188 { 204 189 const struct nft_bitmap *priv = nft_set_priv(set); 205 - struct nft_set_ext_tmpl tmpl; 190 + struct nft_bitmap_elem *be; 206 191 struct nft_set_elem elem; 207 - struct nft_set_ext *ext; 208 - int idx, off; 209 - u16 key; 210 192 211 - nft_set_ext_prepare(&tmpl); 212 - nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY, set->klen); 193 + list_for_each_entry_rcu(be, &priv->list, head) { 194 + if (iter->count < iter->skip) 195 + goto cont; 196 + if (!nft_set_elem_active(&be->ext, iter->genmask)) 197 + goto cont; 213 198 214 - for (idx = 0; idx < priv->bitmap_size; idx++) { 215 - for (off = 0; off < BITS_PER_BYTE; off += 2) { 216 - if (iter->count < iter->skip) 217 - goto cont; 199 + elem.priv = be; 218 200 219 - if (!nft_bitmap_active(priv->bitmap, idx, off, 220 - iter->genmask)) 221 - goto cont; 201 + iter->err = iter->fn(ctx, set, iter, &elem); 222 202 223 - ext = kzalloc(tmpl.len, GFP_KERNEL); 224 - if (!ext) { 225 - iter->err = -ENOMEM; 226 - return; 227 - } 228 - nft_set_ext_init(ext, &tmpl); 229 - key = ((idx * BITS_PER_BYTE) + off) >> 1; 230 - memcpy(nft_set_ext_key(ext), &key, set->klen); 231 - 232 - elem.priv = ext; 233 - iter->err = iter->fn(ctx, set, iter, &elem); 234 - 235 - /* On set flush, this dummy extension object is released 236 - * from the commit/abort path. 237 - */ 238 - if (!iter->flush) 239 - kfree(ext); 240 - 241 - if (iter->err < 0) 242 - return; 203 + if (iter->err < 0) 204 + return; 243 205 cont: 244 - iter->count++; 245 - } 206 + iter->count++; 246 207 } 247 208 } 248 209 ··· 249 258 { 250 259 struct nft_bitmap *priv = nft_set_priv(set); 251 260 261 + INIT_LIST_HEAD(&priv->list); 252 262 priv->bitmap_size = nft_bitmap_size(set->klen); 253 263 254 264 return 0; ··· 275 283 276 284 static struct nft_set_ops nft_bitmap_ops __read_mostly = { 277 285 .privsize = nft_bitmap_privsize, 286 + .elemsize = offsetof(struct nft_bitmap_elem, ext), 278 287 .estimate = nft_bitmap_estimate, 279 288 .init = nft_bitmap_init, 280 289 .destroy = nft_bitmap_destroy,
+41
net/netlink/af_netlink.c
··· 96 96 97 97 static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait); 98 98 99 + static struct lock_class_key nlk_cb_mutex_keys[MAX_LINKS]; 100 + 101 + static const char *const nlk_cb_mutex_key_strings[MAX_LINKS + 1] = { 102 + "nlk_cb_mutex-ROUTE", 103 + "nlk_cb_mutex-1", 104 + "nlk_cb_mutex-USERSOCK", 105 + "nlk_cb_mutex-FIREWALL", 106 + "nlk_cb_mutex-SOCK_DIAG", 107 + "nlk_cb_mutex-NFLOG", 108 + "nlk_cb_mutex-XFRM", 109 + "nlk_cb_mutex-SELINUX", 110 + "nlk_cb_mutex-ISCSI", 111 + "nlk_cb_mutex-AUDIT", 112 + "nlk_cb_mutex-FIB_LOOKUP", 113 + "nlk_cb_mutex-CONNECTOR", 114 + "nlk_cb_mutex-NETFILTER", 115 + "nlk_cb_mutex-IP6_FW", 116 + "nlk_cb_mutex-DNRTMSG", 117 + "nlk_cb_mutex-KOBJECT_UEVENT", 118 + "nlk_cb_mutex-GENERIC", 119 + "nlk_cb_mutex-17", 120 + "nlk_cb_mutex-SCSITRANSPORT", 121 + "nlk_cb_mutex-ECRYPTFS", 122 + "nlk_cb_mutex-RDMA", 123 + "nlk_cb_mutex-CRYPTO", 124 + "nlk_cb_mutex-SMC", 125 + "nlk_cb_mutex-23", 126 + "nlk_cb_mutex-24", 127 + "nlk_cb_mutex-25", 128 + "nlk_cb_mutex-26", 129 + "nlk_cb_mutex-27", 130 + "nlk_cb_mutex-28", 131 + "nlk_cb_mutex-29", 132 + "nlk_cb_mutex-30", 133 + "nlk_cb_mutex-31", 134 + "nlk_cb_mutex-MAX_LINKS" 135 + }; 136 + 99 137 static int netlink_dump(struct sock *sk); 100 138 static void netlink_skb_destructor(struct sk_buff *skb); 101 139 ··· 623 585 } else { 624 586 nlk->cb_mutex = &nlk->cb_def_mutex; 625 587 mutex_init(nlk->cb_mutex); 588 + lockdep_set_class_and_name(nlk->cb_mutex, 589 + nlk_cb_mutex_keys + protocol, 590 + nlk_cb_mutex_key_strings[protocol]); 626 591 } 627 592 init_waitqueue_head(&nlk->wait); 628 593
+3 -1
net/netlink/genetlink.c
··· 783 783 784 784 if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid, 785 785 cb->nlh->nlmsg_seq, NLM_F_MULTI, 786 - skb, CTRL_CMD_NEWFAMILY) < 0) 786 + skb, CTRL_CMD_NEWFAMILY) < 0) { 787 + n--; 787 788 break; 789 + } 788 790 } 789 791 790 792 cb->args[0] = n;
+3 -1
net/openvswitch/flow_netlink.c
··· 604 604 ipv4 = true; 605 605 break; 606 606 case OVS_TUNNEL_KEY_ATTR_IPV6_SRC: 607 - SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.dst, 607 + SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.src, 608 608 nla_get_in6_addr(a), is_mask); 609 609 ipv6 = true; 610 610 break; ··· 664 664 665 665 tun_flags |= TUNNEL_VXLAN_OPT; 666 666 opts_type = type; 667 + break; 668 + case OVS_TUNNEL_KEY_ATTR_PAD: 667 669 break; 668 670 default: 669 671 OVS_NLERR(log, "Unknown IP tunnel attribute %d",
+4
net/rxrpc/conn_event.c
··· 275 275 rxrpc_conn_retransmit_call(conn, skb); 276 276 return 0; 277 277 278 + case RXRPC_PACKET_TYPE_BUSY: 279 + /* Just ignore BUSY packets for now. */ 280 + return 0; 281 + 278 282 case RXRPC_PACKET_TYPE_ABORT: 279 283 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), 280 284 &wtmp, sizeof(wtmp)) < 0)
+8 -2
net/sched/sch_dsmark.c
··· 201 201 pr_debug("%s(skb %p,sch %p,[qdisc %p])\n", __func__, skb, sch, p); 202 202 203 203 if (p->set_tc_index) { 204 + int wlen = skb_network_offset(skb); 205 + 204 206 switch (tc_skb_protocol(skb)) { 205 207 case htons(ETH_P_IP): 206 - if (skb_cow_head(skb, sizeof(struct iphdr))) 208 + wlen += sizeof(struct iphdr); 209 + if (!pskb_may_pull(skb, wlen) || 210 + skb_try_make_writable(skb, wlen)) 207 211 goto drop; 208 212 209 213 skb->tc_index = ipv4_get_dsfield(ip_hdr(skb)) ··· 215 211 break; 216 212 217 213 case htons(ETH_P_IPV6): 218 - if (skb_cow_head(skb, sizeof(struct ipv6hdr))) 214 + wlen += sizeof(struct ipv6hdr); 215 + if (!pskb_may_pull(skb, wlen) || 216 + skb_try_make_writable(skb, wlen)) 219 217 goto drop; 220 218 221 219 skb->tc_index = ipv6_get_dsfield(ipv6_hdr(skb))
+2 -4
net/sctp/associola.c
··· 71 71 { 72 72 struct net *net = sock_net(sk); 73 73 struct sctp_sock *sp; 74 - int i; 75 74 sctp_paramhdr_t *p; 76 - int err; 75 + int i; 77 76 78 77 /* Retrieve the SCTP per socket area. */ 79 78 sp = sctp_sk((struct sock *)sk); ··· 263 264 264 265 /* AUTH related initializations */ 265 266 INIT_LIST_HEAD(&asoc->endpoint_shared_keys); 266 - err = sctp_auth_asoc_copy_shkeys(ep, asoc, gfp); 267 - if (err) 267 + if (sctp_auth_asoc_copy_shkeys(ep, asoc, gfp)) 268 268 goto fail_init; 269 269 270 270 asoc->active_key_id = ep->active_key_id;
+3 -4
net/sctp/output.c
··· 546 546 struct sctp_association *asoc = tp->asoc; 547 547 struct sctp_chunk *chunk, *tmp; 548 548 int pkt_count, gso = 0; 549 - int confirm; 550 549 struct dst_entry *dst; 551 550 struct sk_buff *head; 552 551 struct sctphdr *sh; ··· 624 625 asoc->peer.last_sent_to = tp; 625 626 } 626 627 head->ignore_df = packet->ipfragok; 627 - confirm = tp->dst_pending_confirm; 628 - if (confirm) 628 + if (tp->dst_pending_confirm) 629 629 skb_set_dst_pending_confirm(head, 1); 630 630 /* neighbour should be confirmed on successful transmission or 631 631 * positive error 632 632 */ 633 - if (tp->af_specific->sctp_xmit(head, tp) >= 0 && confirm) 633 + if (tp->af_specific->sctp_xmit(head, tp) >= 0 && 634 + tp->dst_pending_confirm) 634 635 tp->dst_pending_confirm = 0; 635 636 636 637 out:
+5 -6
net/sctp/outqueue.c
··· 382 382 } 383 383 384 384 static int sctp_prsctp_prune_unsent(struct sctp_association *asoc, 385 - struct sctp_sndrcvinfo *sinfo, 386 - struct list_head *queue, int msg_len) 385 + struct sctp_sndrcvinfo *sinfo, int msg_len) 387 386 { 387 + struct sctp_outq *q = &asoc->outqueue; 388 388 struct sctp_chunk *chk, *temp; 389 389 390 - list_for_each_entry_safe(chk, temp, queue, list) { 390 + list_for_each_entry_safe(chk, temp, &q->out_chunk_list, list) { 391 391 if (!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) || 392 392 chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive) 393 393 continue; 394 394 395 395 list_del_init(&chk->list); 396 + q->out_qlen -= chk->skb->len; 396 397 asoc->sent_cnt_removable--; 397 398 asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++; 398 399 ··· 432 431 return; 433 432 } 434 433 435 - sctp_prsctp_prune_unsent(asoc, sinfo, 436 - &asoc->outqueue.out_chunk_list, 437 - msg_len); 434 + sctp_prsctp_prune_unsent(asoc, sinfo, msg_len); 438 435 } 439 436 440 437 /* Mark all the eligible packets on a transport for retransmission. */
+12 -1
net/socket.c
··· 652 652 } 653 653 EXPORT_SYMBOL(kernel_sendmsg); 654 654 655 + static bool skb_is_err_queue(const struct sk_buff *skb) 656 + { 657 + /* pkt_type of skbs enqueued on the error queue are set to 658 + * PACKET_OUTGOING in skb_set_err_queue(). This is only safe to do 659 + * in recvmsg, since skbs received on a local socket will never 660 + * have a pkt_type of PACKET_OUTGOING. 661 + */ 662 + return skb->pkt_type == PACKET_OUTGOING; 663 + } 664 + 655 665 /* 656 666 * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP) 657 667 */ ··· 705 695 put_cmsg(msg, SOL_SOCKET, 706 696 SCM_TIMESTAMPING, sizeof(tss), &tss); 707 697 708 - if (skb->len && (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_STATS)) 698 + if (skb_is_err_queue(skb) && skb->len && 699 + SKB_EXT_ERR(skb)->opt_stats) 709 700 put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMPING_OPT_STATS, 710 701 skb->len, skb->data); 711 702 }
+6 -1
net/tipc/subscr.c
··· 141 141 static void tipc_subscrp_timeout(unsigned long data) 142 142 { 143 143 struct tipc_subscription *sub = (struct tipc_subscription *)data; 144 + struct tipc_subscriber *subscriber = sub->subscriber; 145 + 146 + spin_lock_bh(&subscriber->lock); 147 + tipc_nametbl_unsubscribe(sub); 148 + spin_unlock_bh(&subscriber->lock); 144 149 145 150 /* Notify subscriber of timeout */ 146 151 tipc_subscrp_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, ··· 178 173 struct tipc_subscriber *subscriber = sub->subscriber; 179 174 180 175 spin_lock_bh(&subscriber->lock); 181 - tipc_nametbl_unsubscribe(sub); 182 176 list_del(&sub->subscrp_list); 183 177 atomic_dec(&tn->subscription_count); 184 178 spin_unlock_bh(&subscriber->lock); ··· 209 205 if (s && memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) 210 206 continue; 211 207 208 + tipc_nametbl_unsubscribe(sub); 212 209 tipc_subscrp_get(sub); 213 210 spin_unlock_bh(&subscriber->lock); 214 211 tipc_subscrp_delete(sub);
+9 -8
net/unix/garbage.c
··· 146 146 if (s) { 147 147 struct unix_sock *u = unix_sk(s); 148 148 149 + BUG_ON(!atomic_long_read(&u->inflight)); 149 150 BUG_ON(list_empty(&u->link)); 150 151 151 152 if (atomic_long_dec_and_test(&u->inflight)) ··· 342 341 } 343 342 list_del(&cursor); 344 343 344 + /* Now gc_candidates contains only garbage. Restore original 345 + * inflight counters for these as well, and remove the skbuffs 346 + * which are creating the cycle(s). 347 + */ 348 + skb_queue_head_init(&hitlist); 349 + list_for_each_entry(u, &gc_candidates, link) 350 + scan_children(&u->sk, inc_inflight, &hitlist); 351 + 345 352 /* not_cycle_list contains those sockets which do not make up a 346 353 * cycle. Restore these to the inflight list. 347 354 */ ··· 358 349 __clear_bit(UNIX_GC_CANDIDATE, &u->gc_flags); 359 350 list_move_tail(&u->link, &gc_inflight_list); 360 351 } 361 - 362 - /* Now gc_candidates contains only garbage. Restore original 363 - * inflight counters for these as well, and remove the skbuffs 364 - * which are creating the cycle(s). 365 - */ 366 - skb_queue_head_init(&hitlist); 367 - list_for_each_entry(u, &gc_candidates, link) 368 - scan_children(&u->sk, inc_inflight, &hitlist); 369 352 370 353 spin_unlock(&unix_gc_lock); 371 354
+14
net/vmw_vsock/af_vsock.c
··· 1102 1102 .sendpage = sock_no_sendpage, 1103 1103 }; 1104 1104 1105 + static int vsock_transport_cancel_pkt(struct vsock_sock *vsk) 1106 + { 1107 + if (!transport->cancel_pkt) 1108 + return -EOPNOTSUPP; 1109 + 1110 + return transport->cancel_pkt(vsk); 1111 + } 1112 + 1105 1113 static void vsock_connect_timeout(struct work_struct *work) 1106 1114 { 1107 1115 struct sock *sk; 1108 1116 struct vsock_sock *vsk; 1117 + int cancel = 0; 1109 1118 1110 1119 vsk = container_of(work, struct vsock_sock, dwork.work); 1111 1120 sk = sk_vsock(vsk); ··· 1125 1116 sk->sk_state = SS_UNCONNECTED; 1126 1117 sk->sk_err = ETIMEDOUT; 1127 1118 sk->sk_error_report(sk); 1119 + cancel = 1; 1128 1120 } 1129 1121 release_sock(sk); 1122 + if (cancel) 1123 + vsock_transport_cancel_pkt(vsk); 1130 1124 1131 1125 sock_put(sk); 1132 1126 } ··· 1236 1224 err = sock_intr_errno(timeout); 1237 1225 sk->sk_state = SS_UNCONNECTED; 1238 1226 sock->state = SS_UNCONNECTED; 1227 + vsock_transport_cancel_pkt(vsk); 1239 1228 goto out_wait; 1240 1229 } else if (timeout == 0) { 1241 1230 err = -ETIMEDOUT; 1242 1231 sk->sk_state = SS_UNCONNECTED; 1243 1232 sock->state = SS_UNCONNECTED; 1233 + vsock_transport_cancel_pkt(vsk); 1244 1234 goto out_wait; 1245 1235 } 1246 1236
+42
net/vmw_vsock/virtio_transport.c
··· 213 213 return len; 214 214 } 215 215 216 + static int 217 + virtio_transport_cancel_pkt(struct vsock_sock *vsk) 218 + { 219 + struct virtio_vsock *vsock; 220 + struct virtio_vsock_pkt *pkt, *n; 221 + int cnt = 0; 222 + LIST_HEAD(freeme); 223 + 224 + vsock = virtio_vsock_get(); 225 + if (!vsock) { 226 + return -ENODEV; 227 + } 228 + 229 + spin_lock_bh(&vsock->send_pkt_list_lock); 230 + list_for_each_entry_safe(pkt, n, &vsock->send_pkt_list, list) { 231 + if (pkt->vsk != vsk) 232 + continue; 233 + list_move(&pkt->list, &freeme); 234 + } 235 + spin_unlock_bh(&vsock->send_pkt_list_lock); 236 + 237 + list_for_each_entry_safe(pkt, n, &freeme, list) { 238 + if (pkt->reply) 239 + cnt++; 240 + list_del(&pkt->list); 241 + virtio_transport_free_pkt(pkt); 242 + } 243 + 244 + if (cnt) { 245 + struct virtqueue *rx_vq = vsock->vqs[VSOCK_VQ_RX]; 246 + int new_cnt; 247 + 248 + new_cnt = atomic_sub_return(cnt, &vsock->queued_replies); 249 + if (new_cnt + cnt >= virtqueue_get_vring_size(rx_vq) && 250 + new_cnt < virtqueue_get_vring_size(rx_vq)) 251 + queue_work(virtio_vsock_workqueue, &vsock->rx_work); 252 + } 253 + 254 + return 0; 255 + } 256 + 216 257 static void virtio_vsock_rx_fill(struct virtio_vsock *vsock) 217 258 { 218 259 int buf_len = VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE; ··· 503 462 .release = virtio_transport_release, 504 463 .connect = virtio_transport_connect, 505 464 .shutdown = virtio_transport_shutdown, 465 + .cancel_pkt = virtio_transport_cancel_pkt, 506 466 507 467 .dgram_bind = virtio_transport_dgram_bind, 508 468 .dgram_dequeue = virtio_transport_dgram_dequeue,
+7
net/vmw_vsock/virtio_transport_common.c
··· 58 58 pkt->len = len; 59 59 pkt->hdr.len = cpu_to_le32(len); 60 60 pkt->reply = info->reply; 61 + pkt->vsk = info->vsk; 61 62 62 63 if (info->msg && len > 0) { 63 64 pkt->buf = kmalloc(len, GFP_KERNEL); ··· 181 180 struct virtio_vsock_pkt_info info = { 182 181 .op = VIRTIO_VSOCK_OP_CREDIT_UPDATE, 183 182 .type = type, 183 + .vsk = vsk, 184 184 }; 185 185 186 186 return virtio_transport_send_pkt_info(vsk, &info); ··· 521 519 struct virtio_vsock_pkt_info info = { 522 520 .op = VIRTIO_VSOCK_OP_REQUEST, 523 521 .type = VIRTIO_VSOCK_TYPE_STREAM, 522 + .vsk = vsk, 524 523 }; 525 524 526 525 return virtio_transport_send_pkt_info(vsk, &info); ··· 537 534 VIRTIO_VSOCK_SHUTDOWN_RCV : 0) | 538 535 (mode & SEND_SHUTDOWN ? 539 536 VIRTIO_VSOCK_SHUTDOWN_SEND : 0), 537 + .vsk = vsk, 540 538 }; 541 539 542 540 return virtio_transport_send_pkt_info(vsk, &info); ··· 564 560 .type = VIRTIO_VSOCK_TYPE_STREAM, 565 561 .msg = msg, 566 562 .pkt_len = len, 563 + .vsk = vsk, 567 564 }; 568 565 569 566 return virtio_transport_send_pkt_info(vsk, &info); ··· 586 581 .op = VIRTIO_VSOCK_OP_RST, 587 582 .type = VIRTIO_VSOCK_TYPE_STREAM, 588 583 .reply = !!pkt, 584 + .vsk = vsk, 589 585 }; 590 586 591 587 /* Send RST only if the original pkt is not a RST pkt */ ··· 832 826 .remote_cid = le64_to_cpu(pkt->hdr.src_cid), 833 827 .remote_port = le32_to_cpu(pkt->hdr.src_port), 834 828 .reply = true, 829 + .vsk = vsk, 835 830 }; 836 831 837 832 return virtio_transport_send_pkt_info(vsk, &info);
+56 -71
net/wireless/nl80211.c
··· 545 545 { 546 546 int err; 547 547 548 - rtnl_lock(); 549 - 550 548 if (!cb->args[0]) { 551 549 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, 552 550 genl_family_attrbuf(&nl80211_fam), 553 551 nl80211_fam.maxattr, nl80211_policy); 554 552 if (err) 555 - goto out_unlock; 553 + return err; 556 554 557 555 *wdev = __cfg80211_wdev_from_attrs( 558 556 sock_net(skb->sk), 559 557 genl_family_attrbuf(&nl80211_fam)); 560 - if (IS_ERR(*wdev)) { 561 - err = PTR_ERR(*wdev); 562 - goto out_unlock; 563 - } 558 + if (IS_ERR(*wdev)) 559 + return PTR_ERR(*wdev); 564 560 *rdev = wiphy_to_rdev((*wdev)->wiphy); 565 561 /* 0 is the first index - add 1 to parse only once */ 566 562 cb->args[0] = (*rdev)->wiphy_idx + 1; ··· 566 570 struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1); 567 571 struct wireless_dev *tmp; 568 572 569 - if (!wiphy) { 570 - err = -ENODEV; 571 - goto out_unlock; 572 - } 573 + if (!wiphy) 574 + return -ENODEV; 573 575 *rdev = wiphy_to_rdev(wiphy); 574 576 *wdev = NULL; 575 577 ··· 578 584 } 579 585 } 580 586 581 - if (!*wdev) { 582 - err = -ENODEV; 583 - goto out_unlock; 584 - } 587 + if (!*wdev) 588 + return -ENODEV; 585 589 } 586 590 587 591 return 0; 588 - out_unlock: 589 - rtnl_unlock(); 590 - return err; 591 - } 592 - 593 - static void nl80211_finish_wdev_dump(struct cfg80211_registered_device *rdev) 594 - { 595 - rtnl_unlock(); 596 592 } 597 593 598 594 /* IE validation */ ··· 2592 2608 int filter_wiphy = -1; 2593 2609 struct cfg80211_registered_device *rdev; 2594 2610 struct wireless_dev *wdev; 2611 + int ret; 2595 2612 2596 2613 rtnl_lock(); 2597 2614 if (!cb->args[2]) { 2598 2615 struct nl80211_dump_wiphy_state state = { 2599 2616 .filter_wiphy = -1, 2600 2617 }; 2601 - int ret; 2602 2618 2603 2619 ret = nl80211_dump_wiphy_parse(skb, cb, &state); 2604 2620 if (ret) 2605 - return ret; 2621 + goto out_unlock; 2606 2622 2607 2623 filter_wiphy = state.filter_wiphy; 2608 2624 ··· 2647 2663 wp_idx++; 2648 2664 } 2649 2665 out: 2650 - rtnl_unlock(); 2651 - 2652 2666 cb->args[0] = wp_idx; 2653 2667 cb->args[1] = if_idx; 2654 2668 2655 - return skb->len; 2669 + ret = skb->len; 2670 + out_unlock: 2671 + rtnl_unlock(); 2672 + 2673 + return ret; 2656 2674 } 2657 2675 2658 2676 static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info) ··· 4438 4452 int sta_idx = cb->args[2]; 4439 4453 int err; 4440 4454 4455 + rtnl_lock(); 4441 4456 err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev); 4442 4457 if (err) 4443 - return err; 4458 + goto out_err; 4444 4459 4445 4460 if (!wdev->netdev) { 4446 4461 err = -EINVAL; ··· 4476 4489 cb->args[2] = sta_idx; 4477 4490 err = skb->len; 4478 4491 out_err: 4479 - nl80211_finish_wdev_dump(rdev); 4492 + rtnl_unlock(); 4480 4493 4481 4494 return err; 4482 4495 } ··· 5262 5275 int path_idx = cb->args[2]; 5263 5276 int err; 5264 5277 5278 + rtnl_lock(); 5265 5279 err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev); 5266 5280 if (err) 5267 - return err; 5281 + goto out_err; 5268 5282 5269 5283 if (!rdev->ops->dump_mpath) { 5270 5284 err = -EOPNOTSUPP; ··· 5298 5310 cb->args[2] = path_idx; 5299 5311 err = skb->len; 5300 5312 out_err: 5301 - nl80211_finish_wdev_dump(rdev); 5313 + rtnl_unlock(); 5302 5314 return err; 5303 5315 } 5304 5316 ··· 5458 5470 int path_idx = cb->args[2]; 5459 5471 int err; 5460 5472 5473 + rtnl_lock(); 5461 5474 err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev); 5462 5475 if (err) 5463 - return err; 5476 + goto out_err; 5464 5477 5465 5478 if (!rdev->ops->dump_mpp) { 5466 5479 err = -EOPNOTSUPP; ··· 5494 5505 cb->args[2] = path_idx; 5495 5506 err = skb->len; 5496 5507 out_err: 5497 - nl80211_finish_wdev_dump(rdev); 5508 + rtnl_unlock(); 5498 5509 return err; 5499 5510 } 5500 5511 ··· 7663 7674 int start = cb->args[2], idx = 0; 7664 7675 int err; 7665 7676 7677 + rtnl_lock(); 7666 7678 err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev); 7667 - if (err) 7679 + if (err) { 7680 + rtnl_unlock(); 7668 7681 return err; 7682 + } 7669 7683 7670 7684 wdev_lock(wdev); 7671 7685 spin_lock_bh(&rdev->bss_lock); ··· 7691 7699 wdev_unlock(wdev); 7692 7700 7693 7701 cb->args[2] = idx; 7694 - nl80211_finish_wdev_dump(rdev); 7702 + rtnl_unlock(); 7695 7703 7696 7704 return skb->len; 7697 7705 } ··· 7776 7784 int res; 7777 7785 bool radio_stats; 7778 7786 7787 + rtnl_lock(); 7779 7788 res = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev); 7780 7789 if (res) 7781 - return res; 7790 + goto out_err; 7782 7791 7783 7792 /* prepare_wdev_dump parsed the attributes */ 7784 7793 radio_stats = attrbuf[NL80211_ATTR_SURVEY_RADIO_STATS]; ··· 7820 7827 cb->args[2] = survey_idx; 7821 7828 res = skb->len; 7822 7829 out_err: 7823 - nl80211_finish_wdev_dump(rdev); 7830 + rtnl_unlock(); 7824 7831 return res; 7825 7832 } 7826 7833 ··· 11501 11508 void *data = NULL; 11502 11509 unsigned int data_len = 0; 11503 11510 11504 - rtnl_lock(); 11505 - 11506 11511 if (cb->args[0]) { 11507 11512 /* subtract the 1 again here */ 11508 11513 struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1); 11509 11514 struct wireless_dev *tmp; 11510 11515 11511 - if (!wiphy) { 11512 - err = -ENODEV; 11513 - goto out_unlock; 11514 - } 11516 + if (!wiphy) 11517 + return -ENODEV; 11515 11518 *rdev = wiphy_to_rdev(wiphy); 11516 11519 *wdev = NULL; 11517 11520 ··· 11527 11538 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, 11528 11539 attrbuf, nl80211_fam.maxattr, nl80211_policy); 11529 11540 if (err) 11530 - goto out_unlock; 11541 + return err; 11531 11542 11532 11543 if (!attrbuf[NL80211_ATTR_VENDOR_ID] || 11533 - !attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) { 11534 - err = -EINVAL; 11535 - goto out_unlock; 11536 - } 11544 + !attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) 11545 + return -EINVAL; 11537 11546 11538 11547 *wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk), attrbuf); 11539 11548 if (IS_ERR(*wdev)) 11540 11549 *wdev = NULL; 11541 11550 11542 11551 *rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf); 11543 - if (IS_ERR(*rdev)) { 11544 - err = PTR_ERR(*rdev); 11545 - goto out_unlock; 11546 - } 11552 + if (IS_ERR(*rdev)) 11553 + return PTR_ERR(*rdev); 11547 11554 11548 11555 vid = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_ID]); 11549 11556 subcmd = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_SUBCMD]); ··· 11552 11567 if (vcmd->info.vendor_id != vid || vcmd->info.subcmd != subcmd) 11553 11568 continue; 11554 11569 11555 - if (!vcmd->dumpit) { 11556 - err = -EOPNOTSUPP; 11557 - goto out_unlock; 11558 - } 11570 + if (!vcmd->dumpit) 11571 + return -EOPNOTSUPP; 11559 11572 11560 11573 vcmd_idx = i; 11561 11574 break; 11562 11575 } 11563 11576 11564 - if (vcmd_idx < 0) { 11565 - err = -EOPNOTSUPP; 11566 - goto out_unlock; 11567 - } 11577 + if (vcmd_idx < 0) 11578 + return -EOPNOTSUPP; 11568 11579 11569 11580 if (attrbuf[NL80211_ATTR_VENDOR_DATA]) { 11570 11581 data = nla_data(attrbuf[NL80211_ATTR_VENDOR_DATA]); ··· 11577 11596 11578 11597 /* keep rtnl locked in successful case */ 11579 11598 return 0; 11580 - out_unlock: 11581 - rtnl_unlock(); 11582 - return err; 11583 11599 } 11584 11600 11585 11601 static int nl80211_vendor_cmd_dump(struct sk_buff *skb, ··· 11591 11613 int err; 11592 11614 struct nlattr *vendor_data; 11593 11615 11616 + rtnl_lock(); 11594 11617 err = nl80211_prepare_vendor_dump(skb, cb, &rdev, &wdev); 11595 11618 if (err) 11596 - return err; 11619 + goto out; 11597 11620 11598 11621 vcmd_idx = cb->args[2]; 11599 11622 data = (void *)cb->args[3]; ··· 11603 11624 11604 11625 if (vcmd->flags & (WIPHY_VENDOR_CMD_NEED_WDEV | 11605 11626 WIPHY_VENDOR_CMD_NEED_NETDEV)) { 11606 - if (!wdev) 11607 - return -EINVAL; 11627 + if (!wdev) { 11628 + err = -EINVAL; 11629 + goto out; 11630 + } 11608 11631 if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_NETDEV && 11609 - !wdev->netdev) 11610 - return -EINVAL; 11632 + !wdev->netdev) { 11633 + err = -EINVAL; 11634 + goto out; 11635 + } 11611 11636 11612 11637 if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_RUNNING) { 11613 - if (!wdev_running(wdev)) 11614 - return -ENETDOWN; 11638 + if (!wdev_running(wdev)) { 11639 + err = -ENETDOWN; 11640 + goto out; 11641 + } 11615 11642 } 11616 11643 } 11617 11644
+10 -9
tools/testing/selftests/bpf/Makefile
··· 1 1 LIBDIR := ../../../lib 2 - BPFOBJ := $(LIBDIR)/bpf/bpf.o 2 + BPFDIR := $(LIBDIR)/bpf 3 3 4 - CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) $(BPFOBJ) 4 + CFLAGS += -Wall -O2 -I../../../include/uapi -I$(LIBDIR) 5 + LDLIBS += -lcap 5 6 6 7 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map 7 8 8 9 TEST_PROGS := test_kmod.sh 9 10 10 - all: $(TEST_GEN_PROGS) 11 + include ../lib.mk 11 12 12 - .PHONY: all clean force 13 + BPFOBJ := $(OUTPUT)/bpf.o 14 + 15 + $(TEST_GEN_PROGS): $(BPFOBJ) 16 + 17 + .PHONY: force 13 18 14 19 # force a rebuild of BPFOBJ when its dependencies are updated 15 20 force: 16 21 17 22 $(BPFOBJ): force 18 - $(MAKE) -C $(dir $(BPFOBJ)) 19 - 20 - $(test_objs): $(BPFOBJ) 21 - 22 - include ../lib.mk 23 + $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
+26 -3
tools/testing/selftests/bpf/test_maps.c
··· 80 80 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0); 81 81 key = 2; 82 82 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); 83 - key = 1; 84 - assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); 83 + key = 3; 84 + assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 && 85 + errno == E2BIG); 85 86 86 87 /* Check that key = 0 doesn't exist. */ 87 88 key = 0; ··· 109 108 errno == ENOENT); 110 109 111 110 close(fd); 111 + } 112 + 113 + static void test_hashmap_sizes(int task, void *data) 114 + { 115 + int fd, i, j; 116 + 117 + for (i = 1; i <= 512; i <<= 1) 118 + for (j = 1; j <= 1 << 18; j <<= 1) { 119 + fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, 120 + 2, map_flags); 121 + if (fd < 0) { 122 + printf("Failed to create hashmap key=%d value=%d '%s'\n", 123 + i, j, strerror(errno)); 124 + exit(1); 125 + } 126 + close(fd); 127 + usleep(10); /* give kernel time to destroy */ 128 + } 112 129 } 113 130 114 131 static void test_hashmap_percpu(int task, void *data) ··· 336 317 static void test_arraymap_percpu_many_keys(void) 337 318 { 338 319 unsigned int nr_cpus = bpf_num_possible_cpus(); 339 - unsigned int nr_keys = 20000; 320 + /* nr_keys is not too large otherwise the test stresses percpu 321 + * allocator more than anything else 322 + */ 323 + unsigned int nr_keys = 2000; 340 324 long values[nr_cpus]; 341 325 int key, fd, i; 342 326 ··· 441 419 { 442 420 run_parallel(100, test_hashmap, NULL); 443 421 run_parallel(100, test_hashmap_percpu, NULL); 422 + run_parallel(100, test_hashmap_sizes, NULL); 444 423 445 424 run_parallel(100, test_arraymap, NULL); 446 425 run_parallel(100, test_arraymap_percpu, NULL);