History

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

Pull networking fixes from David Miller: 1) Fix off by one wrt. indexing when dumping /proc/net/route entries, from Alexander Duyck. 2) Fix lockdep splats in iwlwifi, from Johannes Berg. 3) Cure panic when inserting certain netfilter rules when NFT_SET_HASH is disabled, from Liping Zhang. 4) Memory leak when nft_expr_clone() fails, also from Liping Zhang. 5) Disable UFO when path will apply IPSEC tranformations, from Jakub Sitnicki. 6) Don't bogusly double cwnd in dctcp module, from Florian Westphal. 7) skb_checksum_help() should never actually use the value "0" for the resulting checksum, that has a special meaning, use CSUM_MANGLED_0 instead. From Eric Dumazet. 8) Per-tx/rx queue statistic strings are wrong in qed driver, fix from Yuval MIntz. 9) Fix SCTP reference counting of associations and transports in sctp_diag. From Xin Long. 10) When we hit ip6tunnel_xmit() we could have come from an ipv4 path in a previous layer or similar, so explicitly clear the ipv6 control block in the skb. From Eli Cooper. 11) Fix bogus sleeping inside of inet_wait_for_connect(), from WANG Cong. 12) Correct deivce ID of T6 adapter in cxgb4 driver, from Hariprasad Shenai. 13) Fix potential access past the end of the skb page frag array in tcp_sendmsg(). From Eric Dumazet. 14) 'skb' can legitimately be NULL in inet{,6}_exact_dif_match(). Fix from David Ahern. 15) Don't return an error in tcp_sendmsg() if we wronte any bytes successfully, from Eric Dumazet. 16) Extraneous unlocks in netlink_diag_dump(), we removed the locking but forgot to purge these unlock calls. From Eric Dumazet. 17) Fix memory leak in error path of __genl_register_family(). We leak the attrbuf, from WANG Cong. 18) cgroupstats netlink policy table is mis-sized, from WANG Cong. 19) Several XDP bug fixes in mlx5, from Saeed Mahameed. 20) Fix several device refcount leaks in network drivers, from Johan Hovold. 21) icmp6_send() should use skb dst device not skb->dev to determine L3 routing domain. From David Ahern. 22) ip_vs_genl_family sets maxattr incorrectly, from WANG Cong. 23) We leak new macvlan port in some cases of maclan_common_netlink() errors. Fix from Gao Feng. 24) Similar to the icmp6_send() fix, icmp_route_lookup() should determine L3 routing domain using skb_dst(skb)->dev not skb->dev. Also from David Ahern. 25) Several fixes for route offloading and FIB notification handling in mlxsw driver, from Jiri Pirko. 26) Properly cap __skb_flow_dissect()'s return value, from Eric Dumazet. 27) Fix long standing regression in ipv4 redirect handling, wrt. validating the new neighbour's reachability. From Stephen Suryaputra Lin. 28) If sk_filter() trims the packet excessively, handle it reasonably in tcp input instead of exploding. From Eric Dumazet. 29) Fix handling of napi hash state when copying channels in sfc driver, from Bert Kenward. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (121 commits) mlxsw: spectrum_router: Flush FIB tables during fini net: stmmac: Fix lack of link transition for fixed PHYs sctp: change sk state only when it has assocs in sctp_shutdown bnx2: Wait for in-flight DMA to complete at probe stage Revert "bnx2: Reset device during driver initialization" ps3_gelic: fix spelling mistake in debug message net: ethernet: ixp4xx_eth: fix spelling mistake in debug message ibmvnic: Fix size of debugfs name buffer ibmvnic: Unmap ibmvnic_statistics structure sfc: clear napi_hash state when copying channels mlxsw: spectrum_router: Correctly dump neighbour activity mlxsw: spectrum: Fix refcount bug on span entries bnxt_en: Fix VF virtual link state. bnxt_en: Fix ring arithmetic in bnxt_setup_tc(). Revert "include/uapi/linux/atm_zatm.h: include linux/time.h" tcp: take care of truncations done by sk_filter() ipv4: use new_gw for redirect neigh lookup r8152: Fix error path in open function net: bpqether.h: remove if_ether.h guard net: __skb_flow_dissect() must cap its return value ...

Linus Torvalds committed 10 years ago

Commit e76d21c2 parents d4b9532 ac571de120 files · +1358 −465Browse files

Unified · Split

120 files
  1. Documentation/networking/dsa/dsa.txt +2 −1
  2. MAINTAINERS +1 −0
  3. drivers/net/can/sja1000/plx_pci.c +18 −0
  4. drivers/net/ethernet/apm/xgene/xgene_enet_hw.c +0 −12
  5. drivers/net/ethernet/apm/xgene/xgene_enet_hw.h +2 −0
  6. drivers/net/ethernet/apm/xgene/xgene_enet_main.c +2 −1
  7. drivers/net/ethernet/apm/xgene/xgene_enet_ring2.c +7 −5
  8. drivers/net/ethernet/broadcom/bgmac.c +6 −3
  9. drivers/net/ethernet/broadcom/bnx2.c +36 −12
  10. drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 −5
  11. drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +2 −2
  12. drivers/net/ethernet/brocade/bna/bnad.c +2 −2
  13. drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h +1 −1
  14. drivers/net/ethernet/hisilicon/hns/hnae.c +7 −1
  15. drivers/net/ethernet/ibm/ehea/ehea_main.c +2 −0
  16. drivers/net/ethernet/ibm/ibmvnic.c +6 −4
  17. drivers/net/ethernet/marvell/mv643xx_eth.c +2 −0
  18. drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 −1
  19. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +16 −15
  20. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 −1
  21. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 −1
  22. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 −1
  23. drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +1 −1
  24. drivers/net/ethernet/mellanox/mlx5/core/main.c +3 −2
  25. drivers/net/ethernet/mellanox/mlxsw/spectrum.c +3 −1
  26. drivers/net/ethernet/mellanox/mlxsw/spectrum.h +1 −1
  27. drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +70 −64
  28. drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +7 −7
  29. drivers/net/ethernet/qlogic/qed/qed_hsi.h +0 −3
  30. drivers/net/ethernet/qlogic/qed/qed_ll2.c +1 −0
  31. drivers/net/ethernet/qlogic/qed/qed_main.c +8 −9
  32. drivers/net/ethernet/qlogic/qede/qede_ethtool.c +16 −9
  33. drivers/net/ethernet/qlogic/qede/qede_main.c +1 −1
  34. drivers/net/ethernet/qualcomm/emac/emac-mac.c +11 −4
  35. drivers/net/ethernet/qualcomm/emac/emac-sgmii.c +1 −1
  36. drivers/net/ethernet/sfc/efx.c +3 −0
  37. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 −0
  38. drivers/net/ethernet/ti/cpsw-phy-sel.c +3 −0
  39. drivers/net/ethernet/ti/davinci_emac.c +6 −4
  40. drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +1 −1
  41. drivers/net/ethernet/xscale/ixp4xx_eth.c +1 −2
  42. drivers/net/macvlan.c +22 −9
  43. drivers/net/phy/phy_device.c +2 −0
  44. drivers/net/usb/ax88179_178a.c +17 −0
  45. drivers/net/usb/r8152.c +12 −9
  46. drivers/net/virtio_net.c +20 −10
  47. drivers/net/vxlan.c +3 −1
  48. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +1 −1
  49. drivers/net/wireless/intel/iwlwifi/mvm/d3.c +38 −11
  50. drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +2 −2
  51. drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 −2
  52. drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +1 −0
  53. drivers/net/wireless/intel/iwlwifi/mvm/ops.c +1 −0
  54. drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +2 −1
  55. drivers/net/wireless/intel/iwlwifi/mvm/scan.c +27 −6
  56. drivers/net/wireless/intel/iwlwifi/pcie/drv.c +48 −31
  57. drivers/net/wireless/intel/iwlwifi/pcie/tx.c +8 −0
  58. drivers/net/xen-netfront.c +2 −2
  59. include/linux/ipv6.h +1 −1
  60. include/linux/netdevice.h +15 −0
  61. include/net/ip.h +1 −2
  62. include/net/ip6_tunnel.h +1 −0
  63. include/net/netfilter/nf_conntrack_labels.h +1 −2
  64. include/net/netfilter/nf_tables.h +5 −3
  65. include/net/sctp/sctp.h +1 −1
  66. include/net/sock.h +2 −2
  67. include/net/tcp.h +2 −1
  68. include/uapi/linux/atm_zatm.h +0 −1
  69. include/uapi/linux/bpqether.h +0 −2
  70. kernel/bpf/hashtab.c +2 −1
  71. kernel/bpf/syscall.c +3 −1
  72. kernel/taskstats.c +5 −1
  73. net/can/bcm.c +23 −9
  74. net/core/dev.c +7 −12
  75. net/core/filter.c +60 −8
  76. net/core/flow_dissector.c +8 −3
  77. net/core/rtnetlink.c +1 −0
  78. net/core/sock.c +4 −2
  79. net/dccp/ipv4.c +9 −7
  80. net/dccp/ipv6.c +11 −8
  81. net/dccp/proto.c +4 −0
  82. net/ipv4/af_inet.c +4 −5
  83. net/ipv4/fib_trie.c +9 −12
  84. net/ipv4/icmp.c +2 −2
  85. net/ipv4/ip_forward.c +1 −1
  86. net/ipv4/ip_output.c +15 −10
  87. net/ipv4/ip_tunnel_core.c +0 −11
  88. net/ipv4/ipmr.c +1 −1
  89. net/ipv4/netfilter/nft_dup_ipv4.c +4 −2
  90. net/ipv4/route.c +3 −1
  91. net/ipv4/tcp.c +2 −2
  92. net/ipv4/tcp_dctcp.c +12 −1
  93. net/ipv4/tcp_ipv4.c +18 −1
  94. net/ipv6/icmp.c +1 −1
  95. net/ipv6/ip6_output.c +1 −1
  96. net/ipv6/ip6_udp_tunnel.c +0 −3
  97. net/ipv6/netfilter/nft_dup_ipv6.c +4 −2
  98. net/ipv6/route.c +4 −0
  99. net/ipv6/tcp_ipv6.c +10 −4
  100. net/netfilter/ipvs/ip_vs_ctl.c +1 −1
  101. net/netfilter/ipvs/ip_vs_sync.c +5 −2
  102. net/netfilter/nf_conntrack_core.c +41 −8
  103. net/netfilter/nf_conntrack_helper.c +8 −3
  104. net/netfilter/nf_conntrack_sip.c +4 −1
  105. net/netfilter/nf_tables_api.c +11 −7
  106. net/netfilter/nft_dynset.c +13 −6
  107. net/netfilter/nft_set_hash.c +14 −5
  108. net/netfilter/nft_set_rbtree.c +1 −1
  109. net/netfilter/xt_connmark.c +2 −2
  110. net/netlink/diag.c +1 −4
  111. net/netlink/genetlink.c +3 −1
  112. net/sctp/input.c +17 −18
  113. net/sctp/ipv6.c +1 −1
  114. net/sctp/socket.c +13 −14
  115. net/socket.c +2 −0
  116. net/unix/af_unix.c +2 −1
  117. samples/bpf/Makefile +4 −0
  118. samples/bpf/tc_l2_redirect.sh +173 −0
  119. samples/bpf/tc_l2_redirect_kern.c +236 −0
  120. samples/bpf/tc_l2_redirect_user.c +73 −0
