Skip to content

Commit

Permalink
Fix kconfig string loading
Browse files Browse the repository at this point in the history
  • Loading branch information
davibe committed Sep 25, 2024
1 parent 25b5368 commit 67d8937
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions aya/src/bpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ fn compute_kconfig_definition(features: &Features) -> HashMap<String, Vec<u8>> {
Some('y') => to_bytes(1).to_vec(),
Some('m') => to_bytes(2).to_vec(),
Some('"') => {
if raw_value.len() > 2 || raw_value.ends_with('"') {
continue;
}

let raw_value = &raw_value[1..raw_value.len() - 1];

raw_value.as_bytes().to_vec()
Expand Down
8 changes: 8 additions & 0 deletions test/integration-test/bpf/kconfig.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ extern unsigned int CONFIG_BPF __kconfig;
extern unsigned int CONFIG_PANIC_TIMEOUT __kconfig;
// CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
extern unsigned int CONFIG_DEFAULT_HUNG_TASK_TIMEOUT __kconfig;
// CONFIG_DEFAULT_HOSTNAME
extern char CONFIG_DEFAULT_HOSTNAME[] __kconfig;

SEC("xdp")
int kconfig(struct xdp_md *ctx) {
Expand All @@ -24,6 +26,12 @@ int kconfig(struct xdp_md *ctx) {
return XDP_DROP;
}

for (int i = 0; i < 7; i++) {
if ("(none)"[i] != CONFIG_DEFAULT_HOSTNAME[i]) {
return XDP_DROP;
}
}

return XDP_PASS;
}

Expand Down

0 comments on commit 67d8937

Please sign in to comment.