Perf Buffer常规用法: struct addrinfo //需要上传给应用层的数据结构 { int ai_flags; /* Input flags. */ int ai_family; /* Protocol family for socket. */ int ai_socktype; /* Socket type. */ int ai_protocol; /* Protocol for socket. */ u32 ai_addrlen; /* Length of socket address. */ // CHANGED from socklen_t struct sockaddr *ai_addr; /* Socket address for socket. */ char *ai_canonname; /* Canonical name for service location. */ struct addrinfo *ai_next; /* Pointer to next in list. */ }; struct //Perf Map声明 { __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); __uint(key_size, sizeof(int)); __uint(value_size, sizeof(int)); //这里不是 struct addrinfo大小,这里指的是key对应的fd的大小 ***** __uint(max_entries, 1024); //最大 fd 数量,这里可以不设置,在应用层设置,会覆盖这里的值,尽量保证一个cpu对应一个buffer // https://github.com/cilium/ebpf/pull/300 // https://github.com/cilium/ebpf/issues/209