Skip to content

Commit

Permalink
Use unspecified compartment ID as it is less error prone
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Apr 16, 2021
1 parent 7bfc87e commit 8b77656
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sys/pm_callouts.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,20 @@ void redir(portmaster_packet_info* packetInfo, portmaster_packet_info* redirInfo

// Reset routing compartment ID, as we are changing where this is going to.
// This necessity is unconfirmed.
// Experience shows that using the compartment ID can sometimes cause errors.
// It seems safer to always use UNSPECIFIED_COMPARTMENT_ID.
// packetInfo->compartmentId = UNSPECIFIED_COMPARTMENT_ID;

if (packetInfo->direction == 0) {
// INFO("Send: nbl_status=0x%x, %s", NET_BUFFER_LIST_STATUS(inject_nbl), print_ipv4_packet(packet));
status = FwpsInjectNetworkSendAsync(handle, NULL, 0,
packetInfo->compartmentId, inject_nbl, free_after_inject,
UNSPECIFIED_COMPARTMENT_ID, inject_nbl, free_after_inject,
packet);
INFO("InjectNetworkSend executed: %s", print_packet_info(packetInfo));
} else {
// INFO("Recv: nbl_status=0x%x, %s", NET_BUFFER_LIST_STATUS(inject_nbl), print_ipv4_packet(packet));
status = FwpsInjectNetworkReceiveAsync(handle, NULL, 0,
packetInfo->compartmentId, packetInfo->interfaceIndex,
UNSPECIFIED_COMPARTMENT_ID, packetInfo->interfaceIndex,
packetInfo->subInterfaceIndex, inject_nbl, free_after_inject,
packet);
INFO("InjectNetworkReceive executed: %s", print_packet_info(packetInfo));
Expand Down Expand Up @@ -572,13 +574,13 @@ void respondWithVerdict(UINT32 id, verdict_t verdict) {
if (packetInfo->direction == 0) {
// INFO("Send: nbl_status=0x%x, %s", NET_BUFFER_LIST_STATUS(inject_nbl), print_ipv4_packet(packet));
status = FwpsInjectNetworkSendAsync(handle, NULL, 0,
packetInfo->compartmentId, inject_nbl, free_after_inject,
UNSPECIFIED_COMPARTMENT_ID, inject_nbl, free_after_inject,
packet);
INFO("InjectNetworkSend executed: %s", print_packet_info(packetInfo));
} else {
// INFO("Recv: nbl_status=0x%x, %s", NET_BUFFER_LIST_STATUS(inject_nbl), print_ipv4_packet(packet));
status = FwpsInjectNetworkReceiveAsync(handle, NULL, 0,
packetInfo->compartmentId, packetInfo->interfaceIndex,
UNSPECIFIED_COMPARTMENT_ID, packetInfo->interfaceIndex,
packetInfo->subInterfaceIndex, inject_nbl, free_after_inject,
packet);
INFO("InjectNetworkReceive executed: %s", print_packet_info(packetInfo));
Expand Down Expand Up @@ -649,13 +651,13 @@ void copy_and_inject(portmaster_packet_info* packetInfo, PNET_BUFFER nb, UINT32
if (packetInfo->direction == 0) {
// INFO("Send: nbl_status=0x%x, %s", NET_BUFFER_LIST_STATUS(inject_nbl), print_ipv4_packet(packet));
status = FwpsInjectNetworkSendAsync(handle, NULL, 0,
packetInfo->compartmentId, inject_nbl, free_after_inject,
UNSPECIFIED_COMPARTMENT_ID, inject_nbl, free_after_inject,
packet);
INFO("InjectNetworkSend executed: %s", print_packet_info(packetInfo));
} else {
// INFO("Recv: nbl_status=0x%x, %s", NET_BUFFER_LIST_STATUS(inject_nbl), print_ipv4_packet(packet));
status = FwpsInjectNetworkReceiveAsync(handle, NULL, 0,
packetInfo->compartmentId, packetInfo->interfaceIndex,
UNSPECIFIED_COMPARTMENT_ID, packetInfo->interfaceIndex,
packetInfo->subInterfaceIndex, inject_nbl, free_after_inject,
packet);
INFO("InjectNetworkReceive executed: %s", print_packet_info(packetInfo));
Expand Down

0 comments on commit 8b77656

Please sign in to comment.