aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r--net/core/rtnetlink.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 21318d15bbc3..334b930e0de3 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -541,19 +541,6 @@ static const int rta_max[RTM_NR_FAMILIES] =
541 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX, 541 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX,
542}; 542};
543 543
544void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
545{
546 struct rtattr *rta;
547 int size = RTA_LENGTH(attrlen);
548
549 rta = (struct rtattr *)skb_put(skb, RTA_ALIGN(size));
550 rta->rta_type = attrtype;
551 rta->rta_len = size;
552 memcpy(RTA_DATA(rta), data, attrlen);
553 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
554}
555EXPORT_SYMBOL(__rta_fill);
556
557int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo) 544int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo)
558{ 545{
559 struct sock *rtnl = net->rtnl; 546 struct sock *rtnl = net->rtnl;
@@ -628,7 +615,7 @@ nla_put_failure:
628EXPORT_SYMBOL(rtnetlink_put_metrics); 615EXPORT_SYMBOL(rtnetlink_put_metrics);
629 616
630int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id, 617int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
631 u32 ts, u32 tsage, long expires, u32 error) 618 long expires, u32 error)
632{ 619{
633 struct rta_cacheinfo ci = { 620 struct rta_cacheinfo ci = {
634 .rta_lastuse = jiffies_to_clock_t(jiffies - dst->lastuse), 621 .rta_lastuse = jiffies_to_clock_t(jiffies - dst->lastuse),
@@ -636,8 +623,6 @@ int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
636 .rta_clntref = atomic_read(&(dst->__refcnt)), 623 .rta_clntref = atomic_read(&(dst->__refcnt)),
637 .rta_error = error, 624 .rta_error = error,
638 .rta_id = id, 625 .rta_id = id,
639 .rta_ts = ts,
640 .rta_tsage = tsage,
641 }; 626 };
642 627
643 if (expires) 628 if (expires)
@@ -786,6 +771,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
786 + nla_total_size(4) /* IFLA_LINK */ 771 + nla_total_size(4) /* IFLA_LINK */
787 + nla_total_size(4) /* IFLA_MASTER */ 772 + nla_total_size(4) /* IFLA_MASTER */
788 + nla_total_size(4) /* IFLA_PROMISCUITY */ 773 + nla_total_size(4) /* IFLA_PROMISCUITY */
774 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
775 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
789 + nla_total_size(1) /* IFLA_OPERSTATE */ 776 + nla_total_size(1) /* IFLA_OPERSTATE */
790 + nla_total_size(1) /* IFLA_LINKMODE */ 777 + nla_total_size(1) /* IFLA_LINKMODE */
791 + nla_total_size(ext_filter_mask 778 + nla_total_size(ext_filter_mask
@@ -904,6 +891,10 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
904 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 891 nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
905 nla_put_u32(skb, IFLA_GROUP, dev->group) || 892 nla_put_u32(skb, IFLA_GROUP, dev->group) ||
906 nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) || 893 nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) ||
894 nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) ||
895#ifdef CONFIG_RPS
896 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
897#endif
907 (dev->ifindex != dev->iflink && 898 (dev->ifindex != dev->iflink &&
908 nla_put_u32(skb, IFLA_LINK, dev->iflink)) || 899 nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
909 (dev->master && 900 (dev->master &&
@@ -1121,6 +1112,8 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1121 [IFLA_AF_SPEC] = { .type = NLA_NESTED }, 1112 [IFLA_AF_SPEC] = { .type = NLA_NESTED },
1122 [IFLA_EXT_MASK] = { .type = NLA_U32 }, 1113 [IFLA_EXT_MASK] = { .type = NLA_U32 },
1123 [IFLA_PROMISCUITY] = { .type = NLA_U32 }, 1114 [IFLA_PROMISCUITY] = { .type = NLA_U32 },
1115 [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 },
1116 [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 },
1124}; 1117};
1125EXPORT_SYMBOL(ifla_policy); 1118EXPORT_SYMBOL(ifla_policy);
1126 1119
@@ -1639,17 +1632,22 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
1639{ 1632{
1640 int err; 1633 int err;
1641 struct net_device *dev; 1634 struct net_device *dev;
1642 unsigned int num_queues = 1; 1635 unsigned int num_tx_queues = 1;
1636 unsigned int num_rx_queues = 1;
1643 1637
1644 if (ops->get_tx_queues) { 1638 if (tb[IFLA_NUM_TX_QUEUES])
1645 err = ops->get_tx_queues(src_net, tb); 1639 num_tx_queues = nla_get_u32(tb[IFLA_NUM_TX_QUEUES]);
1646 if (err < 0) 1640 else if (ops->get_num_tx_queues)
1647 goto err; 1641 num_tx_queues = ops->get_num_tx_queues();
1648 num_queues = err; 1642
1649 } 1643 if (tb[IFLA_NUM_RX_QUEUES])
1644 num_rx_queues = nla_get_u32(tb[IFLA_NUM_RX_QUEUES]);
1645 else if (ops->get_num_rx_queues)
1646 num_rx_queues = ops->get_num_rx_queues();
1650 1647
1651 err = -ENOMEM; 1648 err = -ENOMEM;
1652 dev = alloc_netdev_mq(ops->priv_size, ifname, ops->setup, num_queues); 1649 dev = alloc_netdev_mqs(ops->priv_size, ifname, ops->setup,
1650 num_tx_queues, num_rx_queues);
1653 if (!dev) 1651 if (!dev)
1654 goto err; 1652 goto err;
1655 1653
@@ -2189,7 +2187,7 @@ skip:
2189} 2187}
2190 2188
2191/** 2189/**
2192 * ndo_dflt_fdb_dump: default netdevice operation to dump an FDB table. 2190 * ndo_dflt_fdb_dump - default netdevice operation to dump an FDB table.
2193 * @nlh: netlink message header 2191 * @nlh: netlink message header
2194 * @dev: netdevice 2192 * @dev: netdevice
2195 * 2193 *
@@ -2366,8 +2364,13 @@ static struct notifier_block rtnetlink_dev_notifier = {
2366static int __net_init rtnetlink_net_init(struct net *net) 2364static int __net_init rtnetlink_net_init(struct net *net)
2367{ 2365{
2368 struct sock *sk; 2366 struct sock *sk;
2369 sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, 2367 struct netlink_kernel_cfg cfg = {
2370 rtnetlink_rcv, &rtnl_mutex, THIS_MODULE); 2368 .groups = RTNLGRP_MAX,
2369 .input = rtnetlink_rcv,
2370 .cb_mutex = &rtnl_mutex,
2371 };
2372
2373 sk = netlink_kernel_create(net, NETLINK_ROUTE, THIS_MODULE, &cfg);
2371 if (!sk) 2374 if (!sk)
2372 return -ENOMEM; 2375 return -ENOMEM;
2373 net->rtnl = sk; 2376 net->rtnl = sk;