Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions bpf/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ static inline bool is_ipv4_mapped_addr(__u32 ip6[4])
return ip6[0] == 0 && ip6[1] == 0 && ip6[2] == 0xFFFF0000;
}

static inline bool is_ip_addr_zero(const struct ip_addr *addr)
{
if (!addr)
return true;

return addr->ip4 == 0 && addr->ip6[0] == 0 && addr->ip6[1] == 0 && addr->ip6[2] == 0 && addr->ip6[3] == 0;
}

#define V4_MAPPED_REVERSE(v4_mapped) \
do { \
(v4_mapped)[0] = (v4_mapped)[3]; \
Expand Down
2 changes: 1 addition & 1 deletion bpf/kmesh/workload/include/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ backend_manager(struct kmesh_context *kmesh_ctx, backend_value *backend_v, __u32
ctx_buff_t *ctx = (ctx_buff_t *)kmesh_ctx->ctx;
__u32 i, user_port = ctx->user_port;

if (backend_v->waypoint_port != 0) {
if (backend_v->waypoint_port != 0 && !is_ip_addr_zero(&backend_v->wp_addr)) {
BPF_LOG(
DEBUG,
BACKEND,
Expand Down
2 changes: 1 addition & 1 deletion bpf/kmesh/workload/include/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline int frontend_manager(struct kmesh_context *kmesh_ctx, frontend_val

if (direct_backend) { // in this case, we donot check the healthy status of the backend, just let it go
// For pod direct access, if a pod has waypoint captured, we will redirect to waypoint, otherwise we do nothing.
if (backend_v->waypoint_port != 0) {
if (backend_v->waypoint_port != 0 && !is_ip_addr_zero(&backend_v->wp_addr)) {
BPF_LOG(
DEBUG,
FRONTEND,
Expand Down
2 changes: 1 addition & 1 deletion bpf/kmesh/workload/include/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static inline int service_manager(struct kmesh_context *kmesh_ctx, __u32 service
{
int ret = 0;

if (service_v->wp_addr.ip4 != 0 && service_v->waypoint_port != 0) {
if (!is_ip_addr_zero(&service_v->wp_addr) && service_v->waypoint_port != 0) {
BPF_LOG(
DEBUG,
SERVICE,
Expand Down
Loading