Re: Interruption in eBPF program after kernel update

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

 



Hi Eric,

On 02/15/2019 02:07 PM, Daniel Borkmann wrote:
> On 02/14/2019 10:37 PM, Alexei Starovoitov wrote:
>> On Thu, Feb 14, 2019 at 10:33 AM Eric Leblond <eric@xxxxxxxxx> wrote:
>>>
>>> Hello,
>>>
>>> On Wed, 2019-02-13 at 20:46 +0100, Eric Leblond wrote:
>>>> Hello,
>>>>
>>>> I've got a simple socket filter program that seems to interrupt when
>>>> calling the load_word construct. I'm seeing the first message but
>>>> never
>>>> the second one.
>>>>
>>>> The code is the following
>>>>
>>>> int SEC("filter") hashfilter(struct __sk_buff *skb) {
>>>>     __u32 nhoff = BPF_LL_OFF + ETH_HLEN;
>>>
>>> So it seems the problem was coming from this line. Removing BPF_LL_OFF
>>> fixes the problem for kernel starting 4.18.
>>>
>>> Is this a known issue ?
>>>
>>> Is there something that would allow a BPF file to work independently of
>>> the kernel version ?
>>
>> Daniel,
>> can this be related to removal of ld_abs legacy ?
> 
> Hm, strange, I'll take a look.

Do you have a concrete stand-alone reproducer? Works fine for me on
latest bpf tree at least (internal code gen is same for filter and
tc BPF) ...

# pwd
/root/iproute2/examples/bpf
# cat foo.c
#include <stdio.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include "../../include/bpf_api.h"

__section_cls_entry
int cls_entry(struct __sk_buff *skb)
{
    __u32 nhoff = BPF_LL_OFF + ETH_HLEN;
    __u32 ip = 0;
    __u32 *value = NULL;
#if 1
    char fmtrei[] = "word load\n";
    trace_printk(fmtrei, sizeof(fmtrei));
#endif
    ip = load_word(skb, nhoff + offsetof(struct iphdr, saddr));
#if 1
    char fmti[] = "work done\n";
    trace_printk(fmti, sizeof(fmti));
#endif
    return TC_ACT_OK;
}

BPF_LICENSE("GPL");
# clang -target bpf -O2 -Wall -c foo.c -o foo.o -I ../../include/uapi/
# tc qdisc add dev bond0 clsact
# tc filter add dev bond0 ingress bpf da obj ./foo.o
# tc exec bpf dbg
[...]
          <idle>-0     [005] .Ns. 21102.794996: 0: work done
          <idle>-0     [005] ..s. 21102.796023: 0: word load
          <idle>-0     [005] .Ns. 21102.796045: 0: work done
          <idle>-0     [005] ..s. 21102.807417: 0: word load
          <idle>-0     [005] .Ns. 21102.807438: 0: work done
          <idle>-0     [005] ..s. 21102.808365: 0: word load
          <idle>-0     [005] .Ns. 21102.808387: 0: work done
          <idle>-0     [005] ..s. 21102.819905: 0: word load
          <idle>-0     [005] .Ns. 21102.819923: 0: work done
          <idle>-0     [005] ..s. 21102.820626: 0: word load
          <idle>-0     [005] .Ns. 21102.820646: 0: work done
          <idle>-0     [005] ..s. 21102.832293: 0: word load
          <idle>-0     [005] .Ns. 21102.832314: 0: work done
[...]
# uname -a
Linux test2 5.0.0-rc6+ #1 SMP Mon Feb 18 13:06:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
# llc --version
[...]
  LLVM version 3.8.0
# cat /proc/sys/net/core/bpf_jit_enable
1

Thanks,
Daniel



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

  Powered by Linux