[llvm-dev] bpf compilation using clang

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 25 03:59:59 PDT 2018


On Tue, 25 Sep 2018 at 11:48, Sameeh Jubran <sameeh at daynix.com> wrote:
> iteration count of 40 is the max key size.

OK, then it's almost certainly this loop:

>     for(i = 0; i < RSS_MAX_KEY_SIZE; i++)
>     {
>         elem = map_lookup_elem(&map_rss_key, &i);
>         array[i] = elem == NULL ? '0' : *elem;
>     }

Loops need to be marked "#pragma unroll" and completely linearized
because (apparently) they're not allowed in BPF programs.

It actually seems like a pretty fragile situation because that pragma
is only an instruction to unroll if possible. A higher quality
implementation would find some way to make a loop in the final code an
error before you tried to load it into the kernel. But it is what it
is.

Cheers.

Tim.


More information about the llvm-dev mailing list