History

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

Pull networking fixes from Jakub Kicinski: "Including fixes from netfilter and IPsec. Current release - regressions: - do not acquire dev->tx_global_lock in netdev_watchdog_up() - ethtool: keep rtnl_lock for ops using ethtool_op_get_link() - fix deadlock in nested UP notifier events Current release - new code bugs: - eth: - cn20k: fix subbank free list indexing for search order - airoha: fix BQL underflow in shared QDMA TX ring Previous releases - regressions: - netfilter: - flowtable: fix offloaded ct timeout never being extended - nf_conncount: prevent connlimit drops for early confirmed ct Previous releases - always broken: - require CAP_NET_ADMIN in the originating netns when modifying cross-netns devices - report NAPI thread PID in the caller's pid namespace - mac802154: fix dirty frag in in-place crypto for IOT radios - sctp: hold socket lock when dumping endpoints in sctp_diag, avoid an overflow - eth: gve: fix header buffer corruption with header-split and HW-GRO - af_key: initialize alg_key_len for IPComp states, prevent OOB read" * tag 'net-7.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (213 commits) selftests: bonding: add a test for VLAN propagation over a bonded real device vlan: defer real device state propagation to netdev_work net: add the driver-facing netdev_work scheduling API net: turn the rx_mode work into a generic netdev_work facility net: ethtool: keep rtnl_lock for ops using ethtool_op_get_link() rxrpc: Fix rxrpc_rotate_tx_rotate() to check there's something to rotate rxrpc: Fix leak of released call in recvmsg(MSG_PEEK) rxrpc: Fix socket notification race rxrpc: Fix potential infinite loop in rxrpc_recvmsg() rxrpc: Fix oob challenge leak in cleanup after notification failure rxrpc: Fix the reception of a reply packet before data transmission afs: Fix uncancelled rxrpc OOB message handler afs: Fix further netns teardown to cancel the preallocation charger rxrpc: Fix double unlock in rxrpc_recvmsg() rxrpc: Fix leak of connection from OOB challenge rxrpc: Fix ACKALL packet handling net: hns3: differentiate autoneg default values between copper and fiber net: hns3: fix permanent link down deadlock after reset net: hns3: refactor MAC autoneg and speed configuration net: hns3: unify copper port ksettings configuration path ...

Linus Torvalds committed 4 months ago

Commit 805185b2 parents c75597c fe9f4ee239 files · +3040 −1289Browse files

Unified · Split

239 files
  1. .mailmap +2 −1
  2. Documentation/devicetree/bindings/clock/qcom,ipq9574-cmn-pll.yaml +1 −1
  3. Documentation/devicetree/bindings/clock/qcom,qca8k-nsscc.yaml +1 −1
  4. Documentation/devicetree/bindings/net/qcom,ipq9574-ppe.yaml +1 −1
  5. Documentation/devicetree/bindings/net/renesas,ether.yaml +1 −2
  6. Documentation/networking/netdevices.rst +2 −0
  7. MAINTAINERS +3 −4
  8. drivers/net/dsa/mxl862xx/mxl862xx-host.c +10 −8
  9. drivers/net/dsa/realtek/rtl8366rb-leds.c +4 −4
  10. drivers/net/dsa/sja1105/sja1105_ptp.c +1 −1
  11. drivers/net/ethernet/airoha/airoha_eth.c +111 −86
  12. drivers/net/ethernet/airoha/airoha_eth.h +1 −2
  13. drivers/net/ethernet/airoha/airoha_ppe.c +2 −1
  14. drivers/net/ethernet/amazon/ena/ena_netdev.c +21 −2
  15. drivers/net/ethernet/amd/au1000_eth.c +2 −1
  16. drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 −2
  17. drivers/net/ethernet/broadcom/bnxt/bnxt.c +47 −1
  18. drivers/net/ethernet/broadcom/bnxt/bnxt.h +5 −0
  19. drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 −0
  20. drivers/net/ethernet/cadence/macb_main.c +8 −0
  21. drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +9 −1
  22. drivers/net/ethernet/freescale/enetc/enetc4_pf.c +3 −0
  23. drivers/net/ethernet/google/gve/gve_ethtool.c +2 −1
  24. drivers/net/ethernet/google/gve/gve_rx_dqo.c +18 −10
  25. drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +15 −16
  26. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +86 −22
  27. drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +1 −0
  28. drivers/net/ethernet/ibm/ehea/ehea_main.c +2 −0
  29. drivers/net/ethernet/ibm/emac/core.c +6 −7
  30. drivers/net/ethernet/intel/e1000e/ich8lan.c +3 −0
  31. drivers/net/ethernet/intel/e1000e/netdev.c +14 −1
  32. drivers/net/ethernet/intel/i40e/i40e_debug.h +1 −1
  33. drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1 −0
  34. drivers/net/ethernet/intel/ice/ice_common.c +0 −1
  35. drivers/net/ethernet/intel/ice/ice_dpll.c +14 −6
  36. drivers/net/ethernet/intel/ice/ice_eswitch.c +2 −2
  37. drivers/net/ethernet/intel/ice/ice_ethtool.c +8 −4
  38. drivers/net/ethernet/intel/ice/ice_main.c +5 −11
  39. drivers/net/ethernet/intel/ice/ice_vf_lib.c +1 −1
  40. drivers/net/ethernet/marvell/mvneta.c +3 −0
  41. drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c +45 −15
  42. drivers/net/ethernet/marvell/octeontx2/af/mcs.c +3 −3
  43. drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +9 −0
  44. drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +32 −27
  45. drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +19 −8
  46. drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +8 −3
  47. drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +1 −1
  48. drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c +8 −2
  49. drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1 −0
  50. drivers/net/ethernet/marvell/prestera/prestera_main.c +1 −1
  51. drivers/net/ethernet/mediatek/mtk_eth_soc.c +5 −5
  52. drivers/net/ethernet/mediatek/mtk_ppe.c +2 −2
  53. drivers/net/ethernet/mellanox/mlx5/core/Kconfig +1 −1
  54. drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 −1
  55. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 −1
  56. drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c +3 −1
  57. drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +0 −1
  58. drivers/net/ethernet/mellanox/mlx5/core/port.c +0 −19
  59. drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +2 −1
  60. drivers/net/ethernet/meta/fbnic/fbnic_fw.c +4 −5
  61. drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +6 −1
  62. drivers/net/ethernet/meta/fbnic/fbnic_pci.c +4 −0
  63. drivers/net/ethernet/meta/fbnic/fbnic_rpc.c +2 −0
  64. drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c +3 −1
  65. drivers/net/ethernet/microsoft/mana/gdma_main.c +64 −14
  66. drivers/net/ethernet/microsoft/mana/mana_bpf.c +2 −1
  67. drivers/net/ethernet/microsoft/mana/mana_en.c +14 −2
  68. drivers/net/ethernet/microsoft/mana/mana_ethtool.c +2 −1
  69. drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +29 −9
  70. drivers/net/ethernet/rocker/rocker_ofdpa.c +3 −0
  71. drivers/net/ethernet/stmicro/stmmac/dwmac-spacemit.c +8 −5
  72. drivers/net/ethernet/sun/sungem.c +9 −4
  73. drivers/net/ethernet/sunplus/spl2sw_phy.c +4 −2
  74. drivers/net/ethernet/ti/icssg/icssg_common.c +39 −33
  75. drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +0 −1
  76. drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +0 −1
  77. drivers/net/geneve.c +16 −2
  78. drivers/net/ieee802154/ca8210.c +6 −3
  79. drivers/net/netconsole.c +7 −5
  80. drivers/net/phy/realtek/realtek_main.c +2 −1
  81. drivers/net/pse-pd/pd692x0.c +1 −1
  82. drivers/net/thunderbolt/main.c +6 −2
  83. drivers/net/usb/kalmia.c +8 −0
  84. drivers/net/usb/lan78xx.c +31 −6
  85. drivers/net/veth.c +2 −0
  86. drivers/net/virtio_net.c +6 −3
  87. drivers/net/wan/hdlc_ppp.c +13 −2
  88. drivers/net/wan/ixp4xx_hss.c +2 −2
  89. drivers/net/wwan/t7xx/t7xx_hif_cldma.c +3 −0
  90. fs/afs/cm_security.c +2 −1
  91. fs/afs/rxrpc.c +9 −1
  92. include/linux/ethtool.h +2 −0
  93. include/linux/netdevice.h +17 −4
  94. include/linux/netfilter/x_tables.h +21 −8
  95. include/net/dst_metadata.h +5 −2
  96. include/net/ip_fib.h +3 −4
  97. include/net/netfilter/nf_conntrack_expect.h +14 −3
  98. include/net/netfilter/nf_conntrack_helper.h +4 −0
  99. include/net/netfilter/nf_queue.h +1 −0
  100. include/net/netfilter/nft_meta.h +2 −0
  101. include/net/rtnetlink.h +2 −0
  102. include/net/sctp/sctp.h +2 −1
  103. include/net/xfrm.h +11 −4
  104. include/uapi/linux/netfilter/nf_conntrack_common.h +1 −0
  105. net/8021q/vlan.c +8 −68
  106. net/8021q/vlan.h +11 −0
  107. net/8021q/vlan_dev.c +60 −0
  108. net/batman-adv/bat_iv_ogm.c +10 −1
  109. net/batman-adv/bat_v.c +1 −0
  110. net/batman-adv/bat_v_ogm.c +22 −1
  111. net/batman-adv/distributed-arp-table.c +9 −3
  112. net/batman-adv/fragmentation.c +21 −1
  113. net/batman-adv/fragmentation.h +2 −1
  114. net/batman-adv/hard-interface.c +2 −26
  115. net/batman-adv/routing.c +69 −4
  116. net/batman-adv/tp_meter.c +48 −26
  117. net/batman-adv/translation-table.c +10 −2
  118. net/batman-adv/tvlv.c +63 −6
  119. net/batman-adv/types.h +13 −8
  120. net/bridge/netfilter/nft_meta_bridge.c +21 −2
  121. net/core/Makefile +1 −1
  122. net/core/dev.c +2 −0
  123. net/core/dev.h +10 −1
  124. net/core/dev_addr_lists.c +3 −74
  125. net/core/filter.c +1 −1
  126. net/core/flow_dissector.c +10 −2
  127. net/core/lwtunnel.c +6 −0
  128. net/core/netdev-genl.c +3 −1
  129. net/core/netdev_work.c +162 −0
  130. net/core/rtnetlink.c +8 −0
  131. net/devlink/rate.c +14 −11
  132. net/ethtool/common.h +4 −0
  133. net/ieee802154/core.c +29 −22
  134. net/ieee802154/header_ops.c +6 −3
  135. net/ieee802154/ieee802154.h +17 −0
  136. net/ieee802154/netlink.c +18 −18
  137. net/ipv4/ip_gre.c +6 −0
  138. net/ipv4/ip_output.c +2 −5
  139. net/ipv4/ip_vti.c +3 −0
  140. net/ipv4/ipip.c +3 −0
  141. net/ipv4/netfilter/nf_reject_ipv4.c +1 −1
  142. net/ipv4/sysctl_net_ipv4.c +8 −2
  143. net/ipv4/tcp_ao.c +4 −0
  144. net/ipv4/tcp_output.c +2 −2
  145. net/ipv4/udp_tunnel_nic.c +1 −1
  146. net/ipv4/xfrm4_input.c +0 −2
  147. net/ipv6/addrconf.c +28 −14
  148. net/ipv6/ioam6_iptunnel.c +4 −4
  149. net/ipv6/ip6_gre.c +6 −0
  150. net/ipv6/ip6_output.c +3 −6
  151. net/ipv6/ip6_tunnel.c +10 −0
  152. net/ipv6/ip6_vti.c +3 −0
  153. net/ipv6/ndisc.c +3 −5
  154. net/ipv6/route.c +3 −0
  155. net/ipv6/sit.c +3 −0
  156. net/ipv6/xfrm6_input.c +0 −2
  157. net/key/af_key.c +1 −0
  158. net/llc/sysctl_net_llc.c +1 −1
  159. net/mac802154/llsec.c +14 −0
  160. net/mac802154/scan.c +1 −0
  161. net/netfilter/Kconfig +6 −5
  162. net/netfilter/ipset/ip_set_bitmap_gen.h +3 −1
  163. net/netfilter/ipset/ip_set_bitmap_ip.c +1 −1
  164. net/netfilter/ipset/ip_set_bitmap_ipmac.c +1 −1
  165. net/netfilter/ipset/ip_set_bitmap_port.c +1 −1
  166. net/netfilter/ipset/ip_set_core.c +2 −2
  167. net/netfilter/ipset/ip_set_hash_gen.h +6 −6
  168. net/netfilter/nf_conncount.c +5 −6
  169. net/netfilter/nf_conntrack_broadcast.c +1 −0
  170. net/netfilter/nf_conntrack_core.c +32 −1
  171. net/netfilter/nf_conntrack_expect.c +81 −74
  172. net/netfilter/nf_conntrack_h323_main.c +2 −2
  173. net/netfilter/nf_conntrack_helper.c +11 −8
  174. net/netfilter/nf_conntrack_irc.c +2 −0
  175. net/netfilter/nf_conntrack_netlink.c +13 −32
  176. net/netfilter/nf_conntrack_pptp.c +2 −0
  177. net/netfilter/nf_conntrack_sip.c +5 −8
  178. net/netfilter/nf_flow_table_core.c +9 −4
  179. net/netfilter/nf_flow_table_ip.c +24 −64
  180. net/netfilter/nf_flow_table_path.c +3 −1
  181. net/netfilter/nf_nat_core.c +10 −0
  182. net/netfilter/nf_queue.c +14 −0
  183. net/netfilter/nfnetlink_queue.c +3 −0
  184. net/netfilter/nft_compat.c +21 −3
  185. net/netfilter/nft_ct.c +18 −4
  186. net/netfilter/nft_meta.c +3 −2
  187. net/netfilter/nft_payload.c +13 −3
  188. net/netfilter/nft_synproxy.c +4 −5
  189. net/netfilter/xt_cluster.c +1 −1
  190. net/openvswitch/conntrack.c +2 −1
  191. net/psample/psample.c +4 −2
  192. net/rds/send.c +2 −0
  193. net/rxrpc/ar-internal.h +4 −2
  194. net/rxrpc/call_event.c +4 −1
  195. net/rxrpc/call_object.c +2 −0
  196. net/rxrpc/conn_client.c +1 −1
  197. net/rxrpc/conn_event.c +7 −2
  198. net/rxrpc/input.c +32 −7
  199. net/rxrpc/oob.c +10 −2
  200. net/rxrpc/recvmsg.c +4 −6
  201. net/rxrpc/sendmsg.c +2 −1
  202. net/sched/act_ct.c +8 −5
  203. net/sched/cls_api.c +3 −0
  204. net/sched/sch_dualpi2.c +5 −6
  205. net/sched/sch_generic.c +2 −5
  206. net/sctp/diag.c +32 −35
  207. net/sctp/sm_statefuns.c +5 −0
  208. net/sctp/socket.c +22 −7
  209. net/tipc/core.c +7 −2
  210. net/tipc/crypto.c +9 −0
  211. net/tipc/discover.c +12 −2
  212. net/tipc/udp_media.c +14 −5
  213. net/xfrm/espintcp.c +7 −27
  214. net/xfrm/xfrm_input.c +16 −13
  215. net/xfrm/xfrm_interface_core.c +3 −0
  216. net/xfrm/xfrm_policy.c +15 −12
  217. net/xfrm/xfrm_state.c +15 −8
  218. net/xfrm/xfrm_user.c +10 −10
  219. tools/net/ynl/Makefile +1 −1
  220. tools/net/ynl/Makefile.deps +2 −0
  221. tools/net/ynl/generated/Makefile +1 −1
  222. tools/net/ynl/lib/Makefile +1 −1
  223. tools/testing/selftests/bpf/config +3 −0
  224. tools/testing/selftests/bpf/prog_tests/test_xsk.c +54 −42
  225. tools/testing/selftests/bpf/prog_tests/test_xsk.h +2 −0
  226. tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c +175 −0
  227. tools/testing/selftests/bpf/progs/test_xdp_meta.c +71 −52
  228. tools/testing/selftests/drivers/net/bonding/Makefile +1 −0
  229. tools/testing/selftests/drivers/net/bonding/bond_vlan_real_dev.sh +180 −0
  230. tools/testing/selftests/drivers/net/so_txtime.c +1 −1
  231. tools/testing/selftests/net/broadcast_ether_dst.sh +1 −1
  232. tools/testing/selftests/net/netfilter/conntrack_sctp_collision.sh +67 −22
  233. tools/testing/selftests/net/netfilter/nft_flowtable.sh +4 −4
  234. tools/testing/selftests/net/netfilter/nft_queue.sh +58 −8
  235. tools/testing/selftests/net/tls.c +7 −1
  236. tools/testing/selftests/net/vlan_bridge_binding.sh +1 −1
  237. tools/testing/selftests/tc-testing/tc-tests/actions/ct.json +38 −0
  238. tools/testing/selftests/tc-testing/tc-tests/qdiscs/dualpi2.json +44 −0
  239. tools/testing/selftests/tc-testing/tdc_gso.py +43 −0
.mailmap+2−1
@@ -530,7 +530,8 @@ Luca Ceresoli <luca.ceresoli@bootlin.com> <luca@lucaceresoli.net> · 529 unmodified lines
530530 Luca Weiss <luca@lucaweiss.eu> <luca@z3ntu.xyz>
531531 Lucas De Marchi <demarchi@kernel.org> <lucas.demarchi@intel.com>
532532 Lukasz Luba <lukasz.luba@arm.com> <l.luba@partner.samsung.com>
533−Luo Jie <quic_luoj@quicinc.com> <luoj@codeaurora.org>
533+Luo Jie <jie.luo@oss.qualcomm.com> <luoj@codeaurora.org>
534+Luo Jie <jie.luo@oss.qualcomm.com> <quic_luoj@quicinc.com>
534535 Lance Yang <lance.yang@linux.dev> <ioworker0@gmail.com>
535536 Lance Yang <lance.yang@linux.dev> <mingzhe.yang@ly.com>
536537 Maciej W. Rozycki <macro@mips.com> <macro@imgtec.com>
Documentation/devicetree/bindings/clock/qcom,ipq9574-cmn-pll.yaml+1−1
@@ -8,7 +8,7 @@ title: Qualcomm CMN PLL Clock Controller on IPQ SoC · 7 unmodified lines
88
99 maintainers:
1010 - Bjorn Andersson <andersson@kernel.org>
11− - Luo Jie <quic_luoj@quicinc.com>
11+ - Luo Jie <jie.luo@oss.qualcomm.com>
1212
1313 description:
1414 The CMN (or common) PLL clock controller expects a reference
Documentation/devicetree/bindings/clock/qcom,qca8k-nsscc.yaml+1−1
@@ -8,7 +8,7 @@ title: Qualcomm NSS Clock & Reset Controller on QCA8386/QCA8084 · 7 unmodified lines
88
99 maintainers:
1010 - Bjorn Andersson <andersson@kernel.org>
11− - Luo Jie <quic_luoj@quicinc.com>
11+ - Luo Jie <jie.luo@oss.qualcomm.com>
1212
1313 description: |
1414 Qualcomm NSS clock control module provides the clocks and resets
Documentation/devicetree/bindings/net/qcom,ipq9574-ppe.yaml+1−1
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# · 6 unmodified lines
77 title: Qualcomm IPQ packet process engine (PPE)
88
99 maintainers:
10− - Luo Jie <quic_luoj@quicinc.com>
10+ - Luo Jie <jie.luo@oss.qualcomm.com>
1111 - Lei Wei <quic_leiwei@quicinc.com>
1212 - Suruchi Agarwal <quic_suruchia@quicinc.com>
1313 - Pavithra R <quic_pavir@quicinc.com>
Documentation/devicetree/bindings/net/renesas,ether.yaml+1−2
@@ -121,8 +121,7 @@ examples: · 120 unmodified lines
121121 #size-cells = <0>;
122122
123123 phy1: ethernet-phy@1 {
124− compatible = "ethernet-phy-id0022.1537",
125− "ethernet-phy-ieee802.3-c22";
124+ compatible = "ethernet-phy-id0022.1537";
126125 reg = <1>;
127126 interrupt-parent = <&irqc0>;
128127 interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
Documentation/networking/netdevices.rst+2−0
@@ -433,6 +433,8 @@ exceptions) notifiers run under the instance lock. Please extend this · 432 unmodified lines
433433 documentation whenever you make explicit assumption about lock being held
434434 from a notifier.
435435
436+Drivers **must not** generate nested notifications of the ops-locked types.
437+
436438 NETDEV_INTERNAL symbol namespace
437439 ================================
438440
MAINTAINERS+3−4
@@ -22323,9 +22323,9 @@ F: Documentation/devicetree/bindings/power/supply/qcom,pmi8998-charger.yaml · 22322 unmodified lines
2232322323 F: drivers/power/supply/qcom_smbx.c
2232422324
2232522325 QUALCOMM PPE DRIVER
22326−M: Luo Jie <quic_luoj@quicinc.com>
22326+M: Luo Jie <jie.luo@oss.qualcomm.com>
2232722327 L: netdev@vger.kernel.org
22328−S: Supported
22328+S: Maintained
2232922329 F: Documentation/devicetree/bindings/net/qcom,ipq9574-ppe.yaml
2233022330 F: Documentation/networking/device_drivers/ethernet/qualcomm/ppe/ppe.rst
2233122331 F: drivers/net/ethernet/qualcomm/ppe/
@@ -26001,9 +26001,8 @@ S: Maintained · 3669 unmodified lines
2600126001 F: drivers/net/ethernet/dlink/sundance.c
2600226002
2600326003 SUNPLUS ETHERNET DRIVER
26004−M: Wells Lu <wellslutw@gmail.com>
2600526004 L: netdev@vger.kernel.org
26006−S: Maintained
26005+S: Orphan
2600726006 W: https://sunplus.atlassian.net/wiki/spaces/doc/overview
2600826007 F: Documentation/devicetree/bindings/net/sunplus,sp7021-emac.yaml
2600926008 F: drivers/net/ethernet/sunplus/
drivers/net/dsa/mxl862xx/mxl862xx-host.c+10−8
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/crc16.h>
1313 #include <linux/iopoll.h>
1414 #include <linux/limits.h>
15+#include <linux/unaligned.h>
1516 #include <net/dsa.h>
1617 #include "mxl862xx.h"
1718 #include "mxl862xx-host.h"
@@ -40,12 +41,13 @@ static void mxl862xx_crc_err_work_fn(struct work_struct *work) · 22 unmodified lines
4041 crc_err_work);
4142 struct dsa_port *dp;
4243
43− dev_warn(&priv->mdiodev->dev,
44− "MDIO CRC error detected, shutting down all ports\n");
45−
4644 rtnl_lock();
47− dsa_switch_for_each_cpu_port(dp, priv->ds)
48− dev_close(dp->conduit);
45+ if (!test_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags)) {
46+ dev_warn(&priv->mdiodev->dev,
47+ "MDIO CRC error detected, shutting down all ports\n");
48+ dsa_switch_for_each_cpu_port(dp, priv->ds)
49+ dev_close(dp->conduit);
50+ }
4951 rtnl_unlock();
5052
5153 clear_bit(MXL862XX_FLAG_CRC_ERR, &priv->flags);
@@ -349,7 +351,7 @@ int mxl862xx_api_wrap(struct mxl862xx_priv *priv, u16 cmd, void *_data, · 297 unmodified lines
349351 * zero words individually.
350352 */
351353 for (i = 0, zeros = 0; i < size / 2 && zeros < RST_DATA_THRESHOLD; i++)
352− if (!data[i])
354+ if (!get_unaligned_le16(&data[i]))
353355 zeros++;
354356
355357 if (zeros < RST_DATA_THRESHOLD && (size & 1) && !*(u8 *)&data[i])
@@ -395,7 +397,7 @@ int mxl862xx_api_wrap(struct mxl862xx_priv *priv, u16 cmd, void *_data, · 39 unmodified lines
395397 */
396398 val = *(u8 *)&data[i] | ((crc & 0xff) << 8);
397399 } else {
398− val = le16_to_cpu(data[i]);
400+ val = get_unaligned_le16(&data[i]);
399401 }
400402
401403 /* After RST_DATA, skip zero data words as the registers
@@ -453,7 +455,7 @@ int mxl862xx_api_wrap(struct mxl862xx_priv *priv, u16 cmd, void *_data, · 51 unmodified lines
453455 *(uint8_t *)&data[i] = ret & 0xff;
454456 crc = (ret >> 8) & 0xff;
455457 } else {
456− data[i] = cpu_to_le16((u16)ret);
458+ put_unaligned_le16((u16)ret, &data[i]);
457459 }
458460 }
459461
drivers/net/dsa/realtek/rtl8366rb-leds.c+4−4
@@ -89,6 +89,7 @@ static int rtl8366rb_setup_led(struct realtek_priv *priv, struct dsa_port *dp, · 88 unmodified lines
8989 struct led_init_data init_data = { };
9090 enum led_default_state state;
9191 struct rtl8366rb_led *led;
92+ char name[64];
9293 u32 led_group;
9394 int ret;
9495
@@ -129,10 +130,9 @@ static int rtl8366rb_setup_led(struct realtek_priv *priv, struct dsa_port *dp, · 34 unmodified lines
129130 init_data.fwnode = led_fwnode;
130131 init_data.devname_mandatory = true;
131132
132− init_data.devicename = kasprintf(GFP_KERNEL, "Realtek-%d:0%d:%d",
133− dp->ds->index, dp->index, led_group);
134− if (!init_data.devicename)
135− return -ENOMEM;
133+ snprintf(name, sizeof(name), "Realtek-%d:0%d:%d",
134+ dp->ds->index, dp->index, led_group);
135+ init_data.devicename = name;
136136
137137 ret = devm_led_classdev_register_ext(priv->dev, &led->cdev, &init_data);
138138 if (ret) {
drivers/net/dsa/sja1105/sja1105_ptp.c+1−1
@@ -755,7 +755,7 @@ static int sja1105_per_out_enable(struct sja1105_private *priv, · 754 unmodified lines
755755 * 2 edges on PTP_CLK. So check for truncation which happens
756756 * at periods larger than around 68.7 seconds.
757757 */
758− pin_duration = ns_to_sja1105_ticks(pin_duration / 2);
758+ pin_duration = max_t(u64, ns_to_sja1105_ticks(pin_duration / 2), 1);
759759 if (pin_duration > U32_MAX) {
760760 rc = -ERANGE;
761761 goto out;
drivers/net/ethernet/airoha/airoha_eth.c+111−86
@@ -1004,6 +1004,7 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget) · 1003 unmodified lines
10041004
10051005 e = &q->entry[index];
10061006 skb = e->skb;
1007+ e->skb = NULL;
10071008
10081009 dma_unmap_single(eth->dev, e->dma_addr, e->dma_len,
10091010 DMA_TO_DEVICE);
@@ -1147,55 +1148,76 @@ static int airoha_qdma_init_tx(struct airoha_qdma *qdma) · 137 unmodified lines
11471148 return 0;
11481149 }
11491150
1150−static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q)
1151+static void airoha_qdma_tx_cleanup(struct airoha_qdma *qdma)
11511152 {
1152− struct airoha_qdma *qdma = q->qdma;
1153− struct airoha_eth *eth = qdma->eth;
1154− int i, qid = q - &qdma->q_tx[0];
1155− u16 index = 0;
1153+ u32 status;
1154+ int i;
11561155
1157− spin_lock_bh(&q->lock);
1158− for (i = 0; i < q->ndesc; i++) {
1159− struct airoha_queue_entry *e = &q->entry[i];
1160− struct airoha_qdma_desc *desc = &q->desc[i];
1156+ airoha_qdma_clear(qdma, REG_QDMA_GLOBAL_CFG,
1157+ GLOBAL_CFG_TX_DMA_EN_MASK);
1158+ if (read_poll_timeout(airoha_qdma_rr, status,
1159+ !(status & GLOBAL_CFG_TX_DMA_BUSY_MASK),
1160+ USEC_PER_MSEC, 50 * USEC_PER_MSEC, true,
1161+ qdma, REG_QDMA_GLOBAL_CFG))
1162+ dev_warn(qdma->eth->dev, "QDMA TX DMA busy timeout\n");
11611163
1162− if (!e->dma_addr)
1164+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
1165+ struct airoha_queue *q = &qdma->q_tx[i];
1166+ u16 index = 0;
1167+ int j;
1168+
1169+ if (!q->ndesc)
11631170 continue;
11641171
1165− dma_unmap_single(eth->dev, e->dma_addr, e->dma_len,
1166− DMA_TO_DEVICE);
1167− dev_kfree_skb_any(e->skb);
1168− e->dma_addr = 0;
1169− e->skb = NULL;
1170− list_add_tail(&e->list, &q->tx_list);
1172+ spin_lock_bh(&q->lock);
11711173
1172− /* Reset DMA descriptor */
1173− WRITE_ONCE(desc->ctrl, 0);
1174− WRITE_ONCE(desc->addr, 0);
1175− WRITE_ONCE(desc->data, 0);
1176− WRITE_ONCE(desc->msg0, 0);
1177− WRITE_ONCE(desc->msg1, 0);
1178− WRITE_ONCE(desc->msg2, 0);
1174+ q->flushing = true;
1175+ for (j = 0; j < q->ndesc; j++) {
1176+ struct airoha_queue_entry *e = &q->entry[j];
1177+ struct airoha_qdma_desc *desc = &q->desc[j];
1178+ struct sk_buff *skb = e->skb;
11791179
1180− q->queued--;
1181− }
1180+ if (!e->dma_addr)
1181+ continue;
11821182
1183− if (!list_empty(&q->tx_list)) {
1184− struct airoha_queue_entry *e;
1183+ dma_unmap_single(qdma->eth->dev, e->dma_addr,
1184+ e->dma_len, DMA_TO_DEVICE);
1185+ e->dma_addr = 0;
1186+ list_add_tail(&e->list, &q->tx_list);
1187+
1188+ WRITE_ONCE(desc->ctrl, 0);
1189+ WRITE_ONCE(desc->addr, 0);
1190+ WRITE_ONCE(desc->data, 0);
1191+ WRITE_ONCE(desc->msg0, 0);
1192+ WRITE_ONCE(desc->msg1, 0);
1193+ WRITE_ONCE(desc->msg2, 0);
1194+
1195+ if (skb) {
1196+ struct netdev_queue *txq;
1197+
1198+ txq = skb_get_tx_queue(skb->dev, skb);
1199+ netdev_tx_completed_queue(txq, 1, skb->len);
1200+ dev_kfree_skb_any(skb);
1201+ e->skb = NULL;
1202+ }
11851203
1186− e = list_first_entry(&q->tx_list, struct airoha_queue_entry,
1187− list);
1188− index = e - q->entry;
1189− }
1190− /* Set TX_DMA_IDX to TX_CPU_IDX to notify the hw the QDMA TX ring is
1191− * empty.
1192− */
1193− airoha_qdma_rmw(qdma, REG_TX_CPU_IDX(qid), TX_RING_CPU_IDX_MASK,
1194− FIELD_PREP(TX_RING_CPU_IDX_MASK, index));
1195− airoha_qdma_rmw(qdma, REG_TX_DMA_IDX(qid), TX_RING_DMA_IDX_MASK,
1196− FIELD_PREP(TX_RING_DMA_IDX_MASK, index));
1204+ q->queued--;
1205+ }
11971206
1198− spin_unlock_bh(&q->lock);
1207+ if (!list_empty(&q->tx_list)) {
1208+ struct airoha_queue_entry *e;
1209+
1210+ e = list_first_entry(&q->tx_list,
1211+ struct airoha_queue_entry, list);
1212+ index = e - q->entry;
1213+ }
1214+ airoha_qdma_rmw(qdma, REG_TX_CPU_IDX(i), TX_RING_CPU_IDX_MASK,
1215+ FIELD_PREP(TX_RING_CPU_IDX_MASK, index));
1216+ airoha_qdma_rmw(qdma, REG_TX_DMA_IDX(i), TX_RING_DMA_IDX_MASK,
1217+ FIELD_PREP(TX_RING_DMA_IDX_MASK, index));
1218+
1219+ spin_unlock_bh(&q->lock);
1220+ }
11991221 }
12001222
12011223 static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
@@ -1523,10 +1545,23 @@ static int airoha_qdma_init(struct platform_device *pdev, · 321 unmodified lines
15231545 return airoha_qdma_hw_init(qdma);
15241546 }
15251547
1526−static void airoha_qdma_cleanup(struct airoha_qdma *qdma)
1548+static void airoha_qdma_cleanup(struct airoha_eth *eth,
1549+ struct airoha_qdma *qdma)
15271550 {
15281551 int i;
15291552
1553+ if (test_bit(DEV_STATE_INITIALIZED, &eth->state)) {
1554+ u32 status;
1555+
1556+ airoha_qdma_clear(qdma, REG_QDMA_GLOBAL_CFG,
1557+ GLOBAL_CFG_RX_DMA_EN_MASK);
1558+ if (read_poll_timeout(airoha_qdma_rr, status,
1559+ !(status & GLOBAL_CFG_RX_DMA_BUSY_MASK),
1560+ USEC_PER_MSEC, 50 * USEC_PER_MSEC, true,
1561+ qdma, REG_QDMA_GLOBAL_CFG))
1562+ dev_warn(eth->dev, "QDMA RX DMA busy timeout\n");
1563+ }
1564+
15301565 for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
15311566 if (!qdma->q_rx[i].ndesc)
15321567 continue;
@@ -1546,12 +1581,6 @@ static void airoha_qdma_cleanup(struct airoha_qdma *qdma) · 13 unmodified lines
15461581 netif_napi_del(&qdma->q_tx_irq[i].napi);
15471582 }
15481583
1549− for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
1550− if (!qdma->q_tx[i].ndesc)
1551− continue;
1552−
1553− airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
1554− }
15551584 }
15561585
15571586 static int airoha_hw_init(struct platform_device *pdev,
@@ -1593,7 +1622,7 @@ static int airoha_hw_init(struct platform_device *pdev, · 35 unmodified lines
15931622 return 0;
15941623 error:
15951624 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
1596− airoha_qdma_cleanup(&eth->qdma[i]);
1625+ airoha_qdma_cleanup(eth, &eth->qdma[i]);
15971626
15981627 return err;
15991628 }
@@ -1603,7 +1632,7 @@ static void airoha_hw_cleanup(struct airoha_eth *eth) · 3 unmodified lines
16031632 int i;
16041633
16051634 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
1606− airoha_qdma_cleanup(&eth->qdma[i]);
1635+ airoha_qdma_cleanup(eth, &eth->qdma[i]);
16071636 airoha_ppe_deinit(eth);
16081637 }
16091638
@@ -1837,11 +1866,6 @@ static int airoha_dev_open(struct net_device *netdev) · 227 unmodified lines
18371866 }
18381867 port->users++;
18391868
1840− airoha_qdma_set(qdma, REG_QDMA_GLOBAL_CFG,
1841− GLOBAL_CFG_TX_DMA_EN_MASK |
1842− GLOBAL_CFG_RX_DMA_EN_MASK);
1843− qdma->users++;
1844−
18451869 if (!airoha_is_lan_gdm_dev(dev) &&
18461870 airoha_ppe_is_enabled(qdma->eth, 1))
18471871 pse_port = FE_PSE_PORT_PPE2;
@@ -1880,12 +1904,9 @@ static int airoha_dev_stop(struct net_device *netdev) · 32 unmodified lines
18801904 struct airoha_gdm_dev *dev = netdev_priv(netdev);
18811905 struct airoha_gdm_port *port = dev->port;
18821906 struct airoha_qdma *qdma = dev->qdma;
1883− int i;
18841907
18851908 netif_tx_disable(netdev);
18861909 airoha_set_vip_for_gdm_port(dev, false);
1887− for (i = 0; i < netdev->num_tx_queues; i++)
1888− netdev_tx_reset_subqueue(netdev, i);
18891910
18901911 if (--port->users)
18911912 airoha_set_port_mtu(dev->eth, port);
@@ -1893,20 +1914,6 @@ static int airoha_dev_stop(struct net_device *netdev) · 1 unmodified line
18931914 airoha_set_gdm_port_fwd_cfg(qdma->eth,
18941915 REG_GDM_FWD_CFG(port->id),
18951916 FE_PSE_PORT_DROP);
1896−
1897− if (!--qdma->users) {
1898− airoha_qdma_clear(qdma, REG_QDMA_GLOBAL_CFG,
1899− GLOBAL_CFG_TX_DMA_EN_MASK |
1900− GLOBAL_CFG_RX_DMA_EN_MASK);
1901−
1902− for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
1903− if (!qdma->q_tx[i].ndesc)
1904− continue;
1905−
1906− airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
1907− }
1908− }
1909−
19101917 return 0;
19111918 }
19121919
@@ -2110,7 +2117,7 @@ static u16 airoha_dev_select_queue(struct net_device *netdev, · 197 unmodified lines
21102117 */
21112118 channel = netdev_uses_dsa(netdev) ? skb_get_queue_mapping(skb) : port->id;
21122119 channel = channel % AIROHA_NUM_QOS_CHANNELS;
2113− queue = (skb->priority - 1) % AIROHA_NUM_QOS_QUEUES; /* QoS queue */
2120+ queue = skb->priority % AIROHA_NUM_QOS_QUEUES;
21142121 queue = channel * AIROHA_NUM_QOS_QUEUES + queue;
21152122
21162123 return queue < netdev->num_tx_queues ? queue : 0;
@@ -2229,6 +2236,9 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb, · 112 unmodified lines
22292236
22302237 spin_lock_bh(&q->lock);
22312238
2239+ if (q->flushing)
2240+ goto error_unlock;
2241+
22322242 txq = skb_get_tx_queue(netdev, skb);
22332243 nr_frags = 1 + skb_shinfo(skb)->nr_frags;
22342244
@@ -2309,7 +2319,7 @@ error_unmap: · 74 unmodified lines
23092319 e->dma_addr = 0;
23102320 }
23112321 list_splice(&tx_list, &q->tx_list);
2312−
2322+error_unlock:
23132323 spin_unlock_bh(&q->lock);
23142324 error:
23152325 dev_kfree_skb_any(skb);
@@ -2395,7 +2405,7 @@ static int airoha_qdma_set_chan_tx_sched(struct net_device *netdev, · 79 unmodified lines
23952405 struct airoha_gdm_dev *dev = netdev_priv(netdev);
23962406 int i;
23972407
2398− for (i = 0; i < AIROHA_NUM_TX_RING; i++)
2408+ for (i = 0; i < AIROHA_NUM_QOS_QUEUES; i++)
23992409 airoha_qdma_clear(dev->qdma, REG_QUEUE_CLOSE_CFG(channel),
24002410 TXQ_DISABLE_CHAN_QUEUE_MASK(channel, i));
24012411
@@ -2789,7 +2799,7 @@ static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev, · 387 unmodified lines
27892799 struct tc_htb_qopt_offload *opt)
27902800 {
27912801 u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS;
2792− int err, num_tx_queues = netdev->real_num_tx_queues;
2802+ int err, num_tx_queues = AIROHA_NUM_TX_RING + channel + 1;
27932803 struct airoha_gdm_dev *dev = netdev_priv(netdev);
27942804 struct airoha_qdma *qdma = dev->qdma;
27952805
@@ -2806,13 +2816,15 @@ static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev, · 10 unmodified lines
28062816 if (err)
28072817 goto error;
28082818
2809− err = netif_set_real_num_tx_queues(netdev, num_tx_queues + 1);
2810− if (err) {
2811− airoha_qdma_set_tx_rate_limit(netdev, channel, 0,
2812− opt->quantum);
2813− NL_SET_ERR_MSG_MOD(opt->extack,
2814− "failed setting real_num_tx_queues");
2815− goto error;
2819+ if (num_tx_queues > netdev->real_num_tx_queues) {
2820+ err = netif_set_real_num_tx_queues(netdev, num_tx_queues);
2821+ if (err) {
2822+ airoha_qdma_set_tx_rate_limit(netdev, channel, 0,
2823+ opt->quantum);
2824+ NL_SET_ERR_MSG_MOD(opt->extack,
2825+ "failed setting real_num_tx_queues");
2826+ goto error;
2827+ }
28162828 }
28172829
28182830 set_bit(channel, dev->qos_sq_bmap);
@@ -3003,13 +3015,18 @@ static int airoha_dev_setup_tc_block(struct net_device *dev, · 184 unmodified lines
30033015 static void airoha_tc_remove_htb_queue(struct net_device *netdev, int queue)
30043016 {
30053017 struct airoha_gdm_dev *dev = netdev_priv(netdev);
3018+ int num_tx_queues = AIROHA_NUM_TX_RING;
30063019 struct airoha_qdma *qdma = dev->qdma;
30073020
3008− netif_set_real_num_tx_queues(netdev, netdev->real_num_tx_queues - 1);
3009− airoha_qdma_set_tx_rate_limit(netdev, queue + 1, 0, 0);
3021+ airoha_qdma_set_tx_rate_limit(netdev, queue, 0, 0);
30103022
30113023 clear_bit(queue, qdma->qos_channel_map);
30123024 clear_bit(queue, dev->qos_sq_bmap);
3025+
3026+ if (!bitmap_empty(dev->qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS))
3027+ num_tx_queues += find_last_bit(dev->qos_sq_bmap,
3028+ AIROHA_NUM_QOS_CHANNELS) + 1;
3029+ netif_set_real_num_tx_queues(netdev, num_tx_queues);
30133030 }
30143031
30153032 static int airoha_tc_htb_delete_leaf_queue(struct net_device *netdev,
@@ -3413,8 +3430,12 @@ static int airoha_probe(struct platform_device *pdev) · 397 unmodified lines
34133430 if (err)
34143431 goto error_netdev_free;
34153432
3416− for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
3433+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
34173434 airoha_qdma_start_napi(&eth->qdma[i]);
3435+ airoha_qdma_set(&eth->qdma[i], REG_QDMA_GLOBAL_CFG,
3436+ GLOBAL_CFG_TX_DMA_EN_MASK |
3437+ GLOBAL_CFG_RX_DMA_EN_MASK);
3438+ }
34183439
34193440 for_each_child_of_node(pdev->dev.of_node, np) {
34203441 if (!of_device_is_compatible(np, "airoha,eth-mac"))
@@ -3437,8 +3458,10 @@ static int airoha_probe(struct platform_device *pdev) · 16 unmodified lines
34373458 return 0;
34383459
34393460 error_napi_stop:
3440− for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
3461+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
34413462 airoha_qdma_stop_napi(&eth->qdma[i]);
3463+ airoha_qdma_tx_cleanup(&eth->qdma[i]);
3464+ }
34423465
34433466 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
34443467 struct airoha_gdm_port *port = eth->ports[i];
@@ -3474,8 +3497,10 @@ static void airoha_remove(struct platform_device *pdev) · 29 unmodified lines
34743497 struct airoha_eth *eth = platform_get_drvdata(pdev);
34753498 int i;
34763499
3477− for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
3500+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
34783501 airoha_qdma_stop_napi(&eth->qdma[i]);
3502+ airoha_qdma_tx_cleanup(&eth->qdma[i]);
3503+ }
34793504
34803505 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
34813506 struct airoha_gdm_port *port = eth->ports[i];
drivers/net/ethernet/airoha/airoha_eth.h+1−2
@@ -197,6 +197,7 @@ struct airoha_queue { · 196 unmodified lines
197197 int free_thr;
198198 int buf_size;
199199 bool txq_stopped;
200+ bool flushing;
200201
201202 struct napi_struct napi;
202203 struct page_pool *page_pool;
@@ -524,8 +525,6 @@ struct airoha_qdma { · 321 unmodified lines
524525 struct airoha_eth *eth;
525526 void __iomem *regs;
526527
527− int users;
528−
529528 struct airoha_irq_bank irq_banks[AIROHA_MAX_NUM_IRQ_BANKS];
530529
531530 struct airoha_tx_irq_queue q_tx_irq[AIROHA_NUM_TX_IRQ];
drivers/net/ethernet/airoha/airoha_ppe.c+2−1
@@ -1601,7 +1601,8 @@ int airoha_ppe_init(struct airoha_eth *eth) · 1600 unmodified lines
16011601 return -ENOMEM;
16021602 }
16031603
1604− ppe->foe_check_time = devm_kzalloc(eth->dev, ppe_num_entries,
1604+ ppe->foe_check_time = devm_kzalloc(eth->dev,
1605+ ppe_num_entries * sizeof(*ppe->foe_check_time),
16051606 GFP_KERNEL);
16061607 if (!ppe->foe_check_time)
16071608 return -ENOMEM;
drivers/net/ethernet/amazon/ena/ena_netdev.c+21−2
@@ -752,6 +752,18 @@ static void ena_destroy_all_tx_queues(struct ena_adapter *adapter) · 751 unmodified lines
752752 }
753753 }
754754
755+static void ena_destroy_xdp_tx_queues(struct ena_adapter *adapter)
756+{
757+ u16 ena_qid;
758+ int i;
759+
760+ for (i = adapter->xdp_first_ring;
761+ i < adapter->xdp_first_ring + adapter->xdp_num_queues; i++) {
762+ ena_qid = ENA_IO_TXQ_IDX(i);
763+ ena_com_destroy_io_queue(adapter->ena_dev, ena_qid);
764+ }
765+}
766+
755767 static void ena_destroy_all_rx_queues(struct ena_adapter *adapter)
756768 {
757769 u16 ena_qid;
@@ -2078,14 +2090,21 @@ static int create_queues_with_size_backoff(struct ena_adapter *adapter) · 1320 unmodified lines
20782090 rc = ena_setup_tx_resources_in_range(adapter,
20792091 0,
20802092 adapter->num_io_queues);
2081− if (rc)
2093+ if (rc) {
2094+ ena_destroy_xdp_tx_queues(adapter);
2095+ ena_free_all_io_tx_resources_in_range(adapter,
2096+ adapter->xdp_first_ring,
2097+ adapter->xdp_num_queues);
20822098 goto err_setup_tx;
2099+ }
20832100
20842101 rc = ena_create_io_tx_queues_in_range(adapter,
20852102 0,
20862103 adapter->num_io_queues);
2087− if (rc)
2104+ if (rc) {
2105+ ena_destroy_xdp_tx_queues(adapter);
20882106 goto err_create_tx_queues;
2107+ }
20892108
20902109 rc = ena_setup_all_rx_resources(adapter);
20912110 if (rc)
drivers/net/ethernet/amd/au1000_eth.c+2−1
@@ -943,9 +943,10 @@ static int au1000_close(struct net_device *dev) · 942 unmodified lines
943943 /* stop the device */
944944 netif_stop_queue(dev);
945945
946+ spin_unlock_irqrestore(&aup->lock, flags);
947+
946948 /* disable the interrupt */
947949 free_irq(dev->irq, dev);
948− spin_unlock_irqrestore(&aup->lock, flags);
949950
950951 return 0;
951952 }
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c+1−2
@@ -4748,6 +4748,7 @@ int bnx2x_alloc_mem_bp(struct bnx2x *bp) · 4747 unmodified lines
47484748 fp = kzalloc_objs(*fp, bp->fp_array_size);
47494749 if (!fp)
47504750 goto alloc_err;
4751+ bp->fp = fp;
47514752 for (i = 0; i < bp->fp_array_size; i++) {
47524753 fp[i].tpa_info =
47534754 kzalloc_objs(struct bnx2x_agg_info,
@@ -4756,8 +4757,6 @@ int bnx2x_alloc_mem_bp(struct bnx2x *bp) · 2 unmodified lines
47564757 goto alloc_err;
47574758 }
47584759
4759− bp->fp = fp;
4760−
47614760 /* allocate sp objs */
47624761 bp->sp_objs = kzalloc_objs(struct bnx2x_sp_objs, bp->fp_array_size);
47634762 if (!bp->sp_objs)
drivers/net/ethernet/broadcom/bnxt/bnxt.c+47−1
@@ -10530,7 +10530,7 @@ static void bnxt_accumulate_stats(struct bnxt_stats_mem *stats) · 10529 unmodified lines
1053010530 stats->hw_masks, stats->len / 8, false);
1053110531 }
1053210532
10533−static void bnxt_accumulate_all_stats(struct bnxt *bp)
10533+static void bnxt_accumulate_ring_stats(struct bnxt *bp)
1053410534 {
1053510535 struct bnxt_stats_mem *ring0_stats;
1053610536 bool ignore_zero = false;
@@ -10553,6 +10553,10 @@ static void bnxt_accumulate_all_stats(struct bnxt *bp) · 16 unmodified lines
1055310553 ring0_stats->hw_masks,
1055410554 ring0_stats->len / 8, ignore_zero);
1055510555 }
10556+}
10557+
10558+static void bnxt_accumulate_port_stats(struct bnxt *bp)
10559+{
1055610560 if (bp->flags & BNXT_FLAG_PORT_STATS) {
1055710561 struct bnxt_stats_mem *stats = &bp->port_stats;
1055810562 __le64 *hw_stats = stats->hw_stats;
@@ -10575,6 +10579,41 @@ static void bnxt_accumulate_all_stats(struct bnxt *bp) · 16 unmodified lines
1057510579 }
1057610580 }
1057710581
10582+static void bnxt_accumulate_all_stats(struct bnxt *bp)
10583+{
10584+ bnxt_accumulate_ring_stats(bp);
10585+ bnxt_accumulate_port_stats(bp);
10586+}
10587+
10588+/* Re-accumulate ring stats from DMA buffers if stale.
10589+ * uAPIs for reading sw_stats should call this first.
10590+ *
10591+ * We promise user space update frequency of bp->stats_coal_ticks but
10592+ * the update is a two step process - first device updates the DMA buffer,
10593+ * then we have to update from that buffer to driver stats in the service work.
10594+ * Worst case we would be 2x off from the desired frequency.
10595+ * Sync the stats sooner, if stale. The 20% threshold was chosen arbitrarily.
10596+ *
10597+ * Ideally we would split the user-configured time into two portions,
10598+ * i.e. also lower the DMA period by the 20%. But the DMA timer seems to have
10599+ * too coarse granularity to play such tricks.
10600+ */
10601+void bnxt_sync_ring_stats(struct bnxt *bp)
10602+{
10603+ unsigned long stale;
10604+
10605+ if (!netif_running(bp->dev) || !bp->stats_coal_ticks)
10606+ return;
10607+
10608+ spin_lock(&bp->stats_lock);
10609+ stale = usecs_to_jiffies(bp->stats_coal_ticks / 5);
10610+ if (time_after_eq(jiffies, bp->stats_updated_jiffies + stale)) {
10611+ bnxt_accumulate_ring_stats(bp);
10612+ bp->stats_updated_jiffies = jiffies;
10613+ }
10614+ spin_unlock(&bp->stats_lock);
10615+}
10616+
1057810617 static int bnxt_hwrm_port_qstats(struct bnxt *bp, u8 flags)
1057910618 {
1058010619 struct hwrm_port_qstats_input *req;
@@ -13577,6 +13616,7 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) · 2996 unmodified lines
1357713616 return;
1357813617 }
1357913618
13619+ bnxt_sync_ring_stats(bp);
1358013620 bnxt_get_ring_stats(bp, stats);
1358113621 bnxt_add_prev_stats(bp, stats);
1358213622
@@ -14753,7 +14793,10 @@ static void bnxt_sp_task(struct work_struct *work) · 1170 unmodified lines
1475314793 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) {
1475414794 bnxt_hwrm_port_qstats(bp, 0);
1475514795 bnxt_hwrm_port_qstats_ext(bp, 0);
14796+ spin_lock(&bp->stats_lock);
1475614797 bnxt_accumulate_all_stats(bp);
14798+ bp->stats_updated_jiffies = jiffies;
14799+ spin_unlock(&bp->stats_lock);
1475714800 }
1475814801
1475914802 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
@@ -15488,6 +15531,7 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) · 728 unmodified lines
1548815531 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task);
1548915532
1549015533 spin_lock_init(&bp->ntp_fltr_lock);
15534+ spin_lock_init(&bp->stats_lock);
1549115535 #if BITS_PER_LONG == 32
1549215536 spin_lock_init(&bp->db_lock);
1549315537 #endif
@@ -16056,6 +16100,7 @@ static void bnxt_get_queue_stats_rx(struct net_device *dev, int i, · 562 unmodified lines
1605616100 if (!bp->bnapi)
1605716101 return;
1605816102
16103+ bnxt_sync_ring_stats(bp);
1605916104 cpr = &bp->bnapi[i]->cp_ring;
1606016105 sw = cpr->stats.sw_stats;
1606116106
@@ -16084,6 +16129,7 @@ static void bnxt_get_queue_stats_tx(struct net_device *dev, int i, · 22 unmodified lines
1608416129 if (!bp->tx_ring)
1608516130 return;
1608616131
16132+ bnxt_sync_ring_stats(bp);
1608716133 bnapi = bp->tx_ring[bp->tx_ring_map[i]].bnapi;
1608816134 sw = bnapi->cp_ring.stats.sw_stats;
1608916135
drivers/net/ethernet/broadcom/bnxt/bnxt.h+5−0
@@ -2620,6 +2620,10 @@ struct bnxt { · 2619 unmodified lines
26202620 #define BNXT_MIN_STATS_COAL_TICKS 250000
26212621 #define BNXT_MAX_STATS_COAL_TICKS 1000000
26222622
2623+ /* Protects stats_updated_jiffies and writes to sw_stats */
2624+ spinlock_t stats_lock;
2625+ unsigned long stats_updated_jiffies;
2626+
26232627 struct work_struct sp_task;
26242628 unsigned long sp_event;
26252629 #define BNXT_RX_NTP_FLTR_SP_EVENT 1
@@ -3027,6 +3031,7 @@ void bnxt_reenable_sriov(struct bnxt *bp); · 401 unmodified lines
30273031 void bnxt_close_nic(struct bnxt *, bool, bool);
30283032 void bnxt_get_ring_drv_stats(struct bnxt *bp,
30293033 struct bnxt_total_ring_drv_stats *stats);
3034+void bnxt_sync_ring_stats(struct bnxt *bp);
30303035 bool bnxt_rfs_capable(struct bnxt *bp, bool new_rss_ctx);
30313036 int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
30323037 u32 *reg_buf);
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c+1−0
@@ -606,6 +606,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, · 605 unmodified lines
606606 goto skip_ring_stats;
607607 }
608608
609+ bnxt_sync_ring_stats(bp);
609610 tpa_stats = bnxt_get_num_tpa_ring_stats(bp);
610611 for (i = 0; i < bp->cp_nr_rings; i++) {
611612 struct bnxt_napi *bnapi = bp->bnapi[i];
drivers/net/ethernet/cadence/macb_main.c+8−0
@@ -4522,6 +4522,13 @@ static int macb_setup_tc(struct net_device *dev, enum tc_setup_type type, · 4521 unmodified lines
45224522 }
45234523 }
45244524
4525+static void macb_tx_timeout(struct net_device *dev, unsigned int q)
4526+{
4527+ struct macb *bp = netdev_priv(dev);
4528+
4529+ macb_tx_restart(&bp->queues[q]);
4530+}
4531+
45254532 static const struct net_device_ops macb_netdev_ops = {
45264533 .ndo_open = macb_open,
45274534 .ndo_stop = macb_close,
@@ -4540,6 +4547,7 @@ static const struct net_device_ops macb_netdev_ops = { · 12 unmodified lines
45404547 .ndo_hwtstamp_set = macb_hwtstamp_set,
45414548 .ndo_hwtstamp_get = macb_hwtstamp_get,
45424549 .ndo_setup_tc = macb_setup_tc,
4550+ .ndo_tx_timeout = macb_tx_timeout,
45434551 };
45444552
45454553 /* Configure peripheral capabilities according to device tree
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c+9−1
@@ -2212,7 +2212,7 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev, · 2211 unmodified lines
22122212 if (err) {
22132213 NL_SET_ERR_MSG_MOD(extack,
22142214 "Cannot join a bridge while VLAN uppers are present");
2215− return 0;
2215+ return err;
22162216 }
22172217
22182218 netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
@@ -2233,6 +2233,7 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev, · 14 unmodified lines
22332233 static int dpaa2_switch_port_prechangeupper(struct net_device *netdev,
22342234 struct netdev_notifier_changeupper_info *info)
22352235 {
2236+ struct ethsw_port_priv *port_priv;
22362237 struct netlink_ext_ack *extack;
22372238 struct net_device *upper_dev;
22382239 int err;
@@ -2251,6 +2252,13 @@ static int dpaa2_switch_port_prechangeupper(struct net_device *netdev, · 12 unmodified lines
22512252
22522253 if (!info->linking)
22532254 dpaa2_switch_port_pre_bridge_leave(netdev);
2255+ } else if (is_vlan_dev(upper_dev)) {
2256+ port_priv = netdev_priv(netdev);
2257+ if (port_priv->fdb->bridge_dev) {
2258+ NL_SET_ERR_MSG_MOD(extack,
2259+ "Cannot accept VLAN uppers while bridged");
2260+ return -EOPNOTSUPP;
2261+ }
22542262 }
22552263
22562264 return 0;
drivers/net/ethernet/freescale/enetc/enetc4_pf.c+3−0
@@ -322,6 +322,9 @@ static void enetc4_default_rings_allocation(struct enetc_pf *pf) · 321 unmodified lines
322322 val = enetc4_psicfgr0_val_construct(false, num_tx_bdr, num_rx_bdr);
323323 enetc_port_wr(hw, ENETC4_PSICFGR0(0), val);
324324
325+ if (!pf->caps.num_vsi)
326+ return;
327+
325328 num_rx_bdr = pf->caps.num_rx_bdr - num_rx_bdr;
326329 rx_rem = num_rx_bdr % pf->caps.num_vsi;
327330 num_rx_bdr = num_rx_bdr / pf->caps.num_vsi;
drivers/net/ethernet/google/gve/gve_ethtool.c+2−1
@@ -984,7 +984,8 @@ const struct ethtool_ops gve_ethtool_ops = { · 983 unmodified lines
984984 .supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT |
985985 ETHTOOL_RING_USE_RX_BUF_LEN,
986986 .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS |
987− ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM,
987+ ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM |
988+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
988989 .get_drvinfo = gve_get_drvinfo,
989990 .get_strings = gve_get_strings,
990991 .get_sset_count = gve_get_sset_count,
drivers/net/ethernet/google/gve/gve_rx_dqo.c+18−10
@@ -21,11 +21,13 @@ · 20 unmodified lines
2121 static void gve_rx_free_hdr_bufs(struct gve_priv *priv, struct gve_rx_ring *rx)
2222 {
2323 struct device *hdev = &priv->pdev->dev;
24− int buf_count = rx->dqo.bufq.mask + 1;
2524
2625 if (rx->dqo.hdr_bufs.data) {
27− dma_free_coherent(hdev, priv->header_buf_size * buf_count,
28− rx->dqo.hdr_bufs.data, rx->dqo.hdr_bufs.addr);
26+ size_t size =
27+ (size_t)priv->header_buf_size * rx->dqo.num_buf_states;
28+
29+ dma_free_coherent(hdev, size, rx->dqo.hdr_bufs.data,
30+ rx->dqo.hdr_bufs.addr);
2931 rx->dqo.hdr_bufs.data = NULL;
3032 }
3133 }
@@ -254,7 +256,7 @@ int gve_rx_alloc_ring_dqo(struct gve_priv *priv, · 222 unmodified lines
254256
255257 /* Allocate header buffers for header-split */
256258 if (cfg->enable_header_split)
257− if (gve_rx_alloc_hdr_bufs(priv, rx, buffer_queue_slots))
259+ if (gve_rx_alloc_hdr_bufs(priv, rx, rx->dqo.num_buf_states))
258260 goto err;
259261
260262 /* Allocate RX completion queue */
@@ -381,10 +383,13 @@ void gve_rx_post_buffers_dqo(struct gve_rx_ring *rx) · 120 unmodified lines
381383 break;
382384 }
383385
384− if (rx->dqo.hdr_bufs.data)
386+ if (rx->dqo.hdr_bufs.data) {
387+ u16 buf_id = le16_to_cpu(desc->buf_id);
388+
385389 desc->header_buf_addr =
386390 cpu_to_le64(rx->dqo.hdr_bufs.addr +
387− priv->header_buf_size * bufq->tail);
391+ (size_t)priv->header_buf_size * buf_id);
392+ }
388393
389394 bufq->tail = (bufq->tail + 1) & bufq->mask;
390395 complq->num_free_slots--;
@@ -826,10 +831,13 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx, · 435 unmodified lines
826831 int unsplit = 0;
827832
828833 if (hdr_len && !hbo) {
829− rx->ctx.skb_head = gve_rx_copy_data(priv->dev, napi,
830− rx->dqo.hdr_bufs.data +
831− desc_idx * priv->header_buf_size,
832− hdr_len);
834+ size_t offset =
835+ (size_t)buffer_id * priv->header_buf_size;
836+
837+ rx->ctx.skb_head =
838+ gve_rx_copy_data(priv->dev, napi,
839+ rx->dqo.hdr_bufs.data + offset,
840+ hdr_len);
833841 if (unlikely(!rx->ctx.skb_head))
834842 goto error;
835843 rx->ctx.skb_tail = rx->ctx.skb_head;
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c+15−16
@@ -811,12 +811,11 @@ static int hns3_get_link_ksettings(struct net_device *netdev, · 810 unmodified lines
811811 }
812812
813813 static int hns3_check_ksettings_param(const struct net_device *netdev,
814− const struct ethtool_link_ksettings *cmd)
814+ const struct ethtool_link_ksettings *cmd,
815+ u8 media_type)
815816 {
816817 struct hnae3_handle *handle = hns3_get_handle(netdev);
817818 const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
818− u8 module_type = HNAE3_MODULE_TYPE_UNKNOWN;
819− u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
820819 u32 lane_num;
821820 u8 autoneg;
822821 u32 speed;
@@ -836,9 +835,6 @@ static int hns3_check_ksettings_param(const struct net_device *netdev, · 13 unmodified lines
836835 return 0;
837836 }
838837
839− if (ops->get_media_type)
840− ops->get_media_type(handle, &media_type, &module_type);
841−
842838 if (cmd->base.duplex == DUPLEX_HALF &&
843839 media_type != HNAE3_MEDIA_TYPE_COPPER) {
844840 netdev_err(netdev,
@@ -863,6 +859,8 @@ static int hns3_set_link_ksettings(struct net_device *netdev, · 18 unmodified lines
863859 struct hnae3_handle *handle = hns3_get_handle(netdev);
864860 struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
865861 const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
862+ u8 module_type = HNAE3_MODULE_TYPE_UNKNOWN;
863+ u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
866864 int ret;
867865
868866 /* Chip don't support this mode. */
@@ -878,22 +876,23 @@ static int hns3_set_link_ksettings(struct net_device *netdev, · 9 unmodified lines
878876 cmd->base.autoneg, cmd->base.speed, cmd->base.duplex,
879877 cmd->lanes);
880878
881− /* Only support ksettings_set for netdev with phy attached for now */
882− if (netdev->phydev) {
883− if (cmd->base.speed == SPEED_1000 &&
884− cmd->base.autoneg == AUTONEG_DISABLE)
885− return -EINVAL;
879+ if (!ops->get_media_type)
880+ return -EOPNOTSUPP;
881+ ops->get_media_type(handle, &media_type, &module_type);
886882
887− return phy_ethtool_ksettings_set(netdev->phydev, cmd);
888− } else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
889− ops->set_phy_link_ksettings) {
890− return ops->set_phy_link_ksettings(handle, cmd);
883+ if (media_type == HNAE3_MEDIA_TYPE_COPPER) {
884+ if (!ops->set_phy_link_ksettings)
885+ return -EOPNOTSUPP;
886+ ret = ops->set_phy_link_ksettings(handle, cmd);
887+ if (ret != -ENODEV)
888+ return ret;
889+ /* PHY_INEXISTENT, use MAC-level configuration */
891890 }
892891
893892 if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
894893 return -EOPNOTSUPP;
895894
896− ret = hns3_check_ksettings_param(netdev, cmd);
895+ ret = hns3_check_ksettings_param(netdev, cmd, media_type);
897896 if (ret)
898897 return ret;
899898
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c+86−22
@@ -1504,6 +1504,11 @@ static int hclge_configure(struct hclge_dev *hdev) · 1503 unmodified lines
15041504 hdev->hw.mac.req_autoneg = AUTONEG_ENABLE;
15051505 hdev->hw.mac.req_duplex = DUPLEX_FULL;
15061506
1507+ /* When lane_num is 0, the firmware will automatically
1508+ * select the appropriate lane_num based on the speed.
1509+ */
1510+ hdev->hw.mac.req_lane_num = 0;
1511+
15071512 hclge_parse_link_mode(hdev, cfg.speed_ability);
15081513
15091514 hdev->hw.mac.max_speed = hclge_get_max_speed(cfg.speed_ability);
@@ -2579,8 +2584,11 @@ static int hclge_cfg_mac_speed_dup_h(struct hnae3_handle *handle, int speed, · 1069 unmodified lines
25792584 if (ret)
25802585 return ret;
25812586
2582− hdev->hw.mac.req_speed = (u32)speed;
2583− hdev->hw.mac.req_duplex = duplex;
2587+ hdev->hw.mac.req_lane_num = lane_num;
2588+ if (speed != SPEED_UNKNOWN)
2589+ hdev->hw.mac.req_speed = (u32)speed;
2590+ if (duplex != DUPLEX_UNKNOWN)
2591+ hdev->hw.mac.req_duplex = duplex;
25842592
25852593 return 0;
25862594 }
@@ -2611,6 +2619,7 @@ static int hclge_set_autoneg(struct hnae3_handle *handle, bool enable) · 24 unmodified lines
26112619 {
26122620 struct hclge_vport *vport = hclge_get_vport(handle);
26132621 struct hclge_dev *hdev = vport->back;
2622+ int ret;
26142623
26152624 if (!hdev->hw.mac.support_autoneg) {
26162625 if (enable) {
@@ -2622,7 +2631,10 @@ static int hclge_set_autoneg(struct hnae3_handle *handle, bool enable) · 5 unmodified lines
26222631 }
26232632 }
26242633
2625− return hclge_set_autoneg_en(hdev, enable);
2634+ ret = hclge_set_autoneg_en(hdev, enable);
2635+ if (!ret)
2636+ hdev->hw.mac.req_autoneg = enable;
2637+ return ret;
26262638 }
26272639
26282640 static int hclge_get_autoneg(struct hnae3_handle *handle)
@@ -2884,20 +2896,6 @@ static int hclge_mac_init(struct hclge_dev *hdev) · 255 unmodified lines
28842896 if (!test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
28852897 hdev->hw.mac.duplex = HCLGE_MAC_FULL;
28862898
2887− if (hdev->hw.mac.support_autoneg) {
2888− ret = hclge_set_autoneg_en(hdev, hdev->hw.mac.autoneg);
2889− if (ret)
2890− return ret;
2891− }
2892−
2893− if (!hdev->hw.mac.autoneg) {
2894− ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.req_speed,
2895− hdev->hw.mac.req_duplex,
2896− hdev->hw.mac.lane_num);
2897− if (ret)
2898− return ret;
2899− }
2900−
29012899 mac->link = 0;
29022900
29032901 if (mac->user_fec_mode & BIT(HNAE3_FEC_USER_DEF)) {
@@ -3285,8 +3283,8 @@ static int hclge_get_phy_link_ksettings(struct hnae3_handle *handle, · 381 unmodified lines
32853283 }
32863284
32873285 static int
3288−hclge_set_phy_link_ksettings(struct hnae3_handle *handle,
3289− const struct ethtool_link_ksettings *cmd)
3286+hclge_ethtool_ksettings_set(struct hnae3_handle *handle,
3287+ const struct ethtool_link_ksettings *cmd)
32903288 {
32913289 struct hclge_desc desc[HCLGE_PHY_LINK_SETTING_BD_NUM];
32923290 struct hclge_vport *vport = hclge_get_vport(handle);
@@ -3327,10 +3325,34 @@ hclge_set_phy_link_ksettings(struct hnae3_handle *handle, · 34 unmodified lines
33273325 return ret;
33283326 }
33293327
3330− hdev->hw.mac.req_autoneg = cmd->base.autoneg;
3331− hdev->hw.mac.req_speed = cmd->base.speed;
3332− hdev->hw.mac.req_duplex = cmd->base.duplex;
33333328 linkmode_copy(hdev->hw.mac.advertising, cmd->link_modes.advertising);
3329+ return 0;
3330+}
3331+
3332+static int
3333+hclge_set_phy_link_ksettings(struct hnae3_handle *handle,
3334+ const struct ethtool_link_ksettings *cmd)
3335+{
3336+ struct hclge_vport *vport = hclge_get_vport(handle);
3337+ struct hclge_dev *hdev = vport->back;
3338+ int ret = -ENODEV;
3339+
3340+ if (hnae3_dev_phy_imp_supported(hdev)) {
3341+ ret = hclge_ethtool_ksettings_set(handle, cmd);
3342+ } else if (handle->netdev->phydev) {
3343+ if (cmd->base.speed == SPEED_1000 &&
3344+ cmd->base.autoneg == AUTONEG_DISABLE)
3345+ return -EINVAL;
3346+ ret = phy_ethtool_ksettings_set(handle->netdev->phydev, cmd);
3347+ }
3348+ if (ret)
3349+ return ret;
3350+
3351+ hdev->hw.mac.req_autoneg = cmd->base.autoneg;
3352+ if (cmd->base.speed != SPEED_UNKNOWN)
3353+ hdev->hw.mac.req_speed = cmd->base.speed;
3354+ if (cmd->base.duplex != DUPLEX_UNKNOWN)
3355+ hdev->hw.mac.req_duplex = cmd->base.duplex;
33343356
33353357 return 0;
33363358 }
@@ -9294,6 +9316,27 @@ static int hclge_set_wol(struct hnae3_handle *handle, · 5957 unmodified lines
92949316 return ret;
92959317 }
92969318
9319+static int hclge_set_autoneg_speed_dup(struct hclge_dev *hdev)
9320+{
9321+ int ret;
9322+
9323+ if (hdev->hw.mac.support_autoneg) {
9324+ ret = hclge_set_autoneg_en(hdev, hdev->hw.mac.req_autoneg);
9325+ if (ret)
9326+ return ret;
9327+ }
9328+
9329+ if (!hdev->hw.mac.req_autoneg) {
9330+ ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.req_speed,
9331+ hdev->hw.mac.req_duplex,
9332+ hdev->hw.mac.req_lane_num);
9333+ if (ret)
9334+ return ret;
9335+ }
9336+
9337+ return 0;
9338+}
9339+
92979340 static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
92989341 {
92999342 struct pci_dev *pdev = ae_dev->pdev;
@@ -9455,6 +9498,20 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) · 155 unmodified lines
94559498 if (ret)
94569499 goto err_ptp_uninit;
94579500
9501+ if (hdev->hw.mac.media_type != HNAE3_MEDIA_TYPE_COPPER) {
9502+ hdev->hw.mac.req_autoneg = hdev->hw.mac.autoneg;
9503+ if (hdev->hw.mac.autoneg == AUTONEG_DISABLE &&
9504+ hdev->hw.mac.speed != SPEED_UNKNOWN)
9505+ hdev->hw.mac.req_speed = hdev->hw.mac.speed;
9506+ }
9507+
9508+ ret = hclge_set_autoneg_speed_dup(hdev);
9509+ if (ret) {
9510+ dev_err(&pdev->dev,
9511+ "failed to set autoneg speed duplex, ret = %d\n", ret);
9512+ goto err_ptp_uninit;
9513+ }
9514+
94589515 INIT_KFIFO(hdev->mac_tnl_log);
94599516
94609517 hclge_dcb_ops_set(hdev);
@@ -9785,6 +9842,13 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) · 324 unmodified lines
97859842 return ret;
97869843 }
97879844
9845+ ret = hclge_set_autoneg_speed_dup(hdev);
9846+ if (ret) {
9847+ dev_err(&pdev->dev,
9848+ "failed to set autoneg speed duplex, ret = %d\n", ret);
9849+ return ret;
9850+ }
9851+
97889852 ret = hclge_tp_port_init(hdev);
97899853 if (ret) {
97909854 dev_err(&pdev->dev, "failed to init tp port, ret = %d\n",
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h+1−0
@@ -287,6 +287,7 @@ struct hclge_mac { · 286 unmodified lines
287287 u8 support_autoneg;
288288 u8 speed_type; /* 0: sfp speed, 1: active speed */
289289 u8 lane_num;
290+ u8 req_lane_num;
290291 u32 speed;
291292 u32 req_speed;
292293 u32 max_speed;
drivers/net/ethernet/ibm/ehea/ehea_main.c+2−0
@@ -3216,6 +3216,8 @@ static int ehea_create_device_sysfs(struct platform_device *dev) · 3215 unmodified lines
32163216 goto out;
32173217
32183218 ret = device_create_file(&dev->dev, &dev_attr_remove_port);
3219+ if (ret)
3220+ device_remove_file(&dev->dev, &dev_attr_probe_port);
32193221 out:
32203222 return ret;
32213223 }
drivers/net/ethernet/ibm/emac/core.c+6−7
@@ -3044,6 +3044,12 @@ static int emac_probe(struct platform_device *ofdev) · 3043 unmodified lines
30443044 if (err)
30453045 goto err_gone;
30463046
3047+ dev->emacp = devm_platform_ioremap_resource(ofdev, 0);
3048+ if (IS_ERR(dev->emacp)) {
3049+ err = PTR_ERR(dev->emacp);
3050+ goto err_gone;
3051+ }
3052+
30473053 /* Setup error IRQ handler */
30483054 dev->emac_irq = platform_get_irq(ofdev, 0);
30493055 if (dev->emac_irq < 0) {
@@ -3061,13 +3067,6 @@ static int emac_probe(struct platform_device *ofdev) · 11 unmodified lines
30613067
30623068 ndev->irq = dev->emac_irq;
30633069
3064− dev->emacp = devm_platform_ioremap_resource(ofdev, 0);
3065− if (IS_ERR(dev->emacp)) {
3066− dev_err(&ofdev->dev, "can't map device registers");
3067− err = PTR_ERR(dev->emacp);
3068− goto err_gone;
3069− }
3070−
30713070 /* Wait for dependent devices */
30723071 err = emac_wait_deps(dev);
30733072 if (err)
drivers/net/ethernet/intel/e1000e/ich8lan.c+3−0
@@ -1594,6 +1594,9 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) · 1593 unmodified lines
15941594 phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
15951595 if (speed == SPEED_100 || speed == SPEED_10)
15961596 phy_reg |= 0x3E8;
1597+ else if (hw->mac.type == e1000_pch_mtp ||
1598+ hw->mac.type == e1000_pch_ptp)
1599+ phy_reg |= 0x1D5;
15971600 else
15981601 phy_reg |= 0xFA;
15991602 e1e_wphy_locked(hw, I217_PLL_CLOCK_GATE_REG, phy_reg);
drivers/net/ethernet/intel/e1000e/netdev.c+14−1
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/pm_runtime.h>
2626 #include <linux/prefetch.h>
2727 #include <linux/suspend.h>
28+#include <linux/dmi.h>
2829
2930 #include "e1000.h"
3031 #define CREATE_TRACE_POINTS
@@ -58,6 +59,17 @@ static const struct e1000_info *e1000_info_tbl[] = { · 27 unmodified lines
5859 [board_pch_ptp] = &e1000_pch_ptp_info,
5960 };
6061
62+static const struct dmi_system_id disable_k1_list[] = {
63+ {
64+ .ident = "Dell Pro 16 Plus PB16250",
65+ .matches = {
66+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
67+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro 16 Plus PB16250"),
68+ },
69+ },
70+ {}
71+};
72+
6173 struct e1000_reg_info {
6274 u32 ofs;
6375 char *name;
@@ -7670,7 +7682,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 7606 unmodified lines
76707682 /* init PTP hardware clock */
76717683 e1000e_ptp_init(adapter);
76727684
7673− if (hw->mac.type >= e1000_pch_mtp)
7685+ /* disable K1 by default on known problematic systems */
7686+ if (hw->mac.type >= e1000_pch_mtp && dmi_check_system(disable_k1_list))
76747687 adapter->flags2 |= FLAG2_DISABLE_K1;
76757688
76767689 /* reset the hardware with the new settings */
drivers/net/ethernet/intel/i40e/i40e_debug.h+1−1
@@ -42,7 +42,7 @@ struct device *i40e_hw_to_dev(struct i40e_hw *hw); · 41 unmodified lines
4242 #define i40e_debug(h, m, s, ...) \
4343 do { \
4444 if (((m) & (h)->debug_mask)) \
45− dev_info(i40e_hw_to_dev(hw), s, ##__VA_ARGS__); \
45+ dev_info(i40e_hw_to_dev(h), s, ##__VA_ARGS__); \
4646 } while (0)
4747
4848 #endif /* _I40E_DEBUG_H_ */
drivers/net/ethernet/intel/iavf/iavf_ethtool.c+1−0
@@ -1855,6 +1855,7 @@ static const struct ethtool_ops iavf_ethtool_ops = { · 1854 unmodified lines
18551855 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
18561856 ETHTOOL_COALESCE_USE_ADAPTIVE,
18571857 .supported_input_xfrm = RXH_XFRM_SYM_XOR,
1858+ .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_GLINK,
18581859 .get_drvinfo = iavf_get_drvinfo,
18591860 .get_link = ethtool_op_get_link,
18601861 .get_ringparam = iavf_get_ringparam,
drivers/net/ethernet/intel/ice/ice_common.c+0−1
@@ -3882,7 +3882,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update) · 3881 unmodified lines
38823882 if (!pi || !aq_failures)
38833883 return -EINVAL;
38843884
3885− *aq_failures = 0;
38863885 hw = pi->hw;
38873886
38883887 pcaps = kzalloc_obj(*pcaps);
drivers/net/ethernet/intel/ice/ice_dpll.c+14−6
@@ -4645,9 +4645,13 @@ ice_dpll_init_pins_info(struct ice_pf *pf, enum ice_dpll_pin_type pin_type) · 4644 unmodified lines
46454645 static void ice_dpll_deinit_info(struct ice_pf *pf)
46464646 {
46474647 kfree(pf->dplls.inputs);
4648+ pf->dplls.inputs = NULL;
46484649 kfree(pf->dplls.outputs);
4650+ pf->dplls.outputs = NULL;
46494651 kfree(pf->dplls.eec.input_prio);
4652+ pf->dplls.eec.input_prio = NULL;
46504653 kfree(pf->dplls.pps.input_prio);
4654+ pf->dplls.pps.input_prio = NULL;
46514655 }
46524656
46534657 /**
@@ -4748,12 +4752,16 @@ static int ice_dpll_init_info(struct ice_pf *pf, bool cgu) · 94 unmodified lines
47484752
47494753 alloc_size = sizeof(*de->input_prio) * d->num_inputs;
47504754 de->input_prio = kzalloc(alloc_size, GFP_KERNEL);
4751− if (!de->input_prio)
4752− return -ENOMEM;
4755+ if (!de->input_prio) {
4756+ ret = -ENOMEM;
4757+ goto deinit_info;
4758+ }
47534759
47544760 dp->input_prio = kzalloc(alloc_size, GFP_KERNEL);
4755− if (!dp->input_prio)
4756− return -ENOMEM;
4761+ if (!dp->input_prio) {
4762+ ret = -ENOMEM;
4763+ goto deinit_info;
4764+ }
47574765
47584766 ret = ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_INPUT);
47594767 if (ret)
@@ -4778,12 +4786,12 @@ static int ice_dpll_init_info(struct ice_pf *pf, bool cgu) · 18 unmodified lines
47784786 ret = ice_get_cgu_rclk_pin_info(&pf->hw, &d->base_rclk_idx,
47794787 &pf->dplls.rclk.num_parents);
47804788 if (ret)
4781− return ret;
4789+ goto deinit_info;
47824790 for (i = 0; i < pf->dplls.rclk.num_parents; i++)
47834791 pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i;
47844792 ret = ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_RCLK_INPUT);
47854793 if (ret)
4786− return ret;
4794+ goto deinit_info;
47874795 de->mode = DPLL_MODE_AUTOMATIC;
47884796 dp->mode = DPLL_MODE_AUTOMATIC;
47894797
drivers/net/ethernet/intel/ice/ice_eswitch.c+2−2
@@ -117,8 +117,6 @@ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr) · 116 unmodified lines
117117 if (!repr->dst)
118118 return -ENOMEM;
119119
120− netif_keep_dst(uplink_vsi->netdev);
121−
122120 dst = repr->dst;
123121 dst->u.port_info.port_id = vsi->vsi_num;
124122 dst->u.port_info.lower_dev = uplink_vsi->netdev;
@@ -312,6 +310,8 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf) · 187 unmodified lines
312310 if (ice_eswitch_br_offloads_init(pf))
313311 goto err_br_offloads;
314312
313+ netif_keep_dst(uplink_vsi->netdev);
314+
315315 pf->eswitch.is_running = true;
316316
317317 return 0;
drivers/net/ethernet/intel/ice/ice_ethtool.c+8−4
@@ -3508,7 +3508,7 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) · 3507 unmodified lines
35083508 struct ice_vsi *vsi = np->vsi;
35093509 struct ice_hw *hw = &pf->hw;
35103510 struct ice_port_info *pi;
3511− u8 aq_failures;
3511+ u8 aq_failures = 0;
35123512 bool link_up;
35133513 u32 is_an;
35143514 int err;
@@ -3579,18 +3579,22 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) · 64 unmodified lines
35793579 /* Set the FC mode and only restart AN if link is up */
35803580 err = ice_set_fc(pi, &aq_failures, link_up);
35813581
3582− if (aq_failures & ICE_SET_FC_AQ_FAIL_GET) {
3582+ switch (aq_failures) {
3583+ case ICE_SET_FC_AQ_FAIL_GET:
35833584 netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %d aq_err %s\n",
35843585 err, libie_aq_str(hw->adminq.sq_last_status));
35853586 err = -EAGAIN;
3586− } else if (aq_failures & ICE_SET_FC_AQ_FAIL_SET) {
3587+ break;
3588+ case ICE_SET_FC_AQ_FAIL_SET:
35873589 netdev_info(netdev, "Set fc failed on the set_phy_config call with err %d aq_err %s\n",
35883590 err, libie_aq_str(hw->adminq.sq_last_status));
35893591 err = -EAGAIN;
3590− } else if (aq_failures & ICE_SET_FC_AQ_FAIL_UPDATE) {
3592+ break;
3593+ case ICE_SET_FC_AQ_FAIL_UPDATE:
35913594 netdev_info(netdev, "Set fc failed on the get_link_info call with err %d aq_err %s\n",
35923595 err, libie_aq_str(hw->adminq.sq_last_status));
35933596 err = -EAGAIN;
3597+ break;
35943598 }
35953599
35963600 return err;
drivers/net/ethernet/intel/ice/ice_main.c+5−11
@@ -4789,16 +4789,14 @@ static void ice_init_wakeup(struct ice_pf *pf) · 4788 unmodified lines
47894789 device_set_wakeup_enable(ice_pf_to_dev(pf), false);
47904790 }
47914791
4792−static int ice_init_link(struct ice_pf *pf)
4792+static void ice_init_link(struct ice_pf *pf)
47934793 {
47944794 struct device *dev = ice_pf_to_dev(pf);
47954795 int err;
47964796
47974797 err = ice_init_link_events(pf->hw.port_info);
4798− if (err) {
4798+ if (err)
47994799 dev_err(dev, "ice_init_link_events failed: %d\n", err);
4800− return err;
4801− }
48024800
48034801 /* not a fatal error if this fails */
48044802 err = ice_init_nvm_phy_type(pf->hw.port_info);
@@ -4838,8 +4836,6 @@ static int ice_init_link(struct ice_pf *pf) · 33 unmodified lines
48384836 } else {
48394837 set_bit(ICE_FLAG_NO_MEDIA, pf->flags);
48404838 }
4841−
4842− return err;
48434839 }
48444840
48454841 static int ice_init_pf_sw(struct ice_pf *pf)
@@ -4982,13 +4978,11 @@ static int ice_init(struct ice_pf *pf) · 136 unmodified lines
49824978
49834979 ice_init_wakeup(pf);
49844980
4985− err = ice_init_link(pf);
4986− if (err)
4987− goto err_init_link;
4981+ ice_init_link(pf);
49884982
49894983 err = ice_send_version(pf);
49904984 if (err)
4991− goto err_init_link;
4985+ goto err_deinit_pf_sw;
49924986
49934987 ice_verify_cacheline_size(pf);
49944988
@@ -5007,7 +5001,7 @@ static int ice_init(struct ice_pf *pf) · 12 unmodified lines
50075001
50085002 return 0;
50095003
5010−err_init_link:
5004+err_deinit_pf_sw:
50115005 ice_deinit_pf_sw(pf);
50125006 err_init_pf_sw:
50135007 ice_dealloc_vsis(pf);
drivers/net/ethernet/intel/ice/ice_vf_lib.c+1−1
@@ -801,7 +801,7 @@ void ice_reset_all_vfs(struct ice_pf *pf) · 800 unmodified lines
801801 * setup only when VF creates its first FDIR rule.
802802 */
803803 if (vf->ctrl_vsi_idx != ICE_NO_VSI)
804− ice_vf_ctrl_invalidate_vsi(vf);
804+ ice_vf_ctrl_vsi_release(vf);
805805
806806 ice_vf_pre_vsi_rebuild(vf);
807807 if (ice_vf_rebuild_vsi(vf)) {
drivers/net/ethernet/marvell/mvneta.c+3−0
@@ -5900,6 +5900,9 @@ static int mvneta_resume(struct device *device) · 5899 unmodified lines
59005900 rtnl_unlock();
59015901 mvneta_set_rx_mode(dev);
59025902
5903+ if (!pp->neta_armada3700)
5904+ on_each_cpu(mvneta_percpu_enable, pp, true);
5905+
59035906 return 0;
59045907 }
59055908 #endif
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c+45−15
@@ -3423,6 +3423,36 @@ static int npc_create_srch_order(int cnt) · 3422 unmodified lines
34233423 return 0;
34243424 }
34253425
3426+static int npc_subbanks_srch_order_init(struct rvu *rvu)
3427+{
3428+ struct npc_subbank *sb;
3429+ int sb_idx;
3430+ int i, j;
3431+ int rc;
3432+
3433+ for (i = 0; i < npc_priv->num_subbanks; i++) {
3434+ sb_idx = subbank_srch_order[i];
3435+ sb = &npc_priv->sb[sb_idx];
3436+ sb->arr_idx = i;
3437+
3438+ dev_dbg(rvu->dev, "%s: sb->idx=%u sb->arr_idx=%u\n",
3439+ __func__, sb->idx, sb->arr_idx);
3440+
3441+ rc = xa_err(xa_store(&npc_priv->xa_sb_free, sb->arr_idx,
3442+ xa_mk_value(sb->idx), GFP_KERNEL));
3443+ if (rc) {
3444+ dev_err(rvu->dev,
3445+ "%s: xa_store(xa_sb_free) failed at slot %d (sb=%d): %d\n",
3446+ __func__, i, sb_idx, rc);
3447+ for (j = 0; j < i; j++)
3448+ xa_erase(&npc_priv->xa_sb_free, j);
3449+ return rc;
3450+ }
3451+ }
3452+
3453+ return 0;
3454+}
3455+
34263456 static void npc_subbank_init(struct rvu *rvu, struct npc_subbank *sb, int idx)
34273457 {
34283458 mutex_init(&sb->lock);
@@ -3435,16 +3465,6 @@ static void npc_subbank_init(struct rvu *rvu, struct npc_subbank *sb, int idx) · 6 unmodified lines
34353465
34363466 sb->flags = NPC_SUBBANK_FLAG_FREE;
34373467 sb->idx = idx;
3438− sb->arr_idx = subbank_srch_order[idx];
3439−
3440− dev_dbg(rvu->dev, "%s: sb->idx=%u sb->arr_idx=%u\n",
3441− __func__, sb->idx, sb->arr_idx);
3442−
3443− /* Keep first and last subbank at end of free array; so that
3444− * it will be used at last
3445− */
3446− xa_store(&npc_priv->xa_sb_free, sb->arr_idx,
3447− xa_mk_value(sb->idx), GFP_KERNEL);
34483468 }
34493469
34503470 static int npc_pcifunc_map_create(struct rvu *rvu)
@@ -3569,15 +3589,18 @@ static int npc_defrag_alloc_free_slots(struct rvu *rvu, · 118 unmodified lines
35693589 alloc_cnt2 = 0;
35703590
35713591 rc = __npc_subbank_alloc(rvu, sb,
3572− NPC_MCAM_KEY_X2, sb->b0b,
3592+ f->key_type, sb->b0b,
35733593 sb->b0t,
35743594 NPC_MCAM_LOWER_PRIO,
35753595 false, cnt, save, cnt, true,
35763596 &alloc_cnt1);
35773597
3578− if (alloc_cnt1 < cnt) {
3598+ /* X4 entries only occupy bank 0 (b0b..b0t); see npc_subbank_idx_2_mcam_idx().
3599+ * X2 uses both halves of the subbank, so spill into bank 1 if needed.
3600+ */
3601+ if (alloc_cnt1 < cnt && f->key_type == NPC_MCAM_KEY_X2) {
35793602 rc = __npc_subbank_alloc(rvu, sb,
3580− NPC_MCAM_KEY_X2, sb->b1b,
3603+ f->key_type, sb->b1b,
35813604 sb->b1t,
35823605 NPC_MCAM_LOWER_PRIO,
35833606 false, cnt - alloc_cnt1,
@@ -4635,6 +4658,7 @@ static int npc_priv_init(struct rvu *rvu) · 1051 unmodified lines
46354658 int num_subbanks, subbank_depth;
46364659 u64 npc_const1, npc_const2 = 0;
46374660 struct npc_subbank *sb;
4661+ int ret = -ENOMEM;
46384662 u64 cfg;
46394663 int i;
46404664
@@ -4727,13 +4751,19 @@ static int npc_priv_init(struct rvu *rvu) · 86 unmodified lines
47274751 for (i = 0, sb = npc_priv->sb; i < num_subbanks; i++, sb++)
47284752 npc_subbank_init(rvu, sb, i);
47294753
4754+ ret = npc_subbanks_srch_order_init(rvu);
4755+ if (ret)
4756+ goto fail3;
4757+
47304758 /* Get number of pcifuncs in the system */
47314759 npc_priv->pf_cnt = npc_pcifunc_map_create(rvu);
47324760 npc_priv->xa_pf2idx_map = kcalloc(npc_priv->pf_cnt,
47334761 sizeof(struct xarray),
47344762 GFP_KERNEL);
4735− if (!npc_priv->xa_pf2idx_map)
4763+ if (!npc_priv->xa_pf2idx_map) {
4764+ ret = -ENOMEM;
47364765 goto fail3;
4766+ }
47374767
47384768 for (i = 0; i < npc_priv->pf_cnt; i++)
47394769 xa_init_flags(&npc_priv->xa_pf2idx_map[i], XA_FLAGS_ALLOC);
@@ -4760,7 +4790,7 @@ fail2: · 20 unmodified lines
47604790 fail1:
47614791 kfree(npc_priv);
47624792 npc_priv = NULL;
4763− return -ENOMEM;
4793+ return ret;
47644794 }
47654795
47664796 void npc_cn20k_deinit(struct rvu *rvu)
drivers/net/ethernet/marvell/octeontx2/af/mcs.c+3−3
@@ -120,13 +120,13 @@ void mcs_get_rx_secy_stats(struct mcs *mcs, struct mcs_secy_stats *stats, int id · 119 unmodified lines
120120 reg = MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYUNTAGGEDX(id);
121121 stats->pkt_untaged_cnt = mcs_reg_read(mcs, reg);
122122
123− reg = MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYCTLX(id);
124− stats->pkt_ctl_cnt = mcs_reg_read(mcs, reg);
125−
126123 if (mcs->hw->mcs_blks > 1) {
127124 reg = MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYNOTAGX(id);
128125 stats->pkt_notag_cnt = mcs_reg_read(mcs, reg);
126+ return;
129127 }
128+ reg = MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYCTLX(id);
129+ stats->pkt_ctl_cnt = mcs_reg_read(mcs, reg);
130130 }
131131
132132 void mcs_get_flowid_stats(struct mcs *mcs, struct mcs_flowid_stats *stats,
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c+9−0
@@ -178,6 +178,15 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, · 177 unmodified lines
178178 * pcifunc (will be the one who is calling this mailbox).
179179 */
180180 if (req->base_pcifunc) {
181+ /* A VF is untrusted and must not redirect its LMTLINE to
182+ * another PF's region, so confine VF callers to their own PF.
183+ */
184+ if (is_vf(req->hdr.pcifunc) &&
185+ (!is_pf_func_valid(rvu, req->base_pcifunc) ||
186+ rvu_get_pf(rvu->pdev, req->hdr.pcifunc) !=
187+ rvu_get_pf(rvu->pdev, req->base_pcifunc)))
188+ return -EPERM;
189+
181190 /* Calculating the LMT table index equivalent to primary
182191 * pcifunc.
183192 */
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c+32−27
@@ -482,10 +482,11 @@ static int rvu_dbg_mcs_rx_secy_stats_display(struct seq_file *filp, void *unused · 481 unmodified lines
482482 seq_printf(filp, "secy%d: Tagged ctrl pkts: %lld\n", secy_id,
483483 stats.pkt_tagged_ctl_cnt);
484484 seq_printf(filp, "secy%d: Untaged pkts: %lld\n", secy_id, stats.pkt_untaged_cnt);
485− seq_printf(filp, "secy%d: Ctrl pkts: %lld\n", secy_id, stats.pkt_ctl_cnt);
486485 if (mcs->hw->mcs_blks > 1)
487486 seq_printf(filp, "secy%d: pkts notag: %lld\n", secy_id,
488487 stats.pkt_notag_cnt);
488+ else
489+ seq_printf(filp, "secy%d: Ctrl pkts: %lld\n", secy_id, stats.pkt_ctl_cnt);
489490 }
490491 mutex_unlock(&mcs->stats_lock);
491492 return 0;
@@ -2809,6 +2810,14 @@ static void rvu_dbg_npa_init(struct rvu *rvu) · 2317 unmodified lines
28092810 &rvu_dbg_npa_ndc_hits_miss_fops);
28102811 }
28112812
2813+/* Per-lmac CGX debugfs files need both RVU and CGX handle; inode->i_private
2814+ * points here so seq_file ops avoid pci_get_device(PCI_DEVID_OCTEONTX2_RVU_AF).
2815+ */
2816+struct rvu_cgx_lmac_dbgfs_ctx {
2817+ struct rvu *rvu;
2818+ void *cgxd;
2819+};
2820+
28122821 #define PRINT_CGX_CUML_NIXRX_STATUS(idx, name) \
28132822 ({ \
28142823 u64 cnt; \
@@ -2831,18 +2840,14 @@ static void rvu_dbg_npa_init(struct rvu *rvu) · 16 unmodified lines
28312840
28322841 static int cgx_print_stats(struct seq_file *s, int lmac_id)
28332842 {
2843+ struct rvu_cgx_lmac_dbgfs_ctx *dctx = s->private;
28342844 struct cgx_link_user_info linfo;
2845+ struct rvu *rvu = dctx->rvu;
28352846 struct mac_ops *mac_ops;
2836− void *cgxd = s->private;
2847+ void *cgxd = dctx->cgxd;
28372848 u64 ucast, mcast, bcast;
28382849 int stat = 0, err = 0;
28392850 u64 tx_stat, rx_stat;
2840− struct rvu *rvu;
2841−
2842− rvu = pci_get_drvdata(pci_get_device(PCI_VENDOR_ID_CAVIUM,
2843− PCI_DEVID_OCTEONTX2_RVU_AF, NULL));
2844− if (!rvu)
2845− return -ENODEV;
28462851
28472852 mac_ops = get_mac_ops(cgxd);
28482853 /* There can be no CGX devices at all */
@@ -2949,20 +2954,16 @@ RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL); · 100 unmodified lines
29492954
29502955 static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id)
29512956 {
2957+ struct rvu_cgx_lmac_dbgfs_ctx *dctx = s->private;
2958+ struct rvu *rvu = dctx->rvu;
29522959 struct pci_dev *pdev = NULL;
2953− void *cgxd = s->private;
2960+ void *cgxd = dctx->cgxd;
29542961 char *bcast, *mcast;
29552962 u16 index, domain;
29562963 u8 dmac[ETH_ALEN];
2957− struct rvu *rvu;
29582964 u64 cfg, mac;
29592965 int pf;
29602966
2961− rvu = pci_get_drvdata(pci_get_device(PCI_VENDOR_ID_CAVIUM,
2962− PCI_DEVID_OCTEONTX2_RVU_AF, NULL));
2963− if (!rvu)
2964− return -ENODEV;
2965−
29662967 pf = cgxlmac_to_pf(rvu, cgx_get_cgxid(cgxd), lmac_id);
29672968 domain = 2;
29682969
@@ -3009,17 +3010,13 @@ RVU_DEBUG_SEQ_FOPS(cgx_dmac_flt, cgx_dmac_flt_display, NULL); · 40 unmodified lines
30093010
30103011 static int cgx_print_fwdata(struct seq_file *s, int lmac_id)
30113012 {
3013+ struct rvu_cgx_lmac_dbgfs_ctx *dctx = s->private;
30123014 struct cgx_lmac_fwdata_s *fwdata;
3013− void *cgxd = s->private;
3015+ struct rvu *rvu = dctx->rvu;
3016+ void *cgxd = dctx->cgxd;
30143017 struct phy_s *phy;
3015− struct rvu *rvu;
30163018 int cgx_id, i;
30173019
3018− rvu = pci_get_drvdata(pci_get_device(PCI_VENDOR_ID_CAVIUM,
3019− PCI_DEVID_OCTEONTX2_RVU_AF, NULL));
3020− if (!rvu)
3021− return -ENODEV;
3022−
30233020 if (!rvu->fwdata)
30243021 return -EAGAIN;
30253022
@@ -3100,6 +3097,7 @@ RVU_DEBUG_SEQ_FOPS(cgx_fwdata, cgx_fwdata_display, NULL); · 74 unmodified lines
31003097
31013098 static void rvu_dbg_cgx_init(struct rvu *rvu)
31023099 {
3100+ struct rvu_cgx_lmac_dbgfs_ctx *ctx;
31033101 struct mac_ops *mac_ops;
31043102 unsigned long lmac_bmap;
31053103 int i, lmac_id;
@@ -3126,6 +3124,13 @@ static void rvu_dbg_cgx_init(struct rvu *rvu) · 20 unmodified lines
31263124 rvu->rvu_dbg.cgx = debugfs_create_dir(dname,
31273125 rvu->rvu_dbg.cgx_root);
31283126
3127+ ctx = devm_kzalloc(rvu->dev, sizeof(*ctx), GFP_KERNEL);
3128+ if (!ctx)
3129+ continue;
3130+
3131+ ctx->rvu = rvu;
3132+ ctx->cgxd = cgx;
3133+
31293134 for_each_set_bit(lmac_id, &lmac_bmap, rvu->hw->lmac_per_cgx) {
31303135 /* lmac debugfs dir */
31313136 sprintf(dname, "lmac%d", lmac_id);
@@ -3133,13 +3138,13 @@ static void rvu_dbg_cgx_init(struct rvu *rvu) · 1 unmodified line
31333138 debugfs_create_dir(dname, rvu->rvu_dbg.cgx);
31343139
31353140 debugfs_create_file_aux_num("stats", 0600, rvu->rvu_dbg.lmac,
3136− cgx, lmac_id, &rvu_dbg_cgx_stat_fops);
3141+ ctx, lmac_id, &rvu_dbg_cgx_stat_fops);
31373142 debugfs_create_file_aux_num("mac_filter", 0600,
3138− rvu->rvu_dbg.lmac, cgx, lmac_id,
3143+ rvu->rvu_dbg.lmac, ctx, lmac_id,
31393144 &rvu_dbg_cgx_dmac_flt_fops);
3140− debugfs_create_file("fwdata", 0600,
3141− rvu->rvu_dbg.lmac, cgx,
3142− &rvu_dbg_cgx_fwdata_fops);
3145+ debugfs_create_file_aux_num("fwdata", 0600,
3146+ rvu->rvu_dbg.lmac, ctx,
3147+ lmac_id, &rvu_dbg_cgx_fwdata_fops);
31433148 }
31443149 }
31453150 }
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c+19−8
@@ -1511,7 +1511,9 @@ static int rvu_af_dl_nix_maxlf_validate(struct devlink *devlink, u32 id, · 1510 unmodified lines
15111511 struct rvu_devlink *rvu_dl = devlink_priv(devlink);
15121512 struct rvu *rvu = rvu_dl->rvu;
15131513 u16 max_nix0_lf, max_nix1_lf;
1514− struct npc_mcam *mcam;
1514+ struct rvu_block *block;
1515+ int blkaddr = 0;
1516+ int free_lfs;
15151517 u64 cfg;
15161518
15171519 cfg = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST2);
@@ -1519,14 +1521,23 @@ static int rvu_af_dl_nix_maxlf_validate(struct devlink *devlink, u32 id, · 1 unmodified line
15191521 cfg = rvu_read64(rvu, BLKADDR_NIX1, NIX_AF_CONST2);
15201522 max_nix1_lf = cfg & 0xFFF;
15211523
1522− /* Do not allow user to modify maximum NIX LFs while mcam entries
1523− * have already been assigned.
1524+ /* Do not allow user to modify maximum NIX LFs while NIX LFs
1525+ * have already been assigned. Note that modifying NIX LFs count
1526+ * can be done only before any LF attach requests from PFs and VFs
1527+ * and not later or concurrently.
15241528 */
1525− mcam = &rvu->hw->mcam;
1526− if (mcam->bmap_fcnt < mcam->bmap_entries) {
1527− NL_SET_ERR_MSG_MOD(extack,
1528− "mcam entries have already been assigned, can't resize");
1529− return -EPERM;
1529+ blkaddr = rvu_get_next_nix_blkaddr(rvu, blkaddr);
1530+ while (blkaddr) {
1531+ block = &rvu->hw->block[blkaddr];
1532+
1533+ free_lfs = rvu_rsrc_free_count(&block->lf);
1534+ if (free_lfs != block->lf.max) {
1535+ NL_SET_ERR_MSG_MOD(extack,
1536+ "NIX LFs already assigned, can't resize");
1537+ return -EPERM;
1538+ }
1539+
1540+ blkaddr = rvu_get_next_nix_blkaddr(rvu, blkaddr);
15301541 }
15311542
15321543 if (max_nix0_lf && val->vu16 > max_nix0_lf) {
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c+8−3
@@ -528,19 +528,24 @@ static int nix_setup_bpids(struct rvu *rvu, struct nix_hw *hw, int blkaddr) · 527 unmodified lines
528528 bp->fn_map = devm_kcalloc(rvu->dev, bp->bpids.max,
529529 sizeof(u16), GFP_KERNEL);
530530 if (!bp->fn_map)
531− return -ENOMEM;
531+ goto free_bpids;
532532
533533 bp->intf_map = devm_kcalloc(rvu->dev, bp->bpids.max,
534534 sizeof(u8), GFP_KERNEL);
535535 if (!bp->intf_map)
536− return -ENOMEM;
536+ goto free_bpids;
537537
538538 bp->ref_cnt = devm_kcalloc(rvu->dev, bp->bpids.max,
539539 sizeof(u8), GFP_KERNEL);
540540 if (!bp->ref_cnt)
541− return -ENOMEM;
541+ goto free_bpids;
542542
543543 return 0;
544+
545+free_bpids:
546+ rvu_free_bitmap(&bp->bpids);
547+ bp->bpids.bmap = NULL;
548+ return -ENOMEM;
544549 }
545550
546551 void rvu_nix_flr_free_bpids(struct rvu *rvu, u16 pcifunc)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c+1−1
@@ -2225,7 +2225,7 @@ int npc_install_mcam_drop_rule(struct rvu *rvu, int mcam_idx, u16 *counter_idx, · 2224 unmodified lines
22252225 return err;
22262226 }
22272227
2228− dev_err(rvu->dev,
2228+ dev_dbg(rvu->dev,
22292229 "%s: Installed single drop on non hit rule at %d, cntr=%d\n",
22302230 __func__, mcam_idx, req.cntr);
22312231
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c+8−2
@@ -182,6 +182,7 @@ static void cn10k_mcs_free_rsrc(struct otx2_nic *pfvf, enum mcs_direction dir, · 181 unmodified lines
182182 clear_req->id = hw_rsrc_id;
183183 clear_req->type = type;
184184 clear_req->dir = dir;
185+ clear_req->all = all;
185186
186187 req = otx2_mbox_alloc_msg_mcs_free_resources(mbox);
187188 if (!req)
@@ -1776,11 +1777,16 @@ fail: · 1588 unmodified lines
17761777
17771778 void cn10k_mcs_free(struct otx2_nic *pfvf)
17781779 {
1780+ struct cn10k_mcs_cfg *cfg = pfvf->macsec_cfg;
1781+
17791782 if (!test_bit(CN10K_HW_MACSEC, &pfvf->hw.cap_flag))
17801783 return;
17811784
1782− cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_SECY, 0, true);
1783− cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SECY, 0, true);
1785+ if (!list_empty(&cfg->txsc_list)) {
1786+ cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_SECY, 0, true);
1787+ cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SECY, 0, true);
1788+ }
1789+
17841790 kfree(pfvf->macsec_cfg);
17851791 pfvf->macsec_cfg = NULL;
17861792 }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c+1−0
@@ -1575,6 +1575,7 @@ static void otx2_free_sq_res(struct otx2_nic *pf) · 1574 unmodified lines
15751575 qmem_free(pf->dev, sq->sqe_ring);
15761576 qmem_free(pf->dev, sq->cpt_resp);
15771577 qmem_free(pf->dev, sq->tso_hdrs);
1578+ qmem_free(pf->dev, sq->timestamps);
15781579 kfree(sq->sg);
15791580 kfree(sq->sqb_ptrs);
15801581 }
drivers/net/ethernet/marvell/prestera/prestera_main.c+1−1
@@ -373,7 +373,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port) · 372 unmodified lines
373373 struct device_node *ports, *node;
374374 struct fwnode_handle *fwnode;
375375 struct phylink *phy_link;
376− int err;
376+ int err = 0;
377377
378378 if (!sw->np)
379379 return 0;
drivers/net/ethernet/mediatek/mtk_eth_soc.c+5−5
@@ -4960,6 +4960,11 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · 4959 unmodified lines
49604960 if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
49614961 mac_ops = &rt5350_phylink_ops;
49624962
4963+ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) &&
4964+ id == MTK_GMAC2_ID)
4965+ __set_bit(PHY_INTERFACE_MODE_INTERNAL,
4966+ mac->phylink_config.supported_interfaces);
4967+
49634968 phylink = phylink_create(&mac->phylink_config,
49644969 of_fwnode_handle(mac->of_node),
49654970 phy_mode, mac_ops);
@@ -4970,11 +4975,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · 4 unmodified lines
49704975
49714976 mac->phylink = phylink;
49724977
4973− if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) &&
4974− id == MTK_GMAC2_ID)
4975− __set_bit(PHY_INTERFACE_MODE_INTERNAL,
4976− mac->phylink_config.supported_interfaces);
4977−
49784978 SET_NETDEV_DEV(eth->netdev[id], eth->dev);
49794979 eth->netdev[id]->watchdog_timeo = 5 * HZ;
49804980 eth->netdev[id]->netdev_ops = &mtk_netdev_ops;
drivers/net/ethernet/mediatek/mtk_ppe.c+2−2
@@ -918,7 +918,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index) · 917 unmodified lines
918918 mib = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*mib),
919919 &ppe->mib_phys, GFP_KERNEL);
920920 if (!mib)
921− return NULL;
921+ goto err_free_l2_flows;
922922
923923 ppe->mib_table = mib;
924924
@@ -926,7 +926,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index) · 1 unmodified line
926926 GFP_KERNEL);
927927
928928 if (!acct)
929− return NULL;
929+ goto err_free_l2_flows;
930930
931931 ppe->acct_table = acct;
932932 }
drivers/net/ethernet/mellanox/mlx5/core/Kconfig+1−1
@@ -143,7 +143,7 @@ config MLX5_CORE_IPOIB · 142 unmodified lines
143143 config MLX5_MACSEC
144144 bool "Connect-X support for MACSec offload"
145145 depends on MLX5_CORE_EN
146− depends on MACSEC
146+ depends on MACSEC=y || MACSEC=MLX5_CORE
147147 default n
148148 help
149149 Build support for MACsec cryptography-offload acceleration in the NIC.
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c+2−1
@@ -2721,7 +2721,8 @@ const struct ethtool_ops mlx5e_ethtool_ops = { · 2720 unmodified lines
27212721 .rxfh_max_num_contexts = MLX5E_MAX_NUM_RSS,
27222722 .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS |
27232723 ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM |
2724− ETHTOOL_OP_NEEDS_RTNL_SPFLAGS,
2724+ ETHTOOL_OP_NEEDS_RTNL_SPFLAGS |
2725+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
27252726 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
27262727 ETHTOOL_COALESCE_MAX_FRAMES |
27272728 ETHTOOL_COALESCE_USE_ADAPTIVE |
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+2−1
@@ -419,7 +419,8 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = { · 418 unmodified lines
419419 ETHTOOL_COALESCE_MAX_FRAMES |
420420 ETHTOOL_COALESCE_USE_ADAPTIVE,
421421 .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS |
422− ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM,
422+ ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM |
423+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
423424 .get_drvinfo = mlx5e_rep_get_drvinfo,
424425 .get_link = ethtool_op_get_link,
425426 .get_strings = mlx5e_rep_get_strings,
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c+3−1
@@ -286,7 +286,8 @@ const struct ethtool_ops mlx5i_ethtool_ops = { · 285 unmodified lines
286286 ETHTOOL_COALESCE_MAX_FRAMES |
287287 ETHTOOL_COALESCE_USE_ADAPTIVE,
288288 .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS |
289− ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM,
289+ ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM |
290+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
290291 .get_drvinfo = mlx5i_get_drvinfo,
291292 .get_strings = mlx5i_get_strings,
292293 .get_sset_count = mlx5i_get_sset_count,
@@ -309,6 +310,7 @@ const struct ethtool_ops mlx5i_ethtool_ops = { · 16 unmodified lines
309310 };
310311
311312 const struct ethtool_ops mlx5i_pkey_ethtool_ops = {
313+ .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_GLINK,
312314 .get_drvinfo = mlx5i_get_drvinfo,
313315 .get_link = ethtool_op_get_link,
314316 .get_ts_info = mlx5i_get_ts_info,
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h+0−1
@@ -297,7 +297,6 @@ void mlx5_core_reps_aux_devs_remove(struct mlx5_core_dev *dev); · 296 unmodified lines
297297 void mlx5_fw_reporters_create(struct mlx5_core_dev *dev);
298298 int mlx5_query_mtpps(struct mlx5_core_dev *dev, u32 *mtpps, u32 mtpps_size);
299299 int mlx5_set_mtpps(struct mlx5_core_dev *mdev, u32 *mtpps, u32 mtpps_size);
300−int mlx5_query_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 *arm, u8 *mode);
301300 int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode);
302301
303302 struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev);
drivers/net/ethernet/mellanox/mlx5/core/port.c+0−19
@@ -908,25 +908,6 @@ int mlx5_set_mtpps(struct mlx5_core_dev *mdev, u32 *mtpps, u32 mtpps_size) · 907 unmodified lines
908908 sizeof(out), MLX5_REG_MTPPS, 0, 1);
909909 }
910910
911−int mlx5_query_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 *arm, u8 *mode)
912−{
913− u32 out[MLX5_ST_SZ_DW(mtppse_reg)] = {0};
914− u32 in[MLX5_ST_SZ_DW(mtppse_reg)] = {0};
915− int err = 0;
916−
917− MLX5_SET(mtppse_reg, in, pin, pin);
918−
919− err = mlx5_core_access_reg(mdev, in, sizeof(in), out,
920− sizeof(out), MLX5_REG_MTPPSE, 0, 0);
921− if (err)
922− return err;
923−
924− *arm = MLX5_GET(mtppse_reg, in, event_arm);
925− *mode = MLX5_GET(mtppse_reg, in, event_generation_mode);
926−
927− return err;
928−}
929−
930911 int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode)
931912 {
932913 u32 out[MLX5_ST_SZ_DW(mtppse_reg)] = {0};
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c+2−1
@@ -2024,7 +2024,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = { · 2023 unmodified lines
20242024 ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM |
20252025 ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM |
20262026 ETHTOOL_OP_NEEDS_RTNL_SCHANNELS |
2027− ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM,
2027+ ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM |
2028+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
20282029 .get_drvinfo = fbnic_get_drvinfo,
20292030 .get_regs_len = fbnic_get_regs_len,
20302031 .get_regs = fbnic_get_regs,
drivers/net/ethernet/meta/fbnic/fbnic_fw.c+4−5
@@ -526,15 +526,10 @@ int fbnic_fw_xmit_ownership_msg(struct fbnic_dev *fbd, bool take_ownership) · 525 unmodified lines
526526 goto free_message;
527527 }
528528
529− err = fbnic_mbx_map_tlv_msg(fbd, msg);
530− if (err)
531− goto free_message;
532−
533529 /* Initialize heartbeat, set last response to 1 second in the past
534530 * so that we will trigger a timeout if the firmware doesn't respond
535531 */
536532 fbd->last_heartbeat_response = req_time - HZ;
537−
538533 fbd->last_heartbeat_request = req_time;
539534
540535 /* Set prev_firmware_time to 0 to avoid triggering firmware crash
@@ -542,6 +537,10 @@ int fbnic_fw_xmit_ownership_msg(struct fbnic_dev *fbd, bool take_ownership) · 1 unmodified line
542537 */
543538 fbd->prev_firmware_time = 0;
544539
540+ err = fbnic_mbx_map_tlv_msg(fbd, msg);
541+ if (err)
542+ goto free_message;
543+
545544 /* Set heartbeat detection based on if we are taking ownership */
546545 fbd->fw_heartbeat_enabled = take_ownership;
547546
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c+6−1
@@ -264,8 +264,11 @@ static int fbnic_set_mac(struct net_device *netdev, void *p) · 263 unmodified lines
264264
265265 eth_hw_addr_set(netdev, addr->sa_data);
266266
267− if (netif_running(netdev))
267+ if (netif_running(netdev)) {
268+ netif_addr_lock_bh(netdev);
268269 __fbnic_set_rx_mode(fbn->fbd, &netdev->uc, &netdev->mc);
270+ netif_addr_unlock_bh(netdev);
271+ }
269272
270273 return 0;
271274 }
@@ -310,8 +313,10 @@ void fbnic_clear_rx_mode(struct fbnic_dev *fbd) · 38 unmodified lines
310313 /* Write updates to hardware */
311314 fbnic_write_macda(fbd);
312315
316+ netif_addr_lock_bh(netdev);
313317 __dev_uc_unsync(netdev, NULL);
314318 __dev_mc_unsync(netdev, NULL);
319+ netif_addr_unlock_bh(netdev);
315320 }
316321
317322 static int fbnic_hwtstamp_get(struct net_device *netdev,
drivers/net/ethernet/meta/fbnic/fbnic_pci.c+4−0
@@ -135,7 +135,9 @@ void fbnic_up(struct fbnic_net *fbn) · 134 unmodified lines
135135
136136 fbnic_rss_reinit_hw(fbn->fbd, fbn);
137137
138+ netif_addr_lock_bh(fbn->netdev);
138139 __fbnic_set_rx_mode(fbn->fbd, &fbn->netdev->uc, &fbn->netdev->mc);
140+ netif_addr_unlock_bh(fbn->netdev);
139141
140142 /* Enable Tx/Rx processing */
141143 fbnic_napi_enable(fbn);
@@ -180,7 +182,9 @@ static int fbnic_fw_config_after_crash(struct fbnic_dev *fbd) · 38 unmodified lines
180182 }
181183
182184 fbnic_rpc_reset_valid_entries(fbd);
185+ netif_addr_lock_bh(fbd->netdev);
183186 __fbnic_set_rx_mode(fbd, &fbd->netdev->uc, &fbd->netdev->mc);
187+ netif_addr_unlock_bh(fbd->netdev);
184188
185189 return 0;
186190 }
drivers/net/ethernet/meta/fbnic/fbnic_rpc.c+2−0
@@ -244,7 +244,9 @@ void fbnic_bmc_rpc_check(struct fbnic_dev *fbd) · 243 unmodified lines
244244
245245 if (fbd->fw_cap.need_bmc_tcam_reinit) {
246246 fbnic_bmc_rpc_init(fbd);
247+ netif_addr_lock_bh(fbd->netdev);
247248 __fbnic_set_rx_mode(fbd, &fbd->netdev->uc, &fbd->netdev->mc);
249+ netif_addr_unlock_bh(fbd->netdev);
248250 fbd->fw_cap.need_bmc_tcam_reinit = false;
249251 }
250252
drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c+3−1
@@ -765,11 +765,13 @@ int sparx5_register_notifier_blocks(struct sparx5 *s5) · 764 unmodified lines
765765 sparx5_owq = alloc_ordered_workqueue("sparx5_order", 0);
766766 if (!sparx5_owq) {
767767 err = -ENOMEM;
768− goto err_switchdev_blocking_nb;
768+ goto err_alloc_workqueue;
769769 }
770770
771771 return 0;
772772
773+err_alloc_workqueue:
774+ unregister_switchdev_blocking_notifier(&s5->switchdev_blocking_nb);
773775 err_switchdev_blocking_nb:
774776 unregister_switchdev_notifier(&s5->switchdev_nb);
775777 err_switchdev_nb:
drivers/net/ethernet/microsoft/mana/gdma_main.c+64−14
@@ -210,6 +210,8 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev) · 209 unmodified lines
210210 } else {
211211 /* If dynamic allocation is enabled we have already allocated
212212 * hwc msi
213+ * Also, we make sure in this case the following is always true
214+ * (num_msix_usable - 1 HWC) <= num_online_cpus()
213215 */
214216 gc->num_msix_usable = min(resp.max_msix, num_online_cpus() + 1);
215217 }
@@ -1909,8 +1911,8 @@ void mana_gd_free_res_map(struct gdma_resource *r) · 1693 unmodified lines
19091911 * do the same thing.
19101912 */
19111913
1912−static int irq_setup(unsigned int *irqs, unsigned int len, int node,
1913− bool skip_first_cpu)
1914+static int mana_irq_setup_numa_aware(unsigned int *irqs, unsigned int len,
1915+ int node, bool skip_first_cpu)
19141916 {
19151917 const struct cpumask *next, *prev = cpu_none_mask;
19161918 cpumask_var_t cpus __free(free_cpumask_var);
@@ -1946,11 +1948,24 @@ done: · 29 unmodified lines
19461948 return 0;
19471949 }
19481950
1951+/* must be called with cpus_read_lock() held */
1952+static void mana_irq_setup_linear(unsigned int *irqs, unsigned int len)
1953+{
1954+ int cpu;
1955+
1956+ for_each_online_cpu(cpu) {
1957+ if (len == 0)
1958+ break;
1959+
1960+ irq_set_affinity_and_hint(*irqs++, cpumask_of(cpu));
1961+ len--;
1962+ }
1963+}
1964+
19491965 static int mana_gd_setup_dyn_irqs(struct pci_dev *pdev, int nvec)
19501966 {
19511967 struct gdma_context *gc = pci_get_drvdata(pdev);
19521968 struct gdma_irq_context *gic;
1953− bool skip_first_cpu = false;
19541969 int *irqs, err, i, msi;
19551970
19561971 irqs = kmalloc_objs(int, nvec);
@@ -1958,10 +1973,12 @@ static int mana_gd_setup_dyn_irqs(struct pci_dev *pdev, int nvec) · 1 unmodified line
19581973 return -ENOMEM;
19591974
19601975 /*
1976+ * In this function, num_msix_usable = HWC IRQ + Queue IRQ.
1977+ * nvec is only Queue IRQ (HWC already setup).
19611978 * While processing the next pci irq vector, we start with index 1,
19621979 * as IRQ vector at index 0 is already processed for HWC.
19631980 * However, the population of irqs array starts with index 0, to be
1964− * further used in irq_setup()
1981+ * further used in mana_irq_setup_numa_aware()
19651982 */
19661983 for (i = 1; i <= nvec; i++) {
19671984 msi = i;
@@ -1975,18 +1992,51 @@ static int mana_gd_setup_dyn_irqs(struct pci_dev *pdev, int nvec) · 7 unmodified lines
19751992 }
19761993
19771994 /*
1978− * When calling irq_setup() for dynamically added IRQs, if number of
1979− * CPUs is more than or equal to allocated MSI-X, we need to skip the
1980− * first CPU sibling group since they are already affinitized to HWC IRQ
1995+ * When calling mana_irq_setup_numa_aware() for dynamically added IRQs,
1996+ * if number of CPUs is more than or equal to allocated MSI-X, we need to
1997+ * skip the first CPU sibling group since they are already affinitized to
1998+ * HWC IRQ
19811999 */
19822000 cpus_read_lock();
1983− if (gc->num_msix_usable <= num_online_cpus())
1984− skip_first_cpu = true;
2001+ if (gc->num_msix_usable <= num_online_cpus()) {
2002+ err = mana_irq_setup_numa_aware(irqs, nvec, gc->numa_node,
2003+ true);
2004+ if (err) {
2005+ cpus_read_unlock();
2006+ goto free_irq;
2007+ }
2008+ } else {
2009+ /*
2010+ * When num_msix_usable are more than num_online_cpus, our
2011+ * queue IRQs should be equal to num of online vCPUs.
2012+ * We try to make sure queue IRQs spread across all vCPUs.
2013+ * In such a case NUMA or CPU core affinity does not matter.
2014+ * Note: in this case the total mana IRQ should always be
2015+ * num_online_cpus + 1. The first HWC IRQ is already handled
2016+ * in HWC setup calls
2017+ * However, if CPUs went offline since num_msix_usable was
2018+ * computed, queue IRQs will be more than num_online_cpus().
2019+ * In such cases remaining extra IRQs will retain their default
2020+ * affinity.
2021+ */
2022+ int first_unassigned = num_online_cpus();
19852023
1986− err = irq_setup(irqs, nvec, gc->numa_node, skip_first_cpu);
1987− if (err) {
1988− cpus_read_unlock();
1989− goto free_irq;
2024+ if (nvec > first_unassigned) {
2025+ char buf[32];
2026+
2027+ if (first_unassigned == nvec - 1)
2028+ snprintf(buf, sizeof(buf), "%d",
2029+ first_unassigned);
2030+ else
2031+ snprintf(buf, sizeof(buf), "%d-%d",
2032+ first_unassigned, nvec - 1);
2033+
2034+ dev_dbg(&pdev->dev,
2035+ "MANA IRQ indices #%s will retain the default CPU affinity\n",
2036+ buf);
2037+ }
2038+
2039+ mana_irq_setup_linear(irqs, nvec);
19902040 }
19912041
19922042 cpus_read_unlock();
@@ -2041,7 +2091,7 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev, int nvec) · 48 unmodified lines
20412091 nvec -= 1;
20422092 }
20432093
2044− err = irq_setup(irqs, nvec, gc->numa_node, false);
2094+ err = mana_irq_setup_numa_aware(irqs, nvec, gc->numa_node, false);
20452095 if (err) {
20462096 cpus_read_unlock();
20472097 goto free_irq;
drivers/net/ethernet/microsoft/mana/mana_bpf.c+2−1
@@ -237,7 +237,8 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, · 236 unmodified lines
237237 bpf_prog_put(old_prog);
238238
239239 if (prog)
240− ndev->max_mtu = MANA_XDP_MTU_MAX;
240+ ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX,
241+ gc->adapter_mtu - ETH_HLEN);
241242 else
242243 ndev->max_mtu = gc->adapter_mtu - ETH_HLEN;
243244
drivers/net/ethernet/microsoft/mana/mana_en.c+14−2
@@ -1233,12 +1233,24 @@ int mana_gd_query_device_cfg(struct gdma_context *gc, u32 proto_major_ver, · 1232 unmodified lines
12331233 *max_num_vports = resp.max_num_vports;
12341234
12351235 if (resp.hdr.response.msg_version >= GDMA_MESSAGE_V2) {
1236− if (resp.adapter_mtu < ETH_MIN_MTU + ETH_HLEN) {
1236+ if (resp.adapter_mtu == 0) {
1237+ /*
1238+ * Some older PF firmware versions report an
1239+ * adapter_mtu of 0. MANA hardware always supports the
1240+ * standard Ethernet MTU, so fall back to ETH_FRAME_LEN.
1241+ * Jumbo frames will not be available in this case.
1242+ */
1243+ dev_info(dev,
1244+ "PF reported adapter_mtu of 0, falling back to %u (jumbo frames disabled)\n",
1245+ ETH_FRAME_LEN);
1246+ gc->adapter_mtu = ETH_FRAME_LEN;
1247+ } else if (resp.adapter_mtu < ETH_MIN_MTU + ETH_HLEN) {
12371248 dev_err(dev, "Adapter MTU too small: %u\n",
12381249 resp.adapter_mtu);
12391250 return -EPROTO;
1251+ } else {
1252+ gc->adapter_mtu = resp.adapter_mtu;
12401253 }
1241− gc->adapter_mtu = resp.adapter_mtu;
12421254 } else {
12431255 gc->adapter_mtu = ETH_FRAME_LEN;
12441256 }
drivers/net/ethernet/microsoft/mana/mana_ethtool.c+2−1
@@ -597,7 +597,8 @@ static int mana_get_link_ksettings(struct net_device *ndev, · 596 unmodified lines
597597 const struct ethtool_ops mana_ethtool_ops = {
598598 .supported_coalesce_params = ETHTOOL_COALESCE_RX_CQE_FRAMES,
599599 .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS |
600− ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM,
600+ ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM |
601+ ETHTOOL_OP_NEEDS_RTNL_GLINK,
601602 .get_ethtool_stats = mana_get_ethtool_stats,
602603 .get_sset_count = mana_get_sset_count,
603604 .get_strings = mana_get_strings,
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c+29−9
@@ -1420,13 +1420,25 @@ pch_gbe_alloc_rx_buffers_pool(struct pch_gbe_adapter *adapter, · 1419 unmodified lines
14201420 return 0;
14211421 }
14221422
1423+static void pch_gbe_free_rx_buffers_pool(struct pch_gbe_adapter *adapter,
1424+ struct pch_gbe_rx_ring *rx_ring)
1425+{
1426+ dma_free_coherent(&adapter->pdev->dev, rx_ring->rx_buff_pool_size,
1427+ rx_ring->rx_buff_pool, rx_ring->rx_buff_pool_logic);
1428+ rx_ring->rx_buff_pool_logic = 0;
1429+ rx_ring->rx_buff_pool_size = 0;
1430+ rx_ring->rx_buff_pool = NULL;
1431+}
1432+
14231433 /**
14241434 * pch_gbe_alloc_tx_buffers - Allocate transmit buffers
14251435 * @adapter: Board private structure
14261436 * @tx_ring: Tx descriptor ring
1437+ *
1438+ * Return: 0 on success, -ENOMEM if a TX skb allocation fails.
14271439 */
1428−static void pch_gbe_alloc_tx_buffers(struct pch_gbe_adapter *adapter,
1429− struct pch_gbe_tx_ring *tx_ring)
1440+static int pch_gbe_alloc_tx_buffers(struct pch_gbe_adapter *adapter,
1441+ struct pch_gbe_tx_ring *tx_ring)
14301442 {
14311443 struct pch_gbe_buffer *buffer_info;
14321444 struct sk_buff *skb;
@@ -1440,12 +1452,17 @@ static void pch_gbe_alloc_tx_buffers(struct pch_gbe_adapter *adapter, · 7 unmodified lines
14401452 for (i = 0; i < tx_ring->count; i++) {
14411453 buffer_info = &tx_ring->buffer_info[i];
14421454 skb = netdev_alloc_skb(adapter->netdev, bufsz);
1455+ if (!skb) {
1456+ pch_gbe_clean_tx_ring(adapter, tx_ring);
1457+ return -ENOMEM;
1458+ }
14431459 skb_reserve(skb, PCH_GBE_DMA_ALIGN);
14441460 buffer_info->skb = skb;
14451461 tx_desc = PCH_GBE_TX_DESC(*tx_ring, i);
14461462 tx_desc->gbec_status = (DSC_INIT16);
14471463 }
1448− return;
1464+
1465+ return 0;
14491466 }
14501467
14511468 /**
@@ -1887,7 +1904,12 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter) · 435 unmodified lines
18871904 "Error: can't bring device up - alloc rx buffers pool failed\n");
18881905 goto freeirq;
18891906 }
1890− pch_gbe_alloc_tx_buffers(adapter, tx_ring);
1907+ err = pch_gbe_alloc_tx_buffers(adapter, tx_ring);
1908+ if (err) {
1909+ netdev_err(netdev,
1910+ "Error: can't bring device up - alloc tx buffers failed\n");
1911+ goto freebuf;
1912+ }
18911913 pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
18921914 adapter->tx_queue_len = netdev->tx_queue_len;
18931915 pch_gbe_enable_dma_rx(&adapter->hw);
@@ -1901,6 +1923,8 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter) · 7 unmodified lines
19011923
19021924 return 0;
19031925
1926+freebuf:
1927+ pch_gbe_free_rx_buffers_pool(adapter, rx_ring);
19041928 freeirq:
19051929 pch_gbe_free_irq(adapter);
19061930 out:
@@ -1936,11 +1960,7 @@ void pch_gbe_down(struct pch_gbe_adapter *adapter) · 29 unmodified lines
19361960 pch_gbe_clean_tx_ring(adapter, adapter->tx_ring);
19371961 pch_gbe_clean_rx_ring(adapter, adapter->rx_ring);
19381962
1939− dma_free_coherent(&adapter->pdev->dev, rx_ring->rx_buff_pool_size,
1940− rx_ring->rx_buff_pool, rx_ring->rx_buff_pool_logic);
1941− rx_ring->rx_buff_pool_logic = 0;
1942− rx_ring->rx_buff_pool_size = 0;
1943− rx_ring->rx_buff_pool = NULL;
1963+ pch_gbe_free_rx_buffers_pool(adapter, rx_ring);
19441964 }
19451965
19461966 /**
drivers/net/ethernet/rocker/rocker_ofdpa.c+3−0
@@ -1924,6 +1924,9 @@ static int ofdpa_port_fdb(struct ofdpa_port *ofdpa_port, · 1923 unmodified lines
19241924 flags |= OFDPA_OP_FLAG_REFRESH;
19251925 }
19261926
1927+ if (found && removing)
1928+ kfree(found);
1929+
19271930 return ofdpa_port_fdb_learn(ofdpa_port, flags, addr, vlan_id);
19281931 }
19291932
drivers/net/ethernet/stmicro/stmmac/dwmac-spacemit.c+8−5
@@ -18,10 +18,12 @@ · 17 unmodified lines
1818 #include "stmmac_platform.h"
1919
2020 /* ctrl register bits */
21−#define CTRL_PHY_INTF_RGMII BIT(3)
22−#define CTRL_PHY_INTF_MII BIT(4)
23−#define CTRL_WAKE_IRQ_EN BIT(9)
24−#define CTRL_PHY_IRQ_EN BIT(12)
21+#define CTRL_PHY_INTF_MODE GENMASK(4, 3)
22+#define CTRL_PHY_INTF_RMII FIELD_PREP(CTRL_PHY_INTF_MODE, 0)
23+#define CTRL_PHY_INTF_RGMII FIELD_PREP(CTRL_PHY_INTF_MODE, 1)
24+#define CTRL_PHY_INTF_MII FIELD_PREP(CTRL_PHY_INTF_MODE, 3)
25+#define CTRL_LPI_IRQ_EN BIT(9)
26+#define CTRL_WAKE_IRQ_EN BIT(12)
2527
2628 /* dline register bits */
2729 #define RGMII_RX_DLINE_EN BIT(0)
@@ -118,7 +120,7 @@ static void spacemit_get_interfaces(struct stmmac_priv *priv, void *bsp_priv, · 90 unmodified lines
118120
119121 static int spacemit_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel)
120122 {
121− unsigned int mask = CTRL_PHY_INTF_MII | CTRL_PHY_INTF_RGMII;
123+ unsigned int mask = CTRL_PHY_INTF_MODE;
122124 struct spacmit_dwmac *dwmac = bsp_priv;
123125 unsigned int val = 0;
124126
@@ -128,6 +130,7 @@ static int spacemit_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel) · 3 unmodified lines
128130 break;
129131
130132 case PHY_INTF_SEL_RMII:
133+ val = CTRL_PHY_INTF_RMII;
131134 break;
132135
133136 case PHY_INTF_SEL_RGMII:
drivers/net/ethernet/sun/sungem.c+9−4
@@ -2978,10 +2978,10 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 2977 unmodified lines
29782978 dev->max_mtu = GEM_MAX_MTU;
29792979
29802980 /* Register with kernel */
2981− if (register_netdev(dev)) {
2981+ err = register_netdev(dev);
2982+ if (err) {
29822983 pr_err("Cannot register net device, aborting\n");
2983− err = -ENOMEM;
2984− goto err_out_free_consistent;
2984+ goto err_out_clear_drvdata;
29852985 }
29862986
29872987 /* Undo the get_cell with appropriate locking (we could use
@@ -2995,8 +2995,13 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 7 unmodified lines
29952995 dev->dev_addr);
29962996 return 0;
29972997
2998+err_out_clear_drvdata:
2999+ pci_set_drvdata(pdev, NULL);
3000+ netif_napi_del(&gp->napi);
3001+
29983002 err_out_free_consistent:
2999− gem_remove_one(pdev);
3003+ dma_free_coherent(&pdev->dev, sizeof(struct gem_init_block),
3004+ gp->init_block, gp->gblock_dvma);
30003005 err_out_iounmap:
30013006 gem_put_cell(gp);
30023007 iounmap(gp->regs);
drivers/net/ethernet/sunplus/spl2sw_phy.c+4−2
@@ -79,12 +79,14 @@ int spl2sw_phy_connect(struct spl2sw_common *comm) · 78 unmodified lines
7979 void spl2sw_phy_remove(struct spl2sw_common *comm)
8080 {
8181 struct net_device *ndev;
82+ struct spl2sw_mac *mac;
8283 int i;
8384
8485 for (i = 0; i < MAX_NETDEV_NUM; i++)
8586 if (comm->ndev[i]) {
8687 ndev = comm->ndev[i];
87− if (ndev)
88− phy_disconnect(ndev->phydev);
88+ mac = netdev_priv(ndev);
89+ phy_disconnect(ndev->phydev);
90+ of_node_put(mac->phy_node);
8991 }
9092 }
drivers/net/ethernet/ti/icssg/icssg_common.c+39−33
@@ -93,8 +93,8 @@ void prueth_ndev_del_tx_napi(struct prueth_emac *emac, int num) · 92 unmodified lines
9393 }
9494 EXPORT_SYMBOL_GPL(prueth_ndev_del_tx_napi);
9595
96−static int emac_xsk_xmit_zc(struct prueth_emac *emac,
97− unsigned int q_idx)
96+static void emac_xsk_xmit_zc(struct prueth_emac *emac,
97+ unsigned int q_idx)
9898 {
9999 struct prueth_tx_chn *tx_chn = &emac->tx_chns[q_idx];
100100 struct xsk_buff_pool *pool = tx_chn->xsk_pool;
@@ -115,7 +115,7 @@ static int emac_xsk_xmit_zc(struct prueth_emac *emac, · 14 unmodified lines
115115 * necessary
116116 */
117117 if (descs_avail <= MAX_SKB_FRAGS)
118− return 0;
118+ return;
119119
120120 descs_avail -= MAX_SKB_FRAGS;
121121
@@ -170,8 +170,8 @@ static int emac_xsk_xmit_zc(struct prueth_emac *emac, · 48 unmodified lines
170170 num_tx++;
171171 }
172172
173− xsk_tx_release(tx_chn->xsk_pool);
174− return num_tx;
173+ if (num_tx)
174+ xsk_tx_release(tx_chn->xsk_pool);
175175 }
176176
177177 void prueth_xmit_free(struct prueth_tx_chn *tx_chn,
@@ -279,9 +279,6 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn, · 101 unmodified lines
279279 num_tx++;
280280 }
281281
282− if (!num_tx)
283− return 0;
284−
285282 netif_txq = netdev_get_tx_queue(ndev, chn);
286283 netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
287284
@@ -297,16 +294,18 @@ int emac_tx_complete_packets(struct prueth_emac *emac, int chn, · 9 unmodified lines
297294 __netif_tx_unlock(netif_txq);
298295 }
299296
300− if (tx_chn->xsk_pool) {
301− if (xsk_frames_done)
297+ if (budget && tx_chn->xsk_pool) {
298+ if (xsk_frames_done) {
302299 xsk_tx_completed(tx_chn->xsk_pool, xsk_frames_done);
300+ txq_trans_cond_update(netif_txq);
301+ }
303302
304303 if (xsk_uses_need_wakeup(tx_chn->xsk_pool))
305304 xsk_set_tx_need_wakeup(tx_chn->xsk_pool);
306305
307− netif_txq = netdev_get_tx_queue(ndev, chn);
308− txq_trans_cond_update(netif_txq);
306+ __netif_tx_lock(netif_txq, smp_processor_id());
309307 emac_xsk_xmit_zc(emac, chn);
308+ __netif_tx_unlock(netif_txq);
310309 }
311310
312311 return num_tx;
@@ -1652,28 +1651,35 @@ void icssg_ndo_get_stats64(struct net_device *ndev, · 1339 unmodified lines
16521651 stats->rx_over_errors = emac_get_stat_by_name(emac, "rx_over_errors");
16531652 stats->multicast = emac_get_stat_by_name(emac, "rx_multicast_frames");
16541653
1655− stats->rx_errors = ndev->stats.rx_errors +
1656− emac_get_stat_by_name(emac, "FW_RX_ERROR") +
1657− emac_get_stat_by_name(emac, "FW_RX_EOF_SHORT_FRMERR") +
1658− emac_get_stat_by_name(emac, "FW_RX_B0_DROP_EARLY_EOF") +
1659− emac_get_stat_by_name(emac, "FW_RX_EXP_FRAG_Q_DROP") +
1660− emac_get_stat_by_name(emac, "FW_RX_FIFO_OVERRUN");
1661− stats->rx_dropped = ndev->stats.rx_dropped +
1662− emac_get_stat_by_name(emac, "FW_DROPPED_PKT") +
1663− emac_get_stat_by_name(emac, "FW_INF_PORT_DISABLED") +
1664− emac_get_stat_by_name(emac, "FW_INF_SAV") +
1665− emac_get_stat_by_name(emac, "FW_INF_SA_DL") +
1666− emac_get_stat_by_name(emac, "FW_INF_PORT_BLOCKED") +
1667− emac_get_stat_by_name(emac, "FW_INF_DROP_TAGGED") +
1668− emac_get_stat_by_name(emac, "FW_INF_DROP_PRIOTAGGED") +
1669− emac_get_stat_by_name(emac, "FW_INF_DROP_NOTAG") +
1670− emac_get_stat_by_name(emac, "FW_INF_DROP_NOTMEMBER");
1654+ stats->rx_errors = ndev->stats.rx_errors;
1655+ stats->rx_dropped = ndev->stats.rx_dropped;
16711656 stats->tx_errors = ndev->stats.tx_errors;
1672− stats->tx_dropped = ndev->stats.tx_dropped +
1673− emac_get_stat_by_name(emac, "FW_RTU_PKT_DROP") +
1674− emac_get_stat_by_name(emac, "FW_TX_DROPPED_PACKET") +
1675− emac_get_stat_by_name(emac, "FW_TX_TS_DROPPED_PACKET") +
1676− emac_get_stat_by_name(emac, "FW_TX_JUMBO_FRM_CUTOFF");
1657+ stats->tx_dropped = ndev->stats.tx_dropped;
1658+
1659+ if (!emac->prueth->pa_stats)
1660+ return;
1661+
1662+ stats->rx_errors +=
1663+ emac_get_stat_by_name(emac, "FW_RX_ERROR") +
1664+ emac_get_stat_by_name(emac, "FW_RX_EOF_SHORT_FRMERR") +
1665+ emac_get_stat_by_name(emac, "FW_RX_B0_DROP_EARLY_EOF") +
1666+ emac_get_stat_by_name(emac, "FW_RX_EXP_FRAG_Q_DROP") +
1667+ emac_get_stat_by_name(emac, "FW_RX_FIFO_OVERRUN");
1668+ stats->rx_dropped +=
1669+ emac_get_stat_by_name(emac, "FW_DROPPED_PKT") +
1670+ emac_get_stat_by_name(emac, "FW_INF_PORT_DISABLED") +
1671+ emac_get_stat_by_name(emac, "FW_INF_SAV") +
1672+ emac_get_stat_by_name(emac, "FW_INF_SA_DL") +
1673+ emac_get_stat_by_name(emac, "FW_INF_PORT_BLOCKED") +
1674+ emac_get_stat_by_name(emac, "FW_INF_DROP_TAGGED") +
1675+ emac_get_stat_by_name(emac, "FW_INF_DROP_PRIOTAGGED") +
1676+ emac_get_stat_by_name(emac, "FW_INF_DROP_NOTAG") +
1677+ emac_get_stat_by_name(emac, "FW_INF_DROP_NOTMEMBER");
1678+ stats->tx_dropped +=
1679+ emac_get_stat_by_name(emac, "FW_RTU_PKT_DROP") +
1680+ emac_get_stat_by_name(emac, "FW_TX_DROPPED_PACKET") +
1681+ emac_get_stat_by_name(emac, "FW_TX_TS_DROPPED_PACKET") +
1682+ emac_get_stat_by_name(emac, "FW_TX_JUMBO_FRM_CUTOFF");
16771683 }
16781684 EXPORT_SYMBOL_GPL(icssg_ndo_get_stats64);
16791685
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c+0−1
@@ -715,7 +715,6 @@ static int ngbe_probe(struct pci_dev *pdev, · 714 unmodified lines
715715 netdev->features |= NETIF_F_GRO;
716716
717717 netdev->priv_flags |= IFF_UNICAST_FLT;
718− netdev->priv_flags |= IFF_SUPP_NOFCS;
719718 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
720719
721720 netdev->min_mtu = ETH_MIN_MTU;
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c+0−1
@@ -796,7 +796,6 @@ static int txgbe_probe(struct pci_dev *pdev, · 795 unmodified lines
796796 netdev->features |= NETIF_F_RX_UDP_TUNNEL_PORT;
797797
798798 netdev->priv_flags |= IFF_UNICAST_FLT;
799− netdev->priv_flags |= IFF_SUPP_NOFCS;
800799 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
801800
802801 netdev->min_mtu = ETH_MIN_MTU;
drivers/net/geneve.c+16−2
@@ -954,13 +954,27 @@ static int geneve_gro_complete(struct sock *sk, struct sk_buff *skb, · 953 unmodified lines
954954 struct genevehdr *gh;
955955 struct packet_offload *ptype;
956956 __be16 type;
957− int gh_len;
957+ unsigned int gh_len;
958958 int err = -ENOSYS;
959959
960960 gh = (struct genevehdr *)(skb->data + nhoff);
961961 gh_len = geneve_hlen(gh);
962962 type = gh->proto_type;
963− geneve_opt_gro_hint_off(gh, &type, &gh_len);
963+ geneve_sk_gro_hint_off(sk, gh, &type, &gh_len);
964+
965+ /* Bail out if we are about to dispatch past the inner network header
966+ * gro_receive() validated. An inner VLAN tag only pushes
967+ * inner_network_offset out, so use a lower bound.
968+ */
969+ if (skb->encapsulation) {
970+ unsigned int inner_nh = nhoff + gh_len;
971+
972+ if (type == htons(ETH_P_TEB))
973+ inner_nh += ETH_HLEN;
974+
975+ if (unlikely(inner_nh > NAPI_GRO_CB(skb)->inner_network_offset))
976+ return -EINVAL;
977+ }
964978
965979 /* since skb->encapsulation is set, eth_gro_complete() sets the inner mac header */
966980 if (likely(type == htons(ETH_P_TEB)))
drivers/net/ieee802154/ca8210.c+6−3
@@ -595,7 +595,7 @@ static int ca8210_test_int_driver_write( · 594 unmodified lines
595595 fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
596596 if (!fifo_buffer)
597597 return -ENOMEM;
598− kfifo_in(&test->up_fifo, &fifo_buffer, 4);
598+ kfifo_in(&test->up_fifo, &fifo_buffer, sizeof(fifo_buffer));
599599 wake_up_interruptible(&priv->test.readq);
600600
601601 return 0;
@@ -919,9 +919,10 @@ static int ca8210_spi_transfer( · 317 unmodified lines
919919 if (status < 0) {
920920 dev_crit(
921921 &spi->dev,
922− "status %d from spi_sync in write\n",
922+ "status %d from spi_async in write\n",
923923 status
924924 );
925+ kfree(cas_ctl);
925926 }
926927
927928 return status;
@@ -2525,6 +2526,7 @@ static ssize_t ca8210_test_int_user_read( · 1597 unmodified lines
25252526 struct ca8210_priv *priv = filp->private_data;
25262527 unsigned char *fifo_buffer;
25272528 unsigned long bytes_not_copied;
2529+ unsigned int copied;
25282530
25292531 if (filp->f_flags & O_NONBLOCK) {
25302532 /* Non-blocking mode */
@@ -2538,7 +2540,8 @@ static ssize_t ca8210_test_int_user_read( · 7 unmodified lines
25382540 );
25392541 }
25402542
2541− if (kfifo_out(&priv->test.up_fifo, &fifo_buffer, 4) != 4) {
2543+ copied = kfifo_out(&priv->test.up_fifo, &fifo_buffer, sizeof(fifo_buffer));
2544+ if (copied != sizeof(fifo_buffer)) {
25422545 dev_err(
25432546 &priv->spi->dev,
25442547 "test_interface: Wrong number of elements popped from upstream fifo\n"
drivers/net/netconsole.c+7−5
@@ -190,8 +190,10 @@ struct netconsole_target { · 189 unmodified lines
190190 bool extended;
191191 bool release;
192192 struct netpoll np;
193− /* protected by target_list_lock */
194− char buf[MAX_PRINT_CHUNK];
193+ /* protected by target_list_lock; +1 gives scnprintf() room for its
194+ * NUL terminator so a full MAX_PRINT_CHUNK payload is not truncated
195+ */
196+ char buf[MAX_PRINT_CHUNK + 1];
195197 struct work_struct resume_wq;
196198 };
197199
@@ -1938,7 +1940,7 @@ static void send_msg_no_fragmentation(struct netconsole_target *nt, · 1740 unmodified lines
19381940 if (release_len) {
19391941 release = init_utsname()->release;
19401942
1941− scnprintf(nt->buf, MAX_PRINT_CHUNK, "%s,%.*s", release,
1943+ scnprintf(nt->buf, sizeof(nt->buf), "%s,%.*s", release,
19421944 msg_len, msg);
19431945 msg_len += release_len;
19441946 } else {
@@ -1947,12 +1949,12 @@ static void send_msg_no_fragmentation(struct netconsole_target *nt, · 2 unmodified lines
19471949
19481950 if (userdata)
19491951 msg_len += scnprintf(&nt->buf[msg_len],
1950− MAX_PRINT_CHUNK - msg_len, "%s",
1952+ sizeof(nt->buf) - msg_len, "%s",
19511953 userdata);
19521954
19531955 if (sysdata)
19541956 msg_len += scnprintf(&nt->buf[msg_len],
1955− MAX_PRINT_CHUNK - msg_len, "%s",
1957+ sizeof(nt->buf) - msg_len, "%s",
19561958 sysdata);
19571959
19581960 send_udp(nt, nt->buf, msg_len);
drivers/net/phy/realtek/realtek_main.c+2−1
@@ -1802,7 +1802,8 @@ static int rtl822x_config_aneg(struct phy_device *phydev) · 1801 unmodified lines
18021802 ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2,
18031803 RTL_MDIO_AN_10GBT_CTRL,
18041804 MDIO_AN_10GBT_CTRL_ADV2_5G |
1805− MDIO_AN_10GBT_CTRL_ADV5G, adv);
1805+ MDIO_AN_10GBT_CTRL_ADV5G |
1806+ MDIO_AN_10GBT_CTRL_ADV10G, adv);
18061807 if (ret < 0)
18071808 return ret;
18081809 }
drivers/net/pse-pd/pd692x0.c+1−1
@@ -200,7 +200,7 @@ static const struct pd692x0_msg pd692x0_msg_template_list[PD692X0_MSG_CNT] = { · 199 unmodified lines
200200 },
201201 [PD692X0_MSG_SET_USER_BYTE] = {
202202 .key = PD692X0_KEY_PRG,
203− .sub = {0x41, PD692X0_USER_BYTE},
203+ .sub = {0x41, PD692X0_USER_BYTE, 0x4e},
204204 .data = {0x4e, 0x4e, 0x4e, 0x4e,
205205 0x4e, 0x4e, 0x4e, 0x4e},
206206 },
drivers/net/thunderbolt/main.c+6−2
@@ -783,8 +783,12 @@ static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf, · 782 unmodified lines
783783 return true;
784784 }
785785
786− /* Start of packet, validate the frame header */
787− if (frame_count == 0 || frame_count > TBNET_RING_SIZE / 4) {
786+ /* Start of packet, validate the frame header. tbnet_poll() puts the
787+ * first frame in the skb linear area and every further frame in a page
788+ * fragment, so a packet may not span more than MAX_SKB_FRAGS + 1 frames
789+ * without overflowing skb_shinfo()->frags[].
790+ */
791+ if (frame_count == 0 || frame_count > MAX_SKB_FRAGS + 1) {
788792 net->stats.rx_length_errors++;
789793 return false;
790794 }
drivers/net/usb/kalmia.c+8−0
@@ -276,6 +276,14 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb) · 275 unmodified lines
276276 "Received header: %6phC. Package length: %i\n",
277277 header_start, skb->len - KALMIA_HEADER_LENGTH);
278278
279+ /* both framing headers must be present before we subtract
280+ * them, otherwise usb_packet_length underflows and the
281+ * device-supplied ether_packet_length drives an out of bounds
282+ * access below
283+ */
284+ if (skb->len < 2 * KALMIA_HEADER_LENGTH)
285+ return 0;
286+
279287 /* subtract start header and end header */
280288 usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH);
281289 ether_packet_length = get_unaligned_le16(&header_start[2]);
drivers/net/usb/lan78xx.c+31−6
@@ -1452,6 +1452,15 @@ static inline u32 lan78xx_hash(char addr[ETH_ALEN]) · 1451 unmodified lines
14521452 return (ether_crc(ETH_ALEN, addr) >> 23) & 0x1ff;
14531453 }
14541454
1455+static int lan78xx_write_mchash_table(struct lan78xx_net *dev)
1456+{
1457+ struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]);
1458+
1459+ return lan78xx_dataport_write(dev, DP_SEL_RSEL_VLAN_DA_,
1460+ DP_SEL_VHF_VLAN_LEN,
1461+ DP_SEL_VHF_HASH_LEN, pdata->mchash_table);
1462+}
1463+
14551464 static void lan78xx_deferred_multicast_write(struct work_struct *param)
14561465 {
14571466 struct lan78xx_priv *pdata =
@@ -1462,9 +1471,7 @@ static void lan78xx_deferred_multicast_write(struct work_struct *param) · 4 unmodified lines
14621471 netif_dbg(dev, drv, dev->net, "deferred multicast write 0x%08x\n",
14631472 pdata->rfe_ctl);
14641473
1465− ret = lan78xx_dataport_write(dev, DP_SEL_RSEL_VLAN_DA_,
1466− DP_SEL_VHF_VLAN_LEN,
1467− DP_SEL_VHF_HASH_LEN, pdata->mchash_table);
1474+ ret = lan78xx_write_mchash_table(dev);
14681475 if (ret < 0)
14691476 goto multicast_write_done;
14701477
@@ -1557,6 +1564,7 @@ static void lan78xx_set_multicast(struct net_device *netdev) · 86 unmodified lines
15571564 }
15581565
15591566 static void lan78xx_rx_urb_submit_all(struct lan78xx_net *dev);
1567+static int lan78xx_write_vlan_table(struct lan78xx_net *dev);
15601568
15611569 static int lan78xx_mac_reset(struct lan78xx_net *dev)
15621570 {
@@ -2514,6 +2522,17 @@ static void lan78xx_mac_link_up(struct phylink_config *config, · 951 unmodified lines
25142522 if (ret < 0)
25152523 goto link_up_fail;
25162524
2525+ /* The RFE clears the VLAN/DA hash filter (VHF) on a link down/up
2526+ * cycle, so reprogram both tables from their shadow copies.
2527+ */
2528+ ret = lan78xx_write_vlan_table(dev);
2529+ if (ret < 0)
2530+ goto link_up_fail;
2531+
2532+ ret = lan78xx_write_mchash_table(dev);
2533+ if (ret < 0)
2534+ goto link_up_fail;
2535+
25172536 netif_start_queue(net);
25182537
25192538 return;
@@ -3065,14 +3084,20 @@ static int lan78xx_set_features(struct net_device *netdev, · 545 unmodified lines
30653084 return lan78xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
30663085 }
30673086
3087+static int lan78xx_write_vlan_table(struct lan78xx_net *dev)
3088+{
3089+ struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]);
3090+
3091+ return lan78xx_dataport_write(dev, DP_SEL_RSEL_VLAN_DA_, 0,
3092+ DP_SEL_VHF_VLAN_LEN, pdata->vlan_table);
3093+}
3094+
30683095 static void lan78xx_deferred_vlan_write(struct work_struct *param)
30693096 {
30703097 struct lan78xx_priv *pdata =
30713098 container_of(param, struct lan78xx_priv, set_vlan);
3072− struct lan78xx_net *dev = pdata->dev;
30733099
3074− lan78xx_dataport_write(dev, DP_SEL_RSEL_VLAN_DA_, 0,
3075− DP_SEL_VHF_VLAN_LEN, pdata->vlan_table);
3100+ lan78xx_write_vlan_table(pdata->dev);
30763101 }
30773102
30783103 static int lan78xx_vlan_rx_add_vid(struct net_device *netdev,
drivers/net/veth.c+2−0
@@ -1137,6 +1137,8 @@ static int veth_enable_xdp_range(struct net_device *dev, int start, int end, · 1136 unmodified lines
11371137 err_reg_mem:
11381138 xdp_rxq_info_unreg(&priv->rq[i].xdp_rxq);
11391139 err_rxq_reg:
1140+ if (!napi_already_on)
1141+ netif_napi_del(&priv->rq[i].xdp_napi);
11401142 for (i--; i >= start; i--) {
11411143 struct veth_rq *rq = &priv->rq[i];
11421144
drivers/net/virtio_net.c+6−3
@@ -1999,15 +1999,18 @@ static struct sk_buff *receive_big(struct net_device *dev, · 1998 unmodified lines
19991999 struct virtnet_rq_stats *stats)
20002000 {
20012001 struct page *page = buf;
2002+ unsigned long max_len;
20022003 struct sk_buff *skb;
20032004
2005+ max_len = (vi->big_packets_num_skbfrags + 1) * PAGE_SIZE -
2006+ sizeof(struct padded_vnet_hdr) + vi->hdr_len;
2007+
20042008 /* Make sure that len does not exceed the size allocated in
20052009 * add_recvbuf_big.
20062010 */
2007− if (unlikely(len > (vi->big_packets_num_skbfrags + 1) * PAGE_SIZE)) {
2011+ if (unlikely(len > max_len)) {
20082012 pr_debug("%s: rx error: len %u exceeds allocated size %lu\n",
2009− dev->name, len,
2010− (vi->big_packets_num_skbfrags + 1) * PAGE_SIZE);
2013+ dev->name, len, max_len);
20112014 goto err;
20122015 }
20132016
drivers/net/wan/hdlc_ppp.c+13−2
@@ -619,7 +619,6 @@ static void ppp_start(struct net_device *dev) · 618 unmodified lines
619619 struct proto *proto = &ppp->protos[i];
620620
621621 proto->dev = dev;
622− timer_setup(&proto->timer, ppp_timer, 0);
623622 proto->state = CLOSED;
624623 }
625624 ppp->protos[IDX_LCP].pid = PID_LCP;
@@ -639,6 +638,15 @@ static void ppp_close(struct net_device *dev) · 13 unmodified lines
639638 ppp_tx_flush();
640639 }
641640
641+static void ppp_timer_release(struct net_device *dev)
642+{
643+ struct ppp *ppp = get_ppp(dev);
644+ int i;
645+
646+ for (i = 0; i < IDX_COUNT; i++)
647+ timer_shutdown_sync(&ppp->protos[i].timer);
648+}
649+
642650 static struct hdlc_proto proto = {
643651 .start = ppp_start,
644652 .stop = ppp_stop,
@@ -647,6 +655,7 @@ static struct hdlc_proto proto = { · 2 unmodified lines
647655 .ioctl = ppp_ioctl,
648656 .netif_rx = ppp_rx,
649657 .module = THIS_MODULE,
658+ .detach = ppp_timer_release,
650659 };
651660
652661 static const struct header_ops ppp_header_ops = {
@@ -657,7 +666,7 @@ static int ppp_ioctl(struct net_device *dev, struct if_settings *ifs) · 4 unmodified lines
657666 {
658667 hdlc_device *hdlc = dev_to_hdlc(dev);
659668 struct ppp *ppp;
660− int result;
669+ int i, result;
661670
662671 switch (ifs->type) {
663672 case IF_GET_PROTO:
@@ -685,6 +694,8 @@ static int ppp_ioctl(struct net_device *dev, struct if_settings *ifs) · 21 unmodified lines
685694 return result;
686695
687696 ppp = get_ppp(dev);
697+ for (i = 0; i < IDX_COUNT; i++)
698+ timer_setup(&ppp->protos[i].timer, ppp_timer, 0);
688699 spin_lock_init(&ppp->lock);
689700 ppp->req_timeout = 2;
690701 ppp->cr_retries = 10;
drivers/net/wan/ixp4xx_hss.c+2−2
@@ -1487,11 +1487,11 @@ static int ixp4xx_hss_probe(struct platform_device *pdev) · 1486 unmodified lines
14871487 "unable to get CLK internal GPIO\n");
14881488
14891489 ndev = alloc_hdlcdev(port);
1490− port->netdev = alloc_hdlcdev(port);
1491− if (!port->netdev) {
1490+ if (!ndev) {
14921491 err = -ENOMEM;
14931492 goto err_plat;
14941493 }
1494+ port->netdev = ndev;
14951495
14961496 SET_NETDEV_DEV(ndev, &pdev->dev);
14971497 hdlc = dev_to_hdlc(ndev);
drivers/net/wwan/t7xx/t7xx_hif_cldma.c+3−0
@@ -1063,6 +1063,9 @@ err_free_tx_ring: · 1062 unmodified lines
10631063 while (i--)
10641064 t7xx_cldma_ring_free(md_ctrl, &md_ctrl->tx_ring[i], DMA_TO_DEVICE);
10651065
1066+ dma_pool_destroy(md_ctrl->gpd_dmapool);
1067+ md_ctrl->gpd_dmapool = NULL;
1068+
10661069 return ret;
10671070 }
10681071
fs/afs/cm_security.c+2−1
@@ -101,7 +101,8 @@ void afs_process_oob_queue(struct work_struct *work) · 100 unmodified lines
101101 struct sk_buff *oob;
102102 enum rxrpc_oob_type type;
103103
104− while ((oob = rxrpc_kernel_dequeue_oob(net->socket, &type))) {
104+ while (READ_ONCE(net->live) &&
105+ (oob = rxrpc_kernel_dequeue_oob(net->socket, &type))) {
105106 switch (type) {
106107 case RXRPC_OOB_CHALLENGE:
107108 afs_respond_to_challenge(oob);
fs/afs/rxrpc.c+9−1
@@ -128,8 +128,14 @@ void afs_close_socket(struct afs_net *net) · 127 unmodified lines
128128 _enter("");
129129
130130 cancel_work_sync(&net->charge_preallocation_work);
131+ cancel_work_sync(&net->rx_oob_work);
132+ /* Future work items should now see ->live is false. */
133+
131134 kernel_listen(net->socket, 0);
135+
136+ /* Make sure work items are no longer running. */
132137 flush_workqueue(afs_async_calls);
138+ cancel_work_sync(&net->charge_preallocation_work);
133139
134140 if (net->spare_incoming_call) {
135141 afs_put_call(net->spare_incoming_call);
@@ -143,6 +149,7 @@ void afs_close_socket(struct afs_net *net) · 7 unmodified lines
143149
144150 kernel_sock_shutdown(net->socket, SHUT_RDWR);
145151 flush_workqueue(afs_async_calls);
152+ cancel_work_sync(&net->rx_oob_work);
146153 net->socket->sk->sk_user_data = NULL;
147154 sock_release(net->socket);
148155 key_put(net->fs_cm_token_key);
@@ -984,5 +991,6 @@ static void afs_rx_notify_oob(struct sock *sk, struct sk_buff *oob) · 835 unmodified lines
984991 {
985992 struct afs_net *net = sk->sk_user_data;
986993
987− schedule_work(&net->rx_oob_work);
994+ if (READ_ONCE(net->live))
995+ queue_work(afs_wq, &net->rx_oob_work);
988996 }
include/linux/ethtool.h+2−0
@@ -942,6 +942,7 @@ struct kernel_ethtool_ts_info { · 941 unmodified lines
942942 #define ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM BIT(5)
943943 #define ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM BIT(6)
944944 #define ETHTOOL_OP_NEEDS_RTNL_RSS BIT(7)
945+#define ETHTOOL_OP_NEEDS_RTNL_GLINK BIT(8)
945946
946947 /**
947948 * struct ethtool_ops - optional netdev operations
@@ -978,6 +979,7 @@ struct kernel_ethtool_ts_info { · 30 unmodified lines
978979 * - phylink helpers (note that phydev is currently unsupported!)
979980 * - netdev_update_features()
980981 * - netif_set_real_num_tx_queues()
982+ * - ethtool_op_get_link() (syncs link watch under rtnl_lock)
981983 *
982984 * @get_drvinfo: Report driver/device information. Modern drivers no
983985 * longer have to implement this callback. Most fields are
include/linux/netdevice.h+17−4
@@ -1131,6 +1131,9 @@ struct netdev_net_notifier { · 1130 unmodified lines
11311131 * netdev_hw_addr_list_for_each(ha, uc). Return 0 on success or a
11321132 * negative errno to request a retry via the core backoff.
11331133 *
1134+ * void (*ndo_work)(struct net_device *dev, unsigned long events);
1135+ * Run deferred work scheduled with netdev_work_sched(@events).
1136+ *
11341137 * int (*ndo_set_mac_address)(struct net_device *dev, void *addr);
11351138 * This function is called when the Media Access Control address
11361139 * needs to be changed. If this interface is not defined, the
@@ -1460,6 +1463,8 @@ struct net_device_ops { · 323 unmodified lines
14601463 struct net_device *dev,
14611464 struct netdev_hw_addr_list *uc,
14621465 struct netdev_hw_addr_list *mc);
1466+ void (*ndo_work)(struct net_device *dev,
1467+ unsigned long events);
14631468 int (*ndo_set_mac_address)(struct net_device *dev,
14641469 void *addr);
14651470 int (*ndo_validate_addr)(struct net_device *dev);
@@ -1930,8 +1935,11 @@ enum netdev_reg_state { · 464 unmodified lines
19301935 * has been enabled due to the need to listen to
19311936 * additional unicast addresses in a device that
19321937 * does not implement ndo_set_rx_mode()
1933− * @rx_mode_node: List entry for rx_mode work processing
1934− * @rx_mode_tracker: Refcount tracker for rx_mode work
1938+ * @work_node: List entry for async netdev_work processing
1939+ * @work_tracker: Refcount tracker for async netdev_work
1940+ * @work_pending: Driver-defined pending netdev_work, passed to
1941+ * ndo_work() (see netdev_work_sched())
1942+ * @work_core_pending: Core-defined pending netdev_work (NETDEV_WORK_*)
19351943 * @rx_mode_addr_cache: Recycled snapshot entries for rx_mode work
19361944 * @rx_mode_retry_timer: Timer that re-queues rx_mode work after failure
19371945 * @rx_mode_retry_count: Number of consecutive retries already scheduled
@@ -2326,8 +2334,10 @@ struct net_device { · 388 unmodified lines
23262334 unsigned int promiscuity;
23272335 unsigned int allmulti;
23282336 bool uc_promisc;
2329− struct list_head rx_mode_node;
2330− netdevice_tracker rx_mode_tracker;
2337+ struct list_head work_node;
2338+ netdevice_tracker work_tracker;
2339+ unsigned long work_pending;
2340+ unsigned long work_core_pending;
23312341 struct netdev_hw_addr_list rx_mode_addr_cache;
23322342 struct timer_list rx_mode_retry_timer;
23332343 unsigned int rx_mode_retry_count;
@@ -5176,6 +5186,9 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, · 2842 unmodified lines
51765186 const struct pcpu_sw_netstats __percpu *netstats);
51775187 void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s);
51785188
5189+void netdev_work_sched(struct net_device *dev, unsigned long events);
5190+unsigned long netdev_work_cancel(struct net_device *dev, unsigned long mask);
5191+
51795192 enum {
51805193 NESTED_SYNC_IMM_BIT,
51815194 NESTED_SYNC_TODO_BIT,
include/linux/netfilter/x_tables.h+21−8
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 * @match: the match extension
1919 * @target: the target extension
2020 * @matchinfo: per-match data
21− * @targetinfo: per-target data
21+ * @targinfo: per-target data
2222 * @state: pointer to hook state this packet came from
2323 * @fragoff: packet is a fragment, this is the data offset
2424 * @thoff: position of transport header relative to skb->data
@@ -77,7 +77,9 @@ static inline u_int8_t xt_family(const struct xt_action_param *par) · 52 unmodified lines
7777 * @match: struct xt_match through which this function was invoked
7878 * @matchinfo: per-match data
7979 * @hook_mask: via which hooks the new rule is reachable
80− * Other fields as above.
80+ * @family: actual NFPROTO_* through which the function is invoked
81+ * (helpful when match->family == NFPROTO_UNSPEC)
82+ * @nft_compat: running from the nft compat layer if true
8183 */
8284 struct xt_mtchk_param {
8385 struct net *net;
@@ -91,8 +93,13 @@ struct xt_mtchk_param { · 7 unmodified lines
9193 };
9294
9395 /**
94− * struct xt_mdtor_param - match destructor parameters
95− * Fields as above.
96+ * struct xt_mtdtor_param - match destructor parameters
97+ *
98+ * @net: network namespace through which the check was invoked
99+ * @match: struct xt_match through which this function was invoked
100+ * @matchinfo: per-match data
101+ * @family: actual NFPROTO_* through which the function is invoked
102+ * (helpful when match->family == NFPROTO_UNSPEC)
96103 */
97104 struct xt_mtdtor_param {
98105 struct net *net;
@@ -105,10 +112,16 @@ struct xt_mtdtor_param { · 6 unmodified lines
105112 * struct xt_tgchk_param - parameters for target extensions'
106113 * checkentry functions
107114 *
115+ * @net: network namespace through which the check was invoked
116+ * @table: table the rule is tried to be inserted into
108117 * @entryinfo: the family-specific rule data
109118 * (struct ipt_entry, ip6t_entry, arpt_entry, ebt_entry)
110− *
111− * Other fields see above.
119+ * @target: the target extension
120+ * @targinfo: per-target data
121+ * @hook_mask: via which hooks the new rule is reachable
122+ * @family: actual NFPROTO_* through which the function is invoked
123+ * (helpful when match->family == NFPROTO_UNSPEC)
124+ * @nft_compat: running from the nft compat layer if true
112125 */
113126 struct xt_tgchk_param {
114127 struct net *net;
@@ -336,9 +349,9 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size); · 221 unmodified lines
336349 void xt_free_table_info(struct xt_table_info *info);
337350
338351 /**
339− * xt_recseq - recursive seqcount for netfilter use
352+ * var xt_recseq - recursive seqcount for netfilter use
340353 *
341− * Packet processing changes the seqcount only if no recursion happened
354+ * Packet processing changes the seqcount only if no recursion happened.
342355 * get_counters() can use read_seqcount_begin()/read_seqcount_retry(),
343356 * because we use the normal seqcount convention :
344357 * Low order bit set to 1 if a writer is active.
include/net/dst_metadata.h+5−2
@@ -164,8 +164,11 @@ static inline struct metadata_dst *tun_dst_unclone(struct sk_buff *skb) · 163 unmodified lines
164164 if (!new_md)
165165 return ERR_PTR(-ENOMEM);
166166
167− memcpy(&new_md->u.tun_info, &md_dst->u.tun_info,
168− sizeof(struct ip_tunnel_info) + md_size);
167+ /* Copy in two stages to keep the __counted_by happy. */
168+ new_md->u.tun_info = md_dst->u.tun_info;
169+ memcpy(ip_tunnel_info_opts(&new_md->u.tun_info),
170+ ip_tunnel_info_opts(&md_dst->u.tun_info), md_size);
171+
169172 #ifdef CONFIG_DST_CACHE
170173 /* Unclone the dst cache if there is one */
171174 if (new_md->u.tun_info.dst_cache.cache) {
include/net/ip_fib.h+3−4
@@ -374,7 +374,7 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp, · 373 unmodified lines
374374 struct fib_result *res, unsigned int flags)
375375 {
376376 struct fib_table *tb;
377− int err = -ENETUNREACH;
377+ int err = -EAGAIN;
378378
379379 flags |= FIB_LOOKUP_NOREF;
380380 if (net->ipv4.fib_has_custom_rules)
@@ -388,17 +388,16 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp, · 7 unmodified lines
388388 if (tb)
389389 err = fib_table_lookup(tb, flp, res, flags);
390390
391− if (!err)
391+ if (err != -EAGAIN)
392392 goto out;
393393
394394 tb = rcu_dereference_rtnl(net->ipv4.fib_default);
395395 if (tb)
396396 err = fib_table_lookup(tb, flp, res, flags);
397397
398−out:
399398 if (err == -EAGAIN)
400399 err = -ENETUNREACH;
401−
400+out:
402401 rcu_read_unlock();
403402
404403 return err;
include/net/netfilter/nf_conntrack_expect.h+14−3
@@ -26,6 +26,7 @@ struct nf_conntrack_expect { · 25 unmodified lines
2626 possible_net_t net;
2727
2828 /* We expect this tuple, with the following mask */
29+ struct nf_conntrack_tuple master_tuple;
2930 struct nf_conntrack_tuple tuple;
3031 struct nf_conntrack_tuple_mask mask;
3132
@@ -54,8 +55,8 @@ struct nf_conntrack_expect { · 22 unmodified lines
5455 /* The conntrack of the master connection */
5556 struct nf_conn *master;
5657
57− /* Timer function; deletes the expectation. */
58− struct timer_list timeout;
58+ /* jiffies32 when this expectation expires */
59+ u32 timeout;
5960
6061 #if IS_ENABLED(CONFIG_NF_NAT)
6162 union nf_inet_addr saved_addr;
@@ -69,6 +70,14 @@ struct nf_conntrack_expect { · 7 unmodified lines
6970 struct rcu_head rcu;
7071 };
7172
73+static inline bool nf_ct_exp_is_expired(const struct nf_conntrack_expect *exp)
74+{
75+ if (READ_ONCE(exp->flags) & NF_CT_EXPECT_DEAD)
76+ return true;
77+
78+ return (__s32)(READ_ONCE(exp->timeout) - nfct_time_stamp) <= 0;
79+}
80+
7281 static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
7382 {
7483 return read_pnet(&exp->net);
@@ -130,7 +139,6 @@ static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) · 55 unmodified lines
130139
131140 void nf_ct_remove_expectations(struct nf_conn *ct);
132141 void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
133−bool nf_ct_remove_expect(struct nf_conntrack_expect *exp);
134142
135143 void nf_ct_expect_iterate_destroy(bool (*iter)(struct nf_conntrack_expect *e, void *data), void *data);
136144 void nf_ct_expect_iterate_net(struct net *net,
@@ -153,5 +161,8 @@ static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect, · 16 unmodified lines
153161 return nf_ct_expect_related_report(expect, 0, 0, flags);
154162 }
155163
164+struct nf_conn_help;
165+void nf_ct_expectation_gc(struct nf_conn_help *master_help);
166+
156167 #endif /*_NF_CONNTRACK_EXPECT_H*/
157168
include/net/netfilter/nf_conntrack_helper.h+4−0
@@ -114,6 +114,10 @@ int nf_conntrack_helpers_register(struct nf_conntrack_helper *, unsigned int, · 113 unmodified lines
114114 void nf_conntrack_helpers_unregister(struct nf_conntrack_helper **,
115115 unsigned int);
116116
117+#define nf_conntrack_helper_deprecated(name) \
118+ pr_warn("The %s conntrack helper is scheduled for removal.\n" \
119+ "Please contact the netfilter-devel mailing list if you still need this.\n", name)
120+
117121 struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);
118122
119123 int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
include/net/netfilter/nf_queue.h+1−0
@@ -18,6 +18,7 @@ struct nf_queue_entry { · 17 unmodified lines
1818 unsigned int id;
1919 unsigned int hook_index; /* index in hook_entries->hook[] */
2020 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
21+ struct net_device *bridge_dev;
2122 struct net_device *physin;
2223 struct net_device *physout;
2324 #endif
include/net/netfilter/nft_meta.h+2−0
@@ -40,6 +40,8 @@ void nft_meta_set_eval(const struct nft_expr *expr, · 39 unmodified lines
4040 void nft_meta_set_destroy(const struct nft_ctx *ctx,
4141 const struct nft_expr *expr);
4242
43+int nft_meta_get_validate(const struct nft_ctx *ctx,
44+ const struct nft_expr *expr);
4345 int nft_meta_set_validate(const struct nft_ctx *ctx,
4446 const struct nft_expr *expr);
4547
include/net/rtnetlink.h+2−0
@@ -256,6 +256,8 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm, · 255 unmodified lines
256256 int rtnl_nla_parse_ifinfomsg(struct nlattr **tb, const struct nlattr *nla_peer,
257257 struct netlink_ext_ack *exterr);
258258 struct net *rtnl_get_net_ns_capable(struct sock *sk, int netnsid);
259+bool rtnl_dev_link_net_capable(const struct net_device *dev,
260+ const struct net *link_net);
259261
260262 #define MODULE_ALIAS_RTNL_LINK(kind) MODULE_ALIAS("rtnl-link-" kind)
261263
include/net/sctp/sctp.h+2−1
@@ -111,7 +111,8 @@ int sctp_transport_lookup_process(sctp_callback_t cb, struct net *net, · 110 unmodified lines
111111 const union sctp_addr *paddr, void *p, int dif);
112112 int sctp_transport_traverse_process(sctp_callback_t cb, sctp_callback_t cb_done,
113113 struct net *net, int *pos, void *p);
114−int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *), void *p);
114+int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *),
115+ struct net *net, int *pos, void *p);
115116 int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc,
116117 struct sctp_info *info);
117118
include/net/xfrm.h+11−4
@@ -953,6 +953,9 @@ static inline bool addr_match(const void *token1, const void *token2, · 952 unmodified lines
953953 unsigned int pdw;
954954 unsigned int pbi;
955955
956+ if (prefixlen > 128)
957+ return false;
958+
956959 pdw = prefixlen >> 5; /* num of whole u32 in prefix */
957960 pbi = prefixlen & 0x1f; /* num of bits in incomplete u32 in prefix */
958961
@@ -977,6 +980,10 @@ static inline bool addr4_match(__be32 a1, __be32 a2, u8 prefixlen) · 18 unmodified lines
977980 /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */
978981 if (sizeof(long) == 4 && prefixlen == 0)
979982 return true;
983+
984+ if (prefixlen > 32)
985+ return false;
986+
980987 return !((a1 ^ a2) & htonl(~0UL << (32 - prefixlen)));
981988 }
982989
@@ -1260,8 +1267,8 @@ int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, · 277 unmodified lines
12601267 static inline bool __xfrm_check_nopolicy(struct net *net, struct sk_buff *skb,
12611268 int dir)
12621269 {
1263− if (!net->xfrm.policy_count[dir] && !secpath_exists(skb))
1264− return net->xfrm.policy_default[dir] == XFRM_USERPOLICY_ACCEPT;
1270+ if (!READ_ONCE(net->xfrm.policy_count[dir]) && !secpath_exists(skb))
1271+ return READ_ONCE(net->xfrm.policy_default[dir]) == XFRM_USERPOLICY_ACCEPT;
12651272
12661273 return false;
12671274 }
@@ -1361,8 +1368,8 @@ static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) · 93 unmodified lines
13611368 {
13621369 struct net *net = dev_net(skb->dev);
13631370
1364− if (!net->xfrm.policy_count[XFRM_POLICY_OUT] &&
1365− net->xfrm.policy_default[XFRM_POLICY_OUT] == XFRM_USERPOLICY_ACCEPT)
1371+ if (!READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_OUT]) &&
1372+ READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_OUT]) == XFRM_USERPOLICY_ACCEPT)
13661373 return true;
13671374
13681375 return (skb_dst(skb)->flags & DST_NOXFRM) ||
include/uapi/linux/netfilter/nf_conntrack_common.h+1−0
@@ -160,6 +160,7 @@ enum ip_conntrack_expect_events { · 159 unmodified lines
160160 #define NF_CT_EXPECT_USERSPACE 0x4
161161
162162 #ifdef __KERNEL__
163+#define NF_CT_EXPECT_DEAD 0x8
163164 #define NF_CT_EXPECT_MASK (NF_CT_EXPECT_PERMANENT | NF_CT_EXPECT_INACTIVE | \
164165 NF_CT_EXPECT_USERSPACE)
165166 #endif
net/8021q/vlan.c+8−68
@@ -77,9 +77,9 @@ static int vlan_group_prealloc_vid(struct vlan_group *vg, · 76 unmodified lines
7777 return 0;
7878 }
7979
80−static void vlan_stacked_transfer_operstate(const struct net_device *rootdev,
81− struct net_device *dev,
82− struct vlan_dev_priv *vlan)
80+void vlan_stacked_transfer_operstate(const struct net_device *rootdev,
81+ struct net_device *dev,
82+ struct vlan_dev_priv *vlan)
8383 {
8484 if (!(vlan->flags & VLAN_FLAG_BRIDGE_BINDING))
8585 netif_stacked_transfer_operstate(rootdev, dev);
@@ -316,29 +316,6 @@ out: · 230 unmodified lines
316316 ether_addr_copy(vlan->real_dev_addr, dev->dev_addr);
317317 }
318318
319−static void vlan_transfer_features(struct net_device *dev,
320− struct net_device *vlandev)
321−{
322− struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
323−
324− netif_inherit_tso_max(vlandev, dev);
325−
326− if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
327− vlandev->hard_header_len = dev->hard_header_len;
328− else
329− vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN;
330−
331−#if IS_ENABLED(CONFIG_FCOE)
332− vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;
333−#endif
334−
335− vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
336− vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE);
337− vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev);
338−
339− netdev_update_features(vlandev);
340−}
341−
342319 static int __vlan_device_event(struct net_device *dev, unsigned long event)
343320 {
344321 int err = 0;
@@ -391,13 +368,11 @@ static void vlan_vid0_del(struct net_device *dev) · 46 unmodified lines
391368 static int vlan_device_event(struct notifier_block *unused, unsigned long event,
392369 void *ptr)
393370 {
394− struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
395371 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
396372 struct vlan_group *grp;
397373 struct vlan_info *vlan_info;
398374 int i, flgs;
399375 struct net_device *vlandev;
400− struct vlan_dev_priv *vlan;
401376 bool last = false;
402377 LIST_HEAD(list);
403378 int err;
@@ -447,54 +422,19 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, · 43 unmodified lines
447422 if (vlandev->mtu <= dev->mtu)
448423 continue;
449424
450− dev_set_mtu(vlandev, dev->mtu);
425+ netdev_work_sched(vlandev, VLAN_WORK_MTU);
451426 }
452427 break;
453428
454429 case NETDEV_FEAT_CHANGE:
455− /* Propagate device features to underlying device */
456430 vlan_group_for_each_dev(grp, i, vlandev)
457− vlan_transfer_features(dev, vlandev);
431+ netdev_work_sched(vlandev, VLAN_WORK_FEATURES);
458432 break;
459433
460− case NETDEV_DOWN: {
461− struct net_device *tmp;
462− LIST_HEAD(close_list);
463−
464− /* Put all VLANs for this dev in the down state too. */
465− vlan_group_for_each_dev(grp, i, vlandev) {
466− flgs = vlandev->flags;
467− if (!(flgs & IFF_UP))
468− continue;
469−
470− vlan = vlan_dev_priv(vlandev);
471− if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
472− list_add(&vlandev->close_list, &close_list);
473− }
474−
475− netif_close_many(&close_list, false);
476−
477− list_for_each_entry_safe(vlandev, tmp, &close_list, close_list) {
478− vlan_stacked_transfer_operstate(dev, vlandev,
479− vlan_dev_priv(vlandev));
480− list_del_init(&vlandev->close_list);
481− }
482− list_del(&close_list);
483− break;
484− }
434+ case NETDEV_DOWN:
485435 case NETDEV_UP:
486− /* Put all VLANs for this dev in the up state too. */
487− vlan_group_for_each_dev(grp, i, vlandev) {
488− flgs = netif_get_flags(vlandev);
489− if (flgs & IFF_UP)
490− continue;
491−
492− vlan = vlan_dev_priv(vlandev);
493− if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
494− dev_change_flags(vlandev, flgs | IFF_UP,
495− extack);
496− vlan_stacked_transfer_operstate(dev, vlandev, vlan);
497− }
436+ vlan_group_for_each_dev(grp, i, vlandev)
437+ netdev_work_sched(vlandev, VLAN_WORK_LINK_STATE);
498438 break;
499439
500440 case NETDEV_UNREGISTER:
net/8021q/vlan.h+11−0
@@ -125,6 +125,17 @@ static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev) · 124 unmodified lines
125125 int vlan_filter_push_vids(struct vlan_info *vlan_info, __be16 proto);
126126 void vlan_filter_drop_vids(struct vlan_info *vlan_info, __be16 proto);
127127
128+/* netdev_work events propagated from the real device, see vlan_dev_work(). */
129+enum {
130+ VLAN_WORK_LINK_STATE = BIT(0), /* sync up/down with real_dev */
131+ VLAN_WORK_MTU = BIT(1), /* clamp mtu to real_dev's */
132+ VLAN_WORK_FEATURES = BIT(2), /* re-inherit real_dev features */
133+};
134+
135+void vlan_stacked_transfer_operstate(const struct net_device *rootdev,
136+ struct net_device *dev,
137+ struct vlan_dev_priv *vlan);
138+
128139 /* found in vlan_dev.c */
129140 void vlan_dev_set_ingress_priority(const struct net_device *dev,
130141 u32 skb_prio, u16 vlan_prio);
net/8021q/vlan_dev.c+60−0
@@ -270,6 +270,9 @@ static int vlan_dev_open(struct net_device *dev) · 269 unmodified lines
270270 !(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
271271 return -ENETDOWN;
272272
273+ /* The explicit open supersedes any deferred link-state sync */
274+ netdev_work_cancel(dev, VLAN_WORK_LINK_STATE);
275+
273276 if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) &&
274277 !vlan_dev_inherit_address(dev, real_dev)) {
275278 err = dev_uc_add(real_dev, dev->dev_addr);
@@ -300,6 +303,9 @@ static int vlan_dev_stop(struct net_device *dev) · 24 unmodified lines
300303 struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
301304 struct net_device *real_dev = vlan->real_dev;
302305
306+ /* The explicit close supersedes any deferred link-state sync */
307+ netdev_work_cancel(dev, VLAN_WORK_LINK_STATE);
308+
303309 dev_mc_unsync(real_dev, dev);
304310 dev_uc_unsync(real_dev, dev);
305311
@@ -1016,6 +1022,59 @@ static const struct ethtool_ops vlan_ethtool_ops = { · 710 unmodified lines
10161022 .get_ts_info = vlan_ethtool_get_ts_info,
10171023 };
10181024
1025+static void vlan_transfer_features(struct net_device *dev,
1026+ struct net_device *vlandev)
1027+{
1028+ struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
1029+
1030+ netif_inherit_tso_max(vlandev, dev);
1031+
1032+ if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
1033+ vlandev->hard_header_len = dev->hard_header_len;
1034+ else
1035+ vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN;
1036+
1037+#if IS_ENABLED(CONFIG_FCOE)
1038+ vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;
1039+#endif
1040+
1041+ vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
1042+ vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE);
1043+ vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev);
1044+
1045+ netdev_update_features(vlandev);
1046+}
1047+
1048+static void vlan_dev_work(struct net_device *vlandev, unsigned long events)
1049+{
1050+ struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
1051+ struct net_device *real_dev = vlan->real_dev;
1052+ bool loose = vlan->flags & VLAN_FLAG_LOOSE_BINDING;
1053+ unsigned int flgs;
1054+
1055+ if (events & VLAN_WORK_LINK_STATE) {
1056+ flgs = netif_get_flags(vlandev);
1057+ if (real_dev->flags & IFF_UP) {
1058+ if (!(flgs & IFF_UP)) {
1059+ if (!loose)
1060+ netif_change_flags(vlandev,
1061+ flgs | IFF_UP, NULL);
1062+ vlan_stacked_transfer_operstate(real_dev,
1063+ vlandev, vlan);
1064+ }
1065+ } else if ((flgs & IFF_UP) && !loose) {
1066+ netif_change_flags(vlandev, flgs & ~IFF_UP, NULL);
1067+ vlan_stacked_transfer_operstate(real_dev, vlandev, vlan);
1068+ }
1069+ }
1070+
1071+ if ((events & VLAN_WORK_MTU) && vlandev->mtu > real_dev->mtu)
1072+ netif_set_mtu(vlandev, real_dev->mtu);
1073+
1074+ if (events & VLAN_WORK_FEATURES)
1075+ vlan_transfer_features(real_dev, vlandev);
1076+}
1077+
10191078 static const struct net_device_ops vlan_netdev_ops = {
10201079 .ndo_change_mtu = vlan_dev_change_mtu,
10211080 .ndo_init = vlan_dev_init,
@@ -1027,6 +1086,7 @@ static const struct net_device_ops vlan_netdev_ops = { · 5 unmodified lines
10271086 .ndo_set_mac_address = vlan_dev_set_mac_address,
10281087 .ndo_set_rx_mode = vlan_dev_set_rx_mode,
10291088 .ndo_change_rx_flags = vlan_dev_change_rx_flags,
1089+ .ndo_work = vlan_dev_work,
10301090 .ndo_eth_ioctl = vlan_dev_ioctl,
10311091 .ndo_neigh_setup = vlan_dev_neigh_setup,
10321092 .ndo_get_stats64 = vlan_dev_get_stats64,
net/batman-adv/bat_iv_ogm.c+10−1
@@ -316,14 +316,23 @@ batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len, · 315 unmodified lines
316316 const struct batadv_ogm_packet *ogm_packet)
317317 {
318318 int next_buff_pos = 0;
319+ u16 tvlv_len;
319320
320321 /* check if there is enough space for the header */
321322 next_buff_pos += buff_pos + sizeof(*ogm_packet);
322323 if (next_buff_pos > packet_len)
323324 return false;
324325
326+ tvlv_len = ntohs(ogm_packet->tvlv_len);
327+
328+ /* the fields of an aggregated OGM are accessed assuming (at least)
329+ * 2-byte alignment, so a following OGM must start at an even offset.
330+ */
331+ if (tvlv_len & 1)
332+ return false;
333+
325334 /* check if there is enough space for the optional TVLV */
326− next_buff_pos += ntohs(ogm_packet->tvlv_len);
335+ next_buff_pos += tvlv_len;
327336
328337 return next_buff_pos <= packet_len;
329338 }
net/batman-adv/bat_v.c+1−0
@@ -817,6 +817,7 @@ void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface) · 816 unmodified lines
817817
818818 hard_iface->bat_v.aggr_len = 0;
819819 skb_queue_head_init(&hard_iface->bat_v.aggr_list);
820+ hard_iface->bat_v.aggr_list_enabled = false;
820821 INIT_DELAYED_WORK(&hard_iface->bat_v.aggr_wq,
821822 batadv_v_ogm_aggr_work);
822823 /* make sure it doesn't run until interface gets enabled */
net/batman-adv/bat_v_ogm.c+22−1
@@ -254,11 +254,18 @@ static void batadv_v_ogm_queue_on_if(struct batadv_priv *bat_priv, · 253 unmodified lines
254254 }
255255
256256 spin_lock_bh(&hard_iface->bat_v.aggr_list.lock);
257+ if (!hard_iface->bat_v.aggr_list_enabled) {
258+ kfree_skb(skb);
259+ goto unlock;
260+ }
261+
257262 if (!batadv_v_ogm_queue_left(skb, hard_iface))
258263 batadv_v_ogm_aggr_send(bat_priv, hard_iface);
259264
260265 hard_iface->bat_v.aggr_len += batadv_v_ogm_len(skb);
261266 __skb_queue_tail(&hard_iface->bat_v.aggr_list, skb);
267+
268+unlock:
262269 spin_unlock_bh(&hard_iface->bat_v.aggr_list.lock);
263270 }
264271
@@ -415,6 +422,10 @@ int batadv_v_ogm_iface_enable(struct batadv_hard_iface *hard_iface) · 150 unmodified lines
415422 {
416423 struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
417424
425+ spin_lock_bh(&hard_iface->bat_v.aggr_list.lock);
426+ hard_iface->bat_v.aggr_list_enabled = true;
427+ spin_unlock_bh(&hard_iface->bat_v.aggr_list.lock);
428+
418429 enable_delayed_work(&hard_iface->bat_v.aggr_wq);
419430
420431 batadv_v_ogm_start_queue_timer(hard_iface);
@@ -432,6 +443,7 @@ void batadv_v_ogm_iface_disable(struct batadv_hard_iface *hard_iface) · 11 unmodified lines
432443 disable_delayed_work_sync(&hard_iface->bat_v.aggr_wq);
433444
434445 spin_lock_bh(&hard_iface->bat_v.aggr_list.lock);
446+ hard_iface->bat_v.aggr_list_enabled = false;
435447 batadv_v_ogm_aggr_list_free(hard_iface);
436448 spin_unlock_bh(&hard_iface->bat_v.aggr_list.lock);
437449 }
@@ -837,14 +849,23 @@ batadv_v_ogm_aggr_packet(int buff_pos, int packet_len, · 399 unmodified lines
837849 const struct batadv_ogm2_packet *ogm2_packet)
838850 {
839851 int next_buff_pos = 0;
852+ u16 tvlv_len;
840853
841854 /* check if there is enough space for the header */
842855 next_buff_pos += buff_pos + sizeof(*ogm2_packet);
843856 if (next_buff_pos > packet_len)
844857 return false;
845858
859+ tvlv_len = ntohs(ogm2_packet->tvlv_len);
860+
861+ /* the fields of an aggregated OGMv2 are accessed assuming (at least)
862+ * 2-byte alignment, so a following OGMv2 must start at an even offset.
863+ */
864+ if (tvlv_len & 1)
865+ return false;
866+
846867 /* check if there is enough space for the optional TVLV */
847− next_buff_pos += ntohs(ogm2_packet->tvlv_len);
868+ next_buff_pos += tvlv_len;
848869
849870 return next_buff_pos <= packet_len;
850871 }
net/batman-adv/distributed-arp-table.c+9−3
@@ -215,10 +215,13 @@ static void batadv_dat_purge(struct work_struct *work) · 214 unmodified lines
215215 */
216216 static bool batadv_compare_dat(const struct hlist_node *node, const void *data2)
217217 {
218− const void *data1 = container_of(node, struct batadv_dat_entry,
219− hash_entry);
218+ const struct batadv_dat_entry *entry1;
219+ const struct batadv_dat_entry *entry2;
220220
221− return memcmp(data1, data2, sizeof(__be32)) == 0;
221+ entry1 = container_of(node, struct batadv_dat_entry, hash_entry);
222+ entry2 = data2;
223+
224+ return entry1->ip == entry2->ip && entry1->vid == entry2->vid;
222225 }
223226
224227 /**
@@ -345,6 +348,9 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip, · 120 unmodified lines
345348 if (dat_entry->ip != ip)
346349 continue;
347350
351+ if (dat_entry->vid != vid)
352+ continue;
353+
348354 if (!kref_get_unless_zero(&dat_entry->refcount))
349355 continue;
350356
net/batman-adv/fragmentation.c+21−1
@@ -386,6 +386,8 @@ out_err: · 385 unmodified lines
386386 * @skb: skb to forward
387387 * @recv_if: interface that the skb is received on
388388 * @orig_node_src: originator that the skb is received from
389+ * @rx_result: set to NET_RX_SUCCESS when the fragment was forwarded and
390+ * NET_RX_DROP when it was dropped; only valid when true is returned
389391 *
390392 * Look up the next-hop of the fragments payload and check if the merged packet
391393 * will exceed the MTU towards the next-hop. If so, the fragment is forwarded
@@ -395,7 +397,8 @@ out_err: · 3 unmodified lines
395397 */
396398 bool batadv_frag_skb_fwd(struct sk_buff *skb,
397399 struct batadv_hard_iface *recv_if,
398− struct batadv_orig_node *orig_node_src)
400+ struct batadv_orig_node *orig_node_src,
401+ int *rx_result)
399402 {
400403 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
401404 struct batadv_neigh_node *neigh_node = NULL;
@@ -414,12 +417,29 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, · 12 unmodified lines
414417 */
415418 total_size = ntohs(packet->total_size);
416419 if (total_size > neigh_node->if_incoming->net_dev->mtu) {
420+ if (packet->ttl < 2) {
421+ kfree_skb(skb);
422+ *rx_result = NET_RX_DROP;
423+ ret = true;
424+ goto out;
425+ }
426+
427+ if (skb_cow(skb, ETH_HLEN) < 0) {
428+ kfree_skb(skb);
429+ *rx_result = NET_RX_DROP;
430+ ret = true;
431+ goto out;
432+ }
433+
434+ packet = (struct batadv_frag_packet *)skb->data;
435+
417436 batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_FWD);
418437 batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES,
419438 skb->len + ETH_HLEN);
420439
421440 packet->ttl--;
422441 batadv_send_unicast_skb(skb, neigh_node);
442+ *rx_result = NET_RX_SUCCESS;
423443 ret = true;
424444 }
425445
net/batman-adv/fragmentation.h+2−1
@@ -19,7 +19,8 @@ void batadv_frag_purge_orig(struct batadv_orig_node *orig, · 18 unmodified lines
1919 bool (*check_cb)(struct batadv_frag_table_entry *));
2020 bool batadv_frag_skb_fwd(struct sk_buff *skb,
2121 struct batadv_hard_iface *recv_if,
22− struct batadv_orig_node *orig_node_src);
22+ struct batadv_orig_node *orig_node_src,
23+ int *rx_result);
2324 bool batadv_frag_skb_buffer(struct sk_buff **skb,
2425 struct batadv_orig_node *orig_node);
2526 int batadv_frag_send_packet(struct sk_buff *skb,
net/batman-adv/hard-interface.c+2−26
@@ -814,30 +814,6 @@ err_dev: · 813 unmodified lines
814814 return ret;
815815 }
816816
817−/**
818− * batadv_hardif_cnt() - get number of interfaces enslaved to mesh interface
819− * @mesh_iface: mesh interface to check
820− *
821− * This function is only using RCU for locking - the result can therefore be
822− * off when another function is modifying the list at the same time. The
823− * caller can use the rtnl_lock to make sure that the count is accurate.
824− *
825− * Return: number of connected/enslaved hard interfaces
826− */
827−static size_t batadv_hardif_cnt(struct net_device *mesh_iface)
828−{
829− struct batadv_hard_iface *hard_iface;
830− struct list_head *iter;
831− size_t count = 0;
832−
833− rcu_read_lock();
834− netdev_for_each_lower_private_rcu(mesh_iface, hard_iface, iter)
835− count++;
836− rcu_read_unlock();
837−
838− return count;
839−}
840−
841817 /**
842818 * batadv_hardif_disable_interface() - Remove hard interface from mesh interface
843819 * @hard_iface: hard interface to be removed
@@ -878,8 +854,8 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) · 34 unmodified lines
878854 netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->mesh_iface);
879855 batadv_hardif_recalc_extra_skbroom(hard_iface->mesh_iface);
880856
881− /* nobody uses this interface anymore */
882− if (batadv_hardif_cnt(hard_iface->mesh_iface) <= 1)
857+ /* nobody uses this mesh interface anymore */
858+ if (list_empty(&hard_iface->mesh_iface->adj_list.lower))
883859 batadv_gw_check_client_stop(bat_priv);
884860
885861 hard_iface->mesh_iface = NULL;
net/batman-adv/routing.c+69−4
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include "main.h"
99
1010 #include <linux/atomic.h>
11+#include <linux/build_bug.h>
1112 #include <linux/byteorder/generic.h>
1213 #include <linux/compiler.h>
1314 #include <linux/errno.h>
@@ -204,6 +205,59 @@ bool batadv_check_management_packet(struct sk_buff *skb, · 190 unmodified lines
204205 return true;
205206 }
206207
208+/**
209+ * batadv_skb_decrement_ttl() - decrement ttl in a batman-adv header, csum-safe
210+ * @skb: the received packet with @skb->data pointing to the batman-adv header
211+ *
212+ * Supports the following packet types, all of which carry the TTL at offset 2:
213+ *
214+ * - batadv_ogm_packet
215+ * - batadv_ogm2_packet
216+ * - batadv_icmp_header
217+ * - batadv_icmp_packet
218+ * - batadv_icmp_tp_packet
219+ * - batadv_icmp_packet_rr
220+ * - batadv_unicast_packet
221+ * - batadv_frag_packet
222+ * - batadv_bcast_packet
223+ * - batadv_mcast_packet
224+ * - batadv_coded_packet
225+ * - batadv_unicast_tvlv_packet
226+ *
227+ * Return: true if the packet may be forwarded (ttl decremented),
228+ * false if it must be dropped (ttl would expire)
229+ */
230+static bool batadv_skb_decrement_ttl(struct sk_buff *skb)
231+{
232+ static const size_t ttl_offset = 2;
233+ u8 *ttl_pos;
234+
235+ BUILD_BUG_ON(offsetof(struct batadv_ogm_packet, ttl) != ttl_offset);
236+ BUILD_BUG_ON(offsetof(struct batadv_ogm2_packet, ttl) != ttl_offset);
237+ BUILD_BUG_ON(offsetof(struct batadv_icmp_header, ttl) != ttl_offset);
238+ BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, ttl) != ttl_offset);
239+ BUILD_BUG_ON(offsetof(struct batadv_icmp_tp_packet, ttl) != ttl_offset);
240+ BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, ttl) != ttl_offset);
241+ BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, ttl) != ttl_offset);
242+ BUILD_BUG_ON(offsetof(struct batadv_frag_packet, ttl) != ttl_offset);
243+ BUILD_BUG_ON(offsetof(struct batadv_bcast_packet, ttl) != ttl_offset);
244+ BUILD_BUG_ON(offsetof(struct batadv_mcast_packet, ttl) != ttl_offset);
245+ BUILD_BUG_ON(offsetof(struct batadv_coded_packet, ttl) != ttl_offset);
246+ BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, ttl) != ttl_offset);
247+
248+ ttl_pos = skb->data + ttl_offset;
249+
250+ /* would expire on this hop -> drop, leave header + csum untouched */
251+ if (*ttl_pos < 2)
252+ return false;
253+
254+ skb_postpull_rcsum(skb, ttl_pos, 1);
255+ (*ttl_pos)--;
256+ skb_postpush_rcsum(skb, ttl_pos, 1);
257+
258+ return true;
259+}
260+
207261 /**
208262 * batadv_recv_my_icmp_packet() - receive an icmp packet locally
209263 * @bat_priv: the bat priv with all the mesh interface information
@@ -1114,10 +1168,9 @@ int batadv_recv_frag_packet(struct sk_buff *skb, · 904 unmodified lines
11141168
11151169 /* Route the fragment if it is not for us and too big to be merged. */
11161170 if (!batadv_is_my_mac(bat_priv, frag_packet->dest) &&
1117− batadv_frag_skb_fwd(skb, recv_if, orig_node_src)) {
1171+ batadv_frag_skb_fwd(skb, recv_if, orig_node_src, &ret)) {
11181172 /* skb was consumed */
11191173 skb = NULL;
1120− ret = NET_RX_SUCCESS;
11211174 goto put_orig_node;
11221175 }
11231176
@@ -1191,7 +1244,13 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, · 67 unmodified lines
11911244 if (batadv_is_my_mac(bat_priv, bcast_packet->orig))
11921245 goto free_skb;
11931246
1194− if (bcast_packet->ttl-- < 2)
1247+ /* create a copy of the skb, if needed, to modify it. */
1248+ if (skb_cow(skb, ETH_HLEN) < 0)
1249+ goto free_skb;
1250+
1251+ bcast_packet = (struct batadv_bcast_packet *)skb->data;
1252+
1253+ if (!batadv_skb_decrement_ttl(skb))
11951254 goto free_skb;
11961255
11971256 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
@@ -1298,7 +1357,7 @@ int batadv_recv_mcast_packet(struct sk_buff *skb, · 100 unmodified lines
12981357 goto free_skb;
12991358
13001359 mcast_packet = (struct batadv_mcast_packet *)skb->data;
1301− if (mcast_packet->ttl-- < 2)
1360+ if (!batadv_skb_decrement_ttl(skb))
13021361 goto free_skb;
13031362
13041363 tvlv_buff = (unsigned char *)(skb->data + hdr_size);
@@ -1307,6 +1366,12 @@ int batadv_recv_mcast_packet(struct sk_buff *skb, · 2 unmodified lines
13071366 if (tvlv_buff_len > skb->len - hdr_size)
13081367 goto free_skb;
13091368
1369+ /* the fields of an multicast payload are accessed assuming (at least)
1370+ * 2-byte alignment, so a following packet must start at an even offset.
1371+ */
1372+ if (tvlv_buff_len & 1)
1373+ goto free_skb;
1374+
13101375 ret = batadv_tvlv_containers_process(bat_priv, BATADV_MCAST, NULL, skb,
13111376 tvlv_buff, tvlv_buff_len);
13121377 if (ret >= 0) {
net/batman-adv/tp_meter.c+48−26
@@ -87,6 +87,11 @@ · 86 unmodified lines
8787 #define BATADV_TP_PLEN (BATADV_TP_PACKET_LEN - ETH_HLEN - \
8888 sizeof(struct batadv_unicast_packet))
8989
90+/**
91+ * BATADV_TP_MAX_UNACKED - maximum number of packets a receiver didn't yet ack
92+ */
93+#define BATADV_TP_MAX_UNACKED 100
94+
9095 static u8 batadv_tp_prerandom[4096] __read_mostly;
9196
9297 /**
@@ -1285,7 +1290,7 @@ static void batadv_tp_receiver_shutdown(struct timer_list *t) · 1192 unmodified lines
12851290 bat_priv = tp_vars->common.bat_priv;
12861291
12871292 /* if there is recent activity rearm the timer */
1288− if (!batadv_has_timed_out(tp_vars->last_recv_time,
1293+ if (!batadv_has_timed_out(READ_ONCE(tp_vars->last_recv_time),
12891294 BATADV_TP_RECV_TIMEOUT)) {
12901295 /* reset the receiver shutdown timer */
12911296 batadv_tp_reset_receiver_timer(tp_vars);
@@ -1303,6 +1308,7 @@ static void batadv_tp_receiver_shutdown(struct timer_list *t) · 11 unmodified lines
13031308 list_for_each_entry_safe(un, safe, &tp_vars->common.unacked_list, list) {
13041309 list_del(&un->list);
13051310 kfree(un);
1311+ tp_vars->common.unacked_count--;
13061312 }
13071313 spin_unlock_bh(&tp_vars->common.unacked_lock);
13081314
@@ -1386,7 +1392,8 @@ out: · 77 unmodified lines
13861392 /**
13871393 * batadv_tp_handle_out_of_order() - store an out of order packet
13881394 * @tp_vars: the private data of the current TP meter session
1389− * @skb: the buffer containing the received packet
1395+ * @seqno: sequence number of new received packet
1396+ * @payload_len: length of the received packet
13901397 *
13911398 * Store the out of order packet in the unacked list for late processing. This
13921399 * packets are kept in this list so that they can be ACKed at once as soon as
@@ -1395,28 +1402,24 @@ out: · 2 unmodified lines
13951402 * Return: true if the packed has been successfully processed, false otherwise
13961403 */
13971404 static bool batadv_tp_handle_out_of_order(struct batadv_tp_receiver *tp_vars,
1398− const struct sk_buff *skb)
1405+ u32 seqno, u32 payload_len)
1406+ __must_hold(&tp_vars->common.unacked_lock)
13991407 {
1400− const struct batadv_icmp_tp_packet *icmp;
14011408 struct batadv_tp_unacked *un, *new;
1402− u32 payload_len;
14031409 bool added = false;
14041410
14051411 new = kmalloc_obj(*new, GFP_ATOMIC);
14061412 if (unlikely(!new))
14071413 return false;
14081414
1409− icmp = (struct batadv_icmp_tp_packet *)skb->data;
1410−
1411− new->seqno = ntohl(icmp->seqno);
1412− payload_len = skb->len - sizeof(struct batadv_unicast_packet);
1415+ new->seqno = seqno;
14131416 new->len = payload_len;
14141417
1415− spin_lock_bh(&tp_vars->common.unacked_lock);
14161418 /* if the list is empty immediately attach this new object */
14171419 if (list_empty(&tp_vars->common.unacked_list)) {
14181420 list_add(&new->list, &tp_vars->common.unacked_list);
1419− goto out;
1421+ tp_vars->common.unacked_count++;
1422+ return true;
14201423 }
14211424
14221425 /* otherwise loop over the list and either drop the packet because this
@@ -1446,15 +1449,24 @@ static bool batadv_tp_handle_out_of_order(struct batadv_tp_receiver *tp_vars, · 23 unmodified lines
14461449 */
14471450 list_add(&new->list, &un->list);
14481451 added = true;
1452+ tp_vars->common.unacked_count++;
14491453 break;
14501454 }
14511455
14521456 /* received packet with smallest seqno out of order; add it to front */
1453− if (!added)
1457+ if (!added) {
14541458 list_add(&new->list, &tp_vars->common.unacked_list);
1459+ tp_vars->common.unacked_count++;
1460+ }
14551461
1456−out:
1457− spin_unlock_bh(&tp_vars->common.unacked_lock);
1462+ /* remove the last (biggest) unacked seqno when list is too large */
1463+ if (tp_vars->common.unacked_count > BATADV_TP_MAX_UNACKED) {
1464+ un = list_last_entry(&tp_vars->common.unacked_list,
1465+ struct batadv_tp_unacked, list);
1466+ list_del(&un->list);
1467+ kfree(un);
1468+ tp_vars->common.unacked_count--;
1469+ }
14581470
14591471 return true;
14601472 }
@@ -1465,6 +1477,7 @@ out: · 4 unmodified lines
14651477 * @tp_vars: the private data of the current TP meter session
14661478 */
14671479 static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars)
1480+ __must_hold(&tp_vars->common.unacked_lock)
14681481 {
14691482 struct batadv_tp_unacked *un, *safe;
14701483 u32 to_ack;
@@ -1472,7 +1485,6 @@ static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars) · 1 unmodified line
14721485 /* go through the unacked packet list and possibly ACK them as
14731486 * well
14741487 */
1475− spin_lock_bh(&tp_vars->common.unacked_lock);
14761488 list_for_each_entry_safe(un, safe, &tp_vars->common.unacked_list, list) {
14771489 /* the list is ordered, therefore it is possible to stop as soon
14781490 * there is a gap between the last acked seqno and the seqno of
@@ -1488,8 +1500,8 @@ static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars) · 9 unmodified lines
14881500
14891501 list_del(&un->list);
14901502 kfree(un);
1503+ tp_vars->common.unacked_count--;
14911504 }
1492− spin_unlock_bh(&tp_vars->common.unacked_lock);
14931505 }
14941506
14951507 /**
@@ -1512,7 +1524,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, · 16 unmodified lines
15121524 tp_vars = batadv_tp_list_find_receiver_session(bat_priv, icmp->orig,
15131525 icmp->session);
15141526 if (tp_vars) {
1515− tp_vars->last_recv_time = jiffies;
1527+ WRITE_ONCE(tp_vars->last_recv_time, jiffies);
15161528 goto out_unlock;
15171529 }
15181530
@@ -1537,11 +1549,12 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, · 18 unmodified lines
15371549
15381550 spin_lock_init(&tp_vars->common.unacked_lock);
15391551 INIT_LIST_HEAD(&tp_vars->common.unacked_list);
1552+ tp_vars->common.unacked_count = 0;
15401553
15411554 kref_get(&tp_vars->common.refcount);
15421555 timer_setup(&tp_vars->common.timer, batadv_tp_receiver_shutdown, 0);
15431556
1544− tp_vars->last_recv_time = jiffies;
1557+ WRITE_ONCE(tp_vars->last_recv_time, jiffies);
15451558
15461559 kref_get(&tp_vars->common.refcount);
15471560 hlist_add_head_rcu(&tp_vars->common.list, &bat_priv->tp_receiver_list);
@@ -1566,7 +1579,8 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv, · 18 unmodified lines
15661579 {
15671580 const struct batadv_icmp_tp_packet *icmp;
15681581 struct batadv_tp_receiver *tp_vars;
1569− size_t packet_size;
1582+ u32 payload_len;
1583+ u32 to_ack;
15701584 u32 seqno;
15711585
15721586 icmp = (struct batadv_icmp_tp_packet *)skb->data;
@@ -1592,40 +1606,48 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv, · 19 unmodified lines
15921606 goto out;
15931607 }
15941608
1595− tp_vars->last_recv_time = jiffies;
1609+ WRITE_ONCE(tp_vars->last_recv_time, jiffies);
15961610 }
15971611
1612+ spin_lock_bh(&tp_vars->common.unacked_lock);
1613+
15981614 /* if the packet is a duplicate, it may be the case that an ACK has been
15991615 * lost. Resend the ACK
16001616 */
1601− if (batadv_seq_before(seqno, tp_vars->last_recv))
1617+ payload_len = skb->len - sizeof(struct batadv_unicast_packet);
1618+ to_ack = seqno + payload_len;
1619+ if (batadv_seq_before(to_ack, tp_vars->last_recv))
16021620 goto send_ack;
16031621
16041622 /* if the packet is out of order enqueue it */
1605− if (ntohl(icmp->seqno) != tp_vars->last_recv) {
1623+ if (batadv_seq_before(tp_vars->last_recv, seqno)) {
16061624 /* exit immediately (and do not send any ACK) if the packet has
16071625 * not been enqueued correctly
16081626 */
1609− if (!batadv_tp_handle_out_of_order(tp_vars, skb))
1627+ if (!batadv_tp_handle_out_of_order(tp_vars, seqno, payload_len)) {
1628+ spin_unlock_bh(&tp_vars->common.unacked_lock);
16101629 goto out;
1630+ }
16111631
16121632 /* send a duplicate ACK */
16131633 goto send_ack;
16141634 }
16151635
16161636 /* if everything was fine count the ACKed bytes */
1617− packet_size = skb->len - sizeof(struct batadv_unicast_packet);
1618− tp_vars->last_recv += packet_size;
1637+ tp_vars->last_recv = to_ack;
16191638
16201639 /* check if this ordered message filled a gap.... */
16211640 batadv_tp_ack_unordered(tp_vars);
16221641
16231642 send_ack:
1643+ to_ack = tp_vars->last_recv;
1644+ spin_unlock_bh(&tp_vars->common.unacked_lock);
1645+
16241646 /* send the ACK. If the received packet was out of order, the ACK that
16251647 * is going to be sent is a duplicate (the sender will count them and
16261648 * possibly enter Fast Retransmit as soon as it has reached 3)
16271649 */
1628− batadv_tp_send_ack(bat_priv, icmp->orig, tp_vars->last_recv,
1650+ batadv_tp_send_ack(bat_priv, icmp->orig, to_ack,
16291651 icmp->timestamp, icmp->session, icmp->uid);
16301652 out:
16311653 batadv_tp_receiver_put(tp_vars);
net/batman-adv/translation-table.c+10−2
@@ -447,6 +447,9 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv, · 446 unmodified lines
447447 if (!batadv_compare_eth(entry->change.addr, common->addr))
448448 continue;
449449
450+ if (entry->change.vid != tt_change_node->change.vid)
451+ continue;
452+
450453 del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL;
451454 if (del_op_requested != del_op_entry) {
452455 /* DEL+ADD in the same orig interval have no effect and
@@ -3447,6 +3450,7 @@ static void batadv_tt_roam_purge(struct batadv_priv *bat_priv) · 2994 unmodified lines
34473450 * batadv_tt_check_roam_count() - check if a client has roamed too frequently
34483451 * @bat_priv: the bat priv with all the mesh interface information
34493452 * @client: mac address of the roaming client
3453+ * @vid: VLAN identifier
34503454 *
34513455 * This function checks whether the client already reached the
34523456 * maximum number of possible roaming phases. In this case the ROAMING_ADV
@@ -3454,7 +3458,7 @@ static void batadv_tt_roam_purge(struct batadv_priv *bat_priv) · 1 unmodified line
34543458 *
34553459 * Return: true if the ROAMING_ADV can be sent, false otherwise
34563460 */
3457−static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, u8 *client)
3461+static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, u8 *client, u16 vid)
34583462 {
34593463 struct batadv_tt_roam_node *tt_roam_node;
34603464 bool ret = false;
@@ -3467,6 +3471,9 @@ static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, u8 *client) · 6 unmodified lines
34673471 if (!batadv_compare_eth(tt_roam_node->addr, client))
34683472 continue;
34693473
3474+ if (tt_roam_node->vid != vid)
3475+ continue;
3476+
34703477 if (batadv_has_timed_out(tt_roam_node->first_time,
34713478 BATADV_ROAMING_MAX_TIME))
34723479 continue;
@@ -3488,6 +3495,7 @@ static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, u8 *client) · 15 unmodified lines
34883495 atomic_set(&tt_roam_node->counter,
34893496 BATADV_ROAMING_MAX_COUNT - 1);
34903497 ether_addr_copy(tt_roam_node->addr, client);
3498+ tt_roam_node->vid = vid;
34913499
34923500 list_add(&tt_roam_node->list, &bat_priv->tt.roam_list);
34933501 ret = true;
@@ -3524,7 +3532,7 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, u8 *client, · 30 unmodified lines
35243532 /* before going on we have to check whether the client has
35253533 * already roamed to us too many times
35263534 */
3527− if (!batadv_tt_check_roam_count(bat_priv, client))
3535+ if (!batadv_tt_check_roam_count(bat_priv, client, vid))
35283536 goto out;
35293537
35303538 batadv_dbg(BATADV_DBG_TT, bat_priv,
net/batman-adv/tvlv.c+63−6
@@ -411,7 +411,6 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv, · 410 unmodified lines
411411 tvlv_handler->ogm_handler(bat_priv, orig_node,
412412 BATADV_NO_FLAGS,
413413 tvlv_value, tvlv_value_len);
414− tvlv_handler->flags |= BATADV_TVLV_HANDLER_OGM_CALLED;
415414 break;
416415 case BATADV_UNICAST_TVLV:
417416 if (!skb)
@@ -443,6 +442,48 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv, · 25 unmodified lines
443442 return NET_RX_SUCCESS;
444443 }
445444
445+/**
446+ * batadv_tvlv_containers_contain() - check if a tvlv buffer holds a container
447+ * @tvlv_value: tvlv content
448+ * @tvlv_value_len: tvlv content length
449+ * @type: tvlv container type to look for
450+ * @version: tvlv container version to look for
451+ *
452+ * Return: true if a container of the given type and version is present in the
453+ * tvlv buffer, false otherwise.
454+ */
455+static bool batadv_tvlv_containers_contain(void *tvlv_value,
456+ u16 tvlv_value_len, u8 type,
457+ u8 version)
458+{
459+ struct batadv_tvlv_hdr *tvlv_hdr;
460+ u16 tvlv_value_cont_len;
461+
462+ while (tvlv_value_len >= sizeof(*tvlv_hdr)) {
463+ tvlv_hdr = tvlv_value;
464+ tvlv_value_cont_len = ntohs(tvlv_hdr->len);
465+ tvlv_value = tvlv_hdr + 1;
466+ tvlv_value_len -= sizeof(*tvlv_hdr);
467+
468+ if (tvlv_value_cont_len > tvlv_value_len)
469+ break;
470+
471+ /* the next tvlv header is accessed assuming (at least) 2-byte
472+ * alignment, so it must start at an even offset.
473+ */
474+ if (tvlv_value_cont_len & 1)
475+ break;
476+
477+ if (tvlv_hdr->type == type && tvlv_hdr->version == version)
478+ return true;
479+
480+ tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len;
481+ tvlv_value_len -= tvlv_value_cont_len;
482+ }
483+
484+ return false;
485+}
486+
446487 /**
447488 * batadv_tvlv_containers_process() - parse the given tvlv buffer to call the
448489 * appropriate handlers
@@ -462,7 +503,9 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, · 13 unmodified lines
462503 struct sk_buff *skb, void *tvlv_value,
463504 u16 tvlv_value_len)
464505 {
506+ u16 tvlv_value_start_len = tvlv_value_len;
465507 struct batadv_tvlv_handler *tvlv_handler;
508+ void *tvlv_value_start = tvlv_value;
466509 struct batadv_tvlv_hdr *tvlv_hdr;
467510 u16 tvlv_value_cont_len;
468511 u8 cifnotfound = BATADV_TVLV_HANDLER_OGM_CIFNOTFND;
@@ -477,6 +520,12 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, · 8 unmodified lines
477520 if (tvlv_value_cont_len > tvlv_value_len)
478521 break;
479522
523+ /* the next tvlv header is accessed assuming (at least) 2-byte
524+ * alignment, so it must start at an even offset.
525+ */
526+ if (tvlv_value_cont_len & 1)
527+ break;
528+
480529 tvlv_handler = batadv_tvlv_handler_get(bat_priv,
481530 tvlv_hdr->type,
482531 tvlv_hdr->version);
@@ -500,12 +549,20 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, · 17 unmodified lines
500549 if (!tvlv_handler->ogm_handler)
501550 continue;
502551
503− if ((tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) &&
504− !(tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CALLED))
505− tvlv_handler->ogm_handler(bat_priv, orig_node,
506− cifnotfound, NULL, 0);
552+ if (!(tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND))
553+ continue;
554+
555+ /* if the corresponding container was present then the handler
556+ * was already called from the loop above
557+ */
558+ if (batadv_tvlv_containers_contain(tvlv_value_start,
559+ tvlv_value_start_len,
560+ tvlv_handler->type,
561+ tvlv_handler->version))
562+ continue;
507563
508− tvlv_handler->flags &= ~BATADV_TVLV_HANDLER_OGM_CALLED;
564+ tvlv_handler->ogm_handler(bat_priv, orig_node,
565+ cifnotfound, NULL, 0);
509566 }
510567 rcu_read_unlock();
511568
net/batman-adv/types.h+13−8
@@ -145,6 +145,12 @@ struct batadv_hard_iface_bat_v { · 144 unmodified lines
145145 /** @aggr_list: queue for to be aggregated OGM packets */
146146 struct sk_buff_head aggr_list;
147147
148+ /**
149+ * @aggr_list_enabled: aggr_list is active and new skbs can be
150+ * enqueued. Protected by aggr_list.lock after initialization
151+ */
152+ bool aggr_list_enabled:1;
153+
148154 /** @aggr_len: size of the OGM aggregate (excluding ethernet header) */
149155 unsigned int aggr_len;
150156
@@ -1357,9 +1363,12 @@ struct batadv_tp_vars_common { · 1206 unmodified lines
13571363 /** @unacked_list: list of unacked packets (meta-info only) */
13581364 struct list_head unacked_list;
13591365
1360− /** @unacked_lock: protect unacked_list */
1366+ /** @unacked_lock: protect unacked_list + &batadv_tp_receiver.last_recv */
13611367 spinlock_t unacked_lock;
13621368
1369+ /** @unacked_count: number of unacked entries */
1370+ size_t unacked_count;
1371+
13631372 /** @refcount: number of context where the object is used */
13641373 struct kref refcount;
13651374
@@ -1952,6 +1961,9 @@ struct batadv_tt_roam_node { · 586 unmodified lines
19521961 /** @addr: mac address of the client in the roaming phase */
19531962 u8 addr[ETH_ALEN];
19541963
1964+ /** @vid: VLAN identifier */
1965+ u16 vid;
1966+
19551967 /**
19561968 * @counter: number of allowed roaming events per client within a single
19571969 * OGM interval (changes are committed with each OGM)
@@ -2282,13 +2294,6 @@ enum batadv_tvlv_handler_flags { · 324 unmodified lines
22822294 * will call this handler even if its type was not found (with no data)
22832295 */
22842296 BATADV_TVLV_HANDLER_OGM_CIFNOTFND = BIT(1),
2285−
2286− /**
2287− * @BATADV_TVLV_HANDLER_OGM_CALLED: interval tvlv handling flag - the
2288− * API marks a handler as being called, so it won't be called if the
2289− * BATADV_TVLV_HANDLER_OGM_CIFNOTFND flag was set
2290− */
2291− BATADV_TVLV_HANDLER_OGM_CALLED = BIT(2),
22922297 };
22932298
22942299 #endif /* _NET_BATMAN_ADV_TYPES_H_ */
net/bridge/netfilter/nft_meta_bridge.c+21−2
@@ -44,7 +44,9 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr, · 43 unmodified lines
4444 if (!br_dev || !br_vlan_enabled(br_dev))
4545 goto err;
4646
47− br_vlan_get_pvid_rcu(in, &p_pvid);
47+ if (br_vlan_get_pvid_rcu(in, &p_pvid))
48+ goto err;
49+
4850 nft_reg_store16(dest, p_pvid);
4951 return;
5052 }
@@ -107,12 +109,30 @@ static int nft_meta_bridge_get_init(const struct nft_ctx *ctx, · 56 unmodified lines
107109 NULL, NFT_DATA_VALUE, len);
108110 }
109111
112+static int nft_meta_bridge_get_validate(const struct nft_ctx *ctx,
113+ const struct nft_expr *expr)
114+{
115+ struct nft_meta *priv = nft_expr_priv(expr);
116+ unsigned int hooks;
117+
118+ switch (priv->key) {
119+ case NFT_META_BRI_IIFHWADDR:
120+ hooks = 1 << NF_BR_PRE_ROUTING;
121+ break;
122+ default:
123+ return nft_meta_get_validate(ctx, expr);
124+ }
125+
126+ return nft_chain_validate_hooks(ctx->chain, hooks);
127+}
128+
110129 static struct nft_expr_type nft_meta_bridge_type;
111130 static const struct nft_expr_ops nft_meta_bridge_get_ops = {
112131 .type = &nft_meta_bridge_type,
113132 .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)),
114133 .eval = nft_meta_bridge_get_eval,
115134 .init = nft_meta_bridge_get_init,
135+ .validate = nft_meta_bridge_get_validate,
116136 .dump = nft_meta_get_dump,
117137 };
118138
@@ -168,7 +188,6 @@ static int nft_meta_bridge_set_validate(const struct nft_ctx *ctx, · 49 unmodified lines
168188
169189 switch (priv->key) {
170190 case NFT_META_BRI_BROUTE:
171− case NFT_META_BRI_IIFHWADDR:
172191 hooks = 1 << NF_BR_PRE_ROUTING;
173192 break;
174193 default:
net/core/Makefile+1−1
@@ -13,7 +13,7 @@ obj-y += dev.o dev_api.o dev_addr_lists.o dst.o netevent.o \ · 12 unmodified lines
1313 neighbour.o rtnetlink.o utils.o link_watch.o filter.o \
1414 sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \
1515 fib_notifier.o xdp.o flow_offload.o gro.o \
16− netdev-genl.o netdev-genl-gen.o gso.o
16+ netdev-genl.o netdev-genl-gen.o netdev_work.o gso.o
1717
1818 obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o
1919
net/core/dev.c+2−0
@@ -9822,6 +9822,7 @@ int netif_change_flags(struct net_device *dev, unsigned int flags, · 9821 unmodified lines
98229822 __dev_notify_flags(dev, old_flags, changes, 0, NULL);
98239823 return ret;
98249824 }
9825+EXPORT_SYMBOL(netif_change_flags);
98259826
98269827 int __netif_set_mtu(struct net_device *dev, int new_mtu)
98279828 {
@@ -12093,6 +12094,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, · 2265 unmodified lines
1209312094 INIT_LIST_HEAD(&dev->ptype_all);
1209412095 INIT_LIST_HEAD(&dev->ptype_specific);
1209512096 INIT_LIST_HEAD(&dev->net_notifier_list);
12097+ INIT_LIST_HEAD(&dev->work_node);
1209612098 #ifdef CONFIG_NET_SCHED
1209712099 hash_init(dev->qdisc_hash);
1209812100 #endif
net/core/dev.h+10−1
@@ -167,10 +167,19 @@ int dev_change_carrier(struct net_device *dev, bool new_carrier); · 166 unmodified lines
167167 void __dev_set_rx_mode(struct net_device *dev);
168168 int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify);
169169 void netif_rx_mode_init(struct net_device *dev);
170−bool netif_rx_mode_clean(struct net_device *dev);
170+void netif_rx_mode_run(struct net_device *dev);
171171 void netif_rx_mode_sync(struct net_device *dev);
172172 void netif_rx_mode_cancel_retry(struct net_device *dev);
173173
174+/* Events for the async netdev work, tracked in netdev->work_core_pending. */
175+enum netdev_work_core {
176+ NETDEV_WORK_RX_MODE = BIT(0), /* run the rx_mode update */
177+};
178+
179+void __netdev_work_core_sched(struct net_device *dev, unsigned long event);
180+unsigned long
181+__netdev_work_core_cancel(struct net_device *dev, unsigned long mask);
182+
174183 void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
175184 unsigned int gchanges, u32 portid,
176185 const struct nlmsghdr *nlh);
net/core/dev_addr_lists.c+3−74
@@ -12,17 +12,10 @@ · 11 unmodified lines
1212 #include <linux/export.h>
1313 #include <linux/list.h>
1414 #include <linux/spinlock.h>
15−#include <linux/workqueue.h>
1615 #include <kunit/visibility.h>
1716
1817 #include "dev.h"
1918
20−static void netdev_rx_mode_work(struct work_struct *work);
21−
22−static LIST_HEAD(rx_mode_list);
23−static DEFINE_SPINLOCK(rx_mode_lock);
24−static DECLARE_WORK(rx_mode_work, netdev_rx_mode_work);
25−
2619 /*
2720 * General list handling functions
2821 */
@@ -1281,7 +1274,7 @@ void netif_rx_mode_cancel_retry(struct net_device *dev) · 1252 unmodified lines
12811274 dev->rx_mode_retry_count = 0;
12821275 }
12831276
1284−static void netif_rx_mode_run(struct net_device *dev)
1277+void netif_rx_mode_run(struct net_device *dev)
12851278 {
12861279 struct netdev_hw_addr_list uc_snap, mc_snap, uc_ref, mc_ref;
12871280 const struct net_device_ops *ops = dev->netdev_ops;
@@ -1339,49 +1332,9 @@ static void netif_rx_mode_run(struct net_device *dev) · 51 unmodified lines
13391332 }
13401333 }
13411334
1342−static void netdev_rx_mode_work(struct work_struct *work)
1343−{
1344− struct net_device *dev;
1345−
1346− rtnl_lock();
1347−
1348− while (true) {
1349− spin_lock_bh(&rx_mode_lock);
1350− if (list_empty(&rx_mode_list)) {
1351− spin_unlock_bh(&rx_mode_lock);
1352− break;
1353− }
1354− dev = list_first_entry(&rx_mode_list, struct net_device,
1355− rx_mode_node);
1356− list_del_init(&dev->rx_mode_node);
1357− /* We must free netdev tracker under
1358− * the spinlock protection.
1359− */
1360− netdev_tracker_free(dev, &dev->rx_mode_tracker);
1361− spin_unlock_bh(&rx_mode_lock);
1362−
1363− netdev_lock_ops(dev);
1364− netif_rx_mode_run(dev);
1365− netdev_unlock_ops(dev);
1366− /* Use __dev_put() because netdev_tracker_free() was already
1367− * called above. Must be after netdev_unlock_ops() to prevent
1368− * netdev_run_todo() from freeing the device while still in use.
1369− */
1370− __dev_put(dev);
1371− }
1372−
1373− rtnl_unlock();
1374−}
1375−
13761335 static void netif_rx_mode_queue(struct net_device *dev)
13771336 {
1378− spin_lock_bh(&rx_mode_lock);
1379− if (list_empty(&dev->rx_mode_node)) {
1380− list_add_tail(&dev->rx_mode_node, &rx_mode_list);
1381− netdev_hold(dev, &dev->rx_mode_tracker, GFP_ATOMIC);
1382− }
1383− spin_unlock_bh(&rx_mode_lock);
1384− schedule_work(&rx_mode_work);
1337+ __netdev_work_core_sched(dev, NETDEV_WORK_RX_MODE);
13851338 }
13861339
13871340 static void netif_rx_mode_retry(struct timer_list *t)
@@ -1394,7 +1347,6 @@ static void netif_rx_mode_retry(struct timer_list *t) · 6 unmodified lines
13941347
13951348 void netif_rx_mode_init(struct net_device *dev)
13961349 {
1397− INIT_LIST_HEAD(&dev->rx_mode_node);
13981350 __hw_addr_init(&dev->rx_mode_addr_cache);
13991351 timer_setup(&dev->rx_mode_retry_timer, netif_rx_mode_retry, 0);
14001352 }
@@ -1442,24 +1394,6 @@ void dev_set_rx_mode(struct net_device *dev) · 41 unmodified lines
14421394 netif_addr_unlock_bh(dev);
14431395 }
14441396
1445−bool netif_rx_mode_clean(struct net_device *dev)
1446−{
1447− bool clean = false;
1448−
1449− spin_lock_bh(&rx_mode_lock);
1450− if (!list_empty(&dev->rx_mode_node)) {
1451− list_del_init(&dev->rx_mode_node);
1452− clean = true;
1453− /* We must release netdev tracker under
1454− * the spinlock protection.
1455− */
1456− netdev_tracker_free(dev, &dev->rx_mode_tracker);
1457− }
1458− spin_unlock_bh(&rx_mode_lock);
1459−
1460− return clean;
1461−}
1462−
14631397 /**
14641398 * netif_rx_mode_sync() - sync rx mode inline
14651399 * @dev: network device
@@ -1473,11 +1407,6 @@ bool netif_rx_mode_clean(struct net_device *dev) · 7 unmodified lines
14731407 */
14741408 void netif_rx_mode_sync(struct net_device *dev)
14751409 {
1476− if (netif_rx_mode_clean(dev)) {
1410+ if (__netdev_work_core_cancel(dev, NETDEV_WORK_RX_MODE))
14771411 netif_rx_mode_run(dev);
1478− /* Use __dev_put() because netdev_tracker_free() was already
1479− * called inside netif_rx_mode_clean().
1480− */
1481− __dev_put(dev);
1482− }
14831412 }
net/core/filter.c+1−1
@@ -4472,7 +4472,7 @@ u32 xdp_master_redirect(struct xdp_buff *xdp) · 4471 unmodified lines
44724472 struct net_device *master, *slave;
44734473
44744474 master = netdev_master_upper_dev_get_rcu(xdp->rxq->dev);
4475− if (unlikely(!(master->flags & IFF_UP)))
4475+ if (unlikely(!master || !(master->flags & IFF_UP)))
44764476 return XDP_ABORTED;
44774477 slave = master->netdev_ops->ndo_xdp_get_xmit_slave(master, xdp);
44784478 if (slave && slave != xdp->rxq->dev) {
net/core/flow_dissector.c+10−2
@@ -1173,13 +1173,21 @@ bool __skb_flow_dissect(const struct net *net, · 1172 unmodified lines
11731173
11741174 if (dissector_uses_key(flow_dissector,
11751175 FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
1176− struct ethhdr *eth = eth_hdr(skb);
11771176 struct flow_dissector_key_eth_addrs *key_eth_addrs;
11781177
11791178 key_eth_addrs = skb_flow_dissector_target(flow_dissector,
11801179 FLOW_DISSECTOR_KEY_ETH_ADDRS,
11811180 target_container);
1182− memcpy(key_eth_addrs, eth, sizeof(*key_eth_addrs));
1181+ /* TC filter blocks can be shared across devices with
1182+ * different link types, so we cannot validate this
1183+ * when the filter is installed -- check at dissect time.
1184+ */
1185+ if (skb && skb->dev &&
1186+ skb->dev->type == ARPHRD_ETHER &&
1187+ skb_mac_header_was_set(skb))
1188+ memcpy(key_eth_addrs, eth_hdr(skb), sizeof(*key_eth_addrs));
1189+ else
1190+ memset(key_eth_addrs, 0, sizeof(*key_eth_addrs));
11831191 }
11841192
11851193 if (dissector_uses_key(flow_dissector,
net/core/lwtunnel.c+6−0
@@ -350,6 +350,8 @@ int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb) · 349 unmodified lines
350350 rcu_read_lock();
351351 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
352352 if (likely(ops && ops->output)) {
353+ /* Encap pushes outer headers over the metadata; drop it. */
354+ skb_metadata_clear(skb);
353355 dev_xmit_recursion_inc();
354356 ret = ops->output(net, sk, skb);
355357 dev_xmit_recursion_dec();
@@ -404,6 +406,8 @@ int lwtunnel_xmit(struct sk_buff *skb) · 48 unmodified lines
404406 rcu_read_lock();
405407 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
406408 if (likely(ops && ops->xmit)) {
409+ /* Encap pushes outer headers over the metadata; drop it. */
410+ skb_metadata_clear(skb);
407411 dev_xmit_recursion_inc();
408412 ret = ops->xmit(skb);
409413 dev_xmit_recursion_dec();
@@ -455,6 +459,8 @@ int lwtunnel_input(struct sk_buff *skb) · 45 unmodified lines
455459 rcu_read_lock();
456460 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
457461 if (likely(ops && ops->input)) {
462+ /* Encap pushes outer headers over the metadata; drop it. */
463+ skb_metadata_clear(skb);
458464 dev_xmit_recursion_inc();
459465 ret = ops->input(skb);
460466 dev_xmit_recursion_dec();
net/core/netdev-genl.c+3−1
@@ -2,6 +2,7 @@ · 1 unmodified line
22
33 #include <linux/netdevice.h>
44 #include <linux/notifier.h>
5+#include <linux/pid_namespace.h>
56 #include <linux/rtnetlink.h>
67 #include <net/busy_poll.h>
78 #include <net/net_namespace.h>
@@ -189,7 +190,8 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, · 181 unmodified lines
189190 goto nla_put_failure;
190191
191192 if (napi->thread) {
192− pid = task_pid_nr(napi->thread);
193+ pid = task_pid_nr_ns(napi->thread,
194+ task_active_pid_ns(current));
193195 if (nla_put_u32(rsp, NETDEV_A_NAPI_PID, pid))
194196 goto nla_put_failure;
195197 }
net/core/netdev_work.c+162−0
@@ -0,0 +1,162 @@
1+// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+#include <linux/export.h>
4+#include <linux/list.h>
5+#include <linux/netdevice.h>
6+#include <linux/rtnetlink.h>
7+#include <linux/spinlock.h>
8+#include <linux/workqueue.h>
9+#include <net/netdev_lock.h>
10+
11+#include "dev.h"
12+
13+static void netdev_work_proc(struct work_struct *work);
14+
15+/* @netdev_work_lock protects:
16+ * - @netdev_work_list
17+ * - within the list entries (struct net_device fields):
18+ * - work_node
19+ * - work_tracker
20+ * - work_pending
21+ * - work_core_pending
22+ */
23+static LIST_HEAD(netdev_work_list);
24+static DEFINE_SPINLOCK(netdev_work_lock);
25+static DECLARE_WORK(netdev_work, netdev_work_proc);
26+
27+static void netdev_work_enqueue(struct net_device *dev, unsigned long events,
28+ unsigned long core)
29+{
30+ if (!events && !core)
31+ return;
32+
33+ spin_lock_bh(&netdev_work_lock);
34+ if (list_empty(&dev->work_node)) {
35+ list_add_tail(&dev->work_node, &netdev_work_list);
36+ netdev_hold(dev, &dev->work_tracker, GFP_ATOMIC);
37+ }
38+ dev->work_pending |= events;
39+ dev->work_core_pending |= core;
40+ spin_unlock_bh(&netdev_work_lock);
41+
42+ schedule_work(&netdev_work);
43+}
44+
45+static unsigned long
46+netdev_work_dequeue(struct net_device *dev, unsigned long *pending,
47+ unsigned long mask)
48+{
49+ unsigned long events;
50+
51+ spin_lock_bh(&netdev_work_lock);
52+ events = *pending & mask;
53+ *pending &= ~events;
54+ if (!list_empty(&dev->work_node) &&
55+ !dev->work_pending && !dev->work_core_pending) {
56+ list_del_init(&dev->work_node);
57+ netdev_put(dev, &dev->work_tracker);
58+ }
59+ spin_unlock_bh(&netdev_work_lock);
60+
61+ return events;
62+}
63+
64+void netdev_work_sched(struct net_device *dev, unsigned long events)
65+{
66+ netdev_work_enqueue(dev, events, 0);
67+}
68+EXPORT_SYMBOL(netdev_work_sched);
69+
70+/**
71+ * netdev_work_cancel() - cancel selected work for a netdev
72+ * @dev: net_device
73+ * @mask: events to cancel
74+ *
75+ * Clear @mask from the device's work pending mask. If no work is left pending
76+ * the device is dequeued and its ndo_work won't be called.
77+ *
78+ * No expectations on locking, but also no guarantees provided. If the caller
79+ * wants to touch @dev afterwards (e.g. call the work that got canceled)
80+ * they have to ensure @dev does not get freed.
81+ *
82+ * Returns: the subset of @mask that was actually pending, so the caller can run
83+ * those events inline.
84+ */
85+unsigned long netdev_work_cancel(struct net_device *dev, unsigned long mask)
86+{
87+ return netdev_work_dequeue(dev, &dev->work_pending, mask);
88+}
89+EXPORT_SYMBOL(netdev_work_cancel);
90+
91+void __netdev_work_core_sched(struct net_device *dev, unsigned long events)
92+{
93+ netdev_work_enqueue(dev, 0, events);
94+}
95+
96+unsigned long
97+__netdev_work_core_cancel(struct net_device *dev, unsigned long mask)
98+{
99+ return netdev_work_dequeue(dev, &dev->work_core_pending, mask);
100+}
101+
102+static void netdev_work_run(struct net_device *dev, unsigned long events,
103+ unsigned long core)
104+{
105+ if (!netif_device_present(dev))
106+ return;
107+
108+ if (core & NETDEV_WORK_RX_MODE)
109+ netif_rx_mode_run(dev);
110+ if (events && dev->netdev_ops->ndo_work)
111+ dev->netdev_ops->ndo_work(dev, events);
112+}
113+
114+static void netdev_work_proc(struct work_struct *work)
115+{
116+ rtnl_lock();
117+
118+ while (true) {
119+ unsigned long events = 0, core = 0;
120+ netdevice_tracker tracker;
121+ struct net_device *dev;
122+
123+ spin_lock_bh(&netdev_work_lock);
124+ if (list_empty(&netdev_work_list)) {
125+ spin_unlock_bh(&netdev_work_lock);
126+ break;
127+ }
128+ dev = list_first_entry(&netdev_work_list, struct net_device,
129+ work_node);
130+ /* Take a temporary reference so @dev can't be freed while we
131+ * drop the lock to grab its ops lock; the work reference is
132+ * only released once we claim the work below.
133+ * The re-locking dance is to ensure that ops lock is enough
134+ * to ensure canceling work is not racy with dequeue.
135+ */
136+ netdev_hold(dev, &tracker, GFP_ATOMIC);
137+ spin_unlock_bh(&netdev_work_lock);
138+
139+ netdev_lock_ops(dev);
140+ spin_lock_bh(&netdev_work_lock);
141+ if (!list_empty(&dev->work_node)) {
142+ list_del_init(&dev->work_node);
143+ core = dev->work_core_pending;
144+ dev->work_core_pending = 0;
145+ events = dev->work_pending;
146+ dev->work_pending = 0;
147+ /* We took another ref above */
148+ netdev_put(dev, &dev->work_tracker);
149+
150+ if (!dev_isalive(dev))
151+ core = events = 0;
152+ }
153+ spin_unlock_bh(&netdev_work_lock);
154+
155+ netdev_work_run(dev, events, core);
156+ netdev_unlock_ops(dev);
157+
158+ netdev_put(dev, &tracker);
159+ }
160+
161+ rtnl_unlock();
162+}
net/core/rtnetlink.c+8−0
@@ -2438,6 +2438,14 @@ struct net *rtnl_get_net_ns_capable(struct sock *sk, int netnsid) · 2437 unmodified lines
24382438 }
24392439 EXPORT_SYMBOL_GPL(rtnl_get_net_ns_capable);
24402440
2441+bool rtnl_dev_link_net_capable(const struct net_device *dev,
2442+ const struct net *link_net)
2443+{
2444+ return net_eq(link_net, dev_net(dev)) ||
2445+ ns_capable(link_net->user_ns, CAP_NET_ADMIN);
2446+}
2447+EXPORT_SYMBOL_GPL(rtnl_dev_link_net_capable);
2448+
24412449 static int rtnl_valid_dump_ifinfo_req(const struct nlmsghdr *nlh,
24422450 bool strict_check, struct nlattr **tb,
24432451 struct netlink_ext_ack *extack)
net/devlink/rate.c+14−11
@@ -486,16 +486,19 @@ static int devlink_nl_rate_set(struct devlink_rate *devlink_rate, · 485 unmodified lines
486486 devlink_rate->tx_weight = weight;
487487 }
488488
489− nla_parent = attrs[DEVLINK_ATTR_RATE_PARENT_NODE_NAME];
490− if (nla_parent) {
491− err = devlink_nl_rate_parent_node_set(devlink_rate, info,
492− nla_parent);
489+ if (attrs[DEVLINK_ATTR_RATE_TC_BWS]) {
490+ err = devlink_nl_rate_tc_bw_set(devlink_rate, info);
493491 if (err)
494492 return err;
495493 }
496494
497− if (attrs[DEVLINK_ATTR_RATE_TC_BWS]) {
498− err = devlink_nl_rate_tc_bw_set(devlink_rate, info);
495+ /* Keep parent setting last because it takes a reference. This function
496+ * has no rollback, so failing after taking the ref would leak it.
497+ */
498+ nla_parent = attrs[DEVLINK_ATTR_RATE_PARENT_NODE_NAME];
499+ if (nla_parent) {
500+ err = devlink_nl_rate_parent_node_set(devlink_rate, info,
501+ nla_parent);
499502 if (err)
500503 return err;
501504 }
@@ -725,11 +728,6 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name, · 223 unmodified lines
725728 if (!rate_node)
726729 return ERR_PTR(-ENOMEM);
727730
728− if (parent) {
729− rate_node->parent = parent;
730− refcount_inc(&rate_node->parent->refcnt);
731− }
732−
733731 rate_node->type = DEVLINK_RATE_TYPE_NODE;
734732 rate_node->devlink = devlink;
735733 rate_node->priv = priv;
@@ -740,6 +738,11 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name, · 4 unmodified lines
740738 return ERR_PTR(-ENOMEM);
741739 }
742740
741+ if (parent) {
742+ rate_node->parent = parent;
743+ refcount_inc(&rate_node->parent->refcnt);
744+ }
745+
743746 refcount_set(&rate_node->refcnt, 1);
744747 list_add(&rate_node->list, &devlink->rate_list);
745748 devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW);
net/ethtool/common.h+4−0
@@ -113,6 +113,8 @@ ethtool_nl_msg_needs_rtnl(const struct net_device *dev, u8 cmd) · 112 unmodified lines
113113 return ops->op_needs_rtnl & ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM;
114114 case ETHTOOL_MSG_RSS_SET:
115115 return ops->op_needs_rtnl & ETHTOOL_OP_NEEDS_RTNL_RSS;
116+ case ETHTOOL_MSG_LINKSTATE_GET:
117+ return ops->op_needs_rtnl & ETHTOOL_OP_NEEDS_RTNL_GLINK;
116118 case ETHTOOL_MSG_TSCONFIG_GET:
117119 case ETHTOOL_MSG_TSCONFIG_SET:
118120 /* tsconfig calls ndos (ndo_hwtstamp_set/get), not ethtool ops.
@@ -159,6 +161,8 @@ ethtool_ioctl_needs_rtnl(const struct net_device *dev, u32 ethcmd) · 40 unmodified lines
159161 case ETHTOOL_SRXFH:
160162 case ETHTOOL_SRXFHINDIR:
161163 return ops->op_needs_rtnl & ETHTOOL_OP_NEEDS_RTNL_RSS;
164+ case ETHTOOL_GLINK:
165+ return ops->op_needs_rtnl & ETHTOOL_OP_NEEDS_RTNL_GLINK;
162166 }
163167 return false;
164168 }
net/ieee802154/core.c+29−22
@@ -228,36 +228,43 @@ int cfg802154_switch_netns(struct cfg802154_registered_device *rdev, · 227 unmodified lines
228228 continue;
229229 wpan_dev->netdev->netns_immutable = false;
230230 err = dev_change_net_namespace(wpan_dev->netdev, net, "wpan%d");
231− if (err)
231+ if (err) {
232+ WARN_ON(err && err != -ENOMEM);
232233 break;
234+ }
233235 wpan_dev->netdev->netns_immutable = true;
234236 }
235237
236− if (err) {
237− /* failed -- clean up to old netns */
238− net = wpan_phy_net(&rdev->wpan_phy);
239−
240− list_for_each_entry_continue_reverse(wpan_dev,
241− &rdev->wpan_dev_list,
242− list) {
243− if (!wpan_dev->netdev)
244− continue;
245− wpan_dev->netdev->netns_immutable = false;
246− err = dev_change_net_namespace(wpan_dev->netdev, net,
247− "wpan%d");
248− WARN_ON(err);
249− wpan_dev->netdev->netns_immutable = true;
250− }
238+ if (err)
239+ goto errout;
251240
252− return err;
253− }
241+ err = device_rename(&rdev->wpan_phy.dev, dev_name(&rdev->wpan_phy.dev));
242+ WARN_ON(err && err != -ENOMEM);
254243
255− wpan_phy_net_set(&rdev->wpan_phy, net);
244+ if (err)
245+ goto errout;
256246
257− err = device_rename(&rdev->wpan_phy.dev, dev_name(&rdev->wpan_phy.dev));
258− WARN_ON(err);
247+ wpan_phy_net_set(&rdev->wpan_phy, net);
259248
260249 return 0;
250+
251+errout:
252+ /* failed -- clean up to old netns */
253+ net = wpan_phy_net(&rdev->wpan_phy);
254+
255+ list_for_each_entry_continue_reverse(wpan_dev,
256+ &rdev->wpan_dev_list,
257+ list) {
258+ if (!wpan_dev->netdev)
259+ continue;
260+ wpan_dev->netdev->netns_immutable = false;
261+ err = dev_change_net_namespace(wpan_dev->netdev, net,
262+ "wpan%d");
263+ WARN_ON(err && err != -ENOMEM);
264+ wpan_dev->netdev->netns_immutable = true;
265+ }
266+
267+ return err;
261268 }
262269
263270 void cfg802154_dev_free(struct cfg802154_registered_device *rdev)
@@ -351,7 +358,7 @@ static void __net_exit cfg802154_pernet_exit(struct net *net) · 87 unmodified lines
351358 rtnl_lock();
352359 list_for_each_entry(rdev, &cfg802154_rdev_list, list) {
353360 if (net_eq(wpan_phy_net(&rdev->wpan_phy), net))
354− WARN_ON(cfg802154_switch_netns(rdev, &init_net));
361+ cfg802154_switch_netns(rdev, &init_net);
355362 }
356363 rtnl_unlock();
357364 }
net/ieee802154/header_ops.c+6−3
@@ -173,10 +173,13 @@ ieee802154_hdr_get_addr(const u8 *buf, int mode, bool omit_pan, · 172 unmodified lines
173173 {
174174 int pos = 0;
175175
176− addr->mode = mode;
177−
178− if (mode == IEEE802154_ADDR_NONE)
176+ if (mode == IEEE802154_ADDR_NONE) {
177+ memset(addr, 0, sizeof(*addr));
178+ addr->mode = IEEE802154_ADDR_NONE;
179179 return 0;
180+ }
181+
182+ addr->mode = mode;
180183
181184 if (!omit_pan) {
182185 memcpy(&addr->pan_id, buf + pos, 2);
net/ieee802154/ieee802154.h+17−0
@@ -16,6 +16,15 @@ void ieee802154_nl_exit(void); · 15 unmodified lines
1616 .flags = GENL_ADMIN_PERM, \
1717 }
1818
19+#define IEEE802154_OP_RELAXED(_cmd, _func) \
20+ { \
21+ .cmd = _cmd, \
22+ .doit = _func, \
23+ .dumpit = NULL, \
24+ .flags = GENL_ADMIN_PERM, \
25+ .validate = GENL_DONT_VALIDATE_STRICT,\
26+ }
27+
1928 #define IEEE802154_DUMP(_cmd, _func, _dump) \
2029 { \
2130 .cmd = _cmd, \
@@ -23,6 +32,14 @@ void ieee802154_nl_exit(void); · 1 unmodified line
2332 .dumpit = _dump, \
2433 }
2534
35+#define IEEE802154_DUMP_PRIV(_cmd, _func, _dump) \
36+ { \
37+ .cmd = _cmd, \
38+ .doit = _func, \
39+ .dumpit = _dump, \
40+ .flags = GENL_ADMIN_PERM, \
41+ }
42+
2643 struct genl_info;
2744
2845 struct sk_buff *ieee802154_nl_create(int flags, u8 req);
net/ieee802154/netlink.c+18−18
@@ -98,24 +98,24 @@ static const struct genl_small_ops ieee802154_ops[] = { · 97 unmodified lines
9898 IEEE802154_OP(IEEE802154_SET_MACPARAMS, ieee802154_set_macparams),
9999 IEEE802154_OP(IEEE802154_LLSEC_GETPARAMS, ieee802154_llsec_getparams),
100100 IEEE802154_OP(IEEE802154_LLSEC_SETPARAMS, ieee802154_llsec_setparams),
101− IEEE802154_DUMP(IEEE802154_LLSEC_LIST_KEY, NULL,
102− ieee802154_llsec_dump_keys),
103− IEEE802154_OP(IEEE802154_LLSEC_ADD_KEY, ieee802154_llsec_add_key),
104− IEEE802154_OP(IEEE802154_LLSEC_DEL_KEY, ieee802154_llsec_del_key),
105− IEEE802154_DUMP(IEEE802154_LLSEC_LIST_DEV, NULL,
106− ieee802154_llsec_dump_devs),
107− IEEE802154_OP(IEEE802154_LLSEC_ADD_DEV, ieee802154_llsec_add_dev),
108− IEEE802154_OP(IEEE802154_LLSEC_DEL_DEV, ieee802154_llsec_del_dev),
109− IEEE802154_DUMP(IEEE802154_LLSEC_LIST_DEVKEY, NULL,
110− ieee802154_llsec_dump_devkeys),
111− IEEE802154_OP(IEEE802154_LLSEC_ADD_DEVKEY, ieee802154_llsec_add_devkey),
112− IEEE802154_OP(IEEE802154_LLSEC_DEL_DEVKEY, ieee802154_llsec_del_devkey),
113− IEEE802154_DUMP(IEEE802154_LLSEC_LIST_SECLEVEL, NULL,
114− ieee802154_llsec_dump_seclevels),
115− IEEE802154_OP(IEEE802154_LLSEC_ADD_SECLEVEL,
116− ieee802154_llsec_add_seclevel),
117− IEEE802154_OP(IEEE802154_LLSEC_DEL_SECLEVEL,
118− ieee802154_llsec_del_seclevel),
101+ IEEE802154_DUMP_PRIV(IEEE802154_LLSEC_LIST_KEY, NULL,
102+ ieee802154_llsec_dump_keys),
103+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_ADD_KEY, ieee802154_llsec_add_key),
104+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_DEL_KEY, ieee802154_llsec_del_key),
105+ IEEE802154_DUMP_PRIV(IEEE802154_LLSEC_LIST_DEV, NULL,
106+ ieee802154_llsec_dump_devs),
107+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_ADD_DEV, ieee802154_llsec_add_dev),
108+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_DEL_DEV, ieee802154_llsec_del_dev),
109+ IEEE802154_DUMP_PRIV(IEEE802154_LLSEC_LIST_DEVKEY, NULL,
110+ ieee802154_llsec_dump_devkeys),
111+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_ADD_DEVKEY, ieee802154_llsec_add_devkey),
112+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_DEL_DEVKEY, ieee802154_llsec_del_devkey),
113+ IEEE802154_DUMP_PRIV(IEEE802154_LLSEC_LIST_SECLEVEL, NULL,
114+ ieee802154_llsec_dump_seclevels),
115+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_ADD_SECLEVEL,
116+ ieee802154_llsec_add_seclevel),
117+ IEEE802154_OP_RELAXED(IEEE802154_LLSEC_DEL_SECLEVEL,
118+ ieee802154_llsec_del_seclevel),
119119 };
120120
121121 static const struct genl_multicast_group ieee802154_mcgrps[] = {
net/ipv4/ip_gre.c+6−0
@@ -1457,6 +1457,9 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[], · 1456 unmodified lines
14571457 __u32 fwmark = t->fwmark;
14581458 int err;
14591459
1460+ if (!rtnl_dev_link_net_capable(dev, t->net))
1461+ return -EPERM;
1462+
14601463 err = ipgre_newlink_encap_setup(dev, data);
14611464 if (err)
14621465 return err;
@@ -1486,6 +1489,9 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[], · 23 unmodified lines
14861489 __u32 fwmark = t->fwmark;
14871490 int err;
14881491
1492+ if (!rtnl_dev_link_net_capable(dev, t->net))
1493+ return -EPERM;
1494+
14891495 err = ipgre_newlink_encap_setup(dev, data);
14901496 if (err)
14911497 return err;
net/ipv4/ip_output.c+2−5
@@ -1116,8 +1116,8 @@ alloc_new_skb: · 1115 unmodified lines
11161116 !(rt->dst.dev->features & NETIF_F_SG)))
11171117 alloclen = fraglen;
11181118 else {
1119− alloclen = fragheaderlen + transhdrlen;
1120− pagedlen = datalen - transhdrlen;
1119+ alloclen = fragheaderlen + transhdrlen + fraggap;
1120+ pagedlen = datalen - transhdrlen - fraggap;
11211121 }
11221122
11231123 alloclen += alloc_extra;
@@ -1164,9 +1164,6 @@ alloc_new_skb: · 40 unmodified lines
11641164 }
11651165
11661166 copy = datalen - transhdrlen - fraggap - pagedlen;
1167− /* [!] NOTE: copy will be negative if pagedlen>0
1168− * because then the equation reduces to -fraggap.
1169− */
11701167 if (copy > 0 &&
11711168 INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
11721169 from, data + transhdrlen, offset,
net/ipv4/ip_vti.c+3−0
@@ -596,6 +596,9 @@ static int vti_changelink(struct net_device *dev, struct nlattr *tb[], · 595 unmodified lines
596596 struct ip_tunnel_parm_kern p;
597597 __u32 fwmark = t->fwmark;
598598
599+ if (!rtnl_dev_link_net_capable(dev, t->net))
600+ return -EPERM;
601+
599602 vti_netlink_parms(data, &p, &fwmark);
600603 return ip_tunnel_changelink(dev, tb, &p, fwmark);
601604 }
net/ipv4/ipip.c+3−0
@@ -494,6 +494,9 @@ static int ipip_changelink(struct net_device *dev, struct nlattr *tb[], · 493 unmodified lines
494494 bool collect_md;
495495 __u32 fwmark = t->fwmark;
496496
497+ if (!rtnl_dev_link_net_capable(dev, t->net))
498+ return -EPERM;
499+
497500 if (ip_tunnel_netlink_encap_parms(data, &ipencap)) {
498501 int err = ip_tunnel_encap_setup(t, &ipencap);
499502
net/ipv4/netfilter/nf_reject_ipv4.c+1−1
@@ -89,7 +89,7 @@ static bool nf_skb_is_icmp_unreach(const struct sk_buff *skb) · 88 unmodified lines
8989 if (iph->protocol != IPPROTO_ICMP)
9090 return false;
9191
92− thoff = skb_network_offset(skb) + sizeof(*iph);
92+ thoff = skb_network_offset(skb) + ip_hdrlen(skb);
9393
9494 tp = skb_header_pointer(skb,
9595 thoff + offsetof(struct icmphdr, type),
net/ipv4/sysctl_net_ipv4.c+8−2
@@ -1058,7 +1058,9 @@ static struct ctl_table ipv4_net_table[] = { · 1057 unmodified lines
10581058 .data = &init_net.ipv4.sysctl_tcp_reordering,
10591059 .maxlen = sizeof(int),
10601060 .mode = 0644,
1061− .proc_handler = proc_dointvec
1061+ .proc_handler = proc_dointvec_minmax,
1062+ .extra1 = SYSCTL_ONE,
1063+ .extra2 = &init_net.ipv4.sysctl_tcp_max_reordering,
10621064 },
10631065 {
10641066 .procname = "tcp_retries1",
@@ -1293,7 +1295,8 @@ static struct ctl_table ipv4_net_table[] = { · 228 unmodified lines
12931295 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
12941296 .maxlen = sizeof(int),
12951297 .mode = 0644,
1296− .proc_handler = proc_dointvec
1298+ .proc_handler = proc_dointvec_minmax,
1299+ .extra1 = SYSCTL_ONE,
12971300 },
12981301 {
12991302 .procname = "tcp_dsack",
@@ -1676,6 +1679,9 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) · 376 unmodified lines
16761679 */
16771680 table[i].mode &= ~0222;
16781681 }
1682+ if (table[i].extra2 >= (void *)&init_net.ipv4 &&
1683+ table[i].extra2 < (void *)(&init_net.ipv4 + 1))
1684+ table[i].extra2 += (void *)net - (void *)&init_net;
16791685 }
16801686 }
16811687
net/ipv4/tcp_ao.c+4−0
@@ -1747,6 +1747,10 @@ static int tcp_ao_delete_key(struct sock *sk, struct tcp_ao_info *ao_info, · 1746 unmodified lines
17471747 * them and we can just free all resources in RCU fashion.
17481748 */
17491749 if (del_async) {
1750+ if (ao_info->current_key == key)
1751+ WRITE_ONCE(ao_info->current_key, NULL);
1752+ if (ao_info->rnext_key == key)
1753+ WRITE_ONCE(ao_info->rnext_key, NULL);
17501754 atomic_sub(tcp_ao_sizeof_key(key), &sk->sk_omem_alloc);
17511755 call_rcu(&key->rcu, tcp_ao_key_free_rcu);
17521756 return 0;
net/ipv4/tcp_output.c+2−2
@@ -2688,7 +2688,7 @@ static int tcp_mtu_probe(struct sock *sk) · 2687 unmodified lines
26882688 struct sk_buff *skb, *nskb, *next;
26892689 struct net *net = sock_net(sk);
26902690 int probe_size;
2691− int size_needed;
2691+ u64 size_needed;
26922692 int copy, len;
26932693 int mss_now;
26942694 int interval;
@@ -2712,7 +2712,7 @@ static int tcp_mtu_probe(struct sock *sk) · 17 unmodified lines
27122712 mss_now = tcp_current_mss(sk);
27132713 probe_size = tcp_mtu_to_mss(sk, (icsk->icsk_mtup.search_high +
27142714 icsk->icsk_mtup.search_low) >> 1);
2715− size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache;
2715+ size_needed = probe_size + (tp->reordering + 1) * (u64)tp->mss_cache;
27162716 interval = icsk->icsk_mtup.search_high - icsk->icsk_mtup.search_low;
27172717 /* When misfortune happens, we are reprobing actively,
27182718 * and then reprobe timer has expired. We stick with current
net/ipv4/udp_tunnel_nic.c+1−1
@@ -301,7 +301,7 @@ __udp_tunnel_nic_device_sync(struct net_device *dev, struct udp_tunnel_nic *utn) · 300 unmodified lines
301301 static void
302302 udp_tunnel_nic_device_sync(struct net_device *dev, struct udp_tunnel_nic *utn)
303303 {
304− if (!utn->need_sync)
304+ if (!utn->need_sync || utn->work_pending)
305305 return;
306306
307307 queue_work(udp_tunnel_nic_workqueue, &utn->work);
net/ipv4/xfrm4_input.c+0−2
@@ -76,8 +76,6 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async) · 75 unmodified lines
7676 NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
7777 dev_net(dev), NULL, skb, dev, NULL,
7878 xfrm4_rcv_encap_finish);
79− if (async)
80− dev_put(dev);
8179 return 0;
8280 }
8381
net/ipv6/addrconf.c+28−14
@@ -913,7 +913,7 @@ static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, int · 912 unmodified lines
913913
914914 if (newf)
915915 rt6_purge_dflt_routers(net);
916− return 1;
916+ return 0;
917917 }
918918
919919 static void addrconf_linkdown_change(struct net *net, __s32 newf)
@@ -955,11 +955,7 @@ static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int ne · 35 unmodified lines
955955 NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
956956 NETCONFA_IFINDEX_DEFAULT,
957957 net->ipv6.devconf_dflt);
958− rtnl_net_unlock(net);
959− return 0;
960− }
961−
962− if (p == &net->ipv6.devconf_all->ignore_routes_with_linkdown) {
958+ } else if (p == &net->ipv6.devconf_all->ignore_routes_with_linkdown) {
963959 WRITE_ONCE(net->ipv6.devconf_dflt->ignore_routes_with_linkdown, newf);
964960 addrconf_linkdown_change(net, newf);
965961 if ((!newf) ^ (!old))
@@ -968,11 +964,21 @@ static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int ne · 2 unmodified lines
968964 NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
969965 NETCONFA_IFINDEX_ALL,
970966 net->ipv6.devconf_all);
967+ } else {
968+ if (!newf ^ !old) {
969+ struct inet6_dev *idev = table->extra1;
970+
971+ inet6_netconf_notify_devconf(net,
972+ RTM_NEWNETCONF,
973+ NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
974+ idev->dev->ifindex,
975+ &idev->cnf);
976+ }
971977 }
972978
973979 rtnl_net_unlock(net);
974980
975− return 1;
981+ return 0;
976982 }
977983
978984 #endif
@@ -6370,6 +6376,8 @@ static int addrconf_sysctl_forward(const struct ctl_table *ctl, int write, · 5391 unmodified lines
63706376 lctl.data = &val;
63716377
63726378 ret = proc_dointvec(&lctl, write, buffer, lenp, ppos);
6379+ if (ret)
6380+ return ret;
63736381
63746382 if (write)
63756383 ret = addrconf_fixup_forwarding(ctl, valp, val);
@@ -6467,6 +6475,8 @@ static int addrconf_sysctl_disable(const struct ctl_table *ctl, int write, · 91 unmodified lines
64676475 lctl.data = &val;
64686476
64696477 ret = proc_dointvec(&lctl, write, buffer, lenp, ppos);
6478+ if (ret)
6479+ return ret;
64706480
64716481 if (write)
64726482 ret = addrconf_disable_ipv6(ctl, valp, val);
@@ -6478,20 +6488,19 @@ static int addrconf_sysctl_disable(const struct ctl_table *ctl, int write, · 5 unmodified lines
64786488 static int addrconf_sysctl_proxy_ndp(const struct ctl_table *ctl, int write,
64796489 void *buffer, size_t *lenp, loff_t *ppos)
64806490 {
6491+ struct net *net = ctl->extra2;
64816492 int *valp = ctl->data;
6482− int ret;
64836493 int old, new;
6494+ int ret;
6495+
6496+ if (write && !rtnl_net_trylock(net))
6497+ return restart_syscall();
64846498
64856499 old = *valp;
64866500 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
64876501 new = *valp;
64886502
64896503 if (write && old != new) {
6490− struct net *net = ctl->extra2;
6491−
6492− if (!rtnl_net_trylock(net))
6493− return restart_syscall();
6494−
64956504 if (valp == &net->ipv6.devconf_dflt->proxy_ndp) {
64966505 inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
64976506 NETCONFA_PROXY_NEIGH,
@@ -6510,8 +6519,9 @@ static int addrconf_sysctl_proxy_ndp(const struct ctl_table *ctl, int write, · 12 unmodified lines
65106519 idev->dev->ifindex,
65116520 &idev->cnf);
65126521 }
6513− rtnl_net_unlock(net);
65146522 }
6523+ if (write)
6524+ rtnl_net_unlock(net);
65156525
65166526 return ret;
65176527 }
@@ -6669,6 +6679,8 @@ int addrconf_sysctl_ignore_routes_with_linkdown(const struct ctl_table *ctl, · 151 unmodified lines
66696679 lctl.data = &val;
66706680
66716681 ret = proc_dointvec(&lctl, write, buffer, lenp, ppos);
6682+ if (ret)
6683+ return ret;
66726684
66736685 if (write)
66746686 ret = addrconf_fixup_linkdown(ctl, valp, val);
@@ -6763,6 +6775,8 @@ static int addrconf_sysctl_disable_policy(const struct ctl_table *ctl, int write · 88 unmodified lines
67636775 lctl = *ctl;
67646776 lctl.data = &val;
67656777 ret = proc_dointvec(&lctl, write, buffer, lenp, ppos);
6778+ if (ret)
6779+ return ret;
67666780
67676781 if (write && (*valp != val))
67686782 ret = addrconf_disable_policy(ctl, valp, val);
net/ipv6/ioam6_iptunnel.c+4−4
@@ -35,7 +35,7 @@ struct ioam6_lwt_freq { · 34 unmodified lines
3535 };
3636
3737 struct ioam6_lwt {
38− struct dst_entry null_dst;
38+ struct rt6_info null_rt;
3939 struct dst_cache cache;
4040 struct ioam6_lwt_freq freq;
4141 atomic_t pkt_cnt;
@@ -176,7 +176,7 @@ static int ioam6_build_state(struct net *net, struct nlattr *nla, · 134 unmodified lines
176176 * it is stored in the cache. Then, +1/-1 each time we read the cache
177177 * and release it. Long story short, we're fine.
178178 */
179− dst_init(&ilwt->null_dst, NULL, NULL, DST_OBSOLETE_NONE, DST_NOCOUNT);
179+ dst_init(&ilwt->null_rt.dst, NULL, NULL, DST_OBSOLETE_NONE, DST_NOCOUNT);
180180
181181 atomic_set(&ilwt->pkt_cnt, 0);
182182 ilwt->freq.k = freq_k;
@@ -360,7 +360,7 @@ static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb) · 177 unmodified lines
360360 /* This is how we notify that the destination does not change after
361361 * transformation and that we need to use orig_dst instead of the cache
362362 */
363− if (dst == &ilwt->null_dst) {
363+ if (dst == &ilwt->null_rt.dst) {
364364 dst_release(dst);
365365
366366 dst = orig_dst;
@@ -429,7 +429,7 @@ do_encap: · 62 unmodified lines
429429 local_bh_disable();
430430 if (orig_dst->lwtstate == dst->lwtstate)
431431 dst_cache_set_ip6(&ilwt->cache,
432− &ilwt->null_dst, &fl6.saddr);
432+ &ilwt->null_rt.dst, &fl6.saddr);
433433 else
434434 dst_cache_set_ip6(&ilwt->cache, dst, &fl6.saddr);
435435 local_bh_enable();
net/ipv6/ip6_gre.c+6−0
@@ -2047,6 +2047,9 @@ static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], · 2046 unmodified lines
20472047 struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id);
20482048 struct __ip6_tnl_parm p;
20492049
2050+ if (!rtnl_dev_link_net_capable(dev, t->net))
2051+ return -EPERM;
2052+
20502053 t = ip6gre_changelink_common(dev, tb, data, &p, extack);
20512054 if (IS_ERR(t))
20522055 return PTR_ERR(t);
@@ -2266,6 +2269,9 @@ static int ip6erspan_changelink(struct net_device *dev, struct nlattr *tb[], · 213 unmodified lines
22662269 struct __ip6_tnl_parm p;
22672270 struct ip6gre_net *ign;
22682271
2272+ if (!rtnl_dev_link_net_capable(dev, t->net))
2273+ return -EPERM;
2274+
22692275 ign = net_generic(t->net, ip6gre_net_id);
22702276 t = ip6gre_changelink_common(dev, tb, data, &p, extack);
22712277 if (IS_ERR(t))
net/ipv6/ip6_output.c+3−6
@@ -1667,8 +1667,8 @@ alloc_new_skb: · 1666 unmodified lines
16671667 !(rt->dst.dev->features & NETIF_F_SG)))
16681668 alloclen = fraglen;
16691669 else {
1670− alloclen = fragheaderlen + transhdrlen;
1671− pagedlen = datalen - transhdrlen;
1670+ alloclen = fragheaderlen + transhdrlen + fraggap;
1671+ pagedlen = datalen - transhdrlen - fraggap;
16721672 }
16731673 alloclen += alloc_extra;
16741674
@@ -1683,10 +1683,7 @@ alloc_new_skb: · 8 unmodified lines
16831683 fraglen = datalen + fragheaderlen;
16841684
16851685 copy = datalen - transhdrlen - fraggap - pagedlen;
1686− /* [!] NOTE: copy may be negative if pagedlen>0
1687− * because then the equation may reduces to -fraggap.
1688− */
1689− if (copy < 0 && !(flags & MSG_SPLICE_PAGES)) {
1686+ if (copy < 0) {
16901687 err = -EINVAL;
16911688 goto error;
16921689 }
net/ipv6/ip6_tunnel.c+10−0
@@ -1851,6 +1851,13 @@ static int ip6_tnl_fill_forward_path(struct net_device_path_ctx *ctx, · 1850 unmodified lines
18511851 struct dst_entry *dst;
18521852 int err;
18531853
1854+ if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) {
1855+ /* encaplimit option is currently not supported is
1856+ * sw-acceleration path.
1857+ */
1858+ return -EOPNOTSUPP;
1859+ }
1860+
18541861 dst = ip6_route_output(dev_net(ctx->dev), NULL, &fl6);
18551862 if (!dst->error) {
18561863 path->type = DEV_PATH_TUN;
@@ -2103,6 +2110,9 @@ static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[], · 246 unmodified lines
21032110 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
21042111 struct ip_tunnel_encap ipencap;
21052112
2113+ if (!rtnl_dev_link_net_capable(dev, net))
2114+ return -EPERM;
2115+
21062116 if (dev == ip6n->fb_tnl_dev) {
21072117 if (ip_tunnel_netlink_encap_parms(data, &ipencap)) {
21082118 /* iproute2 always sets TUNNEL_ENCAP_FLAG_CSUM6, so
net/ipv6/ip6_vti.c+3−0
@@ -1046,6 +1046,9 @@ static int vti6_changelink(struct net_device *dev, struct nlattr *tb[], · 1045 unmodified lines
10461046 struct __ip6_tnl_parm p;
10471047 struct vti6_net *ip6n;
10481048
1049+ if (!rtnl_dev_link_net_capable(dev, net))
1050+ return -EPERM;
1051+
10491052 ip6n = net_generic(net, vti6_net_id);
10501053 if (dev == ip6n->fb_tnl_dev)
10511054 return -EINVAL;
net/ipv6/ndisc.c+3−5
@@ -967,10 +967,8 @@ out: · 966 unmodified lines
967967 return reason;
968968 }
969969
970−static int accept_untracked_na(struct net_device *dev, struct in6_addr *saddr)
970+static int accept_untracked_na(struct inet6_dev *idev, struct in6_addr *saddr)
971971 {
972− struct inet6_dev *idev = __in6_dev_get(dev);
973−
974972 switch (READ_ONCE(idev->cnf.accept_untracked_na)) {
975973 case 0: /* Don't accept untracked na (absent in neighbor cache) */
976974 return 0;
@@ -980,7 +978,7 @@ static int accept_untracked_na(struct net_device *dev, struct in6_addr *saddr) · 3 unmodified lines
980978 * same subnet as an address configured on the interface that
981979 * received the na
982980 */
983− return !!ipv6_chk_prefix(saddr, dev);
981+ return !!ipv6_chk_prefix(saddr, idev->dev);
984982 default:
985983 return 0;
986984 }
@@ -1078,7 +1076,7 @@ static enum skb_drop_reason ndisc_recv_na(struct sk_buff *skb) · 91 unmodified lines
10781076 */
10791077 new_state = msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE;
10801078 if (!neigh && lladdr && idev && READ_ONCE(idev->cnf.forwarding)) {
1081− if (accept_untracked_na(dev, saddr)) {
1079+ if (accept_untracked_na(idev, saddr)) {
10821080 neigh = neigh_create(&nd_tbl, &msg->target, dev);
10831081 new_state = NUD_STALE;
10841082 }
net/ipv6/route.c+3−0
@@ -5055,6 +5055,9 @@ static int fib6_nh_mtu_change(struct fib6_nh *nh, void *_arg) · 5054 unmodified lines
50555055 struct inet6_dev *idev = __in6_dev_get(arg->dev);
50565056 u32 mtu = f6i->fib6_pmtu;
50575057
5058+ if (!idev)
5059+ return 0;
5060+
50585061 if (mtu >= arg->mtu ||
50595062 (mtu < arg->mtu && mtu == idev->cnf.mtu6))
50605063 fib6_metric_set(f6i, RTAX_MTU, arg->mtu);
net/ipv6/sit.c+3−0
@@ -1613,6 +1613,9 @@ static int ipip6_changelink(struct net_device *dev, struct nlattr *tb[], · 1612 unmodified lines
16131613 __u32 fwmark = t->fwmark;
16141614 int err;
16151615
1616+ if (!rtnl_dev_link_net_capable(dev, net))
1617+ return -EPERM;
1618+
16161619 if (dev == sitn->fb_tunnel_dev)
16171620 return -EINVAL;
16181621
net/ipv6/xfrm6_input.c+0−2
@@ -71,8 +71,6 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async) · 70 unmodified lines
7171 NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
7272 dev_net(dev), NULL, skb, dev, NULL,
7373 xfrm6_transport_finish2);
74− if (async)
75− dev_put(dev);
7674 return 0;
7775 }
7876
net/key/af_key.c+1−0
@@ -1218,6 +1218,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net, · 1217 unmodified lines
12181218 goto out;
12191219 }
12201220 strcpy(x->calg->alg_name, a->name);
1221+ x->calg->alg_key_len = 0;
12211222 x->props.calgo = sa->sadb_sa_encrypt;
12221223 } else {
12231224 int keysize = 0;
net/llc/sysctl_net_llc.c+1−1
@@ -47,7 +47,7 @@ static struct ctl_table_header *llc_station_header; · 46 unmodified lines
4747
4848 int __init llc_sysctl_init(void)
4949 {
50− struct ctl_table empty[1] = {};
50+ static struct ctl_table empty[1] = {};
5151 llc2_timeout_header = register_net_sysctl(&init_net, "net/llc/llc2/timeout", llc2_timeout_table);
5252 llc_station_header = register_net_sysctl_sz(&init_net, "net/llc/station", empty, 0);
5353
net/mac802154/llsec.c+14−0
@@ -710,6 +710,7 @@ int mac802154_llsec_encrypt(struct mac802154_llsec *sec, struct sk_buff *skb) · 709 unmodified lines
710710 {
711711 struct ieee802154_hdr hdr;
712712 int rc, authlen, hlen;
713+ struct sk_buff *trailer;
713714 struct mac802154_llsec_key *key;
714715 u32 frame_ctr;
715716
@@ -769,6 +770,12 @@ int mac802154_llsec_encrypt(struct mac802154_llsec *sec, struct sk_buff *skb) · 53 unmodified lines
769770 skb->mac_len = ieee802154_hdr_push(skb, &hdr);
770771 skb_reset_mac_header(skb);
771772
773+ rc = skb_cow_data(skb, 0, &trailer);
774+ if (rc < 0) {
775+ llsec_key_put(key);
776+ return rc;
777+ }
778+
772779 rc = llsec_do_encrypt(skb, sec, &hdr, key);
773780 llsec_key_put(key);
774781
@@ -908,6 +915,13 @@ llsec_do_decrypt(struct sk_buff *skb, const struct mac802154_llsec *sec, · 133 unmodified lines
908915 const struct ieee802154_hdr *hdr,
909916 struct mac802154_llsec_key *key, __le64 dev_addr)
910917 {
918+ struct sk_buff *trailer;
919+ int err;
920+
921+ err = skb_cow_data(skb, 0, &trailer);
922+ if (err < 0)
923+ return err;
924+
911925 if (hdr->sec.level == IEEE802154_SCF_SECLEVEL_ENC)
912926 return llsec_do_decrypt_unauth(skb, sec, hdr, key, dev_addr);
913927 else
net/mac802154/scan.c+1−0
@@ -594,6 +594,7 @@ int mac802154_perform_association(struct ieee802154_sub_if_data *sdata, · 593 unmodified lines
594594 "Negative ASSOC RESP received from %8phC: %s\n", &ceaddr,
595595 local->assoc_status == IEEE802154_PAN_AT_CAPACITY ?
596596 "PAN at capacity" : "access denied");
597+ goto clear_assoc;
597598 }
598599
599600 ret = 0;
net/netfilter/Kconfig+6−5
@@ -256,8 +256,7 @@ config NF_CONNTRACK_H323 · 255 unmodified lines
256256 To compile it as a module, choose M here. If unsure, say N.
257257
258258 config NF_CONNTRACK_IRC
259− tristate "IRC protocol support"
260− default m if NETFILTER_ADVANCED=n
259+ tristate "IRC DCC protocol support (obsolete)"
261260 help
262261 There is a commonly-used extension to IRC called
263262 Direct Client-to-Client Protocol (DCC). This enables users to send
@@ -267,6 +266,8 @@ config NF_CONNTRACK_IRC · 3 unmodified lines
267266 using NAT, this extension will enable you to send files and initiate
268267 chats. Note that you do NOT need this extension to get files or
269268 have others initiate chats, or everything else in IRC.
269+ DCC tracking behind NAT requires plaintext (unencrypted) IRC, so
270+ this helper is of limited use these days.
270271
271272 To compile it as a module, choose M here. If unsure, say N.
272273
@@ -308,17 +309,17 @@ config NF_CONNTRACK_SNMP · 35 unmodified lines
308309 To compile it as a module, choose M here. If unsure, say N.
309310
310311 config NF_CONNTRACK_PPTP
311− tristate "PPtP protocol support"
312+ tristate "PPtP protocol support (deprecated)"
312313 depends on NETFILTER_ADVANCED
313314 select NF_CT_PROTO_GRE
314315 help
315316 This module adds support for PPTP (Point to Point Tunnelling
316317 Protocol, RFC2637) connection tracking and NAT.
317318
318− If you are running PPTP sessions over a stateful firewall or NAT
319+ If you are still running PPTP sessions over a stateful firewall or NAT
319320 box, you may want to enable this feature.
320321
321− Please note that not all PPTP modes of operation are supported yet.
322+ Please note that not all PPTP modes of operation are supported.
322323 Specifically these limitations exist:
323324 - Blindly assumes that control connections are always established
324325 in PNS->PAC direction. This is a violation of RFC2637.
net/netfilter/ipset/ip_set_bitmap_gen.h+3−1
@@ -165,6 +165,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext, · 164 unmodified lines
165165 ip_set_init_skbinfo(ext_skbinfo(x, set), ext);
166166
167167 /* Activate element */
168+ smp_mb__before_atomic();
168169 set_bit(e->id, map->members);
169170 set->elements++;
170171
@@ -219,7 +220,7 @@ mtype_list(const struct ip_set *set, · 48 unmodified lines
219220 cond_resched_rcu();
220221 id = cb->args[IPSET_CB_ARG0];
221222 x = get_ext(set, map, id);
222− if (!test_bit(id, map->members) ||
223+ if (!test_bit_acquire(id, map->members) ||
223224 (SET_WITH_TIMEOUT(set) &&
224225 #ifdef IP_SET_BITMAP_STORED_TIMEOUT
225226 mtype_is_filled(x) &&
@@ -278,6 +279,7 @@ mtype_gc(struct timer_list *t) · 52 unmodified lines
278279 x = get_ext(set, map, id);
279280 if (ip_set_timeout_expired(ext_timeout(x, set))) {
280281 clear_bit(id, map->members);
282+ smp_mb__after_atomic();
281283 ip_set_ext_destroy(set, x);
282284 set->elements--;
283285 }
net/netfilter/ipset/ip_set_bitmap_ip.c+1−1
@@ -67,7 +67,7 @@ static int · 66 unmodified lines
6767 bitmap_ip_do_test(const struct bitmap_ip_adt_elem *e,
6868 struct bitmap_ip *map, size_t dsize)
6969 {
70− return !!test_bit(e->id, map->members);
70+ return !!test_bit_acquire(e->id, map->members);
7171 }
7272
7373 static int
net/netfilter/ipset/ip_set_bitmap_ipmac.c+1−1
@@ -86,7 +86,7 @@ bitmap_ipmac_do_test(const struct bitmap_ipmac_adt_elem *e, · 85 unmodified lines
8686 {
8787 const struct bitmap_ipmac_elem *elem;
8888
89− if (!test_bit(e->id, map->members))
89+ if (!test_bit_acquire(e->id, map->members))
9090 return 0;
9191 elem = get_const_elem(map->extensions, e->id, dsize);
9292 if (e->add_mac && elem->filled == MAC_FILLED)
net/netfilter/ipset/ip_set_bitmap_port.c+1−1
@@ -58,7 +58,7 @@ static int · 57 unmodified lines
5858 bitmap_port_do_test(const struct bitmap_port_adt_elem *e,
5959 const struct bitmap_port *map, size_t dsize)
6060 {
61− return !!test_bit(e->id, map->members);
61+ return !!test_bit_acquire(e->id, map->members);
6262 }
6363
6464 static int
net/netfilter/ipset/ip_set_core.c+2−2
@@ -351,8 +351,8 @@ ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment, · 350 unmodified lines
351351
352352 if (unlikely(c)) {
353353 set->ext_size -= sizeof(*c) + strlen(c->str) + 1;
354− kfree_rcu(c, rcu);
355354 rcu_assign_pointer(comment->c, NULL);
355+ kfree_rcu(c, rcu);
356356 }
357357 if (!len)
358358 return;
@@ -393,8 +393,8 @@ ip_set_comment_free(struct ip_set *set, void *ptr) · 34 unmodified lines
393393 if (unlikely(!c))
394394 return;
395395 set->ext_size -= sizeof(*c) + strlen(c->str) + 1;
396− kfree_rcu(c, rcu);
397396 rcu_assign_pointer(comment->c, NULL);
397+ kfree_rcu(c, rcu);
398398 }
399399
400400 typedef void (*destroyer)(struct ip_set *, void *);
net/netfilter/ipset/ip_set_hash_gen.h+6−6
@@ -606,7 +606,7 @@ mtype_cancel_gc(struct ip_set *set) · 605 unmodified lines
606606 struct htype *h = set->data;
607607
608608 if (SET_WITH_TIMEOUT(set))
609− cancel_delayed_work_sync(&h->gc.dwork);
609+ disable_delayed_work_sync(&h->gc.dwork);
610610 }
611611
612612 static int
@@ -689,7 +689,7 @@ retry: · 76 unmodified lines
689689 continue;
690690 pos = smp_load_acquire(&n->pos);
691691 for (j = 0; j < pos; j++) {
692− if (!test_bit(j, n->used))
692+ if (!test_bit_acquire(j, n->used))
693693 continue;
694694 data = ahash_data(n, j, dsize);
695695 if (SET_ELEM_EXPIRED(set, data))
@@ -826,7 +826,7 @@ mtype_ext_size(struct ip_set *set, u32 *elements, size_t *ext_size) · 130 unmodified lines
826826 continue;
827827 pos = smp_load_acquire(&n->pos);
828828 for (j = 0; j < pos; j++) {
829− if (!test_bit(j, n->used))
829+ if (!test_bit_acquire(j, n->used))
830830 continue;
831831 data = ahash_data(n, j, set->dsize);
832832 if (!SET_ELEM_EXPIRED(set, data))
@@ -1201,7 +1201,7 @@ mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d, · 368 unmodified lines
12011201 continue;
12021202 pos = smp_load_acquire(&n->pos);
12031203 for (i = 0; i < pos; i++) {
1204− if (!test_bit(i, n->used))
1204+ if (!test_bit_acquire(i, n->used))
12051205 continue;
12061206 data = ahash_data(n, i, set->dsize);
12071207 if (!mtype_data_equal(data, d, &multi))
@@ -1259,7 +1259,7 @@ mtype_test(struct ip_set *set, void *value, const struct ip_set_ext *ext, · 51 unmodified lines
12591259 }
12601260 pos = smp_load_acquire(&n->pos);
12611261 for (i = 0; i < pos; i++) {
1262− if (!test_bit(i, n->used))
1262+ if (!test_bit_acquire(i, n->used))
12631263 continue;
12641264 data = ahash_data(n, i, set->dsize);
12651265 if (!mtype_data_equal(data, d, &multi))
@@ -1396,7 +1396,7 @@ mtype_list(const struct ip_set *set, · 130 unmodified lines
13961396 continue;
13971397 pos = smp_load_acquire(&n->pos);
13981398 for (i = 0; i < pos; i++) {
1399− if (!test_bit(i, n->used))
1399+ if (!test_bit_acquire(i, n->used))
14001400 continue;
14011401 e = ahash_data(n, i, set->dsize);
14021402 if (SET_ELEM_EXPIRED(set, e))
net/netfilter/nf_conncount.c+5−6
@@ -183,17 +183,16 @@ static int __nf_conncount_add(struct net *net, · 182 unmodified lines
183183 return -ENOENT;
184184
185185 if (ct && nf_ct_is_confirmed(ct)) {
186− /* local connections are confirmed in postrouting so confirmation
187− * might have happened before hitting connlimit
186+ /* Connection is confirmed but might still be in the setup phase.
187+ * Only skip the tracking if it is fully assured. This guarantees
188+ * that setup packets or retransmissions are properly counted and
189+ * deduplicated.
188190 */
189− if (skb->skb_iif != LOOPBACK_IFINDEX) {
191+ if (test_bit(IPS_ASSURED_BIT, &ct->status)) {
190192 err = -EEXIST;
191193 goto out_put;
192194 }
193195
194− /* this is likely a local connection, skip optimization to avoid
195− * adding duplicates from a 'packet train'
196− */
197196 goto check_connections;
198197 }
199198
net/netfilter/nf_conntrack_broadcast.c+1−0
@@ -62,6 +62,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb, · 61 unmodified lines
6262 if (exp == NULL)
6363 goto out;
6464
65+ exp->master_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
6566 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
6667
6768 helper = rcu_dereference(help->helper);
net/netfilter/nf_conntrack_core.c+32−1
@@ -1471,6 +1471,31 @@ static bool gc_worker_can_early_drop(const struct nf_conn *ct) · 1470 unmodified lines
14711471 return false;
14721472 }
14731473
1474+static void nf_ct_help_gc(struct nf_conn *ct)
1475+{
1476+ struct nf_conn_help *help;
1477+
1478+ if (!refcount_inc_not_zero(&ct->ct_general.use))
1479+ return;
1480+
1481+ /* load ->status after refcount increase */
1482+ smp_acquire__after_ctrl_dep();
1483+
1484+ if (!nf_ct_is_confirmed(ct) || nf_ct_is_dying(ct)) {
1485+ nf_ct_put(ct);
1486+ return;
1487+ }
1488+
1489+ /* re-check helper due to SLAB_TYPESAFE_BY_RCU */
1490+ if (test_bit(IPS_HELPER_BIT, &ct->status)) {
1491+ help = nfct_help(ct);
1492+ if (help)
1493+ nf_ct_expectation_gc(help);
1494+ }
1495+
1496+ nf_ct_put(ct);
1497+}
1498+
14741499 static void gc_worker(struct work_struct *work)
14751500 {
14761501 unsigned int i, hashsz, nf_conntrack_max95 = 0;
@@ -1543,7 +1568,13 @@ static void gc_worker(struct work_struct *work) · 66 unmodified lines
15431568 expires = (expires - (long)next_run) / ++count;
15441569 next_run += expires;
15451570
1546− if (nf_conntrack_max95 == 0 || gc_worker_skip_ct(tmp))
1571+ if (gc_worker_skip_ct(tmp))
1572+ continue;
1573+
1574+ if (test_bit(IPS_HELPER_BIT, &tmp->status))
1575+ nf_ct_help_gc(tmp);
1576+
1577+ if (nf_conntrack_max95 == 0)
15471578 continue;
15481579
15491580 net = nf_ct_net(tmp);
net/netfilter/nf_conntrack_expect.c+81−74
@@ -43,6 +43,24 @@ unsigned int nf_ct_expect_max __read_mostly; · 42 unmodified lines
4343 static struct kmem_cache *nf_ct_expect_cachep __read_mostly;
4444 static siphash_aligned_key_t nf_ct_expect_hashrnd;
4545
46+void nf_ct_expectation_gc(struct nf_conn_help *master_help)
47+{
48+ struct nf_conntrack_expect *exp;
49+ struct hlist_node *next;
50+
51+ if (hlist_empty(&master_help->expectations))
52+ return;
53+
54+ spin_lock_bh(&nf_conntrack_expect_lock);
55+ hlist_for_each_entry_safe(exp, next, &master_help->expectations, lnode) {
56+ if (!nf_ct_exp_is_expired(exp))
57+ continue;
58+
59+ nf_ct_unlink_expect(exp);
60+ }
61+ spin_unlock_bh(&nf_conntrack_expect_lock);
62+}
63+
4664 /* nf_conntrack_expect helper functions */
4765 void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
4866 u32 portid, int report)
@@ -52,7 +70,6 @@ void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp, · 3 unmodified lines
5270 struct nf_conntrack_net *cnet;
5371
5472 lockdep_nfct_expect_lock_held();
55− WARN_ON_ONCE(timer_pending(&exp->timeout));
5673
5774 hlist_del_rcu(&exp->hnode);
5875
@@ -70,16 +87,6 @@ void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp, · 11 unmodified lines
7087 }
7188 EXPORT_SYMBOL_GPL(nf_ct_unlink_expect_report);
7289
73−static void nf_ct_expectation_timed_out(struct timer_list *t)
74−{
75− struct nf_conntrack_expect *exp = timer_container_of(exp, t, timeout);
76−
77− spin_lock_bh(&nf_conntrack_expect_lock);
78− nf_ct_unlink_expect(exp);
79− spin_unlock_bh(&nf_conntrack_expect_lock);
80− nf_ct_expect_put(exp);
81−}
82−
8390 static unsigned int nf_ct_expect_dst_hash(const struct net *n, const struct nf_conntrack_tuple *tuple)
8491 {
8592 struct {
@@ -117,19 +124,6 @@ nf_ct_exp_equal(const struct nf_conntrack_tuple *tuple, · 31 unmodified lines
117124 nf_ct_exp_zone_equal_any(i, zone);
118125 }
119126
120−bool nf_ct_remove_expect(struct nf_conntrack_expect *exp)
121−{
122− lockdep_nfct_expect_lock_held();
123−
124− if (timer_delete(&exp->timeout)) {
125− nf_ct_unlink_expect(exp);
126− nf_ct_expect_put(exp);
127− return true;
128− }
129− return false;
130−}
131−EXPORT_SYMBOL_GPL(nf_ct_remove_expect);
132−
133127 struct nf_conntrack_expect *
134128 __nf_ct_expect_find(struct net *net,
135129 const struct nf_conntrack_zone *zone,
@@ -144,6 +138,8 @@ __nf_ct_expect_find(struct net *net, · 8 unmodified lines
144138
145139 h = nf_ct_expect_dst_hash(net, tuple);
146140 hlist_for_each_entry_rcu(i, &nf_ct_expect_hash[h], hnode) {
141+ if (nf_ct_exp_is_expired(i))
142+ continue;
147143 if (nf_ct_exp_equal(tuple, i, zone, net))
148144 return i;
149145 }
@@ -178,6 +174,7 @@ nf_ct_find_expectation(struct net *net, · 28 unmodified lines
178174 {
179175 struct nf_conntrack_net *cnet = nf_ct_pernet(net);
180176 struct nf_conntrack_expect *i, *exp = NULL;
177+ struct hlist_node *next;
181178 unsigned int h;
182179
183180 lockdep_nfct_expect_lock_held();
@@ -186,7 +183,11 @@ nf_ct_find_expectation(struct net *net, · 2 unmodified lines
186183 return NULL;
187184
188185 h = nf_ct_expect_dst_hash(net, tuple);
189− hlist_for_each_entry(i, &nf_ct_expect_hash[h], hnode) {
186+ hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) {
187+ if (nf_ct_exp_is_expired(i)) {
188+ nf_ct_unlink_expect(i);
189+ continue;
190+ }
190191 if (!(i->flags & NF_CT_EXPECT_INACTIVE) &&
191192 nf_ct_exp_equal(tuple, i, zone, net)) {
192193 exp = i;
@@ -196,13 +197,16 @@ nf_ct_find_expectation(struct net *net, · 3 unmodified lines
196197 if (!exp)
197198 return NULL;
198199
200+ if (!refcount_inc_not_zero(&exp->use))
201+ return NULL;
202+
199203 /* If master is not in hash table yet (ie. packet hasn't left
200204 this machine yet), how can other end know about expected?
201205 Hence these are not the droids you are looking for (if
202206 master ct never got confirmed, we'd hold a reference to it
203207 and weird things would happen to future packets). */
204208 if (!nf_ct_is_confirmed(exp->master))
205− return NULL;
209+ goto err_release_exp;
206210
207211 /* Avoid race with other CPUs, that for exp->master ct, is
208212 * about to invoke ->destroy(), or nf_ct_delete() via timeout
@@ -214,18 +218,17 @@ nf_ct_find_expectation(struct net *net, · 5 unmodified lines
214218 */
215219 if (unlikely(nf_ct_is_dying(exp->master) ||
216220 !refcount_inc_not_zero(&exp->master->ct_general.use)))
217− return NULL;
221+ goto err_release_exp;
218222
219− if (exp->flags & NF_CT_EXPECT_PERMANENT || !unlink) {
220− refcount_inc(&exp->use);
223+ if (exp->flags & NF_CT_EXPECT_PERMANENT || !unlink)
221224 return exp;
222− } else if (timer_delete(&exp->timeout)) {
223− nf_ct_unlink_expect(exp);
224− return exp;
225− }
226− /* Undo exp->master refcnt increase, if timer_delete() failed */
227− nf_ct_put(exp->master);
228225
226+ nf_ct_unlink_expect(exp);
227+
228+ return exp;
229+
230+err_release_exp:
231+ nf_ct_expect_put(exp);
229232 return NULL;
230233 }
231234
@@ -241,9 +244,8 @@ void nf_ct_remove_expectations(struct nf_conn *ct) · 9 unmodified lines
241244 return;
242245
243246 spin_lock_bh(&nf_conntrack_expect_lock);
244− hlist_for_each_entry_safe(exp, next, &help->expectations, lnode) {
245− nf_ct_remove_expect(exp);
246− }
247+ hlist_for_each_entry_safe(exp, next, &help->expectations, lnode)
248+ nf_ct_unlink_expect(exp);
247249 spin_unlock_bh(&nf_conntrack_expect_lock);
248250 }
249251 EXPORT_SYMBOL_GPL(nf_ct_remove_expectations);
@@ -292,7 +294,7 @@ static bool master_matches(const struct nf_conntrack_expect *a, · 42 unmodified lines
292294 void nf_ct_unexpect_related(struct nf_conntrack_expect *exp)
293295 {
294296 spin_lock_bh(&nf_conntrack_expect_lock);
295− nf_ct_remove_expect(exp);
297+ WRITE_ONCE(exp->flags, exp->flags | NF_CT_EXPECT_DEAD);
296298 spin_unlock_bh(&nf_conntrack_expect_lock);
297299 }
298300 EXPORT_SYMBOL_GPL(nf_ct_unexpect_related);
@@ -308,6 +310,7 @@ struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me) · 9 unmodified lines
308310 if (!new)
309311 return NULL;
310312
313+ new->timeout = nfct_time_stamp;
311314 new->master = me;
312315 refcount_set(&new->use, 1);
313316 return new;
@@ -352,6 +355,8 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class, · 38 unmodified lines
352355 exp->tuple.src.l3num = family;
353356 exp->tuple.dst.protonum = proto;
354357
358+ exp->master_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
359+
355360 if (saddr) {
356361 memcpy(&exp->tuple.src.u3, saddr, len);
357362 if (sizeof(exp->tuple.src.u3) > len)
@@ -413,17 +418,12 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp, · 55 unmodified lines
413418 struct net *net = nf_ct_exp_net(exp);
414419 unsigned int h = nf_ct_expect_dst_hash(net, &exp->tuple);
415420
416− /* two references : one for hash insert, one for the timer */
417− refcount_add(2, &exp->use);
421+ refcount_inc(&exp->use);
418422
419− timer_setup(&exp->timeout, nf_ct_expectation_timed_out, 0);
420423 helper = rcu_dereference_protected(master_help->helper,
421424 lockdep_is_held(&nf_conntrack_expect_lock));
422− if (helper) {
423− exp->timeout.expires = jiffies +
424− helper->expect_policy[exp->class].timeout * HZ;
425− }
426− add_timer(&exp->timeout);
425+ if (helper)
426+ exp->timeout += helper->expect_policy[exp->class].timeout * HZ;
427427
428428 hlist_add_head_rcu(&exp->lnode, &master_help->expectations);
429429 master_help->expecting[exp->class]++;
@@ -435,19 +435,26 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp, · 5 unmodified lines
435435 NF_CT_STAT_INC(net, expect_create);
436436 }
437437
438−/* Race with expectations being used means we could have none to find; OK. */
439438 static void evict_oldest_expect(struct nf_conn_help *master_help,
440− struct nf_conntrack_expect *new)
439+ struct nf_conntrack_expect *new,
440+ const struct nf_conntrack_expect_policy *p)
441441 {
442442 struct nf_conntrack_expect *exp, *last = NULL;
443+ struct hlist_node *next;
443444
444− hlist_for_each_entry(exp, &master_help->expectations, lnode) {
445+ hlist_for_each_entry_safe(exp, next, &master_help->expectations, lnode) {
446+ if (nf_ct_exp_is_expired(exp)) {
447+ nf_ct_unlink_expect(exp);
448+ continue;
449+ }
445450 if (exp->class == new->class)
446451 last = exp;
447452 }
448453
449− if (last)
450− nf_ct_remove_expect(last);
454+ /* Still worth to evict oldest expectation after garbage collection? */
455+ if (last &&
456+ master_help->expecting[last->class] >= p->max_expected)
457+ nf_ct_unlink_expect(last);
451458 }
452459
453460 static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect,
@@ -467,14 +474,18 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect, · 13 unmodified lines
467474
468475 h = nf_ct_expect_dst_hash(net, &expect->tuple);
469476 hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) {
477+ if (nf_ct_exp_is_expired(i)) {
478+ nf_ct_unlink_expect(i);
479+ continue;
480+ }
470481 if (master_matches(i, expect, flags) &&
471482 expect_matches(i, expect)) {
472483 if (i->class != expect->class ||
473484 i->master != expect->master)
474485 return -EALREADY;
475486
476− if (nf_ct_remove_expect(i))
477− break;
487+ nf_ct_unlink_expect(i);
488+ break;
478489 } else if (expect_clash(i, expect)) {
479490 ret = -EBUSY;
480491 goto out;
@@ -485,15 +496,15 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect, · 4 unmodified lines
485496 lockdep_is_held(&nf_conntrack_expect_lock));
486497 if (helper) {
487498 p = &helper->expect_policy[expect->class];
488− if (p->max_expected &&
489− master_help->expecting[expect->class] >= p->max_expected) {
490− evict_oldest_expect(master_help, expect);
491− if (master_help->expecting[expect->class]
492− >= p->max_expected) {
493− ret = -EMFILE;
494− goto out;
495− }
496− }
499+ if (master_help->expecting[expect->class] >= p->max_expected)
500+ evict_oldest_expect(master_help, expect, p);
501+ } else {
502+ const struct nf_conntrack_expect_policy default_exp_policy = {
503+ .max_expected = NF_CT_EXPECT_MAX_CNT,
504+ };
505+
506+ if (master_help->expecting[expect->class] >= default_exp_policy.max_expected)
507+ evict_oldest_expect(master_help, expect, &default_exp_policy);
497508 }
498509
499510 cnet = nf_ct_pernet(net);
@@ -547,10 +558,8 @@ void nf_ct_expect_iterate_destroy(bool (*iter)(struct nf_conntrack_expect *e, vo · 47 unmodified lines
547558 hlist_for_each_entry_safe(exp, next,
548559 &nf_ct_expect_hash[i],
549560 hnode) {
550− if (iter(exp, data) && timer_delete(&exp->timeout)) {
561+ if (iter(exp, data))
551562 nf_ct_unlink_expect(exp);
552− nf_ct_expect_put(exp);
553− }
554563 }
555564 }
556565
@@ -577,10 +586,8 @@ void nf_ct_expect_iterate_net(struct net *net, · 20 unmodified lines
577586 if (!net_eq(nf_ct_exp_net(exp), net))
578587 continue;
579588
580− if (iter(exp, data) && timer_delete(&exp->timeout)) {
589+ if (iter(exp, data))
581590 nf_ct_unlink_expect_report(exp, portid, report);
582− nf_ct_expect_put(exp);
583− }
584591 }
585592 }
586593
@@ -657,17 +664,17 @@ static int exp_seq_show(struct seq_file *s, void *v) · 70 unmodified lines
657664 struct net *net = seq_file_net(s);
658665 struct hlist_node *n = v;
659666 char *delim = "";
667+ __s32 timeout;
660668
661669 expect = hlist_entry(n, struct nf_conntrack_expect, hnode);
662670
663671 if (!net_eq(nf_ct_exp_net(expect), net))
664672 return 0;
673+ if (nf_ct_exp_is_expired(expect))
674+ return 0;
665675
666− if (expect->timeout.function)
667− seq_printf(s, "%ld ", timer_pending(&expect->timeout)
668− ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
669− else
670− seq_puts(s, "- ");
676+ timeout = (__s32)(READ_ONCE(expect->timeout) - nfct_time_stamp) / HZ;
677+ seq_printf(s, "%d ", timeout > 0 ? timeout : 0);
671678 seq_printf(s, "l3proto = %u proto=%u ",
672679 expect->tuple.src.l3num,
673680 expect->tuple.dst.protonum);
net/netfilter/nf_conntrack_h323_main.c+2−2
@@ -1388,8 +1388,8 @@ static int process_rcf(struct sk_buff *skb, struct nf_conn *ct, · 1387 unmodified lines
13881388 "timeout to %u seconds for",
13891389 info->timeout);
13901390 nf_ct_dump_tuple(&exp->tuple);
1391− mod_timer_pending(&exp->timeout,
1392− jiffies + info->timeout * HZ);
1391+ WRITE_ONCE(exp->timeout,
1392+ nfct_time_stamp + (info->timeout * HZ));
13931393 }
13941394 spin_unlock_bh(&nf_conntrack_expect_lock);
13951395 }
net/netfilter/nf_conntrack_helper.c+11−8
@@ -181,10 +181,10 @@ nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp) · 180 unmodified lines
181181 struct nf_conn_help *help;
182182
183183 help = nf_ct_ext_add(ct, NF_CT_EXT_HELPER, gfp);
184− if (help)
184+ if (help) {
185+ __set_bit(IPS_HELPER_BIT, &ct->status);
185186 INIT_HLIST_HEAD(&help->expectations);
186− else
187− pr_debug("failed to add helper extension area");
187+ }
188188 return help;
189189 }
190190 EXPORT_SYMBOL_GPL(nf_ct_helper_ext_add);
@@ -203,10 +203,8 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, · 12 unmodified lines
203203 return 0;
204204
205205 help = nfct_help(tmpl);
206− if (help != NULL) {
206+ if (help)
207207 helper = rcu_dereference(help->helper);
208− set_bit(IPS_HELPER_BIT, &ct->status);
209− }
210208
211209 help = nfct_help(ct);
212210
@@ -376,8 +374,13 @@ int __nf_conntrack_helper_register(struct nf_conntrack_helper *me) · 163 unmodified lines
376374 if (!nf_ct_helper_hash)
377375 return -ENOENT;
378376
379− if (me->expect_policy->max_expected > NF_CT_EXPECT_MAX_CNT)
380− return -EINVAL;
377+ for (i = 0; i <= me->expect_class_max; i++) {
378+ if (!me->expect_policy[i].max_expected)
379+ me->expect_policy[i].max_expected = NF_CT_EXPECT_MAX_CNT;
380+
381+ if (me->expect_policy[i].max_expected > NF_CT_EXPECT_MAX_CNT)
382+ return -EINVAL;
383+ }
381384
382385 mutex_lock(&nf_ct_helper_mutex);
383386 for (i = 0; i < nf_ct_helper_hsize; i++) {
net/netfilter/nf_conntrack_irc.c+2−0
@@ -262,6 +262,8 @@ static int __init nf_conntrack_irc_init(void) · 261 unmodified lines
262262 {
263263 int i, ret;
264264
265+ nf_conntrack_helper_deprecated(HELPER_NAME);
266+
265267 if (max_dcc_channels < 1) {
266268 pr_err("max_dcc_channels must not be zero\n");
267269 return -EINVAL;
net/netfilter/nf_conntrack_netlink.c+13−32
@@ -1953,19 +1953,6 @@ static int ctnetlink_change_helper(struct nf_conn *ct, · 1952 unmodified lines
19531953 return err;
19541954 }
19551955
1956− if (!strcmp(helpname, "") && help) {
1957− helper = rcu_dereference(help->helper);
1958− if (helper) {
1959− /* we had a helper before ... */
1960− nf_ct_remove_expectations(ct);
1961− RCU_INIT_POINTER(help->helper, NULL);
1962− if (refcount_dec_and_test(&helper->ct_refcnt))
1963− kfree_rcu(helper, rcu);
1964− }
1965− rcu_read_unlock();
1966− return 0;
1967− }
1968−
19691956 helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct),
19701957 nf_ct_protonum(ct));
19711958 if (helper == NULL) {
@@ -3014,8 +3001,7 @@ static int · 1042 unmodified lines
30143001 ctnetlink_exp_dump_expect(struct sk_buff *skb,
30153002 const struct nf_conntrack_expect *exp)
30163003 {
3017− struct nf_conn *master = exp->master;
3018− long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ;
3004+ __s32 timeout = (__s32)(READ_ONCE(exp->timeout) - nfct_time_stamp) / HZ;
30193005 struct nf_conntrack_helper *helper;
30203006 #if IS_ENABLED(CONFIG_NF_NAT)
30213007 struct nlattr *nest_parms;
@@ -3030,9 +3016,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 8 unmodified lines
30303016 goto nla_put_failure;
30313017 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
30323018 goto nla_put_failure;
3033− if (ctnetlink_exp_dump_tuple(skb,
3034− &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
3035− CTA_EXPECT_MASTER) < 0)
3019+ if (ctnetlink_exp_dump_tuple(skb, &exp->master_tuple, CTA_EXPECT_MASTER) < 0)
30363020 goto nla_put_failure;
30373021
30383022 #if IS_ENABLED(CONFIG_NF_NAT)
@@ -3045,9 +3029,9 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 6 unmodified lines
30453029 if (nla_put_be32(skb, CTA_EXPECT_NAT_DIR, htonl(exp->dir)))
30463030 goto nla_put_failure;
30473031
3048− nat_tuple.src.l3num = nf_ct_l3num(master);
3032+ nat_tuple.src.l3num = exp->master_tuple.src.l3num;
30493033 nat_tuple.src.u3 = exp->saved_addr;
3050− nat_tuple.dst.protonum = nf_ct_protonum(master);
3034+ nat_tuple.dst.protonum = exp->master_tuple.dst.protonum;
30513035 nat_tuple.src.u = exp->saved_proto;
30523036
30533037 if (ctnetlink_exp_dump_tuple(skb, &nat_tuple,
@@ -3178,6 +3162,9 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb) · 124 unmodified lines
31783162 restart:
31793163 hlist_for_each_entry_rcu(exp, &nf_ct_expect_hash[cb->args[0]],
31803164 hnode) {
3165+ if (nf_ct_exp_is_expired(exp))
3166+ continue;
3167+
31813168 if (l3proto && exp->tuple.src.l3num != l3proto)
31823169 continue;
31833170
@@ -3456,11 +3443,8 @@ static int ctnetlink_del_expect(struct sk_buff *skb, · 272 unmodified lines
34563443 }
34573444
34583445 /* after list removal, usage count == 1 */
3459− if (timer_delete(&exp->timeout)) {
3460− nf_ct_unlink_expect_report(exp, NETLINK_CB(skb).portid,
3461− nlmsg_report(info->nlh));
3462− nf_ct_expect_put(exp);
3463− }
3446+ nf_ct_unlink_expect_report(exp, NETLINK_CB(skb).portid,
3447+ nlmsg_report(info->nlh));
34643448 spin_unlock_bh(&nf_conntrack_expect_lock);
34653449 /* have to put what we 'get' above.
34663450 * after this line usage count == 0 */
@@ -3484,14 +3468,10 @@ static int · 17 unmodified lines
34843468 ctnetlink_change_expect(struct nf_conntrack_expect *x,
34853469 const struct nlattr * const cda[])
34863470 {
3487− if (cda[CTA_EXPECT_TIMEOUT]) {
3488− if (!timer_delete(&x->timeout))
3489− return -ETIME;
3471+ if (cda[CTA_EXPECT_TIMEOUT])
3472+ WRITE_ONCE(x->timeout, nfct_time_stamp +
3473+ ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ);
34903474
3491− x->timeout.expires = jiffies +
3492− ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ;
3493− add_timer(&x->timeout);
3494− }
34953475 return 0;
34963476 }
34973477
@@ -3593,6 +3573,7 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 95 unmodified lines
35933573 #endif
35943574 rcu_assign_pointer(exp->helper, helper);
35953575 rcu_assign_pointer(exp->assign_helper, assign_helper);
3576+ exp->master_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
35963577 exp->tuple = *tuple;
35973578 exp->mask.src.u3 = mask->src.u3;
35983579 exp->mask.src.u.all = mask->src.u.all;
net/netfilter/nf_conntrack_pptp.c+2−0
@@ -545,6 +545,8 @@ static int __init nf_conntrack_pptp_init(void) · 544 unmodified lines
545545
546546 pptp.destroy = gre_pptp_destroy_siblings;
547547
548+ nf_conntrack_helper_deprecated(pptp.name);
549+
548550 return nf_conntrack_helper_register(&pptp, &pptp_ptr);
549551 }
550552
net/netfilter/nf_conntrack_sip.c+5−8
@@ -897,11 +897,10 @@ static int refresh_signalling_expectation(struct nf_conn *ct, · 896 unmodified lines
897897 exp->tuple.dst.protonum != proto ||
898898 exp->tuple.dst.u.udp.port != port)
899899 continue;
900− if (mod_timer_pending(&exp->timeout, jiffies + expires * HZ)) {
901− exp->flags &= ~NF_CT_EXPECT_INACTIVE;
902− found = 1;
903− break;
904− }
900+ WRITE_ONCE(exp->timeout, nfct_time_stamp + (expires * HZ));
901+ WRITE_ONCE(exp->flags, exp->flags & ~NF_CT_EXPECT_INACTIVE);
902+ found = 1;
903+ break;
905904 }
906905 spin_unlock_bh(&nf_conntrack_expect_lock);
907906 return found;
@@ -920,8 +919,7 @@ static void flush_expectations(struct nf_conn *ct, bool media) · 12 unmodified lines
920919 hlist_for_each_entry_safe(exp, next, &help->expectations, lnode) {
921920 if ((exp->class != SIP_EXPECT_SIGNALLING) ^ media)
922921 continue;
923− if (!nf_ct_remove_expect(exp))
924− continue;
922+ nf_ct_unlink_expect(exp);
925923 if (!media)
926924 break;
927925 }
@@ -1413,7 +1411,6 @@ static int process_register_request(struct sk_buff *skb, unsigned int protoff, · 485 unmodified lines
14131411
14141412 nf_ct_expect_init(exp, SIP_EXPECT_SIGNALLING, nf_ct_l3num(ct),
14151413 saddr, &daddr, proto, NULL, &port);
1416− exp->timeout.expires = sip_timeout * HZ;
14171414 rcu_assign_pointer(exp->assign_helper, helper);
14181415 exp->flags = NF_CT_EXPECT_PERMANENT | NF_CT_EXPECT_INACTIVE;
14191416
net/netfilter/nf_flow_table_core.c+9−4
@@ -505,8 +505,13 @@ static u32 nf_flow_table_tcp_timeout(const struct nf_conn *ct) · 504 unmodified lines
505505 */
506506 static void nf_flow_table_extend_ct_timeout(struct nf_conn *ct)
507507 {
508− static const u32 min_timeout = 5 * 60 * HZ;
509− u32 expires = nf_ct_expires(ct);
508+ static const s32 min_timeout = 5 * 60 * HZ;
509+ u32 ct_timeout = READ_ONCE(ct->timeout);
510+ s32 expires;
511+
512+ expires = ct_timeout - nfct_time_stamp;
513+ if (expires <= 0) /* already expired */
514+ return;
510515
511516 /* normal case: large enough timeout, nothing to do. */
512517 if (likely(expires >= min_timeout))
@@ -524,7 +529,7 @@ static void nf_flow_table_extend_ct_timeout(struct nf_conn *ct) · 11 unmodified lines
524529 if (nf_ct_is_confirmed(ct) &&
525530 test_bit(IPS_OFFLOAD_BIT, &ct->status)) {
526531 u8 l4proto = nf_ct_protonum(ct);
527− u32 new_timeout = true;
532+ u32 new_timeout = 1;
528533
529534 switch (l4proto) {
530535 case IPPROTO_UDP:
@@ -549,7 +554,7 @@ static void nf_flow_table_extend_ct_timeout(struct nf_conn *ct) · 18 unmodified lines
549554 */
550555 if (new_timeout) {
551556 new_timeout += nfct_time_stamp;
552− cmpxchg(&ct->timeout, expires, new_timeout);
557+ cmpxchg(&ct->timeout, ct_timeout, new_timeout);
553558 }
554559 }
555560
net/netfilter/nf_flow_table_ip.c+24−64
@@ -326,8 +326,10 @@ static bool nf_flow_ip4_tunnel_proto(struct nf_flowtable_ctx *ctx, · 325 unmodified lines
326326 return false;
327327
328328 iph = (struct iphdr *)(skb_network_header(skb) + ctx->offset);
329− size = iph->ihl << 2;
329+ if (iph->ihl < 5)
330+ return false;
330331
332+ size = iph->ihl << 2;
331333 if (ip_is_fragment(iph) || unlikely(ip_has_options(size)))
332334 return false;
333335
@@ -335,9 +337,9 @@ static bool nf_flow_ip4_tunnel_proto(struct nf_flowtable_ctx *ctx, · 1 unmodified line
335337 return false;
336338
337339 if (iph->protocol == IPPROTO_IPIP) {
338− ctx->tun.proto = IPPROTO_IPIP;
340+ ctx->tun.proto = iph->protocol;
339341 ctx->tun.hdr_size = size;
340− ctx->offset += size;
342+ ctx->offset += ctx->tun.hdr_size;
341343 }
342344
343345 return true;
@@ -347,29 +349,23 @@ static bool nf_flow_ip6_tunnel_proto(struct nf_flowtable_ctx *ctx, · 3 unmodified lines
347349 struct sk_buff *skb)
348350 {
349351 #if IS_ENABLED(CONFIG_IPV6)
350− struct ipv6hdr *ip6h, _ip6h;
351− __be16 frag_off;
352− u8 nexthdr;
353− int hdrlen;
352+ struct ipv6hdr *ip6h;
354353
355− ip6h = skb_header_pointer(skb, ctx->offset, sizeof(*ip6h), &_ip6h);
356− if (!ip6h)
354+ if (!pskb_may_pull(skb, sizeof(*ip6h) + ctx->offset))
357355 return false;
358356
357+ ip6h = (struct ipv6hdr *)(skb_network_header(skb) + ctx->offset);
359358 if (ip6h->hop_limit <= 1)
360359 return false;
361360
362− nexthdr = ip6h->nexthdr;
363− hdrlen = ipv6_skip_exthdr(skb, sizeof(*ip6h) + ctx->offset, &nexthdr,
364− &frag_off);
365− if (hdrlen < 0)
361+ if (ipv6_ext_hdr(ip6h->nexthdr))
366362 return false;
367363
368− if (nexthdr == IPPROTO_IPV6) {
369− ctx->tun.hdr_size = hdrlen;
370− ctx->tun.proto = IPPROTO_IPV6;
364+ if (ip6h->nexthdr == IPPROTO_IPV6) {
365+ ctx->tun.proto = ip6h->nexthdr;
366+ ctx->tun.hdr_size = sizeof(*ip6h);
367+ ctx->offset += ctx->tun.hdr_size;
371368 }
372− ctx->offset += ctx->tun.hdr_size;
373369
374370 return true;
375371 #else
@@ -648,25 +644,19 @@ static int nf_flow_tunnel_v4_push(struct net *net, struct sk_buff *skb, · 272 unmodified lines
648644 return 0;
649645 }
650646
651−struct ipv6_tel_txoption {
652− struct ipv6_txoptions ops;
653− __u8 dst_opt[8];
654−};
655−
656647 static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb,
657648 struct flow_offload_tuple *tuple,
658− struct in6_addr **ip6_daddr,
659− int encap_limit)
649+ struct in6_addr **ip6_daddr)
660650 {
661651 struct ipv6hdr *ip6h = (struct ipv6hdr *)skb_network_header(skb);
662− u8 hop_limit = ip6h->hop_limit, proto = IPPROTO_IPV6;
663652 struct rtable *rt = dst_rtable(tuple->dst_cache);
664653 __u8 dsfield = ipv6_get_dsfield(ip6h);
665654 struct flowi6 fl6 = {
666655 .daddr = tuple->tun.src_v6,
667656 .saddr = tuple->tun.dst_v6,
668− .flowi6_proto = proto,
657+ .flowi6_proto = IPPROTO_IPV6,
669658 };
659+ u8 hop_limit = ip6h->hop_limit;
670660 int err, mtu;
671661 u32 headroom;
672662
@@ -674,41 +664,18 @@ static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb, · 1 unmodified line
674664 if (err)
675665 return err;
676666
677− skb_set_inner_ipproto(skb, proto);
667+ skb_set_inner_ipproto(skb, IPPROTO_IPV6);
678668 headroom = sizeof(*ip6h) + LL_RESERVED_SPACE(rt->dst.dev) +
679669 rt->dst.header_len;
680− if (encap_limit)
681− headroom += 8;
682670 err = skb_cow_head(skb, headroom);
683671 if (err)
684672 return err;
685673
686674 skb_scrub_packet(skb, true);
687675 mtu = dst_mtu(&rt->dst) - sizeof(*ip6h);
688− if (encap_limit)
689− mtu -= 8;
690676 mtu = max(mtu, IPV6_MIN_MTU);
691677 skb_dst_update_pmtu_no_confirm(skb, mtu);
692678
693− if (encap_limit > 0) {
694− struct ipv6_tel_txoption opt = {
695− .dst_opt[2] = IPV6_TLV_TNL_ENCAP_LIMIT,
696− .dst_opt[3] = 1,
697− .dst_opt[4] = encap_limit,
698− .dst_opt[5] = IPV6_TLV_PADN,
699− .dst_opt[6] = 1,
700− };
701− struct ipv6_opt_hdr *hopt;
702−
703− opt.ops.dst1opt = (struct ipv6_opt_hdr *)opt.dst_opt;
704− opt.ops.opt_nflen = 8;
705−
706− hopt = skb_push(skb, ipv6_optlen(opt.ops.dst1opt));
707− memcpy(hopt, opt.ops.dst1opt, ipv6_optlen(opt.ops.dst1opt));
708− hopt->nexthdr = IPPROTO_IPV6;
709− proto = NEXTHDR_DEST;
710− }
711−
712679 skb_push(skb, sizeof(*ip6h));
713680 skb_reset_network_header(skb);
714681
@@ -716,7 +683,7 @@ static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb, · 1 unmodified line
716683 ip6_flow_hdr(ip6h, dsfield,
717684 ip6_make_flowlabel(net, skb, fl6.flowlabel, true, &fl6));
718685 ip6h->hop_limit = hop_limit;
719− ip6h->nexthdr = proto;
686+ ip6h->nexthdr = IPPROTO_IPV6;
720687 ip6h->daddr = tuple->tun.src_v6;
721688 ip6h->saddr = tuple->tun.dst_v6;
722689 ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(*ip6h));
@@ -729,12 +696,10 @@ static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb, · 6 unmodified lines
729696
730697 static int nf_flow_tunnel_v6_push(struct net *net, struct sk_buff *skb,
731698 struct flow_offload_tuple *tuple,
732− struct in6_addr **ip6_daddr,
733− int encap_limit)
699+ struct in6_addr **ip6_daddr)
734700 {
735701 if (tuple->tun_num)
736− return nf_flow_tunnel_ip6ip6_push(net, skb, tuple, ip6_daddr,
737− encap_limit);
702+ return nf_flow_tunnel_ip6ip6_push(net, skb, tuple, ip6_daddr);
738703
739704 return 0;
740705 }
@@ -1089,7 +1054,7 @@ static int nf_flow_tuple_ipv6(struct nf_flowtable_ctx *ctx, struct sk_buff *skb, · 348 unmodified lines
10891054 static int nf_flow_offload_ipv6_forward(struct nf_flowtable_ctx *ctx,
10901055 struct nf_flowtable *flow_table,
10911056 struct flow_offload_tuple_rhash *tuplehash,
1092− struct sk_buff *skb, int encap_limit)
1057+ struct sk_buff *skb)
10931058 {
10941059 enum flow_offload_tuple_dir dir;
10951060 struct flow_offload *flow;
@@ -1100,11 +1065,8 @@ static int nf_flow_offload_ipv6_forward(struct nf_flowtable_ctx *ctx, · 4 unmodified lines
11001065 flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
11011066
11021067 mtu = flow->tuplehash[dir].tuple.mtu + ctx->offset;
1103− if (flow->tuplehash[!dir].tuple.tun_num) {
1068+ if (flow->tuplehash[!dir].tuple.tun_num)
11041069 mtu -= sizeof(*ip6h);
1105− if (encap_limit > 0)
1106− mtu -= 8; /* encap limit option */
1107− }
11081070
11091071 if (unlikely(nf_flow_exceeds_mtu(skb, mtu)))
11101072 return 0;
@@ -1158,7 +1120,6 @@ unsigned int · 47 unmodified lines
11581120 nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
11591121 const struct nf_hook_state *state)
11601122 {
1161− int encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
11621123 struct flow_offload_tuple_rhash *tuplehash;
11631124 struct nf_flowtable *flow_table = priv;
11641125 struct flow_offload_tuple *other_tuple;
@@ -1177,8 +1138,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, · 12 unmodified lines
11771138 if (tuplehash == NULL)
11781139 return NF_ACCEPT;
11791140
1180− ret = nf_flow_offload_ipv6_forward(&ctx, flow_table, tuplehash, skb,
1181− encap_limit);
1141+ ret = nf_flow_offload_ipv6_forward(&ctx, flow_table, tuplehash, skb);
11821142 if (ret < 0)
11831143 return NF_DROP;
11841144 else if (ret == 0)
@@ -1198,7 +1158,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, · 13 unmodified lines
11981158 ip6_daddr = &other_tuple->src_v6;
11991159
12001160 if (nf_flow_tunnel_v6_push(state->net, skb, other_tuple,
1201− &ip6_daddr, encap_limit) < 0)
1161+ &ip6_daddr) < 0)
12021162 return NF_DROP;
12031163
12041164 switch (tuplehash->tuple.xmit_type) {
net/netfilter/nf_flow_table_path.c+3−1
@@ -53,8 +53,10 @@ static int nft_dev_fill_forward_path(const struct nf_flow_route *route, · 52 unmodified lines
5353 struct neighbour *n;
5454 u8 nud_state;
5555
56− if (!nft_is_valid_ether_device(dev))
56+ if (!nft_is_valid_ether_device(dev)) {
57+ eth_zero_addr(ha);
5758 goto out;
59+ }
5860
5961 n = dst_neigh_lookup(dst_cache, daddr);
6062 if (!n)
net/netfilter/nf_nat_core.c+10−0
@@ -1181,6 +1181,16 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops, · 1180 unmodified lines
11811181 struct nf_hook_ops *nat_ops;
11821182 int i, ret;
11831183
1184+#ifndef MODULE
1185+ /* If nf_nat_core is built-in and nf_nat_init() fails, dependent
1186+ * modules like nft_chain_nat.ko may still call this function.
1187+ * However, nat_net would be invalid, likely pointing to some other
1188+ * per-net structure.
1189+ */
1190+ if (WARN_ON_ONCE(!nf_nat_hook))
1191+ return -EOPNOTSUPP;
1192+#endif
1193+
11841194 if (WARN_ON_ONCE(pf >= ARRAY_SIZE(nat_net->nat_proto_net)))
11851195 return -EINVAL;
11861196
net/netfilter/nf_queue.c+14−0
@@ -68,6 +68,7 @@ static void nf_queue_entry_release_refs(struct nf_queue_entry *entry) · 67 unmodified lines
6868 nf_queue_sock_put(state->sk);
6969
7070 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
71+ dev_put(entry->bridge_dev);
7172 dev_put(entry->physin);
7273 dev_put(entry->physout);
7374 #endif
@@ -84,6 +85,8 @@ static void __nf_queue_entry_init_physdevs(struct nf_queue_entry *entry) · 10 unmodified lines
8485 {
8586 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
8687 const struct sk_buff *skb = entry->skb;
88+ struct dst_entry *dst = skb_dst(skb);
89+ struct net_device *dev = NULL;
8790
8891 if (nf_bridge_info_exists(skb)) {
8992 entry->physin = nf_bridge_get_physindev(skb, entry->state.net);
@@ -92,6 +95,16 @@ static void __nf_queue_entry_init_physdevs(struct nf_queue_entry *entry) · 2 unmodified lines
9295 entry->physin = NULL;
9396 entry->physout = NULL;
9497 }
98+
99+ if (entry->state.pf == NFPROTO_BRIDGE &&
100+ dst && (dst->flags & DST_FAKE_RTABLE))
101+ dev = dst_dev_rcu(dst);
102+
103+ /* Must hold a reference on the bridge device: dst_hold() protects
104+ * the dst itself, but the fake rtable is embedded in bridge-private
105+ * storage that netdevice teardown can free independently.
106+ */
107+ entry->bridge_dev = dev;
95108 #endif
96109 }
97110
@@ -108,6 +121,7 @@ bool nf_queue_entry_get_refs(struct nf_queue_entry *entry) · 10 unmodified lines
108121 dev_hold(state->out);
109122
110123 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
124+ dev_hold(entry->bridge_dev);
111125 dev_hold(entry->physin);
112126 dev_hold(entry->physout);
113127 #endif
net/netfilter/nfnetlink_queue.c+3−0
@@ -1262,6 +1262,9 @@ dev_cmp(struct nf_queue_entry *entry, unsigned long ifindex) · 1261 unmodified lines
12621262
12631263 if (physinif == ifindex || physoutif == ifindex)
12641264 return 1;
1265+
1266+ if (entry->bridge_dev && entry->bridge_dev->ifindex == ifindex)
1267+ return 1;
12651268 #endif
12661269 if (entry->skb_dev && entry->skb_dev->ifindex == ifindex)
12671270 return 1;
net/netfilter/nft_compat.c+21−3
@@ -397,6 +397,22 @@ static int nft_target_validate(const struct nft_ctx *ctx, · 396 unmodified lines
397397 return 0;
398398 }
399399
400+static int nft_target_bridge_validate(const struct nft_ctx *ctx,
401+ const struct nft_expr *expr)
402+{
403+ struct xt_target *target = expr->ops->data;
404+
405+ /* Do not allow UNSPEC to stand-in for NFPROTO_BRIDGE
406+ * targets: they are incompatible. ebtables targets return
407+ * EBT_ACCEPT, DROP and so on which are not compatible with
408+ * NF_ACCEPT, NF_DROP and so on.
409+ */
410+ if (target->family != NFPROTO_BRIDGE)
411+ return -ENOENT;
412+
413+ return nft_target_validate(ctx, expr);
414+}
415+
400416 static void __nft_match_eval(const struct nft_expr *expr,
401417 struct nft_regs *regs,
402418 const struct nft_pktinfo *pkt,
@@ -932,13 +948,15 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 529 unmodified lines
932948 ops->init = nft_target_init;
933949 ops->destroy = nft_target_destroy;
934950 ops->dump = nft_target_dump;
935− ops->validate = nft_target_validate;
936951 ops->data = target;
937952
938− if (family == NFPROTO_BRIDGE)
953+ if (family == NFPROTO_BRIDGE) {
939954 ops->eval = nft_target_eval_bridge;
940− else
955+ ops->validate = nft_target_bridge_validate;
956+ } else {
941957 ops->eval = nft_target_eval_xt;
958+ ops->validate = nft_target_validate;
959+ }
942960
943961 return ops;
944962 err:
net/netfilter/nft_ct.c+18−4
@@ -1145,7 +1145,6 @@ static void nft_ct_helper_obj_eval(struct nft_object *obj, · 1144 unmodified lines
11451145 help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
11461146 if (help && refcount_inc_not_zero(&to_assign->ct_refcnt)) {
11471147 rcu_assign_pointer(help->helper, to_assign);
1148− set_bit(IPS_HELPER_BIT, &ct->status);
11491148
11501149 if ((ct->status & IPS_NAT_MASK) && !nfct_seqadj(ct))
11511150 if (!nfct_seqadj_ext_add(ct))
@@ -1216,11 +1215,23 @@ struct nft_ct_expect_obj { · 64 unmodified lines
12161215 u32 timeout;
12171216 };
12181217
1218+static int nft_ct_expect_timeout_get(const struct nlattr *attr, u32 *val)
1219+{
1220+ unsigned long jiffies_val = msecs_to_jiffies(nla_get_u32(attr));
1221+
1222+ if (jiffies_val > UINT_MAX)
1223+ return -ERANGE;
1224+
1225+ *val = jiffies_val;
1226+ return 0;
1227+}
1228+
12191229 static int nft_ct_expect_obj_init(const struct nft_ctx *ctx,
12201230 const struct nlattr * const tb[],
12211231 struct nft_object *obj)
12221232 {
12231233 struct nft_ct_expect_obj *priv = nft_obj_data(obj);
1234+ int err;
12241235
12251236 if (!tb[NFTA_CT_EXPECT_L4PROTO] ||
12261237 !tb[NFTA_CT_EXPECT_DPORT] ||
@@ -1255,8 +1266,11 @@ static int nft_ct_expect_obj_init(const struct nft_ctx *ctx, · 28 unmodified lines
12551266 return -EOPNOTSUPP;
12561267 }
12571268
1269+ err = nft_ct_expect_timeout_get(tb[NFTA_CT_EXPECT_TIMEOUT], &priv->timeout);
1270+ if (err)
1271+ return err;
1272+
12581273 priv->dport = nla_get_be16(tb[NFTA_CT_EXPECT_DPORT]);
1259− priv->timeout = nla_get_u32(tb[NFTA_CT_EXPECT_TIMEOUT]);
12601274 priv->size = nla_get_u8(tb[NFTA_CT_EXPECT_SIZE]);
12611275
12621276 return nf_ct_netns_get(ctx->net, ctx->family);
@@ -1276,7 +1290,7 @@ static int nft_ct_expect_obj_dump(struct sk_buff *skb, · 13 unmodified lines
12761290 if (nla_put_be16(skb, NFTA_CT_EXPECT_L3PROTO, htons(priv->l3num)) ||
12771291 nla_put_u8(skb, NFTA_CT_EXPECT_L4PROTO, priv->l4proto) ||
12781292 nla_put_be16(skb, NFTA_CT_EXPECT_DPORT, priv->dport) ||
1279− nla_put_u32(skb, NFTA_CT_EXPECT_TIMEOUT, priv->timeout) ||
1293+ nla_put_u32(skb, NFTA_CT_EXPECT_TIMEOUT, jiffies_to_msecs(priv->timeout)) ||
12801294 nla_put_u8(skb, NFTA_CT_EXPECT_SIZE, priv->size))
12811295 return -1;
12821296
@@ -1326,7 +1340,7 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, · 43 unmodified lines
13261340 &ct->tuplehash[!dir].tuple.src.u3,
13271341 &ct->tuplehash[!dir].tuple.dst.u3,
13281342 priv->l4proto, NULL, &priv->dport);
1329− exp->timeout.expires = jiffies + priv->timeout * HZ;
1343+ exp->timeout += priv->timeout;
13301344
13311345 if (nf_ct_expect_related(exp, 0) != 0)
13321346 regs->verdict.code = NF_DROP;
net/netfilter/nft_meta.c+3−2
@@ -635,8 +635,8 @@ static int nft_meta_get_validate_xfrm(const struct nft_ctx *ctx) · 634 unmodified lines
635635 #endif
636636 }
637637
638−static int nft_meta_get_validate(const struct nft_ctx *ctx,
639− const struct nft_expr *expr)
638+int nft_meta_get_validate(const struct nft_ctx *ctx,
639+ const struct nft_expr *expr)
640640 {
641641 const struct nft_meta *priv = nft_expr_priv(expr);
642642
@@ -652,6 +652,7 @@ static int nft_meta_get_validate(const struct nft_ctx *ctx, · 9 unmodified lines
652652
653653 return 0;
654654 }
655+EXPORT_SYMBOL_GPL(nft_meta_get_validate);
655656
656657 int nft_meta_set_validate(const struct nft_ctx *ctx,
657658 const struct nft_expr *expr)
net/netfilter/nft_payload.c+13−3
@@ -224,11 +224,17 @@ static int nft_payload_init(const struct nft_ctx *ctx, · 223 unmodified lines
224224 const struct nlattr * const tb[])
225225 {
226226 struct nft_payload *priv = nft_expr_priv(expr);
227+ u32 offset;
228+ int err;
227229
228230 priv->base = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE]));
229− priv->offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET]));
230231 priv->len = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN]));
231232
233+ err = nft_parse_u32_check(tb[NFTA_PAYLOAD_OFFSET], U16_MAX, &offset);
234+ if (err < 0)
235+ return err;
236+ priv->offset = offset;
237+
232238 return nft_parse_register_store(ctx, tb[NFTA_PAYLOAD_DREG],
233239 &priv->dreg, NULL, NFT_DATA_VALUE,
234240 priv->len);
@@ -621,7 +627,8 @@ static int nft_payload_inner_init(const struct nft_ctx *ctx, · 386 unmodified lines
621627 const struct nlattr * const tb[])
622628 {
623629 struct nft_payload *priv = nft_expr_priv(expr);
624− u32 base;
630+ u32 base, offset;
631+ int err;
625632
626633 if (!tb[NFTA_PAYLOAD_BASE] || !tb[NFTA_PAYLOAD_OFFSET] ||
627634 !tb[NFTA_PAYLOAD_LEN] || !tb[NFTA_PAYLOAD_DREG])
@@ -639,8 +646,11 @@ static int nft_payload_inner_init(const struct nft_ctx *ctx, · 11 unmodified lines
639646 }
640647
641648 priv->base = base;
642− priv->offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET]));
643649 priv->len = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN]));
650+ err = nft_parse_u32_check(tb[NFTA_PAYLOAD_OFFSET], U16_MAX, &offset);
651+ if (err < 0)
652+ return err;
653+ priv->offset = offset;
644654
645655 return nft_parse_register_store(ctx, tb[NFTA_PAYLOAD_DREG],
646656 &priv->dreg, NULL, NFT_DATA_VALUE,
net/netfilter/nft_synproxy.c+4−5
@@ -24,14 +24,13 @@ static const struct nla_policy nft_synproxy_policy[NFTA_SYNPROXY_MAX + 1] = { · 23 unmodified lines
2424 static void nft_synproxy_tcp_options(struct synproxy_options *opts,
2525 const struct tcphdr *tcp,
2626 struct synproxy_net *snet,
27− struct nf_synproxy_info *info,
28− const struct nft_synproxy *priv)
27+ struct nf_synproxy_info *info)
2928 {
3029 this_cpu_inc(snet->stats->syn_received);
3130 if (tcp->ece && tcp->cwr)
3231 opts->options |= NF_SYNPROXY_OPT_ECN;
3332
34− opts->options &= priv->info.options;
33+ opts->options &= info->options;
3534 opts->mss_encode = opts->mss_option;
3635 opts->mss_option = info->mss;
3736 if (opts->options & NF_SYNPROXY_OPT_TIMESTAMP)
@@ -56,7 +55,7 @@ static void nft_synproxy_eval_v4(const struct nft_synproxy *priv, · 18 unmodified lines
5655
5756 if (tcp->syn) {
5857 /* Initial SYN from client */
59− nft_synproxy_tcp_options(opts, tcp, snet, &info, priv);
58+ nft_synproxy_tcp_options(opts, tcp, snet, &info);
6059 synproxy_send_client_synack(net, skb, tcp, opts);
6160 consume_skb(skb);
6261 regs->verdict.code = NF_STOLEN;
@@ -87,7 +86,7 @@ static void nft_synproxy_eval_v6(const struct nft_synproxy *priv, · 24 unmodified lines
8786
8887 if (tcp->syn) {
8988 /* Initial SYN from client */
90− nft_synproxy_tcp_options(opts, tcp, snet, &info, priv);
89+ nft_synproxy_tcp_options(opts, tcp, snet, &info);
9190 synproxy_send_client_synack_ipv6(net, skb, tcp, opts);
9291 consume_skb(skb);
9392 regs->verdict.code = NF_STOLEN;
net/netfilter/xt_cluster.c+1−1
@@ -107,7 +107,7 @@ xt_cluster_mt(const struct sk_buff *skb, struct xt_action_param *par) · 106 unmodified lines
107107 }
108108
109109 ct = nf_ct_get(skb, &ctinfo);
110− if (ct == NULL)
110+ if (!ct || nf_ct_is_template(ct))
111111 return false;
112112
113113 if (ct->master)
net/openvswitch/conntrack.c+2−1
@@ -883,7 +883,8 @@ static void ct_limit_set(const struct ovs_ct_limit_info *info, · 882 unmodified lines
883883 struct hlist_head *head;
884884
885885 head = ct_limit_hash_bucket(info, new_ct_limit->zone);
886− hlist_for_each_entry_rcu(ct_limit, head, hlist_node) {
886+ hlist_for_each_entry_rcu(ct_limit, head, hlist_node,
887+ lockdep_ovsl_is_held()) {
887888 if (ct_limit->zone == new_ct_limit->zone) {
888889 hlist_replace_rcu(&ct_limit->hlist_node,
889890 &new_ct_limit->hlist_node);
net/psample/psample.c+4−2
@@ -476,15 +476,17 @@ void psample_sample_packet(struct psample_group *group, · 475 unmodified lines
476476 goto error;
477477
478478 if (data_len) {
479− int nla_len = nla_total_size(data_len);
479+ int nla_len = nla_attr_size(data_len);
480480 struct nlattr *nla;
481481
482482 nla = skb_put(nl_skb, nla_len);
483483 nla->nla_type = PSAMPLE_ATTR_DATA;
484− nla->nla_len = nla_attr_size(data_len);
484+ nla->nla_len = nla_len;
485485
486486 if (skb_copy_bits(skb, 0, nla_data(nla), data_len))
487487 goto error;
488+
489+ skb_put_zero(nl_skb, nla_padlen(data_len));
488490 }
489491
490492 #ifdef CONFIG_INET
net/rds/send.c+2−0
@@ -967,6 +967,8 @@ static int rds_rm_size(struct msghdr *msg, int num_sgs, · 966 unmodified lines
967967
968968 switch (cmsg->cmsg_type) {
969969 case RDS_CMSG_RDMA_ARGS:
970+ if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct rds_rdma_args)))
971+ return -EINVAL;
970972 if (vct->indx >= vct->len) {
971973 vct->len += vct->incr;
972974 tmp_iov =
net/rxrpc/ar-internal.h+4−2
@@ -669,7 +669,9 @@ enum rxrpc_call_event { · 668 unmodified lines
669669 enum rxrpc_call_state {
670670 RXRPC_CALL_UNINITIALISED,
671671 RXRPC_CALL_CLIENT_AWAIT_CONN, /* - client waiting for connection to become available */
672+ RXRPC_CALL_CLIENT_PRE_SEND, /* - client is connected, but hasn't sent anything yet */
672673 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
674+ RXRPC_CALL_CLIENT_AWAIT_ACK, /* - client awaiting ACKs of request */
673675 RXRPC_CALL_CLIENT_AWAIT_REPLY, /* - client awaiting reply */
674676 RXRPC_CALL_CLIENT_RECV_REPLY, /* - client receiving reply phase */
675677 RXRPC_CALL_SERVER_PREALLOC, /* - service preallocation */
@@ -1374,9 +1376,9 @@ static inline struct rxrpc_net *rxrpc_net(struct net *net) · 698 unmodified lines
13741376 }
13751377
13761378 /*
1377− * out_of_band.c
1379+ * oob.c
13781380 */
1379−void rxrpc_notify_socket_oob(struct rxrpc_call *call, struct sk_buff *skb);
1381+bool rxrpc_notify_socket_oob(struct rxrpc_call *call, struct sk_buff *skb);
13801382 void rxrpc_add_pending_oob(struct rxrpc_sock *rx, struct sk_buff *skb);
13811383 int rxrpc_sendmsg_oob(struct rxrpc_sock *rx, struct msghdr *msg, size_t len);
13821384
net/rxrpc/call_event.c+4−1
@@ -178,7 +178,7 @@ static void rxrpc_close_tx_phase(struct rxrpc_call *call) · 177 unmodified lines
178178
179179 switch (__rxrpc_call_state(call)) {
180180 case RXRPC_CALL_CLIENT_SEND_REQUEST:
181− rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_AWAIT_REPLY);
181+ rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_AWAIT_ACK);
182182 break;
183183 case RXRPC_CALL_SERVER_SEND_REPLY:
184184 rxrpc_set_call_state(call, RXRPC_CALL_SERVER_AWAIT_ACK);
@@ -244,6 +244,8 @@ static void rxrpc_transmit_fresh_data(struct rxrpc_call *call, unsigned int limi · 59 unmodified lines
244244 break;
245245 } while (req.n < limit && before(seq, send_top));
246246
247+ if (__rxrpc_call_state(call) == RXRPC_CALL_CLIENT_PRE_SEND)
248+ rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_SEND_REQUEST);
247249 if (txb->flags & RXRPC_LAST_PACKET) {
248250 rxrpc_close_tx_phase(call);
249251 tq = NULL;
@@ -267,6 +269,7 @@ void rxrpc_transmit_some_data(struct rxrpc_call *call, unsigned int limit, · 17 unmodified lines
267269 fallthrough;
268270
269271 case RXRPC_CALL_SERVER_SEND_REPLY:
272+ case RXRPC_CALL_CLIENT_PRE_SEND:
270273 case RXRPC_CALL_CLIENT_SEND_REQUEST:
271274 if (!rxrpc_tx_window_space(call))
272275 return;
net/rxrpc/call_object.c+2−0
@@ -18,7 +18,9 @@ · 17 unmodified lines
1818 const char *const rxrpc_call_states[NR__RXRPC_CALL_STATES] = {
1919 [RXRPC_CALL_UNINITIALISED] = "Uninit ",
2020 [RXRPC_CALL_CLIENT_AWAIT_CONN] = "ClWtConn",
21+ [RXRPC_CALL_CLIENT_PRE_SEND] = "ClPreSnd",
2122 [RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq",
23+ [RXRPC_CALL_CLIENT_AWAIT_ACK] = "ClAwtAck",
2224 [RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl",
2325 [RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl",
2426 [RXRPC_CALL_SERVER_PREALLOC] = "SvPrealc",
net/rxrpc/conn_client.c+1−1
@@ -449,7 +449,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn, · 448 unmodified lines
449449 trace_rxrpc_connect_call(call);
450450 call->tx_last_sent = ktime_get_real();
451451 rxrpc_start_call_timer(call);
452− rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_SEND_REQUEST);
452+ rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_PRE_SEND);
453453 wake_up(&call->waitq);
454454 }
455455
net/rxrpc/conn_event.c+7−2
@@ -436,7 +436,7 @@ static bool rxrpc_post_challenge(struct rxrpc_connection *conn, · 435 unmodified lines
436436 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
437437 struct rxrpc_call *call = NULL;
438438 struct rxrpc_sock *rx;
439− bool respond = false;
439+ bool respond = false, queued = false;
440440
441441 sp->chall.conn =
442442 rxrpc_get_connection(conn, rxrpc_conn_get_challenge_input);
@@ -472,8 +472,13 @@ static bool rxrpc_post_challenge(struct rxrpc_connection *conn, · 29 unmodified lines
472472 }
473473
474474 if (call)
475− rxrpc_notify_socket_oob(call, skb);
475+ queued = rxrpc_notify_socket_oob(call, skb);
476476 rcu_read_unlock();
477+ if (call && !queued) {
478+ rxrpc_put_connection(conn, rxrpc_conn_put_challenge_input);
479+ sp->chall.conn = NULL;
480+ return false;
481+ }
477482
478483 if (!call)
479484 rxrpc_post_packet_to_conn(conn, skb);
net/rxrpc/input.c+32−7
@@ -181,7 +181,8 @@ void rxrpc_congestion_degrade(struct rxrpc_call *call) · 180 unmodified lines
181181 if (call->cong_ca_state != RXRPC_CA_SLOW_START &&
182182 call->cong_ca_state != RXRPC_CA_CONGEST_AVOIDANCE)
183183 return;
184− if (__rxrpc_call_state(call) == RXRPC_CALL_CLIENT_AWAIT_REPLY)
184+ if (__rxrpc_call_state(call) == RXRPC_CALL_CLIENT_AWAIT_ACK ||
185+ __rxrpc_call_state(call) == RXRPC_CALL_CLIENT_AWAIT_REPLY)
185186 return;
186187
187188 rtt = ns_to_ktime(call->srtt_us * (NSEC_PER_USEC / 8));
@@ -236,6 +237,9 @@ static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to, · 48 unmodified lines
236237 call->acks_lowest_nak = to;
237238 }
238239
240+ if (after(seq, to))
241+ return false;
242+
239243 /* We may have a left over fully-consumed buffer at the front that we
240244 * couldn't drop before (rotate_and_keep below).
241245 */
@@ -247,7 +251,7 @@ static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to, · 5 unmodified lines
247251 tq = call->tx_queue;
248252 }
249253
250− do {
254+ while (before_eq(seq, to)) {
251255 unsigned int ix = seq - call->tx_qbase;
252256
253257 _debug("tq=%x seq=%x i=%d f=%x", tq->qbase, seq, ix, tq->bufs[ix]->flags);
@@ -317,8 +321,7 @@ static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to, · 63 unmodified lines
317321 break;
318322 }
319323 }
320−
321− } while (before_eq(seq, to));
324+ }
322325
323326 if (trace)
324327 trace_rxrpc_rack_update(call, summary);
@@ -356,6 +359,7 @@ static void rxrpc_end_tx_phase(struct rxrpc_call *call, bool reply_begun, · 31 unmodified lines
356359
357360 switch (__rxrpc_call_state(call)) {
358361 case RXRPC_CALL_CLIENT_SEND_REQUEST:
362+ case RXRPC_CALL_CLIENT_AWAIT_ACK:
359363 case RXRPC_CALL_CLIENT_AWAIT_REPLY:
360364 if (reply_begun) {
361365 rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_RECV_REPLY);
@@ -392,6 +396,14 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call) · 30 unmodified lines
392396 trace_rxrpc_timer_can(call, rxrpc_timer_trace_delayed_ack);
393397 }
394398
399+ /* Deal with an apparent reply coming in before we've got the request
400+ * queued or transmitted.
401+ */
402+ if (!test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
403+ rxrpc_proto_abort(call, top, rxrpc_eproto_early_reply);
404+ return false;
405+ }
406+
395407 if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
396408 if (!rxrpc_rotate_tx_window(call, top, &summary)) {
397409 rxrpc_proto_abort(call, top, rxrpc_eproto_early_reply);
@@ -694,6 +706,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb) · 296 unmodified lines
694706
695707 switch (__rxrpc_call_state(call)) {
696708 case RXRPC_CALL_CLIENT_SEND_REQUEST:
709+ case RXRPC_CALL_CLIENT_AWAIT_ACK:
697710 case RXRPC_CALL_CLIENT_AWAIT_REPLY:
698711 /* Received data implicitly ACKs all of the request
699712 * packets we sent when we're acting as a client.
@@ -1154,10 +1167,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb) · 454 unmodified lines
11541167 if (hard_ack + 1 == 0)
11551168 return rxrpc_proto_abort(call, 0, rxrpc_eproto_ackr_zero);
11561169
1157− /* Ignore ACKs unless we are or have just been transmitting. */
1170+ /* Ignore ACKs unless we are transmitting or are waiting for
1171+ * acknowledgement of the packets we've just been transmitting.
1172+ */
11581173 switch (__rxrpc_call_state(call)) {
11591174 case RXRPC_CALL_CLIENT_SEND_REQUEST:
1160− case RXRPC_CALL_CLIENT_AWAIT_REPLY:
1175+ case RXRPC_CALL_CLIENT_AWAIT_ACK:
11611176 case RXRPC_CALL_SERVER_SEND_REPLY:
11621177 case RXRPC_CALL_SERVER_AWAIT_ACK:
11631178 break;
@@ -1215,7 +1230,17 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb) · 51 unmodified lines
12151230 {
12161231 struct rxrpc_ack_summary summary = { 0 };
12171232
1218− if (rxrpc_rotate_tx_window(call, call->tx_top, &summary))
1233+ switch (__rxrpc_call_state(call)) {
1234+ case RXRPC_CALL_CLIENT_SEND_REQUEST:
1235+ case RXRPC_CALL_CLIENT_AWAIT_ACK:
1236+ case RXRPC_CALL_SERVER_SEND_REPLY:
1237+ case RXRPC_CALL_SERVER_AWAIT_ACK:
1238+ break;
1239+ default:
1240+ return;
1241+ }
1242+
1243+ if (rxrpc_rotate_tx_window(call, call->tx_transmitted, &summary))
12191244 rxrpc_end_tx_phase(call, false, rxrpc_eproto_unexpected_ackall);
12201245 }
12211246
net/rxrpc/oob.c+10−2
@@ -32,11 +32,12 @@ struct rxrpc_oob_params { · 31 unmodified lines
3232 * Post an out-of-band message for attention by the socket or kernel service
3333 * associated with a reference call.
3434 */
35−void rxrpc_notify_socket_oob(struct rxrpc_call *call, struct sk_buff *skb)
35+bool rxrpc_notify_socket_oob(struct rxrpc_call *call, struct sk_buff *skb)
3636 {
3737 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
3838 struct rxrpc_sock *rx;
3939 struct sock *sk;
40+ bool queued = false;
4041
4142 rcu_read_lock();
4243
@@ -49,6 +50,7 @@ void rxrpc_notify_socket_oob(struct rxrpc_call *call, struct sk_buff *skb) · 6 unmodified lines
4950 skb->skb_mstamp_ns = rx->oob_id_counter++;
5051 rxrpc_get_skb(skb, rxrpc_skb_get_post_oob);
5152 skb_queue_tail(&rx->recvmsg_oobq, skb);
53+ queued = true;
5254
5355 trace_rxrpc_notify_socket(call->debug_id, sp->hdr.serial);
5456 if (rx->app_ops)
@@ -56,11 +58,12 @@ void rxrpc_notify_socket_oob(struct rxrpc_call *call, struct sk_buff *skb) · 1 unmodified line
5658 }
5759
5860 spin_unlock_irq(&rx->recvmsg_lock);
59− if (!rx->app_ops && !sock_flag(sk, SOCK_DEAD))
61+ if (queued && !rx->app_ops && !sock_flag(sk, SOCK_DEAD))
6062 sk->sk_data_ready(sk);
6163 }
6264
6365 rcu_read_unlock();
66+ return queued;
6467 }
6568
6669 /*
@@ -210,6 +213,11 @@ static int rxrpc_respond_to_oob(struct rxrpc_sock *rx, · 143 unmodified lines
210213 break;
211214 }
212215
216+ switch (skb->mark) {
217+ case RXRPC_OOB_CHALLENGE:
218+ rxrpc_put_connection(sp->chall.conn, rxrpc_conn_put_oob);
219+ break;
220+ }
213221 rxrpc_free_skb(skb, rxrpc_skb_put_oob);
214222 return ret;
215223 }
net/rxrpc/recvmsg.c+4−6
@@ -27,8 +27,6 @@ void rxrpc_notify_socket(struct rxrpc_call *call) · 26 unmodified lines
2727
2828 _enter("%d", call->debug_id);
2929
30− if (!list_empty(&call->recvmsg_link))
31− return;
3230 if (test_bit(RXRPC_CALL_RELEASED, &call->flags)) {
3331 rxrpc_see_call(call, rxrpc_call_see_notify_released);
3432 return;
@@ -438,7 +436,8 @@ try_again: · 403 unmodified lines
438436 return -EAGAIN;
439437 }
440438
441− if (list_empty(&rx->recvmsg_q)) {
439+ if (list_empty(&rx->recvmsg_q) &&
440+ skb_queue_empty_lockless(&rx->recvmsg_oobq)) {
442441 ret = -EWOULDBLOCK;
443442 if (timeo == 0) {
444443 call = NULL;
@@ -471,7 +470,7 @@ try_again: · 26 unmodified lines
471470 release_sock(&rx->sk);
472471 if (ret == -EAGAIN)
473472 goto try_again;
474− goto error_no_call;
473+ goto error_trace;
475474 }
476475
477476 /* Find the next call and dequeue it if we're not just peeking. If we
@@ -530,8 +529,7 @@ try_again: · 52 unmodified lines
530529 if (test_bit(RXRPC_CALL_RELEASED, &call->flags)) {
531530 rxrpc_see_call(call, rxrpc_call_see_already_released);
532531 mutex_unlock(&call->user_mutex);
533− if (!(flags & MSG_PEEK))
534− rxrpc_put_call(call, rxrpc_call_put_recvmsg);
532+ rxrpc_put_call(call, rxrpc_call_put_recvmsg);
535533 goto try_again;
536534 }
537535
net/rxrpc/sendmsg.c+2−1
@@ -366,7 +366,8 @@ reload: · 365 unmodified lines
366366 if (state >= RXRPC_CALL_COMPLETE)
367367 goto maybe_error;
368368 ret = -EPROTO;
369− if (state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
369+ if (state != RXRPC_CALL_CLIENT_PRE_SEND &&
370+ state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
370371 state != RXRPC_CALL_SERVER_ACK_REQUEST &&
371372 state != RXRPC_CALL_SERVER_SEND_REPLY) {
372373 /* Request phase complete for this client call */
net/sched/act_ct.c+8−5
@@ -844,11 +844,11 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, · 843 unmodified lines
844844 u8 family, u16 zone, bool *defrag)
845845 {
846846 enum ip_conntrack_info ctinfo;
847+ struct tc_skb_cb cb;
847848 struct nf_conn *ct;
848849 int err = 0;
849850 bool frag;
850851 u8 proto;
851− u16 mru;
852852
853853 /* Previously seen (loopback)? Ignore. */
854854 ct = nf_ct_get(skb, &ctinfo);
@@ -862,12 +862,13 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, · 7 unmodified lines
862862 if (err || !frag)
863863 return err;
864864
865− err = nf_ct_handle_fragments(net, skb, zone, family, &proto, &mru);
865+ cb = *tc_skb_cb(skb);
866+ err = nf_ct_handle_fragments(net, skb, zone, family, &proto, &cb.mru);
866867 if (err)
867868 return err;
868869
869870 *defrag = true;
870− tc_skb_cb(skb)->mru = mru;
871+ *tc_skb_cb(skb) = cb;
871872
872873 return 0;
873874 }
@@ -1295,7 +1296,8 @@ static int tcf_ct_fill_params(struct net *net, · 421 unmodified lines
12951296 if (tb[TCA_CT_ZONE]) {
12961297 if (!IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES)) {
12971298 NL_SET_ERR_MSG_MOD(extack, "Conntrack zones isn't enabled.");
1298− return -EOPNOTSUPP;
1299+ err = -EOPNOTSUPP;
1300+ goto err;
12991301 }
13001302
13011303 tcf_ct_set_key_val(tb,
@@ -1308,7 +1310,8 @@ static int tcf_ct_fill_params(struct net *net, · 6 unmodified lines
13081310 tmpl = nf_ct_tmpl_alloc(net, &zone, GFP_KERNEL);
13091311 if (!tmpl) {
13101312 NL_SET_ERR_MSG_MOD(extack, "Failed to allocate conntrack template");
1311− return -ENOMEM;
1313+ err = -ENOMEM;
1314+ goto err;
13121315 }
13131316 p->tmpl = tmpl;
13141317 if (tb[TCA_CT_HELPER_NAME]) {
net/sched/cls_api.c+3−0
@@ -4049,6 +4049,9 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru · 4048 unmodified lines
40494049 skb_do_redirect(skb);
40504050 *ret = __NET_XMIT_STOLEN;
40514051 return NULL;
4052+ case TC_ACT_CONSUMED:
4053+ *ret = __NET_XMIT_STOLEN;
4054+ return NULL;
40524055 }
40534056
40544057 return skb;
net/sched/sch_dualpi2.c+5−6
@@ -461,7 +461,7 @@ static int dualpi2_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, · 460 unmodified lines
461461 if (IS_ERR_OR_NULL(nskb))
462462 return qdisc_drop(skb, sch, to_free);
463463
464− cnt = 1;
464+ cnt = 0;
465465 byte_len = 0;
466466 orig_len = qdisc_pkt_len(skb);
467467 skb_list_walk_safe(nskb, nskb, next) {
@@ -488,16 +488,15 @@ static int dualpi2_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, · 20 unmodified lines
488488 byte_len += nskb->len;
489489 }
490490 }
491− if (cnt > 1) {
491+ if (cnt > 0) {
492492 /* The caller will add the original skb stats to its
493493 * backlog, compensate this if any nskb is enqueued.
494494 */
495− --cnt;
496− byte_len -= orig_len;
495+ qdisc_tree_reduce_backlog(sch, 1 - cnt,
496+ orig_len - byte_len);
497497 }
498− qdisc_tree_reduce_backlog(sch, -cnt, -byte_len);
499498 consume_skb(skb);
500− return err;
499+ return cnt > 0 ? NET_XMIT_SUCCESS : err;
501500 }
502501 return dualpi2_enqueue_skb(skb, sch, to_free);
503502 }
net/sched/sch_generic.c+2−5
@@ -594,9 +594,8 @@ void netdev_watchdog_up(struct net_device *dev) · 593 unmodified lines
594594 return;
595595 if (dev->watchdog_timeo <= 0)
596596 dev->watchdog_timeo = 5*HZ;
597− spin_lock_bh(&dev->tx_global_lock);
598597
599− spin_lock(&dev->watchdog_lock);
598+ spin_lock_bh(&dev->watchdog_lock);
600599 if (!mod_timer(&dev->watchdog_timer,
601600 round_jiffies(jiffies + dev->watchdog_timeo))) {
602601 if (!dev->watchdog_ref_held) {
@@ -605,9 +604,7 @@ void netdev_watchdog_up(struct net_device *dev) · 2 unmodified lines
605604 dev->watchdog_ref_held = true;
606605 }
607606 }
608− spin_unlock(&dev->watchdog_lock);
609−
610− spin_unlock_bh(&dev->tx_global_lock);
607+ spin_unlock_bh(&dev->watchdog_lock);
611608 }
612609 EXPORT_SYMBOL_GPL(netdev_watchdog_up);
613610
net/sctp/diag.c+32−35
@@ -92,6 +92,7 @@ static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb, · 91 unmodified lines
9292 if (!--addrcnt)
9393 break;
9494 }
95+ WARN_ON_ONCE(addrcnt);
9596 rcu_read_unlock();
9697
9798 return 0;
@@ -373,42 +374,39 @@ static int sctp_ep_dump(struct sctp_endpoint *ep, void *p) · 275 unmodified lines
373374 struct sk_buff *skb = commp->skb;
374375 struct netlink_callback *cb = commp->cb;
375376 const struct inet_diag_req_v2 *r = commp->r;
376− struct net *net = sock_net(skb->sk);
377377 struct inet_sock *inet = inet_sk(sk);
378378 int err = 0;
379379
380− if (!net_eq(sock_net(sk), net))
380+ lock_sock(sk);
381+ if (ep->base.dead)
381382 goto out;
382383
383− if (cb->args[4] < cb->args[1])
384− goto next;
385−
386− if (!(r->idiag_states & TCPF_LISTEN) && !list_empty(&ep->asocs))
387− goto next;
384+ /* Skip eps with assocs if non-LISTEN states were requested, since
385+ * they'll be dumped by sctp_sock_dump() during assoc traversal.
386+ */
387+ if ((r->idiag_states & ~(TCPF_LISTEN | TCPF_CLOSE)) &&
388+ !list_empty(&ep->asocs))
389+ goto out;
388390
389391 if (r->sdiag_family != AF_UNSPEC &&
390392 sk->sk_family != r->sdiag_family)
391− goto next;
393+ goto out;
392394
393395 if (r->id.idiag_sport != inet->inet_sport &&
394396 r->id.idiag_sport)
395− goto next;
397+ goto out;
396398
397399 if (r->id.idiag_dport != inet->inet_dport &&
398400 r->id.idiag_dport)
399− goto next;
400−
401− if (inet_sctp_diag_fill(sk, NULL, skb, r,
402− sk_user_ns(NETLINK_CB(cb->skb).sk),
403− NETLINK_CB(cb->skb).portid,
404− cb->nlh->nlmsg_seq, NLM_F_MULTI,
405− cb->nlh, commp->net_admin) < 0) {
406− err = 2;
407401 goto out;
408− }
409−next:
410− cb->args[4]++;
402+
403+ err = inet_sctp_diag_fill(sk, NULL, skb, r,
404+ sk_user_ns(NETLINK_CB(cb->skb).sk),
405+ NETLINK_CB(cb->skb).portid,
406+ cb->nlh->nlmsg_seq, NLM_F_MULTI,
407+ cb->nlh, commp->net_admin);
411408 out:
409+ release_sock(sk);
412410 return err;
413411 }
414412
@@ -479,41 +477,40 @@ static void sctp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, · 64 unmodified lines
479477 .r = r,
480478 .net_admin = netlink_net_capable(cb->skb, CAP_NET_ADMIN),
481479 };
482− int pos = cb->args[2];
480+ int pos;
483481
484482 /* eps hashtable dumps
485483 * args:
486484 * 0 : if it will traversal listen sock
487485 * 1 : to record the sock pos of this time's traversal
488− * 4 : to work as a temporary variable to traversal list
489486 */
490487 if (cb->args[0] == 0) {
491− if (!(idiag_states & TCPF_LISTEN))
492− goto skip;
493− if (sctp_for_each_endpoint(sctp_ep_dump, &commp))
494− goto done;
495−skip:
488+ if (idiag_states & TCPF_LISTEN) {
489+ pos = cb->args[1];
490+ if (sctp_for_each_endpoint(sctp_ep_dump, net, &pos,
491+ &commp)) {
492+ cb->args[1] = pos;
493+ return;
494+ }
495+ }
496496 cb->args[0] = 1;
497497 cb->args[1] = 0;
498− cb->args[4] = 0;
499498 }
500499
500+ if (!(idiag_states & ~(TCPF_LISTEN | TCPF_CLOSE)))
501+ return;
502+
501503 /* asocs by transport hashtable dump
502504 * args:
503505 * 1 : to record the assoc pos of this time's traversal
504506 * 2 : to record the transport pos of this time's traversal
505507 * 3 : to mark if we have dumped the ep info of the current asoc
506− * 4 : to work as a temporary variable to traversal list
507− * 5 : to save the sk we get from travelsing the tsp list.
508+ * 4 : to track position within ep->asocs list in sctp_sock_dump()
508509 */
509− if (!(idiag_states & ~(TCPF_LISTEN | TCPF_CLOSE)))
510− goto done;
511−
510+ pos = cb->args[2];
512511 sctp_transport_traverse_process(sctp_sock_filter, sctp_sock_dump,
513512 net, &pos, &commp);
514513 cb->args[2] = pos;
515−
516−done:
517514 cb->args[1] = cb->args[4];
518515 cb->args[4] = 0;
519516 }
net/sctp/sm_statefuns.c+5−0
@@ -415,6 +415,8 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net, · 414 unmodified lines
415415 /* Update socket peer label if first association. */
416416 if (security_sctp_assoc_request(new_asoc, chunk->skb)) {
417417 sctp_association_free(new_asoc);
418+ if (err_chunk)
419+ sctp_chunk_free(err_chunk);
418420 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
419421 }
420422
@@ -1606,6 +1608,8 @@ static enum sctp_disposition sctp_sf_do_unexpected_init( · 1185 unmodified lines
16061608 /* Update socket peer label if first association. */
16071609 if (security_sctp_assoc_request(new_asoc, chunk->skb)) {
16081610 sctp_association_free(new_asoc);
1611+ if (err_chunk)
1612+ sctp_chunk_free(err_chunk);
16091613 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
16101614 }
16111615
@@ -1671,6 +1675,7 @@ static enum sctp_disposition sctp_sf_do_unexpected_init( · 59 unmodified lines
16711675 * parameter type.
16721676 */
16731677 sctp_addto_chunk(repl, len, unk_param);
1678+ sctp_chunk_free(err_chunk);
16741679 }
16751680
16761681 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc));
net/sctp/socket.c+22−7
@@ -5369,24 +5369,39 @@ struct sctp_transport *sctp_transport_get_idx(struct net *net, · 5368 unmodified lines
53695369 }
53705370
53715371 int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *),
5372− void *p) {
5373− int err = 0;
5374− int hash = 0;
5375− struct sctp_endpoint *ep;
5372+ struct net *net, int *pos, void *p) {
5373+ int err, hash = 0, idx = 0, start;
53765374 struct sctp_hashbucket *head;
5375+ struct sctp_endpoint *ep;
53775376
53785377 for (head = sctp_ep_hashtable; hash < sctp_ep_hashsize;
53795378 hash++, head++) {
5379+ start = idx;
5380+again:
53805381 read_lock_bh(&head->lock);
53815382 sctp_for_each_hentry(ep, &head->chain) {
5382− err = cb(ep, p);
5383− if (err)
5383+ if (sock_net(ep->base.sk) != net)
5384+ continue;
5385+ if (idx++ >= *pos) {
5386+ sctp_endpoint_hold(ep);
53845387 break;
5388+ }
53855389 }
53865390 read_unlock_bh(&head->lock);
5391+
5392+ if (ep) {
5393+ err = cb(ep, p);
5394+ sctp_endpoint_put(ep);
5395+ if (err)
5396+ return err;
5397+ (*pos)++;
5398+
5399+ idx = start;
5400+ goto again;
5401+ }
53875402 }
53885403
5389− return err;
5404+ return 0;
53905405 }
53915406 EXPORT_SYMBOL_GPL(sctp_for_each_endpoint);
53925407
net/tipc/core.c+7−2
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 #include "crypto.h"
4646
4747 #include <linux/module.h>
48+#include <linux/wait_bit.h>
4849
4950 /* configurable TIPC parameters */
5051 unsigned int tipc_net_id __read_mostly;
@@ -118,8 +119,7 @@ static void __net_exit tipc_exit_net(struct net *net) · 67 unmodified lines
118119 #ifdef CONFIG_TIPC_CRYPTO
119120 tipc_crypto_stop(&tipc_net(net)->crypto_tx);
120121 #endif
121− while (atomic_read(&tn->wq_count))
122− cond_resched();
122+ wait_var_event(&tn->wq_count, atomic_read(&tn->wq_count) == 0);
123123 }
124124
125125 static void __net_exit tipc_pernet_pre_exit(struct net *net)
@@ -218,6 +218,11 @@ static void __exit tipc_exit(void) · 92 unmodified lines
218218 unregister_pernet_device(&tipc_net_ops);
219219 tipc_unregister_sysctl();
220220
221+ /* TODO: Wait for all timers that called call_rcu() to finish before
222+ * calling rcu_barrier().
223+ */
224+ rcu_barrier();
225+
221226 pr_info("Deactivated\n");
222227 }
223228
net/tipc/crypto.c+9−0
@@ -941,12 +941,20 @@ static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead, · 940 unmodified lines
941941 goto exit;
942942 }
943943
944+ /* Get net to avoid freed tipc_crypto when delete namespace */
945+ if (!maybe_get_net(net)) {
946+ tipc_bearer_put(b);
947+ rc = -ENODEV;
948+ goto exit;
949+ }
950+
944951 /* Now, do decrypt */
945952 rc = crypto_aead_decrypt(req);
946953 if (rc == -EINPROGRESS || rc == -EBUSY)
947954 return rc;
948955
949956 tipc_bearer_put(b);
957+ put_net(net);
950958
951959 exit:
952960 kfree(ctx);
@@ -984,6 +992,7 @@ static void tipc_aead_decrypt_done(void *data, int err) · 31 unmodified lines
984992 }
985993
986994 tipc_bearer_put(b);
995+ put_net(net);
987996 }
988997
989998 static inline int tipc_ehdr_size(struct tipc_ehdr *ehdr)
net/tipc/discover.c+12−2
@@ -58,6 +58,7 @@ · 57 unmodified lines
5858 * @skb: request message to be (repeatedly) sent
5959 * @timer: timer governing period between requests
6060 * @timer_intv: current interval between requests (in ms)
61+ * @rcu: RCU head for deferred freeing
6162 */
6263 struct tipc_discoverer {
6364 u32 bearer_id;
@@ -69,6 +70,7 @@ struct tipc_discoverer { · 5 unmodified lines
6970 struct sk_buff *skb;
7071 struct timer_list timer;
7172 unsigned long timer_intv;
73+ struct rcu_head rcu;
7274 };
7375
7476 /**
@@ -382,6 +384,15 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b, · 307 unmodified lines
382384 return 0;
383385 }
384386
387+static void tipc_disc_free_rcu(struct rcu_head *rp)
388+{
389+ struct tipc_discoverer *d = container_of(rp, struct tipc_discoverer,
390+ rcu);
391+
392+ kfree_skb(d->skb);
393+ kfree(d);
394+}
395+
385396 /**
386397 * tipc_disc_delete - destroy object sending periodic link setup requests
387398 * @d: ptr to link dest structure
@@ -389,8 +400,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b, · 1 unmodified line
389400 void tipc_disc_delete(struct tipc_discoverer *d)
390401 {
391402 timer_shutdown_sync(&d->timer);
392− kfree_skb(d->skb);
393− kfree(d);
403+ call_rcu(&d->rcu, tipc_disc_free_rcu);
394404 }
395405
396406 /**
net/tipc/udp_media.c+14−5
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 #include <linux/igmp.h>
4141 #include <linux/kernel.h>
4242 #include <linux/workqueue.h>
43+#include <linux/wait_bit.h>
4344 #include <linux/list.h>
4445 #include <net/sock.h>
4546 #include <net/ip.h>
@@ -803,6 +804,14 @@ err: · 757 unmodified lines
803804 return err;
804805 }
805806
807+static void rcast_free_rcu(struct rcu_head *rcu)
808+{
809+ struct udp_replicast *rcast = container_of(rcu, struct udp_replicast, rcu);
810+
811+ dst_cache_destroy(&rcast->dst_cache);
812+ kfree(rcast);
813+}
814+
806815 /* cleanup_bearer - break the socket/bearer association */
807816 static void cleanup_bearer(struct work_struct *work)
808817 {
@@ -811,19 +820,19 @@ static void cleanup_bearer(struct work_struct *work) · 2 unmodified lines
811820 struct tipc_net *tn;
812821
813822 list_for_each_entry_safe(rcast, tmp, &ub->rcast.list, list) {
814− dst_cache_destroy(&rcast->dst_cache);
815823 list_del_rcu(&rcast->list);
816− kfree_rcu(rcast, rcu);
824+ call_rcu_hurry(&rcast->rcu, rcast_free_rcu);
817825 }
818826
819827 tn = tipc_net(sock_net(ub->sk));
820828
821− dst_cache_destroy(&ub->rcast.dst_cache);
822829 udp_tunnel_sock_release(ub->sk);
823830
824− /* Note: could use a call_rcu() to avoid another synchronize_net() */
825831 synchronize_net();
826− atomic_dec(&tn->wq_count);
832+
833+ dst_cache_destroy(&ub->rcast.dst_cache);
834+ if (atomic_dec_and_test(&tn->wq_count))
835+ wake_up_var(&tn->wq_count);
827836 kfree(ub);
828837 }
829838
net/xfrm/espintcp.c+7−27
@@ -212,43 +212,23 @@ static int espintcp_sendskmsg_locked(struct sock *sk, · 211 unmodified lines
212212 struct sk_msg *skmsg = &emsg->skmsg;
213213 bool more = flags & MSG_MORE;
214214 struct scatterlist *sg;
215− int done = 0;
216215 int ret;
217216
218− sg = &skmsg->sg.data[skmsg->sg.start];
219217 do {
220218 struct bio_vec bvec;
221− size_t size = sg->length - emsg->offset;
222− int offset = sg->offset + emsg->offset;
223− struct page *p;
224−
225− emsg->offset = 0;
226219
220+ sg = &skmsg->sg.data[skmsg->sg.start];
227221 if (sg_is_last(sg) && !more)
228222 msghdr.msg_flags &= ~MSG_MORE;
229223
230− p = sg_page(sg);
231−retry:
232− bvec_set_page(&bvec, p, size, offset);
233− iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size);
234− ret = tcp_sendmsg_locked(sk, &msghdr, size);
235− if (ret < 0) {
236− emsg->offset = offset - sg->offset;
237− skmsg->sg.start += done;
224+ bvec_set_page(&bvec, sg_page(sg), sg->length, sg->offset);
225+ iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sg->length);
226+ ret = tcp_sendmsg_locked(sk, &msghdr, sg->length);
227+ if (ret < 0)
238228 return ret;
239− }
240−
241− if (ret != size) {
242− offset += ret;
243− size -= ret;
244− goto retry;
245− }
246229
247− done++;
248− put_page(p);
249− sk_mem_uncharge(sk, sg->length);
250− sg = sg_next(sg);
251− } while (sg);
230+ sk_msg_free_partial(sk, skmsg, ret);
231+ } while (skmsg->sg.size);
252232
253233 memset(emsg, 0, sizeof(*emsg));
254234
net/xfrm/xfrm_input.c+16−13
@@ -467,6 +467,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) · 466 unmodified lines
467467 {
468468 const struct xfrm_state_afinfo *afinfo;
469469 struct net *net = dev_net(skb->dev);
470+ struct net_device *dev = skb->dev;
470471 int err;
471472 __be32 seq;
472473 __be32 seq_hi;
@@ -493,7 +494,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) · 20 unmodified lines
493494 LINUX_MIB_XFRMINSTATEINVALID);
494495
495496 if (encap_type == -1)
496− dev_put(skb->dev);
497+ dev_put(dev);
497498 goto drop;
498499 }
499500
@@ -655,16 +656,16 @@ process: · 155 unmodified lines
655656
656657 if (!crypto_done) {
657658 spin_unlock(&x->lock);
658− dev_hold(skb->dev);
659+ dev_hold(dev);
659660
660661 nexthdr = x->type->input(x, skb);
661662 if (nexthdr == -EINPROGRESS) {
662663 if (async)
663− dev_put(skb->dev);
664+ dev_put(dev);
664665 return 0;
665666 }
666667
667− dev_put(skb->dev);
668+ dev_put(dev);
668669 spin_lock(&x->lock);
669670 }
670671 resume:
@@ -699,7 +700,7 @@ resume: · 28 unmodified lines
699700 err = xfrm_inner_mode_input(x, skb);
700701 if (err == -EINPROGRESS) {
701702 if (async)
702− dev_put(skb->dev);
703+ dev_put(dev);
703704 return 0;
704705 } else if (err) {
705706 XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMODEERROR);
@@ -726,9 +727,12 @@ resume_decapped: · 20 unmodified lines
726727 crypto_done = false;
727728 } while (!err);
728729
730+ rcu_read_lock();
729731 err = xfrm_rcv_cb(skb, family, x->type->proto, 0);
730− if (err)
732+ if (err) {
733+ rcu_read_unlock();
731734 goto drop;
735+ }
732736
733737 nf_reset_ct(skb);
734738
@@ -739,8 +743,9 @@ resume_decapped: · 4 unmodified lines
739743 if (skb_valid_dst(skb))
740744 skb_dst_drop(skb);
741745 if (async)
742− dev_put(skb->dev);
746+ dev_put(dev);
743747 gro_cells_receive(&gro_cells, skb);
748+ rcu_read_unlock();
744749 return 0;
745750 } else {
746751 xo = xfrm_offload(skb);
@@ -748,23 +753,21 @@ resume_decapped: · 1 unmodified line
748753 xfrm_gro = xo->flags & XFRM_GRO;
749754
750755 err = -EAFNOSUPPORT;
751− rcu_read_lock();
752756 afinfo = xfrm_state_afinfo_get_rcu(x->props.family);
753757 if (likely(afinfo))
754758 err = afinfo->transport_finish(skb, xfrm_gro || async);
755− rcu_read_unlock();
756759 if (xfrm_gro) {
757760 sp = skb_sec_path(skb);
758761 if (sp)
759762 sp->olen = 0;
760763 if (skb_valid_dst(skb))
761764 skb_dst_drop(skb);
762− if (async)
763− dev_put(skb->dev);
764765 gro_cells_receive(&gro_cells, skb);
765− return err;
766766 }
767767
768+ if (async)
769+ dev_put(dev);
770+ rcu_read_unlock();
768771 return err;
769772 }
770773
@@ -772,7 +775,7 @@ drop_unlock: · 1 unmodified line
772775 spin_unlock(&x->lock);
773776 drop:
774777 if (async)
775− dev_put(skb->dev);
778+ dev_put(dev);
776779 xfrm_rcv_cb(skb, family, x && x->type ? x->type->proto : nexthdr, -1);
777780 kfree_skb(skb);
778781 return 0;
net/xfrm/xfrm_interface_core.c+3−0
@@ -869,6 +869,9 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[], · 868 unmodified lines
869869 struct net *net = xi->net;
870870 struct xfrm_if_parms p = {};
871871
872+ if (!rtnl_dev_link_net_capable(dev, net))
873+ return -EPERM;
874+
872875 xfrmi_netlink_parms(data, &p);
873876 if (!p.if_id) {
874877 NL_SET_ERR_MSG(extack, "if_id must be non zero");
net/xfrm/xfrm_policy.c+15−12
@@ -242,6 +242,9 @@ __xfrm6_selector_match(const struct xfrm_selector *sel, const struct flowi *fl) · 241 unmodified lines
242242 bool xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,
243243 unsigned short family)
244244 {
245+ if (family != sel->family && sel->family != AF_UNSPEC)
246+ return false;
247+
245248 switch (family) {
246249 case AF_INET:
247250 return __xfrm4_selector_match(sel, fl);
@@ -685,7 +688,7 @@ static void xfrm_byidx_resize(struct net *net) · 437 unmodified lines
685688
686689 static inline int xfrm_bydst_should_resize(struct net *net, int dir, int *total)
687690 {
688− unsigned int cnt = net->xfrm.policy_count[dir];
691+ unsigned int cnt = READ_ONCE(net->xfrm.policy_count[dir]);
689692 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask;
690693
691694 if (total)
@@ -711,12 +714,12 @@ static inline int xfrm_byidx_should_resize(struct net *net, int total) · 19 unmodified lines
711714
712715 void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si)
713716 {
714− si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN];
715− si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT];
716− si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD];
717− si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX];
718− si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX];
719− si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX];
717+ si->incnt = READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_IN]);
718+ si->outcnt = READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_OUT]);
719+ si->fwdcnt = READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_FWD]);
720+ si->inscnt = READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]);
721+ si->outscnt = READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]);
722+ si->fwdscnt = READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]);
720723 si->spdhcnt = net->xfrm.policy_idx_hmask;
721724 si->spdhmcnt = xfrm_policy_hashmax;
722725 }
@@ -2318,7 +2321,7 @@ static void __xfrm_policy_link(struct xfrm_policy *pol, int dir) · 1595 unmodified lines
23182321 }
23192322
23202323 list_add(&pol->walk.all, &net->xfrm.policy_all);
2321− net->xfrm.policy_count[dir]++;
2324+ WRITE_ONCE(net->xfrm.policy_count[dir], net->xfrm.policy_count[dir] + 1);
23222325 xfrm_pol_hold(pol);
23232326 }
23242327
@@ -2337,7 +2340,7 @@ static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol, · 12 unmodified lines
23372340 }
23382341
23392342 list_del_init(&pol->walk.all);
2340− net->xfrm.policy_count[dir]--;
2343+ WRITE_ONCE(net->xfrm.policy_count[dir], net->xfrm.policy_count[dir] - 1);
23412344
23422345 return pol;
23432346 }
@@ -3222,7 +3225,7 @@ struct dst_entry *xfrm_lookup_with_ifid(struct net *net, · 878 unmodified lines
32223225
32233226 /* To accelerate a bit... */
32243227 if (!if_id && ((dst_orig->flags & DST_NOXFRM) ||
3225− !net->xfrm.policy_count[XFRM_POLICY_OUT]))
3228+ !READ_ONCE(net->xfrm.policy_count[XFRM_POLICY_OUT])))
32263229 goto nopol;
32273230
32283231 xdst = xfrm_bundle_lookup(net, fl, family, dir, &xflo, if_id);
@@ -3296,7 +3299,7 @@ ok: · 67 unmodified lines
32963299
32973300 nopol:
32983301 if ((!dst_orig->dev || !(dst_orig->dev->flags & IFF_LOOPBACK)) &&
3299− net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK) {
3302+ READ_ONCE(net->xfrm.policy_default[dir]) == XFRM_USERPOLICY_BLOCK) {
33003303 err = -EPERM;
33013304 goto error;
33023305 }
@@ -3750,7 +3753,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, · 447 unmodified lines
37503753 const bool is_crypto_offload = sp &&
37513754 (xfrm_input_state(skb)->xso.type == XFRM_DEV_OFFLOAD_CRYPTO);
37523755
3753− if (net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK) {
3756+ if (READ_ONCE(net->xfrm.policy_default[dir]) == XFRM_USERPOLICY_BLOCK) {
37543757 XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOPOLS);
37553758 return 0;
37563759 }
net/xfrm/xfrm_state.c+15−8
@@ -1207,9 +1207,11 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark, · 1206 unmodified lines
12071207 struct hlist_head *state_cache_input;
12081208 struct xfrm_state *x = NULL;
12091209
1210+ /* BH is always disabled on the input path. */
1211+ lockdep_assert_in_softirq();
1212+
12101213 state_cache_input = raw_cpu_ptr(net->xfrm.state_cache_input);
12111214
1212− rcu_read_lock();
12131215 hlist_for_each_entry_rcu(x, state_cache_input, state_cache_input) {
12141216 if (x->props.family != family ||
12151217 x->id.spi != spi ||
@@ -1227,20 +1229,25 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark, · 11 unmodified lines
12271229 xfrm_hash_ptrs_get(net, &state_ptrs);
12281230
12291231 x = __xfrm_state_lookup(&state_ptrs, mark, daddr, spi, proto, family);
1230−
1231− if (x && x->km.state == XFRM_STATE_VALID) {
1232− spin_lock_bh(&net->xfrm.xfrm_state_lock);
1233− if (hlist_unhashed(&x->state_cache_input)) {
1232+ if (x) {
1233+ spin_lock(&net->xfrm.xfrm_state_lock);
1234+ if (x->km.state != XFRM_STATE_VALID) {
1235+ /*
1236+ * The state is about to be destroyed.
1237+ *
1238+ * Don't add it to the cache but still
1239+ * return it to the caller.
1240+ */
1241+ } else if (hlist_unhashed(&x->state_cache_input)) {
12341242 hlist_add_head_rcu(&x->state_cache_input, state_cache_input);
12351243 } else {
12361244 hlist_del_rcu(&x->state_cache_input);
12371245 hlist_add_head_rcu(&x->state_cache_input, state_cache_input);
12381246 }
1239− spin_unlock_bh(&net->xfrm.xfrm_state_lock);
1247+ spin_unlock(&net->xfrm.xfrm_state_lock);
12401248 }
12411249
12421250 out:
1243− rcu_read_unlock();
12441251 return x;
12451252 }
12461253 EXPORT_SYMBOL(xfrm_input_state_lookup);
@@ -3014,7 +3021,7 @@ int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, int optlen) · 1767 unmodified lines
30143021 if (IS_ERR(data))
30153022 return PTR_ERR(data);
30163023
3017− if (in_compat_syscall()) {
3024+ if (IS_ENABLED(CONFIG_COMPAT_FOR_U64_ALIGNMENT) && in_compat_syscall()) {
30183025 struct xfrm_translator *xtr = xfrm_get_translator();
30193026
30203027 if (!xtr) {
net/xfrm/xfrm_user.c+10−10
@@ -2511,9 +2511,9 @@ static int xfrm_notify_userpolicy(struct net *net) · 2510 unmodified lines
25112511 }
25122512
25132513 up = nlmsg_data(nlh);
2514− up->in = net->xfrm.policy_default[XFRM_POLICY_IN];
2515− up->fwd = net->xfrm.policy_default[XFRM_POLICY_FWD];
2516− up->out = net->xfrm.policy_default[XFRM_POLICY_OUT];
2514+ up->in = READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_IN]);
2515+ up->fwd = READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_FWD]);
2516+ up->out = READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_OUT]);
25172517
25182518 nlmsg_end(skb, nlh);
25192519
@@ -2537,13 +2537,13 @@ static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh, · 17 unmodified lines
25372537 struct xfrm_userpolicy_default *up = nlmsg_data(nlh);
25382538
25392539 if (xfrm_userpolicy_is_valid(up->in))
2540− net->xfrm.policy_default[XFRM_POLICY_IN] = up->in;
2540+ WRITE_ONCE(net->xfrm.policy_default[XFRM_POLICY_IN], up->in);
25412541
25422542 if (xfrm_userpolicy_is_valid(up->fwd))
2543− net->xfrm.policy_default[XFRM_POLICY_FWD] = up->fwd;
2543+ WRITE_ONCE(net->xfrm.policy_default[XFRM_POLICY_FWD], up->fwd);
25442544
25452545 if (xfrm_userpolicy_is_valid(up->out))
2546− net->xfrm.policy_default[XFRM_POLICY_OUT] = up->out;
2546+ WRITE_ONCE(net->xfrm.policy_default[XFRM_POLICY_OUT], up->out);
25472547
25482548 rt_genid_bump_all(net);
25492549
@@ -2573,9 +2573,9 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, · 23 unmodified lines
25732573 }
25742574
25752575 r_up = nlmsg_data(r_nlh);
2576− r_up->in = net->xfrm.policy_default[XFRM_POLICY_IN];
2577− r_up->fwd = net->xfrm.policy_default[XFRM_POLICY_FWD];
2578− r_up->out = net->xfrm.policy_default[XFRM_POLICY_OUT];
2576+ r_up->in = READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_IN]);
2577+ r_up->fwd = READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_FWD]);
2578+ r_up->out = READ_ONCE(net->xfrm.policy_default[XFRM_POLICY_OUT]);
25792579 nlmsg_end(r_skb, r_nlh);
25802580
25812581 return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, portid);
@@ -3835,7 +3835,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, · 1253 unmodified lines
38353835 if (!netlink_net_capable(skb, CAP_NET_ADMIN))
38363836 return -EPERM;
38373837
3838− if (in_compat_syscall()) {
3838+ if (IS_ENABLED(CONFIG_COMPAT_FOR_U64_ALIGNMENT) && in_compat_syscall()) {
38393839 struct xfrm_translator *xtr = xfrm_get_translator();
38403840
38413841 if (!xtr)
tools/net/ynl/Makefile+1−1
@@ -22,7 +22,7 @@ tests: | lib generated libynl.a · 21 unmodified lines
2222 ynltool: | lib generated libynl.a
2323 libynl.a: | lib generated
2424 @echo -e "\tAR $@"
25− @ar rcs $@ lib/ynl.o generated/*-user.o
25+ @$(AR) rcs $@ lib/ynl.o generated/*-user.o
2626
2727 $(SUBDIRS):
2828 @if [ -f "$@/Makefile" ] ; then \
tools/net/ynl/Makefile.deps+2−0
@@ -14,10 +14,12 @@ UAPI_PATH:=../../../../include/uapi/ · 13 unmodified lines
1414
1515 get_hdr_inc=-D$(1) -include $(UAPI_PATH)/linux/$(2)
1616 get_hdr_inc2=-D$(1) -D$(2) -include $(UAPI_PATH)/linux/$(3)
17+get_hdr_inc_drm=-D$(1) -include $(UAPI_PATH)/drm/$(2)
1718
1819 CFLAGS_dev-energymodel:=$(call get_hdr_inc,_LINUX_DEV_ENERGYMODEL_H,dev_energymodel.h)
1920 CFLAGS_devlink:=$(call get_hdr_inc,_LINUX_DEVLINK_H_,devlink.h)
2021 CFLAGS_dpll:=$(call get_hdr_inc,_LINUX_DPLL_H,dpll.h)
22+CFLAGS_drm_ras:=$(call get_hdr_inc_drm,_LINUX_DRM_RAS_H,drm_ras.h)
2123 CFLAGS_ethtool:=$(call get_hdr_inc,_LINUX_TYPELIMITS_H,typelimits.h) \
2224 $(call get_hdr_inc,_LINUX_ETHTOOL_H,ethtool.h) \
2325 $(call get_hdr_inc,_LINUX_ETHTOOL_NETLINK_H_,ethtool_netlink.h) \
tools/net/ynl/generated/Makefile+1−1
@@ -37,7 +37,7 @@ all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) $(RSTS) · 36 unmodified lines
3737
3838 protos.a: $(OBJS)
3939 @echo -e "\tAR $@"
40− @ar rcs $@ $(OBJS)
40+ @$(AR) rcs $@ $(OBJS)
4141
4242 %-user.h: $(SPECS_DIR)/%.yaml $(TOOL)
4343 @echo -e "\tGEN $@"
tools/net/ynl/lib/Makefile+1−1
@@ -15,7 +15,7 @@ all: ynl.a · 14 unmodified lines
1515
1616 ynl.a: $(OBJS)
1717 @echo -e "\tAR $@"
18− @ar rcs $@ $(OBJS)
18+ @$(AR) rcs $@ $(OBJS)
1919
2020 clean:
2121 rm -f *.o *.d *~
tools/testing/selftests/bpf/config+3−0
@@ -45,13 +45,16 @@ CONFIG_IPV6=y · 44 unmodified lines
4545 CONFIG_IPV6_FOU=y
4646 CONFIG_IPV6_FOU_TUNNEL=y
4747 CONFIG_IPV6_GRE=y
48+CONFIG_IPV6_IOAM6_LWTUNNEL=y
4849 CONFIG_IPV6_SEG6_BPF=y
50+CONFIG_IPV6_SEG6_LWTUNNEL=y
4951 CONFIG_IPV6_SIT=y
5052 CONFIG_IPV6_TUNNEL=y
5153 CONFIG_KEYS=y
5254 CONFIG_LIRC=y
5355 CONFIG_LIVEPATCH=y
5456 CONFIG_LWTUNNEL=y
57+CONFIG_LWTUNNEL_BPF=y
5558 CONFIG_MODULE_SIG=y
5659 CONFIG_MODULE_SRCVERSION_ALL=y
5760 CONFIG_MODULE_UNLOAD=y
tools/testing/selftests/bpf/prog_tests/test_xsk.c+54−42
@@ -7,7 +7,6 @@ · 6 unmodified lines
77 #include <linux/netdev.h>
88 #include <poll.h>
99 #include <pthread.h>
10−#include <signal.h>
1110 #include <string.h>
1211 #include <sys/mman.h>
1312 #include <sys/socket.h>
@@ -65,11 +64,6 @@ static void gen_eth_hdr(struct xsk_socket_info *xsk, struct ethhdr *eth_hdr) · 51 unmodified lines
6564 eth_hdr->h_proto = htons(ETH_P_LOOPBACK);
6665 }
6766
68−static bool is_umem_valid(struct xsk_socket_info *xsk)
69−{
70− return !!xsk->umem->umem;
71−}
72−
7367 static u32 mode_to_xdp_flags(enum test_mode mode)
7468 {
7569 return (mode == TEST_MODE_SKB) ? XDP_FLAGS_SKB_MODE : XDP_FLAGS_DRV_MODE;
@@ -1010,7 +1004,7 @@ static int __receive_pkts(struct test_spec *test, struct xsk_socket_info *xsk) · 934 unmodified lines
10101004 return TEST_FAILURE;
10111005
10121006 if (!ret) {
1013− if (!is_umem_valid(test->ifobj_tx->xsk))
1007+ if (test->poll_tmout)
10141008 return TEST_PASS;
10151009
10161010 ksft_print_msg("ERROR: [%s] Poll timed out\n", __func__);
@@ -1149,7 +1143,7 @@ static int receive_pkts(struct test_spec *test) · 132 unmodified lines
11491143 break;
11501144
11511145 res = __receive_pkts(test, xsk);
1152− if (!(res == TEST_PASS || res == TEST_CONTINUE))
1146+ if (res != TEST_CONTINUE)
11531147 return res;
11541148
11551149 ret = gettimeofday(&tv_now, NULL);
@@ -1166,7 +1160,8 @@ static int receive_pkts(struct test_spec *test) · 10 unmodified lines
11661160 return TEST_PASS;
11671161 }
11681162
1169−static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, bool timeout)
1163+static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk,
1164+ bool test_timeout)
11701165 {
11711166 u32 i, idx = 0, valid_pkts = 0, valid_frags = 0, buffer_len;
11721167 struct pkt_stream *pkt_stream = xsk->pkt_stream;
@@ -1178,7 +1173,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b · 5 unmodified lines
11781173 buffer_len = pkt_get_buffer_len(umem, pkt_stream->max_pkt_len);
11791174 /* pkts_in_flight might be negative if many invalid packets are sent */
11801175 if (pkts_in_flight >= (int)((umem_size(umem) - xsk->batch_size * buffer_len) /
1181− buffer_len)) {
1176+ buffer_len) && !test_timeout) {
11821177 ret = kick_tx(xsk);
11831178 if (ret)
11841179 return TEST_FAILURE;
@@ -1191,7 +1186,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b · 6 unmodified lines
11911186 while (xsk_ring_prod__reserve(&xsk->tx, xsk->batch_size, &idx) < xsk->batch_size) {
11921187 if (use_poll) {
11931188 ret = poll(&fds, 1, POLL_TMOUT);
1194− if (timeout) {
1189+ if (test_timeout) {
11951190 if (ret < 0) {
11961191 ksft_print_msg("ERROR: [%s] Poll error %d\n",
11971192 __func__, errno);
@@ -1271,7 +1266,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b · 73 unmodified lines
12711266 if (use_poll) {
12721267 ret = poll(&fds, 1, POLL_TMOUT);
12731268 if (ret <= 0) {
1274− if (ret == 0 && timeout)
1269+ if (ret == 0 && test_timeout)
12751270 return TEST_PASS;
12761271
12771272 ksft_print_msg("ERROR: [%s] Poll error %d\n", __func__, ret);
@@ -1279,14 +1274,14 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, b · 1 unmodified line
12791274 }
12801275 }
12811276
1282− if (!timeout) {
1277+ if (!test_timeout) {
12831278 if (complete_pkts(xsk, i))
12841279 return TEST_FAILURE;
12851280
12861281 usleep(10);
1287− return TEST_PASS;
12881282 }
12891283
1284+ /* Loop completion is driven by send_pkts() stream progress checks. */
12901285 return TEST_CONTINUE;
12911286 }
12921287
@@ -1322,7 +1317,6 @@ bool all_packets_sent(struct test_spec *test, unsigned long *bitmap) · 29 unmodified lines
13221317
13231318 static int send_pkts(struct test_spec *test, struct ifobject *ifobject)
13241319 {
1325− bool timeout = !is_umem_valid(test->ifobj_rx->xsk);
13261320 DECLARE_BITMAP(bitmap, test->nb_sockets);
13271321 u32 i, ret;
13281322
@@ -1337,19 +1331,18 @@ static int send_pkts(struct test_spec *test, struct ifobject *ifobject) · 8 unmodified lines
13371331 __set_bit(i, bitmap);
13381332 continue;
13391333 }
1340− ret = __send_pkts(ifobject, &ifobject->xsk_arr[i], timeout);
1341− if (ret == TEST_CONTINUE && !test->fail)
1342− continue;
1343−
1344− if ((ret || test->fail) && !timeout)
1345− return TEST_FAILURE;
1346−
1347− if (ret == TEST_PASS && timeout)
1334+ ret = __send_pkts(ifobject, &ifobject->xsk_arr[i], test->poll_tmout);
1335+ if (ret != TEST_CONTINUE)
13481336 return ret;
13491337
1350− ret = wait_for_tx_completion(&ifobject->xsk_arr[i]);
1351− if (ret)
1338+ if (test->fail)
13521339 return TEST_FAILURE;
1340+
1341+ if (!test->poll_tmout) {
1342+ ret = wait_for_tx_completion(&ifobject->xsk_arr[i]);
1343+ if (ret)
1344+ return TEST_FAILURE;
1345+ }
13531346 }
13541347 }
13551348
@@ -1677,7 +1670,8 @@ void *worker_testapp_validate_rx(void *arg) · 321 unmodified lines
16771670 strerror(-err));
16781671 }
16791672
1680− pthread_barrier_wait(&barr);
1673+ if (test->use_barrier)
1674+ pthread_barrier_wait(&barr);
16811675
16821676 /* We leave only now in case of error to avoid getting stuck in the barrier */
16831677 if (err) {
@@ -1716,11 +1710,6 @@ static void testapp_clean_xsk_umem(struct ifobject *ifobj) · 32 unmodified lines
17161710 munmap(umem->buffer, umem->mmap_size);
17171711 }
17181712
1719−static void handler(int signum)
1720−{
1721− pthread_exit(NULL);
1722−}
1723−
17241713 static bool xdp_prog_changed_rx(struct test_spec *test)
17251714 {
17261715 struct ifobject *ifobj = test->ifobj_rx;
@@ -1825,9 +1814,18 @@ static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *i · 98 unmodified lines
18251814 return TEST_FAILURE;
18261815 }
18271816
1828− if (ifobj2) {
1817+ err = xsk_attach_xdp_progs(test, ifobj1, ifobj2);
1818+ if (err) {
1819+ ksft_print_msg("Error: failed to attach XDP programs: %d (%s)\n",
1820+ err, strerror(-err));
1821+ return TEST_FAILURE;
1822+ }
1823+ test->use_barrier = !!ifobj2;
1824+
1825+ if (test->use_barrier) {
18291826 if (pthread_barrier_init(&barr, NULL, 2))
18301827 return TEST_FAILURE;
1828+
18311829 pkt_stream_reset(ifobj2->xsk->pkt_stream);
18321830 }
18331831
@@ -1835,27 +1833,26 @@ static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *i · 1 unmodified line
18351833 pkt_stream_reset(ifobj1->xsk->pkt_stream);
18361834 pkts_in_flight = 0;
18371835
1838− signal(SIGUSR1, handler);
18391836 /*Spawn RX thread */
18401837 pthread_create(&t0, NULL, ifobj1->func_ptr, test);
18411838
1842− if (ifobj2) {
1839+ if (test->use_barrier) {
18431840 pthread_barrier_wait(&barr);
18441841 if (pthread_barrier_destroy(&barr)) {
1845− pthread_kill(t0, SIGUSR1);
1842+ test->use_barrier = false;
1843+ pthread_join(t0, NULL);
18461844 clean_sockets(test, ifobj1);
18471845 clean_umem(test, ifobj1, NULL);
18481846 return TEST_FAILURE;
18491847 }
1848+ }
18501849
1850+ if (ifobj2) {
18511851 /*Spawn TX thread */
18521852 pthread_create(&t1, NULL, ifobj2->func_ptr, test);
1853−
18541853 pthread_join(t1, NULL);
18551854 }
18561855
1857− if (!ifobj2)
1858− pthread_kill(t0, SIGUSR1);
18591856 pthread_join(t0, NULL);
18601857
18611858 if (test->total_steps == test->current_step || test->fail) {
@@ -1893,8 +1890,6 @@ static int testapp_validate_traffic(struct test_spec *test) · 31 unmodified lines
18931890 }
18941891 }
18951892
1896− if (xsk_attach_xdp_progs(test, ifobj_rx, ifobj_tx))
1897− return TEST_FAILURE;
18981893 return __testapp_validate_traffic(test, ifobj_rx, ifobj_tx);
18991894 }
19001895
@@ -2231,16 +2226,33 @@ int testapp_xdp_shared_umem(struct test_spec *test) · 330 unmodified lines
22312226
22322227 int testapp_poll_txq_tmout(struct test_spec *test)
22332228 {
2229+ bool shared_umem = test->ifobj_tx->shared_umem;
2230+ int ret;
2231+
2232+ test->poll_tmout = true;
2233+ /*
2234+ * POLL_TXQ_FULL exercises TX timeout setup in isolation.
2235+ * Keep TX out of shared-UMEM mode here so TX setup does not require
2236+ * RX UMEM to be initialized first.
2237+ */
2238+ test->ifobj_tx->shared_umem = false;
22342239 test->ifobj_tx->use_poll = true;
22352240 /* create invalid frame by set umem frame_size and pkt length equal to 2048 */
22362241 test->ifobj_tx->xsk->umem->frame_size = 2048;
2237− if (pkt_stream_replace(test, 2 * DEFAULT_PKT_CNT, 2048))
2242+ if (pkt_stream_replace(test, 2 * DEFAULT_PKT_CNT, 2048)) {
2243+ test->ifobj_tx->shared_umem = shared_umem;
22382244 return TEST_FAILURE;
2239− return testapp_validate_traffic_single_thread(test, test->ifobj_tx);
2245+ }
2246+
2247+ ret = testapp_validate_traffic_single_thread(test, test->ifobj_tx);
2248+ test->ifobj_tx->shared_umem = shared_umem;
2249+
2250+ return ret;
22402251 }
22412252
22422253 int testapp_poll_rxq_tmout(struct test_spec *test)
22432254 {
2255+ test->poll_tmout = true;
22442256 test->ifobj_rx->use_poll = true;
22452257 return testapp_validate_traffic_single_thread(test, test->ifobj_rx);
22462258 }
tools/testing/selftests/bpf/prog_tests/test_xsk.h+2−0
@@ -207,6 +207,8 @@ struct test_spec { · 206 unmodified lines
207207 bool set_ring;
208208 bool adjust_tail;
209209 bool adjust_tail_support;
210+ bool poll_tmout;
211+ bool use_barrier;
210212 enum test_mode mode;
211213 char name[MAX_TEST_NAME_SIZE];
212214 };
tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c+175−0
@@ -1,6 +1,8 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <test_progs.h>
33 #include <network_helpers.h>
4+#include <linux/ipv6.h>
5+#include <arpa/inet.h>
46 #include "test_xdp_context_test_run.skel.h"
57 #include "test_xdp_meta.skel.h"
68
@@ -8,9 +10,12 @@ · 1 unmodified line
810 #define TX_NAME "veth1"
911 #define TX_NETNS "xdp_context_tx"
1012 #define RX_NETNS "xdp_context_rx"
13+#define RX_MAC "02:00:00:00:00:01"
14+#define TX_MAC "02:00:00:00:00:02"
1115 #define TAP_NAME "tap0"
1216 #define DUMMY_NAME "dum0"
1317 #define TAP_NETNS "xdp_context_tuntap"
18+#define LWT_NETNS "xdp_context_lwt"
1419
1520 #define TEST_PAYLOAD_LEN 32
1621 static const __u8 test_payload[TEST_PAYLOAD_LEN] = {
@@ -187,6 +192,42 @@ static int write_test_packet(int tap_fd) · 170 unmodified lines
187192 return 0;
188193 }
189194
195+/* Inject Ethernet+IPv6+UDP frame into TAP */
196+static int write_test_packet_udp(int tap_fd)
197+{
198+ __u8 pkt[sizeof(struct ethhdr) + sizeof(struct ipv6hdr) +
199+ sizeof(struct udphdr) + TEST_PAYLOAD_LEN] = {};
200+ struct ethhdr *eth = (void *)pkt;
201+ struct ipv6hdr *ip6 = (void *)(eth + 1);
202+ struct udphdr *udp = (void *)(ip6 + 1);
203+ __u8 *payload = (void *)(udp + 1);
204+ const __u8 tap_mac[ETH_ALEN] = { 0x02, 0, 0, 0, 0, 0x01 };
205+ int n;
206+
207+ memcpy(eth->h_dest, tap_mac, ETH_ALEN);
208+ eth->h_proto = htons(ETH_P_IPV6);
209+
210+ ip6->version = 6;
211+ ip6->hop_limit = 64;
212+ ip6->nexthdr = IPPROTO_UDP;
213+ ip6->payload_len = htons(sizeof(*udp) + TEST_PAYLOAD_LEN);
214+ inet_pton(AF_INET6, "fd00::2", &ip6->saddr);
215+ inet_pton(AF_INET6, "fd00:1::1", &ip6->daddr);
216+
217+ udp->source = htons(42);
218+ udp->dest = htons(42);
219+ udp->len = htons(sizeof(*udp) + TEST_PAYLOAD_LEN);
220+ /* UDP checksum is not validated on the forwarding path. */
221+
222+ memcpy(payload, test_payload, TEST_PAYLOAD_LEN);
223+
224+ n = write(tap_fd, pkt, sizeof(pkt));
225+ if (!ASSERT_EQ(n, sizeof(pkt), "write frame"))
226+ return -1;
227+
228+ return 0;
229+}
230+
190231 static void dump_err_stream(const struct bpf_program *prog)
191232 {
192233 char buf[512];
@@ -518,3 +559,137 @@ void test_xdp_context_tuntap(void) · 325 unmodified lines
518559
519560 test_xdp_meta__destroy(skel);
520561 }
562+
563+/*
564+ * Test topology:
565+ *
566+ * tap0 fd00::1
567+ * RX: injected IPv6 UDP frame, XDP ingress sets metadata
568+ * fwd: encap route prepends outer header(s)
569+ * TX: TC egress validates metadata
570+ *
571+ * A routable IPv6 UDP frame is written into the tap fd, so it enters the RX
572+ * path where XDP stores metadata. Routing then forwards it back out the same
573+ * tap through an encapsulating route that prepends outer header(s). The TC
574+ * egress program checks that the pushed header did not silently corrupt
575+ * metadata.
576+ */
577+#define LWT_PIN_PATH "/sys/fs/bpf/xdp_context_lwt_xmit"
578+
579+enum lwt_encap_type {
580+ LWT_ENCAP_BPF,
581+ LWT_ENCAP_MPLS,
582+ LWT_ENCAP_SEG6,
583+ LWT_ENCAP_IOAM6,
584+};
585+
586+static void test_lwt_encap(struct test_xdp_meta *skel,
587+ enum lwt_encap_type type)
588+{
589+ LIBBPF_OPTS(bpf_tc_hook, tc_hook, .attach_point = BPF_TC_EGRESS);
590+ LIBBPF_OPTS(bpf_tc_opts, tc_opts, .handle = 1, .priority = 1);
591+ struct bpf_program *lwt_prog = NULL;
592+ struct netns_obj *ns = NULL;
593+ const char *encap;
594+ bool pinned = false;
595+ int tap_ifindex;
596+ int tap_fd = -1;
597+ int ret;
598+
599+ skel->bss->test_pass = false;
600+
601+ switch (type) {
602+ case LWT_ENCAP_BPF:
603+ encap = "encap bpf xmit pinned " LWT_PIN_PATH " via fd00::2";
604+ lwt_prog = skel->progs.dummy_lwt_xmit;
605+ break;
606+ case LWT_ENCAP_MPLS:
607+ encap = "encap mpls 100 via inet6 fd00::2";
608+ break;
609+ case LWT_ENCAP_SEG6:
610+ encap = "encap seg6 mode encap segs fd00::2";
611+ break;
612+ case LWT_ENCAP_IOAM6:
613+ encap = "encap ioam6 mode encap tundst fd00::2 "
614+ "trace prealloc type 0x800000 ns 0 size 4 via fd00::2";
615+ break;
616+ default:
617+ return;
618+ }
619+
620+ if (lwt_prog) {
621+ unlink(LWT_PIN_PATH);
622+ ret = bpf_program__pin(lwt_prog, LWT_PIN_PATH);
623+ if (!ASSERT_OK(ret, "pin lwt prog"))
624+ return;
625+ pinned = true;
626+ }
627+
628+ ns = netns_new(LWT_NETNS, true);
629+ if (!ASSERT_OK_PTR(ns, "netns_new"))
630+ goto close;
631+
632+ tap_fd = open_tuntap(TAP_NAME, true);
633+ if (!ASSERT_GE(tap_fd, 0, "open_tuntap"))
634+ goto close;
635+
636+ SYS(close, "ip link set dev " TAP_NAME " address " RX_MAC);
637+ SYS(close, "sysctl -wq net.ipv6.conf.all.forwarding=1");
638+ SYS(close, "ip addr add fd00::1/64 dev " TAP_NAME " nodad");
639+ SYS(close, "ip link set dev " TAP_NAME " up");
640+ SYS(close, "ip neigh add fd00::2 lladdr " TX_MAC " nud permanent dev " TAP_NAME);
641+ SYS(close, "ip -6 route add fd00:1::/64 %s dev %s", encap, TAP_NAME);
642+
643+ tap_ifindex = if_nametoindex(TAP_NAME);
644+ if (!ASSERT_GE(tap_ifindex, 0, "if_nametoindex"))
645+ goto close;
646+
647+ ret = bpf_xdp_attach(tap_ifindex, bpf_program__fd(skel->progs.ing_xdp),
648+ 0, NULL);
649+ if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
650+ goto close;
651+
652+ tc_hook.ifindex = tap_ifindex;
653+ ret = bpf_tc_hook_create(&tc_hook);
654+ if (!ASSERT_OK(ret, "bpf_tc_hook_create"))
655+ goto close;
656+
657+ tc_opts.prog_fd = bpf_program__fd(skel->progs.tc_is_meta_empty);
658+ ret = bpf_tc_attach(&tc_hook, &tc_opts);
659+ if (!ASSERT_OK(ret, "bpf_tc_attach"))
660+ goto close;
661+
662+ ret = write_test_packet_udp(tap_fd);
663+ if (!ASSERT_OK(ret, "write_test_packet_udp"))
664+ goto close;
665+
666+ if (!ASSERT_TRUE(skel->bss->test_pass, "test_pass"))
667+ dump_err_stream(skel->progs.tc_is_meta_empty);
668+
669+close:
670+ if (tap_fd >= 0)
671+ close(tap_fd);
672+ netns_free(ns);
673+ if (pinned)
674+ unlink(LWT_PIN_PATH);
675+}
676+
677+void test_xdp_context_lwt_encap(void)
678+{
679+ struct test_xdp_meta *skel;
680+
681+ skel = test_xdp_meta__open_and_load();
682+ if (!ASSERT_OK_PTR(skel, "open and load skeleton"))
683+ return;
684+
685+ if (test__start_subtest("bpf_encap"))
686+ test_lwt_encap(skel, LWT_ENCAP_BPF);
687+ if (test__start_subtest("mpls_encap"))
688+ test_lwt_encap(skel, LWT_ENCAP_MPLS);
689+ if (test__start_subtest("seg6_encap"))
690+ test_lwt_encap(skel, LWT_ENCAP_SEG6);
691+ if (test__start_subtest("ioam6_encap"))
692+ test_lwt_encap(skel, LWT_ENCAP_IOAM6);
693+
694+ test_xdp_meta__destroy(skel);
695+}
tools/testing/selftests/bpf/progs/test_xdp_meta.c+71−52
@@ -21,10 +21,6 @@ · 20 unmodified lines
2121
2222 bool test_pass;
2323
24−static const __u8 smac_want[ETH_ALEN] = {
25− 0x12, 0x34, 0xDE, 0xAD, 0xBE, 0xEF,
26−};
27−
2824 static const __u8 meta_want[META_SIZE] = {
2925 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
3026 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
@@ -32,11 +28,6 @@ static const __u8 meta_want[META_SIZE] = { · 1 unmodified line
3228 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
3329 };
3430
35−static bool check_smac(const struct ethhdr *eth)
36−{
37− return !__builtin_memcmp(eth->h_source, smac_want, ETH_ALEN);
38−}
39−
4031 static bool check_metadata(const char *file, int line, __u8 *meta_have)
4132 {
4233 if (!__builtin_memcmp(meta_have, meta_want, META_SIZE))
@@ -280,18 +271,47 @@ fail: · 237 unmodified lines
280271 return TC_ACT_SHOT;
281272 }
282273
274+/* Test packets carry test metadata pattern as payload. */
275+static bool is_test_packet_xdp(struct xdp_md *ctx)
276+{
277+ __u8 meta_have[META_SIZE];
278+ __u32 len;
279+
280+ len = bpf_xdp_get_buff_len(ctx);
281+ if (len < META_SIZE)
282+ return false;
283+ if (bpf_xdp_load_bytes(ctx, len - META_SIZE, meta_have, META_SIZE))
284+ return false;
285+ if (__builtin_memcmp(meta_have, meta_want, META_SIZE))
286+ return false;
287+
288+ return true;
289+}
290+
291+/* Test packets carry test metadata pattern as payload. */
292+static bool is_test_packet_tc(struct __sk_buff *ctx)
293+{
294+ __u8 meta_have[META_SIZE];
295+
296+ if (ctx->len < META_SIZE)
297+ return false;
298+ if (bpf_skb_load_bytes(ctx, ctx->len - META_SIZE, meta_have, META_SIZE))
299+ return false;
300+ if (__builtin_memcmp(meta_have, meta_want, META_SIZE))
301+ return false;
302+
303+ return true;
304+}
305+
283306 /* Reserve and clear space for metadata but don't populate it */
284307 SEC("xdp")
285308 int ing_xdp_zalloc_meta(struct xdp_md *ctx)
286309 {
287− struct ethhdr *eth = ctx_ptr(ctx, data);
288310 __u8 *meta;
289311 int ret;
290312
291313 /* Drop any non-test packets */
292− if (eth + 1 > ctx_ptr(ctx, data_end))
293− return XDP_DROP;
294− if (!check_smac(eth))
314+ if (!is_test_packet_xdp(ctx))
295315 return XDP_DROP;
296316
297317 ret = bpf_xdp_adjust_meta(ctx, -META_SIZE);
@@ -310,33 +330,24 @@ int ing_xdp_zalloc_meta(struct xdp_md *ctx) · 12 unmodified lines
310330 SEC("xdp")
311331 int ing_xdp(struct xdp_md *ctx)
312332 {
313− __u8 *data, *data_meta, *data_end, *payload;
314− struct ethhdr *eth;
333+ __u8 *data, *data_meta;
315334 int ret;
316335
336+ /* Drop any non-test packets */
337+ if (!is_test_packet_xdp(ctx))
338+ return XDP_DROP;
339+
317340 ret = bpf_xdp_adjust_meta(ctx, -META_SIZE);
318341 if (ret < 0)
319342 return XDP_DROP;
320343
321344 data_meta = ctx_ptr(ctx, data_meta);
322− data_end = ctx_ptr(ctx, data_end);
323345 data = ctx_ptr(ctx, data);
324346
325− eth = (struct ethhdr *)data;
326− payload = data + sizeof(struct ethhdr);
327−
328− if (payload + META_SIZE > data_end ||
329− data_meta + META_SIZE > data)
347+ if (data_meta + META_SIZE > data)
330348 return XDP_DROP;
331349
332− /* The Linux networking stack may send other packets on the test
333− * interface that interfere with the test. Just drop them.
334− * The test packets can be recognized by their source MAC address.
335− */
336− if (!check_smac(eth))
337− return XDP_DROP;
338−
339− __builtin_memcpy(data_meta, payload, META_SIZE);
350+ __builtin_memcpy(data_meta, meta_want, META_SIZE);
340351 return XDP_PASS;
341352 }
342353
@@ -353,7 +364,7 @@ int clone_data_meta_survives_data_write(struct __sk_buff *ctx) · 10 unmodified lines
353364 if (eth + 1 > ctx_ptr(ctx, data_end))
354365 goto out;
355366 /* Ignore non-test packets */
356− if (!check_smac(eth))
367+ if (!is_test_packet_tc(ctx))
357368 goto out;
358369
359370 if (meta_have + META_SIZE > eth)
@@ -383,7 +394,7 @@ int clone_data_meta_survives_meta_write(struct __sk_buff *ctx) · 23 unmodified lines
383394 if (eth + 1 > ctx_ptr(ctx, data_end))
384395 goto out;
385396 /* Ignore non-test packets */
386− if (!check_smac(eth))
397+ if (!is_test_packet_tc(ctx))
387398 goto out;
388399
389400 if (meta_have + META_SIZE > eth)
@@ -416,7 +427,7 @@ int clone_meta_dynptr_survives_data_slice_write(struct __sk_buff *ctx) · 26 unmodified lines
416427 if (!eth)
417428 goto out;
418429 /* Ignore non-test packets */
419− if (!check_smac(eth))
430+ if (!is_test_packet_tc(ctx))
420431 goto out;
421432
422433 bpf_dynptr_from_skb_meta(ctx, 0, &meta);
@@ -436,16 +447,11 @@ out: · 13 unmodified lines
436447 SEC("tc")
437448 int clone_meta_dynptr_survives_meta_slice_write(struct __sk_buff *ctx)
438449 {
439− struct bpf_dynptr data, meta;
440− const struct ethhdr *eth;
450+ struct bpf_dynptr meta;
441451 __u8 *meta_have;
442452
443− bpf_dynptr_from_skb(ctx, 0, &data);
444− eth = bpf_dynptr_slice(&data, 0, NULL, sizeof(*eth));
445− if (!eth)
446− goto out;
447453 /* Ignore non-test packets */
448− if (!check_smac(eth))
454+ if (!is_test_packet_tc(ctx))
449455 goto out;
450456
451457 bpf_dynptr_from_skb_meta(ctx, 0, &meta);
@@ -471,15 +477,10 @@ int clone_meta_dynptr_rw_before_data_dynptr_write(struct __sk_buff *ctx) · 19 unmodified lines
471477 {
472478 struct bpf_dynptr data, meta;
473479 __u8 meta_have[META_SIZE];
474− const struct ethhdr *eth;
475480 int err;
476481
477− bpf_dynptr_from_skb(ctx, 0, &data);
478− eth = bpf_dynptr_slice(&data, 0, NULL, sizeof(*eth));
479− if (!eth)
480− goto out;
481482 /* Ignore non-test packets */
482− if (!check_smac(eth))
483+ if (!is_test_packet_tc(ctx))
483484 goto out;
484485
485486 /* Expect read-write metadata before unclone */
@@ -492,6 +493,7 @@ int clone_meta_dynptr_rw_before_data_dynptr_write(struct __sk_buff *ctx) · 6 unmodified lines
492493 goto out;
493494
494495 /* Helper write to payload will unclone the packet */
496+ bpf_dynptr_from_skb(ctx, 0, &data);
495497 bpf_dynptr_write(&data, offsetof(struct ethhdr, h_proto), "x", 1, 0);
496498
497499 err = bpf_dynptr_read(meta_have, META_SIZE, &meta, 0, 0);
@@ -511,17 +513,12 @@ out: · 13 unmodified lines
511513 SEC("tc")
512514 int clone_meta_dynptr_rw_before_meta_dynptr_write(struct __sk_buff *ctx)
513515 {
514− struct bpf_dynptr data, meta;
516+ struct bpf_dynptr meta;
515517 __u8 meta_have[META_SIZE];
516− const struct ethhdr *eth;
517518 int err;
518519
519− bpf_dynptr_from_skb(ctx, 0, &data);
520− eth = bpf_dynptr_slice(&data, 0, NULL, sizeof(*eth));
521− if (!eth)
522− goto out;
523520 /* Ignore non-test packets */
524− if (!check_smac(eth))
521+ if (!is_test_packet_tc(ctx))
525522 goto out;
526523
527524 /* Expect read-write metadata before unclone */
@@ -545,6 +542,28 @@ out: · 17 unmodified lines
545542 return TC_ACT_SHOT;
546543 }
547544
545+SEC("lwt_xmit")
546+int dummy_lwt_xmit(struct __sk_buff *ctx)
547+{
548+ if (bpf_skb_change_head(ctx, sizeof(struct ipv6hdr), 0))
549+ return BPF_DROP;
550+
551+ return BPF_OK;
552+}
553+
554+SEC("tc")
555+int tc_is_meta_empty(struct __sk_buff *ctx)
556+{
557+ if (!is_test_packet_tc(ctx))
558+ return TC_ACT_OK;
559+
560+ if (ctx->data_meta != ctx->data)
561+ return TC_ACT_OK;
562+
563+ test_pass = true;
564+ return TC_ACT_OK;
565+}
566+
548567 SEC("tc")
549568 int helper_skb_vlan_push_pop(struct __sk_buff *ctx)
550569 {
tools/testing/selftests/drivers/net/bonding/Makefile+1−0
@@ -13,6 +13,7 @@ TEST_PROGS := \ · 12 unmodified lines
1313 bond_options.sh \
1414 bond_passive_lacp.sh \
1515 bond_stacked_header_parse.sh \
16+ bond_vlan_real_dev.sh \
1617 dev_addr_lists.sh \
1718 mode-1-recovery-updelay.sh \
1819 mode-2-recovery-updelay.sh \
tools/testing/selftests/drivers/net/bonding/bond_vlan_real_dev.sh+180−0
@@ -0,0 +1,180 @@
1+#!/bin/bash
2+# SPDX-License-Identifier: GPL-2.0
3+#
4+# Test propagation of a real device's state to the VLANs stacked on top of it
5+# when the real device is (or becomes) a bond member.
6+#
7+# The kernel mirrors a real device's UP/DOWN, MTU and feature changes onto its
8+# VLANs. This is done asynchronously (netdev_work): doing it synchronously from
9+# the real device's notifier could deadlock. If the real device is brought up
10+# while enslaved to a bond - so its instance lock is held across NETDEV_UP - and
11+# a VLAN on top of it is itself a bond member, the synchronous propagation
12+# re-entered the stack and tried to take the same instance lock again.
13+#
14+# Cover both halves:
15+# - the deferred UP/DOWN, MTU and feature propagation actually lands on the
16+# VLAN (link state and MTU use an ops-locked dummy, i.e. the deferral path),
17+# - the deadlock-prone topology - a VLAN on a dummy, with the VLAN and the
18+# dummy each enslaved to a different bond - can be built without hanging.
19+
20+ALL_TESTS="
21+ vlan_link_state
22+ vlan_mtu
23+ vlan_features
24+ vlan_real_dev_enslave
25+"
26+
27+REQUIRE_MZ=no
28+NUM_NETIFS=0
29+lib_dir=$(dirname "$0")
30+source "$lib_dir"/../../../net/forwarding/lib.sh
31+
32+# Return 0 if $dev in netns $ns has flag $flag set (e.g. UP) in its <...> flags.
33+link_has_flag()
34+{
35+ local ns=$1 dev=$2 flag=$3
36+
37+ ip -n "$ns" link show dev "$dev" 2>/dev/null | grep -q "[<,]${flag}[,>]"
38+}
39+
40+link_lacks_flag()
41+{
42+ ! link_has_flag "$@"
43+}
44+
45+link_mtu_is()
46+{
47+ local ns=$1 dev=$2 want=$3 cur
48+
49+ cur=$(ip -n "$ns" link show dev "$dev" 2>/dev/null | \
50+ sed -n 's/.* mtu \([0-9]\+\).*/\1/p')
51+ [ "$cur" = "$want" ]
52+}
53+
54+vlan_feature_is()
55+{
56+ local ns=$1 dev=$2 feature=$3 value=$4
57+
58+ ip netns exec "$ns" ethtool -k "$dev" 2>/dev/null | \
59+ grep -q "^$feature: $value"
60+}
61+
62+link_has_master()
63+{
64+ local ns=$1 dev=$2 master=$3
65+
66+ ip -n "$ns" -o link show dev "$dev" 2>/dev/null | grep -q "master $master"
67+}
68+
69+vlan_link_state()
70+{
71+ RET=0
72+
73+ ip -n "$NS" link add ls_dummy type dummy
74+ ip -n "$NS" link add link ls_dummy name ls_vlan type vlan id 100
75+
76+ # Bringing the real device up must propagate UP to the VLAN.
77+ ip -n "$NS" link set ls_dummy up
78+ busywait "$BUSYWAIT_TIMEOUT" link_has_flag "$NS" ls_vlan UP
79+ check_err $? "VLAN did not go UP after the real device went UP"
80+
81+ # ... and likewise for DOWN.
82+ ip -n "$NS" link set ls_dummy down
83+ busywait "$BUSYWAIT_TIMEOUT" link_lacks_flag "$NS" ls_vlan UP
84+ check_err $? "VLAN did not go DOWN after the real device went DOWN"
85+
86+ ip -n "$NS" link del ls_vlan
87+ ip -n "$NS" link del ls_dummy
88+
89+ log_test "VLAN link state follows the real device"
90+}
91+
92+vlan_mtu()
93+{
94+ RET=0
95+
96+ # The VLAN inherits the real device's MTU (2000) at creation time.
97+ ip -n "$NS" link add mtu_dummy mtu 2000 type dummy
98+ ip -n "$NS" link add link mtu_dummy name mtu_vlan type vlan id 100
99+
100+ # Shrinking the real device's MTU must clamp the VLAN's MTU.
101+ ip -n "$NS" link set mtu_dummy mtu 1500
102+ busywait "$BUSYWAIT_TIMEOUT" link_mtu_is "$NS" mtu_vlan 1500
103+ check_err $? "VLAN MTU not clamped after the real device's MTU shrank"
104+
105+ ip -n "$NS" link del mtu_vlan
106+ ip -n "$NS" link del mtu_dummy
107+
108+ log_test "VLAN MTU clamped to the real device"
109+}
110+
111+vlan_features()
112+{
113+ RET=0
114+
115+ # Use veth as the real device: unlike dummy it exports vlan_features, so
116+ # the VLAN actually inherits a toggleable offload to assert on.
117+ ip -n "$NS" link add ft_veth type veth peer name ft_veth_pr
118+ ip -n "$NS" link add link ft_veth name ft_vlan type vlan id 100
119+
120+ vlan_feature_is "$NS" ft_vlan scatter-gather on
121+ check_err $? "VLAN did not inherit scatter-gather from the real device"
122+
123+ # Toggling the offload on the real device must propagate to the VLAN.
124+ ip netns exec "$NS" ethtool -K ft_veth sg off
125+ busywait "$BUSYWAIT_TIMEOUT" \
126+ vlan_feature_is "$NS" ft_vlan scatter-gather off
127+ check_err $? "VLAN scatter-gather still on after disabling it on real dev"
128+
129+ ip netns exec "$NS" ethtool -K ft_veth sg on
130+ busywait "$BUSYWAIT_TIMEOUT" \
131+ vlan_feature_is "$NS" ft_vlan scatter-gather on
132+ check_err $? "VLAN scatter-gather still off after enabling it on real dev"
133+
134+ ip -n "$NS" link del ft_vlan
135+ ip -n "$NS" link del ft_veth
136+
137+ log_test "VLAN features follow the real device"
138+}
139+
140+vlan_real_dev_enslave()
141+{
142+ RET=0
143+
144+ # dummy <- VLAN -> bond0, then enslave the dummy itself to bond1. The
145+ # last step brings the dummy up under bond1's instance lock, which used
146+ # to deadlock while synchronously propagating UP to the (bond-enslaved)
147+ # VLAN on top.
148+ ip -n "$NS" link add dl_dummy type dummy
149+ ip -n "$NS" link set dl_dummy up
150+ ip -n "$NS" link add link dl_dummy name dl_vlan type vlan id 100
151+
152+ ip -n "$NS" link add dl_bond0 type bond mode active-backup
153+ ip -n "$NS" link set dl_vlan down
154+ ip -n "$NS" link set dl_vlan master dl_bond0
155+ check_err $? "could not enslave the VLAN to bond0"
156+
157+ ip -n "$NS" link add dl_bond1 type bond mode active-backup
158+ ip -n "$NS" link set dl_dummy down
159+ ip -n "$NS" link set dl_dummy master dl_bond1
160+ check_err $? "could not enslave the real device to bond1"
161+
162+ # If we got here the kernel did not deadlock; make sure it is still
163+ # responsive and the enslave really took effect.
164+ link_has_master "$NS" dl_dummy dl_bond1
165+ check_err $? "real device not enslaved to bond1"
166+
167+ ip -n "$NS" link del dl_bond1
168+ ip -n "$NS" link del dl_bond0
169+ ip -n "$NS" link del dl_vlan
170+ ip -n "$NS" link del dl_dummy
171+
172+ log_test "VLAN real device enslaved to a second bond"
173+}
174+
175+setup_ns NS
176+trap 'cleanup_ns $NS' EXIT
177+
178+tests_run
179+
180+exit "$EXIT_STATUS"
tools/testing/selftests/drivers/net/so_txtime.c+1−1
@@ -37,7 +37,7 @@ · 36 unmodified lines
3737
3838 static int cfg_clockid = CLOCK_TAI;
3939 static uint16_t cfg_port = 8000;
40−static int cfg_variance_us = 4000;
40+static int cfg_variance_us = 8000;
4141 static bool cfg_machine_slow;
4242 static uint64_t cfg_start_time_ns;
4343 static int cfg_mark;
tools/testing/selftests/net/broadcast_ether_dst.sh+1−1
@@ -44,7 +44,7 @@ test_broadcast_ether_dst() { · 43 unmodified lines
4444 # tcpdump will exit after receiving a single packet
4545 # timeout will kill tcpdump if it is still running after 2s
4646 timeout 2s ip netns exec "${CLIENT_NS}" \
47− tcpdump -i link0 -c 1 -w "${CAPFILE}" icmp &> "${OUTPUT}" &
47+ tcpdump -i link0 -c 1 -w "${CAPFILE}" -Z root icmp &> "${OUTPUT}" &
4848 pid=$!
4949 slowwait 1 grep -qs "listening" "${OUTPUT}"
5050
tools/testing/selftests/net/netfilter/conntrack_sctp_collision.sh+67−22
@@ -2,18 +2,32 @@ · 1 unmodified line
22 # SPDX-License-Identifier: GPL-2.0
33 #
44 # Testing For SCTP COLLISION SCENARIO as Below:
5−#
5+# 1. Stale INIT_ACK capture:
66 # 14:35:47.655279 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT] [init tag: 2017837359]
77 # 14:35:48.353250 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT] [init tag: 1187206187]
88 # 14:35:48.353275 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT ACK] [init tag: 2017837359]
99 # 14:35:48.353283 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [COOKIE ECHO]
1010 # 14:35:48.353977 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [COOKIE ACK]
1111 # 14:35:48.855335 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT ACK] [init tag: 164579970]
12+# (Delayed)
13+#
14+# 2. Stale INIT capture:
15+# 14:35:48.353250 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT] [init tag: 1187206187]
16+# 14:35:48.353275 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT ACK] [init tag: 2017837359]
17+# 14:35:48.353283 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [COOKIE ECHO]
18+# 14:35:48.353977 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [COOKIE ACK]
19+# 14:35:47.655279 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT] [init tag: 2017837359]
20+# (Delayed)
21+# 14:35:48.855335 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT ACK] [init tag: 164579970]
1222 #
1323 # TOPO: SERVER_NS (link0)<--->(link1) ROUTER_NS (link2)<--->(link3) CLIENT_NS
1424
1525 source lib.sh
1626
27+checktool "nft --version" "run test without nft"
28+checktool "tc -h" "run test without tc"
29+checktool "modprobe -q sctp" "load sctp module"
30+
1731 CLIENT_IP="198.51.200.1"
1832 CLIENT_PORT=1234
1933
@@ -24,7 +38,8 @@ CLIENT_GW="198.51.200.2" · 4 unmodified lines
2438 SERVER_GW="198.51.100.2"
2539
2640 # setup the topo
27−setup() {
41+topo_setup() {
42+ # setup_ns cleans up existing net namespaces first.
2843 setup_ns CLIENT_NS SERVER_NS ROUTER_NS
2944 ip -n "$SERVER_NS" link add link0 type veth peer name link1 netns "$ROUTER_NS"
3045 ip -n "$CLIENT_NS" link add link3 type veth peer name link2 netns "$ROUTER_NS"
@@ -38,35 +53,53 @@ setup() { · 7 unmodified lines
3853 ip -n "$ROUTER_NS" addr add $SERVER_GW/24 dev link1
3954 ip -n "$ROUTER_NS" addr add $CLIENT_GW/24 dev link2
4055 ip net exec "$ROUTER_NS" sysctl -wq net.ipv4.ip_forward=1
56+ sysctl -wq net.netfilter.nf_log_all_netns=1
4157
4258 ip -n "$CLIENT_NS" link set link3 up
4359 ip -n "$CLIENT_NS" addr add $CLIENT_IP/24 dev link3
4460 ip -n "$CLIENT_NS" route add $SERVER_IP dev link3 via $CLIENT_GW
61+}
62+
63+conf_delay()
64+{
65+ # simulate the delay on OVS upcall by setting up a delay for INIT_ACK/INIT with
66+ local ns=$1
67+ local link=$2
68+ local chunk_type=$3
4569
46− # simulate the delay on OVS upcall by setting up a delay for INIT_ACK with
47− # tc on $SERVER_NS side
48− tc -n "$SERVER_NS" qdisc add dev link0 root handle 1: htb r2q 64
49− tc -n "$SERVER_NS" class add dev link0 parent 1: classid 1:1 htb rate 100mbit
50− tc -n "$SERVER_NS" filter add dev link0 parent 1: protocol ip u32 match ip protocol 132 \
51− 0xff match u8 2 0xff at 32 flowid 1:1
52− if ! tc -n "$SERVER_NS" qdisc add dev link0 parent 1:1 handle 10: netem delay 1200ms; then
70+ # use a smaller number for assoc's max_retrans to reproduce the issue
71+ ip net exec "$CLIENT_NS" sysctl -wq net.sctp.association_max_retrans=3
72+
73+ tc -n "$ns" qdisc add dev "$link" root handle 1: htb r2q 64
74+ tc -n "$ns" class add dev "$link" parent 1: classid 1:1 htb rate 100mbit
75+ tc -n "$ns" filter add dev "$link" parent 1: protocol ip \
76+ u32 match ip protocol 132 0xff match u8 "$chunk_type" 0xff at 32 flowid 1:1
77+ if ! tc -n "$ns" qdisc add dev "$link" parent 1:1 handle 10: netem delay 1200ms; then
5378 echo "SKIP: Cannot add netem qdisc"
54− exit $ksft_skip
79+ return $ksft_skip
5580 fi
5681
5782 # simulate the ctstate check on OVS nf_conntrack
58− ip net exec "$ROUTER_NS" iptables -A FORWARD -m state --state INVALID,UNTRACKED -j DROP
59− ip net exec "$ROUTER_NS" iptables -A INPUT -p sctp -j DROP
60−
61− # use a smaller number for assoc's max_retrans to reproduce the issue
62− modprobe -q sctp
63− ip net exec "$CLIENT_NS" sysctl -wq net.sctp.association_max_retrans=3
83+ ip net exec "$ROUTER_NS" nft -f - <<-EOF
84+ table ip t {
85+ chain forward {
86+ type filter hook forward priority filter; policy accept;
87+ meta l4proto icmp counter accept
88+ ct state new counter accept
89+ ct state established,related counter accept
90+ ct state invalid log flags all counter drop comment \
91+ "Expect to drop stale INIT/INIT_ACK chunks"
92+ counter
93+ }
94+ }
95+ EOF
96+ return 0
6497 }
6598
6699 cleanup() {
67− ip net exec "$CLIENT_NS" pkill sctp_collision >/dev/null 2>&1
68− ip net exec "$SERVER_NS" pkill sctp_collision >/dev/null 2>&1
100+ # cleanup_all_ns terminates running processes in the namespaces.
69101 cleanup_all_ns
102+ sysctl -wq net.netfilter.nf_log_all_netns=0
70103 }
71104
72105 do_test() {
@@ -81,7 +114,19 @@ do_test() { · 8 unmodified lines
81114
82115 # run the test case
83116 trap cleanup EXIT
84−setup && \
85−echo "Test for SCTP Collision in nf_conntrack:" && \
86−do_test && echo "PASS!"
87−exit $?
117+
118+echo "Test for SCTP INIT_ACK Collision in nf_conntrack:"
119+topo_setup || exit $?
120+conf_delay $SERVER_NS link0 2 || exit $?
121+
122+if ! do_test; then
123+ exit $ksft_fail
124+fi
125+
126+echo "Test for SCTP INIT Collision in nf_conntrack:"
127+topo_setup || exit $?
128+conf_delay $CLIENT_NS link3 1 || exit $?
129+
130+if ! do_test; then
131+ exit $ksft_fail
132+fi
tools/testing/selftests/net/netfilter/nft_flowtable.sh+4−4
@@ -592,7 +592,7 @@ ip -net "$nsr1" link set tun0 up · 591 unmodified lines
592592 ip -net "$nsr1" addr add 192.168.100.1/24 dev tun0
593593 ip netns exec "$nsr1" sysctl net.ipv4.conf.tun0.forwarding=1 > /dev/null
594594
595−ip -net "$nsr1" link add name tun6 type ip6tnl local fee1:2::1 remote fee1:2::2
595+ip -net "$nsr1" link add name tun6 type ip6tnl local fee1:2::1 remote fee1:2::2 encaplimit none
596596 ip -net "$nsr1" link set tun6 up
597597 ip -net "$nsr1" addr add fee1:3::1/64 dev tun6 nodad
598598
@@ -601,7 +601,7 @@ ip -net "$nsr2" link set tun0 up · 2 unmodified lines
601601 ip -net "$nsr2" addr add 192.168.100.2/24 dev tun0
602602 ip netns exec "$nsr2" sysctl net.ipv4.conf.tun0.forwarding=1 > /dev/null
603603
604−ip -net "$nsr2" link add name tun6 type ip6tnl local fee1:2::2 remote fee1:2::1 || ret=1
604+ip -net "$nsr2" link add name tun6 type ip6tnl local fee1:2::2 remote fee1:2::1 encaplimit none || ret=1
605605 ip -net "$nsr2" link set tun6 up
606606 ip -net "$nsr2" addr add fee1:3::2/64 dev tun6 nodad
607607
@@ -651,7 +651,7 @@ ip -net "$nsr1" route change default via 192.168.200.2 · 43 unmodified lines
651651 ip netns exec "$nsr1" sysctl net.ipv4.conf.tun0/10.forwarding=1 > /dev/null
652652 ip netns exec "$nsr1" nft -a insert rule inet filter forward 'meta oif tun0.10 accept'
653653
654−ip -net "$nsr1" link add name tun6.10 type ip6tnl local fee1:4::1 remote fee1:4::2
654+ip -net "$nsr1" link add name tun6.10 type ip6tnl local fee1:4::1 remote fee1:4::2 encaplimit none
655655 ip -net "$nsr1" link set tun6.10 up
656656 ip -net "$nsr1" addr add fee1:5::1/64 dev tun6.10 nodad
657657 ip -6 -net "$nsr1" route delete default
@@ -670,7 +670,7 @@ ip -net "$nsr2" addr add 192.168.200.2/24 dev tun0.10 · 12 unmodified lines
670670 ip -net "$nsr2" route change default via 192.168.200.1
671671 ip netns exec "$nsr2" sysctl net.ipv4.conf.tun0/10.forwarding=1 > /dev/null
672672
673−ip -net "$nsr2" link add name tun6.10 type ip6tnl local fee1:4::2 remote fee1:4::1 || ret=1
673+ip -net "$nsr2" link add name tun6.10 type ip6tnl local fee1:4::2 remote fee1:4::1 encaplimit none || ret=1
674674 ip -net "$nsr2" link set tun6.10 up
675675 ip -net "$nsr2" addr add fee1:5::2/64 dev tun6.10 nodad
676676 ip -6 -net "$nsr2" route delete default
tools/testing/selftests/net/netfilter/nft_queue.sh+58−8
@@ -85,11 +85,12 @@ ip -net "$ns3" route add default via 10.0.3.1 · 84 unmodified lines
8585 ip -net "$ns3" route add default via dead:3::1
8686
8787 load_ruleset() {
88− local name=$1
89− local prio=$2
88+ local family=$1
89+ local name=$2
90+ local prio=$3
9091
9192 ip netns exec "$nsrouter" nft -f /dev/stdin <<EOF
92−table inet $name {
93+table $family $name {
9394 chain nfq {
9495 ip protocol icmp queue bypass
9596 icmpv6 type { "echo-request", "echo-reply" } queue num 1 bypass
@@ -228,6 +229,7 @@ nf_queue_wait() · 132 unmodified lines
228229 test_queue()
229230 {
230231 local expected="$1"
232+ local family="$2"
231233 local last=""
232234
233235 # spawn nf_queue listeners
@@ -255,11 +257,13 @@ test_queue() · 21 unmodified lines
255257 if [ x"$last" != x"$expected packets total" ]; then
256258 echo "FAIL: Expected $expected packets total, but got $last" 1>&2
257259 ip netns exec "$nsrouter" nft list ruleset
260+ echo -n "$TMPFILE0: ";cat "$TMPFILE0"
261+ echo -n "$TMPFILE1: ";cat "$TMPFILE1"
258262 exit 1
259263 fi
260264 done
261265
262− echo "PASS: Expected and received $last"
266+ echo "PASS: Expected and received $last ($family)"
263267 }
264268
265269 listener_ready()
@@ -400,6 +404,8 @@ EOF · 134 unmodified lines
400404
401405 kill "$nfqpid"
402406 echo "PASS: icmp+nfqueue via vrf"
407+ ip -net "$ns1" link del tvrf
408+ ip netns exec "$ns1" nft flush ruleset
403409 }
404410
405411 sctp_listener_ready()
@@ -814,12 +820,53 @@ EOF · 408 unmodified lines
814820 check_tainted "queue program exiting while packets queued"
815821 }
816822
823+test_queue_bridge()
824+{
825+ ip -net "$nsrouter" addr flush dev veth0
826+ ip -net "$nsrouter" addr flush dev veth1
827+
828+ ip -net "$nsrouter" link add br0 type bridge
829+ ip -net "$nsrouter" link set veth0 master br0
830+ ip -net "$nsrouter" link set veth1 master br0
831+
832+ ip -net "$nsrouter" link set br0 up
833+
834+ ip -net "$nsrouter" addr add 10.0.2.1/16 dev br0
835+ ip -net "$nsrouter" addr add dead:2::1/64 dev br0 nodad
836+
837+ ip -net "$ns1" addr flush dev eth0
838+ ip -net "$ns2" addr flush dev eth0
839+
840+ ip -net "$ns1" addr add 10.0.1.1/16 dev eth0
841+ ip -net "$ns1" addr add dead:2::2/64 dev eth0 nodad
842+
843+ ip -net "$ns2" addr add 10.0.2.99/16 dev eth0
844+ ip -net "$ns2" addr add dead:2::99/64 dev eth0 nodad
845+
846+ ip netns exec "$nsrouter" nft flush ruleset
847+
848+ ip netns exec "$nsrouter" sysctl net.ipv6.conf.all.forwarding=0 > /dev/null
849+ ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth0.forwarding=0 > /dev/null
850+ ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth1.forwarding=0 > /dev/null
851+
852+ if ! test_ping;then
853+ echo "FAIL: netns bridge connectivity" 1>&2
854+ exit $ret
855+ fi
856+
857+ load_ruleset "bridge" "filter" 10
858+ test_queue 10 "bridge"
859+
860+ load_ruleset "bridge" "filter2" 20
861+ test_queue 20 "bridge"
862+}
863+
817864 ip netns exec "$nsrouter" sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
818865 ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
819866 ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
820867 ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth2.forwarding=1 > /dev/null
821868
822−load_ruleset "filter" 0
869+load_ruleset "inet" "filter" 0
823870
824871 if test_ping; then
825872 # queue bypass works (rules were skipped, no listener)
@@ -842,11 +889,11 @@ load_counter_ruleset 10 · 16 unmodified lines
842889 # 1x icmp prerouting,forward,postrouting -> 3 queue events (6 incl. reply).
843890 # 1x icmp prerouting,input,output postrouting -> 4 queue events incl. reply.
844891 # so we expect that userspace program receives 10 packets.
845−test_queue 10
892+test_queue 10 "inet"
846893
847894 # same. We queue to a second program as well.
848−load_ruleset "filter2" 20
849−test_queue 20
895+load_ruleset "inet" "filter2" 20
896+test_queue 20 "inet"
850897 ip netns exec "$ns1" nft flush ruleset
851898
852899 test_tcp_forward
@@ -863,4 +910,7 @@ test_queue_stress · 10 unmodified lines
863910 test_icmp_vrf
864911 test_queue_removal
865912
913+# turns router into a bridge
914+test_queue_bridge
915+
866916 exit $ret
tools/testing/selftests/net/tls.c+7−1
@@ -997,6 +997,8 @@ TEST_F(tls, splice_short) · 996 unmodified lines
997997 char sendbuf[0x100];
998998 char sendchar = 'S';
999999 int pipefds[2];
1000+ int pipe_sz;
1001+ int ret;
10001002 int i;
10011003
10021004 sendchar_iov.iov_base = &sendchar;
@@ -1005,7 +1007,11 @@ TEST_F(tls, splice_short) · 2 unmodified lines
10051007 memset(sendbuf, 's', sizeof(sendbuf));
10061008
10071009 ASSERT_GE(pipe2(pipefds, O_NONBLOCK), 0);
1008− ASSERT_GE(fcntl(pipefds[0], F_SETPIPE_SZ, (MAX_FRAGS + 1) * 0x1000), 0);
1010+ pipe_sz = (MAX_FRAGS + 1) * getpagesize();
1011+ ret = fcntl(pipefds[0], F_SETPIPE_SZ, pipe_sz);
1012+ if (ret < 0 && errno == EPERM)
1013+ SKIP(return, "insufficient pipe capacity");
1014+ ASSERT_GE(ret, pipe_sz);
10091015
10101016 for (i = 0; i < MAX_FRAGS; i++)
10111017 ASSERT_GE(vmsplice(pipefds[1], &sendchar_iov, 1, 0), 0);
tools/testing/selftests/net/vlan_bridge_binding.sh+1−1
@@ -64,7 +64,7 @@ check_operstate() · 63 unmodified lines
6464 local expect=$1; shift
6565 local operstate
6666
67− operstate=$(busywait 1000 \
67+ operstate=$(busywait 2000 \
6868 operstate_is "$dev" "$expect")
6969 check_err $? "Got operstate of $operstate, expected $expect"
7070 }
tools/testing/selftests/tc-testing/tc-tests/actions/ct.json+38−0
@@ -664,5 +664,43 @@ · 663 unmodified lines
664664 "teardown": [
665665 "$TC qdisc del dev $DEV1 ingress_block 21 clsact"
666666 ]
667+ },
668+ {
669+ "id": "9c2a",
670+ "name": "Act_ct preserves skb cb across defrag before prio dequeue",
671+ "category": [
672+ "actions",
673+ "ct",
674+ "scapy"
675+ ],
676+ "plugins": {
677+ "requires": [
678+ "nsPlugin",
679+ "scapyPlugin"
680+ ]
681+ },
682+ "setup": [
683+ "$TC qdisc add dev $DUMMY root handle 1: prio",
684+ "$TC qdisc add dev $DUMMY clsact",
685+ "$TC qdisc add dev $DEV1 clsact",
686+ "$TC filter add dev $DEV1 ingress protocol ip prio 1 matchall action mirred egress redirect dev $DUMMY"
687+ ],
688+ "cmdUnderTest": "$TC filter add dev $DUMMY egress protocol ip prio 1 matchall action ct zone 1 pipe",
689+ "scapy": [
690+ {
691+ "iface": "$DEV0",
692+ "count": 1,
693+ "packet": "[Ether()/frag for frag in fragment(IP(src='10.0.0.10', dst='10.0.0.1', id=1)/UDP(sport=12345, dport=9)/Raw(b'A' * 4000), fragsize=1400)]"
694+ }
695+ ],
696+ "expExitCode": "0",
697+ "verifyCmd": "$TC -s qdisc show dev $DUMMY | grep -A 1 '^qdisc prio 1:'",
698+ "matchPattern": "Sent [1-9][0-9]* bytes [1-9][0-9]* pkt",
699+ "matchCount": "1",
700+ "teardown": [
701+ "$TC qdisc del dev $DEV1 clsact",
702+ "$TC qdisc del dev $DUMMY clsact",
703+ "$TC qdisc del dev $DUMMY root handle 1:"
704+ ]
667705 }
668706 ]
tools/testing/selftests/tc-testing/tc-tests/qdiscs/dualpi2.json+44−0
@@ -250,5 +250,49 @@ · 249 unmodified lines
250250 "teardown": [
251251 "$TC qdisc del dev $DUMMY handle 1: root"
252252 ]
253+ },
254+ {
255+ "id": "891f",
256+ "name": "Verify DualPI2 GSO backlog accounting with QFQ parent",
257+ "category": [
258+ "qdisc",
259+ "dualpi2",
260+ "qfq",
261+ "gso"
262+ ],
263+ "plugins": {
264+ "requires": "nsPlugin"
265+ },
266+ "setup": [
267+ "$IP link set dev $DUMMY up || true",
268+ "$IP addr add 10.10.10.10/24 dev $DUMMY || true",
269+ "$TC qdisc add dev $DUMMY root handle 1: qfq",
270+ "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 1 maxpkt 4096",
271+ "$TC qdisc add dev $DUMMY parent 1:1 handle 2: dualpi2",
272+ "$TC filter add dev $DUMMY parent 1: matchall classid 1:1"
273+ ],
274+ "cmdUnderTest": "./tdc_gso.py 10.10.10.10 10.10.10.1 9000 1200 2400",
275+ "expExitCode": "0",
276+ "verifyCmd": "$TC -j -s qdisc ls dev $DUMMY",
277+ "matchJSON": [
278+ {
279+ "kind": "qfq",
280+ "handle": "1:",
281+ "packets": 2,
282+ "backlog": 0,
283+ "qlen": 0
284+ },
285+ {
286+ "kind": "dualpi2",
287+ "handle": "2:",
288+ "packets": 2,
289+ "backlog": 0,
290+ "qlen": 0
291+ }
292+ ],
293+ "teardown": [
294+ "$TC qdisc del dev $DUMMY root",
295+ "$IP addr del 10.10.10.10/24 dev $DUMMY || true"
296+ ]
253297 }
254298 ]
tools/testing/selftests/tc-testing/tdc_gso.py+43−0
@@ -0,0 +1,43 @@
1+#!/usr/bin/env python3
2+# SPDX-License-Identifier: GPL-2.0
3+
4+"""
5+tdc_gso.py - send a UDP GSO datagram
6+
7+Copyright (C) 2026 Xingquan Liu <b1n@b1n.io>
8+"""
9+
10+import argparse
11+import socket
12+import struct
13+import sys
14+
15+UDP_MAX_SEGMENTS = 1 << 7
16+
17+
18+parser = argparse.ArgumentParser(description="UDP GSO datagram sender")
19+parser.add_argument("src", help="source IPv4 address")
20+parser.add_argument("dst", help="destination IPv4 address")
21+parser.add_argument("port", type=int, help="destination UDP port")
22+parser.add_argument("gso_size", type=int, help="UDP GSO segment payload size")
23+parser.add_argument("payload_len", type=int, help="total UDP payload length")
24+args = parser.parse_args()
25+
26+if args.gso_size <= 0 or args.gso_size > 0xFFFF:
27+ parser.error("gso_size must fit in an unsigned 16-bit integer")
28+if args.payload_len <= args.gso_size:
29+ parser.error("payload_len must be larger than gso_size")
30+if args.payload_len > args.gso_size * UDP_MAX_SEGMENTS:
31+ parser.error("payload_len exceeds UDP_MAX_SEGMENTS")
32+
33+SOL_UDP = getattr(socket, "SOL_UDP", socket.IPPROTO_UDP)
34+UDP_SEGMENT = getattr(socket, "UDP_SEGMENT", 103)
35+
36+sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
37+sock.bind((args.src, 0))
38+
39+payload = b"b" * args.payload_len
40+cmsg = [(SOL_UDP, UDP_SEGMENT, struct.pack("=H", args.gso_size))]
41+
42+sent = sock.sendmsg([payload], cmsg, 0, (args.dst, args.port))
43+sys.exit(sent != len(payload))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t