aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/gen_estimator.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-11-25 21:14:06 -0800
committerDavid S. Miller <davem@davemloft.net>2008-11-25 21:14:06 -0800
commitc1b56878fb68e9c14070939ea4537ad4db79ffae (patch)
tree589f890f81e075380493905509244a0970d942f8 /net/core/gen_estimator.c
parent71bcb09a57894fa35591ce93dd972065eeecb63a (diff)
downloadkernel_samsung_smdk4412-c1b56878fb68e9c14070939ea4537ad4db79ffae.zip
kernel_samsung_smdk4412-c1b56878fb68e9c14070939ea4537ad4db79ffae.tar.gz
kernel_samsung_smdk4412-c1b56878fb68e9c14070939ea4537ad4db79ffae.tar.bz2
tc: policing requires a rate estimator
Found that while trying average rate policing, it was possible to request average rate policing without a rate estimator. This results in no policing which is harmless but incorrect. Since policing could be setup in two steps, need to check in the kernel. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/gen_estimator.c')
-rw-r--r--net/core/gen_estimator.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index 80aa160..3885550 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -242,6 +242,7 @@ int gen_new_estimator(struct gnet_stats_basic *bstats,
return 0;
}
+EXPORT_SYMBOL(gen_new_estimator);
static void __gen_kill_estimator(struct rcu_head *head)
{
@@ -275,6 +276,7 @@ void gen_kill_estimator(struct gnet_stats_basic *bstats,
call_rcu(&e->e_rcu, __gen_kill_estimator);
}
}
+EXPORT_SYMBOL(gen_kill_estimator);
/**
* gen_replace_estimator - replace rate estimator configuration
@@ -295,8 +297,30 @@ int gen_replace_estimator(struct gnet_stats_basic *bstats,
gen_kill_estimator(bstats, rate_est);
return gen_new_estimator(bstats, rate_est, stats_lock, opt);
}
+EXPORT_SYMBOL(gen_replace_estimator);
+
+/**
+ * gen_estimator_active - test if estimator is currently in use
+ * @rate_est: rate estimator statistics
+ *
+ * Returns 1 if estimator is active, and 0 if not.
+ */
+int gen_estimator_active(const struct gnet_stats_rate_est *rate_est)
+{
+ int idx;
+ struct gen_estimator *e;
+ ASSERT_RTNL();
-EXPORT_SYMBOL(gen_kill_estimator);
-EXPORT_SYMBOL(gen_new_estimator);
-EXPORT_SYMBOL(gen_replace_estimator);
+ for (idx=0; idx <= EST_MAX_INTERVAL; idx++) {
+ if (!elist[idx].timer.function)
+ continue;
+
+ list_for_each_entry(e, &elist[idx].list, list) {
+ if (e->rate_est == rate_est)
+ return 1;
+ }
+ }
+ return 0;
+}
+EXPORT_SYMBOL(gen_estimator_active);