You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.4 KiB

  1. #!/bin/sh
  2. ################################################################################
  3. # test_LAN_triple-isolate__piece_of_cake.qos (Cero3 Shaper)
  4. #
  5. # Abstract:
  6. # This is a one band cake and ipv6 enabled shaping script for Ethernet
  7. # gateways. This exists for the purpose of testing cake's different isolation
  8. # options, specifically the non-directional triple-isolate feature that promises
  9. # to finally tackle the bit-torrent hole in simple.qos.
  10. # This specific version is supposed to be used on LAN interfaces:
  11. # the script's ingress direction equals the internet/WAN upload direction
  12. # the script's egress direction equals the internet/WAN download direction
  13. #
  14. # NOTE: Shaping on a LAN interface only affects machines connected via that
  15. # LAN interface, so typically WIFI/WLAN traffic will not be shaped!
  16. #
  17. ################################################################################
  18. #
  19. # This program is free software; you can redistribute it and/or modify
  20. # it under the terms of the GNU General Public License version 2 as
  21. # published by the Free Software Foundation.
  22. #
  23. # Copyright (C) 2012-2016
  24. # Michael D. Taht, Toke Høiland-Jørgensen, Sebastian Moeller
  25. #
  26. ################################################################################
  27. . ${SQM_LIB_DIR}/defaults.sh
  28. ################################################################################
  29. # this will only work with cake as qdisc...
  30. QDISC=cake
  31. # to keep this as simple as possible we ignore the *_CAKE_OPTS from defaults.sh
  32. INGRESS_CAKE_OPTS="besteffort triple-isolate"
  33. EGRESS_CAKE_OPTS="besteffort triple-isolate"
  34. egress() {
  35. sqm_debug "egress"
  36. $TC qdisc del dev $IFACE root 2>/dev/null
  37. $TC qdisc add dev $IFACE root $( get_stab_string ) cake bandwidth ${UPLINK}kbit $( get_cake_lla_string ) ${EGRESS_CAKE_OPTS} ${EQDISC_OPTS}
  38. }
  39. ingress() {
  40. sqm_debug "ingress"
  41. $TC qdisc del dev $IFACE handle ffff: ingress 2>/dev/null
  42. $TC qdisc add dev $IFACE handle ffff: ingress
  43. $TC qdisc del dev $DEV root 2>/dev/null
  44. $TC qdisc add dev $DEV root $( get_stab_string ) cake bandwidth ${DOWNLINK}kbit $( get_cake_lla_string ) ${INGRESS_CAKE_OPTS} ${IQDISC_OPTS}
  45. $IP link set dev $DEV up
  46. # redirect all IP packets arriving in $IFACE to ifb0
  47. $TC filter add dev $IFACE parent ffff: protocol all prio 10 u32 \
  48. match u32 0 0 flowid 1:1 action mirred egress redirect dev $DEV
  49. }
  50. sqm_start() {
  51. #sm: flip upload and download bandwith so that the GUI values reflect directionality in regard to the ISP
  52. #sm: NOTE this is ugly and should be performed in defaults.sh or functions.sh if at all
  53. #sm: but for quick and dirty testing this should do
  54. local ORIG_UPLINK=${UPLINK}
  55. local ORIG_DOWNLINK=${DOWNLINK}
  56. UPLINK=${ORIG_DOWNLINK}
  57. DOWNLINK=${ORIG_UPLINK}
  58. [ -n "$IFACE" ] || return 1
  59. do_modules
  60. verify_qdisc $QDISC "cake" || return 1
  61. sqm_debug "Starting ${SCRIPT}"
  62. [ -z "$DEV" ] && DEV=$( get_ifb_for_if ${IFACE} )
  63. if [ "${UPLINK}" -ne 0 ];
  64. then
  65. egress
  66. sqm_debug "egress shaping activated"
  67. else
  68. sqm_debug "egress shaping deactivated"
  69. $TC qdisc del dev ${IFACE} root 2> /dev/null
  70. fi
  71. if [ "${DOWNLINK}" -ne 0 ];
  72. then
  73. verify_qdisc ingress "ingress" || return 1
  74. ingress
  75. sqm_debug "ingress shaping activated"
  76. else
  77. sqm_debug "ingress shaping deactivated"
  78. $TC qdisc del dev ${DEV} root 2> /dev/null
  79. $TC qdisc del dev ${IFACE} ingress 2> /dev/null
  80. fi
  81. return 0
  82. }