The script to extract BPF instructions from compiled ELF file would break if the ELF file was incorrectly built. Add simple check to give better message.
Fixes: 4e679a5f1212 ("net/tap: add infrastructure to build BPF filter") Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- drivers/net/tap/bpf/bpf_extract.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/tap/bpf/bpf_extract.py b/drivers/net/tap/bpf/bpf_extract.py index b630c42b809f..72c15cf7ad12 100644 --- a/drivers/net/tap/bpf/bpf_extract.py +++ b/drivers/net/tap/bpf/bpf_extract.py @@ -77,6 +77,8 @@ def main(): write_header(out, args.source) for path in args.file: elffile = ELFFile(open_input(path)) + if elffile['e_machine'] != 'EM_BPF': + sys.exit(f'{path} is not BPF') sections = load_sections(elffile) for name, insns in sections: dump_section(name, insns, out) -- 2.43.0