wg-quick: darwin: remove v6 routes after shutdown
This works around a Darwin kernel bug regarding interface removal. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									cfa4203be7
								
							
						
					
					
						commit
						f64f0cc740
					
				@ -106,7 +106,7 @@ add_if() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
del_routes() {
 | 
					del_routes() {
 | 
				
			||||||
	local todelete=( ) destination netif
 | 
						local todelete=( ) destination gateway netif
 | 
				
			||||||
	while read -r destination _ _ _ _ netif _; do
 | 
						while read -r destination _ _ _ _ netif _; do
 | 
				
			||||||
		[[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
 | 
							[[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
 | 
				
			||||||
	done < <(netstat -nr -f inet)
 | 
						done < <(netstat -nr -f inet)
 | 
				
			||||||
@ -114,8 +114,8 @@ del_routes() {
 | 
				
			|||||||
		cmd route -q delete -inet "$destination" >/dev/null || true
 | 
							cmd route -q delete -inet "$destination" >/dev/null || true
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	todelete=( )
 | 
						todelete=( )
 | 
				
			||||||
	while read -r destination _ _ netif; do
 | 
						while read -r destination gateway _ netif; do
 | 
				
			||||||
		[[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
 | 
							[[ $netif == "$REAL_INTERFACE" || ( $netif == lo* && $gateway == "$REAL_INTERFACE" ) ]] && todelete+=( "$destination" )
 | 
				
			||||||
	done < <(netstat -nr -f inet6)
 | 
						done < <(netstat -nr -f inet6)
 | 
				
			||||||
	for destination in "${todelete[@]}"; do
 | 
						for destination in "${todelete[@]}"; do
 | 
				
			||||||
		cmd route -q delete -inet6 "$destination" >/dev/null || true
 | 
							cmd route -q delete -inet6 "$destination" >/dev/null || true
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user