forked from mirrors/linux
		
	s390/qeth: fix race when setting MAC address
When qeth_l2_set_mac_address() finds the card in a non-reachable state, it merely copies the new MAC address into dev->dev_addr so that __qeth_l2_set_online() can later register it with the HW. But __qeth_l2_set_online() may very well be running concurrently, so we can't trust the card state without appropriate locking: If the online sequence is past the point where it registers dev->dev_addr (but not yet in SOFTSETUP state), any address change needs to be properly programmed into the HW. Otherwise the netdevice ends up with a different MAC address than what's set in the HW, and inbound traffic is not forwarded as expected. This is most likely to occur for OSD in LPAR, where commit21b1702af1("s390/qeth: improve fallback to random MAC address") now triggers eg. systemd to immediately change the MAC when the netdevice is registered with a NET_ADDR_RANDOM address. Fixes:bcacfcbc82("s390/qeth: fix MAC address update sequence") Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									4664610537
								
							
						
					
					
						commit
						4789a21880
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		|  | @ -501,27 +501,34 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p) | |||
| 		return -ERESTARTSYS; | ||||
| 	} | ||||
| 
 | ||||
| 	/* avoid racing against concurrent state change: */ | ||||
| 	if (!mutex_trylock(&card->conf_mutex)) | ||||
| 		return -EAGAIN; | ||||
| 
 | ||||
| 	if (!qeth_card_hw_is_reachable(card)) { | ||||
| 		ether_addr_copy(dev->dev_addr, addr->sa_data); | ||||
| 		return 0; | ||||
| 		goto out_unlock; | ||||
| 	} | ||||
| 
 | ||||
| 	/* don't register the same address twice */ | ||||
| 	if (ether_addr_equal_64bits(dev->dev_addr, addr->sa_data) && | ||||
| 	    (card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED)) | ||||
| 		return 0; | ||||
| 		goto out_unlock; | ||||
| 
 | ||||
| 	/* add the new address, switch over, drop the old */ | ||||
| 	rc = qeth_l2_send_setmac(card, addr->sa_data); | ||||
| 	if (rc) | ||||
| 		return rc; | ||||
| 		goto out_unlock; | ||||
| 	ether_addr_copy(old_addr, dev->dev_addr); | ||||
| 	ether_addr_copy(dev->dev_addr, addr->sa_data); | ||||
| 
 | ||||
| 	if (card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED) | ||||
| 		qeth_l2_remove_mac(card, old_addr); | ||||
| 	card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; | ||||
| 	return 0; | ||||
| 
 | ||||
| out_unlock: | ||||
| 	mutex_unlock(&card->conf_mutex); | ||||
| 	return rc; | ||||
| } | ||||
| 
 | ||||
| static void qeth_promisc_to_bridge(struct qeth_card *card) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Julian Wiedmann
						Julian Wiedmann