summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-20 11:21:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-20 11:21:07 -0400
commit78e03651849fd3e8aa9ab3288bc1d3726c4c6129 (patch)
tree4537d358985b4d9ad152bb56321a3b5e88788955
parenta188339ca5a396acc588e5851ed7e19f66b0ebd9 (diff)
parent6a0a923dfa1480df41fb486323b8375e387d516f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller:1) Use after free in __dev_map_entry_free(), from Eric Dumazet. 1) Use after free in __dev_map_entry_free(), from Eric Dumazet. 2) Fix TCP retransmission timestamps on passive Fast Open, from Yuchung Cheng. 3) Orphan NFC, we'll take the patches directly into my tree. From Johannes Berg. 4) We can't recycle cloned TCP skbs, from Eric Dumazet. 5) Some flow dissector bpf test fixes, from Stanislav Fomichev. 6) Fix RCU marking and warnings in rhashtable, from Herbert Xu. 7) Fix some potential fib6 leaks, from Eric Dumazet. 8) Fix a _decode_session4 uninitialized memory read bug fix that got lost in a merge. From Florian Westphal. 9) Fix ipv6 source address routing wrt. exception route entries, from Wei Wang. 10) The netdev_xmit_more() conversion was not done %100 properly in mlx5 driver, fix from Tariq Toukan. 11) Clean up botched merge on netfilter kselftest, from Florian Westphal. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (74 commits) of_net: fix of_get_mac_address retval if compiled without CONFIG_OF net: fix kernel-doc warnings for socket.c net: Treat sock->sk_drops as an unsigned int when printing kselftests: netfilter: fix leftover net/net-next merge conflict mlxsw: core: Prevent reading unsupported slave address from SFP EEPROM mlxsw: core: Prevent QSFP module initialization for old hardware vsock/virtio: Initialize core virtio vsock before registering the driver net/mlx5e: Fix possible modify header actions memory leak net/mlx5e: Fix no rewrite fields with the same match net/mlx5e: Additional check for flow destination comparison net/mlx5e: Add missing ethtool driver info for representors net/mlx5e: Fix number of vports for ingress ACL configuration net/mlx5e: Fix ethtool rxfh commands when CONFIG_MLX5_EN_RXNFC is disabled net/mlx5e: Fix wrong xmit_more application net/mlx5: Fix peer pf disable hca command net/mlx5: E-Switch, Correct type to u16 for vport_num and int for vport_index net/mlx5: Add meaningful return codes to status_to_err function net/mlx5: Imply MLXFW in mlx5_core Revert "tipc: fix modprobe tipc failed after switch order of device registration" vsock/virtio: free packets during the socket release ...
-rw-r--r--Documentation/bpf/btf.rst2
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/atm/iphase.c6
-rw-r--r--drivers/infiniband/hw/mlx5/ib_rep.c13
-rw-r--r--drivers/infiniband/hw/mlx5/ib_rep.h12
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c16
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc.c4
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_ethtool.c2
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_pf.c2
-rw-r--r--drivers/net/ethernet/freescale/enetc/enetc_vf.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Kconfig1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ecpf.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c19
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c29
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c20
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.h22
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c20
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_env.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_thermal.c6
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c17
-rw-r--r--drivers/net/phy/aquantia_main.c1
-rw-r--r--drivers/net/ppp/ppp_deflate.c20
-rw-r--r--drivers/net/usb/aqc111.c35
-rw-r--r--drivers/net/usb/qmi_wwan.c2
-rw-r--r--include/linux/bpf.h1
-rw-r--r--include/linux/mlx5/eswitch.h6
-rw-r--r--include/linux/of_net.h2
-rw-r--r--include/linux/rhashtable.h58
-rw-r--r--include/linux/skbuff.h9
-rw-r--r--include/net/flow_offload.h2
-rw-r--r--include/net/ip6_fib.h3
-rw-r--r--include/net/sock.h2
-rw-r--r--include/uapi/linux/btf.h2
-rw-r--r--kernel/bpf/devmap.c3
-rw-r--r--kernel/bpf/hashtab.c23
-rw-r--r--kernel/bpf/inode.c2
-rw-r--r--kernel/bpf/syscall.c5
-rw-r--r--kernel/trace/bpf_trace.c5
-rw-r--r--lib/random32.c4
-rw-r--r--lib/rhashtable.c33
-rw-r--r--net/caif/cfdbgl.c2
-rw-r--r--net/caif/cfdgml.c3
-rw-r--r--net/caif/cfutill.c2
-rw-r--r--net/caif/cfveil.c2
-rw-r--r--net/caif/cfvidl.c2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/flow_offload.c7
-rw-r--r--net/core/rtnetlink.c16
-rw-r--r--net/core/skmsg.c7
-rw-r--r--net/ipv4/bpfilter/sockopt.c6
-rw-r--r--net/ipv4/ping.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_bpf.c7
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv6/datagram.c2
-rw-r--r--net/ipv6/ip6_fib.c12
-rw-r--r--net/ipv6/route.c58
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/phonet/socket.c2
-rw-r--r--net/socket.c34
-rw-r--r--net/tipc/core.c14
-rw-r--r--net/vmw_vsock/hyperv_transport.c108
-rw-r--r--net/vmw_vsock/virtio_transport.c13
-rw-r--r--net/vmw_vsock/virtio_transport_common.c7
-rw-r--r--net/xfrm/xfrm_policy.c24
-rw-r--r--tools/bpf/bpftool/btf.c4
-rw-r--r--tools/bpf/bpftool/prog.c4
-rw-r--r--tools/include/uapi/linux/btf.h2
-rw-r--r--tools/lib/bpf/btf.c2
-rw-r--r--tools/lib/bpf/libbpf.c3
-rw-r--r--tools/lib/bpf/libbpf_internal.h13
-rw-r--r--tools/lib/bpf/libbpf_util.h13
-rw-r--r--tools/lib/bpf/xsk.c2
-rw-r--r--tools/testing/selftests/bpf/.gitignore1
-rw-r--r--tools/testing/selftests/bpf/bpf_helpers.h2
-rw-r--r--tools/testing/selftests/bpf/map_tests/.gitignore1
-rw-r--r--tools/testing/selftests/bpf/prog_tests/flow_dissector.c9
-rw-r--r--tools/testing/selftests/bpf/test_lru_map.c288
-rwxr-xr-xtools/testing/selftests/net/pmtu.sh18
-rwxr-xr-xtools/testing/selftests/netfilter/nft_nat.sh77
93 files changed, 874 insertions, 416 deletions
diff --git a/Documentation/bpf/btf.rst b/Documentation/bpf/btf.rst
index 8820360d00da..35d83e24dbdb 100644
--- a/Documentation/bpf/btf.rst
+++ b/Documentation/bpf/btf.rst
@@ -131,7 +131,7 @@ The following sections detail encoding of each kind.
131``btf_type`` is followed by a ``u32`` with the following bits arrangement:: 131``btf_type`` is followed by a ``u32`` with the following bits arrangement::
132 132
133 #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 133 #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
134 #define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 134 #define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
135 #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) 135 #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
136 136
137The ``BTF_INT_ENCODING`` has the following attributes:: 137The ``BTF_INT_ENCODING`` has the following attributes::
diff --git a/MAINTAINERS b/MAINTAINERS
index 5cfbea4ce575..0c55b0fedbe2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11068,10 +11068,8 @@ S: Supported
11068F: drivers/net/ethernet/qlogic/netxen/ 11068F: drivers/net/ethernet/qlogic/netxen/
11069 11069
11070NFC SUBSYSTEM 11070NFC SUBSYSTEM
11071M: Samuel Ortiz <sameo@linux.intel.com> 11071L: netdev@vger.kernel.org
11072L: linux-wireless@vger.kernel.org 11072S: Orphan
11073L: linux-nfc@lists.01.org (subscribers-only)
11074S: Supported
11075F: net/nfc/ 11073F: net/nfc/
11076F: include/net/nfc/ 11074F: include/net/nfc/
11077F: include/uapi/linux/nfc.h 11075F: include/uapi/linux/nfc.h
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 5278c57dce73..302cf0ba1600 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -2767,12 +2767,6 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2767 case MEMDUMP: 2767 case MEMDUMP:
2768 { 2768 {
2769 switch (ia_cmds.sub_cmd) { 2769 switch (ia_cmds.sub_cmd) {
2770 case MEMDUMP_DEV:
2771 if (!capable(CAP_NET_ADMIN)) return -EPERM;
2772 if (copy_to_user(ia_cmds.buf, iadev, sizeof(IADEV)))
2773 return -EFAULT;
2774 ia_cmds.status = 0;
2775 break;
2776 case MEMDUMP_SEGREG: 2770 case MEMDUMP_SEGREG:
2777 if (!capable(CAP_NET_ADMIN)) return -EPERM; 2771 if (!capable(CAP_NET_ADMIN)) return -EPERM;
2778 tmps = (u16 __user *)ia_cmds.buf; 2772 tmps = (u16 __user *)ia_cmds.buf;
diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
index cbcc40d776b9..269b24a3baa1 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.c
+++ b/drivers/infiniband/hw/mlx5/ib_rep.c
@@ -109,15 +109,15 @@ u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
109} 109}
110 110
111struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 111struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
112 int vport_index) 112 u16 vport_num)
113{ 113{
114 return mlx5_eswitch_get_proto_dev(esw, vport_index, REP_IB); 114 return mlx5_eswitch_get_proto_dev(esw, vport_num, REP_IB);
115} 115}
116 116
117struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 117struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
118 int vport_index) 118 u16 vport_num)
119{ 119{
120 return mlx5_eswitch_get_proto_dev(esw, vport_index, REP_ETH); 120 return mlx5_eswitch_get_proto_dev(esw, vport_num, REP_ETH);
121} 121}
122 122
123struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw) 123struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw)
@@ -125,9 +125,10 @@ struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw)
125 return mlx5_eswitch_uplink_get_proto_dev(esw, REP_IB); 125 return mlx5_eswitch_uplink_get_proto_dev(esw, REP_IB);
126} 126}
127 127
128struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport) 128struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
129 u16 vport_num)
129{ 130{
130 return mlx5_eswitch_vport_rep(esw, vport); 131 return mlx5_eswitch_vport_rep(esw, vport_num);
131} 132}
132 133
133struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, 134struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
diff --git a/drivers/infiniband/hw/mlx5/ib_rep.h b/drivers/infiniband/hw/mlx5/ib_rep.h
index 1d9778da8a50..8336e0517a5c 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.h
+++ b/drivers/infiniband/hw/mlx5/ib_rep.h
@@ -14,17 +14,17 @@ extern const struct mlx5_ib_profile uplink_rep_profile;
14 14
15u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw); 15u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
16struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 16struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
17 int vport_index); 17 u16 vport_num);
18struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw); 18struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw);
19struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 19struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
20 int vport_index); 20 u16 vport_num);
21void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev); 21void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev);
22void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev); 22void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev);
23struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, 23struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
24 struct mlx5_ib_sq *sq, 24 struct mlx5_ib_sq *sq,
25 u16 port); 25 u16 port);
26struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 26struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
27 int vport_index); 27 u16 vport_num);
28#else /* CONFIG_MLX5_ESWITCH */ 28#else /* CONFIG_MLX5_ESWITCH */
29static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw) 29static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
30{ 30{
@@ -33,7 +33,7 @@ static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
33 33
34static inline 34static inline
35struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 35struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
36 int vport_index) 36 u16 vport_num)
37{ 37{
38 return NULL; 38 return NULL;
39} 39}
@@ -46,7 +46,7 @@ struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw)
46 46
47static inline 47static inline
48struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 48struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
49 int vport_index) 49 u16 vport_num)
50{ 50{
51 return NULL; 51 return NULL;
52} 52}
@@ -63,7 +63,7 @@ struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
63 63
64static inline 64static inline
65struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 65struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
66 int vport_index) 66 u16 vport_num)
67{ 67{
68 return NULL; 68 return NULL;
69} 69}
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 21cde7e78621..0d3ba056cda3 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -40,7 +40,7 @@ obj-$(CONFIG_ARCNET) += arcnet/
40obj-$(CONFIG_DEV_APPLETALK) += appletalk/ 40obj-$(CONFIG_DEV_APPLETALK) += appletalk/
41obj-$(CONFIG_CAIF) += caif/ 41obj-$(CONFIG_CAIF) += caif/
42obj-$(CONFIG_CAN) += can/ 42obj-$(CONFIG_CAN) += can/
43obj-$(CONFIG_NET_DSA) += dsa/ 43obj-y += dsa/
44obj-$(CONFIG_ETHERNET) += ethernet/ 44obj-$(CONFIG_ETHERNET) += ethernet/
45obj-$(CONFIG_FDDI) += fddi/ 45obj-$(CONFIG_FDDI) += fddi/
46obj-$(CONFIG_HIPPI) += hippi/ 46obj-$(CONFIG_HIPPI) += hippi/
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index c049410bc888..bebd9b1aeb64 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3343,7 +3343,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
3343 if (!err) 3343 if (!err)
3344 err = -ENODEV; 3344 err = -ENODEV;
3345 3345
3346 dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); 3346 dev_err(&pdev->dev, "failed to get macb_clk (%d)\n", err);
3347 return err; 3347 return err;
3348 } 3348 }
3349 3349
@@ -3352,7 +3352,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
3352 if (!err) 3352 if (!err)
3353 err = -ENODEV; 3353 err = -ENODEV;
3354 3354
3355 dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); 3355 dev_err(&pdev->dev, "failed to get hclk (%d)\n", err);
3356 return err; 3356 return err;
3357 } 3357 }
3358 3358
@@ -3370,31 +3370,31 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
3370 3370
3371 err = clk_prepare_enable(*pclk); 3371 err = clk_prepare_enable(*pclk);
3372 if (err) { 3372 if (err) {
3373 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); 3373 dev_err(&pdev->dev, "failed to enable pclk (%d)\n", err);
3374 return err; 3374 return err;
3375 } 3375 }
3376 3376
3377 err = clk_prepare_enable(*hclk); 3377 err = clk_prepare_enable(*hclk);
3378 if (err) { 3378 if (err) {
3379 dev_err(&pdev->dev, "failed to enable hclk (%u)\n", err); 3379 dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err);
3380 goto err_disable_pclk; 3380 goto err_disable_pclk;
3381 } 3381 }
3382 3382
3383 err = clk_prepare_enable(*tx_clk); 3383 err = clk_prepare_enable(*tx_clk);
3384 if (err) { 3384 if (err) {
3385 dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", err); 3385 dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err);
3386 goto err_disable_hclk; 3386 goto err_disable_hclk;
3387 } 3387 }
3388 3388
3389 err = clk_prepare_enable(*rx_clk); 3389 err = clk_prepare_enable(*rx_clk);
3390 if (err) { 3390 if (err) {
3391 dev_err(&pdev->dev, "failed to enable rx_clk (%u)\n", err); 3391 dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err);
3392 goto err_disable_txclk; 3392 goto err_disable_txclk;
3393 } 3393 }
3394 3394
3395 err = clk_prepare_enable(*tsu_clk); 3395 err = clk_prepare_enable(*tsu_clk);
3396 if (err) { 3396 if (err) {
3397 dev_err(&pdev->dev, "failed to enable tsu_clk (%u)\n", err); 3397 dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err);
3398 goto err_disable_rxclk; 3398 goto err_disable_rxclk;
3399 } 3399 }
3400 3400
@@ -3868,7 +3868,7 @@ static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk,
3868 3868
3869 err = clk_prepare_enable(*pclk); 3869 err = clk_prepare_enable(*pclk);
3870 if (err) { 3870 if (err) {
3871 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); 3871 dev_err(&pdev->dev, "failed to enable pclk (%d)\n", err);
3872 return err; 3872 return err;
3873 } 3873 }
3874 3874
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 5bb9eb35d76d..491475d87736 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -313,7 +313,9 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
313 while (bds_to_clean && tx_frm_cnt < ENETC_DEFAULT_TX_WORK) { 313 while (bds_to_clean && tx_frm_cnt < ENETC_DEFAULT_TX_WORK) {
314 bool is_eof = !!tx_swbd->skb; 314 bool is_eof = !!tx_swbd->skb;
315 315
316 enetc_unmap_tx_buff(tx_ring, tx_swbd); 316 if (likely(tx_swbd->dma))
317 enetc_unmap_tx_buff(tx_ring, tx_swbd);
318
317 if (is_eof) { 319 if (is_eof) {
318 napi_consume_skb(tx_swbd->skb, napi_budget); 320 napi_consume_skb(tx_swbd->skb, napi_budget);
319 tx_swbd->skb = NULL; 321 tx_swbd->skb = NULL;
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
index 1ecad9ffabae..b9519b6ad727 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
@@ -570,6 +570,7 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = {
570 .get_ringparam = enetc_get_ringparam, 570 .get_ringparam = enetc_get_ringparam,
571 .get_link_ksettings = phy_ethtool_get_link_ksettings, 571 .get_link_ksettings = phy_ethtool_get_link_ksettings,
572 .set_link_ksettings = phy_ethtool_set_link_ksettings, 572 .set_link_ksettings = phy_ethtool_set_link_ksettings,
573 .get_link = ethtool_op_get_link,
573}; 574};
574 575
575static const struct ethtool_ops enetc_vf_ethtool_ops = { 576static const struct ethtool_ops enetc_vf_ethtool_ops = {
@@ -584,6 +585,7 @@ static const struct ethtool_ops enetc_vf_ethtool_ops = {
584 .get_rxfh = enetc_get_rxfh, 585 .get_rxfh = enetc_get_rxfh,
585 .set_rxfh = enetc_set_rxfh, 586 .set_rxfh = enetc_set_rxfh,
586 .get_ringparam = enetc_get_ringparam, 587 .get_ringparam = enetc_get_ringparam,
588 .get_link = ethtool_op_get_link,
587}; 589};
588 590
589void enetc_set_ethtool_ops(struct net_device *ndev) 591void enetc_set_ethtool_ops(struct net_device *ndev)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 15876a6e7598..78287c517095 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -721,7 +721,7 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
721 ndev->watchdog_timeo = 5 * HZ; 721 ndev->watchdog_timeo = 5 * HZ;
722 ndev->max_mtu = ENETC_MAX_MTU; 722 ndev->max_mtu = ENETC_MAX_MTU;
723 723
724 ndev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM | 724 ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
725 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | 725 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
726 NETIF_F_LOOPBACK; 726 NETIF_F_LOOPBACK;
727 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | 727 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG |
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
index 64bebee9f52a..72c3ea887bcf 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
@@ -130,7 +130,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
130 ndev->watchdog_timeo = 5 * HZ; 130 ndev->watchdog_timeo = 5 * HZ;
131 ndev->max_mtu = ENETC_MAX_MTU; 131 ndev->max_mtu = ENETC_MAX_MTU;
132 132
133 ndev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM | 133 ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
134 NETIF_F_HW_VLAN_CTAG_TX | 134 NETIF_F_HW_VLAN_CTAG_TX |
135 NETIF_F_HW_VLAN_CTAG_RX; 135 NETIF_F_HW_VLAN_CTAG_RX;
136 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | 136 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index ffed2d4c9403..9c481823b3e8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -1492,7 +1492,7 @@ int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port,
1492 rule.port = port; 1492 rule.port = port;
1493 rule.qpn = qpn; 1493 rule.qpn = qpn;
1494 INIT_LIST_HEAD(&rule.list); 1494 INIT_LIST_HEAD(&rule.list);
1495 mlx4_err(dev, "going promisc on %x\n", port); 1495 mlx4_info(dev, "going promisc on %x\n", port);
1496 1496
1497 return mlx4_flow_attach(dev, &rule, regid_p); 1497 return mlx4_flow_attach(dev, &rule, regid_p);
1498} 1498}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index 9aca8086ee01..88ccfcfcd128 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -8,6 +8,7 @@ config MLX5_CORE
8 select NET_DEVLINK 8 select NET_DEVLINK
9 imply PTP_1588_CLOCK 9 imply PTP_1588_CLOCK
10 imply VXLAN 10 imply VXLAN
11 imply MLXFW
11 default n 12 default n
12 ---help--- 13 ---help---
13 Core driver for low level functionality of the ConnectX-4 and 14 Core driver for low level functionality of the ConnectX-4 and
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 937ba4bcb056..d2ab8cd8ad9f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1604,7 +1604,27 @@ void mlx5_cmd_flush(struct mlx5_core_dev *dev)
1604 1604
1605static int status_to_err(u8 status) 1605static int status_to_err(u8 status)
1606{ 1606{
1607 return status ? -1 : 0; /* TBD more meaningful codes */ 1607 switch (status) {
1608 case MLX5_CMD_DELIVERY_STAT_OK:
1609 case MLX5_DRIVER_STATUS_ABORTED:
1610 return 0;
1611 case MLX5_CMD_DELIVERY_STAT_SIGNAT_ERR:
1612 case MLX5_CMD_DELIVERY_STAT_TOK_ERR:
1613 return -EBADR;
1614 case MLX5_CMD_DELIVERY_STAT_BAD_BLK_NUM_ERR:
1615 case MLX5_CMD_DELIVERY_STAT_OUT_PTR_ALIGN_ERR:
1616 case MLX5_CMD_DELIVERY_STAT_IN_PTR_ALIGN_ERR:
1617 return -EFAULT; /* Bad address */
1618 case MLX5_CMD_DELIVERY_STAT_IN_LENGTH_ERR:
1619 case MLX5_CMD_DELIVERY_STAT_OUT_LENGTH_ERR:
1620 case MLX5_CMD_DELIVERY_STAT_CMD_DESCR_ERR:
1621 case MLX5_CMD_DELIVERY_STAT_RES_FLD_NOT_CLR_ERR:
1622 return -ENOMSG;
1623 case MLX5_CMD_DELIVERY_STAT_FW_ERR:
1624 return -EIO;
1625 default:
1626 return -EINVAL;
1627 }
1608} 1628}
1609 1629
1610static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size, 1630static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c b/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c
index 4746f2d28fb6..0ccd6d40baf7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c
@@ -26,7 +26,7 @@ static int mlx5_peer_pf_disable_hca(struct mlx5_core_dev *dev)
26 26
27 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA); 27 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
28 MLX5_SET(disable_hca_in, in, function_id, 0); 28 MLX5_SET(disable_hca_in, in, function_id, 0);
29 MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0); 29 MLX5_SET(disable_hca_in, in, embedded_cpu_function, 0);
30 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); 30 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
31} 31}
32 32
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 7efaa58ae034..dd764e0471f2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1901,6 +1901,22 @@ static int mlx5e_flash_device(struct net_device *dev,
1901 return mlx5e_ethtool_flash_device(priv, flash); 1901 return mlx5e_ethtool_flash_device(priv, flash);
1902} 1902}
1903 1903
1904#ifndef CONFIG_MLX5_EN_RXNFC
1905/* When CONFIG_MLX5_EN_RXNFC=n we only support ETHTOOL_GRXRINGS
1906 * otherwise this function will be defined from en_fs_ethtool.c
1907 */
1908static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, u32 *rule_locs)
1909{
1910 struct mlx5e_priv *priv = netdev_priv(dev);
1911
1912 if (info->cmd != ETHTOOL_GRXRINGS)
1913 return -EOPNOTSUPP;
1914 /* ring_count is needed by ethtool -x */
1915 info->data = priv->channels.params.num_channels;
1916 return 0;
1917}
1918#endif
1919
1904const struct ethtool_ops mlx5e_ethtool_ops = { 1920const struct ethtool_ops mlx5e_ethtool_ops = {
1905 .get_drvinfo = mlx5e_get_drvinfo, 1921 .get_drvinfo = mlx5e_get_drvinfo,
1906 .get_link = ethtool_op_get_link, 1922 .get_link = ethtool_op_get_link,
@@ -1919,8 +1935,8 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
1919 .get_rxfh_indir_size = mlx5e_get_rxfh_indir_size, 1935 .get_rxfh_indir_size = mlx5e_get_rxfh_indir_size,
1920 .get_rxfh = mlx5e_get_rxfh, 1936 .get_rxfh = mlx5e_get_rxfh,
1921 .set_rxfh = mlx5e_set_rxfh, 1937 .set_rxfh = mlx5e_set_rxfh,
1922#ifdef CONFIG_MLX5_EN_RXNFC
1923 .get_rxnfc = mlx5e_get_rxnfc, 1938 .get_rxnfc = mlx5e_get_rxnfc,
1939#ifdef CONFIG_MLX5_EN_RXNFC
1924 .set_rxnfc = mlx5e_set_rxnfc, 1940 .set_rxnfc = mlx5e_set_rxnfc,
1925#endif 1941#endif
1926 .flash_device = mlx5e_flash_device, 1942 .flash_device = mlx5e_flash_device,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 91e24f1cead8..5283e16c69e4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -65,9 +65,26 @@ static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv,
65static void mlx5e_rep_get_drvinfo(struct net_device *dev, 65static void mlx5e_rep_get_drvinfo(struct net_device *dev,
66 struct ethtool_drvinfo *drvinfo) 66 struct ethtool_drvinfo *drvinfo)
67{ 67{
68 struct mlx5e_priv *priv = netdev_priv(dev);
69 struct mlx5_core_dev *mdev = priv->mdev;
70
68 strlcpy(drvinfo->driver, mlx5e_rep_driver_name, 71 strlcpy(drvinfo->driver, mlx5e_rep_driver_name,
69 sizeof(drvinfo->driver)); 72 sizeof(drvinfo->driver));
70 strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version)); 73 strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
74 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
75 "%d.%d.%04d (%.16s)",
76 fw_rev_maj(mdev), fw_rev_min(mdev),
77 fw_rev_sub(mdev), mdev->board_id);
78}
79
80static void mlx5e_uplink_rep_get_drvinfo(struct net_device *dev,
81 struct ethtool_drvinfo *drvinfo)
82{
83 struct mlx5e_priv *priv = netdev_priv(dev);
84
85 mlx5e_rep_get_drvinfo(dev, drvinfo);
86 strlcpy(drvinfo->bus_info, pci_name(priv->mdev->pdev),
87 sizeof(drvinfo->bus_info));
71} 88}
72 89
73static const struct counter_desc sw_rep_stats_desc[] = { 90static const struct counter_desc sw_rep_stats_desc[] = {
@@ -363,7 +380,7 @@ static const struct ethtool_ops mlx5e_vf_rep_ethtool_ops = {
363}; 380};
364 381
365static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = { 382static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = {
366 .get_drvinfo = mlx5e_rep_get_drvinfo, 383 .get_drvinfo = mlx5e_uplink_rep_get_drvinfo,
367 .get_link = ethtool_op_get_link, 384 .get_link = ethtool_op_get_link,
368 .get_strings = mlx5e_rep_get_strings, 385 .get_strings = mlx5e_rep_get_strings,
369 .get_sset_count = mlx5e_rep_get_sset_count, 386 .get_sset_count = mlx5e_rep_get_sset_count,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 122f457091a2..31cd02f11499 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1595,7 +1595,7 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
1595 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) { 1595 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) {
1596 struct flow_match_vlan match; 1596 struct flow_match_vlan match;
1597 1597
1598 flow_rule_match_vlan(rule, &match); 1598 flow_rule_match_cvlan(rule, &match);
1599 if (match.mask->vlan_id || 1599 if (match.mask->vlan_id ||
1600 match.mask->vlan_priority || 1600 match.mask->vlan_priority ||
1601 match.mask->vlan_tpid) { 1601 match.mask->vlan_tpid) {
@@ -1916,6 +1916,19 @@ struct mlx5_fields {
1916 offsetof(struct pedit_headers, field) + (off), \ 1916 offsetof(struct pedit_headers, field) + (off), \
1917 MLX5_BYTE_OFF(fte_match_set_lyr_2_4, match_field)} 1917 MLX5_BYTE_OFF(fte_match_set_lyr_2_4, match_field)}
1918 1918
1919/* masked values are the same and there are no rewrites that do not have a
1920 * match.
1921 */
1922#define SAME_VAL_MASK(type, valp, maskp, matchvalp, matchmaskp) ({ \
1923 type matchmaskx = *(type *)(matchmaskp); \
1924 type matchvalx = *(type *)(matchvalp); \
1925 type maskx = *(type *)(maskp); \
1926 type valx = *(type *)(valp); \
1927 \
1928 (valx & maskx) == (matchvalx & matchmaskx) && !(maskx & (maskx ^ \
1929 matchmaskx)); \
1930})
1931
1919static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp, 1932static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp,
1920 void *matchmaskp, int size) 1933 void *matchmaskp, int size)
1921{ 1934{
@@ -1923,16 +1936,13 @@ static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp,
1923 1936
1924 switch (size) { 1937 switch (size) {
1925 case sizeof(u8): 1938 case sizeof(u8):
1926 same = ((*(u8 *)valp) & (*(u8 *)maskp)) == 1939 same = SAME_VAL_MASK(u8, valp, maskp, matchvalp, matchmaskp);
1927 ((*(u8 *)matchvalp) & (*(u8 *)matchmaskp));
1928 break; 1940 break;
1929 case sizeof(u16): 1941 case sizeof(u16):
1930 same = ((*(u16 *)valp) & (*(u16 *)maskp)) == 1942 same = SAME_VAL_MASK(u16, valp, maskp, matchvalp, matchmaskp);
1931 ((*(u16 *)matchvalp) & (*(u16 *)matchmaskp));
1932 break; 1943 break;
1933 case sizeof(u32): 1944 case sizeof(u32):
1934 same = ((*(u32 *)valp) & (*(u32 *)maskp)) == 1945 same = SAME_VAL_MASK(u32, valp, maskp, matchvalp, matchmaskp);
1935 ((*(u32 *)matchvalp) & (*(u32 *)matchmaskp));
1936 break; 1946 break;
1937 } 1947 }
1938 1948
@@ -2557,8 +2567,10 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
2557 /* in case all pedit actions are skipped, remove the MOD_HDR 2567 /* in case all pedit actions are skipped, remove the MOD_HDR
2558 * flag. 2568 * flag.
2559 */ 2569 */
2560 if (parse_attr->num_mod_hdr_actions == 0) 2570 if (parse_attr->num_mod_hdr_actions == 0) {
2561 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; 2571 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
2572 kfree(parse_attr->mod_hdr_actions);
2573 }
2562 } 2574 }
2563 2575
2564 attr->action = action; 2576 attr->action = action;
@@ -2995,6 +3007,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
2995 */ 3007 */
2996 if (parse_attr->num_mod_hdr_actions == 0) { 3008 if (parse_attr->num_mod_hdr_actions == 0) {
2997 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; 3009 action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
3010 kfree(parse_attr->mod_hdr_actions);
2998 if (!((action & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP) || 3011 if (!((action & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP) ||
2999 (action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH))) 3012 (action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH)))
3000 attr->split_count = 0; 3013 attr->split_count = 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 7b61126fcec9..195a7d903cec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -361,7 +361,7 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
361 } 361 }
362 362
363 stats->bytes += num_bytes; 363 stats->bytes += num_bytes;
364 stats->xmit_more += netdev_xmit_more(); 364 stats->xmit_more += xmit_more;
365 365
366 headlen = skb->len - ihs - skb->data_len; 366 headlen = skb->len - ihs - skb->data_len;
367 ds_cnt += !!headlen; 367 ds_cnt += !!headlen;
@@ -624,7 +624,8 @@ mlx5i_txwqe_build_datagram(struct mlx5_av *av, u32 dqpn, u32 dqkey,
624} 624}
625 625
626netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, 626netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
627 struct mlx5_av *av, u32 dqpn, u32 dqkey) 627 struct mlx5_av *av, u32 dqpn, u32 dqkey,
628 bool xmit_more)
628{ 629{
629 struct mlx5_wq_cyc *wq = &sq->wq; 630 struct mlx5_wq_cyc *wq = &sq->wq;
630 struct mlx5i_tx_wqe *wqe; 631 struct mlx5i_tx_wqe *wqe;
@@ -660,7 +661,7 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
660 } 661 }
661 662
662 stats->bytes += num_bytes; 663 stats->bytes += num_bytes;
663 stats->xmit_more += netdev_xmit_more(); 664 stats->xmit_more += xmit_more;
664 665
665 headlen = skb->len - ihs - skb->data_len; 666 headlen = skb->len - ihs - skb->data_len;
666 ds_cnt += !!headlen; 667 ds_cnt += !!headlen;
@@ -705,7 +706,7 @@ netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
705 goto err_drop; 706 goto err_drop;
706 707
707 mlx5e_txwqe_complete(sq, skb, opcode, ds_cnt, num_wqebbs, num_bytes, 708 mlx5e_txwqe_complete(sq, skb, opcode, ds_cnt, num_wqebbs, num_bytes,
708 num_dma, wi, cseg, false); 709 num_dma, wi, cseg, xmit_more);
709 710
710 return NETDEV_TX_OK; 711 return NETDEV_TX_OK;
711 712
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 9ea0ccfe5ef5..6a921e24cd5e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1526,7 +1526,7 @@ static void node_guid_gen_from_mac(u64 *node_guid, u8 mac[ETH_ALEN])
1526static void esw_apply_vport_conf(struct mlx5_eswitch *esw, 1526static void esw_apply_vport_conf(struct mlx5_eswitch *esw,
1527 struct mlx5_vport *vport) 1527 struct mlx5_vport *vport)
1528{ 1528{
1529 int vport_num = vport->vport; 1529 u16 vport_num = vport->vport;
1530 1530
1531 if (esw->manager_vport == vport_num) 1531 if (esw->manager_vport == vport_num)
1532 return; 1532 return;
@@ -1915,7 +1915,7 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
1915 1915
1916/* Vport Administration */ 1916/* Vport Administration */
1917int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, 1917int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
1918 int vport, u8 mac[ETH_ALEN]) 1918 u16 vport, u8 mac[ETH_ALEN])
1919{ 1919{
1920 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1920 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1921 u64 node_guid; 1921 u64 node_guid;
@@ -1959,7 +1959,7 @@ unlock:
1959} 1959}
1960 1960
1961int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, 1961int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
1962 int vport, int link_state) 1962 u16 vport, int link_state)
1963{ 1963{
1964 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1964 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1965 int err = 0; 1965 int err = 0;
@@ -1989,7 +1989,7 @@ unlock:
1989} 1989}
1990 1990
1991int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, 1991int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
1992 int vport, struct ifla_vf_info *ivi) 1992 u16 vport, struct ifla_vf_info *ivi)
1993{ 1993{
1994 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 1994 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1995 1995
@@ -2014,7 +2014,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
2014} 2014}
2015 2015
2016int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 2016int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
2017 int vport, u16 vlan, u8 qos, u8 set_flags) 2017 u16 vport, u16 vlan, u8 qos, u8 set_flags)
2018{ 2018{
2019 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2019 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
2020 int err = 0; 2020 int err = 0;
@@ -2047,7 +2047,7 @@ unlock:
2047} 2047}
2048 2048
2049int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 2049int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
2050 int vport, u16 vlan, u8 qos) 2050 u16 vport, u16 vlan, u8 qos)
2051{ 2051{
2052 u8 set_flags = 0; 2052 u8 set_flags = 0;
2053 2053
@@ -2058,7 +2058,7 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
2058} 2058}
2059 2059
2060int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, 2060int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
2061 int vport, bool spoofchk) 2061 u16 vport, bool spoofchk)
2062{ 2062{
2063 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2063 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
2064 bool pschk; 2064 bool pschk;
@@ -2208,7 +2208,7 @@ out:
2208} 2208}
2209 2209
2210int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw, 2210int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
2211 int vport, bool setting) 2211 u16 vport, bool setting)
2212{ 2212{
2213 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2213 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
2214 2214
@@ -2278,7 +2278,7 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
2278 return 0; 2278 return 0;
2279} 2279}
2280 2280
2281int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport, 2281int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
2282 u32 max_rate, u32 min_rate) 2282 u32 max_rate, u32 min_rate)
2283{ 2283{
2284 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport); 2284 struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
@@ -2368,7 +2368,7 @@ static int mlx5_eswitch_query_vport_drop_stats(struct mlx5_core_dev *dev,
2368} 2368}
2369 2369
2370int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw, 2370int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
2371 int vport_num, 2371 u16 vport_num,
2372 struct ifla_vf_stats *vf_stats) 2372 struct ifla_vf_stats *vf_stats)
2373{ 2373{
2374 struct mlx5_vport *vport = mlx5_eswitch_get_vport(esw, vport_num); 2374 struct mlx5_vport *vport = mlx5_eswitch_get_vport(esw, vport_num);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index ed3fad689ec9..d043d6f9797d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -246,23 +246,23 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
246int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode); 246int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode);
247void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw); 247void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw);
248int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, 248int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
249 int vport, u8 mac[ETH_ALEN]); 249 u16 vport, u8 mac[ETH_ALEN]);
250int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, 250int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
251 int vport, int link_state); 251 u16 vport, int link_state);
252int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 252int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
253 int vport, u16 vlan, u8 qos); 253 u16 vport, u16 vlan, u8 qos);
254int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, 254int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
255 int vport, bool spoofchk); 255 u16 vport, bool spoofchk);
256int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw, 256int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
257 int vport_num, bool setting); 257 u16 vport_num, bool setting);
258int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport, 258int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
259 u32 max_rate, u32 min_rate); 259 u32 max_rate, u32 min_rate);
260int mlx5_eswitch_set_vepa(struct mlx5_eswitch *esw, u8 setting); 260int mlx5_eswitch_set_vepa(struct mlx5_eswitch *esw, u8 setting);
261int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting); 261int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting);
262int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, 262int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
263 int vport, struct ifla_vf_info *ivi); 263 u16 vport, struct ifla_vf_info *ivi);
264int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw, 264int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
265 int vport, 265 u16 vport,
266 struct ifla_vf_stats *vf_stats); 266 struct ifla_vf_stats *vf_stats);
267void mlx5_eswitch_del_send_to_vport_rule(struct mlx5_flow_handle *rule); 267void mlx5_eswitch_del_send_to_vport_rule(struct mlx5_flow_handle *rule);
268 268
@@ -296,7 +296,7 @@ u32
296mlx5_eswitch_get_chain_range(struct mlx5_eswitch *esw); 296mlx5_eswitch_get_chain_range(struct mlx5_eswitch *esw);
297 297
298struct mlx5_flow_handle * 298struct mlx5_flow_handle *
299mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, 299mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, u16 vport,
300 struct mlx5_flow_destination *dest); 300 struct mlx5_flow_destination *dest);
301 301
302enum { 302enum {
@@ -366,7 +366,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
366int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw, 366int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw,
367 struct mlx5_esw_flow_attr *attr); 367 struct mlx5_esw_flow_attr *attr);
368int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, 368int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
369 int vport, u16 vlan, u8 qos, u8 set_flags); 369 u16 vport, u16 vlan, u8 qos, u8 set_flags);
370 370
371static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev, 371static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev,
372 u8 vlan_depth) 372 u8 vlan_depth)
@@ -430,7 +430,7 @@ static inline int mlx5_eswitch_vport_num_to_index(struct mlx5_eswitch *esw,
430 return vport_num; 430 return vport_num;
431} 431}
432 432
433static inline int mlx5_eswitch_index_to_vport_num(struct mlx5_eswitch *esw, 433static inline u16 mlx5_eswitch_index_to_vport_num(struct mlx5_eswitch *esw,
434 int index) 434 int index)
435{ 435{
436 if (index == mlx5_eswitch_ecpf_idx(esw) && 436 if (index == mlx5_eswitch_ecpf_idx(esw) &&
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index e09ae27485ee..47b446d30f71 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -57,7 +57,7 @@
57static struct mlx5_eswitch_rep *mlx5_eswitch_get_rep(struct mlx5_eswitch *esw, 57static struct mlx5_eswitch_rep *mlx5_eswitch_get_rep(struct mlx5_eswitch *esw,
58 u16 vport_num) 58 u16 vport_num)
59{ 59{
60 u16 idx = mlx5_eswitch_vport_num_to_index(esw, vport_num); 60 int idx = mlx5_eswitch_vport_num_to_index(esw, vport_num);
61 61
62 WARN_ON(idx > esw->total_vports - 1); 62 WARN_ON(idx > esw->total_vports - 1);
63 return &esw->offloads.vport_reps[idx]; 63 return &esw->offloads.vport_reps[idx];
@@ -515,7 +515,8 @@ out:
515} 515}
516 516
517struct mlx5_flow_handle * 517struct mlx5_flow_handle *
518mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, int vport, u32 sqn) 518mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, u16 vport,
519 u32 sqn)
519{ 520{
520 struct mlx5_flow_act flow_act = {0}; 521 struct mlx5_flow_act flow_act = {0};
521 struct mlx5_flow_destination dest = {}; 522 struct mlx5_flow_destination dest = {};
@@ -1181,7 +1182,7 @@ static void esw_destroy_vport_rx_group(struct mlx5_eswitch *esw)
1181} 1182}
1182 1183
1183struct mlx5_flow_handle * 1184struct mlx5_flow_handle *
1184mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, 1185mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, u16 vport,
1185 struct mlx5_flow_destination *dest) 1186 struct mlx5_flow_destination *dest)
1186{ 1187{
1187 struct mlx5_flow_act flow_act = {0}; 1188 struct mlx5_flow_act flow_act = {0};
@@ -1731,13 +1732,14 @@ static void esw_prio_tag_acls_cleanup(struct mlx5_eswitch *esw)
1731 struct mlx5_vport *vport; 1732 struct mlx5_vport *vport;
1732 int i; 1733 int i;
1733 1734
1734 mlx5_esw_for_each_vf_vport(esw, i, vport, esw->nvports) { 1735 mlx5_esw_for_each_vf_vport(esw, i, vport, esw->dev->priv.sriov.num_vfs) {
1735 esw_vport_disable_egress_acl(esw, vport); 1736 esw_vport_disable_egress_acl(esw, vport);
1736 esw_vport_disable_ingress_acl(esw, vport); 1737 esw_vport_disable_ingress_acl(esw, vport);
1737 } 1738 }
1738} 1739}
1739 1740
1740static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int nvports) 1741static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int vf_nvports,
1742 int nvports)
1741{ 1743{
1742 int err; 1744 int err;
1743 1745
@@ -1745,7 +1747,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int nvports)
1745 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock); 1747 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock);
1746 1748
1747 if (MLX5_CAP_GEN(esw->dev, prio_tag_required)) { 1749 if (MLX5_CAP_GEN(esw->dev, prio_tag_required)) {
1748 err = esw_prio_tag_acls_config(esw, nvports); 1750 err = esw_prio_tag_acls_config(esw, vf_nvports);
1749 if (err) 1751 if (err)
1750 return err; 1752 return err;
1751 } 1753 }
@@ -1838,7 +1840,7 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int vf_nvports,
1838{ 1840{
1839 int err; 1841 int err;
1840 1842
1841 err = esw_offloads_steering_init(esw, total_nvports); 1843 err = esw_offloads_steering_init(esw, vf_nvports, total_nvports);
1842 if (err) 1844 if (err)
1843 return err; 1845 return err;
1844 1846
@@ -2243,7 +2245,7 @@ void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type)
2243} 2245}
2244 2246
2245void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw, 2247void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
2246 int vport, 2248 u16 vport,
2247 u8 rep_type) 2249 u8 rep_type)
2248{ 2250{
2249 struct mlx5_eswitch_rep *rep; 2251 struct mlx5_eswitch_rep *rep;
@@ -2264,7 +2266,7 @@ void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type)
2264EXPORT_SYMBOL(mlx5_eswitch_uplink_get_proto_dev); 2266EXPORT_SYMBOL(mlx5_eswitch_uplink_get_proto_dev);
2265 2267
2266struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw, 2268struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw,
2267 int vport) 2269 u16 vport)
2268{ 2270{
2269 return mlx5_eswitch_get_rep(esw, vport); 2271 return mlx5_eswitch_get_rep(esw, vport);
2270} 2272}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index fb5b61727ee7..d7ca7e82a832 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1380,6 +1380,8 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
1380 if ((d1->type == MLX5_FLOW_DESTINATION_TYPE_VPORT && 1380 if ((d1->type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
1381 d1->vport.num == d2->vport.num && 1381 d1->vport.num == d2->vport.num &&
1382 d1->vport.flags == d2->vport.flags && 1382 d1->vport.flags == d2->vport.flags &&
1383 ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ?
1384 (d1->vport.vhca_id == d2->vport.vhca_id) : true) &&
1383 ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ? 1385 ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ?
1384 (d1->vport.reformat_id == d2->vport.reformat_id) : true)) || 1386 (d1->vport.reformat_id == d2->vport.reformat_id) : true)) ||
1385 (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE && 1387 (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE &&
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index ada1b7c0e0b8..9ca492b430d8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -619,7 +619,7 @@ static int mlx5i_xmit(struct net_device *dev, struct sk_buff *skb,
619 struct mlx5_ib_ah *mah = to_mah(address); 619 struct mlx5_ib_ah *mah = to_mah(address);
620 struct mlx5i_priv *ipriv = epriv->ppriv; 620 struct mlx5i_priv *ipriv = epriv->ppriv;
621 621
622 return mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey); 622 return mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey, netdev_xmit_more());
623} 623}
624 624
625static void mlx5i_set_pkey_index(struct net_device *netdev, int id) 625static void mlx5i_set_pkey_index(struct net_device *netdev, int id)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
index 9165ca567047..e19ba3fcd1b7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
@@ -119,7 +119,8 @@ static inline void mlx5i_sq_fetch_wqe(struct mlx5e_txqsq *sq,
119} 119}
120 120
121netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, 121netdev_tx_t mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
122 struct mlx5_av *av, u32 dqpn, u32 dqkey); 122 struct mlx5_av *av, u32 dqpn, u32 dqkey,
123 bool xmit_more);
123void mlx5i_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 124void mlx5i_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
124void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats); 125void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
125 126
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index bcbe07ec22be..6ee6de7f0160 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
122} 122}
123EXPORT_SYMBOL(mlxsw_core_driver_priv); 123EXPORT_SYMBOL(mlxsw_core_driver_priv);
124 124
125bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
126{
127 return mlxsw_core->driver->res_query_enabled;
128}
129EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
130
125struct mlxsw_rx_listener_item { 131struct mlxsw_rx_listener_item {
126 struct list_head list; 132 struct list_head list;
127 struct mlxsw_rx_listener rxl; 133 struct mlxsw_rx_listener rxl;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index 917be621c904..e3832cb5bdda 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
28 28
29void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); 29void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
30 30
31bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
32
31int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); 33int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
32void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); 34void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
33 35
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index c1c1965d7acc..72539a9a3847 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -3,6 +3,7 @@
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/err.h> 5#include <linux/err.h>
6#include <linux/sfp.h>
6 7
7#include "core.h" 8#include "core.h"
8#include "core_env.h" 9#include "core_env.h"
@@ -162,7 +163,7 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
162{ 163{
163 u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE]; 164 u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE];
164 u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE; 165 u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE;
165 u8 module_rev_id, module_id; 166 u8 module_rev_id, module_id, diag_mon;
166 unsigned int read_size; 167 unsigned int read_size;
167 int err; 168 int err;
168 169
@@ -195,8 +196,21 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
195 } 196 }
196 break; 197 break;
197 case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP: 198 case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
199 /* Verify if transceiver provides diagnostic monitoring page */
200 err = mlxsw_env_query_module_eeprom(mlxsw_core, module,
201 SFP_DIAGMON, 1, &diag_mon,
202 &read_size);
203 if (err)
204 return err;
205
206 if (read_size < 1)
207 return -EIO;
208
198 modinfo->type = ETH_MODULE_SFF_8472; 209 modinfo->type = ETH_MODULE_SFF_8472;
199 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; 210 if (diag_mon)
211 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
212 else
213 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
200 break; 214 break;
201 default: 215 default:
202 return -EINVAL; 216 return -EINVAL;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
index 6956bbebe2f1..496dc904c5ed 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
@@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
518 u8 width; 518 u8 width;
519 int err; 519 int err;
520 520
521 if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
522 return 0;
523
521 /* Add extra attributes for module temperature. Sensor index is 524 /* Add extra attributes for module temperature. Sensor index is
522 * assigned to sensor_count value, while all indexed before 525 * assigned to sensor_count value, while all indexed before
523 * sensor_count are already utilized by the sensors connected through 526 * sensor_count are already utilized by the sensors connected through
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 472f63f9fac5..d3e851e7ca72 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
740 struct mlxsw_thermal_module *module_tz; 740 struct mlxsw_thermal_module *module_tz;
741 int i, err; 741 int i, err;
742 742
743 if (!mlxsw_core_res_query_enabled(core))
744 return 0;
745
743 thermal->tz_module_arr = kcalloc(module_count, 746 thermal->tz_module_arr = kcalloc(module_count,
744 sizeof(*thermal->tz_module_arr), 747 sizeof(*thermal->tz_module_arr),
745 GFP_KERNEL); 748 GFP_KERNEL);
@@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
776 unsigned int module_count = mlxsw_core_max_ports(thermal->core); 779 unsigned int module_count = mlxsw_core_max_ports(thermal->core);
777 int i; 780 int i;
778 781
782 if (!mlxsw_core_res_query_enabled(thermal->core))
783 return;
784
779 for (i = module_count - 1; i >= 0; i--) 785 for (i = module_count - 1; i >= 0; i--)
780 mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); 786 mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
781 kfree(thermal->tz_module_arr); 787 kfree(thermal->tz_module_arr);
diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
index faa06edf95ac..8c67505865a4 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
@@ -168,6 +168,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)
168 return; 168 return;
169 } 169 }
170 170
171 rcu_read_lock();
171 for (i = 0; i < count; i++) { 172 for (i = 0; i < count; i++) {
172 ipv4_addr = payload->tun_info[i].ipv4; 173 ipv4_addr = payload->tun_info[i].ipv4;
173 port = be32_to_cpu(payload->tun_info[i].egress_port); 174 port = be32_to_cpu(payload->tun_info[i].egress_port);
@@ -183,6 +184,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)
183 neigh_event_send(n, NULL); 184 neigh_event_send(n, NULL);
184 neigh_release(n); 185 neigh_release(n);
185 } 186 }
187 rcu_read_unlock();
186} 188}
187 189
188static int 190static int
@@ -367,9 +369,10 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb)
367 369
368 payload = nfp_flower_cmsg_get_data(skb); 370 payload = nfp_flower_cmsg_get_data(skb);
369 371
372 rcu_read_lock();
370 netdev = nfp_app_dev_get(app, be32_to_cpu(payload->ingress_port), NULL); 373 netdev = nfp_app_dev_get(app, be32_to_cpu(payload->ingress_port), NULL);
371 if (!netdev) 374 if (!netdev)
372 goto route_fail_warning; 375 goto fail_rcu_unlock;
373 376
374 flow.daddr = payload->ipv4_addr; 377 flow.daddr = payload->ipv4_addr;
375 flow.flowi4_proto = IPPROTO_UDP; 378 flow.flowi4_proto = IPPROTO_UDP;
@@ -379,21 +382,23 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb)
379 rt = ip_route_output_key(dev_net(netdev), &flow); 382 rt = ip_route_output_key(dev_net(netdev), &flow);
380 err = PTR_ERR_OR_ZERO(rt); 383 err = PTR_ERR_OR_ZERO(rt);
381 if (err) 384 if (err)
382 goto route_fail_warning; 385 goto fail_rcu_unlock;
383#else 386#else
384 goto route_fail_warning; 387 goto fail_rcu_unlock;
385#endif 388#endif
386 389
387 /* Get the neighbour entry for the lookup */ 390 /* Get the neighbour entry for the lookup */
388 n = dst_neigh_lookup(&rt->dst, &flow.daddr); 391 n = dst_neigh_lookup(&rt->dst, &flow.daddr);
389 ip_rt_put(rt); 392 ip_rt_put(rt);
390 if (!n) 393 if (!n)
391 goto route_fail_warning; 394 goto fail_rcu_unlock;
392 nfp_tun_write_neigh(n->dev, app, &flow, n, GFP_KERNEL); 395 nfp_tun_write_neigh(n->dev, app, &flow, n, GFP_ATOMIC);
393 neigh_release(n); 396 neigh_release(n);
397 rcu_read_unlock();
394 return; 398 return;
395 399
396route_fail_warning: 400fail_rcu_unlock:
401 rcu_read_unlock();
397 nfp_flower_cmsg_warn(app, "Requested route not found.\n"); 402 nfp_flower_cmsg_warn(app, "Requested route not found.\n");
398} 403}
399 404
diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c
index eed4fe3d871f..0fedd28fdb6e 100644
--- a/drivers/net/phy/aquantia_main.c
+++ b/drivers/net/phy/aquantia_main.c
@@ -487,6 +487,7 @@ static int aqr107_config_init(struct phy_device *phydev)
487 /* Check that the PHY interface type is compatible */ 487 /* Check that the PHY interface type is compatible */
488 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && 488 if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
489 phydev->interface != PHY_INTERFACE_MODE_2500BASEX && 489 phydev->interface != PHY_INTERFACE_MODE_2500BASEX &&
490 phydev->interface != PHY_INTERFACE_MODE_XGMII &&
490 phydev->interface != PHY_INTERFACE_MODE_10GKR) 491 phydev->interface != PHY_INTERFACE_MODE_10GKR)
491 return -ENODEV; 492 return -ENODEV;
492 493
diff --git a/drivers/net/ppp/ppp_deflate.c b/drivers/net/ppp/ppp_deflate.c
index b5edc7f96a39..685e875f5164 100644
--- a/drivers/net/ppp/ppp_deflate.c
+++ b/drivers/net/ppp/ppp_deflate.c
@@ -610,12 +610,20 @@ static struct compressor ppp_deflate_draft = {
610 610
611static int __init deflate_init(void) 611static int __init deflate_init(void)
612{ 612{
613 int answer = ppp_register_compressor(&ppp_deflate); 613 int rc;
614 if (answer == 0) 614
615 printk(KERN_INFO 615 rc = ppp_register_compressor(&ppp_deflate);
616 "PPP Deflate Compression module registered\n"); 616 if (rc)
617 ppp_register_compressor(&ppp_deflate_draft); 617 return rc;
618 return answer; 618
619 rc = ppp_register_compressor(&ppp_deflate_draft);
620 if (rc) {
621 ppp_unregister_compressor(&ppp_deflate);
622 return rc;
623 }
624
625 pr_info("PPP Deflate Compression module registered\n");
626 return 0;
619} 627}
620 628
621static void __exit deflate_cleanup(void) 629static void __exit deflate_cleanup(void)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index b86c5ce9a92a..7e44110746dd 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -320,7 +320,6 @@ static int aqc111_get_link_ksettings(struct net_device *net,
320static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) 320static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
321{ 321{
322 struct aqc111_data *aqc111_data = dev->driver_priv; 322 struct aqc111_data *aqc111_data = dev->driver_priv;
323 u32 phy_on_the_wire;
324 323
325 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; 324 aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
326 aqc111_data->phy_cfg |= AQ_PAUSE; 325 aqc111_data->phy_cfg |= AQ_PAUSE;
@@ -362,8 +361,7 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
362 } 361 }
363 } 362 }
364 363
365 phy_on_the_wire = aqc111_data->phy_cfg; 364 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg);
366 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &phy_on_the_wire);
367} 365}
368 366
369static int aqc111_set_link_ksettings(struct net_device *net, 367static int aqc111_set_link_ksettings(struct net_device *net,
@@ -439,7 +437,7 @@ static int aqc111_change_mtu(struct net_device *net, int new_mtu)
439 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 437 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,
440 2, &reg16); 438 2, &reg16);
441 439
442 if (dev->net->mtu > 12500 && dev->net->mtu <= 16334) { 440 if (dev->net->mtu > 12500) {
443 memcpy(buf, &AQC111_BULKIN_SIZE[2], 5); 441 memcpy(buf, &AQC111_BULKIN_SIZE[2], 5);
444 /* RX bulk configuration */ 442 /* RX bulk configuration */
445 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL, 443 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL,
@@ -453,10 +451,8 @@ static int aqc111_change_mtu(struct net_device *net, int new_mtu)
453 reg16 = 0x1020; 451 reg16 = 0x1020;
454 else if (dev->net->mtu <= 12500) 452 else if (dev->net->mtu <= 12500)
455 reg16 = 0x1420; 453 reg16 = 0x1420;
456 else if (dev->net->mtu <= 16334)
457 reg16 = 0x1A20;
458 else 454 else
459 return 0; 455 reg16 = 0x1A20;
460 456
461 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, 457 aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW,
462 2, &reg16); 458 2, &reg16);
@@ -757,7 +753,6 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
757{ 753{
758 struct aqc111_data *aqc111_data = dev->driver_priv; 754 struct aqc111_data *aqc111_data = dev->driver_priv;
759 u16 reg16; 755 u16 reg16;
760 u32 phy_on_the_wire;
761 756
762 /* Force bz */ 757 /* Force bz */
763 reg16 = SFR_PHYPWR_RSTCTL_BZ; 758 reg16 = SFR_PHYPWR_RSTCTL_BZ;
@@ -771,9 +766,8 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
771 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; 766 aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
772 aqc111_data->phy_cfg |= AQ_LOW_POWER; 767 aqc111_data->phy_cfg |= AQ_LOW_POWER;
773 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; 768 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN;
774 phy_on_the_wire = aqc111_data->phy_cfg;
775 aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0, 769 aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0,
776 &phy_on_the_wire); 770 &aqc111_data->phy_cfg);
777 771
778 kfree(aqc111_data); 772 kfree(aqc111_data);
779} 773}
@@ -996,7 +990,6 @@ static int aqc111_reset(struct usbnet *dev)
996{ 990{
997 struct aqc111_data *aqc111_data = dev->driver_priv; 991 struct aqc111_data *aqc111_data = dev->driver_priv;
998 u8 reg8 = 0; 992 u8 reg8 = 0;
999 u32 phy_on_the_wire;
1000 993
1001 dev->rx_urb_size = URB_SIZE; 994 dev->rx_urb_size = URB_SIZE;
1002 995
@@ -1009,9 +1002,8 @@ static int aqc111_reset(struct usbnet *dev)
1009 1002
1010 /* Power up ethernet PHY */ 1003 /* Power up ethernet PHY */
1011 aqc111_data->phy_cfg = AQ_PHY_POWER_EN; 1004 aqc111_data->phy_cfg = AQ_PHY_POWER_EN;
1012 phy_on_the_wire = aqc111_data->phy_cfg;
1013 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1005 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1014 &phy_on_the_wire); 1006 &aqc111_data->phy_cfg);
1015 1007
1016 /* Set the MAC address */ 1008 /* Set the MAC address */
1017 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, 1009 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN,
@@ -1042,7 +1034,6 @@ static int aqc111_stop(struct usbnet *dev)
1042{ 1034{
1043 struct aqc111_data *aqc111_data = dev->driver_priv; 1035 struct aqc111_data *aqc111_data = dev->driver_priv;
1044 u16 reg16 = 0; 1036 u16 reg16 = 0;
1045 u32 phy_on_the_wire;
1046 1037
1047 aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 1038 aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,
1048 2, &reg16); 1039 2, &reg16);
@@ -1054,9 +1045,8 @@ static int aqc111_stop(struct usbnet *dev)
1054 1045
1055 /* Put PHY to low power*/ 1046 /* Put PHY to low power*/
1056 aqc111_data->phy_cfg |= AQ_LOW_POWER; 1047 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1057 phy_on_the_wire = aqc111_data->phy_cfg;
1058 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1048 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1059 &phy_on_the_wire); 1049 &aqc111_data->phy_cfg);
1060 1050
1061 netif_carrier_off(dev->net); 1051 netif_carrier_off(dev->net);
1062 1052
@@ -1332,7 +1322,6 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
1332 u16 temp_rx_ctrl = 0x00; 1322 u16 temp_rx_ctrl = 0x00;
1333 u16 reg16; 1323 u16 reg16;
1334 u8 reg8; 1324 u8 reg8;
1335 u32 phy_on_the_wire;
1336 1325
1337 usbnet_suspend(intf, message); 1326 usbnet_suspend(intf, message);
1338 1327
@@ -1404,14 +1393,12 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
1404 1393
1405 aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0, 1394 aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0,
1406 WOL_CFG_SIZE, &wol_cfg); 1395 WOL_CFG_SIZE, &wol_cfg);
1407 phy_on_the_wire = aqc111_data->phy_cfg;
1408 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1396 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1409 &phy_on_the_wire); 1397 &aqc111_data->phy_cfg);
1410 } else { 1398 } else {
1411 aqc111_data->phy_cfg |= AQ_LOW_POWER; 1399 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1412 phy_on_the_wire = aqc111_data->phy_cfg;
1413 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1400 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1414 &phy_on_the_wire); 1401 &aqc111_data->phy_cfg);
1415 1402
1416 /* Disable RX path */ 1403 /* Disable RX path */
1417 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, 1404 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC,
@@ -1428,7 +1415,7 @@ static int aqc111_resume(struct usb_interface *intf)
1428{ 1415{
1429 struct usbnet *dev = usb_get_intfdata(intf); 1416 struct usbnet *dev = usb_get_intfdata(intf);
1430 struct aqc111_data *aqc111_data = dev->driver_priv; 1417 struct aqc111_data *aqc111_data = dev->driver_priv;
1431 u16 reg16, oldreg16; 1418 u16 reg16;
1432 u8 reg8; 1419 u8 reg8;
1433 1420
1434 netif_carrier_off(dev->net); 1421 netif_carrier_off(dev->net);
@@ -1444,11 +1431,9 @@ static int aqc111_resume(struct usb_interface *intf)
1444 /* Configure RX control register => start operation */ 1431 /* Configure RX control register => start operation */
1445 reg16 = aqc111_data->rxctl; 1432 reg16 = aqc111_data->rxctl;
1446 reg16 &= ~SFR_RX_CTL_START; 1433 reg16 &= ~SFR_RX_CTL_START;
1447 /* needs to be saved in case endianness is swapped */
1448 oldreg16 = reg16;
1449 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16); 1434 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16);
1450 1435
1451 reg16 = oldreg16 | SFR_RX_CTL_START; 1436 reg16 |= SFR_RX_CTL_START;
1452 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16); 1437 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, &reg16);
1453 1438
1454 aqc111_set_phy_speed(dev, aqc111_data->autoneg, 1439 aqc111_set_phy_speed(dev, aqc111_data->autoneg,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 5c3ac97519b7..d9a6699abe59 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -1259,6 +1259,8 @@ static const struct usb_device_id products[] = {
1259 {QMI_FIXED_INTF(0x1bc7, 0x1101, 3)}, /* Telit ME910 dual modem */ 1259 {QMI_FIXED_INTF(0x1bc7, 0x1101, 3)}, /* Telit ME910 dual modem */
1260 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ 1260 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
1261 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ 1261 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */
1262 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1260, 2)}, /* Telit LE910Cx */
1263 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1261, 2)}, /* Telit LE910Cx */
1262 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1900, 1)}, /* Telit LN940 series */ 1264 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1900, 1)}, /* Telit LN940 series */
1263 {QMI_FIXED_INTF(0x1c9e, 0x9801, 3)}, /* Telewell TW-3G HSPA+ */ 1265 {QMI_FIXED_INTF(0x1c9e, 0x9801, 3)}, /* Telewell TW-3G HSPA+ */
1264 {QMI_FIXED_INTF(0x1c9e, 0x9803, 4)}, /* Telewell TW-3G HSPA+ */ 1266 {QMI_FIXED_INTF(0x1c9e, 0x9803, 4)}, /* Telewell TW-3G HSPA+ */
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 59631dd0777c..4fb3aa2dc975 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -36,6 +36,7 @@ struct bpf_map_ops {
36 void (*map_free)(struct bpf_map *map); 36 void (*map_free)(struct bpf_map *map);
37 int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key); 37 int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key);
38 void (*map_release_uref)(struct bpf_map *map); 38 void (*map_release_uref)(struct bpf_map *map);
39 void *(*map_lookup_elem_sys_only)(struct bpf_map *map, void *key);
39 40
40 /* funcs callable from userspace and from eBPF programs */ 41 /* funcs callable from userspace and from eBPF programs */
41 void *(*map_lookup_elem)(struct bpf_map *map, void *key); 42 void *(*map_lookup_elem)(struct bpf_map *map, void *key);
diff --git a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h
index 0ca77dd1429c..cf226c190329 100644
--- a/include/linux/mlx5/eswitch.h
+++ b/include/linux/mlx5/eswitch.h
@@ -51,13 +51,13 @@ void mlx5_eswitch_register_vport_reps(struct mlx5_eswitch *esw,
51 u8 rep_type); 51 u8 rep_type);
52void mlx5_eswitch_unregister_vport_reps(struct mlx5_eswitch *esw, u8 rep_type); 52void mlx5_eswitch_unregister_vport_reps(struct mlx5_eswitch *esw, u8 rep_type);
53void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw, 53void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
54 int vport, 54 u16 vport_num,
55 u8 rep_type); 55 u8 rep_type);
56struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw, 56struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw,
57 int vport); 57 u16 vport_num);
58void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type); 58void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type);
59u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw); 59u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw);
60struct mlx5_flow_handle * 60struct mlx5_flow_handle *
61mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, 61mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw,
62 int vport, u32 sqn); 62 u16 vport_num, u32 sqn);
63#endif 63#endif
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 9cd72aab76fe..0f0346e6829c 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -22,7 +22,7 @@ static inline int of_get_phy_mode(struct device_node *np)
22 22
23static inline const void *of_get_mac_address(struct device_node *np) 23static inline const void *of_get_mac_address(struct device_node *np)
24{ 24{
25 return NULL; 25 return ERR_PTR(-ENODEV);
26} 26}
27 27
28static inline struct net_device *of_find_net_device_by_node(struct device_node *np) 28static inline struct net_device *of_find_net_device_by_node(struct device_node *np)
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index f7714d3b46bd..9f8bc06d4136 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -84,7 +84,7 @@ struct bucket_table {
84 84
85 struct lockdep_map dep_map; 85 struct lockdep_map dep_map;
86 86
87 struct rhash_lock_head __rcu *buckets[] ____cacheline_aligned_in_smp; 87 struct rhash_lock_head *buckets[] ____cacheline_aligned_in_smp;
88}; 88};
89 89
90/* 90/*
@@ -261,13 +261,13 @@ void rhashtable_free_and_destroy(struct rhashtable *ht,
261 void *arg); 261 void *arg);
262void rhashtable_destroy(struct rhashtable *ht); 262void rhashtable_destroy(struct rhashtable *ht);
263 263
264struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl, 264struct rhash_lock_head **rht_bucket_nested(const struct bucket_table *tbl,
265 unsigned int hash); 265 unsigned int hash);
266struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tbl, 266struct rhash_lock_head **__rht_bucket_nested(const struct bucket_table *tbl,
267 unsigned int hash); 267 unsigned int hash);
268struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht, 268struct rhash_lock_head **rht_bucket_nested_insert(struct rhashtable *ht,
269 struct bucket_table *tbl, 269 struct bucket_table *tbl,
270 unsigned int hash); 270 unsigned int hash);
271 271
272#define rht_dereference(p, ht) \ 272#define rht_dereference(p, ht) \
273 rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht)) 273 rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht))
@@ -284,21 +284,21 @@ struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht,
284#define rht_entry(tpos, pos, member) \ 284#define rht_entry(tpos, pos, member) \
285 ({ tpos = container_of(pos, typeof(*tpos), member); 1; }) 285 ({ tpos = container_of(pos, typeof(*tpos), member); 1; })
286 286
287static inline struct rhash_lock_head __rcu *const *rht_bucket( 287static inline struct rhash_lock_head *const *rht_bucket(
288 const struct bucket_table *tbl, unsigned int hash) 288 const struct bucket_table *tbl, unsigned int hash)
289{ 289{
290 return unlikely(tbl->nest) ? rht_bucket_nested(tbl, hash) : 290 return unlikely(tbl->nest) ? rht_bucket_nested(tbl, hash) :
291 &tbl->buckets[hash]; 291 &tbl->buckets[hash];
292} 292}
293 293
294static inline struct rhash_lock_head __rcu **rht_bucket_var( 294static inline struct rhash_lock_head **rht_bucket_var(
295 struct bucket_table *tbl, unsigned int hash) 295 struct bucket_table *tbl, unsigned int hash)
296{ 296{
297 return unlikely(tbl->nest) ? __rht_bucket_nested(tbl, hash) : 297 return unlikely(tbl->nest) ? __rht_bucket_nested(tbl, hash) :
298 &tbl->buckets[hash]; 298 &tbl->buckets[hash];
299} 299}
300 300
301static inline struct rhash_lock_head __rcu **rht_bucket_insert( 301static inline struct rhash_lock_head **rht_bucket_insert(
302 struct rhashtable *ht, struct bucket_table *tbl, unsigned int hash) 302 struct rhashtable *ht, struct bucket_table *tbl, unsigned int hash)
303{ 303{
304 return unlikely(tbl->nest) ? rht_bucket_nested_insert(ht, tbl, hash) : 304 return unlikely(tbl->nest) ? rht_bucket_nested_insert(ht, tbl, hash) :
@@ -349,6 +349,12 @@ static inline void rht_unlock(struct bucket_table *tbl,
349 local_bh_enable(); 349 local_bh_enable();
350} 350}
351 351
352static inline struct rhash_head __rcu *__rht_ptr(
353 struct rhash_lock_head *const *bkt)
354{
355 return (struct rhash_head __rcu *)((unsigned long)*bkt & ~BIT(0));
356}
357
352/* 358/*
353 * Where 'bkt' is a bucket and might be locked: 359 * Where 'bkt' is a bucket and might be locked:
354 * rht_ptr() dereferences that pointer and clears the lock bit. 360 * rht_ptr() dereferences that pointer and clears the lock bit.
@@ -356,30 +362,30 @@ static inline void rht_unlock(struct bucket_table *tbl,
356 * access is guaranteed, such as when destroying the table. 362 * access is guaranteed, such as when destroying the table.
357 */ 363 */
358static inline struct rhash_head *rht_ptr( 364static inline struct rhash_head *rht_ptr(
359 struct rhash_lock_head __rcu * const *bkt, 365 struct rhash_lock_head *const *bkt,
360 struct bucket_table *tbl, 366 struct bucket_table *tbl,
361 unsigned int hash) 367 unsigned int hash)
362{ 368{
363 const struct rhash_lock_head *p = 369 struct rhash_head __rcu *p = __rht_ptr(bkt);
364 rht_dereference_bucket_rcu(*bkt, tbl, hash);
365 370
366 if ((((unsigned long)p) & ~BIT(0)) == 0) 371 if (!p)
367 return RHT_NULLS_MARKER(bkt); 372 return RHT_NULLS_MARKER(bkt);
368 return (void *)(((unsigned long)p) & ~BIT(0)); 373
374 return rht_dereference_bucket_rcu(p, tbl, hash);
369} 375}
370 376
371static inline struct rhash_head *rht_ptr_exclusive( 377static inline struct rhash_head *rht_ptr_exclusive(
372 struct rhash_lock_head __rcu * const *bkt) 378 struct rhash_lock_head *const *bkt)
373{ 379{
374 const struct rhash_lock_head *p = 380 struct rhash_head __rcu *p = __rht_ptr(bkt);
375 rcu_dereference_protected(*bkt, 1);
376 381
377 if (!p) 382 if (!p)
378 return RHT_NULLS_MARKER(bkt); 383 return RHT_NULLS_MARKER(bkt);
379 return (void *)(((unsigned long)p) & ~BIT(0)); 384
385 return rcu_dereference_protected(p, 1);
380} 386}
381 387
382static inline void rht_assign_locked(struct rhash_lock_head __rcu **bkt, 388static inline void rht_assign_locked(struct rhash_lock_head **bkt,
383 struct rhash_head *obj) 389 struct rhash_head *obj)
384{ 390{
385 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt; 391 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt;
@@ -390,7 +396,7 @@ static inline void rht_assign_locked(struct rhash_lock_head __rcu **bkt,
390} 396}
391 397
392static inline void rht_assign_unlock(struct bucket_table *tbl, 398static inline void rht_assign_unlock(struct bucket_table *tbl,
393 struct rhash_lock_head __rcu **bkt, 399 struct rhash_lock_head **bkt,
394 struct rhash_head *obj) 400 struct rhash_head *obj)
395{ 401{
396 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt; 402 struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt;
@@ -587,7 +593,7 @@ static inline struct rhash_head *__rhashtable_lookup(
587 .ht = ht, 593 .ht = ht,
588 .key = key, 594 .key = key,
589 }; 595 };
590 struct rhash_lock_head __rcu * const *bkt; 596 struct rhash_lock_head *const *bkt;
591 struct bucket_table *tbl; 597 struct bucket_table *tbl;
592 struct rhash_head *he; 598 struct rhash_head *he;
593 unsigned int hash; 599 unsigned int hash;
@@ -703,7 +709,7 @@ static inline void *__rhashtable_insert_fast(
703 .ht = ht, 709 .ht = ht,
704 .key = key, 710 .key = key,
705 }; 711 };
706 struct rhash_lock_head __rcu **bkt; 712 struct rhash_lock_head **bkt;
707 struct rhash_head __rcu **pprev; 713 struct rhash_head __rcu **pprev;
708 struct bucket_table *tbl; 714 struct bucket_table *tbl;
709 struct rhash_head *head; 715 struct rhash_head *head;
@@ -989,7 +995,7 @@ static inline int __rhashtable_remove_fast_one(
989 struct rhash_head *obj, const struct rhashtable_params params, 995 struct rhash_head *obj, const struct rhashtable_params params,
990 bool rhlist) 996 bool rhlist)
991{ 997{
992 struct rhash_lock_head __rcu **bkt; 998 struct rhash_lock_head **bkt;
993 struct rhash_head __rcu **pprev; 999 struct rhash_head __rcu **pprev;
994 struct rhash_head *he; 1000 struct rhash_head *he;
995 unsigned int hash; 1001 unsigned int hash;
@@ -1141,7 +1147,7 @@ static inline int __rhashtable_replace_fast(
1141 struct rhash_head *obj_old, struct rhash_head *obj_new, 1147 struct rhash_head *obj_old, struct rhash_head *obj_new,
1142 const struct rhashtable_params params) 1148 const struct rhashtable_params params)
1143{ 1149{
1144 struct rhash_lock_head __rcu **bkt; 1150 struct rhash_lock_head **bkt;
1145 struct rhash_head __rcu **pprev; 1151 struct rhash_head __rcu **pprev;
1146 struct rhash_head *he; 1152 struct rhash_head *he;
1147 unsigned int hash; 1153 unsigned int hash;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6d58fa8a65fd..2ee5e63195c0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1434,10 +1434,12 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy)
1434 struct ubuf_info *uarg = skb_zcopy(skb); 1434 struct ubuf_info *uarg = skb_zcopy(skb);
1435 1435
1436 if (uarg) { 1436 if (uarg) {
1437 if (uarg->callback == sock_zerocopy_callback) { 1437 if (skb_zcopy_is_nouarg(skb)) {
1438 /* no notification callback */
1439 } else if (uarg->callback == sock_zerocopy_callback) {
1438 uarg->zerocopy = uarg->zerocopy && zerocopy; 1440 uarg->zerocopy = uarg->zerocopy && zerocopy;
1439 sock_zerocopy_put(uarg); 1441 sock_zerocopy_put(uarg);
1440 } else if (!skb_zcopy_is_nouarg(skb)) { 1442 } else {
1441 uarg->callback(uarg, zerocopy); 1443 uarg->callback(uarg, zerocopy);
1442 } 1444 }
1443 1445
@@ -2691,7 +2693,8 @@ static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
2691{ 2693{
2692 if (likely(!skb_zcopy(skb))) 2694 if (likely(!skb_zcopy(skb)))
2693 return 0; 2695 return 0;
2694 if (skb_uarg(skb)->callback == sock_zerocopy_callback) 2696 if (!skb_zcopy_is_nouarg(skb) &&
2697 skb_uarg(skb)->callback == sock_zerocopy_callback)
2695 return 0; 2698 return 0;
2696 return skb_copy_ubufs(skb, gfp_mask); 2699 return skb_copy_ubufs(skb, gfp_mask);
2697} 2700}
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 6200900434e1..a2df99f9b196 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -71,6 +71,8 @@ void flow_rule_match_eth_addrs(const struct flow_rule *rule,
71 struct flow_match_eth_addrs *out); 71 struct flow_match_eth_addrs *out);
72void flow_rule_match_vlan(const struct flow_rule *rule, 72void flow_rule_match_vlan(const struct flow_rule *rule,
73 struct flow_match_vlan *out); 73 struct flow_match_vlan *out);
74void flow_rule_match_cvlan(const struct flow_rule *rule,
75 struct flow_match_vlan *out);
74void flow_rule_match_ipv4_addrs(const struct flow_rule *rule, 76void flow_rule_match_ipv4_addrs(const struct flow_rule *rule,
75 struct flow_match_ipv4_addrs *out); 77 struct flow_match_ipv4_addrs *out);
76void flow_rule_match_ipv6_addrs(const struct flow_rule *rule, 78void flow_rule_match_ipv6_addrs(const struct flow_rule *rule,
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 40105738e2f6..525f701653ca 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -167,7 +167,8 @@ struct fib6_info {
167 dst_nocount:1, 167 dst_nocount:1,
168 dst_nopolicy:1, 168 dst_nopolicy:1,
169 dst_host:1, 169 dst_host:1,
170 unused:3; 170 fib6_destroying:1,
171 unused:2;
171 172
172 struct fib6_nh fib6_nh; 173 struct fib6_nh fib6_nh;
173 struct rcu_head rcu; 174 struct rcu_head rcu;
diff --git a/include/net/sock.h b/include/net/sock.h
index 4d208c0f9c14..0680fa988497 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1473,7 +1473,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
1473 sock_set_flag(sk, SOCK_QUEUE_SHRUNK); 1473 sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
1474 sk->sk_wmem_queued -= skb->truesize; 1474 sk->sk_wmem_queued -= skb->truesize;
1475 sk_mem_uncharge(sk, skb->truesize); 1475 sk_mem_uncharge(sk, skb->truesize);
1476 if (!sk->sk_tx_skb_cache) { 1476 if (!sk->sk_tx_skb_cache && !skb_cloned(skb)) {
1477 skb_zcopy_clear(skb, true); 1477 skb_zcopy_clear(skb, true);
1478 sk->sk_tx_skb_cache = skb; 1478 sk->sk_tx_skb_cache = skb;
1479 return; 1479 return;
diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h
index 9310652ca4f9..63ae4a39e58b 100644
--- a/include/uapi/linux/btf.h
+++ b/include/uapi/linux/btf.h
@@ -83,7 +83,7 @@ struct btf_type {
83 * is the 32 bits arrangement: 83 * is the 32 bits arrangement:
84 */ 84 */
85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
86#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 86#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) 87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
88 88
89/* Attributes stored in the BTF_INT_ENCODING */ 89/* Attributes stored in the BTF_INT_ENCODING */
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 191b79948424..1e525d70f833 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -164,6 +164,9 @@ static void dev_map_free(struct bpf_map *map)
164 bpf_clear_redirect_map(map); 164 bpf_clear_redirect_map(map);
165 synchronize_rcu(); 165 synchronize_rcu();
166 166
167 /* Make sure prior __dev_map_entry_free() have completed. */
168 rcu_barrier();
169
167 /* To ensure all pending flush operations have completed wait for flush 170 /* To ensure all pending flush operations have completed wait for flush
168 * bitmap to indicate all flush_needed bits to be zero on _all_ cpus. 171 * bitmap to indicate all flush_needed bits to be zero on _all_ cpus.
169 * Because the above synchronize_rcu() ensures the map is disconnected 172 * Because the above synchronize_rcu() ensures the map is disconnected
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 192d32e77db3..0f2708fde5f7 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -527,18 +527,30 @@ static u32 htab_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
527 return insn - insn_buf; 527 return insn - insn_buf;
528} 528}
529 529
530static void *htab_lru_map_lookup_elem(struct bpf_map *map, void *key) 530static __always_inline void *__htab_lru_map_lookup_elem(struct bpf_map *map,
531 void *key, const bool mark)
531{ 532{
532 struct htab_elem *l = __htab_map_lookup_elem(map, key); 533 struct htab_elem *l = __htab_map_lookup_elem(map, key);
533 534
534 if (l) { 535 if (l) {
535 bpf_lru_node_set_ref(&l->lru_node); 536 if (mark)
537 bpf_lru_node_set_ref(&l->lru_node);
536 return l->key + round_up(map->key_size, 8); 538 return l->key + round_up(map->key_size, 8);
537 } 539 }
538 540
539 return NULL; 541 return NULL;
540} 542}
541 543
544static void *htab_lru_map_lookup_elem(struct bpf_map *map, void *key)
545{
546 return __htab_lru_map_lookup_elem(map, key, true);
547}
548
549static void *htab_lru_map_lookup_elem_sys(struct bpf_map *map, void *key)
550{
551 return __htab_lru_map_lookup_elem(map, key, false);
552}
553
542static u32 htab_lru_map_gen_lookup(struct bpf_map *map, 554static u32 htab_lru_map_gen_lookup(struct bpf_map *map,
543 struct bpf_insn *insn_buf) 555 struct bpf_insn *insn_buf)
544{ 556{
@@ -1250,6 +1262,7 @@ const struct bpf_map_ops htab_lru_map_ops = {
1250 .map_free = htab_map_free, 1262 .map_free = htab_map_free,
1251 .map_get_next_key = htab_map_get_next_key, 1263 .map_get_next_key = htab_map_get_next_key,
1252 .map_lookup_elem = htab_lru_map_lookup_elem, 1264 .map_lookup_elem = htab_lru_map_lookup_elem,
1265 .map_lookup_elem_sys_only = htab_lru_map_lookup_elem_sys,
1253 .map_update_elem = htab_lru_map_update_elem, 1266 .map_update_elem = htab_lru_map_update_elem,
1254 .map_delete_elem = htab_lru_map_delete_elem, 1267 .map_delete_elem = htab_lru_map_delete_elem,
1255 .map_gen_lookup = htab_lru_map_gen_lookup, 1268 .map_gen_lookup = htab_lru_map_gen_lookup,
@@ -1281,7 +1294,6 @@ static void *htab_lru_percpu_map_lookup_elem(struct bpf_map *map, void *key)
1281 1294
1282int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value) 1295int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value)
1283{ 1296{
1284 struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
1285 struct htab_elem *l; 1297 struct htab_elem *l;
1286 void __percpu *pptr; 1298 void __percpu *pptr;
1287 int ret = -ENOENT; 1299 int ret = -ENOENT;
@@ -1297,8 +1309,9 @@ int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value)
1297 l = __htab_map_lookup_elem(map, key); 1309 l = __htab_map_lookup_elem(map, key);
1298 if (!l) 1310 if (!l)
1299 goto out; 1311 goto out;
1300 if (htab_is_lru(htab)) 1312 /* We do not mark LRU map element here in order to not mess up
1301 bpf_lru_node_set_ref(&l->lru_node); 1313 * eviction heuristics when user space does a map walk.
1314 */
1302 pptr = htab_elem_get_ptr(l, map->key_size); 1315 pptr = htab_elem_get_ptr(l, map->key_size);
1303 for_each_possible_cpu(cpu) { 1316 for_each_possible_cpu(cpu) {
1304 bpf_long_memcpy(value + off, 1317 bpf_long_memcpy(value + off,
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index bc53e5b20ddc..84a80b02db99 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -518,7 +518,7 @@ out:
518static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type) 518static struct bpf_prog *__get_prog_inode(struct inode *inode, enum bpf_prog_type type)
519{ 519{
520 struct bpf_prog *prog; 520 struct bpf_prog *prog;
521 int ret = inode_permission(inode, MAY_READ | MAY_WRITE); 521 int ret = inode_permission(inode, MAY_READ);
522 if (ret) 522 if (ret)
523 return ERR_PTR(ret); 523 return ERR_PTR(ret);
524 524
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ad3ccf82f31d..cb5440b02e82 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -808,7 +808,10 @@ static int map_lookup_elem(union bpf_attr *attr)
808 err = map->ops->map_peek_elem(map, value); 808 err = map->ops->map_peek_elem(map, value);
809 } else { 809 } else {
810 rcu_read_lock(); 810 rcu_read_lock();
811 ptr = map->ops->map_lookup_elem(map, key); 811 if (map->ops->map_lookup_elem_sys_only)
812 ptr = map->ops->map_lookup_elem_sys_only(map, key);
813 else
814 ptr = map->ops->map_lookup_elem(map, key);
812 if (IS_ERR(ptr)) { 815 if (IS_ERR(ptr)) {
813 err = PTR_ERR(ptr); 816 err = PTR_ERR(ptr);
814 } else if (!ptr) { 817 } else if (!ptr) {
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index b496ffdf5f36..f92d6ad5e080 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1297,7 +1297,8 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
1297} 1297}
1298 1298
1299#ifdef CONFIG_MODULES 1299#ifdef CONFIG_MODULES
1300int bpf_event_notify(struct notifier_block *nb, unsigned long op, void *module) 1300static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
1301 void *module)
1301{ 1302{
1302 struct bpf_trace_module *btm, *tmp; 1303 struct bpf_trace_module *btm, *tmp;
1303 struct module *mod = module; 1304 struct module *mod = module;
@@ -1336,7 +1337,7 @@ static struct notifier_block bpf_module_nb = {
1336 .notifier_call = bpf_event_notify, 1337 .notifier_call = bpf_event_notify,
1337}; 1338};
1338 1339
1339int __init bpf_event_init(void) 1340static int __init bpf_event_init(void)
1340{ 1341{
1341 register_module_notifier(&bpf_module_nb); 1342 register_module_notifier(&bpf_module_nb);
1342 return 0; 1343 return 0;
diff --git a/lib/random32.c b/lib/random32.c
index 4aaa76404d56..763b920a6206 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -171,9 +171,9 @@ static void prandom_seed_early(struct rnd_state *state, u32 seed,
171 171
172/** 172/**
173 * prandom_seed - add entropy to pseudo random number generator 173 * prandom_seed - add entropy to pseudo random number generator
174 * @seed: seed value 174 * @entropy: entropy value
175 * 175 *
176 * Add some additional seeding to the prandom pool. 176 * Add some additional entropy to the prandom pool.
177 */ 177 */
178void prandom_seed(u32 entropy) 178void prandom_seed(u32 entropy)
179{ 179{
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 6529fe1b45c1..935ec80f213f 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -34,7 +34,7 @@
34 34
35union nested_table { 35union nested_table {
36 union nested_table __rcu *table; 36 union nested_table __rcu *table;
37 struct rhash_lock_head __rcu *bucket; 37 struct rhash_lock_head *bucket;
38}; 38};
39 39
40static u32 head_hashfn(struct rhashtable *ht, 40static u32 head_hashfn(struct rhashtable *ht,
@@ -131,7 +131,7 @@ static union nested_table *nested_table_alloc(struct rhashtable *ht,
131 INIT_RHT_NULLS_HEAD(ntbl[i].bucket); 131 INIT_RHT_NULLS_HEAD(ntbl[i].bucket);
132 } 132 }
133 133
134 if (cmpxchg(prev, NULL, ntbl) == NULL) 134 if (cmpxchg((union nested_table **)prev, NULL, ntbl) == NULL)
135 return ntbl; 135 return ntbl;
136 /* Raced with another thread. */ 136 /* Raced with another thread. */
137 kfree(ntbl); 137 kfree(ntbl);
@@ -216,7 +216,7 @@ static struct bucket_table *rhashtable_last_table(struct rhashtable *ht,
216} 216}
217 217
218static int rhashtable_rehash_one(struct rhashtable *ht, 218static int rhashtable_rehash_one(struct rhashtable *ht,
219 struct rhash_lock_head __rcu **bkt, 219 struct rhash_lock_head **bkt,
220 unsigned int old_hash) 220 unsigned int old_hash)
221{ 221{
222 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); 222 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht);
@@ -269,7 +269,7 @@ static int rhashtable_rehash_chain(struct rhashtable *ht,
269 unsigned int old_hash) 269 unsigned int old_hash)
270{ 270{
271 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); 271 struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht);
272 struct rhash_lock_head __rcu **bkt = rht_bucket_var(old_tbl, old_hash); 272 struct rhash_lock_head **bkt = rht_bucket_var(old_tbl, old_hash);
273 int err; 273 int err;
274 274
275 if (!bkt) 275 if (!bkt)
@@ -296,7 +296,8 @@ static int rhashtable_rehash_attach(struct rhashtable *ht,
296 * rcu_assign_pointer(). 296 * rcu_assign_pointer().
297 */ 297 */
298 298
299 if (cmpxchg(&old_tbl->future_tbl, NULL, new_tbl) != NULL) 299 if (cmpxchg((struct bucket_table **)&old_tbl->future_tbl, NULL,
300 new_tbl) != NULL)
300 return -EEXIST; 301 return -EEXIST;
301 302
302 return 0; 303 return 0;
@@ -478,7 +479,7 @@ fail:
478} 479}
479 480
480static void *rhashtable_lookup_one(struct rhashtable *ht, 481static void *rhashtable_lookup_one(struct rhashtable *ht,
481 struct rhash_lock_head __rcu **bkt, 482 struct rhash_lock_head **bkt,
482 struct bucket_table *tbl, unsigned int hash, 483 struct bucket_table *tbl, unsigned int hash,
483 const void *key, struct rhash_head *obj) 484 const void *key, struct rhash_head *obj)
484{ 485{
@@ -529,7 +530,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht,
529} 530}
530 531
531static struct bucket_table *rhashtable_insert_one(struct rhashtable *ht, 532static struct bucket_table *rhashtable_insert_one(struct rhashtable *ht,
532 struct rhash_lock_head __rcu **bkt, 533 struct rhash_lock_head **bkt,
533 struct bucket_table *tbl, 534 struct bucket_table *tbl,
534 unsigned int hash, 535 unsigned int hash,
535 struct rhash_head *obj, 536 struct rhash_head *obj,
@@ -584,7 +585,7 @@ static void *rhashtable_try_insert(struct rhashtable *ht, const void *key,
584{ 585{
585 struct bucket_table *new_tbl; 586 struct bucket_table *new_tbl;
586 struct bucket_table *tbl; 587 struct bucket_table *tbl;
587 struct rhash_lock_head __rcu **bkt; 588 struct rhash_lock_head **bkt;
588 unsigned int hash; 589 unsigned int hash;
589 void *data; 590 void *data;
590 591
@@ -1166,8 +1167,8 @@ void rhashtable_destroy(struct rhashtable *ht)
1166} 1167}
1167EXPORT_SYMBOL_GPL(rhashtable_destroy); 1168EXPORT_SYMBOL_GPL(rhashtable_destroy);
1168 1169
1169struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tbl, 1170struct rhash_lock_head **__rht_bucket_nested(const struct bucket_table *tbl,
1170 unsigned int hash) 1171 unsigned int hash)
1171{ 1172{
1172 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *)); 1173 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *));
1173 unsigned int index = hash & ((1 << tbl->nest) - 1); 1174 unsigned int index = hash & ((1 << tbl->nest) - 1);
@@ -1195,10 +1196,10 @@ struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tb
1195} 1196}
1196EXPORT_SYMBOL_GPL(__rht_bucket_nested); 1197EXPORT_SYMBOL_GPL(__rht_bucket_nested);
1197 1198
1198struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl, 1199struct rhash_lock_head **rht_bucket_nested(const struct bucket_table *tbl,
1199 unsigned int hash) 1200 unsigned int hash)
1200{ 1201{
1201 static struct rhash_lock_head __rcu *rhnull; 1202 static struct rhash_lock_head *rhnull;
1202 1203
1203 if (!rhnull) 1204 if (!rhnull)
1204 INIT_RHT_NULLS_HEAD(rhnull); 1205 INIT_RHT_NULLS_HEAD(rhnull);
@@ -1206,9 +1207,9 @@ struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl,
1206} 1207}
1207EXPORT_SYMBOL_GPL(rht_bucket_nested); 1208EXPORT_SYMBOL_GPL(rht_bucket_nested);
1208 1209
1209struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht, 1210struct rhash_lock_head **rht_bucket_nested_insert(struct rhashtable *ht,
1210 struct bucket_table *tbl, 1211 struct bucket_table *tbl,
1211 unsigned int hash) 1212 unsigned int hash)
1212{ 1213{
1213 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *)); 1214 const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *));
1214 unsigned int index = hash & ((1 << tbl->nest) - 1); 1215 unsigned int index = hash & ((1 << tbl->nest) - 1);
diff --git a/net/caif/cfdbgl.c b/net/caif/cfdbgl.c
index 7aae0b56829e..cce839bf49f7 100644
--- a/net/caif/cfdbgl.c
+++ b/net/caif/cfdbgl.c
@@ -26,7 +26,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
26 cfsrvl_init(dbg, channel_id, dev_info, false); 26 cfsrvl_init(dbg, channel_id, dev_info, false);
27 dbg->layer.receive = cfdbgl_receive; 27 dbg->layer.receive = cfdbgl_receive;
28 dbg->layer.transmit = cfdbgl_transmit; 28 dbg->layer.transmit = cfdbgl_transmit;
29 snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id); 29 snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ, "dbg%d", channel_id);
30 return &dbg->layer; 30 return &dbg->layer;
31} 31}
32 32
diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c
index 3bdddb32d55a..58fdb99a390f 100644
--- a/net/caif/cfdgml.c
+++ b/net/caif/cfdgml.c
@@ -33,8 +33,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
33 cfsrvl_init(dgm, channel_id, dev_info, true); 33 cfsrvl_init(dgm, channel_id, dev_info, true);
34 dgm->layer.receive = cfdgml_receive; 34 dgm->layer.receive = cfdgml_receive;
35 dgm->layer.transmit = cfdgml_transmit; 35 dgm->layer.transmit = cfdgml_transmit;
36 snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id); 36 snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ, "dgm%d", channel_id);
37 dgm->layer.name[CAIF_LAYER_NAME_SZ - 1] = '\0';
38 return &dgm->layer; 37 return &dgm->layer;
39} 38}
40 39
diff --git a/net/caif/cfutill.c b/net/caif/cfutill.c
index 1728fa4471cf..be7c43a92ead 100644
--- a/net/caif/cfutill.c
+++ b/net/caif/cfutill.c
@@ -33,7 +33,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
33 cfsrvl_init(util, channel_id, dev_info, true); 33 cfsrvl_init(util, channel_id, dev_info, true);
34 util->layer.receive = cfutill_receive; 34 util->layer.receive = cfutill_receive;
35 util->layer.transmit = cfutill_transmit; 35 util->layer.transmit = cfutill_transmit;
36 snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1"); 36 snprintf(util->layer.name, CAIF_LAYER_NAME_SZ, "util1");
37 return &util->layer; 37 return &util->layer;
38} 38}
39 39
diff --git a/net/caif/cfveil.c b/net/caif/cfveil.c
index 262224581efa..35dd3a600dd1 100644
--- a/net/caif/cfveil.c
+++ b/net/caif/cfveil.c
@@ -32,7 +32,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
32 cfsrvl_init(vei, channel_id, dev_info, true); 32 cfsrvl_init(vei, channel_id, dev_info, true);
33 vei->layer.receive = cfvei_receive; 33 vei->layer.receive = cfvei_receive;
34 vei->layer.transmit = cfvei_transmit; 34 vei->layer.transmit = cfvei_transmit;
35 snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id); 35 snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ, "vei%d", channel_id);
36 return &vei->layer; 36 return &vei->layer;
37} 37}
38 38
diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c
index b3b110e8a350..73615e3b3b58 100644
--- a/net/caif/cfvidl.c
+++ b/net/caif/cfvidl.c
@@ -29,7 +29,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
29 cfsrvl_init(vid, channel_id, dev_info, false); 29 cfsrvl_init(vid, channel_id, dev_info, false);
30 vid->layer.receive = cfvidl_receive; 30 vid->layer.receive = cfvidl_receive;
31 vid->layer.transmit = cfvidl_transmit; 31 vid->layer.transmit = cfvidl_transmit;
32 snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1"); 32 snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ, "vid1");
33 return &vid->layer; 33 return &vid->layer;
34} 34}
35 35
diff --git a/net/core/dev.c b/net/core/dev.c
index 108ac8137b9b..b6b8505cfb3e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8927,7 +8927,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
8927 8927
8928 refcnt = netdev_refcnt_read(dev); 8928 refcnt = netdev_refcnt_read(dev);
8929 8929
8930 if (time_after(jiffies, warning_time + 10 * HZ)) { 8930 if (refcnt && time_after(jiffies, warning_time + 10 * HZ)) {
8931 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n", 8931 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
8932 dev->name, refcnt); 8932 dev->name, refcnt);
8933 warning_time = jiffies; 8933 warning_time = jiffies;
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index c3a00eac4804..5ce7d47a960e 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -54,6 +54,13 @@ void flow_rule_match_vlan(const struct flow_rule *rule,
54} 54}
55EXPORT_SYMBOL(flow_rule_match_vlan); 55EXPORT_SYMBOL(flow_rule_match_vlan);
56 56
57void flow_rule_match_cvlan(const struct flow_rule *rule,
58 struct flow_match_vlan *out)
59{
60 FLOW_DISSECTOR_MATCH(rule, FLOW_DISSECTOR_KEY_CVLAN, out);
61}
62EXPORT_SYMBOL(flow_rule_match_cvlan);
63
57void flow_rule_match_ipv4_addrs(const struct flow_rule *rule, 64void flow_rule_match_ipv4_addrs(const struct flow_rule *rule,
58 struct flow_match_ipv4_addrs *out) 65 struct flow_match_ipv4_addrs *out)
59{ 66{
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2bd12afb9297..adcc045952c2 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1496,14 +1496,15 @@ static int put_master_ifindex(struct sk_buff *skb, struct net_device *dev)
1496 return ret; 1496 return ret;
1497} 1497}
1498 1498
1499static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev) 1499static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev,
1500 bool force)
1500{ 1501{
1501 int ifindex = dev_get_iflink(dev); 1502 int ifindex = dev_get_iflink(dev);
1502 1503
1503 if (dev->ifindex == ifindex) 1504 if (force || dev->ifindex != ifindex)
1504 return 0; 1505 return nla_put_u32(skb, IFLA_LINK, ifindex);
1505 1506
1506 return nla_put_u32(skb, IFLA_LINK, ifindex); 1507 return 0;
1507} 1508}
1508 1509
1509static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb, 1510static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb,
@@ -1520,6 +1521,8 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1520 const struct net_device *dev, 1521 const struct net_device *dev,
1521 struct net *src_net) 1522 struct net *src_net)
1522{ 1523{
1524 bool put_iflink = false;
1525
1523 if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) { 1526 if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) {
1524 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev); 1527 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev);
1525 1528
@@ -1528,10 +1531,12 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1528 1531
1529 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id)) 1532 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id))
1530 return -EMSGSIZE; 1533 return -EMSGSIZE;
1534
1535 put_iflink = true;
1531 } 1536 }
1532 } 1537 }
1533 1538
1534 return 0; 1539 return nla_put_iflink(skb, dev, put_iflink);
1535} 1540}
1536 1541
1537static int rtnl_fill_link_af(struct sk_buff *skb, 1542static int rtnl_fill_link_af(struct sk_buff *skb,
@@ -1617,7 +1622,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
1617#ifdef CONFIG_RPS 1622#ifdef CONFIG_RPS
1618 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || 1623 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
1619#endif 1624#endif
1620 nla_put_iflink(skb, dev) ||
1621 put_master_ifindex(skb, dev) || 1625 put_master_ifindex(skb, dev) ||
1622 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || 1626 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
1623 (dev->qdisc && 1627 (dev->qdisc &&
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index cc94d921476c..93bffaad2135 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -411,6 +411,7 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb)
411 sk_mem_charge(sk, skb->len); 411 sk_mem_charge(sk, skb->len);
412 copied = skb->len; 412 copied = skb->len;
413 msg->sg.start = 0; 413 msg->sg.start = 0;
414 msg->sg.size = copied;
414 msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge; 415 msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge;
415 msg->skb = skb; 416 msg->skb = skb;
416 417
@@ -554,8 +555,10 @@ static void sk_psock_destroy_deferred(struct work_struct *gc)
554 struct sk_psock *psock = container_of(gc, struct sk_psock, gc); 555 struct sk_psock *psock = container_of(gc, struct sk_psock, gc);
555 556
556 /* No sk_callback_lock since already detached. */ 557 /* No sk_callback_lock since already detached. */
557 strp_stop(&psock->parser.strp); 558
558 strp_done(&psock->parser.strp); 559 /* Parser has been stopped */
560 if (psock->progs.skb_parser)
561 strp_done(&psock->parser.strp);
559 562
560 cancel_work_sync(&psock->work); 563 cancel_work_sync(&psock->work);
561 564
diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c
index 15427163a041..0480918bfc7c 100644
--- a/net/ipv4/bpfilter/sockopt.c
+++ b/net/ipv4/bpfilter/sockopt.c
@@ -30,13 +30,11 @@ static int bpfilter_mbox_request(struct sock *sk, int optname,
30 mutex_lock(&bpfilter_ops.lock); 30 mutex_lock(&bpfilter_ops.lock);
31 if (!bpfilter_ops.sockopt) { 31 if (!bpfilter_ops.sockopt) {
32 mutex_unlock(&bpfilter_ops.lock); 32 mutex_unlock(&bpfilter_ops.lock);
33 err = request_module("bpfilter"); 33 request_module("bpfilter");
34 mutex_lock(&bpfilter_ops.lock); 34 mutex_lock(&bpfilter_ops.lock);
35 35
36 if (err)
37 goto out;
38 if (!bpfilter_ops.sockopt) { 36 if (!bpfilter_ops.sockopt) {
39 err = -ECHILD; 37 err = -ENOPROTOOPT;
40 goto out; 38 goto out;
41 } 39 }
42 } 40 }
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 7ccb5f87f70b..834be7daeb32 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1113,7 +1113,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1113 __u16 srcp = ntohs(inet->inet_sport); 1113 __u16 srcp = ntohs(inet->inet_sport);
1114 1114
1115 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 1115 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
1116 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", 1116 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
1117 bucket, src, srcp, dest, destp, sp->sk_state, 1117 bucket, src, srcp, dest, destp, sp->sk_state,
1118 sk_wmem_alloc_get(sp), 1118 sk_wmem_alloc_get(sp),
1119 sk_rmem_alloc_get(sp), 1119 sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index dc91c27bb788..0e482f07b37f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -1076,7 +1076,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
1076 srcp = inet->inet_num; 1076 srcp = inet->inet_num;
1077 1077
1078 seq_printf(seq, "%4d: %08X:%04X %08X:%04X" 1078 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
1079 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n", 1079 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
1080 i, src, srcp, dest, destp, sp->sk_state, 1080 i, src, srcp, dest, destp, sp->sk_state,
1081 sk_wmem_alloc_get(sp), 1081 sk_wmem_alloc_get(sp),
1082 sk_rmem_alloc_get(sp), 1082 sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1fa15beb8380..53d61ca3ac4b 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -855,7 +855,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
855 855
856 if (likely(!size)) { 856 if (likely(!size)) {
857 skb = sk->sk_tx_skb_cache; 857 skb = sk->sk_tx_skb_cache;
858 if (skb && !skb_cloned(skb)) { 858 if (skb) {
859 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); 859 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
860 sk->sk_tx_skb_cache = NULL; 860 sk->sk_tx_skb_cache = NULL;
861 pskb_trim(skb, 0); 861 pskb_trim(skb, 0);
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 1bb7321a256d..3d1e15401384 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -27,7 +27,10 @@ static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock,
27 int flags, long timeo, int *err) 27 int flags, long timeo, int *err)
28{ 28{
29 DEFINE_WAIT_FUNC(wait, woken_wake_function); 29 DEFINE_WAIT_FUNC(wait, woken_wake_function);
30 int ret; 30 int ret = 0;
31
32 if (!timeo)
33 return ret;
31 34
32 add_wait_queue(sk_sleep(sk), &wait); 35 add_wait_queue(sk_sleep(sk), &wait);
33 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 36 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
@@ -528,8 +531,6 @@ static void tcp_bpf_remove(struct sock *sk, struct sk_psock *psock)
528{ 531{
529 struct sk_psock_link *link; 532 struct sk_psock_link *link;
530 533
531 sk_psock_cork_free(psock);
532 __sk_psock_purge_ingress_msg(psock);
533 while ((link = sk_psock_link_pop(psock))) { 534 while ((link = sk_psock_link_pop(psock))) {
534 sk_psock_unlink(sk, link); 535 sk_psock_unlink(sk, link);
535 sk_psock_free_link(link); 536 sk_psock_free_link(link);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 20f6fac5882e..c61edd023b35 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6024,6 +6024,9 @@ reset_and_undo:
6024static void tcp_rcv_synrecv_state_fastopen(struct sock *sk) 6024static void tcp_rcv_synrecv_state_fastopen(struct sock *sk)
6025{ 6025{
6026 tcp_try_undo_loss(sk, false); 6026 tcp_try_undo_loss(sk, false);
6027
6028 /* Reset rtx states to prevent spurious retransmits_timed_out() */
6029 tcp_sk(sk)->retrans_stamp = 0;
6027 inet_csk(sk)->icsk_retransmits = 0; 6030 inet_csk(sk)->icsk_retransmits = 0;
6028 6031
6029 /* Once we leave TCP_SYN_RECV or TCP_FIN_WAIT_1, 6032 /* Once we leave TCP_SYN_RECV or TCP_FIN_WAIT_1,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 3c58ba02af7d..8fb250ed53d4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2883,7 +2883,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
2883 __u16 srcp = ntohs(inet->inet_sport); 2883 __u16 srcp = ntohs(inet->inet_sport);
2884 2884
2885 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 2885 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
2886 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", 2886 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
2887 bucket, src, srcp, dest, destp, sp->sk_state, 2887 bucket, src, srcp, dest, destp, sp->sk_state,
2888 sk_wmem_alloc_get(sp), 2888 sk_wmem_alloc_get(sp),
2889 udp_rqueue_get(sp), 2889 udp_rqueue_get(sp),
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index ee4a4e54d016..f07fb24f4ba1 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -1034,7 +1034,7 @@ void __ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
1034 src = &sp->sk_v6_rcv_saddr; 1034 src = &sp->sk_v6_rcv_saddr;
1035 seq_printf(seq, 1035 seq_printf(seq,
1036 "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " 1036 "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
1037 "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n", 1037 "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
1038 bucket, 1038 bucket,
1039 src->s6_addr32[0], src->s6_addr32[1], 1039 src->s6_addr32[0], src->s6_addr32[1],
1040 src->s6_addr32[2], src->s6_addr32[3], srcp, 1040 src->s6_addr32[2], src->s6_addr32[3], srcp,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 08e0390e001c..008421b550c6 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -904,6 +904,12 @@ static void fib6_drop_pcpu_from(struct fib6_info *f6i,
904{ 904{
905 int cpu; 905 int cpu;
906 906
907 /* Make sure rt6_make_pcpu_route() wont add other percpu routes
908 * while we are cleaning them here.
909 */
910 f6i->fib6_destroying = 1;
911 mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
912
907 /* release the reference to this fib entry from 913 /* release the reference to this fib entry from
908 * all of its cached pcpu routes 914 * all of its cached pcpu routes
909 */ 915 */
@@ -927,6 +933,9 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
927{ 933{
928 struct fib6_table *table = rt->fib6_table; 934 struct fib6_table *table = rt->fib6_table;
929 935
936 if (rt->rt6i_pcpu)
937 fib6_drop_pcpu_from(rt, table);
938
930 if (refcount_read(&rt->fib6_ref) != 1) { 939 if (refcount_read(&rt->fib6_ref) != 1) {
931 /* This route is used as dummy address holder in some split 940 /* This route is used as dummy address holder in some split
932 * nodes. It is not leaked, but it still holds other resources, 941 * nodes. It is not leaked, but it still holds other resources,
@@ -948,9 +957,6 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
948 fn = rcu_dereference_protected(fn->parent, 957 fn = rcu_dereference_protected(fn->parent,
949 lockdep_is_held(&table->tb6_lock)); 958 lockdep_is_held(&table->tb6_lock));
950 } 959 }
951
952 if (rt->rt6i_pcpu)
953 fib6_drop_pcpu_from(rt, table);
954 } 960 }
955} 961}
956 962
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 23a20d62daac..7a014ca877ed 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -111,8 +111,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
111 int iif, int type, u32 portid, u32 seq, 111 int iif, int type, u32 portid, u32 seq,
112 unsigned int flags); 112 unsigned int flags);
113static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res, 113static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
114 struct in6_addr *daddr, 114 const struct in6_addr *daddr,
115 struct in6_addr *saddr); 115 const struct in6_addr *saddr);
116 116
117#ifdef CONFIG_IPV6_ROUTE_INFO 117#ifdef CONFIG_IPV6_ROUTE_INFO
118static struct fib6_info *rt6_add_route_info(struct net *net, 118static struct fib6_info *rt6_add_route_info(struct net *net,
@@ -1295,6 +1295,13 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,
1295 prev = cmpxchg(p, NULL, pcpu_rt); 1295 prev = cmpxchg(p, NULL, pcpu_rt);
1296 BUG_ON(prev); 1296 BUG_ON(prev);
1297 1297
1298 if (res->f6i->fib6_destroying) {
1299 struct fib6_info *from;
1300
1301 from = xchg((__force struct fib6_info **)&pcpu_rt->from, NULL);
1302 fib6_info_release(from);
1303 }
1304
1298 return pcpu_rt; 1305 return pcpu_rt;
1299} 1306}
1300 1307
@@ -1566,31 +1573,44 @@ out:
1566 * Caller has to hold rcu_read_lock() 1573 * Caller has to hold rcu_read_lock()
1567 */ 1574 */
1568static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res, 1575static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
1569 struct in6_addr *daddr, 1576 const struct in6_addr *daddr,
1570 struct in6_addr *saddr) 1577 const struct in6_addr *saddr)
1571{ 1578{
1579 const struct in6_addr *src_key = NULL;
1572 struct rt6_exception_bucket *bucket; 1580 struct rt6_exception_bucket *bucket;
1573 struct in6_addr *src_key = NULL;
1574 struct rt6_exception *rt6_ex; 1581 struct rt6_exception *rt6_ex;
1575 struct rt6_info *ret = NULL; 1582 struct rt6_info *ret = NULL;
1576 1583
1577 bucket = rcu_dereference(res->f6i->rt6i_exception_bucket);
1578
1579#ifdef CONFIG_IPV6_SUBTREES 1584#ifdef CONFIG_IPV6_SUBTREES
1580 /* fib6i_src.plen != 0 indicates f6i is in subtree 1585 /* fib6i_src.plen != 0 indicates f6i is in subtree
1581 * and exception table is indexed by a hash of 1586 * and exception table is indexed by a hash of
1582 * both fib6_dst and fib6_src. 1587 * both fib6_dst and fib6_src.
1583 * Otherwise, the exception table is indexed by 1588 * However, the src addr used to create the hash
1584 * a hash of only fib6_dst. 1589 * might not be exactly the passed in saddr which
1590 * is a /128 addr from the flow.
1591 * So we need to use f6i->fib6_src to redo lookup
1592 * if the passed in saddr does not find anything.
1593 * (See the logic in ip6_rt_cache_alloc() on how
1594 * rt->rt6i_src is updated.)
1585 */ 1595 */
1586 if (res->f6i->fib6_src.plen) 1596 if (res->f6i->fib6_src.plen)
1587 src_key = saddr; 1597 src_key = saddr;
1598find_ex:
1588#endif 1599#endif
1600 bucket = rcu_dereference(res->f6i->rt6i_exception_bucket);
1589 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key); 1601 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
1590 1602
1591 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i)) 1603 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
1592 ret = rt6_ex->rt6i; 1604 ret = rt6_ex->rt6i;
1593 1605
1606#ifdef CONFIG_IPV6_SUBTREES
1607 /* Use fib6_src as src_key and redo lookup */
1608 if (!ret && src_key && src_key != &res->f6i->fib6_src.addr) {
1609 src_key = &res->f6i->fib6_src.addr;
1610 goto find_ex;
1611 }
1612#endif
1613
1594 return ret; 1614 return ret;
1595} 1615}
1596 1616
@@ -2665,12 +2685,10 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
2665 const struct in6_addr *daddr, 2685 const struct in6_addr *daddr,
2666 const struct in6_addr *saddr) 2686 const struct in6_addr *saddr)
2667{ 2687{
2668 struct rt6_exception_bucket *bucket;
2669 const struct fib6_nh *nh = res->nh; 2688 const struct fib6_nh *nh = res->nh;
2670 struct fib6_info *f6i = res->f6i; 2689 struct fib6_info *f6i = res->f6i;
2671 const struct in6_addr *src_key;
2672 struct rt6_exception *rt6_ex;
2673 struct inet6_dev *idev; 2690 struct inet6_dev *idev;
2691 struct rt6_info *rt;
2674 u32 mtu = 0; 2692 u32 mtu = 0;
2675 2693
2676 if (unlikely(fib6_metric_locked(f6i, RTAX_MTU))) { 2694 if (unlikely(fib6_metric_locked(f6i, RTAX_MTU))) {
@@ -2679,18 +2697,10 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
2679 goto out; 2697 goto out;
2680 } 2698 }
2681 2699
2682 src_key = NULL; 2700 rt = rt6_find_cached_rt(res, daddr, saddr);
2683#ifdef CONFIG_IPV6_SUBTREES 2701 if (unlikely(rt)) {
2684 if (f6i->fib6_src.plen) 2702 mtu = dst_metric_raw(&rt->dst, RTAX_MTU);
2685 src_key = saddr; 2703 } else {
2686#endif
2687
2688 bucket = rcu_dereference(f6i->rt6i_exception_bucket);
2689 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
2690 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
2691 mtu = dst_metric_raw(&rt6_ex->rt6i->dst, RTAX_MTU);
2692
2693 if (likely(!mtu)) {
2694 struct net_device *dev = nh->fib_nh_dev; 2704 struct net_device *dev = nh->fib_nh_dev;
2695 2705
2696 mtu = IPV6_MIN_MTU; 2706 mtu = IPV6_MIN_MTU;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 216ab915dd54..718a97d5f1fd 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2642,7 +2642,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
2642 struct sock *s = v; 2642 struct sock *s = v;
2643 struct netlink_sock *nlk = nlk_sk(s); 2643 struct netlink_sock *nlk = nlk_sk(s);
2644 2644
2645 seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d %-8lu\n", 2645 seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8u %-8lu\n",
2646 s, 2646 s,
2647 s->sk_protocol, 2647 s->sk_protocol,
2648 nlk->portid, 2648 nlk->portid,
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 30187990257f..2567af2fbd6f 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -607,7 +607,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
607 struct pn_sock *pn = pn_sk(sk); 607 struct pn_sock *pn = pn_sk(sk);
608 608
609 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu " 609 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu "
610 "%d %pK %d", 610 "%d %pK %u",
611 sk->sk_protocol, pn->sobject, pn->dobject, 611 sk->sk_protocol, pn->sobject, pn->dobject,
612 pn->resource, sk->sk_state, 612 pn->resource, sk->sk_state,
613 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk), 613 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
diff --git a/net/socket.c b/net/socket.c
index 472fbefa5d9b..72372dc5dd70 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -645,14 +645,6 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags)
645} 645}
646EXPORT_SYMBOL(__sock_tx_timestamp); 646EXPORT_SYMBOL(__sock_tx_timestamp);
647 647
648/**
649 * sock_sendmsg - send a message through @sock
650 * @sock: socket
651 * @msg: message to send
652 *
653 * Sends @msg through @sock, passing through LSM.
654 * Returns the number of bytes sent, or an error code.
655 */
656INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *, 648INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *,
657 size_t)); 649 size_t));
658static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) 650static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
@@ -663,6 +655,14 @@ static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
663 return ret; 655 return ret;
664} 656}
665 657
658/**
659 * sock_sendmsg - send a message through @sock
660 * @sock: socket
661 * @msg: message to send
662 *
663 * Sends @msg through @sock, passing through LSM.
664 * Returns the number of bytes sent, or an error code.
665 */
666int sock_sendmsg(struct socket *sock, struct msghdr *msg) 666int sock_sendmsg(struct socket *sock, struct msghdr *msg)
667{ 667{
668 int err = security_socket_sendmsg(sock, msg, 668 int err = security_socket_sendmsg(sock, msg,
@@ -875,15 +875,6 @@ void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
875} 875}
876EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops); 876EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops);
877 877
878/**
879 * sock_recvmsg - receive a message from @sock
880 * @sock: socket
881 * @msg: message to receive
882 * @flags: message flags
883 *
884 * Receives @msg from @sock, passing through LSM. Returns the total number
885 * of bytes received, or an error.
886 */
887INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *, 878INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *,
888 size_t , int )); 879 size_t , int ));
889static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, 880static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
@@ -893,6 +884,15 @@ static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
893 msg_data_left(msg), flags); 884 msg_data_left(msg), flags);
894} 885}
895 886
887/**
888 * sock_recvmsg - receive a message from @sock
889 * @sock: socket
890 * @msg: message to receive
891 * @flags: message flags
892 *
893 * Receives @msg from @sock, passing through LSM. Returns the total number
894 * of bytes received, or an error.
895 */
896int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) 896int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags)
897{ 897{
898 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags); 898 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 27cccd101ef6..ddd2e0f67c07 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -131,10 +131,6 @@ static int __init tipc_init(void)
131 if (err) 131 if (err)
132 goto out_netlink_compat; 132 goto out_netlink_compat;
133 133
134 err = tipc_socket_init();
135 if (err)
136 goto out_socket;
137
138 err = tipc_register_sysctl(); 134 err = tipc_register_sysctl();
139 if (err) 135 if (err)
140 goto out_sysctl; 136 goto out_sysctl;
@@ -143,6 +139,10 @@ static int __init tipc_init(void)
143 if (err) 139 if (err)
144 goto out_pernet; 140 goto out_pernet;
145 141
142 err = tipc_socket_init();
143 if (err)
144 goto out_socket;
145
146 err = tipc_bearer_setup(); 146 err = tipc_bearer_setup();
147 if (err) 147 if (err)
148 goto out_bearer; 148 goto out_bearer;
@@ -150,12 +150,12 @@ static int __init tipc_init(void)
150 pr_info("Started in single node mode\n"); 150 pr_info("Started in single node mode\n");
151 return 0; 151 return 0;
152out_bearer: 152out_bearer:
153 tipc_socket_stop();
154out_socket:
153 unregister_pernet_subsys(&tipc_net_ops); 155 unregister_pernet_subsys(&tipc_net_ops);
154out_pernet: 156out_pernet:
155 tipc_unregister_sysctl(); 157 tipc_unregister_sysctl();
156out_sysctl: 158out_sysctl:
157 tipc_socket_stop();
158out_socket:
159 tipc_netlink_compat_stop(); 159 tipc_netlink_compat_stop();
160out_netlink_compat: 160out_netlink_compat:
161 tipc_netlink_stop(); 161 tipc_netlink_stop();
@@ -167,10 +167,10 @@ out_netlink:
167static void __exit tipc_exit(void) 167static void __exit tipc_exit(void)
168{ 168{
169 tipc_bearer_cleanup(); 169 tipc_bearer_cleanup();
170 tipc_socket_stop();
170 unregister_pernet_subsys(&tipc_net_ops); 171 unregister_pernet_subsys(&tipc_net_ops);
171 tipc_netlink_stop(); 172 tipc_netlink_stop();
172 tipc_netlink_compat_stop(); 173 tipc_netlink_compat_stop();
173 tipc_socket_stop();
174 tipc_unregister_sysctl(); 174 tipc_unregister_sysctl();
175 175
176 pr_info("Deactivated\n"); 176 pr_info("Deactivated\n");
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index a827547aa102..982a8dc49e03 100644
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -35,6 +35,9 @@
35/* The MTU is 16KB per the host side's design */ 35/* The MTU is 16KB per the host side's design */
36#define HVS_MTU_SIZE (1024 * 16) 36#define HVS_MTU_SIZE (1024 * 16)
37 37
38/* How long to wait for graceful shutdown of a connection */
39#define HVS_CLOSE_TIMEOUT (8 * HZ)
40
38struct vmpipe_proto_header { 41struct vmpipe_proto_header {
39 u32 pkt_type; 42 u32 pkt_type;
40 u32 data_size; 43 u32 data_size;
@@ -305,19 +308,32 @@ static void hvs_channel_cb(void *ctx)
305 sk->sk_write_space(sk); 308 sk->sk_write_space(sk);
306} 309}
307 310
308static void hvs_close_connection(struct vmbus_channel *chan) 311static void hvs_do_close_lock_held(struct vsock_sock *vsk,
312 bool cancel_timeout)
309{ 313{
310 struct sock *sk = get_per_channel_state(chan); 314 struct sock *sk = sk_vsock(vsk);
311 struct vsock_sock *vsk = vsock_sk(sk);
312
313 lock_sock(sk);
314 315
315 sk->sk_state = TCP_CLOSE;
316 sock_set_flag(sk, SOCK_DONE); 316 sock_set_flag(sk, SOCK_DONE);
317 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN; 317 vsk->peer_shutdown = SHUTDOWN_MASK;
318 318 if (vsock_stream_has_data(vsk) <= 0)
319 sk->sk_state = TCP_CLOSING;
319 sk->sk_state_change(sk); 320 sk->sk_state_change(sk);
321 if (vsk->close_work_scheduled &&
322 (!cancel_timeout || cancel_delayed_work(&vsk->close_work))) {
323 vsk->close_work_scheduled = false;
324 vsock_remove_sock(vsk);
320 325
326 /* Release the reference taken while scheduling the timeout */
327 sock_put(sk);
328 }
329}
330
331static void hvs_close_connection(struct vmbus_channel *chan)
332{
333 struct sock *sk = get_per_channel_state(chan);
334
335 lock_sock(sk);
336 hvs_do_close_lock_held(vsock_sk(sk), true);
321 release_sock(sk); 337 release_sock(sk);
322} 338}
323 339
@@ -452,50 +468,80 @@ static int hvs_connect(struct vsock_sock *vsk)
452 return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id); 468 return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id);
453} 469}
454 470
471static void hvs_shutdown_lock_held(struct hvsock *hvs, int mode)
472{
473 struct vmpipe_proto_header hdr;
474
475 if (hvs->fin_sent || !hvs->chan)
476 return;
477
478 /* It can't fail: see hvs_channel_writable_bytes(). */
479 (void)hvs_send_data(hvs->chan, (struct hvs_send_buf *)&hdr, 0);
480 hvs->fin_sent = true;
481}
482
455static int hvs_shutdown(struct vsock_sock *vsk, int mode) 483static int hvs_shutdown(struct vsock_sock *vsk, int mode)
456{ 484{
457 struct sock *sk = sk_vsock(vsk); 485 struct sock *sk = sk_vsock(vsk);
458 struct vmpipe_proto_header hdr;
459 struct hvs_send_buf *send_buf;
460 struct hvsock *hvs;
461 486
462 if (!(mode & SEND_SHUTDOWN)) 487 if (!(mode & SEND_SHUTDOWN))
463 return 0; 488 return 0;
464 489
465 lock_sock(sk); 490 lock_sock(sk);
491 hvs_shutdown_lock_held(vsk->trans, mode);
492 release_sock(sk);
493 return 0;
494}
466 495
467 hvs = vsk->trans; 496static void hvs_close_timeout(struct work_struct *work)
468 if (hvs->fin_sent) 497{
469 goto out; 498 struct vsock_sock *vsk =
470 499 container_of(work, struct vsock_sock, close_work.work);
471 send_buf = (struct hvs_send_buf *)&hdr; 500 struct sock *sk = sk_vsock(vsk);
472 501
473 /* It can't fail: see hvs_channel_writable_bytes(). */ 502 sock_hold(sk);
474 (void)hvs_send_data(hvs->chan, send_buf, 0); 503 lock_sock(sk);
504 if (!sock_flag(sk, SOCK_DONE))
505 hvs_do_close_lock_held(vsk, false);
475 506
476 hvs->fin_sent = true; 507 vsk->close_work_scheduled = false;
477out:
478 release_sock(sk); 508 release_sock(sk);
479 return 0; 509 sock_put(sk);
480} 510}
481 511
482static void hvs_release(struct vsock_sock *vsk) 512/* Returns true, if it is safe to remove socket; false otherwise */
513static bool hvs_close_lock_held(struct vsock_sock *vsk)
483{ 514{
484 struct sock *sk = sk_vsock(vsk); 515 struct sock *sk = sk_vsock(vsk);
485 struct hvsock *hvs = vsk->trans;
486 struct vmbus_channel *chan;
487 516
488 lock_sock(sk); 517 if (!(sk->sk_state == TCP_ESTABLISHED ||
518 sk->sk_state == TCP_CLOSING))
519 return true;
489 520
490 sk->sk_state = TCP_CLOSING; 521 if ((sk->sk_shutdown & SHUTDOWN_MASK) != SHUTDOWN_MASK)
491 vsock_remove_sock(vsk); 522 hvs_shutdown_lock_held(vsk->trans, SHUTDOWN_MASK);
492 523
493 release_sock(sk); 524 if (sock_flag(sk, SOCK_DONE))
525 return true;
494 526
495 chan = hvs->chan; 527 /* This reference will be dropped by the delayed close routine */
496 if (chan) 528 sock_hold(sk);
497 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN); 529 INIT_DELAYED_WORK(&vsk->close_work, hvs_close_timeout);
530 vsk->close_work_scheduled = true;
531 schedule_delayed_work(&vsk->close_work, HVS_CLOSE_TIMEOUT);
532 return false;
533}
498 534
535static void hvs_release(struct vsock_sock *vsk)
536{
537 struct sock *sk = sk_vsock(vsk);
538 bool remove_sock;
539
540 lock_sock(sk);
541 remove_sock = hvs_close_lock_held(vsk);
542 release_sock(sk);
543 if (remove_sock)
544 vsock_remove_sock(vsk);
499} 545}
500 546
501static void hvs_destruct(struct vsock_sock *vsk) 547static void hvs_destruct(struct vsock_sock *vsk)
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 15eb5d3d4750..96ab344f17bb 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -702,28 +702,27 @@ static int __init virtio_vsock_init(void)
702 if (!virtio_vsock_workqueue) 702 if (!virtio_vsock_workqueue)
703 return -ENOMEM; 703 return -ENOMEM;
704 704
705 ret = register_virtio_driver(&virtio_vsock_driver); 705 ret = vsock_core_init(&virtio_transport.transport);
706 if (ret) 706 if (ret)
707 goto out_wq; 707 goto out_wq;
708 708
709 ret = vsock_core_init(&virtio_transport.transport); 709 ret = register_virtio_driver(&virtio_vsock_driver);
710 if (ret) 710 if (ret)
711 goto out_vdr; 711 goto out_vci;
712 712
713 return 0; 713 return 0;
714 714
715out_vdr: 715out_vci:
716 unregister_virtio_driver(&virtio_vsock_driver); 716 vsock_core_exit();
717out_wq: 717out_wq:
718 destroy_workqueue(virtio_vsock_workqueue); 718 destroy_workqueue(virtio_vsock_workqueue);
719 return ret; 719 return ret;
720
721} 720}
722 721
723static void __exit virtio_vsock_exit(void) 722static void __exit virtio_vsock_exit(void)
724{ 723{
725 vsock_core_exit();
726 unregister_virtio_driver(&virtio_vsock_driver); 724 unregister_virtio_driver(&virtio_vsock_driver);
725 vsock_core_exit();
727 destroy_workqueue(virtio_vsock_workqueue); 726 destroy_workqueue(virtio_vsock_workqueue);
728} 727}
729 728
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 602715fc9a75..f3f3d06cb6d8 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -786,12 +786,19 @@ static bool virtio_transport_close(struct vsock_sock *vsk)
786 786
787void virtio_transport_release(struct vsock_sock *vsk) 787void virtio_transport_release(struct vsock_sock *vsk)
788{ 788{
789 struct virtio_vsock_sock *vvs = vsk->trans;
790 struct virtio_vsock_pkt *pkt, *tmp;
789 struct sock *sk = &vsk->sk; 791 struct sock *sk = &vsk->sk;
790 bool remove_sock = true; 792 bool remove_sock = true;
791 793
792 lock_sock(sk); 794 lock_sock(sk);
793 if (sk->sk_type == SOCK_STREAM) 795 if (sk->sk_type == SOCK_STREAM)
794 remove_sock = virtio_transport_close(vsk); 796 remove_sock = virtio_transport_close(vsk);
797
798 list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) {
799 list_del(&pkt->list);
800 virtio_transport_free_pkt(pkt);
801 }
795 release_sock(sk); 802 release_sock(sk);
796 803
797 if (remove_sock) 804 if (remove_sock)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 410233c5681e..7a43ae6b2a44 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3264,7 +3264,8 @@ static void
3264decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse) 3264decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3265{ 3265{
3266 const struct iphdr *iph = ip_hdr(skb); 3266 const struct iphdr *iph = ip_hdr(skb);
3267 u8 *xprth = skb_network_header(skb) + iph->ihl * 4; 3267 int ihl = iph->ihl;
3268 u8 *xprth = skb_network_header(skb) + ihl * 4;
3268 struct flowi4 *fl4 = &fl->u.ip4; 3269 struct flowi4 *fl4 = &fl->u.ip4;
3269 int oif = 0; 3270 int oif = 0;
3270 3271
@@ -3275,6 +3276,11 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3275 fl4->flowi4_mark = skb->mark; 3276 fl4->flowi4_mark = skb->mark;
3276 fl4->flowi4_oif = reverse ? skb->skb_iif : oif; 3277 fl4->flowi4_oif = reverse ? skb->skb_iif : oif;
3277 3278
3279 fl4->flowi4_proto = iph->protocol;
3280 fl4->daddr = reverse ? iph->saddr : iph->daddr;
3281 fl4->saddr = reverse ? iph->daddr : iph->saddr;
3282 fl4->flowi4_tos = iph->tos;
3283
3278 if (!ip_is_fragment(iph)) { 3284 if (!ip_is_fragment(iph)) {
3279 switch (iph->protocol) { 3285 switch (iph->protocol) {
3280 case IPPROTO_UDP: 3286 case IPPROTO_UDP:
@@ -3286,7 +3292,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3286 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3292 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3287 __be16 *ports; 3293 __be16 *ports;
3288 3294
3289 xprth = skb_network_header(skb) + iph->ihl * 4; 3295 xprth = skb_network_header(skb) + ihl * 4;
3290 ports = (__be16 *)xprth; 3296 ports = (__be16 *)xprth;
3291 3297
3292 fl4->fl4_sport = ports[!!reverse]; 3298 fl4->fl4_sport = ports[!!reverse];
@@ -3298,7 +3304,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3298 pskb_may_pull(skb, xprth + 2 - skb->data)) { 3304 pskb_may_pull(skb, xprth + 2 - skb->data)) {
3299 u8 *icmp; 3305 u8 *icmp;
3300 3306
3301 xprth = skb_network_header(skb) + iph->ihl * 4; 3307 xprth = skb_network_header(skb) + ihl * 4;
3302 icmp = xprth; 3308 icmp = xprth;
3303 3309
3304 fl4->fl4_icmp_type = icmp[0]; 3310 fl4->fl4_icmp_type = icmp[0];
@@ -3310,7 +3316,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3310 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3316 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3311 __be32 *ehdr; 3317 __be32 *ehdr;
3312 3318
3313 xprth = skb_network_header(skb) + iph->ihl * 4; 3319 xprth = skb_network_header(skb) + ihl * 4;
3314 ehdr = (__be32 *)xprth; 3320 ehdr = (__be32 *)xprth;
3315 3321
3316 fl4->fl4_ipsec_spi = ehdr[0]; 3322 fl4->fl4_ipsec_spi = ehdr[0];
@@ -3321,7 +3327,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3321 pskb_may_pull(skb, xprth + 8 - skb->data)) { 3327 pskb_may_pull(skb, xprth + 8 - skb->data)) {
3322 __be32 *ah_hdr; 3328 __be32 *ah_hdr;
3323 3329
3324 xprth = skb_network_header(skb) + iph->ihl * 4; 3330 xprth = skb_network_header(skb) + ihl * 4;
3325 ah_hdr = (__be32 *)xprth; 3331 ah_hdr = (__be32 *)xprth;
3326 3332
3327 fl4->fl4_ipsec_spi = ah_hdr[1]; 3333 fl4->fl4_ipsec_spi = ah_hdr[1];
@@ -3332,7 +3338,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3332 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3338 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3333 __be16 *ipcomp_hdr; 3339 __be16 *ipcomp_hdr;
3334 3340
3335 xprth = skb_network_header(skb) + iph->ihl * 4; 3341 xprth = skb_network_header(skb) + ihl * 4;
3336 ipcomp_hdr = (__be16 *)xprth; 3342 ipcomp_hdr = (__be16 *)xprth;
3337 3343
3338 fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1])); 3344 fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
@@ -3344,7 +3350,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3344 __be16 *greflags; 3350 __be16 *greflags;
3345 __be32 *gre_hdr; 3351 __be32 *gre_hdr;
3346 3352
3347 xprth = skb_network_header(skb) + iph->ihl * 4; 3353 xprth = skb_network_header(skb) + ihl * 4;
3348 greflags = (__be16 *)xprth; 3354 greflags = (__be16 *)xprth;
3349 gre_hdr = (__be32 *)xprth; 3355 gre_hdr = (__be32 *)xprth;
3350 3356
@@ -3360,10 +3366,6 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3360 break; 3366 break;
3361 } 3367 }
3362 } 3368 }
3363 fl4->flowi4_proto = iph->protocol;
3364 fl4->daddr = reverse ? iph->saddr : iph->daddr;
3365 fl4->saddr = reverse ? iph->daddr : iph->saddr;
3366 fl4->flowi4_tos = iph->tos;
3367} 3369}
3368 3370
3369#if IS_ENABLED(CONFIG_IPV6) 3371#if IS_ENABLED(CONFIG_IPV6)
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index 58a2cd002a4b..7317438ecd9e 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -208,8 +208,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
208 break; 208 break;
209 } 209 }
210 case BTF_KIND_FWD: { 210 case BTF_KIND_FWD: {
211 const char *fwd_kind = BTF_INFO_KIND(t->info) ? "union" 211 const char *fwd_kind = BTF_INFO_KFLAG(t->info) ? "union"
212 : "struct"; 212 : "struct";
213 213
214 if (json_output) 214 if (json_output)
215 jsonw_string_field(w, "fwd_kind", fwd_kind); 215 jsonw_string_field(w, "fwd_kind", fwd_kind);
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index fc495b27f0fc..26336bad0442 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -879,6 +879,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
879 } 879 }
880 } 880 }
881 881
882 set_max_rlimit();
883
882 obj = __bpf_object__open_xattr(&attr, bpf_flags); 884 obj = __bpf_object__open_xattr(&attr, bpf_flags);
883 if (IS_ERR_OR_NULL(obj)) { 885 if (IS_ERR_OR_NULL(obj)) {
884 p_err("failed to open object file"); 886 p_err("failed to open object file");
@@ -958,8 +960,6 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
958 goto err_close_obj; 960 goto err_close_obj;
959 } 961 }
960 962
961 set_max_rlimit();
962
963 err = bpf_object__load(obj); 963 err = bpf_object__load(obj);
964 if (err) { 964 if (err) {
965 p_err("failed to load object file"); 965 p_err("failed to load object file");
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h
index 9310652ca4f9..63ae4a39e58b 100644
--- a/tools/include/uapi/linux/btf.h
+++ b/tools/include/uapi/linux/btf.h
@@ -83,7 +83,7 @@ struct btf_type {
83 * is the 32 bits arrangement: 83 * is the 32 bits arrangement:
84 */ 84 */
85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 85#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
86#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 86#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16)
87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) 87#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
88 88
89/* Attributes stored in the BTF_INT_ENCODING */ 89/* Attributes stored in the BTF_INT_ENCODING */
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 75eaf10b9e1a..03348c4d6bd4 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -11,7 +11,7 @@
11#include "btf.h" 11#include "btf.h"
12#include "bpf.h" 12#include "bpf.h"
13#include "libbpf.h" 13#include "libbpf.h"
14#include "libbpf_util.h" 14#include "libbpf_internal.h"
15 15
16#define max(a, b) ((a) > (b) ? (a) : (b)) 16#define max(a, b) ((a) > (b) ? (a) : (b))
17#define min(a, b) ((a) < (b) ? (a) : (b)) 17#define min(a, b) ((a) < (b) ? (a) : (b))
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 7e3b79d7c25f..197b574406b3 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -43,7 +43,6 @@
43#include "bpf.h" 43#include "bpf.h"
44#include "btf.h" 44#include "btf.h"
45#include "str_error.h" 45#include "str_error.h"
46#include "libbpf_util.h"
47#include "libbpf_internal.h" 46#include "libbpf_internal.h"
48 47
49#ifndef EM_BPF 48#ifndef EM_BPF
@@ -1696,7 +1695,7 @@ bpf_object__probe_caps(struct bpf_object *obj)
1696 for (i = 0; i < ARRAY_SIZE(probe_fn); i++) { 1695 for (i = 0; i < ARRAY_SIZE(probe_fn); i++) {
1697 ret = probe_fn[i](obj); 1696 ret = probe_fn[i](obj);
1698 if (ret < 0) 1697 if (ret < 0)
1699 return ret; 1698 pr_debug("Probe #%d failed with %d.\n", i, ret);
1700 } 1699 }
1701 1700
1702 return 0; 1701 return 0;
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index 789e435b5900..f3025b4d90e1 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -21,6 +21,19 @@
21#define BTF_PARAM_ENC(name, type) (name), (type) 21#define BTF_PARAM_ENC(name, type) (name), (type)
22#define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size) 22#define BTF_VAR_SECINFO_ENC(type, offset, size) (type), (offset), (size)
23 23
24extern void libbpf_print(enum libbpf_print_level level,
25 const char *format, ...)
26 __attribute__((format(printf, 2, 3)));
27
28#define __pr(level, fmt, ...) \
29do { \
30 libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
31} while (0)
32
33#define pr_warning(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
34#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
35#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
36
24int libbpf__probe_raw_btf(const char *raw_types, size_t types_len, 37int libbpf__probe_raw_btf(const char *raw_types, size_t types_len,
25 const char *str_sec, size_t str_len); 38 const char *str_sec, size_t str_len);
26 39
diff --git a/tools/lib/bpf/libbpf_util.h b/tools/lib/bpf/libbpf_util.h
index da94c4cb2e4d..59c779c5790c 100644
--- a/tools/lib/bpf/libbpf_util.h
+++ b/tools/lib/bpf/libbpf_util.h
@@ -10,19 +10,6 @@
10extern "C" { 10extern "C" {
11#endif 11#endif
12 12
13extern void libbpf_print(enum libbpf_print_level level,
14 const char *format, ...)
15 __attribute__((format(printf, 2, 3)));
16
17#define __pr(level, fmt, ...) \
18do { \
19 libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
20} while (0)
21
22#define pr_warning(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
23#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
24#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
25
26/* Use these barrier functions instead of smp_[rw]mb() when they are 13/* Use these barrier functions instead of smp_[rw]mb() when they are
27 * used in a libbpf header file. That way they can be built into the 14 * used in a libbpf header file. That way they can be built into the
28 * application that uses libbpf. 15 * application that uses libbpf.
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index a3d1a302bc9c..38667b62f1fe 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -29,7 +29,7 @@
29 29
30#include "bpf.h" 30#include "bpf.h"
31#include "libbpf.h" 31#include "libbpf.h"
32#include "libbpf_util.h" 32#include "libbpf_internal.h"
33#include "xsk.h" 33#include "xsk.h"
34 34
35#ifndef SOL_XDP 35#ifndef SOL_XDP
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore
index a877803e4ba8..dd5d69529382 100644
--- a/tools/testing/selftests/bpf/.gitignore
+++ b/tools/testing/selftests/bpf/.gitignore
@@ -31,6 +31,7 @@ test_section_names
31test_tcpnotify_user 31test_tcpnotify_user
32test_libbpf 32test_libbpf
33test_tcp_check_syncookie_user 33test_tcp_check_syncookie_user
34test_sysctl
34alu32 35alu32
35libbpf.pc 36libbpf.pc
36libbpf.so.* 37libbpf.so.*
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
index 6e80b66d7fb1..5f6f9e7aba2a 100644
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -278,7 +278,7 @@ static int (*bpf_skb_change_type)(void *ctx, __u32 type) =
278 (void *) BPF_FUNC_skb_change_type; 278 (void *) BPF_FUNC_skb_change_type;
279static unsigned int (*bpf_get_hash_recalc)(void *ctx) = 279static unsigned int (*bpf_get_hash_recalc)(void *ctx) =
280 (void *) BPF_FUNC_get_hash_recalc; 280 (void *) BPF_FUNC_get_hash_recalc;
281static unsigned long long (*bpf_get_current_task)(void *ctx) = 281static unsigned long long (*bpf_get_current_task)(void) =
282 (void *) BPF_FUNC_get_current_task; 282 (void *) BPF_FUNC_get_current_task;
283static int (*bpf_skb_change_tail)(void *ctx, __u32 len, __u64 flags) = 283static int (*bpf_skb_change_tail)(void *ctx, __u32 len, __u64 flags) =
284 (void *) BPF_FUNC_skb_change_tail; 284 (void *) BPF_FUNC_skb_change_tail;
diff --git a/tools/testing/selftests/bpf/map_tests/.gitignore b/tools/testing/selftests/bpf/map_tests/.gitignore
new file mode 100644
index 000000000000..45984a364647
--- /dev/null
+++ b/tools/testing/selftests/bpf/map_tests/.gitignore
@@ -0,0 +1 @@
tests.h
diff --git a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
index 8b54adfd6264..fbd1d88a6095 100644
--- a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
+++ b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
@@ -242,12 +242,12 @@ void test_flow_dissector(void)
242 */ 242 */
243 243
244 err = bpf_prog_attach(prog_fd, 0, BPF_FLOW_DISSECTOR, 0); 244 err = bpf_prog_attach(prog_fd, 0, BPF_FLOW_DISSECTOR, 0);
245 CHECK(err, "bpf_prog_attach", "err %d errno %d", err, errno); 245 CHECK(err, "bpf_prog_attach", "err %d errno %d\n", err, errno);
246 246
247 tap_fd = create_tap("tap0"); 247 tap_fd = create_tap("tap0");
248 CHECK(tap_fd < 0, "create_tap", "tap_fd %d errno %d", tap_fd, errno); 248 CHECK(tap_fd < 0, "create_tap", "tap_fd %d errno %d\n", tap_fd, errno);
249 err = ifup("tap0"); 249 err = ifup("tap0");
250 CHECK(err, "ifup", "err %d errno %d", err, errno); 250 CHECK(err, "ifup", "err %d errno %d\n", err, errno);
251 251
252 for (i = 0; i < ARRAY_SIZE(tests); i++) { 252 for (i = 0; i < ARRAY_SIZE(tests); i++) {
253 struct bpf_flow_keys flow_keys = {}; 253 struct bpf_flow_keys flow_keys = {};
@@ -255,7 +255,7 @@ void test_flow_dissector(void)
255 __u32 key = 0; 255 __u32 key = 0;
256 256
257 err = tx_tap(tap_fd, &tests[i].pkt, sizeof(tests[i].pkt)); 257 err = tx_tap(tap_fd, &tests[i].pkt, sizeof(tests[i].pkt));
258 CHECK(err < 0, "tx_tap", "err %d errno %d", err, errno); 258 CHECK(err < 0, "tx_tap", "err %d errno %d\n", err, errno);
259 259
260 err = bpf_map_lookup_elem(keys_fd, &key, &flow_keys); 260 err = bpf_map_lookup_elem(keys_fd, &key, &flow_keys);
261 CHECK_ATTR(err, tests[i].name, "bpf_map_lookup_elem %d\n", err); 261 CHECK_ATTR(err, tests[i].name, "bpf_map_lookup_elem %d\n", err);
@@ -264,5 +264,6 @@ void test_flow_dissector(void)
264 CHECK_FLOW_KEYS(tests[i].name, flow_keys, tests[i].keys); 264 CHECK_FLOW_KEYS(tests[i].name, flow_keys, tests[i].keys);
265 } 265 }
266 266
267 bpf_prog_detach(prog_fd, BPF_FLOW_DISSECTOR);
267 bpf_object__close(obj); 268 bpf_object__close(obj);
268} 269}
diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c
index 781c7de343be..1b25a7e348dc 100644
--- a/tools/testing/selftests/bpf/test_lru_map.c
+++ b/tools/testing/selftests/bpf/test_lru_map.c
@@ -18,9 +18,11 @@
18#include <sys/wait.h> 18#include <sys/wait.h>
19 19
20#include <bpf/bpf.h> 20#include <bpf/bpf.h>
21#include <bpf/libbpf.h>
21 22
22#include "bpf_util.h" 23#include "bpf_util.h"
23#include "bpf_rlimit.h" 24#include "bpf_rlimit.h"
25#include "../../../include/linux/filter.h"
24 26
25#define LOCAL_FREE_TARGET (128) 27#define LOCAL_FREE_TARGET (128)
26#define PERCPU_FREE_TARGET (4) 28#define PERCPU_FREE_TARGET (4)
@@ -40,6 +42,68 @@ static int create_map(int map_type, int map_flags, unsigned int size)
40 return map_fd; 42 return map_fd;
41} 43}
42 44
45static int bpf_map_lookup_elem_with_ref_bit(int fd, unsigned long long key,
46 void *value)
47{
48 struct bpf_load_program_attr prog;
49 struct bpf_create_map_attr map;
50 struct bpf_insn insns[] = {
51 BPF_LD_MAP_VALUE(BPF_REG_9, 0, 0),
52 BPF_LD_MAP_FD(BPF_REG_1, fd),
53 BPF_LD_IMM64(BPF_REG_3, key),
54 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
55 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
56 BPF_STX_MEM(BPF_DW, BPF_REG_2, BPF_REG_3, 0),
57 BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
58 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
59 BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 0),
60 BPF_STX_MEM(BPF_DW, BPF_REG_9, BPF_REG_1, 0),
61 BPF_MOV64_IMM(BPF_REG_0, 42),
62 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
63 BPF_MOV64_IMM(BPF_REG_0, 1),
64 BPF_EXIT_INSN(),
65 };
66 __u8 data[64] = {};
67 int mfd, pfd, ret, zero = 0;
68 __u32 retval = 0;
69
70 memset(&map, 0, sizeof(map));
71 map.map_type = BPF_MAP_TYPE_ARRAY;
72 map.key_size = sizeof(int);
73 map.value_size = sizeof(unsigned long long);
74 map.max_entries = 1;
75
76 mfd = bpf_create_map_xattr(&map);
77 if (mfd < 0)
78 return -1;
79
80 insns[0].imm = mfd;
81
82 memset(&prog, 0, sizeof(prog));
83 prog.prog_type = BPF_PROG_TYPE_SCHED_CLS;
84 prog.insns = insns;
85 prog.insns_cnt = ARRAY_SIZE(insns);
86 prog.license = "GPL";
87
88 pfd = bpf_load_program_xattr(&prog, NULL, 0);
89 if (pfd < 0) {
90 close(mfd);
91 return -1;
92 }
93
94 ret = bpf_prog_test_run(pfd, 1, data, sizeof(data),
95 NULL, NULL, &retval, NULL);
96 if (ret < 0 || retval != 42) {
97 ret = -1;
98 } else {
99 assert(!bpf_map_lookup_elem(mfd, &zero, value));
100 ret = 0;
101 }
102 close(pfd);
103 close(mfd);
104 return ret;
105}
106
43static int map_subset(int map0, int map1) 107static int map_subset(int map0, int map1)
44{ 108{
45 unsigned long long next_key = 0; 109 unsigned long long next_key = 0;
@@ -87,7 +151,7 @@ static int sched_next_online(int pid, int *next_to_try)
87 return ret; 151 return ret;
88} 152}
89 153
90/* Size of the LRU amp is 2 154/* Size of the LRU map is 2
91 * Add key=1 (+1 key) 155 * Add key=1 (+1 key)
92 * Add key=2 (+1 key) 156 * Add key=2 (+1 key)
93 * Lookup Key=1 157 * Lookup Key=1
@@ -157,7 +221,7 @@ static void test_lru_sanity0(int map_type, int map_flags)
157 * stop LRU from removing key=1 221 * stop LRU from removing key=1
158 */ 222 */
159 key = 1; 223 key = 1;
160 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 224 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
161 assert(value[0] == 1234); 225 assert(value[0] == 1234);
162 226
163 key = 3; 227 key = 3;
@@ -167,7 +231,8 @@ static void test_lru_sanity0(int map_type, int map_flags)
167 231
168 /* key=2 has been removed from the LRU */ 232 /* key=2 has been removed from the LRU */
169 key = 2; 233 key = 2;
170 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1); 234 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
235 errno == ENOENT);
171 236
172 assert(map_equal(lru_map_fd, expected_map_fd)); 237 assert(map_equal(lru_map_fd, expected_map_fd));
173 238
@@ -221,7 +286,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
221 /* Lookup 1 to tgt_free/2 */ 286 /* Lookup 1 to tgt_free/2 */
222 end_key = 1 + batch_size; 287 end_key = 1 + batch_size;
223 for (key = 1; key < end_key; key++) { 288 for (key = 1; key < end_key; key++) {
224 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 289 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
225 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 290 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
226 BPF_NOEXIST)); 291 BPF_NOEXIST));
227 } 292 }
@@ -322,10 +387,11 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
322 end_key = 1 + batch_size; 387 end_key = 1 + batch_size;
323 value[0] = 4321; 388 value[0] = 4321;
324 for (key = 1; key < end_key; key++) { 389 for (key = 1; key < end_key; key++) {
325 assert(bpf_map_lookup_elem(lru_map_fd, &key, value)); 390 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
391 errno == ENOENT);
326 assert(!bpf_map_update_elem(lru_map_fd, &key, value, 392 assert(!bpf_map_update_elem(lru_map_fd, &key, value,
327 BPF_NOEXIST)); 393 BPF_NOEXIST));
328 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 394 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
329 assert(value[0] == 4321); 395 assert(value[0] == 4321);
330 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 396 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
331 BPF_NOEXIST)); 397 BPF_NOEXIST));
@@ -404,7 +470,7 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
404 /* Lookup key 1 to tgt_free*3/2 */ 470 /* Lookup key 1 to tgt_free*3/2 */
405 end_key = tgt_free + batch_size; 471 end_key = tgt_free + batch_size;
406 for (key = 1; key < end_key; key++) { 472 for (key = 1; key < end_key; key++) {
407 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 473 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
408 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 474 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
409 BPF_NOEXIST)); 475 BPF_NOEXIST));
410 } 476 }
@@ -463,7 +529,7 @@ static void test_lru_sanity4(int map_type, int map_flags, unsigned int tgt_free)
463 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST)); 529 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
464 530
465 for (key = 1; key <= tgt_free; key++) { 531 for (key = 1; key <= tgt_free; key++) {
466 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value)); 532 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
467 assert(!bpf_map_update_elem(expected_map_fd, &key, value, 533 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
468 BPF_NOEXIST)); 534 BPF_NOEXIST));
469 } 535 }
@@ -494,16 +560,16 @@ static void do_test_lru_sanity5(unsigned long long last_key, int map_fd)
494 unsigned long long key, value[nr_cpus]; 560 unsigned long long key, value[nr_cpus];
495 561
496 /* Ensure the last key inserted by previous CPU can be found */ 562 /* Ensure the last key inserted by previous CPU can be found */
497 assert(!bpf_map_lookup_elem(map_fd, &last_key, value)); 563 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, last_key, value));
498
499 value[0] = 1234; 564 value[0] = 1234;
500 565
501 key = last_key + 1; 566 key = last_key + 1;
502 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST)); 567 assert(!bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST));
503 assert(!bpf_map_lookup_elem(map_fd, &key, value)); 568 assert(!bpf_map_lookup_elem_with_ref_bit(map_fd, key, value));
504 569
505 /* Cannot find the last key because it was removed by LRU */ 570 /* Cannot find the last key because it was removed by LRU */
506 assert(bpf_map_lookup_elem(map_fd, &last_key, value)); 571 assert(bpf_map_lookup_elem(map_fd, &last_key, value) == -1 &&
572 errno == ENOENT);
507} 573}
508 574
509/* Test map with only one element */ 575/* Test map with only one element */
@@ -590,8 +656,8 @@ static void test_lru_sanity6(int map_type, int map_flags, int tgt_free)
590 /* Make ref bit sticky for key: [1, tgt_free] */ 656 /* Make ref bit sticky for key: [1, tgt_free] */
591 for (stable_key = 1; stable_key <= tgt_free; stable_key++) { 657 for (stable_key = 1; stable_key <= tgt_free; stable_key++) {
592 /* Mark the ref bit */ 658 /* Mark the ref bit */
593 assert(!bpf_map_lookup_elem(lru_map_fd, &stable_key, 659 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd,
594 value)); 660 stable_key, value));
595 } 661 }
596 assert(!bpf_map_update_elem(lru_map_fd, &key, value, 662 assert(!bpf_map_update_elem(lru_map_fd, &key, value,
597 BPF_NOEXIST)); 663 BPF_NOEXIST));
@@ -612,6 +678,198 @@ static void test_lru_sanity6(int map_type, int map_flags, int tgt_free)
612 printf("Pass\n"); 678 printf("Pass\n");
613} 679}
614 680
681/* Size of the LRU map is 2
682 * Add key=1 (+1 key)
683 * Add key=2 (+1 key)
684 * Lookup Key=1 (datapath)
685 * Lookup Key=2 (syscall)
686 * Add Key=3
687 * => Key=2 will be removed by LRU
688 * Iterate map. Only found key=1 and key=3
689 */
690static void test_lru_sanity7(int map_type, int map_flags)
691{
692 unsigned long long key, value[nr_cpus];
693 int lru_map_fd, expected_map_fd;
694 int next_cpu = 0;
695
696 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
697 map_flags);
698
699 assert(sched_next_online(0, &next_cpu) != -1);
700
701 if (map_flags & BPF_F_NO_COMMON_LRU)
702 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus);
703 else
704 lru_map_fd = create_map(map_type, map_flags, 2);
705 assert(lru_map_fd != -1);
706
707 expected_map_fd = create_map(BPF_MAP_TYPE_HASH, 0, 2);
708 assert(expected_map_fd != -1);
709
710 value[0] = 1234;
711
712 /* insert key=1 element */
713
714 key = 1;
715 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
716 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
717 BPF_NOEXIST));
718
719 /* BPF_NOEXIST means: add new element if it doesn't exist */
720 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1
721 /* key=1 already exists */
722 && errno == EEXIST);
723
724 /* insert key=2 element */
725
726 /* check that key=2 is not found */
727 key = 2;
728 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
729 errno == ENOENT);
730
731 /* BPF_EXIST means: update existing element */
732 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 &&
733 /* key=2 is not there */
734 errno == ENOENT);
735
736 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
737
738 /* insert key=3 element */
739
740 /* check that key=3 is not found */
741 key = 3;
742 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
743 errno == ENOENT);
744
745 /* check that key=1 can be found and mark the ref bit to
746 * stop LRU from removing key=1
747 */
748 key = 1;
749 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
750 assert(value[0] == 1234);
751
752 /* check that key=2 can be found and do _not_ mark ref bit.
753 * this will be evicted on next update.
754 */
755 key = 2;
756 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
757 assert(value[0] == 1234);
758
759 key = 3;
760 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
761 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
762 BPF_NOEXIST));
763
764 /* key=2 has been removed from the LRU */
765 key = 2;
766 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
767 errno == ENOENT);
768
769 assert(map_equal(lru_map_fd, expected_map_fd));
770
771 close(expected_map_fd);
772 close(lru_map_fd);
773
774 printf("Pass\n");
775}
776
777/* Size of the LRU map is 2
778 * Add key=1 (+1 key)
779 * Add key=2 (+1 key)
780 * Lookup Key=1 (syscall)
781 * Lookup Key=2 (datapath)
782 * Add Key=3
783 * => Key=1 will be removed by LRU
784 * Iterate map. Only found key=2 and key=3
785 */
786static void test_lru_sanity8(int map_type, int map_flags)
787{
788 unsigned long long key, value[nr_cpus];
789 int lru_map_fd, expected_map_fd;
790 int next_cpu = 0;
791
792 printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
793 map_flags);
794
795 assert(sched_next_online(0, &next_cpu) != -1);
796
797 if (map_flags & BPF_F_NO_COMMON_LRU)
798 lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus);
799 else
800 lru_map_fd = create_map(map_type, map_flags, 2);
801 assert(lru_map_fd != -1);
802
803 expected_map_fd = create_map(BPF_MAP_TYPE_HASH, 0, 2);
804 assert(expected_map_fd != -1);
805
806 value[0] = 1234;
807
808 /* insert key=1 element */
809
810 key = 1;
811 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
812
813 /* BPF_NOEXIST means: add new element if it doesn't exist */
814 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST) == -1
815 /* key=1 already exists */
816 && errno == EEXIST);
817
818 /* insert key=2 element */
819
820 /* check that key=2 is not found */
821 key = 2;
822 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
823 errno == ENOENT);
824
825 /* BPF_EXIST means: update existing element */
826 assert(bpf_map_update_elem(lru_map_fd, &key, value, BPF_EXIST) == -1 &&
827 /* key=2 is not there */
828 errno == ENOENT);
829
830 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
831 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
832 BPF_NOEXIST));
833
834 /* insert key=3 element */
835
836 /* check that key=3 is not found */
837 key = 3;
838 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
839 errno == ENOENT);
840
841 /* check that key=1 can be found and do _not_ mark ref bit.
842 * this will be evicted on next update.
843 */
844 key = 1;
845 assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
846 assert(value[0] == 1234);
847
848 /* check that key=2 can be found and mark the ref bit to
849 * stop LRU from removing key=2
850 */
851 key = 2;
852 assert(!bpf_map_lookup_elem_with_ref_bit(lru_map_fd, key, value));
853 assert(value[0] == 1234);
854
855 key = 3;
856 assert(!bpf_map_update_elem(lru_map_fd, &key, value, BPF_NOEXIST));
857 assert(!bpf_map_update_elem(expected_map_fd, &key, value,
858 BPF_NOEXIST));
859
860 /* key=1 has been removed from the LRU */
861 key = 1;
862 assert(bpf_map_lookup_elem(lru_map_fd, &key, value) == -1 &&
863 errno == ENOENT);
864
865 assert(map_equal(lru_map_fd, expected_map_fd));
866
867 close(expected_map_fd);
868 close(lru_map_fd);
869
870 printf("Pass\n");
871}
872
615int main(int argc, char **argv) 873int main(int argc, char **argv)
616{ 874{
617 int map_types[] = {BPF_MAP_TYPE_LRU_HASH, 875 int map_types[] = {BPF_MAP_TYPE_LRU_HASH,
@@ -637,6 +895,8 @@ int main(int argc, char **argv)
637 test_lru_sanity4(map_types[t], map_flags[f], tgt_free); 895 test_lru_sanity4(map_types[t], map_flags[f], tgt_free);
638 test_lru_sanity5(map_types[t], map_flags[f]); 896 test_lru_sanity5(map_types[t], map_flags[f]);
639 test_lru_sanity6(map_types[t], map_flags[f], tgt_free); 897 test_lru_sanity6(map_types[t], map_flags[f], tgt_free);
898 test_lru_sanity7(map_types[t], map_flags[f]);
899 test_lru_sanity8(map_types[t], map_flags[f]);
640 900
641 printf("\n"); 901 printf("\n");
642 } 902 }
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index 524b15dabb3c..b9171a7b3aaa 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -430,15 +430,15 @@ setup_xfrm() {
430 veth_a_addr="${2}" 430 veth_a_addr="${2}"
431 veth_b_addr="${3}" 431 veth_b_addr="${3}"
432 432
433 run_cmd "${ns_a} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" || return 1 433 run_cmd ${ns_a} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 1
434 run_cmd "${ns_a} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" 434 run_cmd ${ns_a} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
435 run_cmd "${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel" 435 run_cmd ${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
436 run_cmd "${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel" 436 run_cmd ${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
437 437
438 run_cmd "${ns_b} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" 438 run_cmd ${ns_b} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
439 run_cmd "${ns_b} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel" 439 run_cmd ${ns_b} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead 'rfc4106(gcm(aes))' 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
440 run_cmd "${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel" 440 run_cmd ${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel
441 run_cmd "${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel" 441 run_cmd ${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel
442} 442}
443 443
444setup_xfrm4() { 444setup_xfrm4() {
diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
index 21159f5f3362..14fcf3104c77 100755
--- a/tools/testing/selftests/netfilter/nft_nat.sh
+++ b/tools/testing/selftests/netfilter/nft_nat.sh
@@ -8,6 +8,11 @@ ksft_skip=4
8ret=0 8ret=0
9test_inet_nat=true 9test_inet_nat=true
10 10
11cleanup()
12{
13 for i in 0 1 2; do ip netns del ns$i;done
14}
15
11nft --version > /dev/null 2>&1 16nft --version > /dev/null 2>&1
12if [ $? -ne 0 ];then 17if [ $? -ne 0 ];then
13 echo "SKIP: Could not run test without nft tool" 18 echo "SKIP: Could not run test without nft tool"
@@ -21,6 +26,13 @@ if [ $? -ne 0 ];then
21fi 26fi
22 27
23ip netns add ns0 28ip netns add ns0
29if [ $? -ne 0 ];then
30 echo "SKIP: Could not create net namespace"
31 exit $ksft_skip
32fi
33
34trap cleanup EXIT
35
24ip netns add ns1 36ip netns add ns1
25ip netns add ns2 37ip netns add ns2
26 38
@@ -347,7 +359,7 @@ EOF
347test_masquerade6() 359test_masquerade6()
348{ 360{
349 local family=$1 361 local family=$1
350 local natflags=$1 362 local natflags=$2
351 local lret=0 363 local lret=0
352 364
353 ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null 365 ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
@@ -392,18 +404,13 @@ EOF
392 404
393 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1 405 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
394 if [ $? -ne 0 ] ; then 406 if [ $? -ne 0 ] ; then
395<<<<<<< HEAD 407 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
396 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerading"
397=======
398 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags"
399>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
400 lret=1 408 lret=1
401 fi 409 fi
402 410
403 # ns1 should have seen packets from ns0, due to masquerade 411 # ns1 should have seen packets from ns0, due to masquerade
404 expect="packets 1 bytes 104" 412 expect="packets 1 bytes 104"
405 for dir in "in6" "out6" ; do 413 for dir in "in6" "out6" ; do
406
407 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect") 414 cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
408 if [ $? -ne 0 ]; then 415 if [ $? -ne 0 ]; then
409 bad_counter ns1 ns0$dir "$expect" 416 bad_counter ns1 ns0$dir "$expect"
@@ -433,38 +440,27 @@ EOF
433 fi 440 fi
434 done 441 done
435 442
436<<<<<<< HEAD
437 ip netns exec ns0 nft flush chain $family nat postrouting
438=======
439 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1 443 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
440 if [ $? -ne 0 ] ; then 444 if [ $? -ne 0 ] ; then
441 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)" 445 echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)"
442 lret=1 446 lret=1
443 fi 447 fi
444 448
445 ip netns exec ns0 nft flush chain ip6 nat postrouting 449 ip netns exec ns0 nft flush chain $family nat postrouting
446>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
447 if [ $? -ne 0 ]; then 450 if [ $? -ne 0 ]; then
448 echo "ERROR: Could not flush $family nat postrouting" 1>&2 451 echo "ERROR: Could not flush $family nat postrouting" 1>&2
449 lret=1 452 lret=1
450 fi 453 fi
451 454
452<<<<<<< HEAD 455 test $lret -eq 0 && echo "PASS: $family IPv6 masquerade $natflags for ns2"
453 test $lret -eq 0 && echo "PASS: $family IPv6 masquerade for ns2"
454=======
455 test $lret -eq 0 && echo "PASS: IPv6 masquerade $natflags for ns2"
456>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
457 456
458 return $lret 457 return $lret
459} 458}
460 459
461test_masquerade() 460test_masquerade()
462{ 461{
463<<<<<<< HEAD
464 local family=$1 462 local family=$1
465======= 463 local natflags=$2
466 local natflags=$1
467>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
468 local lret=0 464 local lret=0
469 465
470 ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null 466 ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
@@ -509,11 +505,7 @@ EOF
509 505
510 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 506 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
511 if [ $? -ne 0 ] ; then 507 if [ $? -ne 0 ] ; then
512<<<<<<< HEAD 508 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
513 echo "ERROR: cannot ping ns1 from ns2 with active $family masquerading"
514=======
515 echo "ERROR: cannot ping ns1 from ns2 with active ip masquere $natflags"
516>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
517 lret=1 509 lret=1
518 fi 510 fi
519 511
@@ -549,27 +541,19 @@ EOF
549 fi 541 fi
550 done 542 done
551 543
552<<<<<<< HEAD
553 ip netns exec ns0 nft flush chain $family nat postrouting
554=======
555 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 544 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
556 if [ $? -ne 0 ] ; then 545 if [ $? -ne 0 ] ; then
557 echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)" 546 echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)"
558 lret=1 547 lret=1
559 fi 548 fi
560 549
561 ip netns exec ns0 nft flush chain ip nat postrouting 550 ip netns exec ns0 nft flush chain $family nat postrouting
562>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
563 if [ $? -ne 0 ]; then 551 if [ $? -ne 0 ]; then
564 echo "ERROR: Could not flush $family nat postrouting" 1>&2 552 echo "ERROR: Could not flush $family nat postrouting" 1>&2
565 lret=1 553 lret=1
566 fi 554 fi
567 555
568<<<<<<< HEAD 556 test $lret -eq 0 && echo "PASS: $family IP masquerade $natflags for ns2"
569 test $lret -eq 0 && echo "PASS: $family IP masquerade for ns2"
570=======
571 test $lret -eq 0 && echo "PASS: IP masquerade $natflags for ns2"
572>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
573 557
574 return $lret 558 return $lret
575} 559}
@@ -842,21 +826,14 @@ reset_counters
842$test_inet_nat && test_local_dnat inet 826$test_inet_nat && test_local_dnat inet
843$test_inet_nat && test_local_dnat6 inet 827$test_inet_nat && test_local_dnat6 inet
844 828
829for flags in "" "fully-random"; do
845reset_counters 830reset_counters
846<<<<<<< HEAD 831test_masquerade ip $flags
847test_masquerade ip 832test_masquerade6 ip6 $flags
848test_masquerade6 ip6
849reset_counters 833reset_counters
850$test_inet_nat && test_masquerade inet 834$test_inet_nat && test_masquerade inet $flags
851$test_inet_nat && test_masquerade6 inet 835$test_inet_nat && test_masquerade6 inet $flags
852======= 836done
853test_masquerade ""
854test_masquerade6 ""
855
856reset_counters
857test_masquerade "fully-random"
858test_masquerade6 "fully-random"
859>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
860 837
861reset_counters 838reset_counters
862test_redirect ip 839test_redirect ip
@@ -865,6 +842,4 @@ reset_counters
865$test_inet_nat && test_redirect inet 842$test_inet_nat && test_redirect inet
866$test_inet_nat && test_redirect6 inet 843$test_inet_nat && test_redirect6 inet
867 844
868for i in 0 1 2; do ip netns del ns$i;done
869
870exit $ret 845exit $ret