46
46
#include <linux/workqueue.h>
47
47
#include <linux/jiffies.h>
48
48
#include <linux/rtnetlink.h>
49
+ #include <linux/netlink.h>
49
50
#include <net/switchdev.h>
50
51
51
52
#include "spectrum.h"
@@ -107,7 +108,8 @@ struct mlxsw_sp_bridge_vlan {
107
108
struct mlxsw_sp_bridge_ops {
108
109
int (* port_join )(struct mlxsw_sp_bridge_device * bridge_device ,
109
110
struct mlxsw_sp_bridge_port * bridge_port ,
110
- struct mlxsw_sp_port * mlxsw_sp_port );
111
+ struct mlxsw_sp_port * mlxsw_sp_port ,
112
+ struct netlink_ext_ack * extack );
111
113
void (* port_leave )(struct mlxsw_sp_bridge_device * bridge_device ,
112
114
struct mlxsw_sp_bridge_port * bridge_port ,
113
115
struct mlxsw_sp_port * mlxsw_sp_port );
@@ -1735,12 +1737,15 @@ static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = {
1735
1737
static int
1736
1738
mlxsw_sp_bridge_8021q_port_join (struct mlxsw_sp_bridge_device * bridge_device ,
1737
1739
struct mlxsw_sp_bridge_port * bridge_port ,
1738
- struct mlxsw_sp_port * mlxsw_sp_port )
1740
+ struct mlxsw_sp_port * mlxsw_sp_port ,
1741
+ struct netlink_ext_ack * extack )
1739
1742
{
1740
1743
struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ;
1741
1744
1742
- if (is_vlan_dev (bridge_port -> dev ))
1745
+ if (is_vlan_dev (bridge_port -> dev )) {
1746
+ NL_SET_ERR_MSG (extack , "spectrum: Can not enslave a VLAN device to a VLAN-aware bridge" );
1743
1747
return - EINVAL ;
1748
+ }
1744
1749
1745
1750
mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid (mlxsw_sp_port , 1 );
1746
1751
if (WARN_ON (!mlxsw_sp_port_vlan ))
@@ -1797,21 +1802,24 @@ mlxsw_sp_port_is_br_member(const struct mlxsw_sp_port *mlxsw_sp_port,
1797
1802
static int
1798
1803
mlxsw_sp_bridge_8021d_port_join (struct mlxsw_sp_bridge_device * bridge_device ,
1799
1804
struct mlxsw_sp_bridge_port * bridge_port ,
1800
- struct mlxsw_sp_port * mlxsw_sp_port )
1805
+ struct mlxsw_sp_port * mlxsw_sp_port ,
1806
+ struct netlink_ext_ack * extack )
1801
1807
{
1802
1808
struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ;
1803
1809
u16 vid ;
1804
1810
1805
- if (!is_vlan_dev (bridge_port -> dev ))
1811
+ if (!is_vlan_dev (bridge_port -> dev )) {
1812
+ NL_SET_ERR_MSG (extack , "spectrum: Only VLAN devices can be enslaved to a VLAN-unaware bridge" );
1806
1813
return - EINVAL ;
1814
+ }
1807
1815
vid = vlan_dev_vlan_id (bridge_port -> dev );
1808
1816
1809
1817
mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid (mlxsw_sp_port , vid );
1810
1818
if (WARN_ON (!mlxsw_sp_port_vlan ))
1811
1819
return - EINVAL ;
1812
1820
1813
1821
if (mlxsw_sp_port_is_br_member (mlxsw_sp_port , bridge_device -> dev )) {
1814
- netdev_err ( mlxsw_sp_port -> dev , "Can't bridge VLAN uppers of the same port\n " );
1822
+ NL_SET_ERR_MSG ( extack , "spectrum: Can not bridge VLAN uppers of the same port" );
1815
1823
return - EINVAL ;
1816
1824
}
1817
1825
@@ -1854,7 +1862,8 @@ static const struct mlxsw_sp_bridge_ops mlxsw_sp_bridge_8021d_ops = {
1854
1862
1855
1863
int mlxsw_sp_port_bridge_join (struct mlxsw_sp_port * mlxsw_sp_port ,
1856
1864
struct net_device * brport_dev ,
1857
- struct net_device * br_dev )
1865
+ struct net_device * br_dev ,
1866
+ struct netlink_ext_ack * extack )
1858
1867
{
1859
1868
struct mlxsw_sp * mlxsw_sp = mlxsw_sp_port -> mlxsw_sp ;
1860
1869
struct mlxsw_sp_bridge_device * bridge_device ;
@@ -1867,7 +1876,7 @@ int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
1867
1876
bridge_device = bridge_port -> bridge_device ;
1868
1877
1869
1878
err = bridge_device -> ops -> port_join (bridge_device , bridge_port ,
1870
- mlxsw_sp_port );
1879
+ mlxsw_sp_port , extack );
1871
1880
if (err )
1872
1881
goto err_port_join ;
1873
1882
0 commit comments