@ -267,8 +267,8 @@ 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 ( kind , name ) = match section . rsplit_once ( '/' ) {
None = > ( section , section ) ,
None = > ( section , None ) ,
Some ( ( kind , name ) ) = > ( kind , name ) ,
Some ( ( kind , name ) ) = > ( kind , Some ( name ) ) ,
} ;
} ;
Ok ( match kind {
Ok ( match kind {
@ -285,8 +285,8 @@ impl FromStr for ProgramSection {
"socket" = > SocketFilter ,
"socket" = > SocketFilter ,
"sk_msg" = > SkMsg ,
"sk_msg" = > SkMsg ,
"sk_skb" = > match name {
"sk_skb" = > match name {
"stream_parser" = > SkSkbStreamParser ,
Some ( "stream_parser" ) = > SkSkbStreamParser ,
"stream_verdict" = > SkSkbStreamVerdict ,
Some ( "stream_verdict" ) = > SkSkbStreamVerdict ,
_ = > {
_ = > {
return Err ( ParseError ::InvalidProgramSection {
return Err ( ParseError ::InvalidProgramSection {
section : section . to_owned ( ) ,
section : section . to_owned ( ) ,
@ -298,8 +298,8 @@ impl FromStr for ProgramSection {
"sockops" = > SockOps ,
"sockops" = > SockOps ,
"classifier" = > SchedClassifier ,
"classifier" = > SchedClassifier ,
"cgroup_skb" = > match name {
"cgroup_skb" = > match name {
"ingress" = > CgroupSkbIngress ,
Some ( "ingress" ) = > CgroupSkbIngress ,
"egress" = > CgroupSkbEgress ,
Some ( "egress" ) = > CgroupSkbEgress ,
_ = > {
_ = > {
return Err ( ParseError ::InvalidProgramSection {
return Err ( ParseError ::InvalidProgramSection {
section : section . to_owned ( ) ,
section : section . to_owned ( ) ,
@ -321,39 +321,71 @@ impl FromStr for ProgramSection {
attach_type : CgroupSockoptAttachType ::Set ,
attach_type : CgroupSockoptAttachType ::Set ,
} ,
} ,
"cgroup" = > match name {
"cgroup" = > match name {
"skb" = > CgroupSkb ,
Some ( "skb" ) = > CgroupSkb ,
"sysctl" = > CgroupSysctl ,
Some ( "sysctl" ) = > CgroupSysctl ,
"dev" = > CgroupDevice ,
Some ( "dev" ) = > CgroupDevice ,
"getsockopt" | "setsockopt" = > {
Some ( "getsockopt" ) = > CgroupSockopt {
if let Ok ( attach_type ) = CgroupSockoptAttachType ::try_from ( name ) {
attach_type : CgroupSockoptAttachType ::Get ,
CgroupSockopt { attach_type }
} ,
} else {
Some ( "setsockopt" ) = > CgroupSockopt {
return Err ( ParseError ::InvalidProgramSection {
attach_type : CgroupSockoptAttachType ::Set ,
section : section . to_owned ( ) ,
} ,
} ) ;
Some ( "sock" ) = > CgroupSock {
}
}
"sock" = > CgroupSock {
attach_type : CgroupSockAttachType ::default ( ) ,
attach_type : CgroupSockAttachType ::default ( ) ,
} ,
} ,
"post_bind4" | "post_bind6" | "sock_create" | "sock_release" = > {
Some ( "post_bind4" ) = > CgroupSock {
if let Ok ( attach_type ) = CgroupSockAttachType ::try_from ( name ) {
attach_type : CgroupSockAttachType ::PostBind4 ,
CgroupSock { attach_type }
} ,
} else {
Some ( "post_bind6" ) = > CgroupSock {
return Err ( ParseError ::InvalidProgramSection {
attach_type : CgroupSockAttachType ::PostBind6 ,
section : section . to_owned ( ) ,
} ,
} ) ;
Some ( "sock_create" ) = > CgroupSock {
}
attach_type : CgroupSockAttachType ::SockCreate ,
}
} ,
name = > {
Some ( "sock_release" ) = > CgroupSock {
if let Ok ( attach_type ) = CgroupSockAddrAttachType ::try_from ( name ) {
attach_type : CgroupSockAttachType ::SockRelease ,
CgroupSockAddr { attach_type }
} ,
} else {
Some ( "bind4" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::Bind4 ,
} ,
Some ( "bind6" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::Bind6 ,
} ,
Some ( "connect4" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::Connect4 ,
} ,
Some ( "connect6" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::Connect6 ,
} ,
Some ( "getpeername4" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::GetPeerName4 ,
} ,
Some ( "getpeername6" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::GetPeerName6 ,
} ,
Some ( "getsockname4" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::GetSockName4 ,
} ,
Some ( "getsockname6" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::GetSockName6 ,
} ,
Some ( "sendmsg4" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::UDPSendMsg4 ,
} ,
Some ( "sendmsg6" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::UDPSendMsg6 ,
} ,
Some ( "recvmsg4" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::UDPRecvMsg4 ,
} ,
Some ( "recvmsg6" ) = > CgroupSockAddr {
attach_type : CgroupSockAddrAttachType ::UDPRecvMsg6 ,
} ,
_ = > {
return Err ( ParseError ::InvalidProgramSection {
return Err ( ParseError ::InvalidProgramSection {
section : section . to_owned ( ) ,
section : section . to_owned ( ) ,
} ) ;
} ) ;
}
}
}
} ,
} ,
"cgroup/post_bind4" = > CgroupSock {
"cgroup/post_bind4" = > CgroupSock {
attach_type : CgroupSockAttachType ::PostBind4 ,
attach_type : CgroupSockAttachType ::PostBind4 ,