History

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

Pull networking fixes from Jakub Kicinski: "Including fixes from xfrm, bpf, netfilter, and wireless. Current release - regressions: - xfrm: fix XFRM_MSG_MAPPING ABI breakage caused by inserting a new value in the middle of an enum - unix: fix an issue in unix_shutdown causing the other end read/write failures - phy: mdio: fix memory leak Current release - new code bugs: - mlx5e: improve MQPRIO resiliency against bad configs Previous releases - regressions: - bpf: fix integer overflow leading to OOB access in map element pre-allocation - stmmac: dwmac-rk: fix ethernet on rk3399 based devices - netfilter: conntrack: fix boot failure with nf_conntrack.enable_hooks=1 - brcmfmac: revert using ISO3166 country code and 0 rev as fallback - i40e: fix freeing of uninitialized misc IRQ vector - iavf: fix double unlock of crit_lock Previous releases - always broken: - bpf, arm: fix register clobbering in div/mod implementation - netfilter: nf_tables: correct issues in netlink rule change event notifications - dsa: tag_dsa: fix mask for trunked packets - usb: r8152: don't resubmit rx immediately to avoid soft lockup on device unplug - i40e: fix endless loop under rtnl if FW fails to correctly respond to capability query - mlx5e: fix rx checksum offload coexistence with ipsec offload - mlx5: force round second at 1PPS out start time and allow it only in supported clock modes - phy: pcs: xpcs: fix incorrect CL37 AN sequence, EEE disable sequence Misc: - xfrm: slightly rejig the new policy uAPI to make it less cryptic" * tag 'net-5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (66 commits) net: prefer socket bound to interface when not in VRF iavf: fix double unlock of crit_lock i40e: Fix freeing of uninitialized misc IRQ vector i40e: fix endless loop under rtnl dt-bindings: net: dsa: marvell: fix compatible in example ionic: move filter sync_needed bit set gve: report 64bit tx_bytes counter from gve_handle_report_stats() gve: fix gve_get_stats() rtnetlink: fix if_nlmsg_stats_size() under estimation gve: Properly handle errors in gve_assign_qpl gve: Avoid freeing NULL pointer gve: Correct available tx qpl check unix: Fix an issue in unix_shutdown causing the other end read/write failures net: stmmac: trigger PCS EEE to turn off on link down net: pcs: xpcs: fix incorrect steps on disable EEE netlink: annotate data races around nlk->bound net: pcs: xpcs: fix incorrect CL37 AN sequence net: sfp: Fix typo in state machine debug string net/sched: sch_taprio: properly cancel timer from taprio_destroy() net: bridge: fix under estimation in br_get_linkxstats_size() ...

Linus Torvalds committed 5 years ago

Commit 4a16df52 parents 52bf803 8d6c41473 files · +566 −298Browse files

Unified · Split

73 files
  1. CREDITS +1 −0
  2. Documentation/devicetree/bindings/net/dsa/marvell.txt +1 −1
  3. MAINTAINERS +1 −4
  4. arch/arm/net/bpf_jit_32.c +19 −0
  5. arch/powerpc/boot/dts/fsl/t1023rdb.dts +1 −1
  6. drivers/net/ethernet/google/gve/gve.h +1 −1
  7. drivers/net/ethernet/google/gve/gve_main.c +29 −16
  8. drivers/net/ethernet/google/gve/gve_rx.c +7 −1
  9. drivers/net/ethernet/intel/i40e/i40e_main.c +3 −2
  10. drivers/net/ethernet/intel/iavf/iavf_main.c +0 −1
  11. drivers/net/ethernet/mellanox/mlx5/core/en.h +5 −7
  12. drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +3 −3
  13. drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +1 −2
  14. drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h +2 −0
  15. drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +11 −0
  16. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +130 −48
  17. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 −2
  18. drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 −6
  19. drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +6 −5
  20. drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c +8 −4
  21. drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c +3 −1
  22. drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 −2
  23. drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +16 −21
  24. drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +5 −4
  25. drivers/net/ethernet/mscc/ocelot_vcap.c +2 −2
  26. drivers/net/ethernet/pensando/ionic/ionic_lif.c +3 −1
  27. drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c +0 −3
  28. drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +5 −0
  29. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 −1
  30. drivers/net/pcs/pcs-xpcs.c +36 −9
  31. drivers/net/phy/mdio_bus.c +7 −1
  32. drivers/net/phy/sfp.c +1 −1
  33. drivers/net/usb/r8152.c +15 −1
  34. drivers/net/wireless/ath/ath5k/Kconfig +1 −3
  35. drivers/net/wireless/ath/ath5k/led.c +6 −4
  36. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +6 −11
  37. drivers/net/wireless/intel/iwlwifi/mvm/d3.c +3 −2
  38. drivers/net/wireless/intel/iwlwifi/mvm/time-event.c +2 −1
  39. drivers/net/wireless/intel/iwlwifi/pcie/drv.c +2 −0
  40. drivers/net/wireless/marvell/mwifiex/sta_tx.c +2 −2
  41. drivers/net/wireless/marvell/mwifiex/uap_txrx.c +2 −2
  42. drivers/ptp/ptp_pch.c +1 −0
  43. include/linux/etherdevice.h +1 −1
  44. include/net/netfilter/ipv6/nf_defrag_ipv6.h +0 −1
  45. include/net/netfilter/nf_tables.h +1 −1
  46. include/net/netns/netfilter.h +6 −0
  47. include/net/sock.h +1 −0
  48. include/soc/mscc/ocelot_vcap.h +2 −2
  49. include/uapi/linux/xfrm.h +9 −6
  50. kernel/bpf/stackmap.c +2 −1
  51. net/bridge/br_netlink.c +2 −1
  52. net/core/rtnetlink.c +1 −1
  53. net/dsa/tag_dsa.c +1 −1
  54. net/ipv4/inet_hashtables.c +3 −1
  55. net/ipv4/netfilter/nf_defrag_ipv4.c +9 −21
  56. net/ipv4/udp.c +2 −1
  57. net/ipv6/inet6_hashtables.c +1 −1
  58. net/ipv6/netfilter/nf_conntrack_reasm.c +1 −1
  59. net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +9 −16
  60. net/ipv6/udp.c +2 −1
  61. net/netfilter/nf_tables_api.c +64 −27
  62. net/netfilter/nft_quota.c +1 −1
  63. net/netlink/af_netlink.c +10 −4
  64. net/sched/sch_fifo.c +3 −0
  65. net/sched/sch_taprio.c +4 −0
  66. net/unix/af_unix.c +5 −4
  67. net/xfrm/xfrm_user.c +55 −12
  68. samples/bpf/Makefile +8 −9
  69. samples/bpf/bpf_insn.h +1 −1
  70. samples/bpf/xdp_redirect_map_multi.bpf.c +0 −5
  71. security/selinux/nlmsgtab.c +3 −1
  72. tools/lib/bpf/libbpf.c +2 −1
  73. tools/lib/bpf/strset.c +1 −0
