tc/qdisc: add support for fq_codel attributes
This commit is contained in:
@@ -84,6 +84,13 @@ enum {
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Compat with older kernels. */
|
||||
|
||||
#define TCA_FQ_CODEL_CE_THRESHOLD 7
|
||||
#define TCA_FQ_CODEL_MEMORY_LIMIT 9
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define VLAN_FLAG_MVRP 0x8
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -3481,6 +3488,7 @@ _new_from_nl_qdisc (struct nlmsghdr *nlh, gboolean id_only)
|
||||
{
|
||||
static const struct nla_policy policy[] = {
|
||||
[TCA_KIND] = { .type = NLA_STRING },
|
||||
[TCA_OPTIONS] = { .type = NLA_NESTED },
|
||||
};
|
||||
struct nlattr *tb[G_N_ELEMENTS (policy)];
|
||||
const struct tcmsg *tcm;
|
||||
@@ -3506,6 +3514,45 @@ _new_from_nl_qdisc (struct nlmsghdr *nlh, gboolean id_only)
|
||||
obj->qdisc.parent = tcm->tcm_parent;
|
||||
obj->qdisc.info = tcm->tcm_info;
|
||||
|
||||
if (tb[TCA_OPTIONS]) {
|
||||
struct nlattr *options_attr;
|
||||
int remaining;
|
||||
|
||||
nla_for_each_nested (options_attr, tb[TCA_OPTIONS], remaining) {
|
||||
if (nla_len (options_attr) < sizeof (uint32_t))
|
||||
continue;
|
||||
|
||||
if (nm_streq0 (obj->qdisc.kind, "fq_codel")) {
|
||||
switch (nla_type (options_attr)) {
|
||||
case TCA_FQ_CODEL_LIMIT:
|
||||
obj->qdisc.fq_codel.limit = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_FLOWS:
|
||||
obj->qdisc.fq_codel.flows = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_TARGET:
|
||||
obj->qdisc.fq_codel.target = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_INTERVAL:
|
||||
obj->qdisc.fq_codel.interval = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_QUANTUM:
|
||||
obj->qdisc.fq_codel.quantum = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_CE_THRESHOLD:
|
||||
obj->qdisc.fq_codel.ce_threshold = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_MEMORY_LIMIT:
|
||||
obj->qdisc.fq_codel.memory = nla_get_u32 (options_attr);
|
||||
break;
|
||||
case TCA_FQ_CODEL_ECN:
|
||||
obj->qdisc.fq_codel.ecn = nla_get_u32 (options_attr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -4161,6 +4208,7 @@ _nl_msg_new_qdisc (int nlmsg_type,
|
||||
const NMPlatformQdisc *qdisc)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
struct nlattr *tc_options;
|
||||
const struct tcmsg tcm = {
|
||||
.tcm_family = qdisc->addr_family,
|
||||
.tcm_ifindex = qdisc->ifindex,
|
||||
@@ -4176,6 +4224,30 @@ _nl_msg_new_qdisc (int nlmsg_type,
|
||||
|
||||
NLA_PUT_STRING (msg, TCA_KIND, qdisc->kind);
|
||||
|
||||
if (!(tc_options = nla_nest_start (msg, TCA_OPTIONS)))
|
||||
goto nla_put_failure;
|
||||
|
||||
if (strcmp (qdisc->kind, "fq_codel") == 0) {
|
||||
if (qdisc->fq_codel.limit)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_LIMIT, qdisc->fq_codel.limit);
|
||||
if (qdisc->fq_codel.flows)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_FLOWS, qdisc->fq_codel.flows);
|
||||
if (qdisc->fq_codel.target)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_TARGET, qdisc->fq_codel.target);
|
||||
if (qdisc->fq_codel.interval)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_INTERVAL, qdisc->fq_codel.interval);
|
||||
if (qdisc->fq_codel.quantum)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_QUANTUM, qdisc->fq_codel.quantum);
|
||||
if (qdisc->fq_codel.ce_threshold != -1)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_CE_THRESHOLD, qdisc->fq_codel.ce_threshold);
|
||||
if (qdisc->fq_codel.memory != -1)
|
||||
NLA_PUT_U32 (msg, TCA_FQ_CODEL_MEMORY_LIMIT, qdisc->fq_codel.memory);
|
||||
if (qdisc->fq_codel.ecn)
|
||||
NLA_PUT_S32 (msg, TCA_FQ_CODEL_ECN, qdisc->fq_codel.ecn);
|
||||
}
|
||||
|
||||
nla_nest_end (msg, tc_options);
|
||||
|
||||
return g_steal_pointer (&msg);
|
||||
|
||||
nla_put_failure:
|
||||
|
Reference in New Issue
Block a user