Skip to content
Snippets Groups Projects
Unverified Commit d3f035db authored by Mohamed S. Mahmoud's avatar Mohamed S. Mahmoud Committed by GitHub
Browse files

Avoid using LRU hashmap because they needs lots of memory (#162)


Even when the feature is not on memory with latest
showing double the normal use

Note: In general relying on LRU to evict old entries
isn;t recommended because its hard to perdict when
an entry will be deleted
at somepoint we need to add eviction logic in userspace

Signed-off-by: default avatarmsherif1234 <mmahmoud@redhat.com>
parent 31526a91
Branches
Tags
No related merge requests found
......@@ -19,24 +19,24 @@ struct {
} aggregated_flows SEC(".maps");
// Common hashmap to keep track of all flow sequences.
// LRU hashmap is used because if some syn packet is received but ack is not
// then the hashmap entry will need to be evicted
// Key is flow_seq_id which is standard 4 tuple and a sequence id
// sequence id is specific to the type of transport protocol
// Value is u64 which represents the occurrence timestamp of the packet.
struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 1 << 20); // Will take around 64MB of space.
__type(key, flow_seq_id);
__type(value, u64);
__uint(map_flags, BPF_F_NO_PREALLOC);
} flow_sequences SEC(".maps");
// DNS tracking flow based hashmap used to correlate query and responses
// to allow calculating latency in ebpf agent directly
struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 1 << 20); // Will take around 64MB of space.
__type(key, dns_flow_id);
__type(value, u64);
__uint(map_flags, BPF_F_NO_PREALLOC);
} dns_flows SEC(".maps");
#endif //__MAPS_DEFINITION_H__
// Code generated by bpf2go; DO NOT EDIT.
//go:build arm64be || armbe || mips || mips64 || mips64p32 || ppc64 || s390 || s390x || sparc || sparc64
// +build arm64be armbe mips mips64 mips64p32 ppc64 s390 s390x sparc sparc64
package ebpf
......
No preview for this file type
// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64 || amd64p32 || arm || arm64 || mips64le || mips64p32le || mipsle || ppc64le || riscv64
// +build 386 amd64 amd64p32 arm arm64 mips64le mips64p32le mipsle ppc64le riscv64
//go:build 386 || amd64 || amd64p32 || arm || arm64 || loong64 || mips64le || mips64p32le || mipsle || ppc64le || riscv64
package ebpf
......
No preview for this file type
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.14.0
// protoc-gen-go v1.31.0
// protoc v3.19.4
// source: proto/flow.proto
package pbflow
......@@ -509,6 +509,7 @@ type IP struct {
unknownFields protoimpl.UnknownFields
// Types that are assignable to IpFamily:
//
// *IP_Ipv4
// *IP_Ipv6
IpFamily isIP_IpFamily `protobuf_oneof:"ip_family"`
......
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.19.4
// source: proto/flow.proto
package pbflow
......@@ -14,6 +18,10 @@ import (
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
Collector_Send_FullMethodName = "/pbflow.Collector/Send"
)
// CollectorClient is the client API for Collector service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
......@@ -31,7 +39,7 @@ func NewCollectorClient(cc grpc.ClientConnInterface) CollectorClient {
func (c *collectorClient) Send(ctx context.Context, in *Records, opts ...grpc.CallOption) (*CollectorReply, error) {
out := new(CollectorReply)
err := c.cc.Invoke(ctx, "/pbflow.Collector/Send", in, out, opts...)
err := c.cc.Invoke(ctx, Collector_Send_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
......@@ -76,7 +84,7 @@ func _Collector_Send_Handler(srv interface{}, ctx context.Context, dec func(inte
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pbflow.Collector/Send",
FullMethod: Collector_Send_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CollectorServer).Send(ctx, req.(*Records))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment