Skip to content

Commit 2864713

Browse files
authored
NETOBSERV-1390: Flow RTT values are n/a (#245)
* update libbpf and update bpf headers Signed-off-by: Mohamed Mahmoud <[email protected]> * change rtt logic to use kprobe and get rtt from tcp socket Signed-off-by: Mohamed Mahmoud <[email protected]> * merge flow record RTT info in case of dup flows Signed-off-by: Mohamed Mahmoud <[email protected]> --------- Signed-off-by: Mohamed Mahmoud <[email protected]>
1 parent cd878fd commit 2864713

35 files changed

+452681
-141702
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ generate: prereqs ## Generate artifacts of the code repo (pkg/ebpf and pkg/proto
123123
.PHONY: docker-generate
124124
docker-generate: ## Create the container that generates the eBPF binaries
125125
@echo "### Creating the container that generates the eBPF binaries"
126-
$(OCI_BIN) build . -f scripts/generators.Dockerfile -t $(LOCAL_GENERATOR_IMAGE)
126+
$(OCI_BIN) build . -f scripts/generators.Dockerfile -t $(LOCAL_GENERATOR_IMAGE) --build-arg EXTENSION="x86_64"
127127
$(OCI_BIN) run --rm -v $(shell pwd):/src $(LOCAL_GENERATOR_IMAGE)
128128

129129
.PHONY: compile

bpf/flows.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ static inline int flow_monitor(struct __sk_buff *skb, u8 direction) {
6666
id.if_index = skb->ifindex;
6767
id.direction = direction;
6868

69-
// We calculate the RTT before looking up aggregated_flows map because we want
70-
// to keep the critical section between map lookup and update consume minimum time.
71-
if (enable_rtt) {
72-
// This is currently not to be enabled by default.
73-
calculate_flow_rtt(&pkt, direction, data_end);
74-
}
7569
int dns_errno = 0;
7670
if (enable_dns_tracking) {
7771
dns_errno = track_dns_packet(skb, &pkt);
@@ -90,10 +84,6 @@ static inline int flow_monitor(struct __sk_buff *skb, u8 direction) {
9084
}
9185
aggregate_flow->flags |= pkt.flags;
9286
aggregate_flow->dscp = pkt.dscp;
93-
// Does not matter the gate. Will be zero if not enabled.
94-
if (pkt.rtt > aggregate_flow->flow_rtt) {
95-
aggregate_flow->flow_rtt = pkt.rtt;
96-
}
9787
aggregate_flow->dns_record.id = pkt.dns_id;
9888
aggregate_flow->dns_record.flags = pkt.dns_flags;
9989
aggregate_flow->dns_record.latency = pkt.dns_latency;
@@ -109,18 +99,22 @@ static inline int flow_monitor(struct __sk_buff *skb, u8 direction) {
10999
}
110100
} else {
111101
// Key does not exist in the map, and will need to create a new entry.
102+
u64 rtt = 0;
103+
if (enable_rtt && id.transport_protocol == IPPROTO_TCP) {
104+
rtt = MIN_RTT;
105+
}
112106
flow_metrics new_flow = {
113107
.packets = 1,
114108
.bytes = skb->len,
115109
.start_mono_time_ts = pkt.current_ts,
116110
.end_mono_time_ts = pkt.current_ts,
117111
.flags = pkt.flags,
118-
.flow_rtt = pkt.rtt,
119112
.dscp = pkt.dscp,
120113
.dns_record.id = pkt.dns_id,
121114
.dns_record.flags = pkt.dns_flags,
122115
.dns_record.latency = pkt.dns_latency,
123116
.dns_record.errno = dns_errno,
117+
.flow_rtt = rtt,
124118
};
125119

126120
// even if we know that the entry is new, another CPU might be concurrently inserting a flow

0 commit comments

Comments
 (0)