diff --git a/load_bpf b/load_bpf index 05156a0..c2d9e15 100755 Binary files a/load_bpf and b/load_bpf differ diff --git a/load_bpf.c b/load_bpf.c index 98d7385..0f5ab34 100644 --- a/load_bpf.c +++ b/load_bpf.c @@ -65,7 +65,6 @@ int main(void){ //printf("%lld\n", stats); struct in_addr *src = (struct in_addr*)&s_reset.saddr; struct in_addr *dest = (struct in_addr*)&s_reset.daddr; - //struct in_addr src = s_reset.saddr; printf("Sport: %d; dport: %d %s %s\n", s_reset.sport, s_reset.dport, inet_ntoa(*src), inet_ntoa(*dest)); } diff --git a/tp_tcp.c b/tp_tcp.c index 9126c54..1601494 100644 --- a/tp_tcp.c +++ b/tp_tcp.c @@ -59,16 +59,15 @@ int tcp_retransmit(struct ctx_reset *ctx){ long long *stats; struct reset *s_reset; int keys = 0; - __u16 sport = 0; - __u16 dport = 0; s_reset = bpf_map_lookup_elem(&tcp_reset_stats, &keys); if (!s_reset) return 0; + if (!ctx) + return 0; + //*stats += 1; - sport = ctx->sport; - dport = ctx->dport; s_reset->saddr[0] = ctx->saddr[0]; s_reset->saddr[1] = ctx->saddr[1]; s_reset->saddr[2] = ctx->saddr[2]; @@ -77,10 +76,10 @@ int tcp_retransmit(struct ctx_reset *ctx){ s_reset->daddr[1] = ctx->daddr[1]; s_reset->daddr[2] = ctx->daddr[2]; s_reset->daddr[3] = ctx->daddr[3];*/ - s_reset->sport = sport; - s_reset->dport = dport; + s_reset->sport = ctx->sport; + s_reset->dport = ctx->dport; //bpf_printk("BPF detected TCP received reset %d - %d %d\n", *stats, dport, sport); - bpf_printk("BPF detected TCP received reset %d %d\n", dport, sport); + bpf_printk("BPF detected TCP received reset %d %d\n", s_reset->sport, s_reset->dport); return 0; } diff --git a/tp_tcp.o b/tp_tcp.o index ad2c7b0..8fa2941 100644 Binary files a/tp_tcp.o and b/tp_tcp.o differ