From: Thomas Graf <tgraf@infradead.org>
To: John Fastabend <john.r.fastabend@intel.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [RFC PATCH v2 2/3] netlink: implement nla_policy for HW QOS
Date: Thu, 2 Dec 2010 05:20:37 -0500 [thread overview]
Message-ID: <20101202102037.GB10221@canuck.infradead.org> (raw)
In-Reply-To: <20101201182258.2748.99569.stgit@jf-dev1-dcblab>
On Wed, Dec 01, 2010 at 10:22:58AM -0800, John Fastabend wrote:
> +
> + NLA_PUT_U8(skb, IFLA_TC_TXMAX, dev->max_tcs);
> + NLA_PUT_U8(skb, IFLA_TC_TXNUM, dev->num_tcs);
> +
> + tc_txq = nla_nest_start(skb, IFLA_TC_TXQS);
You have to check the return value here.
> + for (i = 0; i < dev->num_tcs; i++) {
> + tcq = netdev_get_tc_queue(dev, i);
> + ifla_tcq.tc = i;
> + ifla_tcq.count = tcq->count;
> + ifla_tcq.offset = tcq->offset;
> +
> + NLA_PUT(skb, IFLA_TC_TXQ, sizeof(ifla_tcq), &ifla_tcq);
> + }
> + nla_nest_end(skb, tc_txq);
> +
> + tc_map = nla_nest_start(skb, IFLA_TC_MAPS);
Same here
> + for (i = 0; i < 16; i++) {
> + ifla_map.prio = i;
> + ifla_map.tc = netdev_get_prio_tc_map(dev, i);
> + NLA_PUT(skb, IFLA_TC_MAP, sizeof(ifla_map), &ifla_map);
> + }
>
> +
> +static const struct nla_policy ifla_tc_txq[IFLA_TC_TXQS_MAX+1] = {
> + [IFLA_TC_TXQ] = { .type = NLA_BINARY,
> + .len = sizeof(struct ifla_tc_txq)},
This is probably not what you want. NLA_BINARY only enforces a maximum
payload length but no minimum payload length.
Omit the .type and let it fall back to NLA_UNSPEC and only specify a
.len. This enforces that the attribute payload is at least .len in
length. You should not worry about payload that exceeds your size
expectations. This allows to extend ifla_tc_txq in the future.
> +static const struct nla_policy ifla_tc_map[IFLA_TC_MAPS_MAX+1] = {
> + [IFLA_TC_MAP] = { .type = NLA_BINARY,
> + .len = sizeof(struct ifla_tc_map)},
> +};
Same here
next prev parent reply other threads:[~2010-12-02 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 18:22 [RFC PATCH v2 1/3] net: implement mechanism for HW based QOS John Fastabend
2010-12-01 18:22 ` [RFC PATCH v2 2/3] netlink: implement nla_policy for HW QOS John Fastabend
2010-12-02 10:20 ` Thomas Graf [this message]
2010-12-02 19:53 ` John Fastabend
2010-12-01 18:23 ` [RFC PATCH v2 3/3] ixgbe: add multiple txqs per tc John Fastabend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101202102037.GB10221@canuck.infradead.org \
--to=tgraf@infradead.org \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=john.r.fastabend@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).