mlxsw: spectrum_switchdev: Propagate extack to bridge creation function
authorIdo Schimmel <idosch@mellanox.com>
Mon, 17 Feb 2020 14:29:32 +0000 (16:29 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Feb 2020 22:42:53 +0000 (14:42 -0800)
Propagate extack to bridge creation function so that error messages
could be passed to user space via netlink instead of printing them to
kernel log.

A subsequent patch will pass the new extack argument to more functions.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

index a3af171c6358892656cef7247643294717c05509..798aefd3e3b6358355c68264af61e597116cef30 100644 (file)
@@ -155,7 +155,8 @@ static void mlxsw_sp_bridge_device_rifs_destroy(struct mlxsw_sp *mlxsw_sp,
 
 static struct mlxsw_sp_bridge_device *
 mlxsw_sp_bridge_device_create(struct mlxsw_sp_bridge *bridge,
-                             struct net_device *br_dev)
+                             struct net_device *br_dev,
+                             struct netlink_ext_ack *extack)
 {
        struct device *dev = bridge->mlxsw_sp->bus_info->dev;
        struct mlxsw_sp_bridge_device *bridge_device;
@@ -163,6 +164,7 @@ mlxsw_sp_bridge_device_create(struct mlxsw_sp_bridge *bridge,
 
        if (vlan_enabled && bridge->vlan_enabled_exists) {
                dev_err(dev, "Only one VLAN-aware bridge is supported\n");
+               NL_SET_ERR_MSG_MOD(extack, "Only one VLAN-aware bridge is supported");
                return ERR_PTR(-EINVAL);
        }
 
@@ -203,7 +205,8 @@ mlxsw_sp_bridge_device_destroy(struct mlxsw_sp_bridge *bridge,
 
 static struct mlxsw_sp_bridge_device *
 mlxsw_sp_bridge_device_get(struct mlxsw_sp_bridge *bridge,
-                          struct net_device *br_dev)
+                          struct net_device *br_dev,
+                          struct netlink_ext_ack *extack)
 {
        struct mlxsw_sp_bridge_device *bridge_device;
 
@@ -211,7 +214,7 @@ mlxsw_sp_bridge_device_get(struct mlxsw_sp_bridge *bridge,
        if (bridge_device)
                return bridge_device;
 
-       return mlxsw_sp_bridge_device_create(bridge, br_dev);
+       return mlxsw_sp_bridge_device_create(bridge, br_dev, extack);
 }
 
 static void
@@ -292,7 +295,8 @@ mlxsw_sp_bridge_port_destroy(struct mlxsw_sp_bridge_port *bridge_port)
 
 static struct mlxsw_sp_bridge_port *
 mlxsw_sp_bridge_port_get(struct mlxsw_sp_bridge *bridge,
-                        struct net_device *brport_dev)
+                        struct net_device *brport_dev,
+                        struct netlink_ext_ack *extack)
 {
        struct net_device *br_dev = netdev_master_upper_dev_get(brport_dev);
        struct mlxsw_sp_bridge_device *bridge_device;
@@ -305,7 +309,7 @@ mlxsw_sp_bridge_port_get(struct mlxsw_sp_bridge *bridge,
                return bridge_port;
        }
 
-       bridge_device = mlxsw_sp_bridge_device_get(bridge, br_dev);
+       bridge_device = mlxsw_sp_bridge_device_get(bridge, br_dev, extack);
        if (IS_ERR(bridge_device))
                return ERR_CAST(bridge_device);
 
@@ -1000,7 +1004,7 @@ mlxsw_sp_port_vlan_bridge_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
                 &bridge_vlan->port_vlan_list);
 
        mlxsw_sp_bridge_port_get(mlxsw_sp_port->mlxsw_sp->bridge,
-                                bridge_port->dev);
+                                bridge_port->dev, extack);
        mlxsw_sp_port_vlan->bridge_port = bridge_port;
 
        return 0;
@@ -2287,7 +2291,8 @@ int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
        struct mlxsw_sp_bridge_port *bridge_port;
        int err;
 
-       bridge_port = mlxsw_sp_bridge_port_get(mlxsw_sp->bridge, brport_dev);
+       bridge_port = mlxsw_sp_bridge_port_get(mlxsw_sp->bridge, brport_dev,
+                                              extack);
        if (IS_ERR(bridge_port))
                return PTR_ERR(bridge_port);
        bridge_device = bridge_port->bridge_device;