Commit 90c325e3 authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by David S. Miller

rtnl/do_setlink(): last arg is now a set of flags

There is no functional changes with this commit, it only prepares the next one.
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1889b0e7
...@@ -1481,9 +1481,10 @@ static int do_set_master(struct net_device *dev, int ifindex) ...@@ -1481,9 +1481,10 @@ static int do_set_master(struct net_device *dev, int ifindex)
return 0; return 0;
} }
#define DO_SETLINK_MODIFIED 0x01
static int do_setlink(const struct sk_buff *skb, static int do_setlink(const struct sk_buff *skb,
struct net_device *dev, struct ifinfomsg *ifm, struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified) struct nlattr **tb, char *ifname, int status)
{ {
const struct net_device_ops *ops = dev->netdev_ops; const struct net_device_ops *ops = dev->netdev_ops;
int err; int err;
...@@ -1502,7 +1503,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1502,7 +1503,7 @@ static int do_setlink(const struct sk_buff *skb,
put_net(net); put_net(net);
if (err) if (err)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_MAP]) { if (tb[IFLA_MAP]) {
...@@ -1531,7 +1532,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1531,7 +1532,7 @@ static int do_setlink(const struct sk_buff *skb,
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_ADDRESS]) { if (tb[IFLA_ADDRESS]) {
...@@ -1551,19 +1552,19 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1551,19 +1552,19 @@ static int do_setlink(const struct sk_buff *skb,
kfree(sa); kfree(sa);
if (err) if (err)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_MTU]) { if (tb[IFLA_MTU]) {
err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU])); err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU]));
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_GROUP]) { if (tb[IFLA_GROUP]) {
dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP])); dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
/* /*
...@@ -1575,7 +1576,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1575,7 +1576,7 @@ static int do_setlink(const struct sk_buff *skb,
err = dev_change_name(dev, ifname); err = dev_change_name(dev, ifname);
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_IFALIAS]) { if (tb[IFLA_IFALIAS]) {
...@@ -1583,7 +1584,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1583,7 +1584,7 @@ static int do_setlink(const struct sk_buff *skb,
nla_len(tb[IFLA_IFALIAS])); nla_len(tb[IFLA_IFALIAS]));
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_BROADCAST]) { if (tb[IFLA_BROADCAST]) {
...@@ -1601,21 +1602,21 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1601,21 +1602,21 @@ static int do_setlink(const struct sk_buff *skb,
err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER])); err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
if (err) if (err)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_CARRIER]) { if (tb[IFLA_CARRIER]) {
err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER])); err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER]));
if (err) if (err)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_TXQLEN]) { if (tb[IFLA_TXQLEN]) {
unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]); unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);
if (dev->tx_queue_len ^ value) if (dev->tx_queue_len ^ value)
modified = 1; status |= DO_SETLINK_MODIFIED;
dev->tx_queue_len = value; dev->tx_queue_len = value;
} }
...@@ -1628,7 +1629,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1628,7 +1629,7 @@ static int do_setlink(const struct sk_buff *skb,
write_lock_bh(&dev_base_lock); write_lock_bh(&dev_base_lock);
if (dev->link_mode ^ value) if (dev->link_mode ^ value)
modified = 1; status |= DO_SETLINK_MODIFIED;
dev->link_mode = value; dev->link_mode = value;
write_unlock_bh(&dev_base_lock); write_unlock_bh(&dev_base_lock);
} }
...@@ -1644,7 +1645,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1644,7 +1645,7 @@ static int do_setlink(const struct sk_buff *skb,
err = do_setvfinfo(dev, attr); err = do_setvfinfo(dev, attr);
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
} }
err = 0; err = 0;
...@@ -1674,7 +1675,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1674,7 +1675,7 @@ static int do_setlink(const struct sk_buff *skb,
err = ops->ndo_set_vf_port(dev, vf, port); err = ops->ndo_set_vf_port(dev, vf, port);
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
} }
err = 0; err = 0;
...@@ -1692,7 +1693,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1692,7 +1693,7 @@ static int do_setlink(const struct sk_buff *skb,
err = ops->ndo_set_vf_port(dev, PORT_SELF_VF, port); err = ops->ndo_set_vf_port(dev, PORT_SELF_VF, port);
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (tb[IFLA_AF_SPEC]) { if (tb[IFLA_AF_SPEC]) {
...@@ -1709,13 +1710,13 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -1709,13 +1710,13 @@ static int do_setlink(const struct sk_buff *skb,
if (err < 0) if (err < 0)
goto errout; goto errout;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
} }
err = 0; err = 0;
errout: errout:
if (err < 0 && modified) if (err < 0 && status & DO_SETLINK_MODIFIED)
net_warn_ratelimited("A link change request failed with some changes committed already. Interface %s may have been left with an inconsistent configuration, please check.\n", net_warn_ratelimited("A link change request failed with some changes committed already. Interface %s may have been left with an inconsistent configuration, please check.\n",
dev->name); dev->name);
...@@ -1999,7 +2000,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1999,7 +2000,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
} }
if (dev) { if (dev) {
int modified = 0; int status = 0;
if (nlh->nlmsg_flags & NLM_F_EXCL) if (nlh->nlmsg_flags & NLM_F_EXCL)
return -EEXIST; return -EEXIST;
...@@ -2014,7 +2015,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -2014,7 +2015,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
err = ops->changelink(dev, tb, data); err = ops->changelink(dev, tb, data);
if (err < 0) if (err < 0)
return err; return err;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
if (linkinfo[IFLA_INFO_SLAVE_DATA]) { if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
...@@ -2025,10 +2026,10 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -2025,10 +2026,10 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
tb, slave_data); tb, slave_data);
if (err < 0) if (err < 0)
return err; return err;
modified = 1; status |= DO_SETLINK_MODIFIED;
} }
return do_setlink(skb, dev, ifm, tb, ifname, modified); return do_setlink(skb, dev, ifm, tb, ifname, status);
} }
if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { if (!(nlh->nlmsg_flags & NLM_F_CREATE)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment