Skip to content

Commit 553635d

Browse files
authored
Filter out sockets for loopback and unknown interfaces (#260)
* RTT: filter out sockets for loopback and unknown interfaces Signed-off-by: Mohamed Mahmoud <[email protected]> * filter loopback and unknown interfaces with pkt drop feature Signed-off-by: Mohamed Mahmoud <[email protected]> --------- Signed-off-by: Mohamed Mahmoud <[email protected]>
1 parent 340f97c commit 553635d

File tree

6 files changed

+8
-1
lines changed

6 files changed

+8
-1
lines changed

bpf/pkt_drops.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ static inline int trace_pkt_drop(void *ctx, u8 state,
1717
u16 family = 0,flags = 0;
1818

1919
id.if_index = skb->skb_iif;
20-
20+
// filter out TCP sockets with unknown or loopback interface
21+
if (id.if_index == 0 || id.if_index == 1) {
22+
return 0;
23+
}
2124
// read L2 info
2225
set_key_with_l2_info(skb, &id, &family);
2326

bpf/rtt_tracker.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ static inline int calculate_flow_rtt_tcp(struct sock *sk, struct sk_buff *skb) {
102102
__builtin_memset(&id, 0, sizeof(id));
103103

104104
id.if_index = BPF_CORE_READ(skb, skb_iif);
105+
// filter out TCP sockets with unknown or loopback interface
106+
if (id.if_index == 0 || id.if_index == 1) {
107+
return 0;
108+
}
105109
len = BPF_CORE_READ(skb, len);
106110

107111
// read L2 info

pkg/ebpf/bpf_arm64_bpfel.o

208 Bytes
Binary file not shown.

pkg/ebpf/bpf_powerpc_bpfel.o

208 Bytes
Binary file not shown.

pkg/ebpf/bpf_s390_bpfeb.o

208 Bytes
Binary file not shown.

pkg/ebpf/bpf_x86_bpfel.o

208 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)