-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathWslMirroredNetworking.cpp
More file actions
2720 lines (2379 loc) · 127 KB
/
WslMirroredNetworking.cpp
File metadata and controls
2720 lines (2379 loc) · 127 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*++
Copyright (c) Microsoft. All rights reserved.
Module Name:
WslMirroredNetworking.cpp
Abstract:
This file contains WSL mirrored networking function definitions.
--*/
#include "precomp.h"
#include "WslMirroredNetworking.h"
#include "WslCoreMessageQueue.h"
#include "Stringify.h"
#include "WslCoreNetworkingSupport.h"
#include "WslCoreNetworkEndpointSettings.h"
#include "WslCoreHostDnsInfo.h"
#include "hcs.hpp"
#include "hns_schema.h"
static constexpr auto c_loopbackDeviceName = TEXT(LX_INIT_LOOPBACK_DEVICE_NAME);
static constexpr auto c_initialMirroredGoalStateWaitTimeoutMs = 5 * 1000;
using namespace wsl::windows::common;
using namespace wsl::shared;
using wsl::core::networking::EndpointIpAddress;
using wsl::core::networking::EndpointRoute;
namespace {
inline const auto HnsModifyRequestTypeToString(const hns::ModifyRequestType requestType)
{
return JsonEnumToString<hns::ModifyRequestType>(requestType);
}
} // namespace
_Requires_lock_held_(m_networkLock)
void wsl::core::networking::WslMirroredNetworkManager::ProcessConnectivityChange()
{
const std::set<GUID, wsl::windows::common::helpers::GuidLess> initialConnectedInterfaces{std::move(m_hostConnectedInterfaces)};
m_hostConnectedInterfaces.clear();
const auto coInit = wil::CoInitializeEx();
const wil::com_ptr<INetworkListManager> networkListManager = wil::CoCreateInstance<NetworkListManager, INetworkListManager>();
wil::com_ptr<IEnumNetworks> networksEnumerator;
THROW_IF_FAILED(networkListManager->GetNetworks(NLM_ENUM_NETWORK_CONNECTED, &networksEnumerator));
for (;;)
{
ULONG fetched{};
wil::com_ptr<INetwork> networkInstance;
auto hr = networksEnumerator->Next(1, &networkInstance, &fetched);
THROW_IF_FAILED(hr);
if (hr == S_FALSE || fetched == 0)
{
break;
}
// each NLM network could have multiple interfaces - walk through each
// if we fail trying to access an individual interface, continue the loop for the other interfaces
wil::com_ptr<IEnumNetworkConnections> enumNetworkConnections;
hr = networkInstance->GetNetworkConnections(&enumNetworkConnections);
if (FAILED(hr))
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessConnectivityChange - ignoring interface after processing "
"INetworkConnection::GetAdapterId",
TraceLoggingValue(hr, "hr"));
continue;
}
for (;;)
{
ULONG fetchedNetworkConnections{};
wil::com_ptr<INetworkConnection> networkConnection;
hr = enumNetworkConnections->Next(1, &networkConnection, &fetchedNetworkConnections);
if (FAILED(hr) || hr == S_FALSE || fetchedNetworkConnections == 0)
{
break;
}
GUID interfaceGuid{};
hr = networkConnection->GetAdapterId(&interfaceGuid);
if (FAILED(hr))
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessConnectivityChange - ignoring interface INetworkConnection::GetAdapterId "
"failed",
TraceLoggingValue(hr, "hr"));
continue;
}
NLM_CONNECTIVITY connectivity{};
hr = networkConnection->GetConnectivity(&connectivity);
if (FAILED(hr) || connectivity == NLM_CONNECTIVITY_DISCONNECTED)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessConnectivityChange - ignoring interface after processing "
"INetworkConnection::GetConnectivity",
TraceLoggingValue(wsl::shared::string::GuidToString<wchar_t>(interfaceGuid).c_str(), "interfaceGuid"),
TraceLoggingValue(connectivity == NLM_CONNECTIVITY_DISCONNECTED, "is_NLM_CONNECTIVITY_DISCONNECTED"),
TraceLoggingValue(hr, "hr"));
continue;
}
m_hostConnectedInterfaces.insert(interfaceGuid);
}
}
if (initialConnectedInterfaces != m_hostConnectedInterfaces)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessConnectivityChange - reset goal state",
TraceLoggingValue(initialConnectedInterfaces.size(), "previous_interfaces_size"),
TraceLoggingValue(m_hostConnectedInterfaces.size(), "updated_interfaces_size"));
m_inMirroredGoalState.ResetEvent();
m_connectivityTelemetry.UpdateTimer();
std::wstring guids;
for (const auto& connectedInterface : initialConnectedInterfaces)
{
guids.append(wsl::shared::string::GuidToString<wchar_t>(connectedInterface) + L",");
}
WSL_LOG(
"WslMirroredNetworkManager::ProcessConnectivityChange [previous]",
TraceLoggingValue(guids.c_str(), "connectedInterfaces"));
guids.clear();
for (const auto& connectedInterface : m_hostConnectedInterfaces)
{
guids.append(wsl::shared::string::GuidToString<wchar_t>(connectedInterface) + L",");
}
WSL_LOG(
"WslMirroredNetworkManager::ProcessConnectivityChange [updated]",
TraceLoggingValue(guids.c_str(), "connectedInterfaces"));
}
}
_Requires_lock_held_(m_networkLock)
void wsl::core::networking::WslMirroredNetworkManager::ProcessIpAddressChange()
{
wsl::core::networking::unique_address_table addressTable{};
THROW_IF_WIN32_ERROR(GetUnicastIpAddressTable(AF_UNSPEC, &addressTable));
for (auto& endpoint : m_networkEndpoints)
{
const auto initialAddresses{std::move(endpoint.Network->IpAddresses)};
endpoint.Network->IpAddresses.clear();
// if the interface isn't connected, ensure we always track zero addresses
if (!endpoint.Network->IsConnected)
{
continue;
}
for (const auto& address : wil::make_range(addressTable.get()->Table, addressTable.get()->NumEntries))
{
if (address.InterfaceIndex != endpoint.Network->InterfaceIndex)
{
continue;
}
const auto endpointAddress = EndpointIpAddress(address);
if (endpointAddress.IsPreferred())
{
endpoint.Network->IpAddresses.insert(endpointAddress);
}
}
if (initialAddresses != endpoint.Network->IpAddresses)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessIpAddressChange - reset goal state",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(initialAddresses.size(), "previous_addresses_size"),
TraceLoggingValue(endpoint.Network->IpAddresses.size(), "updated_addresses_size"));
m_inMirroredGoalState.ResetEvent();
m_connectivityTelemetry.UpdateTimer();
for (const auto& address : initialAddresses)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessIpAddressChange [previous]",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(address.AddressString.c_str(), "address"),
TraceLoggingValue(address.PrefixLength, "prefixLength"));
}
for (const auto& address : endpoint.Network->IpAddresses)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessIpAddressChange [updated]",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(address.AddressString.c_str(), "address"),
TraceLoggingValue(address.PrefixLength, "prefixLength"));
}
}
}
}
_Requires_lock_held_(m_networkLock)
void wsl::core::networking::WslMirroredNetworkManager::ProcessRouteChange()
{
wsl::core::networking::unique_address_table addressTable{};
wsl::core::networking::unique_forward_table routeTable{};
THROW_IF_WIN32_ERROR(GetIpForwardTable2(AF_UNSPEC, &routeTable));
for (auto& endpoint : m_networkEndpoints)
{
const auto initialRoutes = endpoint.Network->Routes;
endpoint.Network->Routes.clear();
// if the interface isn't connected, ensure we always track zero routes
// Windows can have routes assigned on disconnected interfaces, Linux cannot
if (!endpoint.Network->IsConnected)
{
continue;
}
// Gather endpoint address prefixes and raw address
std::unordered_set<std::wstring> addressPrefixes{};
std::unordered_set<std::wstring> addresses{};
std::unordered_set<std::wstring> ipv4broadcastAddresses{};
for (const auto& endpointAddress : endpoint.Network->IpAddresses)
{
addresses.insert(endpointAddress.AddressString);
auto addressPrefix = endpointAddress.GetPrefix();
WI_ASSERT(!addressPrefix.empty());
if (!addressPrefix.empty())
{
addressPrefixes.insert(std::move(addressPrefix));
}
if (endpointAddress.Address.si_family == AF_INET)
{
auto v4BroadcastMaskAddress = endpointAddress.GetIpv4BroadcastMask();
WI_ASSERT(!v4BroadcastMaskAddress.empty());
if (!v4BroadcastMaskAddress.empty())
{
ipv4broadcastAddresses.emplace(std::move(v4BroadcastMaskAddress));
}
}
}
for (const auto& route : wil::make_range(routeTable.get()->Table, routeTable.get()->NumEntries))
{
if (route.InterfaceIndex == endpoint.Network->InterfaceIndex)
{
auto endpointRoute = EndpointRoute(route);
endpointRoute.IsAutoGeneratedPrefixRoute =
endpointRoute.IsNextHopOnlink() && addressPrefixes.contains(endpointRoute.GetFullDestinationPrefix());
// Ignore host IPv4 routes, e.g. 192.168.5.2/32 -> 0.0.0.0
if (addresses.contains(endpointRoute.DestinationPrefixString))
{
continue;
}
// ignore host routes for deprecated addresses
// the address will not be in the 'addresses' variable above since it's deprecated
// e.g. a route 2001:0:d5b:9458:1ceb:518b:7c94:609e/128, but the matching local IP address is deprecated
bool shouldIgnoreUnicastAddressRoute = false;
if (endpointRoute.IsUnicastAddressRoute())
{
if (!addressTable)
{
THROW_IF_WIN32_ERROR(GetUnicastIpAddressTable(AF_UNSPEC, &addressTable));
}
// find the address matching this destination prefix
for (const auto& address : wil::make_range(addressTable.get()->Table, addressTable.get()->NumEntries))
{
if (address.InterfaceIndex != endpoint.Network->InterfaceIndex)
{
continue;
}
const auto endpointAddress = EndpointIpAddress(address);
if (endpointAddress.Address == route.DestinationPrefix.Prefix)
{
if (!endpointAddress.IsPreferred())
{
shouldIgnoreUnicastAddressRoute = true;
break;
}
}
}
}
if (shouldIgnoreUnicastAddressRoute)
{
continue;
}
if (endpointRoute.DestinationPrefix.Prefix.si_family == AF_INET)
{
if (endpoint.Network->DisableIpv4DefaultRoutes && endpointRoute.IsDefault())
{
continue;
}
const auto addressType =
Ipv4AddressType(reinterpret_cast<const UCHAR*>(&endpointRoute.DestinationPrefix.Prefix.Ipv4.sin_addr));
if (addressType != NlatUnspecified && addressType != NlatUnicast)
{
// ignore broadcast and multicast routes - Linux doesn't seem to create those like Windows
continue;
}
if (ipv4broadcastAddresses.contains(endpointRoute.DestinationPrefixString))
{
continue;
}
}
else if (endpointRoute.DestinationPrefix.Prefix.si_family == AF_INET6)
{
if (endpoint.Network->DisableIpv6DefaultRoutes && endpointRoute.IsDefault())
{
continue;
}
const auto addressType =
Ipv6AddressType(reinterpret_cast<const UCHAR*>(&endpointRoute.DestinationPrefix.Prefix.Ipv6.sin6_addr));
if (addressType != NlatUnspecified && addressType != NlatUnicast)
{
// ignore broadcast and multicast routes - Linux doesn't seem to create those like Windows
continue;
}
}
// update the route metric for Linux - which to be equivalent to Windows must be the sum of the interface metric and route metric
endpointRoute.Metric += (endpointRoute.Family == AF_INET) ? endpoint.Network->IPv4InterfaceMetric.value_or(0)
: endpoint.Network->IPv6InterfaceMetric.value_or(0);
if (endpointRoute.Metric > UINT16_MAX)
{
endpointRoute.Metric = UINT16_MAX;
}
// Some Windows interfaces (like VPNs) can have metric 0 and routes over that interface with metric also 0, adding up to 0.
// Linux treats metric 0 as unspecified and will default to a 1024 metric. The highest priority metric in Linux is 1
// instead so we need to switch the metric from 0 to 1.
if (endpointRoute.Metric == 0)
{
endpointRoute.Metric = 1;
}
endpoint.Network->Routes.insert(endpointRoute);
}
}
// Linux requires that there's an onlink route for any route with a NextHop address that's not all-zeros (on-link)
// "normal" network deployments with Windows creates an address prefix route that includes that next hop
// but some deployments, like some VPNs, do not include a prefix route that includes the nexthop
// While that works in Windows (all nexthop addresses in a route *must* be on-link), it won't work in Linux
// thus we must guarantee an onlink route for all routes with a non-zero nexthop
std::vector<EndpointRoute> newRoutes;
for (const auto& route : endpoint.Network->Routes)
{
if (!route.IsNextHopOnlink())
{
EndpointRoute newRoute;
newRoute.Family = route.Family;
newRoute.Metric = route.Metric;
newRoute.SitePrefixLength = route.GetMaxPrefixLength();
// update the destination prefix to the nexthop address /32 (for ipv4) or /128 (for ipv6)
newRoute.DestinationPrefix.Prefix = route.NextHop;
newRoute.DestinationPrefix.PrefixLength = route.GetMaxPrefixLength();
newRoute.DestinationPrefixString = windows::common::string::SockAddrInetToWstring(newRoute.DestinationPrefix.Prefix);
// update the destination prefix to be all zeros (on-link)
ZeroMemory(&newRoute.NextHop, sizeof newRoute.NextHop);
newRoute.NextHop.si_family = route.NextHop.si_family;
newRoute.NextHopString = windows::common::string::SockAddrInetToWstring(newRoute.NextHop);
// force a copy so the route strings are re-calculated in the new EndpointRoute object
newRoutes.emplace_back(std::move(newRoute));
}
}
for (const auto& route : newRoutes)
{
endpoint.Network->Routes.insert(route);
}
if (initialRoutes != endpoint.Network->Routes)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessRouteChange - reset goal state",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(initialRoutes.size(), "previous_routes_size"),
TraceLoggingValue(endpoint.Network->Routes.size(), "updated_routes_size"));
m_inMirroredGoalState.ResetEvent();
m_connectivityTelemetry.UpdateTimer();
for (const auto& route : initialRoutes)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessRouteChange [previous]",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(route.Metric, "metric"),
TraceLoggingValue(route.NextHopString.c_str(), "nextHop"),
TraceLoggingValue(route.DestinationPrefixString.c_str(), "destinationPrefix"),
TraceLoggingValue(route.DestinationPrefix.PrefixLength, "destinationPrefixLength"));
}
for (const auto& route : endpoint.Network->Routes)
{
WSL_LOG(
"WslMirroredNetworkManager::ProcessRouteChange [updated]",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(route.Metric, "metric"),
TraceLoggingValue(route.NextHopString.c_str(), "nextHop"),
TraceLoggingValue(route.DestinationPrefixString.c_str(), "destinationPrefix"),
TraceLoggingValue(route.DestinationPrefix.PrefixLength, "destinationPrefixLength"));
}
}
}
}
_Requires_lock_held_(m_networkLock)
void wsl::core::networking::WslMirroredNetworkManager::ProcessDNSChange()
{
const auto initialDnsInfo = m_dnsInfo;
if (m_vmConfig.EnableDnsTunneling)
{
m_dnsInfo = wsl::core::networking::HostDnsInfo::GetDnsTunnelingSettings(m_dnsTunnelingIpAddress);
}
else
{
m_dnsInfo = wsl::core::networking::HostDnsInfo::GetDnsSettings(
wsl::core::networking::DnsSettingsFlags::IncludeVpn | wsl::core::networking::DnsSettingsFlags::IncludeIpv6Servers |
wsl::core::networking::DnsSettingsFlags::IncludeAllSuffixes);
}
if (initialDnsInfo != m_dnsInfo)
{
WSL_LOG("WslMirroredNetworkManager::ProcessDNSChange - reset goal state");
m_inMirroredGoalState.ResetEvent();
m_connectivityTelemetry.UpdateTimer();
WSL_LOG(
"WslMirroredNetworkManager::ProcessDNSChange [previous]",
TraceLoggingValue(wsl::shared::string::Join(initialDnsInfo.Domains, ',').c_str(), "domainList"),
TraceLoggingValue(wsl::shared::string::Join(initialDnsInfo.Servers, ',').c_str(), "dnsServerList"));
WSL_LOG(
"WslMirroredNetworkManager::ProcessDNSChange [updated]",
TraceLoggingValue(wsl::shared::string::Join(m_dnsInfo.Domains, ',').c_str(), "domainList"),
TraceLoggingValue(wsl::shared::string::Join(m_dnsInfo.Servers, ',').c_str(), "dnsServerList"));
}
}
_Requires_lock_held_(m_networkLock)
void wsl::core::networking::WslMirroredNetworkManager::ProcessInterfaceChange()
{
wsl::core::networking::unique_interface_table interfaceTable{};
THROW_IF_WIN32_ERROR(::GetIpInterfaceTable(AF_UNSPEC, &interfaceTable));
for (auto& endpoint : m_networkEndpoints)
{
const auto originalIPv4DisableDefaultRoutes = endpoint.Network->DisableIpv4DefaultRoutes;
const auto originalIPv6DisableDefaultRoutes = endpoint.Network->DisableIpv6DefaultRoutes;
const auto originallyConnected = endpoint.Network->IsConnected;
const auto originalMinimumMtu = endpoint.Network->GetEffectiveMtu();
const auto originalMinimumMetric = endpoint.Network->GetMinimumMetric();
endpoint.Network->IsConnected = false;
auto interfaceFoundCount = 0;
for (const auto& ipInterface : wil::make_range(interfaceTable.get()->Table, interfaceTable.get()->NumEntries))
{
if (ipInterface.InterfaceIndex != endpoint.Network->InterfaceIndex ||
(ipInterface.Family != AF_INET && ipInterface.Family != AF_INET6))
{
continue;
}
// Endpoint is marked as connected if either IPv4 or IPv6 interface is connected
endpoint.Network->IsConnected = endpoint.Network->IsConnected || !!ipInterface.Connected;
if (ipInterface.Family == AF_INET)
{
endpoint.Network->IPv4InterfaceMtu = ipInterface.NlMtu;
endpoint.Network->IPv4InterfaceMetric = ipInterface.Metric;
endpoint.Network->DisableIpv4DefaultRoutes = ipInterface.DisableDefaultRoutes;
}
else
{
endpoint.Network->IPv6InterfaceMtu = ipInterface.NlMtu;
endpoint.Network->IPv6InterfaceMetric = ipInterface.Metric;
endpoint.Network->DisableIpv6DefaultRoutes = ipInterface.DisableDefaultRoutes;
}
++interfaceFoundCount;
if (interfaceFoundCount > 1)
{
// we already found both v4 and v6
break;
}
}
const auto disableDefaultRoutesUpdated = originalIPv4DisableDefaultRoutes != endpoint.Network->DisableIpv4DefaultRoutes ||
originalIPv6DisableDefaultRoutes != endpoint.Network->DisableIpv6DefaultRoutes;
const auto connectedStateUpdated = originallyConnected != endpoint.Network->IsConnected;
const auto minimumMtu = endpoint.Network->GetEffectiveMtu();
const auto mtuUpdated = originalMinimumMtu != minimumMtu;
const auto minimumMetric = endpoint.Network->GetMinimumMetric();
const auto metricUpdate = originalMinimumMetric != minimumMetric;
endpoint.Network->PendingIPInterfaceUpdate |= connectedStateUpdated || mtuUpdated || metricUpdate;
if (disableDefaultRoutesUpdated || connectedStateUpdated || mtuUpdated || metricUpdate)
{
// we want to trace when disableDefaultRoutesUpdated, but that won't trigger resetting the goal-state
// if disableDefaultRoutesUpdated affects routes, then ProcessRouteChange will reset the goal-state accordingly
// but we do want to trace when disableDefaultRoutes get updated - to greatly help debugging
if (connectedStateUpdated || mtuUpdated || metricUpdate)
{
WSL_LOG("WslMirroredNetworkManager::ProcessInterfaceChange - reset goal state");
m_inMirroredGoalState.ResetEvent();
m_connectivityTelemetry.UpdateTimer();
}
WSL_LOG(
"WslMirroredNetworkManager::ProcessInterfaceChange [previous]",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(originallyConnected, "isConnected"),
TraceLoggingValue(originalMinimumMtu, "EffectiveMtu"),
TraceLoggingValue(originalMinimumMetric, "MinimumMetric"),
TraceLoggingValue(originalIPv4DisableDefaultRoutes, "disableIpv4DefaultRoutes"),
TraceLoggingValue(originalIPv6DisableDefaultRoutes, "disableIpv6DefaultRoutes"));
WSL_LOG(
"WslMirroredNetworkManager::ProcessInterfaceChange [updated]",
TraceLoggingValue(endpoint.EndpointId, "endpointId"),
TraceLoggingValue(endpoint.InterfaceGuid, "interfaceGuid"),
TraceLoggingValue(endpoint.Network->IsConnected, "isConnected"),
TraceLoggingValue(endpoint.Network->IPv4InterfaceMtu, "ipv4InterfaceMtu"),
TraceLoggingValue(endpoint.Network->IPv6InterfaceMtu, "ipv6InterfaceMtu"),
TraceLoggingValue(endpoint.Network->IPv4InterfaceMetric.value_or(0xffffffff), "IPv4InterfaceMetric"),
TraceLoggingValue(endpoint.Network->IPv6InterfaceMetric.value_or(0xffffffff), "IPv6InterfaceMetric"),
TraceLoggingValue(endpoint.Network->DisableIpv4DefaultRoutes, "disableIpv4DefaultRoutes"),
TraceLoggingValue(endpoint.Network->DisableIpv6DefaultRoutes, "disableIpv6DefaultRoutes"));
}
}
}
wsl::core::networking::WslMirroredNetworkManager::WslMirroredNetworkManager(
HCS_SYSTEM hcsSystem,
const Config& config,
GnsMessageCallbackWithCallbackResult&& GnsMessageCallbackWithCallbackResult,
AddNetworkEndpointCallback&& addNetworkEndpointCallback,
const std::pair<uint16_t, uint16_t>& ephemeralPortRange) :
m_callbackForGnsMessage(std::move(GnsMessageCallbackWithCallbackResult)),
m_addNetworkEndpointCallback(std::move(addNetworkEndpointCallback)),
m_hcsSystem{hcsSystem},
m_vmConfig{config},
m_ephemeralPortRange(ephemeralPortRange),
m_state(State::Starting)
{
// ensure the MTA apartment stays alive for the lifetime of this object in this process
// we do not want to risk COM unloading / reloading when we need to make our WinRT API calls
// which by default will be in the MTA
LOG_IF_FAILED(CoIncrementMTAUsage(&m_mtaCookie));
// locking in the c'tor in case any of the below callbacks fire before this object is fully constructed
const auto lock = m_networkLock.lock_exclusive();
// keep the WinRT DLL loaded for the lifetime of this instance. we instantiate it repeatedly,
// and today we are loading and unloading 7 dll's over and over again - each time we call it.
// this also circumvents many performance optimizations we made with our WinRT API
const auto roInit = wil::RoInitialize();
m_networkInformationStatics = wil::GetActivationFactory<ABI::Windows::Networking::Connectivity::INetworkInformationStatics>(
RuntimeClass_Windows_Networking_Connectivity_NetworkInformation);
m_netListManager = wil::CoCreateInstance<NetworkListManager, INetworkListManager>();
// create an event sink for NLM Network change notifications, then register (Advise) with NLM
m_netListManagerEventSink = wil::com_ptr<INetworkEvents>(Microsoft::WRL::Make<PublicNLMSink>(this));
// INetworkListManager is actually an inproc COM API - it just calls private COM APIs which are hosted in a service
m_netListManagerAdviseHandler.AdviseInProcObject<INetworkEvents>(m_netListManager, m_netListManagerEventSink.get());
// Subscribe for network change notifications. This is done before
// obtaining the initial list of networks to connect to, in order to
// avoid a race condition between the initial enumeration and any network
// changes that may be occurring at the same time. The subscription will
// receive network change events, but will not be able to react to them
// the lock is released.
m_hcnCallback = windows::common::hcs::RegisterServiceCallback(HcnCallback, this);
// Create the timer used to retry the HNS service connection.
m_retryHcnServiceConnectionTimer.reset(CreateThreadpoolTimer(HcnServiceConnectionTimerCallback, this, nullptr));
THROW_IF_NULL_ALLOC(m_retryHcnServiceConnectionTimer);
// Create the timer used to retry syncing pending IP state with Linux.
m_retryLinuxIpStateSyncTimer.reset(CreateThreadpoolTimer(RetryLinuxIpStateSyncTimerCallback, this, nullptr));
THROW_IF_NULL_ALLOC(m_retryLinuxIpStateSyncTimer);
m_debounceUpdateAllEndpointsDefaultTimer.reset(CreateThreadpoolTimer(DebounceUpdateAllEndpointsDefaultTimerFired, this, nullptr));
THROW_IF_NULL_ALLOC(m_debounceUpdateAllEndpointsDefaultTimer);
m_debounceCreateEndpointFailureTimer.reset(CreateThreadpoolTimer(DebounceCreateEndpointFailureTimerFired, this, nullptr));
THROW_IF_NULL_ALLOC(m_debounceCreateEndpointFailureTimer);
// Populate the initial list of networks. The list will then be kept
// up to date by the above subscription notifications.
for (const auto& networkId : EnumerateMirroredNetworks())
{
// Must call back through MirroredNetworking to create a new Endpoint
// note that the callback will not block - it just queues the work in MirroredNetworking
LOG_IF_FAILED(AddNetwork(networkId));
}
// once HNS has started creating networks, start our telemetry timer
if (config.EnableTelemetry && !WslTraceLoggingShouldDisableTelemetry())
{
m_connectivityTelemetry.StartTimer([&](NLM_CONNECTIVITY hostConnectivity, uint32_t telemetryCounter) {
TelemetryConnectionCallback(hostConnectivity, telemetryCounter);
});
}
if (config.DnsTunnelingIpAddress.has_value())
{
m_dnsTunnelingIpAddress = wsl::windows::common::string::IntegerIpv4ToWstring(config.DnsTunnelingIpAddress.value());
}
m_state = State::Started;
}
wsl::core::networking::WslMirroredNetworkManager::~WslMirroredNetworkManager() noexcept
{
Stop();
}
wsl::core::networking::WslMirroredNetworkManager::HnsStatus wsl::core::networking::WslMirroredNetworkManager::Stop() noexcept
{
HnsStatus returnStatus{};
try
{
// scope to the lock to flip the bit that we are stopping
{
const auto lock = m_networkLock.lock_exclusive();
m_state = State::Stopped;
returnStatus = m_latestHnsStatus;
}
// must set state first so all other threads won't make forward progress
// since we are about to stop all timers and callbacks
// which must be stopped not holding our lock
// Next stop the telemetry timer which could queue work to linux (through m_gnsCallbackQueue)
m_connectivityTelemetry.Reset();
// Next stop the timer which could reset the hcnCallback
m_retryHcnServiceConnectionTimer.reset();
// Next stop the Hcn callback, which could add/remove networks
m_hcnCallback.reset();
m_debounceUpdateAllEndpointsDefaultTimer.reset();
m_debounceCreateEndpointFailureTimer.reset();
// Stop the linux ip state sync timer
m_retryLinuxIpStateSyncTimer.reset();
// canceling the callback queue only after stopping all sources that could queue a callback
m_gnsCallbackQueue.cancel();
m_hnsQueue.cancel();
// all of the above must be done outside holding a lock to avoid deadlocks
const auto lock = m_networkLock.lock_exclusive();
m_networkEndpoints.clear();
}
CATCH_LOG()
return returnStatus;
}
void wsl::core::networking::WslMirroredNetworkManager::DebounceUpdateAllEndpointsDefaultTimerFired(
_Inout_ PTP_CALLBACK_INSTANCE, _Inout_opt_ PVOID Context, _Inout_ PTP_TIMER)
try
{
auto* const instance = static_cast<WslMirroredNetworkManager*>(Context);
const auto lock = instance->m_networkLock.lock_exclusive();
instance->m_IsDebounceUpdateAllEndpointsDefaultTimerSet = false;
if (instance->m_state == State::Stopped)
{
return;
}
instance->UpdateAllEndpointsImpl(UpdateEndpointFlag::Default, "DebounceUpdateAllEndpointsDefaultTimerFired");
}
CATCH_LOG()
void wsl::core::networking::WslMirroredNetworkManager::DebounceCreateEndpointFailureTimerFired(
_Inout_ PTP_CALLBACK_INSTANCE, _Inout_opt_ PVOID Context, _Inout_ PTP_TIMER)
try
{
auto* const instance = static_cast<WslMirroredNetworkManager*>(Context);
const auto lock = instance->m_networkLock.lock_exclusive();
if (instance->m_state == State::Stopped)
{
return;
}
if (!instance->m_failedEndpointProperties.empty())
{
// AddEndpointImpl will update m_failedEndpointProperties if any re-attempts to add the endpoint fail
// thus we must first move everything out
auto failedEndpointProperties = std::move(instance->m_failedEndpointProperties);
instance->m_failedEndpointProperties.clear();
for (auto& endpointProperties : failedEndpointProperties)
{
instance->AddEndpointImpl(std::move(endpointProperties));
}
}
}
CATCH_LOG()
_Requires_lock_held_(m_networkLock)
std::vector<GUID> wsl::core::networking::WslMirroredNetworkManager::EnumerateMirroredNetworks() const noexcept
try
{
WI_ASSERT(m_state == State::Started || m_state == State::Starting);
return EnumerateMirroredNetworksAndHyperVFirewall(m_vmConfig.FirewallConfig.Enabled());
}
catch (...)
{
LOG_CAUGHT_EXCEPTION();
return {};
}
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::AddNetwork(const GUID& networkId) noexcept
try
{
WSL_LOG("WslMirroredNetworkManager::AddNetwork", TraceLoggingValue(networkId, "networkId"));
// Inform the parent class to create a new endpoint object which we can then connect into the container
m_hnsQueue.submit([this, networkId] { m_addNetworkEndpointCallback(networkId); });
return S_OK;
}
CATCH_RETURN()
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::RemoveNetwork(const GUID& networkId) noexcept
try
{
WSL_LOG("WslMirroredNetworkManager::RemoveNetwork", TraceLoggingValue(networkId, "networkId"));
const auto foundEndpoint =
std::ranges::find_if(m_networkEndpoints, [&](const auto& endpoint) { return endpoint.NetworkId == networkId; });
if (foundEndpoint == std::end(m_networkEndpoints))
{
WSL_LOG("WslMirroredNetworkManager::RemoveNetwork - Network not found", TraceLoggingValue(networkId, "networkId"));
return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
}
// RemoveEndpoint will remove this endpoint from m_networkEndpoints
return RemoveEndpoint(foundEndpoint->EndpointId);
}
CATCH_RETURN()
void __stdcall wsl::core::networking::WslMirroredNetworkManager::RetryLinuxIpStateSyncTimerCallback(
_Inout_ PTP_CALLBACK_INSTANCE, _Inout_opt_ PVOID Context, _Inout_ PTP_TIMER) noexcept
{
auto* const manager = static_cast<WslMirroredNetworkManager*>(Context);
const auto lock = manager->m_networkLock.lock_exclusive();
if (manager->m_state == State::Stopped)
{
return;
}
manager->UpdateAllEndpointsImpl(UpdateEndpointFlag::Default, "RetryLinuxIpStateSyncTimerCallback");
}
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::SendAddressRequestToGns(
const NetworkEndpoint& endpoint, const TrackedIpAddress& address, hns::ModifyRequestType requestType) noexcept
try
{
hns::ModifyGuestEndpointSettingRequest<hns::IPAddress> modifyRequest;
modifyRequest.ResourceType = hns::GuestEndpointResourceType::IPAddress;
modifyRequest.RequestType = requestType;
modifyRequest.targetDeviceName = wsl::shared::string::GuidToString<wchar_t>(endpoint.InterfaceGuid);
modifyRequest.Settings = address.ConvertToHnsSettingsMsg();
WSL_LOG(
"WslMirroredNetworkManager::SendAddressRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest - set address [queued]", "GnsMessage"),
TraceLoggingValue(HnsModifyRequestTypeToString(requestType).c_str(), "requestType"),
TraceLoggingValue(endpoint.InterfaceGuid, "InterfaceGuid"),
TraceLoggingValue(address.Address.AddressString.c_str(), "ipAddress"),
TraceLoggingValue(address.Address.PrefixLength, "prefixLength"),
TraceLoggingValue(address.Address.IsPreferred(), "isPreferred"));
int linuxResultCode{};
// can safely capture by ref since we are waiting
const auto hr = m_gnsCallbackQueue.submit_and_wait([&] {
return m_callbackForGnsMessage(LxGnsMessageDeviceSettingRequest, ToJsonW(modifyRequest), GnsCallbackFlags::Wait, &linuxResultCode);
});
WSL_LOG(
"WslMirroredNetworkManager::SendAddressRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest - set address [completed]", "GnsMessage"),
TraceLoggingHResult(hr, "hr"),
TraceLoggingValue(linuxResultCode, "linuxResultCode"));
address.SyncRetryCount = (address.SyncRetryCount > 0) ? address.SyncRetryCount - 1 : 0;
return hr;
}
CATCH_RETURN()
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::SendRouteRequestToGns(
const NetworkEndpoint& endpoint, const TrackedRoute& route, hns::ModifyRequestType requestType) noexcept
try
{
hns::ModifyGuestEndpointSettingRequest<hns::Route> modifyRequest;
modifyRequest.ResourceType = hns::GuestEndpointResourceType::Route;
modifyRequest.RequestType = requestType;
modifyRequest.targetDeviceName = wsl::shared::string::GuidToString<wchar_t>(endpoint.InterfaceGuid);
modifyRequest.Settings = route.ConvertToHnsSettingsMsg();
WSL_LOG(
"WslMirroredNetworkManager::SendRouteRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest : set route [queued]", "GnsMessage"),
TraceLoggingValue(HnsModifyRequestTypeToString(requestType).c_str(), "requestType"),
TraceLoggingValue(endpoint.InterfaceGuid, "InterfaceGuid"),
TraceLoggingValue(route.Route.DestinationPrefixString.c_str(), "destinationPrefix"),
TraceLoggingValue(route.Route.DestinationPrefix.PrefixLength, "prefixLength"),
TraceLoggingValue(route.Route.NextHopString.c_str(), "nextHop"),
TraceLoggingValue(route.Route.Metric, "metric"));
int linuxResultCode{};
// can safely capture by ref since we are waiting
const auto hr = m_gnsCallbackQueue.submit_and_wait([&] {
return m_callbackForGnsMessage(LxGnsMessageDeviceSettingRequest, ToJsonW(modifyRequest), GnsCallbackFlags::Wait, &linuxResultCode);
});
WSL_LOG(
"WslMirroredNetworkManager::SendRouteRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest : set route [completed]", "GnsMessage"),
TraceLoggingHResult(hr, "hr"),
TraceLoggingValue(linuxResultCode, "linuxResultCode"));
route.SyncRetryCount = (route.SyncRetryCount > 0) ? route.SyncRetryCount - 1 : 0;
return hr;
}
CATCH_RETURN()
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::SendLoopbackRequestToGns(
const NetworkEndpoint& endpoint, const TrackedIpAddress& address, hns::OperationType operation) noexcept
try
{
hns::LoopbackRoutesRequest loopbackRequest;
loopbackRequest.operation = operation;
loopbackRequest.targetDeviceName = wsl::shared::string::GuidToString<wchar_t>(endpoint.InterfaceGuid);
loopbackRequest.family = address.Address.Address.si_family;
loopbackRequest.ipAddress = address.Address.AddressString;
WSL_LOG(
"WslMirroredNetworkManager::SendLoopbackRequestToGns",
TraceLoggingValue("LoopbackRoutesRequest [queued]", "GnsMessage"),
TraceLoggingValue(JsonEnumToString(operation).c_str(), "requestType"),
TraceLoggingValue(endpoint.InterfaceGuid, "InterfaceGuid"),
TraceLoggingValue(address.Address.AddressString.c_str(), "ipAddress"));
int linuxResultCode{};
// can safely capture by ref since we are waiting
const auto hr = m_gnsCallbackQueue.submit_and_wait([&]() {
return m_callbackForGnsMessage(LxGnsMessageLoopbackRoutesRequest, ToJsonW(loopbackRequest), GnsCallbackFlags::Wait, &linuxResultCode);
});
WSL_LOG(
"WslMirroredNetworkManager::SendLoopbackRequestToGns",
TraceLoggingValue("LoopbackRoutesRequest [completed]", "GnsMessage"),
TraceLoggingHResult(hr, "hr"),
TraceLoggingValue(linuxResultCode, "linuxResultCode"));
return hr;
}
CATCH_RETURN()
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::SendDnsRequestToGns(
const NetworkEndpoint& endpoint, const DnsInfo& dnsInfo, hns::ModifyRequestType requestType) noexcept
try
{
hns::ModifyGuestEndpointSettingRequest<hns::DNS> modifyRequest;
modifyRequest.ResourceType = hns::GuestEndpointResourceType::DNS;
modifyRequest.RequestType = requestType;
modifyRequest.targetDeviceName = wsl::shared::string::GuidToString<wchar_t>(endpoint.InterfaceGuid);
modifyRequest.Settings = BuildDnsNotification(dnsInfo);
WSL_LOG(
"WslMirroredNetworkManager::SendDnsRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest : set DNS [queued]", "GnsMessage"),
TraceLoggingValue(HnsModifyRequestTypeToString(requestType).c_str(), "requestType"),
TraceLoggingValue(endpoint.InterfaceGuid, "InterfaceGuid"),
TraceLoggingValue(m_vmConfig.EnableDnsTunneling, "m_vmConfig.EnableDnsTunneling"),
TraceLoggingValue(wsl::shared::string::Join(dnsInfo.Servers, ',').c_str(), "server list"),
TraceLoggingValue(wsl::shared::string::Join(dnsInfo.Domains, ',').c_str(), "suffix list"));
int linuxResultCode{};
// can safely capture by ref since we are waiting
const auto hr = m_gnsCallbackQueue.submit_and_wait([&] {
return m_callbackForGnsMessage(LxGnsMessageDeviceSettingRequest, ToJsonW(modifyRequest), GnsCallbackFlags::Wait, &linuxResultCode);
});
WSL_LOG(
"WslMirroredNetworkManager::SendDnsRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest : set DNS [completed]", "GnsMessage"),
TraceLoggingHResult(hr, "hr"),
TraceLoggingValue(linuxResultCode, "linuxResultCode"));
return hr;
}
CATCH_RETURN()
_Requires_lock_held_(m_networkLock)
_Check_return_ HRESULT wsl::core::networking::WslMirroredNetworkManager::SendInterfaceRequestToGns(const NetworkEndpoint& endpoint) noexcept
try
{
const auto interfaceConnected = endpoint.Network->IsConnected;
const auto interfaceMtu = endpoint.Network->GetEffectiveMtu();
const auto interfaceMetric = endpoint.Network->GetMinimumMetric();
hns::ModifyGuestEndpointSettingRequest<hns::NetworkInterface> modifyRequest;
modifyRequest.Settings.Connected = interfaceConnected;
modifyRequest.Settings.NlMtu = interfaceMtu;
modifyRequest.Settings.Metric = interfaceMetric;
modifyRequest.ResourceType = hns::GuestEndpointResourceType::Interface;
modifyRequest.targetDeviceName = wsl::shared::string::GuidToString<wchar_t>(endpoint.InterfaceGuid);
WSL_LOG(
"WslMirroredNetworkManager::SendInterfaceRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest : update interface properties [queued]", "GnsMessage"),
TraceLoggingValue(endpoint.InterfaceGuid, "InterfaceGuid"),
TraceLoggingValue(interfaceConnected, "connected"),
TraceLoggingValue(interfaceMtu, "mtu"),
TraceLoggingValue(interfaceMetric, "metric"));
int linuxResultCode{};
// can safely capture by ref since we are waiting
const auto hr = m_gnsCallbackQueue.submit_and_wait([&] {
return m_callbackForGnsMessage(LxGnsMessageModifyGuestDeviceSettingRequest, ToJsonW(modifyRequest), GnsCallbackFlags::Wait, &linuxResultCode);
});
WSL_LOG(
"WslMirroredNetworkManager::SendInterfaceRequestToGns",
TraceLoggingValue("ModifyGuestDeviceSettingRequest : update interface properties [completed]", "GnsMessage"),
TraceLoggingHResult(hr, "hr"),
TraceLoggingValue(linuxResultCode, "linuxResultCode"));
return hr;
}
CATCH_RETURN()
_Requires_lock_held_(m_networkLock)
_Check_return_ bool wsl::core::networking::WslMirroredNetworkManager::SyncIpStateWithLinux(NetworkEndpoint& endpoint)
{
using hns::GuestEndpointResourceType;
using hns::IPAddress;
using hns::Route;
using TrackedIpStateSyncStatus::PendingAdd;
using TrackedIpStateSyncStatus::PendingRemoval;
using TrackedIpStateSyncStatus::PendingUpdate;
using TrackedIpStateSyncStatus::Synced;
bool syncSuccessful = true;
if (!endpoint.StateTracking->InitialSyncComplete)
{
// Tell GNS that we're ready to start pushing addresses and routes to Linux on this interface.
hns::InitialIpConfigurationNotification notification{};
notification.targetDeviceName = wsl::shared::string::GuidToString<wchar_t>(endpoint.InterfaceGuid);
WI_SetAllFlags(