Skip to content
  • Daniel Borkmann's avatar
    bpf: add BPF_SIZEOF and BPF_FIELD_SIZEOF macros · f035a515
    Daniel Borkmann authored
    
    
    Add BPF_SIZEOF() and BPF_FIELD_SIZEOF() macros to improve the code a bit
    which otherwise often result in overly long bytes_to_bpf_size(sizeof())
    and bytes_to_bpf_size(FIELD_SIZEOF()) lines. So place them into a macro
    helper instead. Moreover, we currently have a BUILD_BUG_ON(BPF_FIELD_SIZEOF())
    check in convert_bpf_extensions(), but we should rather make that generic
    as well and add a BUILD_BUG_ON() test in all BPF_SIZEOF()/BPF_FIELD_SIZEOF()
    users to detect any rewriter size issues at compile time. Note, there are
    currently none, but we want to assert that it stays this way.
    
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f035a515