Merge tag 'nf-24-03-21' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
authorPaolo Abeni <pabeni@redhat.com>
Thu, 21 Mar 2024 14:16:16 +0000 (15:16 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 21 Mar 2024 14:16:17 +0000 (15:16 +0100)
Pablo Neira Ayuso says:

====================
Netfilter fixes for net

The following patchset contains Netfilter fixes for net. There is a
larger batch of fixes still pending that will follow up asap, this is
what I deemed to be more urgent at this time:

1) Use clone view in pipapo set backend to release elements from destroy
   path, otherwise it is possible to destroy elements twice.

2) Incorrect check for internal table flags lead to bogus transaction
   objects.

3) Fix counters memleak in netdev basechain update error path,
   from Quan Tian.

netfilter pull request 24-03-21

* tag 'nf-24-03-21' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf:
  netfilter: nf_tables: Fix a memory leak in nf_tables_updchain
  netfilter: nf_tables: do not compare internal table flags on updates
  netfilter: nft_set_pipapo: release elements in clone only from destroy path
====================

Link: https://lore.kernel.org/r/20240321112117.36737-1-pablo@netfilter.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Documentation/networking/device_drivers/ethernet/pensando/ionic.rst
MAINTAINERS
drivers/net/can/kvaser_pciefd.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/mt7530.h
include/linux/bitmap.h
include/linux/rcupdate.h
kernel/bpf/cpumap.c
net/core/dev.c
tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh
tools/testing/selftests/net/forwarding/vxlan_bridge_1q_ipv6.sh

index 6ec7d686efab04546045a3ccfe0a2d096a2d89b5..05fe2b11bb18834cade782b1426f7c2991de42b8 100644 (file)
@@ -99,6 +99,12 @@ Minimal SR-IOV support is currently offered and can be enabled by setting
 the sysfs 'sriov_numvfs' value, if supported by your particular firmware
 configuration.
 
+XDP
+---
+
+Support for XDP includes the basics, plus Jumbo frames, Redirect and
+ndo_xmit.  There is no current support for zero-copy sockets or HW offload.
+
 Statistics
 ==========
 
@@ -138,6 +144,12 @@ Driver port specific::
      rx_csum_none: 0
      rx_csum_complete: 3
      rx_csum_error: 0
+     xdp_drop: 0
+     xdp_aborted: 0
+     xdp_pass: 0
+     xdp_tx: 0
+     xdp_redirect: 0
+     xdp_frames: 0
 
 Driver queue specific::
 
@@ -149,9 +161,12 @@ Driver queue specific::
      tx_0_frags: 0
      tx_0_tso: 0
      tx_0_tso_bytes: 0
+     tx_0_hwstamp_valid: 0
+     tx_0_hwstamp_invalid: 0
      tx_0_csum_none: 3
      tx_0_csum: 0
      tx_0_vlan_inserted: 0
+     tx_0_xdp_frames: 0
      rx_0_pkts: 2
      rx_0_bytes: 120
      rx_0_dma_map_err: 0
@@ -159,8 +174,15 @@ Driver queue specific::
      rx_0_csum_none: 0
      rx_0_csum_complete: 0
      rx_0_csum_error: 0
+     rx_0_hwstamp_valid: 0
+     rx_0_hwstamp_invalid: 0
      rx_0_dropped: 0
      rx_0_vlan_stripped: 0
+     rx_0_xdp_drop: 0
+     rx_0_xdp_aborted: 0
+     rx_0_xdp_pass: 0
+     rx_0_xdp_tx: 0
+     rx_0_xdp_redirect: 0
 
 Firmware port specific::
 
index 54775eaaf7b37d7d3c50e3ce1706f0b6dca109c9..24b4f59d3ceb1820ff6c864104fa4b3aeaaf0393 100644 (file)
@@ -15164,7 +15164,6 @@ F:      drivers/net/ethernet/neterion/
 NETFILTER
 M:     Pablo Neira Ayuso <pablo@netfilter.org>
 M:     Jozsef Kadlecsik <kadlec@netfilter.org>
