Skip to content

Commit 15a8137

Browse files
authored
Merge pull request #1363 from lec-bit/issue
fix log cannot print in kernel 5.10 by bpf_trace_printk
2 parents 80ae5ef + e4ee237 commit 15a8137

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

bpf/kmesh/ads/include/cluster.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,9 @@ static inline int cluster_handle_loadbalance(Cluster__Cluster *cluster, address_
311311
return -EAGAIN;
312312
}
313313

314-
BPF_LOG(
315-
INFO,
316-
CLUSTER,
317-
"cluster=\"%s\", loadbalance to addr=[%s:%u]\n",
318-
name,
319-
ip2str(&sock_addr->ipv4, 1),
320-
bpf_ntohs(sock_addr->port));
314+
// Since bpf_trace_printk cannot print two %s, the name and ipv4 are printed separately.
315+
BPF_LOG(INFO, CLUSTER, "cluster=\"%s\"\n", name);
316+
BPF_LOG(INFO, CLUSTER, "loadbalance to addr=[%s:%u]\n", ip2str(&sock_addr->ipv4, 1), bpf_ntohs(sock_addr->port));
321317
SET_CTX_ADDRESS(ctx, sock_addr);
322318
return 0;
323319
}
@@ -352,4 +348,4 @@ int cluster_manager(ctx_buff_t *ctx)
352348
return KMESH_TAIL_CALL_RET(ret);
353349
}
354350

355-
#endif
351+
#endif

bpf/kmesh/workload/xdp.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,6 @@ static inline int should_shutdown(struct xdp_info *info, struct bpf_sock_tuple *
4848
return AUTH_PASS;
4949
}
5050

51-
static inline int xdp_deny_packet(struct xdp_info *info, struct bpf_sock_tuple *tuple_info)
52-
{
53-
if (info->iph != NULL && info->iph->version == 4) {
54-
BPF_LOG(
55-
INFO,
56-
XDP,
57-
"auth denied, src ip: %s, dst ip %s, dst port: %u\n",
58-
ip2str(&tuple_info->ipv4.saddr, true),
59-
ip2str(&tuple_info->ipv4.daddr, true),
60-
bpf_ntohs(tuple_info->ipv4.dport));
61-
} else {
62-
BPF_LOG(
63-
INFO,
64-
XDP,
65-
"auth denied, src ip: %s, dst ip %s, dst port: %u\n",
66-
ip2str(&tuple_info->ipv6.saddr[0], false),
67-
ip2str(&tuple_info->ipv6.daddr[0], false),
68-
bpf_ntohs(tuple_info->ipv6.dport));
69-
}
70-
return XDP_DROP;
71-
}
72-
7351
volatile __u32 authz_offload = 1;
7452

7553
static bool is_authz_offload_enabled()

0 commit comments

Comments
 (0)