mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									cbda10fa97
								
							
						
					
					
						commit
						e7ed828f10
					
				
					 1 changed files with 28 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1558,6 +1558,24 @@ struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
 | 
			
		|||
}
 | 
			
		||||
EXPORT_SYMBOL(rtnl_create_link);
 | 
			
		||||
 | 
			
		||||
static int rtnl_group_changelink(struct net *net, int group,
 | 
			
		||||
		struct ifinfomsg *ifm,
 | 
			
		||||
		struct nlattr **tb)
 | 
			
		||||
{
 | 
			
		||||
	struct net_device *dev;
 | 
			
		||||
	int err;
 | 
			
		||||
 | 
			
		||||
	for_each_netdev(net, dev) {
 | 
			
		||||
		if (dev->group == group) {
 | 
			
		||||
			err = do_setlink(dev, ifm, tb, NULL, 0);
 | 
			
		||||
			if (err < 0)
 | 
			
		||||
				return err;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 | 
			
		||||
{
 | 
			
		||||
	struct net *net = sock_net(skb->sk);
 | 
			
		||||
| 
						 | 
				
			
			@ -1585,10 +1603,16 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 | 
			
		|||
	ifm = nlmsg_data(nlh);
 | 
			
		||||
	if (ifm->ifi_index > 0)
 | 
			
		||||
		dev = __dev_get_by_index(net, ifm->ifi_index);
 | 
			
		||||
	else if (ifname[0])
 | 
			
		||||
	else {
 | 
			
		||||
		if (ifname[0])
 | 
			
		||||
			dev = __dev_get_by_name(net, ifname);
 | 
			
		||||
		else if (tb[IFLA_GROUP])
 | 
			
		||||
			return rtnl_group_changelink(net,
 | 
			
		||||
					nla_get_u32(tb[IFLA_GROUP]),
 | 
			
		||||
					ifm, tb);
 | 
			
		||||
		else
 | 
			
		||||
			dev = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = validate_linkmsg(dev, tb);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue