aya-rs / book

The Aya Book is an introductory book about using the Rust Programming Language and Aya library to build extended Berkley Packet Filter (eBPF) programs.
https://aya-rs.dev/book/
Apache License 2.0
81 stars 60 forks source link

A "-" in xdp name leads to os error 22 #53

Closed jornfranke closed 2 years ago

jornfranke commented 2 years ago

If I replace the xpd name found in https://github.com/aya-rs/book/blob/main/examples/myapp-01/myapp-ebpf/src/main.rs#L11 with a name containing a "-" and adapting it https://github.com/aya-rs/book/blob/main/examples/myapp-01/myapp/src/main.rs#L46 then I get when running the program:

Error: the BPF_PROG_LOAD syscall failed. Verifier output: 

Caused by:
    Invalid argument (os error 22)

For example, I replaced "myapp" with "localnet-filter". After changing it to "localnetfilter" it works.

Probably one should adapt the attribute "#xdp" to check for invalid characters and throw an error at compile time.

Btw. is my assumption correct that only alphanumerical characters are allowed for the name?

dave-tucker commented 2 years ago

Hey @jornfranke thanks for reporting this issue.

Btw. is my assumption correct that only alphanumerical characters are allowed for the name?

That is correct.

I'll go ahead and close this here as we'll be revisiting program name handling in https://github.com/aya-rs/aya/issues/375