History

Merge tag 'net-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Jakub Kicinski: "Including fixes from bpf, can and netfilter. Current release - regressions: - bpf: do not reject when the stack read size is different from the tracked scalar size - net: fix premature exit from NAPI state polling in napi_disable() - riscv, bpf: fix RV32 broken build, and silence RV64 warning Current release - new code bugs: - net: fix possible NULL deref in sock_reserve_memory - amt: fix error return code in amt_init(); fix stopping the workqueue - ax88796c: use the correct ioctl callback Previous releases - always broken: - bpf: stop caching subprog index in the bpf_pseudo_func insn - security: fixups for the security hooks in sctp - nfc: add necessary privilege flags in netlink layer, limit operations to admin only - vsock: prevent unnecessary refcnt inc for non-blocking connect - net/smc: fix sk_refcnt underflow on link down and fallback - nfnetlink_queue: fix OOB when mac header was cleared - can: j1939: ignore invalid messages per standard - bpf, sockmap: - fix race in ingress receive verdict with redirect to self - fix incorrect sk_skb data_end access when src_reg = dst_reg - strparser, and tls are reusing qdisc_skb_cb and colliding - ethtool: fix ethtool msg len calculation for pause stats - vlan: fix a UAF in vlan_dev_real_dev() when ref-holder tries to access an unregistering real_dev - udp6: make encap_rcv() bump the v6 not v4 stats - drv: prestera: add explicit padding to fix m68k build - drv: felix: fix broken VLAN-tagged PTP under VLAN-aware bridge - drv: mvpp2: fix wrong SerDes reconfiguration order Misc & small latecomers: - ipvs: auto-load ipvs on genl access - mctp: sanity check the struct sockaddr_mctp padding fields - libfs: support RENAME_EXCHANGE in simple_rename() - avoid double accounting for pure zerocopy skbs" * tag 'net-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (123 commits) selftests/net: udpgso_bench_rx: fix port argument net: wwan: iosm: fix compilation warning cxgb4: fix eeprom len when diagnostics not implemented net: fix premature exit from NAPI state polling in napi_disable() net/smc: fix sk_refcnt underflow on linkdown and fallback net/mlx5: Lag, fix a potential Oops with mlx5_lag_create_definer() gve: fix unmatched u64_stats_update_end() net: ethernet: lantiq_etop: Fix compilation error selftests: forwarding: Fix packet matching in mirroring selftests vsock: prevent unnecessary refcnt inc for nonblocking connect net: marvell: mvpp2: Fix wrong SerDes reconfiguration order net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory net: stmmac: allow a tc-taprio base-time of zero selftests: net: test_vxlan_under_vrf: fix HV connectivity test net: hns3: allow configure ETS bandwidth of all TCs net: hns3: remove check VF uc mac exist when set by PF net: hns3: fix some mac statistics is always 0 in device version V2 net: hns3: fix kernel crash when unload VF while it is being reset net: hns3: sync rx ring head in echo common pull net: hns3: fix pfc packet number incorrect after querying pfc parameters ...

Linus Torvalds committed 5 years ago

Commit f54ca912 parents c55a041 d336509134 files · +1242 −730Browse files

Unified · Split

134 files
  1. Documentation/networking/ip-sysctl.rst +2 −4
  2. Documentation/security/SCTP.rst +33 −32
  3. MAINTAINERS +3 −2
  4. arch/riscv/mm/extable.c +2 −2
  5. arch/riscv/net/bpf_jit_comp64.c +2 −0
  6. drivers/net/Kconfig +1 −0
  7. drivers/net/amt.c +6 −5
  8. drivers/net/bonding/bond_sysfs_slave.c +11 −25
  9. drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +4 −2
  10. drivers/net/can/usb/etas_es58x/es58x_core.c +2 −4
  11. drivers/net/can/usb/peak_usb/pcan_usb.c +13 −14
  12. drivers/net/dsa/mv88e6xxx/chip.c +4 −1
  13. drivers/net/dsa/ocelot/felix.c +3 −6
  14. drivers/net/dsa/qca8k.c +8 −0
  15. drivers/net/dsa/qca8k.h +1 −0
  16. drivers/net/ethernet/asix/ax88796c_main.c +3 −1
  17. drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +1 −1
  18. drivers/net/ethernet/broadcom/tg3.c +0 −1
  19. drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +5 −2
  20. drivers/net/ethernet/chelsio/cxgb4/t4_hw.h +2 −0
  21. drivers/net/ethernet/google/gve/gve_main.c +1 −1
  22. drivers/net/ethernet/google/gve/gve_rx.c +2 −1
  23. drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +7 −0
  24. drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +4 −2
  25. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +1 −0
  26. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +1 −0
  27. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +8 −12
  28. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +39 −67
  29. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +5 −3
  30. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +35 −42
  31. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +2 −2
  32. drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c +32 −0
  33. drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h +9 −0
  34. drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +6 −4
  35. drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +2 −2
  36. drivers/net/ethernet/intel/ice/ice.h +1 −4
  37. drivers/net/ethernet/intel/ice/ice_base.c +1 −1
  38. drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +75 −66
  39. drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +5 −0
  40. drivers/net/ethernet/lantiq_etop.c +1 −1
  41. drivers/net/ethernet/litex/litex_liteeth.c +1 −4
  42. drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +20 −18
  43. drivers/net/ethernet/marvell/octeontx2/Kconfig +1 −0
  44. drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +1 −3
  45. drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +1 −1
  46. drivers/net/ethernet/marvell/prestera/prestera_ethtool.c +2 −1
  47. drivers/net/ethernet/marvell/prestera/prestera_hw.c +81 −63
  48. drivers/net/ethernet/marvell/prestera/prestera_main.c +4 −2
  49. drivers/net/ethernet/marvell/prestera/prestera_pci.c +2 −1
  50. drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c +1 −1
  51. drivers/net/ethernet/microsoft/mana/gdma_main.c +1 −1
  52. drivers/net/ethernet/sfc/falcon/efx.c +2 −6
  53. drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +0 −2
  54. drivers/net/ethernet/ti/cpsw_ale.c +2 −4
  55. drivers/net/ethernet/ti/davinci_emac.c +14 −2
  56. drivers/net/hamradio/6pack.c +4 −2
  57. drivers/net/hamradio/mkiss.c +5 −4
  58. drivers/net/phy/microchip_t1.c +43 −1
  59. drivers/net/phy/phy.c +6 −1
  60. drivers/net/sungem_phy.c +1 −1
  61. drivers/net/wwan/iosm/iosm_ipc_imem_ops.c +0 −2
  62. drivers/nfc/pn533/pn533.c +3 −3
  63. drivers/nfc/port100.c +3 −3
  64. fs/libfs.c +28 −1
  65. include/linux/bpf.h +6 −0
  66. include/linux/dsa/ocelot.h +1 −0
  67. include/linux/ethtool_netlink.h +3 −0
  68. include/linux/fs.h +2 −0
  69. include/linux/lsm_hook_defs.h +4 −2
  70. include/linux/lsm_hooks.h +9 −4
  71. include/linux/security.h +12 −5
  72. include/linux/skbuff.h +34 −1
  73. include/linux/skmsg.h +12 −0
  74. include/net/llc.h +3 −1
  75. include/net/sctp/structs.h +10 −10
  76. include/net/strparser.h +19 −1
  77. include/net/tcp.h +6 −2
  78. include/uapi/linux/ethtool_netlink.h +3 −1
  79. kernel/bpf/core.c +7 −0
  80. kernel/bpf/verifier.c +20 −35
  81. mm/shmem.c +1 −23
  82. net/8021q/vlan.c +0 −3
  83. net/8021q/vlan_dev.c +3 −0
  84. net/can/j1939/main.c +7 −0
  85. net/can/j1939/transport.c +11 −0
  86. net/core/datagram.c +2 −1
  87. net/core/dev.c +5 −2
  88. net/core/devlink.c +1 −1
  89. net/core/filter.c +56 −8
  90. net/core/skbuff.c +3 −14
  91. net/core/sock.c +1 −1
  92. net/core/sock_map.c +0 −6
  93. net/dsa/tag_ocelot.c +3 −0
  94. net/ethtool/pause.c +1 −2
  95. net/ipv4/tcp.c +20 −2
  96. net/ipv4/tcp_bpf.c +47 −1
  97. net/ipv4/tcp_output.c +15 −12
  98. net/ipv6/seg6.c +1 −1
  99. net/ipv6/tcp_ipv6.c +0 −1
  100. net/ipv6/udp.c +3 −3
  101. net/mctp/af_mctp.c +23 −1
  102. net/netfilter/ipvs/ip_vs_ctl.c +2 −0
  103. net/netfilter/nfnetlink_queue.c +1 −1
  104. net/nfc/netlink.c +15 −0
  105. net/sched/sch_taprio.c +17 −10
  106. net/sctp/sm_statefuns.c +18 −16
  107. net/sctp/socket.c +2 −3
  108. net/smc/af_smc.c +11 −7
  109. net/smc/smc_tracepoint.h +1 −1
  110. net/strparser/strparser.c +1 −9
  111. net/vmw_vsock/af_vsock.c +2 −0
  112. security/security.c +11 −4
  113. security/selinux/hooks.c +23 −11
  114. security/selinux/include/netlabel.h +2 −2
  115. security/selinux/netlabel.c +9 −9
  116. tools/bpf/bpftool/Makefile +22 −10
  117. tools/lib/bpf/bpf.c +3 −1
  118. tools/testing/selftests/bpf/prog_tests/netcnt.c +1 −1
  119. tools/testing/selftests/bpf/prog_tests/test_bpffs.c +74 −11
  120. tools/testing/selftests/bpf/progs/for_each_array_map_elem.c +12 −0
  121. tools/testing/selftests/bpf/test_xdp_redirect_multi.sh +35 −27
  122. tools/testing/selftests/bpf/verifier/spill_fill.c +17 −0
  123. tools/testing/selftests/bpf/xdp_redirect_multi.c +2 −2
  124. tools/testing/selftests/net/Makefile +7 −2
  125. tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh +1 −1
  126. tools/testing/selftests/net/forwarding/mirror_gre_changes.sh +1 −1
  127. tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh +7 −6
  128. tools/testing/selftests/net/forwarding/mirror_lib.sh +2 −1
  129. tools/testing/selftests/net/forwarding/mirror_vlan.sh +2 −2
  130. tools/testing/selftests/net/gre_gso.sh +5 −4
  131. tools/testing/selftests/net/reuseport_bpf_numa.c +4 −0
  132. tools/testing/selftests/net/test_vxlan_under_vrf.sh +2 −0
  133. tools/testing/selftests/net/tls.c +0 −3
  134. tools/testing/selftests/net/udpgso_bench_rx.c +7 −4
Documentation/networking/ip-sysctl.rst+2−4
@@ -1004,13 +1004,11 @@ udp_l3mdev_accept - BOOLEAN · 1003 unmodified lines
10041004 udp_mem - vector of 3 INTEGERs: min, pressure, max
10051005 Number of pages allowed for queueing by all UDP sockets.
10061006
1007− min: Below this number of pages UDP is not bothered about its
1008− memory appetite. When amount of memory allocated by UDP exceeds
1009− this number, UDP starts to moderate memory usage.
1007+ min: Number of pages allowed for queueing by all UDP sockets.
10101008
10111009 pressure: This value was introduced to follow format of tcp_mem.
10121010
1013− max: Number of pages allowed for queueing by all UDP sockets.
1011+ max: This value was introduced to follow format of tcp_mem.
10141012
10151013 Default is calculated at boot time from amount of available memory.
10161014
Documentation/security/SCTP.rst+33−32
@@ -15,10 +15,7 @@ For security module support, three SCTP specific hooks have been implemented:: · 14 unmodified lines
1515 security_sctp_assoc_request()
1616 security_sctp_bind_connect()
1717 security_sctp_sk_clone()
18−
19−Also the following security hook has been utilised::
20−
21− security_inet_conn_established()
18+ security_sctp_assoc_established()
2219
2320 The usage of these hooks are described below with the SELinux implementation
2421 described in the `SCTP SELinux Support`_ chapter.
@@ -26,11 +23,11 @@ described in the `SCTP SELinux Support`_ chapter. · 1 unmodified line
2623
2724 security_sctp_assoc_request()
2825 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29−Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the
26+Passes the ``@asoc`` and ``@chunk->skb`` of the association INIT packet to the
3027 security module. Returns 0 on success, error on failure.
3128 ::
3229
33− @ep - pointer to sctp endpoint structure.
30+ @asoc - pointer to sctp association structure.
3431 @skb - pointer to skbuff of association packet.
3532
3633
@@ -117,16 +114,17 @@ Called whenever a new socket is created by **accept**\(2) · 80 unmodified lines
117114 calls **sctp_peeloff**\(3).
118115 ::
119116
120− @ep - pointer to current sctp endpoint structure.
117+ @asoc - pointer to current sctp association structure.
121118 @sk - pointer to current sock structure.
122− @sk - pointer to new sock structure.
119+ @newsk - pointer to new sock structure.
123120
124121
125−security_inet_conn_established()
122+security_sctp_assoc_established()
126123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127−Called when a COOKIE ACK is received::
124+Called when a COOKIE ACK is received, and the peer secid will be
125+saved into ``@asoc->peer_secid`` for client::
128126
129− @sk - pointer to sock structure.
127+ @asoc - pointer to sctp association structure.
130128 @skb - pointer to skbuff of the COOKIE ACK packet.
131129
132130
@@ -134,7 +132,7 @@ Security Hooks used for Association Establishment · 1 unmodified line
134132 -------------------------------------------------
135133
136134 The following diagram shows the use of ``security_sctp_bind_connect()``,
137−``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when
135+``security_sctp_assoc_request()``, ``security_sctp_assoc_established()`` when
138136 establishing an association.
139137 ::
140138
@@ -151,9 +149,9 @@ establishing an association. · 10 unmodified lines
151149 INIT --------------------------------------------->
152150 sctp_sf_do_5_1B_init()
153151 Respond to an INIT chunk.
154− SCTP peer endpoint "A" is
155− asking for an association. Call
156− security_sctp_assoc_request()
152+ SCTP peer endpoint "A" is asking
153+ for a temporary association.
154+ Call security_sctp_assoc_request()
157155 to set the peer label if first
158156 association.
159157 If not first association, check
@@ -163,13 +161,16 @@ establishing an association. · 3 unmodified lines
163161 | discard the packet.
164162 |
165163 COOKIE ECHO ------------------------------------------>
166− |
167− |
168− |
164+ sctp_sf_do_5_1D_ce()
165+ Respond to an COOKIE ECHO chunk.
166+ Confirm the cookie and create a
167+ permanent association.
168+ Call security_sctp_assoc_request() to
169+ do the same as for INIT chunk Response.
169170 <------------------------------------------- COOKIE ACK
170171 | |
171172 sctp_sf_do_5_1E_ca |
172− Call security_inet_conn_established() |
173+ Call security_sctp_assoc_established() |
173174 to set the peer label. |
174175 | |
175176 | If SCTP_SOCKET_TCP or peeled off
@@ -195,27 +196,27 @@ hooks with the SELinux specifics expanded below:: · 19 unmodified lines
195196 security_sctp_assoc_request()
196197 security_sctp_bind_connect()
197198 security_sctp_sk_clone()
198− security_inet_conn_established()
199+ security_sctp_assoc_established()
199200
200201
201202 security_sctp_assoc_request()
202203 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203−Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the
204+Passes the ``@asoc`` and ``@chunk->skb`` of the association INIT packet to the
204205 security module. Returns 0 on success, error on failure.
205206 ::
206207
207− @ep - pointer to sctp endpoint structure.
208+ @asoc - pointer to sctp association structure.
208209 @skb - pointer to skbuff of association packet.
209210
210211 The security module performs the following operations:
211− IF this is the first association on ``@ep->base.sk``, then set the peer
212+ IF this is the first association on ``@asoc->base.sk``, then set the peer
212213 sid to that in ``@skb``. This will ensure there is only one peer sid
213− assigned to ``@ep->base.sk`` that may support multiple associations.
214+ assigned to ``@asoc->base.sk`` that may support multiple associations.
214215
215− ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid``
216+ ELSE validate the ``@asoc->base.sk peer_sid`` against the ``@skb peer sid``
216217 to determine whether the association should be allowed or denied.
217218
218− Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with
219+ Set the sctp ``@asoc sid`` to socket's sid (from ``asoc->base.sk``) with
219220 MLS portion taken from ``@skb peer sid``. This will be used by SCTP
220221 TCP style sockets and peeled off connections as they cause a new socket
221222 to be generated.
@@ -259,21 +260,21 @@ security_sctp_sk_clone() · 37 unmodified lines
259260 Called whenever a new socket is created by **accept**\(2) (i.e. a TCP style
260261 socket) or when a socket is 'peeled off' e.g userspace calls
261262 **sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new
262−sockets sid and peer sid to that contained in the ``@ep sid`` and
263−``@ep peer sid`` respectively.
263+sockets sid and peer sid to that contained in the ``@asoc sid`` and
264+``@asoc peer sid`` respectively.
264265 ::
265266
266− @ep - pointer to current sctp endpoint structure.
267+ @asoc - pointer to current sctp association structure.
267268 @sk - pointer to current sock structure.
268− @sk - pointer to new sock structure.
269+ @newsk - pointer to new sock structure.
269270
270271
271−security_inet_conn_established()
272+security_sctp_assoc_established()
272273 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273274 Called when a COOKIE ACK is received where it sets the connection's peer sid
274275 to that in ``@skb``::
275276
276− @sk - pointer to sock structure.
277+ @asoc - pointer to sctp association structure.
277278 @skb - pointer to skbuff of the COOKIE ACK packet.
278279
279280
MAINTAINERS+3−2
@@ -872,9 +872,10 @@ F: Documentation/devicetree/bindings/thermal/amazon,al-thermal.txt · 871 unmodified lines
872872 F: drivers/thermal/thermal_mmio.c
873873
874874 AMAZON ETHERNET DRIVERS
875−M: Netanel Belgazal <netanel@amazon.com>
875+M: Shay Agroskin <shayagr@amazon.com>
876876 M: Arthur Kiyanovski <akiyano@amazon.com>
877−R: Guy Tzalik <gtzalik@amazon.com>
877+R: David Arinzon <darinzon@amazon.com>
878+R: Noam Dagan <ndagan@amazon.com>
878879 R: Saeed Bishara <saeedb@amazon.com>
879880 L: netdev@vger.kernel.org
880881 S: Supported
arch/riscv/mm/extable.c+2−2
@@ -11,7 +11,7 @@ · 10 unmodified lines
1111 #include <linux/module.h>
1212 #include <linux/uaccess.h>
1313
14−#ifdef CONFIG_BPF_JIT
14+#if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
1515 int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs);
1616 #endif
1717
@@ -23,7 +23,7 @@ int fixup_exception(struct pt_regs *regs) · 5 unmodified lines
2323 if (!fixup)
2424 return 0;
2525
26−#ifdef CONFIG_BPF_JIT
26+#if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
2727 if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END)
2828 return rv_bpf_fixup_exception(fixup, regs);
2929 #endif
arch/riscv/net/bpf_jit_comp64.c+2−0
@@ -459,6 +459,8 @@ static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx) · 458 unmodified lines
459459 #define BPF_FIXUP_OFFSET_MASK GENMASK(26, 0)
460460 #define BPF_FIXUP_REG_MASK GENMASK(31, 27)
461461
462+int rv_bpf_fixup_exception(const struct exception_table_entry *ex,
463+ struct pt_regs *regs);
462464 int rv_bpf_fixup_exception(const struct exception_table_entry *ex,
463465 struct pt_regs *regs)
464466 {
drivers/net/Kconfig+1−0
@@ -294,6 +294,7 @@ config GTP · 293 unmodified lines
294294 config AMT
295295 tristate "Automatic Multicast Tunneling (AMT)"
296296 depends on INET && IP_MULTICAST
297+ depends on IPV6 || !IPV6
297298 select NET_UDP_TUNNEL
298299 help
299300 This allows one to create AMT(Automatic Multicast Tunneling)
drivers/net/amt.c+6−5
@@ -12,7 +12,6 @@ · 11 unmodified lines
1212 #include <linux/igmp.h>
1313 #include <linux/workqueue.h>
1414 #include <net/net_namespace.h>
15−#include <net/protocol.h>
1615 #include <net/ip.h>
1716 #include <net/udp.h>
1817 #include <net/udp_tunnel.h>
@@ -23,7 +22,6 @@ · 4 unmodified lines
2322 #include <linux/security.h>
2423 #include <net/gro_cells.h>
2524 #include <net/ipv6.h>
26−#include <net/protocol.h>
2725 #include <net/if_inet6.h>
2826 #include <net/ndisc.h>
2927 #include <net/addrconf.h>
@@ -2767,7 +2765,7 @@ static int amt_err_lookup(struct sock *sk, struct sk_buff *skb) · 2737 unmodified lines
27672765 rcu_read_lock_bh();
27682766 amt = rcu_dereference_sk_user_data(sk);
27692767 if (!amt)
2770− goto drop;
2768+ goto out;
27712769
27722770 if (amt->mode != AMT_MODE_GATEWAY)
27732771 goto drop;
@@ -2789,6 +2787,7 @@ static int amt_err_lookup(struct sock *sk, struct sk_buff *skb) · 15 unmodified lines
27892787 default:
27902788 goto drop;
27912789 }
2790+out:
27922791 rcu_read_unlock_bh();
27932792 return 0;
27942793 drop:
@@ -3259,8 +3258,10 @@ static int __init amt_init(void) · 464 unmodified lines
32593258 goto unregister_notifier;
32603259
32613260 amt_wq = alloc_workqueue("amt", WQ_UNBOUND, 1);
3262− if (!amt_wq)
3261+ if (!amt_wq) {
3262+ err = -ENOMEM;
32633263 goto rtnl_unregister;
3264+ }
32643265
32653266 spin_lock_init(&source_gc_lock);
32663267 spin_lock_bh(&source_gc_lock);
@@ -3285,7 +3286,7 @@ static void __exit amt_fini(void) · 18 unmodified lines
32853286 {
32863287 rtnl_link_unregister(&amt_link_ops);
32873288 unregister_netdevice_notifier(&amt_notifier_block);
3288− flush_delayed_work(&source_gc_wq);
3289+ cancel_delayed_work(&source_gc_wq);
32893290 __amt_source_gc_work();
32903291 destroy_workqueue(amt_wq);
32913292 }
drivers/net/bonding/bond_sysfs_slave.c+11−25
@@ -108,15 +108,15 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf) · 107 unmodified lines
108108 }
109109 static SLAVE_ATTR_RO(ad_partner_oper_port_state);
110110
111−static const struct slave_attribute *slave_attrs[] = {
112− &slave_attr_state,
113− &slave_attr_mii_status,
114− &slave_attr_link_failure_count,
115− &slave_attr_perm_hwaddr,
116− &slave_attr_queue_id,
117− &slave_attr_ad_aggregator_id,
118− &slave_attr_ad_actor_oper_port_state,
119− &slave_attr_ad_partner_oper_port_state,
111+static const struct attribute *slave_attrs[] = {
112+ &slave_attr_state.attr,
113+ &slave_attr_mii_status.attr,
114+ &slave_attr_link_failure_count.attr,
115+ &slave_attr_perm_hwaddr.attr,
116+ &slave_attr_queue_id.attr,
117+ &slave_attr_ad_aggregator_id.attr,
118+ &slave_attr_ad_actor_oper_port_state.attr,
119+ &slave_attr_ad_partner_oper_port_state.attr,
120120 NULL
121121 };
122122
@@ -137,24 +137,10 @@ const struct sysfs_ops slave_sysfs_ops = { · 14 unmodified lines
137137
138138 int bond_sysfs_slave_add(struct slave *slave)
139139 {
140− const struct slave_attribute **a;
141− int err;
142−
143− for (a = slave_attrs; *a; ++a) {
144− err = sysfs_create_file(&slave->kobj, &((*a)->attr));
145− if (err) {
146− kobject_put(&slave->kobj);
147− return err;
148− }
149− }
150−
151− return 0;
140+ return sysfs_create_files(&slave->kobj, slave_attrs);
152141 }
153142
154143 void bond_sysfs_slave_del(struct slave *slave)
155144 {
156− const struct slave_attribute **a;
157−
158− for (a = slave_attrs; *a; ++a)
159− sysfs_remove_file(&slave->kobj, &((*a)->attr));
145+ sysfs_remove_files(&slave->kobj, slave_attrs);
160146 }
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c+4−2
@@ -1092,7 +1092,7 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv) · 1091 unmodified lines
10921092
10931093 err = mcp251xfd_chip_rx_int_enable(priv);
10941094 if (err)
1095− return err;
1095+ goto out_chip_stop;
10961096
10971097 err = mcp251xfd_chip_ecc_init(priv);
10981098 if (err)
@@ -2290,8 +2290,10 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id) · 1191 unmodified lines
22902290 * check will fail, too. So leave IRQ handler
22912291 * directly.
22922292 */
2293− if (priv->can.state == CAN_STATE_BUS_OFF)
2293+ if (priv->can.state == CAN_STATE_BUS_OFF) {
2294+ can_rx_offload_threaded_irq_finish(&priv->offload);
22942295 return IRQ_HANDLED;
2296+ }
22952297 }
22962298
22972299 handled = IRQ_HANDLED;
drivers/net/can/usb/etas_es58x/es58x_core.c+2−4
@@ -664,7 +664,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, · 663 unmodified lines
664664 struct can_device_stats *can_stats = &can->can_stats;
665665 struct can_frame *cf = NULL;
666666 struct sk_buff *skb;
667− int ret;
667+ int ret = 0;
668668
669669 if (!netif_running(netdev)) {
670670 if (net_ratelimit())
@@ -823,8 +823,6 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, · 152 unmodified lines
823823 can->state = CAN_STATE_BUS_OFF;
824824 can_bus_off(netdev);
825825 ret = can->do_set_mode(netdev, CAN_MODE_STOP);
826− if (ret)
827− return ret;
828826 }
829827 break;
830828
@@ -881,7 +879,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, · 50 unmodified lines
881879 ES58X_EVENT_BUSOFF, timestamp);
882880 }
883881
884− return 0;
882+ return ret;
885883 }
886884
887885 /**
drivers/net/can/usb/peak_usb/pcan_usb.c+13−14
@@ -841,14 +841,14 @@ static int pcan_usb_start(struct peak_usb_device *dev) · 840 unmodified lines
841841 pdev->bec.rxerr = 0;
842842 pdev->bec.txerr = 0;
843843
844− /* be notified on error counter changes (if requested by user) */
845− if (dev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) {
846− err = pcan_usb_set_err_frame(dev, PCAN_USB_BERR_MASK);
847− if (err)
848− netdev_warn(dev->netdev,
849− "Asking for BERR reporting error %u\n",
850− err);
851− }
844+ /* always ask the device for BERR reporting, to be able to switch from
845+ * WARNING to PASSIVE state
846+ */
847+ err = pcan_usb_set_err_frame(dev, PCAN_USB_BERR_MASK);
848+ if (err)
849+ netdev_warn(dev->netdev,
850+ "Asking for BERR reporting error %u\n",
851+ err);
852852
853853 /* if revision greater than 3, can put silent mode on/off */
854854 if (dev->device_rev > 3) {
@@ -883,6 +883,11 @@ static int pcan_usb_init(struct peak_usb_device *dev) · 28 unmodified lines
883883 return err;
884884 }
885885
886+ dev_info(dev->netdev->dev.parent,
887+ "PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n",
888+ pcan_usb.name, dev->device_rev, serial_number,
889+ pcan_usb.ctrl_count);
890+
886891 /* Since rev 4.1, PCAN-USB is able to make single-shot as well as
887892 * looped back frames.
888893 */
@@ -896,11 +901,6 @@ static int pcan_usb_init(struct peak_usb_device *dev) · 7 unmodified lines
896901 "Firmware update available. Please contact support@peak-system.com\n");
897902 }
898903
899− dev_info(dev->netdev->dev.parent,
900− "PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n",
901− pcan_usb.name, dev->device_rev, serial_number,
902− pcan_usb.ctrl_count);
903−
904904 return 0;
905905 }
906906
@@ -986,7 +986,6 @@ const struct peak_usb_adapter pcan_usb = { · 79 unmodified lines
986986 .device_id = PCAN_USB_PRODUCT_ID,
987987 .ctrl_count = 1,
988988 .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
989− CAN_CTRLMODE_BERR_REPORTING |
990989 CAN_CTRLMODE_CC_LEN8_DLC,
991990 .clock = {
992991 .freq = PCAN_USB_CRYSTAL_HZ / 2,
drivers/net/dsa/mv88e6xxx/chip.c+4−1
@@ -640,7 +640,10 @@ static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port, · 639 unmodified lines
640640 unsigned long *mask,
641641 struct phylink_link_state *state)
642642 {
643− if (port == 0 || port == 9 || port == 10) {
643+ bool is_6191x =
644+ chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X;
645+
646+ if (((port == 0 || port == 9) && !is_6191x) || port == 10) {
644647 phylink_set(mask, 10000baseT_Full);
645648 phylink_set(mask, 10000baseKR_Full);
646649 phylink_set(mask, 10000baseCR_Full);
drivers/net/dsa/ocelot/felix.c+3−6
@@ -1370,12 +1370,12 @@ out: · 1369 unmodified lines
13701370 static bool felix_rxtstamp(struct dsa_switch *ds, int port,
13711371 struct sk_buff *skb, unsigned int type)
13721372 {
1373− u8 *extraction = skb->data - ETH_HLEN - OCELOT_TAG_LEN;
1373+ u32 tstamp_lo = OCELOT_SKB_CB(skb)->tstamp_lo;
13741374 struct skb_shared_hwtstamps *shhwtstamps;
13751375 struct ocelot *ocelot = ds->priv;
1376− u32 tstamp_lo, tstamp_hi;
13771376 struct timespec64 ts;
1378− u64 tstamp, val;
1377+ u32 tstamp_hi;
1378+ u64 tstamp;
13791379
13801380 /* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb
13811381 * for RX timestamping. Then free it, and poll for its copy through
@@ -1390,9 +1390,6 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port, · 8 unmodified lines
13901390 ocelot_ptp_gettime64(&ocelot->ptp_info, &ts);
13911391 tstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
13921392
1393− ocelot_xfh_get_rew_val(extraction, &val);
1394− tstamp_lo = (u32)val;
1395−
13961393 tstamp_hi = tstamp >> 32;
13971394 if ((tstamp & 0xffffffff) < tstamp_lo)
13981395 tstamp_hi--;
drivers/net/dsa/qca8k.c+8−0
@@ -1109,6 +1109,14 @@ qca8k_setup(struct dsa_switch *ds) · 1108 unmodified lines
11091109 if (ret)
11101110 return ret;
11111111
1112+ /* Make sure MAC06 is disabled */
1113+ ret = qca8k_reg_clear(priv, QCA8K_REG_PORT0_PAD_CTRL,
1114+ QCA8K_PORT0_PAD_MAC06_EXCHANGE_EN);
1115+ if (ret) {
1116+ dev_err(priv->dev, "failed disabling MAC06 exchange");
1117+ return ret;
1118+ }
1119+
11121120 /* Enable CPU Port */
11131121 ret = qca8k_reg_set(priv, QCA8K_REG_GLOBAL_FW_CTRL0,
11141122 QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN);
drivers/net/dsa/qca8k.h+1−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #define QCA8K_MASK_CTRL_DEVICE_ID_MASK GENMASK(15, 8)
3535 #define QCA8K_MASK_CTRL_DEVICE_ID(x) ((x) >> 8)
3636 #define QCA8K_REG_PORT0_PAD_CTRL 0x004
37+#define QCA8K_PORT0_PAD_MAC06_EXCHANGE_EN BIT(31)
3738 #define QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE BIT(19)
3839 #define QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE BIT(18)
3940 #define QCA8K_REG_PORT5_PAD_CTRL 0x008
drivers/net/ethernet/asix/ax88796c_main.c+3−1
@@ -934,7 +934,7 @@ static const struct net_device_ops ax88796c_netdev_ops = { · 933 unmodified lines
934934 .ndo_stop = ax88796c_close,
935935 .ndo_start_xmit = ax88796c_start_xmit,
936936 .ndo_get_stats64 = ax88796c_get_stats64,
937− .ndo_do_ioctl = ax88796c_ioctl,
937+ .ndo_eth_ioctl = ax88796c_ioctl,
938938 .ndo_set_mac_address = eth_mac_addr,
939939 .ndo_set_features = ax88796c_set_features,
940940 };
@@ -1114,11 +1114,13 @@ static int ax88796c_remove(struct spi_device *spi) · 173 unmodified lines
11141114 return 0;
11151115 }
11161116
1117+#ifdef CONFIG_OF
11171118 static const struct of_device_id ax88796c_dt_ids[] = {
11181119 { .compatible = "asix,ax88796c" },
11191120 {},
11201121 };
11211122 MODULE_DEVICE_TABLE(of, ax88796c_dt_ids);
1123+#endif
11221124
11231125 static const struct spi_device_id asix_id[] = {
11241126 { "ax88796c", 0 },
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c+1−1
@@ -443,7 +443,7 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change, · 442 unmodified lines
443443 case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: {
444444 if (BNXT_PF(bp) && bp->pf.active_vfs) {
445445 NL_SET_ERR_MSG_MOD(extack,
446− "reload is unsupported when VFs are allocated\n");
446+ "reload is unsupported when VFs are allocated");
447447 return -EOPNOTSUPP;
448448 }
449449 rtnl_lock();
drivers/net/ethernet/broadcom/tg3.c+0−1
@@ -5503,7 +5503,6 @@ static bool tg3_setup_fiber_hw_autoneg(struct tg3 *tp, u32 mac_status) · 5502 unmodified lines
55035503 int workaround, port_a;
55045504
55055505 serdes_cfg = 0;
5506− expected_sg_dig_ctrl = 0;
55075506 workaround = 0;
55085507 port_a = 1;
55095508 current_link_up = false;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c+5−2
@@ -2015,12 +2015,15 @@ static int cxgb4_get_module_info(struct net_device *dev, · 2014 unmodified lines
20152015 if (ret)
20162016 return ret;
20172017
2018− if (!sff8472_comp || (sff_diag_type & 4)) {
2018+ if (!sff8472_comp || (sff_diag_type & SFP_DIAG_ADDRMODE)) {
20192019 modinfo->type = ETH_MODULE_SFF_8079;
20202020 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
20212021 } else {
20222022 modinfo->type = ETH_MODULE_SFF_8472;
2023− modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
2023+ if (sff_diag_type & SFP_DIAG_IMPLEMENTED)
2024+ modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
2025+ else
2026+ modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
20242027 }
20252028 break;
20262029
drivers/net/ethernet/chelsio/cxgb4/t4_hw.h+2−0
@@ -293,6 +293,8 @@ enum { · 292 unmodified lines
293293 #define I2C_PAGE_SIZE 0x100
294294 #define SFP_DIAG_TYPE_ADDR 0x5c
295295 #define SFP_DIAG_TYPE_LEN 0x1
296+#define SFP_DIAG_ADDRMODE BIT(2)
297+#define SFP_DIAG_IMPLEMENTED BIT(6)
296298 #define SFF_8472_COMP_ADDR 0x5e
297299 #define SFF_8472_COMP_LEN 0x1
298300 #define SFF_REV_ADDR 0x1
drivers/net/ethernet/google/gve/gve_main.c+1−1
@@ -1137,7 +1137,7 @@ static void gve_tx_timeout(struct net_device *dev, unsigned int txqueue) · 1136 unmodified lines
11371137 goto reset;
11381138
11391139 ntfy_idx = gve_tx_idx_to_ntfy(priv, txqueue);
1140− if (ntfy_idx > priv->num_ntfy_blks)
1140+ if (ntfy_idx >= priv->num_ntfy_blks)
11411141 goto reset;
11421142
11431143 block = &priv->ntfy_blocks[ntfy_idx];
drivers/net/ethernet/google/gve/gve_rx.c+2−1
@@ -500,7 +500,8 @@ static struct sk_buff *gve_rx_skb(struct gve_priv *priv, struct gve_rx_ring *rx, · 499 unmodified lines
500500 rx->rx_copied_pkt++;
501501 rx->rx_frag_copy_cnt++;
502502 rx->rx_copybreak_pkt++;
503− } u64_stats_update_end(&rx->statss);
503+ u64_stats_update_end(&rx->statss);
504+ }
504505 } else {
505506 if (rx->data.raw_addressing) {
506507 int recycle = gve_rx_can_recycle_buffer(page_info);
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c+7−0
@@ -4210,6 +4210,13 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, · 4209 unmodified lines
42104210 }
42114211
42124212 out:
4213+ /* sync head pointer before exiting, since hardware will calculate
4214+ * FBD number with head pointer
4215+ */
4216+ if (unused_count > 0)
4217+ failure = failure ||
4218+ hns3_nic_alloc_rx_buffers(ring, unused_count);
4219+
42134220 return failure ? budget : recv_pkts;
42144221 }
42154222
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c+4−2
@@ -238,9 +238,11 @@ static void hns3_lb_clear_tx_ring(struct hns3_nic_priv *priv, u32 start_ringid, · 237 unmodified lines
238238 }
239239
240240 /**
241− * hns3_lp_run_test - run loopback test
241+ * hns3_lp_run_test - run loopback test
242242 * @ndev: net device
243243 * @mode: loopback type
244+ *
245+ * Return: %0 for success or a NIC loopback test error code on failure
244246 */
245247 static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
246248 {
@@ -398,7 +400,7 @@ static void hns3_do_selftest(struct net_device *ndev, int (*st_param)[2], · 151 unmodified lines
398400 }
399401
400402 /**
401− * hns3_nic_self_test - self test
403+ * hns3_self_test - self test
402404 * @ndev: net device
403405 * @eth_test: test cmd
404406 * @data: test result
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c+1−0
@@ -483,6 +483,7 @@ static int hclge_firmware_compat_config(struct hclge_dev *hdev, bool en) · 482 unmodified lines
483483 if (hnae3_dev_phy_imp_supported(hdev))
484484 hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1);
485485 hnae3_set_bit(compat, HCLGE_MAC_STATS_EXT_EN_B, 1);
486+ hnae3_set_bit(compat, HCLGE_SYNC_RX_RING_HEAD_EN_B, 1);
486487
487488 req->compat = cpu_to_le32(compat);
488489 }
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h+1−0
@@ -1151,6 +1151,7 @@ struct hclge_query_ppu_pf_other_int_dfx_cmd { · 1150 unmodified lines
11511151 #define HCLGE_NCSI_ERROR_REPORT_EN_B 1
11521152 #define HCLGE_PHY_IMP_EN_B 2
11531153 #define HCLGE_MAC_STATS_EXT_EN_B 3
1154+#define HCLGE_SYNC_RX_RING_HEAD_EN_B 4
11541155 struct hclge_firmware_compat_cmd {
11551156 __le32 compat;
11561157 u8 rsv[20];
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c+8−12
@@ -129,7 +129,7 @@ static int hclge_ets_sch_mode_validate(struct hclge_dev *hdev, · 128 unmodified lines
129129 u32 total_ets_bw = 0;
130130 u8 i;
131131
132− for (i = 0; i < hdev->tc_max; i++) {
132+ for (i = 0; i < HNAE3_MAX_TC; i++) {
133133 switch (ets->tc_tsa[i]) {
134134 case IEEE_8021QAZ_TSA_STRICT:
135135 if (hdev->tm_info.tc_info[i].tc_sch_mode !=
@@ -286,28 +286,24 @@ err_out: · 150 unmodified lines
286286
287287 static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
288288 {
289− u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC];
290289 struct hclge_vport *vport = hclge_get_vport(h);
291290 struct hclge_dev *hdev = vport->back;
292291 int ret;
293− u8 i;
294292
295293 memset(pfc, 0, sizeof(*pfc));
296294 pfc->pfc_cap = hdev->pfc_max;
297295 pfc->pfc_en = hdev->tm_info.pfc_en;
298296
299− ret = hclge_pfc_tx_stats_get(hdev, requests);
300− if (ret)
297+ ret = hclge_mac_update_stats(hdev);
298+ if (ret) {
299+ dev_err(&hdev->pdev->dev,
300+ "failed to update MAC stats, ret = %d.\n", ret);
301301 return ret;
302+ }
302303
303− ret = hclge_pfc_rx_stats_get(hdev, indications);
304− if (ret)
305− return ret;
304+ hclge_pfc_tx_stats_get(hdev, pfc->requests);
305+ hclge_pfc_rx_stats_get(hdev, pfc->indications);
306306
307− for (i = 0; i < HCLGE_MAX_TC_NUM; i++) {
308− pfc->requests[i] = requests[i];
309− pfc->indications[i] = indications[i];
310− }
311307 return 0;
312308 }
313309
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c+39−67
@@ -26,8 +26,6 @@ · 25 unmodified lines
2626 #include "hclge_devlink.h"
2727
2828 #define HCLGE_NAME "hclge"
29−#define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
30−#define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
3129
3230 #define HCLGE_BUF_SIZE_UNIT 256U
3331 #define HCLGE_BUF_MUL_BY 2
@@ -568,6 +566,16 @@ static int hclge_mac_query_reg_num(struct hclge_dev *hdev, u32 *reg_num) · 534 unmodified lines
568566 struct hclge_desc desc;
569567 int ret;
570568
569+ /* Driver needs total register number of both valid registers and
570+ * reserved registers, but the old firmware only returns number
571+ * of valid registers in device V2. To be compatible with these
572+ * devices, driver uses a fixed value.
573+ */
574+ if (hdev->ae_dev->dev_version == HNAE3_DEVICE_VERSION_V2) {
575+ *reg_num = HCLGE_MAC_STATS_MAX_NUM_V1;
576+ return 0;
577+ }
578+
571579 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_MAC_REG_NUM, true);
572580 ret = hclge_cmd_send(&hdev->hw, &desc, 1);
573581 if (ret) {
@@ -587,7 +595,7 @@ static int hclge_mac_query_reg_num(struct hclge_dev *hdev, u32 *reg_num) · 13 unmodified lines
587595 return 0;
588596 }
589597
590−static int hclge_mac_update_stats(struct hclge_dev *hdev)
598+int hclge_mac_update_stats(struct hclge_dev *hdev)
591599 {
592600 /* The firmware supports the new statistics acquisition method */
593601 if (hdev->ae_dev->dev_specs.mac_stats_num)
@@ -2581,7 +2589,7 @@ static int hclge_init_roce_base_info(struct hclge_vport *vport) · 1987 unmodified lines
25812589 if (hdev->num_msi < hdev->num_nic_msi + hdev->num_roce_msi)
25822590 return -EINVAL;
25832591
2584− roce->rinfo.base_vector = hdev->roce_base_vector;
2592+ roce->rinfo.base_vector = hdev->num_nic_msi;
25852593
25862594 roce->rinfo.netdev = nic->kinfo.netdev;
25872595 roce->rinfo.roce_io_base = hdev->hw.io_base;
@@ -2617,10 +2625,6 @@ static int hclge_init_msi(struct hclge_dev *hdev) · 29 unmodified lines
26172625 hdev->num_msi = vectors;
26182626 hdev->num_msi_left = vectors;
26192627
2620− hdev->base_msi_vector = pdev->irq;
2621− hdev->roce_base_vector = hdev->base_msi_vector +
2622− hdev->num_nic_msi;
2623−
26242628 hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi,
26252629 sizeof(u16), GFP_KERNEL);
26262630 if (!hdev->vector_status) {
@@ -8949,8 +8953,11 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport, · 6322 unmodified lines
89498953
89508954 err_no_space:
89518955 /* if already overflow, not to print each time */
8952− if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE))
8956+ if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE)) {
8957+ vport->overflow_promisc_flags |= HNAE3_OVERFLOW_MPE;
89538958 dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n");
8959+ }
8960+
89548961 return -ENOSPC;
89558962 }
89568963
@@ -9006,12 +9013,17 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport, · 49 unmodified lines
90069013
90079014 static void hclge_sync_vport_mac_list(struct hclge_vport *vport,
90089015 struct list_head *list,
9009− int (*sync)(struct hclge_vport *,
9010− const unsigned char *))
9016+ enum HCLGE_MAC_ADDR_TYPE mac_type)
90119017 {
9018+ int (*sync)(struct hclge_vport *vport, const unsigned char *addr);
90129019 struct hclge_mac_node *mac_node, *tmp;
90139020 int ret;
90149021
9022+ if (mac_type == HCLGE_MAC_ADDR_UC)
9023+ sync = hclge_add_uc_addr_common;
9024+ else
9025+ sync = hclge_add_mc_addr_common;
9026+
90159027 list_for_each_entry_safe(mac_node, tmp, list, node) {
90169028 ret = sync(vport, mac_node->mac_addr);
90179029 if (!ret) {
@@ -9023,8 +9035,13 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport, · 5 unmodified lines
90239035 /* If one unicast mac address is existing in hardware,
90249036 * we need to try whether other unicast mac addresses
90259037 * are new addresses that can be added.
9038+ * Multicast mac address can be reusable, even though
9039+ * there is no space to add new multicast mac address,
9040+ * we should check whether other mac addresses are
9041+ * existing in hardware for reuse.
90269042 */
9027− if (ret != -EEXIST)
9043+ if ((mac_type == HCLGE_MAC_ADDR_UC && ret != -EEXIST) ||
9044+ (mac_type == HCLGE_MAC_ADDR_MC && ret != -ENOSPC))
90289045 break;
90299046 }
90309047 }
@@ -9032,12 +9049,17 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport, · 1 unmodified line
90329049
90339050 static void hclge_unsync_vport_mac_list(struct hclge_vport *vport,
90349051 struct list_head *list,
9035− int (*unsync)(struct hclge_vport *,
9036− const unsigned char *))
9052+ enum HCLGE_MAC_ADDR_TYPE mac_type)
90379053 {
9054+ int (*unsync)(struct hclge_vport *vport, const unsigned char *addr);
90389055 struct hclge_mac_node *mac_node, *tmp;
90399056 int ret;
90409057
9058+ if (mac_type == HCLGE_MAC_ADDR_UC)
9059+ unsync = hclge_rm_uc_addr_common;
9060+ else
9061+ unsync = hclge_rm_mc_addr_common;
9062+
90419063 list_for_each_entry_safe(mac_node, tmp, list, node) {
90429064 ret = unsync(vport, mac_node->mac_addr);
90439065 if (!ret || ret == -ENOENT) {
@@ -9168,17 +9190,8 @@ stop_traverse: · 124 unmodified lines
91689190 spin_unlock_bh(&vport->mac_list_lock);
91699191
91709192 /* delete first, in order to get max mac table space for adding */
9171− if (mac_type == HCLGE_MAC_ADDR_UC) {
9172− hclge_unsync_vport_mac_list(vport, &tmp_del_list,
9173− hclge_rm_uc_addr_common);
9174− hclge_sync_vport_mac_list(vport, &tmp_add_list,
9175− hclge_add_uc_addr_common);
9176− } else {
9177− hclge_unsync_vport_mac_list(vport, &tmp_del_list,
9178− hclge_rm_mc_addr_common);
9179− hclge_sync_vport_mac_list(vport, &tmp_add_list,
9180− hclge_add_mc_addr_common);
9181− }
9193+ hclge_unsync_vport_mac_list(vport, &tmp_del_list, mac_type);
9194+ hclge_sync_vport_mac_list(vport, &tmp_add_list, mac_type);
91829195
91839196 /* if some mac addresses were added/deleted fail, move back to the
91849197 * mac_list, and retry at next time.
@@ -9337,12 +9350,7 @@ static void hclge_uninit_vport_mac_list(struct hclge_vport *vport, · 152 unmodified lines
93379350
93389351 spin_unlock_bh(&vport->mac_list_lock);
93399352
9340− if (mac_type == HCLGE_MAC_ADDR_UC)
9341− hclge_unsync_vport_mac_list(vport, &tmp_del_list,
9342− hclge_rm_uc_addr_common);
9343− else
9344− hclge_unsync_vport_mac_list(vport, &tmp_del_list,
9345− hclge_rm_mc_addr_common);
9353+ hclge_unsync_vport_mac_list(vport, &tmp_del_list, mac_type);
93469354
93479355 if (!list_empty(&tmp_del_list))
93489356 dev_warn(&hdev->pdev->dev,
@@ -9410,36 +9418,6 @@ static int hclge_get_mac_ethertype_cmd_status(struct hclge_dev *hdev, · 61 unmodified lines
94109418 return return_status;
94119419 }
94129420
9413−static bool hclge_check_vf_mac_exist(struct hclge_vport *vport, int vf_idx,
9414− u8 *mac_addr)
9415−{
9416− struct hclge_mac_vlan_tbl_entry_cmd req;
9417− struct hclge_dev *hdev = vport->back;
9418− struct hclge_desc desc;
9419− u16 egress_port = 0;
9420− int i;
9421−
9422− if (is_zero_ether_addr(mac_addr))
9423− return false;
9424−
9425− memset(&req, 0, sizeof(req));
9426− hnae3_set_field(egress_port, HCLGE_MAC_EPORT_VFID_M,
9427− HCLGE_MAC_EPORT_VFID_S, vport->vport_id);
9428− req.egress_port = cpu_to_le16(egress_port);
9429− hclge_prepare_mac_addr(&req, mac_addr, false);
9430−
9431− if (hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false) != -ENOENT)
9432− return true;
9433−
9434− vf_idx += HCLGE_VF_VPORT_START_NUM;
9435− for (i = HCLGE_VF_VPORT_START_NUM; i < hdev->num_alloc_vport; i++)
9436− if (i != vf_idx &&
9437− ether_addr_equal(mac_addr, hdev->vport[i].vf_info.mac))
9438− return true;
9439−
9440− return false;
9441−}
9442−
94439421 static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf,
94449422 u8 *mac_addr)
94459423 {
@@ -9457,12 +9435,6 @@ static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, · 11 unmodified lines
94579435 return 0;
94589436 }
94599437
9460− if (hclge_check_vf_mac_exist(vport, vf, mac_addr)) {
9461− dev_err(&hdev->pdev->dev, "Specified MAC(=%pM) exists!\n",
9462− mac_addr);
9463− return -EEXIST;
9464− }
9465−
94669438 ether_addr_copy(vport->vf_info.mac, mac_addr);
94679439
94689440 if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) {
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h+5−3
@@ -404,7 +404,7 @@ struct hclge_tm_info { · 403 unmodified lines
404404 };
405405
406406 /* max number of mac statistics on each version */
407−#define HCLGE_MAC_STATS_MAX_NUM_V1 84
407+#define HCLGE_MAC_STATS_MAX_NUM_V1 87
408408 #define HCLGE_MAC_STATS_MAX_NUM_V2 105
409409
410410 struct hclge_comm_stats_str {
@@ -852,6 +852,9 @@ struct hclge_vf_vlan_cfg { · 441 unmodified lines
852852 (y) = (_k_ ^ ~_v_) & (_k_); \
853853 } while (0)
854854
855+#define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
856+#define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
857+
855858 #define HCLGE_MAC_TNL_LOG_SIZE 8
856859 #define HCLGE_VPORT_NUM 256
857860 struct hclge_dev {
@@ -904,12 +907,10 @@ struct hclge_dev { · 46 unmodified lines
904907 u16 num_msi;
905908 u16 num_msi_left;
906909 u16 num_msi_used;
907− u32 base_msi_vector;
908910 u16 *vector_status;
909911 int *vector_irq;
910912 u16 num_nic_msi; /* Num of nic vectors for this PF */
911913 u16 num_roce_msi; /* Num of roce vectors for this PF */
912− int roce_base_vector;
913914
914915 unsigned long service_timer_period;
915916 unsigned long service_timer_previous;
@@ -1168,4 +1169,5 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport); · 252 unmodified lines
11681169 int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len);
11691170 int hclge_push_vf_link_status(struct hclge_vport *vport);
11701171 int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en);
1172+int hclge_mac_update_stats(struct hclge_dev *hdev);
11711173 #endif
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c+35−42
@@ -113,50 +113,50 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level, · 112 unmodified lines
113113 return 0;
114114 }
115115
116−static int hclge_pfc_stats_get(struct hclge_dev *hdev,
117− enum hclge_opcode_type opcode, u64 *stats)
118−{
119− struct hclge_desc desc[HCLGE_TM_PFC_PKT_GET_CMD_NUM];
120− int ret, i, j;
121−
122− if (!(opcode == HCLGE_OPC_QUERY_PFC_RX_PKT_CNT ||
123− opcode == HCLGE_OPC_QUERY_PFC_TX_PKT_CNT))
124− return -EINVAL;
125−
126− for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM - 1; i++) {
127− hclge_cmd_setup_basic_desc(&desc[i], opcode, true);
128− desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
129− }
130−
131− hclge_cmd_setup_basic_desc(&desc[i], opcode, true);
116+static const u16 hclge_pfc_tx_stats_offset[] = {
117+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri0_pkt_num),
118+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri1_pkt_num),
119+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri2_pkt_num),
120+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri3_pkt_num),
121+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri4_pkt_num),
122+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri5_pkt_num),
123+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri6_pkt_num),
124+ HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri7_pkt_num)
125+};
132126
133− ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM);
134− if (ret)
135− return ret;
127+static const u16 hclge_pfc_rx_stats_offset[] = {
128+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri0_pkt_num),
129+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri1_pkt_num),
130+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri2_pkt_num),
131+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri3_pkt_num),
132+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri4_pkt_num),
133+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri5_pkt_num),
134+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri6_pkt_num),
135+ HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri7_pkt_num)
136+};
136137
137− for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) {
138− struct hclge_pfc_stats_cmd *pfc_stats =
139− (struct hclge_pfc_stats_cmd *)desc[i].data;
138+static void hclge_pfc_stats_get(struct hclge_dev *hdev, bool tx, u64 *stats)
139+{
140+ const u16 *offset;
141+ int i;
140142
141− for (j = 0; j < HCLGE_TM_PFC_NUM_GET_PER_CMD; j++) {
142− u32 index = i * HCLGE_TM_PFC_PKT_GET_CMD_NUM + j;
143+ if (tx)
144+ offset = hclge_pfc_tx_stats_offset;
145+ else
146+ offset = hclge_pfc_rx_stats_offset;
143147
144− if (index < HCLGE_MAX_TC_NUM)
145− stats[index] =
146− le64_to_cpu(pfc_stats->pkt_num[j]);
147− }
148− }
149− return 0;
148+ for (i = 0; i < HCLGE_MAX_TC_NUM; i++)
149+ stats[i] = HCLGE_STATS_READ(&hdev->mac_stats, offset[i]);
150150 }
151151
152−int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats)
152+void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats)
153153 {
154− return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_RX_PKT_CNT, stats);
154+ hclge_pfc_stats_get(hdev, false, stats);
155155 }
156156
157−int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats)
157+void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats)
158158 {
159− return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_TX_PKT_CNT, stats);
159+ hclge_pfc_stats_get(hdev, true, stats);
160160 }
161161
162162 int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx)
@@ -1123,7 +1123,6 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev) · 960 unmodified lines
11231123
11241124 static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev)
11251125 {
1126−#define DEFAULT_TC_WEIGHT 1
11271126 #define DEFAULT_TC_OFFSET 14
11281127
11291128 struct hclge_ets_tc_weight_cmd *ets_weight;
@@ -1136,13 +1135,7 @@ static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev) · 6 unmodified lines
11361135 for (i = 0; i < HNAE3_MAX_TC; i++) {
11371136 struct hclge_pg_info *pg_info;
11381137
1139− ets_weight->tc_weight[i] = DEFAULT_TC_WEIGHT;
1140−
1141− if (!(hdev->hw_tc_map & BIT(i)))
1142− continue;
1143−
1144− pg_info =
1145− &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid];
1138+ pg_info = &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid];
11461139 ets_weight->tc_weight[i] = pg_info->tc_dwrr[i];
11471140 }
11481141
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h+2−2
@@ -228,8 +228,8 @@ int hclge_tm_dwrr_cfg(struct hclge_dev *hdev); · 227 unmodified lines
228228 int hclge_tm_init_hw(struct hclge_dev *hdev, bool init);
229229 int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx);
230230 int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr);
231−int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);
232−int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats);
231+void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);
232+void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats);
233233 int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate);
234234 int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num);
235235 int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num);
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c+32−0
@@ -434,8 +434,28 @@ err_csq: · 433 unmodified lines
434434 return ret;
435435 }
436436
437+static int hclgevf_firmware_compat_config(struct hclgevf_dev *hdev, bool en)
438+{
439+ struct hclgevf_firmware_compat_cmd *req;
440+ struct hclgevf_desc desc;
441+ u32 compat = 0;
442+
443+ hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_IMP_COMPAT_CFG, false);
444+
445+ if (en) {
446+ req = (struct hclgevf_firmware_compat_cmd *)desc.data;
447+
448+ hnae3_set_bit(compat, HCLGEVF_SYNC_RX_RING_HEAD_EN_B, 1);
449+
450+ req->compat = cpu_to_le32(compat);
451+ }
452+
453+ return hclgevf_cmd_send(&hdev->hw, &desc, 1);
454+}
455+
437456 int hclgevf_cmd_init(struct hclgevf_dev *hdev)
438457 {
458+ struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
439459 int ret;
440460
441461 spin_lock_bh(&hdev->hw.cmq.csq.lock);
@@ -484,6 +504,17 @@ int hclgevf_cmd_init(struct hclgevf_dev *hdev) · 42 unmodified lines
484504 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK,
485505 HNAE3_FW_VERSION_BYTE0_SHIFT));
486506
507+ if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) {
508+ /* ask the firmware to enable some features, driver can work
509+ * without it.
510+ */
511+ ret = hclgevf_firmware_compat_config(hdev, true);
512+ if (ret)
513+ dev_warn(&hdev->pdev->dev,
514+ "Firmware compatible features not enabled(%d).\n",
515+ ret);
516+ }
517+
487518 return 0;
488519
489520 err_cmd_init:
@@ -508,6 +539,7 @@ static void hclgevf_cmd_uninit_regs(struct hclgevf_hw *hw) · 18 unmodified lines
508539
509540 void hclgevf_cmd_uninit(struct hclgevf_dev *hdev)
510541 {
542+ hclgevf_firmware_compat_config(hdev, false);
511543 set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state);
512544 /* wait to ensure that the firmware completes the possible left
513545 * over commands.
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h+9−0
@@ -15,6 +15,12 @@ · 14 unmodified lines
1515 struct hclgevf_hw;
1616 struct hclgevf_dev;
1717
18+#define HCLGEVF_SYNC_RX_RING_HEAD_EN_B 4
19+struct hclgevf_firmware_compat_cmd {
20+ __le32 compat;
21+ u8 rsv[20];
22+};
23+
1824 struct hclgevf_desc {
1925 __le16 opcode;
2026 __le16 flag;
@@ -107,6 +113,9 @@ enum hclgevf_opcode_type { · 86 unmodified lines
107113 HCLGEVF_OPC_RSS_TC_MODE = 0x0D08,
108114 /* Mailbox cmd */
109115 HCLGEVF_OPC_MBX_VF_TO_PF = 0x2001,
116+
117+ /* IMP stats command */
118+ HCLGEVF_OPC_IMP_COMPAT_CFG = 0x701A,
110119 };
111120
112121 #define HCLGEVF_TQP_REG_OFFSET 0x80000
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c+6−4
@@ -2557,7 +2557,7 @@ static int hclgevf_init_roce_base_info(struct hclgevf_dev *hdev) · 2556 unmodified lines
25572557 hdev->num_msi_left == 0)
25582558 return -EINVAL;
25592559
2560− roce->rinfo.base_vector = hdev->roce_base_vector;
2560+ roce->rinfo.base_vector = hdev->roce_base_msix_offset;
25612561
25622562 roce->rinfo.netdev = nic->kinfo.netdev;
25632563 roce->rinfo.roce_io_base = hdev->hw.io_base;
@@ -2823,9 +2823,6 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) · 259 unmodified lines
28232823 hdev->num_msi = vectors;
28242824 hdev->num_msi_left = vectors;
28252825
2826− hdev->base_msi_vector = pdev->irq;
2827− hdev->roce_base_vector = pdev->irq + hdev->roce_base_msix_offset;
2828−
28292826 hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi,
28302827 sizeof(u16), GFP_KERNEL);
28312828 if (!hdev->vector_status) {
@@ -3013,7 +3010,10 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, · 181 unmodified lines
30133010
30143011 /* un-init roce, if it exists */
30153012 if (hdev->roce_client) {
3013+ while (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state))
3014+ msleep(HCLGEVF_WAIT_RESET_DONE);
30163015 clear_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state);
3016+
30173017 hdev->roce_client->ops->uninit_instance(&hdev->roce, 0);
30183018 hdev->roce_client = NULL;
30193019 hdev->roce.client = NULL;
@@ -3022,6 +3022,8 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, · 2 unmodified lines
30223022 /* un-init nic/unic, if this was not called by roce client */
30233023 if (client->ops->uninit_instance && hdev->nic_client &&
30243024 client->type != HNAE3_CLIENT_ROCE) {
3025+ while (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state))
3026+ msleep(HCLGEVF_WAIT_RESET_DONE);
30253027 clear_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state);
30263028
30273029 client->ops->uninit_instance(&hdev->nic, 0);
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h+2−2
@@ -109,6 +109,8 @@ · 108 unmodified lines
109109 #define HCLGEVF_VF_RST_ING 0x07008
110110 #define HCLGEVF_VF_RST_ING_BIT BIT(16)
111111
112+#define HCLGEVF_WAIT_RESET_DONE 100
113+
112114 #define HCLGEVF_RSS_IND_TBL_SIZE 512
113115 #define HCLGEVF_RSS_SET_BITMAP_MSK 0xffff
114116 #define HCLGEVF_RSS_KEY_SIZE 40
@@ -308,8 +310,6 @@ struct hclgevf_dev { · 193 unmodified lines
308310 u16 num_nic_msix; /* Num of nic vectors for this VF */
309311 u16 num_roce_msix; /* Num of roce vectors for this VF */
310312 u16 roce_base_msix_offset;
311− int roce_base_vector;
312− u32 base_msi_vector;
313313 u16 *vector_status;
314314 int *vector_irq;
315315
drivers/net/ethernet/intel/ice/ice.h+1−4
@@ -165,13 +165,10 @@ · 164 unmodified lines
165165 #define ice_for_each_chnl_tc(i) \
166166 for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++)
167167
168−#define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX | \
169− ICE_PROMISC_UCAST_RX | ICE_PROMISC_MCAST_RX)
168+#define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_UCAST_RX)
170169
171170 #define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \
172− ICE_PROMISC_MCAST_TX | \
173171 ICE_PROMISC_UCAST_RX | \
174− ICE_PROMISC_MCAST_RX | \
175172 ICE_PROMISC_VLAN_TX | \
176173 ICE_PROMISC_VLAN_RX)
177174
drivers/net/ethernet/intel/ice/ice_base.c+1−1
@@ -962,7 +962,7 @@ ice_vsi_stop_tx_ring(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, · 961 unmodified lines
962962 } else if (status == ICE_ERR_DOES_NOT_EXIST) {
963963 dev_dbg(ice_pf_to_dev(vsi->back), "LAN Tx queues do not exist, nothing to disable\n");
964964 } else if (status) {
965− dev_err(ice_pf_to_dev(vsi->back), "Failed to disable LAN Tx queues, error: %s\n",
965+ dev_dbg(ice_pf_to_dev(vsi->back), "Failed to disable LAN Tx queues, error: %s\n",
966966 ice_stat_str(status));
967967 return -ENODEV;
968968 }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c+75−66
@@ -638,8 +638,7 @@ void ice_free_vfs(struct ice_pf *pf) · 637 unmodified lines
638638
639639 /* Avoid wait time by stopping all VFs at the same time */
640640 ice_for_each_vf(pf, i)
641− if (test_bit(ICE_VF_STATE_QS_ENA, pf->vf[i].vf_states))
642− ice_dis_vf_qs(&pf->vf[i]);
641+ ice_dis_vf_qs(&pf->vf[i]);
643642
644643 tmp = pf->num_alloc_vfs;
645644 pf->num_qps_per_vf = 0;
@@ -651,6 +650,8 @@ void ice_free_vfs(struct ice_pf *pf) · 5 unmodified lines
651650 set_bit(ICE_VF_STATE_DIS, pf->vf[i].vf_states);
652651 ice_free_vf_res(&pf->vf[i]);
653652 }
653+
654+ mutex_destroy(&pf->vf[i].cfg_lock);
654655 }
655656
656657 if (ice_sriov_free_msix_res(pf))
@@ -1695,8 +1696,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) · 1038 unmodified lines
16951696
16961697 vsi = ice_get_vf_vsi(vf);
16971698
1698− if (test_bit(ICE_VF_STATE_QS_ENA, vf->vf_states))
1699− ice_dis_vf_qs(vf);
1699+ ice_dis_vf_qs(vf);
17001700
17011701 /* Call Disable LAN Tx queue AQ whether or not queues are
17021702 * enabled. This is needed for successful completion of VFR.
@@ -1948,6 +1948,8 @@ static void ice_set_dflt_settings_vfs(struct ice_pf *pf) · 245 unmodified lines
19481948 ice_vf_fdir_init(vf);
19491949
19501950 ice_vc_set_dflt_vf_ops(&vf->vc_ops);
1951+
1952+ mutex_init(&vf->cfg_lock);
19511953 }
19521954 }
19531955
@@ -3013,6 +3015,7 @@ bool ice_is_any_vf_in_promisc(struct ice_pf *pf) · 1059 unmodified lines
30133015 static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg)
30143016 {
30153017 enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
3018+ enum ice_status mcast_status = 0, ucast_status = 0;
30163019 bool rm_promisc, alluni = false, allmulti = false;
30173020 struct virtchnl_promisc_info *info =
30183021 (struct virtchnl_promisc_info *)msg;
@@ -3054,24 +3057,6 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) · 35 unmodified lines
30543057 rm_promisc = !allmulti && !alluni;
30553058
30563059 if (vsi->num_vlan || vf->port_vlan_info) {
3057− struct ice_vsi *pf_vsi = ice_get_main_vsi(pf);
3058− struct net_device *pf_netdev;
3059−
3060− if (!pf_vsi) {
3061− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
3062− goto error_param;
3063− }
3064−
3065− pf_netdev = pf_vsi->netdev;
3066−
3067− ret = ice_set_vf_spoofchk(pf_netdev, vf->vf_id, rm_promisc);
3068− if (ret) {
3069− dev_err(dev, "Failed to update spoofchk to %s for VF %d VSI %d when setting promiscuous mode\n",
3070− rm_promisc ? "ON" : "OFF", vf->vf_id,
3071− vsi->vsi_num);
3072− v_ret = VIRTCHNL_STATUS_ERR_PARAM;
3073− }
3074−
30753060 if (rm_promisc)
30763061 ret = ice_cfg_vlan_pruning(vsi, true);
30773062 else
@@ -3105,52 +3090,51 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) · 27 unmodified lines
31053090 goto error_param;
31063091 }
31073092 } else {
3108− enum ice_status status;
3109− u8 promisc_m;
3110−
3111− if (alluni) {
3112− if (vf->port_vlan_info || vsi->num_vlan)
3113− promisc_m = ICE_UCAST_VLAN_PROMISC_BITS;
3114− else
3115− promisc_m = ICE_UCAST_PROMISC_BITS;
3116− } else if (allmulti) {
3117− if (vf->port_vlan_info || vsi->num_vlan)
3118− promisc_m = ICE_MCAST_VLAN_PROMISC_BITS;
3119− else
3120− promisc_m = ICE_MCAST_PROMISC_BITS;
3093+ u8 mcast_m, ucast_m;
3094+
3095+ if (vf->port_vlan_info || vsi->num_vlan > 1) {
3096+ mcast_m = ICE_MCAST_VLAN_PROMISC_BITS;
3097+ ucast_m = ICE_UCAST_VLAN_PROMISC_BITS;
31213098 } else {
3122− if (vf->port_vlan_info || vsi->num_vlan)
3123− promisc_m = ICE_UCAST_VLAN_PROMISC_BITS;
3124− else
3125− promisc_m = ICE_UCAST_PROMISC_BITS;
3099+ mcast_m = ICE_MCAST_PROMISC_BITS;
3100+ ucast_m = ICE_UCAST_PROMISC_BITS;
31263101 }
31273102
3128− /* Configure multicast/unicast with or without VLAN promiscuous
3129− * mode
3130− */
3131− status = ice_vf_set_vsi_promisc(vf, vsi, promisc_m, rm_promisc);
3132− if (status) {
3133− dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed, error: %s\n",
3134− rm_promisc ? "dis" : "en", vf->vf_id,
3135− ice_stat_str(status));
3136− v_ret = ice_err_to_virt_err(status);
3137− goto error_param;
3138− } else {
3139− dev_dbg(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d succeeded\n",
3140− rm_promisc ? "dis" : "en", vf->vf_id);
3103+ ucast_status = ice_vf_set_vsi_promisc(vf, vsi, ucast_m,
3104+ !alluni);
3105+ if (ucast_status) {
3106+ dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed\n",
3107+ alluni ? "en" : "dis", vf->vf_id);
3108+ v_ret = ice_err_to_virt_err(ucast_status);
3109+ }
3110+
3111+ mcast_status = ice_vf_set_vsi_promisc(vf, vsi, mcast_m,
3112+ !allmulti);
3113+ if (mcast_status) {
3114+ dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed\n",
3115+ allmulti ? "en" : "dis", vf->vf_id);
3116+ v_ret = ice_err_to_virt_err(mcast_status);
31413117 }
31423118 }
31433119
3144− if (allmulti &&
3145− !test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3146− dev_info(dev, "VF %u successfully set multicast promiscuous mode\n", vf->vf_id);
3147− else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3148− dev_info(dev, "VF %u successfully unset multicast promiscuous mode\n", vf->vf_id);
3120+ if (!mcast_status) {
3121+ if (allmulti &&
3122+ !test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3123+ dev_info(dev, "VF %u successfully set multicast promiscuous mode\n",
3124+ vf->vf_id);
3125+ else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3126+ dev_info(dev, "VF %u successfully unset multicast promiscuous mode\n",
3127+ vf->vf_id);
3128+ }
31493129
3150− if (alluni && !test_and_set_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3151− dev_info(dev, "VF %u successfully set unicast promiscuous mode\n", vf->vf_id);
3152− else if (!alluni && test_and_clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3153− dev_info(dev, "VF %u successfully unset unicast promiscuous mode\n", vf->vf_id);
3130+ if (!ucast_status) {
3131+ if (alluni && !test_and_set_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3132+ dev_info(dev, "VF %u successfully set unicast promiscuous mode\n",
3133+ vf->vf_id);
3134+ else if (!alluni && test_and_clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3135+ dev_info(dev, "VF %u successfully unset unicast promiscuous mode\n",
3136+ vf->vf_id);
3137+ }
31543138
31553139 error_param:
31563140 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
@@ -3824,6 +3808,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, · 667 unmodified lines
38243808 struct device *dev = ice_pf_to_dev(vf->pf);
38253809 u8 *mac_addr = vc_ether_addr->addr;
38263810 enum ice_status status;
3811+ int ret = 0;
38273812
38283813 /* device MAC already added */
38293814 if (ether_addr_equal(mac_addr, vf->dev_lan_addr.addr))
@@ -3836,20 +3821,23 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, · 6 unmodified lines
38363821
38373822 status = ice_fltr_add_mac(vsi, mac_addr, ICE_FWD_TO_VSI);
38383823 if (status == ICE_ERR_ALREADY_EXISTS) {
3839− dev_err(dev, "MAC %pM already exists for VF %d\n", mac_addr,
3824+ dev_dbg(dev, "MAC %pM already exists for VF %d\n", mac_addr,
38403825 vf->vf_id);
3841− return -EEXIST;
3826+ /* don't return since we might need to update
3827+ * the primary MAC in ice_vfhw_mac_add() below
3828+ */
3829+ ret = -EEXIST;
38423830 } else if (status) {
38433831 dev_err(dev, "Failed to add MAC %pM for VF %d\n, error %s\n",
38443832 mac_addr, vf->vf_id, ice_stat_str(status));
38453833 return -EIO;
3834+ } else {
3835+ vf->num_mac++;
38463836 }
38473837
38483838 ice_vfhw_mac_add(vf, vc_ether_addr);
38493839
3850− vf->num_mac++;
3851−
3852− return 0;
3840+ return ret;
38533841 }
38543842
38553843 /**
@@ -4151,6 +4139,8 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 295 unmodified lines
41514139 return 0;
41524140 }
41534141
4142+ mutex_lock(&vf->cfg_lock);
4143+
41544144 vf->port_vlan_info = vlanprio;
41554145
41564146 if (vf->port_vlan_info)
@@ -4160,6 +4150,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 3 unmodified lines
41604150 dev_info(dev, "Clearing port VLAN on VF %d\n", vf_id);
41614151
41624152 ice_vc_reset_vf(vf);
4153+ mutex_unlock(&vf->cfg_lock);
41634154
41644155 return 0;
41654156 }
@@ -4699,6 +4690,15 @@ error_handler: · 533 unmodified lines
46994690 return;
47004691 }
47014692
4693+ /* VF is being configured in another context that triggers a VFR, so no
4694+ * need to process this message
4695+ */
4696+ if (!mutex_trylock(&vf->cfg_lock)) {
4697+ dev_info(dev, "VF %u is being configured in another context that will trigger a VFR, so there is no need to handle this message\n",
4698+ vf->vf_id);
4699+ return;
4700+ }
4701+
47024702 switch (v_opcode) {
47034703 case VIRTCHNL_OP_VERSION:
47044704 err = ops->get_ver_msg(vf, msg);
@@ -4787,6 +4787,8 @@ error_handler: · 82 unmodified lines
47874787 dev_info(dev, "PF failed to honor VF %d, opcode %d, error %d\n",
47884788 vf_id, v_opcode, err);
47894789 }
4790+
4791+ mutex_unlock(&vf->cfg_lock);
47904792 }
47914793
47924794 /**
@@ -4902,6 +4904,8 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) · 109 unmodified lines
49024904 return -EINVAL;
49034905 }
49044906
4907+ mutex_lock(&vf->cfg_lock);
4908+
49054909 /* VF is notified of its new MAC via the PF's response to the
49064910 * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset
49074911 */
@@ -4920,6 +4924,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) · 12 unmodified lines
49204924 }
49214925
49224926 ice_vc_reset_vf(vf);
4927+ mutex_unlock(&vf->cfg_lock);
49234928 return 0;
49244929 }
49254930
@@ -4954,11 +4959,15 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) · 28 unmodified lines
49544959 if (trusted == vf->trusted)
49554960 return 0;
49564961
4962+ mutex_lock(&vf->cfg_lock);
4963+
49574964 vf->trusted = trusted;
49584965 ice_vc_reset_vf(vf);
49594966 dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n",
49604967 vf_id, trusted ? "" : "un");
49614968
4969+ mutex_unlock(&vf->cfg_lock);
4970+
49624971 return 0;
49634972 }
49644973
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h+5−0
@@ -100,6 +100,11 @@ struct ice_vc_vf_ops { · 99 unmodified lines
100100 struct ice_vf {
101101 struct ice_pf *pf;
102102
103+ /* Used during virtchnl message handling and NDO ops against the VF
104+ * that will trigger a VFR
105+ */
106+ struct mutex cfg_lock;
107+
103108 u16 vf_id; /* VF ID in the PF space */
104109 u16 lan_vsi_idx; /* index into PF struct */
105110 u16 ctrl_vsi_idx;
drivers/net/ethernet/lantiq_etop.c+1−1
@@ -262,7 +262,7 @@ ltq_etop_hw_init(struct net_device *dev) · 261 unmodified lines
262262 /* enable crc generation */
263263 ltq_etop_w32(PPE32_CGEN, LQ_PPE32_ENET_MAC_CFG);
264264
265− ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len);
265+ ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, priv->rx_burst_len);
266266
267267 for (i = 0; i < MAX_DMA_CHAN; i++) {
268268 int irq = LTQ_DMA_CH0_INT + i;
drivers/net/ethernet/litex/litex_liteeth.c+1−4
@@ -242,10 +242,8 @@ static int liteeth_probe(struct platform_device *pdev) · 241 unmodified lines
242242 priv->dev = &pdev->dev;
243243
244244 irq = platform_get_irq(pdev, 0);
245− if (irq < 0) {
246− dev_err(&pdev->dev, "Failed to get IRQ %d\n", irq);
245+ if (irq < 0)
247246 return irq;
248− }
249247 netdev->irq = irq;
250248
251249 priv->base = devm_platform_ioremap_resource_byname(pdev, "mac");
@@ -289,7 +287,6 @@ static int liteeth_remove(struct platform_device *pdev) · 37 unmodified lines
289287 struct net_device *netdev = platform_get_drvdata(pdev);
290288
291289 unregister_netdev(netdev);
292− free_netdev(netdev);
293290
294291 return 0;
295292 }
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c+20−18
@@ -1605,7 +1605,7 @@ static void mvpp22_gop_fca_set_periodic_timer(struct mvpp2_port *port) · 1604 unmodified lines
16051605 mvpp22_gop_fca_enable_periodic(port, true);
16061606 }
16071607
1608−static int mvpp22_gop_init(struct mvpp2_port *port)
1608+static int mvpp22_gop_init(struct mvpp2_port *port, phy_interface_t interface)
16091609 {
16101610 struct mvpp2 *priv = port->priv;
16111611 u32 val;
@@ -1613,7 +1613,7 @@ static int mvpp22_gop_init(struct mvpp2_port *port) · 1 unmodified line
16131613 if (!priv->sysctrl_base)
16141614 return 0;
16151615
1616− switch (port->phy_interface) {
1616+ switch (interface) {
16171617 case PHY_INTERFACE_MODE_RGMII:
16181618 case PHY_INTERFACE_MODE_RGMII_ID:
16191619 case PHY_INTERFACE_MODE_RGMII_RXID:
@@ -1743,15 +1743,15 @@ static void mvpp22_gop_setup_irq(struct mvpp2_port *port) · 123 unmodified lines
17431743 * lanes by the physical layer. This is why configurations like
17441744 * "PPv2 (2500BaseX) - COMPHY (2500SGMII)" are valid.
17451745 */
1746−static int mvpp22_comphy_init(struct mvpp2_port *port)
1746+static int mvpp22_comphy_init(struct mvpp2_port *port,
1747+ phy_interface_t interface)
17471748 {
17481749 int ret;
17491750
17501751 if (!port->comphy)
17511752 return 0;
17521753
1753− ret = phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET,
1754− port->phy_interface);
1754+ ret = phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET, interface);
17551755 if (ret)
17561756 return ret;
17571757
@@ -2172,7 +2172,8 @@ static void mvpp22_pcs_reset_assert(struct mvpp2_port *port) · 414 unmodified lines
21722172 writel(val & ~MVPP22_XPCS_CFG0_RESET_DIS, xpcs + MVPP22_XPCS_CFG0);
21732173 }
21742174
2175−static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port)
2175+static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port,
2176+ phy_interface_t interface)
21762177 {
21772178 struct mvpp2 *priv = port->priv;
21782179 void __iomem *mpcs, *xpcs;
@@ -2184,7 +2185,7 @@ static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port) · 5 unmodified lines
21842185 mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id);
21852186 xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id);
21862187
2187− switch (port->phy_interface) {
2188+ switch (interface) {
21882189 case PHY_INTERFACE_MODE_10GBASER:
21892190 val = readl(mpcs + MVPP22_MPCS_CLK_RESET);
21902191 val |= MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX |
@@ -4529,7 +4530,8 @@ static int mvpp2_poll(struct napi_struct *napi, int budget) · 2338 unmodified lines
45294530 return rx_done;
45304531 }
45314532
4532−static void mvpp22_mode_reconfigure(struct mvpp2_port *port)
4533+static void mvpp22_mode_reconfigure(struct mvpp2_port *port,
4534+ phy_interface_t interface)
45334535 {
45344536 u32 ctrl3;
45354537
@@ -4540,18 +4542,18 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port) · 4 unmodified lines
45404542 mvpp22_pcs_reset_assert(port);
45414543
45424544 /* comphy reconfiguration */
4543− mvpp22_comphy_init(port);
4545+ mvpp22_comphy_init(port, interface);
45444546
45454547 /* gop reconfiguration */
4546− mvpp22_gop_init(port);
4548+ mvpp22_gop_init(port, interface);
45474549
4548− mvpp22_pcs_reset_deassert(port);
4550+ mvpp22_pcs_reset_deassert(port, interface);
45494551
45504552 if (mvpp2_port_supports_xlg(port)) {
45514553 ctrl3 = readl(port->base + MVPP22_XLG_CTRL3_REG);
45524554 ctrl3 &= ~MVPP22_XLG_CTRL3_MACMODESELECT_MASK;
45534555
4554− if (mvpp2_is_xlg(port->phy_interface))
4556+ if (mvpp2_is_xlg(interface))
45554557 ctrl3 |= MVPP22_XLG_CTRL3_MACMODESELECT_10G;
45564558 else
45574559 ctrl3 |= MVPP22_XLG_CTRL3_MACMODESELECT_GMAC;
@@ -4559,7 +4561,7 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port) · 1 unmodified line
45594561 writel(ctrl3, port->base + MVPP22_XLG_CTRL3_REG);
45604562 }
45614563
4562− if (mvpp2_port_supports_xlg(port) && mvpp2_is_xlg(port->phy_interface))
4564+ if (mvpp2_port_supports_xlg(port) && mvpp2_is_xlg(interface))
45634565 mvpp2_xlg_max_rx_size_set(port);
45644566 else
45654567 mvpp2_gmac_max_rx_size_set(port);
@@ -4579,7 +4581,7 @@ static void mvpp2_start_dev(struct mvpp2_port *port) · 13 unmodified lines
45794581 mvpp2_interrupts_enable(port);
45804582
45814583 if (port->priv->hw_version >= MVPP22)
4582− mvpp22_mode_reconfigure(port);
4584+ mvpp22_mode_reconfigure(port, port->phy_interface);
45834585
45844586 if (port->phylink) {
45854587 phylink_start(port->phylink);
@@ -6444,6 +6446,9 @@ static int mvpp2__mac_prepare(struct phylink_config *config, unsigned int mode, · 1858 unmodified lines
64446446 mvpp22_gop_mask_irq(port);
64456447
64466448 phy_power_off(port->comphy);
6449+
6450+ /* Reconfigure the serdes lanes */
6451+ mvpp22_mode_reconfigure(port, interface);
64476452 }
64486453 }
64496454
@@ -6498,9 +6503,6 @@ static int mvpp2_mac_finish(struct phylink_config *config, unsigned int mode, · 48 unmodified lines
64986503 port->phy_interface != interface) {
64996504 port->phy_interface = interface;
65006505
6501− /* Reconfigure the serdes lanes */
6502− mvpp22_mode_reconfigure(port);
6503−
65046506 /* Unmask interrupts */
65056507 mvpp22_gop_unmask_irq(port);
65066508 }
@@ -6961,7 +6963,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 454 unmodified lines
69616963 * driver does this, we can remove this code.
69626964 */
69636965 if (port->comphy) {
6964− err = mvpp22_comphy_init(port);
6966+ err = mvpp22_comphy_init(port, port->phy_interface);
69656967 if (err == 0)
69666968 phy_power_off(port->comphy);
69676969 }
drivers/net/ethernet/marvell/octeontx2/Kconfig+1−0
@@ -31,6 +31,7 @@ config NDC_DIS_DYNAMIC_CACHING · 30 unmodified lines
3131 config OCTEONTX2_PF
3232 tristate "Marvell OcteonTX2 NIC Physical Function driver"
3333 select OCTEONTX2_MBOX
34+ select NET_DEVLINK
3435 depends on (64BIT && COMPILE_TEST) || ARM64
3536 depends on PCI
3637 depends on PTP_1588_CLOCK_OPTIONAL
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c+1−3
@@ -2450,9 +2450,7 @@ alloc: · 2449 unmodified lines
24502450 bmap = mcam->bmap_reverse;
24512451 start = mcam->bmap_entries - start;
24522452 end = mcam->bmap_entries - end;
2453− index = start;
2454− start = end;
2455− end = index;
2453+ swap(start, end);
24562454 } else {
24572455 bmap = mcam->bmap;
24582456 }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c+1−1
@@ -501,7 +501,7 @@ static const struct net_device_ops otx2vf_netdev_ops = { · 500 unmodified lines
501501 .ndo_set_features = otx2vf_set_features,
502502 .ndo_get_stats64 = otx2_get_stats64,
503503 .ndo_tx_timeout = otx2_tx_timeout,
504− .ndo_do_ioctl = otx2_ioctl,
504+ .ndo_eth_ioctl = otx2_ioctl,
505505 };
506506
507507 static int otx2_wq_init(struct otx2_nic *vf)
drivers/net/ethernet/marvell/prestera/prestera_ethtool.c+2−1
@@ -499,7 +499,8 @@ static void prestera_port_mdix_get(struct ethtool_link_ksettings *ecmd, · 498 unmodified lines
499499 {
500500 struct prestera_port_phy_state *state = &port->state_phy;
501501
502− if (prestera_hw_port_phy_mode_get(port, &state->mdix, NULL, NULL, NULL)) {
502+ if (prestera_hw_port_phy_mode_get(port,
503+ &state->mdix, NULL, NULL, NULL)) {
503504 netdev_warn(port->dev, "MDIX params get failed");
504505 state->mdix = ETH_TP_MDI_INVALID;
505506 }
drivers/net/ethernet/marvell/prestera/prestera_hw.c+81−63
@@ -180,108 +180,113 @@ struct prestera_msg_common_resp { · 179 unmodified lines
180180 struct prestera_msg_ret ret;
181181 };
182182
183−union prestera_msg_switch_param {
184− u8 mac[ETH_ALEN];
185− __le32 ageing_timeout_ms;
186−} __packed;
187−
188183 struct prestera_msg_switch_attr_req {
189184 struct prestera_msg_cmd cmd;
190185 __le32 attr;
191− union prestera_msg_switch_param param;
186+ union {
187+ __le32 ageing_timeout_ms;
188+ struct {
189+ u8 mac[ETH_ALEN];
190+ u8 __pad[2];
191+ };
192+ } param;
192193 };
193194
194195 struct prestera_msg_switch_init_resp {
195196 struct prestera_msg_ret ret;
196197 __le32 port_count;
197198 __le32 mtu_max;
198− u8 switch_id;
199− u8 lag_max;
200− u8 lag_member_max;
201199 __le32 size_tbl_router_nexthop;
202−} __packed __aligned(4);
200+ u8 switch_id;
201+ u8 lag_max;
202+ u8 lag_member_max;
203+};
203204
204205 struct prestera_msg_event_port_param {
205206 union {
206207 struct {
207− u8 oper;
208208 __le32 mode;
209209 __le32 speed;
210+ u8 oper;
210211 u8 duplex;
211212 u8 fc;
212213 u8 fec;
213− } __packed mac;
214+ } mac;
214215 struct {
215− u8 mdix;
216216 __le64 lmode_bmap;
217+ u8 mdix;
217218 u8 fc;
218− } __packed phy;
219− } __packed;
220−} __packed __aligned(4);
219+ u8 __pad[2];
220+ } __packed phy; /* make sure always 12 bytes size */
221+ };
222+};
221223
222224 struct prestera_msg_port_cap_param {
223225 __le64 link_mode;
224− u8 type;
225− u8 fec;
226− u8 fc;
227− u8 transceiver;
226+ u8 type;
227+ u8 fec;
228+ u8 fc;
229+ u8 transceiver;
228230 };
229231
230232 struct prestera_msg_port_flood_param {
231233 u8 type;
232234 u8 enable;
235+ u8 __pad[2];
233236 };
234237
235238 union prestera_msg_port_param {
239+ __le32 mtu;
240+ __le32 speed;
241+ __le32 link_mode;
236242 u8 admin_state;
237243 u8 oper_state;
238− __le32 mtu;
239244 u8 mac[ETH_ALEN];
240245 u8 accept_frm_type;
241− __le32 speed;
242246 u8 learning;
243247 u8 flood;
244− __le32 link_mode;
245248 u8 type;
246249 u8 duplex;
247250 u8 fec;
248251 u8 fc;
249−
250252 union {
251253 struct {
252− u8 admin:1;
254+ u8 admin;
253255 u8 fc;
254256 u8 ap_enable;
257+ u8 __reserved[5];
255258 union {
256259 struct {
257260 __le32 mode;
258− u8 inband:1;
259261 __le32 speed;
260− u8 duplex;
261− u8 fec;
262− u8 fec_supp;
263− } __packed reg_mode;
262+ u8 inband;
263+ u8 duplex;
264+ u8 fec;
265+ u8 fec_supp;
266+ } reg_mode;
264267 struct {
265268 __le32 mode;
266269 __le32 speed;
267− u8 fec;
268− u8 fec_supp;
269− } __packed ap_modes[PRESTERA_AP_PORT_MAX];
270− } __packed;
271− } __packed mac;
270+ u8 fec;
271+ u8 fec_supp;
272+ u8 __pad[2];
273+ } ap_modes[PRESTERA_AP_PORT_MAX];
274+ };
275+ } mac;
272276 struct {
273− u8 admin:1;
274− u8 adv_enable;
275277 __le64 modes;
276278 __le32 mode;
279+ u8 admin;
280+ u8 adv_enable;
277281 u8 mdix;
278− } __packed phy;
279− } __packed link;
282+ u8 __pad;
283+ } phy;
284+ } link;
280285
281286 struct prestera_msg_port_cap_param cap;
282287 struct prestera_msg_port_flood_param flood_ext;
283288 struct prestera_msg_event_port_param link_evt;
284−} __packed;
289+};
285290
286291 struct prestera_msg_port_attr_req {
287292 struct prestera_msg_cmd cmd;
@@ -289,14 +294,12 @@ struct prestera_msg_port_attr_req { · 1 unmodified line
289294 __le32 port;
290295 __le32 dev;
291296 union prestera_msg_port_param param;
292−} __packed __aligned(4);
293−
297+};
294298
295299 struct prestera_msg_port_attr_resp {
296300 struct prestera_msg_ret ret;
297301 union prestera_msg_port_param param;
298−} __packed __aligned(4);
299−
302+};
300303
301304 struct prestera_msg_port_stats_resp {
302305 struct prestera_msg_ret ret;
@@ -313,6 +316,7 @@ struct prestera_msg_port_info_resp { · 10 unmodified lines
313316 __le32 hw_id;
314317 __le32 dev_id;
315318 __le16 fp_id;
319+ u8 pad[2];
316320 };
317321
318322 struct prestera_msg_vlan_req {
@@ -320,13 +324,13 @@ struct prestera_msg_vlan_req { · 1 unmodified line
320324 __le32 port;
321325 __le32 dev;
322326 __le16 vid;
323− u8 is_member;
324− u8 is_tagged;
327+ u8 is_member;
328+ u8 is_tagged;
325329 };
326330
327331 struct prestera_msg_fdb_req {
328332 struct prestera_msg_cmd cmd;
329− u8 dest_type;
333+ __le32 flush_mode;
330334 union {
331335 struct {
332336 __le32 port;
@@ -334,22 +338,25 @@ struct prestera_msg_fdb_req { · 1 unmodified line
334338 };
335339 __le16 lag_id;
336340 } dest;
337− u8 mac[ETH_ALEN];
338341 __le16 vid;
339− u8 dynamic;
340− __le32 flush_mode;
341−} __packed __aligned(4);
342+ u8 dest_type;
343+ u8 dynamic;
344+ u8 mac[ETH_ALEN];
345+ u8 __pad[2];
346+};
342347
343348 struct prestera_msg_bridge_req {
344349 struct prestera_msg_cmd cmd;
345350 __le32 port;
346351 __le32 dev;
347352 __le16 bridge;
353+ u8 pad[2];
348354 };
349355
350356 struct prestera_msg_bridge_resp {
351357 struct prestera_msg_ret ret;
352358 __le16 bridge;
359+ u8 pad[2];
353360 };
354361
355362 struct prestera_msg_acl_action {
@@ -359,11 +366,12 @@ struct prestera_msg_acl_action { · 3 unmodified lines
359366
360367 struct prestera_msg_acl_match {
361368 __le32 type;
369+ __le32 __reserved;
362370 union {
363371 struct {
364372 u8 key;
365373 u8 mask;
366− } __packed u8;
374+ } u8;
367375 struct {
368376 __le16 key;
369377 __le16 mask;
@@ -379,7 +387,7 @@ struct prestera_msg_acl_match { · 9 unmodified lines
379387 struct {
380388 u8 key[ETH_ALEN];
381389 u8 mask[ETH_ALEN];
382− } __packed mac;
390+ } mac;
383391 } keymask;
384392 };
385393
@@ -408,16 +416,19 @@ struct prestera_msg_acl_ruleset_bind_req { · 22 unmodified lines
408416 __le32 port;
409417 __le32 dev;
410418 __le16 ruleset_id;
419+ u8 pad[2];
411420 };
412421
413422 struct prestera_msg_acl_ruleset_req {
414423 struct prestera_msg_cmd cmd;
415424 __le16 id;
425+ u8 pad[2];
416426 };
417427
418428 struct prestera_msg_acl_ruleset_resp {
419429 struct prestera_msg_ret ret;
420430 __le16 id;
431+ u8 pad[2];
421432 };
422433
423434 struct prestera_msg_span_req {
@@ -425,11 +436,13 @@ struct prestera_msg_span_req { · 1 unmodified line
425436 __le32 port;
426437 __le32 dev;
427438 u8 id;
439+ u8 pad[3];
428440 };
429441
430442 struct prestera_msg_span_resp {
431443 struct prestera_msg_ret ret;
432444 u8 id;
445+ u8 pad[3];
433446 };
434447
435448 struct prestera_msg_stp_req {
@@ -437,12 +450,14 @@ struct prestera_msg_stp_req { · 1 unmodified line
437450 __le32 port;
438451 __le32 dev;
439452 __le16 vid;
440− u8 state;
453+ u8 state;
454+ u8 __pad;
441455 };
442456
443457 struct prestera_msg_rxtx_req {
444458 struct prestera_msg_cmd cmd;
445459 u8 use_sdma;
460+ u8 pad[3];
446461 };
447462
448463 struct prestera_msg_rxtx_resp {
@@ -455,12 +470,14 @@ struct prestera_msg_lag_req { · 6 unmodified lines
455470 __le32 port;
456471 __le32 dev;
457472 __le16 lag_id;
473+ u8 pad[2];
458474 };
459475
460476 struct prestera_msg_cpu_code_counter_req {
461477 struct prestera_msg_cmd cmd;
462478 u8 counter_type;
463479 u8 code;
480+ u8 pad[2];
464481 };
465482
466483 struct mvsw_msg_cpu_code_counter_ret {
@@ -485,21 +502,21 @@ union prestera_msg_event_fdb_param { · 18 unmodified lines
485502
486503 struct prestera_msg_event_fdb {
487504 struct prestera_msg_event id;
488− u8 dest_type;
505+ __le32 vid;
489506 union {
490507 __le32 port_id;
491508 __le16 lag_id;
492509 } dest;
493− __le32 vid;
494510 union prestera_msg_event_fdb_param param;
495−} __packed __aligned(4);
511+ u8 dest_type;
512+};
496513
497−static inline void prestera_hw_build_tests(void)
514+static void prestera_hw_build_tests(void)
498515 {
499516 /* check requests */
500517 BUILD_BUG_ON(sizeof(struct prestera_msg_common_req) != 4);
501518 BUILD_BUG_ON(sizeof(struct prestera_msg_switch_attr_req) != 16);
502− BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_req) != 120);
519+ BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_req) != 144);
503520 BUILD_BUG_ON(sizeof(struct prestera_msg_port_info_req) != 8);
504521 BUILD_BUG_ON(sizeof(struct prestera_msg_vlan_req) != 16);
505522 BUILD_BUG_ON(sizeof(struct prestera_msg_fdb_req) != 28);
@@ -516,7 +533,7 @@ static inline void prestera_hw_build_tests(void) · 10 unmodified lines
516533 /* check responses */
517534 BUILD_BUG_ON(sizeof(struct prestera_msg_common_resp) != 8);
518535 BUILD_BUG_ON(sizeof(struct prestera_msg_switch_init_resp) != 24);
519− BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_resp) != 112);
536+ BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_resp) != 136);
520537 BUILD_BUG_ON(sizeof(struct prestera_msg_port_stats_resp) != 248);
521538 BUILD_BUG_ON(sizeof(struct prestera_msg_port_info_resp) != 20);
522539 BUILD_BUG_ON(sizeof(struct prestera_msg_bridge_resp) != 12);
@@ -549,9 +566,9 @@ static int __prestera_cmd_ret(struct prestera_switch *sw, · 26 unmodified lines
549566 if (err)
550567 return err;
551568
552− if (__le32_to_cpu(ret->cmd.type) != PRESTERA_CMD_TYPE_ACK)
569+ if (ret->cmd.type != __cpu_to_le32(PRESTERA_CMD_TYPE_ACK))
553570 return -EBADE;
554− if (__le32_to_cpu(ret->status) != PRESTERA_CMD_ACK_OK)
571+ if (ret->status != __cpu_to_le32(PRESTERA_CMD_ACK_OK))
555572 return -EINVAL;
556573
557574 return 0;
@@ -1344,7 +1361,8 @@ int prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed) · 786 unmodified lines
13441361 int prestera_hw_port_autoneg_restart(struct prestera_port *port)
13451362 {
13461363 struct prestera_msg_port_attr_req req = {
1347− .attr = __cpu_to_le32(PRESTERA_CMD_PORT_ATTR_PHY_AUTONEG_RESTART),
1364+ .attr =
1365+ __cpu_to_le32(PRESTERA_CMD_PORT_ATTR_PHY_AUTONEG_RESTART),
13481366 .port = __cpu_to_le32(port->hw_id),
13491367 .dev = __cpu_to_le32(port->dev_id),
13501368 };
drivers/net/ethernet/marvell/prestera/prestera_main.c+4−2
@@ -405,7 +405,8 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id) · 404 unmodified lines
405405
406406 err = prestera_port_cfg_mac_write(port, &cfg_mac);
407407 if (err) {
408− dev_err(prestera_dev(sw), "Failed to set port(%u) mac mode\n", id);
408+ dev_err(prestera_dev(sw),
409+ "Failed to set port(%u) mac mode\n", id);
409410 goto err_port_init;
410411 }
411412
@@ -418,7 +419,8 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id) · 6 unmodified lines
418419 false, 0, 0,
419420 port->cfg_phy.mdix);
420421 if (err) {
421− dev_err(prestera_dev(sw), "Failed to set port(%u) phy mode\n", id);
422+ dev_err(prestera_dev(sw),
423+ "Failed to set port(%u) phy mode\n", id);
422424 goto err_port_init;
423425 }
424426 }
drivers/net/ethernet/marvell/prestera/prestera_pci.c+2−1
@@ -411,7 +411,8 @@ static int prestera_fw_cmd_send(struct prestera_fw *fw, int qid, · 410 unmodified lines
411411 goto cmd_exit;
412412 }
413413
414− memcpy_fromio(out_msg, prestera_fw_cmdq_buf(fw, qid) + in_size, ret_size);
414+ memcpy_fromio(out_msg,
415+ prestera_fw_cmdq_buf(fw, qid) + in_size, ret_size);
415416
416417 cmd_exit:
417418 prestera_fw_write(fw, PRESTERA_CMDQ_REQ_CTL_REG(qid),
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c+1−1
@@ -289,7 +289,7 @@ mlx5_lag_create_definer(struct mlx5_lag *ldev, enum netdev_lag_hash hash, · 288 unmodified lines
289289
290290 lag_definer = kzalloc(sizeof(*lag_definer), GFP_KERNEL);
291291 if (!lag_definer)
292− return ERR_PTR(ENOMEM);
292+ return ERR_PTR(-ENOMEM);
293293
294294 match_definer_mask = kvzalloc(MLX5_FLD_SZ_BYTES(match_definer,
295295 match_mask),
drivers/net/ethernet/microsoft/mana/gdma_main.c+1−1
@@ -1424,7 +1424,7 @@ static void mana_gd_shutdown(struct pci_dev *pdev) · 1423 unmodified lines
14241424 {
14251425 struct gdma_context *gc = pci_get_drvdata(pdev);
14261426
1427− dev_info(&pdev->dev, "Shutdown was calledd\n");
1427+ dev_info(&pdev->dev, "Shutdown was called\n");
14281428
14291429 mana_remove(&gc->mana, true);
14301430
drivers/net/ethernet/sfc/falcon/efx.c+2−6
@@ -817,9 +817,7 @@ ef4_realloc_channels(struct ef4_nic *efx, u32 rxq_entries, u32 txq_entries) · 816 unmodified lines
817817 efx->rxq_entries = rxq_entries;
818818 efx->txq_entries = txq_entries;
819819 for (i = 0; i < efx->n_channels; i++) {
820− channel = efx->channel[i];
821− efx->channel[i] = other_channel[i];
822− other_channel[i] = channel;
820+ swap(efx->channel[i], other_channel[i]);
823821 }
824822
825823 /* Restart buffer table allocation */
@@ -863,9 +861,7 @@ rollback: · 37 unmodified lines
863861 efx->rxq_entries = old_rxq_entries;
864862 efx->txq_entries = old_txq_entries;
865863 for (i = 0; i < efx->n_channels; i++) {
866− channel = efx->channel[i];
867− efx->channel[i] = other_channel[i];
868− other_channel[i] = channel;
864+ swap(efx->channel[i], other_channel[i]);
869865 }
870866 goto out;
871867 }
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c+0−2
@@ -786,8 +786,6 @@ static int tc_setup_taprio(struct stmmac_priv *priv, · 785 unmodified lines
786786 goto disable;
787787 if (qopt->num_entries >= dep)
788788 return -EINVAL;
789− if (!qopt->base_time)
790− return -ERANGE;
791789 if (!qopt->cycle_time)
792790 return -ERANGE;
793791
drivers/net/ethernet/ti/cpsw_ale.c+2−4
@@ -1299,10 +1299,8 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params) · 1298 unmodified lines
12991299 if (!ale)
13001300 return ERR_PTR(-ENOMEM);
13011301
1302− ale->p0_untag_vid_mask =
1303− devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
1304− sizeof(unsigned long),
1305− GFP_KERNEL);
1302+ ale->p0_untag_vid_mask = devm_bitmap_zalloc(params->dev, VLAN_N_VID,
1303+ GFP_KERNEL);
13061304 if (!ale->p0_untag_vid_mask)
13071305 return ERR_PTR(-ENOMEM);
13081306
drivers/net/ethernet/ti/davinci_emac.c+14−2
@@ -420,8 +420,20 @@ static int emac_set_coalesce(struct net_device *ndev, · 419 unmodified lines
420420 u32 int_ctrl, num_interrupts = 0;
421421 u32 prescale = 0, addnl_dvdr = 1, coal_intvl = 0;
422422
423− if (!coal->rx_coalesce_usecs)
424− return -EINVAL;
423+ if (!coal->rx_coalesce_usecs) {
424+ priv->coal_intvl = 0;
425+
426+ switch (priv->version) {
427+ case EMAC_VERSION_2:
428+ emac_ctrl_write(EMAC_DM646X_CMINTCTRL, 0);
429+ break;
430+ default:
431+ emac_ctrl_write(EMAC_CTRL_EWINTTCNT, 0);
432+ break;
433+ }
434+
435+ return 0;
436+ }
425437
426438 coal_intvl = coal->rx_coalesce_usecs;
427439
drivers/net/hamradio/6pack.c+4−2
@@ -672,11 +672,13 @@ static void sixpack_close(struct tty_struct *tty) · 671 unmodified lines
672672 del_timer_sync(&sp->tx_t);
673673 del_timer_sync(&sp->resync_t);
674674
675− /* Free all 6pack frame buffers. */
675+ unregister_netdev(sp->dev);
676+
677+ /* Free all 6pack frame buffers after unreg. */
676678 kfree(sp->rbuff);
677679 kfree(sp->xbuff);
678680
679− unregister_netdev(sp->dev);
681+ free_netdev(sp->dev);
680682 }
681683
682684 /* Perform I/O control on an active 6pack channel. */
drivers/net/hamradio/mkiss.c+5−4
@@ -792,13 +792,14 @@ static void mkiss_close(struct tty_struct *tty) · 791 unmodified lines
792792 */
793793 netif_stop_queue(ax->dev);
794794
795− /* Free all AX25 frame buffers. */
796− kfree(ax->rbuff);
797− kfree(ax->xbuff);
798−
799795 ax->tty = NULL;
800796
801797 unregister_netdev(ax->dev);
798+
799+ /* Free all AX25 frame buffers after unreg. */
800+ kfree(ax->rbuff);
801+ kfree(ax->xbuff);
802+
802803 free_netdev(ax->dev);
803804 }
804805
drivers/net/phy/microchip_t1.c+43−1
@@ -28,6 +28,11 @@ · 27 unmodified lines
2828 #define LAN87XX_MASK_LINK_UP (0x0004)
2929 #define LAN87XX_MASK_LINK_DOWN (0x0002)
3030
31+/* MISC Control 1 Register */
32+#define LAN87XX_CTRL_1 (0x11)
33+#define LAN87XX_MASK_RGMII_TXC_DLY_EN (0x4000)
34+#define LAN87XX_MASK_RGMII_RXC_DLY_EN (0x2000)
35+
3136 /* phyaccess nested types */
3237 #define PHYACC_ATTR_MODE_READ 0
3338 #define PHYACC_ATTR_MODE_WRITE 1
@@ -112,6 +117,43 @@ static int access_ereg_modify_changed(struct phy_device *phydev, · 78 unmodified lines
112117 return rc;
113118 }
114119
120+static int lan87xx_config_rgmii_delay(struct phy_device *phydev)
121+{
122+ int rc;
123+
124+ if (!phy_interface_is_rgmii(phydev))
125+ return 0;
126+
127+ rc = access_ereg(phydev, PHYACC_ATTR_MODE_READ,
128+ PHYACC_ATTR_BANK_MISC, LAN87XX_CTRL_1, 0);
129+ if (rc < 0)
130+ return rc;
131+
132+ switch (phydev->interface) {
133+ case PHY_INTERFACE_MODE_RGMII:
134+ rc &= ~LAN87XX_MASK_RGMII_TXC_DLY_EN;
135+ rc &= ~LAN87XX_MASK_RGMII_RXC_DLY_EN;
136+ break;
137+ case PHY_INTERFACE_MODE_RGMII_ID:
138+ rc |= LAN87XX_MASK_RGMII_TXC_DLY_EN;
139+ rc |= LAN87XX_MASK_RGMII_RXC_DLY_EN;
140+ break;
141+ case PHY_INTERFACE_MODE_RGMII_RXID:
142+ rc &= ~LAN87XX_MASK_RGMII_TXC_DLY_EN;
143+ rc |= LAN87XX_MASK_RGMII_RXC_DLY_EN;
144+ break;
145+ case PHY_INTERFACE_MODE_RGMII_TXID:
146+ rc |= LAN87XX_MASK_RGMII_TXC_DLY_EN;
147+ rc &= ~LAN87XX_MASK_RGMII_RXC_DLY_EN;
148+ break;
149+ default:
150+ return 0;
151+ }
152+
153+ return access_ereg(phydev, PHYACC_ATTR_MODE_WRITE,
154+ PHYACC_ATTR_BANK_MISC, LAN87XX_CTRL_1, rc);
155+}
156+
115157 static int lan87xx_phy_init(struct phy_device *phydev)
116158 {
117159 static const struct access_ereg_val init[] = {
@@ -185,7 +227,7 @@ static int lan87xx_phy_init(struct phy_device *phydev) · 67 unmodified lines
185227 return rc;
186228 }
187229
188− return 0;
230+ return lan87xx_config_rgmii_delay(phydev);
189231 }
190232
191233 static int lan87xx_phy_config_intr(struct phy_device *phydev)
drivers/net/phy/phy.c+6−1
@@ -815,7 +815,12 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, · 814 unmodified lines
815815 phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
816816
817817 /* Restart the PHY */
818− _phy_start_aneg(phydev);
818+ if (phy_is_started(phydev)) {
819+ phydev->state = PHY_UP;
820+ phy_trigger_machine(phydev);
821+ } else {
822+ _phy_start_aneg(phydev);
823+ }
819824
820825 mutex_unlock(&phydev->lock);
821826 return 0;
drivers/net/sungem_phy.c+1−1
@@ -409,7 +409,7 @@ static int genmii_read_link(struct mii_phy *phy) · 408 unmodified lines
409409 * though magic-aneg shouldn't prevent this case from occurring
410410 */
411411
412− return 0;
412+ return 0;
413413 }
414414
415415 static int generic_suspend(struct mii_phy* phy)
drivers/net/wwan/iosm/iosm_ipc_imem_ops.c+0−2
@@ -394,12 +394,10 @@ void ipc_imem_sys_devlink_close(struct iosm_devlink *ipc_devlink) · 393 unmodified lines
394394 int boot_check_timeout = BOOT_CHECK_DEFAULT_TIMEOUT;
395395 enum ipc_mem_exec_stage exec_stage;
396396 struct ipc_mem_channel *channel;
397− enum ipc_phase curr_phase;
398397 int status = 0;
399398 u32 tail = 0;
400399
401400 channel = ipc_imem->ipc_devlink->devlink_sio.channel;
402− curr_phase = ipc_imem->phase;
403401 /* Increase the total wait time to boot_check_timeout */
404402 do {
405403 exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio);
drivers/nfc/pn533/pn533.c+3−3
@@ -2216,7 +2216,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb) · 2215 unmodified lines
22162216 frag = pn533_alloc_skb(dev, frag_size);
22172217 if (!frag) {
22182218 skb_queue_purge(&dev->fragment_skb);
2219− break;
2219+ return -ENOMEM;
22202220 }
22212221
22222222 if (!dev->tgt_mode) {
@@ -2285,7 +2285,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev, · 62 unmodified lines
22852285 /* jumbo frame ? */
22862286 if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
22872287 rc = pn533_fill_fragment_skbs(dev, skb);
2288− if (rc <= 0)
2288+ if (rc < 0)
22892289 goto error;
22902290
22912291 skb = skb_dequeue(&dev->fragment_skb);
@@ -2353,7 +2353,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) · 61 unmodified lines
23532353 /* let's split in multiple chunks if size's too big */
23542354 if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
23552355 rc = pn533_fill_fragment_skbs(dev, skb);
2356− if (rc <= 0)
2356+ if (rc < 0)
23572357 goto error;
23582358
23592359 /* get the first skb */
drivers/nfc/port100.c+3−3
@@ -624,7 +624,7 @@ static void port100_recv_response(struct urb *urb) · 623 unmodified lines
624624 break; /* success */
625625 case -ECONNRESET:
626626 case -ENOENT:
627− nfc_err(&dev->interface->dev,
627+ nfc_dbg(&dev->interface->dev,
628628 "The urb has been canceled (status %d)\n", urb->status);
629629 goto sched_wq;
630630 case -ESHUTDOWN:
@@ -678,7 +678,7 @@ static void port100_recv_ack(struct urb *urb) · 47 unmodified lines
678678 break; /* success */
679679 case -ECONNRESET:
680680 case -ENOENT:
681− nfc_err(&dev->interface->dev,
681+ nfc_dbg(&dev->interface->dev,
682682 "The urb has been stopped (status %d)\n", urb->status);
683683 goto sched_wq;
684684 case -ESHUTDOWN:
@@ -942,7 +942,7 @@ static void port100_send_complete(struct urb *urb) · 257 unmodified lines
942942 break; /* success */
943943 case -ECONNRESET:
944944 case -ENOENT:
945− nfc_err(&dev->interface->dev,
945+ nfc_dbg(&dev->interface->dev,
946946 "The urb has been stopped (status %d)\n", urb->status);
947947 break;
948948 case -ESHUTDOWN:
fs/libfs.c+28−1
@@ -448,6 +448,30 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) · 447 unmodified lines
448448 }
449449 EXPORT_SYMBOL(simple_rmdir);
450450
451+int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
452+ struct inode *new_dir, struct dentry *new_dentry)
453+{
454+ bool old_is_dir = d_is_dir(old_dentry);
455+ bool new_is_dir = d_is_dir(new_dentry);
456+
457+ if (old_dir != new_dir && old_is_dir != new_is_dir) {
458+ if (old_is_dir) {
459+ drop_nlink(old_dir);
460+ inc_nlink(new_dir);
461+ } else {
462+ drop_nlink(new_dir);
463+ inc_nlink(old_dir);
464+ }
465+ }
466+ old_dir->i_ctime = old_dir->i_mtime =
467+ new_dir->i_ctime = new_dir->i_mtime =
468+ d_inode(old_dentry)->i_ctime =
469+ d_inode(new_dentry)->i_ctime = current_time(old_dir);
470+
471+ return 0;
472+}
473+EXPORT_SYMBOL_GPL(simple_rename_exchange);
474+
451475 int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
452476 struct dentry *old_dentry, struct inode *new_dir,
453477 struct dentry *new_dentry, unsigned int flags)
@@ -455,9 +479,12 @@ int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir, · 1 unmodified line
455479 struct inode *inode = d_inode(old_dentry);
456480 int they_are_dirs = d_is_dir(old_dentry);
457481
458− if (flags & ~RENAME_NOREPLACE)
482+ if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
459483 return -EINVAL;
460484
485+ if (flags & RENAME_EXCHANGE)
486+ return simple_rename_exchange(old_dir, old_dentry, new_dir, new_dentry);
487+
461488 if (!simple_empty(new_dentry))
462489 return -ENOTEMPTY;
463490
include/linux/bpf.h+6−0
@@ -484,6 +484,12 @@ bpf_ctx_record_field_size(struct bpf_insn_access_aux *aux, u32 size) · 483 unmodified lines
484484 aux->ctx_field_size = size;
485485 }
486486
487+static inline bool bpf_pseudo_func(const struct bpf_insn *insn)
488+{
489+ return insn->code == (BPF_LD | BPF_IMM | BPF_DW) &&
490+ insn->src_reg == BPF_PSEUDO_FUNC;
491+}
492+
487493 struct bpf_prog_ops {
488494 int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr,
489495 union bpf_attr __user *uattr);
include/linux/dsa/ocelot.h+1−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 struct ocelot_skb_cb {
1313 struct sk_buff *clone;
1414 unsigned int ptp_class; /* valid only for clones */
15+ u32 tstamp_lo;
1516 u8 ptp_cmd;
1617 u8 ts_id;
1718 };
include/linux/ethtool_netlink.h+3−0
@@ -10,6 +10,9 @@ · 9 unmodified lines
1010 #define __ETHTOOL_LINK_MODE_MASK_NWORDS \
1111 DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)
1212
13+#define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT - \
14+ ETHTOOL_A_PAUSE_STAT_TX_FRAMES)
15+
1316 enum ethtool_multicast_groups {
1417 ETHNL_MCGRP_MONITOR,
1518 };
include/linux/fs.h+2−0
@@ -3385,6 +3385,8 @@ extern int simple_open(struct inode *inode, struct file *file); · 3384 unmodified lines
33853385 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
33863386 extern int simple_unlink(struct inode *, struct dentry *);
33873387 extern int simple_rmdir(struct inode *, struct dentry *);
3388+extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
3389+ struct inode *new_dir, struct dentry *new_dentry);
33883390 extern int simple_rename(struct user_namespace *, struct inode *,
33893391 struct dentry *, struct inode *, struct dentry *,
33903392 unsigned int);
include/linux/lsm_hook_defs.h+4−2
@@ -329,12 +329,14 @@ LSM_HOOK(int, 0, tun_dev_create, void) · 328 unmodified lines
329329 LSM_HOOK(int, 0, tun_dev_attach_queue, void *security)
330330 LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security)
331331 LSM_HOOK(int, 0, tun_dev_open, void *security)
332−LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_endpoint *ep,
332+LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_association *asoc,
333333 struct sk_buff *skb)
334334 LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname,
335335 struct sockaddr *address, int addrlen)
336−LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_endpoint *ep,
336+LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_association *asoc,
337337 struct sock *sk, struct sock *newsk)
338+LSM_HOOK(void, LSM_RET_VOID, sctp_assoc_established, struct sctp_association *asoc,
339+ struct sk_buff *skb)
338340 #endif /* CONFIG_SECURITY_NETWORK */
339341
340342 #ifdef CONFIG_SECURITY_INFINIBAND
include/linux/lsm_hooks.h+9−4
@@ -1027,9 +1027,9 @@ · 1026 unmodified lines
10271027 * Security hooks for SCTP
10281028 *
10291029 * @sctp_assoc_request:
1030− * Passes the @ep and @chunk->skb of the association INIT packet to
1030+ * Passes the @asoc and @chunk->skb of the association INIT packet to
10311031 * the security module.
1032− * @ep pointer to sctp endpoint structure.
1032+ * @asoc pointer to sctp association structure.
10331033 * @skb pointer to skbuff of association packet.
10341034 * Return 0 on success, error on failure.
10351035 * @sctp_bind_connect:
@@ -1047,9 +1047,14 @@ · 11 unmodified lines
10471047 * Called whenever a new socket is created by accept(2) (i.e. a TCP
10481048 * style socket) or when a socket is 'peeled off' e.g userspace
10491049 * calls sctp_peeloff(3).
1050− * @ep pointer to current sctp endpoint structure.
1050+ * @asoc pointer to current sctp association structure.
10511051 * @sk pointer to current sock structure.
1052− * @sk pointer to new sock structure.
1052+ * @newsk pointer to new sock structure.
1053+ * @sctp_assoc_established:
1054+ * Passes the @asoc and @chunk->skb of the association COOKIE_ACK packet
1055+ * to the security module.
1056+ * @asoc pointer to sctp association structure.
1057+ * @skb pointer to skbuff of association packet.
10531058 *
10541059 * Security hooks for Infiniband
10551060 *
include/linux/security.h+12−5
@@ -179,7 +179,7 @@ struct xfrm_policy; · 178 unmodified lines
179179 struct xfrm_state;
180180 struct xfrm_user_sec_ctx;
181181 struct seq_file;
182−struct sctp_endpoint;
182+struct sctp_association;
183183
184184 #ifdef CONFIG_MMU
185185 extern unsigned long mmap_min_addr;
@@ -1425,11 +1425,13 @@ int security_tun_dev_create(void); · 1239 unmodified lines
14251425 int security_tun_dev_attach_queue(void *security);
14261426 int security_tun_dev_attach(struct sock *sk, void *security);
14271427 int security_tun_dev_open(void *security);
1428−int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb);
1428+int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
14291429 int security_sctp_bind_connect(struct sock *sk, int optname,
14301430 struct sockaddr *address, int addrlen);
1431−void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
1431+void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
14321432 struct sock *newsk);
1433+void security_sctp_assoc_established(struct sctp_association *asoc,
1434+ struct sk_buff *skb);
14331435
14341436 #else /* CONFIG_SECURITY_NETWORK */
14351437 static inline int security_unix_stream_connect(struct sock *sock,
@@ -1631,7 +1633,7 @@ static inline int security_tun_dev_open(void *security) · 195 unmodified lines
16311633 return 0;
16321634 }
16331635
1634−static inline int security_sctp_assoc_request(struct sctp_endpoint *ep,
1636+static inline int security_sctp_assoc_request(struct sctp_association *asoc,
16351637 struct sk_buff *skb)
16361638 {
16371639 return 0;
@@ -1644,11 +1646,16 @@ static inline int security_sctp_bind_connect(struct sock *sk, int optname, · 6 unmodified lines
16441646 return 0;
16451647 }
16461648
1647−static inline void security_sctp_sk_clone(struct sctp_endpoint *ep,
1649+static inline void security_sctp_sk_clone(struct sctp_association *asoc,
16481650 struct sock *sk,
16491651 struct sock *newsk)
16501652 {
16511653 }
1654+
1655+static inline void security_sctp_assoc_established(struct sctp_association *asoc,
1656+ struct sk_buff *skb)
1657+{
1658+}
16521659 #endif /* CONFIG_SECURITY_NETWORK */
16531660
16541661 #ifdef CONFIG_SECURITY_INFINIBAND
include/linux/skbuff.h+34−1
@@ -454,9 +454,15 @@ enum { · 453 unmodified lines
454454 * all frags to avoid possible bad checksum
455455 */
456456 SKBFL_SHARED_FRAG = BIT(1),
457+
458+ /* segment contains only zerocopy data and should not be
459+ * charged to the kernel memory.
460+ */
461+ SKBFL_PURE_ZEROCOPY = BIT(2),
457462 };
458463
459464 #define SKBFL_ZEROCOPY_FRAG (SKBFL_ZEROCOPY_ENABLE | SKBFL_SHARED_FRAG)
465+#define SKBFL_ALL_ZEROCOPY (SKBFL_ZEROCOPY_FRAG | SKBFL_PURE_ZEROCOPY)
460466
461467 /*
462468 * The callback notifies userspace to release buffers when skb DMA is done in
@@ -1464,6 +1470,17 @@ static inline struct ubuf_info *skb_zcopy(struct sk_buff *skb) · 1001 unmodified lines
14641470 return is_zcopy ? skb_uarg(skb) : NULL;
14651471 }
14661472
1473+static inline bool skb_zcopy_pure(const struct sk_buff *skb)
1474+{
1475+ return skb_shinfo(skb)->flags & SKBFL_PURE_ZEROCOPY;
1476+}
1477+
1478+static inline bool skb_pure_zcopy_same(const struct sk_buff *skb1,
1479+ const struct sk_buff *skb2)
1480+{
1481+ return skb_zcopy_pure(skb1) == skb_zcopy_pure(skb2);
1482+}
1483+
14671484 static inline void net_zcopy_get(struct ubuf_info *uarg)
14681485 {
14691486 refcount_inc(&uarg->refcnt);
@@ -1528,7 +1545,7 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy_success) · 58 unmodified lines
15281545 if (!skb_zcopy_is_nouarg(skb))
15291546 uarg->callback(skb, uarg, zerocopy_success);
15301547
1531− skb_shinfo(skb)->flags &= ~SKBFL_ZEROCOPY_FRAG;
1548+ skb_shinfo(skb)->flags &= ~SKBFL_ALL_ZEROCOPY;
15321549 }
15331550 }
15341551
@@ -1675,6 +1692,22 @@ static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) · 140 unmodified lines
16751692 return 0;
16761693 }
16771694
1695+/* This variant of skb_unclone() makes sure skb->truesize is not changed */
1696+static inline int skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri)
1697+{
1698+ might_sleep_if(gfpflags_allow_blocking(pri));
1699+
1700+ if (skb_cloned(skb)) {
1701+ unsigned int save = skb->truesize;
1702+ int res;
1703+
1704+ res = pskb_expand_head(skb, 0, 0, pri);
1705+ skb->truesize = save;
1706+ return res;
1707+ }
1708+ return 0;
1709+}
1710+
16781711 /**
16791712 * skb_header_cloned - is the header a clone
16801713 * @skb: buffer to check
include/linux/skmsg.h+12−0
@@ -507,6 +507,18 @@ static inline bool sk_psock_strp_enabled(struct sk_psock *psock) · 506 unmodified lines
507507 return !!psock->saved_data_ready;
508508 }
509509
510+static inline bool sk_is_tcp(const struct sock *sk)
511+{
512+ return sk->sk_type == SOCK_STREAM &&
513+ sk->sk_protocol == IPPROTO_TCP;
514+}
515+
516+static inline bool sk_is_udp(const struct sock *sk)
517+{
518+ return sk->sk_type == SOCK_DGRAM &&
519+ sk->sk_protocol == IPPROTO_UDP;
520+}
521+
510522 #if IS_ENABLED(CONFIG_NET_SOCK_MSG)
511523
512524 #define BPF_F_STRPARSER (1UL << 1)
include/net/llc.h+3−1
@@ -72,7 +72,9 @@ struct llc_sap { · 71 unmodified lines
7272 static inline
7373 struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex)
7474 {
75− return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES];
75+ u32 bucket = hash_32(ifindex, LLC_SK_DEV_HASH_BITS);
76+
77+ return &sap->sk_dev_hash[bucket];
7678 }
7779
7880 static inline
include/net/sctp/structs.h+10−10
@@ -1355,16 +1355,6 @@ struct sctp_endpoint { · 1354 unmodified lines
13551355 reconf_enable:1;
13561356
13571357 __u8 strreset_enable;
1358−
1359− /* Security identifiers from incoming (INIT). These are set by
1360− * security_sctp_assoc_request(). These will only be used by
1361− * SCTP TCP type sockets and peeled off connections as they
1362− * cause a new socket to be generated. security_sctp_sk_clone()
1363− * will then plug these into the new socket.
1364− */
1365−
1366− u32 secid;
1367− u32 peer_secid;
13681358 };
13691359
13701360 /* Recover the outter endpoint structure. */
@@ -2104,6 +2094,16 @@ struct sctp_association { · 733 unmodified lines
21042094 __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1];
21052095 __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1];
21062096
2097+ /* Security identifiers from incoming (INIT). These are set by
2098+ * security_sctp_assoc_request(). These will only be used by
2099+ * SCTP TCP type sockets and peeled off connections as they
2100+ * cause a new socket to be generated. security_sctp_sk_clone()
2101+ * will then plug these into the new socket.
2102+ */
2103+
2104+ u32 secid;
2105+ u32 peer_secid;
2106+
21072107 struct rcu_head rcu;
21082108 };
21092109
include/net/strparser.h+19−1
@@ -54,10 +54,28 @@ struct strp_msg { · 53 unmodified lines
5454 int offset;
5555 };
5656
57+struct _strp_msg {
58+ /* Internal cb structure. struct strp_msg must be first for passing
59+ * to upper layer.
60+ */
61+ struct strp_msg strp;
62+ int accum_len;
63+};
64+
65+struct sk_skb_cb {
66+#define SK_SKB_CB_PRIV_LEN 20
67+ unsigned char data[SK_SKB_CB_PRIV_LEN];
68+ struct _strp_msg strp;
69+ /* temp_reg is a temporary register used for bpf_convert_data_end_access
70+ * when dst_reg == src_reg.
71+ */
72+ u64 temp_reg;
73+};
74+
5775 static inline struct strp_msg *strp_msg(struct sk_buff *skb)
5876 {
5977 return (struct strp_msg *)((void *)skb->cb +
60− offsetof(struct qdisc_skb_cb, data));
78+ offsetof(struct sk_skb_cb, strp));
6179 }
6280
6381 /* Structure for an attached lower socket */
include/net/tcp.h+6−2
@@ -293,7 +293,10 @@ static inline bool tcp_out_of_memory(struct sock *sk) · 292 unmodified lines
293293 static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
294294 {
295295 sk_wmem_queued_add(sk, -skb->truesize);
296− sk_mem_uncharge(sk, skb->truesize);
296+ if (!skb_zcopy_pure(skb))
297+ sk_mem_uncharge(sk, skb->truesize);
298+ else
299+ sk_mem_uncharge(sk, SKB_TRUESIZE(skb_end_offset(skb)));
297300 __kfree_skb(skb);
298301 }
299302
@@ -974,7 +977,8 @@ static inline bool tcp_skb_can_collapse(const struct sk_buff *to, · 674 unmodified lines
974977 const struct sk_buff *from)
975978 {
976979 return likely(tcp_skb_can_collapse_to(to) &&
977− mptcp_skb_can_collapse(to, from));
980+ mptcp_skb_can_collapse(to, from) &&
981+ skb_pure_zcopy_same(to, from));
978982 }
979983
980984 /* Events passed to congestion control interface */
include/uapi/linux/ethtool_netlink.h+3−1
@@ -411,7 +411,9 @@ enum { · 410 unmodified lines
411411 ETHTOOL_A_PAUSE_STAT_TX_FRAMES,
412412 ETHTOOL_A_PAUSE_STAT_RX_FRAMES,
413413
414− /* add new constants above here */
414+ /* add new constants above here
415+ * adjust ETHTOOL_PAUSE_STAT_CNT if adding non-stats!
416+ */
415417 __ETHTOOL_A_PAUSE_STAT_CNT,
416418 ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1)
417419 };
kernel/bpf/core.c+7−0
@@ -390,6 +390,13 @@ static int bpf_adj_branches(struct bpf_prog *prog, u32 pos, s32 end_old, · 389 unmodified lines
390390 i = end_new;
391391 insn = prog->insnsi + end_old;
392392 }
393+ if (bpf_pseudo_func(insn)) {
394+ ret = bpf_adj_delta_to_imm(insn, pos, end_old,
395+ end_new, i, probe_pass);
396+ if (ret)
397+ return ret;
398+ continue;
399+ }
393400 code = insn->code;
394401 if ((BPF_CLASS(code) != BPF_JMP &&
395402 BPF_CLASS(code) != BPF_JMP32) ||
kernel/bpf/verifier.c+20−35
@@ -240,12 +240,6 @@ static bool bpf_pseudo_kfunc_call(const struct bpf_insn *insn) · 239 unmodified lines
240240 insn->src_reg == BPF_PSEUDO_KFUNC_CALL;
241241 }
242242
243−static bool bpf_pseudo_func(const struct bpf_insn *insn)
244−{
245− return insn->code == (BPF_LD | BPF_IMM | BPF_DW) &&
246− insn->src_reg == BPF_PSEUDO_FUNC;
247−}
248−
249243 struct bpf_call_arg_meta {
250244 struct bpf_map *map_ptr;
251245 bool raw_mode;
@@ -1960,16 +1954,10 @@ static int add_subprog_and_kfunc(struct bpf_verifier_env *env) · 1708 unmodified lines
19601954 return -EPERM;
19611955 }
19621956
1963− if (bpf_pseudo_func(insn)) {
1964− ret = add_subprog(env, i + insn->imm + 1);
1965− if (ret >= 0)
1966− /* remember subprog */
1967− insn[1].imm = ret;
1968− } else if (bpf_pseudo_call(insn)) {
1957+ if (bpf_pseudo_func(insn) || bpf_pseudo_call(insn))
19691958 ret = add_subprog(env, i + insn->imm + 1);
1970− } else {
1959+ else
19711960 ret = add_kfunc_call(env, insn->imm, insn->off);
1972− }
19731961
19741962 if (ret < 0)
19751963 return ret;
@@ -3088,9 +3076,12 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, · 1112 unmodified lines
30883076 reg = &reg_state->stack[spi].spilled_ptr;
30893077
30903078 if (is_spilled_reg(&reg_state->stack[spi])) {
3091− if (size != BPF_REG_SIZE) {
3092− u8 scalar_size = 0;
3079+ u8 spill_size = 1;
3080+
3081+ for (i = BPF_REG_SIZE - 1; i > 0 && stype[i - 1] == STACK_SPILL; i--)
3082+ spill_size++;
30933083
3084+ if (size != BPF_REG_SIZE || spill_size != BPF_REG_SIZE) {
30943085 if (reg->type != SCALAR_VALUE) {
30953086 verbose_linfo(env, env->insn_idx, "; ");
30963087 verbose(env, "invalid size of register fill\n");
@@ -3101,10 +3092,7 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, · 4 unmodified lines
31013092 if (dst_regno < 0)
31023093 return 0;
31033094
3104− for (i = BPF_REG_SIZE; i > 0 && stype[i - 1] == STACK_SPILL; i--)
3105− scalar_size++;
3106−
3107− if (!(off % BPF_REG_SIZE) && size == scalar_size) {
3095+ if (!(off % BPF_REG_SIZE) && size == spill_size) {
31083096 /* The earlier check_reg_arg() has decided the
31093097 * subreg_def for this insn. Save it first.
31103098 */
@@ -3128,12 +3116,6 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, · 17 unmodified lines
31283116 state->regs[dst_regno].live |= REG_LIVE_WRITTEN;
31293117 return 0;
31303118 }
3131− for (i = 1; i < BPF_REG_SIZE; i++) {
3132− if (stype[(slot - i) % BPF_REG_SIZE] != STACK_SPILL) {
3133− verbose(env, "corrupted spill memory\n");
3134− return -EACCES;
3135− }
3136− }
31373119
31383120 if (dst_regno >= 0) {
31393121 /* restore register state from stack */
@@ -9393,7 +9375,8 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn) · 6253 unmodified lines
93939375
93949376 if (insn->src_reg == BPF_PSEUDO_FUNC) {
93959377 struct bpf_prog_aux *aux = env->prog->aux;
9396− u32 subprogno = insn[1].imm;
9378+ u32 subprogno = find_subprog(env,
9379+ env->insn_idx + insn->imm + 1);
93979380
93989381 if (!aux->func_info) {
93999382 verbose(env, "missing btf func_info\n");
@@ -12563,14 +12546,9 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 3163 unmodified lines
1256312546 return 0;
1256412547
1256512548 for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) {
12566− if (bpf_pseudo_func(insn)) {
12567− env->insn_aux_data[i].call_imm = insn->imm;
12568− /* subprog is encoded in insn[1].imm */
12549+ if (!bpf_pseudo_func(insn) && !bpf_pseudo_call(insn))
1256912550 continue;
12570− }
1257112551
12572− if (!bpf_pseudo_call(insn))
12573− continue;
1257412552 /* Upon error here we cannot fall back to interpreter but
1257512553 * need a hard reject of the program. Thus -EFAULT is
1257612554 * propagated in any case.
@@ -12591,6 +12569,12 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 14 unmodified lines
1259112569 env->insn_aux_data[i].call_imm = insn->imm;
1259212570 /* point imm to __bpf_call_base+1 from JITs point of view */
1259312571 insn->imm = 1;
12572+ if (bpf_pseudo_func(insn))
12573+ /* jit (e.g. x86_64) may emit fewer instructions
12574+ * if it learns a u32 imm is the same as a u64 imm.
12575+ * Force a non zero here.
12576+ */
12577+ insn[1].imm = 1;
1259412578 }
1259512579
1259612580 err = bpf_prog_alloc_jited_linfo(prog);
@@ -12675,7 +12659,7 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 78 unmodified lines
1267512659 insn = func[i]->insnsi;
1267612660 for (j = 0; j < func[i]->len; j++, insn++) {
1267712661 if (bpf_pseudo_func(insn)) {
12678− subprog = insn[1].imm;
12662+ subprog = insn->off;
1267912663 insn[0].imm = (u32)(long)func[subprog]->bpf_func;
1268012664 insn[1].imm = ((u64)(long)func[subprog]->bpf_func) >> 32;
1268112665 continue;
@@ -12726,7 +12710,8 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 44 unmodified lines
1272612710 for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) {
1272712711 if (bpf_pseudo_func(insn)) {
1272812712 insn[0].imm = env->insn_aux_data[i].call_imm;
12729− insn[1].imm = find_subprog(env, i + insn[0].imm + 1);
12713+ insn[1].imm = insn->off;
12714+ insn->off = 0;
1273012715 continue;
1273112716 }
1273212717 if (!bpf_pseudo_call(insn))
mm/shmem.c+1−23
@@ -2960,28 +2960,6 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry) · 2959 unmodified lines
29602960 return shmem_unlink(dir, dentry);
29612961 }
29622962
2963−static int shmem_exchange(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
2964−{
2965− bool old_is_dir = d_is_dir(old_dentry);
2966− bool new_is_dir = d_is_dir(new_dentry);
2967−
2968− if (old_dir != new_dir && old_is_dir != new_is_dir) {
2969− if (old_is_dir) {
2970− drop_nlink(old_dir);
2971− inc_nlink(new_dir);
2972− } else {
2973− drop_nlink(new_dir);
2974− inc_nlink(old_dir);
2975− }
2976− }
2977− old_dir->i_ctime = old_dir->i_mtime =
2978− new_dir->i_ctime = new_dir->i_mtime =
2979− d_inode(old_dentry)->i_ctime =
2980− d_inode(new_dentry)->i_ctime = current_time(old_dir);
2981−
2982− return 0;
2983−}
2984−
29852963 static int shmem_whiteout(struct user_namespace *mnt_userns,
29862964 struct inode *old_dir, struct dentry *old_dentry)
29872965 {
@@ -3027,7 +3005,7 @@ static int shmem_rename2(struct user_namespace *mnt_userns, · 39 unmodified lines
30273005 return -EINVAL;
30283006
30293007 if (flags & RENAME_EXCHANGE)
3030− return shmem_exchange(old_dir, old_dentry, new_dir, new_dentry);
3008+ return simple_rename_exchange(old_dir, old_dentry, new_dir, new_dentry);
30313009
30323010 if (!simple_empty(new_dentry))
30333011 return -ENOTEMPTY;
net/8021q/vlan.c+0−3
@@ -123,9 +123,6 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) · 122 unmodified lines
123123 }
124124
125125 vlan_vid_del(real_dev, vlan->vlan_proto, vlan_id);
126−
127− /* Get rid of the vlan's reference to real_dev */
128− dev_put(real_dev);
129126 }
130127
131128 int vlan_check_real_dev(struct net_device *real_dev,
net/8021q/vlan_dev.c+3−0
@@ -843,6 +843,9 @@ static void vlan_dev_free(struct net_device *dev) · 842 unmodified lines
843843
844844 free_percpu(vlan->vlan_pcpu_stats);
845845 vlan->vlan_pcpu_stats = NULL;
846+
847+ /* Get rid of the vlan's reference to real_dev */
848+ dev_put(vlan->real_dev);
846849 }
847850
848851 void vlan_setup(struct net_device *dev)
net/can/j1939/main.c+7−0
@@ -75,6 +75,13 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data) · 74 unmodified lines
7575 skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX;
7676 /* set default message type */
7777 skcb->addr.type = J1939_TP;
78+
79+ if (!j1939_address_is_valid(skcb->addr.sa)) {
80+ netdev_err_once(priv->ndev, "%s: sa is broadcast address, ignoring!\n",
81+ __func__);
82+ goto done;
83+ }
84+
7885 if (j1939_pgn_is_pdu1(skcb->addr.pgn)) {
7986 /* Type 1: with destination address */
8087 skcb->addr.da = skcb->addr.pgn;
net/can/j1939/transport.c+11−0
@@ -2023,6 +2023,11 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb) · 2022 unmodified lines
20232023 extd = J1939_ETP;
20242024 fallthrough;
20252025 case J1939_TP_CMD_BAM:
2026+ if (cmd == J1939_TP_CMD_BAM && !j1939_cb_is_broadcast(skcb)) {
2027+ netdev_err_once(priv->ndev, "%s: BAM to unicast (%02x), ignoring!\n",
2028+ __func__, skcb->addr.sa);
2029+ return;
2030+ }
20262031 fallthrough;
20272032 case J1939_TP_CMD_RTS:
20282033 if (skcb->addr.type != extd)
@@ -2085,6 +2090,12 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb) · 56 unmodified lines
20852090 break;
20862091
20872092 case J1939_ETP_CMD_ABORT: /* && J1939_TP_CMD_ABORT */
2093+ if (j1939_cb_is_broadcast(skcb)) {
2094+ netdev_err_once(priv->ndev, "%s: abort to broadcast (%02x), ignoring!\n",
2095+ __func__, skcb->addr.sa);
2096+ return;
2097+ }
2098+
20882099 if (j1939_tp_im_transmitter(skcb))
20892100 j1939_xtp_rx_abort(priv, skb, true);
20902101
net/core/datagram.c+2−1
@@ -646,7 +646,8 @@ int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb, · 645 unmodified lines
646646 skb->truesize += truesize;
647647 if (sk && sk->sk_type == SOCK_STREAM) {
648648 sk_wmem_queued_add(sk, truesize);
649− sk_mem_charge(sk, truesize);
649+ if (!skb_zcopy_pure(skb))
650+ sk_mem_charge(sk, truesize);
650651 } else {
651652 refcount_add(truesize, &skb->sk->sk_wmem_alloc);
652653 }
net/core/dev.c+5−2
@@ -6928,7 +6928,7 @@ void napi_disable(struct napi_struct *n) · 6927 unmodified lines
69286928 might_sleep();
69296929 set_bit(NAPI_STATE_DISABLE, &n->state);
69306930
6931− do {
6931+ for ( ; ; ) {
69326932 val = READ_ONCE(n->state);
69336933 if (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
69346934 usleep_range(20, 200);
@@ -6937,7 +6937,10 @@ void napi_disable(struct napi_struct *n) · 2 unmodified lines
69376937
69386938 new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC;
69396939 new &= ~(NAPIF_STATE_THREADED | NAPIF_STATE_PREFER_BUSY_POLL);
6940− } while (cmpxchg(&n->state, val, new) != val);
6940+
6941+ if (cmpxchg(&n->state, val, new) == val)
6942+ break;
6943+ }
69416944
69426945 hrtimer_cancel(&n->timer);
69436946
net/core/devlink.c+1−1
@@ -66,7 +66,7 @@ struct devlink { · 65 unmodified lines
6666 u8 reload_failed:1;
6767 refcount_t refcount;
6868 struct completion comp;
69− char priv[0] __aligned(NETDEV_ALIGN);
69+ char priv[] __aligned(NETDEV_ALIGN);
7070 };
7171
7272 void *devlink_priv(struct devlink *devlink)
net/core/filter.c+56−8
@@ -9756,22 +9756,46 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type, · 9755 unmodified lines
97569756 static struct bpf_insn *bpf_convert_data_end_access(const struct bpf_insn *si,
97579757 struct bpf_insn *insn)
97589758 {
9759− /* si->dst_reg = skb->data */
9759+ int reg;
9760+ int temp_reg_off = offsetof(struct sk_buff, cb) +
9761+ offsetof(struct sk_skb_cb, temp_reg);
9762+
9763+ if (si->src_reg == si->dst_reg) {
9764+ /* We need an extra register, choose and save a register. */
9765+ reg = BPF_REG_9;
9766+ if (si->src_reg == reg || si->dst_reg == reg)
9767+ reg--;
9768+ if (si->src_reg == reg || si->dst_reg == reg)
9769+ reg--;
9770+ *insn++ = BPF_STX_MEM(BPF_DW, si->src_reg, reg, temp_reg_off);
9771+ } else {
9772+ reg = si->dst_reg;
9773+ }
9774+
9775+ /* reg = skb->data */
97609776 *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data),
9761− si->dst_reg, si->src_reg,
9777+ reg, si->src_reg,
97629778 offsetof(struct sk_buff, data));
97639779 /* AX = skb->len */
97649780 *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, len),
97659781 BPF_REG_AX, si->src_reg,
97669782 offsetof(struct sk_buff, len));
9767− /* si->dst_reg = skb->data + skb->len */
9768− *insn++ = BPF_ALU64_REG(BPF_ADD, si->dst_reg, BPF_REG_AX);
9783+ /* reg = skb->data + skb->len */
9784+ *insn++ = BPF_ALU64_REG(BPF_ADD, reg, BPF_REG_AX);
97699785 /* AX = skb->data_len */
97709786 *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data_len),
97719787 BPF_REG_AX, si->src_reg,
97729788 offsetof(struct sk_buff, data_len));
9773− /* si->dst_reg = skb->data + skb->len - skb->data_len */
9774− *insn++ = BPF_ALU64_REG(BPF_SUB, si->dst_reg, BPF_REG_AX);
9789+
9790+ /* reg = skb->data + skb->len - skb->data_len */
9791+ *insn++ = BPF_ALU64_REG(BPF_SUB, reg, BPF_REG_AX);
9792+
9793+ if (si->src_reg == si->dst_reg) {
9794+ /* Restore the saved register */
9795+ *insn++ = BPF_MOV64_REG(BPF_REG_AX, si->src_reg);
9796+ *insn++ = BPF_MOV64_REG(si->dst_reg, reg);
9797+ *insn++ = BPF_LDX_MEM(BPF_DW, reg, BPF_REG_AX, temp_reg_off);
9798+ }
97759799
97769800 return insn;
97779801 }
@@ -9782,11 +9806,33 @@ static u32 sk_skb_convert_ctx_access(enum bpf_access_type type, · 4 unmodified lines
97829806 struct bpf_prog *prog, u32 *target_size)
97839807 {
97849808 struct bpf_insn *insn = insn_buf;
9809+ int off;
97859810
97869811 switch (si->off) {
97879812 case offsetof(struct __sk_buff, data_end):
97889813 insn = bpf_convert_data_end_access(si, insn);
97899814 break;
9815+ case offsetof(struct __sk_buff, cb[0]) ...
9816+ offsetofend(struct __sk_buff, cb[4]) - 1:
9817+ BUILD_BUG_ON(sizeof_field(struct sk_skb_cb, data) < 20);
9818+ BUILD_BUG_ON((offsetof(struct sk_buff, cb) +
9819+ offsetof(struct sk_skb_cb, data)) %
9820+ sizeof(__u64));
9821+
9822+ prog->cb_access = 1;
9823+ off = si->off;
9824+ off -= offsetof(struct __sk_buff, cb[0]);
9825+ off += offsetof(struct sk_buff, cb);
9826+ off += offsetof(struct sk_skb_cb, data);
9827+ if (type == BPF_WRITE)
9828+ *insn++ = BPF_STX_MEM(BPF_SIZE(si->code), si->dst_reg,
9829+ si->src_reg, off);
9830+ else
9831+ *insn++ = BPF_LDX_MEM(BPF_SIZE(si->code), si->dst_reg,
9832+ si->src_reg, off);
9833+ break;
9834+
9835+
97909836 default:
97919837 return bpf_convert_ctx_access(type, si, insn_buf, prog,
97929838 target_size);
@@ -10423,8 +10469,10 @@ BPF_CALL_3(bpf_sk_lookup_assign, struct bpf_sk_lookup_kern *, ctx, · 630 unmodified lines
1042310469 return -EINVAL;
1042410470 if (unlikely(sk && sk_is_refcounted(sk)))
1042510471 return -ESOCKTNOSUPPORT; /* reject non-RCU freed sockets */
10426− if (unlikely(sk && sk->sk_state == TCP_ESTABLISHED))
10427− return -ESOCKTNOSUPPORT; /* reject connected sockets */
10472+ if (unlikely(sk && sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN))
10473+ return -ESOCKTNOSUPPORT; /* only accept TCP socket in LISTEN */
10474+ if (unlikely(sk && sk_is_udp(sk) && sk->sk_state != TCP_CLOSE))
10475+ return -ESOCKTNOSUPPORT; /* only accept UDP socket in CLOSE */
1042810476
1042910477 /* Check if socket is suitable for packet L3/L4 protocol */
1043010478 if (sk && sk->sk_protocol != ctx->protocol)
net/core/skbuff.c+3−14
@@ -3433,8 +3433,9 @@ static inline void skb_split_no_header(struct sk_buff *skb, · 3432 unmodified lines
34333433 void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
34343434 {
34353435 int pos = skb_headlen(skb);
3436+ const int zc_flags = SKBFL_SHARED_FRAG | SKBFL_PURE_ZEROCOPY;
34363437
3437− skb_shinfo(skb1)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
3438+ skb_shinfo(skb1)->flags |= skb_shinfo(skb)->flags & zc_flags;
34383439 skb_zerocopy_clone(skb1, skb, 0);
34393440 if (len < pos) /* Split line is inside header. */
34403441 skb_split_inside_header(skb, skb1, len, pos);
@@ -3449,19 +3450,7 @@ EXPORT_SYMBOL(skb_split); · 8 unmodified lines
34493450 */
34503451 static int skb_prepare_for_shift(struct sk_buff *skb)
34513452 {
3452− int ret = 0;
3453−
3454− if (skb_cloned(skb)) {
3455− /* Save and restore truesize: pskb_expand_head() may reallocate
3456− * memory where ksize(kmalloc(S)) != ksize(kmalloc(S)), but we
3457− * cannot change truesize at this point.
3458− */
3459− unsigned int save_truesize = skb->truesize;
3460−
3461− ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
3462− skb->truesize = save_truesize;
3463− }
3464− return ret;
3453+ return skb_unclone_keeptruesize(skb, GFP_ATOMIC);
34653454 }
34663455
34673456 /**
net/core/sock.c+1−1
@@ -976,7 +976,7 @@ static int sock_reserve_memory(struct sock *sk, int bytes) · 975 unmodified lines
976976 bool charged;
977977 int pages;
978978
979− if (!mem_cgroup_sockets_enabled || !sk->sk_memcg)
979+ if (!mem_cgroup_sockets_enabled || !sk->sk_memcg || !sk_has_account(sk))
980980 return -EOPNOTSUPP;
981981
982982 if (!bytes)
net/core/sock_map.c+0−6
@@ -511,12 +511,6 @@ static bool sock_map_op_okay(const struct bpf_sock_ops_kern *ops) · 510 unmodified lines
511511 ops->op == BPF_SOCK_OPS_TCP_LISTEN_CB;
512512 }
513513
514−static bool sk_is_tcp(const struct sock *sk)
515−{
516− return sk->sk_type == SOCK_STREAM &&
517− sk->sk_protocol == IPPROTO_TCP;
518−}
519−
520514 static bool sock_map_redirect_allowed(const struct sock *sk)
521515 {
522516 if (sk_is_tcp(sk))
net/dsa/tag_ocelot.c+3−0
@@ -101,6 +101,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, · 100 unmodified lines
101101 struct dsa_port *dp;
102102 u8 *extraction;
103103 u16 vlan_tpid;
104+ u64 rew_val;
104105
105106 /* Revert skb->data by the amount consumed by the DSA master,
106107 * so it points to the beginning of the frame.
@@ -130,6 +131,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, · 23 unmodified lines
130131 ocelot_xfh_get_qos_class(extraction, &qos_class);
131132 ocelot_xfh_get_tag_type(extraction, &tag_type);
132133 ocelot_xfh_get_vlan_tci(extraction, &vlan_tci);
134+ ocelot_xfh_get_rew_val(extraction, &rew_val);
133135
134136 skb->dev = dsa_master_find_slave(netdev, 0, src_port);
135137 if (!skb->dev)
@@ -143,6 +145,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, · 7 unmodified lines
143145
144146 dsa_default_offload_fwd_mark(skb);
145147 skb->priority = qos_class;
148+ OCELOT_SKB_CB(skb)->tstamp_lo = rew_val;
146149
147150 /* Ocelot switches copy frames unmodified to the CPU. However, it is
148151 * possible for the user to request a VLAN modification through
net/ethtool/pause.c+1−2
@@ -56,8 +56,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base, · 55 unmodified lines
5656
5757 if (req_base->flags & ETHTOOL_FLAG_STATS)
5858 n += nla_total_size(0) + /* _PAUSE_STATS */
59− nla_total_size_64bit(sizeof(u64)) *
60− (ETHTOOL_A_PAUSE_STAT_MAX - 2);
59+ nla_total_size_64bit(sizeof(u64)) * ETHTOOL_PAUSE_STAT_CNT;
6160 return n;
6261 }
6362
net/ipv4/tcp.c+20−2
@@ -862,6 +862,7 @@ struct sk_buff *tcp_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, · 861 unmodified lines
862862 if (likely(skb)) {
863863 bool mem_scheduled;
864864
865+ skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
865866 if (force_schedule) {
866867 mem_scheduled = true;
867868 sk_forced_mem_schedule(sk, skb->truesize);
@@ -1318,6 +1319,15 @@ new_segment: · 450 unmodified lines
13181319
13191320 copy = min_t(int, copy, pfrag->size - pfrag->offset);
13201321
1322+ /* skb changing from pure zc to mixed, must charge zc */
1323+ if (unlikely(skb_zcopy_pure(skb))) {
1324+ if (!sk_wmem_schedule(sk, skb->data_len))
1325+ goto wait_for_space;
1326+
1327+ sk_mem_charge(sk, skb->data_len);
1328+ skb_shinfo(skb)->flags &= ~SKBFL_PURE_ZEROCOPY;
1329+ }
1330+
13211331 if (!sk_wmem_schedule(sk, copy))
13221332 goto wait_for_space;
13231333
@@ -1338,8 +1348,16 @@ new_segment: · 14 unmodified lines
13381348 }
13391349 pfrag->offset += copy;
13401350 } else {
1341− if (!sk_wmem_schedule(sk, copy))
1342− goto wait_for_space;
1351+ /* First append to a fragless skb builds initial
1352+ * pure zerocopy skb
1353+ */
1354+ if (!skb->len)
1355+ skb_shinfo(skb)->flags |= SKBFL_PURE_ZEROCOPY;
1356+
1357+ if (!skb_zcopy_pure(skb)) {
1358+ if (!sk_wmem_schedule(sk, copy))
1359+ goto wait_for_space;
1360+ }
13431361
13441362 err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg);
13451363 if (err == -EMSGSIZE || err == -EEXIST) {
net/ipv4/tcp_bpf.c+47−1
@@ -172,6 +172,41 @@ static int tcp_msg_wait_data(struct sock *sk, struct sk_psock *psock, · 171 unmodified lines
172172 return ret;
173173 }
174174
175+static int tcp_bpf_recvmsg_parser(struct sock *sk,
176+ struct msghdr *msg,
177+ size_t len,
178+ int nonblock,
179+ int flags,
180+ int *addr_len)
181+{
182+ struct sk_psock *psock;
183+ int copied;
184+
185+ if (unlikely(flags & MSG_ERRQUEUE))
186+ return inet_recv_error(sk, msg, len, addr_len);
187+
188+ psock = sk_psock_get(sk);
189+ if (unlikely(!psock))
190+ return tcp_recvmsg(sk, msg, len, nonblock, flags, addr_len);
191+
192+ lock_sock(sk);
193+msg_bytes_ready:
194+ copied = sk_msg_recvmsg(sk, psock, msg, len, flags);
195+ if (!copied) {
196+ long timeo;
197+ int data;
198+
199+ timeo = sock_rcvtimeo(sk, nonblock);
200+ data = tcp_msg_wait_data(sk, psock, timeo);
201+ if (data && !sk_psock_queue_empty(psock))
202+ goto msg_bytes_ready;
203+ copied = -EAGAIN;
204+ }
205+ release_sock(sk);
206+ sk_psock_put(sk, psock);
207+ return copied;
208+}
209+
175210 static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
176211 int nonblock, int flags, int *addr_len)
177212 {
@@ -464,6 +499,8 @@ enum { · 286 unmodified lines
464499 enum {
465500 TCP_BPF_BASE,
466501 TCP_BPF_TX,
502+ TCP_BPF_RX,
503+ TCP_BPF_TXRX,
467504 TCP_BPF_NUM_CFGS,
468505 };
469506
@@ -475,7 +512,6 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], · 5 unmodified lines
475512 struct proto *base)
476513 {
477514 prot[TCP_BPF_BASE] = *base;
478− prot[TCP_BPF_BASE].unhash = sock_map_unhash;
479515 prot[TCP_BPF_BASE].close = sock_map_close;
480516 prot[TCP_BPF_BASE].recvmsg = tcp_bpf_recvmsg;
481517 prot[TCP_BPF_BASE].sock_is_readable = sk_msg_is_readable;
@@ -483,6 +519,12 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], · 1 unmodified line
483519 prot[TCP_BPF_TX] = prot[TCP_BPF_BASE];
484520 prot[TCP_BPF_TX].sendmsg = tcp_bpf_sendmsg;
485521 prot[TCP_BPF_TX].sendpage = tcp_bpf_sendpage;
522+
523+ prot[TCP_BPF_RX] = prot[TCP_BPF_BASE];
524+ prot[TCP_BPF_RX].recvmsg = tcp_bpf_recvmsg_parser;
525+
526+ prot[TCP_BPF_TXRX] = prot[TCP_BPF_TX];
527+ prot[TCP_BPF_TXRX].recvmsg = tcp_bpf_recvmsg_parser;
486528 }
487529
488530 static void tcp_bpf_check_v6_needs_rebuild(struct proto *ops)
@@ -520,6 +562,10 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) · 31 unmodified lines
520562 int family = sk->sk_family == AF_INET6 ? TCP_BPF_IPV6 : TCP_BPF_IPV4;
521563 int config = psock->progs.msg_parser ? TCP_BPF_TX : TCP_BPF_BASE;
522564
565+ if (psock->progs.stream_verdict || psock->progs.skb_verdict) {
566+ config = (config == TCP_BPF_TX) ? TCP_BPF_TXRX : TCP_BPF_RX;
567+ }
568+
523569 if (restore) {
524570 if (inet_csk_has_ulp(sk)) {
525571 /* TLS does not have an unhash proto in SW cases,
net/ipv4/tcp_output.c+15−12
@@ -408,13 +408,13 @@ static inline bool tcp_urg_mode(const struct tcp_sock *tp) · 407 unmodified lines
408408 return tp->snd_una != tp->snd_up;
409409 }
410410
411−#define OPTION_SACK_ADVERTISE (1 << 0)
412−#define OPTION_TS (1 << 1)
413−#define OPTION_MD5 (1 << 2)
414−#define OPTION_WSCALE (1 << 3)
415−#define OPTION_FAST_OPEN_COOKIE (1 << 8)
416−#define OPTION_SMC (1 << 9)
417−#define OPTION_MPTCP (1 << 10)
411+#define OPTION_SACK_ADVERTISE BIT(0)
412+#define OPTION_TS BIT(1)
413+#define OPTION_MD5 BIT(2)
414+#define OPTION_WSCALE BIT(3)
415+#define OPTION_FAST_OPEN_COOKIE BIT(8)
416+#define OPTION_SMC BIT(9)
417+#define OPTION_MPTCP BIT(10)
418418
419419 static void smc_options_write(__be32 *ptr, u16 *options)
420420 {
@@ -1559,7 +1559,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, · 1138 unmodified lines
15591559 return -ENOMEM;
15601560 }
15611561
1562− if (skb_unclone(skb, gfp))
1562+ if (skb_unclone_keeptruesize(skb, gfp))
15631563 return -ENOMEM;
15641564
15651565 /* Get a new skb... force flag on. */
@@ -1667,7 +1667,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) · 101 unmodified lines
16671667 {
16681668 u32 delta_truesize;
16691669
1670− if (skb_unclone(skb, GFP_ATOMIC))
1670+ if (skb_unclone_keeptruesize(skb, GFP_ATOMIC))
16711671 return -ENOMEM;
16721672
16731673 delta_truesize = __pskb_trim_head(skb, len);
@@ -1677,7 +1677,8 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) · 3 unmodified lines
16771677 if (delta_truesize) {
16781678 skb->truesize -= delta_truesize;
16791679 sk_wmem_queued_add(sk, -delta_truesize);
1680− sk_mem_uncharge(sk, delta_truesize);
1680+ if (!skb_zcopy_pure(skb))
1681+ sk_mem_uncharge(sk, delta_truesize);
16811682 }
16821683
16831684 /* Any change of skb->len requires recalculation of tso factor. */
@@ -2295,7 +2296,9 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len) · 611 unmodified lines
22952296 if (len <= skb->len)
22962297 break;
22972298
2298− if (unlikely(TCP_SKB_CB(skb)->eor) || tcp_has_tx_tstamp(skb))
2299+ if (unlikely(TCP_SKB_CB(skb)->eor) ||
2300+ tcp_has_tx_tstamp(skb) ||
2301+ !skb_pure_zcopy_same(skb, next))
22992302 return false;
23002303
23012304 len -= skb->len;
@@ -3166,7 +3169,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) · 864 unmodified lines
31663169 cur_mss, GFP_ATOMIC))
31673170 return -ENOMEM; /* We'll try again later. */
31683171 } else {
3169− if (skb_unclone(skb, GFP_ATOMIC))
3172+ if (skb_unclone_keeptruesize(skb, GFP_ATOMIC))
31703173 return -ENOMEM;
31713174
31723175 diff = tcp_skb_pcount(skb);
net/ipv6/seg6.c+1−1
@@ -378,7 +378,7 @@ static int __net_init seg6_net_init(struct net *net) · 377 unmodified lines
378378 kfree(rcu_dereference_raw(sdata->tun_src));
379379 kfree(sdata);
380380 return -ENOMEM;
381− };
381+ }
382382 #endif
383383
384384 return 0;
net/ipv6/tcp_ipv6.c+0−1
@@ -1263,7 +1263,6 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * · 1262 unmodified lines
12631263
12641264 inet_sk(newsk)->pinet6 = tcp_inet6_sk(newsk);
12651265
1266− newinet = inet_sk(newsk);
12671266 newnp = tcp_inet6_sk(newsk);
12681267 newtp = tcp_sk(newsk);
12691268
net/ipv6/udp.c+3−3
@@ -700,9 +700,9 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) · 699 unmodified lines
700700
701701 ret = encap_rcv(sk, skb);
702702 if (ret <= 0) {
703− __UDP_INC_STATS(sock_net(sk),
704− UDP_MIB_INDATAGRAMS,
705− is_udplite);
703+ __UDP6_INC_STATS(sock_net(sk),
704+ UDP_MIB_INDATAGRAMS,
705+ is_udplite);
706706 return -ret;
707707 }
708708 }
net/mctp/af_mctp.c+23−1
@@ -33,6 +33,19 @@ static int mctp_release(struct socket *sock) · 32 unmodified lines
3333 return 0;
3434 }
3535
36+/* Generic sockaddr checks, padding checks only so far */
37+static bool mctp_sockaddr_is_ok(const struct sockaddr_mctp *addr)
38+{
39+ return !addr->__smctp_pad0 && !addr->__smctp_pad1;
40+}
41+
42+static bool mctp_sockaddr_ext_is_ok(const struct sockaddr_mctp_ext *addr)
43+{
44+ return !addr->__smctp_pad0[0] &&
45+ !addr->__smctp_pad0[1] &&
46+ !addr->__smctp_pad0[2];
47+}
48+
3649 static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
3750 {
3851 struct sock *sk = sock->sk;
@@ -52,6 +65,9 @@ static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen) · 13 unmodified lines
5265 /* it's a valid sockaddr for MCTP, cast and do protocol checks */
5366 smctp = (struct sockaddr_mctp *)addr;
5467
68+ if (!mctp_sockaddr_is_ok(smctp))
69+ return -EINVAL;
70+
5571 lock_sock(sk);
5672
5773 /* TODO: allow rebind */
@@ -87,6 +103,8 @@ static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) · 29 unmodified lines
87103 return -EINVAL;
88104 if (addr->smctp_family != AF_MCTP)
89105 return -EINVAL;
106+ if (!mctp_sockaddr_is_ok(addr))
107+ return -EINVAL;
90108 if (addr->smctp_tag & ~(MCTP_TAG_MASK | MCTP_TAG_OWNER))
91109 return -EINVAL;
92110
@@ -124,7 +142,8 @@ static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) · 31 unmodified lines
124142 DECLARE_SOCKADDR(struct sockaddr_mctp_ext *,
125143 extaddr, msg->msg_name);
126144
127− if (extaddr->smctp_halen > sizeof(cb->haddr)) {
145+ if (!mctp_sockaddr_ext_is_ok(extaddr) ||
146+ extaddr->smctp_halen > sizeof(cb->haddr)) {
128147 rc = -EINVAL;
129148 goto err_free;
130149 }
@@ -198,11 +217,13 @@ static int mctp_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, · 67 unmodified lines
198217
199218 addr = msg->msg_name;
200219 addr->smctp_family = AF_MCTP;
220+ addr->__smctp_pad0 = 0;
201221 addr->smctp_network = cb->net;
202222 addr->smctp_addr.s_addr = hdr->src;
203223 addr->smctp_type = type;
204224 addr->smctp_tag = hdr->flags_seq_tag &
205225 (MCTP_HDR_TAG_MASK | MCTP_HDR_FLAG_TO);
226+ addr->__smctp_pad1 = 0;
206227 msg->msg_namelen = sizeof(*addr);
207228
208229 if (msk->addr_ext) {
@@ -211,6 +232,7 @@ static int mctp_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, · 2 unmodified lines
211232 msg->msg_namelen = sizeof(*ae);
212233 ae->smctp_ifindex = cb->ifindex;
213234 ae->smctp_halen = cb->halen;
235+ memset(ae->__smctp_pad0, 0x0, sizeof(ae->__smctp_pad0));
214236 memset(ae->smctp_haddr, 0x0, sizeof(ae->smctp_haddr));
215237 memcpy(ae->smctp_haddr, cb->haddr, cb->halen);
216238 }
net/netfilter/ipvs/ip_vs_ctl.c+2−0
@@ -47,6 +47,8 @@ · 46 unmodified lines
4747
4848 #include <net/ip_vs.h>
4949
50+MODULE_ALIAS_GENL_FAMILY(IPVS_GENL_NAME);
51+
5052 /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */
5153 static DEFINE_MUTEX(__ip_vs_mutex);
5254
net/netfilter/nfnetlink_queue.c+1−1
@@ -560,7 +560,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, · 559 unmodified lines
560560 goto nla_put_failure;
561561
562562 if (indev && entskb->dev &&
563− entskb->mac_header != entskb->network_header) {
563+ skb_mac_header_was_set(entskb)) {
564564 struct nfqnl_msg_packet_hw phw;
565565 int len;
566566
net/nfc/netlink.c+15−0
@@ -1664,31 +1664,37 @@ static const struct genl_ops nfc_genl_ops[] = { · 1663 unmodified lines
16641664 .cmd = NFC_CMD_DEV_UP,
16651665 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
16661666 .doit = nfc_genl_dev_up,
1667+ .flags = GENL_ADMIN_PERM,
16671668 },
16681669 {
16691670 .cmd = NFC_CMD_DEV_DOWN,
16701671 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
16711672 .doit = nfc_genl_dev_down,
1673+ .flags = GENL_ADMIN_PERM,
16721674 },
16731675 {
16741676 .cmd = NFC_CMD_START_POLL,
16751677 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
16761678 .doit = nfc_genl_start_poll,
1679+ .flags = GENL_ADMIN_PERM,
16771680 },
16781681 {
16791682 .cmd = NFC_CMD_STOP_POLL,
16801683 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
16811684 .doit = nfc_genl_stop_poll,
1685+ .flags = GENL_ADMIN_PERM,
16821686 },
16831687 {
16841688 .cmd = NFC_CMD_DEP_LINK_UP,
16851689 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
16861690 .doit = nfc_genl_dep_link_up,
1691+ .flags = GENL_ADMIN_PERM,
16871692 },
16881693 {
16891694 .cmd = NFC_CMD_DEP_LINK_DOWN,
16901695 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
16911696 .doit = nfc_genl_dep_link_down,
1697+ .flags = GENL_ADMIN_PERM,
16921698 },
16931699 {
16941700 .cmd = NFC_CMD_GET_TARGET,
@@ -1706,26 +1712,31 @@ static const struct genl_ops nfc_genl_ops[] = { · 11 unmodified lines
17061712 .cmd = NFC_CMD_LLC_SET_PARAMS,
17071713 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17081714 .doit = nfc_genl_llc_set_params,
1715+ .flags = GENL_ADMIN_PERM,
17091716 },
17101717 {
17111718 .cmd = NFC_CMD_LLC_SDREQ,
17121719 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17131720 .doit = nfc_genl_llc_sdreq,
1721+ .flags = GENL_ADMIN_PERM,
17141722 },
17151723 {
17161724 .cmd = NFC_CMD_FW_DOWNLOAD,
17171725 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17181726 .doit = nfc_genl_fw_download,
1727+ .flags = GENL_ADMIN_PERM,
17191728 },
17201729 {
17211730 .cmd = NFC_CMD_ENABLE_SE,
17221731 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17231732 .doit = nfc_genl_enable_se,
1733+ .flags = GENL_ADMIN_PERM,
17241734 },
17251735 {
17261736 .cmd = NFC_CMD_DISABLE_SE,
17271737 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17281738 .doit = nfc_genl_disable_se,
1739+ .flags = GENL_ADMIN_PERM,
17291740 },
17301741 {
17311742 .cmd = NFC_CMD_GET_SE,
@@ -1737,21 +1748,25 @@ static const struct genl_ops nfc_genl_ops[] = { · 5 unmodified lines
17371748 .cmd = NFC_CMD_SE_IO,
17381749 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17391750 .doit = nfc_genl_se_io,
1751+ .flags = GENL_ADMIN_PERM,
17401752 },
17411753 {
17421754 .cmd = NFC_CMD_ACTIVATE_TARGET,
17431755 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17441756 .doit = nfc_genl_activate_target,
1757+ .flags = GENL_ADMIN_PERM,
17451758 },
17461759 {
17471760 .cmd = NFC_CMD_VENDOR,
17481761 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17491762 .doit = nfc_genl_vendor_cmd,
1763+ .flags = GENL_ADMIN_PERM,
17501764 },
17511765 {
17521766 .cmd = NFC_CMD_DEACTIVATE_TARGET,
17531767 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
17541768 .doit = nfc_genl_deactivate_target,
1769+ .flags = GENL_ADMIN_PERM,
17551770 },
17561771 };
17571772
net/sched/sch_taprio.c+17−10
@@ -95,18 +95,22 @@ static ktime_t sched_base_time(const struct sched_gate_list *sched) · 94 unmodified lines
9595 return ns_to_ktime(sched->base_time);
9696 }
9797
98−static ktime_t taprio_get_time(struct taprio_sched *q)
98+static ktime_t taprio_mono_to_any(const struct taprio_sched *q, ktime_t mono)
9999 {
100− ktime_t mono = ktime_get();
100+ /* This pairs with WRITE_ONCE() in taprio_parse_clockid() */
101+ enum tk_offsets tk_offset = READ_ONCE(q->tk_offset);
101102
102− switch (q->tk_offset) {
103+ switch (tk_offset) {
103104 case TK_OFFS_MAX:
104105 return mono;
105106 default:
106− return ktime_mono_to_any(mono, q->tk_offset);
107+ return ktime_mono_to_any(mono, tk_offset);
107108 }
109+}
108110
109− return KTIME_MAX;
111+static ktime_t taprio_get_time(const struct taprio_sched *q)
112+{
113+ return taprio_mono_to_any(q, ktime_get());
110114 }
111115
112116 static void taprio_free_sched_cb(struct rcu_head *head)
@@ -319,7 +323,7 @@ static ktime_t get_tcp_tstamp(struct taprio_sched *q, struct sk_buff *skb) · 206 unmodified lines
319323 return 0;
320324 }
321325
322− return ktime_mono_to_any(skb->skb_mstamp_ns, q->tk_offset);
326+ return taprio_mono_to_any(q, skb->skb_mstamp_ns);
323327 }
324328
325329 /* There are a few scenarios where we will have to modify the txtime from
@@ -1352,6 +1356,7 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, · 1026 unmodified lines
13521356 }
13531357 } else if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]) {
13541358 int clockid = nla_get_s32(tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]);
1359+ enum tk_offsets tk_offset;
13551360
13561361 /* We only support static clockids and we don't allow
13571362 * for it to be modified after the first init.
@@ -1366,22 +1371,24 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, · 8 unmodified lines
13661371
13671372 switch (clockid) {
13681373 case CLOCK_REALTIME:
1369− q->tk_offset = TK_OFFS_REAL;
1374+ tk_offset = TK_OFFS_REAL;
13701375 break;
13711376 case CLOCK_MONOTONIC:
1372− q->tk_offset = TK_OFFS_MAX;
1377+ tk_offset = TK_OFFS_MAX;
13731378 break;
13741379 case CLOCK_BOOTTIME:
1375− q->tk_offset = TK_OFFS_BOOT;
1380+ tk_offset = TK_OFFS_BOOT;
13761381 break;
13771382 case CLOCK_TAI:
1378− q->tk_offset = TK_OFFS_TAI;
1383+ tk_offset = TK_OFFS_TAI;
13791384 break;
13801385 default:
13811386 NL_SET_ERR_MSG(extack, "Invalid 'clockid'");
13821387 err = -EINVAL;
13831388 goto out;
13841389 }
1390+ /* This pairs with READ_ONCE() in taprio_mono_to_any */
1391+ WRITE_ONCE(q->tk_offset, tk_offset);
13851392
13861393 q->clockid = clockid;
13871394 } else {
net/sctp/sm_statefuns.c+18−16
@@ -326,11 +326,6 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net, · 325 unmodified lines
326326 struct sctp_packet *packet;
327327 int len;
328328
329− /* Update socket peer label if first association. */
330− if (security_sctp_assoc_request((struct sctp_endpoint *)ep,
331− chunk->skb))
332− return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
333−
334329 /* 6.10 Bundling
335330 * An endpoint MUST NOT bundle INIT, INIT ACK or
336331 * SHUTDOWN COMPLETE with any other chunks.
@@ -415,6 +410,12 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net, · 78 unmodified lines
415410 if (!new_asoc)
416411 goto nomem;
417412
413+ /* Update socket peer label if first association. */
414+ if (security_sctp_assoc_request(new_asoc, chunk->skb)) {
415+ sctp_association_free(new_asoc);
416+ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
417+ }
418+
418419 if (sctp_assoc_set_bind_addr_from_ep(new_asoc,
419420 sctp_scope(sctp_source(chunk)),
420421 GFP_ATOMIC) < 0)
@@ -780,6 +781,10 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, · 359 unmodified lines
780781 }
781782 }
782783
784+ if (security_sctp_assoc_request(new_asoc, chunk->skb)) {
785+ sctp_association_free(new_asoc);
786+ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
787+ }
783788
784789 /* Delay state machine commands until later.
785790 *
@@ -941,7 +946,7 @@ enum sctp_disposition sctp_sf_do_5_1E_ca(struct net *net, · 155 unmodified lines
941946 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL());
942947
943948 /* Set peer label for connection. */
944− security_inet_conn_established(ep->base.sk, chunk->skb);
949+ security_sctp_assoc_established((struct sctp_association *)asoc, chunk->skb);
945950
946951 /* RFC 2960 5.1 Normal Establishment of an Association
947952 *
@@ -1517,11 +1522,6 @@ static enum sctp_disposition sctp_sf_do_unexpected_init( · 569 unmodified lines
15171522 struct sctp_packet *packet;
15181523 int len;
15191524
1520− /* Update socket peer label if first association. */
1521− if (security_sctp_assoc_request((struct sctp_endpoint *)ep,
1522− chunk->skb))
1523− return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
1524−
15251525 /* 6.10 Bundling
15261526 * An endpoint MUST NOT bundle INIT, INIT ACK or
15271527 * SHUTDOWN COMPLETE with any other chunks.
@@ -1594,6 +1594,12 @@ static enum sctp_disposition sctp_sf_do_unexpected_init( · 66 unmodified lines
15941594 if (!new_asoc)
15951595 goto nomem;
15961596
1597+ /* Update socket peer label if first association. */
1598+ if (security_sctp_assoc_request(new_asoc, chunk->skb)) {
1599+ sctp_association_free(new_asoc);
1600+ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
1601+ }
1602+
15971603 if (sctp_assoc_set_bind_addr_from_ep(new_asoc,
15981604 sctp_scope(sctp_source(chunk)), GFP_ATOMIC) < 0)
15991605 goto nomem;
@@ -2255,8 +2261,7 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook( · 655 unmodified lines
22552261 }
22562262
22572263 /* Update socket peer label if first association. */
2258− if (security_sctp_assoc_request((struct sctp_endpoint *)ep,
2259− chunk->skb)) {
2264+ if (security_sctp_assoc_request(new_asoc, chunk->skb)) {
22602265 sctp_association_free(new_asoc);
22612266 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
22622267 }
@@ -4893,9 +4898,6 @@ static enum sctp_disposition sctp_sf_violation_chunk( · 2630 unmodified lines
48934898 {
48944899 static const char err_str[] = "The following chunk violates protocol:";
48954900
4896− if (!asoc)
4897− return sctp_sf_violation(net, ep, asoc, type, arg, commands);
4898−
48994901 return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str,
49004902 sizeof(err_str));
49014903 }
net/sctp/socket.c+2−3
@@ -9412,7 +9412,6 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, · 9411 unmodified lines
94129412 struct inet_sock *inet = inet_sk(sk);
94139413 struct inet_sock *newinet;
94149414 struct sctp_sock *sp = sctp_sk(sk);
9415− struct sctp_endpoint *ep = sp->ep;
94169415
94179416 newsk->sk_type = sk->sk_type;
94189417 newsk->sk_bound_dev_if = sk->sk_bound_dev_if;
@@ -9457,9 +9456,9 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, · 38 unmodified lines
94579456 net_enable_timestamp();
94589457
94599458 /* Set newsk security attributes from original sk and connection
9460− * security attribute from ep.
9459+ * security attribute from asoc.
94619460 */
9462− security_sctp_sk_clone(ep, sk, newsk);
9461+ security_sctp_sk_clone(asoc, sk, newsk);
94639462 }
94649463
94659464 static inline void sctp_copy_descendant(struct sock *sk_to,
net/smc/af_smc.c+11−7
@@ -149,14 +149,18 @@ static int __smc_release(struct smc_sock *smc) · 148 unmodified lines
149149 sock_set_flag(sk, SOCK_DEAD);
150150 sk->sk_shutdown |= SHUTDOWN_MASK;
151151 } else {
152− if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT)
153− sock_put(sk); /* passive closing */
154− if (sk->sk_state == SMC_LISTEN) {
155− /* wake up clcsock accept */
156− rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
152+ if (sk->sk_state != SMC_CLOSED) {
153+ if (sk->sk_state != SMC_LISTEN &&
154+ sk->sk_state != SMC_INIT)
155+ sock_put(sk); /* passive closing */
156+ if (sk->sk_state == SMC_LISTEN) {
157+ /* wake up clcsock accept */
158+ rc = kernel_sock_shutdown(smc->clcsock,
159+ SHUT_RDWR);
160+ }
161+ sk->sk_state = SMC_CLOSED;
162+ sk->sk_state_change(sk);
157163 }
158− sk->sk_state = SMC_CLOSED;
159− sk->sk_state_change(sk);
160164 smc_restore_fallback_changes(smc);
161165 }
162166
net/smc/smc_tracepoint.h+1−1
@@ -99,7 +99,7 @@ TRACE_EVENT(smcr_link_down, · 98 unmodified lines
9999 __entry->location = location;
100100 ),
101101
102− TP_printk("lnk=%p lgr=%p state=%d dev=%s location=%p",
102+ TP_printk("lnk=%p lgr=%p state=%d dev=%s location=%pS",
103103 __entry->lnk, __entry->lgr,
104104 __entry->state, __get_str(name),
105105 __entry->location)
net/strparser/strparser.c+1−9
@@ -27,18 +27,10 @@ · 26 unmodified lines
2727
2828 static struct workqueue_struct *strp_wq;
2929
30−struct _strp_msg {
31− /* Internal cb structure. struct strp_msg must be first for passing
32− * to upper layer.
33− */
34− struct strp_msg strp;
35− int accum_len;
36−};
37−
3830 static inline struct _strp_msg *_strp_msg(struct sk_buff *skb)
3931 {
4032 return (struct _strp_msg *)((void *)skb->cb +
41− offsetof(struct qdisc_skb_cb, data));
33+ offsetof(struct sk_skb_cb, strp));
4234 }
4335
4436 /* Lower lock held */
net/vmw_vsock/af_vsock.c+2−0
@@ -1322,6 +1322,8 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr, · 1321 unmodified lines
13221322 * non-blocking call.
13231323 */
13241324 err = -EALREADY;
1325+ if (flags & O_NONBLOCK)
1326+ goto out;
13251327 break;
13261328 default:
13271329 if ((sk->sk_state == TCP_LISTEN) ||
security/security.c+11−4
@@ -2367,9 +2367,9 @@ int security_tun_dev_open(void *security) · 2366 unmodified lines
23672367 }
23682368 EXPORT_SYMBOL(security_tun_dev_open);
23692369
2370−int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb)
2370+int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb)
23712371 {
2372− return call_int_hook(sctp_assoc_request, 0, ep, skb);
2372+ return call_int_hook(sctp_assoc_request, 0, asoc, skb);
23732373 }
23742374 EXPORT_SYMBOL(security_sctp_assoc_request);
23752375
@@ -2381,13 +2381,20 @@ int security_sctp_bind_connect(struct sock *sk, int optname, · 5 unmodified lines
23812381 }
23822382 EXPORT_SYMBOL(security_sctp_bind_connect);
23832383
2384−void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
2384+void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
23852385 struct sock *newsk)
23862386 {
2387− call_void_hook(sctp_sk_clone, ep, sk, newsk);
2387+ call_void_hook(sctp_sk_clone, asoc, sk, newsk);
23882388 }
23892389 EXPORT_SYMBOL(security_sctp_sk_clone);
23902390
2391+void security_sctp_assoc_established(struct sctp_association *asoc,
2392+ struct sk_buff *skb)
2393+{
2394+ call_void_hook(sctp_assoc_established, asoc, skb);
2395+}
2396+EXPORT_SYMBOL(security_sctp_assoc_established);
2397+
23912398 #endif /* CONFIG_SECURITY_NETWORK */
23922399
23932400 #ifdef CONFIG_SECURITY_INFINIBAND
security/selinux/hooks.c+23−11
@@ -5339,10 +5339,10 @@ static void selinux_sock_graft(struct sock *sk, struct socket *parent) · 5338 unmodified lines
53395339 * connect(2), sctp_connectx(3) or sctp_sendmsg(3) (with no association
53405340 * already present).
53415341 */
5342−static int selinux_sctp_assoc_request(struct sctp_endpoint *ep,
5342+static int selinux_sctp_assoc_request(struct sctp_association *asoc,
53435343 struct sk_buff *skb)
53445344 {
5345− struct sk_security_struct *sksec = ep->base.sk->sk_security;
5345+ struct sk_security_struct *sksec = asoc->base.sk->sk_security;
53465346 struct common_audit_data ad;
53475347 struct lsm_network_audit net = {0,};
53485348 u8 peerlbl_active;
@@ -5359,7 +5359,7 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 10 unmodified lines
53595359 /* This will return peer_sid = SECSID_NULL if there are
53605360 * no peer labels, see security_net_peersid_resolve().
53615361 */
5362− err = selinux_skb_peerlbl_sid(skb, ep->base.sk->sk_family,
5362+ err = selinux_skb_peerlbl_sid(skb, asoc->base.sk->sk_family,
53635363 &peer_sid);
53645364 if (err)
53655365 return err;
@@ -5383,7 +5383,7 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 17 unmodified lines
53835383 */
53845384 ad.type = LSM_AUDIT_DATA_NET;
53855385 ad.u.net = &net;
5386− ad.u.net->sk = ep->base.sk;
5386+ ad.u.net->sk = asoc->base.sk;
53875387 err = avc_has_perm(&selinux_state,
53885388 sksec->peer_sid, peer_sid, sksec->sclass,
53895389 SCTP_SOCKET__ASSOCIATION, &ad);
@@ -5392,7 +5392,7 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 2 unmodified lines
53925392 }
53935393
53945394 /* Compute the MLS component for the connection and store
5395− * the information in ep. This will be used by SCTP TCP type
5395+ * the information in asoc. This will be used by SCTP TCP type
53965396 * sockets and peeled off connections as they cause a new
53975397 * socket to be generated. selinux_sctp_sk_clone() will then
53985398 * plug this into the new socket.
@@ -5401,11 +5401,11 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 2 unmodified lines
54015401 if (err)
54025402 return err;
54035403
5404− ep->secid = conn_sid;
5405− ep->peer_secid = peer_sid;
5404+ asoc->secid = conn_sid;
5405+ asoc->peer_secid = peer_sid;
54065406
54075407 /* Set any NetLabel labels including CIPSO/CALIPSO options. */
5408− return selinux_netlbl_sctp_assoc_request(ep, skb);
5408+ return selinux_netlbl_sctp_assoc_request(asoc, skb);
54095409 }
54105410
54115411 /* Check if sctp IPv4/IPv6 addresses are valid for binding or connecting
@@ -5490,7 +5490,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname, · 78 unmodified lines
54905490 }
54915491
54925492 /* Called whenever a new socket is created by accept(2) or sctp_peeloff(3). */
5493−static void selinux_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk,
5493+static void selinux_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
54945494 struct sock *newsk)
54955495 {
54965496 struct sk_security_struct *sksec = sk->sk_security;
@@ -5502,8 +5502,9 @@ static void selinux_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk, · 5 unmodified lines
55025502 if (!selinux_policycap_extsockclass())
55035503 return selinux_sk_clone_security(sk, newsk);
55045504
5505− newsksec->sid = ep->secid;
5506− newsksec->peer_sid = ep->peer_secid;
5505+ if (asoc->secid != SECSID_WILD)
5506+ newsksec->sid = asoc->secid;
5507+ newsksec->peer_sid = asoc->peer_secid;
55075508 newsksec->sclass = sksec->sclass;
55085509 selinux_netlbl_sctp_sk_clone(sk, newsk);
55095510 }
@@ -5558,6 +5559,16 @@ static void selinux_inet_conn_established(struct sock *sk, struct sk_buff *skb) · 48 unmodified lines
55585559 selinux_skb_peerlbl_sid(skb, family, &sksec->peer_sid);
55595560 }
55605561
5562+static void selinux_sctp_assoc_established(struct sctp_association *asoc,
5563+ struct sk_buff *skb)
5564+{
5565+ struct sk_security_struct *sksec = asoc->base.sk->sk_security;
5566+
5567+ selinux_inet_conn_established(asoc->base.sk, skb);
5568+ asoc->peer_secid = sksec->peer_sid;
5569+ asoc->secid = SECSID_WILD;
5570+}
5571+
55615572 static int selinux_secmark_relabel_packet(u32 sid)
55625573 {
55635574 const struct task_security_struct *__tsec;
@@ -7228,6 +7239,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = { · 1664 unmodified lines
72287239 LSM_HOOK_INIT(sctp_assoc_request, selinux_sctp_assoc_request),
72297240 LSM_HOOK_INIT(sctp_sk_clone, selinux_sctp_sk_clone),
72307241 LSM_HOOK_INIT(sctp_bind_connect, selinux_sctp_bind_connect),
7242+ LSM_HOOK_INIT(sctp_assoc_established, selinux_sctp_assoc_established),
72317243 LSM_HOOK_INIT(inet_conn_request, selinux_inet_conn_request),
72327244 LSM_HOOK_INIT(inet_csk_clone, selinux_inet_csk_clone),
72337245 LSM_HOOK_INIT(inet_conn_established, selinux_inet_conn_established),
security/selinux/include/netlabel.h+2−2
@@ -39,7 +39,7 @@ int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, · 38 unmodified lines
3939 int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
4040 u16 family,
4141 u32 sid);
42−int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep,
42+int selinux_netlbl_sctp_assoc_request(struct sctp_association *asoc,
4343 struct sk_buff *skb);
4444 int selinux_netlbl_inet_conn_request(struct request_sock *req, u16 family);
4545 void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family);
@@ -98,7 +98,7 @@ static inline int selinux_netlbl_skbuff_setsid(struct sk_buff *skb, · 52 unmodified lines
9898 return 0;
9999 }
100100
101−static inline int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep,
101+static inline int selinux_netlbl_sctp_assoc_request(struct sctp_association *asoc,
102102 struct sk_buff *skb)
103103 {
104104 return 0;
security/selinux/netlabel.c+9−9
@@ -261,30 +261,30 @@ skbuff_setsid_return: · 260 unmodified lines
261261
262262 /**
263263 * selinux_netlbl_sctp_assoc_request - Label an incoming sctp association.
264− * @ep: incoming association endpoint.
264+ * @asoc: incoming association.
265265 * @skb: the packet.
266266 *
267267 * Description:
268− * A new incoming connection is represented by @ep, ......
268+ * A new incoming connection is represented by @asoc, ......
269269 * Returns zero on success, negative values on failure.
270270 *
271271 */
272−int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep,
272+int selinux_netlbl_sctp_assoc_request(struct sctp_association *asoc,
273273 struct sk_buff *skb)
274274 {
275275 int rc;
276276 struct netlbl_lsm_secattr secattr;
277− struct sk_security_struct *sksec = ep->base.sk->sk_security;
277+ struct sk_security_struct *sksec = asoc->base.sk->sk_security;
278278 struct sockaddr_in addr4;
279279 struct sockaddr_in6 addr6;
280280
281− if (ep->base.sk->sk_family != PF_INET &&
282− ep->base.sk->sk_family != PF_INET6)
281+ if (asoc->base.sk->sk_family != PF_INET &&
282+ asoc->base.sk->sk_family != PF_INET6)
283283 return 0;
284284
285285 netlbl_secattr_init(&secattr);
286286 rc = security_netlbl_sid_to_secattr(&selinux_state,
287− ep->secid, &secattr);
287+ asoc->secid, &secattr);
288288 if (rc != 0)
289289 goto assoc_request_return;
290290
@@ -294,11 +294,11 @@ int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep, · 3 unmodified lines
294294 if (ip_hdr(skb)->version == 4) {
295295 addr4.sin_family = AF_INET;
296296 addr4.sin_addr.s_addr = ip_hdr(skb)->saddr;
297− rc = netlbl_conn_setattr(ep->base.sk, (void *)&addr4, &secattr);
297+ rc = netlbl_conn_setattr(asoc->base.sk, (void *)&addr4, &secattr);
298298 } else if (IS_ENABLED(CONFIG_IPV6) && ip_hdr(skb)->version == 6) {
299299 addr6.sin6_family = AF_INET6;
300300 addr6.sin6_addr = ipv6_hdr(skb)->saddr;
301− rc = netlbl_conn_setattr(ep->base.sk, (void *)&addr6, &secattr);
301+ rc = netlbl_conn_setattr(asoc->base.sk, (void *)&addr6, &secattr);
302302 } else {
303303 rc = -EAFNOSUPPORT;
304304 }
tools/bpf/bpftool/Makefile+22−10
@@ -22,24 +22,29 @@ else · 21 unmodified lines
2222 _OUTPUT := $(CURDIR)
2323 endif
2424 BOOTSTRAP_OUTPUT := $(_OUTPUT)/bootstrap/
25+
2526 LIBBPF_OUTPUT := $(_OUTPUT)/libbpf/
2627 LIBBPF_DESTDIR := $(LIBBPF_OUTPUT)
2728 LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include
2829 LIBBPF_HDRS_DIR := $(LIBBPF_INCLUDE)/bpf
30+LIBBPF := $(LIBBPF_OUTPUT)libbpf.a
2931
30−LIBBPF = $(LIBBPF_OUTPUT)libbpf.a
31−LIBBPF_BOOTSTRAP_OUTPUT = $(BOOTSTRAP_OUTPUT)libbpf/
32−LIBBPF_BOOTSTRAP = $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a
32+LIBBPF_BOOTSTRAP_OUTPUT := $(BOOTSTRAP_OUTPUT)libbpf/
33+LIBBPF_BOOTSTRAP_DESTDIR := $(LIBBPF_BOOTSTRAP_OUTPUT)
34+LIBBPF_BOOTSTRAP_INCLUDE := $(LIBBPF_BOOTSTRAP_DESTDIR)/include
35+LIBBPF_BOOTSTRAP_HDRS_DIR := $(LIBBPF_BOOTSTRAP_INCLUDE)/bpf
36+LIBBPF_BOOTSTRAP := $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a
3337
3438 # We need to copy hashmap.h and nlattr.h which is not otherwise exported by
3539 # libbpf, but still required by bpftool.
3640 LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h)
41+LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h)
3742
3843 ifeq ($(BPFTOOL_VERSION),)
3944 BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion)
4045 endif
4146
42−$(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR):
47+$(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR):
4348 $(QUIET_MKDIR)mkdir -p $@
4449
4550 $(LIBBPF): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_OUTPUT)
@@ -52,7 +57,12 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_ · 6 unmodified lines
5257
5358 $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT)
5459 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \
55− ARCH= CC=$(HOSTCC) LD=$(HOSTLD) $@
60+ DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR) prefix= \
61+ ARCH= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers
62+
63+$(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
64+ $(call QUIET_INSTALL, $@)
65+ $(Q)install -m 644 -t $(LIBBPF_BOOTSTRAP_HDRS_DIR) $<
5666
5767 $(LIBBPF)-clean: FORCE | $(LIBBPF_OUTPUT)
5868 $(call QUIET_CLEAN, libbpf)
@@ -172,11 +182,11 @@ else · 113 unmodified lines
172182 $(Q)cp "$(VMLINUX_H)" $@
173183 endif
174184
175−$(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF)
185+$(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP)
176186 $(QUIET_CLANG)$(CLANG) \
177187 -I$(if $(OUTPUT),$(OUTPUT),.) \
178188 -I$(srctree)/tools/include/uapi/ \
179− -I$(LIBBPF_INCLUDE) \
189+ -I$(LIBBPF_BOOTSTRAP_INCLUDE) \
180190 -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@
181191
182192 $(OUTPUT)%.skel.h: $(OUTPUT)%.bpf.o $(BPFTOOL_BOOTSTRAP)
@@ -209,8 +219,10 @@ $(BPFTOOL_BOOTSTRAP): $(BOOTSTRAP_OBJS) $(LIBBPF_BOOTSTRAP) · 26 unmodified lines
209219 $(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
210220 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
211221
212−$(BOOTSTRAP_OUTPUT)%.o: %.c $(LIBBPF_INTERNAL_HDRS) | $(BOOTSTRAP_OUTPUT)
213− $(QUIET_CC)$(HOSTCC) $(CFLAGS) -c -MMD -o $@ $<
222+$(BOOTSTRAP_OUTPUT)%.o: %.c $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS) | $(BOOTSTRAP_OUTPUT)
223+ $(QUIET_CC)$(HOSTCC) \
224+ $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),$(CFLAGS)) \
225+ -c -MMD -o $@ $<
214226
215227 $(OUTPUT)%.o: %.c
216228 $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $<
@@ -257,6 +269,6 @@ doc-uninstall: · 40 unmodified lines
257269 FORCE:
258270
259271 .SECONDARY:
260−.PHONY: all FORCE clean install-bin install uninstall
272+.PHONY: all FORCE bootstrap clean install-bin install uninstall
261273 .PHONY: doc doc-clean doc-install doc-uninstall
262274 .DEFAULT_GOAL := all
tools/lib/bpf/bpf.c+3−1
@@ -515,6 +515,7 @@ int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value) · 514 unmodified lines
515515 int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, __u64 flags)
516516 {
517517 union bpf_attr attr;
518+ int ret;
518519
519520 memset(&attr, 0, sizeof(attr));
520521 attr.map_fd = fd;
@@ -522,7 +523,8 @@ int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, _ · 1 unmodified line
522523 attr.value = ptr_to_u64(value);
523524 attr.flags = flags;
524525
525− return sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, sizeof(attr));
526+ ret = sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, sizeof(attr));
527+ return libbpf_err_errno(ret);
526528 }
527529
528530 int bpf_map_delete_elem(int fd, const void *key)
tools/testing/selftests/bpf/prog_tests/netcnt.c+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
88
99 #define CG_NAME "/netcnt"
1010
11−void test_netcnt(void)
11+void serial_test_netcnt(void)
1212 {
1313 union percpu_net_cnt *percpu_netcnt = NULL;
1414 struct bpf_cgroup_storage_key key;
tools/testing/selftests/bpf/prog_tests/test_bpffs.c+74−11
@@ -1,6 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0
22 /* Copyright (c) 2020 Facebook */
33 #define _GNU_SOURCE
4+#include <stdio.h>
45 #include <sched.h>
56 #include <sys/mount.h>
67 #include <sys/stat.h>
@@ -29,44 +30,106 @@ static int read_iter(char *file) · 22 unmodified lines
2930
3031 static int fn(void)
3132 {
32− int err, duration = 0;
33+ struct stat a, b, c;
34+ int err, map;
3335
3436 err = unshare(CLONE_NEWNS);
35− if (CHECK(err, "unshare", "failed: %d\n", errno))
37+ if (!ASSERT_OK(err, "unshare"))
3638 goto out;
3739
3840 err = mount("", "/", "", MS_REC | MS_PRIVATE, NULL);
39− if (CHECK(err, "mount /", "failed: %d\n", errno))
41+ if (!ASSERT_OK(err, "mount /"))
4042 goto out;
4143
4244 err = umount(TDIR);
43− if (CHECK(err, "umount " TDIR, "failed: %d\n", errno))
45+ if (!ASSERT_OK(err, "umount " TDIR))
4446 goto out;
4547
4648 err = mount("none", TDIR, "tmpfs", 0, NULL);
47− if (CHECK(err, "mount", "mount root failed: %d\n", errno))
49+ if (!ASSERT_OK(err, "mount tmpfs"))
4850 goto out;
4951
5052 err = mkdir(TDIR "/fs1", 0777);
51− if (CHECK(err, "mkdir "TDIR"/fs1", "failed: %d\n", errno))
53+ if (!ASSERT_OK(err, "mkdir " TDIR "/fs1"))
5254 goto out;
5355 err = mkdir(TDIR "/fs2", 0777);
54− if (CHECK(err, "mkdir "TDIR"/fs2", "failed: %d\n", errno))
56+ if (!ASSERT_OK(err, "mkdir " TDIR "/fs2"))
5557 goto out;
5658
5759 err = mount("bpf", TDIR "/fs1", "bpf", 0, NULL);
58− if (CHECK(err, "mount bpffs "TDIR"/fs1", "failed: %d\n", errno))
60+ if (!ASSERT_OK(err, "mount bpffs " TDIR "/fs1"))
5961 goto out;
6062 err = mount("bpf", TDIR "/fs2", "bpf", 0, NULL);
61− if (CHECK(err, "mount bpffs " TDIR "/fs2", "failed: %d\n", errno))
63+ if (!ASSERT_OK(err, "mount bpffs " TDIR "/fs2"))
6264 goto out;
6365
6466 err = read_iter(TDIR "/fs1/maps.debug");
65− if (CHECK(err, "reading " TDIR "/fs1/maps.debug", "failed\n"))
67+ if (!ASSERT_OK(err, "reading " TDIR "/fs1/maps.debug"))
6668 goto out;
6769 err = read_iter(TDIR "/fs2/progs.debug");
68− if (CHECK(err, "reading " TDIR "/fs2/progs.debug", "failed\n"))
70+ if (!ASSERT_OK(err, "reading " TDIR "/fs2/progs.debug"))
6971 goto out;
72+
73+ err = mkdir(TDIR "/fs1/a", 0777);
74+ if (!ASSERT_OK(err, "creating " TDIR "/fs1/a"))
75+ goto out;
76+ err = mkdir(TDIR "/fs1/a/1", 0777);
77+ if (!ASSERT_OK(err, "creating " TDIR "/fs1/a/1"))
78+ goto out;
79+ err = mkdir(TDIR "/fs1/b", 0777);
80+ if (!ASSERT_OK(err, "creating " TDIR "/fs1/b"))
81+ goto out;
82+
83+ map = bpf_create_map(BPF_MAP_TYPE_ARRAY, 4, 4, 1, 0);
84+ if (!ASSERT_GT(map, 0, "create_map(ARRAY)"))
85+ goto out;
86+ err = bpf_obj_pin(map, TDIR "/fs1/c");
87+ if (!ASSERT_OK(err, "pin map"))
88+ goto out;
89+ close(map);
90+
91+ /* Check that RENAME_EXCHANGE works for directories. */
92+ err = stat(TDIR "/fs1/a", &a);
93+ if (!ASSERT_OK(err, "stat(" TDIR "/fs1/a)"))
94+ goto out;
95+ err = renameat2(0, TDIR "/fs1/a", 0, TDIR "/fs1/b", RENAME_EXCHANGE);
96+ if (!ASSERT_OK(err, "renameat2(/fs1/a, /fs1/b, RENAME_EXCHANGE)"))
97+ goto out;
98+ err = stat(TDIR "/fs1/b", &b);
99+ if (!ASSERT_OK(err, "stat(" TDIR "/fs1/b)"))
100+ goto out;
101+ if (!ASSERT_EQ(a.st_ino, b.st_ino, "b should have a's inode"))
102+ goto out;
103+ err = access(TDIR "/fs1/b/1", F_OK);
104+ if (!ASSERT_OK(err, "access(" TDIR "/fs1/b/1)"))
105+ goto out;
106+
107+ /* Check that RENAME_EXCHANGE works for mixed file types. */
108+ err = stat(TDIR "/fs1/c", &c);
109+ if (!ASSERT_OK(err, "stat(" TDIR "/fs1/map)"))
110+ goto out;
111+ err = renameat2(0, TDIR "/fs1/c", 0, TDIR "/fs1/b", RENAME_EXCHANGE);
112+ if (!ASSERT_OK(err, "renameat2(/fs1/c, /fs1/b, RENAME_EXCHANGE)"))
113+ goto out;
114+ err = stat(TDIR "/fs1/b", &b);
115+ if (!ASSERT_OK(err, "stat(" TDIR "/fs1/b)"))
116+ goto out;
117+ if (!ASSERT_EQ(c.st_ino, b.st_ino, "b should have c's inode"))
118+ goto out;
119+ err = access(TDIR "/fs1/c/1", F_OK);
120+ if (!ASSERT_OK(err, "access(" TDIR "/fs1/c/1)"))
121+ goto out;
122+
123+ /* Check that RENAME_NOREPLACE works. */
124+ err = renameat2(0, TDIR "/fs1/b", 0, TDIR "/fs1/a", RENAME_NOREPLACE);
125+ if (!ASSERT_ERR(err, "renameat2(RENAME_NOREPLACE)")) {
126+ err = -EINVAL;
127+ goto out;
128+ }
129+ err = access(TDIR "/fs1/b", F_OK);
130+ if (!ASSERT_OK(err, "access(" TDIR "/fs1/b)"))
131+ goto out;
132+
70133 out:
71134 umount(TDIR "/fs1");
72135 umount(TDIR "/fs2");
tools/testing/selftests/bpf/progs/for_each_array_map_elem.c+12−0
@@ -23,6 +23,16 @@ struct callback_ctx { · 22 unmodified lines
2323 int output;
2424 };
2525
26+const volatile int bypass_unused = 1;
27+
28+static __u64
29+unused_subprog(struct bpf_map *map, __u32 *key, __u64 *val,
30+ struct callback_ctx *data)
31+{
32+ data->output = 0;
33+ return 1;
34+}
35+
2636 static __u64
2737 check_array_elem(struct bpf_map *map, __u32 *key, __u64 *val,
2838 struct callback_ctx *data)
@@ -54,6 +64,8 @@ int test_pkt_access(struct __sk_buff *skb) · 25 unmodified lines
5464
5565 data.output = 0;
5666 bpf_for_each_map_elem(&arraymap, check_array_elem, &data, 0);
67+ if (!bypass_unused)
68+ bpf_for_each_map_elem(&arraymap, unused_subprog, &data, 0);
5769 arraymap_output = data.output;
5870
5971 bpf_for_each_map_elem(&percpu_map, check_percpu_elem, (void *)0, 0);
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh+35−27
@@ -2,11 +2,11 @@ · 1 unmodified line
22 # SPDX-License-Identifier: GPL-2.0
33 #
44 # Test topology:
5−# - - - - - - - - - - - - - - - - - - - - - - - - -
6−# | veth1 veth2 veth3 | ... init net
5+# - - - - - - - - - - - - - - - - - - -
6+# | veth1 veth2 veth3 | ns0
77 # - -| - - - - - - | - - - - - - | - -
88 # --------- --------- ---------
9−# | veth0 | | veth0 | | veth0 | ...
9+# | veth0 | | veth0 | | veth0 |
1010 # --------- --------- ---------
1111 # ns1 ns2 ns3
1212 #
@@ -31,6 +31,7 @@ IFACES="" · 18 unmodified lines
3131 DRV_MODE="xdpgeneric xdpdrv xdpegress"
3232 PASS=0
3333 FAIL=0
34+LOG_DIR=$(mktemp -d)
3435
3536 test_pass()
3637 {
@@ -50,6 +51,7 @@ clean_up() · 13 unmodified lines
5051 ip link del veth$i 2> /dev/null
5152 ip netns del ns$i 2> /dev/null
5253 done
54+ ip netns del ns0 2> /dev/null
5355 }
5456
5557 # Kselftest framework requirement - SKIP code is 4.
@@ -77,10 +79,12 @@ setup_ns() · 21 unmodified lines
7779 mode="xdpdrv"
7880 fi
7981
82+ ip netns add ns0
8083 for i in $(seq $NUM); do
8184 ip netns add ns$i
82− ip link add veth$i type veth peer name veth0 netns ns$i
83− ip link set veth$i up
85+ ip -n ns$i link add veth0 index 2 type veth \
86+ peer name veth$i netns ns0 index $((1 + $i))
87+ ip -n ns0 link set veth$i up
8488 ip -n ns$i link set veth0 up
8589
8690 ip -n ns$i addr add 192.0.2.$i/24 dev veth0
@@ -91,7 +95,7 @@ setup_ns() · 4 unmodified lines
9195 xdp_dummy.o sec xdp &> /dev/null || \
9296 { test_fail "Unable to load dummy xdp" && exit 1; }
9397 IFACES="$IFACES veth$i"
94− veth_mac[$i]=$(ip link show veth$i | awk '/link\/ether/ {print $2}')
98+ veth_mac[$i]=$(ip -n ns0 link show veth$i | awk '/link\/ether/ {print $2}')
9599 done
96100 }
97101
@@ -100,17 +104,17 @@ do_egress_tests() · 2 unmodified lines
100104 local mode=$1
101105
102106 # mac test
103− ip netns exec ns2 tcpdump -e -i veth0 -nn -l -e &> mac_ns1-2_${mode}.log &
104− ip netns exec ns3 tcpdump -e -i veth0 -nn -l -e &> mac_ns1-3_${mode}.log &
107+ ip netns exec ns2 tcpdump -e -i veth0 -nn -l -e &> ${LOG_DIR}/mac_ns1-2_${mode}.log &
108+ ip netns exec ns3 tcpdump -e -i veth0 -nn -l -e &> ${LOG_DIR}/mac_ns1-3_${mode}.log &
105109 sleep 0.5
106110 ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null
107111 sleep 0.5
108− pkill -9 tcpdump
112+ pkill tcpdump
109113
110114 # mac check
111− grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" mac_ns1-2_${mode}.log && \
115+ grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-2_${mode}.log && \
112116 test_pass "$mode mac ns1-2" || test_fail "$mode mac ns1-2"
113− grep -q "${veth_mac[3]} > ff:ff:ff:ff:ff:ff" mac_ns1-3_${mode}.log && \
117+ grep -q "${veth_mac[3]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-3_${mode}.log && \
114118 test_pass "$mode mac ns1-3" || test_fail "$mode mac ns1-3"
115119 }
116120
@@ -121,46 +125,46 @@ do_ping_tests() · 4 unmodified lines
121125 # ping6 test: echo request should be redirect back to itself, not others
122126 ip netns exec ns1 ip neigh add 2001:db8::2 dev veth0 lladdr 00:00:00:00:00:02
123127
124− ip netns exec ns1 tcpdump -i veth0 -nn -l -e &> ns1-1_${mode}.log &
125− ip netns exec ns2 tcpdump -i veth0 -nn -l -e &> ns1-2_${mode}.log &
126− ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ns1-3_${mode}.log &
128+ ip netns exec ns1 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-1_${mode}.log &
129+ ip netns exec ns2 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-2_${mode}.log &
130+ ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-3_${mode}.log &
127131 sleep 0.5
128132 # ARP test
129− ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null
133+ ip netns exec ns1 arping -q -c 2 -I veth0 192.0.2.254
130134 # IPv4 test
131135 ip netns exec ns1 ping 192.0.2.253 -i 0.1 -c 4 &> /dev/null
132136 # IPv6 test
133137 ip netns exec ns1 ping6 2001:db8::2 -i 0.1 -c 2 &> /dev/null
134138 sleep 0.5
135− pkill -9 tcpdump
139+ pkill tcpdump
136140
137141 # All netns should receive the redirect arp requests
138− [ $(grep -c "who-has 192.0.2.254" ns1-1_${mode}.log) -gt 4 ] && \
142+ [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \
139143 test_pass "$mode arp(F_BROADCAST) ns1-1" || \
140144 test_fail "$mode arp(F_BROADCAST) ns1-1"
141− [ $(grep -c "who-has 192.0.2.254" ns1-2_${mode}.log) -le 4 ] && \
145+ [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-2_${mode}.log) -eq 2 ] && \
142146 test_pass "$mode arp(F_BROADCAST) ns1-2" || \
143147 test_fail "$mode arp(F_BROADCAST) ns1-2"
144− [ $(grep -c "who-has 192.0.2.254" ns1-3_${mode}.log) -le 4 ] && \
148+ [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-3_${mode}.log) -eq 2 ] && \
145149 test_pass "$mode arp(F_BROADCAST) ns1-3" || \
146150 test_fail "$mode arp(F_BROADCAST) ns1-3"
147151
148152 # ns1 should not receive the redirect echo request, others should
149− [ $(grep -c "ICMP echo request" ns1-1_${mode}.log) -eq 4 ] && \
153+ [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \
150154 test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" || \
151155 test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1"
152− [ $(grep -c "ICMP echo request" ns1-2_${mode}.log) -eq 4 ] && \
156+ [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-2_${mode}.log) -eq 4 ] && \
153157 test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" || \
154158 test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2"
155− [ $(grep -c "ICMP echo request" ns1-3_${mode}.log) -eq 4 ] && \
159+ [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-3_${mode}.log) -eq 4 ] && \
156160 test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" || \
157161 test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3"
158162
159163 # ns1 should receive the echo request, ns2 should not
160− [ $(grep -c "ICMP6, echo request" ns1-1_${mode}.log) -eq 4 ] && \
164+ [ $(grep -c "ICMP6, echo request" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \
161165 test_pass "$mode IPv6 (no flags) ns1-1" || \
162166 test_fail "$mode IPv6 (no flags) ns1-1"
163− [ $(grep -c "ICMP6, echo request" ns1-2_${mode}.log) -eq 0 ] && \
167+ [ $(grep -c "ICMP6, echo request" ${LOG_DIR}/ns1-2_${mode}.log) -eq 0 ] && \
164168 test_pass "$mode IPv6 (no flags) ns1-2" || \
165169 test_fail "$mode IPv6 (no flags) ns1-2"
166170 }
@@ -176,9 +180,13 @@ do_tests() · 9 unmodified lines
176180 xdpgeneric) drv_p="-S";;
177181 esac
178182
179− ./xdp_redirect_multi $drv_p $IFACES &> xdp_redirect_${mode}.log &
183+ ip netns exec ns0 ./xdp_redirect_multi $drv_p $IFACES &> ${LOG_DIR}/xdp_redirect_${mode}.log &
180184 xdp_pid=$!
181185 sleep 1
186+ if ! ps -p $xdp_pid > /dev/null; then
187+ test_fail "$mode xdp_redirect_multi start failed"
188+ return 1
189+ fi
182190
183191 if [ "$mode" = "xdpegress" ]; then
184192 do_egress_tests $mode
@@ -189,16 +197,16 @@ do_tests() · 4 unmodified lines
189197 kill $xdp_pid
190198 }
191199
192−trap clean_up 0 2 3 6 9
200+trap clean_up EXIT
193201
194202 check_env
195−rm -f xdp_redirect_*.log ns*.log mac_ns*.log
196203
197204 for mode in ${DRV_MODE}; do
198205 setup_ns $mode
199206 do_tests $mode
200207 clean_up
201208 done
209+rm -rf ${LOG_DIR}
202210
203211 echo "Summary: PASS $PASS, FAIL $FAIL"
204212 [ $FAIL -eq 0 ] && exit 0 || exit 1
tools/testing/selftests/bpf/verifier/spill_fill.c+17−0
@@ -265,3 +265,20 @@ · 264 unmodified lines
265265 .result = ACCEPT,
266266 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
267267 },
268+{
269+ "Spill a u32 scalar at fp-4 and then at fp-8",
270+ .insns = {
271+ /* r4 = 4321 */
272+ BPF_MOV32_IMM(BPF_REG_4, 4321),
273+ /* *(u32 *)(r10 -4) = r4 */
274+ BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_4, -4),
275+ /* *(u32 *)(r10 -8) = r4 */
276+ BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_4, -8),
277+ /* r4 = *(u64 *)(r10 -8) */
278+ BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_10, -8),
279+ BPF_MOV64_IMM(BPF_REG_0, 0),
280+ BPF_EXIT_INSN(),
281+ },
282+ .result = ACCEPT,
283+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
284+},
tools/testing/selftests/bpf/xdp_redirect_multi.c+2−2
@@ -129,7 +129,7 @@ int main(int argc, char **argv) · 128 unmodified lines
129129 goto err_out;
130130 }
131131
132− printf("Get interfaces");
132+ printf("Get interfaces:");
133133 for (i = 0; i < MAX_IFACE_NUM && argv[optind + i]; i++) {
134134 ifaces[i] = if_nametoindex(argv[optind + i]);
135135 if (!ifaces[i])
@@ -139,7 +139,7 @@ int main(int argc, char **argv) · 3 unmodified lines
139139 goto err_out;
140140 }
141141 if (ifaces[i] > MAX_INDEX_NUM) {
142− printf("Interface index to large\n");
142+ printf(" interface index too large\n");
143143 goto err_out;
144144 }
145145 printf(" %d", ifaces[i]);
tools/testing/selftests/net/Makefile+7−2
@@ -12,7 +12,7 @@ TEST_PROGS += udpgro_bench.sh udpgro.sh test_vxlan_under_vrf.sh reuseport_addr_a · 11 unmodified lines
1212 TEST_PROGS += test_vxlan_fdb_changelink.sh so_txtime.sh ipv6_flowlabel.sh
1313 TEST_PROGS += tcp_fastopen_backup_key.sh fcnal-test.sh l2tp.sh traceroute.sh
1414 TEST_PROGS += fin_ack_lat.sh fib_nexthop_multiprefix.sh fib_nexthops.sh
15−TEST_PROGS += altnames.sh icmp_redirect.sh ip6_gre_headroom.sh
15+TEST_PROGS += altnames.sh icmp.sh icmp_redirect.sh ip6_gre_headroom.sh
1616 TEST_PROGS += route_localnet.sh
1717 TEST_PROGS += reuseaddr_ports_exhausted.sh
1818 TEST_PROGS += txtimestamp.sh
@@ -30,7 +30,12 @@ TEST_PROGS += ioam6.sh · 11 unmodified lines
3030 TEST_PROGS += gro.sh
3131 TEST_PROGS += gre_gso.sh
3232 TEST_PROGS += cmsg_so_mark.sh
33−TEST_PROGS_EXTENDED := in_netns.sh
33+TEST_PROGS += srv6_end_dt46_l3vpn_test.sh
34+TEST_PROGS += srv6_end_dt4_l3vpn_test.sh
35+TEST_PROGS += srv6_end_dt6_l3vpn_test.sh
36+TEST_PROGS += vrf_strict_mode_test.sh
37+TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh
38+TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh
3439 TEST_GEN_FILES = socket nettest
3540 TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
3641 TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh+1−1
@@ -80,7 +80,7 @@ test_gretap() · 79 unmodified lines
8080
8181 test_ip6gretap()
8282 {
83− test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \
83+ test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ipv6' \
8484 "mirror to ip6gretap"
8585 }
8686
tools/testing/selftests/net/forwarding/mirror_gre_changes.sh+1−1
@@ -74,7 +74,7 @@ test_span_gre_ttl() · 73 unmodified lines
7474
7575 mirror_install $swp1 ingress $tundev "matchall $tcflags"
7676 tc filter add dev $h3 ingress pref 77 prot $prot \
77− flower ip_ttl 50 action pass
77+ flower skip_hw ip_ttl 50 action pass
7878
7979 mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 0
8080
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh+7−6
@@ -141,7 +141,7 @@ test_gretap() · 140 unmodified lines
141141
142142 test_ip6gretap()
143143 {
144− test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \
144+ test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ipv6' \
145145 "mirror to ip6gretap"
146146 }
147147
@@ -218,6 +218,7 @@ test_ip6gretap_forbidden_egress() · 70 unmodified lines
218218 test_span_gre_untagged_egress()
219219 {
220220 local tundev=$1; shift
221+ local ul_proto=$1; shift
221222 local what=$1; shift
222223
223224 RET=0
@@ -225,7 +226,7 @@ test_span_gre_untagged_egress() · 1 unmodified line
225226 mirror_install $swp1 ingress $tundev "matchall $tcflags"
226227
227228 quick_test_span_gre_dir $tundev ingress
228− quick_test_span_vlan_dir $h3 555 ingress
229+ quick_test_span_vlan_dir $h3 555 ingress "$ul_proto"
229230
230231 h3_addr_add_del del $h3.555
231232 bridge vlan add dev $swp3 vid 555 pvid untagged
@@ -233,7 +234,7 @@ test_span_gre_untagged_egress() · 1 unmodified line
233234 sleep 5
234235
235236 quick_test_span_gre_dir $tundev ingress
236− fail_test_span_vlan_dir $h3 555 ingress
237+ fail_test_span_vlan_dir $h3 555 ingress "$ul_proto"
237238
238239 h3_addr_add_del del $h3
239240 bridge vlan add dev $swp3 vid 555
@@ -241,7 +242,7 @@ test_span_gre_untagged_egress() · 1 unmodified line
241242 sleep 5
242243
243244 quick_test_span_gre_dir $tundev ingress
244− quick_test_span_vlan_dir $h3 555 ingress
245+ quick_test_span_vlan_dir $h3 555 ingress "$ul_proto"
245246
246247 mirror_uninstall $swp1 ingress
247248
@@ -250,12 +251,12 @@ test_span_gre_untagged_egress() · 2 unmodified lines
250251
251252 test_gretap_untagged_egress()
252253 {
253− test_span_gre_untagged_egress gt4 "mirror to gretap"
254+ test_span_gre_untagged_egress gt4 ip "mirror to gretap"
254255 }
255256
256257 test_ip6gretap_untagged_egress()
257258 {
258− test_span_gre_untagged_egress gt6 "mirror to ip6gretap"
259+ test_span_gre_untagged_egress gt6 ipv6 "mirror to ip6gretap"
259260 }
260261
261262 test_span_gre_fdb_roaming()
tools/testing/selftests/net/forwarding/mirror_lib.sh+2−1
@@ -115,13 +115,14 @@ do_test_span_vlan_dir_ips() · 114 unmodified lines
115115 local dev=$1; shift
116116 local vid=$1; shift
117117 local direction=$1; shift
118+ local ul_proto=$1; shift
118119 local ip1=$1; shift
119120 local ip2=$1; shift
120121
121122 # Install the capture as skip_hw to avoid double-counting of packets.
122123 # The traffic is meant for local box anyway, so will be trapped to
123124 # kernel.
124− vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype ip"
125+ vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype $ul_proto"
125126 mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
126127 mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
127128 vlan_capture_uninstall $dev
tools/testing/selftests/net/forwarding/mirror_vlan.sh+2−2
@@ -85,9 +85,9 @@ test_tagged_vlan_dir() · 84 unmodified lines
8585 RET=0
8686
8787 mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
88− do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" \
88+ do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" ip \
8989 192.0.2.17 192.0.2.18
90− do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" \
90+ do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" ip \
9191 192.0.2.17 192.0.2.18
9292 mirror_uninstall $swp1 $direction
9393
tools/testing/selftests/net/gre_gso.sh+5−4
@@ -116,17 +116,18 @@ gre_gst_test_checks() · 115 unmodified lines
116116 {
117117 local name=$1
118118 local addr=$2
119+ local proto=$3
119120
120− $NS_EXEC nc -kl $port >/dev/null &
121+ $NS_EXEC nc $proto -kl $port >/dev/null &
121122 PID=$!
122123 while ! $NS_EXEC ss -ltn | grep -q $port; do ((i++)); sleep 0.01; done
123124
124− cat $TMPFILE | timeout 1 nc $addr $port
125+ cat $TMPFILE | timeout 1 nc $proto -N $addr $port
125126 log_test $? 0 "$name - copy file w/ TSO"
126127
127128 ethtool -K veth0 tso off
128129
129− cat $TMPFILE | timeout 1 nc $addr $port
130+ cat $TMPFILE | timeout 1 nc $proto -N $addr $port
130131 log_test $? 0 "$name - copy file w/ GSO"
131132
132133 ethtool -K veth0 tso on
@@ -155,7 +156,7 @@ gre6_gso_test() · 22 unmodified lines
155156 sleep 2
156157
157158 gre_gst_test_checks GREv6/v4 172.16.2.2
158− gre_gst_test_checks GREv6/v6 2001:db8:1::2
159+ gre_gst_test_checks GREv6/v6 2001:db8:1::2 -6
159160
160161 cleanup
161162 }
tools/testing/selftests/net/reuseport_bpf_numa.c+4−0
@@ -211,12 +211,16 @@ static void test(int *rcv_fd, int len, int family, int proto) · 210 unmodified lines
211211
212212 /* Forward iterate */
213213 for (node = 0; node < len; ++node) {
214+ if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
215+ continue;
214216 send_from_node(node, family, proto);
215217 receive_on_node(rcv_fd, len, epfd, node, proto);
216218 }
217219
218220 /* Reverse iterate */
219221 for (node = len - 1; node >= 0; --node) {
222+ if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
223+ continue;
220224 send_from_node(node, family, proto);
221225 receive_on_node(rcv_fd, len, epfd, node, proto);
222226 }
tools/testing/selftests/net/test_vxlan_under_vrf.sh+2−0
@@ -101,6 +101,8 @@ setup-vm() { · 100 unmodified lines
101101 ip -netns hv-$id link set veth-tap master br0
102102 ip -netns hv-$id link set veth-tap up
103103
104+ ip link set veth-hv address 02:1d:8d:dd:0c:6$id
105+
104106 ip link set veth-hv netns vm-$id
105107 ip -netns vm-$id addr add 10.0.0.$id/24 dev veth-hv
106108 ip -netns vm-$id link set veth-hv up
tools/testing/selftests/net/tls.c+0−3
@@ -654,7 +654,6 @@ TEST_F(tls, recvmsg_single_max) · 653 unmodified lines
654654 TEST_F(tls, recvmsg_multiple)
655655 {
656656 unsigned int msg_iovlen = 1024;
657− unsigned int len_compared = 0;
658657 struct iovec vec[1024];
659658 char *iov_base[1024];
660659 unsigned int iov_len = 16;
@@ -675,8 +674,6 @@ TEST_F(tls, recvmsg_multiple) · 14 unmodified lines
675674 hdr.msg_iovlen = msg_iovlen;
676675 hdr.msg_iov = vec;
677676 EXPECT_NE(recvmsg(self->cfd, &hdr, 0), -1);
678− for (i = 0; i < msg_iovlen; i++)
679− len_compared += iov_len;
680677
681678 for (i = 0; i < msg_iovlen; i++)
682679 free(iov_base[i]);
tools/testing/selftests/net/udpgso_bench_rx.c+7−4
@@ -293,19 +293,17 @@ static void usage(const char *filepath) · 292 unmodified lines
293293
294294 static void parse_opts(int argc, char **argv)
295295 {
296+ const char *bind_addr = NULL;
296297 int c;
297298
298− /* bind to any by default */
299− setup_sockaddr(PF_INET6, "::", &cfg_bind_addr);
300299 while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) {
301300 switch (c) {
302301 case '4':
303302 cfg_family = PF_INET;
304303 cfg_alen = sizeof(struct sockaddr_in);
305− setup_sockaddr(PF_INET, "0.0.0.0", &cfg_bind_addr);
306304 break;
307305 case 'b':
308− setup_sockaddr(cfg_family, optarg, &cfg_bind_addr);
306+ bind_addr = optarg;
309307 break;
310308 case 'C':
311309 cfg_connect_timeout_ms = strtoul(optarg, NULL, 0);
@@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv) · 29 unmodified lines
341339 }
342340 }
343341
342+ if (!bind_addr)
343+ bind_addr = cfg_family == PF_INET6 ? "::" : "0.0.0.0";
344+
345+ setup_sockaddr(cfg_family, bind_addr, &cfg_bind_addr);
346+
344347 if (optind != argc)
345348 usage(argv[0]);
346349