mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	tipc: make function tipc_net_finalize() thread safe
The setting of the node address is not thread safe, meaning that
two discoverers may decide to set it simultanously, with a duplicate
entry in the name table as result. We fix that with this commit.
Fixes: 25b0b9c4e8 ("tipc: handle collisions of 32-bit node address hash values")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
			
			
This commit is contained in:
		
							parent
							
								
									92018c7ca9
								
							
						
					
					
						commit
						9faa89d4ed
					
				
					 1 changed files with 11 additions and 6 deletions
				
			
		| 
						 | 
					@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void tipc_net_finalize(struct net *net, u32 addr)
 | 
					void tipc_net_finalize(struct net *net, u32 addr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tipc_set_node_addr(net, addr);
 | 
						struct tipc_net *tn = tipc_net(net);
 | 
				
			||||||
	smp_mb();
 | 
					
 | 
				
			||||||
	tipc_named_reinit(net);
 | 
						spin_lock_bh(&tn->node_list_lock);
 | 
				
			||||||
	tipc_sk_reinit(net);
 | 
						if (!tipc_own_addr(net)) {
 | 
				
			||||||
	tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
 | 
							tipc_set_node_addr(net, addr);
 | 
				
			||||||
			     TIPC_CLUSTER_SCOPE, 0, addr);
 | 
							tipc_named_reinit(net);
 | 
				
			||||||
 | 
							tipc_sk_reinit(net);
 | 
				
			||||||
 | 
							tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
 | 
				
			||||||
 | 
									     TIPC_CLUSTER_SCOPE, 0, addr);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						spin_unlock_bh(&tn->node_list_lock);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void tipc_net_stop(struct net *net)
 | 
					void tipc_net_stop(struct net *net)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue