htb_0.8.5_ipv6.diff 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. --- htb.init.old 2004-01-29 22:41:23.000000000 +0100
  2. +++ htb.init 2006-09-07 23:32:58.000000000 +0200
  3. @@ -275,6 +284,7 @@
  4. ### Filtering parameters
  5. #
  6. # RULE=[[saddr[/prefix]][:port[/mask]],][daddr[/prefix]][:port[/mask]]
  7. +# RULEIPv6=[[saddr[/prefix]][_port[/mask]],][daddr[/prefix]][_port[/mask]]
  8. #
  9. # These parameters make up "u32" filter rules that select traffic for
  10. # each of the classes. You can use multiple RULE fields per config.
  11. @@ -300,9 +310,13 @@
  12. # RULE=10.5.5.5:80,
  13. # selects traffic going from port 80 of single host 10.5.5.5
  14. #
  15. +# RULEIPv6=3ffe:80fe:c28:1:45d1:3a1:5e2b:e6c8
  16. +# selects traffic going to IPv6 host 3ffe:80fe:c28:1:45d1:3a1:5e2b:e6c8
  17. +#
  18. #
  19. #
  20. # REALM=[srealm,][drealm]
  21. +# REALMIPv6=[srealm,][drealm]
  22. #
  23. # These parameters make up "route" filter rules that classify traffic
  24. # according to packet source/destination realms. For information about
  25. @@ -327,6 +341,7 @@
  26. #
  27. #
  28. # MARK=<mark>
  29. +# MARKIPv6=<mark>
  30. #
  31. # These parameters make up "fw" filter rules that select traffic for
  32. # each of the classes accoring to firewall "mark". Mark is a decimal
  33. @@ -414,6 +429,9 @@
  34. PRIO_RULE_DEFAULT=${PRIO_RULE:-100}
  35. PRIO_MARK_DEFAULT=${PRIO_MARK:-200}
  36. PRIO_REALM_DEFAULT=${PRIO_REALM:-300}
  37. +PRIO_RULEIPv6=${PRIO_RULEIPv6:-150}
  38. +PRIO_MARKIPv6=${PRIO_MARKIPv6:-250}
  39. +PRIO_REALMIPv6=${PRIO_REALMIPv6:-350}
  40. ### Default HTB_PATH & HTB_CACHE settings
  41. HTB_PATH=${HTB_PATH:-/etc/sysconfig/htb}
  42. @@ -818,6 +838,13 @@
  43. prio $PRIO_MARK handle $mark fw classid 1:$CLASS
  44. done ### mark
  45. + ### Create fw filter for MARKIPv6 fields
  46. + for mark in `htb_cfile_rules MARKIPv6`; do
  47. + ### Attach fw filter to root class
  48. + tc filter add dev $DEVICE parent 1:0 protocol ipv6 \
  49. + prio $PRIO_MARKIPv6 handle $mark fw classid 1:$CLASS
  50. + done ### markipv6
  51. +
  52. ### Create route filter for REALM fields
  53. for realm in `htb_cfile_rules REALM`; do
  54. ### Split realm into source & destination realms
  55. @@ -833,6 +860,21 @@
  56. ${DREALM:+to $DREALM} classid 1:$CLASS
  57. done ### realm
  58. + ### Create route filter for REALMIPv6 fields
  59. + for realm in `htb_cfile_rules REALMIPv6`; do
  60. + ### Split realm into source & destination realms
  61. + SREALM=${realm%%,*}; DREALM=${realm##*,}
  62. + [ "$SREALM" = "$DREALM" ] && SREALM=""
  63. +
  64. + ### Convert asterisks to empty strings
  65. + SREALM=${SREALM#\*}; DREALM=${DREALM#\*}
  66. +
  67. + ### Attach route filter to the root class
  68. + tc filter add dev $DEVICE parent 1:0 protocol ipv6 \
  69. + prio $PRIO_REALM route ${SREALM:+from $SREALM} \
  70. + ${DREALM:+to $DREALM} classid 1:$CLASS
  71. + done ### realmipv6
  72. +
  73. ### Create u32 filter for RULE fields
  74. for rule in `htb_cfile_rules RULE`; do
  75. ### Split rule into source & destination
  76. @@ -876,6 +918,49 @@
  77. prio $PRIO_RULE u32 $u32_s $u32_d classid 1:$CLASS
  78. done ### rule
  79. + ### Create u32 filter for RULEIPv6 fields
  80. + for rule in `htb_cfile_rules RULEIPv6`; do
  81. + ### Split rule into source & destination
  82. + SRC=${rule%%,*}; DST=${rule##*,}
  83. + [ "$SRC" = "$rule" ] && SRC=""
  84. +
  85. +
  86. + ### Split destination into address, port & mask fields
  87. + DADDR=${DST%%_*}; DTEMP=${DST##*_}
  88. + [ "$DADDR" = "$DST" ] && DTEMP=""
  89. +
  90. + DPORT=${DTEMP%%/*}; DMASK=${DTEMP##*/}
  91. + [ "$DPORT" = "$DTEMP" ] && DMASK="0xffff"
  92. +
  93. +
  94. + ### Split up source (if specified)
  95. + SADDR=""; SPORT=""
  96. + if [ -n "$SRC" ]; then
  97. + SADDR=${SRC%%_*}; STEMP=${SRC##*_}
  98. + [ "$SADDR" = "$SRC" ] && STEMP=""
  99. +
  100. + SPORT=${STEMP%%/*}; SMASK=${STEMP##*/}
  101. + [ "$SPORT" = "$STEMP" ] && SMASK="0xffff"
  102. + fi
  103. +
  104. +
  105. + ### Convert asterisks to empty strings
  106. + SADDR=${SADDR#\*}; DADDR=${DADDR#\*}
  107. +
  108. + ### Compose u32 filter rules
  109. + u32_s="${SPORT:+match ip6 sport $SPORT $SMASK}"
  110. + u32_s="${SADDR:+match ip6 src $SADDR} $u32_s"
  111. + u32_d="${DPORT:+match ip6 dport $DPORT $DMASK}"
  112. + u32_d="${DADDR:+match ip6 dst $DADDR} $u32_d"
  113. +
  114. + ### Uncomment the following if you want to see parsed rules
  115. + #echo "$rule: $u32_s $u32_d"
  116. +
  117. + ### Attach u32 filter to the appropriate class
  118. + tc filter add dev $DEVICE parent 1:0 protocol ipv6 \
  119. + prio $PRIO_RULEIPv6 u32 $u32_s $u32_d classid 1:$CLASS
  120. + done ### ruleipv6
  121. +
  122. [ "$1" = "compile" ] && echo
  123. done ### classfile
  124. ;;