mirror of https://github.com/microsoft/WSL
wip address feedback and simplify script
This commit is contained in:
parent
417be2744f
commit
330da55610
|
|
@ -117,35 +117,16 @@ Availability Capabilities CapabilityDescriptions
|
|||
{3, 4, 10} {"Random Access", "Supports Writing", "SMART Notification"} \\.\PHYSICALDRIVE2 SCSI TRUE Fixed hard disk media ST2000DM001-1ER164 \\.\PHYSICALDRIVE2 1
|
||||
```
|
||||
|
||||
#### Networking issues
|
||||
#### Collect WSL logs for networking issues
|
||||
|
||||
Install tcpdump in your WSL distribution using the following commands.
|
||||
Note: This might not work if WSL has Internet connectivity issues.
|
||||
To collect WSL networking logs, download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1) in an administrative powershell prompt:
|
||||
|
||||
```
|
||||
# sudo apt-get update
|
||||
# sudo apt-get -y install tcpdump
|
||||
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-networking-logs.ps1" -OutFile collect-networking-logs.ps1
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
.\collect-networking-logs.ps1
|
||||
```
|
||||
|
||||
Run networking_diagnostics.bat in an administrative Powershell window:
|
||||
|
||||
```
|
||||
$ Invoke-WebRequest 'https://github.com/microsoft/WSL/archive/refs/heads/master.zip' -OutFile .\wsl.zip
|
||||
$ Expand-Archive .\wsl.zip .\
|
||||
$ Remove-Item .\wsl.zip
|
||||
$ cd .\WSL-master\diagnostics
|
||||
$ .\networking_diagnostics.bat
|
||||
```
|
||||
|
||||
Note:
|
||||
If tcpdump is installed, the script will open 2 more shells.
|
||||
If tcpdump is not installed, only 1 additional shell will be opened
|
||||
Wait for those shells to be opened before reproducing the issue
|
||||
|
||||
After reproducing the issue, in the shell with tcpdump, hit Ctrl + C. In the other shell, press any key.
|
||||
After the new shells exit, press any key in the original Powershell window.
|
||||
|
||||
The script will output the path to a zip archive with the diagnostics when done. Collect the zip and attach it to the issue.
|
||||
The script will output the path of the log file once done.
|
||||
|
||||
<!-- Preserving anchors -->
|
||||
<div id="8-detailed-logs"></div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,191 @@
|
|||
#Requires -RunAsAdministrator
|
||||
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[switch]$DeleteHnsState = $false
|
||||
)
|
||||
|
||||
$folder = "WslNetworkingLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
|
||||
mkdir -p $folder
|
||||
|
||||
# TODO! tcpdump??
|
||||
|
||||
# Retrieve WSL version and wslconfig file
|
||||
get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
|
||||
|
||||
$wslconfig = "$env:USERPROFILE/.wslconfig"
|
||||
if (Test-Path $wslconfig)
|
||||
{
|
||||
Copy-Item $wslconfig $folder
|
||||
}
|
||||
|
||||
if ($DeleteHnsState)
|
||||
{
|
||||
# The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
|
||||
Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL'} | Remove-HnsNetwork
|
||||
|
||||
# Stop WSL.
|
||||
net.exe stop WslService || net.exe stop LxssManager
|
||||
}
|
||||
|
||||
# Collect Linux network state before the repro
|
||||
& wsl.exe -e ./networking.sh 2>&1 > $folder/linux_network_configuration_before.log
|
||||
|
||||
# Start logging.
|
||||
$logProfile = ".\wsl_networking.wprp"
|
||||
$wprOutputLog = "$folder/wpr.txt"
|
||||
|
||||
wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog
|
||||
if ($LastExitCode -Ne 0)
|
||||
{
|
||||
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
|
||||
wpr.exe -cancel 2>&1 >> $wprOutputLog
|
||||
|
||||
wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog
|
||||
if ($LastExitCode -Ne 0)
|
||||
{
|
||||
Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
|
||||
}
|
||||
}
|
||||
|
||||
# Start packet capture using pktmon
|
||||
pktmon start -c --flags 0x1A --file-name "$folder/pktmon.etl"
|
||||
|
||||
# Start WFP capture
|
||||
netsh wfp capture start file="$folder/wfpdiag.cab"
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host -NoNewLine -ForegroundColor Green "Log collection is running. Please reproduce the problem and press any key to save the logs."
|
||||
|
||||
$KeysToIgnore =
|
||||
16, # Shift (left or right)
|
||||
17, # Ctrl (left or right)
|
||||
18, # Alt (left or right)
|
||||
20, # Caps lock
|
||||
91, # Windows key (left)
|
||||
92, # Windows key (right)
|
||||
93, # Menu key
|
||||
144, # Num lock
|
||||
145, # Scroll lock
|
||||
166, # Back
|
||||
167, # Forward
|
||||
168, # Refresh
|
||||
169, # Stop
|
||||
170, # Search
|
||||
171, # Favorites
|
||||
172, # Start/Home
|
||||
173, # Mute
|
||||
174, # Volume Down
|
||||
175, # Volume Up
|
||||
176, # Next Track
|
||||
177, # Previous Track
|
||||
178, # Stop Media
|
||||
179, # Play
|
||||
180, # Mail
|
||||
181, # Select Media
|
||||
182, # Application 1
|
||||
183 # Application 2
|
||||
|
||||
$Key = $null
|
||||
while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
|
||||
{
|
||||
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
||||
}
|
||||
|
||||
Write-Host "`nSaving logs..."
|
||||
}
|
||||
finally
|
||||
{
|
||||
netsh wfp capture stop
|
||||
pktmon stop
|
||||
wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
|
||||
}
|
||||
|
||||
# Collect Linux network state after the repro
|
||||
& wsl.exe -e ./networking.sh 2>&1 > $folder/linux_network_configuration_after.log
|
||||
|
||||
# Collect host networking state relevant for WSL
|
||||
# Using a try/catch for commands below, as some of them do not exist on all OS versions
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$folder/Get-NetAdapter.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$folder/Get-NetIPConfiguration.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetRoute | Out-File -FilePath "$folder/Get-NetRoute.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$folder/Get-NetFirewallHyperVVMCreator.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallHyperVVMSetting_ActiveStore.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallHyperVProfile_ActiveStore.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVRule -PolicyStore ActiveStore | Out-File -FilePath "$folder/Get-NetFirewallHyperVRule_ActiveStore.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVPort | Out-File -FilePath "$folder/Get-NetFirewallHyperVPort.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
& hnsdiag.exe list all 2>&1 > $folder/hnsdiag_list_all.log
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
& hnsdiag.exe list endpoints -df 2>&1 > $folder/hnsdiag_list_endpoints.log
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($port in Get-NetFirewallHyperVPort)
|
||||
{
|
||||
& vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$folder/vfp-port-$($port.PortName)-get-port-state.log"
|
||||
& vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$folder/vfp-port-$($port.PortName)-list-rule.log"
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
& vfpctrl.exe /list-vmswitch-port 2>&1 > $folder/vfpctrl_list_vmswitch_port.log
|
||||
}
|
||||
catch {}
|
||||
|
||||
logArchive = "$(Resolve-Path $folder).zip"
|
||||
Compress-Archive -Path $folder -DestinationPath $logArchive
|
||||
Remove-Item $folder -Recurse
|
||||
|
||||
Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."
|
||||
|
|
@ -130,79 +130,6 @@ if ($Dump)
|
|||
}
|
||||
}
|
||||
|
||||
# Collect networking state relevant for WSL
|
||||
# Using a try/catch for commands below, as some of them do not exist on all OS versions
|
||||
|
||||
Write-Host "`nCollecting additional network state..."
|
||||
|
||||
$networkingFolder = "$folder/networking"
|
||||
mkdir -p $networkingFolder
|
||||
|
||||
# Host networking info
|
||||
try
|
||||
{
|
||||
Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$networkingFolder/Get-NetAdapter.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$networkingFolder/Get-NetIPConfiguration.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMCreator.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMSetting_ActiveStore.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVProfile_ActiveStore.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
Get-NetFirewallHyperVPort | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVPort.log" -Append
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
& hnsdiag.exe list all 2>&1 > $networkingFolder/hnsdiag_list_all.log
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
& hnsdiag.exe list endpoints -df 2>&1 > $networkingFolder/hnsdiag_list_endpoints.log
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($port in Get-NetFirewallHyperVPort)
|
||||
{
|
||||
& vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-get-port-state.log"
|
||||
& vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-list-rule.log"
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
|
||||
try
|
||||
{
|
||||
& vfpctrl.exe /list-vmswitch-port 2>&1 > $networkingFolder/vfpctrl_list_vmswitch_port.log
|
||||
}
|
||||
catch {}
|
||||
|
||||
$logArchive = "$(Resolve-Path $folder).zip"
|
||||
Compress-Archive -Path $folder -DestinationPath $logArchive
|
||||
Remove-Item $folder -Recurse
|
||||
|
|
|
|||
|
|
@ -5,11 +5,15 @@ set -xu
|
|||
lsb_release -a || cat /etc/issue /etc/os-release
|
||||
uname -a
|
||||
|
||||
# Output adapter & routing configuration.
|
||||
echo "Printing adapter & routing configuration"
|
||||
ip a
|
||||
ip route show table all
|
||||
ip neighbor
|
||||
ip link
|
||||
|
||||
# Display the DNS configuration.
|
||||
# This will include the HTTP proxy env variables, if present
|
||||
echo "Printing all environment variables"
|
||||
printenv
|
||||
|
||||
echo "Printing DNS configuration"
|
||||
cat /etc/resolv.conf
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
:: Check for administrator privileges.
|
||||
net session >nul 2>&1 || goto :admin
|
||||
|
||||
:: Validate that required files are here.
|
||||
if not exist wsl_networking.wprp (echo wsl_networking.wprp not found && exit /b 1)
|
||||
if not exist networking.sh (echo networking.sh not found && exit /b 1)
|
||||
|
||||
set networking_folder=".\networking_logs"
|
||||
set neworking_logs_zip=".\WslNetworkingLogs.zip"
|
||||
|
||||
mkdir %networking_folder%
|
||||
|
||||
cd %networking_folder%
|
||||
|
||||
IF "%1"=="--stop-wsl" (
|
||||
:: The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
|
||||
echo Deleting HNS network
|
||||
powershell.exe -NoProfile "Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL'} | Remove-HnsNetwork"
|
||||
|
||||
:: Stop WSL.
|
||||
net.exe stop WslService || net.exe stop LxssManager
|
||||
)
|
||||
|
||||
wsl.exe tr -d "\r" ^| bash < ../networking.sh > wsl_network_configuration_before.log
|
||||
powershell Get-NetRoute > get_netroute.log
|
||||
|
||||
powershell invoke-expression 'cmd /c start powershell -Command { ..\collect-wsl-logs.ps1 }'
|
||||
powershell invoke-expression 'cmd /c start powershell -Command { "wsl.exe -u root sudo tcpdump -n -i any > tcpdump.log" }'
|
||||
|
||||
wpr -start ..\wsl_networking.wprp -filemode -instanceName wpr_networking
|
||||
pktmon start -c --flags 0x1A
|
||||
netsh wfp capture start
|
||||
|
||||
pause
|
||||
|
||||
:: allow some time for the user to stop logs in all the spawned shells
|
||||
timeout 20
|
||||
|
||||
netsh wfp capture stop
|
||||
pktmon stop
|
||||
wpr -stop wsl_networking.etl -instanceName wpr_networking
|
||||
|
||||
wsl.exe tr -d "\r" ^| bash < ../networking.sh > wsl_network_configuration_after.log
|
||||
|
||||
cd ..
|
||||
|
||||
del %neworking_logs_zip%
|
||||
powershell Compress-Archive -Path %networking_folder% -DestinationPath %neworking_logs_zip%
|
||||
|
||||
rmdir /s /q %networking_folder%
|
||||
|
||||
echo "Finished log collection - please collect the zip archive from the path below"
|
||||
powershell Resolve-Path %neworking_logs_zip%
|
||||
|
||||
exit /b 0
|
||||
|
||||
:: Error message if the user does not have administrative privileges.
|
||||
:admin
|
||||
echo This script needs to run with administrative privileges.
|
||||
exit /b 1
|
||||
Loading…
Reference in New Issue