20#include <netlink-private/netlink.h>
21#include <netlink-private/tc.h>
22#include <netlink/netlink.h>
23#include <netlink/utils.h>
24#include <netlink-private/route/tc-api.h>
25#include <netlink/route/qdisc.h>
26#include <netlink/route/qdisc/sfq.h>
29#define SCH_SFQ_ATTR_QUANTUM 0x01
30#define SCH_SFQ_ATTR_PERTURB 0x02
31#define SCH_SFQ_ATTR_LIMIT 0x04
32#define SCH_SFQ_ATTR_DIVISOR 0x08
33#define SCH_SFQ_ATTR_FLOWS 0x10
36static int sfq_msg_parser(
struct rtnl_tc *tc,
void *data)
38 struct rtnl_sfq *sfq = data;
39 struct tc_sfq_qopt *opts;
41 if (!(tc->ce_mask & TCA_ATTR_OPTS))
44 if (tc->tc_opts->d_size <
sizeof(*opts))
47 opts = (
struct tc_sfq_qopt *) tc->tc_opts->d_data;
49 sfq->qs_quantum = opts->quantum;
50 sfq->qs_perturb = opts->perturb_period;
51 sfq->qs_limit = opts->limit;
52 sfq->qs_divisor = opts->divisor;
53 sfq->qs_flows = opts->flows;
55 sfq->qs_mask = (SCH_SFQ_ATTR_QUANTUM | SCH_SFQ_ATTR_PERTURB |
56 SCH_SFQ_ATTR_LIMIT | SCH_SFQ_ATTR_DIVISOR |
62static void sfq_dump_line(
struct rtnl_tc *tc,
void *data,
65 struct rtnl_sfq *sfq = data;
68 nl_dump(p,
" quantum %u perturb %us", sfq->qs_quantum,
72static void sfq_dump_details(
struct rtnl_tc *tc,
void *data,
75 struct rtnl_sfq *sfq = data;
78 nl_dump(p,
"limit %u divisor %u",
79 sfq->qs_limit, sfq->qs_divisor);
82static int sfq_msg_fill(
struct rtnl_tc *tc,
void *data,
struct nl_msg *msg)
84 struct rtnl_sfq *sfq = data;
85 struct tc_sfq_qopt opts = {0};
90 opts.quantum = sfq->qs_quantum;
91 opts.perturb_period = sfq->qs_perturb;
92 opts.limit = sfq->qs_limit;
94 return nlmsg_append(msg, &opts,
sizeof(opts), NL_DONTPAD);
110 struct rtnl_sfq *sfq;
115 sfq->qs_quantum = quantum;
116 sfq->qs_mask |= SCH_SFQ_ATTR_QUANTUM;
126 struct rtnl_sfq *sfq;
131 if (sfq->qs_mask & SCH_SFQ_ATTR_QUANTUM)
132 return sfq->qs_quantum;
145 struct rtnl_sfq *sfq;
150 sfq->qs_limit = limit;
151 sfq->qs_mask |= SCH_SFQ_ATTR_LIMIT;
161 struct rtnl_sfq *sfq;
166 if (sfq->qs_mask & SCH_SFQ_ATTR_LIMIT)
167 return sfq->qs_limit;
181 struct rtnl_sfq *sfq;
186 sfq->qs_perturb = perturb;
187 sfq->qs_mask |= SCH_SFQ_ATTR_PERTURB;
197 struct rtnl_sfq *sfq;
202 if (sfq->qs_mask & SCH_SFQ_ATTR_PERTURB)
203 return sfq->qs_perturb;
215 struct rtnl_sfq *sfq;
220 if (sfq->qs_mask & SCH_SFQ_ATTR_DIVISOR)
221 return sfq->qs_divisor;
228static struct rtnl_tc_ops sfq_ops = {
230 .to_type = RTNL_TC_TYPE_QDISC,
231 .to_size =
sizeof(
struct rtnl_sfq),
232 .to_msg_parser = sfq_msg_parser,
237 .to_msg_fill = sfq_msg_fill,
240static void __init sfq_init(
void)
245static void __exit sfq_exit(
void)
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
int rtnl_sfq_get_quantum(struct rtnl_qdisc *qdisc)
Get quantum of SFQ qdisc.
void rtnl_sfq_set_perturb(struct rtnl_qdisc *qdisc, int perturb)
Set perturbation interval of SFQ qdisc.
int rtnl_sfq_get_divisor(struct rtnl_qdisc *qdisc)
Get divisor of SFQ qdisc.
int rtnl_sfq_get_perturb(struct rtnl_qdisc *qdisc)
Get perturbation interval of SFQ qdisc.
void rtnl_sfq_set_quantum(struct rtnl_qdisc *qdisc, int quantum)
Set quantum of SFQ qdisc.
int rtnl_sfq_get_limit(struct rtnl_qdisc *qdisc)
Get limit of SFQ qdisc.
void rtnl_sfq_set_limit(struct rtnl_qdisc *qdisc, int limit)
Set limit of SFQ qdisc.
#define TC_CAST(ptr)
Macro to cast qdisc/class/classifier to tc object.
void * rtnl_tc_data(struct rtnl_tc *tc)
Return pointer to private data of traffic control object.
int rtnl_tc_register(struct rtnl_tc_ops *ops)
Register a traffic control module.
void rtnl_tc_unregister(struct rtnl_tc_ops *ops)
Unregister a traffic control module.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.