MaeBPF.Supervisor (maebpf v0.1.0)

Copy Markdown View Source

Standard OTP Supervisor managing one or more MaeBPF policy workers.

Stopping the supervisor via MaeBPF.detach/1 or MaeBPF.Supervisor.stop/1..2 shuts down every child in reverse startup order so every unpinned kernel bpf_link is automatically detached.

Accepted child entries:

  • Standard OTP child spec maps (%{id: ..., start: ...})
  • {PolicyMod, target: target, ...} or {PolicyMod, targets: [...]}
  • Concise target shorthand: {PolicyMod, {:xdp, "eth0"}}, {PolicyMod, {:cgroup, "/sys/fs/cgroup/app"}}, {PolicyMod, {:systemd, "app.service"}}, {PolicyMod, {:pid, os_pid}}
  • {PolicyMod, target, extra_opts}
  • Any module implementing child_spec/1

Summary

Functions

Returns a specification to start this module under a supervisor.

Normalizes shorthand policy child entries into standard OTP child specs.

Starts a linked MaeBPF.Supervisor supervising children.

Stops a MaeBPF.Supervisor cleanly, tearing down every supervised policy worker and detaching all unpinned kernel links.

Returns true if pid_or_name refers to a live OTP Supervisor process.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

normalize_child(spec)

@spec normalize_child(term()) ::
  Supervisor.child_spec() | {module(), term()} | module()

Normalizes shorthand policy child entries into standard OTP child specs.

start_link(children, opts \\ [])

@spec start_link([term()], keyword()) :: Supervisor.on_start()

Starts a linked MaeBPF.Supervisor supervising children.

Options:

  • :name - optional registered supervisor name
  • :strategy - OTP restart strategy (default :one_for_one)
  • :max_restarts - supervisor restart intensity
  • :max_seconds - supervisor restart period

stop(supervisor, reason \\ :normal, timeout \\ :infinity)

@spec stop(Supervisor.supervisor(), term(), timeout()) :: :ok

Stops a MaeBPF.Supervisor cleanly, tearing down every supervised policy worker and detaching all unpinned kernel links.

supervisor_process?(pid_or_name)

@spec supervisor_process?(GenServer.server()) :: boolean()

Returns true if pid_or_name refers to a live OTP Supervisor process.