0
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2025-08-09 07:51:36 +00:00
Files
openwrt/package/kernel/lantiq/vrx518_tc/patches/207-dcdp-atm_tc-fix-crash-on-subif_reg-absence.patch
Sergey Ryazanov 6d6dc3a3c9 ipq40xx: fix compatibility with linux-atm tools
atm_qos struct should be the same both for user and kernel spaces. Via
the __SO_ENCODE() macro it is used to define the SO_ATMQOS socket IOC.

During the VRX518 support introduction, the atm_trafprm sturct nested
into the atm_qos stucture was update with newer fields that are
referenced by the ATM TC layer of the VRX518 TC driver. These new fields
are intended to communicate information for extra traffic classes
supported by the driver. But we are still using vanilla kernel headers
to build the toolchain. Due to the atm.h header incoherency br2684ctl
from linux-atm tools is incapable to configure the ATM bridge netdev:

  br2684ctl: Interface "dsl0" created sucessfully
  br2684ctl: Communicating over ATM 0.1.2, encapsulation: LLC
  br2684ctl: setsockopt SO_ATMQOS 22 <-- EINVAL errno
  br2684ctl: Fatal: failed to connect on socket; File descriptor in bad state

There are two options to fix this incoherency. (a) update the header
file in the toolchain to build linux-atm against updated atm_trafprm and
atm_qos structures, or (b) revert atm_trafprm changes.

Since there are no actual users of the extra ATM QoS traffic classes,
just drop these extra traffic classes from vrx518_tc ATM TC layer and
drop the kernel patch updating atm.h.

Besides fixing the compatibility with linux-atm tools, removing the
kernel patch should simplify kernel updates removing unneeded burden of
maintenance.

Run tested with FRITZ!Box 7530 with disabled extra traffic classes and
then removed them entirely before the submission.

CC: John Crispin <john@phrozen.org>
Fixes: cfd42a0098 ("ipq40xx: add Intel/Lantiq ATM hacks")
Suggested-by: Andre Heider <a.heider@gmail.com>
Reported-and-tested-by: nebibigon93@yandex.ru
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Link: https://patchwork.ozlabs.org/project/openwrt/patch/20250122222654.21833-4-ryazanov.s.a@gmail.com/
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-01-23 20:27:49 +01:00

76 lines
2.6 KiB
Diff

From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Date: Fri, 10 Jan 2025 00:57:27 +0000
Subject: [PATCH] vrx518_tc: atm_tc: fix crash on subif_reg absence
VRX518 (sw_plat) platform does not provid the subif_reg/subif_unreg ops
in the same time ATM TC layer unconditionally calls them, what leads to
the kernel crash on the atm_hook_mpoa_setup hook invocation from the ATM
stack:
vrx518_tc:mpoa_setup_sync : sync: conn: 0, vpi: 0, vci: 35, mpoa_type: 0, mpoa_mode: 0
Unable to handle kernel NULL pointer dereference at virtual address 00000000
Subif registration is optional and PTM TC do this only when the
corresponding ops are defined. Do the same for ATM TC and call
subif_reg/subif_unreg only if they are not NULL.
While at it, move subif related data preparation under the 'if' block
in order to group and isolate that aux code.
Run tested with FRITZ!Box 7530.
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
--- a/dcdp/atm_tc.c
+++ b/dcdp/atm_tc.c
@@ -1158,8 +1158,9 @@ static void ppe_close(struct atm_vcc *vc
validate_oam_htu_entry(priv, 0);
spin_unlock_bh(&priv->atm_lock);
- priv->tc_priv->tc_ops.subif_unreg(dev, (!dev) ? dev_name : dev->name,
- priv->conn[cid].subif_id, 0);
+ if (priv->tc_priv->tc_ops.subif_unreg)
+ priv->tc_priv->tc_ops.subif_unreg(dev, (!dev) ? dev_name : dev->name,
+ priv->conn[cid].subif_id, 0);
memset(conn, 0, sizeof(*conn));
@@ -2710,24 +2711,26 @@ static void mpoa_setup_sync(struct atm_p
struct wtx_queue_config_t tx_qcfg;
struct uni_cell_header *cell_header;
struct atm_vcc *vcc;
- struct net_device *dev;
- char dev_name[32];
tc_dbg(priv->tc_priv, MSG_INIT,
"sync: conn: %d, vpi: %d, vci: %d, mpoa_type: %d, mpoa_mode: %d\n",
conn, priv->conn[conn].vcc->vpi, priv->conn[conn].vcc->vci,
priv->conn[conn].mpoa_type, priv->conn[conn].mpoa_mode);
- dev = priv->conn[conn].dev;
+ if (priv->tc_priv->tc_ops.subif_reg) {
+ struct net_device *dev;
+ char dev_name[32];
+
+ dev = priv->conn[conn].dev;
+ if (!dev)
+ sprintf(dev_name, "atm_%d%d",
+ priv->conn[conn].vcc->vpi, priv->conn[conn].vcc->vci);
- if (!dev)
- sprintf(dev_name, "atm_%d%d",
- priv->conn[conn].vcc->vpi, priv->conn[conn].vcc->vci);
-
- priv->tc_priv->tc_ops.subif_reg(dev, (!dev) ? dev_name : dev->name,
- &priv->conn[conn].subif_id, 0);
- tc_dbg(priv->tc_priv, MSG_INIT,
- "conn[%d]subif_id[%x]", conn, priv->conn[conn].subif_id);
+ priv->tc_priv->tc_ops.subif_reg(dev, !dev ? dev_name : dev->name,
+ &priv->conn[conn].subif_id, 0);
+ tc_dbg(priv->tc_priv, MSG_INIT,
+ "conn[%d]subif_id[%x]", conn, priv->conn[conn].subif_id);
+ }
vcc = priv->conn[conn].vcc;
/* set htu entry */