[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <02ffb733-8a2d-2ad0-2643-d3ef88cf8856@gmail.com>
Date: Fri, 19 Jan 2018 16:00:36 -0800
From: David Ahern <dsahern@...il.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: Arkadi Sharshevsky <arkadis@...lanox.com>, netdev@...r.kernel.org,
davem@...emloft.net, mlxsw@...lanox.com
Subject: Re: [PATCH iproute2] devlink: Ignore unknown attributes
On 1/19/18 3:40 PM, Stephen Hemminger wrote:
>> mnl_attr_type_valid calls mnl_attr_get_type which does attr->nla_type &
>> NLA_TYPE_MASK. Since you are no longer acknowledging the return code of
>> mnl_attr_type_valid, you don't care about its checks so you might as
>> well not call it. I don't see anything in libmnl that checks that
>> mnl_attr_type_valid is invoked on an attr, so hence my question -- given
>> the change above why call it all?
ok. I see the error in my thinking.
> The part that matters is:
>
> static int attr_cb(const struct nlattr *attr, void *data)
> {
> const struct nlattr **tb = data;
> int type;
>
> if (mnl_attr_type_valid(attr, DEVLINK_ATTR_MAX) < 0) << makes sure that type < DEVLINK_ATTR_MAX
> return MNL_CB_OK;
>
> type = mnl_attr_get_type(attr);
> if (mnl_attr_validate(attr, devlink_policy[type]) < 0) << this part doesn't matter really
> return MNL_CB_ERROR;
>
> tb[type] = attr; << necessary so that tb[] is filled in.
> return MNL_CB_OK;
> }
Powered by blists - more mailing lists