Skip to content

Commit

Permalink
Remove unuse comment and add debug message for XDP program.
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwenwwer committed Apr 5, 2024
1 parent c63e438 commit 7dca0ff
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bpf/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,16 @@ int xdp_sock_prog(struct xdp_md *ctx) {

struct iphdr *ip = data + sizeof(*eth);
if ((void *)ip + sizeof(*ip) > data_end) {
// bpf_printk("ip + sizeof(*ip) > data_end\n");
#ifdef DEBUG_XDP
bpf_printk("ip + sizeof(*ip) > data_end\n");
#endif
goto out;
}

if (ip->protocol != IPPROTO_UDP) { // Only UDP packets
// bpf_printk("ip->protocol != IPPROTO_UDP\n");
#ifdef DEBUG_XDP
bpf_printk("ip->protocol != IPPROTO_UDP\n");
#endif
goto out;
}

Expand All @@ -437,7 +441,9 @@ int xdp_sock_prog(struct xdp_md *ctx) {
}

if (udp->dest != bpf_htons(PORT)) {
// bpf_printk("Not the port.\n");
#ifdef DEBUG_XDP
bpf_printk("Not the port.\n");
#endif
goto out;
}

Expand All @@ -448,7 +454,6 @@ int xdp_sock_prog(struct xdp_md *ctx) {
return XDP_DROP;

out:
// bpf_printk("[xdp_sock_prog] XDP_PASS\n");
return XDP_PASS;
}

Expand Down

0 comments on commit 7dca0ff

Please sign in to comment.