• Alexei Starovoitov's avatar
    bpf: allow helpers access the packet directly · 6841de8b
    Alexei Starovoitov authored
    The helper functions like bpf_map_lookup_elem(map, key) were only
    allowing 'key' to point to the initialized stack area.
    That is causing performance degradation when programs need to process
    millions of packets per second and need to copy contents of the packet
    into the stack just to pass the stack pointer into the lookup() function.
    Allow such helpers read from the packet directly.
    All helpers that expect ARG_PTR_TO_MAP_KEY, ARG_PTR_TO_MAP_VALUE,
    ARG_PTR_TO_STACK assume byte aligned pointer, so no alignment concerns,
    only need to check that helper will not be accessing beyond
    the packet range verified by the prior 'if (ptr < data_end)' condition.
    For now allow this feature for XDP programs only. Later it can be
    relaxed for the clsact programs as well.
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    6841de8b
verifier.c 78 KB