Skip to content

Commit

Permalink
fix: must_rules cause entire match_set to become must. (daeuniverse#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
LostAttractor authored Dec 27, 2024
1 parent 2932d5b commit 8693f52
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions control/kern/tproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,20 @@ static int route_loop_cb(__u32 index, void *data)
ctx->isdns_must_goodsubrule_badrule |= 0b10;
break;
case MatchType_ProcessName:
#ifdef __DEBUG_ROUTING
bpf_printk(
"CHECK: pname, match_set->type: %u, not: %d, outbound: %u",
match_set->type, match_set->not, match_set->outbound);
#endif
if (_is_wan && equal16(match_set->pname, _pname))
ctx->isdns_must_goodsubrule_badrule |= 0b10;
break;
case MatchType_Dscp:
#ifdef __DEBUG_ROUTING
bpf_printk(
"CHECK: dscp, match_set->type: %u, not: %d, outbound: %u",
match_set->type, match_set->not, match_set->outbound);
#endif
if (_dscp == match_set->dscp)
ctx->isdns_must_goodsubrule_badrule |= 0b10;
break;
Expand Down Expand Up @@ -819,15 +829,16 @@ 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",
Expand All @@ -837,7 +848,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);
Expand Down

0 comments on commit 8693f52

Please sign in to comment.