mlxsw: spectrum: Add extack messages to VXLAN FDB rejection
authorPetr Machata <petrm@mellanox.com>
Wed, 16 Jan 2019 23:06:58 +0000 (23:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Jan 2019 23:18:47 +0000 (15:18 -0800)
Annotate the rejections in mlxsw_sp_switchdev_vxlan_work_prepare() with
textual reasons.

Because this code ends up being invoked for FDB replay as well, drop the
default message from there, so that the more accurate error message is
not overwritten.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

index 94e0776..1df164a 100644 (file)
@@ -842,10 +842,8 @@ int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
        nve->config = config;
 
        err = ops->fdb_replay(params->dev, params->vni, extack);
-       if (err) {
-               NL_SET_ERR_MSG_MOD(extack, "Failed to offload the FDB");
+       if (err)
                goto err_fdb_replay;
-       }
 
        return 0;
 
index 71aad9d..8ab796e 100644 (file)
@@ -3099,23 +3099,34 @@ mlxsw_sp_switchdev_vxlan_work_prepare(struct mlxsw_sp_switchdev_event_work *
        struct vxlan_dev *vxlan = netdev_priv(switchdev_work->dev);
        struct switchdev_notifier_vxlan_fdb_info *vxlan_fdb_info;
        struct vxlan_config *cfg = &vxlan->cfg;
+       struct netlink_ext_ack *extack;
 
+       extack = switchdev_notifier_info_to_extack(info);
        vxlan_fdb_info = container_of(info,
                                      struct switchdev_notifier_vxlan_fdb_info,
                                      info);
 
-       if (vxlan_fdb_info->remote_port != cfg->dst_port)
-               return -EOPNOTSUPP;
-       if (vxlan_fdb_info->remote_vni != cfg->vni)
+       if (vxlan_fdb_info->remote_port != cfg->dst_port) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: FDB: Non-default remote port is not supported");
                return -EOPNOTSUPP;
-       if (vxlan_fdb_info->vni != cfg->vni)
+       }
+       if (vxlan_fdb_info->remote_vni != cfg->vni ||
+           vxlan_fdb_info->vni != cfg->vni) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: FDB: Non-default VNI is not supported");
                return -EOPNOTSUPP;
-       if (vxlan_fdb_info->remote_ifindex)
+       }
+       if (vxlan_fdb_info->remote_ifindex) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: FDB: Local interface is not supported");
                return -EOPNOTSUPP;
-       if (is_multicast_ether_addr(vxlan_fdb_info->eth_addr))
+       }
+       if (is_multicast_ether_addr(vxlan_fdb_info->eth_addr)) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: FDB: Multicast MAC addresses not supported");
                return -EOPNOTSUPP;
-       if (vxlan_addr_multicast(&vxlan_fdb_info->remote_ip))
+       }
+       if (vxlan_addr_multicast(&vxlan_fdb_info->remote_ip)) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: FDB: Multicast destination IP is not supported");
                return -EOPNOTSUPP;
+       }
 
        switchdev_work->vxlan_fdb_info = *vxlan_fdb_info;