Add qos example - #628
Conversation
| -- struct flow_stats { | ||
| -- u64 packets; | ||
| -- u32 avg_pkt_size; | ||
| -- }; |
There was a problem hiding this comment.
now we can have named struct fields on autogen; won't it help here?
There was a problem hiding this comment.
flow_stats is currently only defined in the example BPF program, not in a kernel header. Are you suggesting to move it to a shared header so autogen can generate a layout for it, or some other mechanism?
There was a problem hiding this comment.
I wasn't suggesting that, but I think it's a good idea to leverage autogen for this.
| if avg < 256 then | ||
| skb.priority = TC_H_MAKE(1, 0x10) | ||
| elseif avg < 800 then | ||
| skb.priority = TC_H_MAKE(1, 0x20) | ||
| else | ||
| skb.priority = TC_H_MAKE(1, 0x30) | ||
| end |
There was a problem hiding this comment.
| if avg < 256 then | |
| skb.priority = TC_H_MAKE(1, 0x10) | |
| elseif avg < 800 then | |
| skb.priority = TC_H_MAKE(1, 0x20) | |
| else | |
| skb.priority = TC_H_MAKE(1, 0x30) | |
| end | |
| local mask = (avg < 256 and 0x10) or (avg < 800 and 0x20) or 0x30 | |
| skb.priority = TC_H_MAKE(1, mask) |
I think this is more Lua-ish; couldn't find a better name for mask though. (Just a suggestion ;-)
| local skbattr = require("skb.attr") | ||
| local map = require("ebpf.map") | ||
|
|
||
| local TC_H_MAKE = function(maj, min) return (maj << 16) | min end |
There was a problem hiding this comment.
this is a defined kernel macro (/include/uapi/linux/pkt_sched.h#L72)
There was a problem hiding this comment.
I think it's fine to leave it as is by now, but I think we should have a better way to export such macros.. perhaps leveraging autogen as well.. it is worth creating an issue at least..
62459a3 to
14d4447
Compare
4399249 to
8c84824
Compare
14d4447 to
fba9b12
Compare
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
fba9b12 to
9466196
Compare
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
8c84824 to
1df3778
Compare
f0179dc to
4a5453a
Compare
No description provided.