HALF ECHO LEARN / REFERENCE COLLECTION
v262.2src/core/dbus-cgroup.c
Git blob: 168bdf10c13da78d4726ca648f42a4ffbd95ad80
Lines 2001–2101 of 2,101
int source, nfproto;
const char *table, *set;
bool empty = true;
r = sd_bus_message_enter_container(message, 'a', "(iiss)");
if (r < 0)
return r;
while ((r = sd_bus_message_read(message, "(iiss)", &source, &nfproto, &table, &set)) > 0) {
const char *source_name, *nfproto_name;
if (!IN_SET(source, NFT_SET_SOURCE_CGROUP, NFT_SET_SOURCE_USER, NFT_SET_SOURCE_GROUP))
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid source %d.", source);
source_name = nft_set_source_to_string(source);
assert(source_name);
nfproto_name = nfproto_to_string(nfproto);
if (!nfproto_name)
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid protocol %d.", nfproto);
if (!nft_identifier_valid(table)) {
_cleanup_free_ char *esc = NULL;
esc = cescape(table);
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid NFT table name %s.", strna(esc));
}
if (!nft_identifier_valid(set)) {
_cleanup_free_ char *esc = NULL;
esc = cescape(set);
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid NFT set name %s.", strna(esc));
}
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
r = nft_set_add(&c->nft_set_context, source, nfproto, table, set);
if (r < 0)
return r;
unit_write_settingf(
u, flags|UNIT_ESCAPE_SPECIFIERS, name,
"%s=%s:%s:%s:%s",
name,
source_name,
nfproto_name,
table,
set);
}
empty = false;
}
if (r < 0)
return r;
r = sd_bus_message_exit_container(message);
if (r < 0)
return r;
if (empty && !UNIT_WRITE_FLAGS_NOOP(flags)) {
nft_set_context_clear(&c->nft_set_context);
unit_write_settingf(u, flags, name, "%s=", name);
}
return 1;
}
if (STR_IN_SET(name,
/* deprecated CGroup v1 properties */
"MemoryLimit",
"MemoryLimitScale",
"CPUShares",
"StartupCPUShares",
"BlockIOAccounting",
"BlockIOWeight",
"StartupBlockIOWeight",
"BlockIODeviceWeight",
"BlockIOReadBandwidth",
"BlockIOWriteBandwidth",
/* see comments in bus_cgroup_vtable */
"CPUAccounting",
"DefaultMemoryMin",
"DefaultMemoryMinScale",
"DefaultMemoryLow",
"DefaultMemoryLowScale",
"DefaultStartupMemoryLow")) {
r = sd_bus_message_skip(message, NULL);
if (r < 0)
return r;
return 1;
}
/* must be last */
if (streq(name, "DisableControllers") || (u->transient && u->load_state == UNIT_STUB))
return bus_cgroup_set_transient_property(u, c, name, message, flags, reterr_error);
return 0;
}