Skip to content

Commit 67a13bb

Browse files
authored
Merge pull request #166 from coroot/protocol_detection_accuracy
ebpf: improve protocol identification accuracy
2 parents f49ea14 + 2658190 commit 67a13bb

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

ebpftracer/ebpf.go

Lines changed: 10 additions & 10 deletions
Large diffs are not rendered by default.

ebpftracer/ebpf/l7/l7.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
276276
return 0;
277277
} else if (is_cassandra_request(payload, size, &k.stream_id)) {
278278
req->protocol = PROTOCOL_CASSANDRA;
279-
} else if (is_kafka_request(payload, size, &req->request_id)) {
280-
req->protocol = PROTOCOL_KAFKA;
281-
struct l7_request *prev_req = bpf_map_lookup_elem(&active_l7_requests, &k);
282-
if (prev_req && prev_req->protocol == PROTOCOL_KAFKA) {
283-
req->ns = prev_req->ns;
284-
}
285279
} else if (looks_like_http2_frame(payload, size, METHOD_HTTP2_CLIENT_FRAMES)) {
286280
struct l7_event *e = bpf_map_lookup_elem(&l7_event_heap, &zero);
287281
if (!e) {
@@ -298,6 +292,12 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
298292
req->protocol = PROTOCOL_CLICKHOUSE;
299293
} else if (is_zk_request(payload, total_size)) {
300294
req->protocol = PROTOCOL_ZOOKEEPER;
295+
} else if (is_kafka_request(payload, size, &req->request_id)) {
296+
req->protocol = PROTOCOL_KAFKA;
297+
struct l7_request *prev_req = bpf_map_lookup_elem(&active_l7_requests, &k);
298+
if (prev_req && prev_req->protocol == PROTOCOL_KAFKA) {
299+
req->ns = prev_req->ns;
300+
}
301301
} else if (is_dubbo2_request(payload, size)) {
302302
req->protocol = PROTOCOL_DUBBO2;
303303
} else if (is_dns_request(payload, size, &k.stream_id)) {

0 commit comments

Comments
 (0)