Skip to content

Add qos example - #628

Draft
sneaky-potato wants to merge 11 commits into
sneaky-potato/gsoc26from
sneaky-potato/qos
Draft

Add qos example#628
sneaky-potato wants to merge 11 commits into
sneaky-potato/gsoc26from
sneaky-potato/qos

Conversation

@sneaky-potato

Copy link
Copy Markdown
Member

No description provided.

Comment thread examples/qos/tc.lua
-- struct flow_stats {
-- u64 packets;
-- u32 avg_pkt_size;
-- };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we can have named struct fields on autogen; won't it help here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't suggesting that, but I think it's a good idea to leverage autogen for this.

Comment thread examples/qos/tc.lua Outdated
Comment on lines +53 to +59
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ;-)

Comment thread examples/qos/tc.lua
local skbattr = require("skb.attr")
local map = require("ebpf.map")

local TC_H_MAKE = function(maj, min) return (maj << 16) | min end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the caps?

@sneaky-potato sneaky-potato Jul 28, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a defined kernel macro (/include/uapi/linux/pkt_sched.h#L72)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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..

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>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
@sneaky-potato
sneaky-potato force-pushed the sneaky-potato/gsoc26 branch 2 times, most recently from f0179dc to 4a5453a Compare August 10, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants