Skip to content

Commit

Permalink
Merge pull request #281 from dave-tucker/export
Browse files Browse the repository at this point in the history
aya: Export program modules
  • Loading branch information
dave-tucker committed May 24, 2022
2 parents c385d18 + 824baf9 commit 7d8365c
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 28 deletions.
1 change: 1 addition & 0 deletions aya/src/programs/cgroup_skb.rs
@@ -1,3 +1,4 @@
//! Cgroup skb programs.
use std::{
hash::Hash,
os::unix::prelude::{AsRawFd, RawFd},
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/cgroup_sock_addr.rs
@@ -1,3 +1,4 @@
//! Cgroup socket address programs.
use thiserror::Error;

use crate::generated::bpf_attach_type;
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/cgroup_sockopt.rs
@@ -1,3 +1,4 @@
//! Cgroup socket option programs.
use thiserror::Error;

use std::{
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/cgroup_sysctl.rs
@@ -1,3 +1,4 @@
//! Cgroup sysctl programs.
use std::{
hash::Hash,
os::unix::prelude::{AsRawFd, RawFd},
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/extension.rs
@@ -1,3 +1,4 @@
//! Extension programs.
use std::os::unix::prelude::{AsRawFd, RawFd};
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion aya/src/programs/fentry.rs
@@ -1,4 +1,4 @@
//! fentry programs.
//! Fentry programs.

use crate::{
generated::{bpf_attach_type::BPF_TRACE_FENTRY, bpf_prog_type::BPF_PROG_TYPE_TRACING},
Expand Down
2 changes: 1 addition & 1 deletion aya/src/programs/fexit.rs
@@ -1,4 +1,4 @@
//! fexit programs.
//! Fexit programs.

use crate::{
generated::{bpf_attach_type::BPF_TRACE_FEXIT, bpf_prog_type::BPF_PROG_TYPE_TRACING},
Expand Down
15 changes: 10 additions & 5 deletions aya/src/programs/links.rs
@@ -1,3 +1,4 @@
//! Program links.
use libc::{close, dup};

use std::{
Expand All @@ -9,7 +10,7 @@ use std::{

use crate::{generated::bpf_attach_type, programs::ProgramError, sys::bpf_prog_detach};

/// A Link
/// A Link.
pub trait Link: std::fmt::Debug + 'static {
/// Unique Id
type Id: std::fmt::Debug + std::hash::Hash + Eq + PartialEq;
Expand Down Expand Up @@ -91,11 +92,13 @@ impl<T: Link> Drop for LinkMap<T> {
}
}

/// The identifier of an `FdLink`.
#[derive(Debug, Hash, Eq, PartialEq)]
pub(crate) struct FdLinkId(pub(crate) RawFd);
pub struct FdLinkId(pub(crate) RawFd);

/// A file descriptor link.
#[derive(Debug)]
pub(crate) struct FdLink {
pub struct FdLink {
pub(crate) fd: RawFd,
}

Expand All @@ -118,11 +121,13 @@ impl Link for FdLink {
}
}

/// The identifier of a `ProgAttachLink`.
#[derive(Debug, Hash, Eq, PartialEq)]
pub(crate) struct ProgAttachLinkId(RawFd, RawFd, bpf_attach_type);
pub struct ProgAttachLinkId(RawFd, RawFd, bpf_attach_type);

/// The Link type used by programs that are attached with `bpf_prog_attach`.
#[derive(Debug)]
pub(crate) struct ProgAttachLink {
pub struct ProgAttachLink {
prog_fd: RawFd,
target_fd: RawFd,
attach_type: bpf_attach_type,
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/lirc_mode2.rs
@@ -1,3 +1,4 @@
//! Lirc programs.
use std::os::unix::prelude::{AsRawFd, RawFd};

use crate::{
Expand Down
42 changes: 21 additions & 21 deletions aya/src/programs/mod.rs
Expand Up @@ -36,31 +36,31 @@
//! [`Bpf::program`]: crate::Bpf::program
//! [`Bpf::program_mut`]: crate::Bpf::program_mut
//! [`maps`]: crate::maps
mod cgroup_skb;
mod cgroup_sock_addr;
mod cgroup_sockopt;
mod cgroup_sysctl;
mod extension;
mod fentry;
mod fexit;
mod kprobe;
mod links;
mod lirc_mode2;
mod lsm;
mod perf_attach;
pub mod cgroup_skb;
pub mod cgroup_sock_addr;
pub mod cgroup_sockopt;
pub mod cgroup_sysctl;
pub mod extension;
pub mod fentry;
pub mod fexit;
pub mod kprobe;
pub mod links;
pub mod lirc_mode2;
pub mod lsm;
pub mod perf_attach;
pub mod perf_event;
mod probe;
mod raw_trace_point;
mod sk_msg;
mod sk_skb;
mod sock_ops;
mod socket_filter;
pub mod raw_trace_point;
pub mod sk_msg;
pub mod sk_skb;
pub mod sock_ops;
pub mod socket_filter;
pub mod tc;
mod tp_btf;
mod trace_point;
mod uprobe;
pub mod tp_btf;
pub mod trace_point;
pub mod uprobe;
mod utils;
mod xdp;
pub mod xdp;

use libc::ENOSPC;
use std::{
Expand Down
3 changes: 3 additions & 0 deletions aya/src/programs/perf_attach.rs
@@ -1,3 +1,4 @@
//! Perf attach links.
use libc::close;
use std::os::unix::io::RawFd;

Expand All @@ -7,9 +8,11 @@ use crate::{
PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE, PERF_EVENT_IOC_SET_BPF,
};

/// The identifer of a PerfLink.
#[derive(Debug, Hash, Eq, PartialEq)]
pub struct PerfLinkId(RawFd);

/// The attachment type of PerfEvent programs.
#[derive(Debug)]
pub struct PerfLink {
perf_fd: RawFd,
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/sk_msg.rs
@@ -1,3 +1,4 @@
//! Skmsg programs.
use crate::{
generated::{bpf_attach_type::BPF_SK_MSG_VERDICT, bpf_prog_type::BPF_PROG_TYPE_SK_MSG},
maps::sock::SocketMap,
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/sk_skb.rs
@@ -1,3 +1,4 @@
//! Skskb programs.
use crate::{
generated::{
bpf_attach_type::{BPF_SK_SKB_STREAM_PARSER, BPF_SK_SKB_STREAM_VERDICT},
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/sock_ops.rs
@@ -1,3 +1,4 @@
//! Socket option programs.
use std::os::unix::io::AsRawFd;

use crate::{
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/socket_filter.rs
@@ -1,3 +1,4 @@
//! Socket filter programs.
use libc::{setsockopt, SOL_SOCKET};
use std::{
io, mem,
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/trace_point.rs
@@ -1,3 +1,4 @@
//! Tracepoint programs.
use std::{fs, io};
use thiserror::Error;

Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/xdp.rs
@@ -1,3 +1,4 @@
//! eXpress Data Path (XDP) programs.
use bitflags;
use libc::if_nametoindex;
use std::{ffi::CString, hash::Hash, io, os::unix::io::RawFd};
Expand Down

0 comments on commit 7d8365c

Please sign in to comment.