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

feature: support create new map and pin it to bpffs as file(BPF_TABLE_PINNED) #3382

Merged
merged 3 commits into from
Apr 30, 2021
Merged

feature: support create new map and pin it to bpffs as file(BPF_TABLE_PINNED) #3382

merged 3 commits into from
Apr 30, 2021

Conversation

chenyuezhou
Copy link
Contributor

@chenyuezhou chenyuezhou commented Apr 27, 2021

resolve #3373

In function VisitVarDecl. If bpf_obj_get() returns an invalid fd, marked pinned_id to -1.

In function create_maps. If pinned_id less than 0, create a new map, if pinned_id is -1 pin map fd to specified file.

@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

Copy link
Collaborator

@yonghong-song yonghong-song left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a few coding style comments. it would be great if you can change that. We also try to have indentation level with 2 char's instead of 4. If you can change that, that will be great!

src/cc/libbpf.c Outdated
dname = strdup(path);
if (dname == NULL) {
return -ENOMEM;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one line after if statement, let us remove {}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

src/cc/libbpf.c Outdated
dir = dirname(dname);
if (mkdir(dir, 0700) && errno != EEXIST) {
err = -errno;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

src/cc/libbpf.c Outdated
free(dname);
if (err) {
fprintf(stderr, "failed to mkdir %s: %s\n", path, strerror(-err));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for the rest code below.

Copy link
Contributor Author

@chenyuezhou chenyuezhou Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed for the rest code below.

@yonghong-song
Copy link
Collaborator

[buildbot, ok to test]

@chenyuezhou
Copy link
Contributor Author

LGTM. Just a few coding style comments. it would be great if you can change that. We also try to have indentation level with 2 char's instead of 4. If you can change that, that will be great!

Hi @yonghong-song I've adjusted it.

@yonghong-song yonghong-song merged commit b209161 into iovisor:master Apr 30, 2021
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
…_PINNED) (iovisor#3382)

Support create a new map and pin it if the pinned file is not available.

Co-authored-by: chenyue.zhou <chenyue.zhou@upai.com>
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.

Is it possible to create a new map and pin it to bpffs as FILE.
2 participants