mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	uspot: accounting: send RADIUS acct Stop on disconnect
If a client "disappears" from wireless, spotfilter eventually wipes their state data before the accounting removal occurs. Thus in radius_acct(), the ubus call returns empty and no RADIUS accounting Stop frame is sent in this condition, leaving a dangling accounting for the client. This commit solves this issue by maintaining a local copy of the most recent accounting data and sending that when the live data is no longer available. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
		 Thibaut VARÈNE
					Thibaut VARÈNE
				
			
				
					committed by
					
						 John Crispin
						John Crispin
					
				
			
			
				
	
			
			
			 John Crispin
						John Crispin
					
				
			
						parent
						
							e30cfbf36b
						
					
				
				
					commit
					ec924ea3d7
				
			| @@ -60,7 +60,7 @@ function radius_acct(interface, mac, payload) { | |||||||
| 	let state = ubus.call('spotfilter', 'client_get', { | 	let state = ubus.call('spotfilter', 'client_get', { | ||||||
| 		interface, | 		interface, | ||||||
| 		address: mac | 		address: mac | ||||||
| 	}); | 	}) || clients[interface][mac];	// fallback to last known state | ||||||
| 	if (!state) | 	if (!state) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| @@ -111,7 +111,20 @@ function radius_interim(interface, mac) { | |||||||
| function client_interim(interface, mac, time) { | function client_interim(interface, mac, time) { | ||||||
| 	let client = clients[interface][mac]; | 	let client = clients[interface][mac]; | ||||||
|  |  | ||||||
| 	if (!client.accounting || !client.interval) | 	if (!client.accounting) | ||||||
|  | 		return; | ||||||
|  |  | ||||||
|  | 	// preserve a copy of last spotfilter stats for use in disconnect case | ||||||
|  | 	let state = ubus.call('spotfilter', 'client_get', { | ||||||
|  | 		interface, | ||||||
|  | 		address: mac | ||||||
|  | 	}); | ||||||
|  | 	if (!state) | ||||||
|  | 		return; | ||||||
|  |  | ||||||
|  | 	client.acct_data = state.acct_data; | ||||||
|  |  | ||||||
|  | 	if (!client.interval) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	if (time >= client.next_interim) { | 	if (time >= client.next_interim) { | ||||||
| @@ -146,6 +159,9 @@ function client_add(interface, mac, state) { | |||||||
| 		session, | 		session, | ||||||
| 		idle, | 		idle, | ||||||
| 		max_total, | 		max_total, | ||||||
|  | 		data: { | ||||||
|  | 			connect: state.data.connect, | ||||||
|  | 		} | ||||||
| 	}; | 	}; | ||||||
| 	if (state.ip4addr) | 	if (state.ip4addr) | ||||||
| 		clients[interface][mac].ip4addr = state.ip4addr; | 		clients[interface][mac].ip4addr = state.ip4addr; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user