rtnetlink.c (a13511dfa836c8305a737436eed3ba9a8e74a826) | rtnetlink.c (d0522f1cd25edb796548f91e04766fa3cbc3b6df) |
---|---|
1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Routing netlink socket interface: protocol independent part. 7 * 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> --- 2871 unchanged lines hidden (view full) --- 2880 } else { 2881 dev->rtnl_link_state = RTNL_LINK_INITIALIZED; 2882 __dev_notify_flags(dev, old_flags, ~0U); 2883 } 2884 return 0; 2885} 2886EXPORT_SYMBOL(rtnl_configure_link); 2887 | 1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Routing netlink socket interface: protocol independent part. 7 * 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> --- 2871 unchanged lines hidden (view full) --- 2880 } else { 2881 dev->rtnl_link_state = RTNL_LINK_INITIALIZED; 2882 __dev_notify_flags(dev, old_flags, ~0U); 2883 } 2884 return 0; 2885} 2886EXPORT_SYMBOL(rtnl_configure_link); 2887 |
2888struct 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[]) | 2888struct 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) |
2891{ 2892 struct net_device *dev; 2893 unsigned int num_tx_queues = 1; 2894 unsigned int num_rx_queues = 1; 2895 2896 if (tb[IFLA_NUM_TX_QUEUES]) 2897 num_tx_queues = nla_get_u32(tb[IFLA_NUM_TX_QUEUES]); 2898 else if (ops->get_num_tx_queues) 2899 num_tx_queues = ops->get_num_tx_queues(); 2900 2901 if (tb[IFLA_NUM_RX_QUEUES]) 2902 num_rx_queues = nla_get_u32(tb[IFLA_NUM_RX_QUEUES]); 2903 else if (ops->get_num_rx_queues) 2904 num_rx_queues = ops->get_num_rx_queues(); 2905 | 2893{ 2894 struct net_device *dev; 2895 unsigned int num_tx_queues = 1; 2896 unsigned int num_rx_queues = 1; 2897 2898 if (tb[IFLA_NUM_TX_QUEUES]) 2899 num_tx_queues = nla_get_u32(tb[IFLA_NUM_TX_QUEUES]); 2900 else if (ops->get_num_tx_queues) 2901 num_tx_queues = ops->get_num_tx_queues(); 2902 2903 if (tb[IFLA_NUM_RX_QUEUES]) 2904 num_rx_queues = nla_get_u32(tb[IFLA_NUM_RX_QUEUES]); 2905 else if (ops->get_num_rx_queues) 2906 num_rx_queues = ops->get_num_rx_queues(); 2907 |
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"); |
2907 return ERR_PTR(-EINVAL); | 2910 return ERR_PTR(-EINVAL); |
2911 } |
|
2908 | 2912 |
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"); |
2910 return ERR_PTR(-EINVAL); | 2915 return ERR_PTR(-EINVAL); |
2916 } |
|
2911 2912 dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type, 2913 ops->setup, num_tx_queues, num_rx_queues); 2914 if (!dev) 2915 return ERR_PTR(-ENOMEM); 2916 2917 dev_net_set(dev, net); 2918 dev->rtnl_link_ops = ops; --- 239 unchanged lines hidden (view full) --- 3158 goto out; 3159 } 3160 err = -EPERM; 3161 if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) 3162 goto out; 3163 } 3164 3165 dev = rtnl_create_link(link_net ? : dest_net, ifname, | 2917 2918 dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type, 2919 ops->setup, num_tx_queues, num_rx_queues); 2920 if (!dev) 2921 return ERR_PTR(-ENOMEM); 2922 2923 dev_net_set(dev, net); 2924 dev->rtnl_link_ops = ops; --- 239 unchanged lines hidden (view full) --- 3164 goto out; 3165 } 3166 err = -EPERM; 3167 if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) 3168 goto out; 3169 } 3170 3171 dev = rtnl_create_link(link_net ? : dest_net, ifname, |
3166 name_assign_type, ops, tb); | 3172 name_assign_type, ops, tb, extack); |
3167 if (IS_ERR(dev)) { 3168 err = PTR_ERR(dev); 3169 goto out; 3170 } 3171 3172 dev->ifindex = ifm->ifi_index; 3173 3174 if (ops->newlink) { --- 1894 unchanged lines hidden --- | 3173 if (IS_ERR(dev)) { 3174 err = PTR_ERR(dev); 3175 goto out; 3176 } 3177 3178 dev->ifindex = ifm->ifi_index; 3179 3180 if (ops->newlink) { --- 1894 unchanged lines hidden --- |