CREDITS+1−0
@@ -971,6 +971,7 @@ D: PowerPC · 970 unmodified lines
971971 N: Daniel Drake
972972 E: dsd@gentoo.org
973973 D: USBAT02 CompactFlash support in usb-storage
974+D: ZD1211RW wireless driver
974975 S: UK
975976
976977 N: Oleg Drokin
Documentation/devicetree/bindings/net/dsa/marvell.txt+1−1
@@ -83,7 +83,7 @@ Example: · 82 unmodified lines
8383 #interrupt-cells = <2>;
8484
8585 switch0: switch@0 {
86− compatible = "marvell,mv88e6390";
86+ compatible = "marvell,mv88e6190";
8787 reg = <0>;
8888 reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
8989
MAINTAINERS+1−4
@@ -8609,9 +8609,8 @@ F: Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml · 8608 unmodified lines
86098609 F: drivers/iio/humidity/hts221*
86108610
86118611 HUAWEI ETHERNET DRIVER
8612−M: Bin Luo <luobin9@huawei.com>
86138612 L: netdev@vger.kernel.org
8614−S: Supported
8613+S: Orphan
86158614 F: Documentation/networking/device_drivers/ethernet/huawei/hinic.rst
86168615 F: drivers/net/ethernet/huawei/hinic/
86178616
@@ -17794,7 +17793,6 @@ F: drivers/staging/nvec/ · 9176 unmodified lines
1779417793
1779517794 STAGING - OLPC SECONDARY DISPLAY CONTROLLER (DCON)
1779617795 M: Jens Frederich <jfrederich@gmail.com>
17797−M: Daniel Drake <dsd@laptop.org>
1779817796 M: Jon Nettleton <jon.nettleton@gmail.com>
1779917797 S: Maintained
1780017798 W: http://wiki.laptop.org/go/DCON
@@ -20700,7 +20698,6 @@ S: Maintained · 2899 unmodified lines
2070020698 F: mm/zbud.c
2070120699
2070220700 ZD1211RW WIRELESS DRIVER
20703−M: Daniel Drake <dsd@gentoo.org>
2070420701 M: Ulrich Kunitz <kune@deine-taler.de>
2070520702 L: linux-wireless@vger.kernel.org
2070620703 L: zd1211-devs@lists.sourceforge.net (subscribers-only)
arch/arm/net/bpf_jit_32.c+19−0
@@ -36,6 +36,10 @@ · 35 unmodified lines
3636 * +-----+
3737 * |RSVD | JIT scratchpad
3838 * current ARM_SP => +-----+ <= (BPF_FP - STACK_SIZE + SCRATCH_SIZE)
39+ * | ... | caller-saved registers
40+ * +-----+
41+ * | ... | arguments passed on stack
42+ * ARM_SP during call => +-----|
3943 * | |
4044 * | ... | Function call stack
4145 * | |
@@ -63,6 +67,12 @@ · 21 unmodified lines
6367 *
6468 * When popping registers off the stack at the end of a BPF function, we
6569 * reference them via the current ARM_FP register.
70+ *
71+ * Some eBPF operations are implemented via a call to a helper function.
72+ * Such calls are "invisible" in the eBPF code, so it is up to the calling
73+ * program to preserve any caller-saved ARM registers during the call. The
74+ * JIT emits code to push and pop those registers onto the stack, immediately
75+ * above the callee stack frame.
6676 */
6777 #define CALLEE_MASK (1 << ARM_R4 | 1 << ARM_R5 | 1 << ARM_R6 | \
6878 1 << ARM_R7 | 1 << ARM_R8 | 1 << ARM_R9 | \
@@ -70,6 +80,8 @@ · 1 unmodified line
7080 #define CALLEE_PUSH_MASK (CALLEE_MASK | 1 << ARM_LR)
7181 #define CALLEE_POP_MASK (CALLEE_MASK | 1 << ARM_PC)
7282
83+#define CALLER_MASK (1 << ARM_R0 | 1 << ARM_R1 | 1 << ARM_R2 | 1 << ARM_R3)
84+
7385 enum {
7486 /* Stack layout - these are offsets from (top of stack - 4) */
7587 BPF_R2_HI,
@@ -464,6 +476,7 @@ static inline int epilogue_offset(const struct jit_ctx *ctx) · 388 unmodified lines
464476
465477 static inline void emit_udivmod(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx, u8 op)
466478 {
479+ const int exclude_mask = BIT(ARM_R0) | BIT(ARM_R1);
467480 const s8 *tmp = bpf2a32[TMP_REG_1];
468481
469482 #if __LINUX_ARM_ARCH__ == 7
@@ -495,11 +508,17 @@ static inline void emit_udivmod(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx, u8 op) · 25 unmodified lines
495508 emit(ARM_MOV_R(ARM_R0, rm), ctx);
496509 }
497510
511+ /* Push caller-saved registers on stack */
512+ emit(ARM_PUSH(CALLER_MASK & ~exclude_mask), ctx);
513+
498514 /* Call appropriate function */
499515 emit_mov_i(ARM_IP, op == BPF_DIV ?
500516 (u32)jit_udiv32 : (u32)jit_mod32, ctx);
501517 emit_blx_r(ARM_IP, ctx);
502518
519+ /* Restore caller-saved registers from stack */
520+ emit(ARM_POP(CALLER_MASK & ~exclude_mask), ctx);
521+
503522 /* Save return value */
504523 if (rd != ARM_R0)
505524 emit(ARM_MOV_R(rd, ARM_R0), ctx);
arch/powerpc/boot/dts/fsl/t1023rdb.dts+1−1
@@ -154,7 +154,7 @@ · 153 unmodified lines
154154
155155 fm1mac3: ethernet@e4000 {
156156 phy-handle = <&sgmii_aqr_phy3>;
157− phy-connection-type = "sgmii-2500";
157+ phy-connection-type = "2500base-x";
158158 sleep = <&rcpm 0x20000000>;
159159 };
160160
drivers/net/ethernet/google/gve/gve.h+1−1
@@ -780,7 +780,7 @@ struct gve_queue_page_list *gve_assign_rx_qpl(struct gve_priv *priv) · 779 unmodified lines
780780 gve_num_tx_qpls(priv));
781781
782782 /* we are out of rx qpls */
783− if (id == priv->qpl_cfg.qpl_map_size)
783+ if (id == gve_num_tx_qpls(priv) + gve_num_rx_qpls(priv))
784784 return NULL;
785785
786786 set_bit(id, priv->qpl_cfg.qpl_id_map);
drivers/net/ethernet/google/gve/gve_main.c+29−16
@@ -41,6 +41,7 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s) · 40 unmodified lines
4141 {
4242 struct gve_priv *priv = netdev_priv(dev);
4343 unsigned int start;
44+ u64 packets, bytes;
4445 int ring;
4546
4647 if (priv->rx) {
@@ -48,10 +49,12 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s) · 1 unmodified line
4849 do {
4950 start =
5051 u64_stats_fetch_begin(&priv->rx[ring].statss);
51− s->rx_packets += priv->rx[ring].rpackets;
52− s->rx_bytes += priv->rx[ring].rbytes;
52+ packets = priv->rx[ring].rpackets;
53+ bytes = priv->rx[ring].rbytes;
5354 } while (u64_stats_fetch_retry(&priv->rx[ring].statss,
5455 start));
56+ s->rx_packets += packets;
57+ s->rx_bytes += bytes;
5558 }
5659 }
5760 if (priv->tx) {
@@ -59,10 +62,12 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s) · 1 unmodified line
5962 do {
6063 start =
6164 u64_stats_fetch_begin(&priv->tx[ring].statss);
62− s->tx_packets += priv->tx[ring].pkt_done;
63− s->tx_bytes += priv->tx[ring].bytes_done;
65+ packets = priv->tx[ring].pkt_done;
66+ bytes = priv->tx[ring].bytes_done;
6467 } while (u64_stats_fetch_retry(&priv->tx[ring].statss,
6568 start));
69+ s->tx_packets += packets;
70+ s->tx_bytes += bytes;
6671 }
6772 }
6873 }
@@ -82,6 +87,9 @@ static int gve_alloc_counter_array(struct gve_priv *priv) · 13 unmodified lines
8287
8388 static void gve_free_counter_array(struct gve_priv *priv)
8489 {
90+ if (!priv->counter_array)
91+ return;
92+
8593 dma_free_coherent(&priv->pdev->dev,
8694 priv->num_event_counters *
8795 sizeof(*priv->counter_array),
@@ -142,6 +150,9 @@ static int gve_alloc_stats_report(struct gve_priv *priv) · 54 unmodified lines
142150
143151 static void gve_free_stats_report(struct gve_priv *priv)
144152 {
153+ if (!priv->stats_report)
154+ return;
155+
145156 del_timer_sync(&priv->stats_report_timer);
146157 dma_free_coherent(&priv->pdev->dev, priv->stats_report_len,
147158 priv->stats_report, priv->stats_report_bus);
@@ -370,18 +381,19 @@ static void gve_free_notify_blocks(struct gve_priv *priv) · 222 unmodified lines
370381 {
371382 int i;
372383
373− if (priv->msix_vectors) {
374− /* Free the irqs */
375− for (i = 0; i < priv->num_ntfy_blks; i++) {
376− struct gve_notify_block *block = &priv->ntfy_blocks[i];
377− int msix_idx = i;
384+ if (!priv->msix_vectors)
385+ return;
378386
379− irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector,
380− NULL);
381− free_irq(priv->msix_vectors[msix_idx].vector, block);
382− }
383− free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
387+ /* Free the irqs */
388+ for (i = 0; i < priv->num_ntfy_blks; i++) {
389+ struct gve_notify_block *block = &priv->ntfy_blocks[i];
390+ int msix_idx = i;
391+
392+ irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector,
393+ NULL);
394+ free_irq(priv->msix_vectors[msix_idx].vector, block);
384395 }
396+ free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
385397 dma_free_coherent(&priv->pdev->dev,
386398 priv->num_ntfy_blks * sizeof(*priv->ntfy_blocks),
387399 priv->ntfy_blocks, priv->ntfy_block_bus);
@@ -1185,9 +1197,10 @@ static void gve_handle_reset(struct gve_priv *priv) · 797 unmodified lines
11851197
11861198 void gve_handle_report_stats(struct gve_priv *priv)
11871199 {
1188− int idx, stats_idx = 0, tx_bytes;
1189− unsigned int start = 0;
11901200 struct stats *stats = priv->stats_report->stats;
1201+ int idx, stats_idx = 0;
1202+ unsigned int start = 0;
1203+ u64 tx_bytes;
11911204
11921205 if (!gve_get_report_stats(priv))
11931206 return;
drivers/net/ethernet/google/gve/gve_rx.c+7−1
@@ -104,8 +104,14 @@ static int gve_prefill_rx_pages(struct gve_rx_ring *rx) · 103 unmodified lines
104104 if (!rx->data.page_info)
105105 return -ENOMEM;
106106
107− if (!rx->data.raw_addressing)
107+ if (!rx->data.raw_addressing) {
108108 rx->data.qpl = gve_assign_rx_qpl(priv);
109+ if (!rx->data.qpl) {
110+ kvfree(rx->data.page_info);
111+ rx->data.page_info = NULL;
112+ return -ENOMEM;
113+ }
114+ }
109115 for (i = 0; i < slots; i++) {
110116 if (!rx->data.raw_addressing) {
111117 struct page *page = rx->data.qpl->pages[i];
drivers/net/ethernet/intel/i40e/i40e_main.c+3−2
@@ -4871,7 +4871,8 @@ static void i40e_clear_interrupt_scheme(struct i40e_pf *pf) · 4870 unmodified lines
48714871 {
48724872 int i;
48734873
4874− i40e_free_misc_vector(pf);
4874+ if (test_bit(__I40E_MISC_IRQ_REQUESTED, pf->state))
4875+ i40e_free_misc_vector(pf);
48754876
48764877 i40e_put_lump(pf->irq_pile, pf->iwarp_base_vector,
48774878 I40E_IWARP_IRQ_PILE_ID);
@@ -10113,7 +10114,7 @@ static int i40e_get_capabilities(struct i40e_pf *pf, · 5235 unmodified lines
1011310114 if (pf->hw.aq.asq_last_status == I40E_AQ_RC_ENOMEM) {
1011410115 /* retry with a larger buffer */
1011510116 buf_len = data_size;
10116− } else if (pf->hw.aq.asq_last_status != I40E_AQ_RC_OK) {
10117+ } else if (pf->hw.aq.asq_last_status != I40E_AQ_RC_OK || err) {
1011710118 dev_info(&pf->pdev->dev,
1011810119 "capability discovery failed, err %s aq_err %s\n",
1011910120 i40e_stat_str(&pf->hw, err),
drivers/net/ethernet/intel/iavf/iavf_main.c+0−1
@@ -1965,7 +1965,6 @@ static void iavf_watchdog_task(struct work_struct *work) · 1964 unmodified lines
19651965 }
19661966 adapter->aq_required = 0;
19671967 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1968− mutex_unlock(&adapter->crit_lock);
19691968 queue_delayed_work(iavf_wq,
19701969 &adapter->watchdog_task,
19711970 msecs_to_jiffies(10));
drivers/net/ethernet/mellanox/mlx5/core/en.h+5−7
@@ -252,6 +252,7 @@ struct mlx5e_params { · 251 unmodified lines
252252 struct {
253253 u16 mode;
254254 u8 num_tc;
255+ struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
255256 } mqprio;
256257 bool rx_cqe_compress_def;
257258 bool tunneled_offload_en;
@@ -845,6 +846,7 @@ struct mlx5e_priv { · 587 unmodified lines
845846 struct mlx5e_channel_stats channel_stats[MLX5E_MAX_NUM_CHANNELS];
846847 struct mlx5e_channel_stats trap_stats;
847848 struct mlx5e_ptp_stats ptp_stats;
849+ u16 stats_nch;
848850 u16 max_nch;
849851 u8 max_opened_tc;
850852 bool tx_ptp_opened;
@@ -1100,12 +1102,6 @@ int mlx5e_ethtool_set_pauseparam(struct mlx5e_priv *priv, · 249 unmodified lines
11001102 struct ethtool_pauseparam *pauseparam);
11011103
11021104 /* mlx5e generic netdev management API */
1103−static inline unsigned int
1104−mlx5e_calc_max_nch(struct mlx5e_priv *priv, const struct mlx5e_profile *profile)
1105−{
1106− return priv->netdev->num_rx_queues / max_t(u8, profile->rq_groups, 1);
1107−}
1108−
11091105 static inline bool
11101106 mlx5e_tx_mpwqe_supported(struct mlx5_core_dev *mdev)
11111107 {
@@ -1114,11 +1110,13 @@ mlx5e_tx_mpwqe_supported(struct mlx5_core_dev *mdev) · 2 unmodified lines
11141110 }
11151111
11161112 int mlx5e_priv_init(struct mlx5e_priv *priv,
1113+ const struct mlx5e_profile *profile,
11171114 struct net_device *netdev,
11181115 struct mlx5_core_dev *mdev);
11191116 void mlx5e_priv_cleanup(struct mlx5e_priv *priv);
11201117 struct net_device *
1121−mlx5e_create_netdev(struct mlx5_core_dev *mdev, unsigned int txqs, unsigned int rxqs);
1118+mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
1119+ unsigned int txqs, unsigned int rxqs);
11221120 int mlx5e_attach_netdev(struct mlx5e_priv *priv);
11231121 void mlx5e_detach_netdev(struct mlx5e_priv *priv);
11241122 void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c+3−3
@@ -35,7 +35,7 @@ static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, void *data, · 34 unmodified lines
3535 {
3636 int ch, i = 0;
3737
38− for (ch = 0; ch < priv->max_nch; ch++) {
38+ for (ch = 0; ch < priv->stats_nch; ch++) {
3939 void *buf = data + i;
4040
4141 if (WARN_ON_ONCE(buf +
@@ -51,7 +51,7 @@ static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, void *data, · 9 unmodified lines
5151 static int mlx5e_hv_vhca_stats_buf_size(struct mlx5e_priv *priv)
5252 {
5353 return (sizeof(struct mlx5e_hv_vhca_per_ring_stats) *
54− priv->max_nch);
54+ priv->stats_nch);
5555 }
5656
5757 static void mlx5e_hv_vhca_stats_work(struct work_struct *work)
@@ -100,7 +100,7 @@ static void mlx5e_hv_vhca_stats_control(struct mlx5_hv_vhca_agent *agent, · 42 unmodified lines
100100 sagent = &priv->stats_agent;
101101
102102 block->version = MLX5_HV_VHCA_STATS_VERSION;
103− block->rings = priv->max_nch;
103+ block->rings = priv->stats_nch;
104104
105105 if (!block->command) {
106106 cancel_delayed_work_sync(&priv->stats_agent.work);
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c+1−2
@@ -13,8 +13,6 @@ struct mlx5e_ptp_fs { · 12 unmodified lines
1313 bool valid;
1414 };
1515
16−#define MLX5E_PTP_CHANNEL_IX 0
17−
1816 struct mlx5e_ptp_params {
1917 struct mlx5e_params params;
2018 struct mlx5e_sq_param txq_sq_param;
@@ -509,6 +507,7 @@ static int mlx5e_init_ptp_rq(struct mlx5e_ptp *c, struct mlx5e_params *params, · 488 unmodified lines
509507 rq->mdev = mdev;
510508 rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
511509 rq->stats = &c->priv->ptp_stats.rq;
510+ rq->ix = MLX5E_PTP_CHANNEL_IX;
512511 rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
513512 err = mlx5e_rq_set_handlers(rq, params, false);
514513 if (err)
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h+2−0
@@ -8,6 +8,8 @@ · 7 unmodified lines
88 #include "en_stats.h"
99 #include <linux/ptp_classify.h>
1010
11+#define MLX5E_PTP_CHANNEL_IX 0
12+
1113 struct mlx5e_ptpsq {
1214 struct mlx5e_txqsq txqsq;
1315 struct mlx5e_cq ts_cq;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c+11−0
@@ -2036,6 +2036,17 @@ static int set_pflag_tx_port_ts(struct net_device *netdev, bool enable) · 2035 unmodified lines
20362036 }
20372037
20382038 new_params = priv->channels.params;
2039+ /* Don't allow enabling TX-port-TS if MQPRIO mode channel offload is
2040+ * active, since it defines explicitly which TC accepts the packet.
2041+ * This conflicts with TX-port-TS hijacking the PTP traffic to a specific
2042+ * HW TX-queue.
2043+ */
2044+ if (enable && new_params.mqprio.mode == TC_MQPRIO_MODE_CHANNEL) {
2045+ netdev_err(priv->netdev,
2046+ "%s: MQPRIO mode channel offload is active, cannot set the TX-port-TS\n",
2047+ __func__);
2048+ return -EINVAL;
2049+ }
20392050 MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_TX_PORT_TS, enable);
20402051 /* No need to verify SQ stop room as
20412052 * ptpsq.txqsq.stop_room <= generic_sq->stop_room, and both
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+130−48
@@ -2264,7 +2264,7 @@ void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv) · 2263 unmodified lines
22642264 }
22652265
22662266 static int mlx5e_netdev_set_tcs(struct net_device *netdev, u16 nch, u8 ntc,
2267− struct tc_mqprio_qopt_offload *mqprio)
2267+ struct netdev_tc_txq *tc_to_txq)
22682268 {
22692269 int tc, err;
22702270
@@ -2282,11 +2282,8 @@ static int mlx5e_netdev_set_tcs(struct net_device *netdev, u16 nch, u8 ntc, · 11 unmodified lines
22822282 for (tc = 0; tc < ntc; tc++) {
22832283 u16 count, offset;
22842284
2285− /* For DCB mode, map netdev TCs to offset 0
2286− * We have our own UP to TXQ mapping for QoS
2287− */
2288− count = mqprio ? mqprio->qopt.count[tc] : nch;
2289− offset = mqprio ? mqprio->qopt.offset[tc] : 0;
2285+ count = tc_to_txq[tc].count;
2286+ offset = tc_to_txq[tc].offset;
22902287 netdev_set_tc_queue(netdev, tc, count, offset);
22912288 }
22922289
@@ -2315,19 +2312,24 @@ int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv) · 22 unmodified lines
23152312
23162313 static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
23172314 {
2315+ struct netdev_tc_txq old_tc_to_txq[TC_MAX_QUEUE], *tc_to_txq;
23182316 struct net_device *netdev = priv->netdev;
23192317 int old_num_txqs, old_ntc;
23202318 int num_rxqs, nch, ntc;
23212319 int err;
2320+ int i;
23222321
23232322 old_num_txqs = netdev->real_num_tx_queues;
23242323 old_ntc = netdev->num_tc ? : 1;
2324+ for (i = 0; i < ARRAY_SIZE(old_tc_to_txq); i++)
2325+ old_tc_to_txq[i] = netdev->tc_to_txq[i];
23252326
23262327 nch = priv->channels.params.num_channels;
2327− ntc = mlx5e_get_dcb_num_tc(&priv->channels.params);
2328+ ntc = priv->channels.params.mqprio.num_tc;
23282329 num_rxqs = nch * priv->profile->rq_groups;
2330+ tc_to_txq = priv->channels.params.mqprio.tc_to_txq;
23292331
2330− err = mlx5e_netdev_set_tcs(netdev, nch, ntc, NULL);
2332+ err = mlx5e_netdev_set_tcs(netdev, nch, ntc, tc_to_txq);
23312333 if (err)
23322334 goto err_out;
23332335 err = mlx5e_update_tx_netdev_queues(priv);
@@ -2350,11 +2352,14 @@ err_txqs: · 16 unmodified lines
23502352 WARN_ON_ONCE(netif_set_real_num_tx_queues(netdev, old_num_txqs));
23512353
23522354 err_tcs:
2353− mlx5e_netdev_set_tcs(netdev, old_num_txqs / old_ntc, old_ntc, NULL);
2355+ WARN_ON_ONCE(mlx5e_netdev_set_tcs(netdev, old_num_txqs / old_ntc, old_ntc,
2356+ old_tc_to_txq));
23542357 err_out:
23552358 return err;
23562359 }
23572360
2361+static MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_update_netdev_queues);
2362+
23582363 static void mlx5e_set_default_xps_cpumasks(struct mlx5e_priv *priv,
23592364 struct mlx5e_params *params)
23602365 {
@@ -2861,6 +2866,58 @@ static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd) · 500 unmodified lines
28612866 return 0;
28622867 }
28632868
2869+static void mlx5e_mqprio_build_default_tc_to_txq(struct netdev_tc_txq *tc_to_txq,
2870+ int ntc, int nch)
2871+{
2872+ int tc;
2873+
2874+ memset(tc_to_txq, 0, sizeof(*tc_to_txq) * TC_MAX_QUEUE);
2875+
2876+ /* Map netdev TCs to offset 0.
2877+ * We have our own UP to TXQ mapping for DCB mode of QoS
2878+ */
2879+ for (tc = 0; tc < ntc; tc++) {
2880+ tc_to_txq[tc] = (struct netdev_tc_txq) {
2881+ .count = nch,
2882+ .offset = 0,
2883+ };
2884+ }
2885+}
2886+
2887+static void mlx5e_mqprio_build_tc_to_txq(struct netdev_tc_txq *tc_to_txq,
2888+ struct tc_mqprio_qopt *qopt)
2889+{
2890+ int tc;
2891+
2892+ for (tc = 0; tc < TC_MAX_QUEUE; tc++) {
2893+ tc_to_txq[tc] = (struct netdev_tc_txq) {
2894+ .count = qopt->count[tc],
2895+ .offset = qopt->offset[tc],
2896+ };
2897+ }
2898+}
2899+
2900+static void mlx5e_params_mqprio_dcb_set(struct mlx5e_params *params, u8 num_tc)
2901+{
2902+ params->mqprio.mode = TC_MQPRIO_MODE_DCB;
2903+ params->mqprio.num_tc = num_tc;
2904+ mlx5e_mqprio_build_default_tc_to_txq(params->mqprio.tc_to_txq, num_tc,
2905+ params->num_channels);
2906+}
2907+
2908+static void mlx5e_params_mqprio_channel_set(struct mlx5e_params *params,
2909+ struct tc_mqprio_qopt *qopt)
2910+{
2911+ params->mqprio.mode = TC_MQPRIO_MODE_CHANNEL;
2912+ params->mqprio.num_tc = qopt->num_tc;
2913+ mlx5e_mqprio_build_tc_to_txq(params->mqprio.tc_to_txq, qopt);
2914+}
2915+
2916+static void mlx5e_params_mqprio_reset(struct mlx5e_params *params)
2917+{
2918+ mlx5e_params_mqprio_dcb_set(params, 1);
2919+}
2920+
28642921 static int mlx5e_setup_tc_mqprio_dcb(struct mlx5e_priv *priv,
28652922 struct tc_mqprio_qopt *mqprio)
28662923 {
@@ -2874,8 +2931,7 @@ static int mlx5e_setup_tc_mqprio_dcb(struct mlx5e_priv *priv, · 7 unmodified lines
28742931 return -EINVAL;
28752932
28762933 new_params = priv->channels.params;
2877− new_params.mqprio.mode = TC_MQPRIO_MODE_DCB;
2878− new_params.mqprio.num_tc = tc ? tc : 1;
2934+ mlx5e_params_mqprio_dcb_set(&new_params, tc ? tc : 1);
28792935
28802936 err = mlx5e_safe_switch_params(priv, &new_params,
28812937 mlx5e_num_channels_changed_ctx, NULL, true);
@@ -2889,9 +2945,17 @@ static int mlx5e_mqprio_channel_validate(struct mlx5e_priv *priv, · 7 unmodified lines
28892945 struct tc_mqprio_qopt_offload *mqprio)
28902946 {
28912947 struct net_device *netdev = priv->netdev;
2948+ struct mlx5e_ptp *ptp_channel;
28922949 int agg_count = 0;
28932950 int i;
28942951
2952+ ptp_channel = priv->channels.ptp;
2953+ if (ptp_channel && test_bit(MLX5E_PTP_STATE_TX, ptp_channel->state)) {
2954+ netdev_err(netdev,
2955+ "Cannot activate MQPRIO mode channel since it conflicts with TX port TS\n");
2956+ return -EINVAL;
2957+ }
2958+
28952959 if (mqprio->qopt.offset[0] != 0 || mqprio->qopt.num_tc < 1 ||
28962960 mqprio->qopt.num_tc > MLX5E_MAX_NUM_MQPRIO_CH_TC)
28972961 return -EINVAL;
@@ -2926,25 +2990,12 @@ static int mlx5e_mqprio_channel_validate(struct mlx5e_priv *priv, · 28 unmodified lines
29262990 return 0;
29272991 }
29282992
2929−static int mlx5e_mqprio_channel_set_tcs_ctx(struct mlx5e_priv *priv, void *ctx)
2930−{
2931− struct tc_mqprio_qopt_offload *mqprio = (struct tc_mqprio_qopt_offload *)ctx;
2932− struct net_device *netdev = priv->netdev;
2933− u8 num_tc;
2934−
2935− if (priv->channels.params.mqprio.mode != TC_MQPRIO_MODE_CHANNEL)
2936− return -EINVAL;
2937−
2938− num_tc = priv->channels.params.mqprio.num_tc;
2939− mlx5e_netdev_set_tcs(netdev, 0, num_tc, mqprio);
2940−
2941− return 0;
2942−}
2943−
29442993 static int mlx5e_setup_tc_mqprio_channel(struct mlx5e_priv *priv,
29452994 struct tc_mqprio_qopt_offload *mqprio)
29462995 {
2996+ mlx5e_fp_preactivate preactivate;
29472997 struct mlx5e_params new_params;
2998+ bool nch_changed;
29482999 int err;
29493000
29503001 err = mlx5e_mqprio_channel_validate(priv, mqprio);
@@ -2952,12 +3003,12 @@ static int mlx5e_setup_tc_mqprio_channel(struct mlx5e_priv *priv, · 1 unmodified line
29523003 return err;
29533004
29543005 new_params = priv->channels.params;
2955− new_params.mqprio.mode = TC_MQPRIO_MODE_CHANNEL;
2956− new_params.mqprio.num_tc = mqprio->qopt.num_tc;
2957− err = mlx5e_safe_switch_params(priv, &new_params,
2958− mlx5e_mqprio_channel_set_tcs_ctx, mqprio, true);
3006+ mlx5e_params_mqprio_channel_set(&new_params, &mqprio->qopt);
29593007
2960− return err;
3008+ nch_changed = mlx5e_get_dcb_num_tc(&priv->channels.params) > 1;
3009+ preactivate = nch_changed ? mlx5e_num_channels_changed_ctx :
3010+ mlx5e_update_netdev_queues_ctx;
3011+ return mlx5e_safe_switch_params(priv, &new_params, preactivate, NULL, true);
29613012 }
29623013
29633014 static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,
@@ -3065,7 +3116,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s) · 101 unmodified lines
30653116 {
30663117 int i;
30673118
3068− for (i = 0; i < priv->max_nch; i++) {
3119+ for (i = 0; i < priv->stats_nch; i++) {
30693120 struct mlx5e_channel_stats *channel_stats = &priv->channel_stats[i];
30703121 struct mlx5e_rq_stats *xskrq_stats = &channel_stats->xskrq;
30713122 struct mlx5e_rq_stats *rq_stats = &channel_stats->rq;
@@ -4186,13 +4237,11 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16 · 1114 unmodified lines
41864237 struct mlx5_core_dev *mdev = priv->mdev;
41874238 u8 rx_cq_period_mode;
41884239
4189− priv->max_nch = mlx5e_calc_max_nch(priv, priv->profile);
4190−
41914240 params->sw_mtu = mtu;
41924241 params->hard_mtu = MLX5E_ETH_HARD_MTU;
41934242 params->num_channels = min_t(unsigned int, MLX5E_MAX_NUM_CHANNELS / 2,
41944243 priv->max_nch);
4195− params->mqprio.num_tc = 1;
4244+ mlx5e_params_mqprio_reset(params);
41964245
41974246 /* Set an initial non-zero value, so that mlx5e_select_queue won't
41984247 * divide by zero if called before first activating channels.
@@ -4682,8 +4731,35 @@ static const struct mlx5e_profile mlx5e_nic_profile = { · 483 unmodified lines
46824731 .rx_ptp_support = true,
46834732 };
46844733
4734+static unsigned int
4735+mlx5e_calc_max_nch(struct mlx5_core_dev *mdev, struct net_device *netdev,
4736+ const struct mlx5e_profile *profile)
4737+
4738+{
4739+ unsigned int max_nch, tmp;
4740+
4741+ /* core resources */
4742+ max_nch = mlx5e_get_max_num_channels(mdev);
4743+
4744+ /* netdev rx queues */
4745+ tmp = netdev->num_rx_queues / max_t(u8, profile->rq_groups, 1);
4746+ max_nch = min_t(unsigned int, max_nch, tmp);
4747+
4748+ /* netdev tx queues */
4749+ tmp = netdev->num_tx_queues;
4750+ if (mlx5_qos_is_supported(mdev))
4751+ tmp -= mlx5e_qos_max_leaf_nodes(mdev);
4752+ if (MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn))
4753+ tmp -= profile->max_tc;
4754+ tmp = tmp / profile->max_tc;
4755+ max_nch = min_t(unsigned int, max_nch, tmp);
4756+
4757+ return max_nch;
4758+}
4759+
46854760 /* mlx5e generic netdev management API (move to en_common.c) */
46864761 int mlx5e_priv_init(struct mlx5e_priv *priv,
4762+ const struct mlx5e_profile *profile,
46874763 struct net_device *netdev,
46884764 struct mlx5_core_dev *mdev)
46894765 {
@@ -4691,6 +4767,8 @@ int mlx5e_priv_init(struct mlx5e_priv *priv, · 1 unmodified line
46914767 priv->mdev = mdev;
46924768 priv->netdev = netdev;
46934769 priv->msglevel = MLX5E_MSG_LEVEL;
4770+ priv->max_nch = mlx5e_calc_max_nch(mdev, netdev, profile);
4771+ priv->stats_nch = priv->max_nch;
46944772 priv->max_opened_tc = 1;
46954773
46964774 if (!alloc_cpumask_var(&priv->scratchpad.cpumask, GFP_KERNEL))
@@ -4734,7 +4812,8 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv) · 37 unmodified lines
47344812 }
47354813
47364814 struct net_device *
4737−mlx5e_create_netdev(struct mlx5_core_dev *mdev, unsigned int txqs, unsigned int rxqs)
4815+mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
4816+ unsigned int txqs, unsigned int rxqs)
47384817 {
47394818 struct net_device *netdev;
47404819 int err;
@@ -4745,7 +4824,7 @@ mlx5e_create_netdev(struct mlx5_core_dev *mdev, unsigned int txqs, unsigned int · 4 unmodified lines
47454824 return NULL;
47464825 }
47474826
4748− err = mlx5e_priv_init(netdev_priv(netdev), netdev, mdev);
4827+ err = mlx5e_priv_init(netdev_priv(netdev), profile, netdev, mdev);
47494828 if (err) {
47504829 mlx5_core_err(mdev, "mlx5e_priv_init failed, err=%d\n", err);
47514830 goto err_free_netdev;
@@ -4787,7 +4866,7 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv) · 35 unmodified lines
47874866 clear_bit(MLX5E_STATE_DESTROYING, &priv->state);
47884867
47894868 /* max number of channels may have changed */
4790− max_nch = mlx5e_get_max_num_channels(priv->mdev);
4869+ max_nch = mlx5e_calc_max_nch(priv->mdev, priv->netdev, profile);
47914870 if (priv->channels.params.num_channels > max_nch) {
47924871 mlx5_core_warn(priv->mdev, "MLX5E: Reducing number of channels to %d\n", max_nch);
47934872 /* Reducing the number of channels - RXFH has to be reset, and
@@ -4795,7 +4874,18 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv) · 1 unmodified line
47954874 */
47964875 priv->netdev->priv_flags &= ~IFF_RXFH_CONFIGURED;
47974876 priv->channels.params.num_channels = max_nch;
4877+ if (priv->channels.params.mqprio.mode == TC_MQPRIO_MODE_CHANNEL) {
4878+ mlx5_core_warn(priv->mdev, "MLX5E: Disabling MQPRIO channel mode\n");
4879+ mlx5e_params_mqprio_reset(&priv->channels.params);
4880+ }
47984881 }
4882+ if (max_nch != priv->max_nch) {
4883+ mlx5_core_warn(priv->mdev,
4884+ "MLX5E: Updating max number of channels from %u to %u\n",
4885+ priv->max_nch, max_nch);
4886+ priv->max_nch = max_nch;
4887+ }
4888+
47994889 /* 1. Set the real number of queues in the kernel the first time.
48004890 * 2. Set our default XPS cpumask.
48014891 * 3. Build the RQT.
@@ -4860,7 +4950,7 @@ mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mde · 58 unmodified lines
48604950 struct mlx5e_priv *priv = netdev_priv(netdev);
48614951 int err;
48624952
4863− err = mlx5e_priv_init(priv, netdev, mdev);
4953+ err = mlx5e_priv_init(priv, new_profile, netdev, mdev);
48644954 if (err) {
48654955 mlx5_core_err(mdev, "mlx5e_priv_init failed, err=%d\n", err);
48664956 return err;
@@ -4886,20 +4976,12 @@ priv_cleanup: · 19 unmodified lines
48864976 int mlx5e_netdev_change_profile(struct mlx5e_priv *priv,
48874977 const struct mlx5e_profile *new_profile, void *new_ppriv)
48884978 {
4889− unsigned int new_max_nch = mlx5e_calc_max_nch(priv, new_profile);
48904979 const struct mlx5e_profile *orig_profile = priv->profile;
48914980 struct net_device *netdev = priv->netdev;
48924981 struct mlx5_core_dev *mdev = priv->mdev;
48934982 void *orig_ppriv = priv->ppriv;
48944983 int err, rollback_err;
48954984
4896− /* sanity */
4897− if (new_max_nch != priv->max_nch) {
4898− netdev_warn(netdev, "%s: Replacing profile with different max channels\n",
4899− __func__);
4900− return -EINVAL;
4901− }
4902−
49034985 /* cleanup old profile */
49044986 mlx5e_detach_netdev(priv);
49054987 priv->profile->cleanup(priv);
@@ -4995,7 +5077,7 @@ static int mlx5e_probe(struct auxiliary_device *adev, · 89 unmodified lines
49955077 nch = mlx5e_get_max_num_channels(mdev);
49965078 txqs = nch * profile->max_tc + ptp_txqs + qos_sqs;
49975079 rxqs = nch * profile->rq_groups;
4998− netdev = mlx5e_create_netdev(mdev, txqs, rxqs);
5080+ netdev = mlx5e_create_netdev(mdev, profile, txqs, rxqs);
49995081 if (!netdev) {
50005082 mlx5_core_err(mdev, "mlx5e_create_netdev failed\n");
50015083 return -ENOMEM;
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+1−2
@@ -596,7 +596,6 @@ static void mlx5e_build_rep_params(struct net_device *netdev) · 595 unmodified lines
596596 MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
597597 MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
598598
599− priv->max_nch = mlx5e_calc_max_nch(priv, priv->profile);
600599 params = &priv->channels.params;
601600
602601 params->num_channels = MLX5E_REP_PARAMS_DEF_NUM_CHANNELS;
@@ -1169,7 +1168,7 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) · 566 unmodified lines
11691168 nch = mlx5e_get_max_num_channels(dev);
11701169 txqs = nch * profile->max_tc;
11711170 rxqs = nch * profile->rq_groups;
1172− netdev = mlx5e_create_netdev(dev, txqs, rxqs);
1171+ netdev = mlx5e_create_netdev(dev, profile, txqs, rxqs);
11731172 if (!netdev) {
11741173 mlx5_core_warn(dev,
11751174 "Failed to create representor netdev for vport %d\n",
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c+1−6
@@ -1001,14 +1001,9 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, · 1000 unmodified lines
10011001 goto csum_unnecessary;
10021002
10031003 if (likely(is_last_ethertype_ip(skb, &network_depth, &proto))) {
1004− u8 ipproto = get_ip_proto(skb, network_depth, proto);
1005−
1006− if (unlikely(ipproto == IPPROTO_SCTP))
1004+ if (unlikely(get_ip_proto(skb, network_depth, proto) == IPPROTO_SCTP))
10071005 goto csum_unnecessary;
10081006
1009− if (unlikely(mlx5_ipsec_is_rx_flow(cqe)))
1010− goto csum_none;
1011−
10121007 stats->csum_complete++;
10131008 skb->ip_summed = CHECKSUM_COMPLETE;
10141009 skb->csum = csum_unfold((__force __sum16)cqe->check_sum);
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c+6−5
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "en.h"
3535 #include "en_accel/tls.h"
3636 #include "en_accel/en_accel.h"
37+#include "en/ptp.h"
3738
3839 static unsigned int stats_grps_num(struct mlx5e_priv *priv)
3940 {
@@ -450,7 +451,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw) · 410 unmodified lines
450451
451452 memset(s, 0, sizeof(*s));
452453
453− for (i = 0; i < priv->max_nch; i++) {
454+ for (i = 0; i < priv->stats_nch; i++) {
454455 struct mlx5e_channel_stats *channel_stats =
455456 &priv->channel_stats[i];
456457 int j;
@@ -2076,7 +2077,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ptp) · 1619 unmodified lines
20762077 if (priv->rx_ptp_opened) {
20772078 for (i = 0; i < NUM_PTP_RQ_STATS; i++)
20782079 sprintf(data + (idx++) * ETH_GSTRING_LEN,
2079− ptp_rq_stats_desc[i].format);
2080+ ptp_rq_stats_desc[i].format, MLX5E_PTP_CHANNEL_IX);
20802081 }
20812082 return idx;
20822083 }
@@ -2119,7 +2120,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(ptp) { return; } · 36 unmodified lines
21192120
21202121 static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(channels)
21212122 {
2122− int max_nch = priv->max_nch;
2123+ int max_nch = priv->stats_nch;
21232124
21242125 return (NUM_RQ_STATS * max_nch) +
21252126 (NUM_CH_STATS * max_nch) +
@@ -2133,7 +2134,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(channels) · 7 unmodified lines
21332134 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(channels)
21342135 {
21352136 bool is_xsk = priv->xsk.ever_used;
2136− int max_nch = priv->max_nch;
2137+ int max_nch = priv->stats_nch;
21372138 int i, j, tc;
21382139
21392140 for (i = 0; i < max_nch; i++)
@@ -2175,7 +2176,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(channels) · 35 unmodified lines
21752176 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels)
21762177 {
21772178 bool is_xsk = priv->xsk.ever_used;
2178− int max_nch = priv->max_nch;
2179+ int max_nch = priv->stats_nch;
21792180 int i, j, tc;
21802181
21812182 for (i = 0; i < max_nch; i++)
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c+8−4
@@ -79,12 +79,16 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw, · 78 unmodified lines
7979 int dest_num = 0;
8080 int err = 0;
8181
82− if (MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter)) {
82+ if (vport->egress.legacy.drop_counter) {
83+ drop_counter = vport->egress.legacy.drop_counter;
84+ } else if (MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter)) {
8385 drop_counter = mlx5_fc_create(esw->dev, false);
84− if (IS_ERR(drop_counter))
86+ if (IS_ERR(drop_counter)) {
8587 esw_warn(esw->dev,
8688 "vport[%d] configure egress drop rule counter err(%ld)\n",
8789 vport->vport, PTR_ERR(drop_counter));
90+ drop_counter = NULL;
91+ }
8892 vport->egress.legacy.drop_counter = drop_counter;
8993 }
9094
@@ -123,7 +127,7 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw, · 32 unmodified lines
123127 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
124128
125129 /* Attach egress drop flow counter */
126− if (!IS_ERR_OR_NULL(drop_counter)) {
130+ if (drop_counter) {
127131 flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_COUNT;
128132 drop_ctr_dst.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
129133 drop_ctr_dst.counter_id = mlx5_fc_id(drop_counter);
@@ -162,7 +166,7 @@ void esw_acl_egress_lgcy_cleanup(struct mlx5_eswitch *esw, · 32 unmodified lines
162166 esw_acl_egress_table_destroy(vport);
163167
164168 clean_drop_counter:
165− if (!IS_ERR_OR_NULL(vport->egress.legacy.drop_counter)) {
169+ if (vport->egress.legacy.drop_counter) {
166170 mlx5_fc_destroy(esw->dev, vport->egress.legacy.drop_counter);
167171 vport->egress.legacy.drop_counter = NULL;
168172 }
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c+3−1
@@ -160,7 +160,9 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw, · 159 unmodified lines
160160
161161 esw_acl_ingress_lgcy_rules_destroy(vport);
162162
163− if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
163+ if (vport->ingress.legacy.drop_counter) {
164+ counter = vport->ingress.legacy.drop_counter;
165+ } else if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
164166 counter = mlx5_fc_create(esw->dev, false);
165167 if (IS_ERR(counter)) {
166168 esw_warn(esw->dev,
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c+2−2
@@ -113,7 +113,7 @@ static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv) · 112 unmodified lines
113113 struct mlx5e_sw_stats s = { 0 };
114114 int i, j;
115115
116− for (i = 0; i < priv->max_nch; i++) {
116+ for (i = 0; i < priv->stats_nch; i++) {
117117 struct mlx5e_channel_stats *channel_stats;
118118 struct mlx5e_rq_stats *rq_stats;
119119
@@ -711,7 +711,7 @@ static int mlx5_rdma_setup_rn(struct ib_device *ibdev, u32 port_num, · 591 unmodified lines
711711 goto destroy_ht;
712712 }
713713
714− err = mlx5e_priv_init(epriv, netdev, mdev);
714+ err = mlx5e_priv_init(epriv, prof, netdev, mdev);
715715 if (err)
716716 goto destroy_mdev_resources;
717717
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c+16−21
@@ -448,22 +448,20 @@ static u64 find_target_cycles(struct mlx5_core_dev *mdev, s64 target_ns) · 447 unmodified lines
448448 return cycles_now + cycles_delta;
449449 }
450450
451−static u64 perout_conf_internal_timer(struct mlx5_core_dev *mdev,
452− s64 sec, u32 nsec)
451+static u64 perout_conf_internal_timer(struct mlx5_core_dev *mdev, s64 sec)
453452 {
454− struct timespec64 ts;
453+ struct timespec64 ts = {};
455454 s64 target_ns;
456455
457456 ts.tv_sec = sec;
458− ts.tv_nsec = nsec;
459457 target_ns = timespec64_to_ns(&ts);
460458
461459 return find_target_cycles(mdev, target_ns);
462460 }
463461
464−static u64 perout_conf_real_time(s64 sec, u32 nsec)
462+static u64 perout_conf_real_time(s64 sec)
465463 {
466− return (u64)nsec | (u64)sec << 32;
464+ return (u64)sec << 32;
467465 }
468466
469467 static int mlx5_perout_configure(struct ptp_clock_info *ptp,
@@ -474,6 +472,7 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp, · 4 unmodified lines
474472 container_of(ptp, struct mlx5_clock, ptp_info);
475473 struct mlx5_core_dev *mdev =
476474 container_of(clock, struct mlx5_core_dev, clock);
475+ bool rt_mode = mlx5_real_time_mode(mdev);
477476 u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0};
478477 struct timespec64 ts;
479478 u32 field_select = 0;
@@ -501,8 +500,10 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp, · 21 unmodified lines
501500
502501 if (on) {
503502 bool rt_mode = mlx5_real_time_mode(mdev);
504− u32 nsec;
505− s64 sec;
503+ s64 sec = rq->perout.start.sec;
504+
505+ if (rq->perout.start.nsec)
506+ return -EINVAL;
506507
507508 pin_mode = MLX5_PIN_MODE_OUT;
508509 pattern = MLX5_OUT_PATTERN_PERIODIC;
@@ -513,14 +514,11 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp, · 4 unmodified lines
513514 if ((ns >> 1) != 500000000LL)
514515 return -EINVAL;
515516
516− nsec = rq->perout.start.nsec;
517− sec = rq->perout.start.sec;
518−
519517 if (rt_mode && sec > U32_MAX)
520518 return -EINVAL;
521519
522− time_stamp = rt_mode ? perout_conf_real_time(sec, nsec) :
523− perout_conf_internal_timer(mdev, sec, nsec);
520+ time_stamp = rt_mode ? perout_conf_real_time(sec) :
521+ perout_conf_internal_timer(mdev, sec);
524522
525523 field_select |= MLX5_MTPPS_FS_PIN_MODE |
526524 MLX5_MTPPS_FS_PATTERN |
@@ -538,6 +536,9 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp, · 11 unmodified lines
538536 if (err)
539537 return err;
540538
539+ if (rt_mode)
540+ return 0;
541+
541542 return mlx5_set_mtppse(mdev, pin, 0,
542543 MLX5_EVENT_MODE_REPETETIVE & on);
543544 }
@@ -705,20 +706,14 @@ static void ts_next_sec(struct timespec64 *ts) · 161 unmodified lines
705706 static u64 perout_conf_next_event_timer(struct mlx5_core_dev *mdev,
706707 struct mlx5_clock *clock)
707708 {
708− bool rt_mode = mlx5_real_time_mode(mdev);
709709 struct timespec64 ts;
710710 s64 target_ns;
711711
712− if (rt_mode)
713− ts = mlx5_ptp_gettimex_real_time(mdev, NULL);
714− else
715− mlx5_ptp_gettimex(&clock->ptp_info, &ts, NULL);
716−
712+ mlx5_ptp_gettimex(&clock->ptp_info, &ts, NULL);
717713 ts_next_sec(&ts);
718714 target_ns = timespec64_to_ns(&ts);
719715
720− return rt_mode ? perout_conf_real_time(ts.tv_sec, ts.tv_nsec) :
721− find_target_cycles(mdev, target_ns);
716+ return find_target_cycles(mdev, target_ns);
722717 }
723718
724719 static int mlx5_pps_event(struct notifier_block *nb,
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c+5−4
@@ -13,8 +13,8 @@ · 12 unmodified lines
1313 #endif
1414
1515 #define MLX5_MAX_IRQ_NAME (32)
16−/* max irq_index is 255. three chars */
17−#define MLX5_MAX_IRQ_IDX_CHARS (3)
16+/* max irq_index is 2047, so four chars */
17+#define MLX5_MAX_IRQ_IDX_CHARS (4)
1818
1919 #define MLX5_SFS_PER_CTRL_IRQ 64
2020 #define MLX5_IRQ_CTRL_SF_MAX 8
@@ -633,8 +633,9 @@ void mlx5_irq_table_destroy(struct mlx5_core_dev *dev) · 612 unmodified lines
633633 int mlx5_irq_table_get_sfs_vec(struct mlx5_irq_table *table)
634634 {
635635 if (table->sf_comp_pool)
636− return table->sf_comp_pool->xa_num_irqs.max -
637− table->sf_comp_pool->xa_num_irqs.min + 1;
636+ return min_t(int, num_online_cpus(),
637+ table->sf_comp_pool->xa_num_irqs.max -
638+ table->sf_comp_pool->xa_num_irqs.min + 1);
638639 else
639640 return mlx5_irq_table_get_num_comp(table);
640641 }
drivers/net/ethernet/mscc/ocelot_vcap.c+2−2
@@ -998,8 +998,8 @@ ocelot_vcap_block_find_filter_by_index(struct ocelot_vcap_block *block, · 997 unmodified lines
998998 }
999999
10001000 struct ocelot_vcap_filter *
1001−ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block, int cookie,
1002− bool tc_offload)
1001+ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block,
1002+ unsigned long cookie, bool tc_offload)
10031003 {
10041004 struct ocelot_vcap_filter *filter;
10051005
drivers/net/ethernet/pensando/ionic/ionic_lif.c+3−1
@@ -1292,8 +1292,10 @@ int ionic_lif_addr_add(struct ionic_lif *lif, const u8 *addr) · 1291 unmodified lines
12921292 if (err && err != -EEXIST) {
12931293 /* set the state back to NEW so we can try again later */
12941294 f = ionic_rx_filter_by_addr(lif, addr);
1295− if (f && f->state == IONIC_FILTER_STATE_SYNCED)
1295+ if (f && f->state == IONIC_FILTER_STATE_SYNCED) {
12961296 f->state = IONIC_FILTER_STATE_NEW;
1297+ set_bit(IONIC_LIF_F_FILTER_SYNC_NEEDED, lif->state);
1298+ }
12971299
12981300 spin_unlock_bh(&lif->rx_filters.lock);
12991301
drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c+0−3
@@ -349,9 +349,6 @@ loop_out: · 348 unmodified lines
349349 list_for_each_entry_safe(sync_item, spos, &sync_add_list, list) {
350350 (void)ionic_lif_addr_add(lif, sync_item->f.cmd.mac.addr);
351351
352− if (sync_item->f.state != IONIC_FILTER_STATE_SYNCED)
353− set_bit(IONIC_LIF_F_FILTER_SYNC_NEEDED, lif->state);
354−
355352 list_del(&sync_item->list);
356353 devm_kfree(dev, sync_item);
357354 }
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c+5−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <linux/delay.h>
2222 #include <linux/mfd/syscon.h>
2323 #include <linux/regmap.h>
24+#include <linux/pm_runtime.h>
2425
2526 #include "stmmac_platform.h"
2627
@@ -1528,6 +1529,8 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) · 1501 unmodified lines
15281529 return ret;
15291530 }
15301531
1532+ pm_runtime_get_sync(dev);
1533+
15311534 if (bsp_priv->integrated_phy)
15321535 rk_gmac_integrated_phy_powerup(bsp_priv);
15331536
@@ -1539,6 +1542,8 @@ static void rk_gmac_powerdown(struct rk_priv_data *gmac) · 5 unmodified lines
15391542 if (gmac->integrated_phy)
15401543 rk_gmac_integrated_phy_powerdown(gmac);
15411544
1545+ pm_runtime_put_sync(&gmac->pdev->dev);
1546+
15421547 phy_power_on(gmac, false);
15431548 gmac_clk_enable(gmac, false);
15441549 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+5−1
@@ -477,6 +477,10 @@ bool stmmac_eee_init(struct stmmac_priv *priv) · 476 unmodified lines
477477 stmmac_lpi_entry_timer_config(priv, 0);
478478 del_timer_sync(&priv->eee_ctrl_timer);
479479 stmmac_set_eee_timer(priv, priv->hw, 0, eee_tw_timer);
480+ if (priv->hw->xpcs)
481+ xpcs_config_eee(priv->hw->xpcs,
482+ priv->plat->mult_fact_100ns,
483+ false);
480484 }
481485 mutex_unlock(&priv->lock);
482486 return false;
@@ -1038,7 +1042,7 @@ static void stmmac_mac_link_down(struct phylink_config *config, · 555 unmodified lines
10381042 stmmac_mac_set(priv, priv->ioaddr, false);
10391043 priv->eee_active = false;
10401044 priv->tx_lpi_enabled = false;
1041− stmmac_eee_init(priv);
1045+ priv->eee_enabled = stmmac_eee_init(priv);
10421046 stmmac_set_eee_pls(priv, priv->hw, false);
10431047
10441048 if (priv->dma_cap.fpesel)
drivers/net/pcs/pcs-xpcs.c+36−9
@@ -666,6 +666,10 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) · 665 unmodified lines
666666 {
667667 int ret;
668668
669+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0);
670+ if (ret < 0)
671+ return ret;
672+
669673 if (enable) {
670674 /* Enable EEE */
671675 ret = DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN |
@@ -673,9 +677,6 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) · 1 unmodified line
673677 DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL |
674678 mult_fact_100ns << DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT;
675679 } else {
676− ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0);
677− if (ret < 0)
678− return ret;
679680 ret &= ~(DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN |
680681 DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN |
681682 DW_VR_MII_EEE_TX_EN_CTRL | DW_VR_MII_EEE_RX_EN_CTRL |
@@ -690,21 +691,28 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) · 8 unmodified lines
690691 if (ret < 0)
691692 return ret;
692693
693− ret |= DW_VR_MII_EEE_TRN_LPI;
694+ if (enable)
695+ ret |= DW_VR_MII_EEE_TRN_LPI;
696+ else
697+ ret &= ~DW_VR_MII_EEE_TRN_LPI;
698+
694699 return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1, ret);
695700 }
696701 EXPORT_SYMBOL_GPL(xpcs_config_eee);
697702
698703 static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode)
699704 {
700− int ret;
705+ int ret, mdio_ctrl;
701706
702707 /* For AN for C37 SGMII mode, the settings are :-
703− * 1) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 10b (SGMII AN)
704− * 2) VR_MII_AN_CTRL Bit(3) [TX_CONFIG] = 0b (MAC side SGMII)
708+ * 1) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 0b (Disable SGMII AN in case
709+ it is already enabled)
710+ * 2) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 10b (SGMII AN)
711+ * 3) VR_MII_AN_CTRL Bit(3) [TX_CONFIG] = 0b (MAC side SGMII)
705712 * DW xPCS used with DW EQoS MAC is always MAC side SGMII.
706− * 3) VR_MII_DIG_CTRL1 Bit(9) [MAC_AUTO_SW] = 1b (Automatic
713+ * 4) VR_MII_DIG_CTRL1 Bit(9) [MAC_AUTO_SW] = 1b (Automatic
707714 * speed/duplex mode change by HW after SGMII AN complete)
715+ * 5) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable SGMII AN)
708716 *
709717 * Note: Since it is MAC side SGMII, there is no need to set
710718 * SR_MII_AN_ADV. MAC side SGMII receives AN Tx Config from
@@ -712,6 +720,17 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode) · 1 unmodified line
712720 * between PHY and Link Partner. There is also no need to
713721 * trigger AN restart for MAC-side SGMII.
714722 */
723+ mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL);
724+ if (mdio_ctrl < 0)
725+ return mdio_ctrl;
726+
727+ if (mdio_ctrl & AN_CL37_EN) {
728+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL,
729+ mdio_ctrl & ~AN_CL37_EN);
730+ if (ret < 0)
731+ return ret;
732+ }
733+
715734 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL);
716735 if (ret < 0)
717736 return ret;
@@ -736,7 +755,15 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode) · 18 unmodified lines
736755 else
737756 ret &= ~DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW;
738757
739− return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret);
758+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret);
759+ if (ret < 0)
760+ return ret;
761+
762+ if (phylink_autoneg_inband(mode))
763+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL,
764+ mdio_ctrl | AN_CL37_EN);
765+
766+ return ret;
740767 }
741768
742769 static int xpcs_config_2500basex(struct dw_xpcs *xpcs)
drivers/net/phy/mdio_bus.c+7−1
@@ -538,10 +538,16 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) · 537 unmodified lines
538538 bus->dev.groups = NULL;
539539 dev_set_name(&bus->dev, "%s", bus->id);
540540
541+ /* We need to set state to MDIOBUS_UNREGISTERED to correctly release
542+ * the device in mdiobus_free()
543+ *
544+ * State will be updated later in this function in case of success
545+ */
546+ bus->state = MDIOBUS_UNREGISTERED;
547+
541548 err = device_register(&bus->dev);
542549 if (err) {
543550 pr_err("mii_bus %s failed to register\n", bus->id);
544− put_device(&bus->dev);
545551 return -EINVAL;
546552 }
547553
drivers/net/phy/sfp.c+1−1
@@ -134,7 +134,7 @@ static const char * const sm_state_strings[] = { · 133 unmodified lines
134134 [SFP_S_LINK_UP] = "link_up",
135135 [SFP_S_TX_FAULT] = "tx_fault",
136136 [SFP_S_REINIT] = "reinit",
137− [SFP_S_TX_DISABLE] = "rx_disable",
137+ [SFP_S_TX_DISABLE] = "tx_disable",
138138 };
139139
140140 static const char *sm_state_to_str(unsigned short sm_state)
drivers/net/usb/r8152.c+15−1
@@ -767,6 +767,7 @@ enum rtl8152_flags { · 766 unmodified lines
767767 PHY_RESET,
768768 SCHEDULE_TASKLET,
769769 GREEN_ETHERNET,
770+ RX_EPROTO,
770771 };
771772
772773 #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2 0x3082
@@ -1770,6 +1771,14 @@ static void read_bulk_callback(struct urb *urb) · 997 unmodified lines
17701771 rtl_set_unplug(tp);
17711772 netif_device_detach(tp->netdev);
17721773 return;
1774+ case -EPROTO:
1775+ urb->actual_length = 0;
1776+ spin_lock_irqsave(&tp->rx_lock, flags);
1777+ list_add_tail(&agg->list, &tp->rx_done);
1778+ spin_unlock_irqrestore(&tp->rx_lock, flags);
1779+ set_bit(RX_EPROTO, &tp->flags);
1780+ schedule_delayed_work(&tp->schedule, 1);
1781+ return;
17731782 case -ENOENT:
17741783 return; /* the urb is in unlink state */
17751784 case -ETIME:
@@ -2425,6 +2434,7 @@ static int rx_bottom(struct r8152 *tp, int budget) · 649 unmodified lines
24252434 if (list_empty(&tp->rx_done))
24262435 goto out1;
24272436
2437+ clear_bit(RX_EPROTO, &tp->flags);
24282438 INIT_LIST_HEAD(&rx_queue);
24292439 spin_lock_irqsave(&tp->rx_lock, flags);
24302440 list_splice_init(&tp->rx_done, &rx_queue);
@@ -2441,7 +2451,7 @@ static int rx_bottom(struct r8152 *tp, int budget) · 10 unmodified lines
24412451
24422452 agg = list_entry(cursor, struct rx_agg, list);
24432453 urb = agg->urb;
2444− if (urb->actual_length < ETH_ZLEN)
2454+ if (urb->status != 0 || urb->actual_length < ETH_ZLEN)
24452455 goto submit;
24462456
24472457 agg_free = rtl_get_free_rx(tp, GFP_ATOMIC);
@@ -6643,6 +6653,10 @@ static void rtl_work_func_t(struct work_struct *work) · 4195 unmodified lines
66436653 netif_carrier_ok(tp->netdev))
66446654 tasklet_schedule(&tp->tx_tl);
66456655
6656+ if (test_and_clear_bit(RX_EPROTO, &tp->flags) &&
6657+ !list_empty(&tp->rx_done))
6658+ napi_schedule(&tp->napi);
6659+
66466660 mutex_unlock(&tp->control);
66476661
66486662 out1:
drivers/net/wireless/ath/ath5k/Kconfig+1−3
@@ -3,9 +3,7 @@ config ATH5K · 2 unmodified lines
33 tristate "Atheros 5xxx wireless cards support"
44 depends on (PCI || ATH25) && MAC80211
55 select ATH_COMMON
6− select MAC80211_LEDS
7− select LEDS_CLASS
8− select NEW_LEDS
6+ select MAC80211_LEDS if LEDS_CLASS=y || LEDS_CLASS=MAC80211
97 select ATH5K_AHB if ATH25
108 select ATH5K_PCI if !ATH25
119 help
drivers/net/wireless/ath/ath5k/led.c+6−4
@@ -89,7 +89,8 @@ static const struct pci_device_id ath5k_led_devices[] = { · 88 unmodified lines
8989
9090 void ath5k_led_enable(struct ath5k_hw *ah)
9191 {
92− if (test_bit(ATH_STAT_LEDSOFT, ah->status)) {
92+ if (IS_ENABLED(CONFIG_MAC80211_LEDS) &&
93+ test_bit(ATH_STAT_LEDSOFT, ah->status)) {
9394 ath5k_hw_set_gpio_output(ah, ah->led_pin);
9495 ath5k_led_off(ah);
9596 }
@@ -104,7 +105,8 @@ static void ath5k_led_on(struct ath5k_hw *ah) · 8 unmodified lines
104105
105106 void ath5k_led_off(struct ath5k_hw *ah)
106107 {
107− if (!test_bit(ATH_STAT_LEDSOFT, ah->status))
108+ if (!IS_ENABLED(CONFIG_MAC80211_LEDS) ||
109+ !test_bit(ATH_STAT_LEDSOFT, ah->status))
108110 return;
109111 ath5k_hw_set_gpio(ah, ah->led_pin, !ah->led_on);
110112 }
@@ -146,7 +148,7 @@ ath5k_register_led(struct ath5k_hw *ah, struct ath5k_led *led, · 35 unmodified lines
146148 static void
147149 ath5k_unregister_led(struct ath5k_led *led)
148150 {
149− if (!led->ah)
151+ if (!IS_ENABLED(CONFIG_MAC80211_LEDS) || !led->ah)
150152 return;
151153 led_classdev_unregister(&led->led_dev);
152154 ath5k_led_off(led->ah);
@@ -169,7 +171,7 @@ int ath5k_init_leds(struct ath5k_hw *ah) · 16 unmodified lines
169171 char name[ATH5K_LED_MAX_NAME_LEN + 1];
170172 const struct pci_device_id *match;
171173
172− if (!ah->pdev)
174+ if (!IS_ENABLED(CONFIG_MAC80211_LEDS) || !ah->pdev)
173175 return 0;
174176
175177 #ifdef CONFIG_ATH5K_AHB
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c+6−11
@@ -7463,23 +7463,18 @@ static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2], · 7462 unmodified lines
74637463 s32 found_index;
74647464 int i;
74657465
7466+ country_codes = drvr->settings->country_codes;
7467+ if (!country_codes) {
7468+ brcmf_dbg(TRACE, "No country codes configured for device\n");
7469+ return -EINVAL;
7470+ }
7471+
74667472 if ((alpha2[0] == ccreq->country_abbrev[0]) &&
74677473 (alpha2[1] == ccreq->country_abbrev[1])) {
74687474 brcmf_dbg(TRACE, "Country code already set\n");
74697475 return -EAGAIN;
74707476 }
74717477
7472− country_codes = drvr->settings->country_codes;
7473− if (!country_codes) {
7474− brcmf_dbg(TRACE, "No country codes configured for device, using ISO3166 code and 0 rev\n");
7475− memset(ccreq, 0, sizeof(*ccreq));
7476− ccreq->country_abbrev[0] = alpha2[0];
7477− ccreq->country_abbrev[1] = alpha2[1];
7478− ccreq->ccode[0] = alpha2[0];
7479− ccreq->ccode[1] = alpha2[1];
7480− return 0;
7481− }
7482−
74837478 found_index = -1;
74847479 for (i = 0; i < country_codes->table_size; i++) {
74857480 cc = &country_codes->table[i];
drivers/net/wireless/intel/iwlwifi/mvm/d3.c+3−2
@@ -160,6 +160,7 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, · 159 unmodified lines
160160 mvm->ptk_icvlen = key->icv_len;
161161 mvm->gtk_ivlen = key->iv_len;
162162 mvm->gtk_icvlen = key->icv_len;
163+ mutex_unlock(&mvm->mutex);
163164
164165 /* don't upload key again */
165166 return;
@@ -360,11 +361,11 @@ static void iwl_mvm_wowlan_get_rsc_v5_data(struct ieee80211_hw *hw, · 194 unmodified lines
360361 if (sta) {
361362 rsc = data->rsc->ucast_rsc;
362363 } else {
363− if (WARN_ON(data->gtks > ARRAY_SIZE(data->gtk_ids)))
364+ if (WARN_ON(data->gtks >= ARRAY_SIZE(data->gtk_ids)))
364365 return;
365366 data->gtk_ids[data->gtks] = key->keyidx;
366367 rsc = data->rsc->mcast_rsc[data->gtks % 2];
367− if (WARN_ON(key->keyidx >
368+ if (WARN_ON(key->keyidx >=
368369 ARRAY_SIZE(data->rsc->mcast_key_id_map)))
369370 return;
370371 data->rsc->mcast_key_id_map[key->keyidx] = data->gtks % 2;
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c+2−1
@@ -662,12 +662,13 @@ static bool __iwl_mvm_remove_time_event(struct iwl_mvm *mvm, · 661 unmodified lines
662662 u32 *uid)
663663 {
664664 u32 id;
665− struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
665+ struct iwl_mvm_vif *mvmvif;
666666 enum nl80211_iftype iftype;
667667
668668 if (!te_data->vif)
669669 return false;
670670
671+ mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
671672 iftype = te_data->vif->type;
672673
673674 /*
drivers/net/wireless/intel/iwlwifi/pcie/drv.c+2−0
@@ -547,6 +547,8 @@ static const struct iwl_dev_info iwl_dev_info_table[] = { · 546 unmodified lines
547547 IWL_DEV_INFO(0x43F0, 0x0074, iwl_ax201_cfg_qu_hr, NULL),
548548 IWL_DEV_INFO(0x43F0, 0x0078, iwl_ax201_cfg_qu_hr, NULL),
549549 IWL_DEV_INFO(0x43F0, 0x007C, iwl_ax201_cfg_qu_hr, NULL),
550+ IWL_DEV_INFO(0x43F0, 0x1651, killer1650s_2ax_cfg_qu_b0_hr_b0, iwl_ax201_killer_1650s_name),
551+ IWL_DEV_INFO(0x43F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0, iwl_ax201_killer_1650i_name),
550552 IWL_DEV_INFO(0x43F0, 0x2074, iwl_ax201_cfg_qu_hr, NULL),
551553 IWL_DEV_INFO(0x43F0, 0x4070, iwl_ax201_cfg_qu_hr, NULL),
552554 IWL_DEV_INFO(0xA0F0, 0x0070, iwl_ax201_cfg_qu_hr, NULL),
drivers/net/wireless/marvell/mwifiex/sta_tx.c+2−2
@@ -62,8 +62,8 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv, · 61 unmodified lines
6262
6363 pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0;
6464
65− pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)-
66− NULL) & (MWIFIEX_DMA_ALIGN_SZ - 1);
65+ pad = ((uintptr_t)skb->data - (sizeof(*local_tx_pd) + hroom)) &
66+ (MWIFIEX_DMA_ALIGN_SZ - 1);
6767 skb_push(skb, sizeof(*local_tx_pd) + pad);
6868
6969 local_tx_pd = (struct txpd *) skb->data;
drivers/net/wireless/marvell/mwifiex/uap_txrx.c+2−2
@@ -475,8 +475,8 @@ void *mwifiex_process_uap_txpd(struct mwifiex_private *priv, · 474 unmodified lines
475475
476476 pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0;
477477
478− pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) &
479− (MWIFIEX_DMA_ALIGN_SZ - 1);
478+ pad = ((uintptr_t)skb->data - (sizeof(*txpd) + hroom)) &
479+ (MWIFIEX_DMA_ALIGN_SZ - 1);
480480
481481 skb_push(skb, sizeof(*txpd) + pad);
482482
drivers/ptp/ptp_pch.c+1−0
@@ -644,6 +644,7 @@ static const struct pci_device_id pch_ieee1588_pcidev_id[] = { · 643 unmodified lines
644644 },
645645 {0}
646646 };
647+MODULE_DEVICE_TABLE(pci, pch_ieee1588_pcidev_id);
647648
648649 static SIMPLE_DEV_PM_OPS(pch_pm_ops, pch_suspend, pch_resume);
649650
include/linux/etherdevice.h+1−1
@@ -308,7 +308,7 @@ static inline void ether_addr_copy(u8 *dst, const u8 *src) · 307 unmodified lines
308308 */
309309 static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
310310 {
311− ether_addr_copy(dev->dev_addr, addr);
311+ __dev_addr_set(dev, addr, ETH_ALEN);
312312 }
313313
314314 /**
include/net/netfilter/ipv6/nf_defrag_ipv6.h+0−1
@@ -17,7 +17,6 @@ struct inet_frags_ctl; · 16 unmodified lines
1717 struct nft_ct_frag6_pernet {
1818 struct ctl_table_header *nf_frag_frags_hdr;
1919 struct fqdir *fqdir;
20− unsigned int users;
2120 };
2221
2322 #endif /* _NF_DEFRAG_IPV6_H */
include/net/netfilter/nf_tables.h+1−1
@@ -1202,7 +1202,7 @@ struct nft_object *nft_obj_lookup(const struct net *net, · 1201 unmodified lines
12021202
12031203 void nft_obj_notify(struct net *net, const struct nft_table *table,
12041204 struct nft_object *obj, u32 portid, u32 seq,
1205− int event, int family, int report, gfp_t gfp);
1205+ int event, u16 flags, int family, int report, gfp_t gfp);
12061206
12071207 /**
12081208 * struct nft_object_type - stateful object type
include/net/netns/netfilter.h+6−0
@@ -27,5 +27,11 @@ struct netns_nf { · 26 unmodified lines
2727 #if IS_ENABLED(CONFIG_DECNET)
2828 struct nf_hook_entries __rcu *hooks_decnet[NF_DN_NUMHOOKS];
2929 #endif
30+#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
31+ unsigned int defrag_ipv4_users;
32+#endif
33+#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
34+ unsigned int defrag_ipv6_users;
35+#endif
3036 };
3137 #endif
include/net/sock.h+1−0
@@ -307,6 +307,7 @@ struct bpf_local_storage; · 306 unmodified lines
307307 * @sk_priority: %SO_PRIORITY setting
308308 * @sk_type: socket type (%SOCK_STREAM, etc)
309309 * @sk_protocol: which protocol this socket belongs in this network family
310+ * @sk_peer_lock: lock protecting @sk_peer_pid and @sk_peer_cred
310311 * @sk_peer_pid: &struct pid for this socket's peer
311312 * @sk_peer_cred: %SO_PEERCRED setting
312313 * @sk_rcvlowat: %SO_RCVLOWAT setting
include/soc/mscc/ocelot_vcap.h+2−2
@@ -694,7 +694,7 @@ int ocelot_vcap_filter_add(struct ocelot *ocelot, · 693 unmodified lines
694694 int ocelot_vcap_filter_del(struct ocelot *ocelot,
695695 struct ocelot_vcap_filter *rule);
696696 struct ocelot_vcap_filter *
697−ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block, int id,
698− bool tc_offload);
697+ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block,
698+ unsigned long cookie, bool tc_offload);
699699
700700 #endif /* _OCELOT_VCAP_H_ */
include/uapi/linux/xfrm.h+9−6
@@ -213,13 +213,13 @@ enum { · 212 unmodified lines
213213 XFRM_MSG_GETSPDINFO,
214214 #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
215215
216+ XFRM_MSG_MAPPING,
217+#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
218+
216219 XFRM_MSG_SETDEFAULT,
217220 #define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT
218221 XFRM_MSG_GETDEFAULT,
219222 #define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT
220−
221− XFRM_MSG_MAPPING,
222−#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
223223 __XFRM_MSG_MAX
224224 };
225225 #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
@@ -514,9 +514,12 @@ struct xfrm_user_offload { · 288 unmodified lines
514514 #define XFRM_OFFLOAD_INBOUND 2
515515
516516 struct xfrm_userpolicy_default {
517−#define XFRM_USERPOLICY_DIRMASK_MAX (sizeof(__u8) * 8)
518− __u8 dirmask;
519− __u8 action;
517+#define XFRM_USERPOLICY_UNSPEC 0
518+#define XFRM_USERPOLICY_BLOCK 1
519+#define XFRM_USERPOLICY_ACCEPT 2
520+ __u8 in;
521+ __u8 fwd;
522+ __u8 out;
520523 };
521524
522525 #ifndef __KERNEL__
kernel/bpf/stackmap.c+2−1
@@ -63,7 +63,8 @@ static inline int stack_map_data_size(struct bpf_map *map) · 62 unmodified lines
6363
6464 static int prealloc_elems_and_freelist(struct bpf_stack_map *smap)
6565 {
66− u32 elem_size = sizeof(struct stack_map_bucket) + smap->map.value_size;
66+ u64 elem_size = sizeof(struct stack_map_bucket) +
67+ (u64)smap->map.value_size;
6768 int err;
6869
6970 smap->elems = bpf_map_area_alloc(elem_size * smap->map.max_entries,
net/bridge/br_netlink.c+2−1
@@ -1666,7 +1666,8 @@ static size_t br_get_linkxstats_size(const struct net_device *dev, int attr) · 1665 unmodified lines
16661666 }
16671667
16681668 return numvls * nla_total_size(sizeof(struct bridge_vlan_xstats)) +
1669− nla_total_size(sizeof(struct br_mcast_stats)) +
1669+ nla_total_size_64bit(sizeof(struct br_mcast_stats)) +
1670+ (p ? nla_total_size_64bit(sizeof(p->stp_xstats)) : 0) +
16701671 nla_total_size(0);
16711672 }
16721673
net/core/rtnetlink.c+1−1
@@ -5262,7 +5262,7 @@ nla_put_failure: · 5261 unmodified lines
52625262 static size_t if_nlmsg_stats_size(const struct net_device *dev,
52635263 u32 filter_mask)
52645264 {
5265− size_t size = 0;
5265+ size_t size = NLMSG_ALIGN(sizeof(struct if_stats_msg));
52665266
52675267 if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_64, 0))
52685268 size += nla_total_size_64bit(sizeof(struct rtnl_link_stats64));
net/dsa/tag_dsa.c+1−1
@@ -210,7 +210,7 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, · 209 unmodified lines
210210 cmd = dsa_header[0] >> 6;
211211 switch (cmd) {
212212 case DSA_CMD_FORWARD:
213− trunk = !!(dsa_header[1] & 7);
213+ trunk = !!(dsa_header[1] & 4);
214214 break;
215215
216216 case DSA_CMD_TO_CPU:
net/ipv4/inet_hashtables.c+3−1
@@ -242,8 +242,10 @@ static inline int compute_score(struct sock *sk, struct net *net, · 241 unmodified lines
242242
243243 if (!inet_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif))
244244 return -1;
245+ score = sk->sk_bound_dev_if ? 2 : 1;
245246
246− score = sk->sk_family == PF_INET ? 2 : 1;
247+ if (sk->sk_family == PF_INET)
248+ score++;
247249 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
248250 score++;
249251 }
net/ipv4/netfilter/nf_defrag_ipv4.c+9−21
@@ -20,13 +20,8 @@ · 19 unmodified lines
2020 #endif
2121 #include <net/netfilter/nf_conntrack_zones.h>
2222
23−static unsigned int defrag4_pernet_id __read_mostly;
2423 static DEFINE_MUTEX(defrag4_mutex);
2524
26−struct defrag4_pernet {
27− unsigned int users;
28−};
29−
3025 static int nf_ct_ipv4_gather_frags(struct net *net, struct sk_buff *skb,
3126 u_int32_t user)
3227 {
@@ -111,19 +106,15 @@ static const struct nf_hook_ops ipv4_defrag_ops[] = { · 78 unmodified lines
111106
112107 static void __net_exit defrag4_net_exit(struct net *net)
113108 {
114− struct defrag4_pernet *nf_defrag = net_generic(net, defrag4_pernet_id);
115−
116− if (nf_defrag->users) {
109+ if (net->nf.defrag_ipv4_users) {
117110 nf_unregister_net_hooks(net, ipv4_defrag_ops,
118111 ARRAY_SIZE(ipv4_defrag_ops));
119− nf_defrag->users = 0;
112+ net->nf.defrag_ipv4_users = 0;
120113 }
121114 }
122115
123116 static struct pernet_operations defrag4_net_ops = {
124117 .exit = defrag4_net_exit,
125− .id = &defrag4_pernet_id,
126− .size = sizeof(struct defrag4_pernet),
127118 };
128119
129120 static int __init nf_defrag_init(void)
@@ -138,24 +129,23 @@ static void __exit nf_defrag_fini(void) · 8 unmodified lines
138129
139130 int nf_defrag_ipv4_enable(struct net *net)
140131 {
141− struct defrag4_pernet *nf_defrag = net_generic(net, defrag4_pernet_id);
142132 int err = 0;
143133
144134 mutex_lock(&defrag4_mutex);
145− if (nf_defrag->users == UINT_MAX) {
135+ if (net->nf.defrag_ipv4_users == UINT_MAX) {
146136 err = -EOVERFLOW;
147137 goto out_unlock;
148138 }
149139
150− if (nf_defrag->users) {
151− nf_defrag->users++;
140+ if (net->nf.defrag_ipv4_users) {
141+ net->nf.defrag_ipv4_users++;
152142 goto out_unlock;
153143 }
154144
155145 err = nf_register_net_hooks(net, ipv4_defrag_ops,
156146 ARRAY_SIZE(ipv4_defrag_ops));
157147 if (err == 0)
158− nf_defrag->users = 1;
148+ net->nf.defrag_ipv4_users = 1;
159149
160150 out_unlock:
161151 mutex_unlock(&defrag4_mutex);
@@ -165,12 +155,10 @@ EXPORT_SYMBOL_GPL(nf_defrag_ipv4_enable); · 3 unmodified lines
165155
166156 void nf_defrag_ipv4_disable(struct net *net)
167157 {
168− struct defrag4_pernet *nf_defrag = net_generic(net, defrag4_pernet_id);
169−
170158 mutex_lock(&defrag4_mutex);
171− if (nf_defrag->users) {
172− nf_defrag->users--;
173− if (nf_defrag->users == 0)
159+ if (net->nf.defrag_ipv4_users) {
160+ net->nf.defrag_ipv4_users--;
161+ if (net->nf.defrag_ipv4_users == 0)
174162 nf_unregister_net_hooks(net, ipv4_defrag_ops,
175163 ARRAY_SIZE(ipv4_defrag_ops));
176164 }
net/ipv4/udp.c+2−1
@@ -390,7 +390,8 @@ static int compute_score(struct sock *sk, struct net *net, · 389 unmodified lines
390390 dif, sdif);
391391 if (!dev_match)
392392 return -1;
393− score += 4;
393+ if (sk->sk_bound_dev_if)
394+ score += 4;
394395
395396 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
396397 score++;
net/ipv6/inet6_hashtables.c+1−1
@@ -106,7 +106,7 @@ static inline int compute_score(struct sock *sk, struct net *net, · 105 unmodified lines
106106 if (!inet_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif))
107107 return -1;
108108
109− score = 1;
109+ score = sk->sk_bound_dev_if ? 2 : 1;
110110 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
111111 score++;
112112 }
net/ipv6/netfilter/nf_conntrack_reasm.c+1−1
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333
3434 static const char nf_frags_cache_name[] = "nf-frags";
3535
36−unsigned int nf_frag_pernet_id __read_mostly;
36+static unsigned int nf_frag_pernet_id __read_mostly;
3737 static struct inet_frags nf_frags;
3838
3939 static struct nft_ct_frag6_pernet *nf_frag_pernet(struct net *net)
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c+9−16
@@ -25,8 +25,6 @@ · 24 unmodified lines
2525 #include <net/netfilter/nf_conntrack_zones.h>
2626 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
2727
28−extern unsigned int nf_frag_pernet_id;
29−
3028 static DEFINE_MUTEX(defrag6_mutex);
3129
3230 static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
@@ -91,12 +89,10 @@ static const struct nf_hook_ops ipv6_defrag_ops[] = { · 58 unmodified lines
9189
9290 static void __net_exit defrag6_net_exit(struct net *net)
9391 {
94− struct nft_ct_frag6_pernet *nf_frag = net_generic(net, nf_frag_pernet_id);
95−
96− if (nf_frag->users) {
92+ if (net->nf.defrag_ipv6_users) {
9793 nf_unregister_net_hooks(net, ipv6_defrag_ops,
9894 ARRAY_SIZE(ipv6_defrag_ops));
99− nf_frag->users = 0;
95+ net->nf.defrag_ipv6_users = 0;
10096 }
10197 }
10298
@@ -134,24 +130,23 @@ static void __exit nf_defrag_fini(void) · 31 unmodified lines
134130
135131 int nf_defrag_ipv6_enable(struct net *net)
136132 {
137− struct nft_ct_frag6_pernet *nf_frag = net_generic(net, nf_frag_pernet_id);
138133 int err = 0;
139134
140135 mutex_lock(&defrag6_mutex);
141− if (nf_frag->users == UINT_MAX) {
136+ if (net->nf.defrag_ipv6_users == UINT_MAX) {
142137 err = -EOVERFLOW;
143138 goto out_unlock;
144139 }
145140
146− if (nf_frag->users) {
147− nf_frag->users++;
141+ if (net->nf.defrag_ipv6_users) {
142+ net->nf.defrag_ipv6_users++;
148143 goto out_unlock;
149144 }
150145
151146 err = nf_register_net_hooks(net, ipv6_defrag_ops,
152147 ARRAY_SIZE(ipv6_defrag_ops));
153148 if (err == 0)
154− nf_frag->users = 1;
149+ net->nf.defrag_ipv6_users = 1;
155150
156151 out_unlock:
157152 mutex_unlock(&defrag6_mutex);
@@ -161,12 +156,10 @@ EXPORT_SYMBOL_GPL(nf_defrag_ipv6_enable); · 3 unmodified lines
161156
162157 void nf_defrag_ipv6_disable(struct net *net)
163158 {
164− struct nft_ct_frag6_pernet *nf_frag = net_generic(net, nf_frag_pernet_id);
165−
166159 mutex_lock(&defrag6_mutex);
167− if (nf_frag->users) {
168− nf_frag->users--;
169− if (nf_frag->users == 0)
160+ if (net->nf.defrag_ipv6_users) {
161+ net->nf.defrag_ipv6_users--;
162+ if (net->nf.defrag_ipv6_users == 0)
170163 nf_unregister_net_hooks(net, ipv6_defrag_ops,
171164 ARRAY_SIZE(ipv6_defrag_ops));
172165 }
net/ipv6/udp.c+2−1
@@ -133,7 +133,8 @@ static int compute_score(struct sock *sk, struct net *net, · 132 unmodified lines
133133 dev_match = udp_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif);
134134 if (!dev_match)
135135 return -1;
136− score++;
136+ if (sk->sk_bound_dev_if)
137+ score++;
137138
138139 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
139140 score++;
net/netfilter/nf_tables_api.c+64−27
@@ -780,6 +780,7 @@ static void nf_tables_table_notify(const struct nft_ctx *ctx, int event) · 779 unmodified lines
780780 {
781781 struct nftables_pernet *nft_net;
782782 struct sk_buff *skb;
783+ u16 flags = 0;
783784 int err;
784785
785786 if (!ctx->report &&
@@ -790,8 +791,11 @@ static void nf_tables_table_notify(const struct nft_ctx *ctx, int event) · 4 unmodified lines
790791 if (skb == NULL)
791792 goto err;
792793
794+ if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL))
795+ flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL);
796+
793797 err = nf_tables_fill_table_info(skb, ctx->net, ctx->portid, ctx->seq,
794− event, 0, ctx->family, ctx->table);
798+ event, flags, ctx->family, ctx->table);
795799 if (err < 0) {
796800 kfree_skb(skb);
797801 goto err;
@@ -1563,6 +1567,7 @@ static void nf_tables_chain_notify(const struct nft_ctx *ctx, int event) · 765 unmodified lines
15631567 {
15641568 struct nftables_pernet *nft_net;
15651569 struct sk_buff *skb;
1570+ u16 flags = 0;
15661571 int err;
15671572
15681573 if (!ctx->report &&
@@ -1573,8 +1578,11 @@ static void nf_tables_chain_notify(const struct nft_ctx *ctx, int event) · 4 unmodified lines
15731578 if (skb == NULL)
15741579 goto err;
15751580
1581+ if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL))
1582+ flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL);
1583+
15761584 err = nf_tables_fill_chain_info(skb, ctx->net, ctx->portid, ctx->seq,
1577− event, 0, ctx->family, ctx->table,
1585+ event, flags, ctx->family, ctx->table,
15781586 ctx->chain);
15791587 if (err < 0) {
15801588 kfree_skb(skb);
@@ -2866,8 +2874,7 @@ static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net, · 1285 unmodified lines
28662874 u32 flags, int family,
28672875 const struct nft_table *table,
28682876 const struct nft_chain *chain,
2869− const struct nft_rule *rule,
2870− const struct nft_rule *prule)
2877+ const struct nft_rule *rule, u64 handle)
28712878 {
28722879 struct nlmsghdr *nlh;
28732880 const struct nft_expr *expr, *next;
@@ -2887,9 +2894,8 @@ static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net, · 13 unmodified lines
28872894 NFTA_RULE_PAD))
28882895 goto nla_put_failure;
28892896
2890− if (event != NFT_MSG_DELRULE && prule) {
2891− if (nla_put_be64(skb, NFTA_RULE_POSITION,
2892− cpu_to_be64(prule->handle),
2897+ if (event != NFT_MSG_DELRULE && handle) {
2898+ if (nla_put_be64(skb, NFTA_RULE_POSITION, cpu_to_be64(handle),
28932899 NFTA_RULE_PAD))
28942900 goto nla_put_failure;
28952901 }
@@ -2925,7 +2931,10 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx, · 29 unmodified lines
29252931 const struct nft_rule *rule, int event)
29262932 {
29272933 struct nftables_pernet *nft_net = nft_pernet(ctx->net);
2934+ const struct nft_rule *prule;
29282935 struct sk_buff *skb;
2936+ u64 handle = 0;
2937+ u16 flags = 0;
29292938 int err;
29302939
29312940 if (!ctx->report &&
@@ -2936,9 +2945,20 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx, · 4 unmodified lines
29362945 if (skb == NULL)
29372946 goto err;
29382947
2948+ if (event == NFT_MSG_NEWRULE &&
2949+ !list_is_first(&rule->list, &ctx->chain->rules) &&
2950+ !list_is_last(&rule->list, &ctx->chain->rules)) {
2951+ prule = list_prev_entry(rule, list);
2952+ handle = prule->handle;
2953+ }
2954+ if (ctx->flags & (NLM_F_APPEND | NLM_F_REPLACE))
2955+ flags |= NLM_F_APPEND;
2956+ if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL))
2957+ flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL);
2958+
29392959 err = nf_tables_fill_rule_info(skb, ctx->net, ctx->portid, ctx->seq,
2940− event, 0, ctx->family, ctx->table,
2941− ctx->chain, rule, NULL);
2960+ event, flags, ctx->family, ctx->table,
2961+ ctx->chain, rule, handle);
29422962 if (err < 0) {
29432963 kfree_skb(skb);
29442964 goto err;
@@ -2964,6 +2984,7 @@ static int __nf_tables_dump_rules(struct sk_buff *skb, · 19 unmodified lines
29642984 struct net *net = sock_net(skb->sk);
29652985 const struct nft_rule *rule, *prule;
29662986 unsigned int s_idx = cb->args[0];
2987+ u64 handle;
29672988
29682989 prule = NULL;
29692990 list_for_each_entry_rcu(rule, &chain->rules, list) {
@@ -2975,12 +2996,17 @@ static int __nf_tables_dump_rules(struct sk_buff *skb, · 5 unmodified lines
29752996 memset(&cb->args[1], 0,
29762997 sizeof(cb->args) - sizeof(cb->args[0]));
29772998 }
2999+ if (prule)
3000+ handle = prule->handle;
3001+ else
3002+ handle = 0;
3003+
29783004 if (nf_tables_fill_rule_info(skb, net, NETLINK_CB(cb->skb).portid,
29793005 cb->nlh->nlmsg_seq,
29803006 NFT_MSG_NEWRULE,
29813007 NLM_F_MULTI | NLM_F_APPEND,
29823008 table->family,
2983− table, chain, rule, prule) < 0)
3009+ table, chain, rule, handle) < 0)
29843010 return 1;
29853011
29863012 nl_dump_check_consistent(cb, nlmsg_hdr(skb));
@@ -3143,7 +3169,7 @@ static int nf_tables_getrule(struct sk_buff *skb, const struct nfnl_info *info, · 156 unmodified lines
31433169
31443170 err = nf_tables_fill_rule_info(skb2, net, NETLINK_CB(skb).portid,
31453171 info->nlh->nlmsg_seq, NFT_MSG_NEWRULE, 0,
3146− family, table, chain, rule, NULL);
3172+ family, table, chain, rule, 0);
31473173 if (err < 0)
31483174 goto err_fill_rule_info;
31493175
@@ -3403,17 +3429,15 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info, · 253 unmodified lines
34033429 }
34043430
34053431 if (info->nlh->nlmsg_flags & NLM_F_REPLACE) {
3432+ err = nft_delrule(&ctx, old_rule);
3433+ if (err < 0)
3434+ goto err_destroy_flow_rule;
3435+
34063436 trans = nft_trans_rule_add(&ctx, NFT_MSG_NEWRULE, rule);
34073437 if (trans == NULL) {
34083438 err = -ENOMEM;
34093439 goto err_destroy_flow_rule;
34103440 }
3411− err = nft_delrule(&ctx, old_rule);
3412− if (err < 0) {
3413− nft_trans_destroy(trans);
3414− goto err_destroy_flow_rule;
3415− }
3416−
34173441 list_add_tail_rcu(&rule->list, &old_rule->list);
34183442 } else {
34193443 trans = nft_trans_rule_add(&ctx, NFT_MSG_NEWRULE, rule);
@@ -3943,8 +3967,9 @@ static void nf_tables_set_notify(const struct nft_ctx *ctx, · 523 unmodified lines
39433967 gfp_t gfp_flags)
39443968 {
39453969 struct nftables_pernet *nft_net = nft_pernet(ctx->net);
3946− struct sk_buff *skb;
39473970 u32 portid = ctx->portid;
3971+ struct sk_buff *skb;
3972+ u16 flags = 0;
39483973 int err;
39493974
39503975 if (!ctx->report &&
@@ -3955,7 +3980,10 @@ static void nf_tables_set_notify(const struct nft_ctx *ctx, · 4 unmodified lines
39553980 if (skb == NULL)
39563981 goto err;
39573982
3958− err = nf_tables_fill_set(skb, ctx, set, event, 0);
3983+ if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL))
3984+ flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL);
3985+
3986+ err = nf_tables_fill_set(skb, ctx, set, event, flags);
39593987 if (err < 0) {
39603988 kfree_skb(skb);
39613989 goto err;
@@ -5231,12 +5259,13 @@ static int nf_tables_getsetelem(struct sk_buff *skb, · 1269 unmodified lines
52315259 static void nf_tables_setelem_notify(const struct nft_ctx *ctx,
52325260 const struct nft_set *set,
52335261 const struct nft_set_elem *elem,
5234− int event, u16 flags)
5262+ int event)
52355263 {
52365264 struct nftables_pernet *nft_net;
52375265 struct net *net = ctx->net;
52385266 u32 portid = ctx->portid;
52395267 struct sk_buff *skb;
5268+ u16 flags = 0;
52405269 int err;
52415270
52425271 if (!ctx->report && !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
@@ -5246,6 +5275,9 @@ static void nf_tables_setelem_notify(const struct nft_ctx *ctx, · 3 unmodified lines
52465275 if (skb == NULL)
52475276 goto err;
52485277
5278+ if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL))
5279+ flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL);
5280+
52495281 err = nf_tables_fill_setelem_info(skb, ctx, 0, portid, event, flags,
52505282 set, elem);
52515283 if (err < 0) {
@@ -6921,7 +6953,7 @@ static int nf_tables_delobj(struct sk_buff *skb, const struct nfnl_info *info, · 1669 unmodified lines
69216953
69226954 void nft_obj_notify(struct net *net, const struct nft_table *table,
69236955 struct nft_object *obj, u32 portid, u32 seq, int event,
6924− int family, int report, gfp_t gfp)
6956+ u16 flags, int family, int report, gfp_t gfp)
69256957 {
69266958 struct nftables_pernet *nft_net = nft_pernet(net);
69276959 struct sk_buff *skb;
@@ -6946,8 +6978,9 @@ void nft_obj_notify(struct net *net, const struct nft_table *table, · 18 unmodified lines
69466978 if (skb == NULL)
69476979 goto err;
69486980
6949− err = nf_tables_fill_obj_info(skb, net, portid, seq, event, 0, family,
6950− table, obj, false);
6981+ err = nf_tables_fill_obj_info(skb, net, portid, seq, event,
6982+ flags & (NLM_F_CREATE | NLM_F_EXCL),
6983+ family, table, obj, false);
69516984 if (err < 0) {
69526985 kfree_skb(skb);
69536986 goto err;
@@ -6964,7 +6997,7 @@ static void nf_tables_obj_notify(const struct nft_ctx *ctx, · 10 unmodified lines
69646997 struct nft_object *obj, int event)
69656998 {
69666999 nft_obj_notify(ctx->net, ctx->table, obj, ctx->portid, ctx->seq, event,
6967− ctx->family, ctx->report, GFP_KERNEL);
7000+ ctx->flags, ctx->family, ctx->report, GFP_KERNEL);
69687001 }
69697002
69707003 /*
@@ -7745,6 +7778,7 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx, · 774 unmodified lines
77457778 {
77467779 struct nftables_pernet *nft_net = nft_pernet(ctx->net);
77477780 struct sk_buff *skb;
7781+ u16 flags = 0;
77487782 int err;
77497783
77507784 if (!ctx->report &&
@@ -7755,8 +7789,11 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx, · 4 unmodified lines
77557789 if (skb == NULL)
77567790 goto err;
77577791
7792+ if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL))
7793+ flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL);
7794+
77587795 err = nf_tables_fill_flowtable_info(skb, ctx->net, ctx->portid,
7759− ctx->seq, event, 0,
7796+ ctx->seq, event, flags,
77607797 ctx->family, flowtable, hook_list);
77617798 if (err < 0) {
77627799 kfree_skb(skb);
@@ -8634,7 +8671,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) · 871 unmodified lines
86348671 nft_setelem_activate(net, te->set, &te->elem);
86358672 nf_tables_setelem_notify(&trans->ctx, te->set,
86368673 &te->elem,
8637− NFT_MSG_NEWSETELEM, 0);
8674+ NFT_MSG_NEWSETELEM);
86388675 nft_trans_destroy(trans);
86398676 break;
86408677 case NFT_MSG_DELSETELEM:
@@ -8642,7 +8679,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) · 1 unmodified line
86428679
86438680 nf_tables_setelem_notify(&trans->ctx, te->set,
86448681 &te->elem,
8645− NFT_MSG_DELSETELEM, 0);
8682+ NFT_MSG_DELSETELEM);
86468683 nft_setelem_remove(net, te->set, &te->elem);
86478684 if (!nft_setelem_is_catchall(te->set, &te->elem)) {
86488685 atomic_dec(&te->set->nelems);
net/netfilter/nft_quota.c+1−1
@@ -60,7 +60,7 @@ static void nft_quota_obj_eval(struct nft_object *obj, · 59 unmodified lines
6060 if (overquota &&
6161 !test_and_set_bit(NFT_QUOTA_DEPLETED_BIT, &priv->flags))
6262 nft_obj_notify(nft_net(pkt), obj->key.table, obj, 0, 0,
63− NFT_MSG_NEWOBJ, nft_pf(pkt), 0, GFP_ATOMIC);
63+ NFT_MSG_NEWOBJ, 0, nft_pf(pkt), 0, GFP_ATOMIC);
6464 }
6565
6666 static int nft_quota_do_init(const struct nlattr * const tb[],
net/netlink/af_netlink.c+10−4
@@ -594,7 +594,10 @@ static int netlink_insert(struct sock *sk, u32 portid) · 593 unmodified lines
594594
595595 /* We need to ensure that the socket is hashed and visible. */
596596 smp_wmb();
597− nlk_sk(sk)->bound = portid;
597+ /* Paired with lockless reads from netlink_bind(),
598+ * netlink_connect() and netlink_sendmsg().
599+ */
600+ WRITE_ONCE(nlk_sk(sk)->bound, portid);
598601
599602 err:
600603 release_sock(sk);
@@ -1012,7 +1015,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, · 411 unmodified lines
10121015 if (nlk->ngroups < BITS_PER_LONG)
10131016 groups &= (1UL << nlk->ngroups) - 1;
10141017
1015− bound = nlk->bound;
1018+ /* Paired with WRITE_ONCE() in netlink_insert() */
1019+ bound = READ_ONCE(nlk->bound);
10161020 if (bound) {
10171021 /* Ensure nlk->portid is up-to-date. */
10181022 smp_rmb();
@@ -1098,8 +1102,9 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr, · 79 unmodified lines
10981102
10991103 /* No need for barriers here as we return to user-space without
11001104 * using any of the bound attributes.
1105+ * Paired with WRITE_ONCE() in netlink_insert().
11011106 */
1102− if (!nlk->bound)
1107+ if (!READ_ONCE(nlk->bound))
11031108 err = netlink_autobind(sock);
11041109
11051110 if (err == 0) {
@@ -1888,7 +1893,8 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) · 782 unmodified lines
18881893 dst_group = nlk->dst_group;
18891894 }
18901895
1891− if (!nlk->bound) {
1896+ /* Paired with WRITE_ONCE() in netlink_insert() */
1897+ if (!READ_ONCE(nlk->bound)) {
18921898 err = netlink_autobind(sock);
18931899 if (err)
18941900 goto out;
net/sched/sch_fifo.c+3−0
@@ -233,6 +233,9 @@ int fifo_set_limit(struct Qdisc *q, unsigned int limit) · 232 unmodified lines
233233 if (strncmp(q->ops->id + 1, "fifo", 4) != 0)
234234 return 0;
235235
236+ if (!q->ops->change)
237+ return 0;
238+
236239 nla = kmalloc(nla_attr_size(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
237240 if (nla) {
238241 nla->nla_type = RTM_NEWQDISC;
net/sched/sch_taprio.c+4−0
@@ -1641,6 +1641,10 @@ static void taprio_destroy(struct Qdisc *sch) · 1640 unmodified lines
16411641 list_del(&q->taprio_list);
16421642 spin_unlock(&taprio_list_lock);
16431643
1644+ /* Note that taprio_reset() might not be called if an error
1645+ * happens in qdisc_create(), after taprio_init() has been called.
1646+ */
1647+ hrtimer_cancel(&q->advance_timer);
16441648
16451649 taprio_disable_offload(dev, q, NULL);
16461650
net/unix/af_unix.c+5−4
@@ -2882,6 +2882,9 @@ static int unix_shutdown(struct socket *sock, int mode) · 2881 unmodified lines
28822882
28832883 unix_state_lock(sk);
28842884 sk->sk_shutdown |= mode;
2885+ if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) &&
2886+ mode == SHUTDOWN_MASK)
2887+ sk->sk_state = TCP_CLOSE;
28852888 other = unix_peer(sk);
28862889 if (other)
28872890 sock_hold(other);
@@ -2904,12 +2907,10 @@ static int unix_shutdown(struct socket *sock, int mode) · 16 unmodified lines
29042907 other->sk_shutdown |= peer_mode;
29052908 unix_state_unlock(other);
29062909 other->sk_state_change(other);
2907− if (peer_mode == SHUTDOWN_MASK) {
2910+ if (peer_mode == SHUTDOWN_MASK)
29082911 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP);
2909− other->sk_state = TCP_CLOSE;
2910− } else if (peer_mode & RCV_SHUTDOWN) {
2912+ else if (peer_mode & RCV_SHUTDOWN)
29112913 sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN);
2912− }
29132914 }
29142915 if (other)
29152916 sock_put(other);
net/xfrm/xfrm_user.c+55−12
@@ -1961,24 +1961,65 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb, · 1960 unmodified lines
19611961 return skb;
19621962 }
19631963
1964+static int xfrm_notify_userpolicy(struct net *net)
1965+{
1966+ struct xfrm_userpolicy_default *up;
1967+ int len = NLMSG_ALIGN(sizeof(*up));
1968+ struct nlmsghdr *nlh;
1969+ struct sk_buff *skb;
1970+ int err;
1971+
1972+ skb = nlmsg_new(len, GFP_ATOMIC);
1973+ if (skb == NULL)
1974+ return -ENOMEM;
1975+
1976+ nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_GETDEFAULT, sizeof(*up), 0);
1977+ if (nlh == NULL) {
1978+ kfree_skb(skb);
1979+ return -EMSGSIZE;
1980+ }
1981+
1982+ up = nlmsg_data(nlh);
1983+ up->in = net->xfrm.policy_default & XFRM_POL_DEFAULT_IN ?
1984+ XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT;
1985+ up->fwd = net->xfrm.policy_default & XFRM_POL_DEFAULT_FWD ?
1986+ XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT;
1987+ up->out = net->xfrm.policy_default & XFRM_POL_DEFAULT_OUT ?
1988+ XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT;
1989+
1990+ nlmsg_end(skb, nlh);
1991+
1992+ rcu_read_lock();
1993+ err = xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY);
1994+ rcu_read_unlock();
1995+
1996+ return err;
1997+}
1998+
19641999 static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,
19652000 struct nlattr **attrs)
19662001 {
19672002 struct net *net = sock_net(skb->sk);
19682003 struct xfrm_userpolicy_default *up = nlmsg_data(nlh);
1969− u8 dirmask;
1970− u8 old_default = net->xfrm.policy_default;
19712004
1972− if (up->dirmask >= XFRM_USERPOLICY_DIRMASK_MAX)
1973− return -EINVAL;
2005+ if (up->in == XFRM_USERPOLICY_BLOCK)
2006+ net->xfrm.policy_default |= XFRM_POL_DEFAULT_IN;
2007+ else if (up->in == XFRM_USERPOLICY_ACCEPT)
2008+ net->xfrm.policy_default &= ~XFRM_POL_DEFAULT_IN;
19742009
1975− dirmask = (1 << up->dirmask) & XFRM_POL_DEFAULT_MASK;
2010+ if (up->fwd == XFRM_USERPOLICY_BLOCK)
2011+ net->xfrm.policy_default |= XFRM_POL_DEFAULT_FWD;
2012+ else if (up->fwd == XFRM_USERPOLICY_ACCEPT)
2013+ net->xfrm.policy_default &= ~XFRM_POL_DEFAULT_FWD;
19762014
1977− net->xfrm.policy_default = (old_default & (0xff ^ dirmask))
1978− | (up->action << up->dirmask);
2015+ if (up->out == XFRM_USERPOLICY_BLOCK)
2016+ net->xfrm.policy_default |= XFRM_POL_DEFAULT_OUT;
2017+ else if (up->out == XFRM_USERPOLICY_ACCEPT)
2018+ net->xfrm.policy_default &= ~XFRM_POL_DEFAULT_OUT;
19792019
19802020 rt_genid_bump_all(net);
19812021
2022+ xfrm_notify_userpolicy(net);
19822023 return 0;
19832024 }
19842025
@@ -1988,13 +2029,11 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, · 3 unmodified lines
19882029 struct sk_buff *r_skb;
19892030 struct nlmsghdr *r_nlh;
19902031 struct net *net = sock_net(skb->sk);
1991− struct xfrm_userpolicy_default *r_up, *up;
2032+ struct xfrm_userpolicy_default *r_up;
19922033 int len = NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_default));
19932034 u32 portid = NETLINK_CB(skb).portid;
19942035 u32 seq = nlh->nlmsg_seq;
19952036
1996− up = nlmsg_data(nlh);
1997−
19982037 r_skb = nlmsg_new(len, GFP_ATOMIC);
19992038 if (!r_skb)
20002039 return -ENOMEM;
@@ -2007,8 +2046,12 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, · 6 unmodified lines
20072046
20082047 r_up = nlmsg_data(r_nlh);
20092048
2010− r_up->action = ((net->xfrm.policy_default & (1 << up->dirmask)) >> up->dirmask);
2011− r_up->dirmask = up->dirmask;
2049+ r_up->in = net->xfrm.policy_default & XFRM_POL_DEFAULT_IN ?
2050+ XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT;
2051+ r_up->fwd = net->xfrm.policy_default & XFRM_POL_DEFAULT_FWD ?
2052+ XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT;
2053+ r_up->out = net->xfrm.policy_default & XFRM_POL_DEFAULT_OUT ?
2054+ XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT;
20122055 nlmsg_end(r_skb, r_nlh);
20132056
20142057 return nlmsg_unicast(net->xfrm.nlsk, r_skb, portid);
samples/bpf/Makefile+8−9
@@ -322,17 +322,11 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h · 321 unmodified lines
322322
323323 -include $(BPF_SAMPLES_PATH)/Makefile.target
324324
325−VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \
326− $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \
327− ../../../../vmlinux \
328− /sys/kernel/btf/vmlinux \
329− /boot/vmlinux-$(shell uname -r)
325+VMLINUX_BTF_PATHS ?= $(abspath $(if $(O),$(O)/vmlinux)) \
326+ $(abspath $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)) \
327+ $(abspath ./vmlinux)
330328 VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
331329
332−ifeq ($(VMLINUX_BTF),)
333−$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
334−endif
335−
336330 $(obj)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL)
337331 ifeq ($(VMLINUX_H),)
338332 $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
@@ -340,6 +334,11 @@ else · 1 unmodified line
340334 $(Q)cp "$(VMLINUX_H)" $@
341335 endif
342336
337+ifeq ($(VMLINUX_BTF),)
338+ $(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)",\
339+ build the kernel or set VMLINUX_BTF variable)
340+endif
341+
343342 clean-files += vmlinux.h
344343
345344 # Get Clang's default includes on this system, as opposed to those seen by
samples/bpf/bpf_insn.h+1−1
@@ -1,4 +1,4 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
1+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22 /* eBPF instruction mini library */
33 #ifndef __BPF_INSN_H
44 #define __BPF_INSN_H
samples/bpf/xdp_redirect_map_multi.bpf.c+0−5
@@ -5,11 +5,6 @@ · 4 unmodified lines
55 #include "xdp_sample.bpf.h"
66 #include "xdp_sample_shared.h"
77
8−enum {
9− BPF_F_BROADCAST = (1ULL << 3),
10− BPF_F_EXCLUDE_INGRESS = (1ULL << 4),
11−};
12−
138 struct {
149 __uint(type, BPF_MAP_TYPE_DEVMAP_HASH);
1510 __uint(key_size, sizeof(int));
security/selinux/nlmsgtab.c+3−1
@@ -126,6 +126,8 @@ static const struct nlmsg_perm nlmsg_xfrm_perms[] = · 125 unmodified lines
126126 { XFRM_MSG_NEWSPDINFO, NETLINK_XFRM_SOCKET__NLMSG_WRITE },
127127 { XFRM_MSG_GETSPDINFO, NETLINK_XFRM_SOCKET__NLMSG_READ },
128128 { XFRM_MSG_MAPPING, NETLINK_XFRM_SOCKET__NLMSG_READ },
129+ { XFRM_MSG_SETDEFAULT, NETLINK_XFRM_SOCKET__NLMSG_WRITE },
130+ { XFRM_MSG_GETDEFAULT, NETLINK_XFRM_SOCKET__NLMSG_READ },
129131 };
130132
131133 static const struct nlmsg_perm nlmsg_audit_perms[] =
@@ -189,7 +191,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm) · 57 unmodified lines
189191 * structures at the top of this file with the new mappings
190192 * before updating the BUILD_BUG_ON() macro!
191193 */
192− BUILD_BUG_ON(XFRM_MSG_MAX != XFRM_MSG_MAPPING);
194+ BUILD_BUG_ON(XFRM_MSG_MAX != XFRM_MSG_GETDEFAULT);
193195 err = nlmsg_perm(nlmsg_type, perm, nlmsg_xfrm_perms,
194196 sizeof(nlmsg_xfrm_perms));
195197 break;
tools/lib/bpf/libbpf.c+2−1
@@ -6894,7 +6894,8 @@ int bpf_object__load_xattr(struct bpf_object_load_attr *attr) · 6893 unmodified lines
68946894
68956895 if (obj->gen_loader) {
68966896 /* reset FDs */
6897− btf__set_fd(obj->btf, -1);
6897+ if (obj->btf)
6898+ btf__set_fd(obj->btf, -1);
68986899 for (i = 0; i < obj->nr_maps; i++)
68996900 obj->maps[i].fd = -1;
69006901 if (!err)
tools/lib/bpf/strset.c+1−0
@@ -88,6 +88,7 @@ void strset__free(struct strset *set) · 87 unmodified lines
8888
8989 hashmap__free(set->strs_hash);
9090 free(set->strs_data);
91+ free(set);
9192 }
9293
9394 size_t strset__data_size(const struct strset *set)