]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: l3: move notifier blocks to private structure 23937/head
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Thu, 25 Jun 2026 09:20:16 +0000 (11:20 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Fri, 26 Jun 2026 16:06:56 +0000 (18:06 +0200)
Relocate the notification handlers into the new L3 ecosystem.

Link: https://github.com/openwrt/openwrt/pull/23937
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h

index 00d462369169df94e901c13421f35d4e2fbba1d2..db3caadb8bd93ab52c953757385a4b8b16a4c20b 100644 (file)
@@ -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");
        }
index ac9ea1664cdf1b77a33e4010fc4ae2470a05e092..d61087dffff4d50d1aa72af899a8f8a0f0fc790c 100644 (file)
@@ -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 {
index f81156bbd73391a4a1fb3b9f1695b371fa60e78a..832f047562d7df636cbd93585f5fcc20b25a2ac0 100644 (file)
@@ -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;