aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-27 15:54:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-27 15:54:16 -0500
commit1b1bc42c1692e9b62756323c675a44cb1a1f9dbd (patch)
treed514a2d8512fc52c15747841e2368f8f99a50787
parent3365135d43f861003555c963b309672d053a2228 (diff)
parent950eabbd6ddedc1b08350b9169a6a51b130ebaaf (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) GTP fixes from Andreas Schultz (missing genl module alias, clear IP DF on transmit). 2) Netfilter needs to reflect the fwmark when sending resets, from Pau Espin Pedrol. 3) nftable dump OOPS fix from Liping Zhang. 4) Fix erroneous setting of VIRTIO_NET_HDR_F_DATA_VALID on transmit, from Rolf Neugebauer. 5) Fix build error of ipt_CLUSTERIP when procfs is disabled, from Arnd Bergmann. 6) Fix regression in handling of NETIF_F_SG in harmonize_features(), from Eric Dumazet. 7) Fix RTNL deadlock wrt. lwtunnel module loading, from David Ahern. 8) tcp_fastopen_create_child() needs to setup tp->max_window, from Alexey Kodanev. 9) Missing kmemdup() failure check in ipv6 segment routing code, from Eric Dumazet. 10) Don't execute unix_bind() under the bindlock, otherwise we deadlock with splice. From WANG Cong. 11) ip6_tnl_parse_tlv_enc_lim() potentially reallocates the skb buffer, therefore callers must reload cached header pointers into that skb. Fix from Eric Dumazet. 12) Fix various bugs in legacy IRQ fallback handling in alx driver, from Tobias Regnery. 13) Do not allow lwtunnel drivers to be unloaded while they are referenced by active instances, from Robert Shearman. 14) Fix truncated PHY LED trigger names, from Geert Uytterhoeven. 15) Fix a few regressions from virtio_net XDP support, from John Fastabend and Jakub Kicinski. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (102 commits) ISDN: eicon: silence misleading array-bounds warning net: phy: micrel: add support for KSZ8795 gtp: fix cross netns recv on gtp socket gtp: clear DF bit on GTP packet tx gtp: add genl family modules alias tcp: don't annotate mark on control socket from tcp_v6_send_response() ravb: unmap descriptors when freeing rings virtio_net: reject XDP programs using header adjustment virtio_net: use dev_kfree_skb for small buffer XDP receive r8152: check rx after napi is enabled r8152: re-schedule napi for tx r8152: avoid start_xmit to schedule napi when napi is disabled r8152: avoid start_xmit to call napi_schedule during autosuspend net: dsa: Bring back device detaching in dsa_slave_suspend() net: phy: leds: Fix truncated LED trigger names net: phy: leds: Break dependency of phy.h on phy_led_triggers.h net: phy: leds: Clear phy_num_led_triggers on failure to avoid crash net-next: ethernet: mediatek: change the compatible string Documentation: devicetree: change the mediatek ethernet compatible string bnxt_en: Fix RTNL lock usage on bnxt_get_port_module_status(). ...
-rw-r--r--Documentation/devicetree/bindings/net/mediatek-net.txt2
-rw-r--r--Documentation/devicetree/bindings/net/phy.txt5
-rw-r--r--MAINTAINERS2
-rw-r--r--drivers/isdn/hardware/eicon/message.c3
-rw-r--r--drivers/net/can/c_can/c_can_pci.c1
-rw-r--r--drivers/net/can/ti_hecc.c16
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-common.h2
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-dev.c8
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c4
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-pci.c15
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe.h2
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c11
-rw-r--r--drivers/net/ethernet/broadcom/bcm63xx_enet.c6
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c80
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c2
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.c7
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c10
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_ll2.c88
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_ll2.h24
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_roce.c2
-rw-r--r--drivers/net/ethernet/renesas/ravb_main.c112
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
-rw-r--r--drivers/net/gtp.c13
-rw-r--r--drivers/net/macvtap.c2
-rw-r--r--drivers/net/phy/bcm63xx.c21
-rw-r--r--drivers/net/phy/dp83848.c3
-rw-r--r--drivers/net/phy/marvell.c2
-rw-r--r--drivers/net/phy/micrel.c14
-rw-r--r--drivers/net/phy/phy.c15
-rw-r--r--drivers/net/phy/phy_led_triggers.c9
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/net/usb/cdc_ether.c8
-rw-r--r--drivers/net/usb/qmi_wwan.c7
-rw-r--r--drivers/net/usb/r8152.c34
-rw-r--r--drivers/net/virtio_net.c25
-rw-r--r--drivers/net/vxlan.c12
-rw-r--r--drivers/net/xen-netback/interface.c6
-rw-r--r--drivers/net/xen-netback/xenbus.c13
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--include/linux/bpf.h2
-rw-r--r--include/linux/micrel_phy.h2
-rw-r--r--include/linux/phy.h1
-rw-r--r--include/linux/phy_led_triggers.h4
-rw-r--r--include/linux/virtio_net.h6
-rw-r--r--include/net/ipv6.h2
-rw-r--r--include/net/lwtunnel.h13
-rw-r--r--include/net/netfilter/nf_tables.h6
-rw-r--r--include/net/netfilter/nft_fib.h6
-rw-r--r--include/uapi/linux/netfilter/nf_log.h2
-rw-r--r--include/uapi/linux/netfilter/nf_tables.h4
-rw-r--r--kernel/bpf/arraymap.c18
-rw-r--r--kernel/bpf/hashtab.c22
-rw-r--r--kernel/bpf/stackmap.c20
-rw-r--r--kernel/bpf/syscall.c26
-rw-r--r--net/batman-adv/fragmentation.c10
-rw-r--r--net/bridge/br_netlink.c33
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/ethtool.c2
-rw-r--r--net/core/lwt_bpf.c1
-rw-r--r--net/core/lwtunnel.c66
-rw-r--r--net/dccp/ipv6.c4
-rw-r--r--net/dsa/slave.c8
-rw-r--r--net/ipv4/fib_frontend.c8
-rw-r--r--net/ipv4/ip_output.c1
-rw-r--r--net/ipv4/ip_tunnel_core.c2
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c7
-rw-r--r--net/ipv4/netfilter/ipt_rpfilter.c8
-rw-r--r--net/ipv4/netfilter/nf_reject_ipv4.c2
-rw-r--r--net/ipv4/netfilter/nft_fib_ipv4.c15
-rw-r--r--net/ipv4/tcp_fastopen.c1
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/ila/ila_lwt.c1
-rw-r--r--net/ipv6/inet6_connection_sock.c2
-rw-r--r--net/ipv6/ip6_gre.c3
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/ip6_tunnel.c36
-rw-r--r--net/ipv6/netfilter/ip6t_rpfilter.c8
-rw-r--r--net/ipv6/netfilter/nf_reject_ipv6.c3
-rw-r--r--net/ipv6/netfilter/nft_fib_ipv6.c13
-rw-r--r--net/ipv6/route.c12
-rw-r--r--net/ipv6/seg6.c2
-rw-r--r--net/ipv6/seg6_iptunnel.c1
-rw-r--r--net/ipv6/tcp_ipv6.c4
-rw-r--r--net/mac80211/rate.c2
-rw-r--r--net/mpls/af_mpls.c48
-rw-r--r--net/mpls/mpls_iptunnel.c1
-rw-r--r--net/netfilter/Kconfig2
-rw-r--r--net/netfilter/nf_conntrack_core.c44
-rw-r--r--net/netfilter/nf_log.c1
-rw-r--r--net/netfilter/nf_tables_api.c67
-rw-r--r--net/netfilter/nft_dynset.c3
-rw-r--r--net/netfilter/nft_log.c3
-rw-r--r--net/netfilter/nft_lookup.c3
-rw-r--r--net/netfilter/nft_objref.c6
-rw-r--r--net/netfilter/nft_set_hash.c2
-rw-r--r--net/netfilter/nft_set_rbtree.c2
-rw-r--r--net/packet/af_packet.c4
-rw-r--r--net/sctp/ipv6.c3
-rw-r--r--net/sctp/offload.c2
-rw-r--r--net/sctp/socket.c6
-rw-r--r--net/tipc/node.c9
-rw-r--r--net/tipc/server.c48
-rw-r--r--net/tipc/subscr.c124
-rw-r--r--net/tipc/subscr.h1
-rw-r--r--net/unix/af_unix.c27
-rw-r--r--samples/bpf/tc_l2_redirect_kern.c1
-rw-r--r--samples/bpf/xdp_tx_iptunnel_kern.c1
-rw-r--r--tools/testing/selftests/bpf/test_lru_map.c53
113 files changed, 916 insertions, 562 deletions
diff --git a/Documentation/devicetree/bindings/net/mediatek-net.txt b/Documentation/devicetree/bindings/net/mediatek-net.txt
index c010fafc66a8..c7194e87d5f4 100644
--- a/Documentation/devicetree/bindings/net/mediatek-net.txt
+++ b/Documentation/devicetree/bindings/net/mediatek-net.txt
@@ -7,7 +7,7 @@ have dual GMAC each represented by a child node..
7* Ethernet controller node 7* Ethernet controller node
8 8
9Required properties: 9Required properties:
10- compatible: Should be "mediatek,mt7623-eth" 10- compatible: Should be "mediatek,mt2701-eth"
11- reg: Address and length of the register set for the device 11- reg: Address and length of the register set for the device
12- interrupts: Should contain the three frame engines interrupts in numeric 12- interrupts: Should contain the three frame engines interrupts in numeric
13 order. These are fe_int0, fe_int1 and fe_int2. 13 order. These are fe_int0, fe_int1 and fe_int2.
diff --git a/Documentation/devicetree/bindings/net/phy.txt b/Documentation/devicetree/bindings/net/phy.txt
index ff1bc4b1bb3b..fb5056b22685 100644
--- a/Documentation/devicetree/bindings/net/phy.txt
+++ b/Documentation/devicetree/bindings/net/phy.txt
@@ -19,8 +19,9 @@ Optional Properties:
19 specifications. If neither of these are specified, the default is to 19 specifications. If neither of these are specified, the default is to
20 assume clause 22. 20 assume clause 22.
21 21
22 If the phy's identifier is known then the list may contain an entry 22 If the PHY reports an incorrect ID (or none at all) then the
23 of the form: "ethernet-phy-idAAAA.BBBB" where 23 "compatible" list may contain an entry with the correct PHY ID in the
24 form: "ethernet-phy-idAAAA.BBBB" where
24 AAAA - The value of the 16 bit Phy Identifier 1 register as 25 AAAA - The value of the 16 bit Phy Identifier 1 register as
25 4 hex digits. This is the chip vendor OUI bits 3:18 26 4 hex digits. This is the chip vendor OUI bits 3:18
26 BBBB - The value of the 16 bit Phy Identifier 2 register as 27 BBBB - The value of the 16 bit Phy Identifier 2 register as
diff --git a/MAINTAINERS b/MAINTAINERS
index 24a31b500a6c..5f10c28b2e15 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3567,7 +3567,7 @@ F: drivers/infiniband/hw/cxgb3/
3567F: include/uapi/rdma/cxgb3-abi.h 3567F: include/uapi/rdma/cxgb3-abi.h
3568 3568
3569CXGB4 ETHERNET DRIVER (CXGB4) 3569CXGB4 ETHERNET DRIVER (CXGB4)
3570M: Hariprasad S <hariprasad@chelsio.com> 3570M: Ganesh Goudar <ganeshgr@chelsio.com>
3571L: netdev@vger.kernel.org 3571L: netdev@vger.kernel.org
3572W: http://www.chelsio.com 3572W: http://www.chelsio.com
3573S: Supported 3573S: Supported
diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c
index 1a1d99704fe6..296f1411fe84 100644
--- a/drivers/isdn/hardware/eicon/message.c
+++ b/drivers/isdn/hardware/eicon/message.c
@@ -11297,7 +11297,8 @@ static void mixer_notify_update(PLCI *plci, byte others)
11297 ((CAPI_MSG *) msg)->header.ncci = 0; 11297 ((CAPI_MSG *) msg)->header.ncci = 0;
11298 ((CAPI_MSG *) msg)->info.facility_req.Selector = SELECTOR_LINE_INTERCONNECT; 11298 ((CAPI_MSG *) msg)->info.facility_req.Selector = SELECTOR_LINE_INTERCONNECT;
11299 ((CAPI_MSG *) msg)->info.facility_req.structs[0] = 3; 11299 ((CAPI_MSG *) msg)->info.facility_req.structs[0] = 3;
11300 PUT_WORD(&(((CAPI_MSG *) msg)->info.facility_req.structs[1]), LI_REQ_SILENT_UPDATE); 11300 ((CAPI_MSG *) msg)->info.facility_req.structs[1] = LI_REQ_SILENT_UPDATE & 0xff;
11301 ((CAPI_MSG *) msg)->info.facility_req.structs[2] = LI_REQ_SILENT_UPDATE >> 8;
11301 ((CAPI_MSG *) msg)->info.facility_req.structs[3] = 0; 11302 ((CAPI_MSG *) msg)->info.facility_req.structs[3] = 0;
11302 w = api_put(notify_plci->appl, (CAPI_MSG *) msg); 11303 w = api_put(notify_plci->appl, (CAPI_MSG *) msg);
11303 if (w != _QUEUE_FULL) 11304 if (w != _QUEUE_FULL)
diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c
index 7be393c96b1a..cf7c18947189 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -161,6 +161,7 @@ static int c_can_pci_probe(struct pci_dev *pdev,
161 161
162 dev->irq = pdev->irq; 162 dev->irq = pdev->irq;
163 priv->base = addr; 163 priv->base = addr;
164 priv->device = &pdev->dev;
164 165
165 if (!c_can_pci_data->freq) { 166 if (!c_can_pci_data->freq) {
166 dev_err(&pdev->dev, "no clock frequency defined\n"); 167 dev_err(&pdev->dev, "no clock frequency defined\n");
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 680d1ff07a55..6749b1829469 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -948,7 +948,12 @@ static int ti_hecc_probe(struct platform_device *pdev)
948 netif_napi_add(ndev, &priv->napi, ti_hecc_rx_poll, 948 netif_napi_add(ndev, &priv->napi, ti_hecc_rx_poll,
949 HECC_DEF_NAPI_WEIGHT); 949 HECC_DEF_NAPI_WEIGHT);
950 950
951 clk_enable(priv->clk); 951 err = clk_prepare_enable(priv->clk);
952 if (err) {
953 dev_err(&pdev->dev, "clk_prepare_enable() failed\n");
954 goto probe_exit_clk;
955 }
956
952 err = register_candev(ndev); 957 err = register_candev(ndev);
953 if (err) { 958 if (err) {
954 dev_err(&pdev->dev, "register_candev() failed\n"); 959 dev_err(&pdev->dev, "register_candev() failed\n");
@@ -981,7 +986,7 @@ static int ti_hecc_remove(struct platform_device *pdev)
981 struct ti_hecc_priv *priv = netdev_priv(ndev); 986 struct ti_hecc_priv *priv = netdev_priv(ndev);
982 987
983 unregister_candev(ndev); 988 unregister_candev(ndev);
984 clk_disable(priv->clk); 989 clk_disable_unprepare(priv->clk);
985 clk_put(priv->clk); 990 clk_put(priv->clk);
986 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 991 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
987 iounmap(priv->base); 992 iounmap(priv->base);
@@ -1006,7 +1011,7 @@ static int ti_hecc_suspend(struct platform_device *pdev, pm_message_t state)
1006 hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_PDR); 1011 hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_PDR);
1007 priv->can.state = CAN_STATE_SLEEPING; 1012 priv->can.state = CAN_STATE_SLEEPING;
1008 1013
1009 clk_disable(priv->clk); 1014 clk_disable_unprepare(priv->clk);
1010 1015
1011 return 0; 1016 return 0;
1012} 1017}
@@ -1015,8 +1020,11 @@ static int ti_hecc_resume(struct platform_device *pdev)
1015{ 1020{
1016 struct net_device *dev = platform_get_drvdata(pdev); 1021 struct net_device *dev = platform_get_drvdata(pdev);
1017 struct ti_hecc_priv *priv = netdev_priv(dev); 1022 struct ti_hecc_priv *priv = netdev_priv(dev);
1023 int err;
1018 1024
1019 clk_enable(priv->clk); 1025 err = clk_prepare_enable(priv->clk);
1026 if (err)
1027 return err;
1020 1028
1021 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_PDR); 1029 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_PDR);
1022 priv->can.state = CAN_STATE_ERROR_ACTIVE; 1030 priv->can.state = CAN_STATE_ERROR_ACTIVE;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
index 5b7ba25e0065..8a280e7d66bd 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
@@ -891,6 +891,8 @@
891#define PCS_V1_WINDOW_SELECT 0x03fc 891#define PCS_V1_WINDOW_SELECT 0x03fc
892#define PCS_V2_WINDOW_DEF 0x9060 892#define PCS_V2_WINDOW_DEF 0x9060
893#define PCS_V2_WINDOW_SELECT 0x9064 893#define PCS_V2_WINDOW_SELECT 0x9064
894#define PCS_V2_RV_WINDOW_DEF 0x1060
895#define PCS_V2_RV_WINDOW_SELECT 0x1064
894 896
895/* PCS register entry bit positions and sizes */ 897/* PCS register entry bit positions and sizes */
896#define PCS_V2_WINDOW_DEF_OFFSET_INDEX 6 898#define PCS_V2_WINDOW_DEF_OFFSET_INDEX 6
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index aaf0350076a9..a7d16db5c4b2 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -1151,7 +1151,7 @@ static int xgbe_read_mmd_regs_v2(struct xgbe_prv_data *pdata, int prtad,
1151 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask); 1151 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
1152 1152
1153 spin_lock_irqsave(&pdata->xpcs_lock, flags); 1153 spin_lock_irqsave(&pdata->xpcs_lock, flags);
1154 XPCS32_IOWRITE(pdata, PCS_V2_WINDOW_SELECT, index); 1154 XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
1155 mmd_data = XPCS16_IOREAD(pdata, offset); 1155 mmd_data = XPCS16_IOREAD(pdata, offset);
1156 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); 1156 spin_unlock_irqrestore(&pdata->xpcs_lock, flags);
1157 1157
@@ -1183,7 +1183,7 @@ static void xgbe_write_mmd_regs_v2(struct xgbe_prv_data *pdata, int prtad,
1183 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask); 1183 offset = pdata->xpcs_window + (mmd_address & pdata->xpcs_window_mask);
1184 1184
1185 spin_lock_irqsave(&pdata->xpcs_lock, flags); 1185 spin_lock_irqsave(&pdata->xpcs_lock, flags);
1186 XPCS32_IOWRITE(pdata, PCS_V2_WINDOW_SELECT, index); 1186 XPCS32_IOWRITE(pdata, pdata->xpcs_window_sel_reg, index);
1187 XPCS16_IOWRITE(pdata, offset, mmd_data); 1187 XPCS16_IOWRITE(pdata, offset, mmd_data);
1188 spin_unlock_irqrestore(&pdata->xpcs_lock, flags); 1188 spin_unlock_irqrestore(&pdata->xpcs_lock, flags);
1189} 1189}
@@ -3407,8 +3407,10 @@ static int xgbe_init(struct xgbe_prv_data *pdata)
3407 3407
3408 /* Flush Tx queues */ 3408 /* Flush Tx queues */
3409 ret = xgbe_flush_tx_queues(pdata); 3409 ret = xgbe_flush_tx_queues(pdata);
3410 if (ret) 3410 if (ret) {
3411 netdev_err(pdata->netdev, "error flushing TX queues\n");
3411 return ret; 3412 return ret;
3413 }
3412 3414
3413 /* 3415 /*
3414 * Initialize DMA related features 3416 * Initialize DMA related features
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 9943629fcbf9..1c87cc204075 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1070,7 +1070,9 @@ static int xgbe_start(struct xgbe_prv_data *pdata)
1070 1070
1071 DBGPR("-->xgbe_start\n"); 1071 DBGPR("-->xgbe_start\n");
1072 1072
1073 hw_if->init(pdata); 1073 ret = hw_if->init(pdata);
1074 if (ret)
1075 return ret;
1074 1076
1075 xgbe_napi_enable(pdata, 1); 1077 xgbe_napi_enable(pdata, 1);
1076 1078
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
index e76b7f65b805..c2730f15bd8b 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
@@ -265,6 +265,7 @@ static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
265 struct xgbe_prv_data *pdata; 265 struct xgbe_prv_data *pdata;
266 struct device *dev = &pdev->dev; 266 struct device *dev = &pdev->dev;
267 void __iomem * const *iomap_table; 267 void __iomem * const *iomap_table;
268 struct pci_dev *rdev;
268 unsigned int ma_lo, ma_hi; 269 unsigned int ma_lo, ma_hi;
269 unsigned int reg; 270 unsigned int reg;
270 int bar_mask; 271 int bar_mask;
@@ -326,8 +327,20 @@ static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
326 if (netif_msg_probe(pdata)) 327 if (netif_msg_probe(pdata))
327 dev_dbg(dev, "xpcs_regs = %p\n", pdata->xpcs_regs); 328 dev_dbg(dev, "xpcs_regs = %p\n", pdata->xpcs_regs);
328 329
330 /* Set the PCS indirect addressing definition registers */
331 rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
332 if (rdev &&
333 (rdev->vendor == PCI_VENDOR_ID_AMD) && (rdev->device == 0x15d0)) {
334 pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
335 pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
336 } else {
337 pdata->xpcs_window_def_reg = PCS_V2_WINDOW_DEF;
338 pdata->xpcs_window_sel_reg = PCS_V2_WINDOW_SELECT;
339 }
340 pci_dev_put(rdev);
341
329 /* Configure the PCS indirect addressing support */ 342 /* Configure the PCS indirect addressing support */
330 reg = XPCS32_IOREAD(pdata, PCS_V2_WINDOW_DEF); 343 reg = XPCS32_IOREAD(pdata, pdata->xpcs_window_def_reg);
331 pdata->xpcs_window = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, OFFSET); 344 pdata->xpcs_window = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, OFFSET);
332 pdata->xpcs_window <<= 6; 345 pdata->xpcs_window <<= 6;
333 pdata->xpcs_window_size = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, SIZE); 346 pdata->xpcs_window_size = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, SIZE);
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index f52a9bd05bac..00108815b55e 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -955,6 +955,8 @@ struct xgbe_prv_data {
955 955
956 /* XPCS indirect addressing lock */ 956 /* XPCS indirect addressing lock */
957 spinlock_t xpcs_lock; 957 spinlock_t xpcs_lock;
958 unsigned int xpcs_window_def_reg;
959 unsigned int xpcs_window_sel_reg;
958 unsigned int xpcs_window; 960 unsigned int xpcs_window;
959 unsigned int xpcs_window_size; 961 unsigned int xpcs_window_size;
960 unsigned int xpcs_window_mask; 962 unsigned int xpcs_window_mask;
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index c8f525574d68..7dcc907a449d 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -685,8 +685,6 @@ static int alx_alloc_rings(struct alx_priv *alx)
685 return -ENOMEM; 685 return -ENOMEM;
686 } 686 }
687 687
688 alx_reinit_rings(alx);
689
690 return 0; 688 return 0;
691} 689}
692 690
@@ -703,7 +701,7 @@ static void alx_free_rings(struct alx_priv *alx)
703 if (alx->qnapi[0] && alx->qnapi[0]->rxq) 701 if (alx->qnapi[0] && alx->qnapi[0]->rxq)
704 kfree(alx->qnapi[0]->rxq->bufs); 702 kfree(alx->qnapi[0]->rxq->bufs);
705 703
706 if (!alx->descmem.virt) 704 if (alx->descmem.virt)
707 dma_free_coherent(&alx->hw.pdev->dev, 705 dma_free_coherent(&alx->hw.pdev->dev,
708 alx->descmem.size, 706 alx->descmem.size,
709 alx->descmem.virt, 707 alx->descmem.virt,
@@ -984,6 +982,7 @@ static int alx_realloc_resources(struct alx_priv *alx)
984 alx_free_rings(alx); 982 alx_free_rings(alx);
985 alx_free_napis(alx); 983 alx_free_napis(alx);
986 alx_disable_advanced_intr(alx); 984 alx_disable_advanced_intr(alx);
985 alx_init_intr(alx, false);
987 986
988 err = alx_alloc_napis(alx); 987 err = alx_alloc_napis(alx);
989 if (err) 988 if (err)
@@ -1241,6 +1240,12 @@ static int __alx_open(struct alx_priv *alx, bool resume)
1241 if (err) 1240 if (err)
1242 goto out_free_rings; 1241 goto out_free_rings;
1243 1242
1243 /* must be called after alx_request_irq because the chip stops working
1244 * if we copy the dma addresses in alx_init_ring_ptrs twice when
1245 * requesting msi-x interrupts failed
1246 */
1247 alx_reinit_rings(alx);
1248
1244 netif_set_real_num_tx_queues(alx->dev, alx->num_txq); 1249 netif_set_real_num_tx_queues(alx->dev, alx->num_txq);
1245 netif_set_real_num_rx_queues(alx->dev, alx->num_rxq); 1250 netif_set_real_num_rx_queues(alx->dev, alx->num_rxq);
1246 1251
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 3b14d5144228..c483618b57bd 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -913,6 +913,8 @@ static int bcm_enet_open(struct net_device *dev)
913 priv->old_link = 0; 913 priv->old_link = 0;
914 priv->old_duplex = -1; 914 priv->old_duplex = -1;
915 priv->old_pause = -1; 915 priv->old_pause = -1;
916 } else {
917 phydev = NULL;
916 } 918 }
917 919
918 /* mask all interrupts and request them */ 920 /* mask all interrupts and request them */
@@ -1083,7 +1085,7 @@ static int bcm_enet_open(struct net_device *dev)
1083 enet_dmac_writel(priv, priv->dma_chan_int_mask, 1085 enet_dmac_writel(priv, priv->dma_chan_int_mask,
1084 ENETDMAC_IRMASK, priv->tx_chan); 1086 ENETDMAC_IRMASK, priv->tx_chan);
1085 1087
1086 if (priv->has_phy) 1088 if (phydev)
1087 phy_start(phydev); 1089 phy_start(phydev);
1088 else 1090 else
1089 bcm_enet_adjust_link(dev); 1091 bcm_enet_adjust_link(dev);
@@ -1126,7 +1128,7 @@ out_freeirq:
1126 free_irq(dev->irq, dev); 1128 free_irq(dev->irq, dev);
1127 1129
1128out_phy_disconnect: 1130out_phy_disconnect:
1129 if (priv->has_phy) 1131 if (phydev)
1130 phy_disconnect(phydev); 1132 phy_disconnect(phydev);
1131 1133
1132 return ret; 1134 return ret;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 9608cb49a11c..4fcc6a84a087 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1099,7 +1099,7 @@ static struct sk_buff *bnxt_gro_func_5730x(struct bnxt_tpa_info *tpa_info,
1099{ 1099{
1100#ifdef CONFIG_INET 1100#ifdef CONFIG_INET
1101 struct tcphdr *th; 1101 struct tcphdr *th;
1102 int len, nw_off, tcp_opt_len; 1102 int len, nw_off, tcp_opt_len = 0;
1103 1103
1104 if (tcp_ts) 1104 if (tcp_ts)
1105 tcp_opt_len = 12; 1105 tcp_opt_len = 12;
@@ -5314,17 +5314,12 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
5314 if ((link_info->support_auto_speeds | diff) != 5314 if ((link_info->support_auto_speeds | diff) !=
5315 link_info->support_auto_speeds) { 5315 link_info->support_auto_speeds) {
5316 /* An advertised speed is no longer supported, so we need to 5316 /* An advertised speed is no longer supported, so we need to
5317 * update the advertisement settings. See bnxt_reset() for 5317 * update the advertisement settings. Caller holds RTNL
5318 * comments about the rtnl_lock() sequence below. 5318 * so we can modify link settings.
5319 */ 5319 */
5320 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
5321 rtnl_lock();
5322 link_info->advertising = link_info->support_auto_speeds; 5320 link_info->advertising = link_info->support_auto_speeds;
5323 if (test_bit(BNXT_STATE_OPEN, &bp->state) && 5321 if (link_info->autoneg & BNXT_AUTONEG_SPEED)
5324 (link_info->autoneg & BNXT_AUTONEG_SPEED))
5325 bnxt_hwrm_set_link_setting(bp, true, false); 5322 bnxt_hwrm_set_link_setting(bp, true, false);
5326 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
5327 rtnl_unlock();
5328 } 5323 }
5329 return 0; 5324 return 0;
5330} 5325}
@@ -6200,29 +6195,37 @@ bnxt_restart_timer:
6200 mod_timer(&bp->timer, jiffies + bp->current_interval); 6195 mod_timer(&bp->timer, jiffies + bp->current_interval);
6201} 6196}
6202 6197
6203/* Only called from bnxt_sp_task() */ 6198static void bnxt_rtnl_lock_sp(struct bnxt *bp)
6204static void bnxt_reset(struct bnxt *bp, bool silent)
6205{ 6199{
6206 /* bnxt_reset_task() calls bnxt_close_nic() which waits 6200 /* We are called from bnxt_sp_task which has BNXT_STATE_IN_SP_TASK
6207 * for BNXT_STATE_IN_SP_TASK to clear. 6201 * set. If the device is being closed, bnxt_close() may be holding
6208 * If there is a parallel dev_close(), bnxt_close() may be holding
6209 * rtnl() and waiting for BNXT_STATE_IN_SP_TASK to clear. So we 6202 * rtnl() and waiting for BNXT_STATE_IN_SP_TASK to clear. So we
6210 * must clear BNXT_STATE_IN_SP_TASK before holding rtnl(). 6203 * must clear BNXT_STATE_IN_SP_TASK before holding rtnl().
6211 */ 6204 */
6212 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6205 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
6213 rtnl_lock(); 6206 rtnl_lock();
6214 if (test_bit(BNXT_STATE_OPEN, &bp->state)) 6207}
6215 bnxt_reset_task(bp, silent); 6208
6209static void bnxt_rtnl_unlock_sp(struct bnxt *bp)
6210{
6216 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6211 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
6217 rtnl_unlock(); 6212 rtnl_unlock();
6218} 6213}
6219 6214
6215/* Only called from bnxt_sp_task() */
6216static void bnxt_reset(struct bnxt *bp, bool silent)
6217{
6218 bnxt_rtnl_lock_sp(bp);
6219 if (test_bit(BNXT_STATE_OPEN, &bp->state))
6220 bnxt_reset_task(bp, silent);
6221 bnxt_rtnl_unlock_sp(bp);
6222}
6223
6220static void bnxt_cfg_ntp_filters(struct bnxt *); 6224static void bnxt_cfg_ntp_filters(struct bnxt *);
6221 6225
6222static void bnxt_sp_task(struct work_struct *work) 6226static void bnxt_sp_task(struct work_struct *work)
6223{ 6227{
6224 struct bnxt *bp = container_of(work, struct bnxt, sp_task); 6228 struct bnxt *bp = container_of(work, struct bnxt, sp_task);
6225 int rc;
6226 6229
6227 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6230 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
6228 smp_mb__after_atomic(); 6231 smp_mb__after_atomic();
@@ -6236,16 +6239,6 @@ static void bnxt_sp_task(struct work_struct *work)
6236 6239
6237 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) 6240 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event))
6238 bnxt_cfg_ntp_filters(bp); 6241 bnxt_cfg_ntp_filters(bp);
6239 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
6240 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,
6241 &bp->sp_event))
6242 bnxt_hwrm_phy_qcaps(bp);
6243
6244 rc = bnxt_update_link(bp, true);
6245 if (rc)
6246 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
6247 rc);
6248 }
6249 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) 6242 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event))
6250 bnxt_hwrm_exec_fwd_req(bp); 6243 bnxt_hwrm_exec_fwd_req(bp);
6251 if (test_and_clear_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event)) { 6244 if (test_and_clear_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event)) {
@@ -6266,18 +6259,39 @@ static void bnxt_sp_task(struct work_struct *work)
6266 bnxt_hwrm_tunnel_dst_port_free( 6259 bnxt_hwrm_tunnel_dst_port_free(
6267 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE); 6260 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE);
6268 } 6261 }
6262 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event))
6263 bnxt_hwrm_port_qstats(bp);
6264
6265 /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
6266 * must be the last functions to be called before exiting.
6267 */
6268 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
6269 int rc = 0;
6270
6271 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,
6272 &bp->sp_event))
6273 bnxt_hwrm_phy_qcaps(bp);
6274
6275 bnxt_rtnl_lock_sp(bp);
6276 if (test_bit(BNXT_STATE_OPEN, &bp->state))
6277 rc = bnxt_update_link(bp, true);
6278 bnxt_rtnl_unlock_sp(bp);
6279 if (rc)
6280 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
6281 rc);
6282 }
6283 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) {
6284 bnxt_rtnl_lock_sp(bp);
6285 if (test_bit(BNXT_STATE_OPEN, &bp->state))
6286 bnxt_get_port_module_status(bp);
6287 bnxt_rtnl_unlock_sp(bp);
6288 }
6269 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) 6289 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
6270 bnxt_reset(bp, false); 6290 bnxt_reset(bp, false);
6271 6291
6272 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) 6292 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event))
6273 bnxt_reset(bp, true); 6293 bnxt_reset(bp, true);
6274 6294
6275 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event))
6276 bnxt_get_port_module_status(bp);
6277
6278 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event))
6279 bnxt_hwrm_port_qstats(bp);
6280
6281 smp_mb__before_atomic(); 6295 smp_mb__before_atomic();
6282 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); 6296 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
6283} 6297}
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index a6e7afa878be..c1b671667920 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2948,7 +2948,7 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus,
2948 } 2948 }
2949 2949
2950 /* try reuse page */ 2950 /* try reuse page */
2951 if (unlikely(page_count(page) != 1)) 2951 if (unlikely(page_count(page) != 1 || page_is_pfmemalloc(page)))
2952 return false; 2952 return false;
2953 2953
2954 /* change offset to the other half */ 2954 /* change offset to the other half */
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index a831f947ca8c..309f5c66083c 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1601,8 +1601,11 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
1601 netdev->netdev_ops = &ibmveth_netdev_ops; 1601 netdev->netdev_ops = &ibmveth_netdev_ops;
1602 netdev->ethtool_ops = &netdev_ethtool_ops; 1602 netdev->ethtool_ops = &netdev_ethtool_ops;
1603 SET_NETDEV_DEV(netdev, &dev->dev); 1603 SET_NETDEV_DEV(netdev, &dev->dev);
1604 netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | 1604 netdev->hw_features = NETIF_F_SG;
1605 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; 1605 if (vio_get_attribute(dev, "ibm,illan-options", NULL) != NULL) {
1606 netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
1607 NETIF_F_RXCSUM;
1608 }
1606 1609
1607 netdev->features |= netdev->hw_features; 1610 netdev->features |= netdev->hw_features;
1608 1611
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 3dd87889e67e..1c29c86f8709 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2517,7 +2517,7 @@ static int mtk_remove(struct platform_device *pdev)
2517} 2517}
2518 2518
2519const struct of_device_id of_mtk_match[] = { 2519const struct of_device_id of_mtk_match[] = {
2520 { .compatible = "mediatek,mt7623-eth" }, 2520 { .compatible = "mediatek,mt2701-eth" },
2521 {}, 2521 {},
2522}; 2522};
2523MODULE_DEVICE_TABLE(of, of_mtk_match); 2523MODULE_DEVICE_TABLE(of, of_mtk_match);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index d9c9f86a30df..d5a9372ed84d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -1732,8 +1732,6 @@ static void mlx4_en_get_channels(struct net_device *dev,
1732{ 1732{
1733 struct mlx4_en_priv *priv = netdev_priv(dev); 1733 struct mlx4_en_priv *priv = netdev_priv(dev);
1734 1734
1735 memset(channel, 0, sizeof(*channel));
1736
1737 channel->max_rx = MAX_RX_RINGS; 1735 channel->max_rx = MAX_RX_RINGS;
1738 channel->max_tx = MLX4_EN_MAX_TX_RING_P_UP; 1736 channel->max_tx = MLX4_EN_MAX_TX_RING_P_UP;
1739 1737
@@ -1752,10 +1750,7 @@ static int mlx4_en_set_channels(struct net_device *dev,
1752 int xdp_count; 1750 int xdp_count;
1753 int err = 0; 1751 int err = 0;
1754 1752
1755 if (channel->other_count || channel->combined_count || 1753 if (!channel->tx_count || !channel->rx_count)
1756 channel->tx_count > MLX4_EN_MAX_TX_RING_P_UP ||
1757 channel->rx_count > MAX_RX_RINGS ||
1758 !channel->tx_count || !channel->rx_count)
1759 return -EINVAL; 1754 return -EINVAL;
1760 1755
1761 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 1756 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 33a399a8b5d5..5197817e4b2f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -543,7 +543,6 @@ static int mlx5e_set_channels(struct net_device *dev,
543 struct ethtool_channels *ch) 543 struct ethtool_channels *ch)
544{ 544{
545 struct mlx5e_priv *priv = netdev_priv(dev); 545 struct mlx5e_priv *priv = netdev_priv(dev);
546 int ncv = mlx5e_get_max_num_channels(priv->mdev);
547 unsigned int count = ch->combined_count; 546 unsigned int count = ch->combined_count;
548 bool arfs_enabled; 547 bool arfs_enabled;
549 bool was_opened; 548 bool was_opened;
@@ -554,16 +553,6 @@ static int mlx5e_set_channels(struct net_device *dev,
554 __func__); 553 __func__);
555 return -EINVAL; 554 return -EINVAL;
556 } 555 }
557 if (ch->rx_count || ch->tx_count) {
558 netdev_info(dev, "%s: separate rx/tx count not supported\n",
559 __func__);
560 return -EINVAL;
561 }
562 if (count > ncv) {
563 netdev_info(dev, "%s: count (%d) > max (%d)\n",
564 __func__, count, ncv);
565 return -EINVAL;
566 }
567 556
568 if (priv->params.num_channels == count) 557 if (priv->params.num_channels == count)
569 return 0; 558 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 0e2fb3ed1790..06d5e6fecb0a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -193,6 +193,9 @@ static inline bool mlx5e_rx_cache_put(struct mlx5e_rq *rq,
193 return false; 193 return false;
194 } 194 }
195 195
196 if (unlikely(page_is_pfmemalloc(dma_info->page)))
197 return false;
198
196 cache->page_cache[cache->tail] = *dma_info; 199 cache->page_cache[cache->tail] = *dma_info;
197 cache->tail = tail_next; 200 cache->tail = tail_next;
198 return true; 201 return true;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 01d0efa9c5c7..9e494a446b7e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1172,7 +1172,8 @@ static int mlxsw_sp_nexthop_mac_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
1172 1172
1173static int 1173static int
1174mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp, 1174mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp,
1175 struct mlxsw_sp_nexthop_group *nh_grp) 1175 struct mlxsw_sp_nexthop_group *nh_grp,
1176 bool reallocate)
1176{ 1177{
1177 u32 adj_index = nh_grp->adj_index; /* base */ 1178 u32 adj_index = nh_grp->adj_index; /* base */
1178 struct mlxsw_sp_nexthop *nh; 1179 struct mlxsw_sp_nexthop *nh;
@@ -1187,7 +1188,7 @@ mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp,
1187 continue; 1188 continue;
1188 } 1189 }
1189 1190
1190 if (nh->update) { 1191 if (nh->update || reallocate) {
1191 err = mlxsw_sp_nexthop_mac_update(mlxsw_sp, 1192 err = mlxsw_sp_nexthop_mac_update(mlxsw_sp,
1192 adj_index, nh); 1193 adj_index, nh);
1193 if (err) 1194 if (err)
@@ -1248,7 +1249,8 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
1248 /* Nothing was added or removed, so no need to reallocate. Just 1249 /* Nothing was added or removed, so no need to reallocate. Just
1249 * update MAC on existing adjacency indexes. 1250 * update MAC on existing adjacency indexes.
1250 */ 1251 */
1251 err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp); 1252 err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp,
1253 false);
1252 if (err) { 1254 if (err) {
1253 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n"); 1255 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n");
1254 goto set_trap; 1256 goto set_trap;
@@ -1276,7 +1278,7 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
1276 nh_grp->adj_index_valid = 1; 1278 nh_grp->adj_index_valid = 1;
1277 nh_grp->adj_index = adj_index; 1279 nh_grp->adj_index = adj_index;
1278 nh_grp->ecmp_size = ecmp_size; 1280 nh_grp->ecmp_size = ecmp_size;
1279 err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp); 1281 err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp, true);
1280 if (err) { 1282 if (err) {
1281 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n"); 1283 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n");
1282 goto set_trap; 1284 goto set_trap;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 8e5cb7605b0f..873ce2cd76ba 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -297,7 +297,7 @@ static void qed_ll2_txq_flush(struct qed_hwfn *p_hwfn, u8 connection_handle)
297 list_del(&p_pkt->list_entry); 297 list_del(&p_pkt->list_entry);
298 b_last_packet = list_empty(&p_tx->active_descq); 298 b_last_packet = list_empty(&p_tx->active_descq);
299 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); 299 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq);
300 if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) { 300 if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO) {
301 struct qed_ooo_buffer *p_buffer; 301 struct qed_ooo_buffer *p_buffer;
302 302
303 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; 303 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie;
@@ -309,7 +309,7 @@ static void qed_ll2_txq_flush(struct qed_hwfn *p_hwfn, u8 connection_handle)
309 b_last_frag = 309 b_last_frag =
310 p_tx->cur_completing_bd_idx == p_pkt->bd_used; 310 p_tx->cur_completing_bd_idx == p_pkt->bd_used;
311 tx_frag = p_pkt->bds_set[0].tx_frag; 311 tx_frag = p_pkt->bds_set[0].tx_frag;
312 if (p_ll2_conn->gsi_enable) 312 if (p_ll2_conn->conn.gsi_enable)
313 qed_ll2b_release_tx_gsi_packet(p_hwfn, 313 qed_ll2b_release_tx_gsi_packet(p_hwfn,
314 p_ll2_conn-> 314 p_ll2_conn->
315 my_id, 315 my_id,
@@ -378,7 +378,7 @@ static int qed_ll2_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
378 378
379 spin_unlock_irqrestore(&p_tx->lock, flags); 379 spin_unlock_irqrestore(&p_tx->lock, flags);
380 tx_frag = p_pkt->bds_set[0].tx_frag; 380 tx_frag = p_pkt->bds_set[0].tx_frag;
381 if (p_ll2_conn->gsi_enable) 381 if (p_ll2_conn->conn.gsi_enable)
382 qed_ll2b_complete_tx_gsi_packet(p_hwfn, 382 qed_ll2b_complete_tx_gsi_packet(p_hwfn,
383 p_ll2_conn->my_id, 383 p_ll2_conn->my_id,
384 p_pkt->cookie, 384 p_pkt->cookie,
@@ -550,7 +550,7 @@ static void qed_ll2_rxq_flush(struct qed_hwfn *p_hwfn, u8 connection_handle)
550 550
551 list_move_tail(&p_pkt->list_entry, &p_rx->free_descq); 551 list_move_tail(&p_pkt->list_entry, &p_rx->free_descq);
552 552
553 if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) { 553 if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO) {
554 struct qed_ooo_buffer *p_buffer; 554 struct qed_ooo_buffer *p_buffer;
555 555
556 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; 556 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie;
@@ -738,7 +738,7 @@ qed_ooo_submit_tx_buffers(struct qed_hwfn *p_hwfn,
738 rc = qed_ll2_prepare_tx_packet(p_hwfn, p_ll2_conn->my_id, 1, 738 rc = qed_ll2_prepare_tx_packet(p_hwfn, p_ll2_conn->my_id, 1,
739 p_buffer->vlan, bd_flags, 739 p_buffer->vlan, bd_flags,
740 l4_hdr_offset_w, 740 l4_hdr_offset_w,
741 p_ll2_conn->tx_dest, 0, 741 p_ll2_conn->conn.tx_dest, 0,
742 first_frag, 742 first_frag,
743 p_buffer->packet_length, 743 p_buffer->packet_length,
744 p_buffer, true); 744 p_buffer, true);
@@ -858,7 +858,7 @@ qed_ll2_acquire_connection_ooo(struct qed_hwfn *p_hwfn,
858 u16 buf_idx; 858 u16 buf_idx;
859 int rc = 0; 859 int rc = 0;
860 860
861 if (p_ll2_info->conn_type != QED_LL2_TYPE_ISCSI_OOO) 861 if (p_ll2_info->conn.conn_type != QED_LL2_TYPE_ISCSI_OOO)
862 return rc; 862 return rc;
863 863
864 if (!rx_num_ooo_buffers) 864 if (!rx_num_ooo_buffers)
@@ -901,7 +901,7 @@ static void
901qed_ll2_establish_connection_ooo(struct qed_hwfn *p_hwfn, 901qed_ll2_establish_connection_ooo(struct qed_hwfn *p_hwfn,
902 struct qed_ll2_info *p_ll2_conn) 902 struct qed_ll2_info *p_ll2_conn)
903{ 903{
904 if (p_ll2_conn->conn_type != QED_LL2_TYPE_ISCSI_OOO) 904 if (p_ll2_conn->conn.conn_type != QED_LL2_TYPE_ISCSI_OOO)
905 return; 905 return;
906 906
907 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); 907 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info);
@@ -913,7 +913,7 @@ static void qed_ll2_release_connection_ooo(struct qed_hwfn *p_hwfn,
913{ 913{
914 struct qed_ooo_buffer *p_buffer; 914 struct qed_ooo_buffer *p_buffer;
915 915
916 if (p_ll2_conn->conn_type != QED_LL2_TYPE_ISCSI_OOO) 916 if (p_ll2_conn->conn.conn_type != QED_LL2_TYPE_ISCSI_OOO)
917 return; 917 return;
918 918
919 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); 919 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info);
@@ -945,23 +945,19 @@ static int qed_ll2_start_ooo(struct qed_dev *cdev,
945{ 945{
946 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); 946 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
947 u8 *handle = &hwfn->pf_params.iscsi_pf_params.ll2_ooo_queue_id; 947 u8 *handle = &hwfn->pf_params.iscsi_pf_params.ll2_ooo_queue_id;
948 struct qed_ll2_info *ll2_info; 948 struct qed_ll2_conn ll2_info;
949 int rc; 949 int rc;
950 950
951 ll2_info = kzalloc(sizeof(*ll2_info), GFP_KERNEL); 951 ll2_info.conn_type = QED_LL2_TYPE_ISCSI_OOO;
952 if (!ll2_info) 952 ll2_info.mtu = params->mtu;
953 return -ENOMEM; 953 ll2_info.rx_drop_ttl0_flg = params->drop_ttl0_packets;
954 ll2_info->conn_type = QED_LL2_TYPE_ISCSI_OOO; 954 ll2_info.rx_vlan_removal_en = params->rx_vlan_stripping;
955 ll2_info->mtu = params->mtu; 955 ll2_info.tx_tc = OOO_LB_TC;
956 ll2_info->rx_drop_ttl0_flg = params->drop_ttl0_packets; 956 ll2_info.tx_dest = CORE_TX_DEST_LB;
957 ll2_info->rx_vlan_removal_en = params->rx_vlan_stripping; 957
958 ll2_info->tx_tc = OOO_LB_TC; 958 rc = qed_ll2_acquire_connection(hwfn, &ll2_info,
959 ll2_info->tx_dest = CORE_TX_DEST_LB;
960
961 rc = qed_ll2_acquire_connection(hwfn, ll2_info,
962 QED_LL2_RX_SIZE, QED_LL2_TX_SIZE, 959 QED_LL2_RX_SIZE, QED_LL2_TX_SIZE,
963 handle); 960 handle);
964 kfree(ll2_info);
965 if (rc) { 961 if (rc) {
966 DP_INFO(cdev, "Failed to acquire LL2 OOO connection\n"); 962 DP_INFO(cdev, "Failed to acquire LL2 OOO connection\n");
967 goto out; 963 goto out;
@@ -1006,7 +1002,7 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn *p_hwfn,
1006 struct qed_ll2_info *p_ll2_conn, 1002 struct qed_ll2_info *p_ll2_conn,
1007 u8 action_on_error) 1003 u8 action_on_error)
1008{ 1004{
1009 enum qed_ll2_conn_type conn_type = p_ll2_conn->conn_type; 1005 enum qed_ll2_conn_type conn_type = p_ll2_conn->conn.conn_type;
1010 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; 1006 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue;
1011 struct core_rx_start_ramrod_data *p_ramrod = NULL; 1007 struct core_rx_start_ramrod_data *p_ramrod = NULL;
1012 struct qed_spq_entry *p_ent = NULL; 1008 struct qed_spq_entry *p_ent = NULL;
@@ -1032,7 +1028,7 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn *p_hwfn,
1032 p_ramrod->sb_index = p_rx->rx_sb_index; 1028 p_ramrod->sb_index = p_rx->rx_sb_index;
1033 p_ramrod->complete_event_flg = 1; 1029 p_ramrod->complete_event_flg = 1;
1034 1030
1035 p_ramrod->mtu = cpu_to_le16(p_ll2_conn->mtu); 1031 p_ramrod->mtu = cpu_to_le16(p_ll2_conn->conn.mtu);
1036 DMA_REGPAIR_LE(p_ramrod->bd_base, 1032 DMA_REGPAIR_LE(p_ramrod->bd_base,
1037 p_rx->rxq_chain.p_phys_addr); 1033 p_rx->rxq_chain.p_phys_addr);
1038 cqe_pbl_size = (u16)qed_chain_get_page_cnt(&p_rx->rcq_chain); 1034 cqe_pbl_size = (u16)qed_chain_get_page_cnt(&p_rx->rcq_chain);
@@ -1040,8 +1036,8 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn *p_hwfn,
1040 DMA_REGPAIR_LE(p_ramrod->cqe_pbl_addr, 1036 DMA_REGPAIR_LE(p_ramrod->cqe_pbl_addr,
1041 qed_chain_get_pbl_phys(&p_rx->rcq_chain)); 1037 qed_chain_get_pbl_phys(&p_rx->rcq_chain));
1042 1038
1043 p_ramrod->drop_ttl0_flg = p_ll2_conn->rx_drop_ttl0_flg; 1039 p_ramrod->drop_ttl0_flg = p_ll2_conn->conn.rx_drop_ttl0_flg;
1044 p_ramrod->inner_vlan_removal_en = p_ll2_conn->rx_vlan_removal_en; 1040 p_ramrod->inner_vlan_removal_en = p_ll2_conn->conn.rx_vlan_removal_en;
1045 p_ramrod->queue_id = p_ll2_conn->queue_id; 1041 p_ramrod->queue_id = p_ll2_conn->queue_id;
1046 p_ramrod->main_func_queue = (conn_type == QED_LL2_TYPE_ISCSI_OOO) ? 0 1042 p_ramrod->main_func_queue = (conn_type == QED_LL2_TYPE_ISCSI_OOO) ? 0
1047 : 1; 1043 : 1;
@@ -1056,14 +1052,14 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn *p_hwfn,
1056 } 1052 }
1057 1053
1058 p_ramrod->action_on_error.error_type = action_on_error; 1054 p_ramrod->action_on_error.error_type = action_on_error;
1059 p_ramrod->gsi_offload_flag = p_ll2_conn->gsi_enable; 1055 p_ramrod->gsi_offload_flag = p_ll2_conn->conn.gsi_enable;
1060 return qed_spq_post(p_hwfn, p_ent, NULL); 1056 return qed_spq_post(p_hwfn, p_ent, NULL);
1061} 1057}
1062 1058
1063static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn, 1059static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn,
1064 struct qed_ll2_info *p_ll2_conn) 1060 struct qed_ll2_info *p_ll2_conn)
1065{ 1061{
1066 enum qed_ll2_conn_type conn_type = p_ll2_conn->conn_type; 1062 enum qed_ll2_conn_type conn_type = p_ll2_conn->conn.conn_type;
1067 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; 1063 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue;
1068 struct core_tx_start_ramrod_data *p_ramrod = NULL; 1064 struct core_tx_start_ramrod_data *p_ramrod = NULL;
1069 struct qed_spq_entry *p_ent = NULL; 1065 struct qed_spq_entry *p_ent = NULL;
@@ -1075,7 +1071,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn,
1075 if (!QED_LL2_TX_REGISTERED(p_ll2_conn)) 1071 if (!QED_LL2_TX_REGISTERED(p_ll2_conn))
1076 return 0; 1072 return 0;
1077 1073
1078 if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) 1074 if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO)
1079 p_ll2_conn->tx_stats_en = 0; 1075 p_ll2_conn->tx_stats_en = 0;
1080 else 1076 else
1081 p_ll2_conn->tx_stats_en = 1; 1077 p_ll2_conn->tx_stats_en = 1;
@@ -1096,7 +1092,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn,
1096 1092
1097 p_ramrod->sb_id = cpu_to_le16(qed_int_get_sp_sb_id(p_hwfn)); 1093 p_ramrod->sb_id = cpu_to_le16(qed_int_get_sp_sb_id(p_hwfn));
1098 p_ramrod->sb_index = p_tx->tx_sb_index; 1094 p_ramrod->sb_index = p_tx->tx_sb_index;
1099 p_ramrod->mtu = cpu_to_le16(p_ll2_conn->mtu); 1095 p_ramrod->mtu = cpu_to_le16(p_ll2_conn->conn.mtu);
1100 p_ramrod->stats_en = p_ll2_conn->tx_stats_en; 1096 p_ramrod->stats_en = p_ll2_conn->tx_stats_en;
1101 p_ramrod->stats_id = p_ll2_conn->tx_stats_id; 1097 p_ramrod->stats_id = p_ll2_conn->tx_stats_id;
1102 1098
@@ -1106,7 +1102,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn,
1106 p_ramrod->pbl_size = cpu_to_le16(pbl_size); 1102 p_ramrod->pbl_size = cpu_to_le16(pbl_size);
1107 1103
1108 memset(&pq_params, 0, sizeof(pq_params)); 1104 memset(&pq_params, 0, sizeof(pq_params));
1109 pq_params.core.tc = p_ll2_conn->tx_tc; 1105 pq_params.core.tc = p_ll2_conn->conn.tx_tc;
1110 pq_id = qed_get_qm_pq(p_hwfn, PROTOCOLID_CORE, &pq_params); 1106 pq_id = qed_get_qm_pq(p_hwfn, PROTOCOLID_CORE, &pq_params);
1111 p_ramrod->qm_pq_id = cpu_to_le16(pq_id); 1107 p_ramrod->qm_pq_id = cpu_to_le16(pq_id);
1112 1108
@@ -1123,7 +1119,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn,
1123 DP_NOTICE(p_hwfn, "Unknown connection type: %d\n", conn_type); 1119 DP_NOTICE(p_hwfn, "Unknown connection type: %d\n", conn_type);
1124 } 1120 }
1125 1121
1126 p_ramrod->gsi_offload_flag = p_ll2_conn->gsi_enable; 1122 p_ramrod->gsi_offload_flag = p_ll2_conn->conn.gsi_enable;
1127 return qed_spq_post(p_hwfn, p_ent, NULL); 1123 return qed_spq_post(p_hwfn, p_ent, NULL);
1128} 1124}
1129 1125
@@ -1224,7 +1220,7 @@ qed_ll2_acquire_connection_rx(struct qed_hwfn *p_hwfn,
1224 1220
1225 DP_VERBOSE(p_hwfn, QED_MSG_LL2, 1221 DP_VERBOSE(p_hwfn, QED_MSG_LL2,
1226 "Allocated LL2 Rxq [Type %08x] with 0x%08x buffers\n", 1222 "Allocated LL2 Rxq [Type %08x] with 0x%08x buffers\n",
1227 p_ll2_info->conn_type, rx_num_desc); 1223 p_ll2_info->conn.conn_type, rx_num_desc);
1228 1224
1229out: 1225out:
1230 return rc; 1226 return rc;
@@ -1262,7 +1258,7 @@ static int qed_ll2_acquire_connection_tx(struct qed_hwfn *p_hwfn,
1262 1258
1263 DP_VERBOSE(p_hwfn, QED_MSG_LL2, 1259 DP_VERBOSE(p_hwfn, QED_MSG_LL2,
1264 "Allocated LL2 Txq [Type %08x] with 0x%08x buffers\n", 1260 "Allocated LL2 Txq [Type %08x] with 0x%08x buffers\n",
1265 p_ll2_info->conn_type, tx_num_desc); 1261 p_ll2_info->conn.conn_type, tx_num_desc);
1266 1262
1267out: 1263out:
1268 if (rc) 1264 if (rc)
@@ -1273,7 +1269,7 @@ out:
1273} 1269}
1274 1270
1275int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn, 1271int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn,
1276 struct qed_ll2_info *p_params, 1272 struct qed_ll2_conn *p_params,
1277 u16 rx_num_desc, 1273 u16 rx_num_desc,
1278 u16 tx_num_desc, 1274 u16 tx_num_desc,
1279 u8 *p_connection_handle) 1275 u8 *p_connection_handle)
@@ -1302,15 +1298,7 @@ int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn,
1302 if (!p_ll2_info) 1298 if (!p_ll2_info)
1303 return -EBUSY; 1299 return -EBUSY;
1304 1300
1305 p_ll2_info->conn_type = p_params->conn_type; 1301 p_ll2_info->conn = *p_params;
1306 p_ll2_info->mtu = p_params->mtu;
1307 p_ll2_info->rx_drop_ttl0_flg = p_params->rx_drop_ttl0_flg;
1308 p_ll2_info->rx_vlan_removal_en = p_params->rx_vlan_removal_en;
1309 p_ll2_info->tx_tc = p_params->tx_tc;
1310 p_ll2_info->tx_dest = p_params->tx_dest;
1311 p_ll2_info->ai_err_packet_too_big = p_params->ai_err_packet_too_big;
1312 p_ll2_info->ai_err_no_buf = p_params->ai_err_no_buf;
1313 p_ll2_info->gsi_enable = p_params->gsi_enable;
1314 1302
1315 rc = qed_ll2_acquire_connection_rx(p_hwfn, p_ll2_info, rx_num_desc); 1303 rc = qed_ll2_acquire_connection_rx(p_hwfn, p_ll2_info, rx_num_desc);
1316 if (rc) 1304 if (rc)
@@ -1371,9 +1359,9 @@ static int qed_ll2_establish_connection_rx(struct qed_hwfn *p_hwfn,
1371 1359
1372 SET_FIELD(action_on_error, 1360 SET_FIELD(action_on_error,
1373 CORE_RX_ACTION_ON_ERROR_PACKET_TOO_BIG, 1361 CORE_RX_ACTION_ON_ERROR_PACKET_TOO_BIG,
1374 p_ll2_conn->ai_err_packet_too_big); 1362 p_ll2_conn->conn.ai_err_packet_too_big);
1375 SET_FIELD(action_on_error, 1363 SET_FIELD(action_on_error,
1376 CORE_RX_ACTION_ON_ERROR_NO_BUFF, p_ll2_conn->ai_err_no_buf); 1364 CORE_RX_ACTION_ON_ERROR_NO_BUFF, p_ll2_conn->conn.ai_err_no_buf);
1377 1365
1378 return qed_sp_ll2_rx_queue_start(p_hwfn, p_ll2_conn, action_on_error); 1366 return qed_sp_ll2_rx_queue_start(p_hwfn, p_ll2_conn, action_on_error);
1379} 1367}
@@ -1600,7 +1588,7 @@ static void qed_ll2_prepare_tx_packet_set_bd(struct qed_hwfn *p_hwfn,
1600 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Tx Producer at [0x%04x] - set with a %04x bytes %02x BDs buffer at %08x:%08x\n", 1588 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Tx Producer at [0x%04x] - set with a %04x bytes %02x BDs buffer at %08x:%08x\n",
1601 p_ll2->queue_id, 1589 p_ll2->queue_id,
1602 p_ll2->cid, 1590 p_ll2->cid,
1603 p_ll2->conn_type, 1591 p_ll2->conn.conn_type,
1604 prod_idx, 1592 prod_idx,
1605 first_frag_len, 1593 first_frag_len,
1606 num_of_bds, 1594 num_of_bds,
@@ -1676,7 +1664,7 @@ static void qed_ll2_tx_packet_notify(struct qed_hwfn *p_hwfn,
1676 (NETIF_MSG_TX_QUEUED | QED_MSG_LL2), 1664 (NETIF_MSG_TX_QUEUED | QED_MSG_LL2),
1677 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Doorbelled [producer 0x%04x]\n", 1665 "LL2 [q 0x%02x cid 0x%08x type 0x%08x] Doorbelled [producer 0x%04x]\n",
1678 p_ll2_conn->queue_id, 1666 p_ll2_conn->queue_id,
1679 p_ll2_conn->cid, p_ll2_conn->conn_type, db_msg.spq_prod); 1667 p_ll2_conn->cid, p_ll2_conn->conn.conn_type, db_msg.spq_prod);
1680} 1668}
1681 1669
1682int qed_ll2_prepare_tx_packet(struct qed_hwfn *p_hwfn, 1670int qed_ll2_prepare_tx_packet(struct qed_hwfn *p_hwfn,
@@ -1817,7 +1805,7 @@ int qed_ll2_terminate_connection(struct qed_hwfn *p_hwfn, u8 connection_handle)
1817 qed_ll2_rxq_flush(p_hwfn, connection_handle); 1805 qed_ll2_rxq_flush(p_hwfn, connection_handle);
1818 } 1806 }
1819 1807
1820 if (p_ll2_conn->conn_type == QED_LL2_TYPE_ISCSI_OOO) 1808 if (p_ll2_conn->conn.conn_type == QED_LL2_TYPE_ISCSI_OOO)
1821 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); 1809 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info);
1822 1810
1823 return rc; 1811 return rc;
@@ -1993,7 +1981,7 @@ static void qed_ll2_register_cb_ops(struct qed_dev *cdev,
1993 1981
1994static int qed_ll2_start(struct qed_dev *cdev, struct qed_ll2_params *params) 1982static int qed_ll2_start(struct qed_dev *cdev, struct qed_ll2_params *params)
1995{ 1983{
1996 struct qed_ll2_info ll2_info; 1984 struct qed_ll2_conn ll2_info;
1997 struct qed_ll2_buffer *buffer, *tmp_buffer; 1985 struct qed_ll2_buffer *buffer, *tmp_buffer;
1998 enum qed_ll2_conn_type conn_type; 1986 enum qed_ll2_conn_type conn_type;
1999 struct qed_ptt *p_ptt; 1987 struct qed_ptt *p_ptt;
@@ -2041,6 +2029,7 @@ static int qed_ll2_start(struct qed_dev *cdev, struct qed_ll2_params *params)
2041 2029
2042 /* Prepare the temporary ll2 information */ 2030 /* Prepare the temporary ll2 information */
2043 memset(&ll2_info, 0, sizeof(ll2_info)); 2031 memset(&ll2_info, 0, sizeof(ll2_info));
2032
2044 ll2_info.conn_type = conn_type; 2033 ll2_info.conn_type = conn_type;
2045 ll2_info.mtu = params->mtu; 2034 ll2_info.mtu = params->mtu;
2046 ll2_info.rx_drop_ttl0_flg = params->drop_ttl0_packets; 2035 ll2_info.rx_drop_ttl0_flg = params->drop_ttl0_packets;
@@ -2120,7 +2109,6 @@ static int qed_ll2_start(struct qed_dev *cdev, struct qed_ll2_params *params)
2120 } 2109 }
2121 2110
2122 ether_addr_copy(cdev->ll2_mac_address, params->ll2_mac_address); 2111 ether_addr_copy(cdev->ll2_mac_address, params->ll2_mac_address);
2123
2124 return 0; 2112 return 0;
2125 2113
2126release_terminate_all: 2114release_terminate_all:
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.h b/drivers/net/ethernet/qlogic/qed/qed_ll2.h
index 6625a3ae5a33..31417928b635 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.h
@@ -112,15 +112,8 @@ struct qed_ll2_tx_queue {
112 bool b_completing_packet; 112 bool b_completing_packet;
113}; 113};
114 114
115struct qed_ll2_info { 115struct qed_ll2_conn {
116 /* Lock protecting the state of LL2 */
117 struct mutex mutex;
118 enum qed_ll2_conn_type conn_type; 116 enum qed_ll2_conn_type conn_type;
119 u32 cid;
120 u8 my_id;
121 u8 queue_id;
122 u8 tx_stats_id;
123 bool b_active;
124 u16 mtu; 117 u16 mtu;
125 u8 rx_drop_ttl0_flg; 118 u8 rx_drop_ttl0_flg;
126 u8 rx_vlan_removal_en; 119 u8 rx_vlan_removal_en;
@@ -128,10 +121,21 @@ struct qed_ll2_info {
128 enum core_tx_dest tx_dest; 121 enum core_tx_dest tx_dest;
129 enum core_error_handle ai_err_packet_too_big; 122 enum core_error_handle ai_err_packet_too_big;
130 enum core_error_handle ai_err_no_buf; 123 enum core_error_handle ai_err_no_buf;
124 u8 gsi_enable;
125};
126
127struct qed_ll2_info {
128 /* Lock protecting the state of LL2 */
129 struct mutex mutex;
130 struct qed_ll2_conn conn;
131 u32 cid;
132 u8 my_id;
133 u8 queue_id;
134 u8 tx_stats_id;
135 bool b_active;
131 u8 tx_stats_en; 136 u8 tx_stats_en;
132 struct qed_ll2_rx_queue rx_queue; 137 struct qed_ll2_rx_queue rx_queue;
133 struct qed_ll2_tx_queue tx_queue; 138 struct qed_ll2_tx_queue tx_queue;
134 u8 gsi_enable;
135}; 139};
136 140
137/** 141/**
@@ -149,7 +153,7 @@ struct qed_ll2_info {
149 * @return 0 on success, failure otherwise 153 * @return 0 on success, failure otherwise
150 */ 154 */
151int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn, 155int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn,
152 struct qed_ll2_info *p_params, 156 struct qed_ll2_conn *p_params,
153 u16 rx_num_desc, 157 u16 rx_num_desc,
154 u16 tx_num_desc, 158 u16 tx_num_desc,
155 u8 *p_connection_handle); 159 u8 *p_connection_handle);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c
index 2a16547c8966..2dbdb3298991 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_roce.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c
@@ -2632,7 +2632,7 @@ static int qed_roce_ll2_start(struct qed_dev *cdev,
2632{ 2632{
2633 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); 2633 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2634 struct qed_roce_ll2_info *roce_ll2; 2634 struct qed_roce_ll2_info *roce_ll2;
2635 struct qed_ll2_info ll2_params; 2635 struct qed_ll2_conn ll2_params;
2636 int rc; 2636 int rc;
2637 2637
2638 if (!params) { 2638 if (!params) {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 89ac1e3f6175..301f48755093 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -179,6 +179,49 @@ static struct mdiobb_ops bb_ops = {
179 .get_mdio_data = ravb_get_mdio_data, 179 .get_mdio_data = ravb_get_mdio_data,
180}; 180};
181 181
182/* Free TX skb function for AVB-IP */
183static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
184{
185 struct ravb_private *priv = netdev_priv(ndev);
186 struct net_device_stats *stats = &priv->stats[q];
187 struct ravb_tx_desc *desc;
188 int free_num = 0;
189 int entry;
190 u32 size;
191
192 for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
193 bool txed;
194
195 entry = priv->dirty_tx[q] % (priv->num_tx_ring[q] *
196 NUM_TX_DESC);
197 desc = &priv->tx_ring[q][entry];
198 txed = desc->die_dt == DT_FEMPTY;
199 if (free_txed_only && !txed)
200 break;
201 /* Descriptor type must be checked before all other reads */
202 dma_rmb();
203 size = le16_to_cpu(desc->ds_tagl) & TX_DS;
204 /* Free the original skb. */
205 if (priv->tx_skb[q][entry / NUM_TX_DESC]) {
206 dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
207 size, DMA_TO_DEVICE);
208 /* Last packet descriptor? */
209 if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) {
210 entry /= NUM_TX_DESC;
211 dev_kfree_skb_any(priv->tx_skb[q][entry]);
212 priv->tx_skb[q][entry] = NULL;
213 if (txed)
214 stats->tx_packets++;
215 }
216 free_num++;
217 }
218 if (txed)
219 stats->tx_bytes += size;
220 desc->die_dt = DT_EEMPTY;
221 }
222 return free_num;
223}
224
182/* Free skb's and DMA buffers for Ethernet AVB */ 225/* Free skb's and DMA buffers for Ethernet AVB */
183static void ravb_ring_free(struct net_device *ndev, int q) 226static void ravb_ring_free(struct net_device *ndev, int q)
184{ 227{
@@ -194,19 +237,21 @@ static void ravb_ring_free(struct net_device *ndev, int q)
194 kfree(priv->rx_skb[q]); 237 kfree(priv->rx_skb[q]);
195 priv->rx_skb[q] = NULL; 238 priv->rx_skb[q] = NULL;
196 239
197 /* Free TX skb ringbuffer */
198 if (priv->tx_skb[q]) {
199 for (i = 0; i < priv->num_tx_ring[q]; i++)
200 dev_kfree_skb(priv->tx_skb[q][i]);
201 }
202 kfree(priv->tx_skb[q]);
203 priv->tx_skb[q] = NULL;
204
205 /* Free aligned TX buffers */ 240 /* Free aligned TX buffers */
206 kfree(priv->tx_align[q]); 241 kfree(priv->tx_align[q]);
207 priv->tx_align[q] = NULL; 242 priv->tx_align[q] = NULL;
208 243
209 if (priv->rx_ring[q]) { 244 if (priv->rx_ring[q]) {
245 for (i = 0; i < priv->num_rx_ring[q]; i++) {
246 struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
247
248 if (!dma_mapping_error(ndev->dev.parent,
249 le32_to_cpu(desc->dptr)))
250 dma_unmap_single(ndev->dev.parent,
251 le32_to_cpu(desc->dptr),
252 PKT_BUF_SZ,
253 DMA_FROM_DEVICE);
254 }
210 ring_size = sizeof(struct ravb_ex_rx_desc) * 255 ring_size = sizeof(struct ravb_ex_rx_desc) *
211 (priv->num_rx_ring[q] + 1); 256 (priv->num_rx_ring[q] + 1);
212 dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q], 257 dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q],
@@ -215,12 +260,20 @@ static void ravb_ring_free(struct net_device *ndev, int q)
215 } 260 }
216 261
217 if (priv->tx_ring[q]) { 262 if (priv->tx_ring[q]) {
263 ravb_tx_free(ndev, q, false);
264
218 ring_size = sizeof(struct ravb_tx_desc) * 265 ring_size = sizeof(struct ravb_tx_desc) *
219 (priv->num_tx_ring[q] * NUM_TX_DESC + 1); 266 (priv->num_tx_ring[q] * NUM_TX_DESC + 1);
220 dma_free_coherent(ndev->dev.parent, ring_size, priv->tx_ring[q], 267 dma_free_coherent(ndev->dev.parent, ring_size, priv->tx_ring[q],
221 priv->tx_desc_dma[q]); 268 priv->tx_desc_dma[q]);
222 priv->tx_ring[q] = NULL; 269 priv->tx_ring[q] = NULL;
223 } 270 }
271
272 /* Free TX skb ringbuffer.
273 * SKBs are freed by ravb_tx_free() call above.
274 */
275 kfree(priv->tx_skb[q]);
276 priv->tx_skb[q] = NULL;
224} 277}
225 278
226/* Format skb and descriptor buffer for Ethernet AVB */ 279/* Format skb and descriptor buffer for Ethernet AVB */
@@ -431,44 +484,6 @@ static int ravb_dmac_init(struct net_device *ndev)
431 return 0; 484 return 0;
432} 485}
433 486
434/* Free TX skb function for AVB-IP */
435static int ravb_tx_free(struct net_device *ndev, int q)
436{
437 struct ravb_private *priv = netdev_priv(ndev);
438 struct net_device_stats *stats = &priv->stats[q];
439 struct ravb_tx_desc *desc;
440 int free_num = 0;
441 int entry;
442 u32 size;
443
444 for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
445 entry = priv->dirty_tx[q] % (priv->num_tx_ring[q] *
446 NUM_TX_DESC);
447 desc = &priv->tx_ring[q][entry];
448 if (desc->die_dt != DT_FEMPTY)
449 break;
450 /* Descriptor type must be checked before all other reads */
451 dma_rmb();
452 size = le16_to_cpu(desc->ds_tagl) & TX_DS;
453 /* Free the original skb. */
454 if (priv->tx_skb[q][entry / NUM_TX_DESC]) {
455 dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
456 size, DMA_TO_DEVICE);
457 /* Last packet descriptor? */
458 if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) {
459 entry /= NUM_TX_DESC;
460 dev_kfree_skb_any(priv->tx_skb[q][entry]);
461 priv->tx_skb[q][entry] = NULL;
462 stats->tx_packets++;
463 }
464 free_num++;
465 }
466 stats->tx_bytes += size;
467 desc->die_dt = DT_EEMPTY;
468 }
469 return free_num;
470}
471
472static void ravb_get_tx_tstamp(struct net_device *ndev) 487static void ravb_get_tx_tstamp(struct net_device *ndev)
473{ 488{
474 struct ravb_private *priv = netdev_priv(ndev); 489 struct ravb_private *priv = netdev_priv(ndev);
@@ -902,7 +917,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
902 spin_lock_irqsave(&priv->lock, flags); 917 spin_lock_irqsave(&priv->lock, flags);
903 /* Clear TX interrupt */ 918 /* Clear TX interrupt */
904 ravb_write(ndev, ~mask, TIS); 919 ravb_write(ndev, ~mask, TIS);
905 ravb_tx_free(ndev, q); 920 ravb_tx_free(ndev, q, true);
906 netif_wake_subqueue(ndev, q); 921 netif_wake_subqueue(ndev, q);
907 mmiowb(); 922 mmiowb();
908 spin_unlock_irqrestore(&priv->lock, flags); 923 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1567,7 +1582,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1567 1582
1568 priv->cur_tx[q] += NUM_TX_DESC; 1583 priv->cur_tx[q] += NUM_TX_DESC;
1569 if (priv->cur_tx[q] - priv->dirty_tx[q] > 1584 if (priv->cur_tx[q] - priv->dirty_tx[q] >
1570 (priv->num_tx_ring[q] - 1) * NUM_TX_DESC && !ravb_tx_free(ndev, q)) 1585 (priv->num_tx_ring[q] - 1) * NUM_TX_DESC &&
1586 !ravb_tx_free(ndev, q, true))
1571 netif_stop_subqueue(ndev, q); 1587 netif_stop_subqueue(ndev, q);
1572 1588
1573exit: 1589exit:
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 082cd48db6a7..36942f5a6a53 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -351,6 +351,7 @@ void stmmac_remove_config_dt(struct platform_device *pdev,
351 if (of_phy_is_fixed_link(np)) 351 if (of_phy_is_fixed_link(np))
352 of_phy_deregister_fixed_link(np); 352 of_phy_deregister_fixed_link(np);
353 of_node_put(plat->phy_node); 353 of_node_put(plat->phy_node);
354 of_node_put(plat->mdio_node);
354} 355}
355#else 356#else
356struct plat_stmmacenet_data * 357struct plat_stmmacenet_data *
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 8b6810bad54b..99d3df788ce8 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -69,7 +69,6 @@ struct gtp_dev {
69 struct socket *sock0; 69 struct socket *sock0;
70 struct socket *sock1u; 70 struct socket *sock1u;
71 71
72 struct net *net;
73 struct net_device *dev; 72 struct net_device *dev;
74 73
75 unsigned int hash_size; 74 unsigned int hash_size;
@@ -316,7 +315,7 @@ static int gtp_encap_recv(struct sock *sk, struct sk_buff *skb)
316 315
317 netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk); 316 netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk);
318 317
319 xnet = !net_eq(gtp->net, dev_net(gtp->dev)); 318 xnet = !net_eq(sock_net(sk), dev_net(gtp->dev));
320 319
321 switch (udp_sk(sk)->encap_type) { 320 switch (udp_sk(sk)->encap_type) {
322 case UDP_ENCAP_GTP0: 321 case UDP_ENCAP_GTP0:
@@ -612,7 +611,7 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)
612 pktinfo.fl4.saddr, pktinfo.fl4.daddr, 611 pktinfo.fl4.saddr, pktinfo.fl4.daddr,
613 pktinfo.iph->tos, 612 pktinfo.iph->tos,
614 ip4_dst_hoplimit(&pktinfo.rt->dst), 613 ip4_dst_hoplimit(&pktinfo.rt->dst),
615 htons(IP_DF), 614 0,
616 pktinfo.gtph_port, pktinfo.gtph_port, 615 pktinfo.gtph_port, pktinfo.gtph_port,
617 true, false); 616 true, false);
618 break; 617 break;
@@ -658,7 +657,7 @@ static void gtp_link_setup(struct net_device *dev)
658static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize); 657static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize);
659static void gtp_hashtable_free(struct gtp_dev *gtp); 658static void gtp_hashtable_free(struct gtp_dev *gtp);
660static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp, 659static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp,
661 int fd_gtp0, int fd_gtp1, struct net *src_net); 660 int fd_gtp0, int fd_gtp1);
662 661
663static int gtp_newlink(struct net *src_net, struct net_device *dev, 662static int gtp_newlink(struct net *src_net, struct net_device *dev,
664 struct nlattr *tb[], struct nlattr *data[]) 663 struct nlattr *tb[], struct nlattr *data[])
@@ -675,7 +674,7 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
675 fd0 = nla_get_u32(data[IFLA_GTP_FD0]); 674 fd0 = nla_get_u32(data[IFLA_GTP_FD0]);
676 fd1 = nla_get_u32(data[IFLA_GTP_FD1]); 675 fd1 = nla_get_u32(data[IFLA_GTP_FD1]);
677 676
678 err = gtp_encap_enable(dev, gtp, fd0, fd1, src_net); 677 err = gtp_encap_enable(dev, gtp, fd0, fd1);
679 if (err < 0) 678 if (err < 0)
680 goto out_err; 679 goto out_err;
681 680
@@ -821,7 +820,7 @@ static void gtp_hashtable_free(struct gtp_dev *gtp)
821} 820}
822 821
823static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp, 822static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp,
824 int fd_gtp0, int fd_gtp1, struct net *src_net) 823 int fd_gtp0, int fd_gtp1)
825{ 824{
826 struct udp_tunnel_sock_cfg tuncfg = {NULL}; 825 struct udp_tunnel_sock_cfg tuncfg = {NULL};
827 struct socket *sock0, *sock1u; 826 struct socket *sock0, *sock1u;
@@ -858,7 +857,6 @@ static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp,
858 857
859 gtp->sock0 = sock0; 858 gtp->sock0 = sock0;
860 gtp->sock1u = sock1u; 859 gtp->sock1u = sock1u;
861 gtp->net = src_net;
862 860
863 tuncfg.sk_user_data = gtp; 861 tuncfg.sk_user_data = gtp;
864 tuncfg.encap_rcv = gtp_encap_recv; 862 tuncfg.encap_rcv = gtp_encap_recv;
@@ -1376,3 +1374,4 @@ MODULE_LICENSE("GPL");
1376MODULE_AUTHOR("Harald Welte <hwelte@sysmocom.de>"); 1374MODULE_AUTHOR("Harald Welte <hwelte@sysmocom.de>");
1377MODULE_DESCRIPTION("Interface driver for GTP encapsulated traffic"); 1375MODULE_DESCRIPTION("Interface driver for GTP encapsulated traffic");
1378MODULE_ALIAS_RTNL_LINK("gtp"); 1376MODULE_ALIAS_RTNL_LINK("gtp");
1377MODULE_ALIAS_GENL_FAMILY("gtp");
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 5c26653eceb5..402618565838 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -825,7 +825,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
825 return -EINVAL; 825 return -EINVAL;
826 826
827 if (virtio_net_hdr_from_skb(skb, &vnet_hdr, 827 if (virtio_net_hdr_from_skb(skb, &vnet_hdr,
828 macvtap_is_little_endian(q))) 828 macvtap_is_little_endian(q), true))
829 BUG(); 829 BUG();
830 830
831 if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) != 831 if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) !=
diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
index e741bf614c4e..b0492ef2cdaa 100644
--- a/drivers/net/phy/bcm63xx.c
+++ b/drivers/net/phy/bcm63xx.c
@@ -21,6 +21,23 @@ MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
21MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); 21MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
22MODULE_LICENSE("GPL"); 22MODULE_LICENSE("GPL");
23 23
24static int bcm63xx_config_intr(struct phy_device *phydev)
25{
26 int reg, err;
27
28 reg = phy_read(phydev, MII_BCM63XX_IR);
29 if (reg < 0)
30 return reg;
31
32 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
33 reg &= ~MII_BCM63XX_IR_GMASK;
34 else
35 reg |= MII_BCM63XX_IR_GMASK;
36
37 err = phy_write(phydev, MII_BCM63XX_IR, reg);
38 return err;
39}
40
24static int bcm63xx_config_init(struct phy_device *phydev) 41static int bcm63xx_config_init(struct phy_device *phydev)
25{ 42{
26 int reg, err; 43 int reg, err;
@@ -55,7 +72,7 @@ static struct phy_driver bcm63xx_driver[] = {
55 .config_aneg = genphy_config_aneg, 72 .config_aneg = genphy_config_aneg,
56 .read_status = genphy_read_status, 73 .read_status = genphy_read_status,
57 .ack_interrupt = bcm_phy_ack_intr, 74 .ack_interrupt = bcm_phy_ack_intr,
58 .config_intr = bcm_phy_config_intr, 75 .config_intr = bcm63xx_config_intr,
59}, { 76}, {
60 /* same phy as above, with just a different OUI */ 77 /* same phy as above, with just a different OUI */
61 .phy_id = 0x002bdc00, 78 .phy_id = 0x002bdc00,
@@ -67,7 +84,7 @@ static struct phy_driver bcm63xx_driver[] = {
67 .config_aneg = genphy_config_aneg, 84 .config_aneg = genphy_config_aneg,
68 .read_status = genphy_read_status, 85 .read_status = genphy_read_status,
69 .ack_interrupt = bcm_phy_ack_intr, 86 .ack_interrupt = bcm_phy_ack_intr,
70 .config_intr = bcm_phy_config_intr, 87 .config_intr = bcm63xx_config_intr,
71} }; 88} };
72 89
73module_phy_driver(bcm63xx_driver); 90module_phy_driver(bcm63xx_driver);
diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 800b39f06279..a10d0e7fc5f7 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -17,6 +17,7 @@
17#include <linux/phy.h> 17#include <linux/phy.h>
18 18
19#define TI_DP83848C_PHY_ID 0x20005ca0 19#define TI_DP83848C_PHY_ID 0x20005ca0
20#define TI_DP83620_PHY_ID 0x20005ce0
20#define NS_DP83848C_PHY_ID 0x20005c90 21#define NS_DP83848C_PHY_ID 0x20005c90
21#define TLK10X_PHY_ID 0x2000a210 22#define TLK10X_PHY_ID 0x2000a210
22#define TI_DP83822_PHY_ID 0x2000a240 23#define TI_DP83822_PHY_ID 0x2000a240
@@ -77,6 +78,7 @@ static int dp83848_config_intr(struct phy_device *phydev)
77static struct mdio_device_id __maybe_unused dp83848_tbl[] = { 78static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
78 { TI_DP83848C_PHY_ID, 0xfffffff0 }, 79 { TI_DP83848C_PHY_ID, 0xfffffff0 },
79 { NS_DP83848C_PHY_ID, 0xfffffff0 }, 80 { NS_DP83848C_PHY_ID, 0xfffffff0 },
81 { TI_DP83620_PHY_ID, 0xfffffff0 },
80 { TLK10X_PHY_ID, 0xfffffff0 }, 82 { TLK10X_PHY_ID, 0xfffffff0 },
81 { TI_DP83822_PHY_ID, 0xfffffff0 }, 83 { TI_DP83822_PHY_ID, 0xfffffff0 },
82 { } 84 { }
@@ -106,6 +108,7 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
106static struct phy_driver dp83848_driver[] = { 108static struct phy_driver dp83848_driver[] = {
107 DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"), 109 DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
108 DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"), 110 DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"),
111 DP83848_PHY_DRIVER(TI_DP83620_PHY_ID, "TI DP83620 10/100 Mbps PHY"),
109 DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"), 112 DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"),
110 DP83848_PHY_DRIVER(TI_DP83822_PHY_ID, "TI DP83822 10/100 Mbps PHY"), 113 DP83848_PHY_DRIVER(TI_DP83822_PHY_ID, "TI DP83822 10/100 Mbps PHY"),
111}; 114};
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 0b78210c0fa7..ed0d235cf850 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1679,6 +1679,8 @@ static struct phy_driver marvell_drivers[] = {
1679 .ack_interrupt = &marvell_ack_interrupt, 1679 .ack_interrupt = &marvell_ack_interrupt,
1680 .config_intr = &marvell_config_intr, 1680 .config_intr = &marvell_config_intr,
1681 .did_interrupt = &m88e1121_did_interrupt, 1681 .did_interrupt = &m88e1121_did_interrupt,
1682 .get_wol = &m88e1318_get_wol,
1683 .set_wol = &m88e1318_set_wol,
1682 .resume = &marvell_resume, 1684 .resume = &marvell_resume,
1683 .suspend = &marvell_suspend, 1685 .suspend = &marvell_suspend,
1684 .get_sset_count = marvell_get_sset_count, 1686 .get_sset_count = marvell_get_sset_count,
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 9a77289109b7..e55809c5beb7 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1008,6 +1008,20 @@ static struct phy_driver ksphy_driver[] = {
1008 .get_stats = kszphy_get_stats, 1008 .get_stats = kszphy_get_stats,
1009 .suspend = genphy_suspend, 1009 .suspend = genphy_suspend,
1010 .resume = genphy_resume, 1010 .resume = genphy_resume,
1011}, {
1012 .phy_id = PHY_ID_KSZ8795,
1013 .phy_id_mask = MICREL_PHY_ID_MASK,
1014 .name = "Micrel KSZ8795",
1015 .features = (SUPPORTED_Pause | SUPPORTED_Asym_Pause),
1016 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
1017 .config_init = kszphy_config_init,
1018 .config_aneg = ksz8873mll_config_aneg,
1019 .read_status = ksz8873mll_read_status,
1020 .get_sset_count = kszphy_get_sset_count,
1021 .get_strings = kszphy_get_strings,
1022 .get_stats = kszphy_get_stats,
1023 .suspend = genphy_suspend,
1024 .resume = genphy_resume,
1011} }; 1025} };
1012 1026
1013module_phy_driver(ksphy_driver); 1027module_phy_driver(ksphy_driver);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 48da6e93c3f7..7cc1b7dcfe05 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -29,6 +29,7 @@
29#include <linux/mii.h> 29#include <linux/mii.h>
30#include <linux/ethtool.h> 30#include <linux/ethtool.h>
31#include <linux/phy.h> 31#include <linux/phy.h>
32#include <linux/phy_led_triggers.h>
32#include <linux/timer.h> 33#include <linux/timer.h>
33#include <linux/workqueue.h> 34#include <linux/workqueue.h>
34#include <linux/mdio.h> 35#include <linux/mdio.h>
@@ -649,14 +650,18 @@ void phy_start_machine(struct phy_device *phydev)
649 * phy_trigger_machine - trigger the state machine to run 650 * phy_trigger_machine - trigger the state machine to run
650 * 651 *
651 * @phydev: the phy_device struct 652 * @phydev: the phy_device struct
653 * @sync: indicate whether we should wait for the workqueue cancelation
652 * 654 *
653 * Description: There has been a change in state which requires that the 655 * Description: There has been a change in state which requires that the
654 * state machine runs. 656 * state machine runs.
655 */ 657 */
656 658
657static void phy_trigger_machine(struct phy_device *phydev) 659static void phy_trigger_machine(struct phy_device *phydev, bool sync)
658{ 660{
659 cancel_delayed_work_sync(&phydev->state_queue); 661 if (sync)
662 cancel_delayed_work_sync(&phydev->state_queue);
663 else
664 cancel_delayed_work(&phydev->state_queue);
660 queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0); 665 queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0);
661} 666}
662 667
@@ -693,7 +698,7 @@ static void phy_error(struct phy_device *phydev)
693 phydev->state = PHY_HALTED; 698 phydev->state = PHY_HALTED;
694 mutex_unlock(&phydev->lock); 699 mutex_unlock(&phydev->lock);
695 700
696 phy_trigger_machine(phydev); 701 phy_trigger_machine(phydev, false);
697} 702}
698 703
699/** 704/**
@@ -840,7 +845,7 @@ void phy_change(struct phy_device *phydev)
840 } 845 }
841 846
842 /* reschedule state queue work to run as soon as possible */ 847 /* reschedule state queue work to run as soon as possible */
843 phy_trigger_machine(phydev); 848 phy_trigger_machine(phydev, true);
844 return; 849 return;
845 850
846ignore: 851ignore:
@@ -942,7 +947,7 @@ void phy_start(struct phy_device *phydev)
942 if (do_resume) 947 if (do_resume)
943 phy_resume(phydev); 948 phy_resume(phydev);
944 949
945 phy_trigger_machine(phydev); 950 phy_trigger_machine(phydev, true);
946} 951}
947EXPORT_SYMBOL(phy_start); 952EXPORT_SYMBOL(phy_start);
948 953
diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c
index fa62bdf2f526..94ca42e630bb 100644
--- a/drivers/net/phy/phy_led_triggers.c
+++ b/drivers/net/phy/phy_led_triggers.c
@@ -12,6 +12,7 @@
12 */ 12 */
13#include <linux/leds.h> 13#include <linux/leds.h>
14#include <linux/phy.h> 14#include <linux/phy.h>
15#include <linux/phy_led_triggers.h>
15#include <linux/netdevice.h> 16#include <linux/netdevice.h>
16 17
17static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy, 18static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy,
@@ -102,8 +103,10 @@ int phy_led_triggers_register(struct phy_device *phy)
102 sizeof(struct phy_led_trigger) * 103 sizeof(struct phy_led_trigger) *
103 phy->phy_num_led_triggers, 104 phy->phy_num_led_triggers,
104 GFP_KERNEL); 105 GFP_KERNEL);
105 if (!phy->phy_led_triggers) 106 if (!phy->phy_led_triggers) {
106 return -ENOMEM; 107 err = -ENOMEM;
108 goto out_clear;
109 }
107 110
108 for (i = 0; i < phy->phy_num_led_triggers; i++) { 111 for (i = 0; i < phy->phy_num_led_triggers; i++) {
109 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], 112 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i],
@@ -120,6 +123,8 @@ out_unreg:
120 while (i--) 123 while (i--)
121 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); 124 phy_led_trigger_unregister(&phy->phy_led_triggers[i]);
122 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); 125 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers);
126out_clear:
127 phy->phy_num_led_triggers = 0;
123 return err; 128 return err;
124} 129}
125EXPORT_SYMBOL_GPL(phy_led_triggers_register); 130EXPORT_SYMBOL_GPL(phy_led_triggers_register);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index cd8e02c94be0..2cd10b26b650 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1360,7 +1360,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1360 return -EINVAL; 1360 return -EINVAL;
1361 1361
1362 if (virtio_net_hdr_from_skb(skb, &gso, 1362 if (virtio_net_hdr_from_skb(skb, &gso,
1363 tun_is_little_endian(tun))) { 1363 tun_is_little_endian(tun), true)) {
1364 struct skb_shared_info *sinfo = skb_shinfo(skb); 1364 struct skb_shared_info *sinfo = skb_shinfo(skb);
1365 pr_err("unexpected GSO type: " 1365 pr_err("unexpected GSO type: "
1366 "0x%x, gso_size %d, hdr_len %d\n", 1366 "0x%x, gso_size %d, hdr_len %d\n",
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index fe7b2886cb6b..86144f9a80ee 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -531,6 +531,7 @@ static const struct driver_info wwan_info = {
531#define SAMSUNG_VENDOR_ID 0x04e8 531#define SAMSUNG_VENDOR_ID 0x04e8
532#define LENOVO_VENDOR_ID 0x17ef 532#define LENOVO_VENDOR_ID 0x17ef
533#define NVIDIA_VENDOR_ID 0x0955 533#define NVIDIA_VENDOR_ID 0x0955
534#define HP_VENDOR_ID 0x03f0
534 535
535static const struct usb_device_id products[] = { 536static const struct usb_device_id products[] = {
536/* BLACKLIST !! 537/* BLACKLIST !!
@@ -677,6 +678,13 @@ static const struct usb_device_id products[] = {
677 .driver_info = 0, 678 .driver_info = 0,
678}, 679},
679 680
681/* HP lt2523 (Novatel E371) - handled by qmi_wwan */
682{
683 USB_DEVICE_AND_INTERFACE_INFO(HP_VENDOR_ID, 0x421d, USB_CLASS_COMM,
684 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
685 .driver_info = 0,
686},
687
680/* AnyDATA ADU960S - handled by qmi_wwan */ 688/* AnyDATA ADU960S - handled by qmi_wwan */
681{ 689{
682 USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM, 690 USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 6fe1cdb0174f..24d5272cdce5 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -654,6 +654,13 @@ static const struct usb_device_id products[] = {
654 USB_CDC_PROTO_NONE), 654 USB_CDC_PROTO_NONE),
655 .driver_info = (unsigned long)&qmi_wwan_info, 655 .driver_info = (unsigned long)&qmi_wwan_info,
656 }, 656 },
657 { /* HP lt2523 (Novatel E371) */
658 USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d,
659 USB_CLASS_COMM,
660 USB_CDC_SUBCLASS_ETHERNET,
661 USB_CDC_PROTO_NONE),
662 .driver_info = (unsigned long)&qmi_wwan_info,
663 },
657 { /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */ 664 { /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
658 USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), 665 USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7),
659 .driver_info = (unsigned long)&qmi_wwan_info, 666 .driver_info = (unsigned long)&qmi_wwan_info,
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f3b48ad90865..ad42295356dd 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -32,7 +32,7 @@
32#define NETNEXT_VERSION "08" 32#define NETNEXT_VERSION "08"
33 33
34/* Information for net */ 34/* Information for net */
35#define NET_VERSION "6" 35#define NET_VERSION "8"
36 36
37#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION 37#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
38#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" 38#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
@@ -1936,6 +1936,9 @@ static int r8152_poll(struct napi_struct *napi, int budget)
1936 napi_complete(napi); 1936 napi_complete(napi);
1937 if (!list_empty(&tp->rx_done)) 1937 if (!list_empty(&tp->rx_done))
1938 napi_schedule(napi); 1938 napi_schedule(napi);
1939 else if (!skb_queue_empty(&tp->tx_queue) &&
1940 !list_empty(&tp->tx_free))
1941 napi_schedule(napi);
1939 } 1942 }
1940 1943
1941 return work_done; 1944 return work_done;
@@ -3155,10 +3158,13 @@ static void set_carrier(struct r8152 *tp)
3155 if (!netif_carrier_ok(netdev)) { 3158 if (!netif_carrier_ok(netdev)) {
3156 tp->rtl_ops.enable(tp); 3159 tp->rtl_ops.enable(tp);
3157 set_bit(RTL8152_SET_RX_MODE, &tp->flags); 3160 set_bit(RTL8152_SET_RX_MODE, &tp->flags);
3161 netif_stop_queue(netdev);
3158 napi_disable(&tp->napi); 3162 napi_disable(&tp->napi);
3159 netif_carrier_on(netdev); 3163 netif_carrier_on(netdev);
3160 rtl_start_rx(tp); 3164 rtl_start_rx(tp);
3161 napi_enable(&tp->napi); 3165 napi_enable(&tp->napi);
3166 netif_wake_queue(netdev);
3167 netif_info(tp, link, netdev, "carrier on\n");
3162 } 3168 }
3163 } else { 3169 } else {
3164 if (netif_carrier_ok(netdev)) { 3170 if (netif_carrier_ok(netdev)) {
@@ -3166,6 +3172,7 @@ static void set_carrier(struct r8152 *tp)
3166 napi_disable(&tp->napi); 3172 napi_disable(&tp->napi);
3167 tp->rtl_ops.disable(tp); 3173 tp->rtl_ops.disable(tp);
3168 napi_enable(&tp->napi); 3174 napi_enable(&tp->napi);
3175 netif_info(tp, link, netdev, "carrier off\n");
3169 } 3176 }
3170 } 3177 }
3171} 3178}
@@ -3515,12 +3522,12 @@ static int rtl8152_pre_reset(struct usb_interface *intf)
3515 if (!netif_running(netdev)) 3522 if (!netif_running(netdev))
3516 return 0; 3523 return 0;
3517 3524
3525 netif_stop_queue(netdev);
3518 napi_disable(&tp->napi); 3526 napi_disable(&tp->napi);
3519 clear_bit(WORK_ENABLE, &tp->flags); 3527 clear_bit(WORK_ENABLE, &tp->flags);
3520 usb_kill_urb(tp->intr_urb); 3528 usb_kill_urb(tp->intr_urb);
3521 cancel_delayed_work_sync(&tp->schedule); 3529 cancel_delayed_work_sync(&tp->schedule);
3522 if (netif_carrier_ok(netdev)) { 3530 if (netif_carrier_ok(netdev)) {
3523 netif_stop_queue(netdev);
3524 mutex_lock(&tp->control); 3531 mutex_lock(&tp->control);
3525 tp->rtl_ops.disable(tp); 3532 tp->rtl_ops.disable(tp);
3526 mutex_unlock(&tp->control); 3533 mutex_unlock(&tp->control);
@@ -3545,12 +3552,17 @@ static int rtl8152_post_reset(struct usb_interface *intf)
3545 if (netif_carrier_ok(netdev)) { 3552 if (netif_carrier_ok(netdev)) {
3546 mutex_lock(&tp->control); 3553 mutex_lock(&tp->control);
3547 tp->rtl_ops.enable(tp); 3554 tp->rtl_ops.enable(tp);
3555 rtl_start_rx(tp);
3548 rtl8152_set_rx_mode(netdev); 3556 rtl8152_set_rx_mode(netdev);
3549 mutex_unlock(&tp->control); 3557 mutex_unlock(&tp->control);
3550 netif_wake_queue(netdev);
3551 } 3558 }
3552 3559
3553 napi_enable(&tp->napi); 3560 napi_enable(&tp->napi);
3561 netif_wake_queue(netdev);
3562 usb_submit_urb(tp->intr_urb, GFP_KERNEL);
3563
3564 if (!list_empty(&tp->rx_done))
3565 napi_schedule(&tp->napi);
3554 3566
3555 return 0; 3567 return 0;
3556} 3568}
@@ -3572,6 +3584,8 @@ static bool delay_autosuspend(struct r8152 *tp)
3572 */ 3584 */
3573 if (!sw_linking && tp->rtl_ops.in_nway(tp)) 3585 if (!sw_linking && tp->rtl_ops.in_nway(tp))
3574 return true; 3586 return true;
3587 else if (!skb_queue_empty(&tp->tx_queue))
3588 return true;
3575 else 3589 else
3576 return false; 3590 return false;
3577} 3591}
@@ -3581,10 +3595,15 @@ static int rtl8152_rumtime_suspend(struct r8152 *tp)
3581 struct net_device *netdev = tp->netdev; 3595 struct net_device *netdev = tp->netdev;
3582 int ret = 0; 3596 int ret = 0;
3583 3597
3598 set_bit(SELECTIVE_SUSPEND, &tp->flags);
3599 smp_mb__after_atomic();
3600
3584 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { 3601 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3585 u32 rcr = 0; 3602 u32 rcr = 0;
3586 3603
3587 if (delay_autosuspend(tp)) { 3604 if (delay_autosuspend(tp)) {
3605 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3606 smp_mb__after_atomic();
3588 ret = -EBUSY; 3607 ret = -EBUSY;
3589 goto out1; 3608 goto out1;
3590 } 3609 }
@@ -3601,6 +3620,8 @@ static int rtl8152_rumtime_suspend(struct r8152 *tp)
3601 if (!(ocp_data & RXFIFO_EMPTY)) { 3620 if (!(ocp_data & RXFIFO_EMPTY)) {
3602 rxdy_gated_en(tp, false); 3621 rxdy_gated_en(tp, false);
3603 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr); 3622 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
3623 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3624 smp_mb__after_atomic();
3604 ret = -EBUSY; 3625 ret = -EBUSY;
3605 goto out1; 3626 goto out1;
3606 } 3627 }
@@ -3620,8 +3641,6 @@ static int rtl8152_rumtime_suspend(struct r8152 *tp)
3620 } 3641 }
3621 } 3642 }
3622 3643
3623 set_bit(SELECTIVE_SUSPEND, &tp->flags);
3624
3625out1: 3644out1:
3626 return ret; 3645 return ret;
3627} 3646}
@@ -3677,12 +3696,15 @@ static int rtl8152_resume(struct usb_interface *intf)
3677 if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) { 3696 if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) {
3678 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3697 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3679 tp->rtl_ops.autosuspend_en(tp, false); 3698 tp->rtl_ops.autosuspend_en(tp, false);
3680 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3681 napi_disable(&tp->napi); 3699 napi_disable(&tp->napi);
3682 set_bit(WORK_ENABLE, &tp->flags); 3700 set_bit(WORK_ENABLE, &tp->flags);
3683 if (netif_carrier_ok(tp->netdev)) 3701 if (netif_carrier_ok(tp->netdev))
3684 rtl_start_rx(tp); 3702 rtl_start_rx(tp);
3685 napi_enable(&tp->napi); 3703 napi_enable(&tp->napi);
3704 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3705 smp_mb__after_atomic();
3706 if (!list_empty(&tp->rx_done))
3707 napi_schedule(&tp->napi);
3686 } else { 3708 } else {
3687 tp->rtl_ops.up(tp); 3709 tp->rtl_ops.up(tp);
3688 netif_carrier_off(tp->netdev); 3710 netif_carrier_off(tp->netdev);
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4a105006ca63..765c2d6358da 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -48,8 +48,16 @@ module_param(gso, bool, 0444);
48 */ 48 */
49DECLARE_EWMA(pkt_len, 1, 64) 49DECLARE_EWMA(pkt_len, 1, 64)
50 50
51/* With mergeable buffers we align buffer address and use the low bits to
52 * encode its true size. Buffer size is up to 1 page so we need to align to
53 * square root of page size to ensure we reserve enough bits to encode the true
54 * size.
55 */
56#define MERGEABLE_BUFFER_MIN_ALIGN_SHIFT ((PAGE_SHIFT + 1) / 2)
57
51/* Minimum alignment for mergeable packet buffers. */ 58/* Minimum alignment for mergeable packet buffers. */
52#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256) 59#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, \
60 1 << MERGEABLE_BUFFER_MIN_ALIGN_SHIFT)
53 61
54#define VIRTNET_DRIVER_VERSION "1.0.0" 62#define VIRTNET_DRIVER_VERSION "1.0.0"
55 63
@@ -1104,7 +1112,7 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
1104 hdr = skb_vnet_hdr(skb); 1112 hdr = skb_vnet_hdr(skb);
1105 1113
1106 if (virtio_net_hdr_from_skb(skb, &hdr->hdr, 1114 if (virtio_net_hdr_from_skb(skb, &hdr->hdr,
1107 virtio_is_little_endian(vi->vdev))) 1115 virtio_is_little_endian(vi->vdev), false))
1108 BUG(); 1116 BUG();
1109 1117
1110 if (vi->mergeable_rx_bufs) 1118 if (vi->mergeable_rx_bufs)
@@ -1707,6 +1715,11 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
1707 u16 xdp_qp = 0, curr_qp; 1715 u16 xdp_qp = 0, curr_qp;
1708 int i, err; 1716 int i, err;
1709 1717
1718 if (prog && prog->xdp_adjust_head) {
1719 netdev_warn(dev, "Does not support bpf_xdp_adjust_head()\n");
1720 return -EOPNOTSUPP;
1721 }
1722
1710 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) || 1723 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) ||
1711 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || 1724 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
1712 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || 1725 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
@@ -1890,8 +1903,12 @@ static void free_receive_page_frags(struct virtnet_info *vi)
1890 put_page(vi->rq[i].alloc_frag.page); 1903 put_page(vi->rq[i].alloc_frag.page);
1891} 1904}
1892 1905
1893static bool is_xdp_queue(struct virtnet_info *vi, int q) 1906static bool is_xdp_raw_buffer_queue(struct virtnet_info *vi, int q)
1894{ 1907{
1908 /* For small receive mode always use kfree_skb variants */
1909 if (!vi->mergeable_rx_bufs)
1910 return false;
1911
1895 if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) 1912 if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs))
1896 return false; 1913 return false;
1897 else if (q < vi->curr_queue_pairs) 1914 else if (q < vi->curr_queue_pairs)
@@ -1908,7 +1925,7 @@ static void free_unused_bufs(struct virtnet_info *vi)
1908 for (i = 0; i < vi->max_queue_pairs; i++) { 1925 for (i = 0; i < vi->max_queue_pairs; i++) {
1909 struct virtqueue *vq = vi->sq[i].vq; 1926 struct virtqueue *vq = vi->sq[i].vq;
1910 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { 1927 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) {
1911 if (!is_xdp_queue(vi, i)) 1928 if (!is_xdp_raw_buffer_queue(vi, i))
1912 dev_kfree_skb(buf); 1929 dev_kfree_skb(buf);
1913 else 1930 else
1914 put_page(virt_to_head_page(buf)); 1931 put_page(virt_to_head_page(buf));
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index ca7196c40060..50b62db213b0 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2268,7 +2268,7 @@ static void vxlan_cleanup(unsigned long arg)
2268 = container_of(p, struct vxlan_fdb, hlist); 2268 = container_of(p, struct vxlan_fdb, hlist);
2269 unsigned long timeout; 2269 unsigned long timeout;
2270 2270
2271 if (f->state & NUD_PERMANENT) 2271 if (f->state & (NUD_PERMANENT | NUD_NOARP))
2272 continue; 2272 continue;
2273 2273
2274 timeout = f->used + vxlan->cfg.age_interval * HZ; 2274 timeout = f->used + vxlan->cfg.age_interval * HZ;
@@ -2354,7 +2354,7 @@ static int vxlan_open(struct net_device *dev)
2354} 2354}
2355 2355
2356/* Purge the forwarding table */ 2356/* Purge the forwarding table */
2357static void vxlan_flush(struct vxlan_dev *vxlan) 2357static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all)
2358{ 2358{
2359 unsigned int h; 2359 unsigned int h;
2360 2360
@@ -2364,6 +2364,8 @@ static void vxlan_flush(struct vxlan_dev *vxlan)
2364 hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) { 2364 hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) {
2365 struct vxlan_fdb *f 2365 struct vxlan_fdb *f
2366 = container_of(p, struct vxlan_fdb, hlist); 2366 = container_of(p, struct vxlan_fdb, hlist);
2367 if (!do_all && (f->state & (NUD_PERMANENT | NUD_NOARP)))
2368 continue;
2367 /* the all_zeros_mac entry is deleted at vxlan_uninit */ 2369 /* the all_zeros_mac entry is deleted at vxlan_uninit */
2368 if (!is_zero_ether_addr(f->eth_addr)) 2370 if (!is_zero_ether_addr(f->eth_addr))
2369 vxlan_fdb_destroy(vxlan, f); 2371 vxlan_fdb_destroy(vxlan, f);
@@ -2385,7 +2387,7 @@ static int vxlan_stop(struct net_device *dev)
2385 2387
2386 del_timer_sync(&vxlan->age_timer); 2388 del_timer_sync(&vxlan->age_timer);
2387 2389
2388 vxlan_flush(vxlan); 2390 vxlan_flush(vxlan, false);
2389 vxlan_sock_release(vxlan); 2391 vxlan_sock_release(vxlan);
2390 2392
2391 return ret; 2393 return ret;
@@ -2890,7 +2892,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
2890 memcpy(&vxlan->cfg, conf, sizeof(*conf)); 2892 memcpy(&vxlan->cfg, conf, sizeof(*conf));
2891 if (!vxlan->cfg.dst_port) { 2893 if (!vxlan->cfg.dst_port) {
2892 if (conf->flags & VXLAN_F_GPE) 2894 if (conf->flags & VXLAN_F_GPE)
2893 vxlan->cfg.dst_port = 4790; /* IANA assigned VXLAN-GPE port */ 2895 vxlan->cfg.dst_port = htons(4790); /* IANA VXLAN-GPE port */
2894 else 2896 else
2895 vxlan->cfg.dst_port = default_port; 2897 vxlan->cfg.dst_port = default_port;
2896 } 2898 }
@@ -3058,6 +3060,8 @@ static void vxlan_dellink(struct net_device *dev, struct list_head *head)
3058 struct vxlan_dev *vxlan = netdev_priv(dev); 3060 struct vxlan_dev *vxlan = netdev_priv(dev);
3059 struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 3061 struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
3060 3062
3063 vxlan_flush(vxlan, true);
3064
3061 spin_lock(&vn->sock_lock); 3065 spin_lock(&vn->sock_lock);
3062 if (!hlist_unhashed(&vxlan->hlist)) 3066 if (!hlist_unhashed(&vxlan->hlist))
3063 hlist_del_rcu(&vxlan->hlist); 3067 hlist_del_rcu(&vxlan->hlist);
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index e30ffd29b7e9..579521327b03 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -221,18 +221,18 @@ static struct net_device_stats *xenvif_get_stats(struct net_device *dev)
221{ 221{
222 struct xenvif *vif = netdev_priv(dev); 222 struct xenvif *vif = netdev_priv(dev);
223 struct xenvif_queue *queue = NULL; 223 struct xenvif_queue *queue = NULL;
224 unsigned int num_queues = vif->num_queues;
225 unsigned long rx_bytes = 0; 224 unsigned long rx_bytes = 0;
226 unsigned long rx_packets = 0; 225 unsigned long rx_packets = 0;
227 unsigned long tx_bytes = 0; 226 unsigned long tx_bytes = 0;
228 unsigned long tx_packets = 0; 227 unsigned long tx_packets = 0;
229 unsigned int index; 228 unsigned int index;
230 229
230 spin_lock(&vif->lock);
231 if (vif->queues == NULL) 231 if (vif->queues == NULL)
232 goto out; 232 goto out;
233 233
234 /* Aggregate tx and rx stats from each queue */ 234 /* Aggregate tx and rx stats from each queue */
235 for (index = 0; index < num_queues; ++index) { 235 for (index = 0; index < vif->num_queues; ++index) {
236 queue = &vif->queues[index]; 236 queue = &vif->queues[index];
237 rx_bytes += queue->stats.rx_bytes; 237 rx_bytes += queue->stats.rx_bytes;
238 rx_packets += queue->stats.rx_packets; 238 rx_packets += queue->stats.rx_packets;
@@ -241,6 +241,8 @@ static struct net_device_stats *xenvif_get_stats(struct net_device *dev)
241 } 241 }
242 242
243out: 243out:
244 spin_unlock(&vif->lock);
245
244 vif->dev->stats.rx_bytes = rx_bytes; 246 vif->dev->stats.rx_bytes = rx_bytes;
245 vif->dev->stats.rx_packets = rx_packets; 247 vif->dev->stats.rx_packets = rx_packets;
246 vif->dev->stats.tx_bytes = tx_bytes; 248 vif->dev->stats.tx_bytes = tx_bytes;
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 3124eaec9427..85b742e1c42f 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -493,11 +493,22 @@ static int backend_create_xenvif(struct backend_info *be)
493static void backend_disconnect(struct backend_info *be) 493static void backend_disconnect(struct backend_info *be)
494{ 494{
495 if (be->vif) { 495 if (be->vif) {
496 unsigned int queue_index;
497
496 xen_unregister_watchers(be->vif); 498 xen_unregister_watchers(be->vif);
497#ifdef CONFIG_DEBUG_FS 499#ifdef CONFIG_DEBUG_FS
498 xenvif_debugfs_delif(be->vif); 500 xenvif_debugfs_delif(be->vif);
499#endif /* CONFIG_DEBUG_FS */ 501#endif /* CONFIG_DEBUG_FS */
500 xenvif_disconnect_data(be->vif); 502 xenvif_disconnect_data(be->vif);
503 for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index)
504 xenvif_deinit_queue(&be->vif->queues[queue_index]);
505
506 spin_lock(&be->vif->lock);
507 vfree(be->vif->queues);
508 be->vif->num_queues = 0;
509 be->vif->queues = NULL;
510 spin_unlock(&be->vif->lock);
511
501 xenvif_disconnect_ctrl(be->vif); 512 xenvif_disconnect_ctrl(be->vif);
502 } 513 }
503} 514}
@@ -1034,6 +1045,8 @@ static void connect(struct backend_info *be)
1034err: 1045err:
1035 if (be->vif->num_queues > 0) 1046 if (be->vif->num_queues > 0)
1036 xenvif_disconnect_data(be->vif); /* Clean up existing queues */ 1047 xenvif_disconnect_data(be->vif); /* Clean up existing queues */
1048 for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index)
1049 xenvif_deinit_queue(&be->vif->queues[queue_index]);
1037 vfree(be->vif->queues); 1050 vfree(be->vif->queues);
1038 be->vif->queues = NULL; 1051 be->vif->queues = NULL;
1039 be->vif->num_queues = 0; 1052 be->vif->num_queues = 0;
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index a479cd99911d..8315fe73ecd0 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -321,7 +321,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
321 queue->rx.req_prod_pvt = req_prod; 321 queue->rx.req_prod_pvt = req_prod;
322 322
323 /* Not enough requests? Try again later. */ 323 /* Not enough requests? Try again later. */
324 if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN) { 324 if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) {
325 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10)); 325 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10));
326 return; 326 return;
327 } 327 }
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 05cf951df3fe..3ed1f3b1d594 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -247,6 +247,8 @@ struct bpf_map * __must_check bpf_map_inc(struct bpf_map *map, bool uref);
247void bpf_map_put_with_uref(struct bpf_map *map); 247void bpf_map_put_with_uref(struct bpf_map *map);
248void bpf_map_put(struct bpf_map *map); 248void bpf_map_put(struct bpf_map *map);
249int bpf_map_precharge_memlock(u32 pages); 249int bpf_map_precharge_memlock(u32 pages);
250void *bpf_map_area_alloc(size_t size);
251void bpf_map_area_free(void *base);
250 252
251extern int sysctl_unprivileged_bpf_disabled; 253extern int sysctl_unprivileged_bpf_disabled;
252 254
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 257173e0095e..f541da68d1e7 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -35,6 +35,8 @@
35#define PHY_ID_KSZ886X 0x00221430 35#define PHY_ID_KSZ886X 0x00221430
36#define PHY_ID_KSZ8863 0x00221435 36#define PHY_ID_KSZ8863 0x00221435
37 37
38#define PHY_ID_KSZ8795 0x00221550
39
38/* struct phy_device dev_flags definitions */ 40/* struct phy_device dev_flags definitions */
39#define MICREL_PHY_50MHZ_CLK 0x00000001 41#define MICREL_PHY_50MHZ_CLK 0x00000001
40#define MICREL_PHY_FXEN 0x00000002 42#define MICREL_PHY_FXEN 0x00000002
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f7d95f644eed..7fc1105605bf 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -25,7 +25,6 @@
25#include <linux/timer.h> 25#include <linux/timer.h>
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/mod_devicetable.h> 27#include <linux/mod_devicetable.h>
28#include <linux/phy_led_triggers.h>
29 28
30#include <linux/atomic.h> 29#include <linux/atomic.h>
31 30
diff --git a/include/linux/phy_led_triggers.h b/include/linux/phy_led_triggers.h
index a2daea0a37d2..b37b05bfd1a6 100644
--- a/include/linux/phy_led_triggers.h
+++ b/include/linux/phy_led_triggers.h
@@ -18,11 +18,11 @@ struct phy_device;
18#ifdef CONFIG_LED_TRIGGER_PHY 18#ifdef CONFIG_LED_TRIGGER_PHY
19 19
20#include <linux/leds.h> 20#include <linux/leds.h>
21#include <linux/phy.h>
21 22
22#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10 23#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10
23#define PHY_MII_BUS_ID_SIZE (20 - 3)
24 24
25#define PHY_LINK_LED_TRIGGER_NAME_SIZE (PHY_MII_BUS_ID_SIZE + \ 25#define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \
26 FIELD_SIZEOF(struct mdio_device, addr)+\ 26 FIELD_SIZEOF(struct mdio_device, addr)+\
27 PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE) 27 PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE)
28 28
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 66204007d7ac..5209b5ed2a64 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -56,7 +56,8 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
56 56
57static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb, 57static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
58 struct virtio_net_hdr *hdr, 58 struct virtio_net_hdr *hdr,
59 bool little_endian) 59 bool little_endian,
60 bool has_data_valid)
60{ 61{
61 memset(hdr, 0, sizeof(*hdr)); /* no info leak */ 62 memset(hdr, 0, sizeof(*hdr)); /* no info leak */
62 63
@@ -91,7 +92,8 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
91 skb_checksum_start_offset(skb)); 92 skb_checksum_start_offset(skb));
92 hdr->csum_offset = __cpu_to_virtio16(little_endian, 93 hdr->csum_offset = __cpu_to_virtio16(little_endian,
93 skb->csum_offset); 94 skb->csum_offset);
94 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 95 } else if (has_data_valid &&
96 skb->ip_summed == CHECKSUM_UNNECESSARY) {
95 hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID; 97 hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
96 } /* else everything is zero */ 98 } /* else everything is zero */
97 99
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 487e57391664..7afe991e900e 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -871,7 +871,7 @@ int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
871 * upper-layer output functions 871 * upper-layer output functions
872 */ 872 */
873int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, 873int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
874 struct ipv6_txoptions *opt, int tclass); 874 __u32 mark, struct ipv6_txoptions *opt, int tclass);
875 875
876int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr); 876int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr);
877 877
diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h
index d4c1c75b8862..73dd87647460 100644
--- a/include/net/lwtunnel.h
+++ b/include/net/lwtunnel.h
@@ -44,6 +44,8 @@ struct lwtunnel_encap_ops {
44 int (*get_encap_size)(struct lwtunnel_state *lwtstate); 44 int (*get_encap_size)(struct lwtunnel_state *lwtstate);
45 int (*cmp_encap)(struct lwtunnel_state *a, struct lwtunnel_state *b); 45 int (*cmp_encap)(struct lwtunnel_state *a, struct lwtunnel_state *b);
46 int (*xmit)(struct sk_buff *skb); 46 int (*xmit)(struct sk_buff *skb);
47
48 struct module *owner;
47}; 49};
48 50
49#ifdef CONFIG_LWTUNNEL 51#ifdef CONFIG_LWTUNNEL
@@ -105,6 +107,8 @@ int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op,
105 unsigned int num); 107 unsigned int num);
106int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op, 108int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
107 unsigned int num); 109 unsigned int num);
110int lwtunnel_valid_encap_type(u16 encap_type);
111int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len);
108int lwtunnel_build_state(struct net_device *dev, u16 encap_type, 112int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
109 struct nlattr *encap, 113 struct nlattr *encap,
110 unsigned int family, const void *cfg, 114 unsigned int family, const void *cfg,
@@ -168,6 +172,15 @@ static inline int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
168 return -EOPNOTSUPP; 172 return -EOPNOTSUPP;
169} 173}
170 174
175static inline int lwtunnel_valid_encap_type(u16 encap_type)
176{
177 return -EOPNOTSUPP;
178}
179static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len)
180{
181 return -EOPNOTSUPP;
182}
183
171static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type, 184static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
172 struct nlattr *encap, 185 struct nlattr *encap,
173 unsigned int family, const void *cfg, 186 unsigned int family, const void *cfg,
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 924325c46aab..7dfdb517f0be 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -207,9 +207,9 @@ struct nft_set_iter {
207 unsigned int skip; 207 unsigned int skip;
208 int err; 208 int err;
209 int (*fn)(const struct nft_ctx *ctx, 209 int (*fn)(const struct nft_ctx *ctx,
210 const struct nft_set *set, 210 struct nft_set *set,
211 const struct nft_set_iter *iter, 211 const struct nft_set_iter *iter,
212 const struct nft_set_elem *elem); 212 struct nft_set_elem *elem);
213}; 213};
214 214
215/** 215/**
@@ -301,7 +301,7 @@ struct nft_set_ops {
301 void (*remove)(const struct nft_set *set, 301 void (*remove)(const struct nft_set *set,
302 const struct nft_set_elem *elem); 302 const struct nft_set_elem *elem);
303 void (*walk)(const struct nft_ctx *ctx, 303 void (*walk)(const struct nft_ctx *ctx,
304 const struct nft_set *set, 304 struct nft_set *set,
305 struct nft_set_iter *iter); 305 struct nft_set_iter *iter);
306 306
307 unsigned int (*privsize)(const struct nlattr * const nla[]); 307 unsigned int (*privsize)(const struct nlattr * const nla[]);
diff --git a/include/net/netfilter/nft_fib.h b/include/net/netfilter/nft_fib.h
index cbedda077db2..5ceb2205e4e3 100644
--- a/include/net/netfilter/nft_fib.h
+++ b/include/net/netfilter/nft_fib.h
@@ -9,6 +9,12 @@ struct nft_fib {
9 9
10extern const struct nla_policy nft_fib_policy[]; 10extern const struct nla_policy nft_fib_policy[];
11 11
12static inline bool
13nft_fib_is_loopback(const struct sk_buff *skb, const struct net_device *in)
14{
15 return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK;
16}
17
12int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr); 18int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr);
13int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr, 19int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
14 const struct nlattr * const tb[]); 20 const struct nlattr * const tb[]);
diff --git a/include/uapi/linux/netfilter/nf_log.h b/include/uapi/linux/netfilter/nf_log.h
index 8be21e02387d..d0b5fa91ff54 100644
--- a/include/uapi/linux/netfilter/nf_log.h
+++ b/include/uapi/linux/netfilter/nf_log.h
@@ -9,4 +9,6 @@
9#define NF_LOG_MACDECODE 0x20 /* Decode MAC header */ 9#define NF_LOG_MACDECODE 0x20 /* Decode MAC header */
10#define NF_LOG_MASK 0x2f 10#define NF_LOG_MASK 0x2f
11 11
12#define NF_LOG_PREFIXLEN 128
13
12#endif /* _NETFILTER_NF_LOG_H */ 14#endif /* _NETFILTER_NF_LOG_H */
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 881d49e94569..e3f27e09eb2b 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -235,7 +235,7 @@ enum nft_rule_compat_flags {
235/** 235/**
236 * enum nft_rule_compat_attributes - nf_tables rule compat attributes 236 * enum nft_rule_compat_attributes - nf_tables rule compat attributes
237 * 237 *
238 * @NFTA_RULE_COMPAT_PROTO: numerice value of handled protocol (NLA_U32) 238 * @NFTA_RULE_COMPAT_PROTO: numeric value of handled protocol (NLA_U32)
239 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32) 239 * @NFTA_RULE_COMPAT_FLAGS: bitmask of enum nft_rule_compat_flags (NLA_U32)
240 */ 240 */
241enum nft_rule_compat_attributes { 241enum nft_rule_compat_attributes {
@@ -499,7 +499,7 @@ enum nft_bitwise_attributes {
499 * enum nft_byteorder_ops - nf_tables byteorder operators 499 * enum nft_byteorder_ops - nf_tables byteorder operators
500 * 500 *
501 * @NFT_BYTEORDER_NTOH: network to host operator 501 * @NFT_BYTEORDER_NTOH: network to host operator
502 * @NFT_BYTEORDER_HTON: host to network opertaor 502 * @NFT_BYTEORDER_HTON: host to network operator
503 */ 503 */
504enum nft_byteorder_ops { 504enum nft_byteorder_ops {
505 NFT_BYTEORDER_NTOH, 505 NFT_BYTEORDER_NTOH,
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 229a5d5df977..3d55d95dcf49 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <linux/bpf.h> 12#include <linux/bpf.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/vmalloc.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include <linux/mm.h> 15#include <linux/mm.h>
17#include <linux/filter.h> 16#include <linux/filter.h>
@@ -74,14 +73,10 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
74 if (array_size >= U32_MAX - PAGE_SIZE) 73 if (array_size >= U32_MAX - PAGE_SIZE)
75 return ERR_PTR(-ENOMEM); 74 return ERR_PTR(-ENOMEM);
76 75
77
78 /* allocate all map elements and zero-initialize them */ 76 /* allocate all map elements and zero-initialize them */
79 array = kzalloc(array_size, GFP_USER | __GFP_NOWARN); 77 array = bpf_map_area_alloc(array_size);
80 if (!array) { 78 if (!array)
81 array = vzalloc(array_size); 79 return ERR_PTR(-ENOMEM);
82 if (!array)
83 return ERR_PTR(-ENOMEM);
84 }
85 80
86 /* copy mandatory map attributes */ 81 /* copy mandatory map attributes */
87 array->map.map_type = attr->map_type; 82 array->map.map_type = attr->map_type;
@@ -97,7 +92,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
97 92
98 if (array_size >= U32_MAX - PAGE_SIZE || 93 if (array_size >= U32_MAX - PAGE_SIZE ||
99 elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) { 94 elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) {
100 kvfree(array); 95 bpf_map_area_free(array);
101 return ERR_PTR(-ENOMEM); 96 return ERR_PTR(-ENOMEM);
102 } 97 }
103out: 98out:
@@ -262,7 +257,7 @@ static void array_map_free(struct bpf_map *map)
262 if (array->map.map_type == BPF_MAP_TYPE_PERCPU_ARRAY) 257 if (array->map.map_type == BPF_MAP_TYPE_PERCPU_ARRAY)
263 bpf_array_free_percpu(array); 258 bpf_array_free_percpu(array);
264 259
265 kvfree(array); 260 bpf_map_area_free(array);
266} 261}
267 262
268static const struct bpf_map_ops array_ops = { 263static const struct bpf_map_ops array_ops = {
@@ -319,7 +314,8 @@ static void fd_array_map_free(struct bpf_map *map)
319 /* make sure it's empty */ 314 /* make sure it's empty */
320 for (i = 0; i < array->map.max_entries; i++) 315 for (i = 0; i < array->map.max_entries; i++)
321 BUG_ON(array->ptrs[i] != NULL); 316 BUG_ON(array->ptrs[i] != NULL);
322 kvfree(array); 317
318 bpf_map_area_free(array);
323} 319}
324 320
325static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key) 321static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key)
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 3f2bb58952d8..a753bbe7df0a 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -13,7 +13,6 @@
13#include <linux/bpf.h> 13#include <linux/bpf.h>
14#include <linux/jhash.h> 14#include <linux/jhash.h>
15#include <linux/filter.h> 15#include <linux/filter.h>
16#include <linux/vmalloc.h>
17#include "percpu_freelist.h" 16#include "percpu_freelist.h"
18#include "bpf_lru_list.h" 17#include "bpf_lru_list.h"
19 18
@@ -103,7 +102,7 @@ static void htab_free_elems(struct bpf_htab *htab)
103 free_percpu(pptr); 102 free_percpu(pptr);
104 } 103 }
105free_elems: 104free_elems:
106 vfree(htab->elems); 105 bpf_map_area_free(htab->elems);
107} 106}
108 107
109static struct htab_elem *prealloc_lru_pop(struct bpf_htab *htab, void *key, 108static struct htab_elem *prealloc_lru_pop(struct bpf_htab *htab, void *key,
@@ -125,7 +124,8 @@ static int prealloc_init(struct bpf_htab *htab)
125{ 124{
126 int err = -ENOMEM, i; 125 int err = -ENOMEM, i;
127 126
128 htab->elems = vzalloc(htab->elem_size * htab->map.max_entries); 127 htab->elems = bpf_map_area_alloc(htab->elem_size *
128 htab->map.max_entries);
129 if (!htab->elems) 129 if (!htab->elems)
130 return -ENOMEM; 130 return -ENOMEM;
131 131
@@ -320,14 +320,10 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
320 goto free_htab; 320 goto free_htab;
321 321
322 err = -ENOMEM; 322 err = -ENOMEM;
323 htab->buckets = kmalloc_array(htab->n_buckets, sizeof(struct bucket), 323 htab->buckets = bpf_map_area_alloc(htab->n_buckets *
324 GFP_USER | __GFP_NOWARN); 324 sizeof(struct bucket));
325 325 if (!htab->buckets)
326 if (!htab->buckets) { 326 goto free_htab;
327 htab->buckets = vmalloc(htab->n_buckets * sizeof(struct bucket));
328 if (!htab->buckets)
329 goto free_htab;
330 }
331 327
332 for (i = 0; i < htab->n_buckets; i++) { 328 for (i = 0; i < htab->n_buckets; i++) {
333 INIT_HLIST_HEAD(&htab->buckets[i].head); 329 INIT_HLIST_HEAD(&htab->buckets[i].head);
@@ -354,7 +350,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
354free_extra_elems: 350free_extra_elems:
355 free_percpu(htab->extra_elems); 351 free_percpu(htab->extra_elems);
356free_buckets: 352free_buckets:
357 kvfree(htab->buckets); 353 bpf_map_area_free(htab->buckets);
358free_htab: 354free_htab:
359 kfree(htab); 355 kfree(htab);
360 return ERR_PTR(err); 356 return ERR_PTR(err);
@@ -1014,7 +1010,7 @@ static void htab_map_free(struct bpf_map *map)
1014 prealloc_destroy(htab); 1010 prealloc_destroy(htab);
1015 1011
1016 free_percpu(htab->extra_elems); 1012 free_percpu(htab->extra_elems);
1017 kvfree(htab->buckets); 1013 bpf_map_area_free(htab->buckets);
1018 kfree(htab); 1014 kfree(htab);
1019} 1015}
1020 1016
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 732ae16d12b7..be8519148c25 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -7,7 +7,6 @@
7#include <linux/bpf.h> 7#include <linux/bpf.h>
8#include <linux/jhash.h> 8#include <linux/jhash.h>
9#include <linux/filter.h> 9#include <linux/filter.h>
10#include <linux/vmalloc.h>
11#include <linux/stacktrace.h> 10#include <linux/stacktrace.h>
12#include <linux/perf_event.h> 11#include <linux/perf_event.h>
13#include "percpu_freelist.h" 12#include "percpu_freelist.h"
@@ -32,7 +31,7 @@ static int prealloc_elems_and_freelist(struct bpf_stack_map *smap)
32 u32 elem_size = sizeof(struct stack_map_bucket) + smap->map.value_size; 31 u32 elem_size = sizeof(struct stack_map_bucket) + smap->map.value_size;
33 int err; 32 int err;
34 33
35 smap->elems = vzalloc(elem_size * smap->map.max_entries); 34 smap->elems = bpf_map_area_alloc(elem_size * smap->map.max_entries);
36 if (!smap->elems) 35 if (!smap->elems)
37 return -ENOMEM; 36 return -ENOMEM;
38 37
@@ -45,7 +44,7 @@ static int prealloc_elems_and_freelist(struct bpf_stack_map *smap)
45 return 0; 44 return 0;
46 45
47free_elems: 46free_elems:
48 vfree(smap->elems); 47 bpf_map_area_free(smap->elems);
49 return err; 48 return err;
50} 49}
51 50
@@ -76,12 +75,9 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
76 if (cost >= U32_MAX - PAGE_SIZE) 75 if (cost >= U32_MAX - PAGE_SIZE)
77 return ERR_PTR(-E2BIG); 76 return ERR_PTR(-E2BIG);
78 77
79 smap = kzalloc(cost, GFP_USER | __GFP_NOWARN); 78 smap = bpf_map_area_alloc(cost);
80 if (!smap) { 79 if (!smap)
81 smap = vzalloc(cost); 80 return ERR_PTR(-ENOMEM);
82 if (!smap)
83 return ERR_PTR(-ENOMEM);
84 }
85 81
86 err = -E2BIG; 82 err = -E2BIG;
87 cost += n_buckets * (value_size + sizeof(struct stack_map_bucket)); 83 cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
@@ -112,7 +108,7 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
112put_buffers: 108put_buffers:
113 put_callchain_buffers(); 109 put_callchain_buffers();
114free_smap: 110free_smap:
115 kvfree(smap); 111 bpf_map_area_free(smap);
116 return ERR_PTR(err); 112 return ERR_PTR(err);
117} 113}
118 114
@@ -262,9 +258,9 @@ static void stack_map_free(struct bpf_map *map)
262 /* wait for bpf programs to complete before freeing stack map */ 258 /* wait for bpf programs to complete before freeing stack map */
263 synchronize_rcu(); 259 synchronize_rcu();
264 260
265 vfree(smap->elems); 261 bpf_map_area_free(smap->elems);
266 pcpu_freelist_destroy(&smap->freelist); 262 pcpu_freelist_destroy(&smap->freelist);
267 kvfree(smap); 263 bpf_map_area_free(smap);
268 put_callchain_buffers(); 264 put_callchain_buffers();
269} 265}
270 266
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 1d6b29e4e2c3..19b6129eab23 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -12,6 +12,8 @@
12#include <linux/bpf.h> 12#include <linux/bpf.h>
13#include <linux/syscalls.h> 13#include <linux/syscalls.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/vmalloc.h>
16#include <linux/mmzone.h>
15#include <linux/anon_inodes.h> 17#include <linux/anon_inodes.h>
16#include <linux/file.h> 18#include <linux/file.h>
17#include <linux/license.h> 19#include <linux/license.h>
@@ -49,6 +51,30 @@ void bpf_register_map_type(struct bpf_map_type_list *tl)
49 list_add(&tl->list_node, &bpf_map_types); 51 list_add(&tl->list_node, &bpf_map_types);
50} 52}
51 53
54void *bpf_map_area_alloc(size_t size)
55{
56 /* We definitely need __GFP_NORETRY, so OOM killer doesn't
57 * trigger under memory pressure as we really just want to
58 * fail instead.
59 */
60 const gfp_t flags = __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO;
61 void *area;
62
63 if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
64 area = kmalloc(size, GFP_USER | flags);
65 if (area != NULL)
66 return area;
67 }
68
69 return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | flags,
70 PAGE_KERNEL);
71}
72
73void bpf_map_area_free(void *area)
74{
75 kvfree(area);
76}
77
52int bpf_map_precharge_memlock(u32 pages) 78int bpf_map_precharge_memlock(u32 pages)
53{ 79{
54 struct user_struct *user = get_current_user(); 80 struct user_struct *user = get_current_user();
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 9c561e683f4b..0854ebd8613e 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -474,7 +474,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
474 primary_if = batadv_primary_if_get_selected(bat_priv); 474 primary_if = batadv_primary_if_get_selected(bat_priv);
475 if (!primary_if) { 475 if (!primary_if) {
476 ret = -EINVAL; 476 ret = -EINVAL;
477 goto put_primary_if; 477 goto free_skb;
478 } 478 }
479 479
480 /* Create one header to be copied to all fragments */ 480 /* Create one header to be copied to all fragments */
@@ -502,7 +502,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
502 skb_fragment = batadv_frag_create(skb, &frag_header, mtu); 502 skb_fragment = batadv_frag_create(skb, &frag_header, mtu);
503 if (!skb_fragment) { 503 if (!skb_fragment) {
504 ret = -ENOMEM; 504 ret = -ENOMEM;
505 goto free_skb; 505 goto put_primary_if;
506 } 506 }
507 507
508 batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX); 508 batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX);
@@ -511,7 +511,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
511 ret = batadv_send_unicast_skb(skb_fragment, neigh_node); 511 ret = batadv_send_unicast_skb(skb_fragment, neigh_node);
512 if (ret != NET_XMIT_SUCCESS) { 512 if (ret != NET_XMIT_SUCCESS) {
513 ret = NET_XMIT_DROP; 513 ret = NET_XMIT_DROP;
514 goto free_skb; 514 goto put_primary_if;
515 } 515 }
516 516
517 frag_header.no++; 517 frag_header.no++;
@@ -519,7 +519,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
519 /* The initial check in this function should cover this case */ 519 /* The initial check in this function should cover this case */
520 if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) { 520 if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) {
521 ret = -EINVAL; 521 ret = -EINVAL;
522 goto free_skb; 522 goto put_primary_if;
523 } 523 }
524 } 524 }
525 525
@@ -527,7 +527,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
527 if (batadv_skb_head_push(skb, header_size) < 0 || 527 if (batadv_skb_head_push(skb, header_size) < 0 ||
528 pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) { 528 pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) {
529 ret = -ENOMEM; 529 ret = -ENOMEM;
530 goto free_skb; 530 goto put_primary_if;
531 } 531 }
532 532
533 memcpy(skb->data, &frag_header, header_size); 533 memcpy(skb->data, &frag_header, header_size);
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 71c7453268c1..7109b389ea58 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -781,20 +781,6 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[])
781 return 0; 781 return 0;
782} 782}
783 783
784static int br_dev_newlink(struct net *src_net, struct net_device *dev,
785 struct nlattr *tb[], struct nlattr *data[])
786{
787 struct net_bridge *br = netdev_priv(dev);
788
789 if (tb[IFLA_ADDRESS]) {
790 spin_lock_bh(&br->lock);
791 br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS]));
792 spin_unlock_bh(&br->lock);
793 }
794
795 return register_netdevice(dev);
796}
797
798static int br_port_slave_changelink(struct net_device *brdev, 784static int br_port_slave_changelink(struct net_device *brdev,
799 struct net_device *dev, 785 struct net_device *dev,
800 struct nlattr *tb[], 786 struct nlattr *tb[],
@@ -1115,6 +1101,25 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
1115 return 0; 1101 return 0;
1116} 1102}
1117 1103
1104static int br_dev_newlink(struct net *src_net, struct net_device *dev,
1105 struct nlattr *tb[], struct nlattr *data[])
1106{
1107 struct net_bridge *br = netdev_priv(dev);
1108 int err;
1109
1110 if (tb[IFLA_ADDRESS]) {
1111 spin_lock_bh(&br->lock);
1112 br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS]));
1113 spin_unlock_bh(&br->lock);
1114 }
1115
1116 err = br_changelink(dev, tb, data);
1117 if (err)
1118 return err;
1119
1120 return register_netdevice(dev);
1121}
1122
1118static size_t br_get_size(const struct net_device *brdev) 1123static size_t br_get_size(const struct net_device *brdev)
1119{ 1124{
1120 return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */ 1125 return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */
diff --git a/net/core/dev.c b/net/core/dev.c
index 07b307b0b414..7f218e095361 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2795,9 +2795,9 @@ static netdev_features_t harmonize_features(struct sk_buff *skb,
2795 if (skb->ip_summed != CHECKSUM_NONE && 2795 if (skb->ip_summed != CHECKSUM_NONE &&
2796 !can_checksum_protocol(features, type)) { 2796 !can_checksum_protocol(features, type)) {
2797 features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 2797 features &= ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
2798 } else if (illegal_highdma(skb->dev, skb)) {
2799 features &= ~NETIF_F_SG;
2800 } 2798 }
2799 if (illegal_highdma(skb->dev, skb))
2800 features &= ~NETIF_F_SG;
2801 2801
2802 return features; 2802 return features;
2803} 2803}
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index e23766c7e3ba..236a21e3c878 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1712,7 +1712,7 @@ static noinline_for_stack int ethtool_get_channels(struct net_device *dev,
1712static noinline_for_stack int ethtool_set_channels(struct net_device *dev, 1712static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
1713 void __user *useraddr) 1713 void __user *useraddr)
1714{ 1714{
1715 struct ethtool_channels channels, max; 1715 struct ethtool_channels channels, max = { .cmd = ETHTOOL_GCHANNELS };
1716 u32 max_rx_in_use = 0; 1716 u32 max_rx_in_use = 0;
1717 1717
1718 if (!dev->ethtool_ops->set_channels || !dev->ethtool_ops->get_channels) 1718 if (!dev->ethtool_ops->set_channels || !dev->ethtool_ops->get_channels)
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index 71bb3e2eca08..b3eef90b2df9 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -386,6 +386,7 @@ static const struct lwtunnel_encap_ops bpf_encap_ops = {
386 .fill_encap = bpf_fill_encap_info, 386 .fill_encap = bpf_fill_encap_info,
387 .get_encap_size = bpf_encap_nlsize, 387 .get_encap_size = bpf_encap_nlsize,
388 .cmp_encap = bpf_encap_cmp, 388 .cmp_encap = bpf_encap_cmp,
389 .owner = THIS_MODULE,
389}; 390};
390 391
391static int __init bpf_lwt_init(void) 392static int __init bpf_lwt_init(void)
diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
index a5d4e866ce88..c23465005f2f 100644
--- a/net/core/lwtunnel.c
+++ b/net/core/lwtunnel.c
@@ -26,6 +26,7 @@
26#include <net/lwtunnel.h> 26#include <net/lwtunnel.h>
27#include <net/rtnetlink.h> 27#include <net/rtnetlink.h>
28#include <net/ip6_fib.h> 28#include <net/ip6_fib.h>
29#include <net/nexthop.h>
29 30
30#ifdef CONFIG_MODULES 31#ifdef CONFIG_MODULES
31 32
@@ -114,25 +115,77 @@ int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
114 ret = -EOPNOTSUPP; 115 ret = -EOPNOTSUPP;
115 rcu_read_lock(); 116 rcu_read_lock();
116 ops = rcu_dereference(lwtun_encaps[encap_type]); 117 ops = rcu_dereference(lwtun_encaps[encap_type]);
118 if (likely(ops && ops->build_state && try_module_get(ops->owner))) {
119 ret = ops->build_state(dev, encap, family, cfg, lws);
120 if (ret)
121 module_put(ops->owner);
122 }
123 rcu_read_unlock();
124
125 return ret;
126}
127EXPORT_SYMBOL(lwtunnel_build_state);
128
129int lwtunnel_valid_encap_type(u16 encap_type)
130{
131 const struct lwtunnel_encap_ops *ops;
132 int ret = -EINVAL;
133
134 if (encap_type == LWTUNNEL_ENCAP_NONE ||
135 encap_type > LWTUNNEL_ENCAP_MAX)
136 return ret;
137
138 rcu_read_lock();
139 ops = rcu_dereference(lwtun_encaps[encap_type]);
140 rcu_read_unlock();
117#ifdef CONFIG_MODULES 141#ifdef CONFIG_MODULES
118 if (!ops) { 142 if (!ops) {
119 const char *encap_type_str = lwtunnel_encap_str(encap_type); 143 const char *encap_type_str = lwtunnel_encap_str(encap_type);
120 144
121 if (encap_type_str) { 145 if (encap_type_str) {
122 rcu_read_unlock(); 146 __rtnl_unlock();
123 request_module("rtnl-lwt-%s", encap_type_str); 147 request_module("rtnl-lwt-%s", encap_type_str);
148 rtnl_lock();
149
124 rcu_read_lock(); 150 rcu_read_lock();
125 ops = rcu_dereference(lwtun_encaps[encap_type]); 151 ops = rcu_dereference(lwtun_encaps[encap_type]);
152 rcu_read_unlock();
126 } 153 }
127 } 154 }
128#endif 155#endif
129 if (likely(ops && ops->build_state)) 156 return ops ? 0 : -EOPNOTSUPP;
130 ret = ops->build_state(dev, encap, family, cfg, lws); 157}
131 rcu_read_unlock(); 158EXPORT_SYMBOL(lwtunnel_valid_encap_type);
132 159
133 return ret; 160int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int remaining)
161{
162 struct rtnexthop *rtnh = (struct rtnexthop *)attr;
163 struct nlattr *nla_entype;
164 struct nlattr *attrs;
165 struct nlattr *nla;
166 u16 encap_type;
167 int attrlen;
168
169 while (rtnh_ok(rtnh, remaining)) {
170 attrlen = rtnh_attrlen(rtnh);
171 if (attrlen > 0) {
172 attrs = rtnh_attrs(rtnh);
173 nla = nla_find(attrs, attrlen, RTA_ENCAP);
174 nla_entype = nla_find(attrs, attrlen, RTA_ENCAP_TYPE);
175
176 if (nla_entype) {
177 encap_type = nla_get_u16(nla_entype);
178
179 if (lwtunnel_valid_encap_type(encap_type) != 0)
180 return -EOPNOTSUPP;
181 }
182 }
183 rtnh = rtnh_next(rtnh, &remaining);
184 }
185
186 return 0;
134} 187}
135EXPORT_SYMBOL(lwtunnel_build_state); 188EXPORT_SYMBOL(lwtunnel_valid_encap_type_attr);
136 189
137void lwtstate_free(struct lwtunnel_state *lws) 190void lwtstate_free(struct lwtunnel_state *lws)
138{ 191{
@@ -144,6 +197,7 @@ void lwtstate_free(struct lwtunnel_state *lws)
144 } else { 197 } else {
145 kfree(lws); 198 kfree(lws);
146 } 199 }
200 module_put(ops->owner);
147} 201}
148EXPORT_SYMBOL(lwtstate_free); 202EXPORT_SYMBOL(lwtstate_free);
149 203
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index adfc790f7193..c4e879c02186 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -227,7 +227,7 @@ static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req
227 opt = ireq->ipv6_opt; 227 opt = ireq->ipv6_opt;
228 if (!opt) 228 if (!opt)
229 opt = rcu_dereference(np->opt); 229 opt = rcu_dereference(np->opt);
230 err = ip6_xmit(sk, skb, &fl6, opt, np->tclass); 230 err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass);
231 rcu_read_unlock(); 231 rcu_read_unlock();
232 err = net_xmit_eval(err); 232 err = net_xmit_eval(err);
233 } 233 }
@@ -281,7 +281,7 @@ static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)
281 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL); 281 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
282 if (!IS_ERR(dst)) { 282 if (!IS_ERR(dst)) {
283 skb_dst_set(skb, dst); 283 skb_dst_set(skb, dst);
284 ip6_xmit(ctl_sk, skb, &fl6, NULL, 0); 284 ip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0);
285 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 285 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
286 DCCP_INC_STATS(DCCP_MIB_OUTRSTS); 286 DCCP_INC_STATS(DCCP_MIB_OUTRSTS);
287 return; 287 return;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 68c9eea00518..7d4596110851 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1105,10 +1105,8 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
1105 /* Use already configured phy mode */ 1105 /* Use already configured phy mode */
1106 if (p->phy_interface == PHY_INTERFACE_MODE_NA) 1106 if (p->phy_interface == PHY_INTERFACE_MODE_NA)
1107 p->phy_interface = p->phy->interface; 1107 p->phy_interface = p->phy->interface;
1108 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 1108 return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
1109 p->phy_interface); 1109 p->phy_interface);
1110
1111 return 0;
1112} 1110}
1113 1111
1114static int dsa_slave_phy_setup(struct dsa_slave_priv *p, 1112static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
@@ -1203,6 +1201,8 @@ int dsa_slave_suspend(struct net_device *slave_dev)
1203{ 1201{
1204 struct dsa_slave_priv *p = netdev_priv(slave_dev); 1202 struct dsa_slave_priv *p = netdev_priv(slave_dev);
1205 1203
1204 netif_device_detach(slave_dev);
1205
1206 if (p->phy) { 1206 if (p->phy) {
1207 phy_stop(p->phy); 1207 phy_stop(p->phy);
1208 p->old_pause = -1; 1208 p->old_pause = -1;
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index eae0332b0e8c..7db2ad2e82d3 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -46,6 +46,7 @@
46#include <net/rtnetlink.h> 46#include <net/rtnetlink.h>
47#include <net/xfrm.h> 47#include <net/xfrm.h>
48#include <net/l3mdev.h> 48#include <net/l3mdev.h>
49#include <net/lwtunnel.h>
49#include <trace/events/fib.h> 50#include <trace/events/fib.h>
50 51
51#ifndef CONFIG_IP_MULTIPLE_TABLES 52#ifndef CONFIG_IP_MULTIPLE_TABLES
@@ -677,6 +678,10 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
677 cfg->fc_mx_len = nla_len(attr); 678 cfg->fc_mx_len = nla_len(attr);
678 break; 679 break;
679 case RTA_MULTIPATH: 680 case RTA_MULTIPATH:
681 err = lwtunnel_valid_encap_type_attr(nla_data(attr),
682 nla_len(attr));
683 if (err < 0)
684 goto errout;
680 cfg->fc_mp = nla_data(attr); 685 cfg->fc_mp = nla_data(attr);
681 cfg->fc_mp_len = nla_len(attr); 686 cfg->fc_mp_len = nla_len(attr);
682 break; 687 break;
@@ -691,6 +696,9 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
691 break; 696 break;
692 case RTA_ENCAP_TYPE: 697 case RTA_ENCAP_TYPE:
693 cfg->fc_encap_type = nla_get_u16(attr); 698 cfg->fc_encap_type = nla_get_u16(attr);
699 err = lwtunnel_valid_encap_type(cfg->fc_encap_type);
700 if (err < 0)
701 goto errout;
694 break; 702 break;
695 } 703 }
696 } 704 }
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index fac275c48108..b67719f45953 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1629,6 +1629,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
1629 sk->sk_protocol = ip_hdr(skb)->protocol; 1629 sk->sk_protocol = ip_hdr(skb)->protocol;
1630 sk->sk_bound_dev_if = arg->bound_dev_if; 1630 sk->sk_bound_dev_if = arg->bound_dev_if;
1631 sk->sk_sndbuf = sysctl_wmem_default; 1631 sk->sk_sndbuf = sysctl_wmem_default;
1632 sk->sk_mark = fl4.flowi4_mark;
1632 err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, 1633 err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base,
1633 len, 0, &ipc, &rt, MSG_DONTWAIT); 1634 len, 0, &ipc, &rt, MSG_DONTWAIT);
1634 if (unlikely(err)) { 1635 if (unlikely(err)) {
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index fed3d29f9eb3..0fd1976ab63b 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -313,6 +313,7 @@ static const struct lwtunnel_encap_ops ip_tun_lwt_ops = {
313 .fill_encap = ip_tun_fill_encap_info, 313 .fill_encap = ip_tun_fill_encap_info,
314 .get_encap_size = ip_tun_encap_nlsize, 314 .get_encap_size = ip_tun_encap_nlsize,
315 .cmp_encap = ip_tun_cmp_encap, 315 .cmp_encap = ip_tun_cmp_encap,
316 .owner = THIS_MODULE,
316}; 317};
317 318
318static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = { 319static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = {
@@ -403,6 +404,7 @@ static const struct lwtunnel_encap_ops ip6_tun_lwt_ops = {
403 .fill_encap = ip6_tun_fill_encap_info, 404 .fill_encap = ip6_tun_fill_encap_info,
404 .get_encap_size = ip6_tun_encap_nlsize, 405 .get_encap_size = ip6_tun_encap_nlsize,
405 .cmp_encap = ip_tun_cmp_encap, 406 .cmp_encap = ip_tun_cmp_encap,
407 .owner = THIS_MODULE,
406}; 408};
407 409
408void __init ip_tunnel_core_init(void) 410void __init ip_tunnel_core_init(void)
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index a6b8c1a4102b..0a783cd73faf 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -144,7 +144,12 @@ clusterip_config_find_get(struct net *net, __be32 clusterip, int entry)
144 rcu_read_lock_bh(); 144 rcu_read_lock_bh();
145 c = __clusterip_config_find(net, clusterip); 145 c = __clusterip_config_find(net, clusterip);
146 if (c) { 146 if (c) {
147 if (!c->pde || unlikely(!atomic_inc_not_zero(&c->refcount))) 147#ifdef CONFIG_PROC_FS
148 if (!c->pde)
149 c = NULL;
150 else
151#endif
152 if (unlikely(!atomic_inc_not_zero(&c->refcount)))
148 c = NULL; 153 c = NULL;
149 else if (entry) 154 else if (entry)
150 atomic_inc(&c->entries); 155 atomic_inc(&c->entries);
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index f273098e48fd..37fb9552e858 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -63,10 +63,10 @@ static bool rpfilter_lookup_reverse(struct net *net, struct flowi4 *fl4,
63 return dev_match || flags & XT_RPFILTER_LOOSE; 63 return dev_match || flags & XT_RPFILTER_LOOSE;
64} 64}
65 65
66static bool rpfilter_is_local(const struct sk_buff *skb) 66static bool
67rpfilter_is_loopback(const struct sk_buff *skb, const struct net_device *in)
67{ 68{
68 const struct rtable *rt = skb_rtable(skb); 69 return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK;
69 return rt && (rt->rt_flags & RTCF_LOCAL);
70} 70}
71 71
72static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) 72static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
@@ -79,7 +79,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
79 info = par->matchinfo; 79 info = par->matchinfo;
80 invert = info->flags & XT_RPFILTER_INVERT; 80 invert = info->flags & XT_RPFILTER_INVERT;
81 81
82 if (rpfilter_is_local(skb)) 82 if (rpfilter_is_loopback(skb, xt_in(par)))
83 return true ^ invert; 83 return true ^ invert;
84 84
85 iph = ip_hdr(skb); 85 iph = ip_hdr(skb);
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index fd8220213afc..146d86105183 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -126,6 +126,8 @@ void nf_send_reset(struct net *net, struct sk_buff *oldskb, int hook)
126 /* ip_route_me_harder expects skb->dst to be set */ 126 /* ip_route_me_harder expects skb->dst to be set */
127 skb_dst_set_noref(nskb, skb_dst(oldskb)); 127 skb_dst_set_noref(nskb, skb_dst(oldskb));
128 128
129 nskb->mark = IP4_REPLY_MARK(net, oldskb->mark);
130
129 skb_reserve(nskb, LL_MAX_HEADER); 131 skb_reserve(nskb, LL_MAX_HEADER);
130 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP, 132 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
131 ip4_dst_hoplimit(skb_dst(nskb))); 133 ip4_dst_hoplimit(skb_dst(nskb)));
diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
index 965b1a161369..2981291910dd 100644
--- a/net/ipv4/netfilter/nft_fib_ipv4.c
+++ b/net/ipv4/netfilter/nft_fib_ipv4.c
@@ -26,13 +26,6 @@ static __be32 get_saddr(__be32 addr)
26 return addr; 26 return addr;
27} 27}
28 28
29static bool fib4_is_local(const struct sk_buff *skb)
30{
31 const struct rtable *rt = skb_rtable(skb);
32
33 return rt && (rt->rt_flags & RTCF_LOCAL);
34}
35
36#define DSCP_BITS 0xfc 29#define DSCP_BITS 0xfc
37 30
38void nft_fib4_eval_type(const struct nft_expr *expr, struct nft_regs *regs, 31void nft_fib4_eval_type(const struct nft_expr *expr, struct nft_regs *regs,
@@ -95,8 +88,10 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
95 else 88 else
96 oif = NULL; 89 oif = NULL;
97 90
98 if (nft_hook(pkt) == NF_INET_PRE_ROUTING && fib4_is_local(pkt->skb)) { 91 if (nft_hook(pkt) == NF_INET_PRE_ROUTING &&
99 nft_fib_store_result(dest, priv->result, pkt, LOOPBACK_IFINDEX); 92 nft_fib_is_loopback(pkt->skb, nft_in(pkt))) {
93 nft_fib_store_result(dest, priv->result, pkt,
94 nft_in(pkt)->ifindex);
100 return; 95 return;
101 } 96 }
102 97
@@ -131,7 +126,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
131 switch (res.type) { 126 switch (res.type) {
132 case RTN_UNICAST: 127 case RTN_UNICAST:
133 break; 128 break;
134 case RTN_LOCAL: /* should not appear here, see fib4_is_local() above */ 129 case RTN_LOCAL: /* Should not see RTN_LOCAL here */
135 return; 130 return;
136 default: 131 default:
137 break; 132 break;
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index f51919535ca7..dd2560c83a85 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -205,6 +205,7 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk,
205 * scaled. So correct it appropriately. 205 * scaled. So correct it appropriately.
206 */ 206 */
207 tp->snd_wnd = ntohs(tcp_hdr(skb)->window); 207 tp->snd_wnd = ntohs(tcp_hdr(skb)->window);
208 tp->max_window = tp->snd_wnd;
208 209
209 /* Activate the retrans timer so that SYNACK can be retransmitted. 210 /* Activate the retrans timer so that SYNACK can be retransmitted.
210 * The request socket is not added to the ehash 211 * The request socket is not added to the ehash
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 6c790754ae3e..41dcbd568cbe 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5078,7 +5078,7 @@ static void tcp_check_space(struct sock *sk)
5078 if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) { 5078 if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) {
5079 sock_reset_flag(sk, SOCK_QUEUE_SHRUNK); 5079 sock_reset_flag(sk, SOCK_QUEUE_SHRUNK);
5080 /* pairs with tcp_poll() */ 5080 /* pairs with tcp_poll() */
5081 smp_mb__after_atomic(); 5081 smp_mb();
5082 if (sk->sk_socket && 5082 if (sk->sk_socket &&
5083 test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { 5083 test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
5084 tcp_new_space(sk); 5084 tcp_new_space(sk);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c1e124bc8e1e..f60e88e56255 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5540,8 +5540,7 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
5540 struct net_device *dev; 5540 struct net_device *dev;
5541 struct inet6_dev *idev; 5541 struct inet6_dev *idev;
5542 5542
5543 rcu_read_lock(); 5543 for_each_netdev(net, dev) {
5544 for_each_netdev_rcu(net, dev) {
5545 idev = __in6_dev_get(dev); 5544 idev = __in6_dev_get(dev);
5546 if (idev) { 5545 if (idev) {
5547 int changed = (!idev->cnf.disable_ipv6) ^ (!newf); 5546 int changed = (!idev->cnf.disable_ipv6) ^ (!newf);
@@ -5550,7 +5549,6 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
5550 dev_disable_change(idev); 5549 dev_disable_change(idev);
5551 } 5550 }
5552 } 5551 }
5553 rcu_read_unlock();
5554} 5552}
5555 5553
5556static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf) 5554static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
diff --git a/net/ipv6/ila/ila_lwt.c b/net/ipv6/ila/ila_lwt.c
index a7bc54ab46e2..13b5e85fe0d5 100644
--- a/net/ipv6/ila/ila_lwt.c
+++ b/net/ipv6/ila/ila_lwt.c
@@ -238,6 +238,7 @@ static const struct lwtunnel_encap_ops ila_encap_ops = {
238 .fill_encap = ila_fill_encap_info, 238 .fill_encap = ila_fill_encap_info,
239 .get_encap_size = ila_encap_nlsize, 239 .get_encap_size = ila_encap_nlsize,
240 .cmp_encap = ila_encap_cmp, 240 .cmp_encap = ila_encap_cmp,
241 .owner = THIS_MODULE,
241}; 242};
242 243
243int ila_lwt_init(void) 244int ila_lwt_init(void)
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 7396e75e161b..75c308239243 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -176,7 +176,7 @@ int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl_unused
176 /* Restore final destination back after routing done */ 176 /* Restore final destination back after routing done */
177 fl6.daddr = sk->sk_v6_daddr; 177 fl6.daddr = sk->sk_v6_daddr;
178 178
179 res = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt), 179 res = ip6_xmit(sk, skb, &fl6, sk->sk_mark, rcu_dereference(np->opt),
180 np->tclass); 180 np->tclass);
181 rcu_read_unlock(); 181 rcu_read_unlock();
182 return res; 182 return res;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 75b6108234dd..558631860d91 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -582,6 +582,9 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
582 return -1; 582 return -1;
583 583
584 offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb)); 584 offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb));
585 /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head */
586 ipv6h = ipv6_hdr(skb);
587
585 if (offset > 0) { 588 if (offset > 0) {
586 struct ipv6_tlv_tnl_enc_lim *tel; 589 struct ipv6_tlv_tnl_enc_lim *tel;
587 tel = (struct ipv6_tlv_tnl_enc_lim *)&skb_network_header(skb)[offset]; 590 tel = (struct ipv6_tlv_tnl_enc_lim *)&skb_network_header(skb)[offset];
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 38122d04fadc..2c0df09e9036 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -172,7 +172,7 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
172 * which are using proper atomic operations or spinlocks. 172 * which are using proper atomic operations or spinlocks.
173 */ 173 */
174int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, 174int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
175 struct ipv6_txoptions *opt, int tclass) 175 __u32 mark, struct ipv6_txoptions *opt, int tclass)
176{ 176{
177 struct net *net = sock_net(sk); 177 struct net *net = sock_net(sk);
178 const struct ipv6_pinfo *np = inet6_sk(sk); 178 const struct ipv6_pinfo *np = inet6_sk(sk);
@@ -240,7 +240,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
240 240
241 skb->protocol = htons(ETH_P_IPV6); 241 skb->protocol = htons(ETH_P_IPV6);
242 skb->priority = sk->sk_priority; 242 skb->priority = sk->sk_priority;
243 skb->mark = sk->sk_mark; 243 skb->mark = mark;
244 244
245 mtu = dst_mtu(dst); 245 mtu = dst_mtu(dst);
246 if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) { 246 if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) {
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 753d6d0860fb..ff8ee06491c3 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -400,18 +400,19 @@ ip6_tnl_dev_uninit(struct net_device *dev)
400 400
401__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw) 401__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
402{ 402{
403 const struct ipv6hdr *ipv6h = (const struct ipv6hdr *) raw; 403 const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)raw;
404 __u8 nexthdr = ipv6h->nexthdr; 404 unsigned int nhoff = raw - skb->data;
405 __u16 off = sizeof(*ipv6h); 405 unsigned int off = nhoff + sizeof(*ipv6h);
406 u8 next, nexthdr = ipv6h->nexthdr;
406 407
407 while (ipv6_ext_hdr(nexthdr) && nexthdr != NEXTHDR_NONE) { 408 while (ipv6_ext_hdr(nexthdr) && nexthdr != NEXTHDR_NONE) {
408 __u16 optlen = 0;
409 struct ipv6_opt_hdr *hdr; 409 struct ipv6_opt_hdr *hdr;
410 if (raw + off + sizeof(*hdr) > skb->data && 410 u16 optlen;
411 !pskb_may_pull(skb, raw - skb->data + off + sizeof (*hdr))) 411
412 if (!pskb_may_pull(skb, off + sizeof(*hdr)))
412 break; 413 break;
413 414
414 hdr = (struct ipv6_opt_hdr *) (raw + off); 415 hdr = (struct ipv6_opt_hdr *)(skb->data + off);
415 if (nexthdr == NEXTHDR_FRAGMENT) { 416 if (nexthdr == NEXTHDR_FRAGMENT) {
416 struct frag_hdr *frag_hdr = (struct frag_hdr *) hdr; 417 struct frag_hdr *frag_hdr = (struct frag_hdr *) hdr;
417 if (frag_hdr->frag_off) 418 if (frag_hdr->frag_off)
@@ -422,20 +423,29 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
422 } else { 423 } else {
423 optlen = ipv6_optlen(hdr); 424 optlen = ipv6_optlen(hdr);
424 } 425 }
426 /* cache hdr->nexthdr, since pskb_may_pull() might
427 * invalidate hdr
428 */
429 next = hdr->nexthdr;
425 if (nexthdr == NEXTHDR_DEST) { 430 if (nexthdr == NEXTHDR_DEST) {
426 __u16 i = off + 2; 431 u16 i = 2;
432
433 /* Remember : hdr is no longer valid at this point. */
434 if (!pskb_may_pull(skb, off + optlen))
435 break;
436
427 while (1) { 437 while (1) {
428 struct ipv6_tlv_tnl_enc_lim *tel; 438 struct ipv6_tlv_tnl_enc_lim *tel;
429 439
430 /* No more room for encapsulation limit */ 440 /* No more room for encapsulation limit */
431 if (i + sizeof (*tel) > off + optlen) 441 if (i + sizeof(*tel) > optlen)
432 break; 442 break;
433 443
434 tel = (struct ipv6_tlv_tnl_enc_lim *) &raw[i]; 444 tel = (struct ipv6_tlv_tnl_enc_lim *) skb->data + off + i;
435 /* return index of option if found and valid */ 445 /* return index of option if found and valid */
436 if (tel->type == IPV6_TLV_TNL_ENCAP_LIMIT && 446 if (tel->type == IPV6_TLV_TNL_ENCAP_LIMIT &&
437 tel->length == 1) 447 tel->length == 1)
438 return i; 448 return i + off - nhoff;
439 /* else jump to next option */ 449 /* else jump to next option */
440 if (tel->type) 450 if (tel->type)
441 i += tel->length + 2; 451 i += tel->length + 2;
@@ -443,7 +453,7 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
443 i++; 453 i++;
444 } 454 }
445 } 455 }
446 nexthdr = hdr->nexthdr; 456 nexthdr = next;
447 off += optlen; 457 off += optlen;
448 } 458 }
449 return 0; 459 return 0;
@@ -1303,6 +1313,8 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
1303 fl6.flowlabel = key->label; 1313 fl6.flowlabel = key->label;
1304 } else { 1314 } else {
1305 offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb)); 1315 offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb));
1316 /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head */
1317 ipv6h = ipv6_hdr(skb);
1306 if (offset > 0) { 1318 if (offset > 0) {
1307 struct ipv6_tlv_tnl_enc_lim *tel; 1319 struct ipv6_tlv_tnl_enc_lim *tel;
1308 1320
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index d5263dc364a9..b12e61b7b16c 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -72,10 +72,10 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
72 return ret; 72 return ret;
73} 73}
74 74
75static bool rpfilter_is_local(const struct sk_buff *skb) 75static bool
76rpfilter_is_loopback(const struct sk_buff *skb, const struct net_device *in)
76{ 77{
77 const struct rt6_info *rt = (const void *) skb_dst(skb); 78 return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK;
78 return rt && (rt->rt6i_flags & RTF_LOCAL);
79} 79}
80 80
81static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) 81static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
@@ -85,7 +85,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
85 struct ipv6hdr *iph; 85 struct ipv6hdr *iph;
86 bool invert = info->flags & XT_RPFILTER_INVERT; 86 bool invert = info->flags & XT_RPFILTER_INVERT;
87 87
88 if (rpfilter_is_local(skb)) 88 if (rpfilter_is_loopback(skb, xt_in(par)))
89 return true ^ invert; 89 return true ^ invert;
90 90
91 iph = ipv6_hdr(skb); 91 iph = ipv6_hdr(skb);
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 10090400c72f..eedee5d108d9 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -157,6 +157,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
157 fl6.fl6_sport = otcph->dest; 157 fl6.fl6_sport = otcph->dest;
158 fl6.fl6_dport = otcph->source; 158 fl6.fl6_dport = otcph->source;
159 fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev); 159 fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev);
160 fl6.flowi6_mark = IP6_REPLY_MARK(net, oldskb->mark);
160 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6)); 161 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
161 dst = ip6_route_output(net, NULL, &fl6); 162 dst = ip6_route_output(net, NULL, &fl6);
162 if (dst->error) { 163 if (dst->error) {
@@ -180,6 +181,8 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
180 181
181 skb_dst_set(nskb, dst); 182 skb_dst_set(nskb, dst);
182 183
184 nskb->mark = fl6.flowi6_mark;
185
183 skb_reserve(nskb, hh_len + dst->header_len); 186 skb_reserve(nskb, hh_len + dst->header_len);
184 ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP, 187 ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
185 ip6_dst_hoplimit(dst)); 188 ip6_dst_hoplimit(dst));
diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
index c947aad8bcc6..765facf03d45 100644
--- a/net/ipv6/netfilter/nft_fib_ipv6.c
+++ b/net/ipv6/netfilter/nft_fib_ipv6.c
@@ -18,13 +18,6 @@
18#include <net/ip6_fib.h> 18#include <net/ip6_fib.h>
19#include <net/ip6_route.h> 19#include <net/ip6_route.h>
20 20
21static bool fib6_is_local(const struct sk_buff *skb)
22{
23 const struct rt6_info *rt = (const void *)skb_dst(skb);
24
25 return rt && (rt->rt6i_flags & RTF_LOCAL);
26}
27
28static int get_ifindex(const struct net_device *dev) 21static int get_ifindex(const struct net_device *dev)
29{ 22{
30 return dev ? dev->ifindex : 0; 23 return dev ? dev->ifindex : 0;
@@ -164,8 +157,10 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs,
164 157
165 lookup_flags = nft_fib6_flowi_init(&fl6, priv, pkt, oif); 158 lookup_flags = nft_fib6_flowi_init(&fl6, priv, pkt, oif);
166 159
167 if (nft_hook(pkt) == NF_INET_PRE_ROUTING && fib6_is_local(pkt->skb)) { 160 if (nft_hook(pkt) == NF_INET_PRE_ROUTING &&
168 nft_fib_store_result(dest, priv->result, pkt, LOOPBACK_IFINDEX); 161 nft_fib_is_loopback(pkt->skb, nft_in(pkt))) {
162 nft_fib_store_result(dest, priv->result, pkt,
163 nft_in(pkt)->ifindex);
169 return; 164 return;
170 } 165 }
171 166
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4f6b067c8753..7ea85370c11c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2896,6 +2896,11 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
2896 if (tb[RTA_MULTIPATH]) { 2896 if (tb[RTA_MULTIPATH]) {
2897 cfg->fc_mp = nla_data(tb[RTA_MULTIPATH]); 2897 cfg->fc_mp = nla_data(tb[RTA_MULTIPATH]);
2898 cfg->fc_mp_len = nla_len(tb[RTA_MULTIPATH]); 2898 cfg->fc_mp_len = nla_len(tb[RTA_MULTIPATH]);
2899
2900 err = lwtunnel_valid_encap_type_attr(cfg->fc_mp,
2901 cfg->fc_mp_len);
2902 if (err < 0)
2903 goto errout;
2899 } 2904 }
2900 2905
2901 if (tb[RTA_PREF]) { 2906 if (tb[RTA_PREF]) {
@@ -2909,9 +2914,14 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
2909 if (tb[RTA_ENCAP]) 2914 if (tb[RTA_ENCAP])
2910 cfg->fc_encap = tb[RTA_ENCAP]; 2915 cfg->fc_encap = tb[RTA_ENCAP];
2911 2916
2912 if (tb[RTA_ENCAP_TYPE]) 2917 if (tb[RTA_ENCAP_TYPE]) {
2913 cfg->fc_encap_type = nla_get_u16(tb[RTA_ENCAP_TYPE]); 2918 cfg->fc_encap_type = nla_get_u16(tb[RTA_ENCAP_TYPE]);
2914 2919
2920 err = lwtunnel_valid_encap_type(cfg->fc_encap_type);
2921 if (err < 0)
2922 goto errout;
2923 }
2924
2915 if (tb[RTA_EXPIRES]) { 2925 if (tb[RTA_EXPIRES]) {
2916 unsigned long timeout = addrconf_timeout_fixup(nla_get_u32(tb[RTA_EXPIRES]), HZ); 2926 unsigned long timeout = addrconf_timeout_fixup(nla_get_u32(tb[RTA_EXPIRES]), HZ);
2917 2927
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index b172d85c650a..a855eb325b03 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -176,6 +176,8 @@ static int seg6_genl_set_tunsrc(struct sk_buff *skb, struct genl_info *info)
176 176
177 val = nla_data(info->attrs[SEG6_ATTR_DST]); 177 val = nla_data(info->attrs[SEG6_ATTR_DST]);
178 t_new = kmemdup(val, sizeof(*val), GFP_KERNEL); 178 t_new = kmemdup(val, sizeof(*val), GFP_KERNEL);
179 if (!t_new)
180 return -ENOMEM;
179 181
180 mutex_lock(&sdata->lock); 182 mutex_lock(&sdata->lock);
181 183
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 1d60cb132835..c46f8cbf5ab5 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -422,6 +422,7 @@ static const struct lwtunnel_encap_ops seg6_iptun_ops = {
422 .fill_encap = seg6_fill_encap_info, 422 .fill_encap = seg6_fill_encap_info,
423 .get_encap_size = seg6_encap_nlsize, 423 .get_encap_size = seg6_encap_nlsize,
424 .cmp_encap = seg6_encap_cmp, 424 .cmp_encap = seg6_encap_cmp,
425 .owner = THIS_MODULE,
425}; 426};
426 427
427int __init seg6_iptunnel_init(void) 428int __init seg6_iptunnel_init(void)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 73bc8fc68acd..cb8929681dc7 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -469,7 +469,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,
469 opt = ireq->ipv6_opt; 469 opt = ireq->ipv6_opt;
470 if (!opt) 470 if (!opt)
471 opt = rcu_dereference(np->opt); 471 opt = rcu_dereference(np->opt);
472 err = ip6_xmit(sk, skb, fl6, opt, np->tclass); 472 err = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass);
473 rcu_read_unlock(); 473 rcu_read_unlock();
474 err = net_xmit_eval(err); 474 err = net_xmit_eval(err);
475 } 475 }
@@ -840,7 +840,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
840 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL); 840 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
841 if (!IS_ERR(dst)) { 841 if (!IS_ERR(dst)) {
842 skb_dst_set(buff, dst); 842 skb_dst_set(buff, dst);
843 ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass); 843 ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass);
844 TCP_INC_STATS(net, TCP_MIB_OUTSEGS); 844 TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
845 if (rst) 845 if (rst)
846 TCP_INC_STATS(net, TCP_MIB_OUTRSTS); 846 TCP_INC_STATS(net, TCP_MIB_OUTRSTS);
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 9e2641d45587..206698bc93f4 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -40,8 +40,6 @@ void rate_control_rate_init(struct sta_info *sta)
40 40
41 ieee80211_sta_set_rx_nss(sta); 41 ieee80211_sta_set_rx_nss(sta);
42 42
43 ieee80211_recalc_min_chandef(sta->sdata);
44
45 if (!ref) 43 if (!ref)
46 return; 44 return;
47 45
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 15fe97644ffe..5b77377e5a15 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -98,18 +98,19 @@ bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
98} 98}
99EXPORT_SYMBOL_GPL(mpls_pkt_too_big); 99EXPORT_SYMBOL_GPL(mpls_pkt_too_big);
100 100
101static u32 mpls_multipath_hash(struct mpls_route *rt, 101static u32 mpls_multipath_hash(struct mpls_route *rt, struct sk_buff *skb)
102 struct sk_buff *skb, bool bos)
103{ 102{
104 struct mpls_entry_decoded dec; 103 struct mpls_entry_decoded dec;
104 unsigned int mpls_hdr_len = 0;
105 struct mpls_shim_hdr *hdr; 105 struct mpls_shim_hdr *hdr;
106 bool eli_seen = false; 106 bool eli_seen = false;
107 int label_index; 107 int label_index;
108 u32 hash = 0; 108 u32 hash = 0;
109 109
110 for (label_index = 0; label_index < MAX_MP_SELECT_LABELS && !bos; 110 for (label_index = 0; label_index < MAX_MP_SELECT_LABELS;
111 label_index++) { 111 label_index++) {
112 if (!pskb_may_pull(skb, sizeof(*hdr) * label_index)) 112 mpls_hdr_len += sizeof(*hdr);
113 if (!pskb_may_pull(skb, mpls_hdr_len))
113 break; 114 break;
114 115
115 /* Read and decode the current label */ 116 /* Read and decode the current label */
@@ -134,37 +135,38 @@ static u32 mpls_multipath_hash(struct mpls_route *rt,
134 eli_seen = true; 135 eli_seen = true;
135 } 136 }
136 137
137 bos = dec.bos; 138 if (!dec.bos)
138 if (bos && pskb_may_pull(skb, sizeof(*hdr) * label_index + 139 continue;
139 sizeof(struct iphdr))) { 140
141 /* found bottom label; does skb have room for a header? */
142 if (pskb_may_pull(skb, mpls_hdr_len + sizeof(struct iphdr))) {
140 const struct iphdr *v4hdr; 143 const struct iphdr *v4hdr;
141 144
142 v4hdr = (const struct iphdr *)(mpls_hdr(skb) + 145 v4hdr = (const struct iphdr *)(hdr + 1);
143 label_index);
144 if (v4hdr->version == 4) { 146 if (v4hdr->version == 4) {
145 hash = jhash_3words(ntohl(v4hdr->saddr), 147 hash = jhash_3words(ntohl(v4hdr->saddr),
146 ntohl(v4hdr->daddr), 148 ntohl(v4hdr->daddr),
147 v4hdr->protocol, hash); 149 v4hdr->protocol, hash);
148 } else if (v4hdr->version == 6 && 150 } else if (v4hdr->version == 6 &&
149 pskb_may_pull(skb, sizeof(*hdr) * label_index + 151 pskb_may_pull(skb, mpls_hdr_len +
150 sizeof(struct ipv6hdr))) { 152 sizeof(struct ipv6hdr))) {
151 const struct ipv6hdr *v6hdr; 153 const struct ipv6hdr *v6hdr;
152 154
153 v6hdr = (const struct ipv6hdr *)(mpls_hdr(skb) + 155 v6hdr = (const struct ipv6hdr *)(hdr + 1);
154 label_index);
155
156 hash = __ipv6_addr_jhash(&v6hdr->saddr, hash); 156 hash = __ipv6_addr_jhash(&v6hdr->saddr, hash);
157 hash = __ipv6_addr_jhash(&v6hdr->daddr, hash); 157 hash = __ipv6_addr_jhash(&v6hdr->daddr, hash);
158 hash = jhash_1word(v6hdr->nexthdr, hash); 158 hash = jhash_1word(v6hdr->nexthdr, hash);
159 } 159 }
160 } 160 }
161
162 break;
161 } 163 }
162 164
163 return hash; 165 return hash;
164} 166}
165 167
166static struct mpls_nh *mpls_select_multipath(struct mpls_route *rt, 168static struct mpls_nh *mpls_select_multipath(struct mpls_route *rt,
167 struct sk_buff *skb, bool bos) 169 struct sk_buff *skb)
168{ 170{
169 int alive = ACCESS_ONCE(rt->rt_nhn_alive); 171 int alive = ACCESS_ONCE(rt->rt_nhn_alive);
170 u32 hash = 0; 172 u32 hash = 0;
@@ -180,7 +182,7 @@ static struct mpls_nh *mpls_select_multipath(struct mpls_route *rt,
180 if (alive <= 0) 182 if (alive <= 0)
181 return NULL; 183 return NULL;
182 184
183 hash = mpls_multipath_hash(rt, skb, bos); 185 hash = mpls_multipath_hash(rt, skb);
184 nh_index = hash % alive; 186 nh_index = hash % alive;
185 if (alive == rt->rt_nhn) 187 if (alive == rt->rt_nhn)
186 goto out; 188 goto out;
@@ -278,17 +280,11 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
278 hdr = mpls_hdr(skb); 280 hdr = mpls_hdr(skb);
279 dec = mpls_entry_decode(hdr); 281 dec = mpls_entry_decode(hdr);
280 282
281 /* Pop the label */
282 skb_pull(skb, sizeof(*hdr));
283 skb_reset_network_header(skb);
284
285 skb_orphan(skb);
286
287 rt = mpls_route_input_rcu(net, dec.label); 283 rt = mpls_route_input_rcu(net, dec.label);
288 if (!rt) 284 if (!rt)
289 goto drop; 285 goto drop;
290 286
291 nh = mpls_select_multipath(rt, skb, dec.bos); 287 nh = mpls_select_multipath(rt, skb);
292 if (!nh) 288 if (!nh)
293 goto drop; 289 goto drop;
294 290
@@ -297,6 +293,12 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
297 if (!mpls_output_possible(out_dev)) 293 if (!mpls_output_possible(out_dev))
298 goto drop; 294 goto drop;
299 295
296 /* Pop the label */
297 skb_pull(skb, sizeof(*hdr));
298 skb_reset_network_header(skb);
299
300 skb_orphan(skb);
301
300 if (skb_warn_if_lro(skb)) 302 if (skb_warn_if_lro(skb))
301 goto drop; 303 goto drop;
302 304
diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
index 2f7ccd934416..1d281c1ff7c1 100644
--- a/net/mpls/mpls_iptunnel.c
+++ b/net/mpls/mpls_iptunnel.c
@@ -215,6 +215,7 @@ static const struct lwtunnel_encap_ops mpls_iptun_ops = {
215 .fill_encap = mpls_fill_encap_info, 215 .fill_encap = mpls_fill_encap_info,
216 .get_encap_size = mpls_encap_nlsize, 216 .get_encap_size = mpls_encap_nlsize,
217 .cmp_encap = mpls_encap_cmp, 217 .cmp_encap = mpls_encap_cmp,
218 .owner = THIS_MODULE,
218}; 219};
219 220
220static int __init mpls_iptunnel_init(void) 221static int __init mpls_iptunnel_init(void)
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 63729b489c2c..bbc45f8a7b2d 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -494,7 +494,7 @@ config NFT_CT
494 depends on NF_CONNTRACK 494 depends on NF_CONNTRACK
495 tristate "Netfilter nf_tables conntrack module" 495 tristate "Netfilter nf_tables conntrack module"
496 help 496 help
497 This option adds the "meta" expression that you can use to match 497 This option adds the "ct" expression that you can use to match
498 connection tracking information such as the flow state. 498 connection tracking information such as the flow state.
499 499
500config NFT_SET_RBTREE 500config NFT_SET_RBTREE
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 3a073cd9fcf4..4e8083c5e01d 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -85,11 +85,11 @@ static __read_mostly DEFINE_SPINLOCK(nf_conntrack_locks_all_lock);
85static __read_mostly bool nf_conntrack_locks_all; 85static __read_mostly bool nf_conntrack_locks_all;
86 86
87/* every gc cycle scans at most 1/GC_MAX_BUCKETS_DIV part of table */ 87/* every gc cycle scans at most 1/GC_MAX_BUCKETS_DIV part of table */
88#define GC_MAX_BUCKETS_DIV 64u 88#define GC_MAX_BUCKETS_DIV 128u
89/* upper bound of scan intervals */ 89/* upper bound of full table scan */
90#define GC_INTERVAL_MAX (2 * HZ) 90#define GC_MAX_SCAN_JIFFIES (16u * HZ)
91/* maximum conntracks to evict per gc run */ 91/* desired ratio of entries found to be expired */
92#define GC_MAX_EVICTS 256u 92#define GC_EVICT_RATIO 50u
93 93
94static struct conntrack_gc_work conntrack_gc_work; 94static struct conntrack_gc_work conntrack_gc_work;
95 95
@@ -938,6 +938,7 @@ static noinline int early_drop(struct net *net, unsigned int _hash)
938 938
939static void gc_worker(struct work_struct *work) 939static void gc_worker(struct work_struct *work)
940{ 940{
941 unsigned int min_interval = max(HZ / GC_MAX_BUCKETS_DIV, 1u);
941 unsigned int i, goal, buckets = 0, expired_count = 0; 942 unsigned int i, goal, buckets = 0, expired_count = 0;
942 struct conntrack_gc_work *gc_work; 943 struct conntrack_gc_work *gc_work;
943 unsigned int ratio, scanned = 0; 944 unsigned int ratio, scanned = 0;
@@ -979,8 +980,7 @@ static void gc_worker(struct work_struct *work)
979 */ 980 */
980 rcu_read_unlock(); 981 rcu_read_unlock();
981 cond_resched_rcu_qs(); 982 cond_resched_rcu_qs();
982 } while (++buckets < goal && 983 } while (++buckets < goal);
983 expired_count < GC_MAX_EVICTS);
984 984
985 if (gc_work->exiting) 985 if (gc_work->exiting)
986 return; 986 return;
@@ -997,27 +997,25 @@ static void gc_worker(struct work_struct *work)
997 * 1. Minimize time until we notice a stale entry 997 * 1. Minimize time until we notice a stale entry
998 * 2. Maximize scan intervals to not waste cycles 998 * 2. Maximize scan intervals to not waste cycles
999 * 999 *
1000 * Normally, expired_count will be 0, this increases the next_run time 1000 * Normally, expire ratio will be close to 0.
1001 * to priorize 2) above.
1002 * 1001 *
1003 * As soon as a timed-out entry is found, move towards 1) and increase 1002 * As soon as a sizeable fraction of the entries have expired
1004 * the scan frequency. 1003 * increase scan frequency.
1005 * In case we have lots of evictions next scan is done immediately.
1006 */ 1004 */
1007 ratio = scanned ? expired_count * 100 / scanned : 0; 1005 ratio = scanned ? expired_count * 100 / scanned : 0;
1008 if (ratio >= 90 || expired_count == GC_MAX_EVICTS) { 1006 if (ratio > GC_EVICT_RATIO) {
1009 gc_work->next_gc_run = 0; 1007 gc_work->next_gc_run = min_interval;
1010 next_run = 0;
1011 } else if (expired_count) {
1012 gc_work->next_gc_run /= 2U;
1013 next_run = msecs_to_jiffies(1);
1014 } else { 1008 } else {
1015 if (gc_work->next_gc_run < GC_INTERVAL_MAX) 1009 unsigned int max = GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV;
1016 gc_work->next_gc_run += msecs_to_jiffies(1);
1017 1010
1018 next_run = gc_work->next_gc_run; 1011 BUILD_BUG_ON((GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV) == 0);
1012
1013 gc_work->next_gc_run += min_interval;
1014 if (gc_work->next_gc_run > max)
1015 gc_work->next_gc_run = max;
1019 } 1016 }
1020 1017
1018 next_run = gc_work->next_gc_run;
1021 gc_work->last_bucket = i; 1019 gc_work->last_bucket = i;
1022 queue_delayed_work(system_long_wq, &gc_work->dwork, next_run); 1020 queue_delayed_work(system_long_wq, &gc_work->dwork, next_run);
1023} 1021}
@@ -1025,7 +1023,7 @@ static void gc_worker(struct work_struct *work)
1025static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work) 1023static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work)
1026{ 1024{
1027 INIT_DELAYED_WORK(&gc_work->dwork, gc_worker); 1025 INIT_DELAYED_WORK(&gc_work->dwork, gc_worker);
1028 gc_work->next_gc_run = GC_INTERVAL_MAX; 1026 gc_work->next_gc_run = HZ;
1029 gc_work->exiting = false; 1027 gc_work->exiting = false;
1030} 1028}
1031 1029
@@ -1917,7 +1915,7 @@ int nf_conntrack_init_start(void)
1917 nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED); 1915 nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED);
1918 1916
1919 conntrack_gc_work_init(&conntrack_gc_work); 1917 conntrack_gc_work_init(&conntrack_gc_work);
1920 queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, GC_INTERVAL_MAX); 1918 queue_delayed_work(system_long_wq, &conntrack_gc_work.dwork, HZ);
1921 1919
1922 return 0; 1920 return 0;
1923 1921
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index 3dca90dc24ad..ffb9e8ada899 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -13,7 +13,6 @@
13/* Internal logging interface, which relies on the real 13/* Internal logging interface, which relies on the real
14 LOG target modules */ 14 LOG target modules */
15 15
16#define NF_LOG_PREFIXLEN 128
17#define NFLOGGER_NAME_LEN 64 16#define NFLOGGER_NAME_LEN 64
18 17
19static struct nf_logger __rcu *loggers[NFPROTO_NUMPROTO][NF_LOG_TYPE_MAX] __read_mostly; 18static struct nf_logger __rcu *loggers[NFPROTO_NUMPROTO][NF_LOG_TYPE_MAX] __read_mostly;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 0db5f9782265..1b913760f205 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -928,7 +928,8 @@ static struct nft_chain *nf_tables_chain_lookup(const struct nft_table *table,
928} 928}
929 929
930static const struct nla_policy nft_chain_policy[NFTA_CHAIN_MAX + 1] = { 930static const struct nla_policy nft_chain_policy[NFTA_CHAIN_MAX + 1] = {
931 [NFTA_CHAIN_TABLE] = { .type = NLA_STRING }, 931 [NFTA_CHAIN_TABLE] = { .type = NLA_STRING,
932 .len = NFT_TABLE_MAXNAMELEN - 1 },
932 [NFTA_CHAIN_HANDLE] = { .type = NLA_U64 }, 933 [NFTA_CHAIN_HANDLE] = { .type = NLA_U64 },
933 [NFTA_CHAIN_NAME] = { .type = NLA_STRING, 934 [NFTA_CHAIN_NAME] = { .type = NLA_STRING,
934 .len = NFT_CHAIN_MAXNAMELEN - 1 }, 935 .len = NFT_CHAIN_MAXNAMELEN - 1 },
@@ -1854,7 +1855,8 @@ static struct nft_rule *nf_tables_rule_lookup(const struct nft_chain *chain,
1854} 1855}
1855 1856
1856static const struct nla_policy nft_rule_policy[NFTA_RULE_MAX + 1] = { 1857static const struct nla_policy nft_rule_policy[NFTA_RULE_MAX + 1] = {
1857 [NFTA_RULE_TABLE] = { .type = NLA_STRING }, 1858 [NFTA_RULE_TABLE] = { .type = NLA_STRING,
1859 .len = NFT_TABLE_MAXNAMELEN - 1 },
1858 [NFTA_RULE_CHAIN] = { .type = NLA_STRING, 1860 [NFTA_RULE_CHAIN] = { .type = NLA_STRING,
1859 .len = NFT_CHAIN_MAXNAMELEN - 1 }, 1861 .len = NFT_CHAIN_MAXNAMELEN - 1 },
1860 [NFTA_RULE_HANDLE] = { .type = NLA_U64 }, 1862 [NFTA_RULE_HANDLE] = { .type = NLA_U64 },
@@ -2443,7 +2445,8 @@ nft_select_set_ops(const struct nlattr * const nla[],
2443} 2445}
2444 2446
2445static const struct nla_policy nft_set_policy[NFTA_SET_MAX + 1] = { 2447static const struct nla_policy nft_set_policy[NFTA_SET_MAX + 1] = {
2446 [NFTA_SET_TABLE] = { .type = NLA_STRING }, 2448 [NFTA_SET_TABLE] = { .type = NLA_STRING,
2449 .len = NFT_TABLE_MAXNAMELEN - 1 },
2447 [NFTA_SET_NAME] = { .type = NLA_STRING, 2450 [NFTA_SET_NAME] = { .type = NLA_STRING,
2448 .len = NFT_SET_MAXNAMELEN - 1 }, 2451 .len = NFT_SET_MAXNAMELEN - 1 },
2449 [NFTA_SET_FLAGS] = { .type = NLA_U32 }, 2452 [NFTA_SET_FLAGS] = { .type = NLA_U32 },
@@ -3084,9 +3087,9 @@ static int nf_tables_delset(struct net *net, struct sock *nlsk,
3084} 3087}
3085 3088
3086static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx, 3089static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx,
3087 const struct nft_set *set, 3090 struct nft_set *set,
3088 const struct nft_set_iter *iter, 3091 const struct nft_set_iter *iter,
3089 const struct nft_set_elem *elem) 3092 struct nft_set_elem *elem)
3090{ 3093{
3091 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv); 3094 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv);
3092 enum nft_registers dreg; 3095 enum nft_registers dreg;
@@ -3192,8 +3195,10 @@ static const struct nla_policy nft_set_elem_policy[NFTA_SET_ELEM_MAX + 1] = {
3192}; 3195};
3193 3196
3194static const struct nla_policy nft_set_elem_list_policy[NFTA_SET_ELEM_LIST_MAX + 1] = { 3197static const struct nla_policy nft_set_elem_list_policy[NFTA_SET_ELEM_LIST_MAX + 1] = {
3195 [NFTA_SET_ELEM_LIST_TABLE] = { .type = NLA_STRING }, 3198 [NFTA_SET_ELEM_LIST_TABLE] = { .type = NLA_STRING,
3196 [NFTA_SET_ELEM_LIST_SET] = { .type = NLA_STRING }, 3199 .len = NFT_TABLE_MAXNAMELEN - 1 },
3200 [NFTA_SET_ELEM_LIST_SET] = { .type = NLA_STRING,
3201 .len = NFT_SET_MAXNAMELEN - 1 },
3197 [NFTA_SET_ELEM_LIST_ELEMENTS] = { .type = NLA_NESTED }, 3202 [NFTA_SET_ELEM_LIST_ELEMENTS] = { .type = NLA_NESTED },
3198 [NFTA_SET_ELEM_LIST_SET_ID] = { .type = NLA_U32 }, 3203 [NFTA_SET_ELEM_LIST_SET_ID] = { .type = NLA_U32 },
3199}; 3204};
@@ -3303,9 +3308,9 @@ struct nft_set_dump_args {
3303}; 3308};
3304 3309
3305static int nf_tables_dump_setelem(const struct nft_ctx *ctx, 3310static int nf_tables_dump_setelem(const struct nft_ctx *ctx,
3306 const struct nft_set *set, 3311 struct nft_set *set,
3307 const struct nft_set_iter *iter, 3312 const struct nft_set_iter *iter,
3308 const struct nft_set_elem *elem) 3313 struct nft_set_elem *elem)
3309{ 3314{
3310 struct nft_set_dump_args *args; 3315 struct nft_set_dump_args *args;
3311 3316
@@ -3317,7 +3322,7 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
3317{ 3322{
3318 struct net *net = sock_net(skb->sk); 3323 struct net *net = sock_net(skb->sk);
3319 u8 genmask = nft_genmask_cur(net); 3324 u8 genmask = nft_genmask_cur(net);
3320 const struct nft_set *set; 3325 struct nft_set *set;
3321 struct nft_set_dump_args args; 3326 struct nft_set_dump_args args;
3322 struct nft_ctx ctx; 3327 struct nft_ctx ctx;
3323 struct nlattr *nla[NFTA_SET_ELEM_LIST_MAX + 1]; 3328 struct nlattr *nla[NFTA_SET_ELEM_LIST_MAX + 1];
@@ -3740,10 +3745,18 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
3740 goto err5; 3745 goto err5;
3741 } 3746 }
3742 3747
3748 if (set->size &&
3749 !atomic_add_unless(&set->nelems, 1, set->size + set->ndeact)) {
3750 err = -ENFILE;
3751 goto err6;
3752 }
3753
3743 nft_trans_elem(trans) = elem; 3754 nft_trans_elem(trans) = elem;
3744 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 3755 list_add_tail(&trans->list, &ctx->net->nft.commit_list);
3745 return 0; 3756 return 0;
3746 3757
3758err6:
3759 set->ops->remove(set, &elem);
3747err5: 3760err5:
3748 kfree(trans); 3761 kfree(trans);
3749err4: 3762err4:
@@ -3790,15 +3803,9 @@ static int nf_tables_newsetelem(struct net *net, struct sock *nlsk,
3790 return -EBUSY; 3803 return -EBUSY;
3791 3804
3792 nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) { 3805 nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) {
3793 if (set->size &&
3794 !atomic_add_unless(&set->nelems, 1, set->size + set->ndeact))
3795 return -ENFILE;
3796
3797 err = nft_add_set_elem(&ctx, set, attr, nlh->nlmsg_flags); 3806 err = nft_add_set_elem(&ctx, set, attr, nlh->nlmsg_flags);
3798 if (err < 0) { 3807 if (err < 0)
3799 atomic_dec(&set->nelems);
3800 break; 3808 break;
3801 }
3802 } 3809 }
3803 return err; 3810 return err;
3804} 3811}
@@ -3883,9 +3890,9 @@ err1:
3883} 3890}
3884 3891
3885static int nft_flush_set(const struct nft_ctx *ctx, 3892static int nft_flush_set(const struct nft_ctx *ctx,
3886 const struct nft_set *set, 3893 struct nft_set *set,
3887 const struct nft_set_iter *iter, 3894 const struct nft_set_iter *iter,
3888 const struct nft_set_elem *elem) 3895 struct nft_set_elem *elem)
3889{ 3896{
3890 struct nft_trans *trans; 3897 struct nft_trans *trans;
3891 int err; 3898 int err;
@@ -3899,9 +3906,10 @@ static int nft_flush_set(const struct nft_ctx *ctx,
3899 err = -ENOENT; 3906 err = -ENOENT;
3900 goto err1; 3907 goto err1;
3901 } 3908 }
3909 set->ndeact++;
3902 3910
3903 nft_trans_elem_set(trans) = (struct nft_set *)set; 3911 nft_trans_elem_set(trans) = set;
3904 nft_trans_elem(trans) = *((struct nft_set_elem *)elem); 3912 nft_trans_elem(trans) = *elem;
3905 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 3913 list_add_tail(&trans->list, &ctx->net->nft.commit_list);
3906 3914
3907 return 0; 3915 return 0;
@@ -4032,8 +4040,10 @@ struct nft_object *nf_tables_obj_lookup(const struct nft_table *table,
4032EXPORT_SYMBOL_GPL(nf_tables_obj_lookup); 4040EXPORT_SYMBOL_GPL(nf_tables_obj_lookup);
4033 4041
4034static const struct nla_policy nft_obj_policy[NFTA_OBJ_MAX + 1] = { 4042static const struct nla_policy nft_obj_policy[NFTA_OBJ_MAX + 1] = {
4035 [NFTA_OBJ_TABLE] = { .type = NLA_STRING }, 4043 [NFTA_OBJ_TABLE] = { .type = NLA_STRING,
4036 [NFTA_OBJ_NAME] = { .type = NLA_STRING }, 4044 .len = NFT_TABLE_MAXNAMELEN - 1 },
4045 [NFTA_OBJ_NAME] = { .type = NLA_STRING,
4046 .len = NFT_OBJ_MAXNAMELEN - 1 },
4037 [NFTA_OBJ_TYPE] = { .type = NLA_U32 }, 4047 [NFTA_OBJ_TYPE] = { .type = NLA_U32 },
4038 [NFTA_OBJ_DATA] = { .type = NLA_NESTED }, 4048 [NFTA_OBJ_DATA] = { .type = NLA_NESTED },
4039}; 4049};
@@ -4262,10 +4272,11 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
4262 if (idx > s_idx) 4272 if (idx > s_idx)
4263 memset(&cb->args[1], 0, 4273 memset(&cb->args[1], 0,
4264 sizeof(cb->args) - sizeof(cb->args[0])); 4274 sizeof(cb->args) - sizeof(cb->args[0]));
4265 if (filter->table[0] && 4275 if (filter && filter->table[0] &&
4266 strcmp(filter->table, table->name)) 4276 strcmp(filter->table, table->name))
4267 goto cont; 4277 goto cont;
4268 if (filter->type != NFT_OBJECT_UNSPEC && 4278 if (filter &&
4279 filter->type != NFT_OBJECT_UNSPEC &&
4269 obj->type->type != filter->type) 4280 obj->type->type != filter->type)
4270 goto cont; 4281 goto cont;
4271 4282
@@ -5009,9 +5020,9 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
5009 const struct nft_chain *chain); 5020 const struct nft_chain *chain);
5010 5021
5011static int nf_tables_loop_check_setelem(const struct nft_ctx *ctx, 5022static int nf_tables_loop_check_setelem(const struct nft_ctx *ctx,
5012 const struct nft_set *set, 5023 struct nft_set *set,
5013 const struct nft_set_iter *iter, 5024 const struct nft_set_iter *iter,
5014 const struct nft_set_elem *elem) 5025 struct nft_set_elem *elem)
5015{ 5026{
5016 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv); 5027 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv);
5017 const struct nft_data *data; 5028 const struct nft_data *data;
@@ -5035,7 +5046,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
5035{ 5046{
5036 const struct nft_rule *rule; 5047 const struct nft_rule *rule;
5037 const struct nft_expr *expr, *last; 5048 const struct nft_expr *expr, *last;
5038 const struct nft_set *set; 5049 struct nft_set *set;
5039 struct nft_set_binding *binding; 5050 struct nft_set_binding *binding;
5040 struct nft_set_iter iter; 5051 struct nft_set_iter iter;
5041 5052
diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
index 7de2f46734a4..049ad2d9ee66 100644
--- a/net/netfilter/nft_dynset.c
+++ b/net/netfilter/nft_dynset.c
@@ -98,7 +98,8 @@ out:
98} 98}
99 99
100static const struct nla_policy nft_dynset_policy[NFTA_DYNSET_MAX + 1] = { 100static const struct nla_policy nft_dynset_policy[NFTA_DYNSET_MAX + 1] = {
101 [NFTA_DYNSET_SET_NAME] = { .type = NLA_STRING }, 101 [NFTA_DYNSET_SET_NAME] = { .type = NLA_STRING,
102 .len = NFT_SET_MAXNAMELEN - 1 },
102 [NFTA_DYNSET_SET_ID] = { .type = NLA_U32 }, 103 [NFTA_DYNSET_SET_ID] = { .type = NLA_U32 },
103 [NFTA_DYNSET_OP] = { .type = NLA_U32 }, 104 [NFTA_DYNSET_OP] = { .type = NLA_U32 },
104 [NFTA_DYNSET_SREG_KEY] = { .type = NLA_U32 }, 105 [NFTA_DYNSET_SREG_KEY] = { .type = NLA_U32 },
diff --git a/net/netfilter/nft_log.c b/net/netfilter/nft_log.c
index 6271e40a3dd6..6f6e64423643 100644
--- a/net/netfilter/nft_log.c
+++ b/net/netfilter/nft_log.c
@@ -39,7 +39,8 @@ static void nft_log_eval(const struct nft_expr *expr,
39 39
40static const struct nla_policy nft_log_policy[NFTA_LOG_MAX + 1] = { 40static const struct nla_policy nft_log_policy[NFTA_LOG_MAX + 1] = {
41 [NFTA_LOG_GROUP] = { .type = NLA_U16 }, 41 [NFTA_LOG_GROUP] = { .type = NLA_U16 },
42 [NFTA_LOG_PREFIX] = { .type = NLA_STRING }, 42 [NFTA_LOG_PREFIX] = { .type = NLA_STRING,
43 .len = NF_LOG_PREFIXLEN - 1 },
43 [NFTA_LOG_SNAPLEN] = { .type = NLA_U32 }, 44 [NFTA_LOG_SNAPLEN] = { .type = NLA_U32 },
44 [NFTA_LOG_QTHRESHOLD] = { .type = NLA_U16 }, 45 [NFTA_LOG_QTHRESHOLD] = { .type = NLA_U16 },
45 [NFTA_LOG_LEVEL] = { .type = NLA_U32 }, 46 [NFTA_LOG_LEVEL] = { .type = NLA_U32 },
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index d4f97fa7e21d..e21aea7e5ec8 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -49,7 +49,8 @@ static void nft_lookup_eval(const struct nft_expr *expr,
49} 49}
50 50
51static const struct nla_policy nft_lookup_policy[NFTA_LOOKUP_MAX + 1] = { 51static const struct nla_policy nft_lookup_policy[NFTA_LOOKUP_MAX + 1] = {
52 [NFTA_LOOKUP_SET] = { .type = NLA_STRING }, 52 [NFTA_LOOKUP_SET] = { .type = NLA_STRING,
53 .len = NFT_SET_MAXNAMELEN - 1 },
53 [NFTA_LOOKUP_SET_ID] = { .type = NLA_U32 }, 54 [NFTA_LOOKUP_SET_ID] = { .type = NLA_U32 },
54 [NFTA_LOOKUP_SREG] = { .type = NLA_U32 }, 55 [NFTA_LOOKUP_SREG] = { .type = NLA_U32 },
55 [NFTA_LOOKUP_DREG] = { .type = NLA_U32 }, 56 [NFTA_LOOKUP_DREG] = { .type = NLA_U32 },
diff --git a/net/netfilter/nft_objref.c b/net/netfilter/nft_objref.c
index 415a65ba2b85..1ae8c49ca4a1 100644
--- a/net/netfilter/nft_objref.c
+++ b/net/netfilter/nft_objref.c
@@ -193,10 +193,12 @@ nft_objref_select_ops(const struct nft_ctx *ctx,
193} 193}
194 194
195static const struct nla_policy nft_objref_policy[NFTA_OBJREF_MAX + 1] = { 195static const struct nla_policy nft_objref_policy[NFTA_OBJREF_MAX + 1] = {
196 [NFTA_OBJREF_IMM_NAME] = { .type = NLA_STRING }, 196 [NFTA_OBJREF_IMM_NAME] = { .type = NLA_STRING,
197 .len = NFT_OBJ_MAXNAMELEN - 1 },
197 [NFTA_OBJREF_IMM_TYPE] = { .type = NLA_U32 }, 198 [NFTA_OBJREF_IMM_TYPE] = { .type = NLA_U32 },
198 [NFTA_OBJREF_SET_SREG] = { .type = NLA_U32 }, 199 [NFTA_OBJREF_SET_SREG] = { .type = NLA_U32 },
199 [NFTA_OBJREF_SET_NAME] = { .type = NLA_STRING }, 200 [NFTA_OBJREF_SET_NAME] = { .type = NLA_STRING,
201 .len = NFT_SET_MAXNAMELEN - 1 },
200 [NFTA_OBJREF_SET_ID] = { .type = NLA_U32 }, 202 [NFTA_OBJREF_SET_ID] = { .type = NLA_U32 },
201}; 203};
202 204
diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c
index 1e20e2bbb6d9..e36069fb76ae 100644
--- a/net/netfilter/nft_set_hash.c
+++ b/net/netfilter/nft_set_hash.c
@@ -212,7 +212,7 @@ static void nft_hash_remove(const struct nft_set *set,
212 rhashtable_remove_fast(&priv->ht, &he->node, nft_hash_params); 212 rhashtable_remove_fast(&priv->ht, &he->node, nft_hash_params);
213} 213}
214 214
215static void nft_hash_walk(const struct nft_ctx *ctx, const struct nft_set *set, 215static void nft_hash_walk(const struct nft_ctx *ctx, struct nft_set *set,
216 struct nft_set_iter *iter) 216 struct nft_set_iter *iter)
217{ 217{
218 struct nft_hash *priv = nft_set_priv(set); 218 struct nft_hash *priv = nft_set_priv(set);
diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
index 08376e50f6cd..f06f55ee516d 100644
--- a/net/netfilter/nft_set_rbtree.c
+++ b/net/netfilter/nft_set_rbtree.c
@@ -221,7 +221,7 @@ static void *nft_rbtree_deactivate(const struct net *net,
221} 221}
222 222
223static void nft_rbtree_walk(const struct nft_ctx *ctx, 223static void nft_rbtree_walk(const struct nft_ctx *ctx,
224 const struct nft_set *set, 224 struct nft_set *set,
225 struct nft_set_iter *iter) 225 struct nft_set_iter *iter)
226{ 226{
227 const struct nft_rbtree *priv = nft_set_priv(set); 227 const struct nft_rbtree *priv = nft_set_priv(set);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index b9e1a13b4ba3..3d555c79a7b5 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1976,7 +1976,7 @@ static int packet_rcv_vnet(struct msghdr *msg, const struct sk_buff *skb,
1976 return -EINVAL; 1976 return -EINVAL;
1977 *len -= sizeof(vnet_hdr); 1977 *len -= sizeof(vnet_hdr);
1978 1978
1979 if (virtio_net_hdr_from_skb(skb, &vnet_hdr, vio_le())) 1979 if (virtio_net_hdr_from_skb(skb, &vnet_hdr, vio_le(), true))
1980 return -EINVAL; 1980 return -EINVAL;
1981 1981
1982 return memcpy_to_msg(msg, (void *)&vnet_hdr, sizeof(vnet_hdr)); 1982 return memcpy_to_msg(msg, (void *)&vnet_hdr, sizeof(vnet_hdr));
@@ -2237,7 +2237,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
2237 if (po->has_vnet_hdr) { 2237 if (po->has_vnet_hdr) {
2238 if (virtio_net_hdr_from_skb(skb, h.raw + macoff - 2238 if (virtio_net_hdr_from_skb(skb, h.raw + macoff -
2239 sizeof(struct virtio_net_hdr), 2239 sizeof(struct virtio_net_hdr),
2240 vio_le())) { 2240 vio_le(), true)) {
2241 spin_lock(&sk->sk_receive_queue.lock); 2241 spin_lock(&sk->sk_receive_queue.lock);
2242 goto drop_n_account; 2242 goto drop_n_account;
2243 } 2243 }
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 5ed8e79bf102..64dfd35ccdcc 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -222,7 +222,8 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
222 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS); 222 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
223 223
224 rcu_read_lock(); 224 rcu_read_lock();
225 res = ip6_xmit(sk, skb, fl6, rcu_dereference(np->opt), np->tclass); 225 res = ip6_xmit(sk, skb, fl6, sk->sk_mark, rcu_dereference(np->opt),
226 np->tclass);
226 rcu_read_unlock(); 227 rcu_read_unlock();
227 return res; 228 return res;
228} 229}
diff --git a/net/sctp/offload.c b/net/sctp/offload.c
index 7e869d0cca69..4f5a2b580aa5 100644
--- a/net/sctp/offload.c
+++ b/net/sctp/offload.c
@@ -68,7 +68,7 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb,
68 goto out; 68 goto out;
69 } 69 }
70 70
71 segs = skb_segment(skb, features | NETIF_F_HW_CSUM); 71 segs = skb_segment(skb, features | NETIF_F_HW_CSUM | NETIF_F_SG);
72 if (IS_ERR(segs)) 72 if (IS_ERR(segs))
73 goto out; 73 goto out;
74 74
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 318c6786d653..37eeab7899fc 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -235,8 +235,12 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
235 sctp_assoc_t id) 235 sctp_assoc_t id)
236{ 236{
237 struct sctp_association *addr_asoc = NULL, *id_asoc = NULL; 237 struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
238 struct sctp_transport *transport; 238 struct sctp_af *af = sctp_get_af_specific(addr->ss_family);
239 union sctp_addr *laddr = (union sctp_addr *)addr; 239 union sctp_addr *laddr = (union sctp_addr *)addr;
240 struct sctp_transport *transport;
241
242 if (sctp_verify_addr(sk, laddr, af->sockaddr_len))
243 return NULL;
240 244
241 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep, 245 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
242 laddr, 246 laddr,
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 9d2f4c2b08ab..27753325e06e 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -263,6 +263,11 @@ static void tipc_node_write_lock(struct tipc_node *n)
263 write_lock_bh(&n->lock); 263 write_lock_bh(&n->lock);
264} 264}
265 265
266static void tipc_node_write_unlock_fast(struct tipc_node *n)
267{
268 write_unlock_bh(&n->lock);
269}
270
266static void tipc_node_write_unlock(struct tipc_node *n) 271static void tipc_node_write_unlock(struct tipc_node *n)
267{ 272{
268 struct net *net = n->net; 273 struct net *net = n->net;
@@ -417,7 +422,7 @@ void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr)
417 } 422 }
418 tipc_node_write_lock(n); 423 tipc_node_write_lock(n);
419 list_add_tail(subscr, &n->publ_list); 424 list_add_tail(subscr, &n->publ_list);
420 tipc_node_write_unlock(n); 425 tipc_node_write_unlock_fast(n);
421 tipc_node_put(n); 426 tipc_node_put(n);
422} 427}
423 428
@@ -435,7 +440,7 @@ void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr)
435 } 440 }
436 tipc_node_write_lock(n); 441 tipc_node_write_lock(n);
437 list_del_init(subscr); 442 list_del_init(subscr);
438 tipc_node_write_unlock(n); 443 tipc_node_write_unlock_fast(n);
439 tipc_node_put(n); 444 tipc_node_put(n);
440} 445}
441 446
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 215849ce453d..3cd6402e812c 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -86,12 +86,12 @@ struct outqueue_entry {
86static void tipc_recv_work(struct work_struct *work); 86static void tipc_recv_work(struct work_struct *work);
87static void tipc_send_work(struct work_struct *work); 87static void tipc_send_work(struct work_struct *work);
88static void tipc_clean_outqueues(struct tipc_conn *con); 88static void tipc_clean_outqueues(struct tipc_conn *con);
89static void tipc_sock_release(struct tipc_conn *con);
90 89
91static void tipc_conn_kref_release(struct kref *kref) 90static void tipc_conn_kref_release(struct kref *kref)
92{ 91{
93 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref); 92 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref);
94 struct sockaddr_tipc *saddr = con->server->saddr; 93 struct tipc_server *s = con->server;
94 struct sockaddr_tipc *saddr = s->saddr;
95 struct socket *sock = con->sock; 95 struct socket *sock = con->sock;
96 struct sock *sk; 96 struct sock *sk;
97 97
@@ -103,9 +103,13 @@ static void tipc_conn_kref_release(struct kref *kref)
103 } 103 }
104 saddr->scope = -TIPC_NODE_SCOPE; 104 saddr->scope = -TIPC_NODE_SCOPE;
105 kernel_bind(sock, (struct sockaddr *)saddr, sizeof(*saddr)); 105 kernel_bind(sock, (struct sockaddr *)saddr, sizeof(*saddr));
106 tipc_sock_release(con);
107 sock_release(sock); 106 sock_release(sock);
108 con->sock = NULL; 107 con->sock = NULL;
108
109 spin_lock_bh(&s->idr_lock);
110 idr_remove(&s->conn_idr, con->conid);
111 s->idr_in_use--;
112 spin_unlock_bh(&s->idr_lock);
109 } 113 }
110 114
111 tipc_clean_outqueues(con); 115 tipc_clean_outqueues(con);
@@ -128,8 +132,10 @@ static struct tipc_conn *tipc_conn_lookup(struct tipc_server *s, int conid)
128 132
129 spin_lock_bh(&s->idr_lock); 133 spin_lock_bh(&s->idr_lock);
130 con = idr_find(&s->conn_idr, conid); 134 con = idr_find(&s->conn_idr, conid);
131 if (con) 135 if (con && test_bit(CF_CONNECTED, &con->flags))
132 conn_get(con); 136 conn_get(con);
137 else
138 con = NULL;
133 spin_unlock_bh(&s->idr_lock); 139 spin_unlock_bh(&s->idr_lock);
134 return con; 140 return con;
135} 141}
@@ -186,26 +192,15 @@ static void tipc_unregister_callbacks(struct tipc_conn *con)
186 write_unlock_bh(&sk->sk_callback_lock); 192 write_unlock_bh(&sk->sk_callback_lock);
187} 193}
188 194
189static void tipc_sock_release(struct tipc_conn *con)
190{
191 struct tipc_server *s = con->server;
192
193 if (con->conid)
194 s->tipc_conn_release(con->conid, con->usr_data);
195
196 tipc_unregister_callbacks(con);
197}
198
199static void tipc_close_conn(struct tipc_conn *con) 195static void tipc_close_conn(struct tipc_conn *con)
200{ 196{
201 struct tipc_server *s = con->server; 197 struct tipc_server *s = con->server;
202 198
203 if (test_and_clear_bit(CF_CONNECTED, &con->flags)) { 199 if (test_and_clear_bit(CF_CONNECTED, &con->flags)) {
200 tipc_unregister_callbacks(con);
204 201
205 spin_lock_bh(&s->idr_lock); 202 if (con->conid)
206 idr_remove(&s->conn_idr, con->conid); 203 s->tipc_conn_release(con->conid, con->usr_data);
207 s->idr_in_use--;
208 spin_unlock_bh(&s->idr_lock);
209 204
210 /* We shouldn't flush pending works as we may be in the 205 /* We shouldn't flush pending works as we may be in the
211 * thread. In fact the races with pending rx/tx work structs 206 * thread. In fact the races with pending rx/tx work structs
@@ -458,6 +453,11 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
458 if (!con) 453 if (!con)
459 return -EINVAL; 454 return -EINVAL;
460 455
456 if (!test_bit(CF_CONNECTED, &con->flags)) {
457 conn_put(con);
458 return 0;
459 }
460
461 e = tipc_alloc_entry(data, len); 461 e = tipc_alloc_entry(data, len);
462 if (!e) { 462 if (!e) {
463 conn_put(con); 463 conn_put(con);
@@ -471,12 +471,8 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
471 list_add_tail(&e->list, &con->outqueue); 471 list_add_tail(&e->list, &con->outqueue);
472 spin_unlock_bh(&con->outqueue_lock); 472 spin_unlock_bh(&con->outqueue_lock);
473 473
474 if (test_bit(CF_CONNECTED, &con->flags)) { 474 if (!queue_work(s->send_wq, &con->swork))
475 if (!queue_work(s->send_wq, &con->swork))
476 conn_put(con);
477 } else {
478 conn_put(con); 475 conn_put(con);
479 }
480 return 0; 476 return 0;
481} 477}
482 478
@@ -500,7 +496,7 @@ static void tipc_send_to_sock(struct tipc_conn *con)
500 int ret; 496 int ret;
501 497
502 spin_lock_bh(&con->outqueue_lock); 498 spin_lock_bh(&con->outqueue_lock);
503 while (1) { 499 while (test_bit(CF_CONNECTED, &con->flags)) {
504 e = list_entry(con->outqueue.next, struct outqueue_entry, 500 e = list_entry(con->outqueue.next, struct outqueue_entry,
505 list); 501 list);
506 if ((struct list_head *) e == &con->outqueue) 502 if ((struct list_head *) e == &con->outqueue)
@@ -623,14 +619,12 @@ int tipc_server_start(struct tipc_server *s)
623void tipc_server_stop(struct tipc_server *s) 619void tipc_server_stop(struct tipc_server *s)
624{ 620{
625 struct tipc_conn *con; 621 struct tipc_conn *con;
626 int total = 0;
627 int id; 622 int id;
628 623
629 spin_lock_bh(&s->idr_lock); 624 spin_lock_bh(&s->idr_lock);
630 for (id = 0; total < s->idr_in_use; id++) { 625 for (id = 0; s->idr_in_use; id++) {
631 con = idr_find(&s->conn_idr, id); 626 con = idr_find(&s->conn_idr, id);
632 if (con) { 627 if (con) {
633 total++;
634 spin_unlock_bh(&s->idr_lock); 628 spin_unlock_bh(&s->idr_lock);
635 tipc_close_conn(con); 629 tipc_close_conn(con);
636 spin_lock_bh(&s->idr_lock); 630 spin_lock_bh(&s->idr_lock);
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 0dd02244e21d..9d94e65d0894 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -54,6 +54,8 @@ struct tipc_subscriber {
54 54
55static void tipc_subscrp_delete(struct tipc_subscription *sub); 55static void tipc_subscrp_delete(struct tipc_subscription *sub);
56static void tipc_subscrb_put(struct tipc_subscriber *subscriber); 56static void tipc_subscrb_put(struct tipc_subscriber *subscriber);
57static void tipc_subscrp_put(struct tipc_subscription *subscription);
58static void tipc_subscrp_get(struct tipc_subscription *subscription);
57 59
58/** 60/**
59 * htohl - convert value to endianness used by destination 61 * htohl - convert value to endianness used by destination
@@ -123,6 +125,7 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower,
123{ 125{
124 struct tipc_name_seq seq; 126 struct tipc_name_seq seq;
125 127
128 tipc_subscrp_get(sub);
126 tipc_subscrp_convert_seq(&sub->evt.s.seq, sub->swap, &seq); 129 tipc_subscrp_convert_seq(&sub->evt.s.seq, sub->swap, &seq);
127 if (!tipc_subscrp_check_overlap(&seq, found_lower, found_upper)) 130 if (!tipc_subscrp_check_overlap(&seq, found_lower, found_upper))
128 return; 131 return;
@@ -132,30 +135,23 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower,
132 135
133 tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref, 136 tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref,
134 node); 137 node);
138 tipc_subscrp_put(sub);
135} 139}
136 140
137static void tipc_subscrp_timeout(unsigned long data) 141static void tipc_subscrp_timeout(unsigned long data)
138{ 142{
139 struct tipc_subscription *sub = (struct tipc_subscription *)data; 143 struct tipc_subscription *sub = (struct tipc_subscription *)data;
140 struct tipc_subscriber *subscriber = sub->subscriber;
141 144
142 /* Notify subscriber of timeout */ 145 /* Notify subscriber of timeout */
143 tipc_subscrp_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, 146 tipc_subscrp_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper,
144 TIPC_SUBSCR_TIMEOUT, 0, 0); 147 TIPC_SUBSCR_TIMEOUT, 0, 0);
145 148
146 spin_lock_bh(&subscriber->lock); 149 tipc_subscrp_put(sub);
147 tipc_subscrp_delete(sub);
148 spin_unlock_bh(&subscriber->lock);
149
150 tipc_subscrb_put(subscriber);
151} 150}
152 151
153static void tipc_subscrb_kref_release(struct kref *kref) 152static void tipc_subscrb_kref_release(struct kref *kref)
154{ 153{
155 struct tipc_subscriber *subcriber = container_of(kref, 154 kfree(container_of(kref,struct tipc_subscriber, kref));
156 struct tipc_subscriber, kref);
157
158 kfree(subcriber);
159} 155}
160 156
161static void tipc_subscrb_put(struct tipc_subscriber *subscriber) 157static void tipc_subscrb_put(struct tipc_subscriber *subscriber)
@@ -168,6 +164,59 @@ static void tipc_subscrb_get(struct tipc_subscriber *subscriber)
168 kref_get(&subscriber->kref); 164 kref_get(&subscriber->kref);
169} 165}
170 166
167static void tipc_subscrp_kref_release(struct kref *kref)
168{
169 struct tipc_subscription *sub = container_of(kref,
170 struct tipc_subscription,
171 kref);
172 struct tipc_net *tn = net_generic(sub->net, tipc_net_id);
173 struct tipc_subscriber *subscriber = sub->subscriber;
174
175 spin_lock_bh(&subscriber->lock);
176 tipc_nametbl_unsubscribe(sub);
177 list_del(&sub->subscrp_list);
178 atomic_dec(&tn->subscription_count);
179 spin_unlock_bh(&subscriber->lock);
180 kfree(sub);
181 tipc_subscrb_put(subscriber);
182}
183
184static void tipc_subscrp_put(struct tipc_subscription *subscription)
185{
186 kref_put(&subscription->kref, tipc_subscrp_kref_release);
187}
188
189static void tipc_subscrp_get(struct tipc_subscription *subscription)
190{
191 kref_get(&subscription->kref);
192}
193
194/* tipc_subscrb_subscrp_delete - delete a specific subscription or all
195 * subscriptions for a given subscriber.
196 */
197static void tipc_subscrb_subscrp_delete(struct tipc_subscriber *subscriber,
198 struct tipc_subscr *s)
199{
200 struct list_head *subscription_list = &subscriber->subscrp_list;
201 struct tipc_subscription *sub, *temp;
202
203 spin_lock_bh(&subscriber->lock);
204 list_for_each_entry_safe(sub, temp, subscription_list, subscrp_list) {
205 if (s && memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr)))
206 continue;
207
208 tipc_subscrp_get(sub);
209 spin_unlock_bh(&subscriber->lock);
210 tipc_subscrp_delete(sub);
211 tipc_subscrp_put(sub);
212 spin_lock_bh(&subscriber->lock);
213
214 if (s)
215 break;
216 }
217 spin_unlock_bh(&subscriber->lock);
218}
219
171static struct tipc_subscriber *tipc_subscrb_create(int conid) 220static struct tipc_subscriber *tipc_subscrb_create(int conid)
172{ 221{
173 struct tipc_subscriber *subscriber; 222 struct tipc_subscriber *subscriber;
@@ -177,8 +226,8 @@ static struct tipc_subscriber *tipc_subscrb_create(int conid)
177 pr_warn("Subscriber rejected, no memory\n"); 226 pr_warn("Subscriber rejected, no memory\n");
178 return NULL; 227 return NULL;
179 } 228 }
180 kref_init(&subscriber->kref);
181 INIT_LIST_HEAD(&subscriber->subscrp_list); 229 INIT_LIST_HEAD(&subscriber->subscrp_list);
230 kref_init(&subscriber->kref);
182 subscriber->conid = conid; 231 subscriber->conid = conid;
183 spin_lock_init(&subscriber->lock); 232 spin_lock_init(&subscriber->lock);
184 233
@@ -187,55 +236,22 @@ static struct tipc_subscriber *tipc_subscrb_create(int conid)
187 236
188static void tipc_subscrb_delete(struct tipc_subscriber *subscriber) 237static void tipc_subscrb_delete(struct tipc_subscriber *subscriber)
189{ 238{
190 struct tipc_subscription *sub, *temp; 239 tipc_subscrb_subscrp_delete(subscriber, NULL);
191 u32 timeout;
192
193 spin_lock_bh(&subscriber->lock);
194 /* Destroy any existing subscriptions for subscriber */
195 list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list,
196 subscrp_list) {
197 timeout = htohl(sub->evt.s.timeout, sub->swap);
198 if ((timeout == TIPC_WAIT_FOREVER) || del_timer(&sub->timer)) {
199 tipc_subscrp_delete(sub);
200 tipc_subscrb_put(subscriber);
201 }
202 }
203 spin_unlock_bh(&subscriber->lock);
204
205 tipc_subscrb_put(subscriber); 240 tipc_subscrb_put(subscriber);
206} 241}
207 242
208static void tipc_subscrp_delete(struct tipc_subscription *sub) 243static void tipc_subscrp_delete(struct tipc_subscription *sub)
209{ 244{
210 struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 245 u32 timeout = htohl(sub->evt.s.timeout, sub->swap);
211 246
212 tipc_nametbl_unsubscribe(sub); 247 if (timeout == TIPC_WAIT_FOREVER || del_timer(&sub->timer))
213 list_del(&sub->subscrp_list); 248 tipc_subscrp_put(sub);
214 kfree(sub);
215 atomic_dec(&tn->subscription_count);
216} 249}
217 250
218static void tipc_subscrp_cancel(struct tipc_subscr *s, 251static void tipc_subscrp_cancel(struct tipc_subscr *s,
219 struct tipc_subscriber *subscriber) 252 struct tipc_subscriber *subscriber)
220{ 253{
221 struct tipc_subscription *sub, *temp; 254 tipc_subscrb_subscrp_delete(subscriber, s);
222 u32 timeout;
223
224 spin_lock_bh(&subscriber->lock);
225 /* Find first matching subscription, exit if not found */
226 list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list,
227 subscrp_list) {
228 if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) {
229 timeout = htohl(sub->evt.s.timeout, sub->swap);
230 if ((timeout == TIPC_WAIT_FOREVER) ||
231 del_timer(&sub->timer)) {
232 tipc_subscrp_delete(sub);
233 tipc_subscrb_put(subscriber);
234 }
235 break;
236 }
237 }
238 spin_unlock_bh(&subscriber->lock);
239} 255}
240 256
241static struct tipc_subscription *tipc_subscrp_create(struct net *net, 257static struct tipc_subscription *tipc_subscrp_create(struct net *net,
@@ -272,6 +288,7 @@ static struct tipc_subscription *tipc_subscrp_create(struct net *net,
272 sub->swap = swap; 288 sub->swap = swap;
273 memcpy(&sub->evt.s, s, sizeof(*s)); 289 memcpy(&sub->evt.s, s, sizeof(*s));
274 atomic_inc(&tn->subscription_count); 290 atomic_inc(&tn->subscription_count);
291 kref_init(&sub->kref);
275 return sub; 292 return sub;
276} 293}
277 294
@@ -288,17 +305,16 @@ static void tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s,
288 305
289 spin_lock_bh(&subscriber->lock); 306 spin_lock_bh(&subscriber->lock);
290 list_add(&sub->subscrp_list, &subscriber->subscrp_list); 307 list_add(&sub->subscrp_list, &subscriber->subscrp_list);
291 tipc_subscrb_get(subscriber);
292 sub->subscriber = subscriber; 308 sub->subscriber = subscriber;
293 tipc_nametbl_subscribe(sub); 309 tipc_nametbl_subscribe(sub);
310 tipc_subscrb_get(subscriber);
294 spin_unlock_bh(&subscriber->lock); 311 spin_unlock_bh(&subscriber->lock);
295 312
313 setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub);
296 timeout = htohl(sub->evt.s.timeout, swap); 314 timeout = htohl(sub->evt.s.timeout, swap);
297 if (timeout == TIPC_WAIT_FOREVER)
298 return;
299 315
300 setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub); 316 if (timeout != TIPC_WAIT_FOREVER)
301 mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)); 317 mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout));
302} 318}
303 319
304/* Handle one termination request for the subscriber */ 320/* Handle one termination request for the subscriber */
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index be60103082c9..ffdc214c117a 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -57,6 +57,7 @@ struct tipc_subscriber;
57 * @evt: template for events generated by subscription 57 * @evt: template for events generated by subscription
58 */ 58 */
59struct tipc_subscription { 59struct tipc_subscription {
60 struct kref kref;
60 struct tipc_subscriber *subscriber; 61 struct tipc_subscriber *subscriber;
61 struct net *net; 62 struct net *net;
62 struct timer_list timer; 63 struct timer_list timer;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 127656ebe7be..cef79873b09d 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -995,6 +995,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
995 unsigned int hash; 995 unsigned int hash;
996 struct unix_address *addr; 996 struct unix_address *addr;
997 struct hlist_head *list; 997 struct hlist_head *list;
998 struct path path = { NULL, NULL };
998 999
999 err = -EINVAL; 1000 err = -EINVAL;
1000 if (sunaddr->sun_family != AF_UNIX) 1001 if (sunaddr->sun_family != AF_UNIX)
@@ -1010,9 +1011,20 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1010 goto out; 1011 goto out;
1011 addr_len = err; 1012 addr_len = err;
1012 1013
1014 if (sun_path[0]) {
1015 umode_t mode = S_IFSOCK |
1016 (SOCK_INODE(sock)->i_mode & ~current_umask());
1017 err = unix_mknod(sun_path, mode, &path);
1018 if (err) {
1019 if (err == -EEXIST)
1020 err = -EADDRINUSE;
1021 goto out;
1022 }
1023 }
1024
1013 err = mutex_lock_interruptible(&u->bindlock); 1025 err = mutex_lock_interruptible(&u->bindlock);
1014 if (err) 1026 if (err)
1015 goto out; 1027 goto out_put;
1016 1028
1017 err = -EINVAL; 1029 err = -EINVAL;
1018 if (u->addr) 1030 if (u->addr)
@@ -1029,16 +1041,6 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1029 atomic_set(&addr->refcnt, 1); 1041 atomic_set(&addr->refcnt, 1);
1030 1042
1031 if (sun_path[0]) { 1043 if (sun_path[0]) {
1032 struct path path;
1033 umode_t mode = S_IFSOCK |
1034 (SOCK_INODE(sock)->i_mode & ~current_umask());
1035 err = unix_mknod(sun_path, mode, &path);
1036 if (err) {
1037 if (err == -EEXIST)
1038 err = -EADDRINUSE;
1039 unix_release_addr(addr);
1040 goto out_up;
1041 }
1042 addr->hash = UNIX_HASH_SIZE; 1044 addr->hash = UNIX_HASH_SIZE;
1043 hash = d_backing_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1); 1045 hash = d_backing_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1);
1044 spin_lock(&unix_table_lock); 1046 spin_lock(&unix_table_lock);
@@ -1065,6 +1067,9 @@ out_unlock:
1065 spin_unlock(&unix_table_lock); 1067 spin_unlock(&unix_table_lock);
1066out_up: 1068out_up:
1067 mutex_unlock(&u->bindlock); 1069 mutex_unlock(&u->bindlock);
1070out_put:
1071 if (err)
1072 path_put(&path);
1068out: 1073out:
1069 return err; 1074 return err;
1070} 1075}
diff --git a/samples/bpf/tc_l2_redirect_kern.c b/samples/bpf/tc_l2_redirect_kern.c
index 92a44729dbe4..7ef2a12b25b2 100644
--- a/samples/bpf/tc_l2_redirect_kern.c
+++ b/samples/bpf/tc_l2_redirect_kern.c
@@ -4,6 +4,7 @@
4 * modify it under the terms of version 2 of the GNU General Public 4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation. 5 * License as published by the Free Software Foundation.
6 */ 6 */
7#define KBUILD_MODNAME "foo"
7#include <uapi/linux/bpf.h> 8#include <uapi/linux/bpf.h>
8#include <uapi/linux/if_ether.h> 9#include <uapi/linux/if_ether.h>
9#include <uapi/linux/if_packet.h> 10#include <uapi/linux/if_packet.h>
diff --git a/samples/bpf/xdp_tx_iptunnel_kern.c b/samples/bpf/xdp_tx_iptunnel_kern.c
index 85c38ecd3a2d..0f4f6e8c8611 100644
--- a/samples/bpf/xdp_tx_iptunnel_kern.c
+++ b/samples/bpf/xdp_tx_iptunnel_kern.c
@@ -8,6 +8,7 @@
8 * encapsulating the incoming packet in an IPv4/v6 header 8 * encapsulating the incoming packet in an IPv4/v6 header
9 * and then XDP_TX it out. 9 * and then XDP_TX it out.
10 */ 10 */
11#define KBUILD_MODNAME "foo"
11#include <uapi/linux/bpf.h> 12#include <uapi/linux/bpf.h>
12#include <linux/in.h> 13#include <linux/in.h>
13#include <linux/if_ether.h> 14#include <linux/if_ether.h>
diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c
index b13fed534d76..9f7bd1915c21 100644
--- a/tools/testing/selftests/bpf/test_lru_map.c
+++ b/tools/testing/selftests/bpf/test_lru_map.c
@@ -67,21 +67,23 @@ static int map_equal(int lru_map, int expected)
67 return map_subset(lru_map, expected) && map_subset(expected, lru_map); 67 return map_subset(lru_map, expected) && map_subset(expected, lru_map);
68} 68}
69 69
70static int sched_next_online(int pid, int next_to_try) 70static int sched_next_online(int pid, int *next_to_try)
71{ 71{
72 cpu_set_t cpuset; 72 cpu_set_t cpuset;
73 int next = *next_to_try;
74 int ret = -1;
73 75
74 if (next_to_try == nr_cpus) 76 while (next < nr_cpus) {
75 return -1;
76
77 while (next_to_try < nr_cpus) {
78 CPU_ZERO(&cpuset); 77 CPU_ZERO(&cpuset);
79 CPU_SET(next_to_try++, &cpuset); 78 CPU_SET(next++, &cpuset);
80 if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) 79 if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) {
80 ret = 0;
81 break; 81 break;
82 }
82 } 83 }
83 84
84 return next_to_try; 85 *next_to_try = next;
86 return ret;
85} 87}
86 88
87/* Size of the LRU amp is 2 89/* Size of the LRU amp is 2
@@ -96,11 +98,12 @@ static void test_lru_sanity0(int map_type, int map_flags)
96{ 98{
97 unsigned long long key, value[nr_cpus]; 99 unsigned long long key, value[nr_cpus];
98 int lru_map_fd, expected_map_fd; 100 int lru_map_fd, expected_map_fd;
101 int next_cpu = 0;
99 102
100 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 103 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
101 map_flags); 104 map_flags);
102 105
103 assert(sched_next_online(0, 0) != -1); 106 assert(sched_next_online(0, &next_cpu) != -1);
104 107
105 if (map_flags & BPF_F_NO_COMMON_LRU) 108 if (map_flags & BPF_F_NO_COMMON_LRU)
106 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus); 109 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus);
@@ -183,6 +186,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
183 int lru_map_fd, expected_map_fd; 186 int lru_map_fd, expected_map_fd;
184 unsigned int batch_size; 187 unsigned int batch_size;
185 unsigned int map_size; 188 unsigned int map_size;
189 int next_cpu = 0;
186 190
187 if (map_flags & BPF_F_NO_COMMON_LRU) 191 if (map_flags & BPF_F_NO_COMMON_LRU)
188 /* Ther percpu lru list (i.e each cpu has its own LRU 192 /* Ther percpu lru list (i.e each cpu has its own LRU
@@ -196,7 +200,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
196 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 200 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
197 map_flags); 201 map_flags);
198 202
199 assert(sched_next_online(0, 0) != -1); 203 assert(sched_next_online(0, &next_cpu) != -1);
200 204
201 batch_size = tgt_free / 2; 205 batch_size = tgt_free / 2;
202 assert(batch_size * 2 == tgt_free); 206 assert(batch_size * 2 == tgt_free);
@@ -262,6 +266,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
262 int lru_map_fd, expected_map_fd; 266 int lru_map_fd, expected_map_fd;
263 unsigned int batch_size; 267 unsigned int batch_size;
264 unsigned int map_size; 268 unsigned int map_size;
269 int next_cpu = 0;
265 270
266 if (map_flags & BPF_F_NO_COMMON_LRU) 271 if (map_flags & BPF_F_NO_COMMON_LRU)
267 /* Ther percpu lru list (i.e each cpu has its own LRU 272 /* Ther percpu lru list (i.e each cpu has its own LRU
@@ -275,7 +280,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
275 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 280 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
276 map_flags); 281 map_flags);
277 282
278 assert(sched_next_online(0, 0) != -1); 283 assert(sched_next_online(0, &next_cpu) != -1);
279 284
280 batch_size = tgt_free / 2; 285 batch_size = tgt_free / 2;
281 assert(batch_size * 2 == tgt_free); 286 assert(batch_size * 2 == tgt_free);
@@ -370,11 +375,12 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
370 int lru_map_fd, expected_map_fd; 375 int lru_map_fd, expected_map_fd;
371 unsigned int batch_size; 376 unsigned int batch_size;
372 unsigned int map_size; 377 unsigned int map_size;
378 int next_cpu = 0;
373 379
374 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 380 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
375 map_flags); 381 map_flags);
376 382
377 assert(sched_next_online(0, 0) != -1); 383 assert(sched_next_online(0, &next_cpu) != -1);
378 384
379 batch_size = tgt_free / 2; 385 batch_size = tgt_free / 2;
380 assert(batch_size * 2 == tgt_free); 386 assert(batch_size * 2 == tgt_free);
@@ -430,11 +436,12 @@ static void test_lru_sanity4(int map_type, int map_flags, unsigned int tgt_free)
430 int lru_map_fd, expected_map_fd; 436 int lru_map_fd, expected_map_fd;
431 unsigned long long key, value[nr_cpus]; 437 unsigned long long key, value[nr_cpus];
432 unsigned long long end_key; 438 unsigned long long end_key;
439 int next_cpu = 0;
433 440
434 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, 441 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
435 map_flags); 442 map_flags);
436 443
437 assert(sched_next_online(0, 0) != -1); 444 assert(sched_next_online(0, &next_cpu) != -1);
438 445
439 if (map_flags & BPF_F_NO_COMMON_LRU) 446 if (map_flags & BPF_F_NO_COMMON_LRU)
440 lru_map_fd = create_map(map_type, map_flags, 447 lru_map_fd = create_map(map_type, map_flags,
@@ -502,9 +509,8 @@ static void do_test_lru_sanity5(unsigned long long last_key, int map_fd)
502static void test_lru_sanity5(int map_type, int map_flags) 509static void test_lru_sanity5(int map_type, int map_flags)
503{ 510{
504 unsigned long long key, value[nr_cpus]; 511 unsigned long long key, value[nr_cpus];
505 int next_sched_cpu = 0; 512 int next_cpu = 0;
506 int map_fd; 513 int map_fd;
507 int i;
508 514
509 if (map_flags & BPF_F_NO_COMMON_LRU) 515 if (map_flags & BPF_F_NO_COMMON_LRU)
510 return; 516 return;
@@ -519,27 +525,20 @@ static void test_lru_sanity5(int map_type, int map_flags)
519 key = 0; 525 key = 0;
520 assert(!bpf_map_update(map_fd, &key, value, BPF_NOEXIST)); 526 assert(!bpf_map_update(map_fd, &key, value, BPF_NOEXIST));
521 527
522 for (i = 0; i < nr_cpus; i++) { 528 while (sched_next_online(0, &next_cpu) != -1) {
523 pid_t pid; 529 pid_t pid;
524 530
525 pid = fork(); 531 pid = fork();
526 if (pid == 0) { 532 if (pid == 0) {
527 next_sched_cpu = sched_next_online(0, next_sched_cpu); 533 do_test_lru_sanity5(key, map_fd);
528 if (next_sched_cpu != -1)
529 do_test_lru_sanity5(key, map_fd);
530 exit(0); 534 exit(0);
531 } else if (pid == -1) { 535 } else if (pid == -1) {
532 printf("couldn't spawn #%d process\n", i); 536 printf("couldn't spawn process to test key:%llu\n",
537 key);
533 exit(1); 538 exit(1);
534 } else { 539 } else {
535 int status; 540 int status;
536 541
537 /* It is mostly redundant and just allow the parent
538 * process to update next_shced_cpu for the next child
539 * process
540 */
541 next_sched_cpu = sched_next_online(pid, next_sched_cpu);
542
543 assert(waitpid(pid, &status, 0) == pid); 542 assert(waitpid(pid, &status, 0) == pid);
544 assert(status == 0); 543 assert(status == 0);
545 key++; 544 key++;
@@ -547,6 +546,8 @@ static void test_lru_sanity5(int map_type, int map_flags)
547 } 546 }
548 547
549 close(map_fd); 548 close(map_fd);
549 /* At least one key should be tested */
550 assert(key > 0);
550 551
551 printf("Pass\n"); 552 printf("Pass\n");
552} 553}