aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.c
diff options
context:
space:
mode:
authorVlad Dogaru <ddvlad@rosedu.org>2011-01-13 18:38:31 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-20 02:31:10 -0500
commite7ed828f10bd89a28f821ae7f20e691704d61923 (patch)
treee1e19b5e6d7c2f5291a7ea6a09ff34cf631a3c67 /net/core/rtnetlink.c
parentcbda10fa97d72c7a1923be4426171aa90e8c6dab (diff)
netlink: support setting devgroup parameters
If a rtnetlink request specifies a negative or zero ifindex and has no interface name attribute, but has a group attribute, then the chenges are made to all the interfaces belonging to the specified group. Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org> Acked-by: Jamal Hadi Salim <hadi@cyberus.ca> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r--net/core/rtnetlink.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 09062b07bf7f..a0b2eeb3b610 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1558,6 +1558,24 @@ err:
1558} 1558}
1559EXPORT_SYMBOL(rtnl_create_link); 1559EXPORT_SYMBOL(rtnl_create_link);
1560 1560
1561static int rtnl_group_changelink(struct net *net, int group,
1562 struct ifinfomsg *ifm,
1563 struct nlattr **tb)
1564{
1565 struct net_device *dev;
1566 int err;
1567
1568 for_each_netdev(net, dev) {
1569 if (dev->group == group) {
1570 err = do_setlink(dev, ifm, tb, NULL, 0);
1571 if (err < 0)
1572 return err;
1573 }
1574 }
1575
1576 return 0;
1577}
1578
1561static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1579static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1562{ 1580{
1563 struct net *net = sock_net(skb->sk); 1581 struct net *net = sock_net(skb->sk);
@@ -1585,10 +1603,16 @@ replay:
1585 ifm = nlmsg_data(nlh); 1603 ifm = nlmsg_data(nlh);
1586 if (ifm->ifi_index > 0) 1604 if (ifm->ifi_index > 0)
1587 dev = __dev_get_by_index(net, ifm->ifi_index); 1605 dev = __dev_get_by_index(net, ifm->ifi_index);
1588 else if (ifname[0]) 1606 else {
1589 dev = __dev_get_by_name(net, ifname); 1607 if (ifname[0])
1590 else 1608 dev = __dev_get_by_name(net, ifname);
1591 dev = NULL; 1609 else if (tb[IFLA_GROUP])
1610 return rtnl_group_changelink(net,
1611 nla_get_u32(tb[IFLA_GROUP]),
1612 ifm, tb);
1613 else
1614 dev = NULL;
1615 }
1592 1616
1593 err = validate_linkmsg(dev, tb); 1617 err = validate_linkmsg(dev, tb);
1594 if (err < 0) 1618 if (err < 0)