Skip to content

Commit e7ed828

Browse files
ddvladdavem330
authored andcommitted
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 <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cbda10f commit e7ed828

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

net/core/rtnetlink.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,24 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
15581558
}
15591559
EXPORT_SYMBOL(rtnl_create_link);
15601560

1561+
static 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+
15611579
static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
15621580
{
15631581
struct net *net = sock_net(skb->sk);
@@ -1585,10 +1603,16 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
15851603
ifm = nlmsg_data(nlh);
15861604
if (ifm->ifi_index > 0)
15871605
dev = __dev_get_by_index(net, ifm->ifi_index);
1588-
else if (ifname[0])
1589-
dev = __dev_get_by_name(net, ifname);
1590-
else
1591-
dev = NULL;
1606+
else {
1607+
if (ifname[0])
1608+
dev = __dev_get_by_name(net, ifname);
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+
}
15921616

15931617
err = validate_linkmsg(dev, tb);
15941618
if (err < 0)

0 commit comments

Comments
 (0)