winws: handle signals when busy, pass impostor and loopback

This commit is contained in:
bol-van 2024-05-11 16:48:51 +03:00
parent 23f2de8014
commit 4febb74b0d
4 changed files with 12 additions and 8 deletions

Binary file not shown.

View File

@ -1037,6 +1037,7 @@ static bool windivert_recv_filter(HANDLE hFilter, uint8_t *packet, size_t *len,
errno=EINTR; errno=EINTR;
return false; return false;
} }
usleep(0);
if (WinDivertRecvEx(hFilter, packet, *len, &recv_len, 0, wa, NULL, &ovl)) if (WinDivertRecvEx(hFilter, packet, *len, &recv_len, 0, wa, NULL, &ovl))
{ {
*len = recv_len; *len = recv_len;

View File

@ -444,17 +444,20 @@ static int win_main(const char *windivert_filter)
DLOG("packet: id=%u len=%zu %s IPv6=%u IPChecksum=%u TCPChecksum=%u UDPChecksum=%u IfIdx=%u.%u\n", id, len, wa.Outbound ? "outbound" : "inbound", wa.IPv6, wa.IPChecksum, wa.TCPChecksum, wa.UDPChecksum, wa.Network.IfIdx, wa.Network.SubIfIdx) DLOG("packet: id=%u len=%zu %s IPv6=%u IPChecksum=%u TCPChecksum=%u UDPChecksum=%u IfIdx=%u.%u\n", id, len, wa.Outbound ? "outbound" : "inbound", wa.IPv6, wa.IPChecksum, wa.TCPChecksum, wa.UDPChecksum, wa.Network.IfIdx, wa.Network.SubIfIdx)
if (wa.Impostor) if (wa.Impostor)
{ {
DLOG("windivert: skipping impostor packet\n") DLOG("windivert: passing impostor packet\n")
continue; verdict = VERDICT_PASS;
} }
if (wa.Loopback) else if (wa.Loopback)
{ {
DLOG("windivert: skipping loopback packet\n") DLOG("windivert: passing loopback packet\n")
continue; verdict = VERDICT_PASS;
}
else
{
mark=0;
// pseudo interface id IfIdx.SubIfIdx
verdict = processPacketData(&mark, ifout, packet, &len);
} }
mark=0;
// pseudo interface id IfIdx.SubIfIdx
verdict = processPacketData(&mark, ifout, packet, &len);
switch (verdict & VERDICT_MASK) switch (verdict & VERDICT_MASK)
{ {
case VERDICT_PASS: case VERDICT_PASS: