oxidecomputer / oxidecomputer/opte

Want abstraction over USDT/SDT split in probes

Open
#389 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cleanup
Dominant language
Rust
Stars
77
Forks
11
Avg merge
9d 20h
Merged PRs (30d)
8

Description

Many of the DTrace probes we have in OPTE are structured such that they automatically switch between USDT and SDT probes depending on whether the crate is compiled for userland (cargo test) or as part of the kernel module (xde):

impl Port {
    fn xyz_probe(&self, dir: Direction, pkt: &Packet<Parsed>, msg: String) {
        cfg_if::cfg_if! {
            if #[cfg(all(not(feature = "std"), not(test)))] {
                /* SDT-specific arg conversion: String->CString, ... */
                unsafe {
                    __dtrace_probe_xyz(
                        /* ... pointers to args ... */
                    );
                }
            } else if #[cfg(feature = "usdt")] {
                /* USDT-specific arg conversion */
                crate::opte_provider::xyz!(
                    || (/* ... Rust-friendly args (references, owned types) ... */)
                );
            } else {
                /* feature-flag-driven no-op */
                let (..) = (dir, pkt, msg);
            }
        }
    }
}

Many of the Port::*_probe methods have a structure more or less in line with this, which leads to a lot of duplication and noise. We should define a macro or similar abstraction to simplify the implementation of {current, future} DTrace probes we choose to insert.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by surveying the Port::*_probe methods and their repeated cfg_if! branches for SDT, USDT, and no-op behavior. Compare the argument-conversion paths and determine the intended macro or abstraction boundary. Done means current and future DTrace probes can use the shared abstraction without duplicating the conditional probe setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.