generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Daemon part of FD tracking
- Loading branch information
Showing
15 changed files
with
379 additions
and
14 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
frontend/app/src/main/java/de/amosproj3/ziofa/ui/configuration/utils/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// SPDX-FileCopyrightText: 2025 Robin Seidl <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package de.amosproj3.ziofa.ui.configuration.utils | ||
|
||
import de.amosproj3.ziofa.client.Configuration | ||
|
||
val EMPTY_CONFIGURATION = Configuration(null, null, listOf(), null, null, null) | ||
val EMPTY_CONFIGURATION = Configuration(null, null, listOf(), null, null, null, null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]> | ||
// SPDX-FileCopyrightText: 2025 Robin Seidl <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
|
@@ -14,6 +14,7 @@ data class Configuration( | |
val jniReferences: JniReferencesConfig?, | ||
val sysSigquit: SysSigquitConfig?, | ||
val gc: GcConfig?, | ||
val sysFdTracking: SysFdTrackingConfig?, | ||
) | ||
|
||
data class VfsWriteConfig(val entries: Map<UInt, ULong>) | ||
|
@@ -28,6 +29,8 @@ data class SysSigquitConfig(val pids: List<UInt>) | |
|
||
data object GcConfig | ||
|
||
data class SysFdTrackingConfig(val pids: List<UInt>) | ||
|
||
sealed class Event { | ||
data class VfsWrite( | ||
val pid: UInt, | ||
|
@@ -80,6 +83,18 @@ sealed class Event { | |
var freedLosBytes: Long, | ||
var pauseTimes: List<ULong>, | ||
) : Event() | ||
|
||
data class SysFdTracking( | ||
val pid: UInt, | ||
val tid: UInt, | ||
val timeStamp: ULong, | ||
val fdAction: SysFdAction?, | ||
) : Event() { | ||
enum class SysFdAction { | ||
Created, | ||
Destroyed, | ||
} | ||
} | ||
} | ||
|
||
data class Process(val pid: UInt, val ppid: UInt, val state: String, val cmd: Command?) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]> | ||
// SPDX-FileCopyrightText: 2025 Robin Seidl <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
|
@@ -23,6 +23,7 @@ object RustClient : Client { | |
jniReferences = JniReferencesConfig(pids = listOf()), | ||
sysSigquit = SysSigquitConfig(pids = listOf()), | ||
gc = GcConfig, | ||
sysFdTracking = SysFdTrackingConfig(pids = listOf()), | ||
) | ||
|
||
override suspend fun serverCount(): Flow<UInt> = flow { | ||
|
@@ -143,6 +144,16 @@ object RustClient : Client { | |
) | ||
) | ||
} | ||
configuration.sysFdTracking?.pids?.forEach { | ||
emit( | ||
Event.SysFdTracking( | ||
pid = it, | ||
tid = 1234u, | ||
timeStamp = 12312412u, | ||
fdAction = Event.SysFdTracking.SysFdAction.Created, | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]> | ||
// SPDX-FileCopyrightText: 2025 Robin Seidl <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
|
@@ -12,9 +12,11 @@ import kotlinx.coroutines.flow.mapNotNull | |
import kotlinx.coroutines.sync.Mutex | ||
import kotlinx.coroutines.sync.withLock | ||
import uniffi.client.jniMethodNameFromI32 | ||
import uniffi.client.sysFdActionFromI32 | ||
import uniffi.shared.Cmd | ||
import uniffi.shared.EventData | ||
import uniffi.shared.JniMethodName | ||
import uniffi.shared.SysFdAction | ||
|
||
private fun uniffi.shared.Process.into() = | ||
Process( | ||
|
@@ -86,6 +88,18 @@ private fun uniffi.shared.Event.into() = | |
freedLosBytes = d.v1.freedLosBytes, | ||
pauseTimes = d.v1.pauseTimes, | ||
) | ||
is EventData.SysFdTracking -> | ||
Event.SysFdTracking( | ||
pid = d.v1.pid, | ||
tid = d.v1.tid, | ||
timeStamp = d.v1.timeStamp, | ||
fdAction = | ||
when (sysFdActionFromI32(d.v1.fdAction)) { | ||
SysFdAction.CREATED -> Event.SysFdTracking.SysFdAction.Created | ||
SysFdAction.DESTROYED -> Event.SysFdTracking.SysFdAction.Destroyed | ||
SysFdAction.UNDEFINED -> null | ||
}, | ||
) | ||
null -> null | ||
} | ||
|
||
|
@@ -105,6 +119,7 @@ private fun uniffi.shared.Configuration.into() = | |
jniReferences = jniReferences?.let { JniReferencesConfig(pids = it.pids) }, | ||
sysSigquit = sysSigquit?.let { SysSigquitConfig(pids = it.pids) }, | ||
gc = gc?.let { GcConfig }, | ||
sysFdTracking = sysFdTracking?.let { SysFdTrackingConfig(pids = it.pids) }, | ||
) | ||
|
||
private fun Configuration.into() = | ||
|
@@ -123,6 +138,7 @@ private fun Configuration.into() = | |
jniReferences = jniReferences?.let { uniffi.shared.JniReferencesConfig(it.pids) }, | ||
sysSigquit = sysSigquit?.let { uniffi.shared.SysSigquitConfig(it.pids) }, | ||
gc = gc?.let { uniffi.shared.GcConfig() }, | ||
sysFdTracking = sysFdTracking?.let { uniffi.shared.SysFdTrackingConfig(it.pids) }, | ||
) | ||
|
||
private fun uniffi.shared.StringResponse.into() = StringResponse(name) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]> | ||
// SPDX-FileCopyrightText: 2025 Tom Weisshuhn <[email protected]> | ||
// SPDX-FileCopyrightText: 2025 Felix Hilgers <felix.hilgers@fau.de> | ||
// SPDX-FileCopyrightText: 2025 Robin Seidl <robin.seidl@fau.de> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
|
@@ -46,6 +46,12 @@ impl TryFromRaw for SysGcCall { | |
} | ||
} | ||
|
||
impl TryFromRaw for SysFdActionCall { | ||
fn try_from_raw(raw: &[u8]) -> Result<Self, CheckedCastError> { | ||
Ok(*bytemuck::checked::try_from_bytes(raw)?) | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone, AnyBitPattern)] | ||
pub struct VfsWriteCall { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
|
@@ -23,6 +24,7 @@ enum CollectorT { | |
JniCall, | ||
SysSigquit, | ||
Gc, | ||
SysFdTracking, | ||
} | ||
|
||
pub struct CollectorSupervisor; | ||
|
@@ -50,7 +52,7 @@ impl CollectorRefs { | |
self.collectors.remove(cell) | ||
} | ||
async fn start_all(&mut self, registry: &EbpfEventRegistry, event_actor: &ActorRef<Event>, supervisor: &ActorCell) -> Result<(), ActorProcessingErr> { | ||
for who in [CollectorT::VfsWrite, CollectorT::SysSendmsg, CollectorT::JniCall, CollectorT::SysSigquit, CollectorT::Gc] { | ||
for who in [CollectorT::VfsWrite, CollectorT::SysSendmsg, CollectorT::JniCall, CollectorT::SysSigquit, CollectorT::Gc, CollectorT::SysFdTracking] { | ||
self.start(who, registry, event_actor, supervisor).await?; | ||
} | ||
Ok(()) | ||
|
@@ -62,6 +64,7 @@ impl CollectorRefs { | |
CollectorT::JniCall => start_collector(registry.jni_ref_calls.clone(), event_actor.clone(), supervisor.clone()).await?, | ||
CollectorT::SysSigquit => start_collector(registry.sys_sigquit_events.clone(), event_actor.clone(), supervisor.clone()).await?, | ||
CollectorT::Gc => start_collector(registry.gc_events.clone(), event_actor.clone(), supervisor.clone()).await?, | ||
CollectorT::SysFdTracking => start_collector(registry.sys_fd_tracking_events.clone(), event_actor.clone(), supervisor.clone()).await?, | ||
}; | ||
self.collectors.insert(actor_ref.get_cell(), who); | ||
Ok(()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.