views:

12

answers:

1

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?

A: 

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.

alnet