-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feature: support create new map and pin it to bpffs as file(BPF_TABLE_PINNED) #3382
Conversation
[buildbot, test this please] |
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
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 {}
.
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
There was a problem hiding this comment.
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)); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
[buildbot, ok to test] |
Hi @yonghong-song I've adjusted it. |
…_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>
resolve #3373
In function
VisitVarDecl
. If bpf_obj_get() returns an invalid fd, markedpinned_id
to -1.In function
create_maps
. Ifpinned_id
less than 0, create a new map, ifpinned_id
is -1 pin map fd to specified file.