26#include <netlink-private/netlink.h>
27#include <netlink-private/tc.h>
28#include <netlink/netlink.h>
29#include <netlink-private/route/tc-api.h>
30#include <netlink/route/qdisc.h>
31#include <netlink/route/qdisc/fifo.h>
32#include <netlink/utils.h>
35#define SCH_FIFO_ATTR_LIMIT 1
38static int fifo_msg_parser(
struct rtnl_tc *tc,
void *data)
40 struct rtnl_fifo *fifo = data;
41 struct tc_fifo_qopt *opt;
43 if (tc->tc_opts->d_size <
sizeof(
struct tc_fifo_qopt))
46 opt = (
struct tc_fifo_qopt *) tc->tc_opts->d_data;
47 fifo->qf_limit = opt->limit;
48 fifo->qf_mask = SCH_FIFO_ATTR_LIMIT;
53static void pfifo_dump_line(
struct rtnl_tc *tc,
void *data,
56 struct rtnl_fifo *fifo = data;
59 nl_dump(p,
" limit %u packets", fifo->qf_limit);
62static void bfifo_dump_line(
struct rtnl_tc *tc,
void *data,
65 struct rtnl_fifo *fifo = data;
73 nl_dump(p,
" limit %.1f%s", r, unit);
76static int fifo_msg_fill(
struct rtnl_tc *tc,
void *data,
struct nl_msg *msg)
78 struct rtnl_fifo *fifo = data;
79 struct tc_fifo_qopt opts = {0};
81 if (!fifo || !(fifo->qf_mask & SCH_FIFO_ATTR_LIMIT))
84 opts.limit = fifo->qf_limit;
86 return nlmsg_append(msg, &opts,
sizeof(opts), NL_DONTPAD);
102 struct rtnl_fifo *fifo;
107 fifo->qf_limit = limit;
108 fifo->qf_mask |= SCH_FIFO_ATTR_LIMIT;
120 struct rtnl_fifo *fifo;
125 if (fifo->qf_mask & SCH_FIFO_ATTR_LIMIT)
126 return fifo->qf_limit;
133static struct rtnl_tc_ops pfifo_ops = {
135 .to_type = RTNL_TC_TYPE_QDISC,
136 .to_size =
sizeof(
struct rtnl_fifo),
137 .to_msg_parser = fifo_msg_parser,
139 .to_msg_fill = fifo_msg_fill,
142static struct rtnl_tc_ops bfifo_ops = {
144 .to_type = RTNL_TC_TYPE_QDISC,
145 .to_size =
sizeof(
struct rtnl_fifo),
146 .to_msg_parser = fifo_msg_parser,
148 .to_msg_fill = fifo_msg_fill,
151static void __init fifo_init(
void)
157static void __exit fifo_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_qdisc_fifo_get_limit(struct rtnl_qdisc *qdisc)
Get limit of a FIFO qdisc.
int rtnl_qdisc_fifo_set_limit(struct rtnl_qdisc *qdisc, int limit)
Set limit of FIFO 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.
double nl_cancel_down_bytes(unsigned long long l, char **unit)
Cancel down a byte counter.
@ NL_DUMP_LINE
Dump object briefly on one line.