net: vrf: Add extack messages for enslave errors
authorDavid Ahern <dsahern@gmail.com>
Thu, 5 Oct 2017 00:48:48 +0000 (17:48 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Oct 2017 04:39:33 +0000 (21:39 -0700)
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vrf.c

index 77d0655a02506f83fa4152957155758ecb40ea9f..0b54f553228e951e30e2b61fece6ff3fd09ca1eb 100644 (file)
@@ -772,8 +772,11 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev,
        /* do not allow loopback device to be enslaved to a VRF.
         * The vrf device acts as the loopback for the vrf.
         */
-       if (port_dev == dev_net(dev)->loopback_dev)
+       if (port_dev == dev_net(dev)->loopback_dev) {
+               NL_SET_ERR_MSG(extack,
+                              "Can not enslave loopback device to a VRF");
                return -EOPNOTSUPP;
+       }
 
        port_dev->priv_flags |= IFF_L3MDEV_SLAVE;
        ret = netdev_master_upper_dev_link(port_dev, dev, NULL, NULL, extack);
@@ -792,7 +795,13 @@ err:
 static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev,
                         struct netlink_ext_ack *extack)
 {
-       if (netif_is_l3_master(port_dev) || netif_is_l3_slave(port_dev))
+       if (netif_is_l3_master(port_dev)) {
+               NL_SET_ERR_MSG(extack,
+                              "Can not enslave an L3 master device to a VRF");
+               return -EINVAL;
+       }
+
+       if (netif_is_l3_slave(port_dev))
                return -EINVAL;
 
        return do_vrf_add_slave(dev, port_dev, extack);