mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: hold netdev instance lock during nft ndo_setup_tc
Introduce new dev_setup_tc for nft ndo_setup_tc paths. Reviewed-by: Eric Dumazet <edumazet@google.com> Cc: Saeed Mahameed <saeed@kernel.org> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250305163732.2766420-3-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
		
							parent
							
								
									d4c22ec680
								
							
						
					
					
						commit
						c4f0f30b42
					
				
					 5 changed files with 22 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -3894,10 +3894,8 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 | 
			
		|||
	if (test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	netdev_lock(netdev);
 | 
			
		||||
	netif_set_real_num_rx_queues(netdev, total_qps);
 | 
			
		||||
	netif_set_real_num_tx_queues(netdev, total_qps);
 | 
			
		||||
	netdev_unlock(netdev);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3353,6 +3353,8 @@ int dev_alloc_name(struct net_device *dev, const char *name);
 | 
			
		|||
int dev_open(struct net_device *dev, struct netlink_ext_ack *extack);
 | 
			
		||||
void dev_close(struct net_device *dev);
 | 
			
		||||
void dev_close_many(struct list_head *head, bool unlink);
 | 
			
		||||
int dev_setup_tc(struct net_device *dev, enum tc_setup_type type,
 | 
			
		||||
		 void *type_data);
 | 
			
		||||
void dev_disable_lro(struct net_device *dev);
 | 
			
		||||
int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb);
 | 
			
		||||
u16 dev_pick_tx_zero(struct net_device *dev, struct sk_buff *skb,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1786,6 +1786,24 @@ void dev_close(struct net_device *dev)
 | 
			
		|||
}
 | 
			
		||||
EXPORT_SYMBOL(dev_close);
 | 
			
		||||
 | 
			
		||||
int dev_setup_tc(struct net_device *dev, enum tc_setup_type type,
 | 
			
		||||
		 void *type_data)
 | 
			
		||||
{
 | 
			
		||||
	const struct net_device_ops *ops = dev->netdev_ops;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	ASSERT_RTNL();
 | 
			
		||||
 | 
			
		||||
	if (!ops->ndo_setup_tc)
 | 
			
		||||
		return -EOPNOTSUPP;
 | 
			
		||||
 | 
			
		||||
	netdev_lock_ops(dev);
 | 
			
		||||
	ret = ops->ndo_setup_tc(dev, type, type_data);
 | 
			
		||||
	netdev_unlock_ops(dev);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
EXPORT_SYMBOL(dev_setup_tc);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *	dev_disable_lro - disable Large Receive Offload on a device
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1175,7 +1175,7 @@ static int nf_flow_table_offload_cmd(struct flow_block_offload *bo,
 | 
			
		|||
	nf_flow_table_block_offload_init(bo, dev_net(dev), cmd, flowtable,
 | 
			
		||||
					 extack);
 | 
			
		||||
	down_write(&flowtable->flow_block_lock);
 | 
			
		||||
	err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_FT, bo);
 | 
			
		||||
	err = dev_setup_tc(dev, TC_SETUP_FT, bo);
 | 
			
		||||
	up_write(&flowtable->flow_block_lock);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -390,7 +390,7 @@ static int nft_block_offload_cmd(struct nft_base_chain *chain,
 | 
			
		|||
 | 
			
		||||
	nft_flow_block_offload_init(&bo, dev_net(dev), cmd, chain, &extack);
 | 
			
		||||
 | 
			
		||||
	err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_BLOCK, &bo);
 | 
			
		||||
	err = dev_setup_tc(dev, TC_SETUP_BLOCK, &bo);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue