]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net: introduce NETDEV_CHANGE_TX_QUEUE_LEN
authorJason Wang <jasowang@redhat.com>
Thu, 30 Jun 2016 06:45:35 +0000 (14:45 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Jul 2016 09:32:17 +0000 (05:32 -0400)
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>
include/linux/netdevice.h
net/core/net-sysfs.c
net/core/rtnetlink.c

index e84d9d23c2d517568eaed025ff9f8438b528f2c0..7dc2ec74122aba85b8288033a3d22f2a38c04413 100644 (file)
@@ -2237,6 +2237,7 @@ struct netdev_lag_lower_state_info {
 #define NETDEV_PRECHANGEUPPER  0x001A
 #define NETDEV_CHANGELOWERSTATE        0x001B
 #define NETDEV_UDP_TUNNEL_PUSH_INFO    0x001C
+#define NETDEV_CHANGE_TX_QUEUE_LEN     0x001E
 
 int register_netdevice_notifier(struct notifier_block *nb);
 int unregister_netdevice_notifier(struct notifier_block *nb);
index 7a0b616557abb6570dbc86a0a7cf04a50a83214b..6e4f3472108015f0fbd7ac6f3dfe7e74a019e8be 100644 (file)
@@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
 
 static int change_tx_queue_len(struct net_device *dev, unsigned long new_len)
 {
-       dev->tx_queue_len = new_len;
+       int res, orig_len = dev->tx_queue_len;
+
+       if (new_len != orig_len) {
+               dev->tx_queue_len = new_len;
+               res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
+               res = notifier_to_errno(res);
+               if (res) {
+                       netdev_err(dev,
+                                  "refused to change device tx_queue_len\n");
+                       dev->tx_queue_len = orig_len;
+                       return -EFAULT;
+               }
+       }
+
        return 0;
 }
 
index cfed7bc14ee6d93a97fc0eb9b0bc896044671cb1..a9e3805af739c9b8d87fba66ed305fa00ced4e65 100644 (file)
@@ -1927,11 +1927,19 @@ static int do_setlink(const struct sk_buff *skb,
 
        if (tb[IFLA_TXQLEN]) {
                unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);
-
-               if (dev->tx_queue_len ^ value)
+               unsigned long orig_len = dev->tx_queue_len;
+
+               if (dev->tx_queue_len ^ value) {
+                       dev->tx_queue_len = value;
+                       err = call_netdevice_notifiers(
+                             NETDEV_CHANGE_TX_QUEUE_LEN, dev);
+                       err = notifier_to_errno(err);
+                       if (err) {
+                               dev->tx_queue_len = orig_len;
+                               goto errout;
+                       }
                        status |= DO_SETLINK_NOTIFY;
-
-               dev->tx_queue_len = value;
+               }
        }
 
        if (tb[IFLA_OPERSTATE])