Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
9a2a38b3
Unverified
Commit
9a2a38b3
authored
Feb 18, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: rework bpf devices BPF_F_REPLACE codepath
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c38e5c4f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
commands.c
src/lxc/commands.c
+21
-12
No files found.
src/lxc/commands.c
View file @
9a2a38b3
...
@@ -1203,6 +1203,8 @@ static int lxc_cmd_add_bpf_device_cgroup_callback(int fd, struct lxc_cmd_req *re
...
@@ -1203,6 +1203,8 @@ static int lxc_cmd_add_bpf_device_cgroup_callback(int fd, struct lxc_cmd_req *re
struct
lxc_conf
*
conf
=
handler
->
conf
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
struct
cgroup_ops
*
cgroup_ops
=
handler
->
cgroup_ops
;
struct
cgroup_ops
*
cgroup_ops
=
handler
->
cgroup_ops
;
struct
hierarchy
*
unified
=
cgroup_ops
->
unified
;
struct
hierarchy
*
unified
=
cgroup_ops
->
unified
;
int
fd_replace
=
-
EBADF
;
__u32
flags
=
0
;
int
ret
;
int
ret
;
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
struct
device_item
*
device
;
struct
device_item
*
device
;
...
@@ -1260,22 +1262,29 @@ static int lxc_cmd_add_bpf_device_cgroup_callback(int fd, struct lxc_cmd_req *re
...
@@ -1260,22 +1262,29 @@ static int lxc_cmd_add_bpf_device_cgroup_callback(int fd, struct lxc_cmd_req *re
if
(
ret
)
if
(
ret
)
goto
respond
;
goto
respond
;
flags
|=
BPF_F_ALLOW_MULTI
;
devices_old
=
cgroup_ops
->
cgroup2_devices
;
devices_old
=
cgroup_ops
->
cgroup2_devices
;
if
(
devices_old
&&
devices_old
->
kernel_fd
>=
0
)
if
(
devices_old
&&
devices_old
->
kernel_fd
>=
0
)
{
ret
=
bpf_program_cgroup_attach
(
devices
,
flags
|=
BPF_F_REPLACE
;
BPF_CGROUP_DEVICE
,
fd_replace
=
devices_old
->
kernel_fd
;
unified
->
cgfd_limit
,
}
devices_old
->
kernel_fd
,
BPF_F_ALLOW_MULTI
|
BPF_F_REPLACE
);
ret
=
bpf_program_cgroup_attach
(
devices
,
BPF_CGROUP_DEVICE
,
else
unified
->
cgfd_limit
,
fd_replace
,
flags
);
ret
=
bpf_program_cgroup_attach
(
devices
,
BPF_CGROUP_DEVICE
,
unified
->
cgfd_limit
,
-
EBADF
,
BPF_F_ALLOW_MULTI
);
if
(
ret
)
if
(
ret
)
goto
respond
;
goto
respond
;
/*
* In case we replaced the current bpf program then we don't
* need to detach anything. We simply need to close the old fd.
*/
if
(
devices_old
&&
(
flags
&
BPF_F_REPLACE
))
{
close_prot_errno_disarm
(
devices_old
->
kernel_fd
);
/* Technically not needed but better safe than segfaulted. */
fd_replace
=
-
EBADF
;
}
/* Replace old bpf program. */
/* Replace old bpf program. */
devices_old
=
move_ptr
(
cgroup_ops
->
cgroup2_devices
);
devices_old
=
move_ptr
(
cgroup_ops
->
cgroup2_devices
);
cgroup_ops
->
cgroup2_devices
=
move_ptr
(
devices
);
cgroup_ops
->
cgroup2_devices
=
move_ptr
(
devices
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment