fixed4338

This commit is contained in:
Rodrigo Bertoldo de Sousa Martins committed 2026-09-14 09:28:31 -03:00
1 parent e97a83c989
commit 26d0220ecb
1 file changed
+12
+12
View File
@@ -157,8 +157,13 @@ int bpf_sockops_handler(struct bpf_sock_ops *skops)
struct sock_key key = {}; struct sock_key key = {};
extract_key_from_ops(skops, &key); extract_key_from_ops(skops, &key);
// DEBUG TEMPORÁRIO — remover depois de confirmar o comportamento.
bpf_printk("REG op=%u sip=%x dip=%x", op, key.sip4, key.dip4);
bpf_printk("REG sport=%u dport=%u", key.sport, key.dport);
// BPF_ANY: atualiza mesmo se já existir (cobre reconexões keepalive) // BPF_ANY: atualiza mesmo se já existir (cobre reconexões keepalive)
int ret = bpf_sock_hash_update(skops, &sock_hash, &key, BPF_ANY); int ret = bpf_sock_hash_update(skops, &sock_hash, &key, BPF_ANY);
bpf_printk("REG update ret=%d", ret);
if (ret == 0) { if (ret == 0) {
stats_inc(0); stats_inc(0);
@@ -186,6 +191,8 @@ int bpf_sockops_handler(struct bpf_sock_ops *skops)
new_state == BPF_TCP_TIME_WAIT) { new_state == BPF_TCP_TIME_WAIT) {
struct sock_key key = {}; struct sock_key key = {};
extract_key_from_ops(skops, &key); extract_key_from_ops(skops, &key);
// DEBUG TEMPORÁRIO
bpf_printk("DEL state=%u sport=%u dport=%u", new_state, key.sport, key.dport);
bpf_map_delete_elem(&sock_hash, &key); bpf_map_delete_elem(&sock_hash, &key);
} }
break; break;
@@ -229,8 +236,13 @@ int bpf_msg_redirect(struct sk_msg_md *msg)
key.dport = bpf_htonl(msg->local_port) >> 16; key.dport = bpf_htonl(msg->local_port) >> 16;
key.family = msg->family; key.family = msg->family;
// DEBUG TEMPORÁRIO
bpf_printk("MSG sip=%x dip=%x", key.sip4, key.dip4);
bpf_printk("MSG sport=%u dport=%u size=%u", key.sport, key.dport, msg->size);
// Tenta redirecionar diretamente para o socket par. // Tenta redirecionar diretamente para o socket par.
int ret = bpf_msg_redirect_hash(msg, &sock_hash, &key, BPF_F_INGRESS); int ret = bpf_msg_redirect_hash(msg, &sock_hash, &key, BPF_F_INGRESS);
bpf_printk("MSG redirect ret=%d", ret);
if (ret == SK_PASS) { if (ret == SK_PASS) {
stats_inc(1); // Redirecionamento OK — caminho acelerado stats_inc(1); // Redirecionamento OK — caminho acelerado
return SK_PASS; return SK_PASS;