-
Notifications
You must be signed in to change notification settings - Fork 333
Open
Description
Working on #6, looking at #10, #9 and #8. I see that we have a lack of high-level stack of bpf instructions.
Personally, I see it as the following:
struct InsnStack {
head: RefToInsn // points on the first instruction that will be executed
tail: RefToInsn // points on `exit` instuction, unless it is an invalid bpf program
}
impl InsnStack {
pub fn create() -> Self {
//...
}
pub fn disassemble() -> String {
//...
}
//may be a bunch of functions from #6 ... I am ok if we remove `insn_builder` module
pub fn patch(patch: MbuffStructure) {
//...
}
pub fn validate() -> Result<ValidInsnStack, ValidationError> { // <- the same as InsnStack but `tail` always points to `exit` Insn :smile:
//...
}
}
pub fn parse_assemble(raw_bpf_asm: String) -> InsnStack {
//...
}RefToInsn can be any type of reference, however, we could not use Box here.
Having that structure we can provide API to easily manipulate its content.
@qmonnet, thoughts?
PS1: again as in #12 we need to do some prototype here.
PS2: I also don't like that we have the bunch of different structures that in some or other way represent bpf instruction, but I don't see the solution to this problem right now.
Metadata
Metadata
Assignees
Labels
No labels