Skip to content

adapt BPF_LOG in route_config.h #1220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions bpf/kmesh/ads/include/route_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ virtual_host_match_check(Route__VirtualHost *virt_host, address_t *addr, ctx_buf
return 1;

if (bpf_strnstr(ptr, domain, ptr_length) != NULL) {
BPF_LOG(
DEBUG,
ROUTER_CONFIG,
"match virtual_host, name=\"%s\"\n",
(char *)KMESH_GET_PTR_VAL(virt_host->name, char *));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we know which is matched now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line 364, virt_host = virtual_host_match(route_config, &addr, ctx);
we can log here

return 1;
}
}
Expand Down Expand Up @@ -311,15 +306,15 @@ static inline char *select_weight_cluster(Route__RouteAction *route_act)
select_value = select_value - (int)route_cluster_weight->weight;
if (select_value <= 0) {
cluster_name = KMESH_GET_PTR_VAL(route_cluster_weight->name, char *);
BPF_LOG(
DEBUG,
ROUTER_CONFIG,
"select cluster, name:weight %s:%d\n",
cluster_name,
route_cluster_weight->weight);
return cluster_name;
break;
}
}

if (cluster_name != NULL) {
BPF_LOG(DEBUG, ROUTER_CONFIG, "select cluster, name %s\n", cluster_name);
return cluster_name;
}

return NULL;
}

Expand Down Expand Up @@ -371,6 +366,9 @@ int route_config_manager(ctx_buff_t *ctx)
return KMESH_TAIL_CALL_RET(-1);
}

BPF_LOG(
DEBUG, ROUTER_CONFIG, "match virtual_host, name=\"%s\"\n", (char *)KMESH_GET_PTR_VAL(virt_host->name, char *));

route = virtual_host_route_match(virt_host, &addr, ctx, (struct bpf_mem_ptr *)ctx_val->msg);
if (!route) {
BPF_LOG(ERR, ROUTER_CONFIG, "failed to match route action, addr=%s\n", ip2str(&addr.ipv4, 1));
Expand Down
Loading