Qdisc running flag

0.0.1. Summary

In struct Qdisc, there are two similar fileds.
running flag is stored in __state of struct Qdisc, NOT state.
Every time, when we send a packet from qdisc, the running flag is
set by qdisc_run_begin, and after that, it is removed by qdisc_run_end.

1
2
3
84         unsigned long           state;
...
87 unsigned int __state;

0.0.1.1. todo

why need busylock?

0.0.1.2. The values of state.

1
2
3
4
5
24 enum qdisc_state_t {
25 __QDISC_STATE_SCHED,
26 __QDISC_STATE_DEACTIVATED,
27 __QDISC_STATE_THROTTLED,
28 };

0.0.1.3. The value of __state.

1
2
3
33 enum qdisc___state_t {
34 __QDISC___STATE_RUNNING = 1,
35 };

0.1. Running flag

0.1.1. check Qdisc running

1
2
3
4
96 static inline bool qdisc_is_running(const struct Qdisc *qdisc)
97 {
98 return (qdisc->__state & __QDISC___STATE_RUNNING) ? true : false;
99 }

0.1.2. Set Qdisc running

1
2
3
4
5
6
7
101 static inline bool qdisc_run_begin(struct Qdisc *qdisc)
102 {
103 if (qdisc_is_running(qdisc))
104 return false;
105 qdisc->__state |= __QDISC___STATE_RUNNING;
106 return true;
107 }

0.1.3. Unset Qdisc running

1
2
3
4
109 static inline void qdisc_run_end(struct Qdisc *qdisc)
110 {
111 qdisc->__state &= ~__QDISC___STATE_RUNNING;
112 }

Qdisc running flag
https://martinbj2008.github.io/2014/02/08/2014-02-08-qdisc-running-flag/
Author
Martinbj2008
Posted on
February 8, 2014
Licensed under