#!/bin/sh
# Disable flow control. For more info, see
# https://help.ubuntu.com/community/UbuntuLTSP/FlowControl

PATH=/sbin:/bin:/usr/sbin:/usr/bin

# Don't do anything for the lo interface
test "$IFACE" != lo || exit 0

# Only run from ifup
test "$MODE" = start || exit 0

# Only care about inet, inet6 and NetworkManager
case "$ADDRFAM" in
    inet|inet6|NetworkManager)
        ;;
    *)
        exit 0
esac

if [ -x /usr/bin/logger ]; then
    logger=logger
else
    logger=true
fi

# Is /usr mounted and ethtool there?
if [ -x /usr/sbin/ethtool ]; then
    if ethtool --pause $IFACE autoneg off rx off >/dev/null 2>&1; then
        $logger -t sch-scripts -p syslog.info "Successfully disabled flow control for interface $IFACE"
    else
        $logger -t sch-scripts -p syslog.info "Didn't disable flow control for interface $IFACE"
    fi
fi
