Re: bpf_trace_printk isn't working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I tested on latest net-next 4.12.0-rc6+ which is also fine.

On Fri, Jun 30, 2017 at 9:26 PM, 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



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux