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

Add ability to export maps, enables cross-program sharing #309

Merged
merged 2 commits into from
Jan 8, 2016
Merged

Conversation

drzaeus77
Copy link
Collaborator

Allow a program to export a map for other programs to use. This enables
cross-program map sharing.

parent program syntax:
BPF_TABLE("array", int, int, shared, 10);
BPF_TABLE_EXPORT(shared);

child program syntax:
BPF_TABLE("extern", int, int, shared, 10);

Signed-off-by: Brenden Blanco [email protected]

Allow a program to export a map for other programs to use. This enables
cross-program map sharing.

parent program syntax:
BPF_TABLE("array", int, int, shared, 10);
BPF_TABLE_EXPORT(shared);

child program syntax:
BPF_TABLE("extern", int, int, shared, 10);

Signed-off-by: Brenden Blanco <[email protected]>
@4ast
Copy link
Member

4ast commented Jan 8, 2016

both programs need to be loaded by the same python/go master script, right?
syntax is a bit verbose... can export and definition be done with one macro?

@drzaeus77
Copy link
Collaborator Author

Same process, different BpfModule instance, correct. I had a different iteration which used bpf_pin_obj to share the maps, but that wasn't necessary for my use case and I didn't want to depend on 4.4 kernel just yet.

Right now the example is this:

BPF_TABLE("array", int, struct metadata, metadata, 8);
BPF_TABLE_EXPORT(metadata);

As a shorter syntax, how about:

BPF_TABLE_PUBLIC("array", int, struct metadata, metadata, 8);

Which is better, or can you think of a 3rd option?

@4ast
Copy link
Member

4ast commented Jan 8, 2016

BPF_TABLE_EXPORT("array", int, struct metadata, metadata, 8);
or
BPF_TABLE_PUBLIC("array", int, struct metadata, metadata, 8);
look fine.
Just BPF_TABLE + BPF_TABLE_EXPORT seems too verbose.

@drzaeus77
Copy link
Collaborator Author

@4ast please +1/-1

@4ast
Copy link
Member

4ast commented Jan 8, 2016

didn't get an email that pullreq got updated...
looks good. thanks for adding the test.

4ast added a commit that referenced this pull request Jan 8, 2016
Add ability to export maps, enables cross-program sharing
@4ast 4ast merged commit 1ec515e into master Jan 8, 2016
@drzaeus77 drzaeus77 deleted the sharedmaps branch January 8, 2016 19:31
@zaheersm
Copy link

Any thoughts on how a table can be shared by two separate python master scripts?
BTW sorry for intruding. Thanks.

@drzaeus77
Copy link
Collaborator Author

Yes, we would use the BPF_OBJ_PIN and BPF_OBJ_GET features from the kernel to retrieve maps and programs that are persisted using the bpffs support that was added in kernel 4.4. I considered using that feature to implement this PR, but decided against it. Supporting fd pinning does require a bit of thought, since adding the feature will involve a system resource that needs to be properly cared for, otherwise resource leaks may occur.

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

Successfully merging this pull request may close these issues.

None yet

3 participants