Skip to content

Commit 62e6c22

Browse files
committed
adapt BPF_LOG in route_config.h
Signed-off-by: lec-bit <glfhmzmy@126.com>
1 parent 114428f commit 62e6c22

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

bpf/kmesh/ads/include/route_config.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ virtual_host_match_check(Route__VirtualHost *virt_host, address_t *addr, ctx_buf
6666
return 1;
6767

6868
if (bpf_strnstr(ptr, domain, ptr_length) != NULL) {
69-
BPF_LOG(
70-
DEBUG,
71-
ROUTER_CONFIG,
72-
"match virtual_host, name=\"%s\"\n",
73-
(char *)KMESH_GET_PTR_VAL(virt_host->name, char *));
7469
return 1;
7570
}
7671
}
@@ -311,15 +306,16 @@ static inline char *select_weight_cluster(Route__RouteAction *route_act)
311306
select_value = select_value - (int)route_cluster_weight->weight;
312307
if (select_value <= 0) {
313308
cluster_name = KMESH_GET_PTR_VAL(route_cluster_weight->name, char *);
314-
BPF_LOG(
315-
DEBUG,
316-
ROUTER_CONFIG,
317-
"select cluster, name:weight %s:%d\n",
318-
cluster_name,
319-
route_cluster_weight->weight);
320-
return cluster_name;
309+
break;
321310
}
322311
}
312+
313+
if (cluster_name != NULL) {
314+
BPF_LOG(
315+
DEBUG, ROUTER_CONFIG, "select cluster, name:weight %s:%d\n", cluster_name, route_cluster_weight->weight);
316+
return cluster_name;
317+
}
318+
323319
return NULL;
324320
}
325321

@@ -371,6 +367,9 @@ int route_config_manager(ctx_buff_t *ctx)
371367
return KMESH_TAIL_CALL_RET(-1);
372368
}
373369

370+
BPF_LOG(
371+
DEBUG, ROUTER_CONFIG, "match virtual_host, name=\"%s\"\n", (char *)KMESH_GET_PTR_VAL(virt_host->name, char *));
372+
374373
route = virtual_host_route_match(virt_host, &addr, ctx, (struct bpf_mem_ptr *)ctx_val->msg);
375374
if (!route) {
376375
BPF_LOG(ERR, ROUTER_CONFIG, "failed to match route action, addr=%s\n", ip2str(&addr.ipv4, 1));

0 commit comments

Comments
 (0)