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

handle partial Zookeeper reads #162

Merged
merged 1 commit into from
Dec 25, 2024
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
20 changes: 10 additions & 10 deletions ebpftracer/ebpf.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion ebpftracer/ebpf/l7/l7.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,11 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
return 0; // keeping the query in the map
}
} else if (e->protocol == PROTOCOL_ZOOKEEPER) {
response = is_zk_response(payload, total_size, &e->status);
response = is_zk_response(payload, total_size, &e->status, req->partial);
if (response == 2) { // partial
req->partial = 1;
return 0; // keeping the query in the map
}
} else if (e->protocol == PROTOCOL_DUBBO2) {
response = is_dubbo2_response(payload, &e->status);
}
Expand Down
16 changes: 12 additions & 4 deletions ebpftracer/ebpf/l7/zookeeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@ int is_zk_request(char *buf, __u64 buf_size) {
}

static __always_inline
int is_zk_response(char *buf, __u64 buf_size, __s32 *status) {
int is_zk_response(char *buf, __u64 buf_size, __s32 *status, __u8 partial) {
if (partial == 0 && buf_size == 4) { //partial read
return 2;
}
struct zk_response_header resp = {};
bpf_read(buf, resp);
if (bpf_ntohl(resp.length)+4 != buf_size) {
return 0;
if (partial) {
bpf_read(buf, resp.xid);
bpf_read(buf+12, resp.err_code);
} else {
bpf_read(buf, resp);
if (bpf_ntohl(resp.length)+4 != buf_size) {
return 0;
}
}
__s32 xid = bpf_ntohl(resp.xid);
if (xid < 0 && xid != -1 && xid != -2) {
Expand Down
Loading