Skip to content

Commit

Permalink
Hacking away - remove the fin/reset flags because they shouldn't be n…
Browse files Browse the repository at this point in the history
…eeded.
  • Loading branch information
thebracket committed Feb 14, 2024
1 parent 295caaa commit 1ca595b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/rust/lqos_sys/src/bpf/common/flows.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct tcp_flow_key_t {

// TCP connection flow entry
struct tcp_flow_data_t {
__u64 start_time;
__u64 last_seen_a;
__u64 last_seen_b;
__u64 bytes_sent;
Expand All @@ -24,6 +25,8 @@ struct tcp_flow_data_t {
__u64 last_rtt;
__u64 packets_sent;
__u64 packets_received;
__u64 retries_a;
__u64 retries_b;
};

// Map for tracking TCP flow progress.
Expand Down Expand Up @@ -127,6 +130,7 @@ static __always_inline void track_flows(
// We need to add this flow to the tracking table.
bpf_debug("New TCP connection detected");
struct tcp_flow_data_t data = {
.start_time = now,
.last_seen_a = now,
.last_seen_b = now,
.bytes_sent = dissector->skb_len,
Expand All @@ -135,7 +139,9 @@ static __always_inline void track_flows(
.time_b = 0,
.last_rtt = 0,
.packets_sent = 1,
.packets_received = 0
.packets_received = 0,
.retries_a = 0,
.retries_b = 0
};
bpf_map_update_elem(&flowbee, &key, &data, BPF_ANY);
}
Expand Down Expand Up @@ -176,8 +182,9 @@ static __always_inline void track_flows(

if (data->time_a != 0 && sequence < data->time_a) {
// This is a retransmission
bpf_debug("DIR 1 Retransmission (or out of order) detected");
bpf_debug("to 192.168.66.%d => SEQ %d < %d", dissector->dst_ip.in6_u.u6_addr8[15], sequence, data->time_a);
//bpf_debug("DIR 1 Retransmission (or out of order) detected");
//bpf_debug("to 192.168.66.%d => SEQ %d < %d", dissector->dst_ip.in6_u.u6_addr8[15], sequence, data->time_a);
data->retries_a++;
}

data->time_a = sequence;
Expand All @@ -192,8 +199,9 @@ static __always_inline void track_flows(

if (data->time_b != 0 && sequence < data->time_b) {
// This is a retransmission
bpf_debug("DIR 2 Retransmission (or out of order) detected");
bpf_debug("to 192.168.66.%d => SEQ %d > %d", dissector->dst_ip.in6_u.u6_addr8[15], sequence, data->time_b);
//bpf_debug("DIR 2 Retransmission (or out of order) detected");
//bpf_debug("to 192.168.66.%d => SEQ %d > %d", dissector->dst_ip.in6_u.u6_addr8[15], sequence, data->time_b);
data->retries_b++;
}

data->time_b = sequence;
Expand All @@ -206,19 +214,23 @@ static __always_inline void track_flows(
// We need to remove this flow from the tracking table.
bpf_debug("TCP connection closed");
// TODO: Submit the result somewhere
bpf_debug(" Flow Lifetime: %u nanos", now - data->start_time);
bpf_debug(" BYTES : %d / %d", data->bytes_sent, data->bytes_received);
bpf_debug(" PACKETS : %d / %d", data->packets_sent, data->packets_received);
bpf_debug(" RTT : %d", data->last_rtt);
bpf_debug(" RTT : %d nanos", data->last_rtt);
bpf_debug(" RETRIES : %d / %d", data->retries_a, data->retries_b);
// /TODO
bpf_map_delete_elem(&flowbee, &key);
} else if ( tcp->rst ) {
// RST packet. We are resetting a connection.
// We need to remove this flow from the tracking table.
bpf_debug("TCP connection reset");
// TODO: Submit the result somewhere
bpf_debug(" Flow Lifetime: %u nanos", now - data->start_time);
bpf_debug(" BYTES : %d / %d", data->bytes_sent, data->bytes_received);
bpf_debug(" PACKETS : %d / %d", data->packets_sent, data->packets_received);
bpf_debug(" RTT : %d", data->last_rtt);
bpf_debug(" RTT : %d nanos", data->last_rtt);
bpf_debug(" RETRIES : %d / %d", data->retries_a, data->retries_b);
// /TODO
bpf_map_delete_elem(&flowbee, &key);
}
Expand Down

0 comments on commit 1ca595b

Please sign in to comment.