Skip to content

Commit

Permalink
Remove debug lines (netbirdio#1468)
Browse files Browse the repository at this point in the history
Remove print lines from EBPF code
  • Loading branch information
pappz committed Jan 15, 2024
1 parent 23c42cb commit d2e85dd
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
1 change: 0 additions & 1 deletion client/internal/ebpf/ebpf/bpf_bpfeb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified client/internal/ebpf/ebpf/bpf_bpfeb.o
Binary file not shown.
3 changes: 1 addition & 2 deletions client/internal/ebpf/ebpf/bpf_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified client/internal/ebpf/ebpf/bpf_bpfel.o
Binary file not shown.
6 changes: 3 additions & 3 deletions client/internal/ebpf/ebpf/src/dns_fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ int xdp_dns_fwd(struct iphdr *ip, struct udphdr *udp) {
if(!read_settings()){
return XDP_PASS;
}
bpf_printk("dns port: %d", ntohs(dns_port));
bpf_printk("dns ip: %d", ntohl(dns_ip));
// bpf_printk("dns port: %d", ntohs(dns_port));
// bpf_printk("dns ip: %d", ntohl(dns_ip));
}

if (udp->dest == GENERAL_DNS_PORT && ip->daddr == dns_ip) {
Expand All @@ -61,4 +61,4 @@ int xdp_dns_fwd(struct iphdr *ip, struct udphdr *udp) {
}

return XDP_PASS;
}
}
8 changes: 1 addition & 7 deletions client/internal/ebpf/ebpf/src/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
#include "dns_fwd.c"
#include "wg_proxy.c"

#define bpf_printk(fmt, ...) \
({ \
char ____fmt[] = fmt; \
bpf_trace_printk(____fmt, sizeof(____fmt), ##__VA_ARGS__); \
})

const __u16 flag_feature_wg_proxy = 0b01;
const __u16 flag_feature_dns_fwd = 0b10;

Expand Down Expand Up @@ -63,4 +57,4 @@ int nb_xdp_prog(struct xdp_md *ctx) {
}
return XDP_PASS;
}
char _license[] SEC("license") = "GPL";
char _license[] SEC("license") = "GPL";
12 changes: 12 additions & 0 deletions client/internal/ebpf/ebpf/src/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Debug


The CONFIG_BPF_EVENTS kernel module is required for bpf_printk.
Apply this code to use bpf_printk
```
#define bpf_printk(fmt, ...) \
({ \
char ____fmt[] = fmt; \
bpf_trace_printk(____fmt, sizeof(____fmt), ##__VA_ARGS__); \
})
```
4 changes: 2 additions & 2 deletions client/internal/ebpf/ebpf/src/wg_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int xdp_wg_proxy(struct iphdr *ip, struct udphdr *udp) {
if (!read_port_settings()){
return XDP_PASS;
}
bpf_printk("proxy port: %d, wg port: %d", proxy_port, wg_port);
// bpf_printk("proxy port: %d, wg port: %d", proxy_port, wg_port);
}

// 2130706433 = 127.0.0.1
Expand All @@ -51,4 +51,4 @@ int xdp_wg_proxy(struct iphdr *ip, struct udphdr *udp) {
udp->dest = new_dst_port;
udp->source = new_src_port;
return XDP_PASS;
}
}

0 comments on commit d2e85dd

Please sign in to comment.