[ "$ACTION" = 'add' ] || exit 0

config_load simple-tc


tc_interface() {
	local iface="$1"

	config_get ifname "$iface" ifname

	[ "$INTERFACE" = "$ifname" ] || return

	config_get_bool enabled "$iface" enabled 0

	[ "$enabled" -eq 1 ] || return

	config_get limit_ingress "$iface" limit_ingress
	config_get limit_egress "$iface" limit_egress

	[ "$limit_ingress" ] || limit_ingress=-
	[ "$limit_egress" ] || limit_egress=-

	simple-tc "$INTERFACE" "$limit_ingress" "$limit_egress"
}

config_foreach tc_interface 'interface'
