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
354d21c4
Unverified
Commit
354d21c4
authored
Feb 18, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpf: let bpf_list_add_device() take the device list directly
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
7da502de
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
+8
-7
cgfsng.c
src/lxc/cgroups/cgfsng.c
+1
-1
cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.c
+4
-4
cgroup2_devices.h
src/lxc/cgroups/cgroup2_devices.h
+2
-1
commands.c
src/lxc/commands.c
+1
-1
No files found.
src/lxc/cgroups/cgfsng.c
View file @
354d21c4
...
@@ -3112,7 +3112,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
...
@@ -3112,7 +3112,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
EINVAL
,
"Failed to parse device string %s=%s"
,
key
,
val
);
return
log_error_errno
(
-
1
,
EINVAL
,
"Failed to parse device string %s=%s"
,
key
,
val
);
ret
=
bpf_list_add_device
(
conf
,
&
device_item
);
ret
=
bpf_list_add_device
(
&
conf
->
devices
,
&
device_item
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
...
src/lxc/cgroups/cgroup2_devices.c
View file @
354d21c4
...
@@ -467,16 +467,16 @@ void bpf_device_program_free(struct cgroup_ops *ops)
...
@@ -467,16 +467,16 @@ void bpf_device_program_free(struct cgroup_ops *ops)
}
}
}
}
int
bpf_list_add_device
(
struct
lxc_
conf
*
conf
,
struct
device_item
*
device
)
int
bpf_list_add_device
(
struct
lxc_
list
*
devices
,
struct
device_item
*
device
)
{
{
__do_free
struct
lxc_list
*
list_elem
=
NULL
;
__do_free
struct
lxc_list
*
list_elem
=
NULL
;
__do_free
struct
device_item
*
new_device
=
NULL
;
__do_free
struct
device_item
*
new_device
=
NULL
;
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
if
(
!
conf
||
!
device
)
if
(
!
devices
||
!
device
)
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
lxc_list_for_each
(
it
,
&
conf
->
devices
)
{
lxc_list_for_each
(
it
,
devices
)
{
struct
device_item
*
cur
=
it
->
elem
;
struct
device_item
*
cur
=
it
->
elem
;
if
(
cur
->
global_rule
>
LXC_BPF_DEVICE_CGROUP_LOCAL_RULE
&&
if
(
cur
->
global_rule
>
LXC_BPF_DEVICE_CGROUP_LOCAL_RULE
&&
...
@@ -527,7 +527,7 @@ int bpf_list_add_device(struct lxc_conf *conf, struct device_item *device)
...
@@ -527,7 +527,7 @@ int bpf_list_add_device(struct lxc_conf *conf, struct device_item *device)
return
log_error_errno
(
-
1
,
ENOMEM
,
"Failed to allocate new device item"
);
return
log_error_errno
(
-
1
,
ENOMEM
,
"Failed to allocate new device item"
);
lxc_list_add_elem
(
list_elem
,
move_ptr
(
new_device
));
lxc_list_add_elem
(
list_elem
,
move_ptr
(
new_device
));
lxc_list_add_tail
(
&
conf
->
devices
,
move_ptr
(
list_elem
));
lxc_list_add_tail
(
devices
,
move_ptr
(
list_elem
));
return
0
;
return
0
;
}
}
...
...
src/lxc/cgroups/cgroup2_devices.h
View file @
354d21c4
...
@@ -96,7 +96,8 @@ __hidden extern void bpf_program_free(struct bpf_program *prog);
...
@@ -96,7 +96,8 @@ __hidden extern void bpf_program_free(struct bpf_program *prog);
__hidden
extern
void
bpf_device_program_free
(
struct
cgroup_ops
*
ops
);
__hidden
extern
void
bpf_device_program_free
(
struct
cgroup_ops
*
ops
);
__hidden
extern
bool
bpf_devices_cgroup_supported
(
void
);
__hidden
extern
bool
bpf_devices_cgroup_supported
(
void
);
__hidden
extern
int
bpf_list_add_device
(
struct
lxc_conf
*
conf
,
struct
device_item
*
device
);
__hidden
extern
int
bpf_list_add_device
(
struct
lxc_list
*
devices
,
struct
device_item
*
device
);
__hidden
extern
bool
bpf_cgroup_devices_attach
(
struct
cgroup_ops
*
ops
,
__hidden
extern
bool
bpf_cgroup_devices_attach
(
struct
cgroup_ops
*
ops
,
struct
lxc_list
*
devices
);
struct
lxc_list
*
devices
);
...
...
src/lxc/commands.c
View file @
354d21c4
...
@@ -1222,7 +1222,7 @@ static int lxc_cmd_add_bpf_device_cgroup_callback(int fd, struct lxc_cmd_req *re
...
@@ -1222,7 +1222,7 @@ static int lxc_cmd_add_bpf_device_cgroup_callback(int fd, struct lxc_cmd_req *re
if
(
unified
->
cgfd_mon
<
0
)
if
(
unified
->
cgfd_mon
<
0
)
goto
respond
;
goto
respond
;
ret
=
bpf_list_add_device
(
conf
,
device
);
ret
=
bpf_list_add_device
(
&
conf
->
devices
,
device
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
respond
;
goto
respond
;
...
...
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