Thank you Song and Brenden! Apparently I do need to check the data_end. Is there a reason why it was silently ignoring the print_trace? I also got following warning; clang -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/5/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h \ -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ -Wno-compare-distinct-pointer-types \ -Wno-gnu-variable-sized-type-not-at-end \ -Wno-address-of-packed-member -Wno-tautological-compare \ -O2 -emit-llvm -c samples/bpf/parse_simple.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/parse_simple.o warning: unknown warning option '-Wno-address-of-packed-member' [-Wunknown-warning-option] Does it have anything to do with the problem? Many thanks Tamim On Sat, Jul 1, 2017 at 12:26 AM, Y Song <ys114321@xxxxxxxxx> wrote: > I created a test case on fc25 (kernel 4.8.6) like below and it works > fine for me. > > unsigned char *data = (unsigned char *)(long)skb->data; > unsigned char *data_end = (unsigned char *)(long)skb->data_end; > if (data + 2 > data_end) > return 0; > char fmt[] = "%u\n"; > bpf_trace_printk_(fmt, sizeof(fmt), *data); > > > > On Fri, Jun 30, 2017 at 2:25 PM, MD I. Islam <tamim@xxxxxxxxxxx> wrote: >> I tried to cast it into int *. In that case, it should print the >> integer. But I get the same problem. >> >> On Fri, Jun 30, 2017 at 5:16 PM, Y Song <ys114321@xxxxxxxxx> wrote: >>> Maybe *data is not a printable character? >>> >>> On Fri, Jun 30, 2017 at 12:54 PM, MD I. Islam <tamim@xxxxxxxxxxx> wrote: >>>> Hi >>>> >>>> I have following code attached to an interface: >>>> >>>> SEC("simple") >>>> int handle_ingress(struct __sk_buff *skb) >>>> { >>>> unsigned char *data = (unsigned char *)(long)skb->data; >>>> char fmt[] = "%u\n"; >>>> bpf_trace_printk(fmt, sizeof(fmt), *data); >>>> return 0; >>>> } >>>> >>>> When packets pass through the interface, it does not print anything at >>>> /sys/kernel/debug/tracing/trace_pipe. However if I do >>>> bpf_trace_printk(fmt, sizeof(fmt), data), it prints the pointer. Could >>>> you please advise what is wrong here? >>>> >>>> Many thanks >>>> Tamim