* [PATCH iproute2] devlink: Ignore unknown attributes
@ 2018-01-17 13:28 Arkadi Sharshevsky
2018-01-17 13:37 ` Jiri Pirko
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Arkadi Sharshevsky @ 2018-01-17 13:28 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, mlxsw, Arkadi Sharshevsky
In case of extending the UAPI old packages would break.
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
---
devlink/devlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 39cda06..c9d1838 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -343,7 +343,7 @@ static int attr_cb(const struct nlattr *attr, void *data)
int type;
if (mnl_attr_type_valid(attr, DEVLINK_ATTR_MAX) < 0)
- return MNL_CB_ERROR;
+ return MNL_CB_OK;
type = mnl_attr_get_type(attr);
if (mnl_attr_validate(attr, devlink_policy[type]) < 0)
--
2.4.11
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-17 13:28 [PATCH iproute2] devlink: Ignore unknown attributes Arkadi Sharshevsky
@ 2018-01-17 13:37 ` Jiri Pirko
2018-01-19 0:32 ` Stephen Hemminger
2018-01-19 4:42 ` David Ahern
2 siblings, 0 replies; 8+ messages in thread
From: Jiri Pirko @ 2018-01-17 13:37 UTC (permalink / raw)
To: Arkadi Sharshevsky; +Cc: netdev, davem, stephen, mlxsw
Wed, Jan 17, 2018 at 02:28:00PM CET, arkadis@mellanox.com wrote:
>In case of extending the UAPI old packages would break.
>
>Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-17 13:28 [PATCH iproute2] devlink: Ignore unknown attributes Arkadi Sharshevsky
2018-01-17 13:37 ` Jiri Pirko
@ 2018-01-19 0:32 ` Stephen Hemminger
2018-01-19 4:42 ` David Ahern
2 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2018-01-19 0:32 UTC (permalink / raw)
To: Arkadi Sharshevsky; +Cc: netdev, davem, mlxsw
On Wed, 17 Jan 2018 15:28:00 +0200
Arkadi Sharshevsky <arkadis@mellanox.com> wrote:
> In case of extending the UAPI old packages would break.
>
> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Looks like good future proofing.
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-17 13:28 [PATCH iproute2] devlink: Ignore unknown attributes Arkadi Sharshevsky
2018-01-17 13:37 ` Jiri Pirko
2018-01-19 0:32 ` Stephen Hemminger
@ 2018-01-19 4:42 ` David Ahern
2018-01-19 22:02 ` Stephen Hemminger
2 siblings, 1 reply; 8+ messages in thread
From: David Ahern @ 2018-01-19 4:42 UTC (permalink / raw)
To: Arkadi Sharshevsky, netdev; +Cc: davem, stephen, mlxsw
On 1/17/18 5:28 AM, Arkadi Sharshevsky wrote:
> In case of extending the UAPI old packages would break.
>
> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
> ---
> devlink/devlink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/devlink/devlink.c b/devlink/devlink.c
> index 39cda06..c9d1838 100644
> --- a/devlink/devlink.c
> +++ b/devlink/devlink.c
> @@ -343,7 +343,7 @@ static int attr_cb(const struct nlattr *attr, void *data)
> int type;
>
> if (mnl_attr_type_valid(attr, DEVLINK_ATTR_MAX) < 0)
> - return MNL_CB_ERROR;
> + return MNL_CB_OK;
>
> type = mnl_attr_get_type(attr);
> if (mnl_attr_validate(attr, devlink_policy[type]) < 0)
>
What's the point of calling mnl_attr_type_valid if you disregard a
failure? you might as well not call mnl_attr_type_valid at all.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-19 4:42 ` David Ahern
@ 2018-01-19 22:02 ` Stephen Hemminger
2018-01-19 22:27 ` David Ahern
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2018-01-19 22:02 UTC (permalink / raw)
To: David Ahern; +Cc: Arkadi Sharshevsky, netdev, davem, mlxsw
On Thu, 18 Jan 2018 20:42:44 -0800
David Ahern <dsahern@gmail.com> wrote:
> On 1/17/18 5:28 AM, Arkadi Sharshevsky wrote:
> > In case of extending the UAPI old packages would break.
> >
> > Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
> > ---
> > devlink/devlink.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/devlink/devlink.c b/devlink/devlink.c
> > index 39cda06..c9d1838 100644
> > --- a/devlink/devlink.c
> > +++ b/devlink/devlink.c
> > @@ -343,7 +343,7 @@ static int attr_cb(const struct nlattr *attr, void *data)
> > int type;
> >
> > if (mnl_attr_type_valid(attr, DEVLINK_ATTR_MAX) < 0)
> > - return MNL_CB_ERROR;
> > + return MNL_CB_OK;
> >
> > type = mnl_attr_get_type(attr);
> > if (mnl_attr_validate(attr, devlink_policy[type]) < 0)
> >
>
> What's the point of calling mnl_attr_type_valid if you disregard a
> failure? you might as well not call mnl_attr_type_valid at all.
The way mnl handles attributes, you have to have a callback and it is up
to the callback to copy the values it wants. The idea is that old code
running against a newer kernel will have a smaller array of attributes
it wants, and only copy those.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-19 22:02 ` Stephen Hemminger
@ 2018-01-19 22:27 ` David Ahern
2018-01-19 23:40 ` Stephen Hemminger
0 siblings, 1 reply; 8+ messages in thread
From: David Ahern @ 2018-01-19 22:27 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Arkadi Sharshevsky, netdev, davem, mlxsw
On 1/19/18 2:02 PM, Stephen Hemminger wrote:
> On Thu, 18 Jan 2018 20:42:44 -0800
> David Ahern <dsahern@gmail.com> wrote:
>
>> On 1/17/18 5:28 AM, Arkadi Sharshevsky wrote:
>>> In case of extending the UAPI old packages would break.
>>>
>>> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
>>> ---
>>> devlink/devlink.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/devlink/devlink.c b/devlink/devlink.c
>>> index 39cda06..c9d1838 100644
>>> --- a/devlink/devlink.c
>>> +++ b/devlink/devlink.c
>>> @@ -343,7 +343,7 @@ static int attr_cb(const struct nlattr *attr, void *data)
>>> int type;
>>>
>>> if (mnl_attr_type_valid(attr, DEVLINK_ATTR_MAX) < 0)
>>> - return MNL_CB_ERROR;
>>> + return MNL_CB_OK;
>>>
>>> type = mnl_attr_get_type(attr);
>>> if (mnl_attr_validate(attr, devlink_policy[type]) < 0)
>>>
>>
>> What's the point of calling mnl_attr_type_valid if you disregard a
>> failure? you might as well not call mnl_attr_type_valid at all.
>
> The way mnl handles attributes, you have to have a callback and it is up
> to the callback to copy the values it wants. The idea is that old code
> running against a newer kernel will have a smaller array of attributes
> it wants, and only copy those.
>
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?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-19 22:27 ` David Ahern
@ 2018-01-19 23:40 ` Stephen Hemminger
2018-01-20 0:00 ` David Ahern
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2018-01-19 23:40 UTC (permalink / raw)
To: David Ahern; +Cc: Arkadi Sharshevsky, netdev, davem, mlxsw
On Fri, 19 Jan 2018 14:27:06 -0800
David Ahern <dsahern@gmail.com> wrote:
> On 1/19/18 2:02 PM, Stephen Hemminger wrote:
> > On Thu, 18 Jan 2018 20:42:44 -0800
> > David Ahern <dsahern@gmail.com> wrote:
> >
> >> On 1/17/18 5:28 AM, Arkadi Sharshevsky wrote:
> >>> In case of extending the UAPI old packages would break.
> >>>
> >>> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
> >>> ---
> >>> devlink/devlink.c | 2 +-
> >>> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/devlink/devlink.c b/devlink/devlink.c
> >>> index 39cda06..c9d1838 100644
> >>> --- a/devlink/devlink.c
> >>> +++ b/devlink/devlink.c
> >>> @@ -343,7 +343,7 @@ static int attr_cb(const struct nlattr *attr, void *data)
> >>> int type;
> >>>
> >>> if (mnl_attr_type_valid(attr, DEVLINK_ATTR_MAX) < 0)
> >>> - return MNL_CB_ERROR;
> >>> + return MNL_CB_OK;
> >>>
> >>> type = mnl_attr_get_type(attr);
> >>> if (mnl_attr_validate(attr, devlink_policy[type]) < 0)
> >>>
> >>
> >> What's the point of calling mnl_attr_type_valid if you disregard a
> >> failure? you might as well not call mnl_attr_type_valid at all.
> >
> > The way mnl handles attributes, you have to have a callback and it is up
> > to the callback to copy the values it wants. The idea is that old code
> > running against a newer kernel will have a smaller array of attributes
> > it wants, and only copy those.
> >
>
> 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?
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;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2] devlink: Ignore unknown attributes
2018-01-19 23:40 ` Stephen Hemminger
@ 2018-01-20 0:00 ` David Ahern
0 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2018-01-20 0:00 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Arkadi Sharshevsky, netdev, davem, mlxsw
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;
> }
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-01-20 0:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-17 13:28 [PATCH iproute2] devlink: Ignore unknown attributes Arkadi Sharshevsky
2018-01-17 13:37 ` Jiri Pirko
2018-01-19 0:32 ` Stephen Hemminger
2018-01-19 4:42 ` David Ahern
2018-01-19 22:02 ` Stephen Hemminger
2018-01-19 22:27 ` David Ahern
2018-01-19 23:40 ` Stephen Hemminger
2018-01-20 0:00 ` David Ahern
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).