mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
fix xdp test c form test
Signed-off-by: varun-r-mallya <varunrmallya@gmail.com>
This commit is contained in:
@ -1,18 +1,16 @@
|
||||
#include <linux/bpf.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/ip.h>
|
||||
#include "vmlinux.h"
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
struct fake_iphdr {
|
||||
unsigned short useless;
|
||||
unsigned short tot_len;
|
||||
unsigned short id;
|
||||
unsigned short frag_off;
|
||||
unsigned char ttl;
|
||||
unsigned char protocol;
|
||||
unsigned short check;
|
||||
unsigned int saddr;
|
||||
unsigned int daddr;
|
||||
unsigned short useless;
|
||||
unsigned short tot_len;
|
||||
unsigned short id;
|
||||
unsigned short frag_off;
|
||||
unsigned char ttl;
|
||||
unsigned char protocol;
|
||||
unsigned short check;
|
||||
unsigned int saddr;
|
||||
unsigned int daddr;
|
||||
};
|
||||
|
||||
SEC("xdp")
|
||||
@ -25,9 +23,9 @@ int xdp_prog(struct xdp_md *ctx) {
|
||||
}
|
||||
struct fake_iphdr *iph = (void *)data + sizeof(struct ethhdr);
|
||||
|
||||
bpf_printk("%d", iph->saddr);
|
||||
bpf_printk("%d", iph->saddr);
|
||||
|
||||
return XDP_PASS;
|
||||
return XDP_PASS;
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
Reference in New Issue
Block a user