From 626cc6770b02613e9705449755035cac571039f3 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Thu, 25 Jun 2026 11:20:16 +0200 Subject: [PATCH] realtek: l3: move notifier blocks to private structure Relocate the notification handlers into the new L3 ecosystem. Link: https://github.com/openwrt/openwrt/pull/23937 Signed-off-by: Markus Stockhausen --- .../files-6.18/drivers/net/dsa/rtl83xx/l3.c | 42 +++++++++---------- .../files-6.18/drivers/net/dsa/rtl83xx/l3.h | 2 + .../drivers/net/dsa/rtl83xx/rtl-otto.h | 2 - 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c index 00d46236916..db3caadb8bd 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c @@ -567,17 +567,16 @@ static void otto_l3_fib_event_work_do(struct work_struct *work) /* Called with rcu_read_lock() */ static int otto_l3_fib_notifier(struct notifier_block *this, unsigned long event, void *ptr) { - struct fib_notifier_info *info = ptr; - struct rtl838x_switch_priv *priv; + struct otto_l3_ctrl *ctrl = container_of(this, struct otto_l3_ctrl, fib_nb); + struct rtl838x_switch_priv *priv = ctrl->priv; struct otto_l3_fib_event_work *fib_work; + struct fib_notifier_info *info = ptr; if ((info->family != AF_INET && info->family != AF_INET6 && info->family != RTNL_FAMILY_IPMR && info->family != RTNL_FAMILY_IP6MR)) return NOTIFY_DONE; - priv = container_of(this, struct rtl838x_switch_priv, fib_nb); - /* ignore FIB events for HW with missing L3 offloading implementation */ if (!priv->r->l3_setup) return NOTIFY_DONE; @@ -647,13 +646,12 @@ static void otto_l3_net_event_work_do(struct work_struct *work) static int otto_l3_netevent_notifier(struct notifier_block *this, unsigned long event, void *ptr) { - struct rtl838x_switch_priv *priv; - struct net_device *dev; + struct otto_l3_ctrl *ctrl = container_of(this, struct otto_l3_ctrl, ne_nb); + struct rtl838x_switch_priv *priv = ctrl->priv; + struct otto_l3_net_event_work *net_work; struct neighbour *n = ptr; + struct net_device *dev; int err, port; - struct otto_l3_net_event_work *net_work; - - priv = container_of(this, struct rtl838x_switch_priv, ne_nb); switch (event) { case NETEVENT_NEIGH_UPDATE: @@ -693,13 +691,15 @@ static int otto_l3_netevent_notifier(struct notifier_block *this, unsigned long void otto_l3_remove(struct rtl838x_switch_priv *priv) { - if (priv->ne_nb.notifier_call) { - unregister_netevent_notifier(&priv->ne_nb); - priv->ne_nb.notifier_call = NULL; + struct otto_l3_ctrl *ctrl = priv->l3_ctrl; + + if (ctrl->ne_nb.notifier_call) { + unregister_netevent_notifier(&ctrl->ne_nb); + ctrl->ne_nb.notifier_call = NULL; } - if (priv->fib_nb.notifier_call) { - unregister_fib_notifier(&init_net, &priv->fib_nb); - priv->fib_nb.notifier_call = NULL; + if (ctrl->fib_nb.notifier_call) { + unregister_fib_notifier(&init_net, &ctrl->fib_nb); + ctrl->fib_nb.notifier_call = NULL; } } @@ -721,10 +721,10 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv) * Register netevent notifier callback to catch notifications about neighboring changes * to update nexthop entries for L3 routing. */ - priv->ne_nb.notifier_call = otto_l3_netevent_notifier; - err = register_netevent_notifier(&priv->ne_nb); + ctrl->ne_nb.notifier_call = otto_l3_netevent_notifier; + err = register_netevent_notifier(&ctrl->ne_nb); if (err) { - priv->ne_nb.notifier_call = NULL; + ctrl->ne_nb.notifier_call = NULL; return dev_err_probe(dev, err, "Failed to register netevent notifier\n"); } @@ -733,10 +733,10 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv) * FIBs pointing to our own netdevs are programmed into the device, so no need to pass a * callback. */ - priv->fib_nb.notifier_call = otto_l3_fib_notifier; - err = register_fib_notifier(&init_net, &priv->fib_nb, NULL, NULL); + ctrl->fib_nb.notifier_call = otto_l3_fib_notifier; + err = register_fib_notifier(&init_net, &ctrl->fib_nb, NULL, NULL); if (err) { - priv->fib_nb.notifier_call = NULL; + ctrl->fib_nb.notifier_call = NULL; otto_l3_remove(priv); return dev_err_probe(dev, err, "Failed to register fib event notifier\n"); } diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h index ac9ea1664cd..d61087dffff 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h @@ -7,6 +7,8 @@ struct otto_l3_ctrl { struct rtl838x_switch_priv *priv; + struct notifier_block fib_nb; + struct notifier_block ne_nb; }; struct otto_l3_route_attr { diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h index f81156bbd73..832f047562d 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h @@ -1504,8 +1504,6 @@ struct rtl838x_switch_priv { /** @lagmembers: Port (bit) is part of any LAG */ u64 lagmembers; struct workqueue_struct *wq; - struct notifier_block ne_nb; - struct notifier_block fib_nb; bool eee_enabled; unsigned long mc_group_bm[MAX_MC_GROUPS >> 5]; struct rhashtable tc_ht; -- 2.47.3