Commit 41b2bd20 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller
Browse files

mlxsw: spectrum_router: Move here inetaddr validator notifiers



The validation logic is already in the router code. Move there the notifier
blocks themselves as well.

Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarAmit Cohen <amcohen@nvidia.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 50f6c3d5
Loading
Loading
Loading
Loading
+1 −17
Original line number Diff line number Diff line
@@ -5139,14 +5139,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb,
	return notifier_from_errno(err);
}

static struct notifier_block mlxsw_sp_inetaddr_valid_nb __read_mostly = {
	.notifier_call = mlxsw_sp_inetaddr_valid_event,
};

static struct notifier_block mlxsw_sp_inet6addr_valid_nb __read_mostly = {
	.notifier_call = mlxsw_sp_inet6addr_valid_event,
};

static const struct pci_device_id mlxsw_sp1_pci_id_table[] = {
	{PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM), 0},
	{0, },
@@ -5191,12 +5183,9 @@ static int __init mlxsw_sp_module_init(void)
{
	int err;

	register_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
	register_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);

	err = mlxsw_core_driver_register(&mlxsw_sp1_driver);
	if (err)
		goto err_sp1_core_driver_register;
		return err;

	err = mlxsw_core_driver_register(&mlxsw_sp2_driver);
	if (err)
@@ -5242,9 +5231,6 @@ static int __init mlxsw_sp_module_init(void)
	mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
err_sp2_core_driver_register:
	mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
err_sp1_core_driver_register:
	unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
	unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
	return err;
}

@@ -5258,8 +5244,6 @@ static void __exit mlxsw_sp_module_exit(void)
	mlxsw_core_driver_unregister(&mlxsw_sp3_driver);
	mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
	mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
	unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
	unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
}

module_init(mlxsw_sp_module_init);
+0 −4
Original line number Diff line number Diff line
@@ -755,10 +755,6 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
			      const struct net_device *macvlan_dev);
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_port_vlan_router_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
			       struct net_device *l3_dev,
+22 −4
Original line number Diff line number Diff line
@@ -8879,7 +8879,7 @@ static int mlxsw_sp_inetaddr_event(struct notifier_block *nb,
	return notifier_from_errno(err);
}

int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
static int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
					 unsigned long event, void *ptr)
{
	struct in_validator_info *ivi = (struct in_validator_info *) ptr;
@@ -8962,7 +8962,7 @@ static int mlxsw_sp_inet6addr_event(struct notifier_block *nb,
	return NOTIFY_DONE;
}

int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
static int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
					  unsigned long event, void *ptr)
{
	struct in6_validator_info *i6vi = (struct in6_validator_info *) ptr;
@@ -10510,6 +10510,7 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
			 struct netlink_ext_ack *extack)
{
	struct mlxsw_sp_router *router;
	struct notifier_block *nb;
	int err;

	router = kzalloc(sizeof(*mlxsw_sp->router), GFP_KERNEL);
@@ -10588,6 +10589,17 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
	if (err)
		goto err_register_inet6addr_notifier;

	router->inetaddr_valid_nb.notifier_call = mlxsw_sp_inetaddr_valid_event;
	err = register_inetaddr_validator_notifier(&router->inetaddr_valid_nb);
	if (err)
		goto err_register_inetaddr_valid_notifier;

	nb = &router->inet6addr_valid_nb;
	nb->notifier_call = mlxsw_sp_inet6addr_valid_event;
	err = register_inet6addr_validator_notifier(nb);
	if (err)
		goto err_register_inet6addr_valid_notifier;

	mlxsw_sp->router->netevent_nb.notifier_call =
		mlxsw_sp_router_netevent_event;
	err = register_netevent_notifier(&mlxsw_sp->router->netevent_nb);
@@ -10627,6 +10639,10 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
err_register_nexthop_notifier:
	unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb);
err_register_netevent_notifier:
	unregister_inet6addr_validator_notifier(&router->inet6addr_valid_nb);
err_register_inet6addr_valid_notifier:
	unregister_inetaddr_validator_notifier(&router->inetaddr_valid_nb);
err_register_inetaddr_valid_notifier:
	unregister_inet6addr_notifier(&router->inet6addr_nb);
err_register_inet6addr_notifier:
	unregister_inetaddr_notifier(&router->inetaddr_nb);
@@ -10672,6 +10688,8 @@ void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
	unregister_nexthop_notifier(mlxsw_sp_net(mlxsw_sp),
				    &router->nexthop_nb);
	unregister_netevent_notifier(&router->netevent_nb);
	unregister_inet6addr_validator_notifier(&router->inet6addr_valid_nb);
	unregister_inetaddr_validator_notifier(&router->inetaddr_valid_nb);
	unregister_inet6addr_notifier(&router->inet6addr_nb);
	unregister_inetaddr_notifier(&router->inetaddr_nb);
	mlxsw_core_flush_owq();
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ struct mlxsw_sp_router {
	struct notifier_block inetaddr_nb;
	struct notifier_block inet6addr_nb;
	struct notifier_block netdevice_nb;
	struct notifier_block inetaddr_valid_nb;
	struct notifier_block inet6addr_valid_nb;
	const struct mlxsw_sp_rif_ops **rif_ops_arr;
	const struct mlxsw_sp_ipip_ops **ipip_ops_arr;
	struct mlxsw_sp_router_nve_decap nve_decap_config;