Compare commits

...

19 Commits

Author SHA1 Message Date
Anita Zhang 4047a411f4
Merge pull request #15186 from DaanDeMeyer/clangd-fix-wstring-plus-int
Silence Wstring-plus-int warning when using clangd with GCC.
2020-03-26 16:45:01 -07:00
Anita Zhang c08323dcd1
Merge pull request #15236 from ssahani/br-follow-up
shared- bride util allign bridge_state_table
2020-03-26 16:27:33 -07:00
Susant Sahani 4c6a4a5bfe shared- bride util allign bridge_state_table 2020-03-26 19:43:58 +01:00
Yuri Chornoivan 6281c6e56c
po: update Ukrainian translation (#15228) 2020-03-26 18:45:41 +01:00
Zbigniew Jędrzejewski-Szmek 1ab2033804
Merge pull request #15224 from ssahani/geneve
networkctl: Display more geneve properties
2020-03-26 18:30:37 +01:00
David Edmundson f0d0698f0b path-lookup: Use default value for XDG_CONFIG_DIRS if environment is not set
If XDG_CONFIG_DIRS is unset, the specification says we should assume
/etc/xdg.
2020-03-26 18:25:41 +01:00
Zbigniew Jędrzejewski-Szmek a879b6d22f
Merge pull request #15214 from ssahani/networkctl-br1
network: Introduce bridge util
2020-03-26 17:51:29 +01:00
Zbigniew Jędrzejewski-Szmek 272a8864da
Merge pull request #15170 from keszybz/sd-bus-resolve-magic
sd-bus: resolve SD_BUS_DEFAULT_* in more places
2020-03-26 17:08:09 +01:00
Zbigniew Jędrzejewski-Szmek ce4c73eb5d
Merge pull request #15209 from anitazha/moar-cgroup-utils
cgroup-utils: convenience helpers
2020-03-26 16:54:08 +01:00
Susant Sahani e7b38d7d5c networkctl: Display more geneve preperties 2020-03-25 14:52:52 +01:00
Susant Sahani 3039cc0281 network: Introduce geneve util 2020-03-25 14:52:31 +01:00
Anita Zhang baa358df32 cgroup-util: cg_get_xattr_malloc helper
`cg_get_xattr_malloc` to read a cgroup xattr value and allocate space
to hold said value (simple helper combining existing functions).
2020-03-24 16:06:32 -07:00
Anita Zhang 613328c3e2 cgroup-util: helper to cg_get_attribute and convert to uint64_t
A common pattern in the codebase is reading a cgroup memory value
and converting it to a uint64_t. Let's make it a helper and refactor a
few places to use it so it's more concise.
2020-03-24 16:05:16 -07:00
Susant Sahani a8389a3307 networkctl: Use string table for bridge state 2020-03-24 14:22:59 +01:00
Susant Sahani af94bb24b5 shared: Introduce bridge util 2020-03-24 14:22:50 +01:00
Daan De Meyer f455f8633e Silence Wstring-plus-int warning when using clangd with GCC. 2020-03-21 22:30:59 +01:00
Zbigniew Jędrzejewski-Szmek f41df6954c sd-bus: whitespace adjustments 2020-03-19 21:38:46 +01:00
Zbigniew Jędrzejewski-Szmek 70bc558cc1 sd-bus: support SD_BUS_DEFAULT* and don't crash in functions where bus is optional
In those functions where bus defaults to the m->bus, we should also
resolve the magic parameters. And if neither called with bus=NULL
and an unattached message, return properly instead of crashing in assert
later.
2020-03-19 21:38:46 +01:00
Zbigniew Jędrzejewski-Szmek 501ecd670c sd-bus: make sure SD_BUS_DEFAULT* works everywhere
I'm not sure why those functions were not touched in
45b1f410ba. Anyway, it seems easier
to just support the magic parameters everywhere.
2020-03-19 21:38:46 +01:00
16 changed files with 272 additions and 141 deletions

View File

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: systemd master\n"
"Report-Msgid-Bugs-To: https://github.com/systemd/systemd/issues\n"
"POT-Creation-Date: 2020-01-30 15:31+0000\n"
"PO-Revision-Date: 2020-02-07 12:37+0200\n"
"POT-Creation-Date: 2020-03-22 04:04+0000\n"
"PO-Revision-Date: 2020-03-25 18:40+0200\n"
"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
"Language-Team: Ukrainian <kde-i18n-uk@kde.org>\n"
"Language: uk\n"
@ -94,8 +94,8 @@ msgstr "Перевірка реєстраційних даних для дост
msgid ""
"Authentication is required to check credentials against a user's home area."
msgstr ""
"Для перевірки реєстраційних даних для доступу до домашньої теки користувача"
" слід пройти розпізнавання."
"Для перевірки реєстраційних даних для доступу до домашньої теки користувача "
"слід пройти розпізнавання."
#: src/home/org.freedesktop.home1.policy:43
msgid "Update a home area"
@ -119,10 +119,11 @@ msgid "Change password of a home area"
msgstr "Зміна пароля до домашньої теки"
#: src/home/org.freedesktop.home1.policy:64
msgid "Authentication is required to change the password of a user's home area."
msgid ""
"Authentication is required to change the password of a user's home area."
msgstr ""
"Для зміни пароля для доступу до домашньої теки користувача слід пройти"
" розпізнавання."
"Для зміни пароля для доступу до домашньої теки користувача слід пройти "
"розпізнавання."
#: src/hostname/org.freedesktop.hostname1.policy:20
msgid "Set host name"
@ -345,8 +346,7 @@ msgid "Flush device to seat attachments"
msgstr "Очисний пристрій для під'єднань до місця"
#: src/login/org.freedesktop.login1.policy:149
msgid ""
"Authentication is required to reset how devices are attached to seats."
msgid "Authentication is required to reset how devices are attached to seats."
msgstr ""
"Потрібна автентифікація, щоб перезапустити спосіб під'єднання до місць."
@ -375,8 +375,8 @@ msgstr "Вимкнути систему, коли програми намага
#: src/login/org.freedesktop.login1.policy:181
msgid ""
"Authentication is required to power off the system while an application "
"is inhibiting this."
"Authentication is required to power off the system while an application is "
"inhibiting this."
msgstr ""
"Потрібна автентифікація, щоб вимкнути систему, коли програми намагаються "
"перешкодити цьому."
@ -395,8 +395,8 @@ msgstr "Перезавантажити, якщо інші користувачі
#: src/login/org.freedesktop.login1.policy:203
msgid ""
"Authentication is required to reboot the system while other users are "
"logged in."
"Authentication is required to reboot the system while other users are logged "
"in."
msgstr ""
"Потрібна автентифікація, щоб перезапустити систему, коли інші користувачі в "
"ній."
@ -407,8 +407,8 @@ msgstr "Перезапустити систему, коли програми н
#: src/login/org.freedesktop.login1.policy:214
msgid ""
"Authentication is required to reboot the system while an application "
"is inhibiting this."
"Authentication is required to reboot the system while an application is "
"inhibiting this."
msgstr ""
"Потрібна автентифікація, щоб перезапустити систему, коли програми "
"намагаються перешкодити цьому."
@ -427,8 +427,8 @@ msgstr "Зупинити систему, коли інші користувач
#: src/login/org.freedesktop.login1.policy:236
msgid ""
"Authentication is required to halt the system while other users are "
"logged in."
"Authentication is required to halt the system while other users are logged "
"in."
msgstr ""
"Потрібна автентифікація, щоб зупинити систему, коли інші користувачі в ній."
@ -438,10 +438,11 @@ msgstr "Зупинити систему, коли програми намага
#: src/login/org.freedesktop.login1.policy:247
msgid ""
"Authentication is required to halt the system while an application asked "
"to inhibit it."
"Authentication is required to halt the system while an application is "
"inhibiting this."
msgstr ""
"Потрібна автентифікація, щоб зупинити систему, коли програми намагаються "
"Потрібна автентифікація, щоб зупинити систему, коли програма"
" намагається "
"перешкодити цьому."
#: src/login/org.freedesktop.login1.policy:257
@ -470,8 +471,8 @@ msgstr "Призупинити систему, коли програми нам
#: src/login/org.freedesktop.login1.policy:279
msgid ""
"Authentication is required to suspend the system while an application "
"is inhibiting this."
"Authentication is required to suspend the system while an application is "
"inhibiting this."
msgstr ""
"Потрібна автентифікація, щоб призупинити систему, коли програми намагаються "
"перешкодити цьому."
@ -501,8 +502,8 @@ msgstr "Приспати систему, коли програми намага
#: src/login/org.freedesktop.login1.policy:311
msgid ""
"Authentication is required to hibernate the system while an application "
"is inhibiting this."
"Authentication is required to hibernate the system while an application is "
"inhibiting this."
msgstr ""
"Потрібна автентифікація, щоб приспати систему, коли програми намагаються "
"перешкодити цьому."
@ -512,8 +513,7 @@ msgid "Manage active sessions, users and seats"
msgstr "Керувати сеансами, користувачами і робочими місцями"
#: src/login/org.freedesktop.login1.policy:322
msgid ""
"Authentication is required to manage active sessions, users and seats."
msgid "Authentication is required to manage active sessions, users and seats."
msgstr ""
"Потрібна автентифікація, щоб керувати сеансами, користувачами і робочими "
"місцями."
@ -767,26 +767,35 @@ msgid "Authentication is required to reset DNS settings."
msgstr "Для скидання параметрів DNS до типових слід пройти розпізнавання."
#: src/network/org.freedesktop.network1.policy:143
msgid "DHCP server sends force renew message"
msgstr "Сервер DHCP надсилає повідомлення щодо примусового оновлення"
#: src/network/org.freedesktop.network1.policy:144
msgid "Authentication is required to send force renew message."
msgstr ""
"Потрібна автентифікація, щоб надіслати повідомлення щодо примусового оновлення"
#: src/network/org.freedesktop.network1.policy:154
msgid "Renew dynamic addresses"
msgstr "Оновлення динамічних адрес"
#: src/network/org.freedesktop.network1.policy:144
#: src/network/org.freedesktop.network1.policy:155
msgid "Authentication is required to renew dynamic addresses."
msgstr "Для оновлення динамічних адрес слід пройти розпізнавання."
#: src/network/org.freedesktop.network1.policy:154
#: src/network/org.freedesktop.network1.policy:165
msgid "Reload network settings"
msgstr "Перезавантаження параметрів мережі"
#: src/network/org.freedesktop.network1.policy:155
#: src/network/org.freedesktop.network1.policy:166
msgid "Authentication is required to reload network settings."
msgstr "Для перезавантаження параметрів мережі слід пройти розпізнавання."
#: src/network/org.freedesktop.network1.policy:165
#: src/network/org.freedesktop.network1.policy:176
msgid "Reconfigure network interface"
msgstr "Переналаштування інтерфейсу мережі"
#: src/network/org.freedesktop.network1.policy:166
#: src/network/org.freedesktop.network1.policy:177
msgid "Authentication is required to reconfigure network interface."
msgstr "Для зміни налаштувань інтерфейсу мережі слід пройти розпізнавання."
@ -842,8 +851,8 @@ msgstr "Повернення до початкових параметрів ви
#: src/resolve/org.freedesktop.resolve1.policy:133
msgid "Authentication is required to reset name resolution settings."
msgstr ""
"Для повернення до початкових параметрів визначення назв вузлів за адресами"
" слід пройти розпізнавання."
"Для повернення до початкових параметрів визначення назв вузлів за адресами "
"слід пройти розпізнавання."
#: src/timedate/org.freedesktop.timedate1.policy:22
msgid "Set system time"
@ -885,38 +894,38 @@ msgstr ""
"Потрібна автентифікація, щоб контролювати, чи синхронізування часу через "
"мережу запущено."
#: src/core/dbus-unit.c:355
#: src/core/dbus-unit.c:356
msgid "Authentication is required to start '$(unit)'."
msgstr "Потрібна автентифікація, щоб запустити «$(unit)»."
#: src/core/dbus-unit.c:356
#: src/core/dbus-unit.c:357
msgid "Authentication is required to stop '$(unit)'."
msgstr "Потрібна автентифікація, щоб зупинити «$(unit)»."
#: src/core/dbus-unit.c:357
#: src/core/dbus-unit.c:358
msgid "Authentication is required to reload '$(unit)'."
msgstr "Потрібна автентифікація, щоб перезавантажити «$(unit)»."
#: src/core/dbus-unit.c:358 src/core/dbus-unit.c:359
#: src/core/dbus-unit.c:359 src/core/dbus-unit.c:360
msgid "Authentication is required to restart '$(unit)'."
msgstr "Потрібна автентифікація, щоб перезапустити «$(unit)»."
#: src/core/dbus-unit.c:531
#: src/core/dbus-unit.c:532
msgid ""
"Authentication is required to send a UNIX signal to the processes of "
"'$(unit)'."
msgstr ""
"Потрібна автентифікація, щоб надіслати сигнал UNIX до процесів «$(unit)»."
#: src/core/dbus-unit.c:562
#: src/core/dbus-unit.c:563
msgid "Authentication is required to reset the \"failed\" state of '$(unit)'."
msgstr "Потрібна автентифікація, щоб скинути «пошкоджений» стан з «$(unit)»."
#: src/core/dbus-unit.c:595
#: src/core/dbus-unit.c:596
msgid "Authentication is required to set properties on '$(unit)'."
msgstr "Потрібна автентифікація, щоб вказати властивості на «$(unit)»."
#: src/core/dbus-unit.c:704
#: src/core/dbus-unit.c:705
msgid ""
"Authentication is required to delete files and directories associated with "
"'$(unit)'."

View File

@ -37,6 +37,7 @@
#include "strv.h"
#include "unit-name.h"
#include "user-util.h"
#include "xattr-util.h"
static int cg_enumerate_items(const char *controller, const char *path, FILE **_f, const char *item) {
_cleanup_free_ char *fs = NULL;
@ -605,6 +606,24 @@ int cg_get_xattr(const char *controller, const char *path, const char *name, voi
return (int) n;
}
int cg_get_xattr_malloc(const char *controller, const char *path, const char *name, char **ret) {
_cleanup_free_ char *fs = NULL;
int r;
assert(path);
assert(name);
r = cg_get_path(controller, path, NULL, &fs);
if (r < 0)
return r;
r = getxattr_malloc(fs, name, ret, false);
if (r < 0)
return r;
return r;
}
int cg_remove_xattr(const char *controller, const char *path, const char *name) {
_cleanup_free_ char *fs = NULL;
int r;
@ -1639,6 +1658,32 @@ int cg_get_attribute(const char *controller, const char *path, const char *attri
return read_one_line_file(p, ret);
}
int cg_get_attribute_as_uint64(const char *controller, const char *path, const char *attribute, uint64_t *ret) {
_cleanup_free_ char *value = NULL;
uint64_t v;
int r;
assert(ret);
r = cg_get_attribute(controller, path, attribute, &value);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
if (streq(value, "max")) {
*ret = CGROUP_LIMIT_MAX;
return 0;
}
r = safe_atou64(value, &v);
if (r < 0)
return r;
*ret = v;
return 0;
}
int cg_get_keyed_attribute(
const char *controller,
const char *path,

View File

@ -184,10 +184,13 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri
int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret);
int cg_get_keyed_attribute(const char *controller, const char *path, const char *attribute, char **keys, char **values);
int cg_get_attribute_as_uint64(const char *controller, const char *path, const char *attribute, uint64_t *ret);
int cg_set_access(const char *controller, const char *path, uid_t uid, gid_t gid);
int cg_set_xattr(const char *controller, const char *path, const char *name, const void *value, size_t size, int flags);
int cg_get_xattr(const char *controller, const char *path, const char *name, void *value, size_t size);
int cg_get_xattr_malloc(const char *controller, const char *path, const char *name, char **ret);
int cg_remove_xattr(const char *controller, const char *path, const char *name);
int cg_install_release_agent(const char *controller, const char *agent);

View File

@ -120,16 +120,9 @@ uint64_t system_tasks_max(void) {
if (r < 0)
log_debug_errno(r, "Failed to determine cgroup root path, ignoring: %m");
else {
_cleanup_free_ char *value = NULL;
r = cg_get_attribute("pids", root, "pids.max", &value);
r = cg_get_attribute_as_uint64("pids", root, "pids.max", &b);
if (r < 0)
log_debug_errno(r, "Failed to read pids.max attribute of cgroup root, ignoring: %m");
else if (!streq(value, "max")) {
r = safe_atou64(value, &b);
if (r < 0)
log_debug_errno(r, "Failed to parse pids.max attribute of cgroup root, ignoring: %m");
}
}
return MIN3(TASKS_MAX,

View File

@ -74,7 +74,7 @@ int log_get_max_level_realm(LogRealm realm) _pure_;
*/
assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1);
#define PROJECT_FILE (__FILE__ + STRLEN(RELATIVE_SOURCE_PATH) + 1)
#define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1])
int log_open(void);
void log_close(void);

View File

@ -215,31 +215,12 @@ void cgroup_context_done(CGroupContext *c) {
}
static int unit_get_kernel_memory_limit(Unit *u, const char *file, uint64_t *ret) {
_cleanup_free_ char *raw_kval = NULL;
uint64_t kval;
int r;
assert(u);
if (!u->cgroup_realized)
return -EOWNERDEAD;
r = cg_get_attribute("memory", u->cgroup_path, file, &raw_kval);
if (r < 0)
return r;
if (streq(raw_kval, "max")) {
*ret = CGROUP_LIMIT_MAX;
return 0;
}
r = safe_atou64(raw_kval, &kval);
if (r < 0)
return r;
*ret = kval;
return 0;
return cg_get_attribute_as_uint64("memory", u->cgroup_path, file, ret);
}
static int unit_compare_memory_limit(Unit *u, const char *property_name, uint64_t *ret_unit_value, uint64_t *ret_kernel_value) {
@ -3112,7 +3093,6 @@ int manager_notify_cgroup_empty(Manager *m, const char *cgroup) {
}
int unit_get_memory_current(Unit *u, uint64_t *ret) {
_cleanup_free_ char *v = NULL;
int r;
assert(u);
@ -3134,22 +3114,11 @@ int unit_get_memory_current(Unit *u, uint64_t *ret) {
r = cg_all_unified();
if (r < 0)
return r;
if (r > 0)
r = cg_get_attribute("memory", u->cgroup_path, "memory.current", &v);
else
r = cg_get_attribute("memory", u->cgroup_path, "memory.usage_in_bytes", &v);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
return safe_atou64(v, ret);
return cg_get_attribute_as_uint64("memory", u->cgroup_path, r > 0 ? "memory.current" : "memory.usage_in_bytes", ret);
}
int unit_get_tasks_current(Unit *u, uint64_t *ret) {
_cleanup_free_ char *v = NULL;
int r;
assert(u);
assert(ret);
@ -3166,17 +3135,10 @@ int unit_get_tasks_current(Unit *u, uint64_t *ret) {
if ((u->cgroup_realized_mask & CGROUP_MASK_PIDS) == 0)
return -ENODATA;
r = cg_get_attribute("pids", u->cgroup_path, "pids.current", &v);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
return safe_atou64(v, ret);
return cg_get_attribute_as_uint64("pids", u->cgroup_path, "pids.current", ret);
}
static int unit_get_cpu_usage_raw(Unit *u, nsec_t *ret) {
_cleanup_free_ char *v = NULL;
uint64_t ns;
int r;
@ -3212,17 +3174,8 @@ static int unit_get_cpu_usage_raw(Unit *u, nsec_t *ret) {
return r;
ns = us * NSEC_PER_USEC;
} else {
r = cg_get_attribute("cpuacct", u->cgroup_path, "cpuacct.usage", &v);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
r = safe_atou64(v, &ns);
if (r < 0)
return r;
}
} else
return cg_get_attribute_as_uint64("cpuacct", u->cgroup_path, "cpuacct.usage", ret);
*ret = ns;
return 0;

View File

@ -96,6 +96,7 @@ _public_ int sd_bus_call_method(
int r;
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
@ -283,6 +284,7 @@ _public_ int sd_bus_get_property(
int r;
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(reply, -EINVAL, error);
@ -294,7 +296,10 @@ _public_ int sd_bus_get_property(
goto fail;
}
r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &rep, "ss", strempty(interface), member);
r = sd_bus_call_method(bus, destination, path,
"org.freedesktop.DBus.Properties", "Get",
error, &rep,
"ss", strempty(interface), member);
if (r < 0)
return r;
@ -324,6 +329,7 @@ _public_ int sd_bus_get_property_trivial(
int r;
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(bus_type_is_trivial(type), -EINVAL, error);
@ -368,6 +374,7 @@ _public_ int sd_bus_get_property_string(
int r;
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(ret, -EINVAL, error);
@ -416,6 +423,7 @@ _public_ int sd_bus_get_property_strv(
int r;
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(ret, -EINVAL, error);
@ -458,6 +466,7 @@ _public_ int sd_bus_set_property(
int r;
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(signature_is_single(type, false), -EINVAL, error);

View File

@ -585,14 +585,13 @@ _public_ int sd_bus_message_new(
sd_bus_message **m,
uint8_t type) {
sd_bus_message *t;
assert_return(bus, -ENOTCONN);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state != BUS_UNSET, -ENOTCONN);
assert_return(m, -EINVAL);
assert_return(type < _SD_BUS_MESSAGE_TYPE_MAX, -EINVAL);
t = malloc0(ALIGN(sizeof(sd_bus_message)) + sizeof(struct bus_header));
sd_bus_message *t = malloc0(ALIGN(sizeof(sd_bus_message)) + sizeof(struct bus_header));
if (!t)
return -ENOMEM;
@ -623,6 +622,7 @@ _public_ int sd_bus_message_new_signal(
int r;
assert_return(bus, -ENOTCONN);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state != BUS_UNSET, -ENOTCONN);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(interface_name_is_valid(interface), -EINVAL);
@ -663,6 +663,7 @@ _public_ int sd_bus_message_new_method_call(
int r;
assert_return(bus, -ENOTCONN);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state != BUS_UNSET, -ENOTCONN);
assert_return(!destination || service_name_is_valid(destination), -EINVAL);
assert_return(object_path_is_valid(path), -EINVAL);

View File

@ -504,7 +504,6 @@ static int synthesize_connected_signal(sd_bus *bus) {
}
void bus_set_state(sd_bus *bus, enum bus_state state) {
static const char * const table[_BUS_STATE_MAX] = {
[BUS_UNSET] = "UNSET",
[BUS_WATCH_BIND] = "WATCH_BIND",
@ -1899,9 +1898,10 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie) {
assert_return(m, -EINVAL);
if (!bus)
bus = m->bus;
if (bus)
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
@ -1983,9 +1983,10 @@ _public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destinat
assert_return(m, -EINVAL);
if (!bus)
bus = m->bus;
if (bus)
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
@ -2048,9 +2049,10 @@ _public_ int sd_bus_call_async(
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(!m->sealed || (!!callback == !(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)), -EINVAL);
if (!bus)
bus = m->bus;
if (bus)
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
@ -2154,9 +2156,10 @@ _public_ int sd_bus_call(
bus_assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL, error);
bus_assert_return(!bus_error_is_dirty(error), -EINVAL, error);
if (!bus)
bus = m->bus;
if (bus)
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
@ -2283,7 +2286,6 @@ fail:
}
_public_ int sd_bus_get_fd(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->input_fd == bus->output_fd, -EPERM);
@ -3674,31 +3676,31 @@ _public_ int sd_bus_detach_event(sd_bus *bus) {
}
_public_ sd_event* sd_bus_get_event(sd_bus *bus) {
assert_return(bus, NULL);
assert_return(bus = bus_resolve(bus), NULL);
return bus->event;
}
_public_ sd_bus_message* sd_bus_get_current_message(sd_bus *bus) {
assert_return(bus, NULL);
assert_return(bus = bus_resolve(bus), NULL);
return bus->current_message;
}
_public_ sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus) {
assert_return(bus, NULL);
assert_return(bus = bus_resolve(bus), NULL);
return bus->current_slot;
}
_public_ sd_bus_message_handler_t sd_bus_get_current_handler(sd_bus *bus) {
assert_return(bus, NULL);
assert_return(bus = bus_resolve(bus), NULL);
return bus->current_handler;
}
_public_ void* sd_bus_get_current_userdata(sd_bus *bus) {
assert_return(bus, NULL);
assert_return(bus = bus_resolve(bus), NULL);
return bus->current_userdata;
}
@ -4015,7 +4017,6 @@ _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
}
_public_ int sd_bus_get_address(sd_bus *bus, const char **address) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(address, -EINVAL);

View File

@ -21,6 +21,7 @@
#include "bus-common-errors.h"
#include "bus-error.h"
#include "bus-util.h"
#include "bridge-util.h"
#include "device-util.h"
#include "escape.h"
#include "ether-addr-util.h"
@ -28,6 +29,7 @@
#include "fd-util.h"
#include "format-table.h"
#include "format-util.h"
#include "geneve-util.h"
#include "glob-util.h"
#include "hwdb-util.h"
#include "local-addresses.h"
@ -160,8 +162,14 @@ typedef struct LinkInfo {
/* tunnel info */
uint8_t ttl;
uint8_t tos;
uint8_t inherit;
uint8_t df;
uint8_t csum;
uint8_t csum6_tx;
uint8_t csum6_rx;
uint16_t tunnel_port;
uint32_t vni;
uint32_t label;
union in_addr_union local;
union in_addr_union remote;
@ -285,8 +293,14 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
(void) sd_netlink_message_read_in6_addr(m, IFLA_GENEVE_REMOTE6, &info->remote.in6);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_TTL, &info->ttl);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_TTL_INHERIT, &info->inherit);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_TOS, &info->tos);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_DF, &info->df);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_UDP_CSUM, &info->csum);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_UDP_ZERO_CSUM6_TX, &info->csum6_tx);
(void) sd_netlink_message_read_u8(m, IFLA_GENEVE_UDP_ZERO_CSUM6_RX, &info->csum6_rx);
(void) sd_netlink_message_read_u16(m, IFLA_GENEVE_PORT, &info->tunnel_port);
(void) sd_netlink_message_read_u32(m, IFLA_GENEVE_LABEL, &info->label);
} else if (STR_IN_SET(received_kind, "gre", "gretap", "erspan")) {
(void) sd_netlink_message_read_in_addr(m, IFLA_GRE_LOCAL, &info->local.in);
(void) sd_netlink_message_read_in_addr(m, IFLA_GRE_REMOTE, &info->remote.in);
@ -1487,20 +1501,10 @@ static int link_status_one(
return table_log_add_error(r);
if (info->port_state <= BR_STATE_BLOCKING) {
static const struct {
const char *state;
} state_table[] = {
{ "disabled" },
{ "listening" },
{ "learning" },
{ "forwarding" },
{ "blocking" },
};
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Port State:",
TABLE_STRING, state_table[info->port_state]);
TABLE_STRING, bridge_state_to_string(info->port_state));
}
} else if (streq_ptr(info->netdev_kind, "bond")) {
static const struct {
@ -1669,6 +1673,52 @@ static int link_status_one(
TABLE_UINT16, info->tunnel_port);
if (r < 0)
return table_log_add_error(r);
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Inherit:",
TABLE_STRING, geneve_df_to_string(info->inherit));
if (r < 0)
return table_log_add_error(r);
if (info->df > 0) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "IPDoNotFragment:",
TABLE_UINT8, info->df);
if (r < 0)
return table_log_add_error(r);
}
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "UDPChecksum:",
TABLE_BOOLEAN, info->csum);
if (r < 0)
return table_log_add_error(r);
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "UDP6ZeroChecksumTx:",
TABLE_BOOLEAN, info->csum6_tx);
if (r < 0)
return table_log_add_error(r);
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "UDP6ZeroChecksumRx:",
TABLE_BOOLEAN, info->csum6_rx);
if (r < 0)
return table_log_add_error(r);
if (info->label > 0) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "FlowLabel:",
TABLE_UINT32, info->label);
if (r < 0)
return table_log_add_error(r);
}
}
if (info->has_wlan_link_info) {

13
src/shared/bridge-util.c Normal file
View File

@ -0,0 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "bridge-util.h"
#include "string-table.h"
static const char* const bridge_state_table[_NETDEV_BRIDGE_STATE_MAX] = {
[NETDEV_BRIDGE_STATE_DISABLED] = "disabled",
[NETDEV_BRIDGE_STATE_LISTENING] = "listening",
[NETDEV_BRIDGE_STATE_LEARNING] = "learning",
[NETDEV_BRIDGE_STATE_FORWARDING] = "forwading",
};
DEFINE_STRING_TABLE_LOOKUP(bridge_state, BridgeState);

20
src/shared/bridge-util.h Normal file
View File

@ -0,0 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <netinet/in.h>
#include <linux/if_bridge.h>
#include "conf-parser.h"
typedef enum BridgeState {
NETDEV_BRIDGE_STATE_DISABLED = BR_STATE_DISABLED,
NETDEV_BRIDGE_STATE_LISTENING = BR_STATE_LISTENING,
NETDEV_BRIDGE_STATE_LEARNING = BR_STATE_LEARNING,
NETDEV_BRIDGE_STATE_FORWARDING = BR_STATE_FORWARDING,
NETDEV_BRIDGE_STATE_BLOCKING = BR_STATE_BLOCKING,
_NETDEV_BRIDGE_STATE_MAX,
_NETDEV_BRIDGE_STATE_INVALID = -1,
} BridgeState;
const char *bridge_state_to_string(BridgeState d) _const_;
BridgeState bridge_state_from_string(const char *d) _pure_;

12
src/shared/geneve-util.c Normal file
View File

@ -0,0 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "geneve-util.h"
#include "string-table.h"
static const char* const geneve_df_table[_NETDEV_GENEVE_DF_MAX] = {
[NETDEV_GENEVE_DF_UNSET] = "unset",
[NETDEV_GENEVE_DF_SET] = "set",
[NETDEV_GENEVE_DF_INHERIT] = "inherit",
};
DEFINE_STRING_TABLE_LOOKUP(geneve_df, GeneveDF);

17
src/shared/geneve-util.h Normal file
View File

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <linux/if_link.h>
#include "conf-parser.h"
typedef enum GeneveDF {
NETDEV_GENEVE_DF_UNSET = GENEVE_DF_UNSET,
NETDEV_GENEVE_DF_SET = GENEVE_DF_SET,
NETDEV_GENEVE_DF_INHERIT = GENEVE_DF_INHERIT,
_NETDEV_GENEVE_DF_MAX,
_NETDEV_GENEVE_DF_INVALID = -1,
} GeneveDF;
const char *geneve_df_to_string(GeneveDF d) _const_;
GeneveDF geneve_df_from_string(const char *d) _pure_;

View File

@ -21,6 +21,8 @@ shared_sources = files('''
bootspec.h
bpf-program.c
bpf-program.h
bridge-util.c
bridge-util.h
bus-unit-procs.c
bus-unit-procs.h
bus-unit-util.c
@ -87,6 +89,8 @@ shared_sources = files('''
fstab-util.h
generator.c
generator.h
geneve-util.c
geneve-util.h
gpt.c
gpt.h
group-record-nss.c

View File

@ -125,11 +125,12 @@ int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs) {
_cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL;
e = getenv("XDG_CONFIG_DIRS");
if (e) {
if (e)
config_dirs = strv_split(e, ":");
if (!config_dirs)
return -ENOMEM;
}
else
config_dirs = strv_new("/etc/xdg");
if (!config_dirs)
return -ENOMEM;
e = getenv("XDG_DATA_DIRS");
if (e)