From 7e91fee7bfd6015d4a87c4c1f81818e19eaaa6d5 Mon Sep 17 00:00:00 2001 From: ChaosAttractor Date: Tue, 24 Dec 2024 01:23:24 +0800 Subject: [PATCH] fix: must_rules causes match_set modification --- control/kern/tproxy.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/control/kern/tproxy.c b/control/kern/tproxy.c index 88fc56f17..8b02dbea2 100644 --- a/control/kern/tproxy.c +++ b/control/kern/tproxy.c @@ -829,15 +829,14 @@ static int route_loop_cb(__u32 index, void *data) OUTBOUND_MUST_RULES)) { ctx->isdns_must_goodsubrule_badrule |= 0b100; } else { - if (ctx->isdns_must_goodsubrule_badrule & 0b100) - match_set->must = true; - if (!match_set->must && + bool must = ctx->isdns_must_goodsubrule_badrule & 0b100 || match_set->must; + if (!must && (ctx->isdns_must_goodsubrule_badrule & 0b1000)) { ctx->result = (__s64)OUTBOUND_CONTROL_PLANE_ROUTING | ((__s64)match_set->mark << 8) | - ((__s64)match_set->must << 40); + ((__s64)must << 40); #ifdef __DEBUG_ROUTING bpf_printk( "OUTBOUND_CONTROL_PLANE_ROUTING: %ld", @@ -847,7 +846,7 @@ static int route_loop_cb(__u32 index, void *data) } ctx->result = (__s64)match_set->outbound | ((__s64)match_set->mark << 8) | - ((__s64)match_set->must << 40); + ((__s64)must << 40); #ifdef __DEBUG_ROUTING bpf_printk("outbound %u: %ld", match_set->outbound, ctx->result);