Managing NIC ring buffer sizes with ethtool is simple, for example:

ethtool -G eth0 rx 4096 tx 4096

(Or replace eth0 with whatever interface you need to manage.)

Doing this live is easy.

Trouble is, when you do this on each slave interface that's part of a bonded interface, you mess up the bond. (The aggregator IDs will in many cases not match up afterwards the way they do before.) EDIT: I have learned this is not expected behavior. (I may update when I learn more regarding why it happened in the case I observed.)

In RHEL 7, you can set the ring buffer size to come up at boot time by setting the ETHTOOL_OPTS value in /etc/sysconfig/network-scripts/ifcfg-eth0 to (for example) ETHTOOL_OPTS="-G ${DEVICE} rx 4096 tx 4096" (as per the access Red Hat article). (Caveat: I have not tested that this actually avoids the aggregator ID mismatch mentioned above.)

However, for Ubuntu 18.04, there is no such obvious easy place to look.

I've delved through netplan documentation, systemd network documentation, and networkd-dispatcher.

A colleague of mine came up with a solution using networkd-dispatcher that seems to work, but it's not clear whether there might still be race conditions involved such that it only happens to work, rather than being guaranteed to set the ring buffer sizes before the interface bond is set up. I'll post this below (later on), but I don't know if it is THE correct answer. (Also, it's not mentioned in any systemd documentation.)

So the question is:

What is the systemd native way to manage ring buffer sizes for ethernet interfaces at boot-up time before those interfaces are bonded?


The systemd native way to set parameters is with a .link file (see the systemd.link manpage, however it currently doesn't have a way to set the ring buffer parameters. So AFAIK there isn't a native systemd way to do this. This will change when a new systemd with Wildcard's feature request is released with RxBufferSize and TxBufferSize options.

If you're actually using /etc/network/interfaces to configure, then just use a pre-up command there. This would be my preference instead of bothering with systemd-networkd.

You could set up some udev rules to match the device when it appears, and run ethtool there. This should run before systemd is informed about the device (and this before it does anything with it).

You could set up a systemd service (type oneshot, just exec ethtool) to run before whichever service sets up your bond device and after the device shows up, and use that. systemd makes .device units for Ethernet devices; use systemctl list-units | grep sys-subsystem-net to find the right one (so you can have your service be Wants/After it).

  • Thanks, I've opened a feature request upstream for systemd to make this possible in future versions: github.com/systemd/systemd/issues/13601 – Wildcard Sep 19 '19 at 19:34
  • Unfortunately, we're not using /etc/network/interfaces - it's Ubuntu 18, so we're using netplan, which doesn't support pre-up hooks. There is a related question over at AskUbuntu: askubuntu.com/q/1175333/457111 – Wildcard Sep 19 '19 at 19:35
  • When you say a udev rule "should run before systemd is informed about the device" — do you mean that's how it should work with no special attention, or that I should do something to configure it so it will work that way? (I haven't used udev before, so a link to the documentation would be very helpful.) – Wildcard Sep 19 '19 at 19:36
  • 1
    @Wildcard I mean it should work that way with no special attention. I said "should" just because I haven't actually tested it. – derobert Sep 19 '19 at 20:00
  • 2
    Incidentally, my systemd feature request was accepted and implemented. :) – Wildcard Sep 25 '19 at 1:01

Here is a udev rule that works on Ubuntu 18:

ACTION=="add|change", SUBSYSTEM=="net", KERNEL=="eth*|en*", RUN+="/sbin/ethtool -G $name rx 4096 tx 4096"

Put this in /etc/udev/rules.d/59-net.ring.rules and it takes effect early in the boot process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.