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

bpf: declare maps with __type for key and value #3307

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

mtardy
Copy link
Member

@mtardy mtardy commented Jan 15, 2025

Using __type(key, type) instead of __uint(key_size, sizeof(type)), and similarly for value, adds BTF information on the map which can be useful. When using 'bpftool map dump' with the BTF information, the formatting is then correct according to the types.

This patch is the result of running:

find bpf -type f -exec sed -i -E 's/__uint\(value_size,\s*sizeof\(([^)]+)\)\)/__type(value, \1)/g' {} +
find bpf -type f -exec sed -i -E 's/__uint\(key_size,\s*sizeof\(([^)]+)\)\)/__type(key, \1)/g' {} +

Some __uint(value_size were kept because they did not use sizeof but literal integers.

Using __type(key, type) instead of __uint(key_size, sizeof(type)), and
similarly for value, adds BTF information on the map which can be
useful. When using 'bpftool map dump' with the BTF information, the
formatting is then correct according to the types.

This patch is the result of running:

	find bpf -type f -exec sed -i -E 's/__uint\(value_size,\s*sizeof\(([^)]+)\)\)/__type(value, \1)/g' {} +
	find bpf -type f -exec sed -i -E 's/__uint\(key_size,\s*sizeof\(([^)]+)\)\)/__type(key, \1)/g' {} +

Some __uint(value_size were kept because they did not use sizeof but
literal integers.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy added area/bpf This is related to BPF code release-note/misc This PR makes changes that have no direct user impact. labels Jan 15, 2025
@mtardy mtardy requested a review from a team as a code owner January 15, 2025 18:39
@mtardy mtardy requested a review from tpapagian January 15, 2025 18:39
@mtardy mtardy merged commit 62712a5 into main Jan 16, 2025
44 checks passed
@mtardy mtardy deleted the pr/mtardy/bpf-map-declaration-sizeof branch January 16, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bpf This is related to BPF code 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.

3 participants