cgroup: rename cgroup_modify_nft_set() → unit_modify_nft_set()
This is the only function that cgroup.h exports that is prefixed with cgroup_ where this does not refer to some type such as CGroupContext or CGroupTasksMax or so. It simply operates on a unit. And it doesn't even modify a cgroup, but just modifies an nft set. Hence, to make the naming scheme systematic, change prefix from cgroup_ to unit_, matching the majority of the functions that operate on Unit* in the file.
This commit is contained in:
+8
-5
@@ -1387,19 +1387,20 @@ static void cgroup_apply_firewall(Unit *u) {
|
||||
(void) bpf_firewall_install(u);
|
||||
}
|
||||
|
||||
void cgroup_modify_nft_set(Unit *u, bool add) {
|
||||
void unit_modify_nft_set(Unit *u, bool add) {
|
||||
int r;
|
||||
CGroupContext *c;
|
||||
|
||||
assert(u);
|
||||
|
||||
if (!MANAGER_IS_SYSTEM(u->manager))
|
||||
return;
|
||||
|
||||
if (!UNIT_HAS_CGROUP_CONTEXT(u))
|
||||
return;
|
||||
|
||||
if (cg_all_unified() <= 0)
|
||||
return;
|
||||
|
||||
assert_se(c = unit_get_cgroup_context(u));
|
||||
if (u->cgroup_id == 0)
|
||||
return;
|
||||
|
||||
@@ -1411,6 +1412,8 @@ void cgroup_modify_nft_set(Unit *u, bool add) {
|
||||
assert(u->manager->fw_ctx);
|
||||
}
|
||||
|
||||
CGroupContext *c = ASSERT_PTR(unit_get_cgroup_context(u));
|
||||
|
||||
FOREACH_ARRAY(nft_set, c->nft_set_context.sets, c->nft_set_context.n_sets) {
|
||||
uint64_t element = u->cgroup_id;
|
||||
|
||||
@@ -1864,7 +1867,7 @@ static void cgroup_context_apply(
|
||||
if (apply_mask & CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES)
|
||||
cgroup_apply_restrict_network_interfaces(u);
|
||||
|
||||
cgroup_modify_nft_set(u, /* add = */ true);
|
||||
unit_modify_nft_set(u, /* add = */ true);
|
||||
}
|
||||
|
||||
static bool unit_get_needs_bpf_firewall(Unit *u) {
|
||||
@@ -3042,7 +3045,7 @@ void unit_prune_cgroup(Unit *u) {
|
||||
(void) lsm_bpf_cleanup(u); /* Remove cgroup from the global LSM BPF map */
|
||||
#endif
|
||||
|
||||
cgroup_modify_nft_set(u, /* add = */ false);
|
||||
unit_modify_nft_set(u, /* add = */ false);
|
||||
|
||||
is_root_slice = unit_has_name(u, SPECIAL_ROOT_SLICE);
|
||||
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ static inline bool cgroup_context_want_memory_pressure(const CGroupContext *c) {
|
||||
int cgroup_context_add_device_allow(CGroupContext *c, const char *dev, const char *mode);
|
||||
int cgroup_context_add_bpf_foreign_program(CGroupContext *c, uint32_t attach_type, const char *path);
|
||||
|
||||
void cgroup_modify_nft_set(Unit *u, bool add);
|
||||
void unit_modify_nft_set(Unit *u, bool add);
|
||||
|
||||
CGroupMask unit_get_own_mask(Unit *u);
|
||||
CGroupMask unit_get_delegate_mask(Unit *u);
|
||||
|
||||
+1
-4
@@ -3843,10 +3843,7 @@ int unit_coldplug(Unit *u) {
|
||||
if (u->nop_job)
|
||||
RET_GATHER(r, job_coldplug(u->nop_job));
|
||||
|
||||
CGroupContext *c = unit_get_cgroup_context(u);
|
||||
if (c)
|
||||
cgroup_modify_nft_set(u, /* add = */ true);
|
||||
|
||||
unit_modify_nft_set(u, /* add = */ true);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user