-M:     Florian Westphal <fw@strlen.de>
 L:     netfilter-devel@vger.kernel.org
 L:     coreteam@netfilter.org
 S:     Maintained
index f81b598147b3062b453a246f27032c23f9e0d2cb..7b5028b67cd5cb56943c86c946f14d838b25b531 100644 (file)
@@ -370,8 +370,8 @@ static const struct kvaser_pciefd_irq_mask kvaser_pciefd_sf2_irq_mask = {
 
 static const struct kvaser_pciefd_irq_mask kvaser_pciefd_xilinx_irq_mask = {
        .kcan_rx0 = BIT(4),
-       .kcan_tx = { BIT(16), BIT(17), BIT(18), BIT(19) },
-       .all = GENMASK(19, 16) | BIT(4),
+       .kcan_tx = { BIT(16), BIT(17), BIT(18), BIT(19), BIT(20), BIT(21), BIT(22), BIT(23) },
+       .all = GENMASK(23, 16) | BIT(4),
 };
 
 static const struct kvaser_pciefd_dev_ops kvaser_pciefd_altera_dev_ops = {
index 6986f538a4d01d75da09f6ba4535ccd6c95ea5c3..767f66c37f6b5cf63db379232af407b9813428a1 100644 (file)
@@ -950,20 +950,56 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
        mutex_unlock(&priv->reg_mutex);
 }
 
+/* On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE Std
+ * 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC DA
+ * must only be propagated to C-VLAN and MAC Bridge components. That means
+ * VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports,
+ * these frames are supposed to be processed by the CPU (software). So we make
+ * the switch only forward them to the CPU port. And if received from a CPU
+ * port, forward to a single port. The software is responsible of making the
+ * switch conform to the latter by setting a single port as destination port on
+ * the special tag.
+ *
+ * This switch intellectual property cannot conform to this part of the standard
+ * fully. Whilst the REV_UN frame tag covers the remaining :04-0D and :0F MAC
+ * DAs, it also includes :22-FF which the scope of propagation is not supposed
+ * to be restricted for these MAC DAs.
+ */
 static void
 mt753x_trap_frames(struct mt7530_priv *priv)
 {
-       /* Trap BPDUs to the CPU port(s) */
-       mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
+       /* Trap 802.1X PAE frames and BPDUs to the CPU port(s) and egress them
+        * VLAN-untagged.
+        */
+       mt7530_rmw(priv, MT753X_BPC, MT753X_PAE_EG_TAG_MASK |
+                  MT753X_PAE_PORT_FW_MASK | MT753X_BPDU_EG_TAG_MASK |
+                  MT753X_BPDU_PORT_FW_MASK,
+                  MT753X_PAE_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
+                  MT753X_PAE_PORT_FW(MT753X_BPDU_CPU_ONLY) |
+                  MT753X_BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
                   MT753X_BPDU_CPU_ONLY);
 
-       /* Trap 802.1X PAE frames to the CPU port(s) */
-       mt7530_rmw(priv, MT753X_BPC, MT753X_PAE_PORT_FW_MASK,
-                  MT753X_PAE_PORT_FW(MT753X_BPDU_CPU_ONLY));
+       /* Trap frames with :01 and :02 MAC DAs to the CPU port(s) and egress
+        * them VLAN-untagged.
+        */
+       mt7530_rmw(priv, MT753X_RGAC1, MT753X_R02_EG_TAG_MASK |
+                  MT753X_R02_PORT_FW_MASK | MT753X_R01_EG_TAG_MASK |
+                  MT753X_R01_PORT_FW_MASK,
+                  MT753X_R02_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
+                  MT753X_R02_PORT_FW(MT753X_BPDU_CPU_ONLY) |
+                  MT753X_R01_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
+                  MT753X_BPDU_CPU_ONLY);
 
-       /* Trap LLDP frames with :0E MAC DA to the CPU port(s) */
-       mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
-                  MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
+       /* Trap frames with :03 and :0E MAC DAs to the CPU port(s) and egress
+        * them VLAN-untagged.
+        */
+       mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_EG_TAG_MASK |
+                  MT753X_R0E_PORT_FW_MASK | MT753X_R03_EG_TAG_MASK |
+                  MT753X_R03_PORT_FW_MASK,
+                  MT753X_R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
+                  MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY) |
+                  MT753X_R03_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
+                  MT753X_BPDU_CPU_ONLY);
 }
 
 static void
index a71166e0a7fcf2411292bc713f0bcbd75c2db32c..d17b318e6ee4882ed8b6f6668eaa57a99a38d184 100644 (file)
@@ -65,14 +65,33 @@ enum mt753x_id {
 
 /* Registers for BPDU and PAE frame control*/
 #define MT753X_BPC                     0x24
-#define  MT753X_BPDU_PORT_FW_MASK      GENMASK(2, 0)
+#define  MT753X_PAE_EG_TAG_MASK                GENMASK(24, 22)
+#define  MT753X_PAE_EG_TAG(x)          FIELD_PREP(MT753X_PAE_EG_TAG_MASK, x)
 #define  MT753X_PAE_PORT_FW_MASK       GENMASK(18, 16)
 #define  MT753X_PAE_PORT_FW(x)         FIELD_PREP(MT753X_PAE_PORT_FW_MASK, x)
+#define  MT753X_BPDU_EG_TAG_MASK       GENMASK(8, 6)
+#define  MT753X_BPDU_EG_TAG(x)         FIELD_PREP(MT753X_BPDU_EG_TAG_MASK, x)
+#define  MT753X_BPDU_PORT_FW_MASK      GENMASK(2, 0)
+
+/* Register for :01 and :02 MAC DA frame control */
+#define MT753X_RGAC1                   0x28
+#define  MT753X_R02_EG_TAG_MASK                GENMASK(24, 22)
+#define  MT753X_R02_EG_TAG(x)          FIELD_PREP(MT753X_R02_EG_TAG_MASK, x)
+#define  MT753X_R02_PORT_FW_MASK       GENMASK(18, 16)
+#define  MT753X_R02_PORT_FW(x)         FIELD_PREP(MT753X_R02_PORT_FW_MASK, x)
+#define  MT753X_R01_EG_TAG_MASK                GENMASK(8, 6)
+#define  MT753X_R01_EG_TAG(x)          FIELD_PREP(MT753X_R01_EG_TAG_MASK, x)
+#define  MT753X_R01_PORT_FW_MASK       GENMASK(2, 0)
 
 /* Register for :03 and :0E MAC DA frame control */
 #define MT753X_RGAC2                   0x2c
+#define  MT753X_R0E_EG_TAG_MASK                GENMASK(24, 22)
+#define  MT753X_R0E_EG_TAG(x)          FIELD_PREP(MT753X_R0E_EG_TAG_MASK, x)
 #define  MT753X_R0E_PORT_FW_MASK       GENMASK(18, 16)
 #define  MT753X_R0E_PORT_FW(x)         FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x)
+#define  MT753X_R03_EG_TAG_MASK                GENMASK(8, 6)
+#define  MT753X_R03_EG_TAG(x)          FIELD_PREP(MT753X_R03_EG_TAG_MASK, x)
+#define  MT753X_R03_PORT_FW_MASK       GENMASK(2, 0)
 
 enum mt753x_bpdu_port_fw {
        MT753X_BPDU_FOLLOW_MFC,
@@ -253,6 +272,7 @@ enum mt7530_port_mode {
 enum mt7530_vlan_port_eg_tag {
        MT7530_VLAN_EG_DISABLED = 0,
        MT7530_VLAN_EG_CONSISTENT = 1,
+       MT7530_VLAN_EG_UNTAGGED = 4,
 };
 
 enum mt7530_vlan_port_attr {
index fb3a9c93ac86af937e3319fc2e445e0f0d9cb4e6..aa4096126553753de4d2201e596b92a8a804bc1c 100644 (file)
@@ -522,17 +522,18 @@ static inline void bitmap_replace(unsigned long *dst,
  *
  * (Bits 0, 1, 2, 3, 4, 5 are copied to the bits 0, 1, 4, 8, 9, 12)
  *
- * A more 'visual' description of the operation:
- * src:  0000000001011010
- *                 ||||||
- *          +------+|||||
- *          |  +----+||||
- *          |  |+----+|||
- *          |  ||   +-+||
- *          |  ||   |  ||
- * mask: ...v..vv...v..vv
- *       ...0..11...0..10
- * dst:  0000001100000010
+ * A more 'visual' description of the operation::
+ *
+ *     src:  0000000001011010
+ *                     ||||||
+ *              +------+|||||
+ *              |  +----+||||
+ *              |  |+----+|||
+ *              |  ||   +-+||
+ *              |  ||   |  ||
+ *     mask: ...v..vv...v..vv
+ *           ...0..11...0..10
+ *     dst:  0000001100000010
  *
  * A relationship exists between bitmap_scatter() and bitmap_gather().
  * bitmap_gather() can be seen as the 'reverse' bitmap_scatter() operation.
@@ -568,16 +569,17 @@ static inline void bitmap_scatter(unsigned long *dst, const unsigned long *src,
  *
  * (Bits 0, 1, 4, 8, 9, 12 are copied to the bits 0, 1, 2, 3, 4, 5)
  *
- * A more 'visual' description of the operation:
- * mask: ...v..vv...v..vv
- * src:  0000001100000010
- *          ^  ^^   ^   0
- *          |  ||   |  10
- *          |  ||   > 010
- *          |  |+--> 1010
- *          |  +--> 11010
- *          +----> 011010
- * dst:  0000000000011010
+ * A more 'visual' description of the operation::
+ *
+ *     mask: ...v..vv...v..vv
+ *     src:  0000001100000010
+ *              ^  ^^   ^   0
+ *              |  ||   |  10
+ *              |  ||   > 010
+ *              |  |+--> 1010
+ *              |  +--> 11010
+ *              +----> 011010
+ *     dst:  0000000000011010
  *
  * A relationship exists between bitmap_gather() and bitmap_scatter(). See
  * bitmap_scatter() for the bitmap scatter detailed operations.
index 16f519914415ebf5592e75be67e8660339d6b0e7..17d7ed5f3ae6e5c612acd4261be763855069946d 100644 (file)
@@ -247,6 +247,37 @@ do { \
        cond_resched(); \
 } while (0)
 
+/**
+ * rcu_softirq_qs_periodic - Report RCU and RCU-Tasks quiescent states
+ * @old_ts: jiffies at start of processing.
+ *
+ * This helper is for long-running softirq handlers, such as NAPI threads in
+ * networking. The caller should initialize the variable passed in as @old_ts
+ * at the beginning of the softirq handler. When invoked frequently, this macro
+ * will invoke rcu_softirq_qs() every 100 milliseconds thereafter, which will
+ * provide both RCU and RCU-Tasks quiescent states. Note that this macro
+ * modifies its old_ts argument.
+ *
+ * Because regions of code that have disabled softirq act as RCU read-side
+ * critical sections, this macro should be invoked with softirq (and
+ * preemption) enabled.
+ *
+ * The macro is not needed when CONFIG_PREEMPT_RT is defined. RT kernels would
+ * have more chance to invoke schedule() calls and provide necessary quiescent
+ * states. As a contrast, calling cond_resched() only won't achieve the same
+ * effect because cond_resched() does not provide RCU-Tasks quiescent states.
+ */
+#define rcu_softirq_qs_periodic(old_ts) \
+do { \
+       if (!IS_ENABLED(CONFIG_PREEMPT_RT) && \
+           time_after(jiffies, (old_ts) + HZ / 10)) { \
+               preempt_disable(); \
+               rcu_softirq_qs(); \
+               preempt_enable(); \
+               (old_ts) = jiffies; \
+       } \
+} while (0)
+
 /*
  * Infrastructure to implement the synchronize_() primitives in
  * TREE_RCU and rcu_barrier_() primitives in TINY_RCU.
index 9ee8da4774656716718909d2c7d93362d9313ecd..a8e34416e960f5c89d90e0e2981154aa206bac42 100644 (file)
@@ -263,6 +263,7 @@ static int cpu_map_bpf_prog_run(struct bpf_cpu_map_entry *rcpu, void **frames,
 static int cpu_map_kthread_run(void *data)
 {
        struct bpf_cpu_map_entry *rcpu = data;
+       unsigned long last_qs = jiffies;
 
        complete(&rcpu->kthread_running);
        set_current_state(TASK_INTERRUPTIBLE);
@@ -288,10 +289,12 @@ static int cpu_map_kthread_run(void *data)
                        if (__ptr_ring_empty(rcpu->queue)) {
                                schedule();
                                sched = 1;
+                               last_qs = jiffies;
                        } else {
                                __set_current_state(TASK_RUNNING);
                        }
                } else {
+                       rcu_softirq_qs_periodic(last_qs);
                        sched = cond_resched();
                }
 
index 303a6ff46e4e16296e94ed6b726621abe093e567..9a67003e49db87f3f92b6c6296b3e7a5ca9d9171 100644 (file)
@@ -6743,6 +6743,8 @@ static int napi_threaded_poll(void *data)
        void *have;
 
        while (!napi_thread_wait(napi)) {
+               unsigned long last_qs = jiffies;
+
                for (;;) {
                        bool repoll = false;
 
@@ -6767,6 +6769,7 @@ static int napi_threaded_poll(void *data)
                        if (!repoll)
                                break;
 
+                       rcu_softirq_qs_periodic(last_qs);
                        cond_resched();
                }
        }
index a0bb4524e1e9c66bed9ff99d08232be8c4f409fc..a603f7b0a08f07e5d7ac71cd916791c1a7774572 100755 (executable)
@@ -354,7 +354,7 @@ __ping_ipv4()
 
        # Send 100 packets and verify that at least 100 packets hit the rule,
        # to overcome ARP noise.
-       PING_COUNT=100 PING_TIMEOUT=11 ping_do $dev $dst_ip
+       PING_COUNT=100 PING_TIMEOUT=20 ping_do $dev $dst_ip
        check_err $? "Ping failed"
 
        tc_check_at_least_x_packets "dev $rp1 egress" 101 10 100
@@ -410,7 +410,7 @@ __ping_ipv6()
 
        # Send 100 packets and verify that at least 100 packets hit the rule,
        # to overcome neighbor discovery noise.
-       PING_COUNT=100 PING_TIMEOUT=11 ping6_do $dev $dst_ip
+       PING_COUNT=100 PING_TIMEOUT=20 ping6_do $dev $dst_ip
        check_err $? "Ping failed"
 
        tc_check_at_least_x_packets "dev $rp1 egress" 101 100
index d880df89bc8bd51bca702736bad069aa2639f169..e83fde79f40d0f5bc31353a05714e7fd123fc8f8 100755 (executable)
@@ -457,7 +457,7 @@ __ping_ipv4()
 
        # Send 100 packets and verify that at least 100 packets hit the rule,
        # to overcome ARP noise.
-       PING_COUNT=100 PING_TIMEOUT=11 ping_do $dev $dst_ip
+       PING_COUNT=100 PING_TIMEOUT=20 ping_do $dev $dst_ip
        check_err $? "Ping failed"
 
        tc_check_at_least_x_packets "dev $rp1 egress" 101 10 100
@@ -522,7 +522,7 @@ __ping_ipv6()
 
        # Send 100 packets and verify that at least 100 packets hit the rule,
        # to overcome neighbor discovery noise.
-       PING_COUNT=100 PING_TIMEOUT=11 ping6_do $dev $dst_ip
+       PING_COUNT=100 PING_TIMEOUT=20 ping6_do $dev $dst_ip
        check_err $? "Ping failed"
 
        tc_check_at_least_x_packets "dev $rp1 egress" 101 100