]> git.proxmox.com Git - mirror_lxc.git/commitdiff
bpf: let bpf_list_add_device() take the device list directly
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 18 Feb 2021 12:35:03 +0000 (13:35 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 18 Feb 2021 12:35:03 +0000 (13:35 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.h
src/lxc/commands.c

index 64276cde80ed15f5a9263f5b635d7fe18ff2f173..c8441e7e63194cba4b5dad8dc3a3b19f6eeb24bc 100644 (file)
@@ -3112,7 +3112,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
        if (ret < 0)
                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)
                return -1;
        return 0;
index a1c9bc98b2d6d6be938bc41bf1549e33e61da0d4..57dbfbf8eb18f8ac61bf217d3d6d5e59c9130bde 100644 (file)
@@ -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 device_item *new_device = NULL;
        struct lxc_list *it;
 
-       if (!conf || !device)
+       if (!devices || !device)
                return ret_errno(EINVAL);
 
-       lxc_list_for_each(it, &conf->devices) {
+       lxc_list_for_each(it, devices) {
                struct device_item *cur = it->elem;
 
                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)
                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_tail(&conf->devices, move_ptr(list_elem));
+       lxc_list_add_tail(devices, move_ptr(list_elem));
 
        return 0;
 }
index 89388934ddba5755c7925660bd49a8a2a4ccdc76..3def6359756f55352da8e02bf45da48a821bdc29 100644 (file)
@@ -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 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,
                                               struct lxc_list *devices);
 
index 6a64b061fe705370ca34dbe18b4388ee227605e7..32144b51191b34627ad0d23dcfff0b004c540863 100644 (file)
@@ -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)
                goto respond;
 
-       ret = bpf_list_add_device(conf, device);
+       ret = bpf_list_add_device(&conf->devices, device);
        if (ret < 0)
                goto respond;