1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
# apparently redundant "count" is not "optimized" away ------------------------
tcc -xif:err 2>&1 >/dev/null | grep -v '^#'
$p = police(rate 8kbps,burst 1000B);
prio {
class if count $p || 1;
}
EOF
block eth0 egress
bucket 1 = 1000 0 1000 1000 0
action 1 = class 1:1
action 0 = count 1 action 1
match action 0
# apparently redundant "count" is not "optimized" away by -B ------------------
tcc -xif:err -B 2>&1 >/dev/null | grep -v '^#'
$p = police(rate 8kbps,burst 1000B);
prio {
class if count $p || 1;
}
EOF
block eth0 egress
bucket 1 = 1000 0 1000 1000 0
action 0 = class 1:1
action 1 = count 1 action 0
match action 1
# tcc-ext-test detects empty bucket -------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed 's/^.* c .* returns //p;d'
dev eth 10000 {
$p = police(rate 8kbps,burst 1100B); /* allow for rounding errors */
prio {
class if raw[0] == 0 && count $p;
class if conform $p;
drop if 1;
}
}
send 0 0 x 999 /* bucket down to 100 */
send 1 0 x 999 /* packet is dropped */
EOF
OK (0) (1:1, 0x0)
SHOT (2)
# tcc-ext-test refills bucket on "conform" ------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed 's/^.* c .* returns //p;d'
dev eth 10000 {
$p = police(rate 8kbps,burst 1100B);
prio {
class if raw[0] == 0 && count $p;
class if conform $p;
drop if 1;
}
}
send 0 0 x 999 /* bucket down to 100 */
time 1.1s /* bucket fills up again (allow for some rounding errors) */
send 1 0 x 999 /* packet passes */
EOF
OK (0) (1:1, 0x0)
OK (0) (1:2, 0x0)
# tcc-ext-test refills bucket on "count" --------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed 's/^.* c .* returns //p;d'
dev eth 10000 {
$p = police(rate 8kbps,burst 1100B);
prio {
class if raw[0] == 0 && count $p;
class if conform $p;
drop if 1;
}
}
send 0 0 x 999 /* bucket down to 100 */
time 1.1s /* bucket fills up again (allow for some rounding errors) */
send 0 0 x 999 /* bucket down to 100 */
send 1 0 x 999 /* packet is dropped */
EOF
OK (0) (1:1, 0x0)
OK (0) (1:1, 0x0)
SHOT (2)
# tcm_cls.c detects empty bucket ----------------------------------------------
LD_LIBRARY_PATH=. tcsim -v -Xc,-tc | sed 's/^.* c .* returns //p;d'
dev eth 10000 {
$p = police(rate 8kbps,burst 1100B);
prio {
class if raw[0] == 0 && count $p;
class if conform $p;
drop if 1;
}
}
send 0 0 x 999 /* bucket down to 100 */
send 1 0 x 999 /* packet is dropped */
EOF
OK (0) (1:1, 0x1)
SHOT (2)
# tcm_cls.c refills bucket on "conform" ---------------------------------------
LD_LIBRARY_PATH=. tcsim -v -Xc,-tc | sed 's/^.* c .* returns //p;d'
dev eth 10000 {
$p = police(rate 8kbps,burst 1100B);
prio {
class if raw[0] == 0 && count $p;
class if conform $p;
drop if 1;
}
}
send 0 0 x 999 /* bucket down to 100 */
time 1.1s /* bucket fills up again */
send 1 0 x 999 /* packet passes */
EOF
OK (0) (1:1, 0x1)
OK (0) (1:2, 0x2)
# tcm_cls.c refills bucket on "count" -----------------------------------------
LD_LIBRARY_PATH=. tcsim -v -Xc,-tc | sed 's/^.* c .* returns //p;d'
dev eth 10000 {
$p = police(rate 8kbps,burst 1100B);
prio {
class if raw[0] == 0 && count $p;
class if conform $p;
drop if 1;
}
}
send 0 0 x 999 /* bucket down to 100 */
time 1.1s /* bucket fills up again */
send 0 0 x 999 /* bucket down to 100 */
send 1 0 x 999 /* packet is dropped */
EOF
OK (0) (1:1, 0x1)
OK (0) (1:1, 0x1)
SHOT (2)
|