_goon
-_h "set SQM device (downstream)"
-ifb_dev=$(find /sys/devices/virtual/net/ -name ifb\* -print | head -n 1)
-if [ -e /sys/devices/virtual/net/ifb* ]
+_h "set SQM device (downstream/rx)"
+ifb_dev=$( (find /sys/devices/virtual/net/ -name ifb\* -print; echo sorry-no-dev-found) | head -n 1)
+if [ -e "${ifb_dev}" ]
then
- printf 'Likely network device auto-detected to apply traffic shaping to:\n\t%s\n\n' "${ifb_dev}" >&2
- printf 'Please confirm this by supplying either this device path,\nor a custom value to replace it:\n\t' >&2
+ printf 'Auto-detected downstream (rx) network device to adjust:\n\t%s\n\n' "${ifb_dev}" >&2
+ printf 'Please confirm this by supplying either this device path again,\nor a custom value to replace it:\n\t' >&2
read ifb_dev
else
printf 'FATAL: No SQM shaping network device could be determined.\nAre you sure SQM has been set up via luci-app-sqm?\n' >&2
if ! [ -f "${ifb_dev}"///statistics/tx_bytes ]
then
- printf 'FATAL: No SQM shaping network device could be identified at\n\t%s\n' "${ifb_dev}" >&2
+ printf 'FATAL: No SQM shaping network device could be identified at\n\t"%s"\n' "${ifb_dev}" >&2
exit 1
fi
stats_rx="${ifb_dev}"/statistics/tx_bytes
-iface_rx="${ifb_dev%%*/}"
+iface_rx="${ifb_dev##*/}"
+
+iface_tx="${iface_rx/ifb4/}"
+if [ -e /sys/class/net/"${iface_tx}" ]
+then
+ printf 'Auto-detected dependent upstream (tx) device:\n\t%s\n\n' "${iface_tx}" >&2
+ printf 'Please confirm this by supplying either this interface name again,\nor a custom value to replace it:\n\t' >&2
+else
+ printf 'Failed to auto-detect a suitable upstream/tx interface.\nPlease supply a valid sysfs device path to it.\n\t' >&2
+fi
+read iface_tx
+
+if ! [ -f /sys/class/net/"${iface_tx}"///statistics/rx_bytes ]
+then
+ printf 'FATAL: No suitable network device could be identified at\n\t"%s"\n' "/sys/class/net/${iface_tx}" >&2
+ exit 1
+fi
+stats_tx=/sys/class/net/"${iface_tx}"/statistics/rx_bytes
_goon
_h "set bandwidth limits"
if ! [ ${bw_down_min}0 -lt ${bw_down_max}0 ]
then
- printf 'FATAL: Maximum shaping bandwith must be greater than minimum.\n'
+ printf 'FATAL: Maximum shaping bandwith must be greater than the minimum.\n'
exit 1
fi
_goon
printf 'BW_MAX_RX="%d"\n' "${bw_down_max}" >> "${cfgo}"
printf 'STATS_RX="%s"\n' "${stats_rx}" >> "${cfgo}"
printf 'IFACE_RX="%s"\n' "${iface_rx##*/}" >> "${cfgo}"
+printf 'STATS_TX="%s"\n' "${stats_tx}" >> "${cfgo}"
+printf 'IFACE_TX="%s"\n' "${iface_tx##*/}" >> "${cfgo}"
printf 'OPTIMIZATION_PREFERENCE="%s"\n' "${bw_or_lat_bias}" >> "${cfgo}"
printf 'TREND_DECISION="%s"\n' "${relaxed_or_eager}" >> "${cfgo}"