Skip to content

Instruction stack data structure #14

@alex-dukhno

Description

@alex-dukhno

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions