Skip to content

Commit

Permalink
Add handling
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-szweda committed Feb 5, 2024
1 parent 7e8fa77 commit 2e448c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 2 additions & 9 deletions libebpfdiscoveryskel/src/Handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

#define PROTOCOL_VEC_LIMIT 3

__attribute__((always_inline)) inline static void handleAcceptIPv4Session(
struct pt_regs* ctx,
const struct DiscoveryTrackedSessionKey trackedSessionKey,
Expand Down Expand Up @@ -210,15 +212,6 @@ __attribute__((always_inline)) inline static void handleRead(
sessionPtr->bufferCount++;
}

__attribute__((always_inline)) inline static void handleReadVector(
struct pt_regs* ctx,
struct DiscoveryGlobalState* globalStatePtr,
struct DiscoveryAllSessionState* allSessionStatePtr,
struct ReadVectorArgs* readVectorArgsPtr,
ssize_t bytesCount) {
return;
}

__attribute__((always_inline)) inline static void handleClose(
struct pt_regs* ctx, struct DiscoveryGlobalState* globalStatePtr, struct DiscoveryAllSessionState* allSessionStatePtr, int fd) {
struct DiscoveryTrackedSessionKey trackedSessionKey = {};
Expand Down
8 changes: 7 additions & 1 deletion libebpfdiscoveryskel/src/SyscallProbes.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,13 @@ __attribute__((always_inline)) inline static int handleSysRecvmsgExit(struct pt_
return 0;
}

handleReadVector(ctx, globalStatePtr, allSessionStatePtr, readVectorArgsPtr, bytesCount);
for (size_t i = 0; i < PROTOCOL_VEC_LIMIT && i < readVectorArgsPtr->iovlen; i++) {
struct ReadArgs readArgs = {
.fd = readVectorArgsPtr->fd,
.buf = (char*) readVectorArgsPtr->iov[i].iov_base,
};
handleRead(ctx, globalStatePtr, allSessionStatePtr, &readArgs, readVectorArgsPtr->iov[i].iov_len);
}
bpf_map_delete_elem(&runningReadVectorArgsMap, &pidTgid);

return 0;
Expand Down

0 comments on commit 2e448c2

Please sign in to comment.