Fix kconfig string loading

pull/1017/head
Davide Bertola 7 months ago
parent d95a4561ed
commit 8179853f53

@ -171,12 +171,11 @@ fn compute_kconfig_definition(features: &Features) -> HashMap<String, Vec<u8>> {
Some('y') => 1_u64.to_ne_bytes().to_vec(), Some('y') => 1_u64.to_ne_bytes().to_vec(),
Some('m') => 2_u64.to_ne_bytes().to_vec(), Some('m') => 2_u64.to_ne_bytes().to_vec(),
Some('"') => { Some('"') => {
if raw_value.len() > 2 || raw_value.ends_with('"') { if raw_value.len() < 2 || !raw_value.ends_with('"') {
continue; continue;
} }
let raw_value = &raw_value[1..raw_value.len() - 1]; let raw_value = &raw_value[1..raw_value.len() - 1];
raw_value.as_bytes().to_vec() raw_value.as_bytes().to_vec()
} }
Some(_) => { Some(_) => {

@ -9,6 +9,8 @@ extern unsigned int CONFIG_BPF __kconfig;
extern unsigned int CONFIG_PANIC_TIMEOUT __kconfig; extern unsigned int CONFIG_PANIC_TIMEOUT __kconfig;
// CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 // CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
extern unsigned int CONFIG_DEFAULT_HUNG_TASK_TIMEOUT __kconfig; extern unsigned int CONFIG_DEFAULT_HUNG_TASK_TIMEOUT __kconfig;
// CONFIG_DEFAULT_HOSTNAME
extern char CONFIG_DEFAULT_HOSTNAME[] __kconfig;
SEC("xdp") SEC("xdp")
int kconfig(struct xdp_md *ctx) { int kconfig(struct xdp_md *ctx) {
@ -24,6 +26,12 @@ int kconfig(struct xdp_md *ctx) {
return XDP_DROP; return XDP_DROP;
} }
for (int i = 0; i < 7; i++) {
if ("(none)"[i] != CONFIG_DEFAULT_HOSTNAME[i]) {
return XDP_DROP;
}
}
return XDP_PASS; return XDP_PASS;
} }

Loading…
Cancel
Save