* [PATCH] rtnetlink: fix link attribute validation with IFLA_GROUP
@ 2011-01-20 13:00 Patrick McHardy
2011-01-20 16:09 ` Vlad Dogaru
0 siblings, 1 reply; 3+ messages in thread
From: Patrick McHardy @ 2011-01-20 13:00 UTC (permalink / raw)
To: Vlad Dogaru; +Cc: NetDev, David S. Miller
[-- Attachment #1: Type: text/plain, Size: 151 bytes --]
Fix a few semantic problems with the new IFLA_GROUP attribute.
Vlad, could you please give this is a try to see whether it
still behaves as expected?
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1876 bytes --]
commit e4b31d565a45e06ed2e51a005f5c00ff1d00725c
Author: Patrick McHardy <kaber@trash.net>
Date: Thu Jan 20 13:55:25 2011 +0100
rtnetlink: fix link attribute validation with IFLA_GROUP
rtnl_group_changelink() is invoked by rtnl_newlink() before the link
attributes have been validated. Additionally the group changes are
performed even if NLM_F_CREATE is specified and a new link is
created, while more reasonable semantics would be to set the group
value on the newly created link.
Fix both problems by moving the rtnl_group_changelink() invocation
down to the handling of non-existant links without NLM_F_CREATE()
and add a dev_set_group() call to rtnl_create_link().
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a0b2eeb..310eb80 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1548,6 +1548,8 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]));
if (tb[IFLA_LINKMODE])
dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
+ if (tb[IFLA_GROUP])
+ dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
return dev;
@@ -1606,10 +1608,6 @@ replay:
else {
if (ifname[0])
dev = __dev_get_by_name(net, ifname);
- else if (tb[IFLA_GROUP])
- return rtnl_group_changelink(net,
- nla_get_u32(tb[IFLA_GROUP]),
- ifm, tb);
else
dev = NULL;
}
@@ -1676,8 +1674,13 @@ replay:
return do_setlink(dev, ifm, tb, ifname, modified);
}
- if (!(nlh->nlmsg_flags & NLM_F_CREATE))
+ if (!(nlh->nlmsg_flags & NLM_F_CREATE)) {
+ if (ifm->ifi_index == 0 && tb[IFLA_GROUP])
+ return rtnl_group_changelink(net,
+ nla_get_u32(tb[IFLA_GROUP]),
+ ifm, tb);
return -ENODEV;
+ }
if (ifm->ifi_index)
return -EOPNOTSUPP;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rtnetlink: fix link attribute validation with IFLA_GROUP
2011-01-20 13:00 [PATCH] rtnetlink: fix link attribute validation with IFLA_GROUP Patrick McHardy
@ 2011-01-20 16:09 ` Vlad Dogaru
2011-01-21 7:29 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Vlad Dogaru @ 2011-01-20 16:09 UTC (permalink / raw)
To: Patrick McHardy; +Cc: NetDev, David S. Miller
On Thu, Jan 20, 2011 at 02:00:42PM +0100, Patrick McHardy wrote:
> Fix a few semantic problems with the new IFLA_GROUP attribute.
>
> Vlad, could you please give this is a try to see whether it
> still behaves as expected?
> commit e4b31d565a45e06ed2e51a005f5c00ff1d00725c
> Author: Patrick McHardy <kaber@trash.net>
> Date: Thu Jan 20 13:55:25 2011 +0100
>
> rtnetlink: fix link attribute validation with IFLA_GROUP
>
> rtnl_group_changelink() is invoked by rtnl_newlink() before the link
> attributes have been validated. Additionally the group changes are
> performed even if NLM_F_CREATE is specified and a new link is
> created, while more reasonable semantics would be to set the group
> value on the newly created link.
>
> Fix both problems by moving the rtnl_group_changelink() invocation
> down to the handling of non-existant links without NLM_F_CREATE()
> and add a dev_set_group() call to rtnl_create_link().
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
Acked-by: Vlad Dogaru <ddvlad@rosedu.org>
This looks OK and behaves as before. Thanks for taking the time to look
through it, the new semantics do seem saner.
There is a slight difference, though: in the (yet unapplied) iproute2
patch, ifi_index is set to -1 and kernel space checks that it is <= 0;
your patch checks for == 0. I will update the iproute2 patches with
setting ifi_index to 0 (and other changes) and resubmit them.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtnetlink: fix link attribute validation with IFLA_GROUP
2011-01-20 16:09 ` Vlad Dogaru
@ 2011-01-21 7:29 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-01-21 7:29 UTC (permalink / raw)
To: ddvlad; +Cc: kaber, netdev
From: Vlad Dogaru <ddvlad@rosedu.org>
Date: Thu, 20 Jan 2011 18:09:10 +0200
> On Thu, Jan 20, 2011 at 02:00:42PM +0100, Patrick McHardy wrote:
>> Fix a few semantic problems with the new IFLA_GROUP attribute.
>>
>> Vlad, could you please give this is a try to see whether it
>> still behaves as expected?
>
>> commit e4b31d565a45e06ed2e51a005f5c00ff1d00725c
>> Author: Patrick McHardy <kaber@trash.net>
>> Date: Thu Jan 20 13:55:25 2011 +0100
>>
>> rtnetlink: fix link attribute validation with IFLA_GROUP
>>
>> rtnl_group_changelink() is invoked by rtnl_newlink() before the link
>> attributes have been validated. Additionally the group changes are
>> performed even if NLM_F_CREATE is specified and a new link is
>> created, while more reasonable semantics would be to set the group
>> value on the newly created link.
>>
>> Fix both problems by moving the rtnl_group_changelink() invocation
>> down to the handling of non-existant links without NLM_F_CREATE()
>> and add a dev_set_group() call to rtnl_create_link().
>>
>> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> Acked-by: Vlad Dogaru <ddvlad@rosedu.org>
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-21 7:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-20 13:00 [PATCH] rtnetlink: fix link attribute validation with IFLA_GROUP Patrick McHardy
2011-01-20 16:09 ` Vlad Dogaru
2011-01-21 7:29 ` David Miller
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).