Skip to content

Commit 75f8b96

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

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ bincode = { workspace = true }
6262
bs58 = { workspace = true }
6363
bytemuck = { workspace = true }
6464
bytes = { workspace = true }
65+
caps = { workspace = true }
6566
chrono = { workspace = true, features = ["default", "serde"] }
6667
crossbeam-channel = { workspace = true }
6768
dashmap = { workspace = true, features = ["rayon", "raw-api"] }

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)