Skip to content

Commit

Permalink
feat: Add process PID to SessionMeta (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
hparzych authored Oct 10, 2023
1 parent 0dc255b commit c708d5a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
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

0 comments on commit c708d5a

Please sign in to comment.