do not calculate tc leafs and parents if enabled_all_classes_qdiscs is enabled
Costa Tsaousis (ktsaou) committed
Feb 2, 2017 at 23:40 UTC
bf26c3b0983584a0bc3539d510fc8ef777af94d9
1 file changed
+25
-23
src/plugin_tc.c
+25
-23
@@ -283,29 +283,31 @@ static inline void tc_device_commit(struct tc_device *d) {
283
//
284
// so, here we remove the isleaf flag from nodes in the middle
285
// and we add the hasparent flag to leaf nodes we found their parent
286
- for(c = d->classes; c; c = c->next) {
287
- if(unlikely(!c->updated)) continue;
288
-
289
- //debug(D_TC_LOOP, "TC: In device '%s', %s '%s' has leafid: '%s' and parentid '%s'.",
290
- // d->id,
291
- // c->isqdisc?"qdisc":"class",
292
- // c->id,
293
- // c->leafid?c->leafid:"NULL",
294
- // c->parentid?c->parentid:"NULL");
295
-
296
- // find if c is leaf or not
297
- for(x = d->classes; x; x = x->next) {
298
- if(unlikely(!x->updated || c == x || !x->parentid)) continue;
299
-
300
- // classes have both parentid and leafid
301
- // qdiscs have only parentid
302
- // the following works for both (it is an OR)
303
-
304
- if( (c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
305
- (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0)) {
306
- // debug(D_TC_LOOP, "TC: In device '%s', %s '%s' (leafid: '%s') has as leaf %s '%s' (parentid: '%s').", d->name?d->name:d->id, c->isqdisc?"qdisc":"class", c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->isqdisc?"qdisc":"class", x->name?x->name:x->id, x->parentid?x->parentid:x->id);
307
- c->isleaf = 0;
308
- x->hasparent = 1;
286
+ if(likely(!d->enabled_all_classes_qdiscs)) {
287
+ for(c = d->classes; c; c = c->next) {
288
+ if(unlikely(!c->updated)) continue;
289
+
290
+ //debug(D_TC_LOOP, "TC: In device '%s', %s '%s' has leafid: '%s' and parentid '%s'.",
291
+ // d->id,
292
+ // c->isqdisc?"qdisc":"class",
293
+ // c->id,
294
+ // c->leafid?c->leafid:"NULL",
295
+ // c->parentid?c->parentid:"NULL");
296
+
297
+ // find if c is leaf or not
298
+ for(x = d->classes; x; x = x->next) {
299
+ if(unlikely(!x->updated || c == x || !x->parentid)) continue;
300
+
301
+ // classes have both parentid and leafid
302
+ // qdiscs have only parentid
303
+ // the following works for both (it is an OR)
304
+
305
+ if((c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
306
+ (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0)) {
307
+ // debug(D_TC_LOOP, "TC: In device '%s', %s '%s' (leafid: '%s') has as leaf %s '%s' (parentid: '%s').", d->name?d->name:d->id, c->isqdisc?"qdisc":"class", c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->isqdisc?"qdisc":"class", x->name?x->name:x->id, x->parentid?x->parentid:x->id);
308
+ c->isleaf = 0;
309
+ x->hasparent = 1;
310
+ }
311
}
312
}
313
}