aboutsummaryrefslogtreecommitdiffstats
path: root/driver/socket.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-08-03 17:24:37 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-08-03 17:30:43 +0200
commitd9d77101ec06de0ab2aa95f76f6d0bd7c0bedbc1 (patch)
tree882b6cd0020a36df9666818fe0afb092e4172b30 /driver/socket.c
parentTODO: note current unsolved MTU notification issue (diff)
downloadwireguard-nt-d9d77101ec06de0ab2aa95f76f6d0bd7c0bedbc1.tar.xz
wireguard-nt-d9d77101ec06de0ab2aa95f76f6d0bd7c0bedbc1.zip
driver: socket: ignore interfaces with down oper status
This should allow better transition between wifi and wired. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'driver/socket.c')
-rw-r--r--driver/socket.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/driver/socket.c b/driver/socket.c
index 36c310b..836e344 100644
--- a/driver/socket.c
+++ b/driver/socket.c
@@ -262,11 +262,14 @@ retry:
if (Endpoint->Addr.si_family == AF_INET6 &&
!CidrMaskMatchV6(&Endpoint->Addr.Ipv6.sin6_addr, &Table->Table[i].DestinationPrefix))
continue;
- MIB_IPINTERFACE_ROW Interface = { .Family = Endpoint->Addr.si_family,
- .InterfaceLuid = Table->Table[i].InterfaceLuid };
- if (!NT_SUCCESS(GetIpInterfaceEntry(&Interface)))
+ MIB_IF_ROW2 Interface = { .InterfaceLuid = Table->Table[i].InterfaceLuid };
+ if (!NT_SUCCESS(GetIfEntry2(&Interface)) || Interface.OperStatus != IfOperStatusUp)
continue;
- ULONG Metric = Table->Table[i].Metric + Interface.Metric;
+ MIB_IPINTERFACE_ROW IpInterface = { .Family = Endpoint->Addr.si_family,
+ .InterfaceLuid = Table->Table[i].InterfaceLuid };
+ if (!NT_SUCCESS(GetIpInterfaceEntry(&IpInterface)))
+ continue;
+ ULONG Metric = Table->Table[i].Metric + IpInterface.Metric;
if (Table->Table[i].DestinationPrefix.PrefixLength == BestCidr && Metric > BestMetric)
continue;
BestCidr = Table->Table[i].DestinationPrefix.PrefixLength;