Persistent txqueuelen network parameter using udev

txqueuelen is one of many configurable networking parameters. This paremeter defines the queue size in which the kernel stores data before it is sent over the network. By default this parameter has a value of 1000 - depending on your application you might want to increase this value using ifconfig or ip:

1# ifconfig eth0 txqueuelen 5000
2# ip link set eth0 txqueuelen 5000

This is no smart solution because this command has to be entered again after each reboot or network restart. Of course you could also insert the command into the /etc/rc.local script - but there is a much nicer way to get it working.. ๐Ÿ™‚

According to a bugfix report there should be a variable for Red Hat Enterprise Linux or CentOS which can be used in the network interface configuration file for setting parameters. This isn't working under RHEL5 and 6 for me:

1# vi /etc/sysconfig/network-scripts/ifcfg-eth0
2...
3IFCONFIG_OPTS="txqueuelen 5000"
4
5ESC ZZ
6
7# ifdown eth0; ifup eth0
8# ifconfig eth0|grep txqueuelen
9          collisions:0 txqueuelen:1000

You can implement this very comfortable using udev: simply create a small rule under /etc/udev/rules.d/60-custom-txqueuelen.rules - this rule runs the above-named ifconfig command after the network interface is recognized:

 1#
 2# custom txqueuelen parameter value
 3#
 4# Sets a custom txqueuelen parameter value for network interfaces.
 5# This variable sets the length of the transmit queue of a device.
 6# The default value is 1000 - depending on your application setup you
 7# might want to increase this value (e.g. 5000)
 8#
 9
10KERNEL=="eth[0,1]", RUN+="/sbin/ifconfig %k txqueuelen 5000"
11#KERNEL=="eth[0-9]", RUN+="/sbin/ifconfig %k txqueuelen 5000"

You could also use the ip command instead - ifconfig is well-known obsolete:

1...
2KERNEL=="eth[0,1]", RUN+="/sbin/ip link set %k txqueuelen 5000"
3#KERNEL=="eth[0-9]", RUN+="/sbin/ip link set %k txqueuelen 5000"

Run one of the following commands to apply the changes:

1# udevtrigger
2# /sbin/udevadm trigger

The value has been changed:

1# ifconfig eth0|grep txqueuelen
2          collisions:0 txqueuelen:5000
3# ifconfig eth1|grep txqueuelen
4          collisions:0 txqueuelen:5000

๐Ÿ™‚

Translations: