Skip to content

Commit 0822766

Browse files
committed
feat(rtx-xdp): drop caps when done with them
1 parent f5b3ea2 commit 0822766

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ trees = { workspace = true }
186186
[target.'cfg(not(any(target_env = "msvc", target_os = "freebsd")))'.dependencies]
187187
jemallocator = { workspace = true }
188188

189+
[target.'cfg(target_os = "linux")'.dependencies]
190+
caps = { workspace = true }
191+
189192
[target."cfg(unix)".dependencies]
190193
rts-alloc = { workspace = true }
191194
shaq = { workspace = true }

core/src/validator.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,22 @@ impl Validator {
15501550
(None, None)
15511551
};
15521552

1553+
#[cfg(target_os = "linux")]
1554+
{
1555+
use caps::{
1556+
CapSet,
1557+
Capability::{CAP_BPF, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON},
1558+
};
1559+
// we're done with caps needed to init xdp now. remove them from our process
1560+
let cap_sets = [CapSet::Inheritable, CapSet::Permitted];
1561+
for cap_set in cap_sets {
1562+
caps::drop(None, cap_set, CAP_NET_ADMIN).expect("drop CAP_NET_ADMIN");
1563+
caps::drop(None, cap_set, CAP_NET_RAW).expect("drop CAP_NET_RAW");
1564+
caps::drop(None, cap_set, CAP_BPF).expect("drop CAP_BPF");
1565+
caps::drop(None, cap_set, CAP_PERFMON).expect("drop CAP_PERFMON");
1566+
}
1567+
}
1568+
15531569
// disable all2all tests if not allowed for a given cluster type
15541570
let alpenglow_socket = if genesis_config.cluster_type == ClusterType::Testnet
15551571
|| genesis_config.cluster_type == ClusterType::Development

dev-bins/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/sbf/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)