p>Network connection is essentially socket communication. eBPF provides a function <code>bpf_msg_redirect_hash</code>, to directly forward the packets sent by the application in the inbound socket to the outbound socket. By entering the function mentioned before, developers can perform any logic to decide the packet destination. According to this characteristic, the datapath of packets can noticeably be optimized in the kernel.</p><p>The <code>sock_map</code> is the crucial piece in recording information fo