I keep wondering if it was possible to dump just the queue tree for
tc -s qdisc show dev whatever parent 5:1.
Presently your code, and tc, dump the whole thing, then parse it out... There must be a better way....
I keep wondering if it was possible to dump just the queue tree for
tc -s qdisc show dev whatever parent 5:1.
Presently your code, and tc, dump the whole thing, then parse it out... There must be a better way....
Yeah I used strace on tc to help me figure out what I needed to send to get what I needed,
so the similar behavior is to be expected.
Although looking at a tc show strace again, if I call tc qdisc show dev eth0, tc will set the ifindex in the request,
but the kernel will still return all qdiscs. Tried to set NLM_F_MATCH in my code to test as well, but it didn't make any difference
Yeah I used strace on tc to help me figure out what I needed to send to get what I needed,
so the similar behavior is to be expected.
Although looking at a tc show strace again, if I call `tc qdisc show dev eth0`, tc will set the ifindex in the request,
but the kernel will still return all qdiscs. Tried to set NLM_F_MATCH in my code to test as well, but it didn't make any difference
Mine too. Albeit with Rust there's at least usually someone else that's run into the same problem,
with Netlink you're often on your own
At a first glance I should avoid setting NLM_F_DUMP, that will cause it to dump all qdiscs,
but just having NLM_F_REQUEST and NLM_F_MATCH flags set still causes a full dump cue confusion
Will need to dig some more
Mine too. Albeit with Rust there's at least usually someone else that's run into the same problem,
with Netlink you're often on your own
At a first glance I should avoid setting NLM_F_DUMP, that will cause it to dump all qdiscs,
but just having NLM_F_REQUEST and NLM_F_MATCH flags set still causes a full dump *cue confusion*
Will need to dig some more
For GET - NLM_F_ROOT and NLM_F_MATCH are combined into NLM_F_DUMP, and not used separately. NLM_F_ATOMIC is never used.
I originally thought that was specific to generic netlink, and didn't apply to rtnetlink, but evidently not.
However running with only NLM_F_REQUEST gives me an Unknown error -2 (os error -2) error message.
I can see from the printk's I added that it now ends up in tc_get_qdisc, but is unhappy.
That being the case, I'm not sure if there's actually a reasonable way to do this without dumping the whole thing
Yep.
Some printk's later, I at least understand what's going on.
NLM_F_REQUEST and NLM_F_MATCH becomes 0x201.
So in this check: https://github.com/torvalds/linux/blob/master/net/core/rtnetlink.c#L6098
```c
if (kind == RTNL_KIND_GET && (nlh->nlmsg_flags & NLM_F_DUMP)) {
```
nlh->nlmsg_flags & NLM_F_DUMP will evaluate to 0x1 and pass.
Here: https://www.kernel.org/doc/html/latest/userspace-api/netlink/intro.html#other-request-type-specific-flags, it says that
> For GET - NLM_F_ROOT and NLM_F_MATCH are combined into NLM_F_DUMP, and not used separately. NLM_F_ATOMIC is never used.
I originally thought that was specific to generic netlink, and didn't apply to rtnetlink, but evidently not.
However running with only NLM_F_REQUEST gives me an `Unknown error -2 (os error -2)` error message.
I can see from the printk's I added that it now ends up in tc_get_qdisc, but is unhappy.
That error should be coming from [here](https://github.com/torvalds/linux/blob/master/net/sched/sch_api.c#L1491), indicating that it can't find the qdisc. I don't set the qdisc handle in the request, so I believe it bails early here in qdisc_lookup: https://github.com/torvalds/linux/blob/master/net/sched/sch_api.c#L304
That being the case, I'm not sure if there's actually a reasonable way to do this without dumping the whole thing
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
I keep wondering if it was possible to dump just the queue tree for
tc -s qdisc show dev whatever parent 5:1.
Presently your code, and tc, dump the whole thing, then parse it out... There must be a better way....
Yeah I used strace on tc to help me figure out what I needed to send to get what I needed,
so the similar behavior is to be expected.
Although looking at a tc show strace again, if I call
tc qdisc show dev eth0, tc will set the ifindex in the request,but the kernel will still return all qdiscs. Tried to set NLM_F_MATCH in my code to test as well, but it didn't make any difference
yea. Seems like a bug to me...
maybe if it set the ifindex separately?
not sure. guess I'll have to dig into the kernel a bit to see how this is supposed to work
I'm rooting for you. netlink makes my head hurt. So does rust.
Mine too. Albeit with Rust there's at least usually someone else that's run into the same problem,
with Netlink you're often on your own
At a first glance I should avoid setting NLM_F_DUMP, that will cause it to dump all qdiscs,
but just having NLM_F_REQUEST and NLM_F_MATCH flags set still causes a full dump cue confusion
Will need to dig some more
Yea. Even with ifindex directly specified?
Moving to containers would fix some of my problem in LibreQos, but introduce others.
Yep.
Some printk's later, I at least understand what's going on.
NLM_F_REQUEST and NLM_F_MATCH becomes 0x201.
So in this check: https://github.com/torvalds/linux/blob/master/net/core/rtnetlink.c#L6098
nlh->nlmsg_flags & NLM_F_DUMP will evaluate to 0x1 and pass.
Here: https://www.kernel.org/doc/html/latest/userspace-api/netlink/intro.html#other-request-type-specific-flags, it says that
However running with only NLM_F_REQUEST gives me an
Unknown error -2 (os error -2)error message.I can see from the printk's I added that it now ends up in tc_get_qdisc, but is unhappy.
That error should be coming from here, indicating that it can't find the qdisc. I don't set the qdisc handle in the request, so I believe it bails early here in qdisc_lookup: https://github.com/torvalds/linux/blob/master/net/sched/sch_api.c#L304
That being the case, I'm not sure if there's actually a reasonable way to do this without dumping the whole thing