Commit Graph
3572 Commits
Author SHA1 Message Date
Yu Watanabe 51b8753017 sd-netlink: fix attribute type for RTAX_CC_ALGO 2022-08-26 14:33:54 +09:00
Lennart Poettering 98f3e84342 Merge pull request #24420 from keszybz/mouse-power
Rework on_ac_power()
2022-08-24 10:16:14 +02:00
Zbigniew Jędrzejewski-Szmek 48a511cf92 sd-device: add helper to read a unsigned int attribute
There are dozens of places where this could be used, but I don't
want to do the conversion now because it's quite a bit of work.
I think we could export this function later on, because reading
numerical attributes is so common. But for now, I'm just adding the
helper to use it one place.
2022-08-23 17:04:31 +02:00
Lennart Poettering 45519d13a4 tree-wide: port things dirname_malloc() → path_extract_directory() 2022-08-23 15:10:15 +02:00
Lennart Poettering 8e7e4a730b tree-wide: use path_join() instead of prefix_roota() in various cases
prefix_roota() is something we should stop using. It is bad for three
reasons:

1. As it names suggests it's supposed to be used when working relative
   to some root directory, but given it doesn't follow symlinks (and
   instead just stupidly joins paths) it is not a good choice for that.

2. More often than not it is currently used with inputs under control of
   the user, and that is icky given it typically allocates memory on the
   stack.

3. It's a redundant interface, where chase_symlinks() and path_join()
   already exist as better, safer interfaces.

Hence, let's start moving things from prefix_roota() to path_join() for
the cases where that's appropriate.
2022-08-22 19:15:29 +01:00
Frantisek Sumsal 94510784e1 sd-journal: drop an unused variable 2022-08-20 20:46:23 +02:00
Yu Watanabe 0f27758ae9 Merge pull request #24356 from keszybz/sd-netlink-api
Small improvements to the sd-netlink api
2022-08-20 19:11:02 +09:00
Zbigniew Jędrzejewski-Szmek 93c0a5eccf sd-netlink: use SD_EVENT_ONESHOT for a time-based callback 2022-08-19 17:43:56 +02:00
Lennart Poettering 2ab1fb77e2 tree-wide: pass proper values (not bools) to sd_event_source_set_enabled() 2022-08-19 14:56:26 +02:00
Zbigniew Jędrzejewski-Szmek 40c864afe0 sd-netlink: simplify error code retention 2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek 3310e0647c sd-netlink: delete sd_netlink_new_from_fd()
It was somewhat similar to sd_netlink_open_fd(), and unused.
2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek 24c0f38591 sd-netlink: rename sd_netlink_message_request_dump to sd_netlink_message_set_request_dump 2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek f4f81a6b35 sd-netlink: constify parameters in public api and adjust pointer formatting
In the internal api, 'char* const*' is used instead of 'const char* const*'
because otherwise we'd get a mismatch with the various strv apis.
2022-08-19 11:52:25 +02:00
Zbigniew Jędrzejewski-Szmek b44662fee5 sd-netlink: prefix output param names with 'ret'
In some places, the code was already using that, so only the header file needed
to be adjusted.

We use 'nl' for the sd_netlink* when it's passed in as input. I was considering
renaming to 'netlink', but that'd add a lot of verbosity and also we have
'sd_journal *j' in sd-journal, so the short name matches in style.
2022-08-19 11:52:21 +02:00
Yu Watanabe 9d9bc6fc57 Merge pull request #24285 from yuwata/sd-device-new-from-path
sd-device: make sd_device_new_from_path() support symlink outside of /sys
2022-08-13 03:27:26 +09:00
Yu Watanabe 284ef480d0 test: add more tests for sd_device_new_from_path() 2022-08-12 21:42:00 +09:00
Yu Watanabe 95c250be0d sd-device: allow to create sd-device object through a symlink outside of /sys
For example, /proc/device-tree is a symlink to /sys/firmware/devicetree/base,
and the kernel documentation says the symlink should be used by userspace app.
See, https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw.
Hence, it is useful to make `sd_device_new_from_path()` support such symlink.
2022-08-12 21:41:12 +09:00
Yu Watanabe cbdf6a1fcf test: use sd_device_monitor_set_description() 2022-08-12 21:27:14 +09:00
Yu Watanabe f36b683f6c sd-device-monitor: logs description for device monitor 2022-08-12 21:27:14 +09:00
Yu Watanabe 39f11aa422 sd-device-monitor: introduce sd_device_monitor_{set,get}_description() 2022-08-12 21:27:14 +09:00
Yu Watanabe edf6cbc30f Merge pull request #24286 from yuwata/test-sd-device-monitor
test-sd-device-monitor: several fixlets
2022-08-12 21:24:40 +09:00
Yu Watanabe 0186571c9f sd-device-enumerator: drop noisy log messages
These are not for failed tasks, and provide almost no information.
2022-08-12 21:23:58 +09:00
Yu Watanabe 8bb4989906 sd-device-monitor: actually refuse to send invalid devices
Fixes an issue introduced by 9e79123884.
2022-08-12 04:34:19 +09:00
Yu Watanabe 133d78966f sd-device-monitor: fix inversed condition
Fixes an issue introduced by b3d06b9226.
2022-08-12 04:34:19 +09:00
Yu Watanabe 8164957461 test: do not fill up receiver buffer
If a system has many devices, then the receiver buffer may be filled up.

