Disable TCP Offloading in Xen and Persist after Boot

Have you ever wanted to disable offloading of all your Xen DomU's?  How about doing it without having to think about it? 

The future is now, and it means you can disable gso, ufo, tso, sg, tx, and rx offloading in one quick swoop with this simple script. 

(Note: YMMV, and this should be considered "use at your own risk" as I am not a trained professional programmer, and there potentially could be issues with the script.  This was run directly on XenServer 7.4.0 and hasn't been tested in other environments)

echo "This script is disabling gso, ufo, tso, sg, tx, and rx offloading in all Xen VMs"
for tbl in $(xe vif-list | awk '/uuid/{print$5}')
echo "Setting UUID: $tbl"
xe vif-param-set uuid=$tbl other-config:ethtool-gso="off";
xe vif-param-set uuid=$tbl other-config:ethtool-ufo="off";
xe vif-param-set uuid=$tbl other-config:ethtool-tso="off";
xe vif-param-set uuid=$tbl other-config:ethtool-sg="off";
xe vif-param-set uuid=$tbl other-config:ethtool-tx="off";
xe vif-param-set uuid=$tbl other-config:ethtool-rx="off";
echo "All systems updated.  Please note, if any changes were made, the VM will need to be power cycled in order for the changes to take effect.  Happy Fast Networking!"

Essentially, what this script does is utilizes the xe command to set the offloading of every VM (identified by uuid) at boot.  So when the DomU boots up, it reads the script as part of the creation of the DomU, and turns off the offloading for gso, ufo, tso, sg, tx, and rx if it's set to on.  The end result is faster networking, especially when you are placing the DomU's behind a virtualized firewall (think pfSense in a DomU routing all your traffic to the other DomU's).  With tx and rx offloading on, your network performance behind the firewall essentially drops to a crawl.  Disabling tx and rx offloading is the suggested method of increasing performance, as well as gso, ufo, tso, and sg offloading.  (source: https://support.citrix.com/article/CTX212540)

So if you have been plagued for months trying to figure out how to disable TCP Offloading in Xen without having to use ethtool every time you reboot, here you go! 

Wasn't that easy?  :)