@DTS Engineer
I took following approaches to handle ICMP and UDP bypass:
Create a raw socket at helper process side as this is not allowed from extension sandbox environment
Upon receiving the pkt from extension over UDS at helper side, change source address of packets to en0 address and recommpute checksum.(source address will have utun address of Pkt Tunnel extn)
Send packet on raw socket
it will be send to destinations.
Inbound traffics comes to kernel
ICMP gets deliver to applications. ICMP don’t require explicit binding by the app (system handles it), so raw injection + kernel delivery works naturally
Inbound UDP and TCP will not get deliver because kernel doesn’t know which socket to deliver it to
recvfrom for rawsocket doesn't works
Handling Inbound UDP and TCP
sniff en0 using libpcap
Maintain some map / state table to pick only intrested packets
change the destination back to packet tunnel utun interface address and re compute checksum
tell packet tunnel to write it back
The final step in our inbound packet processing is failing intermittently. The kernel is silently dropping the packet sometime during the packetFlow.writePacketObjects call, and it never reaches the application. How can we debug why the kernel is dropping it?
Topic:
App & System Services
SubTopic:
Networking
Tags: