mlxsw: spectrum: Move handling of VRF events to router code
authorPetr Machata <petrm@nvidia.com>
Sun, 8 May 2022 08:08:16 +0000 (11:08 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 8 May 2022 10:46:20 +0000 (11:46 +0100)
Events involving VRF, as L3 concern, are handled in the router code, by the
helper mlxsw_sp_netdevice_vrf_event(). The handler is currently invoked
from the centralized dispatcher in spectrum.c. Instead, move the call to
the newly-introduced router-specific notifier handler.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 12fd846..867c1f3 100644 (file)
@@ -4936,15 +4936,6 @@ static int mlxsw_sp_netdevice_macvlan_event(struct net_device *macvlan_dev,
        return 0;
 }
 
-static bool mlxsw_sp_is_vrf_event(unsigned long event, void *ptr)
-{
-       struct netdev_notifier_changeupper_info *info = ptr;
-
-       if (event != NETDEV_PRECHANGEUPPER && event != NETDEV_CHANGEUPPER)
-               return false;
-       return netif_is_l3_master(info->upper_dev);
-}
-
 static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,
                                          struct net_device *dev,
                                          unsigned long event, void *ptr)
@@ -5055,8 +5046,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb,
                                                       event, ptr);
        else if (mlxsw_sp_netdevice_event_is_router(event))
                err = mlxsw_sp_netdevice_router_port_event(dev, event, ptr);
-       else if (mlxsw_sp_is_vrf_event(event, ptr))
-               err = mlxsw_sp_netdevice_vrf_event(dev, event, ptr);
        else if (mlxsw_sp_port_dev_check(dev))
                err = mlxsw_sp_netdevice_port_event(dev, dev, event, ptr);
        else if (netif_is_lag_master(dev))
index 2ad29ae..a20e2a1 100644 (file)
@@ -726,8 +726,6 @@ int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
                                  unsigned long event, void *ptr);
 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
                                   unsigned long event, void *ptr);
-int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
-                                struct netdev_notifier_changeupper_info *info);
 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp,
                                const struct net_device *dev);
 bool mlxsw_sp_netdev_is_ipip_ul(struct mlxsw_sp *mlxsw_sp,
index 3fcb848..fa4d9bf 100644 (file)
@@ -9476,8 +9476,18 @@ static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp,
        __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, NULL);
 }
 
-int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
-                                struct netdev_notifier_changeupper_info *info)
+static bool mlxsw_sp_is_vrf_event(unsigned long event, void *ptr)
+{
+       struct netdev_notifier_changeupper_info *info = ptr;
+
+       if (event != NETDEV_PRECHANGEUPPER && event != NETDEV_CHANGEUPPER)
+               return false;
+       return netif_is_l3_master(info->upper_dev);
+}
+
+static int
+mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
+                            struct netdev_notifier_changeupper_info *info)
 {
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(l3_dev);
        int err = 0;
@@ -9511,8 +9521,12 @@ int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
 static int mlxsw_sp_router_netdevice_event(struct notifier_block *nb,
                                           unsigned long event, void *ptr)
 {
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
        int err = 0;
 
+       if (mlxsw_sp_is_vrf_event(event, ptr))
+               err = mlxsw_sp_netdevice_vrf_event(dev, event, ptr);
+
        return notifier_from_errno(err);
 }