diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2014-09-01 10:07:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-02 15:57:04 -0400 |
commit | 90c325e3bfe14ef360de6650fa2a2e92685e5cee (patch) | |
tree | 4f64122b802812d540186f73f5e84a829fe2245f /net/core | |
parent | 1889b0e7efe8373793069bd3deb7702a51e6f2a5 (diff) |
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: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/rtnetlink.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 2bd9fb15b987..7d84db3e0597 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1481,9 +1481,10 @@ static int do_set_master(struct net_device *dev, int ifindex) | |||
1481 | return 0; | 1481 | return 0; |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | #define DO_SETLINK_MODIFIED 0x01 | ||
1484 | static int do_setlink(const struct sk_buff *skb, | 1485 | static int do_setlink(const struct sk_buff *skb, |
1485 | struct net_device *dev, struct ifinfomsg *ifm, | 1486 | struct net_device *dev, struct ifinfomsg *ifm, |
1486 | struct nlattr **tb, char *ifname, int modified) | 1487 | struct nlattr **tb, char *ifname, int status) |
1487 | { | 1488 | { |
1488 | const struct net_device_ops *ops = dev->netdev_ops; | 1489 | const struct net_device_ops *ops = dev->netdev_ops; |
1489 | int err; | 1490 | int err; |
@@ -1502,7 +1503,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1502 | put_net(net); | 1503 | put_net(net); |
1503 | if (err) | 1504 | if (err) |
1504 | goto errout; | 1505 | goto errout; |
1505 | modified = 1; | 1506 | status |= DO_SETLINK_MODIFIED; |
1506 | } | 1507 | } |
1507 | 1508 | ||
1508 | if (tb[IFLA_MAP]) { | 1509 | if (tb[IFLA_MAP]) { |
@@ -1531,7 +1532,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1531 | if (err < 0) | 1532 | if (err < 0) |
1532 | goto errout; | 1533 | goto errout; |
1533 | 1534 | ||
1534 | modified = 1; | 1535 | status |= DO_SETLINK_MODIFIED; |
1535 | } | 1536 | } |
1536 | 1537 | ||
1537 | if (tb[IFLA_ADDRESS]) { | 1538 | if (tb[IFLA_ADDRESS]) { |
@@ -1551,19 +1552,19 @@ static int do_setlink(const struct sk_buff *skb, | |||
1551 | kfree(sa); | 1552 | kfree(sa); |
1552 | if (err) | 1553 | if (err) |
1553 | goto errout; | 1554 | goto errout; |
1554 | modified = 1; | 1555 | status |= DO_SETLINK_MODIFIED; |
1555 | } | 1556 | } |
1556 | 1557 | ||
1557 | if (tb[IFLA_MTU]) { | 1558 | if (tb[IFLA_MTU]) { |
1558 | err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU])); | 1559 | err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU])); |
1559 | if (err < 0) | 1560 | if (err < 0) |
1560 | goto errout; | 1561 | goto errout; |
1561 | modified = 1; | 1562 | status |= DO_SETLINK_MODIFIED; |
1562 | } | 1563 | } |
1563 | 1564 | ||
1564 | if (tb[IFLA_GROUP]) { | 1565 | if (tb[IFLA_GROUP]) { |
1565 | dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP])); | 1566 | dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP])); |
1566 | modified = 1; | 1567 | status |= DO_SETLINK_MODIFIED; |
1567 | } | 1568 | } |
1568 | 1569 | ||
1569 | /* | 1570 | /* |
@@ -1575,7 +1576,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1575 | err = dev_change_name(dev, ifname); | 1576 | err = dev_change_name(dev, ifname); |
1576 | if (err < 0) | 1577 | if (err < 0) |
1577 | goto errout; | 1578 | goto errout; |
1578 | modified = 1; | 1579 | status |= DO_SETLINK_MODIFIED; |
1579 | } | 1580 | } |
1580 | 1581 | ||
1581 | if (tb[IFLA_IFALIAS]) { | 1582 | if (tb[IFLA_IFALIAS]) { |
@@ -1583,7 +1584,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1583 | nla_len(tb[IFLA_IFALIAS])); | 1584 | nla_len(tb[IFLA_IFALIAS])); |
1584 | if (err < 0) | 1585 | if (err < 0) |
1585 | goto errout; | 1586 | goto errout; |
1586 | modified = 1; | 1587 | status |= DO_SETLINK_MODIFIED; |
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | if (tb[IFLA_BROADCAST]) { | 1590 | if (tb[IFLA_BROADCAST]) { |
@@ -1601,21 +1602,21 @@ static int do_setlink(const struct sk_buff *skb, | |||
1601 | err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER])); | 1602 | err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER])); |
1602 | if (err) | 1603 | if (err) |
1603 | goto errout; | 1604 | goto errout; |
1604 | modified = 1; | 1605 | status |= DO_SETLINK_MODIFIED; |
1605 | } | 1606 | } |
1606 | 1607 | ||
1607 | if (tb[IFLA_CARRIER]) { | 1608 | if (tb[IFLA_CARRIER]) { |
1608 | err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER])); | 1609 | err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER])); |
1609 | if (err) | 1610 | if (err) |
1610 | goto errout; | 1611 | goto errout; |
1611 | modified = 1; | 1612 | status |= DO_SETLINK_MODIFIED; |
1612 | } | 1613 | } |
1613 | 1614 | ||
1614 | if (tb[IFLA_TXQLEN]) { | 1615 | if (tb[IFLA_TXQLEN]) { |
1615 | unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]); | 1616 | unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]); |
1616 | 1617 | ||
1617 | if (dev->tx_queue_len ^ value) | 1618 | if (dev->tx_queue_len ^ value) |
1618 | modified = 1; | 1619 | status |= DO_SETLINK_MODIFIED; |
1619 | 1620 | ||
1620 | dev->tx_queue_len = value; | 1621 | dev->tx_queue_len = value; |
1621 | } | 1622 | } |
@@ -1628,7 +1629,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1628 | 1629 | ||
1629 | write_lock_bh(&dev_base_lock); | 1630 | write_lock_bh(&dev_base_lock); |
1630 | if (dev->link_mode ^ value) | 1631 | if (dev->link_mode ^ value) |
1631 | modified = 1; | 1632 | status |= DO_SETLINK_MODIFIED; |
1632 | dev->link_mode = value; | 1633 | dev->link_mode = value; |
1633 | write_unlock_bh(&dev_base_lock); | 1634 | write_unlock_bh(&dev_base_lock); |
1634 | } | 1635 | } |
@@ -1644,7 +1645,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1644 | err = do_setvfinfo(dev, attr); | 1645 | err = do_setvfinfo(dev, attr); |
1645 | if (err < 0) | 1646 | if (err < 0) |
1646 | goto errout; | 1647 | goto errout; |
1647 | modified = 1; | 1648 | status |= DO_SETLINK_MODIFIED; |
1648 | } | 1649 | } |
1649 | } | 1650 | } |
1650 | err = 0; | 1651 | err = 0; |
@@ -1674,7 +1675,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1674 | err = ops->ndo_set_vf_port(dev, vf, port); | 1675 | err = ops->ndo_set_vf_port(dev, vf, port); |
1675 | if (err < 0) | 1676 | if (err < 0) |
1676 | goto errout; | 1677 | goto errout; |
1677 | modified = 1; | 1678 | status |= DO_SETLINK_MODIFIED; |
1678 | } | 1679 | } |
1679 | } | 1680 | } |
1680 | err = 0; | 1681 | err = 0; |
@@ -1692,7 +1693,7 @@ static int do_setlink(const struct sk_buff *skb, | |||
1692 | err = ops->ndo_set_vf_port(dev, PORT_SELF_VF, port); | 1693 | err = ops->ndo_set_vf_port(dev, PORT_SELF_VF, port); |
1693 | if (err < 0) | 1694 | if (err < 0) |
1694 | goto errout; | 1695 | goto errout; |
1695 | modified = 1; | 1696 | status |= DO_SETLINK_MODIFIED; |
1696 | } | 1697 | } |
1697 | 1698 | ||
1698 | if (tb[IFLA_AF_SPEC]) { | 1699 | if (tb[IFLA_AF_SPEC]) { |
@@ -1709,13 +1710,13 @@ static int do_setlink(const struct sk_buff *skb, | |||
1709 | if (err < 0) | 1710 | if (err < 0) |
1710 | goto errout; | 1711 | goto errout; |
1711 | 1712 | ||
1712 | modified = 1; | 1713 | status |= DO_SETLINK_MODIFIED; |
1713 | } | 1714 | } |
1714 | } | 1715 | } |
1715 | err = 0; | 1716 | err = 0; |
1716 | 1717 | ||
1717 | errout: | 1718 | errout: |
1718 | if (err < 0 && modified) | 1719 | if (err < 0 && status & DO_SETLINK_MODIFIED) |
1719 | 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", | 1720 | 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", |
1720 | dev->name); | 1721 | dev->name); |
1721 | 1722 | ||
@@ -1999,7 +2000,7 @@ replay: | |||
1999 | } | 2000 | } |
2000 | 2001 | ||
2001 | if (dev) { | 2002 | if (dev) { |
2002 | int modified = 0; | 2003 | int status = 0; |
2003 | 2004 | ||
2004 | if (nlh->nlmsg_flags & NLM_F_EXCL) | 2005 | if (nlh->nlmsg_flags & NLM_F_EXCL) |
2005 | return -EEXIST; | 2006 | return -EEXIST; |
@@ -2014,7 +2015,7 @@ replay: | |||
2014 | err = ops->changelink(dev, tb, data); | 2015 | err = ops->changelink(dev, tb, data); |
2015 | if (err < 0) | 2016 | if (err < 0) |
2016 | return err; | 2017 | return err; |
2017 | modified = 1; | 2018 | status |= DO_SETLINK_MODIFIED; |
2018 | } | 2019 | } |
2019 | 2020 | ||
2020 | if (linkinfo[IFLA_INFO_SLAVE_DATA]) { | 2021 | if (linkinfo[IFLA_INFO_SLAVE_DATA]) { |
@@ -2025,10 +2026,10 @@ replay: | |||
2025 | tb, slave_data); | 2026 | tb, slave_data); |
2026 | if (err < 0) | 2027 | if (err < 0) |
2027 | return err; | 2028 | return err; |
2028 | modified = 1; | 2029 | status |= DO_SETLINK_MODIFIED; |
2029 | } | 2030 | } |
2030 | 2031 | ||
2031 | return do_setlink(skb, dev, ifm, tb, ifname, modified); | 2032 | return do_setlink(skb, dev, ifm, tb, ifname, status); |
2032 | } | 2033 | } |
2033 | 2034 | ||
2034 | if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { | 2035 | if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { |