如何从内核管理 qdisc
我很难找到内核 API 来启用某些 qdisc 策略“tc”实用程序从用户空间运行。
我在 net/sched/sch_*.c 中找到了这些模块,但我不知道如何使用它们。
例如,如果我想启用 TBF,我应该在代码中执行以下操作吗?
static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
.next = NULL,
.cl_ops = &tbf_class_ops,
.id = "tbf",
.priv_size = sizeof(struct tbf_sched_data),
.enqueue = tbf_enqueue,
.dequeue = tbf_dequeue,
.peek = qdisc_peek_dequeued,
.drop = tbf_drop,
.init = tbf_init,
.reset = tbf_reset,
.destroy = tbf_destroy,
.change = tbf_change,
.dump = tbf_dump,
.owner = THIS_MODULE,
}; register_qdisc(&tbf_qdisc_ops); 够了吗? 如何将 qdisc 连接到网络设备?
I have trouble to find the kernel API to enable some qdisc policies "tc" utility run from user-space.
I found the modules in net/sched/sch_*.c but I'm not sure how to use them.
For instance, if I want to enable TBF, should I do something like the following in my code?
static struct Qdisc_ops tbf_qdisc_ops __read_mostly = {
.next = NULL,
.cl_ops = &tbf_class_ops,
.id = "tbf",
.priv_size = sizeof(struct tbf_sched_data),
.enqueue = tbf_enqueue,
.dequeue = tbf_dequeue,
.peek = qdisc_peek_dequeued,
.drop = tbf_drop,
.init = tbf_init,
.reset = tbf_reset,
.destroy = tbf_destroy,
.change = tbf_change,
.dump = tbf_dump,
.owner = THIS_MODULE,
};
register_qdisc(&tbf_qdisc_ops);
Is that enough?
How do I attach qdisc to a net device?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
qdisc 修改仅暴露给 netlink API。这意味着它被设计为从用户空间进行更改。但是,如果使用 tc 定义 qdisc,则可以通过调用 .change() 函数在内核中更改其参数。
qdisc modification is exposed only to netlink API. That means that it's designed to be changed from the userspace. However, if qdisc is defined using tc, its' parameters can be changed within the kernel by calling .change() function.