net: bridge: Pass extack to down to netdev_master_upper_dev_link
authorDavid Ahern <dsahern@gmail.com>
Thu, 5 Oct 2017 00:48:50 +0000 (17:48 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Oct 2017 04:39:34 +0000 (21:39 -0700)
Pass extack arg to br_add_if. Add messages for a couple of failures
and pass arg to netdev_master_upper_dev_link.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_device.c
net/bridge/br_if.c
net/bridge/br_ioctl.c
net/bridge/br_private.h

index cb0131d70ab1e0dd9bb66a910c424061706fd949..7acb77c9bd65ccf98788f5ebe72eb2175a54032d 100644 (file)
@@ -326,7 +326,7 @@ static int br_add_slave(struct net_device *dev, struct net_device *slave_dev,
 {
        struct net_bridge *br = netdev_priv(dev);
 
-       return br_add_if(br, slave_dev);
+       return br_add_if(br, slave_dev, extack);
 }
 
 static int br_del_slave(struct net_device *dev, struct net_device *slave_dev)
index 0a3fd727048deb1a47bf6a0a90f15d81947477a8..59a74a414e20403636d7d16629f13352da591b00 100644 (file)
@@ -480,7 +480,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br,
 }
 
 /* called with RTNL */
-int br_add_if(struct net_bridge *br, struct net_device *dev)
+int br_add_if(struct net_bridge *br, struct net_device *dev,
+             struct netlink_ext_ack *extack)
 {
        struct net_bridge_port *p;
        int err = 0;
@@ -500,16 +501,22 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
                return -EINVAL;
 
        /* No bridging of bridges */
-       if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit)
+       if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) {
+               NL_SET_ERR_MSG(extack,
+                              "Can not enslave a bridge to a bridge");
                return -ELOOP;
+       }
 
        /* Device is already being bridged */
        if (br_port_exists(dev))
                return -EBUSY;
 
        /* No bridging devices that dislike that (e.g. wireless) */
-       if (dev->priv_flags & IFF_DONT_BRIDGE)
+       if (dev->priv_flags & IFF_DONT_BRIDGE) {
+               NL_SET_ERR_MSG(extack,
+                              "Device does not allow enslaving to a bridge");
                return -EOPNOTSUPP;
+       }
 
        p = new_nbp(br, dev);
        if (IS_ERR(p))
@@ -540,7 +547,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 
        dev->priv_flags |= IFF_BRIDGE_PORT;
 
-       err = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL, NULL);
+       err = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL, extack);
        if (err)
                goto err5;
 
index 66cd9877205180aba5b6ed145353cb27e3263e13..8f29103935a3b50794ca1da5b8ac70427c2fef71 100644 (file)
@@ -98,7 +98,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
                return -EINVAL;
 
        if (isadd)
-               ret = br_add_if(br, dev);
+               ret = br_add_if(br, dev, NULL);
        else
                ret = br_del_if(br, dev);
 
index 020c709a017f089d34e38a2bf17ca977a7836fa0..ab4df24f7bba52b78a5ee3f945366ad5e37652d4 100644 (file)
@@ -566,7 +566,8 @@ void br_flood(struct net_bridge *br, struct sk_buff *skb,
 void br_port_carrier_check(struct net_bridge_port *p);
 int br_add_bridge(struct net *net, const char *name);
 int br_del_bridge(struct net *net, const char *name);
-int br_add_if(struct net_bridge *br, struct net_device *dev);
+int br_add_if(struct net_bridge *br, struct net_device *dev,
+             struct netlink_ext_ack *extack);
 int br_del_if(struct net_bridge *br, struct net_device *dev);
 int br_min_mtu(const struct net_bridge *br);
 netdev_features_t br_features_recompute(struct net_bridge *br,