1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-19 10:10:40 +03:00

Merge pull request #1758 from domosekai/ipv6rs

Cedar/IPC: Change IPv6 router lookup to non-blocking
This commit is contained in:
Yihong Wu 2023-01-31 19:52:10 +09:00 committed by GitHub
commit 7c642c7d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 47 deletions

View File

@ -2365,8 +2365,11 @@ bool IPCIPv6CheckUnicastFromRouterPrefix(IPC *ipc, IP *ip, IPC_IPV6_ROUTER_ADVER
IPC_IPV6_ROUTER_ADVERTISEMENT *matchingRA = NULL; IPC_IPV6_ROUTER_ADVERTISEMENT *matchingRA = NULL;
bool isInPrefix = false; bool isInPrefix = false;
if (LIST_NUM(ipc->IPv6RouterAdvs) == 0 && IPCSendIPv6RouterSoliciation(ipc) == false) if (LIST_NUM(ipc->IPv6RouterAdvs) == 0)
{ {
// We have a unicast packet but we haven't got any RAs.
// The client is probably misconfigured in IPv6. We send non-blocking RS at best effort.
IPCSendIPv6RouterSoliciation(ipc, false);
return false; return false;
} }
@ -2390,16 +2393,8 @@ bool IPCIPv6CheckUnicastFromRouterPrefix(IPC *ipc, IP *ip, IPC_IPV6_ROUTER_ADVER
} }
// Send router solicitation to find a router // Send router solicitation to find a router
bool IPCSendIPv6RouterSoliciation(IPC *ipc) bool IPCSendIPv6RouterSoliciation(IPC *ipc, bool blocking)
{ {
// If we don't have a valid client EUI, we can't generate a correct link local
if (ipc->IPv6ClientEUI == 0)
{
return false;
}
if (LIST_NUM(ipc->IPv6RouterAdvs) == 0)
{
IP destIP; IP destIP;
IPV6_ADDR destV6; IPV6_ADDR destV6;
UCHAR destMacAddress[6]; UCHAR destMacAddress[6];
@ -2408,6 +2403,12 @@ bool IPCSendIPv6RouterSoliciation(IPC *ipc)
UINT64 giveup_time = Tick64() + (UINT64)(IPC_IPV6_RA_MAX_RETRIES * IPC_IPV6_RA_INTERVAL); UINT64 giveup_time = Tick64() + (UINT64)(IPC_IPV6_RA_MAX_RETRIES * IPC_IPV6_RA_INTERVAL);
UINT64 timeout_retry = 0; UINT64 timeout_retry = 0;
// If we don't have a valid client EUI, we can't generate a correct link local
if (ipc->IPv6ClientEUI == 0)
{
return false;
}
Zero(&linkLocal, sizeof(IPV6_ADDR)); Zero(&linkLocal, sizeof(IPV6_ADDR));
// Generate link local from client's EUI // Generate link local from client's EUI
@ -2426,6 +2427,12 @@ bool IPCSendIPv6RouterSoliciation(IPC *ipc)
packet = BuildICMPv6RouterSoliciation(&linkLocal, &destV6, ipc->MacAddress, 0); packet = BuildICMPv6RouterSoliciation(&linkLocal, &destV6, ipc->MacAddress, 0);
if (blocking == false) {
IPCIPv6SendWithDestMacAddr(ipc, packet->Buf, packet->Size, destMacAddress);
FreeBuf(packet);
return false;
}
while (LIST_NUM(ipc->IPv6RouterAdvs) == 0) while (LIST_NUM(ipc->IPv6RouterAdvs) == 0)
{ {
UINT64 now = Tick64(); UINT64 now = Tick64();
@ -2449,8 +2456,6 @@ bool IPCSendIPv6RouterSoliciation(IPC *ipc)
} }
FreeBuf(packet); FreeBuf(packet);
}
return true; return true;
} }

View File

@ -233,7 +233,7 @@ bool IPCIPv6CheckExistingLinkLocal(IPC *ipc, UINT64 eui);
// RA // RA
void IPCIPv6AddRouterPrefixes(IPC *ipc, ICMPV6_OPTION_LIST *recvPrefix, UCHAR *macAddress, IP *ip); void IPCIPv6AddRouterPrefixes(IPC *ipc, ICMPV6_OPTION_LIST *recvPrefix, UCHAR *macAddress, IP *ip);
bool IPCIPv6CheckUnicastFromRouterPrefix(IPC *ipc, IP *ip, IPC_IPV6_ROUTER_ADVERTISEMENT *matchedRA); bool IPCIPv6CheckUnicastFromRouterPrefix(IPC *ipc, IP *ip, IPC_IPV6_ROUTER_ADVERTISEMENT *matchedRA);
bool IPCSendIPv6RouterSoliciation(IPC *ipc); bool IPCSendIPv6RouterSoliciation(IPC *ipc, bool blocking);
// Data flow // Data flow
BLOCK *IPCIPv6Recv(IPC *ipc); BLOCK *IPCIPv6Recv(IPC *ipc);
void IPCIPv6Send(IPC *ipc, void *data, UINT size); void IPCIPv6Send(IPC *ipc, void *data, UINT size);