• Dave Marchevsky's avatar
    selftests/bpf: Modify linked_list tests to work with macro-ified inserts · de67ba39
    Dave Marchevsky authored
    The linked_list tests use macros and function pointers to reduce code
    duplication. Earlier in the series, bpf_list_push_{front,back} were
    modified to be macros, expanding to invoke actual kfuncs
    bpf_list_push_{front,back}_impl. Due to this change, a code snippet
    like:
    
      void (*p)(void *, void *) = (void *)&bpf_list_##op;
      p(hexpr, nexpr);
    
    meant to do bpf_list_push_{front,back}(hexpr, nexpr), will no longer
    work as it's no longer valid to do &bpf_list_push_{front,back} since
    they're no longer functions.
    
    This patch fixes issues of this type, along with two other minor changes
    - one improvement and one fix - both related to the node argument to
    list_push_{front,back}.
    
      * The fix: migration of list_push tests away from (void *, void *)
        func ptr uncovered that some tests were incorrectly passing pointer
        to node, not pointer to struct bpf_list_node within the node. This
        patch fixes such issues (CHECK(..., f) -> CHECK(..., &f->node))
    
      * The improvement: In linked_list tests, the struct foo type has two
        list_node fields: node and node2, at byte offsets 0 and 40 within
        the struct, respectively. Currently node is used in ~all tests
        involving struct foo and lists. The verifier needs to do some work
        to account for the offset of bpf_list_node within the node type, so
        using node2 instead of node exercises that logic more in the tests.
        This patch migrates linked_list tests to use node2 instead of node.
    Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
    Link: https://lore.kernel.org/r/20230415201811.343116-7-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    de67ba39
linked_list.h 1.14 KB