Closed Sherlock-Holo closed 2 years ago
Well for once, those functions all use std::fmt
internally, which we do not have access to as eBPF programs work without stdlib, so you can't just proxy.
Next, you have to recall that in eBPF, we do not have access to any (standard) memory allocation mechanisms (only limited size stack and some map trickery), so working with arbitrary size data is not possible. You would have to write a very limited emulation of the format!
macro.
What printk!
does internally, it just calls the kernel's printk
function (plus some safety checks). And %llu, %d
etc all happen to be the syntax used by the kernel: https://www.kernel.org/doc/Documentation/printk-formats.txt
in rust world,
format!
,println!
orlog::info!
, all of them use{}
, whyprintk!
use%llu
%d
?