Skip to content

Commit 25fa915

Browse files
d-e-s-odanielocfb
authored andcommitted
libbpf-cargo: Restrict visibility of skeleton's BPF object
It seems a bit unnecessary to expose the skeleton's BPF object publicly: we already provide accessors that basically don't impose any limits on what accesses are possible. Restrict the visibility of the actual object reference in order to more easily change this detail of the implementation in the future. On top of that, by funneling everything through an accessor method we basically prevent somewhat dodgy-seeming accesses to Object::maps_mut() (or similar) while we have mutable Maps objects around in the skeleton itself. Given that direct Object access is meant as an escape-hatch only, this seems like a sensible restriction to have in place. Signed-off-by: Daniel Müller <[email protected]>
1 parent aa060c0 commit 25fa915

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libbpf-cargo/src/gen/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ pub struct StructOps {{}}
10571057
skel,
10581058
"\
10591059
pub struct Open{name}Skel<'obj> {{
1060-
pub obj: &'obj mut libbpf_rs::OpenObject,
1060+
obj: &'obj mut libbpf_rs::OpenObject,
10611061
pub maps: Open{name}Maps<'obj>,
10621062
pub progs: Open{name}Progs<'obj>,
10631063
pub struct_ops: StructOps,
@@ -1124,7 +1124,7 @@ pub struct StructOps {{}}
11241124
skel,
11251125
"\
11261126
pub struct {name}Skel<'obj> {{
1127-
pub obj: &'obj mut libbpf_rs::Object,
1127+
obj: &'obj mut libbpf_rs::Object,
11281128
pub maps: {name}Maps<'obj>,
11291129
pub progs: {name}Progs<'obj>,
11301130
struct_ops: StructOps,

0 commit comments

Comments
 (0)