@samitouri / QOSAMI-WSL / commits / 8f23d2f2

Add networking diagnostics to collect-wsl-logs script (#10180)

Add netwokring diagnostics to collect-wsl-logs script and additional commands to networking.sh --------- Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com> Co-authored-by: Mitchell Schmidt <74631052+mitschmi@users.noreply.github.com>

Cătălin Emil Fetoiu committed Jun 21, 2023 at 17:23 UTC 8f23d2f2349a48413a98c330333eb14937f48024
2 files changed +76 -1
diagnostics/collect-wsl-logs.ps1
+73
@@ -130,6 +130,79 @@ if ($Dump)
130 }
131 }
132
133 +# Collect networking state relevant for WSL
134 +# Using a try/catch for commands below, as some of them do not exist on all OS versions
135 +
136 +Write-Host "`nCollecting additional network state..."
137 +
138 +$networkingFolder = "$folder/networking"
139 +mkdir -p $networkingFolder
140 +
141 +# Host networking info
142 +try
143 +{
144 + 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
145 +}
146 +catch {}
147 +
148 +try
149 +{
150 + Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$networkingFolder/Get-NetIPConfiguration.log" -Append
151 +}
152 +catch {}
153 +
154 +try
155 +{
156 + Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMCreator.log" -Append
157 +}
158 +catch {}
159 +
160 +try
161 +{
162 + Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMSetting_ActiveStore.log" -Append
163 +}
164 +catch {}
165 +
166 +try
167 +{
168 + Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVProfile_ActiveStore.log" -Append
169 +}
170 +catch {}
171 +
172 +try
173 +{
174 + Get-NetFirewallHyperVPort | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVPort.log" -Append
175 +}
176 +catch {}
177 +
178 +try
179 +{
180 + & hnsdiag.exe list all 2>&1 > $networkingFolder/hnsdiag_list_all.log
181 +}
182 +catch {}
183 +
184 +try
185 +{
186 + & hnsdiag.exe list endpoints -df 2>&1 > $networkingFolder/hnsdiag_list_endpoints.log
187 +}
188 +catch {}
189 +
190 +try
191 +{
192 + foreach ($port in Get-NetFirewallHyperVPort)
193 + {
194 + & vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-get-port-state.log"
195 + & vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-list-rule.log"
196 + }
197 +}
198 +catch {}
199 +
200 +try
201 +{
202 + & vfpctrl.exe /list-vmswitch-port 2>&1 > $networkingFolder/vfpctrl_list_vmswitch_port.log
203 +}
204 +catch {}
205 +
206 $logArchive = "$(Resolve-Path $folder).zip"
207 Compress-Archive -Path $folder -DestinationPath $logArchive
208 Remove-Item $folder -Recurse
diagnostics/networking.sh
+3 -1
@@ -13,7 +13,9 @@ uname -a
13
14 # Output adapter & routing configuration.
15 ip a
16 -ip route show
16 +ip route show table all
17 +ip neighbor
18 +ip link
19
20 # Validate that the gateway is responsive and can route ICMP correctly.
21 if gateway=$(ip route show | awk '/default/ { print $3 }'); then