constchecker: check constants between Go/BPF#12436
constchecker: check constants between Go/BPF#12436kkourt wants to merge 1 commit intocilium:masterfrom
Conversation
christarazi
left a comment
There was a problem hiding this comment.
Nice! Overall looks good, just have a few comments below.
|
test-me-please |
|
test-me-please |
|
test-me-please |
tklauser
left a comment
There was a problem hiding this comment.
Nice work.
Some small comments inline, nothing major. Probably not worth to respin the PR if these are the only requested changes.
|
Commit 6c8907e8b195748c2a23e3a7b519db9badf95e71 does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
1 similar comment
|
Commit 6c8907e8b195748c2a23e3a7b519db9badf95e71 does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
|
Commits 6c8907e8b195748c2a23e3a7b519db9badf95e71, ee15973bc54aafe669e332469aae4ee2f8f7265a do not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
1 similar comment
|
Commits 6c8907e8b195748c2a23e3a7b519db9badf95e71, ee15973bc54aafe669e332469aae4ee2f8f7265a do not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
|
test-me-please |
|
test-me-please |
|
test-me-please |
|
Latest version adds a check for the loadbalancer, a minor checkpatch fix, and removes the object file for the constchecker self-test. |
|
@qmonnet I added a small checkpatch change here so that it does not complain about using inline comments for SPDX, since using SPDX seems to be the preferred way (#12436 (comment)). I later noticed that you had sent a (more complete) patch upstream for this issue (https://lore.kernel.org/patchwork/patch/1265784/#1461076). Not sure what the proper thing to do here, but it's a bit confusing to get conflicting checkpatch errors, so maybe we should carry the SPDX change locally regardless of whether it's upstreamed? |
(Thanks for asking!) I agree this is confusing. I was hoping the patch would be merged upstream, but it didn't get a warm reception and now this seems unlikely to happen. We discussed that during a datapath meeting (last week maybe), and we agreed on the following: There is some follow-up I intend to do on checkpatch, to package it as a Docker image instead of keeping it in the Cilium repo (on Ilya's suggestion). Once we have that, we can apply local patches ( In the meantime, I would as well keep the current version untouched. Unless you feel this is too much confusing and really prefer to patch, in which case we can start changing checkpatch.pl now and then report the changes later when packaging it as an image. I opened #12467 about packaging checkpatch. |
As long as people don't mind the red checkmark in BPF checks, it's fine by me :) As a side note, there is also: This seems like something that can be applied directly (or maybe not?) |
|
We could either ignore the |
|
test-me-please |
There was a problem hiding this comment.
I think there are Makefle environment variables set for go and test. I know this is a script but I'm wondering if it would make sense to keep them consistent.
There was a problem hiding this comment.
Indeed, they seem to be. My original thought was to add this test in the Makefile (defining the CILIUM_CONSTCHECKER_BPF_OBJ env variable would be enough), but this felt too intrusive/complex, so I decided to put it on a separate script. Since the const are fairly simple and have no other dependencies except for cosntchecker, I would think that running them as they are would be OK.
|
rebased |
|
test-me-please |
There was a problem hiding this comment.
This seems like a reasonable way to perform such checks. At a high level, I wonder whether we would benefit from moving more towards a model where the Golang implementation generates all of these constants from the Golang definition into a header file instead, then the BPF code simply includes those headers. That way, the constants would be ensured to be the same without having to perform additional checks afterwards.
That said, modulo the minor nits below I'm fine with the current approach.
The goal is to ensure that common constants between Go and BPF match. This commit adds: - constchecker, which checks values between BPF and Go by reading the ELF .rodata section of a BPF object file. - two tests, one for constchecker itself with dummy constants and one for loadbalancer. Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
|
test-me-please |
I do think that the approach in this PR is problematic in the sense that it's too much work for a developer to add new checks. They would have to edit two (go test, bpf file with constants) or more (test script) files, and probably would end up just adding a comment instead. And, if people are not going to use it, I'm not sure if it's worth merging. Generating constants from Go would be better in that sense, but I'm also not sure if it's worth doing it, since it adds some level of complexity, and I do like the fact that the bpf code is self-contained. Also, I'm not sure if constants checks solve a real problem, i.e., having a chance to catch actual bugs. Maybe a comment in Go and BPF side that these constants should match is the best solution at this point. |
|
test-me-please |
|
retest-net-next |
In practice we're already doing this via the headerfiles for
It's always possible, but given that both (Go/C) constants are usually introduced at the same time it's typically fairly easy to catch mistakes. I can't specifically recall hitting an issue like this in the past with Cilium. |
joestringer
left a comment
There was a problem hiding this comment.
I'm fine with the changes. We still have a partially-finished discussion above about the overall approach which could end in either deciding to merge this PR or not, so my approval is subject to that. I appreciate the effort looking into this either way :-)
|
Unless someone suggests differently, I would opt to drop this one. (I know it's my PR and I'm the one supposed to argue for it, but as I said I think it's too much hassle for people to use it.) We can always resurrect it if we think it makes sense. |
In the context of #12415, we wanted to add a test to compare values in
Go with ones in BPF. The first approach used
cgo, which is not ideal.This add some initial code to alignchecker that allows to check values
between BPF and go by reading the ELF .rodata section.
If this makes sense, it can be used for to add testing for #12415.
Signed-off-by: Kornilios Kourtis kornilios@isovalent.com