|
structs := []struct { |
|
goType string |
|
cType string |
|
patches []patch |
|
}{ |
|
{ |
|
"ProgInfo", "bpf_prog_info", |
|
[]patch{ |
|
replace(objName, "name"), |
|
replace(pointer, "xlated_prog_insns"), |
|
replace(pointer, "map_ids"), |
|
replace(pointer, "line_info"), |
|
replace(pointer, "func_info"), |
|
replace(btfID, "btf_id", "attach_btf_obj_id"), |
|
replace(typeID, "attach_btf_id"), |
|
}, |
|
}, |
|
{ |
|
"MapInfo", "bpf_map_info", |
|
[]patch{ |
|
replace(objName, "name"), |
|
replace(mapFlags, "map_flags"), |
|
replace(typeID, "btf_vmlinux_value_type_id", "btf_key_type_id", "btf_value_type_id"), |
|
}, |
|
}, |
|
{ |
|
"BtfInfo", "bpf_btf_info", |
|
[]patch{ |
|
replace(pointer, "btf", "name"), |
|
replace(btfID, "id"), |
|
}, |
|
}, |
|
{ |
|
"LinkInfo", "bpf_link_info", |
|
[]patch{ |
|
replace(enumTypes["LinkType"], "type"), |
|
replace(linkID, "id"), |
|
name(3, "extra"), |
|
replaceWithBytes("extra"), |
|
}, |
|
}, |
|
{"FuncInfo", "bpf_func_info", nil}, |
|
{"LineInfo", "bpf_line_info", nil}, |
|
{"XdpMd", "xdp_md", nil}, |
|
{ |
|
"SkLookup", "bpf_sk_lookup", |
|
[]patch{ |
|
choose(0, "cookie"), |
|
replaceWithBytes("remote_ip4", "remote_ip6", "local_ip4", "local_ip6"), |
|
}, |
|
}, |
|
} |
btf_types.go contains a bunch of hand written structs that map to types defined in the kernel's UAPI. We should replace these with auto generated types in sys package and use those from btf. This guarantees that we match the kernel 1:1 and also ensures that there is no implicit padding present.
The changes need to be made here:
ebpf/internal/cmd/gentypes/main.go
Lines 157 to 208 in 0acd95c