Hi, Linux 4.11 has LPM trie support exactly for this [1]. I'm using regular hashmaps for now with a fixed subnet length step (e.g. for IPv4, I'm looking up /24, /16) for steering purposes. This however might not work in your use case, especially if you're not in control of the block subdivision.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b95a5c4db09bc7c253636cb84dc9b12c577fd5a0 Cheers, Marek On Tue, Oct 3, 2017 at 9:50 AM, Sasha Goldshtein via iovisor-dev <iovisor-dev@lists.iovisor.org> wrote: > Hi all, > > I was asked at Velocity yesterday if there’s an efficient way to summarize > incoming and outgoing traffic by subnet using BPF (providing rx and tx byte > counts per subnet). The use case is trying to estimate traffic costs for > cross-region or cross-availability zone deployments in cloud environments. > > For static subnet definitions it would be fairly reasonable to use kprobes > like tcptop does, and apply IP bitmasks hardcoded into the BPF program. But > what about subnets added dynamically, or for incoming traffic? > > Any suggestions or pointers would be very appreciated. > > Thanks, > Sasha > > _______________________________________________ > iovisor-dev mailing list > iovisor-dev@lists.iovisor.org > https://lists.iovisor.org/mailman/listinfo/iovisor-dev > _______________________________________________ iovisor-dev mailing list iovisor-dev@lists.iovisor.org https://lists.iovisor.org/mailman/listinfo/iovisor-dev