Hopefully fixes https://bugzilla.redhat.com/show_bug.cgi?id=2095750
2022-08-12 03:13:22 +09:00
Yu Watanabe 46c1223b24 test: add fake action and seqnum
Otherwise, the receiver refuses the devices. See device_verify().
2022-08-12 03:13:22 +09:00
Yu Watanabe 50f9c507b2 test: add tests for sd_device_enumerator_add_match_sysattr/property() 2022-08-09 02:21:25 +09:00
Yu Watanabe b07131facf sd-device-enumerator: FOREACH_DEVICE_PROPERTY() does not provide NULL value
Hence, when sd_device_enumerator_add_match_property() called with NULL
for value, then the filter always unmatches with the device.
2022-08-09 01:17:03 +09:00
Yu Watanabe 585f2035b3 sd-device-enumerator,monitor: fix sysattr match
Previously, if sd_device_enumerator_add_match_sysattr() is called for
the same sysattr with different values, then no device passed the filter.

Now, the accepted values (or patterns) are stored in strv, and if the
sysattr value of a device matches with the strv, then the device passes
the filter.
2022-08-09 01:17:00 +09:00
Yu Watanabe ebf404a4d0 sd-netlink: rename NLType and friends
In sd-netlink, we use 'type' for naming many variables with different type,
and worst of all, function like `type_get_type()` exists. That makes the
code hard to understood.

Let's rename
- NLType -> NLAPolicy
- NLTypeSystem -> NLAPolicySet
- NLTypeSystemUnion -> NLAPolicySetUnion
- type_get_type() -> policy_get_type()
- type_get_type_system() -> policy_get_policy_set(), and so on.

This also changes the type of attribute taken by e.g.
`sd_netlink_message_append_string()` from `unsigned short` -> `uint16_t`
to make the variable size clearer.
2022-08-06 03:53:51 +09:00
Yu Watanabe 1ab7e2b587 Merge pull request #23340 from yuwata/network-check-sr-iov-pf-state
network: check SR-IOV PF state
2022-08-06 03:18:30 +09:00
David Rheinsberg 347f48246f bus: use inline trace argument for ANONYMOUS auth
Rather than using a separate DATA round to transmit the trace-string of
the ANONYMOUS authentication scheme, transmit it inline as argument.
This requires a refactor of the client-side SASL parser, as we now have
a different set of replies depending on the mode used.

This fixes an issue where libdbus-1 does not query for trace-strings if
not transmit inline as AUTH-ANONYMOUS argument. It is unclear from the
wording of the spec whether this is a violation by libdbus-1. However,
we can work around it by simply changing our mode of transmittal.
2022-08-05 16:39:55 +01:00
Yu Watanabe 68a52f5973 sd-device: introduce sd_device_new_child() 2022-08-05 21:49:23 +09:00
igo95862 b283d50240 Fix ObjectManager interface emitted for non-manager objects 2022-07-25 23:54:54 +03:00
igo95862 19b581466a test-bus-objects: Test interfaces added/removed signal interfaces
`org.freedesktop.DBus.ObjectManager` should only be emitted if
object in question has ObjectManager attached.
2022-07-25 23:53:18 +03:00
igo95862 2ccd0828fc Fix GetManagedObjects returning ObjectManager interface for non-manager objects 2022-07-25 23:37:00 +03:00
igo95862 724e13b346 test-bus-objects: Test GetManagedObjects interfaces are correct
Objects without ObjectManager should not have
`org.freedesktop.DBus.ObjectManager` interface.

Object with ObjectManager should do.

Also added ASSERT_SE_NONNEG and ASSERT_NONNEG macros.
2022-07-25 23:29:17 +03:00
Yu Watanabe 978642b633 Merge pull request #24020 from yuwata/network-rfkill
network: fix wlan interface handling when its RF is killed
2022-07-24 13:01:50 +09:00
Yu Watanabe 573bb24df7 sd-netlink: introduce sd_nfnl_{send,call}_batch()
This also introduces sd_nfnl_message_new() which can be also used for
non-nftables subsystems.
2022-07-24 00:16:21 +09:00
Yu Watanabe 04d2003718 sd-netlink: do not compare pointer with 0 2022-07-24 00:05:32 +09:00
Yu Watanabe df7371708e sd-netlink: merge sd_nfnl_nft_message_{new,del}_setelems_begin()
And this makes the new merged function `sd_nfnl_nft_message_new_setelems()`
not open container, as containers should be opened and closed in the
same function in general. Otherwise, it is hard to understand which
level we are in the nested attribute tree.
2022-07-24 00:05:09 +09:00
Yu Watanabe 9d884ac36d sd-netlink: drop unused sd_nfnl_nft_message_del_table() 2022-07-23 23:52:42 +09:00
Yu Watanabe 2c08455eed sd-netlink: introduce sd_netlink_message_append_container_data() 2022-07-23 23:52:42 +09:00
Yu Watanabe 64f090a61a sd-netlink: several cleanups for netfilter
- rename family -> nfproto, and other arguments,
- check specified nfproto,
- change type of several function arguments that specify data length,
- add several assertions,
- drop unnecessary headers.
2022-07-23 23:52:42 +09:00
Yu Watanabe 8547260579 tree-wide: drop unnecessary inclusion of netlink-util.h 2022-07-23 23:31:23 +09:00
Yu Watanabe 13c026ca83 sd-netlink: move rtnl_message_type_is_*() to netlink-message-rtnl.c 2022-07-23 23:31:23 +09:00
Yu Watanabe d6985e76f2 sd-device: introduce device_unref_and_replace() 2022-07-23 08:16:38 +09:00
Yu Watanabe 5eb83e9000 sd-device: introduce device_clear_sysattr_cache() 2022-07-23 08:11:36 +09:00
Yu Watanabe 2829fca249 sd-device: introduce device_get_sysattr_bool() 2022-07-23 08:11:36 +09:00
Lennart Poettering 4a0cb5474e Merge pull request #23963 from matoro/main
Replace __sync intrinsics with __atomic
2022-07-21 00:10:01 +02:00