mac80211: fix MAC address allocations when local bit set on base addr
Testing with hwsim reveals two problems:
1. phyX/addresses has two addresses and mac80211_get_addr keeps
returning the last one when asked for more;
2. The base address has the local bit set and the operation unsets it.
Fix both.
Fixes: 866790fd82
Reported-by: Zero_Chaos
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
			
			
This commit is contained in:
		 Paul Fertser
					Paul Fertser
				
			
				
					committed by
					
						 Petr Štetiar
						Petr Štetiar
					
				
			
			
				
	
			
			
			 Petr Štetiar
						Petr Štetiar
					
				
			
						parent
						
							a9deace10c
						
					
				
				
					commit
					39c8bc4422
				
			| @@ -409,7 +409,7 @@ mac80211_generate_mac() { | |||||||
| 	[ "$mask" = "00:00:00:00:00:00" ] && { | 	[ "$mask" = "00:00:00:00:00:00" ] && { | ||||||
| 		mask="ff:ff:ff:ff:ff:ff"; | 		mask="ff:ff:ff:ff:ff:ff"; | ||||||
|  |  | ||||||
| 		[ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt 1 ] && { | 		[ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt $id ] && { | ||||||
| 			addr="$(mac80211_get_addr "$phy" "$id")" | 			addr="$(mac80211_get_addr "$phy" "$id")" | ||||||
| 			[ -n "$addr" ] && { | 			[ -n "$addr" ] && { | ||||||
| 				echo "$addr" | 				echo "$addr" | ||||||
| @@ -429,7 +429,7 @@ mac80211_generate_mac() { | |||||||
| 	[ "$((0x$mask1))" -gt 0 ] && { | 	[ "$((0x$mask1))" -gt 0 ] && { | ||||||
| 		b1="0x$1" | 		b1="0x$1" | ||||||
| 		[ "$id" -gt 0 ] && \ | 		[ "$id" -gt 0 ] && \ | ||||||
| 			b1=$(($b1 ^ ((($id - !($b1 & 2)) << 2) | 0x2))) | 			b1=$(($b1 ^ ((($id - !($b1 & 2)) << 2)) | 0x2)) | ||||||
| 		printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6 | 		printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6 | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user