Documentation/networking/dsa/dsa.txt+2−1
@@ -67,13 +67,14 @@ Note that DSA does not currently create network interfaces for the "cpu" and · 66 unmodified lines
6767 Switch tagging protocols
6868 ------------------------
6969
70−DSA currently supports 4 different tagging protocols, and a tag-less mode as
70+DSA currently supports 5 different tagging protocols, and a tag-less mode as
7171 well. The different protocols are implemented in:
7272
7373 net/dsa/tag_trailer.c: Marvell's 4 trailer tag mode (legacy)
7474 net/dsa/tag_dsa.c: Marvell's original DSA tag
7575 net/dsa/tag_edsa.c: Marvell's enhanced DSA tag
7676 net/dsa/tag_brcm.c: Broadcom's 4 bytes tag
77+net/dsa/tag_qca.c: Qualcomm's 2 bytes tag
7778
7879 The exact format of the tag protocol is vendor specific, but in general, they
7980 all contain something which:
MAINTAINERS+1−0
@@ -8057,6 +8057,7 @@ F: drivers/infiniband/hw/mlx4/ · 8056 unmodified lines
80578057 F: include/linux/mlx4/
80588058
80598059 MELLANOX MLX5 core VPI driver
8060+M: Saeed Mahameed <saeedm@mellanox.com>
80608061 M: Matan Barak <matanb@mellanox.com>
80618062 M: Leon Romanovsky <leonro@mellanox.com>
80628063 L: netdev@vger.kernel.org
drivers/net/can/sja1000/plx_pci.c+18−0
@@ -142,6 +142,9 @@ struct plx_pci_card { · 141 unmodified lines
142142 #define CTI_PCI_VENDOR_ID 0x12c4
143143 #define CTI_PCI_DEVICE_ID_CRG001 0x0900
144144
145+#define MOXA_PCI_VENDOR_ID 0x1393
146+#define MOXA_PCI_DEVICE_ID 0x0100
147+
145148 static void plx_pci_reset_common(struct pci_dev *pdev);
146149 static void plx9056_pci_reset_common(struct pci_dev *pdev);
147150 static void plx_pci_reset_marathon_pci(struct pci_dev *pdev);
@@ -258,6 +261,14 @@ static struct plx_pci_card_info plx_pci_card_info_elcus = { · 110 unmodified lines
258261 /* based on PLX9030 */
259262 };
260263
264+static struct plx_pci_card_info plx_pci_card_info_moxa = {
265+ "MOXA", 2,
266+ PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
267+ {0, 0x00, 0x00}, { {0, 0x00, 0x80}, {1, 0x00, 0x80} },
268+ &plx_pci_reset_common
269+ /* based on PLX9052 */
270+};
271+
261272 static const struct pci_device_id plx_pci_tbl[] = {
262273 {
263274 /* Adlink PCI-7841/cPCI-7841 */
@@ -357,6 +368,13 @@ static const struct pci_device_id plx_pci_tbl[] = { · 93 unmodified lines
357368 0, 0,
358369 (kernel_ulong_t)&plx_pci_card_info_elcus
359370 },
371+ {
372+ /* moxa */
373+ MOXA_PCI_VENDOR_ID, MOXA_PCI_DEVICE_ID,
374+ PCI_ANY_ID, PCI_ANY_ID,
375+ 0, 0,
376+ (kernel_ulong_t)&plx_pci_card_info_moxa
377+ },
360378 { 0,}
361379 };
362380 MODULE_DEVICE_TABLE(pci, plx_pci_tbl);
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c+0−12
@@ -204,17 +204,6 @@ static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring) · 203 unmodified lines
204204 return num_msgs;
205205 }
206206
207−static void xgene_enet_setup_coalescing(struct xgene_enet_desc_ring *ring)
208−{
209− u32 data = 0x7777;
210−
211− xgene_enet_ring_wr32(ring, CSR_PBM_COAL, 0x8e);
212− xgene_enet_ring_wr32(ring, CSR_PBM_CTICK1, data);
213− xgene_enet_ring_wr32(ring, CSR_PBM_CTICK2, data << 16);
214− xgene_enet_ring_wr32(ring, CSR_THRESHOLD0_SET1, 0x40);
215− xgene_enet_ring_wr32(ring, CSR_THRESHOLD1_SET1, 0x80);
216−}
217−
218207 void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
219208 struct xgene_enet_pdata *pdata,
220209 enum xgene_enet_err_code status)
@@ -929,5 +918,4 @@ struct xgene_ring_ops xgene_ring1_ops = { · 708 unmodified lines
929918 .clear = xgene_enet_clear_ring,
930919 .wr_cmd = xgene_enet_wr_cmd,
931920 .len = xgene_enet_ring_len,
932− .coalesce = xgene_enet_setup_coalescing,
933921 };
drivers/net/ethernet/apm/xgene/xgene_enet_hw.h+2−0
@@ -55,8 +55,10 @@ enum xgene_enet_rm { · 54 unmodified lines
5555 #define PREFETCH_BUF_EN BIT(21)
5656 #define CSR_RING_ID_BUF 0x000c
5757 #define CSR_PBM_COAL 0x0014
58+#define CSR_PBM_CTICK0 0x0018
5859 #define CSR_PBM_CTICK1 0x001c
5960 #define CSR_PBM_CTICK2 0x0020
61+#define CSR_PBM_CTICK3 0x0024
6062 #define CSR_THRESHOLD0_SET1 0x0030
6163 #define CSR_THRESHOLD1_SET1 0x0034
6264 #define CSR_RING_NE_INT_MODE 0x017c
drivers/net/ethernet/apm/xgene/xgene_enet_main.c+2−1
@@ -1188,7 +1188,8 @@ static int xgene_enet_create_desc_rings(struct net_device *ndev) · 1187 unmodified lines
11881188 tx_ring->dst_ring_num = xgene_enet_dst_ring_num(cp_ring);
11891189 }
11901190
1191− pdata->ring_ops->coalesce(pdata->tx_ring[0]);
1191+ if (pdata->ring_ops->coalesce)
1192+ pdata->ring_ops->coalesce(pdata->tx_ring[0]);
11921193 pdata->tx_qcnt_hi = pdata->tx_ring[0]->slots - 128;
11931194
11941195 return 0;
drivers/net/ethernet/apm/xgene/xgene_enet_ring2.c+7−5
@@ -30,7 +30,7 @@ static void xgene_enet_ring_init(struct xgene_enet_desc_ring *ring) · 29 unmodified lines
3030 ring_cfg[0] |= SET_VAL(X2_INTLINE, ring->id & RING_BUFNUM_MASK);
3131 ring_cfg[3] |= SET_BIT(X2_DEQINTEN);
3232 }
33− ring_cfg[0] |= SET_VAL(X2_CFGCRID, 1);
33+ ring_cfg[0] |= SET_VAL(X2_CFGCRID, 2);
3434
3535 addr >>= 8;
3636 ring_cfg[2] |= QCOHERENT | SET_VAL(RINGADDRL, addr);
@@ -192,13 +192,15 @@ static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring) · 155 unmodified lines
192192
193193 static void xgene_enet_setup_coalescing(struct xgene_enet_desc_ring *ring)
194194 {
195− u32 data = 0x7777;
195+ u32 data = 0x77777777;
196196
197197 xgene_enet_ring_wr32(ring, CSR_PBM_COAL, 0x8e);
198+ xgene_enet_ring_wr32(ring, CSR_PBM_CTICK0, data);
198199 xgene_enet_ring_wr32(ring, CSR_PBM_CTICK1, data);
199− xgene_enet_ring_wr32(ring, CSR_PBM_CTICK2, data << 16);
200− xgene_enet_ring_wr32(ring, CSR_THRESHOLD0_SET1, 0x40);
201− xgene_enet_ring_wr32(ring, CSR_THRESHOLD1_SET1, 0x80);
200+ xgene_enet_ring_wr32(ring, CSR_PBM_CTICK2, data);
201+ xgene_enet_ring_wr32(ring, CSR_PBM_CTICK3, data);
202+ xgene_enet_ring_wr32(ring, CSR_THRESHOLD0_SET1, 0x08);
203+ xgene_enet_ring_wr32(ring, CSR_THRESHOLD1_SET1, 0x10);
202204 }
203205
204206 struct xgene_ring_ops xgene_ring2_ops = {
drivers/net/ethernet/broadcom/bgmac.c+6−3
@@ -307,6 +307,10 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac, · 306 unmodified lines
307307 u32 ctl;
308308
309309 ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL);
310+
311+ /* preserve ONLY bits 16-17 from current hardware value */
312+ ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
313+
310314 if (bgmac->feature_flags & BGMAC_FEAT_RX_MASK_SETUP) {
311315 ctl &= ~BGMAC_DMA_RX_BL_MASK;
312316 ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT;
@@ -317,7 +321,6 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac, · 4 unmodified lines
317321 ctl &= ~BGMAC_DMA_RX_PT_MASK;
318322 ctl |= BGMAC_DMA_RX_PT_1 << BGMAC_DMA_RX_PT_SHIFT;
319323 }
320− ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
321324 ctl |= BGMAC_DMA_RX_ENABLE;
322325 ctl |= BGMAC_DMA_RX_PARITY_DISABLE;
323326 ctl |= BGMAC_DMA_RX_OVERFLOW_CONT;
@@ -1046,9 +1049,9 @@ static void bgmac_enable(struct bgmac *bgmac) · 722 unmodified lines
10461049
10471050 mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
10481051 BGMAC_DS_MM_SHIFT;
1049− if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) || mode != 0)
1052+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
10501053 bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
1051− if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
1054+ if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) && mode == 2)
10521055 bgmac_cco_ctl_maskset(bgmac, 1, ~0,
10531056 BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
10541057
drivers/net/ethernet/broadcom/bnx2.c+36−12
@@ -49,6 +49,7 @@ · 48 unmodified lines
4949 #include <linux/firmware.h>
5050 #include <linux/log2.h>
5151 #include <linux/aer.h>
52+#include <linux/crash_dump.h>
5253
5354 #if IS_ENABLED(CONFIG_CNIC)
5455 #define BCM_CNIC 1
@@ -4764,15 +4765,16 @@ bnx2_setup_msix_tbl(struct bnx2 *bp) · 4709 unmodified lines
47644765 BNX2_WR(bp, BNX2_PCI_GRC_WINDOW3_ADDR, BNX2_MSIX_PBA_ADDR);
47654766 }
47664767
4767−static int
4768−bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
4768+static void
4769+bnx2_wait_dma_complete(struct bnx2 *bp)
47694770 {
47704771 u32 val;
4771− int i, rc = 0;
4772− u8 old_port;
4772+ int i;
47734773
4774− /* Wait for the current PCI transaction to complete before
4775− * issuing a reset. */
4774+ /*
4775+ * Wait for the current PCI transaction to complete before
4776+ * issuing a reset.
4777+ */
47764778 if ((BNX2_CHIP(bp) == BNX2_CHIP_5706) ||
47774779 (BNX2_CHIP(bp) == BNX2_CHIP_5708)) {
47784780 BNX2_WR(bp, BNX2_MISC_ENABLE_CLR_BITS,
@@ -4796,6 +4798,21 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code) · 17 unmodified lines
47964798 }
47974799 }
47984800
4801+ return;
4802+}
4803+
4804+
4805+static int
4806+bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
4807+{
4808+ u32 val;
4809+ int i, rc = 0;
4810+ u8 old_port;
4811+
4812+ /* Wait for the current PCI transaction to complete before
4813+ * issuing a reset. */
4814+ bnx2_wait_dma_complete(bp);
4815+
47994816 /* Wait for the firmware to tell us it is ok to issue a reset. */
48004817 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code, 1, 1);
48014818
@@ -6361,6 +6378,10 @@ bnx2_open(struct net_device *dev) · 1559 unmodified lines
63616378 struct bnx2 *bp = netdev_priv(dev);
63626379 int rc;
63636380
6381+ rc = bnx2_request_firmware(bp);
6382+ if (rc < 0)
6383+ goto out;
6384+
63646385 netif_carrier_off(dev);
63656386
63666387 bnx2_disable_int(bp);
@@ -6429,6 +6450,7 @@ open_err: · 62 unmodified lines
64296450 bnx2_free_irq(bp);
64306451 bnx2_free_mem(bp);
64316452 bnx2_del_napi(bp);
6453+ bnx2_release_firmware(bp);
64326454 goto out;
64336455 }
64346456
@@ -8575,12 +8597,15 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 2140 unmodified lines
85758597
85768598 pci_set_drvdata(pdev, dev);
85778599
8578− rc = bnx2_request_firmware(bp);
8579− if (rc < 0)
8580− goto error;
8581−
8600+ /*
8601+ * In-flight DMA from 1st kernel could continue going in kdump kernel.
8602+ * New io-page table has been created before bnx2 does reset at open stage.
8603+ * We have to wait for the in-flight DMA to complete to avoid it look up
8604+ * into the newly created io-page table.
8605+ */
8606+ if (is_kdump_kernel())
8607+ bnx2_wait_dma_complete(bp);
85828608
8583− bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
85848609 memcpy(dev->dev_addr, bp->mac_addr, ETH_ALEN);
85858610
85868611 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
@@ -8613,7 +8638,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 26 unmodified lines
86138638 return 0;
86148639
86158640 error:
8616− bnx2_release_firmware(bp);
86178641 pci_iounmap(pdev, bp->regview);
86188642 pci_release_regions(pdev);
86198643 pci_disable_device(pdev);
drivers/net/ethernet/broadcom/bnxt/bnxt.c+6−5
@@ -6309,6 +6309,7 @@ static int bnxt_setup_tc(struct net_device *dev, u32 handle, __be16 proto, · 6308 unmodified lines
63096309 struct tc_to_netdev *ntc)
63106310 {
63116311 struct bnxt *bp = netdev_priv(dev);
6312+ bool sh = false;
63126313 u8 tc;
63136314
63146315 if (ntc->type != TC_SETUP_MQPRIO)
@@ -6325,12 +6326,11 @@ static int bnxt_setup_tc(struct net_device *dev, u32 handle, __be16 proto, · 10 unmodified lines
63256326 if (netdev_get_num_tc(dev) == tc)
63266327 return 0;
63276328
6329+ if (bp->flags & BNXT_FLAG_SHARED_RINGS)
6330+ sh = true;
6331+
63286332 if (tc) {
63296333 int max_rx_rings, max_tx_rings, rc;
6330− bool sh = false;
6331−
6332− if (bp->flags & BNXT_FLAG_SHARED_RINGS)
6333− sh = true;
63346334
63356335 rc = bnxt_get_max_rings(bp, &max_rx_rings, &max_tx_rings, sh);
63366336 if (rc || bp->tx_nr_rings_per_tc * tc > max_tx_rings)
@@ -6348,7 +6348,8 @@ static int bnxt_setup_tc(struct net_device *dev, u32 handle, __be16 proto, · 11 unmodified lines
63486348 bp->tx_nr_rings = bp->tx_nr_rings_per_tc;
63496349 netdev_reset_tc(dev);
63506350 }
6351− bp->cp_nr_rings = max_t(int, bp->tx_nr_rings, bp->rx_nr_rings);
6351+ bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
6352+ bp->tx_nr_rings + bp->rx_nr_rings;
63526353 bp->num_stat_ctxs = bp->cp_nr_rings;
63536354
63546355 if (netif_running(bp->dev))
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c+2−2
@@ -774,8 +774,8 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf) · 773 unmodified lines
774774
775775 if (vf->flags & BNXT_VF_LINK_UP) {
776776 /* if physical link is down, force link up on VF */
777− if (phy_qcfg_resp.link ==
778− PORT_PHY_QCFG_RESP_LINK_NO_LINK) {
777+ if (phy_qcfg_resp.link !=
778+ PORT_PHY_QCFG_RESP_LINK_LINK) {
779779 phy_qcfg_resp.link =
780780 PORT_PHY_QCFG_RESP_LINK_LINK;
781781 phy_qcfg_resp.link_speed = cpu_to_le16(
drivers/net/ethernet/brocade/bna/bnad.c+2−2
@@ -177,6 +177,7 @@ bnad_txcmpl_process(struct bnad *bnad, struct bna_tcb *tcb) · 176 unmodified lines
177177 return 0;
178178
179179 hw_cons = *(tcb->hw_consumer_index);
180+ rmb();
180181 cons = tcb->consumer_index;
181182 q_depth = tcb->q_depth;
182183
@@ -3094,7 +3095,7 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev) · 2911 unmodified lines
30943095 BNA_QE_INDX_INC(prod, q_depth);
30953096 tcb->producer_index = prod;
30963097
3097− smp_mb();
3098+ wmb();
30983099
30993100 if (unlikely(!test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags)))
31003101 return NETDEV_TX_OK;
@@ -3102,7 +3103,6 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev) · 1 unmodified line
31023103 skb_tx_timestamp(skb);
31033104
31043105 bna_txq_prod_indx_doorbell(tcb);
3105− smp_mb();
31063106
31073107 return NETDEV_TX_OK;
31083108 }
drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h+1−1
@@ -178,9 +178,9 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN · 177 unmodified lines
178178 CH_PCI_ID_TABLE_FENTRY(0x6005),
179179 CH_PCI_ID_TABLE_FENTRY(0x6006),
180180 CH_PCI_ID_TABLE_FENTRY(0x6007),
181+ CH_PCI_ID_TABLE_FENTRY(0x6008),
181182 CH_PCI_ID_TABLE_FENTRY(0x6009),
182183 CH_PCI_ID_TABLE_FENTRY(0x600d),
183− CH_PCI_ID_TABLE_FENTRY(0x6010),
184184 CH_PCI_ID_TABLE_FENTRY(0x6011),
185185 CH_PCI_ID_TABLE_FENTRY(0x6014),
186186 CH_PCI_ID_TABLE_FENTRY(0x6015),
drivers/net/ethernet/hisilicon/hns/hnae.c+7−1
@@ -332,8 +332,10 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev, · 331 unmodified lines
332332 return ERR_PTR(-ENODEV);
333333
334334 handle = dev->ops->get_handle(dev, port_id);
335− if (IS_ERR(handle))
335+ if (IS_ERR(handle)) {
336+ put_device(&dev->cls_dev);
336337 return handle;
338+ }
337339
338340 handle->dev = dev;
339341 handle->owner_dev = owner_dev;
@@ -356,6 +358,8 @@ out_when_init_queue: · 16 unmodified lines
356358 for (j = i - 1; j >= 0; j--)
357359 hnae_fini_queue(handle->qs[j]);
358360
361+ put_device(&dev->cls_dev);
362+
359363 return ERR_PTR(-ENOMEM);
360364 }
361365 EXPORT_SYMBOL(hnae_get_handle);
@@ -377,6 +381,8 @@ void hnae_put_handle(struct hnae_handle *h) · 15 unmodified lines
377381 dev->ops->put_handle(h);
378382
379383 module_put(dev->owner);
384+
385+ put_device(&dev->cls_dev);
380386 }
381387 EXPORT_SYMBOL(hnae_put_handle);
382388
drivers/net/ethernet/ibm/ehea/ehea_main.c+2−0
@@ -2446,6 +2446,8 @@ static int ehea_open(struct net_device *dev) · 2445 unmodified lines
24462446
24472447 netif_info(port, ifup, dev, "enabling port\n");
24482448
2449+ netif_carrier_off(dev);
2450+
24492451 ret = ehea_up(dev);
24502452 if (!ret) {
24512453 port_napi_enable(port);
drivers/net/ethernet/ibm/ibmvnic.c+6−4
@@ -1505,9 +1505,8 @@ static void init_sub_crqs(struct ibmvnic_adapter *adapter, int retry) · 1504 unmodified lines
15051505 adapter->max_rx_add_entries_per_subcrq > entries_page ?
15061506 entries_page : adapter->max_rx_add_entries_per_subcrq;
15071507
1508− /* Choosing the maximum number of queues supported by firmware*/
1509− adapter->req_tx_queues = adapter->max_tx_queues;
1510− adapter->req_rx_queues = adapter->max_rx_queues;
1508+ adapter->req_tx_queues = adapter->opt_tx_comp_sub_queues;
1509+ adapter->req_rx_queues = adapter->opt_rx_comp_queues;
15111510 adapter->req_rx_add_queues = adapter->max_rx_add_queues;
15121511
15131512 adapter->req_mtu = adapter->max_mtu;
@@ -3706,7 +3705,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) · 2192 unmodified lines
37063705 struct net_device *netdev;
37073706 unsigned char *mac_addr_p;
37083707 struct dentry *ent;
3709− char buf[16]; /* debugfs name buf */
3708+ char buf[17]; /* debugfs name buf */
37103709 int rc;
37113710
37123711 dev_dbg(&dev->dev, "entering ibmvnic_probe for UA 0x%x\n",
@@ -3845,6 +3844,9 @@ static int ibmvnic_remove(struct vio_dev *dev) · 132 unmodified lines
38453844 if (adapter->debugfs_dir && !IS_ERR(adapter->debugfs_dir))
38463845 debugfs_remove_recursive(adapter->debugfs_dir);
38473846
3847+ dma_unmap_single(&dev->dev, adapter->stats_token,
3848+ sizeof(struct ibmvnic_statistics), DMA_FROM_DEVICE);
3849+
38483850 if (adapter->ras_comps)
38493851 dma_free_coherent(&dev->dev,
38503852 adapter->ras_comp_num *
drivers/net/ethernet/marvell/mv643xx_eth.c+2−0
@@ -1381,6 +1381,7 @@ static unsigned int get_rx_coal(struct mv643xx_eth_private *mp) · 1380 unmodified lines
13811381 temp = (val & 0x003fff00) >> 8;
13821382
13831383 temp *= 64000000;
1384+ temp += mp->t_clk / 2;
13841385 do_div(temp, mp->t_clk);
13851386
13861387 return (unsigned int)temp;
@@ -1417,6 +1418,7 @@ static unsigned int get_tx_coal(struct mv643xx_eth_private *mp) · 30 unmodified lines
14171418
14181419 temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4;
14191420 temp *= 64000000;
1421+ temp += mp->t_clk / 2;
14201422 do_div(temp, mp->t_clk);
14211423
14221424 return (unsigned int)temp;
drivers/net/ethernet/mellanox/mlx4/en_netdev.c+0−1
@@ -2202,7 +2202,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 2201 unmodified lines
22022202
22032203 if (!shutdown)
22042204 free_netdev(dev);
2205− dev->ethtool_ops = NULL;
22062205 }
22072206
22082207 static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+16−15
@@ -1445,6 +1445,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, · 1444 unmodified lines
14451445 c->netdev = priv->netdev;
14461446 c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.mkey.key);
14471447 c->num_tc = priv->params.num_tc;
1448+ c->xdp = !!priv->xdp_prog;
14481449
14491450 if (priv->params.rx_am_enabled)
14501451 rx_cq_profile = mlx5e_am_get_def_profile(priv->params.rx_cq_period_mode);
@@ -1468,6 +1469,12 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, · 17 unmodified lines
14681469 if (err)
14691470 goto err_close_tx_cqs;
14701471
1472+ /* XDP SQ CQ params are same as normal TXQ sq CQ params */
1473+ err = c->xdp ? mlx5e_open_cq(c, &cparam->tx_cq, &c->xdp_sq.cq,
1474+ priv->params.tx_cq_moderation) : 0;
1475+ if (err)
1476+ goto err_close_rx_cq;
1477+
14711478 napi_enable(&c->napi);
14721479
14731480 err = mlx5e_open_sq(c, 0, &cparam->icosq, &c->icosq);
@@ -1488,21 +1495,10 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, · 14 unmodified lines
14881495 }
14891496 }
14901497
1491− if (priv->xdp_prog) {
1492− /* XDP SQ CQ params are same as normal TXQ sq CQ params */
1493− err = mlx5e_open_cq(c, &cparam->tx_cq, &c->xdp_sq.cq,
1494− priv->params.tx_cq_moderation);
1495− if (err)
1496− goto err_close_sqs;
1497−
1498− err = mlx5e_open_sq(c, 0, &cparam->xdp_sq, &c->xdp_sq);
1499− if (err) {
1500− mlx5e_close_cq(&c->xdp_sq.cq);
1501− goto err_close_sqs;
1502− }
1503− }
1498+ err = c->xdp ? mlx5e_open_sq(c, 0, &cparam->xdp_sq, &c->xdp_sq) : 0;
1499+ if (err)
1500+ goto err_close_sqs;
15041501
1505− c->xdp = !!priv->xdp_prog;
15061502 err = mlx5e_open_rq(c, &cparam->rq, &c->rq);
15071503 if (err)
15081504 goto err_close_xdp_sq;
@@ -1512,7 +1508,8 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, · 3 unmodified lines
15121508
15131509 return 0;
15141510 err_close_xdp_sq:
1515− mlx5e_close_sq(&c->xdp_sq);
1511+ if (c->xdp)
1512+ mlx5e_close_sq(&c->xdp_sq);
15161513
15171514 err_close_sqs:
15181515 mlx5e_close_sqs(c);
@@ -1522,6 +1519,10 @@ err_close_icosq: · 3 unmodified lines
15221519
15231520 err_disable_napi:
15241521 napi_disable(&c->napi);
1522+ if (c->xdp)
1523+ mlx5e_close_cq(&c->xdp_sq.cq);
1524+
1525+err_close_rx_cq:
15251526 mlx5e_close_cq(&c->rq.cq);
15261527
15271528 err_close_tx_cqs:
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+1−1
@@ -308,7 +308,7 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) · 307 unmodified lines
308308 netdev->switchdev_ops = &mlx5e_rep_switchdev_ops;
309309 #endif
310310
311− netdev->features |= NETIF_F_VLAN_CHALLENGED | NETIF_F_HW_TC;
311+ netdev->features |= NETIF_F_VLAN_CHALLENGED | NETIF_F_HW_TC | NETIF_F_NETNS_LOCAL;
312312 netdev->hw_features |= NETIF_F_HW_TC;
313313
314314 eth_hw_addr_random(netdev);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+4−1
@@ -237,12 +237,15 @@ static int parse_cls_flower(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec · 236 unmodified lines
237237 skb_flow_dissector_target(f->dissector,
238238 FLOW_DISSECTOR_KEY_VLAN,
239239 f->mask);
240− if (mask->vlan_id) {
240+ if (mask->vlan_id || mask->vlan_priority) {
241241 MLX5_SET(fte_match_set_lyr_2_4, headers_c, vlan_tag, 1);
242242 MLX5_SET(fte_match_set_lyr_2_4, headers_v, vlan_tag, 1);
243243
244244 MLX5_SET(fte_match_set_lyr_2_4, headers_c, first_vid, mask->vlan_id);
245245 MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, key->vlan_id);
246+
247+ MLX5_SET(fte_match_set_lyr_2_4, headers_c, first_prio, mask->vlan_priority);
248+ MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_prio, key->vlan_priority);
246249 }
247250 }
248251
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+2−1
@@ -57,7 +57,8 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, · 56 unmodified lines
5757 if (esw->mode != SRIOV_OFFLOADS)
5858 return ERR_PTR(-EOPNOTSUPP);
5959
60− action = attr->action;
60+ /* per flow vlan pop/push is emulated, don't set that into the firmware */
61+ action = attr->action & ~(MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH | MLX5_FLOW_CONTEXT_ACTION_VLAN_POP);
6162
6263 if (action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
6364 dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c+1−1
@@ -1690,7 +1690,7 @@ static int init_root_ns(struct mlx5_flow_steering *steering) · 1689 unmodified lines
16901690 {
16911691
16921692 steering->root_ns = create_root_ns(steering, FS_FT_NIC_RX);
1693− if (IS_ERR_OR_NULL(steering->root_ns))
1693+ if (!steering->root_ns)
16941694 goto cleanup;
16951695
16961696 if (init_root_tree(steering, &root_fs, &steering->root_ns->ns.node))
drivers/net/ethernet/mellanox/mlx5/core/main.c+3−2
@@ -1226,6 +1226,9 @@ static int init_one(struct pci_dev *pdev, · 1225 unmodified lines
12261226
12271227 pci_set_drvdata(pdev, dev);
12281228
1229+ dev->pdev = pdev;
1230+ dev->event = mlx5_core_event;
1231+
12291232 if (prof_sel < 0 || prof_sel >= ARRAY_SIZE(profile)) {
12301233 mlx5_core_warn(dev,
12311234 "selected profile out of range, selecting default (%d)\n",
@@ -1233,8 +1236,6 @@ static int init_one(struct pci_dev *pdev, · 1 unmodified line
12331236 prof_sel = MLX5_DEFAULT_PROF;
12341237 }
12351238 dev->profile = &profile[prof_sel];
1236− dev->pdev = pdev;
1237− dev->event = mlx5_core_event;
12381239
12391240 INIT_LIST_HEAD(&priv->ctx_list);
12401241 spin_lock_init(&priv->ctx_lock);
drivers/net/ethernet/mellanox/mlxsw/spectrum.c+3−1
@@ -231,7 +231,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port) · 230 unmodified lines
231231
232232 span_entry->used = true;
233233 span_entry->id = index;
234− span_entry->ref_count = 0;
234+ span_entry->ref_count = 1;
235235 span_entry->local_port = local_port;
236236 return span_entry;
237237 }
@@ -270,6 +270,7 @@ static struct mlxsw_sp_span_entry · 32 unmodified lines
270270
271271 span_entry = mlxsw_sp_span_entry_find(port);
272272 if (span_entry) {
273+ /* Already exists, just take a reference */
273274 span_entry->ref_count++;
274275 return span_entry;
275276 }
@@ -280,6 +281,7 @@ static struct mlxsw_sp_span_entry · 4 unmodified lines
280281 static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
281282 struct mlxsw_sp_span_entry *span_entry)
282283 {
284+ WARN_ON(!span_entry->ref_count);
283285 if (--span_entry->ref_count == 0)
284286 mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
285287 return 0;
drivers/net/ethernet/mellanox/mlxsw/spectrum.h+1−1
@@ -115,7 +115,7 @@ struct mlxsw_sp_rif { · 114 unmodified lines
115115 struct mlxsw_sp_mid {
116116 struct list_head list;
117117 unsigned char addr[ETH_ALEN];
118− u16 vid;
118+ u16 fid;
119119 u16 mid;
120120 unsigned int ref_count;
121121 };
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c+70−64
@@ -594,21 +594,22 @@ static int mlxsw_sp_vrs_init(struct mlxsw_sp *mlxsw_sp) · 593 unmodified lines
594594 return 0;
595595 }
596596
597+static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp);
598+
597599 static void mlxsw_sp_vrs_fini(struct mlxsw_sp *mlxsw_sp)
598600 {
601+ mlxsw_sp_router_fib_flush(mlxsw_sp);
599602 kfree(mlxsw_sp->router.vrs);
600603 }
601604
602605 struct mlxsw_sp_neigh_key {
603− unsigned char addr[sizeof(struct in6_addr)];
604− struct net_device *dev;
606+ struct neighbour *n;
605607 };
606608
607609 struct mlxsw_sp_neigh_entry {
608610 struct rhash_head ht_node;
609611 struct mlxsw_sp_neigh_key key;
610612 u16 rif;
611− struct neighbour *n;
612613 bool offloaded;
613614 struct delayed_work dw;
614615 struct mlxsw_sp_port *mlxsw_sp_port;
@@ -646,19 +647,15 @@ mlxsw_sp_neigh_entry_remove(struct mlxsw_sp *mlxsw_sp, · 31 unmodified lines
646647 static void mlxsw_sp_router_neigh_update_hw(struct work_struct *work);
647648
648649 static struct mlxsw_sp_neigh_entry *
649−mlxsw_sp_neigh_entry_create(const void *addr, size_t addr_len,
650− struct net_device *dev, u16 rif,
651− struct neighbour *n)
650+mlxsw_sp_neigh_entry_create(struct neighbour *n, u16 rif)
652651 {
653652 struct mlxsw_sp_neigh_entry *neigh_entry;
654653
655654 neigh_entry = kzalloc(sizeof(*neigh_entry), GFP_ATOMIC);
656655 if (!neigh_entry)
657656 return NULL;
658− memcpy(neigh_entry->key.addr, addr, addr_len);
659− neigh_entry->key.dev = dev;
657+ neigh_entry->key.n = n;
660658 neigh_entry->rif = rif;
661− neigh_entry->n = n;
662659 INIT_DELAYED_WORK(&neigh_entry->dw, mlxsw_sp_router_neigh_update_hw);
663660 INIT_LIST_HEAD(&neigh_entry->nexthop_list);
664661 return neigh_entry;
@@ -671,13 +668,11 @@ mlxsw_sp_neigh_entry_destroy(struct mlxsw_sp_neigh_entry *neigh_entry) · 6 unmodified lines
671668 }
672669
673670 static struct mlxsw_sp_neigh_entry *
674−mlxsw_sp_neigh_entry_lookup(struct mlxsw_sp *mlxsw_sp, const void *addr,
675− size_t addr_len, struct net_device *dev)
671+mlxsw_sp_neigh_entry_lookup(struct mlxsw_sp *mlxsw_sp, struct neighbour *n)
676672 {
677− struct mlxsw_sp_neigh_key key = {{ 0 } };
673+ struct mlxsw_sp_neigh_key key;
678674
679− memcpy(key.addr, addr, addr_len);
680− key.dev = dev;
675+ key.n = n;
681676 return rhashtable_lookup_fast(&mlxsw_sp->router.neigh_ht,
682677 &key, mlxsw_sp_neigh_ht_params);
683678 }
@@ -689,26 +684,20 @@ int mlxsw_sp_router_neigh_construct(struct net_device *dev, · 5 unmodified lines
689684 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
690685 struct mlxsw_sp_neigh_entry *neigh_entry;
691686 struct mlxsw_sp_rif *r;
692− u32 dip;
693687 int err;
694688
695689 if (n->tbl != &arp_tbl)
696690 return 0;
697691
698− dip = ntohl(*((__be32 *) n->primary_key));
699− neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, &dip, sizeof(dip),
700− n->dev);
701− if (neigh_entry) {
702− WARN_ON(neigh_entry->n != n);
692+ neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, n);
693+ if (neigh_entry)
703694 return 0;
704− }
705695
706696 r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, n->dev);
707697 if (WARN_ON(!r))
708698 return -EINVAL;
709699
710− neigh_entry = mlxsw_sp_neigh_entry_create(&dip, sizeof(dip), n->dev,
711− r->rif, n);
700+ neigh_entry = mlxsw_sp_neigh_entry_create(n, r->rif);
712701 if (!neigh_entry)
713702 return -ENOMEM;
714703 err = mlxsw_sp_neigh_entry_insert(mlxsw_sp, neigh_entry);
@@ -727,14 +716,11 @@ void mlxsw_sp_router_neigh_destroy(struct net_device *dev, · 12 unmodified lines
727716 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
728717 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
729718 struct mlxsw_sp_neigh_entry *neigh_entry;
730− u32 dip;
731719
732720 if (n->tbl != &arp_tbl)
733721 return;
734722
735− dip = ntohl(*((__be32 *) n->primary_key));
736− neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, &dip, sizeof(dip),
737− n->dev);
723+ neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, n);
738724 if (!neigh_entry)
739725 return;
740726 mlxsw_sp_neigh_entry_remove(mlxsw_sp, neigh_entry);
@@ -817,6 +803,26 @@ static void mlxsw_sp_router_neigh_rec_process(struct mlxsw_sp *mlxsw_sp, · 76 unmodified lines
817803 }
818804 }
819805
806+static bool mlxsw_sp_router_rauhtd_is_full(char *rauhtd_pl)
807+{
808+ u8 num_rec, last_rec_index, num_entries;
809+
810+ num_rec = mlxsw_reg_rauhtd_num_rec_get(rauhtd_pl);
811+ last_rec_index = num_rec - 1;
812+
813+ if (num_rec < MLXSW_REG_RAUHTD_REC_MAX_NUM)
814+ return false;
815+ if (mlxsw_reg_rauhtd_rec_type_get(rauhtd_pl, last_rec_index) ==
816+ MLXSW_REG_RAUHTD_TYPE_IPV6)
817+ return true;
818+
819+ num_entries = mlxsw_reg_rauhtd_ipv4_rec_num_entries_get(rauhtd_pl,
820+ last_rec_index);
821+ if (++num_entries == MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC)
822+ return true;
823+ return false;
824+}
825+
820826 static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
821827 {
822828 char *rauhtd_pl;
@@ -843,7 +849,7 @@ static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp) · 20 unmodified lines
843849 for (i = 0; i < num_rec; i++)
844850 mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl,
845851 i);
846− } while (num_rec);
852+ } while (mlxsw_sp_router_rauhtd_is_full(rauhtd_pl));
847853 rtnl_unlock();
848854
849855 kfree(rauhtd_pl);
@@ -862,7 +868,7 @@ static void mlxsw_sp_router_neighs_update_nh(struct mlxsw_sp *mlxsw_sp) · 12 unmodified lines
862868 * is active regardless of the traffic.
863869 */
864870 if (!list_empty(&neigh_entry->nexthop_list))
865− neigh_event_send(neigh_entry->n, NULL);
871+ neigh_event_send(neigh_entry->key.n, NULL);
866872 }
867873 rtnl_unlock();
868874 }
@@ -908,9 +914,9 @@ static void mlxsw_sp_router_probe_unresolved_nexthops(struct work_struct *work) · 39 unmodified lines
908914 rtnl_lock();
909915 list_for_each_entry(neigh_entry, &mlxsw_sp->router.nexthop_neighs_list,
910916 nexthop_neighs_list_node) {
911− if (!(neigh_entry->n->nud_state & NUD_VALID) &&
917+ if (!(neigh_entry->key.n->nud_state & NUD_VALID) &&
912918 !list_empty(&neigh_entry->nexthop_list))
913− neigh_event_send(neigh_entry->n, NULL);
919+ neigh_event_send(neigh_entry->key.n, NULL);
914920 }
915921 rtnl_unlock();
916922
@@ -927,7 +933,7 @@ static void mlxsw_sp_router_neigh_update_hw(struct work_struct *work) · 10 unmodified lines
927933 {
928934 struct mlxsw_sp_neigh_entry *neigh_entry =
929935 container_of(work, struct mlxsw_sp_neigh_entry, dw.work);
930− struct neighbour *n = neigh_entry->n;
936+ struct neighbour *n = neigh_entry->key.n;
931937 struct mlxsw_sp_port *mlxsw_sp_port = neigh_entry->mlxsw_sp_port;
932938 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
933939 char rauht_pl[MLXSW_REG_RAUHT_LEN];
@@ -1030,11 +1036,8 @@ int mlxsw_sp_router_netevent_event(struct notifier_block *unused, · 96 unmodified lines
10301036
10311037 mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
10321038 dip = ntohl(*((__be32 *) n->primary_key));
1033− neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp,
1034− &dip,
1035− sizeof(__be32),
1036− dev);
1037− if (WARN_ON(!neigh_entry) || WARN_ON(neigh_entry->n != n)) {
1039+ neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, n);
1040+ if (WARN_ON(!neigh_entry)) {
10381041 mlxsw_sp_port_dev_put(mlxsw_sp_port);
10391042 return NOTIFY_DONE;
10401043 }
@@ -1343,33 +1346,26 @@ static int mlxsw_sp_nexthop_init(struct mlxsw_sp *mlxsw_sp, · 302 unmodified lines
13431346 struct fib_nh *fib_nh)
13441347 {
13451348 struct mlxsw_sp_neigh_entry *neigh_entry;
1346− u32 gwip = ntohl(fib_nh->nh_gw);
13471349 struct net_device *dev = fib_nh->nh_dev;
13481350 struct neighbour *n;
13491351 u8 nud_state;
13501352
1351− neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, &gwip,
1352− sizeof(gwip), dev);
1353− if (!neigh_entry) {
1354− __be32 gwipn = htonl(gwip);
1355−
1356− n = neigh_create(&arp_tbl, &gwipn, dev);
1353+ /* Take a reference of neigh here ensuring that neigh would
1354+ * not be detructed before the nexthop entry is finished.
1355+ * The reference is taken either in neigh_lookup() or
1356+ * in neith_create() in case n is not found.
1357+ */
1358+ n = neigh_lookup(&arp_tbl, &fib_nh->nh_gw, dev);
1359+ if (!n) {
1360+ n = neigh_create(&arp_tbl, &fib_nh->nh_gw, dev);
13571361 if (IS_ERR(n))
13581362 return PTR_ERR(n);
13591363 neigh_event_send(n, NULL);
1360− neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, &gwip,
1361− sizeof(gwip), dev);
1362− if (!neigh_entry) {
1363− neigh_release(n);
1364− return -EINVAL;
1365− }
1366− } else {
1367− /* Take a reference of neigh here ensuring that neigh would
1368− * not be detructed before the nexthop entry is finished.
1369− * The second branch takes the reference in neith_create()
1370− */
1371− n = neigh_entry->n;
1372− neigh_clone(n);
1364+ }
1365+ neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, n);
1366+ if (!neigh_entry) {
1367+ neigh_release(n);
1368+ return -EINVAL;
13731369 }
13741370
13751371 /* If that is the first nexthop connected to that neigh, add to
@@ -1403,7 +1399,7 @@ static void mlxsw_sp_nexthop_fini(struct mlxsw_sp *mlxsw_sp, · 27 unmodified lines
14031399 if (list_empty(&nh->neigh_entry->nexthop_list))
14041400 list_del(&nh->neigh_entry->nexthop_neighs_list_node);
14051401
1406− neigh_release(neigh_entry->n);
1402+ neigh_release(neigh_entry->key.n);
14071403 }
14081404
14091405 static struct mlxsw_sp_nexthop_group *
@@ -1463,11 +1459,11 @@ static bool mlxsw_sp_nexthop_match(struct mlxsw_sp_nexthop *nh, · 53 unmodified lines
14631459
14641460 for (i = 0; i < fi->fib_nhs; i++) {
14651461 struct fib_nh *fib_nh = &fi->fib_nh[i];
1466− u32 gwip = ntohl(fib_nh->nh_gw);
1462+ struct neighbour *n = nh->neigh_entry->key.n;
14671463
1468− if (memcmp(nh->neigh_entry->key.addr,
1469− &gwip, sizeof(u32)) == 0 &&
1470− nh->neigh_entry->key.dev == fib_nh->nh_dev)
1464+ if (memcmp(n->primary_key, &fib_nh->nh_gw,
1465+ sizeof(fib_nh->nh_gw)) == 0 &&
1466+ n->dev == fib_nh->nh_dev)
14711467 return true;
14721468 }
14731469 return false;
@@ -1874,18 +1870,18 @@ static int mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp) · 400 unmodified lines
18741870 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl);
18751871 }
18761872
1877−static void mlxsw_sp_router_fib4_abort(struct mlxsw_sp *mlxsw_sp)
1873+static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp)
18781874 {
18791875 struct mlxsw_resources *resources;
18801876 struct mlxsw_sp_fib_entry *fib_entry;
18811877 struct mlxsw_sp_fib_entry *tmp;
18821878 struct mlxsw_sp_vr *vr;
18831879 int i;
1884− int err;
18851880
18861881 resources = mlxsw_core_resources_get(mlxsw_sp->core);
18871882 for (i = 0; i < resources->max_virtual_routers; i++) {
18881883 vr = &mlxsw_sp->router.vrs[i];
1884+
18891885 if (!vr->used)
18901886 continue;
18911887
@@ -1901,6 +1897,13 @@ static void mlxsw_sp_router_fib4_abort(struct mlxsw_sp *mlxsw_sp) · 9 unmodified lines
19011897 break;
19021898 }
19031899 }
1900+}
1901+
1902+static void mlxsw_sp_router_fib4_abort(struct mlxsw_sp *mlxsw_sp)
1903+{
1904+ int err;
1905+
1906+ mlxsw_sp_router_fib_flush(mlxsw_sp);
19041907 mlxsw_sp->router.aborted = true;
19051908 err = mlxsw_sp_router_set_abort_trap(mlxsw_sp);
19061909 if (err)
@@ -1958,6 +1961,9 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb, · 51 unmodified lines
19581961 struct fib_entry_notifier_info *fen_info = ptr;
19591962 int err;
19601963
1964+ if (!net_eq(fen_info->info.net, &init_net))
1965+ return NOTIFY_DONE;
1966+
19611967 switch (event) {
19621968 case FIB_EVENT_ENTRY_ADD:
19631969 err = mlxsw_sp_router_fib4_add(mlxsw_sp, fen_info);
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c+7−7
@@ -929,12 +929,12 @@ static int mlxsw_sp_port_smid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mid, · 928 unmodified lines
929929
930930 static struct mlxsw_sp_mid *__mlxsw_sp_mc_get(struct mlxsw_sp *mlxsw_sp,
931931 const unsigned char *addr,
932− u16 vid)
932+ u16 fid)
933933 {
934934 struct mlxsw_sp_mid *mid;
935935
936936 list_for_each_entry(mid, &mlxsw_sp->br_mids.list, list) {
937− if (ether_addr_equal(mid->addr, addr) && mid->vid == vid)
937+ if (ether_addr_equal(mid->addr, addr) && mid->fid == fid)
938938 return mid;
939939 }
940940 return NULL;
@@ -942,7 +942,7 @@ static struct mlxsw_sp_mid *__mlxsw_sp_mc_get(struct mlxsw_sp *mlxsw_sp, · 1 unmodified line
942942
943943 static struct mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp,
944944 const unsigned char *addr,
945− u16 vid)
945+ u16 fid)
946946 {
947947 struct mlxsw_sp_mid *mid;
948948 u16 mid_idx;
@@ -958,7 +958,7 @@ static struct mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp, · 9 unmodified lines
958958
959959 set_bit(mid_idx, mlxsw_sp->br_mids.mapped);
960960 ether_addr_copy(mid->addr, addr);
961− mid->vid = vid;
961+ mid->fid = fid;
962962 mid->mid = mid_idx;
963963 mid->ref_count = 0;
964964 list_add_tail(&mid->list, &mlxsw_sp->br_mids.list);
@@ -991,9 +991,9 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port, · 26 unmodified lines
991991 if (switchdev_trans_ph_prepare(trans))
992992 return 0;
993993
994− mid = __mlxsw_sp_mc_get(mlxsw_sp, mdb->addr, mdb->vid);
994+ mid = __mlxsw_sp_mc_get(mlxsw_sp, mdb->addr, fid);
995995 if (!mid) {
996− mid = __mlxsw_sp_mc_alloc(mlxsw_sp, mdb->addr, mdb->vid);
996+ mid = __mlxsw_sp_mc_alloc(mlxsw_sp, mdb->addr, fid);
997997 if (!mid) {
998998 netdev_err(dev, "Unable to allocate MC group\n");
999999 return -ENOMEM;
@@ -1137,7 +1137,7 @@ static int mlxsw_sp_port_mdb_del(struct mlxsw_sp_port *mlxsw_sp_port, · 137 unmodified lines
11371137 u16 mid_idx;
11381138 int err = 0;
11391139
1140− mid = __mlxsw_sp_mc_get(mlxsw_sp, mdb->addr, mdb->vid);
1140+ mid = __mlxsw_sp_mc_get(mlxsw_sp, mdb->addr, fid);
11411141 if (!mid) {
11421142 netdev_err(dev, "Unable to remove port from MC DB\n");
11431143 return -EINVAL;
drivers/net/ethernet/qlogic/qed/qed_hsi.h+0−3
@@ -727,9 +727,6 @@ struct core_tx_bd_flags { · 726 unmodified lines
727727 #define CORE_TX_BD_FLAGS_L4_PROTOCOL_SHIFT 6
728728 #define CORE_TX_BD_FLAGS_L4_PSEUDO_CSUM_MODE_MASK 0x1
729729 #define CORE_TX_BD_FLAGS_L4_PSEUDO_CSUM_MODE_SHIFT 7
730−#define CORE_TX_BD_FLAGS_ROCE_FLAV_MASK 0x1
731−#define CORE_TX_BD_FLAGS_ROCE_FLAV_SHIFT 12
732−
733730 };
734731
735732 struct core_tx_bd {
drivers/net/ethernet/qlogic/qed/qed_ll2.c+1−0
@@ -1119,6 +1119,7 @@ static void qed_ll2_prepare_tx_packet_set_bd(struct qed_hwfn *p_hwfn, · 1118 unmodified lines
11191119 start_bd->bd_flags.as_bitfield |= CORE_TX_BD_FLAGS_START_BD_MASK <<
11201120 CORE_TX_BD_FLAGS_START_BD_SHIFT;
11211121 SET_FIELD(start_bd->bitfield0, CORE_TX_BD_NBDS, num_of_bds);
1122+ SET_FIELD(start_bd->bitfield0, CORE_TX_BD_ROCE_FLAV, type);
11221123 DMA_REGPAIR_LE(start_bd->addr, first_frag);
11231124 start_bd->nbytes = cpu_to_le16(first_frag_len);
11241125
drivers/net/ethernet/qlogic/qed/qed_main.c+8−9
@@ -839,20 +839,19 @@ static void qed_update_pf_params(struct qed_dev *cdev, · 838 unmodified lines
839839 {
840840 int i;
841841
842+ if (IS_ENABLED(CONFIG_QED_RDMA)) {
843+ params->rdma_pf_params.num_qps = QED_ROCE_QPS;
844+ params->rdma_pf_params.min_dpis = QED_ROCE_DPIS;
845+ /* divide by 3 the MRs to avoid MF ILT overflow */
846+ params->rdma_pf_params.num_mrs = RDMA_MAX_TIDS;
847+ params->rdma_pf_params.gl_pi = QED_ROCE_PROTOCOL_INDEX;
848+ }
849+
842850 for (i = 0; i < cdev->num_hwfns; i++) {
843851 struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
844852
845853 p_hwfn->pf_params = *params;
846854 }
847−
848− if (!IS_ENABLED(CONFIG_QED_RDMA))
849− return;
850−
851− params->rdma_pf_params.num_qps = QED_ROCE_QPS;
852− params->rdma_pf_params.min_dpis = QED_ROCE_DPIS;
853− /* divide by 3 the MRs to avoid MF ILT overflow */
854− params->rdma_pf_params.num_mrs = RDMA_MAX_TIDS;
855− params->rdma_pf_params.gl_pi = QED_ROCE_PROTOCOL_INDEX;
856855 }
857856
858857 static int qed_slowpath_start(struct qed_dev *cdev,
drivers/net/ethernet/qlogic/qede/qede_ethtool.c+16−9
@@ -175,16 +175,23 @@ static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf) · 174 unmodified lines
175175 for (i = 0, k = 0; i < QEDE_QUEUE_CNT(edev); i++) {
176176 int tc;
177177
178− for (j = 0; j < QEDE_NUM_RQSTATS; j++)
179− sprintf(buf + (k + j) * ETH_GSTRING_LEN,
180− "%d: %s", i, qede_rqstats_arr[j].string);
181− k += QEDE_NUM_RQSTATS;
182− for (tc = 0; tc < edev->num_tc; tc++) {
183− for (j = 0; j < QEDE_NUM_TQSTATS; j++)
178+ if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
179+ for (j = 0; j < QEDE_NUM_RQSTATS; j++)
184180 sprintf(buf + (k + j) * ETH_GSTRING_LEN,
185− "%d.%d: %s", i, tc,
186− qede_tqstats_arr[j].string);
187− k += QEDE_NUM_TQSTATS;
181+ "%d: %s", i,
182+ qede_rqstats_arr[j].string);
183+ k += QEDE_NUM_RQSTATS;
184+ }
185+
186+ if (edev->fp_array[i].type & QEDE_FASTPATH_TX) {
187+ for (tc = 0; tc < edev->num_tc; tc++) {
188+ for (j = 0; j < QEDE_NUM_TQSTATS; j++)
189+ sprintf(buf + (k + j) *
190+ ETH_GSTRING_LEN,
191+ "%d.%d: %s", i, tc,
192+ qede_tqstats_arr[j].string);
193+ k += QEDE_NUM_TQSTATS;
194+ }
188195 }
189196 }
190197
drivers/net/ethernet/qlogic/qede/qede_main.c+1−1
@@ -2839,7 +2839,7 @@ static int qede_alloc_sge_mem(struct qede_dev *edev, struct qede_rx_queue *rxq) · 2838 unmodified lines
28392839 }
28402840
28412841 mapping = dma_map_page(&edev->pdev->dev, replace_buf->data, 0,
2842− rxq->rx_buf_size, DMA_FROM_DEVICE);
2842+ PAGE_SIZE, DMA_FROM_DEVICE);
28432843 if (unlikely(dma_mapping_error(&edev->pdev->dev, mapping))) {
28442844 DP_NOTICE(edev,
28452845 "Failed to map TPA replacement buffer\n");
drivers/net/ethernet/qualcomm/emac/emac-mac.c+11−4
@@ -575,10 +575,11 @@ void emac_mac_start(struct emac_adapter *adpt) · 574 unmodified lines
575575
576576 mac |= TXEN | RXEN; /* enable RX/TX */
577577
578− /* We don't have ethtool support yet, so force flow-control mode
579− * to 'full' always.
580− */
581− mac |= TXFC | RXFC;
578+ /* Configure MAC flow control to match the PHY's settings. */
579+ if (phydev->pause)
580+ mac |= RXFC;
581+ if (phydev->pause != phydev->asym_pause)
582+ mac |= TXFC;
582583
583584 /* setup link speed */
584585 mac &= ~SPEED_MASK;
@@ -1003,6 +1004,12 @@ int emac_mac_up(struct emac_adapter *adpt) · 418 unmodified lines
10031004 writel((u32)~DIS_INT, adpt->base + EMAC_INT_STATUS);
10041005 writel(adpt->irq.mask, adpt->base + EMAC_INT_MASK);
10051006
1007+ /* Enable pause frames. Without this feature, the EMAC has been shown
1008+ * to receive (and drop) frames with FCS errors at gigabit connections.
1009+ */
1010+ adpt->phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
1011+ adpt->phydev->advertising |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
1012+
10061013 adpt->phydev->irq = PHY_IGNORE_INTERRUPT;
10071014 phy_start(adpt->phydev);
10081015
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c+1−1
@@ -421,7 +421,7 @@ static const struct emac_reg_write sgmii_v2_laned[] = { · 420 unmodified lines
421421 /* CDR Settings */
422422 {EMAC_SGMII_LN_UCDR_FO_GAIN_MODE0,
423423 UCDR_STEP_BY_TWO_MODE0 | UCDR_xO_GAIN_MODE(10)},
424− {EMAC_SGMII_LN_UCDR_SO_GAIN_MODE0, UCDR_xO_GAIN_MODE(6)},
424+ {EMAC_SGMII_LN_UCDR_SO_GAIN_MODE0, UCDR_xO_GAIN_MODE(0)},
425425 {EMAC_SGMII_LN_UCDR_SO_CONFIG, UCDR_ENABLE | UCDR_SO_SATURATION(12)},
426426
427427 /* TX/RX Settings */
drivers/net/ethernet/sfc/efx.c+3−0
@@ -485,6 +485,9 @@ efx_copy_channel(const struct efx_channel *old_channel) · 484 unmodified lines
485485 *channel = *old_channel;
486486
487487 channel->napi_dev = NULL;
488+ INIT_HLIST_NODE(&channel->napi_str.napi_hash_node);
489+ channel->napi_str.napi_id = 0;
490+ channel->napi_str.state = 0;
488491 memset(&channel->eventq, 0, sizeof(channel->eventq));
489492
490493 for (j = 0; j < EFX_TXQ_TYPES; j++) {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+7−0
@@ -880,6 +880,13 @@ static int stmmac_init_phy(struct net_device *dev) · 879 unmodified lines
880880 return -ENODEV;
881881 }
882882
883+ /* stmmac_adjust_link will change this to PHY_IGNORE_INTERRUPT to avoid
884+ * subsequent PHY polling, make sure we force a link transition if
885+ * we have a UP/DOWN/UP transition
886+ */
887+ if (phydev->is_pseudo_fixed_link)
888+ phydev->irq = PHY_POLL;
889+
883890 pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)"
884891 " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
885892
drivers/net/ethernet/ti/cpsw-phy-sel.c+3−0
@@ -176,9 +176,12 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave) · 175 unmodified lines
176176 }
177177
178178 dev = bus_find_device(&platform_bus_type, NULL, node, match);
179+ of_node_put(node);
179180 priv = dev_get_drvdata(dev);
180181
181182 priv->cpsw_phy_sel(priv, phy_mode, slave);
183+
184+ put_device(dev);
182185 }
183186 EXPORT_SYMBOL_GPL(cpsw_phy_sel);
184187
drivers/net/ethernet/ti/davinci_emac.c+6−4
@@ -1410,6 +1410,7 @@ static int emac_dev_open(struct net_device *ndev) · 1409 unmodified lines
14101410 int i = 0;
14111411 struct emac_priv *priv = netdev_priv(ndev);
14121412 struct phy_device *phydev = NULL;
1413+ struct device *phy = NULL;
14131414
14141415 ret = pm_runtime_get_sync(&priv->pdev->dev);
14151416 if (ret < 0) {
@@ -1488,19 +1489,20 @@ static int emac_dev_open(struct net_device *ndev) · 72 unmodified lines
14881489
14891490 /* use the first phy on the bus if pdata did not give us a phy id */
14901491 if (!phydev && !priv->phy_id) {
1491− struct device *phy;
1492−
14931492 phy = bus_find_device(&mdio_bus_type, NULL, NULL,
14941493 match_first_device);
1495− if (phy)
1494+ if (phy) {
14961495 priv->phy_id = dev_name(phy);
1496+ if (!priv->phy_id || !*priv->phy_id)
1497+ put_device(phy);
1498+ }
14971499 }
14981500
14991501 if (!phydev && priv->phy_id && *priv->phy_id) {
15001502 phydev = phy_connect(ndev, priv->phy_id,
15011503 &emac_adjust_link,
15021504 PHY_INTERFACE_MODE_MII);
1503−
1505+ put_device(phy); /* reference taken by bus_find_device */
15041506 if (IS_ERR(phydev)) {
15051507 dev_err(emac_dev, "could not connect to phy %s\n",
15061508 priv->phy_id);
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c+1−1
@@ -1694,7 +1694,7 @@ struct gelic_wl_scan_info *gelic_wl_find_best_bss(struct gelic_wl_info *wl) · 1693 unmodified lines
16941694 pr_debug("%s: bssid matched\n", __func__);
16951695 break;
16961696 } else {
1697− pr_debug("%s: bssid unmached\n", __func__);
1697+ pr_debug("%s: bssid unmatched\n", __func__);
16981698 continue;
16991699 }
17001700 }
drivers/net/ethernet/xscale/ixp4xx_eth.c+1−2
@@ -708,8 +708,7 @@ static int eth_poll(struct napi_struct *napi, int budget) · 707 unmodified lines
708708 if (!qmgr_stat_below_low_watermark(rxq) &&
709709 napi_reschedule(napi)) { /* not empty again */
710710 #if DEBUG_RX
711− printk(KERN_DEBUG "%s: eth_poll"
712− " napi_reschedule successed\n",
711+ printk(KERN_DEBUG "%s: eth_poll napi_reschedule succeeded\n",
713712 dev->name);
714713 #endif
715714 qmgr_disable_irq(rxq);
drivers/net/macvlan.c+22−9
@@ -1278,6 +1278,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, · 1277 unmodified lines
12781278 struct net_device *lowerdev;
12791279 int err;
12801280 int macmode;
1281+ bool create = false;
12811282
12821283 if (!tb[IFLA_LINK])
12831284 return -EINVAL;
@@ -1304,12 +1305,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, · 20 unmodified lines
13041305 err = macvlan_port_create(lowerdev);
13051306 if (err < 0)
13061307 return err;
1308+ create = true;
13071309 }
13081310 port = macvlan_port_get_rtnl(lowerdev);
13091311
13101312 /* Only 1 macvlan device can be created in passthru mode */
1311− if (port->passthru)
1312− return -EINVAL;
1313+ if (port->passthru) {
1314+ /* The macvlan port must be not created this time,
1315+ * still goto destroy_macvlan_port for readability.
1316+ */
1317+ err = -EINVAL;
1318+ goto destroy_macvlan_port;
1319+ }
13131320
13141321 vlan->lowerdev = lowerdev;
13151322 vlan->dev = dev;
@@ -1325,24 +1332,28 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, · 9 unmodified lines
13251332 vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
13261333
13271334 if (vlan->mode == MACVLAN_MODE_PASSTHRU) {
1328− if (port->count)
1329− return -EINVAL;
1335+ if (port->count) {
1336+ err = -EINVAL;
1337+ goto destroy_macvlan_port;
1338+ }
13301339 port->passthru = true;
13311340 eth_hw_addr_inherit(dev, lowerdev);
13321341 }
13331342
13341343 if (data && data[IFLA_MACVLAN_MACADDR_MODE]) {
1335− if (vlan->mode != MACVLAN_MODE_SOURCE)
1336− return -EINVAL;
1344+ if (vlan->mode != MACVLAN_MODE_SOURCE) {
1345+ err = -EINVAL;
1346+ goto destroy_macvlan_port;
1347+ }
13371348 macmode = nla_get_u32(data[IFLA_MACVLAN_MACADDR_MODE]);
13381349 err = macvlan_changelink_sources(vlan, macmode, data);
13391350 if (err)
1340− return err;
1351+ goto destroy_macvlan_port;
13411352 }
13421353
13431354 err = register_netdevice(dev);
13441355 if (err < 0)
1345− return err;
1356+ goto destroy_macvlan_port;
13461357
13471358 dev->priv_flags |= IFF_MACVLAN;
13481359 err = netdev_upper_dev_link(lowerdev, dev);
@@ -1357,7 +1368,9 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, · 8 unmodified lines
13571368
13581369 unregister_netdev:
13591370 unregister_netdevice(dev);
1360−
1371+destroy_macvlan_port:
1372+ if (create)
1373+ macvlan_port_destroy(port->dev);
13611374 return err;
13621375 }
13631376 EXPORT_SYMBOL_GPL(macvlan_common_newlink);
drivers/net/phy/phy_device.c+2−0
@@ -723,6 +723,7 @@ struct phy_device *phy_connect(struct net_device *dev, const char *bus_id, · 722 unmodified lines
723723 phydev = to_phy_device(d);
724724
725725 rc = phy_connect_direct(dev, phydev, handler, interface);
726+ put_device(d);
726727 if (rc)
727728 return ERR_PTR(rc);
728729
@@ -953,6 +954,7 @@ struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, · 224 unmodified lines
953954 phydev = to_phy_device(d);
954955
955956 rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface);
957+ put_device(d);
956958 if (rc)
957959 return ERR_PTR(rc);
958960
drivers/net/usb/ax88179_178a.c+17−0
@@ -1656,6 +1656,19 @@ static const struct driver_info ax88178a_info = { · 1655 unmodified lines
16561656 .tx_fixup = ax88179_tx_fixup,
16571657 };
16581658
1659+static const struct driver_info cypress_GX3_info = {
1660+ .description = "Cypress GX3 SuperSpeed to Gigabit Ethernet Controller",
1661+ .bind = ax88179_bind,
1662+ .unbind = ax88179_unbind,
1663+ .status = ax88179_status,
1664+ .link_reset = ax88179_link_reset,
1665+ .reset = ax88179_reset,
1666+ .stop = ax88179_stop,
1667+ .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1668+ .rx_fixup = ax88179_rx_fixup,
1669+ .tx_fixup = ax88179_tx_fixup,
1670+};
1671+
16591672 static const struct driver_info dlink_dub1312_info = {
16601673 .description = "D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter",
16611674 .bind = ax88179_bind,
@@ -1717,6 +1730,10 @@ static const struct usb_device_id products[] = { · 55 unmodified lines
17171730 /* ASIX AX88178A 10/100/1000 */
17181731 USB_DEVICE(0x0b95, 0x178a),
17191732 .driver_info = (unsigned long)&ax88178a_info,
1733+}, {
1734+ /* Cypress GX3 SuperSpeed to Gigabit Ethernet Bridge Controller */
1735+ USB_DEVICE(0x04b4, 0x3610),
1736+ .driver_info = (unsigned long)&cypress_GX3_info,
17201737 }, {
17211738 /* D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter */
17221739 USB_DEVICE(0x2001, 0x4a00),
drivers/net/usb/r8152.c+12−9
@@ -1730,7 +1730,7 @@ static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc) · 1729 unmodified lines
17301730 u8 checksum = CHECKSUM_NONE;
17311731 u32 opts2, opts3;
17321732
1733− if (tp->version == RTL_VER_01)
1733+ if (tp->version == RTL_VER_01 || tp->version == RTL_VER_02)
17341734 goto return_result;
17351735
17361736 opts2 = le32_to_cpu(rx_desc->opts2);
@@ -1745,7 +1745,7 @@ static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc) · 8 unmodified lines
17451745 checksum = CHECKSUM_NONE;
17461746 else
17471747 checksum = CHECKSUM_UNNECESSARY;
1748− } else if (RD_IPV6_CS) {
1748+ } else if (opts2 & RD_IPV6_CS) {
17491749 if ((opts2 & RD_UDP_CS) && !(opts3 & UDPF))
17501750 checksum = CHECKSUM_UNNECESSARY;
17511751 else if ((opts2 & RD_TCP_CS) && !(opts3 & TCPF))
@@ -3266,10 +3266,8 @@ static int rtl8152_open(struct net_device *netdev) · 1514 unmodified lines
32663266 goto out;
32673267
32683268 res = usb_autopm_get_interface(tp->intf);
3269− if (res < 0) {
3270− free_all_mem(tp);
3271− goto out;
3272− }
3269+ if (res < 0)
3270+ goto out_free;
32733271
32743272 mutex_lock(&tp->control);
32753273
@@ -3285,10 +3283,9 @@ static int rtl8152_open(struct net_device *netdev) · 9 unmodified lines
32853283 netif_device_detach(tp->netdev);
32863284 netif_warn(tp, ifup, netdev, "intr_urb submit failed: %d\n",
32873285 res);
3288− free_all_mem(tp);
3289− } else {
3290− napi_enable(&tp->napi);
3286+ goto out_unlock;
32913287 }
3288+ napi_enable(&tp->napi);
32923289
32933290 mutex_unlock(&tp->control);
32943291
@@ -3297,7 +3294,13 @@ static int rtl8152_open(struct net_device *netdev) · 2 unmodified lines
32973294 tp->pm_notifier.notifier_call = rtl_notifier;
32983295 register_pm_notifier(&tp->pm_notifier);
32993296 #endif
3297+ return 0;
33003298
3299+out_unlock:
3300+ mutex_unlock(&tp->control);
3301+ usb_autopm_put_interface(tp->intf);
3302+out_free:
3303+ free_all_mem(tp);
33013304 out:
33023305 return res;
33033306 }
drivers/net/virtio_net.c+20−10
@@ -2038,23 +2038,33 @@ static struct virtio_device_id id_table[] = { · 2037 unmodified lines
20382038 { 0 },
20392039 };
20402040
2041+#define VIRTNET_FEATURES \
2042+ VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, \
2043+ VIRTIO_NET_F_MAC, \
2044+ VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, \
2045+ VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, \
2046+ VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, \
2047+ VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, \
2048+ VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, \
2049+ VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, \
2050+ VIRTIO_NET_F_CTRL_MAC_ADDR, \
2051+ VIRTIO_NET_F_MTU
2052+
20412053 static unsigned int features[] = {
2042− VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
2043− VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
2044− VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
2045− VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
2046− VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
2047− VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
2048− VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
2049− VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
2050− VIRTIO_NET_F_CTRL_MAC_ADDR,
2054+ VIRTNET_FEATURES,
2055+};
2056+
2057+static unsigned int features_legacy[] = {
2058+ VIRTNET_FEATURES,
2059+ VIRTIO_NET_F_GSO,
20512060 VIRTIO_F_ANY_LAYOUT,
2052− VIRTIO_NET_F_MTU,
20532061 };
20542062
20552063 static struct virtio_driver virtio_net_driver = {
20562064 .feature_table = features,
20572065 .feature_table_size = ARRAY_SIZE(features),
2066+ .feature_table_legacy = features_legacy,
2067+ .feature_table_size_legacy = ARRAY_SIZE(features_legacy),
20582068 .driver.name = KBUILD_MODNAME,
20592069 .driver.owner = THIS_MODULE,
20602070 .id_table = id_table,
drivers/net/vxlan.c+3−1
@@ -944,7 +944,9 @@ static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev) · 943 unmodified lines
944944 {
945945 struct vxlan_dev *vxlan;
946946 struct vxlan_sock *sock4;
947− struct vxlan_sock *sock6 = NULL;
947+#if IS_ENABLED(CONFIG_IPV6)
948+ struct vxlan_sock *sock6;
949+#endif
948950 unsigned short family = dev->default_dst.remote_ip.sa.sa_family;
949951
950952 sock4 = rtnl_dereference(dev->vn4_sock);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c+1−1
@@ -4516,7 +4516,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev, · 4515 unmodified lines
45164516 /* store current 11d setting */
45174517 if (brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY,
45184518 &ifp->vif->is_11d)) {
4519− supports_11d = false;
4519+ is_11d = supports_11d = false;
45204520 } else {
45214521 country_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,
45224522 settings->beacon.tail_len,
drivers/net/wireless/intel/iwlwifi/mvm/d3.c+38−11
@@ -1087,6 +1087,15 @@ iwl_mvm_netdetect_config(struct iwl_mvm *mvm, · 1086 unmodified lines
10871087 ret = iwl_mvm_switch_to_d3(mvm);
10881088 if (ret)
10891089 return ret;
1090+ } else {
1091+ /* In theory, we wouldn't have to stop a running sched
1092+ * scan in order to start another one (for
1093+ * net-detect). But in practice this doesn't seem to
1094+ * work properly, so stop any running sched_scan now.
1095+ */
1096+ ret = iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true);
1097+ if (ret)
1098+ return ret;
10901099 }
10911100
10921101 /* rfkill release can be either for wowlan or netdetect */
@@ -1254,7 +1263,10 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw, · 161 unmodified lines
12541263 out:
12551264 if (ret < 0) {
12561265 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
1257− ieee80211_restart_hw(mvm->hw);
1266+ if (mvm->restart_fw > 0) {
1267+ mvm->restart_fw--;
1268+ ieee80211_restart_hw(mvm->hw);
1269+ }
12581270 iwl_mvm_free_nd(mvm);
12591271 }
12601272 out_noreset:
@@ -2088,6 +2100,16 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) · 827 unmodified lines
20882100 iwl_mvm_update_changed_regdom(mvm);
20892101
20902102 if (mvm->net_detect) {
2103+ /* If this is a non-unified image, we restart the FW,
2104+ * so no need to stop the netdetect scan. If that
2105+ * fails, continue and try to get the wake-up reasons,
2106+ * but trigger a HW restart by keeping a failure code
2107+ * in ret.
2108+ */
2109+ if (unified_image)
2110+ ret = iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_NETDETECT,
2111+ false);
2112+
20912113 iwl_mvm_query_netdetect_reasons(mvm, vif);
20922114 /* has unlocked the mutex, so skip that */
20932115 goto out;
@@ -2271,7 +2293,8 @@ static void iwl_mvm_d3_test_disconn_work_iter(void *_data, u8 *mac, · 177 unmodified lines
22712293 static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
22722294 {
22732295 struct iwl_mvm *mvm = inode->i_private;
2274− int remaining_time = 10;
2296+ bool unified_image = fw_has_capa(&mvm->fw->ucode_capa,
2297+ IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
22752298
22762299 mvm->d3_test_active = false;
22772300
@@ -2282,17 +2305,21 @@ static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file) · 4 unmodified lines
22822305 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED;
22832306
22842307 iwl_abort_notification_waits(&mvm->notif_wait);
2285− ieee80211_restart_hw(mvm->hw);
2308+ if (!unified_image) {
2309+ int remaining_time = 10;
22862310
2287− /* wait for restart and disconnect all interfaces */
2288− while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
2289− remaining_time > 0) {
2290− remaining_time--;
2291− msleep(1000);
2292− }
2311+ ieee80211_restart_hw(mvm->hw);
2312+
2313+ /* wait for restart and disconnect all interfaces */
2314+ while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
2315+ remaining_time > 0) {
2316+ remaining_time--;
2317+ msleep(1000);
2318+ }
22932319
2294− if (remaining_time == 0)
2295− IWL_ERR(mvm, "Timed out waiting for HW restart to finish!\n");
2320+ if (remaining_time == 0)
2321+ IWL_ERR(mvm, "Timed out waiting for HW restart!\n");
2322+ }
22962323
22972324 ieee80211_iterate_active_interfaces_atomic(
22982325 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c+2−2
@@ -1529,8 +1529,8 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf, · 1528 unmodified lines
15291529 .data = { &cmd, },
15301530 .len = { sizeof(cmd) },
15311531 };
1532− size_t delta, len;
1533− ssize_t ret;
1532+ size_t delta;
1533+ ssize_t ret, len;
15341534
15351535 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
15361536 DEBUG_GROUP, 0);
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c+1−2
@@ -4121,7 +4121,6 @@ void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, · 4120 unmodified lines
41214121 struct iwl_mvm_internal_rxq_notif *notif,
41224122 u32 size)
41234123 {
4124− DECLARE_WAIT_QUEUE_HEAD_ONSTACK(notif_waitq);
41254124 u32 qmask = BIT(mvm->trans->num_rx_queues) - 1;
41264125 int ret;
41274126
@@ -4143,7 +4142,7 @@ void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, · 15 unmodified lines
41434142 }
41444143
41454144 if (notif->sync)
4146− ret = wait_event_timeout(notif_waitq,
4145+ ret = wait_event_timeout(mvm->rx_sync_waitq,
41474146 atomic_read(&mvm->queue_sync_counter) == 0,
41484147 HZ);
41494148 WARN_ON_ONCE(!ret);
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h+1−0
@@ -937,6 +937,7 @@ struct iwl_mvm { · 936 unmodified lines
937937 /* sync d0i3_tx queue and IWL_MVM_STATUS_IN_D0I3 status flag */
938938 spinlock_t d0i3_tx_lock;
939939 wait_queue_head_t d0i3_exit_waitq;
940+ wait_queue_head_t rx_sync_waitq;
940941
941942 /* BT-Coex */
942943 struct iwl_bt_coex_profile_notif last_bt_notif;
drivers/net/wireless/intel/iwlwifi/mvm/ops.c+1−0
@@ -619,6 +619,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, · 618 unmodified lines
619619 spin_lock_init(&mvm->refs_lock);
620620 skb_queue_head_init(&mvm->d0i3_tx);
621621 init_waitqueue_head(&mvm->d0i3_exit_waitq);
622+ init_waitqueue_head(&mvm->rx_sync_waitq);
622623
623624 atomic_set(&mvm->queue_sync_counter, 0);
624625
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c+2−1
@@ -547,7 +547,8 @@ void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, · 546 unmodified lines
547547 "Received expired RX queue sync message\n");
548548 return;
549549 }
550− atomic_dec(&mvm->queue_sync_counter);
550+ if (!atomic_dec_return(&mvm->queue_sync_counter))
551+ wake_up(&mvm->rx_sync_waitq);
551552 }
552553
553554 switch (internal_notif->type) {
drivers/net/wireless/intel/iwlwifi/mvm/scan.c+27−6
@@ -1199,6 +1199,9 @@ static int iwl_mvm_num_scans(struct iwl_mvm *mvm) · 1198 unmodified lines
11991199
12001200 static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
12011201 {
1202+ bool unified_image = fw_has_capa(&mvm->fw->ucode_capa,
1203+ IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
1204+
12021205 /* This looks a bit arbitrary, but the idea is that if we run
12031206 * out of possible simultaneous scans and the userspace is
12041207 * trying to run a scan type that is already running, we
@@ -1225,12 +1228,30 @@ static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type) · 20 unmodified lines
12251228 return -EBUSY;
12261229 return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true);
12271230 case IWL_MVM_SCAN_NETDETECT:
1228− /* No need to stop anything for net-detect since the
1229− * firmware is restarted anyway. This way, any sched
1230− * scans that were running will be restarted when we
1231− * resume.
1232− */
1233− return 0;
1231+ /* For non-unified images, there's no need to stop
1232+ * anything for net-detect since the firmware is
1233+ * restarted anyway. This way, any sched scans that
1234+ * were running will be restarted when we resume.
1235+ */
1236+ if (!unified_image)
1237+ return 0;
1238+
1239+ /* If this is a unified image and we ran out of scans,
1240+ * we need to stop something. Prefer stopping regular
1241+ * scans, because the results are useless at this
1242+ * point, and we should be able to keep running
1243+ * another scheduled scan while suspended.
1244+ */
1245+ if (mvm->scan_status & IWL_MVM_SCAN_REGULAR_MASK)
1246+ return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR,
1247+ true);
1248+ if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK)
1249+ return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED,
1250+ true);
1251+
1252+ /* fall through, something is wrong if no scan was
1253+ * running but we ran out of scans.
1254+ */
12341255 default:
12351256 WARN_ON(1);
12361257 break;
drivers/net/wireless/intel/iwlwifi/pcie/drv.c+48−31
@@ -541,48 +541,64 @@ static const struct pci_device_id iwl_hw_card_ids[] = { · 540 unmodified lines
541541 MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
542542
543543 #ifdef CONFIG_ACPI
544−#define SPL_METHOD "SPLC"
545−#define SPL_DOMAINTYPE_MODULE BIT(0)
546−#define SPL_DOMAINTYPE_WIFI BIT(1)
547−#define SPL_DOMAINTYPE_WIGIG BIT(2)
548−#define SPL_DOMAINTYPE_RFEM BIT(3)
544+#define ACPI_SPLC_METHOD "SPLC"
545+#define ACPI_SPLC_DOMAIN_WIFI (0x07)
549546
550−static u64 splx_get_pwr_limit(struct iwl_trans *trans, union acpi_object *splx)
547+static u64 splc_get_pwr_limit(struct iwl_trans *trans, union acpi_object *splc)
551548 {
552− union acpi_object *limits, *domain_type, *power_limit;
553−
554− if (splx->type != ACPI_TYPE_PACKAGE ||
555− splx->package.count != 2 ||
556− splx->package.elements[0].type != ACPI_TYPE_INTEGER ||
557− splx->package.elements[0].integer.value != 0) {
558− IWL_ERR(trans, "Unsupported splx structure\n");
549+ union acpi_object *data_pkg, *dflt_pwr_limit;
550+ int i;
551+
552+ /* We need at least two elements, one for the revision and one
553+ * for the data itself. Also check that the revision is
554+ * supported (currently only revision 0).
555+ */
556+ if (splc->type != ACPI_TYPE_PACKAGE ||
557+ splc->package.count < 2 ||
558+ splc->package.elements[0].type != ACPI_TYPE_INTEGER ||
559+ splc->package.elements[0].integer.value != 0) {
560+ IWL_DEBUG_INFO(trans,
561+ "Unsupported structure returned by the SPLC method. Ignoring.\n");
559562 return 0;
560563 }
561564
562− limits = &splx->package.elements[1];
563− if (limits->type != ACPI_TYPE_PACKAGE ||
564− limits->package.count < 2 ||
565− limits->package.elements[0].type != ACPI_TYPE_INTEGER ||
566− limits->package.elements[1].type != ACPI_TYPE_INTEGER) {
567− IWL_ERR(trans, "Invalid limits element\n");
568− return 0;
565+ /* loop through all the packages to find the one for WiFi */
566+ for (i = 1; i < splc->package.count; i++) {
567+ union acpi_object *domain;
568+
569+ data_pkg = &splc->package.elements[i];
570+
571+ /* Skip anything that is not a package with the right
572+ * amount of elements (i.e. at least 2 integers).
573+ */
574+ if (data_pkg->type != ACPI_TYPE_PACKAGE ||
575+ data_pkg->package.count < 2 ||
576+ data_pkg->package.elements[0].type != ACPI_TYPE_INTEGER ||
577+ data_pkg->package.elements[1].type != ACPI_TYPE_INTEGER)
578+ continue;
579+
580+ domain = &data_pkg->package.elements[0];
581+ if (domain->integer.value == ACPI_SPLC_DOMAIN_WIFI)
582+ break;
583+
584+ data_pkg = NULL;
569585 }
570586
571− domain_type = &limits->package.elements[0];
572− power_limit = &limits->package.elements[1];
573− if (!(domain_type->integer.value & SPL_DOMAINTYPE_WIFI)) {
574− IWL_DEBUG_INFO(trans, "WiFi power is not limited\n");
587+ if (!data_pkg) {
588+ IWL_DEBUG_INFO(trans,
589+ "No element for the WiFi domain returned by the SPLC method.\n");
575590 return 0;
576591 }
577592
578− return power_limit->integer.value;
593+ dflt_pwr_limit = &data_pkg->package.elements[1];
594+ return dflt_pwr_limit->integer.value;
579595 }
580596
581597 static void set_dflt_pwr_limit(struct iwl_trans *trans, struct pci_dev *pdev)
582598 {
583599 acpi_handle pxsx_handle;
584600 acpi_handle handle;
585− struct acpi_buffer splx = {ACPI_ALLOCATE_BUFFER, NULL};
601+ struct acpi_buffer splc = {ACPI_ALLOCATE_BUFFER, NULL};
586602 acpi_status status;
587603
588604 pxsx_handle = ACPI_HANDLE(&pdev->dev);
@@ -593,23 +609,24 @@ static void set_dflt_pwr_limit(struct iwl_trans *trans, struct pci_dev *pdev) · 4 unmodified lines
593609 }
594610
595611 /* Get the method's handle */
596− status = acpi_get_handle(pxsx_handle, (acpi_string)SPL_METHOD, &handle);
612+ status = acpi_get_handle(pxsx_handle, (acpi_string)ACPI_SPLC_METHOD,
613+ &handle);
597614 if (ACPI_FAILURE(status)) {
598− IWL_DEBUG_INFO(trans, "SPL method not found\n");
615+ IWL_DEBUG_INFO(trans, "SPLC method not found\n");
599616 return;
600617 }
601618
602619 /* Call SPLC with no arguments */
603− status = acpi_evaluate_object(handle, NULL, NULL, &splx);
620+ status = acpi_evaluate_object(handle, NULL, NULL, &splc);
604621 if (ACPI_FAILURE(status)) {
605622 IWL_ERR(trans, "SPLC invocation failed (0x%x)\n", status);
606623 return;
607624 }
608625
609− trans->dflt_pwr_limit = splx_get_pwr_limit(trans, splx.pointer);
626+ trans->dflt_pwr_limit = splc_get_pwr_limit(trans, splc.pointer);
610627 IWL_DEBUG_INFO(trans, "Default power limit set to %lld\n",
611628 trans->dflt_pwr_limit);
612− kfree(splx.pointer);
629+ kfree(splc.pointer);
613630 }
614631
615632 #else /* CONFIG_ACPI */
drivers/net/wireless/intel/iwlwifi/pcie/tx.c+8−0
@@ -592,6 +592,7 @@ error: · 591 unmodified lines
592592 static int iwl_pcie_txq_init(struct iwl_trans *trans, struct iwl_txq *txq,
593593 int slots_num, u32 txq_id)
594594 {
595+ struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
595596 int ret;
596597
597598 txq->need_update = false;
@@ -606,6 +607,13 @@ static int iwl_pcie_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, · 8 unmodified lines
606607 return ret;
607608
608609 spin_lock_init(&txq->lock);
610+
611+ if (txq_id == trans_pcie->cmd_queue) {
612+ static struct lock_class_key iwl_pcie_cmd_queue_lock_class;
613+
614+ lockdep_set_class(&txq->lock, &iwl_pcie_cmd_queue_lock_class);
615+ }
616+
609617 __skb_queue_head_init(&txq->overflow_q);
610618
611619 /*
drivers/net/xen-netfront.c+2−2
@@ -304,7 +304,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue) · 303 unmodified lines
304304 queue->rx_skbs[id] = skb;
305305
306306 ref = gnttab_claim_grant_reference(&queue->gref_rx_head);
307− BUG_ON((signed short)ref < 0);
307+ WARN_ON_ONCE(IS_ERR_VALUE((unsigned long)(int)ref));
308308 queue->grant_rx_ref[id] = ref;
309309
310310 page = skb_frag_page(&skb_shinfo(skb)->frags[0]);
@@ -428,7 +428,7 @@ static void xennet_tx_setup_grant(unsigned long gfn, unsigned int offset, · 117 unmodified lines
428428 id = get_id_from_freelist(&queue->tx_skb_freelist, queue->tx_skbs);
429429 tx = RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++);
430430 ref = gnttab_claim_grant_reference(&queue->gref_tx_head);
431− BUG_ON((signed short)ref < 0);
431+ WARN_ON_ONCE(IS_ERR_VALUE((unsigned long)(int)ref));
432432
433433 gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id,
434434 gfn, GNTMAP_readonly);
include/linux/ipv6.h+1−1
@@ -149,7 +149,7 @@ static inline bool inet6_exact_dif_match(struct net *net, struct sk_buff *skb) · 148 unmodified lines
149149 {
150150 #if defined(CONFIG_NET_L3_MASTER_DEV)
151151 if (!net->ipv4.sysctl_tcp_l3mdev_accept &&
152− ipv6_l3mdev_skb(IP6CB(skb)->flags))
152+ skb && ipv6_l3mdev_skb(IP6CB(skb)->flags))
153153 return true;
154154 #endif
155155 return false;
include/linux/netdevice.h+15−0
@@ -3354,6 +3354,21 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); · 3353 unmodified lines
33543354 bool is_skb_forwardable(const struct net_device *dev,
33553355 const struct sk_buff *skb);
33563356
3357+static __always_inline int ____dev_forward_skb(struct net_device *dev,
3358+ struct sk_buff *skb)
3359+{
3360+ if (skb_orphan_frags(skb, GFP_ATOMIC) ||
3361+ unlikely(!is_skb_forwardable(dev, skb))) {
3362+ atomic_long_inc(&dev->rx_dropped);
3363+ kfree_skb(skb);
3364+ return NET_RX_DROP;
3365+ }
3366+
3367+ skb_scrub_packet(skb, true);
3368+ skb->priority = 0;
3369+ return 0;
3370+}
3371+
33573372 void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
33583373
33593374 extern int netdev_budget;
include/net/ip.h+1−2
@@ -47,8 +47,7 @@ struct inet_skb_parm { · 46 unmodified lines
4747 #define IPSKB_REROUTED BIT(4)
4848 #define IPSKB_DOREDIRECT BIT(5)
4949 #define IPSKB_FRAG_PMTU BIT(6)
50−#define IPSKB_FRAG_SEGS BIT(7)
51−#define IPSKB_L3SLAVE BIT(8)
50+#define IPSKB_L3SLAVE BIT(7)
5251
5352 u16 frag_max_size;
5453 };
include/net/ip6_tunnel.h+1−0
@@ -146,6 +146,7 @@ static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb, · 145 unmodified lines
146146 {
147147 int pkt_len, err;
148148
149+ memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
149150 pkt_len = skb->len - skb_inner_network_offset(skb);
150151 err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
151152 if (unlikely(net_xmit_eval(err)))
include/net/netfilter/nf_conntrack_labels.h+1−2
@@ -30,8 +30,7 @@ static inline struct nf_conn_labels *nf_ct_labels_ext_add(struct nf_conn *ct) · 29 unmodified lines
3030 if (net->ct.labels_used == 0)
3131 return NULL;
3232
33− return nf_ct_ext_add_length(ct, NF_CT_EXT_LABELS,
34− sizeof(struct nf_conn_labels), GFP_ATOMIC);
33+ return nf_ct_ext_add(ct, NF_CT_EXT_LABELS, GFP_ATOMIC);
3534 #else
3635 return NULL;
3736 #endif
include/net/netfilter/nf_tables.h+5−3
@@ -145,7 +145,7 @@ static inline enum nft_registers nft_type_to_reg(enum nft_data_types type) · 144 unmodified lines
145145 return type == NFT_DATA_VERDICT ? NFT_REG_VERDICT : NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE;
146146 }
147147
148−unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest);
148+int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest);
149149 unsigned int nft_parse_register(const struct nlattr *attr);
150150 int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg);
151151
@@ -542,7 +542,8 @@ void *nft_set_elem_init(const struct nft_set *set, · 390 unmodified lines
542542 const struct nft_set_ext_tmpl *tmpl,
543543 const u32 *key, const u32 *data,
544544 u64 timeout, gfp_t gfp);
545−void nft_set_elem_destroy(const struct nft_set *set, void *elem);
545+void nft_set_elem_destroy(const struct nft_set *set, void *elem,
546+ bool destroy_expr);
546547
547548 /**
548549 * struct nft_set_gc_batch_head - nf_tables set garbage collection batch
@@ -693,7 +694,6 @@ static inline int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src) · 144 unmodified lines
693694 {
694695 int err;
695696
696− __module_get(src->ops->type->owner);
697697 if (src->ops->clone) {
698698 dst->ops = src->ops;
699699 err = src->ops->clone(dst, src);
@@ -702,6 +702,8 @@ static inline int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src) · 2 unmodified lines
702702 } else {
703703 memcpy(dst, src, src->ops->size);
704704 }
705+
706+ __module_get(src->ops->type->owner);
705707 return 0;
706708 }
707709
include/net/sctp/sctp.h+1−1
@@ -152,7 +152,7 @@ void sctp_unhash_endpoint(struct sctp_endpoint *); · 151 unmodified lines
152152 struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *,
153153 struct sctphdr *, struct sctp_association **,
154154 struct sctp_transport **);
155−void sctp_err_finish(struct sock *, struct sctp_association *);
155+void sctp_err_finish(struct sock *, struct sctp_transport *);
156156 void sctp_icmp_frag_needed(struct sock *, struct sctp_association *,
157157 struct sctp_transport *t, __u32 pmtu);
158158 void sctp_icmp_redirect(struct sock *, struct sctp_transport *,
include/net/sock.h+2−2
@@ -1596,11 +1596,11 @@ static inline void sock_put(struct sock *sk) · 1595 unmodified lines
15961596 void sock_gen_put(struct sock *sk);
15971597
15981598 int __sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested,
1599− unsigned int trim_cap);
1599+ unsigned int trim_cap, bool refcounted);
16001600 static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
16011601 const int nested)
16021602 {
1603− return __sk_receive_skb(sk, skb, nested, 1);
1603+ return __sk_receive_skb(sk, skb, nested, 1, true);
16041604 }
16051605
16061606 static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
include/net/tcp.h+2−1
@@ -805,7 +805,7 @@ static inline bool inet_exact_dif_match(struct net *net, struct sk_buff *skb) · 804 unmodified lines
805805 {
806806 #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
807807 if (!net->ipv4.sysctl_tcp_l3mdev_accept &&
808− ipv4_l3mdev_skb(TCP_SKB_CB(skb)->header.h4.flags))
808+ skb && ipv4_l3mdev_skb(TCP_SKB_CB(skb)->header.h4.flags))
809809 return true;
810810 #endif
811811 return false;
@@ -1220,6 +1220,7 @@ static inline void tcp_prequeue_init(struct tcp_sock *tp) · 408 unmodified lines
12201220
12211221 bool tcp_prequeue(struct sock *sk, struct sk_buff *skb);
12221222 bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb);
1223+int tcp_filter(struct sock *sk, struct sk_buff *skb);
12231224
12241225 #undef STATE_TRACE
12251226
include/uapi/linux/atm_zatm.h+0−1
@@ -14,7 +14,6 @@ · 13 unmodified lines
1414
1515 #include <linux/atmapi.h>
1616 #include <linux/atmioc.h>
17−#include <linux/time.h>
1817
1918 #define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc)
2019 /* get pool statistics */
include/uapi/linux/bpqether.h+0−2
@@ -5,9 +5,7 @@ · 4 unmodified lines
55 * Defines for the BPQETHER pseudo device driver
66 */
77
8−#ifndef __LINUX_IF_ETHER_H
98 #include <linux/if_ether.h>
10−#endif
119
1210 #define SIOCSBPQETHOPT (SIOCDEVPRIVATE+0) /* reserved */
1311 #define SIOCSBPQETHADDR (SIOCDEVPRIVATE+1)
kernel/bpf/hashtab.c+2−1
@@ -687,7 +687,8 @@ static void delete_all_elements(struct bpf_htab *htab) · 686 unmodified lines
687687
688688 hlist_for_each_entry_safe(l, n, head, hash_node) {
689689 hlist_del_rcu(&l->hash_node);
690− htab_elem_free(htab, l);
690+ if (l->state != HTAB_EXTRA_ELEM_USED)
691+ htab_elem_free(htab, l);
691692 }
692693 }
693694 }
kernel/bpf/syscall.c+3−1
@@ -194,7 +194,7 @@ static int map_create(union bpf_attr *attr) · 193 unmodified lines
194194
195195 err = bpf_map_charge_memlock(map);
196196 if (err)
197− goto free_map;
197+ goto free_map_nouncharge;
198198
199199 err = bpf_map_new_fd(map);
200200 if (err < 0)
@@ -204,6 +204,8 @@ static int map_create(union bpf_attr *attr) · 3 unmodified lines
204204 return err;
205205
206206 free_map:
207+ bpf_map_uncharge_memlock(map);
208+free_map_nouncharge:
207209 map->ops->map_free(map);
208210 return err;
209211 }
kernel/taskstats.c+5−1
@@ -54,7 +54,11 @@ static const struct nla_policy taskstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1 · 53 unmodified lines
5454 [TASKSTATS_CMD_ATTR_REGISTER_CPUMASK] = { .type = NLA_STRING },
5555 [TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK] = { .type = NLA_STRING },};
5656
57−static const struct nla_policy cgroupstats_cmd_get_policy[CGROUPSTATS_CMD_ATTR_MAX+1] = {
57+/*
58+ * We have to use TASKSTATS_CMD_ATTR_MAX here, it is the maxattr in the family.
59+ * Make sure they are always aligned.
60+ */
61+static const struct nla_policy cgroupstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1] = {
5862 [CGROUPSTATS_CMD_ATTR_FD] = { .type = NLA_U32 },
5963 };
6064
net/can/bcm.c+23−9
@@ -1549,24 +1549,31 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, · 1548 unmodified lines
15491549 struct sockaddr_can *addr = (struct sockaddr_can *)uaddr;
15501550 struct sock *sk = sock->sk;
15511551 struct bcm_sock *bo = bcm_sk(sk);
1552+ int ret = 0;
15521553
15531554 if (len < sizeof(*addr))
15541555 return -EINVAL;
15551556
1556− if (bo->bound)
1557− return -EISCONN;
1557+ lock_sock(sk);
1558+
1559+ if (bo->bound) {
1560+ ret = -EISCONN;
1561+ goto fail;
1562+ }
15581563
15591564 /* bind a device to this socket */
15601565 if (addr->can_ifindex) {
15611566 struct net_device *dev;
15621567
15631568 dev = dev_get_by_index(&init_net, addr->can_ifindex);
1564− if (!dev)
1565− return -ENODEV;
1566−
1569+ if (!dev) {
1570+ ret = -ENODEV;
1571+ goto fail;
1572+ }
15671573 if (dev->type != ARPHRD_CAN) {
15681574 dev_put(dev);
1569− return -ENODEV;
1575+ ret = -ENODEV;
1576+ goto fail;
15701577 }
15711578
15721579 bo->ifindex = dev->ifindex;
@@ -1577,17 +1584,24 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, · 4 unmodified lines
15771584 bo->ifindex = 0;
15781585 }
15791586
1580− bo->bound = 1;
1581−
15821587 if (proc_dir) {
15831588 /* unique socket address as filename */
15841589 sprintf(bo->procname, "%lu", sock_i_ino(sk));
15851590 bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
15861591 proc_dir,
15871592 &bcm_proc_fops, sk);
1593+ if (!bo->bcm_proc_read) {
1594+ ret = -ENOMEM;
1595+ goto fail;
1596+ }
15881597 }
15891598
1590− return 0;
1599+ bo->bound = 1;
1600+
1601+fail:
1602+ release_sock(sk);
1603+
1604+ return ret;
15911605 }
15921606
15931607 static int bcm_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
net/core/dev.c+7−12
@@ -1766,19 +1766,14 @@ EXPORT_SYMBOL_GPL(is_skb_forwardable); · 1765 unmodified lines
17661766
17671767 int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
17681768 {
1769− if (skb_orphan_frags(skb, GFP_ATOMIC) ||
1770− unlikely(!is_skb_forwardable(dev, skb))) {
1771− atomic_long_inc(&dev->rx_dropped);
1772− kfree_skb(skb);
1773− return NET_RX_DROP;
1774− }
1769+ int ret = ____dev_forward_skb(dev, skb);
17751770
1776− skb_scrub_packet(skb, true);
1777− skb->priority = 0;
1778− skb->protocol = eth_type_trans(skb, dev);
1779− skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
1771+ if (likely(!ret)) {
1772+ skb->protocol = eth_type_trans(skb, dev);
1773+ skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
1774+ }
17801775
1781− return 0;
1776+ return ret;
17821777 }
17831778 EXPORT_SYMBOL_GPL(__dev_forward_skb);
17841779
@@ -2484,7 +2479,7 @@ int skb_checksum_help(struct sk_buff *skb) · 699 unmodified lines
24842479 goto out;
24852480 }
24862481
2487− *(__sum16 *)(skb->data + offset) = csum_fold(csum);
2482+ *(__sum16 *)(skb->data + offset) = csum_fold(csum) ?: CSUM_MANGLED_0;
24882483 out_set_summed:
24892484 skb->ip_summed = CHECKSUM_NONE;
24902485 out:
net/core/filter.c+60−8
@@ -1628,6 +1628,19 @@ static inline int __bpf_rx_skb(struct net_device *dev, struct sk_buff *skb) · 1627 unmodified lines
16281628 return dev_forward_skb(dev, skb);
16291629 }
16301630
1631+static inline int __bpf_rx_skb_no_mac(struct net_device *dev,
1632+ struct sk_buff *skb)
1633+{
1634+ int ret = ____dev_forward_skb(dev, skb);
1635+
1636+ if (likely(!ret)) {
1637+ skb->dev = dev;
1638+ ret = netif_rx(skb);
1639+ }
1640+
1641+ return ret;
1642+}
1643+
16311644 static inline int __bpf_tx_skb(struct net_device *dev, struct sk_buff *skb)
16321645 {
16331646 int ret;
@@ -1647,6 +1660,51 @@ static inline int __bpf_tx_skb(struct net_device *dev, struct sk_buff *skb) · 13 unmodified lines
16471660 return ret;
16481661 }
16491662
1663+static int __bpf_redirect_no_mac(struct sk_buff *skb, struct net_device *dev,
1664+ u32 flags)
1665+{
1666+ /* skb->mac_len is not set on normal egress */
1667+ unsigned int mlen = skb->network_header - skb->mac_header;
1668+
1669+ __skb_pull(skb, mlen);
1670+
1671+ /* At ingress, the mac header has already been pulled once.
1672+ * At egress, skb_pospull_rcsum has to be done in case that
1673+ * the skb is originated from ingress (i.e. a forwarded skb)
1674+ * to ensure that rcsum starts at net header.
1675+ */
1676+ if (!skb_at_tc_ingress(skb))
1677+ skb_postpull_rcsum(skb, skb_mac_header(skb), mlen);
1678+ skb_pop_mac_header(skb);
1679+ skb_reset_mac_len(skb);
1680+ return flags & BPF_F_INGRESS ?
1681+ __bpf_rx_skb_no_mac(dev, skb) : __bpf_tx_skb(dev, skb);
1682+}
1683+
1684+static int __bpf_redirect_common(struct sk_buff *skb, struct net_device *dev,
1685+ u32 flags)
1686+{
1687+ bpf_push_mac_rcsum(skb);
1688+ return flags & BPF_F_INGRESS ?
1689+ __bpf_rx_skb(dev, skb) : __bpf_tx_skb(dev, skb);
1690+}
1691+
1692+static int __bpf_redirect(struct sk_buff *skb, struct net_device *dev,
1693+ u32 flags)
1694+{
1695+ switch (dev->type) {
1696+ case ARPHRD_TUNNEL:
1697+ case ARPHRD_TUNNEL6:
1698+ case ARPHRD_SIT:
1699+ case ARPHRD_IPGRE:
1700+ case ARPHRD_VOID:
1701+ case ARPHRD_NONE:
1702+ return __bpf_redirect_no_mac(skb, dev, flags);
1703+ default:
1704+ return __bpf_redirect_common(skb, dev, flags);
1705+ }
1706+}
1707+
16501708 BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)
16511709 {
16521710 struct net_device *dev;
@@ -1675,10 +1733,7 @@ BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags) · 22 unmodified lines
16751733 return -ENOMEM;
16761734 }
16771735
1678− bpf_push_mac_rcsum(clone);
1679−
1680− return flags & BPF_F_INGRESS ?
1681− __bpf_rx_skb(dev, clone) : __bpf_tx_skb(dev, clone);
1736+ return __bpf_redirect(clone, dev, flags);
16821737 }
16831738
16841739 static const struct bpf_func_proto bpf_clone_redirect_proto = {
@@ -1722,10 +1777,7 @@ int skb_do_redirect(struct sk_buff *skb) · 37 unmodified lines
17221777 return -EINVAL;
17231778 }
17241779
1725− bpf_push_mac_rcsum(skb);
1726−
1727− return ri->flags & BPF_F_INGRESS ?
1728− __bpf_rx_skb(dev, skb) : __bpf_tx_skb(dev, skb);
1780+ return __bpf_redirect(skb, dev, ri->flags);
17291781 }
17301782
17311783 static const struct bpf_func_proto bpf_redirect_proto = {
net/core/flow_dissector.c+8−3
@@ -122,7 +122,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb, · 121 unmodified lines
122122 struct flow_dissector_key_keyid *key_keyid;
123123 bool skip_vlan = false;
124124 u8 ip_proto = 0;
125− bool ret = false;
125+ bool ret;
126126
127127 if (!data) {
128128 data = skb->data;
@@ -549,12 +549,17 @@ ip_proto_again: · 420 unmodified lines
549549 out_good:
550550 ret = true;
551551
552−out_bad:
552+ key_control->thoff = (u16)nhoff;
553+out:
553554 key_basic->n_proto = proto;
554555 key_basic->ip_proto = ip_proto;
555− key_control->thoff = (u16)nhoff;
556556
557557 return ret;
558+
559+out_bad:
560+ ret = false;
561+ key_control->thoff = min_t(u16, nhoff, skb ? skb->len : hlen);
562+ goto out;
558563 }
559564 EXPORT_SYMBOL(__skb_flow_dissect);
560565
net/core/rtnetlink.c+1−0
@@ -275,6 +275,7 @@ int rtnl_unregister(int protocol, int msgtype) · 274 unmodified lines
275275
276276 rtnl_msg_handlers[protocol][msgindex].doit = NULL;
277277 rtnl_msg_handlers[protocol][msgindex].dumpit = NULL;
278+ rtnl_msg_handlers[protocol][msgindex].calcit = NULL;
278279
279280 return 0;
280281 }
net/core/sock.c+4−2
@@ -453,7 +453,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) · 452 unmodified lines
453453 EXPORT_SYMBOL(sock_queue_rcv_skb);
454454
455455 int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
456− const int nested, unsigned int trim_cap)
456+ const int nested, unsigned int trim_cap, bool refcounted)
457457 {
458458 int rc = NET_RX_SUCCESS;
459459
@@ -487,7 +487,8 @@ int __sk_receive_skb(struct sock *sk, struct sk_buff *skb, · 27 unmodified lines
487487
488488 bh_unlock_sock(sk);
489489 out:
490− sock_put(sk);
490+ if (refcounted)
491+ sock_put(sk);
491492 return rc;
492493 discard_and_relse:
493494 kfree_skb(skb);
@@ -1543,6 +1544,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) · 1049 unmodified lines
15431544 RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL);
15441545
15451546 newsk->sk_err = 0;
1547+ newsk->sk_err_soft = 0;
15461548 newsk->sk_priority = 0;
15471549 newsk->sk_incoming_cpu = raw_smp_processor_id();
15481550 atomic64_set(&newsk->sk_cookie, 0);
net/dccp/ipv4.c+9−7
@@ -235,7 +235,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) · 234 unmodified lines
235235 {
236236 const struct iphdr *iph = (struct iphdr *)skb->data;
237237 const u8 offset = iph->ihl << 2;
238− const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
238+ const struct dccp_hdr *dh;
239239 struct dccp_sock *dp;
240240 struct inet_sock *inet;
241241 const int type = icmp_hdr(skb)->type;
@@ -245,11 +245,13 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) · 3 unmodified lines
245245 int err;
246246 struct net *net = dev_net(skb->dev);
247247
248− if (skb->len < offset + sizeof(*dh) ||
249− skb->len < offset + __dccp_basic_hdr_len(dh)) {
250− __ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
251− return;
252− }
248+ /* Only need dccph_dport & dccph_sport which are the first
249+ * 4 bytes in dccp header.
250+ * Our caller (icmp_socket_deliver()) already pulled 8 bytes for us.
251+ */
252+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
253+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
254+ dh = (struct dccp_hdr *)(skb->data + offset);
253255
254256 sk = __inet_lookup_established(net, &dccp_hashinfo,
255257 iph->daddr, dh->dccph_dport,
@@ -868,7 +870,7 @@ lookup: · 612 unmodified lines
868870 goto discard_and_relse;
869871 nf_reset(skb);
870872
871− return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4);
873+ return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4, refcounted);
872874
873875 no_dccp_socket:
874876 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
net/dccp/ipv6.c+11−8
@@ -70,7 +70,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 69 unmodified lines
7070 u8 type, u8 code, int offset, __be32 info)
7171 {
7272 const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
73− const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
73+ const struct dccp_hdr *dh;
7474 struct dccp_sock *dp;
7575 struct ipv6_pinfo *np;
7676 struct sock *sk;
@@ -78,12 +78,13 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 1 unmodified line
7878 __u64 seq;
7979 struct net *net = dev_net(skb->dev);
8080
81− if (skb->len < offset + sizeof(*dh) ||
82− skb->len < offset + __dccp_basic_hdr_len(dh)) {
83− __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),
84− ICMP6_MIB_INERRORS);
85− return;
86− }
81+ /* Only need dccph_dport & dccph_sport which are the first
82+ * 4 bytes in dccp header.
83+ * Our caller (icmpv6_notify()) already pulled 8 bytes for us.
84+ */
85+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
86+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
87+ dh = (struct dccp_hdr *)(skb->data + offset);
8788
8889 sk = __inet6_lookup_established(net, &dccp_hashinfo,
8990 &hdr->daddr, dh->dccph_dport,
@@ -738,7 +739,8 @@ lookup: · 648 unmodified lines
738739 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
739740 goto discard_and_relse;
740741
741− return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4) ? -1 : 0;
742+ return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,
743+ refcounted) ? -1 : 0;
742744
743745 no_dccp_socket:
744746 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
@@ -956,6 +958,7 @@ static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = { · 211 unmodified lines
956958 .getsockopt = ipv6_getsockopt,
957959 .addr2sockaddr = inet6_csk_addr2sockaddr,
958960 .sockaddr_len = sizeof(struct sockaddr_in6),
961+ .bind_conflict = inet6_csk_bind_conflict,
959962 #ifdef CONFIG_COMPAT
960963 .compat_setsockopt = compat_ipv6_setsockopt,
961964 .compat_getsockopt = compat_ipv6_getsockopt,
net/dccp/proto.c+4−0
@@ -1009,6 +1009,10 @@ void dccp_close(struct sock *sk, long timeout) · 1008 unmodified lines
10091009 __kfree_skb(skb);
10101010 }
10111011
1012+ /* If socket has been already reset kill it. */
1013+ if (sk->sk_state == DCCP_CLOSED)
1014+ goto adjudge_to_death;
1015+
10121016 if (data_was_unread) {
10131017 /* Unread data was tossed, send an appropriate Reset Code */
10141018 DCCP_WARN("ABORT with %u bytes unread\n", data_was_unread);
net/ipv4/af_inet.c+4−5
@@ -533,9 +533,9 @@ EXPORT_SYMBOL(inet_dgram_connect); · 532 unmodified lines
533533
534534 static long inet_wait_for_connect(struct sock *sk, long timeo, int writebias)
535535 {
536− DEFINE_WAIT(wait);
536+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
537537
538− prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
538+ add_wait_queue(sk_sleep(sk), &wait);
539539 sk->sk_write_pending += writebias;
540540
541541 /* Basic assumption: if someone sets sk->sk_err, he _must_
@@ -545,13 +545,12 @@ static long inet_wait_for_connect(struct sock *sk, long timeo, int writebias) · 3 unmodified lines
545545 */
546546 while ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
547547 release_sock(sk);
548− timeo = schedule_timeout(timeo);
548+ timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
549549 lock_sock(sk);
550550 if (signal_pending(current) || !timeo)
551551 break;
552− prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
553552 }
554− finish_wait(sk_sleep(sk), &wait);
553+ remove_wait_queue(sk_sleep(sk), &wait);
555554 sk->sk_write_pending -= writebias;
556555 return timeo;
557556 }
net/ipv4/fib_trie.c+9−12
@@ -2413,22 +2413,19 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter, · 2412 unmodified lines
24132413 struct key_vector *l, **tp = &iter->tnode;
24142414 t_key key;
24152415
2416− /* use cache location of next-to-find key */
2416+ /* use cached location of previously found key */
24172417 if (iter->pos > 0 && pos >= iter->pos) {
2418− pos -= iter->pos;
24192418 key = iter->key;
24202419 } else {
2421− iter->pos = 0;
2420+ iter->pos = 1;
24222421 key = 0;
24232422 }
24242423
2425− while ((l = leaf_walk_rcu(tp, key)) != NULL) {
2424+ pos -= iter->pos;
2425+
2426+ while ((l = leaf_walk_rcu(tp, key)) && (pos-- > 0)) {
24262427 key = l->key + 1;
24272428 iter->pos++;
2428−
2429− if (--pos <= 0)
2430− break;
2431−
24322429 l = NULL;
24332430
24342431 /* handle unlikely case of a key wrap */
@@ -2437,7 +2434,7 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter, · 2 unmodified lines
24372434 }
24382435
24392436 if (l)
2440− iter->key = key; /* remember it */
2437+ iter->key = l->key; /* remember it */
24412438 else
24422439 iter->pos = 0; /* forget it */
24432440
@@ -2465,7 +2462,7 @@ static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos) · 21 unmodified lines
24652462 return fib_route_get_idx(iter, *pos);
24662463
24672464 iter->pos = 0;
2468− iter->key = 0;
2465+ iter->key = KEY_MAX;
24692466
24702467 return SEQ_START_TOKEN;
24712468 }
@@ -2474,7 +2471,7 @@ static void *fib_route_seq_next(struct seq_file *seq, void *v, loff_t *pos) · 2 unmodified lines
24742471 {
24752472 struct fib_route_iter *iter = seq->private;
24762473 struct key_vector *l = NULL;
2477− t_key key = iter->key;
2474+ t_key key = iter->key + 1;
24782475
24792476 ++*pos;
24802477
@@ -2483,7 +2480,7 @@ static void *fib_route_seq_next(struct seq_file *seq, void *v, loff_t *pos) · 2 unmodified lines
24832480 l = leaf_walk_rcu(&iter->tnode, key);
24842481
24852482 if (l) {
2486− iter->key = l->key + 1;
2483+ iter->key = l->key;
24872484 iter->pos++;
24882485 } else {
24892486 iter->pos = 0;
net/ipv4/icmp.c+2−2
@@ -477,7 +477,7 @@ static struct rtable *icmp_route_lookup(struct net *net, · 476 unmodified lines
477477 fl4->flowi4_proto = IPPROTO_ICMP;
478478 fl4->fl4_icmp_type = type;
479479 fl4->fl4_icmp_code = code;
480− fl4->flowi4_oif = l3mdev_master_ifindex(skb_in->dev);
480+ fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);
481481
482482 security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
483483 rt = __ip_route_output_key_hash(net, fl4,
@@ -502,7 +502,7 @@ static struct rtable *icmp_route_lookup(struct net *net, · 18 unmodified lines
502502 if (err)
503503 goto relookup_failed;
504504
505− if (inet_addr_type_dev_table(net, skb_in->dev,
505+ if (inet_addr_type_dev_table(net, skb_dst(skb_in)->dev,
506506 fl4_dec.saddr) == RTN_LOCAL) {
507507 rt2 = __ip_route_output_key(net, &fl4_dec);
508508 if (IS_ERR(rt2))
net/ipv4/ip_forward.c+1−1
@@ -117,7 +117,7 @@ int ip_forward(struct sk_buff *skb) · 116 unmodified lines
117117 if (opt->is_strictroute && rt->rt_uses_gateway)
118118 goto sr_failed;
119119
120− IPCB(skb)->flags |= IPSKB_FORWARDED | IPSKB_FRAG_SEGS;
120+ IPCB(skb)->flags |= IPSKB_FORWARDED;
121121 mtu = ip_dst_mtu_maybe_forward(&rt->dst, true);
122122 if (ip_exceeds_mtu(skb, mtu)) {
123123 IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
net/ipv4/ip_output.c+15−10
@@ -239,19 +239,23 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk, · 238 unmodified lines
239239 struct sk_buff *segs;
240240 int ret = 0;
241241
242− /* common case: fragmentation of segments is not allowed,
243− * or seglen is <= mtu
242+ /* common case: seglen is <= mtu
244243 */
245− if (((IPCB(skb)->flags & IPSKB_FRAG_SEGS) == 0) ||
246− skb_gso_validate_mtu(skb, mtu))
244+ if (skb_gso_validate_mtu(skb, mtu))
247245 return ip_finish_output2(net, sk, skb);
248246
249− /* Slowpath - GSO segment length is exceeding the dst MTU.
247+ /* Slowpath - GSO segment length exceeds the egress MTU.
250248 *
251− * This can happen in two cases:
252− * 1) TCP GRO packet, DF bit not set
253− * 2) skb arrived via virtio-net, we thus get TSO/GSO skbs directly
254− * from host network stack.
249+ * This can happen in several cases:
250+ * - Forwarding of a TCP GRO skb, when DF flag is not set.
251+ * - Forwarding of an skb that arrived on a virtualization interface
252+ * (virtio-net/vhost/tap) with TSO/GSO size set by other network
253+ * stack.
254+ * - Local GSO skb transmitted on an NETIF_F_TSO tunnel stacked over an
255+ * interface with a smaller MTU.
256+ * - Arriving GRO skb (or GSO skb in a virtualized environment) that is
257+ * bridged to a NETIF_F_TSO tunnel stacked over an interface with an
258+ * insufficent MTU.
255259 */
256260 features = netif_skb_features(skb);
257261 BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET);
@@ -1579,7 +1583,8 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, · 1321 unmodified lines
15791583 }
15801584
15811585 oif = arg->bound_dev_if;
1582− oif = oif ? : skb->skb_iif;
1586+ if (!oif && netif_index_is_l3_master(net, skb->skb_iif))
1587+ oif = skb->skb_iif;
15831588
15841589 flowi4_init_output(&fl4, oif,
15851590 IP4_REPLY_MARK(net, skb->mark),
net/ipv4/ip_tunnel_core.c+0−11
@@ -63,7 +63,6 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, · 62 unmodified lines
6363 int pkt_len = skb->len - skb_inner_network_offset(skb);
6464 struct net *net = dev_net(rt->dst.dev);
6565 struct net_device *dev = skb->dev;
66− int skb_iif = skb->skb_iif;
6766 struct iphdr *iph;
6867 int err;
6968
@@ -73,16 +72,6 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, · 3 unmodified lines
7372 skb_dst_set(skb, &rt->dst);
7473 memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
7574
76− if (skb_iif && !(df & htons(IP_DF))) {
77− /* Arrived from an ingress interface, got encapsulated, with
78− * fragmentation of encapulating frames allowed.
79− * If skb is gso, the resulting encapsulated network segments
80− * may exceed dst mtu.
81− * Allow IP Fragmentation of segments.
82− */
83− IPCB(skb)->flags |= IPSKB_FRAG_SEGS;
84− }
85−
8675 /* Push down and install the IP header. */
8776 skb_push(skb, sizeof(struct iphdr));
8877 skb_reset_network_header(skb);
net/ipv4/ipmr.c+1−1
@@ -1749,7 +1749,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt, · 1748 unmodified lines
17491749 vif->dev->stats.tx_bytes += skb->len;
17501750 }
17511751
1752− IPCB(skb)->flags |= IPSKB_FORWARDED | IPSKB_FRAG_SEGS;
1752+ IPCB(skb)->flags |= IPSKB_FORWARDED;
17531753
17541754 /* RFC1584 teaches, that DVMRP/PIM router must deliver packets locally
17551755 * not only before forwarding, but after forwarding on all output
net/ipv4/netfilter/nft_dup_ipv4.c+4−2
@@ -28,7 +28,7 @@ static void nft_dup_ipv4_eval(const struct nft_expr *expr, · 27 unmodified lines
2828 struct in_addr gw = {
2929 .s_addr = (__force __be32)regs->data[priv->sreg_addr],
3030 };
31− int oif = regs->data[priv->sreg_dev];
31+ int oif = priv->sreg_dev ? regs->data[priv->sreg_dev] : -1;
3232
3333 nf_dup_ipv4(pkt->net, pkt->skb, pkt->hook, &gw, oif);
3434 }
@@ -59,7 +59,9 @@ static int nft_dup_ipv4_dump(struct sk_buff *skb, const struct nft_expr *expr) · 24 unmodified lines
5959 {
6060 struct nft_dup_ipv4 *priv = nft_expr_priv(expr);
6161
62− if (nft_dump_register(skb, NFTA_DUP_SREG_ADDR, priv->sreg_addr) ||
62+ if (nft_dump_register(skb, NFTA_DUP_SREG_ADDR, priv->sreg_addr))
63+ goto nla_put_failure;
64+ if (priv->sreg_dev &&
6365 nft_dump_register(skb, NFTA_DUP_SREG_DEV, priv->sreg_dev))
6466 goto nla_put_failure;
6567
net/ipv4/route.c+3−1
@@ -753,7 +753,9 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow · 752 unmodified lines
753753 goto reject_redirect;
754754 }
755755
756− n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
756+ n = __ipv4_neigh_lookup(rt->dst.dev, new_gw);
757+ if (!n)
758+ n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev);
757759 if (!IS_ERR(n)) {
758760 if (!(n->nud_state & NUD_VALID)) {
759761 neigh_event_send(n, NULL);
net/ipv4/tcp.c+2−2
@@ -1164,7 +1164,7 @@ restart: · 1163 unmodified lines
11641164
11651165 err = -EPIPE;
11661166 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
1167− goto out_err;
1167+ goto do_error;
11681168
11691169 sg = !!(sk->sk_route_caps & NETIF_F_SG);
11701170
@@ -1241,7 +1241,7 @@ new_segment: · 70 unmodified lines
12411241
12421242 if (!skb_can_coalesce(skb, i, pfrag->page,
12431243 pfrag->offset)) {
1244− if (i == sysctl_max_skb_frags || !sg) {
1244+ if (i >= sysctl_max_skb_frags || !sg) {
12451245 tcp_mark_push(tp, skb);
12461246 goto new_segment;
12471247 }
net/ipv4/tcp_dctcp.c+12−1
@@ -56,6 +56,7 @@ struct dctcp { · 55 unmodified lines
5656 u32 next_seq;
5757 u32 ce_state;
5858 u32 delayed_ack_reserved;
59+ u32 loss_cwnd;
5960 };
6061
6162 static unsigned int dctcp_shift_g __read_mostly = 4; /* g = 1/2^4 */
@@ -96,6 +97,7 @@ static void dctcp_init(struct sock *sk) · 34 unmodified lines
9697 ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
9798
9899 ca->delayed_ack_reserved = 0;
100+ ca->loss_cwnd = 0;
99101 ca->ce_state = 0;
100102
101103 dctcp_reset(tp, ca);
@@ -111,9 +113,10 @@ static void dctcp_init(struct sock *sk) · 9 unmodified lines
111113
112114 static u32 dctcp_ssthresh(struct sock *sk)
113115 {
114− const struct dctcp *ca = inet_csk_ca(sk);
116+ struct dctcp *ca = inet_csk_ca(sk);
115117 struct tcp_sock *tp = tcp_sk(sk);
116118
119+ ca->loss_cwnd = tp->snd_cwnd;
117120 return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->dctcp_alpha) >> 11U), 2U);
118121 }
119122
@@ -308,12 +311,20 @@ static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr, · 188 unmodified lines
308311 return 0;
309312 }
310313
314+static u32 dctcp_cwnd_undo(struct sock *sk)
315+{
316+ const struct dctcp *ca = inet_csk_ca(sk);
317+
318+ return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd);
319+}
320+
311321 static struct tcp_congestion_ops dctcp __read_mostly = {
312322 .init = dctcp_init,
313323 .in_ack_event = dctcp_update_alpha,
314324 .cwnd_event = dctcp_cwnd_event,
315325 .ssthresh = dctcp_ssthresh,
316326 .cong_avoid = tcp_reno_cong_avoid,
327+ .undo_cwnd = dctcp_cwnd_undo,
317328 .set_state = dctcp_state,
318329 .get_info = dctcp_get_info,
319330 .flags = TCP_CONG_NEEDS_ECN,
net/ipv4/tcp_ipv4.c+18−1
@@ -1564,6 +1564,21 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) · 1563 unmodified lines
15641564 }
15651565 EXPORT_SYMBOL(tcp_add_backlog);
15661566
1567+int tcp_filter(struct sock *sk, struct sk_buff *skb)
1568+{
1569+ struct tcphdr *th = (struct tcphdr *)skb->data;
1570+ unsigned int eaten = skb->len;
1571+ int err;
1572+
1573+ err = sk_filter_trim_cap(sk, skb, th->doff * 4);
1574+ if (!err) {
1575+ eaten -= skb->len;
1576+ TCP_SKB_CB(skb)->end_seq -= eaten;
1577+ }
1578+ return err;
1579+}
1580+EXPORT_SYMBOL(tcp_filter);
1581+
15671582 /*
15681583 * From tcp_input.c
15691584 */
@@ -1676,8 +1691,10 @@ process: · 106 unmodified lines
16761691
16771692 nf_reset(skb);
16781693
1679− if (sk_filter(sk, skb))
1694+ if (tcp_filter(sk, skb))
16801695 goto discard_and_relse;
1696+ th = (const struct tcphdr *)skb->data;
1697+ iph = ip_hdr(skb);
16811698
16821699 skb->dev = NULL;
16831700
net/ipv6/icmp.c+1−1
@@ -448,7 +448,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 447 unmodified lines
448448 if (__ipv6_addr_needs_scope_id(addr_type))
449449 iif = skb->dev->ifindex;
450450 else
451− iif = l3mdev_master_ifindex(skb->dev);
451+ iif = l3mdev_master_ifindex(skb_dst(skb)->dev);
452452
453453 /*
454454 * Must not send error if the source does not uniquely
net/ipv6/ip6_output.c+1−1
@@ -1366,7 +1366,7 @@ emsgsize: · 1365 unmodified lines
13661366 if (((length > mtu) ||
13671367 (skb && skb_is_gso(skb))) &&
13681368 (sk->sk_protocol == IPPROTO_UDP) &&
1369− (rt->dst.dev->features & NETIF_F_UFO) &&
1369+ (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len &&
13701370 (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) {
13711371 err = ip6_ufo_append_data(sk, queue, getfrag, from, length,
13721372 hh_len, fragheaderlen, exthdrlen,
net/ipv6/ip6_udp_tunnel.c+0−3
@@ -88,9 +88,6 @@ int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk, · 87 unmodified lines
8888
8989 uh->len = htons(skb->len);
9090
91− memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
92− IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
93− | IPSKB_REROUTED);
9491 skb_dst_set(skb, dst);
9592
9693 udp6_set_csum(nocheck, skb, saddr, daddr, skb->len);
net/ipv6/netfilter/nft_dup_ipv6.c+4−2
@@ -26,7 +26,7 @@ static void nft_dup_ipv6_eval(const struct nft_expr *expr, · 25 unmodified lines
2626 {
2727 struct nft_dup_ipv6 *priv = nft_expr_priv(expr);
2828 struct in6_addr *gw = (struct in6_addr *)&regs->data[priv->sreg_addr];
29− int oif = regs->data[priv->sreg_dev];
29+ int oif = priv->sreg_dev ? regs->data[priv->sreg_dev] : -1;
3030
3131 nf_dup_ipv6(pkt->net, pkt->skb, pkt->hook, gw, oif);
3232 }
@@ -57,7 +57,9 @@ static int nft_dup_ipv6_dump(struct sk_buff *skb, const struct nft_expr *expr) · 24 unmodified lines
5757 {
5858 struct nft_dup_ipv6 *priv = nft_expr_priv(expr);
5959
60− if (nft_dump_register(skb, NFTA_DUP_SREG_ADDR, priv->sreg_addr) ||
60+ if (nft_dump_register(skb, NFTA_DUP_SREG_ADDR, priv->sreg_addr))
61+ goto nla_put_failure;
62+ if (priv->sreg_dev &&
6163 nft_dump_register(skb, NFTA_DUP_SREG_DEV, priv->sreg_dev))
6264 goto nla_put_failure;
6365
net/ipv6/route.c+4−0
@@ -1364,6 +1364,9 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, · 1363 unmodified lines
13641364 if (rt6->rt6i_flags & RTF_LOCAL)
13651365 return;
13661366
1367+ if (dst_metric_locked(dst, RTAX_MTU))
1368+ return;
1369+
13671370 dst_confirm(dst);
13681371 mtu = max_t(u32, mtu, IPV6_MIN_MTU);
13691372 if (mtu >= dst_mtu(dst))
@@ -2758,6 +2761,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) · 1388 unmodified lines
27582761 PMTU discouvery.
27592762 */
27602763 if (rt->dst.dev == arg->dev &&
2764+ dst_metric_raw(&rt->dst, RTAX_MTU) &&
27612765 !dst_metric_locked(&rt->dst, RTAX_MTU)) {
27622766 if (rt->rt6i_flags & RTF_CACHE) {
27632767 /* For RTF_CACHE with rt6i_pmtu == 0
net/ipv6/tcp_ipv6.c+10−4
@@ -818,8 +818,12 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 · 817 unmodified lines
818818 fl6.flowi6_proto = IPPROTO_TCP;
819819 if (rt6_need_strict(&fl6.daddr) && !oif)
820820 fl6.flowi6_oif = tcp_v6_iif(skb);
821− else
822− fl6.flowi6_oif = oif ? : skb->skb_iif;
821+ else {
822+ if (!oif && netif_index_is_l3_master(net, skb->skb_iif))
823+ oif = skb->skb_iif;
824+
825+ fl6.flowi6_oif = oif;
826+ }
823827
824828 fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark);
825829 fl6.fl6_dport = t1->dest;
@@ -1225,7 +1229,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) · 399 unmodified lines
12251229 if (skb->protocol == htons(ETH_P_IP))
12261230 return tcp_v4_do_rcv(sk, skb);
12271231
1228− if (sk_filter(sk, skb))
1232+ if (tcp_filter(sk, skb))
12291233 goto discard;
12301234
12311235 /*
@@ -1453,8 +1457,10 @@ process: · 221 unmodified lines
14531457 if (tcp_v6_inbound_md5_hash(sk, skb))
14541458 goto discard_and_relse;
14551459
1456− if (sk_filter(sk, skb))
1460+ if (tcp_filter(sk, skb))
14571461 goto discard_and_relse;
1462+ th = (const struct tcphdr *)skb->data;
1463+ hdr = ipv6_hdr(skb);
14581464
14591465 skb->dev = NULL;
14601466
net/netfilter/ipvs/ip_vs_ctl.c+1−1
@@ -2845,7 +2845,7 @@ static struct genl_family ip_vs_genl_family = { · 2844 unmodified lines
28452845 .hdrsize = 0,
28462846 .name = IPVS_GENL_NAME,
28472847 .version = IPVS_GENL_VERSION,
2848− .maxattr = IPVS_CMD_MAX,
2848+ .maxattr = IPVS_CMD_ATTR_MAX,
28492849 .netnsok = true, /* Make ipvsadm to work on netns */
28502850 };
28512851
net/netfilter/ipvs/ip_vs_sync.c+5−2
@@ -283,6 +283,7 @@ struct ip_vs_sync_buff { · 282 unmodified lines
283283 */
284284 static void ntoh_seq(struct ip_vs_seq *no, struct ip_vs_seq *ho)
285285 {
286+ memset(ho, 0, sizeof(*ho));
286287 ho->init_seq = get_unaligned_be32(&no->init_seq);
287288 ho->delta = get_unaligned_be32(&no->delta);
288289 ho->previous_delta = get_unaligned_be32(&no->previous_delta);
@@ -917,8 +918,10 @@ static void ip_vs_proc_conn(struct netns_ipvs *ipvs, struct ip_vs_conn_param *pa · 628 unmodified lines
917918 kfree(param->pe_data);
918919 }
919920
920− if (opt)
921− memcpy(&cp->in_seq, opt, sizeof(*opt));
921+ if (opt) {
922+ cp->in_seq = opt->in_seq;
923+ cp->out_seq = opt->out_seq;
924+ }
922925 atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
923926 cp->state = state;
924927 cp->old_state = cp->state;
net/netfilter/nf_conntrack_core.c+41−8
@@ -76,6 +76,7 @@ struct conntrack_gc_work { · 75 unmodified lines
7676 struct delayed_work dwork;
7777 u32 last_bucket;
7878 bool exiting;
79+ long next_gc_run;
7980 };
8081
8182 static __read_mostly struct kmem_cache *nf_conntrack_cachep;
@@ -83,9 +84,11 @@ static __read_mostly spinlock_t nf_conntrack_locks_all_lock; · 1 unmodified line
8384 static __read_mostly DEFINE_SPINLOCK(nf_conntrack_locks_all_lock);
8485 static __read_mostly bool nf_conntrack_locks_all;
8586
87+/* every gc cycle scans at most 1/GC_MAX_BUCKETS_DIV part of table */
8688 #define GC_MAX_BUCKETS_DIV 64u
87−#define GC_MAX_BUCKETS 8192u
88−#define GC_INTERVAL (5 * HZ)
89+/* upper bound of scan intervals */
90+#define GC_INTERVAL_MAX (2 * HZ)
91+/* maximum conntracks to evict per gc run */
8992 #define GC_MAX_EVICTS 256u
9093
9194 static struct conntrack_gc_work conntrack_gc_work;
@@ -936,13 +939,13 @@ static noinline int early_drop(struct net *net, unsigned int _hash) · 844 unmodified lines
936939 static void gc_worker(struct work_struct *work)
937940 {
938941 unsigned int i, goal, buckets = 0, expired_count = 0;
939− unsigned long next_run = GC_INTERVAL;
940− unsigned int ratio, scanned = 0;
941942 struct conntrack_gc_work *gc_work;
943+ unsigned int ratio, scanned = 0;
944+ unsigned long next_run;
942945
943946 gc_work = container_of(work, struct conntrack_gc_work, dwork.work);
944947
945− goal = min(nf_conntrack_htable_size / GC_MAX_BUCKETS_DIV, GC_MAX_BUCKETS);
948+ goal = nf_conntrack_htable_size / GC_MAX_BUCKETS_DIV;
946949 i = gc_work->last_bucket;
947950
948951 do {
@@ -982,17 +985,47 @@ static void gc_worker(struct work_struct *work) · 33 unmodified lines
982985 if (gc_work->exiting)
983986 return;
984987
988+ /*
989+ * Eviction will normally happen from the packet path, and not
990+ * from this gc worker.
991+ *
992+ * This worker is only here to reap expired entries when system went
993+ * idle after a busy period.
994+ *
995+ * The heuristics below are supposed to balance conflicting goals:
996+ *
997+ * 1. Minimize time until we notice a stale entry
998+ * 2. Maximize scan intervals to not waste cycles
999+ *
1000+ * Normally, expired_count will be 0, this increases the next_run time
1001+ * to priorize 2) above.
1002+ *
1003+ * As soon as a timed-out entry is found, move towards 1) and increase
1004+ * the scan frequency.
1005+ * In case we have lots of evictions next scan is done immediately.
1006+ */
9851007 ratio = scanned ? expired_count * 100 / scanned : 0;
986− if (ratio >= 90 || expired_count == GC_MAX_EVICTS)
1008+ if (ratio >= 90 || expired_count == GC_MAX_EVICTS) {
1009+ gc_work->next_gc_run = 0;
9871010 next_run = 0;
1011+ } else if (expired_count) {
1012+ gc_work->next_gc_run /= 2U;
1013+ next_run = msecs_to_jiffies(1);
1014+ } else {
1015+ if (gc_work->next_gc_run < GC_INTERVAL_MAX)
1016+ gc_work->next_gc_run += msecs_to_jiffies(1);
1017+
1018+ next_run = gc_work->next_gc_run;
1019+ }
9881020
9891021 gc_work->last_bucket = i;
990− schedule_delayed_work(&gc_work->dwork, next_run);
1022+ queue_delayed_work(system_long_wq, &gc_work->dwork, next_run);
9911023 }
9921024
9931025 static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work)
9941026 {
9951027 INIT_DELAYED_WORK(&gc_work->dwork, gc_worker);
1028+ gc_work->next_gc_run = GC_INTERVAL_MAX;
9961029 gc_work->exiting = false;
9971030 }
9981031
@@ -1885,7 +1918,7 @@ int nf_conntrack_init_start(void) · 886 unmodified lines
18851918 nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED);
18861919
18871920 conntrack_gc_work_init(&conntrack_gc_work);
1888− schedule_delayed_work(&conntrack_gc_work.dwork, GC_INTERVAL);
1921+ queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, GC_INTERVAL_MAX);
18891922
18901923 return 0;
18911924
net/netfilter/nf_conntrack_helper.c+8−3
@@ -138,9 +138,14 @@ __nf_conntrack_helper_find(const char *name, u16 l3num, u8 protonum) · 137 unmodified lines
138138
139139 for (i = 0; i < nf_ct_helper_hsize; i++) {
140140 hlist_for_each_entry_rcu(h, &nf_ct_helper_hash[i], hnode) {
141− if (!strcmp(h->name, name) &&
142− h->tuple.src.l3num == l3num &&
143− h->tuple.dst.protonum == protonum)
141+ if (strcmp(h->name, name))
142+ continue;
143+
144+ if (h->tuple.src.l3num != NFPROTO_UNSPEC &&
145+ h->tuple.src.l3num != l3num)
146+ continue;
147+
148+ if (h->tuple.dst.protonum == protonum)
144149 return h;
145150 }
146151 }
net/netfilter/nf_conntrack_sip.c+4−1
@@ -1436,9 +1436,12 @@ static int process_sip_request(struct sk_buff *skb, unsigned int protoff, · 1435 unmodified lines
14361436 handler = &sip_handlers[i];
14371437 if (handler->request == NULL)
14381438 continue;
1439− if (*datalen < handler->len ||
1439+ if (*datalen < handler->len + 2 ||
14401440 strncasecmp(*dptr, handler->method, handler->len))
14411441 continue;
1442+ if ((*dptr)[handler->len] != ' ' ||
1443+ !isalpha((*dptr)[handler->len+1]))
1444+ continue;
14421445
14431446 if (ct_sip_get_header(ct, *dptr, 0, *datalen, SIP_HDR_CSEQ,
14441447 &matchoff, &matchlen) <= 0) {
net/netfilter/nf_tables_api.c+11−7
@@ -2956,12 +2956,14 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk, · 2955 unmodified lines
29562956
29572957 err = nft_trans_set_add(&ctx, NFT_MSG_NEWSET, set);
29582958 if (err < 0)
2959− goto err2;
2959+ goto err3;
29602960
29612961 list_add_tail_rcu(&set->list, &table->sets);
29622962 table->use++;
29632963 return 0;
29642964
2965+err3:
2966+ ops->destroy(set);
29652967 err2:
29662968 kfree(set);
29672969 err1:
@@ -3452,14 +3454,15 @@ void *nft_set_elem_init(const struct nft_set *set, · 484 unmodified lines
34523454 return elem;
34533455 }
34543456
3455−void nft_set_elem_destroy(const struct nft_set *set, void *elem)
3457+void nft_set_elem_destroy(const struct nft_set *set, void *elem,
3458+ bool destroy_expr)
34563459 {
34573460 struct nft_set_ext *ext = nft_set_elem_ext(set, elem);
34583461
34593462 nft_data_uninit(nft_set_ext_key(ext), NFT_DATA_VALUE);
34603463 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA))
34613464 nft_data_uninit(nft_set_ext_data(ext), set->dtype);
3462− if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPR))
3465+ if (destroy_expr && nft_set_ext_exists(ext, NFT_SET_EXT_EXPR))
34633466 nf_tables_expr_destroy(NULL, nft_set_ext_expr(ext));
34643467
34653468 kfree(elem);
@@ -3565,6 +3568,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, · 99 unmodified lines
35653568 dreg = nft_type_to_reg(set->dtype);
35663569 list_for_each_entry(binding, &set->bindings, list) {
35673570 struct nft_ctx bind_ctx = {
3571+ .net = ctx->net,
35683572 .afi = ctx->afi,
35693573 .table = ctx->table,
35703574 .chain = (struct nft_chain *)binding->chain,
@@ -3812,7 +3816,7 @@ void nft_set_gc_batch_release(struct rcu_head *rcu) · 241 unmodified lines
38123816
38133817 gcb = container_of(rcu, struct nft_set_gc_batch, head.rcu);
38143818 for (i = 0; i < gcb->head.cnt; i++)
3815− nft_set_elem_destroy(gcb->head.set, gcb->elems[i]);
3819+ nft_set_elem_destroy(gcb->head.set, gcb->elems[i], true);
38163820 kfree(gcb);
38173821 }
38183822 EXPORT_SYMBOL_GPL(nft_set_gc_batch_release);
@@ -4030,7 +4034,7 @@ static void nf_tables_commit_release(struct nft_trans *trans) · 211 unmodified lines
40304034 break;
40314035 case NFT_MSG_DELSETELEM:
40324036 nft_set_elem_destroy(nft_trans_elem_set(trans),
4033− nft_trans_elem(trans).priv);
4037+ nft_trans_elem(trans).priv, true);
40344038 break;
40354039 }
40364040 kfree(trans);
@@ -4171,7 +4175,7 @@ static void nf_tables_abort_release(struct nft_trans *trans) · 134 unmodified lines
41714175 break;
41724176 case NFT_MSG_NEWSETELEM:
41734177 nft_set_elem_destroy(nft_trans_elem_set(trans),
4174− nft_trans_elem(trans).priv);
4178+ nft_trans_elem(trans).priv, true);
41754179 break;
41764180 }
41774181 kfree(trans);
@@ -4421,7 +4425,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx, · 243 unmodified lines
44214425 * Otherwise a 0 is returned and the attribute value is stored in the
44224426 * destination variable.
44234427 */
4424−unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
4428+int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
44254429 {
44264430 u32 val;
44274431
net/netfilter/nft_dynset.c+13−6
@@ -44,18 +44,22 @@ static void *nft_dynset_new(struct nft_set *set, const struct nft_expr *expr, · 43 unmodified lines
4444 &regs->data[priv->sreg_key],
4545 &regs->data[priv->sreg_data],
4646 timeout, GFP_ATOMIC);
47− if (elem == NULL) {
48− if (set->size)
49− atomic_dec(&set->nelems);
50− return NULL;
51− }
47+ if (elem == NULL)
48+ goto err1;
5249
5350 ext = nft_set_elem_ext(set, elem);
5451 if (priv->expr != NULL &&
5552 nft_expr_clone(nft_set_ext_expr(ext), priv->expr) < 0)
56− return NULL;
53+ goto err2;
5754
5855 return elem;
56+
57+err2:
58+ nft_set_elem_destroy(set, elem, false);
59+err1:
60+ if (set->size)
61+ atomic_dec(&set->nelems);
62+ return NULL;
5963 }
6064
6165 static void nft_dynset_eval(const struct nft_expr *expr,
@@ -139,6 +143,9 @@ static int nft_dynset_init(const struct nft_ctx *ctx, · 77 unmodified lines
139143 return PTR_ERR(set);
140144 }
141145
146+ if (set->ops->update == NULL)
147+ return -EOPNOTSUPP;
148+
142149 if (set->flags & NFT_SET_CONSTANT)
143150 return -EBUSY;
144151
net/netfilter/nft_set_hash.c+14−5
@@ -98,7 +98,7 @@ static bool nft_hash_update(struct nft_set *set, const u32 *key, · 97 unmodified lines
9898 const struct nft_set_ext **ext)
9999 {
100100 struct nft_hash *priv = nft_set_priv(set);
101− struct nft_hash_elem *he;
101+ struct nft_hash_elem *he, *prev;
102102 struct nft_hash_cmp_arg arg = {
103103 .genmask = NFT_GENMASK_ANY,
104104 .set = set,
@@ -112,15 +112,24 @@ static bool nft_hash_update(struct nft_set *set, const u32 *key, · 7 unmodified lines
112112 he = new(set, expr, regs);
113113 if (he == NULL)
114114 goto err1;
115− if (rhashtable_lookup_insert_key(&priv->ht, &arg, &he->node,
116− nft_hash_params))
115+
116+ prev = rhashtable_lookup_get_insert_key(&priv->ht, &arg, &he->node,
117+ nft_hash_params);
118+ if (IS_ERR(prev))
117119 goto err2;
120+
121+ /* Another cpu may race to insert the element with the same key */
122+ if (prev) {
123+ nft_set_elem_destroy(set, he, true);
124+ he = prev;
125+ }
126+
118127 out:
119128 *ext = &he->ext;
120129 return true;
121130
122131 err2:
123− nft_set_elem_destroy(set, he);
132+ nft_set_elem_destroy(set, he, true);
124133 err1:
125134 return false;
126135 }
@@ -332,7 +341,7 @@ static int nft_hash_init(const struct nft_set *set, · 205 unmodified lines
332341
333342 static void nft_hash_elem_destroy(void *ptr, void *arg)
334343 {
335− nft_set_elem_destroy((const struct nft_set *)arg, ptr);
344+ nft_set_elem_destroy((const struct nft_set *)arg, ptr, true);
336345 }
337346
338347 static void nft_hash_destroy(const struct nft_set *set)
net/netfilter/nft_set_rbtree.c+1−1
@@ -266,7 +266,7 @@ static void nft_rbtree_destroy(const struct nft_set *set) · 265 unmodified lines
266266 while ((node = priv->root.rb_node) != NULL) {
267267 rb_erase(node, &priv->root);
268268 rbe = rb_entry(node, struct nft_rbtree_elem, node);
269− nft_set_elem_destroy(set, rbe);
269+ nft_set_elem_destroy(set, rbe, true);
270270 }
271271 }
272272
net/netfilter/xt_connmark.c+2−2
@@ -44,7 +44,7 @@ connmark_tg(struct sk_buff *skb, const struct xt_action_param *par) · 43 unmodified lines
4444 u_int32_t newmark;
4545
4646 ct = nf_ct_get(skb, &ctinfo);
47− if (ct == NULL)
47+ if (ct == NULL || nf_ct_is_untracked(ct))
4848 return XT_CONTINUE;
4949
5050 switch (info->mode) {
@@ -97,7 +97,7 @@ connmark_mt(const struct sk_buff *skb, struct xt_action_param *par) · 46 unmodified lines
9797 const struct nf_conn *ct;
9898
9999 ct = nf_ct_get(skb, &ctinfo);
100− if (ct == NULL)
100+ if (ct == NULL || nf_ct_is_untracked(ct))
101101 return false;
102102
103103 return ((ct->mark & info->mask) == info->mark) ^ info->invert;
net/netlink/diag.c+1−4
@@ -178,11 +178,8 @@ static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) · 177 unmodified lines
178178 }
179179 cb->args[1] = i;
180180 } else {
181− if (req->sdiag_protocol >= MAX_LINKS) {
182− read_unlock(&nl_table_lock);
183− rcu_read_unlock();
181+ if (req->sdiag_protocol >= MAX_LINKS)
184182 return -ENOENT;
185− }
186183
187184 err = __netlink_diag_dump(skb, cb, req->sdiag_protocol, s_num);
188185 }
net/netlink/genetlink.c+3−1
@@ -404,7 +404,7 @@ int __genl_register_family(struct genl_family *family) · 403 unmodified lines
404404
405405 err = genl_validate_assign_mc_groups(family);
406406 if (err)
407− goto errout_locked;
407+ goto errout_free;
408408
409409 list_add_tail(&family->family_list, genl_family_chain(family->id));
410410 genl_unlock_all();
@@ -417,6 +417,8 @@ int __genl_register_family(struct genl_family *family) · 6 unmodified lines
417417
418418 return 0;
419419
420+errout_free:
421+ kfree(family->attrbuf);
420422 errout_locked:
421423 genl_unlock_all();
422424 errout:
net/sctp/input.c+17−18
@@ -181,9 +181,10 @@ int sctp_rcv(struct sk_buff *skb) · 180 unmodified lines
181181 * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
182182 */
183183 if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) {
184− if (asoc) {
185− sctp_association_put(asoc);
184+ if (transport) {
185+ sctp_transport_put(transport);
186186 asoc = NULL;
187+ transport = NULL;
187188 } else {
188189 sctp_endpoint_put(ep);
189190 ep = NULL;
@@ -269,8 +270,8 @@ int sctp_rcv(struct sk_buff *skb) · 79 unmodified lines
269270 bh_unlock_sock(sk);
270271
271272 /* Release the asoc/ep ref we took in the lookup calls. */
272− if (asoc)
273− sctp_association_put(asoc);
273+ if (transport)
274+ sctp_transport_put(transport);
274275 else
275276 sctp_endpoint_put(ep);
276277
@@ -283,8 +284,8 @@ discard_it: · 6 unmodified lines
283284
284285 discard_release:
285286 /* Release the asoc/ep ref we took in the lookup calls. */
286− if (asoc)
287− sctp_association_put(asoc);
287+ if (transport)
288+ sctp_transport_put(transport);
288289 else
289290 sctp_endpoint_put(ep);
290291
@@ -300,6 +301,7 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb) · 9 unmodified lines
300301 {
301302 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
302303 struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
304+ struct sctp_transport *t = chunk->transport;
303305 struct sctp_ep_common *rcvr = NULL;
304306 int backloged = 0;
305307
@@ -351,7 +353,7 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb) · 45 unmodified lines
351353 done:
352354 /* Release the refs we took in sctp_add_backlog */
353355 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
354− sctp_association_put(sctp_assoc(rcvr));
356+ sctp_transport_put(t);
355357 else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
356358 sctp_endpoint_put(sctp_ep(rcvr));
357359 else
@@ -363,6 +365,7 @@ done: · 5 unmodified lines
363365 static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
364366 {
365367 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
368+ struct sctp_transport *t = chunk->transport;
366369 struct sctp_ep_common *rcvr = chunk->rcvr;
367370 int ret;
368371
@@ -373,7 +376,7 @@ static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb) · 4 unmodified lines
373376 * from us
374377 */
375378 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
376− sctp_association_hold(sctp_assoc(rcvr));
379+ sctp_transport_hold(t);
377380 else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
378381 sctp_endpoint_hold(sctp_ep(rcvr));
379382 else
@@ -537,15 +540,15 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb, · 157 unmodified lines
537540 return sk;
538541
539542 out:
540− sctp_association_put(asoc);
543+ sctp_transport_put(transport);
541544 return NULL;
542545 }
543546
544547 /* Common cleanup code for icmp/icmpv6 error handler. */
545−void sctp_err_finish(struct sock *sk, struct sctp_association *asoc)
548+void sctp_err_finish(struct sock *sk, struct sctp_transport *t)
546549 {
547550 bh_unlock_sock(sk);
548− sctp_association_put(asoc);
551+ sctp_transport_put(t);
549552 }
550553
551554 /*
@@ -641,7 +644,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) · 89 unmodified lines
641644 }
642645
643646 out_unlock:
644− sctp_err_finish(sk, asoc);
647+ sctp_err_finish(sk, transport);
645648 }
646649
647650 /*
@@ -952,11 +955,8 @@ static struct sctp_association *__sctp_lookup_association( · 304 unmodified lines
952955 goto out;
953956
954957 asoc = t->asoc;
955− sctp_association_hold(asoc);
956958 *pt = t;
957959
958− sctp_transport_put(t);
959−
960960 out:
961961 return asoc;
962962 }
@@ -986,7 +986,7 @@ int sctp_has_association(struct net *net, · 23 unmodified lines
986986 struct sctp_transport *transport;
987987
988988 if ((asoc = sctp_lookup_association(net, laddr, paddr, &transport))) {
989− sctp_association_put(asoc);
989+ sctp_transport_put(transport);
990990 return 1;
991991 }
992992
@@ -1021,7 +1021,6 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net, · 28 unmodified lines
10211021 struct sctphdr *sh = sctp_hdr(skb);
10221022 union sctp_params params;
10231023 sctp_init_chunk_t *init;
1024− struct sctp_transport *transport;
10251024 struct sctp_af *af;
10261025
10271026 /*
@@ -1052,7 +1051,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net, · 24 unmodified lines
10521051
10531052 af->from_addr_param(paddr, params.addr, sh->source, 0);
10541053
1055− asoc = __sctp_lookup_association(net, laddr, paddr, &transport);
1054+ asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
10561055 if (asoc)
10571056 return asoc;
10581057 }
net/sctp/ipv6.c+1−1
@@ -198,7 +198,7 @@ static void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 197 unmodified lines
198198 }
199199
200200 out_unlock:
201− sctp_err_finish(sk, asoc);
201+ sctp_err_finish(sk, transport);
202202 out:
203203 if (likely(idev != NULL))
204204 in6_dev_put(idev);
net/sctp/socket.c+13−14
@@ -1214,9 +1214,12 @@ static int __sctp_connect(struct sock *sk, · 1213 unmodified lines
12141214
12151215 timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK);
12161216
1217− err = sctp_wait_for_connect(asoc, &timeo);
1218− if ((err == 0 || err == -EINPROGRESS) && assoc_id)
1217+ if (assoc_id)
12191218 *assoc_id = asoc->assoc_id;
1219+ err = sctp_wait_for_connect(asoc, &timeo);
1220+ /* Note: the asoc may be freed after the return of
1221+ * sctp_wait_for_connect.
1222+ */
12201223
12211224 /* Don't free association on exit. */
12221225 asoc = NULL;
@@ -4282,19 +4285,18 @@ static void sctp_shutdown(struct sock *sk, int how) · 3059 unmodified lines
42824285 {
42834286 struct net *net = sock_net(sk);
42844287 struct sctp_endpoint *ep;
4285− struct sctp_association *asoc;
42864288
42874289 if (!sctp_style(sk, TCP))
42884290 return;
42894291
4290− if (how & SEND_SHUTDOWN) {
4292+ ep = sctp_sk(sk)->ep;
4293+ if (how & SEND_SHUTDOWN && !list_empty(&ep->asocs)) {
4294+ struct sctp_association *asoc;
4295+
42914296 sk->sk_state = SCTP_SS_CLOSING;
4292− ep = sctp_sk(sk)->ep;
4293− if (!list_empty(&ep->asocs)) {
4294− asoc = list_entry(ep->asocs.next,
4295− struct sctp_association, asocs);
4296− sctp_primitive_SHUTDOWN(net, asoc, NULL);
4297− }
4297+ asoc = list_entry(ep->asocs.next,
4298+ struct sctp_association, asocs);
4299+ sctp_primitive_SHUTDOWN(net, asoc, NULL);
42984300 }
42994301 }
43004302
@@ -4480,12 +4482,9 @@ int sctp_transport_lookup_process(int (*cb)(struct sctp_transport *, void *), · 179 unmodified lines
44804482 if (!transport || !sctp_transport_hold(transport))
44814483 goto out;
44824484
4483− sctp_association_hold(transport->asoc);
4484− sctp_transport_put(transport);
4485−
44864485 rcu_read_unlock();
44874486 err = cb(transport, p);
4488− sctp_association_put(transport->asoc);
4487+ sctp_transport_put(transport);
44894488
44904489 out:
44914490 return err;
net/socket.c+2−0
@@ -2038,6 +2038,8 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, · 2037 unmodified lines
20382038 if (err)
20392039 break;
20402040 ++datagrams;
2041+ if (msg_data_left(&msg_sys))
2042+ break;
20412043 cond_resched();
20422044 }
20432045
net/unix/af_unix.c+2−1
@@ -2812,7 +2812,8 @@ static int unix_seq_show(struct seq_file *seq, void *v) · 2811 unmodified lines
28122812 i++;
28132813 }
28142814 for ( ; i < len; i++)
2815− seq_putc(seq, u->addr->name->sun_path[i]);
2815+ seq_putc(seq, u->addr->name->sun_path[i] ?:
2816+ '@');
28162817 }
28172818 unix_state_unlock(s);
28182819 seq_putc(seq, '\n');
samples/bpf/Makefile+4−0
@@ -27,6 +27,7 @@ hostprogs-y += xdp2 · 26 unmodified lines
2727 hostprogs-y += test_current_task_under_cgroup
2828 hostprogs-y += trace_event
2929 hostprogs-y += sampleip
30+hostprogs-y += tc_l2_redirect
3031
3132 test_verifier-objs := test_verifier.o libbpf.o
3233 test_maps-objs := test_maps.o libbpf.o
@@ -56,6 +57,7 @@ test_current_task_under_cgroup-objs := bpf_load.o libbpf.o \ · 23 unmodified lines
5657 test_current_task_under_cgroup_user.o
5758 trace_event-objs := bpf_load.o libbpf.o trace_event_user.o
5859 sampleip-objs := bpf_load.o libbpf.o sampleip_user.o
60+tc_l2_redirect-objs := bpf_load.o libbpf.o tc_l2_redirect_user.o
5961
6062 # Tell kbuild to always build the programs
6163 always := $(hostprogs-y)
@@ -72,6 +74,7 @@ always += test_probe_write_user_kern.o · 10 unmodified lines
7274 always += trace_output_kern.o
7375 always += tcbpf1_kern.o
7476 always += tcbpf2_kern.o
77+always += tc_l2_redirect_kern.o
7578 always += lathist_kern.o
7679 always += offwaketime_kern.o
7780 always += spintest_kern.o
@@ -111,6 +114,7 @@ HOSTLOADLIBES_xdp2 += -lelf · 33 unmodified lines
111114 HOSTLOADLIBES_test_current_task_under_cgroup += -lelf
112115 HOSTLOADLIBES_trace_event += -lelf
113116 HOSTLOADLIBES_sampleip += -lelf
117+HOSTLOADLIBES_tc_l2_redirect += -l elf
114118
115119 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
116120 # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
samples/bpf/tc_l2_redirect.sh+173−0
@@ -0,0 +1,173 @@
1+#!/bin/bash
2+
3+[[ -z $TC ]] && TC='tc'
4+[[ -z $IP ]] && IP='ip'
5+
6+REDIRECT_USER='./tc_l2_redirect'
7+REDIRECT_BPF='./tc_l2_redirect_kern.o'
8+
9+RP_FILTER=$(< /proc/sys/net/ipv4/conf/all/rp_filter)
10+IPV6_FORWARDING=$(< /proc/sys/net/ipv6/conf/all/forwarding)
11+
12+function config_common {
13+ local tun_type=$1
14+
15+ $IP netns add ns1
16+ $IP netns add ns2
17+ $IP link add ve1 type veth peer name vens1
18+ $IP link add ve2 type veth peer name vens2
19+ $IP link set dev ve1 up
20+ $IP link set dev ve2 up
21+ $IP link set dev ve1 mtu 1500
22+ $IP link set dev ve2 mtu 1500
23+ $IP link set dev vens1 netns ns1
24+ $IP link set dev vens2 netns ns2
25+
26+ $IP -n ns1 link set dev lo up
27+ $IP -n ns1 link set dev vens1 up
28+ $IP -n ns1 addr add 10.1.1.101/24 dev vens1
29+ $IP -n ns1 addr add 2401:db01::65/64 dev vens1 nodad
30+ $IP -n ns1 route add default via 10.1.1.1 dev vens1
31+ $IP -n ns1 route add default via 2401:db01::1 dev vens1
32+
33+ $IP -n ns2 link set dev lo up
34+ $IP -n ns2 link set dev vens2 up
35+ $IP -n ns2 addr add 10.2.1.102/24 dev vens2
36+ $IP -n ns2 addr add 2401:db02::66/64 dev vens2 nodad
37+ $IP -n ns2 addr add 10.10.1.102 dev lo
38+ $IP -n ns2 addr add 2401:face::66/64 dev lo nodad
39+ $IP -n ns2 link add ipt2 type ipip local 10.2.1.102 remote 10.2.1.1
40+ $IP -n ns2 link add ip6t2 type ip6tnl mode any local 2401:db02::66 remote 2401:db02::1
41+ $IP -n ns2 link set dev ipt2 up
42+ $IP -n ns2 link set dev ip6t2 up
43+ $IP netns exec ns2 $TC qdisc add dev vens2 clsact
44+ $IP netns exec ns2 $TC filter add dev vens2 ingress bpf da obj $REDIRECT_BPF sec drop_non_tun_vip
45+ if [[ $tun_type == "ipip" ]]; then
46+ $IP -n ns2 route add 10.1.1.0/24 dev ipt2
47+ $IP netns exec ns2 sysctl -q -w net.ipv4.conf.all.rp_filter=0
48+ $IP netns exec ns2 sysctl -q -w net.ipv4.conf.ipt2.rp_filter=0
49+ else
50+ $IP -n ns2 route add 10.1.1.0/24 dev ip6t2
51+ $IP -n ns2 route add 2401:db01::/64 dev ip6t2
52+ $IP netns exec ns2 sysctl -q -w net.ipv4.conf.all.rp_filter=0
53+ $IP netns exec ns2 sysctl -q -w net.ipv4.conf.ip6t2.rp_filter=0
54+ fi
55+
56+ $IP addr add 10.1.1.1/24 dev ve1
57+ $IP addr add 2401:db01::1/64 dev ve1 nodad
58+ $IP addr add 10.2.1.1/24 dev ve2
59+ $IP addr add 2401:db02::1/64 dev ve2 nodad
60+
61+ $TC qdisc add dev ve2 clsact
62+ $TC filter add dev ve2 ingress bpf da obj $REDIRECT_BPF sec l2_to_iptun_ingress_forward
63+
64+ sysctl -q -w net.ipv4.conf.all.rp_filter=0
65+ sysctl -q -w net.ipv6.conf.all.forwarding=1
66+}
67+
68+function cleanup {
69+ set +e
70+ [[ -z $DEBUG ]] || set +x
71+ $IP netns delete ns1 >& /dev/null
72+ $IP netns delete ns2 >& /dev/null
73+ $IP link del ve1 >& /dev/null
74+ $IP link del ve2 >& /dev/null
75+ $IP link del ipt >& /dev/null
76+ $IP link del ip6t >& /dev/null
77+ sysctl -q -w net.ipv4.conf.all.rp_filter=$RP_FILTER
78+ sysctl -q -w net.ipv6.conf.all.forwarding=$IPV6_FORWARDING
79+ rm -f /sys/fs/bpf/tc/globals/tun_iface
80+ [[ -z $DEBUG ]] || set -x
81+ set -e
82+}
83+
84+function l2_to_ipip {
85+ echo -n "l2_to_ipip $1: "
86+
87+ local dir=$1
88+
89+ config_common ipip
90+
91+ $IP link add ipt type ipip external
92+ $IP link set dev ipt up
93+ sysctl -q -w net.ipv4.conf.ipt.rp_filter=0
94+ sysctl -q -w net.ipv4.conf.ipt.forwarding=1
95+
96+ if [[ $dir == "egress" ]]; then
97+ $IP route add 10.10.1.0/24 via 10.2.1.102 dev ve2
98+ $TC filter add dev ve2 egress bpf da obj $REDIRECT_BPF sec l2_to_iptun_ingress_redirect
99+ sysctl -q -w net.ipv4.conf.ve1.forwarding=1
100+ else
101+ $TC qdisc add dev ve1 clsact
102+ $TC filter add dev ve1 ingress bpf da obj $REDIRECT_BPF sec l2_to_iptun_ingress_redirect
103+ fi
104+
105+ $REDIRECT_USER -U /sys/fs/bpf/tc/globals/tun_iface -i $(< /sys/class/net/ipt/ifindex)
106+
107+ $IP netns exec ns1 ping -c1 10.10.1.102 >& /dev/null
108+
109+ if [[ $dir == "egress" ]]; then
110+ # test direct egress to ve2 (i.e. not forwarding from
111+ # ve1 to ve2).
112+ ping -c1 10.10.1.102 >& /dev/null
113+ fi
114+
115+ cleanup
116+
117+ echo "OK"
118+}
119+
120+function l2_to_ip6tnl {
121+ echo -n "l2_to_ip6tnl $1: "
122+
123+ local dir=$1
124+
125+ config_common ip6tnl
126+
127+ $IP link add ip6t type ip6tnl mode any external
128+ $IP link set dev ip6t up
129+ sysctl -q -w net.ipv4.conf.ip6t.rp_filter=0
130+ sysctl -q -w net.ipv4.conf.ip6t.forwarding=1
131+
132+ if [[ $dir == "egress" ]]; then
133+ $IP route add 10.10.1.0/24 via 10.2.1.102 dev ve2
134+ $IP route add 2401:face::/64 via 2401:db02::66 dev ve2
135+ $TC filter add dev ve2 egress bpf da obj $REDIRECT_BPF sec l2_to_ip6tun_ingress_redirect
136+ sysctl -q -w net.ipv4.conf.ve1.forwarding=1
137+ else
138+ $TC qdisc add dev ve1 clsact
139+ $TC filter add dev ve1 ingress bpf da obj $REDIRECT_BPF sec l2_to_ip6tun_ingress_redirect
140+ fi
141+
142+ $REDIRECT_USER -U /sys/fs/bpf/tc/globals/tun_iface -i $(< /sys/class/net/ip6t/ifindex)
143+
144+ $IP netns exec ns1 ping -c1 10.10.1.102 >& /dev/null
145+ $IP netns exec ns1 ping -6 -c1 2401:face::66 >& /dev/null
146+
147+ if [[ $dir == "egress" ]]; then
148+ # test direct egress to ve2 (i.e. not forwarding from
149+ # ve1 to ve2).
150+ ping -c1 10.10.1.102 >& /dev/null
151+ ping -6 -c1 2401:face::66 >& /dev/null
152+ fi
153+
154+ cleanup
155+
156+ echo "OK"
157+}
158+
159+cleanup
160+test_names="l2_to_ipip l2_to_ip6tnl"
161+test_dirs="ingress egress"
162+if [[ $# -ge 2 ]]; then
163+ test_names=$1
164+ test_dirs=$2
165+elif [[ $# -ge 1 ]]; then
166+ test_names=$1
167+fi
168+
169+for t in $test_names; do
170+ for d in $test_dirs; do
171+ $t $d
172+ done
173+done
samples/bpf/tc_l2_redirect_kern.c+236−0
@@ -0,0 +1,236 @@
1+/* Copyright (c) 2016 Facebook
2+ *
3+ * This program is free software; you can redistribute it and/or
4+ * modify it under the terms of version 2 of the GNU General Public
5+ * License as published by the Free Software Foundation.
6+ */
7+#include <uapi/linux/bpf.h>
8+#include <uapi/linux/if_ether.h>
9+#include <uapi/linux/if_packet.h>
10+#include <uapi/linux/ip.h>
11+#include <uapi/linux/ipv6.h>
12+#include <uapi/linux/in.h>
13+#include <uapi/linux/tcp.h>
14+#include <uapi/linux/filter.h>
15+#include <uapi/linux/pkt_cls.h>
16+#include <net/ipv6.h>
17+#include "bpf_helpers.h"
18+
19+#define _htonl __builtin_bswap32
20+
21+#define PIN_GLOBAL_NS 2
22+struct bpf_elf_map {
23+ __u32 type;
24+ __u32 size_key;
25+ __u32 size_value;
26+ __u32 max_elem;
27+ __u32 flags;
28+ __u32 id;
29+ __u32 pinning;
30+};
31+
32+/* copy of 'struct ethhdr' without __packed */
33+struct eth_hdr {
34+ unsigned char h_dest[ETH_ALEN];
35+ unsigned char h_source[ETH_ALEN];
36+ unsigned short h_proto;
37+};
38+
39+struct bpf_elf_map SEC("maps") tun_iface = {
40+ .type = BPF_MAP_TYPE_ARRAY,
41+ .size_key = sizeof(int),
42+ .size_value = sizeof(int),
43+ .pinning = PIN_GLOBAL_NS,
44+ .max_elem = 1,
45+};
46+
47+static __always_inline bool is_vip_addr(__be16 eth_proto, __be32 daddr)
48+{
49+ if (eth_proto == htons(ETH_P_IP))
50+ return (_htonl(0xffffff00) & daddr) == _htonl(0x0a0a0100);
51+ else if (eth_proto == htons(ETH_P_IPV6))
52+ return (daddr == _htonl(0x2401face));
53+
54+ return false;
55+}
56+
57+SEC("l2_to_iptun_ingress_forward")
58+int _l2_to_iptun_ingress_forward(struct __sk_buff *skb)
59+{
60+ struct bpf_tunnel_key tkey = {};
61+ void *data = (void *)(long)skb->data;
62+ struct eth_hdr *eth = data;
63+ void *data_end = (void *)(long)skb->data_end;
64+ int key = 0, *ifindex;
65+
66+ int ret;
67+
68+ if (data + sizeof(*eth) > data_end)
69+ return TC_ACT_OK;
70+
71+ ifindex = bpf_map_lookup_elem(&tun_iface, &key);
72+ if (!ifindex)
73+ return TC_ACT_OK;
74+
75+ if (eth->h_proto == htons(ETH_P_IP)) {
76+ char fmt4[] = "ingress forward to ifindex:%d daddr4:%x\n";
77+ struct iphdr *iph = data + sizeof(*eth);
78+
79+ if (data + sizeof(*eth) + sizeof(*iph) > data_end)
80+ return TC_ACT_OK;
81+
82+ if (iph->protocol != IPPROTO_IPIP)
83+ return TC_ACT_OK;
84+
85+ bpf_trace_printk(fmt4, sizeof(fmt4), *ifindex,
86+ _htonl(iph->daddr));
87+ return bpf_redirect(*ifindex, BPF_F_INGRESS);
88+ } else if (eth->h_proto == htons(ETH_P_IPV6)) {
89+ char fmt6[] = "ingress forward to ifindex:%d daddr6:%x::%x\n";
90+ struct ipv6hdr *ip6h = data + sizeof(*eth);
91+
92+ if (data + sizeof(*eth) + sizeof(*ip6h) > data_end)
93+ return TC_ACT_OK;
94+
95+ if (ip6h->nexthdr != IPPROTO_IPIP &&
96+ ip6h->nexthdr != IPPROTO_IPV6)
97+ return TC_ACT_OK;
98+
99+ bpf_trace_printk(fmt6, sizeof(fmt6), *ifindex,
100+ _htonl(ip6h->daddr.s6_addr32[0]),
101+ _htonl(ip6h->daddr.s6_addr32[3]));
102+ return bpf_redirect(*ifindex, BPF_F_INGRESS);
103+ }
104+
105+ return TC_ACT_OK;
106+}
107+
108+SEC("l2_to_iptun_ingress_redirect")
109+int _l2_to_iptun_ingress_redirect(struct __sk_buff *skb)
110+{
111+ struct bpf_tunnel_key tkey = {};
112+ void *data = (void *)(long)skb->data;
113+ struct eth_hdr *eth = data;
114+ void *data_end = (void *)(long)skb->data_end;
115+ int key = 0, *ifindex;
116+
117+ int ret;
118+
119+ if (data + sizeof(*eth) > data_end)
120+ return TC_ACT_OK;
121+
122+ ifindex = bpf_map_lookup_elem(&tun_iface, &key);
123+ if (!ifindex)
124+ return TC_ACT_OK;
125+
126+ if (eth->h_proto == htons(ETH_P_IP)) {
127+ char fmt4[] = "e/ingress redirect daddr4:%x to ifindex:%d\n";
128+ struct iphdr *iph = data + sizeof(*eth);
129+ __be32 daddr = iph->daddr;
130+
131+ if (data + sizeof(*eth) + sizeof(*iph) > data_end)
132+ return TC_ACT_OK;
133+
134+ if (!is_vip_addr(eth->h_proto, daddr))
135+ return TC_ACT_OK;
136+
137+ bpf_trace_printk(fmt4, sizeof(fmt4), _htonl(daddr), *ifindex);
138+ } else {
139+ return TC_ACT_OK;
140+ }
141+
142+ tkey.tunnel_id = 10000;
143+ tkey.tunnel_ttl = 64;
144+ tkey.remote_ipv4 = 0x0a020166; /* 10.2.1.102 */
145+ bpf_skb_set_tunnel_key(skb, &tkey, sizeof(tkey), 0);
146+ return bpf_redirect(*ifindex, 0);
147+}
148+
149+SEC("l2_to_ip6tun_ingress_redirect")
150+int _l2_to_ip6tun_ingress_redirect(struct __sk_buff *skb)
151+{
152+ struct bpf_tunnel_key tkey = {};
153+ void *data = (void *)(long)skb->data;
154+ struct eth_hdr *eth = data;
155+ void *data_end = (void *)(long)skb->data_end;
156+ int key = 0, *ifindex;
157+
158+ if (data + sizeof(*eth) > data_end)
159+ return TC_ACT_OK;
160+
161+ ifindex = bpf_map_lookup_elem(&tun_iface, &key);
162+ if (!ifindex)
163+ return TC_ACT_OK;
164+
165+ if (eth->h_proto == htons(ETH_P_IP)) {
166+ char fmt4[] = "e/ingress redirect daddr4:%x to ifindex:%d\n";
167+ struct iphdr *iph = data + sizeof(*eth);
168+
169+ if (data + sizeof(*eth) + sizeof(*iph) > data_end)
170+ return TC_ACT_OK;
171+
172+ if (!is_vip_addr(eth->h_proto, iph->daddr))
173+ return TC_ACT_OK;
174+
175+ bpf_trace_printk(fmt4, sizeof(fmt4), _htonl(iph->daddr),
176+ *ifindex);
177+ } else if (eth->h_proto == htons(ETH_P_IPV6)) {
178+ char fmt6[] = "e/ingress redirect daddr6:%x to ifindex:%d\n";
179+ struct ipv6hdr *ip6h = data + sizeof(*eth);
180+
181+ if (data + sizeof(*eth) + sizeof(*ip6h) > data_end)
182+ return TC_ACT_OK;
183+
184+ if (!is_vip_addr(eth->h_proto, ip6h->daddr.s6_addr32[0]))
185+ return TC_ACT_OK;
186+
187+ bpf_trace_printk(fmt6, sizeof(fmt6),
188+ _htonl(ip6h->daddr.s6_addr32[0]), *ifindex);
189+ } else {
190+ return TC_ACT_OK;
191+ }
192+
193+ tkey.tunnel_id = 10000;
194+ tkey.tunnel_ttl = 64;
195+ /* 2401:db02:0:0:0:0:0:66 */
196+ tkey.remote_ipv6[0] = _htonl(0x2401db02);
197+ tkey.remote_ipv6[1] = 0;
198+ tkey.remote_ipv6[2] = 0;
199+ tkey.remote_ipv6[3] = _htonl(0x00000066);
200+ bpf_skb_set_tunnel_key(skb, &tkey, sizeof(tkey), BPF_F_TUNINFO_IPV6);
201+ return bpf_redirect(*ifindex, 0);
202+}
203+
204+SEC("drop_non_tun_vip")
205+int _drop_non_tun_vip(struct __sk_buff *skb)
206+{
207+ struct bpf_tunnel_key tkey = {};
208+ void *data = (void *)(long)skb->data;
209+ struct eth_hdr *eth = data;
210+ void *data_end = (void *)(long)skb->data_end;
211+
212+ if (data + sizeof(*eth) > data_end)
213+ return TC_ACT_OK;
214+
215+ if (eth->h_proto == htons(ETH_P_IP)) {
216+ struct iphdr *iph = data + sizeof(*eth);
217+
218+ if (data + sizeof(*eth) + sizeof(*iph) > data_end)
219+ return TC_ACT_OK;
220+
221+ if (is_vip_addr(eth->h_proto, iph->daddr))
222+ return TC_ACT_SHOT;
223+ } else if (eth->h_proto == htons(ETH_P_IPV6)) {
224+ struct ipv6hdr *ip6h = data + sizeof(*eth);
225+
226+ if (data + sizeof(*eth) + sizeof(*ip6h) > data_end)
227+ return TC_ACT_OK;
228+
229+ if (is_vip_addr(eth->h_proto, ip6h->daddr.s6_addr32[0]))
230+ return TC_ACT_SHOT;
231+ }
232+
233+ return TC_ACT_OK;
234+}
235+
236+char _license[] SEC("license") = "GPL";
samples/bpf/tc_l2_redirect_user.c+73−0
@@ -0,0 +1,73 @@
1+/* Copyright (c) 2016 Facebook
2+ *
3+ * This program is free software; you can redistribute it and/or
4+ * modify it under the terms of version 2 of the GNU General Public
5+ * License as published by the Free Software Foundation.
6+ */
7+#include <linux/unistd.h>
8+#include <linux/bpf.h>
9+
10+#include <stdlib.h>
11+#include <stdio.h>
12+#include <unistd.h>
13+#include <string.h>
14+#include <errno.h>
15+
16+#include "libbpf.h"
17+
18+static void usage(void)
19+{
20+ printf("Usage: tc_l2_ipip_redirect [...]\n");
21+ printf(" -U <file> Update an already pinned BPF array\n");
22+ printf(" -i <ifindex> Interface index\n");
23+ printf(" -h Display this help\n");
24+}
25+
26+int main(int argc, char **argv)
27+{
28+ const char *pinned_file = NULL;
29+ int ifindex = -1;
30+ int array_key = 0;
31+ int array_fd = -1;
32+ int ret = -1;
33+ int opt;
34+
35+ while ((opt = getopt(argc, argv, "F:U:i:")) != -1) {
36+ switch (opt) {
37+ /* General args */
38+ case 'U':
39+ pinned_file = optarg;
40+ break;
41+ case 'i':
42+ ifindex = atoi(optarg);
43+ break;
44+ default:
45+ usage();
46+ goto out;
47+ }
48+ }
49+
50+ if (ifindex < 0 || !pinned_file) {
51+ usage();
52+ goto out;
53+ }
54+
55+ array_fd = bpf_obj_get(pinned_file);
56+ if (array_fd < 0) {
57+ fprintf(stderr, "bpf_obj_get(%s): %s(%d)\n",
58+ pinned_file, strerror(errno), errno);
59+ goto out;
60+ }
61+
62+ /* bpf_tunnel_key.remote_ipv4 expects host byte orders */
63+ ret = bpf_update_elem(array_fd, &array_key, &ifindex, 0);
64+ if (ret) {
65+ perror("bpf_update_elem");
66+ goto out;
67+ }
68+
69+out:
70+ if (array_fd != -1)
71+ close(array_fd);
72+ return ret;
73+}