Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BPF implementation does not support BPF to BPF function calls #2086

Closed
6 tasks done
jackcmay opened this issue Dec 10, 2018 · 4 comments
Closed
6 tasks done

BPF implementation does not support BPF to BPF function calls #2086

jackcmay opened this issue Dec 10, 2018 · 4 comments
Assignees

Comments

@jackcmay
Copy link
Contributor

jackcmay commented Dec 10, 2018

Problem

In order to support multi-file BPF programs and linking in/with libraries, our BPF implementation must support BPF to BPF calls.

Proposed Solution

  • BPF to BPF function calls
    • Add BPF symbol resolutions (intra ELF)
    • Handle BPF subroutine return
    • Support BPF subroutine stack frames

Depends on

@jackcmay
Copy link
Contributor Author

jackcmay commented Dec 13, 2018

The linker is not resolving symbols between ELFs. There are two approaches:

  1. Add support to the linker (right solution but will take some time)
  2. Modify rbpf to do the resolutions at run-time

Moving forward on #2 since should be able to get that working quickly

@mvines
Copy link
Member

mvines commented Dec 13, 2018

I support the right solution that takes longer, (1). It would be nice to get this into v0.11 but not at the expense of short-term work that we would immediately need to undo and redo.

@jackcmay
Copy link
Contributor Author

Turns out this is more complicated than it originally presented. The right solution is a combination of both.

@jackcmay jackcmay changed the title BPF C build system does not support multiple source files for single program BPF implementation does not support BPF to BPF function calls Dec 14, 2018
@jackcmay
Copy link
Contributor Author

One pain point of the proposed work is that BPF does not interact with the stack in a typical way. Typically a stack pointer is managed that moves as things a pushed and popped from the stack. For example, when functions are called, zero or more of their parameters maybe be pushed and the return address is pushed. BPF programs don't manage a head pointer, instead, a function's stack is a fixed size buffer essentially used as a scratch buffer. BPF does not pass parameters via the stack (only registers) This comes historically from the fact that all BPF programs are a single function. This means that each BPF function has its own "stack" frame. Linux recently added support for BPF to BPF calls and they do this by providing a 512 byte stack frame for each function called with a maximum depth of 8 function calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants