-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement packet sniffing with less overhead using tc-mirred
We use packet sniffing based on an expensive AF-PACKET to learn app IPs so that they can be reported to the user. Additionally, we capture DNS packets to log DNS requests as part of flow logging. This can be done more efficiently by mirroring DHCP, ARP and few other protocols that we are interested in into a dummy interface and capture packets there. This avoids cloning/copying every packet. Only those few we need will be cloned in the kernel. I think that the main problem is that AF-PACKET + BPF filter is only optimized in the Linux kernel for locally delivered traffic. The filter is applied before the packet is copied for delivery into the user-space via AF-PACKET socket. This avoids copying packets which are not matched by the filter. But in our case, we are interested in the forwarded traffic and therefore have to set bridge to the promiscuous mode for the packet sniffing. This then significantly degrades the performance because *every* packet forwarded by the bridge is skb_clone-d before it reaches the BPF filter. The solution is to use tc-filter and the ingress qdisc to mirror packets that we are interested in (ICMP, DHCP, ARP, DNS) into a separate dummy interface. Then we can run pcap on this dummy interface instead and avoid putting network instance bridge into the promiscuous mode. Signed-off-by: Milan Lenco <milan@zededa.com>
- Loading branch information
1 parent
2dfd31b
commit cdc6a49
Showing
14 changed files
with
713 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.