Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btf: fix off-by-one in Spec.TypeByID #993

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Mar 29, 2023

Spec.lastTypeID was introduced to avoid having to do overflow checks in multiple places. However, in combination with firstTypeID it leads to confusion. Spec.lastTypeID is actually a valid id, instead of the first invalid one. This bit me when refactoring Spec.TypeByID.

Remove Spec.lastTypeID in favour of arithmetic based on firstTypeID and len(types).

Spec.lastTypeID was introduced to avoid having to do overflow checks
in multiple places. However, in combination with firstTypeID it leads
to confusion. Spec.lastTypeID is actually a valid id, instead of the
first invalid one. This bit me when refactoring Spec.TypeByID.

Remove Spec.lastTypeID in favour of arithmetic based on firstTypeID
and len(types).

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb requested a review from rgo3 March 29, 2023 10:29
@lmb lmb added the bug Something isn't working label Mar 29, 2023
@lmb lmb merged commit 1c5fc27 into cilium:master Mar 30, 2023
@lmb lmb deleted the btf-fix-type-by-id branch March 30, 2023 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants