Skip to content

Commit d0522f1

Browse files
dsaherndavem330
authored andcommitted
net: Add extack argument to rtnl_create_link
Add extack arg to rtnl_create_link and add messages for invalid number of Tx or Rx queues. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0b215b9 commit d0522f1

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

drivers/net/can/vxcan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
207207
return PTR_ERR(peer_net);
208208

209209
peer = rtnl_create_link(peer_net, ifname, name_assign_type,
210-
&vxcan_link_ops, tbp);
210+
&vxcan_link_ops, tbp, extack);
211211
if (IS_ERR(peer)) {
212212
put_net(peer_net);
213213
return PTR_ERR(peer);

drivers/net/geneve.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
16661666

16671667
memset(tb, 0, sizeof(tb));
16681668
dev = rtnl_create_link(net, name, name_assign_type,
1669-
&geneve_link_ops, tb);
1669+
&geneve_link_ops, tb, NULL);
16701670
if (IS_ERR(dev))
16711671
return dev;
16721672

drivers/net/veth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
12531253
return PTR_ERR(net);
12541254

12551255
peer = rtnl_create_link(net, ifname, name_assign_type,
1256-
&veth_link_ops, tbp);
1256+
&veth_link_ops, tbp, extack);
12571257
if (IS_ERR(peer)) {
12581258
put_net(net);
12591259
return PTR_ERR(peer);

drivers/net/vxlan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@ struct net_device *vxlan_dev_create(struct net *net, const char *name,
37493749
memset(&tb, 0, sizeof(tb));
37503750

37513751
dev = rtnl_create_link(net, name, name_assign_type,
3752-
&vxlan_link_ops, tb);
3752+
&vxlan_link_ops, tb, NULL);
37533753
if (IS_ERR(dev))
37543754
return dev;
37553755

include/net/rtnetlink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
159159
struct net_device *rtnl_create_link(struct net *net, const char *ifname,
160160
unsigned char name_assign_type,
161161
const struct rtnl_link_ops *ops,
162-
struct nlattr *tb[]);
162+
struct nlattr *tb[],
163+
struct netlink_ext_ack *extack);
163164
int rtnl_delete_link(struct net_device *dev);
164165
int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm);
165166

net/core/rtnetlink.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,9 +2885,11 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
28852885
}
28862886
EXPORT_SYMBOL(rtnl_configure_link);
28872887

2888-
struct net_device *rtnl_create_link(struct net *net,
2889-
const char *ifname, unsigned char name_assign_type,
2890-
const struct rtnl_link_ops *ops, struct nlattr *tb[])
2888+
struct net_device *rtnl_create_link(struct net *net, const char *ifname,
2889+
unsigned char name_assign_type,
2890+
const struct rtnl_link_ops *ops,
2891+
struct nlattr *tb[],
2892+
struct netlink_ext_ack *extack)
28912893
{
28922894
struct net_device *dev;
28932895
unsigned int num_tx_queues = 1;
@@ -2903,11 +2905,15 @@ struct net_device *rtnl_create_link(struct net *net,
29032905
else if (ops->get_num_rx_queues)
29042906
num_rx_queues = ops->get_num_rx_queues();
29052907

2906-
if (num_tx_queues < 1 || num_tx_queues > 4096)
2908+
if (num_tx_queues < 1 || num_tx_queues > 4096) {
2909+
NL_SET_ERR_MSG(extack, "Invalid number of transmit queues");
29072910
return ERR_PTR(-EINVAL);
2911+
}
29082912

2909-
if (num_rx_queues < 1 || num_rx_queues > 4096)
2913+
if (num_rx_queues < 1 || num_rx_queues > 4096) {
2914+
NL_SET_ERR_MSG(extack, "Invalid number of receive queues");
29102915
return ERR_PTR(-EINVAL);
2916+
}
29112917

29122918
dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type,
29132919
ops->setup, num_tx_queues, num_rx_queues);
@@ -3163,7 +3169,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
31633169
}
31643170

31653171
dev = rtnl_create_link(link_net ? : dest_net, ifname,
3166-
name_assign_type, ops, tb);
3172+
name_assign_type, ops, tb, extack);
31673173
if (IS_ERR(dev)) {
31683174
err = PTR_ERR(dev);
31693175
goto out;

net/ipv4/ip_gre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
16011601
memset(&tb, 0, sizeof(tb));
16021602

16031603
dev = rtnl_create_link(net, name, name_assign_type,
1604-
&ipgre_tap_ops, tb);
1604+
&ipgre_tap_ops, tb, NULL);
16051605
if (IS_ERR(dev))
16061606
return dev;
16071607

0 commit comments

Comments
 (0)