SQM - per-host isolation

This second helper setup is redirecting to the wrong path (iface vs net). :slight_smile:

Edit: now fixed.

Question: do you run pppoe directly on an VLAN-free interface, like eth0 or are you using a VLAN tag, e.g. eth0.42?

Straight on eth1, no vlans.

So here is my ugly beyond all believe work-around for what on my system was a lack if iface hotplug events for pppoe-wan, I use this as /etc/hotplug.d/net/40-iface-synthesizer :

#! /bin/sh

# 20210803 since 0725 TOS fails to call the hotplug.d/iface scripts causing issues with among other's sqm, ddns and firewall
# so here we try to synthesize the relevant information and manually call those scripts as a stop-gap measure
# Here are examples of hotplug.g/net events and their information
#Aug  2 23:23:36 turris hotplug_net_logger: USER=root ACTION=remove SHLVL=1 HOME=/ SEQNUM=1477 IFINDEX=32 HOTPLUG_TYPE=net DEVPATH=/d
#evices/virtual/net/pppoe-wan mangled_fs=btrfs LOGNAME=root DEVICENAME=pppoe-wan TERM=linux SUBSYSTEM=net PATH=/usr/sbin:/usr/bin:/sb
#in:/bin INTERFACE=pppoe-wan PWD=/ DEVTYPE=ppp 
#
#Aug  2 23:23:46 turris hotplug_net_logger: USER=root ACTION=add SHLVL=1 HOME=/ SEQNUM=1478 IFINDEX=37 HOTPLUG_TYPE=net DEVPATH=/devi
#ces/virtual/net/ppp0 mangled_fs=btrfs LOGNAME=root DEVICENAME=ppp0 TERM=linux SUBSYSTEM=net PATH=/usr/sbin:/usr/bin:/sbin:/bin INTER
#FACE=ppp0 PWD=/ DEVTYPE=ppp  
#                                                                                                       
#Aug  2 23:23:46 turris hotplug_net_logger: USER=root ACTION=move SHLVL=1 HOME=/ SEQNUM=1481 IFINDEX=37 HOTPLUG_TYPE=net DEVPATH=/dev
#ices/virtual/net/pppoe-wan mangled_fs=btrfs LOGNAME=root DEVICENAME=pppoe-wan TERM=linux SUBSYSTEM=net DEVPATH_OLD=/devices/virtual/
#net/ppp0 PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=pppoe-wan PWD=/ DEVTYPE=ppp        

# here are the variables passed to / expected by iface scripts
#ACTION	“ifup”, “ifdown”, “ifupdate”
#INTERFACE	Name of the logical interface which went up or down (e.g. “wan” or “ppp0”)
#DEVICE	Physical device name which interface went up or down (e.g. “eth0.1” or “br-lan”)
#IFUPDATE_ADDRESSES	“1” if address changed
#IFUPDATE_PREFIXES	“1” if prefix updated FIXME what constitutes an update?


VERBOSE=0


[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "Running 40-iface-synthesizer"
[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer $(env)

# 1) generate the required action name
NET_ACTION="$ACTION"
case "$NET_ACTION" in
    remove)
	IFACE_ACTION="ifdown"
    ;;
    add|move)
	IFACE_ACTION="ifup"
    ;;
    *)
	# log the environment variable to help figuring out what went wrong
	logger -t hotplug_synthesizer "ERROR: Unhandled ACTION ($ACTION) encoutered."
	logger -t hotplug_synthesizer $(env)
	exit 0
    ;;
