2020-09-21 14:04:10 +00:00
|
|
|
#!/bin/sh
|
2020-09-21 14:36:34 +00:00
|
|
|
# gather params for a given prefix, based on executor-scripts/linux/tunnel.
|
|
|
|
gather_params() {
|
2020-09-22 23:24:56 +00:00
|
|
|
env | sed -E "
|
2020-09-21 14:36:34 +00:00
|
|
|
s/^IF_${1}_([A-Z0-9_]+)=(.+)/\1\n\2/
|
|
|
|
ta
|
|
|
|
d
|
|
|
|
:a
|
|
|
|
h
|
|
|
|
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
|
|
|
P
|
|
|
|
g
|
2020-09-21 15:38:39 +00:00
|
|
|
s/.*\n//" | sed -E "s/_/-/g"
|
2020-09-21 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 14:20:43 +00:00
|
|
|
case "$PHASE" in
|
|
|
|
pre-up)
|
2020-09-21 14:31:20 +00:00
|
|
|
settings="\
|
|
|
|
${IF_ETHTOOL_ETHERNET_PORT:+ port $IF_ETHTOOL_ETHERNET_PORT}
|
|
|
|
${IF_ETHTOOL_MSGLVL:+ msglvl $IF_ETHTOOL_MSGLVL}
|
|
|
|
"
|
|
|
|
[ -z "$settings" ] || $MOCK ethtool --change "$IFACE" $settings
|
2020-09-21 14:20:43 +00:00
|
|
|
;;
|
|
|
|
up)
|
2020-09-21 14:31:20 +00:00
|
|
|
# first do the link settings.
|
2020-09-21 15:08:17 +00:00
|
|
|
link_settings="${IF_ETHTOOL_LINK_SPEED:+ speed $IF_ETHTOOL_LINK_SPEED}${IF_ETHTOOL_LINK_DUPLEX:+ duplex $IF_ETHTOOL_LINK_DUPLEX}"
|
2020-09-21 14:31:20 +00:00
|
|
|
|
|
|
|
# ethernet-wol can have a second arg (key), split into $1 and $2
|
|
|
|
set -- $IF_ETHTOOL_ETHERNET_WOL
|
|
|
|
link_settings="$link_settings${1:+ wol $1}${2:+ sopass $2}"
|
|
|
|
|
|
|
|
# handle ethtool-ethernet-autoneg like Debian would
|
|
|
|
case "$IF_ETHTOOL_ETHERNET_AUTONEG" in
|
2020-09-21 15:08:17 +00:00
|
|
|
'')
|
|
|
|
;;
|
2020-09-21 14:31:20 +00:00
|
|
|
on|off)
|
|
|
|
link_settings="$link_settings autoneg $IF_ETHTOOL_ETHERNET_AUTONEG"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
link_settings="$link_settings autoneg on advertise $IF_ETHTOOL_ETHERNET_AUTONEG"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
[ -z "$link_settings" ] || $MOCK ethtool --change "$IFACE" $link_settings
|
|
|
|
|
2020-09-21 15:08:17 +00:00
|
|
|
pause_settings=$(gather_params ETHTOOL_PAUSE)
|
2020-09-21 14:36:34 +00:00
|
|
|
[ -z "$pause_settings" ] || $MOCK ethtool --pause "$IFACE" $pause_settings
|
|
|
|
|
2020-09-21 15:08:17 +00:00
|
|
|
offload_settings=$(gather_params ETHTOOL_OFFLOAD)
|
2020-09-21 14:36:34 +00:00
|
|
|
[ -z "$offload_settings" ] || $MOCK ethtool --offload "$IFACE" $offload_settings
|
2020-09-21 15:32:37 +00:00
|
|
|
|
|
|
|
dma_settings=$(gather_params ETHTOOL_DMA_RING)
|
|
|
|
[ -z "$dma_settings" ] || $MOCK ethtool --set-ring "$IFACE" $dma_settings
|
2020-09-21 16:06:58 +00:00
|
|
|
|
|
|
|
coalesce_settings=$(gather_params ETHTOOL_COALESCE)
|
|
|
|
[ -z "$coalesce_settings" ] || $MOCK ethtool --coalesce "$IFACE" $coalesce_settings
|
2020-09-21 14:20:43 +00:00
|
|
|
;;
|
|
|
|
esac
|