net: Add extack argument to rtnl_create_link
authorDavid Ahern <dsahern@gmail.com>
Tue, 6 Nov 2018 20:51:14 +0000 (12:51 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Nov 2018 23:00:45 +0000 (15:00 -0800)
Add extack arg to rtnl_create_link and add messages for invalid
number of Tx or Rx queues.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/can/vxcan.c
drivers/net/geneve.c
drivers/net/veth.c
drivers/net/vxlan.c
include/net/rtnetlink.h
net/core/rtnetlink.c
net/ipv4/ip_gre.c

index ed6828821fbd3c5f707068101e23adfcadbeffab..80af658e530d6443284c904a4f9876e6b490787a 100644 (file)
@@ -207,7 +207,7 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
                return PTR_ERR(peer_net);
 
        peer = rtnl_create_link(peer_net, ifname, name_assign_type,
-                               &vxcan_link_ops, tbp);
+                               &vxcan_link_ops, tbp, extack);
        if (IS_ERR(peer)) {
                put_net(peer_net);
                return PTR_ERR(peer);
index a0cd1c41cf5f07255283be656f1ecf074417532a..fbfc13d81f66abd5bc4e7331e8aea0fe94bd872b 100644 (file)
@@ -1666,7 +1666,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
 
        memset(tb, 0, sizeof(tb));
        dev = rtnl_create_link(net, name, name_assign_type,
-                              &geneve_link_ops, tb);
+                              &geneve_link_ops, tb, NULL);
        if (IS_ERR(dev))
                return dev;
 
index 890fa5b905e27a2dd8b177495cc61ad39cc35091..f412ea1cef18bbf215ac6ae46d257b39a8a95c74 100644 (file)
@@ -1253,7 +1253,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
                return PTR_ERR(net);
 
        peer = rtnl_create_link(net, ifname, name_assign_type,
-                               &veth_link_ops, tbp);
+                               &veth_link_ops, tbp, extack);
        if (IS_ERR(peer)) {
                put_net(net);
                return PTR_ERR(peer);
index 297cdeaef4796501279f826154191eb6e0e0d298..ae969f806d565d5890cc6745a7aa3d7c8d7b1201 100644 (file)
@@ -3749,7 +3749,7 @@ struct net_device *vxlan_dev_create(struct net *net, const char *name,
        memset(&tb, 0, sizeof(tb));
 
        dev = rtnl_create_link(net, name, name_assign_type,
-                              &vxlan_link_ops, tb);
+                              &vxlan_link_ops, tb, NULL);
        if (IS_ERR(dev))
                return dev;
 
index cf26e5aacac49f26667e674ad59aafa953e0f017..e2091bb2b3a8e72715d83f5b1c36304a026b4330 100644 (file)
@@ -159,7 +159,8 @@ struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
 struct net_device *rtnl_create_link(struct net *net, const char *ifname,
                                    unsigned char name_assign_type,
                                    const struct rtnl_link_ops *ops,
-                                   struct nlattr *tb[]);
+                                   struct nlattr *tb[],
+                                   struct netlink_ext_ack *extack);
 int rtnl_delete_link(struct net_device *dev);
 int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm);
 
index 33d9227a8b8077a8cf6edbcaaa9f5b92d4fee48e..f787b7640d490cb8da97461f7386950849bb551b 100644 (file)
@@ -2885,9 +2885,11 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
 }
 EXPORT_SYMBOL(rtnl_configure_link);
 
-struct net_device *rtnl_create_link(struct net *net,
-       const char *ifname, unsigned char name_assign_type,
-       const struct rtnl_link_ops *ops, struct nlattr *tb[])
+struct net_device *rtnl_create_link(struct net *net, const char *ifname,
+                                   unsigned char name_assign_type,
+                                   const struct rtnl_link_ops *ops,
+                                   struct nlattr *tb[],
+                                   struct netlink_ext_ack *extack)
 {
        struct net_device *dev;
        unsigned int num_tx_queues = 1;
@@ -2903,11 +2905,15 @@ struct net_device *rtnl_create_link(struct net *net,
        else if (ops->get_num_rx_queues)
                num_rx_queues = ops->get_num_rx_queues();
 
-       if (num_tx_queues < 1 || num_tx_queues > 4096)
+       if (num_tx_queues < 1 || num_tx_queues > 4096) {
+               NL_SET_ERR_MSG(extack, "Invalid number of transmit queues");
                return ERR_PTR(-EINVAL);
+       }
 
-       if (num_rx_queues < 1 || num_rx_queues > 4096)
+       if (num_rx_queues < 1 || num_rx_queues > 4096) {
+               NL_SET_ERR_MSG(extack, "Invalid number of receive queues");
                return ERR_PTR(-EINVAL);
+       }
 
        dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type,
                               ops->setup, num_tx_queues, num_rx_queues);
@@ -3163,7 +3169,7 @@ replay:
                }
 
                dev = rtnl_create_link(link_net ? : dest_net, ifname,
-                                      name_assign_type, ops, tb);
+                                      name_assign_type, ops, tb, extack);
                if (IS_ERR(dev)) {
                        err = PTR_ERR(dev);
                        goto out;
index 38befe829caf51c56f9661abe71f3dc4a030bd86..2c67af644e64bcffb8a48ebbf9289b699e56482f 100644 (file)
@@ -1601,7 +1601,7 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
        memset(&tb, 0, sizeof(tb));
 
        dev = rtnl_create_link(net, name, name_assign_type,
-                              &ipgre_tap_ops, tb);
+                              &ipgre_tap_ops, tb, NULL);
        if (IS_ERR(dev))
                return dev;