esac
[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "NET_ACTION: $NET_ACTION; IFACE_ACTION: $IFACE_ACTION"




# 2) assign the INTERFACE
NET_INTERFACE="$INTERFACE"
IFACE_INTERFACE="$NET_INTERFACE"
[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "NET_INTERFACE: $NET_INTERFACE; IFACE_INTERFACE: $IFACE_INTERFACE"


# 3) get the DEVICE
NET_DEVICE="$DEVICE"
case "$NET_INTERFACE" in
    TMP_IFB_4_SQM)
	# this gets created a lot during SQM scipts execution so silence this
	exit 0
    ;;
    eth*)
	NET_DEVICE=$NET_INTERFACE
    ;;
    pppoe-wan)
	# this needs to get automatically extracted
	NET_DEVICE="eth2"
    ;;
    *)
	logger -t hotplug_synthesizer "ERROR: Unhandled INTERFACE ($NET_INTERFACE) for DEVICE extraction encountered."
	logger -t hotplug_synthesizer $(env)
	exit 0
    ;;
esac
IFACE_DEVICE="$NET_DEVICE"
[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "NET_DEVICE: $NET_DEVICE; IFACE_DEVICE: $IFACE_DEVICE"



# 4) deal with IFUPDATE_ADDRESSES
NET_IFUPDATE_ADDRESSES="1"
IFACE_IFUPDATE_ADDRESSES="$NET_IFUPDATE_ADDRESSES"
[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "NET_IFUPDATE_ADDRESSES: $NET_IFUPDATE_ADDRESSES; IFACE_IFUPDATE_ADDRESSES: $IFACE_IFUPDATE_ADDRESSES"


# 5) deal with IFUPDATE_PREFIXES
NET_IFUPDATE_PREFIXES="1"
IFACE_IFUPDATE_PREFIXES="$NET_IFUPDATE_PREFIXES"
[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "NET_IFUPDATE_PREFIXES: $NET_IFUPDATE_PREFIXES; IFACE_IFUPDATE_PREFIXES: $IFACE_IFUPDATE_PREFIXES"


[ "$VERBOSE" = "1" ] && logger -t hotplug_synthesizer "ACTION=$IFACE_ACTION INTERFACE=$IFACE_INTERFACE DEVICE=$IFACE_DEVICE IFUPDATE_ADDRESSES=$IFACE_IFUPDATE_ADDRESSES IFUPDATE_PREFIXES=$IFACE_IFUPDATE_PREFIXES $IFACE_SCRIPT"

# 6) find all scripts in /etc/hotplug.d/iface and call them with appropirate environment variables
for IFACE_SCRIPT in /etc/hotplug.d/iface/*; do
    logger -t hotplug_synthesizer "Calling $IFACE_SCRIPT"
    logger -t hotplug_synthesizer "ACTION=$IFACE_ACTION INTERFACE=$IFACE_INTERFACE DEVICE=$IFACE_DEVICE IFUPDATE_ADDRESSES=$IFACE_IFUPDATE_ADDRESSES IFUPDATE_PREFIXES=$IFACE_IFUPDATE_PREFIXES $IFACE_SCRIPT"
    ACTION=$IFACE_ACTION INTERFACE=$IFACE_INTERFACE DEVICE=$IFACE_DEVICE IFUPDATE_ADDRESSES=$IFACE_IFUPDATE_ADDRESSES IFUPDATE_PREFIXES=$IFACE_IFUPDATE_PREFIXES $IFACE_SCRIPT
done

You would likely need to change:

    pppoe-wan)
	# this needs to get automatically extracted
	NET_DEVICE="eth2"

to:

    pppoe-wan)
	# this needs to get automatically extracted
	NET_DEVICE="eth1"

it would be interesting if you could test that, the questions are:
a) does this solve the sqm hotplug issue
b) does it also solve the software flow offloading issue (so will pppoe-wan appear in the flowtable's device list)

This, to be explicit is not a real solution (in spite of me at home running this for years, in my defense I always thought this to be a specific quirk of turrisOS* and was ignoring that it might affect main-line as well). But this might tell us whether we are dealing with a general hotplug issue.
Another indicator would be if logread | grep -e hotplug_iface_logger shortly after e.g. un- and replugging the ethernet cable on eth1 returns nothing, while logread | grep -e hotplug_net_logger returns something...

*) turrisOS, unfortunately typically lags behind mainline 1 or more versions and currently is based still on OpenWrt-24, so it is not feature or bug identical to mainline OpenWrt.