Skip to content

Conversation

lmb
Copy link
Contributor

@lmb lmb commented Nov 30, 2023

complexity-tests: remove Egress Gateway from IPv6-only tests

Egress Gateway only supports IPv4 so enabling it on IPv6-only tests doesn't
make a lot of sense.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

bpf: prevent clang from reordering address calculations before NULL check

Compiling the BPF complexity tests currently bails out in 
tail_nodeport_nat_egress_ipv4 and tail_nodeport_nat_egress_ipv6. The error 
for the v4 case is the following:

    ; return map_lookup_elem(map, tuple);
   169: (18) r1 = 0xffff9dfb4d0f9800     ;
R1_w=map_ptr(off=0,ks=14,vs=40,imm=0)
   171: (85) call bpf_map_lookup_elem#1
   172: (bf) r5 = r0
   173: (07) r5 += 32
   R5 pointer arithmetic on map_value_or_null prohibited, null-check it
first

The problem is easier to spot when looking at the disassembly of the
function:

    ;       return map_lookup_elem(map, tuple);
   169:       r1 = 0x0 ll
   171:       call 0x1
   172:       r5 = r0
   173:       r5 += 0x20
   174:       r3 = r0
   175:       r3 += 0x24
   ;       if (*state)
   176:       if r0 != 0x0 goto +0x6da <LBB9_167>

It seems like clang has decided that it can hoist the address calculation
based on r0 before checking that r0 != 0.

Work around this issue by inserting a barrier_data() call.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

test/verifier: fix complexity tests not being recompiled

TestVerifier is accidentally reusing the result of previous subtest 
compilations. This means that only the first set of configurations was
tested.

Invoke clean for every new compilation. The generated object files are moved
to the test directory to make them accessible as artifacts from CI.

Fixes: d3ef5b2ac8 ("test/verifier: Avoid pruning object files before testing
the next file") Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

test/verifier: improve log output

Include the command invoked to compile the BPF and the output of the command
in the test output by default.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

Egress Gateway only supports IPv4 so enabling it on IPv6-only
tests doesn't make a lot of sense.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb added area/loader Impacts the loading of BPF programs into the kernel. area/CI Continuous Integration testing issue or flake release-note/misc This PR makes changes that have no direct user impact. labels Nov 30, 2023
@lmb
Copy link
Contributor Author

lmb commented Nov 30, 2023

/ci-verifier

lmb added 3 commits November 30, 2023 13:41
…heck

Compiling the BPF complexity tests currently bails out in
tail_nodeport_nat_egress_ipv4 and tail_nodeport_nat_egress_ipv6. The error
for the v4 case is the following:

    ; return map_lookup_elem(map, tuple);
    169: (18) r1 = 0xffff9dfb4d0f9800     ; R1_w=map_ptr(off=0,ks=14,vs=40,imm=0)
    171: (85) call bpf_map_lookup_elem#1
    172: (bf) r5 = r0
    173: (07) r5 += 32
    R5 pointer arithmetic on map_value_or_null prohibited, null-check it first

The problem is easier to spot when looking at the disassembly of the function:

    ;       return map_lookup_elem(map, tuple);
    169:       r1 = 0x0 ll
    171:       call 0x1
    172:       r5 = r0
    173:       r5 += 0x20
    174:       r3 = r0
    175:       r3 += 0x24
    ;       if (*state)
    176:       if r0 != 0x0 goto +0x6da <LBB9_167>

It seems like clang has decided that it can hoist the address calculation based
on r0 before checking that r0 != 0.

Work around this issue by inserting a barrier_data() call.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
TestVerifier is accidentally reusing the result of previous subtest
compilations. This means that only the first set of configurations was tested.

Invoke clean for every new compilation. The generated object files are
moved to the test directory to make them accessible as artifacts from CI.

Fixes: d3ef5b2 ("test/verifier: Avoid pruning object files before testing the next file")
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Include the command invoked to compile the BPF and the output of
the command in the test output by default.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb force-pushed the fix-complexity-test branch from 53ee2a3 to 1edeb5d Compare November 30, 2023 15:09
@lmb
Copy link
Contributor Author

lmb commented Nov 30, 2023

/test

@lmb lmb added the affects/v1.14 This issue affects v1.14 branch label Nov 30, 2023
@lmb
Copy link
Contributor Author

lmb commented Nov 30, 2023

This might need a manual backport to v1.14, I think that reverting the offending commit is probably the best option.

@lmb lmb marked this pull request as ready for review November 30, 2023 15:12
@lmb lmb requested review from a team as code owners November 30, 2023 15:12
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Dec 1, 2023
@aanm aanm added this pull request to the merge queue Dec 1, 2023
@pchaigno
Copy link
Member

pchaigno commented Dec 1, 2023

@lmb If it affects v1.14, shouldn't we backport there?

@lmb
Copy link
Contributor Author

lmb commented Dec 1, 2023

Yes, I'll do that once this is in main.

@julianwiedmann julianwiedmann added backport/author The backport will be carried out by the author of the PR. needs-backport/1.14 labels Dec 1, 2023
@pchaigno
Copy link
Member

pchaigno commented Dec 1, 2023

@lmb I was referring to the labels :-)

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 1, 2023
@julianwiedmann julianwiedmann added this pull request to the merge queue Dec 1, 2023
Merged via the queue into cilium:main with commit 1e71a19 Dec 1, 2023
@lmb lmb deleted the fix-complexity-test branch December 1, 2023 14:03
@lmb
Copy link
Contributor Author

lmb commented Dec 1, 2023

#29553

@julianwiedmann julianwiedmann added backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. and removed needs-backport/1.14 labels Dec 1, 2023
@nebril nebril added backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Dec 11, 2023
@gentoo-root gentoo-root added backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/v1.14 This issue affects v1.14 branch area/CI Continuous Integration testing issue or flake area/loader Impacts the loading of BPF programs into the kernel. backport/author The backport will be carried out by the author of the PR. backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants