Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
added code to attempt stateful detection of path mtu based on interna…
Browse files Browse the repository at this point in the history
…l tcp session initiation
  • Loading branch information
r-caamano committed Dec 22, 2023
1 parent cbfa55a commit e0c4107
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/zfw_tc_ingress.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,28 @@ int bpf_sk_splice(struct __sk_buff *skb){
}
return TC_ACT_SHOT;
}
bpf_printk("fragment needed srcip=%x, destip=%x", inner_iph->saddr, inner_iph->daddr);
return TC_ACT_OK;
if(inner_iph->protocol == tcp){
struct bpf_sock_tuple *o_session = (struct bpf_sock_tuple *)&inner_iph->saddr;
if ((unsigned long)(o_session + 1) > (unsigned long)skb->data_end){
event.error_code = IP_TUPLE_TOO_BIG;
send_event(&event);
return TC_ACT_SHOT;
}
sk = bpf_skc_lookup_tcp(skb, o_session, sizeof(*o_session),BPF_F_CURRENT_NETNS, 0);
if(sk){
if (sk->state != BPF_TCP_LISTEN){
bpf_printk("fragmentation needed srcip=%x, destip=%x, dport=%d", inner_iph->saddr, inner_iph->daddr, bpf_ntohs(o_session->ipv4.dport));
/*if(local_diag->verbose){
send_event(&event);
}*/
bpf_sk_release(sk);
return TC_ACT_OK;
}
bpf_sk_release(sk);
}
}
return TC_ACT_SHOT;
}
else{
return TC_ACT_SHOT;
Expand Down

0 comments on commit e0c4107

Please sign in to comment.