diff options
author | Patrick McHardy <kaber@trash.net> | 2007-05-22 20:00:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-05-22 20:00:01 -0400 |
commit | 83b496e928dbd38104bfb107230cc88751b09d89 (patch) | |
tree | c4c31034bd85034845974de89ddff52ab04dfdcf | |
parent | 1f8481d19af005c469ee50cf972486240905585e (diff) |
[RTNETLINK]: Allow changing of subsets of netdevice flags in rtnl_setlink
rtnl_setlink doesn't allow to change subsets of the flags, just to override
the set entirely by a new one. This means that for simply setting a device
up or down userspace first needs to query the current flags, change it and
send the changed flags back, which is racy and needlessly complicated.
Mask the flags using ifi_change since this is what it is intended for.
For backwards compatibility treat ifi_change == 0 as ~0 (even though it
seems quite unlikely that anyone has been using this so far).
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/rtnetlink.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 8c971a2efe2a..1a6c5b9d41b6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -689,8 +689,15 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
689 | } | 689 | } |
690 | 690 | ||
691 | 691 | ||
692 | if (ifm->ifi_flags) | 692 | if (ifm->ifi_flags || ifm->ifi_change) { |
693 | dev_change_flags(dev, ifm->ifi_flags); | 693 | unsigned int flags = ifm->ifi_flags; |
694 | |||
695 | /* bugwards compatibility: ifi_change == 0 is treated as ~0 */ | ||
696 | if (ifm->ifi_change) | ||
697 | flags = (flags & ifm->ifi_change) | | ||
698 | (dev->flags & ~ifm->ifi_change); | ||
699 | dev_change_flags(dev, flags); | ||
700 | } | ||
694 | 701 | ||
695 | if (tb[IFLA_TXQLEN]) | 702 | if (tb[IFLA_TXQLEN]) |
696 | dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); | 703 | dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); |