50-gluon-simple-tc 737 B

123456789101112131415161718192021222324252627282930
  1. [ "$ACTION" = 'add' ] || exit 0
  2. config_load gluon-simple-tc
  3. tc_interface() {
  4. local iface="$1"
  5. config_get ifname "$iface" ifname
  6. [ "$INTERFACE" = "$ifname" ] || return
  7. config_get_bool enabled "$iface" enabled 0
  8. [ "$enabled" -eq 1 ] || return
  9. config_get limit_egress "$iface" limit_egress
  10. config_get limit_ingress "$iface" limit_ingress
  11. if [ "$limit_egress" ]; then
  12. tc qdisc add dev "$INTERFACE" root tbf rate "${limit_egress}kbit" latency 50ms burst 2k
  13. fi
  14. if [ "$limit_ingress" ]; then
  15. tc qdisc add dev "$INTERFACE" handle ffff: ingress
  16. tc filter add dev "$INTERFACE" parent ffff: u32 match u8 00 00 at 0 police rate "${limit_ingress}kbit" burst 10k drop flowid :1
  17. fi
  18. }
  19. config_foreach tc_interface 'interface'