Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add process PID to SessionMeta #23

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions libebpfdiscovery/src/Discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace ebpfdiscovery {
static void printSession(const Session& session, const DiscoverySessionMeta& meta) {
const auto& request{session.parser.result};
std::cout << request.method << " " << request.host << request.url;

if (const auto& xForwardedFor{request.xForwardedFor}; !xForwardedFor.empty()) {
std::cout << " X-Forwarded-For: " << '"' << xForwardedFor << '"';
} else if (discoverySessionFlagsIsIPv4(meta.flags)) {
Expand All @@ -37,8 +36,7 @@ static void printSession(const Session& session, const DiscoverySessionMeta& met
if (auto srcIpv6{ipv6ToString(meta.sourceIPData)}; !srcIpv6.empty())
std::cout << " srcIpv6: " << '"' << srcIpv6 << '"';
}

std::cout << '\n';
std::cout << " pid: " << meta.pid << '\n';
}

Discovery::Discovery() : Discovery(DiscoveryConfig{}) {
Expand Down
1 change: 1 addition & 0 deletions libebpfdiscoveryshared/headers/ebpfdiscoveryshared/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ __attribute__((always_inline)) inline static void discoverySessionFlagsSetIPv6(D
struct DiscoverySessionMeta {
__u8 sourceIPData[16];
DiscoverySessionFlags flags;
__u32 pid;
};

struct DiscoverySession {
Expand Down
1 change: 1 addition & 0 deletions libebpfdiscoveryskel/src/Handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ __attribute__((always_inline)) inline static void handleRead(
}

sessionPtr->id = allSessionStatePtr->sessionCounter;
sessionPtr->meta.pid = event.dataKey.pid;
allSessionStatePtr->sessionCounter++;
sessionFillIP((struct DiscoveryTrackedSessionKey*)&event.dataKey, sessionPtr);
} else {
Expand Down