|
|
@ -266,10 +266,15 @@ impl FromStr for ProgramSection {
|
|
|
|
|
|
|
|
|
|
|
|
// parse the common case, eg "xdp/program_name" or
|
|
|
|
// parse the common case, eg "xdp/program_name" or
|
|
|
|
// "sk_skb/stream_verdict/program_name"
|
|
|
|
// "sk_skb/stream_verdict/program_name"
|
|
|
|
let (kind, name) = match section.rsplit_once('/') {
|
|
|
|
let mut pieces = section.split('/');
|
|
|
|
None => (section, section),
|
|
|
|
let mut next = || {
|
|
|
|
Some((kind, name)) => (kind, name),
|
|
|
|
pieces
|
|
|
|
|
|
|
|
.next()
|
|
|
|
|
|
|
|
.ok_or_else(|| ParseError::InvalidProgramSection {
|
|
|
|
|
|
|
|
section: section.to_owned(),
|
|
|
|
|
|
|
|
})
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
let kind = next()?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(match kind {
|
|
|
|
Ok(match kind {
|
|
|
|
"kprobe" => KProbe,
|
|
|
|
"kprobe" => KProbe,
|
|
|
@ -281,10 +286,12 @@ impl FromStr for ProgramSection {
|
|
|
|
"xdp" => Xdp { frags: false },
|
|
|
|
"xdp" => Xdp { frags: false },
|
|
|
|
"xdp.frags" => Xdp { frags: true },
|
|
|
|
"xdp.frags" => Xdp { frags: true },
|
|
|
|
"tp_btf" => BtfTracePoint,
|
|
|
|
"tp_btf" => BtfTracePoint,
|
|
|
|
kind if kind.starts_with("tracepoint") || kind.starts_with("tp") => TracePoint,
|
|
|
|
"tracepoint" | "tp" => TracePoint,
|
|
|
|
"socket" => SocketFilter,
|
|
|
|
"socket" => SocketFilter,
|
|
|
|
"sk_msg" => SkMsg,
|
|
|
|
"sk_msg" => SkMsg,
|
|
|
|
"sk_skb" => match name {
|
|
|
|
"sk_skb" => {
|
|
|
|
|
|
|
|
let name = next()?;
|
|
|
|
|
|
|
|
match name {
|
|
|
|
"stream_parser" => SkSkbStreamParser,
|
|
|
|
"stream_parser" => SkSkbStreamParser,
|
|
|
|
"stream_verdict" => SkSkbStreamVerdict,
|
|
|
|
"stream_verdict" => SkSkbStreamVerdict,
|
|
|
|
_ => {
|
|
|
|
_ => {
|
|
|
@ -292,12 +299,13 @@ impl FromStr for ProgramSection {
|
|
|
|
section: section.to_owned(),
|
|
|
|
section: section.to_owned(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
"sk_skb/stream_parser" => SkSkbStreamParser,
|
|
|
|
}
|
|
|
|
"sk_skb/stream_verdict" => SkSkbStreamVerdict,
|
|
|
|
|
|
|
|
"sockops" => SockOps,
|
|
|
|
"sockops" => SockOps,
|
|
|
|
"classifier" => SchedClassifier,
|
|
|
|
"classifier" => SchedClassifier,
|
|
|
|
"cgroup_skb" => match name {
|
|
|
|
"cgroup_skb" => {
|
|
|
|
|
|
|
|
let name = next()?;
|
|
|
|
|
|
|
|
match name {
|
|
|
|
"ingress" => CgroupSkbIngress,
|
|
|
|
"ingress" => CgroupSkbIngress,
|
|
|
|
"egress" => CgroupSkbEgress,
|
|
|
|
"egress" => CgroupSkbEgress,
|
|
|
|
_ => {
|
|
|
|
_ => {
|
|
|
@ -305,104 +313,78 @@ impl FromStr for ProgramSection {
|
|
|
|
section: section.to_owned(),
|
|
|
|
section: section.to_owned(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
"cgroup_skb/ingress" => CgroupSkbIngress,
|
|
|
|
}
|
|
|
|
"cgroup_skb/egress" => CgroupSkbEgress,
|
|
|
|
"cgroup" => {
|
|
|
|
"cgroup/skb" => CgroupSkb,
|
|
|
|
let name = next()?;
|
|
|
|
"cgroup/sock" => CgroupSock {
|
|
|
|
match name {
|
|
|
|
attach_type: CgroupSockAttachType::default(),
|
|
|
|
"skb" => CgroupSkb,
|
|
|
|
},
|
|
|
|
"sysctl" => CgroupSysctl,
|
|
|
|
"cgroup/sysctl" => CgroupSysctl,
|
|
|
|
"dev" => CgroupDevice,
|
|
|
|
"cgroup/dev" => CgroupDevice,
|
|
|
|
"getsockopt" => CgroupSockopt {
|
|
|
|
"cgroup/getsockopt" => CgroupSockopt {
|
|
|
|
|
|
|
|
attach_type: CgroupSockoptAttachType::Get,
|
|
|
|
attach_type: CgroupSockoptAttachType::Get,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/setsockopt" => CgroupSockopt {
|
|
|
|
"setsockopt" => CgroupSockopt {
|
|
|
|
attach_type: CgroupSockoptAttachType::Set,
|
|
|
|
attach_type: CgroupSockoptAttachType::Set,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup" => match name {
|
|
|
|
|
|
|
|
"skb" => CgroupSkb,
|
|
|
|
|
|
|
|
"sysctl" => CgroupSysctl,
|
|
|
|
|
|
|
|
"dev" => CgroupDevice,
|
|
|
|
|
|
|
|
"getsockopt" | "setsockopt" => {
|
|
|
|
|
|
|
|
if let Ok(attach_type) = CgroupSockoptAttachType::try_from(name) {
|
|
|
|
|
|
|
|
CgroupSockopt { attach_type }
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Err(ParseError::InvalidProgramSection {
|
|
|
|
|
|
|
|
section: section.to_owned(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
"sock" => CgroupSock {
|
|
|
|
"sock" => CgroupSock {
|
|
|
|
attach_type: CgroupSockAttachType::default(),
|
|
|
|
attach_type: CgroupSockAttachType::default(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"post_bind4" | "post_bind6" | "sock_create" | "sock_release" => {
|
|
|
|
"post_bind4" => CgroupSock {
|
|
|
|
if let Ok(attach_type) = CgroupSockAttachType::try_from(name) {
|
|
|
|
|
|
|
|
CgroupSock { attach_type }
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Err(ParseError::InvalidProgramSection {
|
|
|
|
|
|
|
|
section: section.to_owned(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
name => {
|
|
|
|
|
|
|
|
if let Ok(attach_type) = CgroupSockAddrAttachType::try_from(name) {
|
|
|
|
|
|
|
|
CgroupSockAddr { attach_type }
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Err(ParseError::InvalidProgramSection {
|
|
|
|
|
|
|
|
section: section.to_owned(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"cgroup/post_bind4" => CgroupSock {
|
|
|
|
|
|
|
|
attach_type: CgroupSockAttachType::PostBind4,
|
|
|
|
attach_type: CgroupSockAttachType::PostBind4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/post_bind6" => CgroupSock {
|
|
|
|
"post_bind6" => CgroupSock {
|
|
|
|
attach_type: CgroupSockAttachType::PostBind6,
|
|
|
|
attach_type: CgroupSockAttachType::PostBind6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/sock_create" => CgroupSock {
|
|
|
|
"sock_create" => CgroupSock {
|
|
|
|
attach_type: CgroupSockAttachType::SockCreate,
|
|
|
|
attach_type: CgroupSockAttachType::SockCreate,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/sock_release" => CgroupSock {
|
|
|
|
"sock_release" => CgroupSock {
|
|
|
|
attach_type: CgroupSockAttachType::SockRelease,
|
|
|
|
attach_type: CgroupSockAttachType::SockRelease,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/bind4" => CgroupSockAddr {
|
|
|
|
"bind4" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::Bind4,
|
|
|
|
attach_type: CgroupSockAddrAttachType::Bind4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/bind6" => CgroupSockAddr {
|
|
|
|
"bind6" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::Bind6,
|
|
|
|
attach_type: CgroupSockAddrAttachType::Bind6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/connect4" => CgroupSockAddr {
|
|
|
|
"connect4" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::Connect4,
|
|
|
|
attach_type: CgroupSockAddrAttachType::Connect4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/connect6" => CgroupSockAddr {
|
|
|
|
"connect6" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::Connect6,
|
|
|
|
attach_type: CgroupSockAddrAttachType::Connect6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/getpeername4" => CgroupSockAddr {
|
|
|
|
"getpeername4" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetPeerName4,
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetPeerName4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/getpeername6" => CgroupSockAddr {
|
|
|
|
"getpeername6" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetPeerName6,
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetPeerName6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/getsockname4" => CgroupSockAddr {
|
|
|
|
"getsockname4" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetSockName4,
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetSockName4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/getsockname6" => CgroupSockAddr {
|
|
|
|
"getsockname6" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetSockName6,
|
|
|
|
attach_type: CgroupSockAddrAttachType::GetSockName6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/sendmsg4" => CgroupSockAddr {
|
|
|
|
"sendmsg4" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPSendMsg4,
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPSendMsg4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/sendmsg6" => CgroupSockAddr {
|
|
|
|
"sendmsg6" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPSendMsg6,
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPSendMsg6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/recvmsg4" => CgroupSockAddr {
|
|
|
|
"recvmsg4" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPRecvMsg4,
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPRecvMsg4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cgroup/recvmsg6" => CgroupSockAddr {
|
|
|
|
"recvmsg6" => CgroupSockAddr {
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPRecvMsg6,
|
|
|
|
attach_type: CgroupSockAddrAttachType::UDPRecvMsg6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
_ => {
|
|
|
|
|
|
|
|
return Err(ParseError::InvalidProgramSection {
|
|
|
|
|
|
|
|
section: section.to_owned(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
"lirc_mode2" => LircMode2,
|
|
|
|
"lirc_mode2" => LircMode2,
|
|
|
|
"perf_event" => PerfEvent,
|
|
|
|
"perf_event" => PerfEvent,
|
|
|
|
"raw_tp" | "raw_tracepoint" => RawTracePoint,
|
|
|
|
"raw_tp" | "raw_tracepoint" => RawTracePoint,
|
|
|
|