From dc453390655fae003778e7146a213bccca582b77 Mon Sep 17 00:00:00 2001 From: mzz <2017@duck.com> Date: Sun, 2 Jul 2023 19:29:18 +0800 Subject: [PATCH] fix: samba not work (#173) Co-authored-by: dae-bot[bot] <136105375+dae-bot[bot]@users.noreply.github.com> --- control/kern/tproxy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/control/kern/tproxy.c b/control/kern/tproxy.c index 276b8cd..63bb01d 100644 --- a/control/kern/tproxy.c +++ b/control/kern/tproxy.c @@ -1307,6 +1307,10 @@ int tproxy_lan_ingress(struct __sk_buff *skb) { sk = bpf_skc_lookup_tcp(skb, &tuple, tuple_size, BPF_F_CURRENT_NETNS, 0); if (sk) { + if (tuples.dport == bpf_ntohs(445)) { + // samba. It is safe because the smb port cannot be customized. + goto sk_accept; + } if (sk->state != BPF_TCP_LISTEN) { is_old_conn = true; goto assign; @@ -1548,7 +1552,7 @@ int tproxy_wan_egress(struct __sk_buff *skb) { // interface. if (tproxy_response && l4proto == IPPROTO_TCP) { // If it is a TCP first handshake, it is not a tproxy response. - if (tcph.syn && !tcph.syn) { + if (tcph.syn && !tcph.ack) { tproxy_response = false; // Abnormal. return TC_ACT_SHOT;