Пример #1
0
static int htb_class_msg_parser(struct rtnl_tc *tc, void *data)
{
	struct nlattr *tb[TCA_HTB_MAX + 1];
	struct rtnl_htb_class *htb = data;
	int err;

	if ((err = tca_parse(tb, TCA_HTB_MAX, tc, htb_policy)) < 0)
		return err;
	
	if (tb[TCA_HTB_PARMS]) {
		struct tc_htb_opt opts;

		nla_memcpy(&opts, tb[TCA_HTB_PARMS], sizeof(opts));
		htb->ch_prio = opts.prio;
		rtnl_copy_ratespec(&htb->ch_rate, &opts.rate);
		rtnl_copy_ratespec(&htb->ch_ceil, &opts.ceil);
		htb->ch_rbuffer = rtnl_tc_calc_bufsize(opts.buffer,
						       opts.rate.rate);
		htb->ch_cbuffer = rtnl_tc_calc_bufsize(opts.cbuffer,
						       opts.ceil.rate);
		htb->ch_quantum = opts.quantum;
		htb->ch_level = opts.level;

		rtnl_tc_set_mpu(tc, htb->ch_rate.rs_mpu);
		rtnl_tc_set_overhead(tc, htb->ch_rate.rs_overhead);

		htb->ch_mask = (SCH_HTB_HAS_PRIO | SCH_HTB_HAS_RATE |
				SCH_HTB_HAS_CEIL | SCH_HTB_HAS_RBUFFER |
				SCH_HTB_HAS_CBUFFER | SCH_HTB_HAS_QUANTUM |
				SCH_HTB_HAS_LEVEL);
	}

	return 0;
}
Пример #2
0
static int tbf_msg_parser(struct rtnl_qdisc *q)
{
    int err;
    struct nlattr *tb[TCA_TBF_MAX + 1];
    struct rtnl_tbf *tbf;

    err = tca_parse(tb, TCA_TBF_MAX, (struct rtnl_tca *) q, tbf_policy);
    if (err < 0)
        return err;

    tbf = tbf_qdisc(q);
    if (!tbf)
        return nl_errno(ENOMEM);

    if (tb[TCA_TBF_PARMS]) {
        struct tc_tbf_qopt opts;
        int bufsize;

        nla_memcpy(&opts, tb[TCA_TBF_PARMS], sizeof(opts));
        tbf->qt_limit = opts.limit;
        tbf->qt_mpu = opts.rate.mpu;

        rtnl_copy_ratespec(&tbf->qt_rate, &opts.rate);
        tbf->qt_rate_txtime = opts.buffer;
        bufsize = rtnl_tc_calc_bufsize(nl_ticks2us(opts.buffer),
                                       opts.rate.rate);
        tbf->qt_rate_bucket = bufsize;

        rtnl_copy_ratespec(&tbf->qt_peakrate, &opts.peakrate);
        tbf->qt_peakrate_txtime = opts.mtu;
        bufsize = rtnl_tc_calc_bufsize(nl_ticks2us(opts.mtu),
                                       opts.peakrate.rate);
        tbf->qt_peakrate_bucket = bufsize;

        tbf->qt_mask = (TBF_ATTR_LIMIT | TBF_ATTR_MPU | TBF_ATTR_RATE |
                        TBF_ATTR_PEAKRATE);
    }

    return 0;
}
Пример #3
0
static int tbf_msg_parser(struct rtnl_tc *tc, void *data)
{
	struct nlattr *tb[TCA_TBF_MAX + 1];
	struct rtnl_tbf *tbf = data;
	int err;

	if ((err = tca_parse(tb, TCA_TBF_MAX, tc, tbf_policy)) < 0)
		return err;
	
	if (tb[TCA_TBF_PARMS]) {
		struct tc_tbf_qopt opts;
		int bufsize;

		nla_memcpy(&opts, tb[TCA_TBF_PARMS], sizeof(opts));
		tbf->qt_limit = opts.limit;
	
		rtnl_copy_ratespec(&tbf->qt_rate, &opts.rate);
		tbf->qt_rate_txtime = opts.buffer;
		bufsize = rtnl_tc_calc_bufsize(nl_ticks2us(opts.buffer),
					       opts.rate.rate);
		tbf->qt_rate_bucket = bufsize;

		rtnl_copy_ratespec(&tbf->qt_peakrate, &opts.peakrate);
		tbf->qt_peakrate_txtime = opts.mtu;
		bufsize = rtnl_tc_calc_bufsize(nl_ticks2us(opts.mtu),
					       opts.peakrate.rate);
		tbf->qt_peakrate_bucket = bufsize;

		rtnl_tc_set_mpu(tc, tbf->qt_rate.rs_mpu);
		rtnl_tc_set_overhead(tc, tbf->qt_rate.rs_overhead);

		tbf->qt_mask = (TBF_ATTR_LIMIT | TBF_ATTR_RATE | TBF_ATTR_PEAKRATE);
	}

	return 0;
}