diff options
author | Jason Wang <jasowang@redhat.com> | 2016-06-30 02:45:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-07-01 05:32:17 -0400 |
commit | 08294a26e15d7baf1e14ee569e9f2bc82a7ae768 (patch) | |
tree | f64f414e88d4352b4f20f4db869848caa4144c62 /net/core | |
parent | bf900b3dbefee49855c17aa09fb4245346a78fb3 (diff) |
net: introduce NETDEV_CHANGE_TX_QUEUE_LEN
This patch introduces a new event - NETDEV_CHANGE_TX_QUEUE_LEN, this
will be triggered when tx_queue_len. It could be used by net device
who want to do some processing at that time. An example is tun who may
want to resize tx array when tx_queue_len is changed.
Cc: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/net-sysfs.c | 15 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 16 |
2 files changed, 26 insertions, 5 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 7a0b616557ab..6e4f34721080 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex); | |||
322 | 322 | ||
323 | static int change_tx_queue_len(struct net_device *dev, unsigned long new_len) | 323 | static int change_tx_queue_len(struct net_device *dev, unsigned long new_len) |
324 | { | 324 | { |
325 | dev->tx_queue_len = new_len; | 325 | int res, orig_len = dev->tx_queue_len; |
326 | |||
327 | if (new_len != orig_len) { | ||
328 | dev->tx_queue_len = new_len; | ||
329 | res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev); | ||
330 | res = notifier_to_errno(res); | ||
331 | if (res) { | ||
332 | netdev_err(dev, | ||
333 | "refused to change device tx_queue_len\n"); | ||
334 | dev->tx_queue_len = orig_len; | ||
335 | return -EFAULT; | ||
336 | } | ||
337 | } | ||
338 | |||
326 | return 0; | 339 | return 0; |
327 | } | 340 | } |
328 | 341 | ||
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index cfed7bc14ee6..a9e3805af739 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1927,11 +1927,19 @@ static int do_setlink(const struct sk_buff *skb, | |||
1927 | 1927 | ||
1928 | if (tb[IFLA_TXQLEN]) { | 1928 | if (tb[IFLA_TXQLEN]) { |
1929 | unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]); | 1929 | unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]); |
1930 | 1930 | unsigned long orig_len = dev->tx_queue_len; | |
1931 | if (dev->tx_queue_len ^ value) | 1931 | |
1932 | if (dev->tx_queue_len ^ value) { | ||
1933 | dev->tx_queue_len = value; | ||
1934 | err = call_netdevice_notifiers( | ||
1935 | NETDEV_CHANGE_TX_QUEUE_LEN, dev); | ||
1936 | err = notifier_to_errno(err); | ||
1937 | if (err) { | ||
1938 | dev->tx_queue_len = orig_len; | ||
1939 | goto errout; | ||
1940 | } | ||
1932 | status |= DO_SETLINK_NOTIFY; | 1941 | status |= DO_SETLINK_NOTIFY; |
1933 | 1942 | } | |
1934 | dev->tx_queue_len = value; | ||
1935 | } | 1943 | } |
1936 | 1944 | ||
1937 | if (tb[IFLA_OPERSTATE]) | 1945 | if (tb[IFLA_OPERSTATE]) |