Commit Graph
2679 Commits
Author SHA1 Message Date
Yu Watanabe c990101f23 sd-netlink: fix type of NDA_LLADDR attribute 2021-11-11 12:49:42 +09:00
Yu Watanabe e2b777f821 sd-id128: use /proc/device-tree 2021-11-11 04:42:50 +09:00
Lennart Poettering 035daf73fb test: add test case for self-destroy inotify handler 2021-11-09 13:13:25 +01:00
Lennart Poettering e67d738a87 sd-event: add sd_event_add_inotify_fd() call
sd_event_add_inotify_fd() is like sd_event_add_inotify(), but takes an
fd to an inode instead of a path, and is hence a ton nicer.
2021-11-09 13:02:13 +01:00
Lennart Poettering 53baf2efa4 sd-event: don't destroy inotify data structures from inotify event handler
This fixes a bad memory access when we destroy an inotify source handler
from the handler itself, and thus destroy the associated inotify_data
structures.

Fixes: #20177
2021-11-09 12:53:04 +01:00
Lennart Poettering 4f538d7b22 tree-wide: use sd_event_source_disable_unref() where we can 2021-11-09 12:52:53 +01:00
Zbigniew Jędrzejewski-Szmek ed8ba68f3b Merge pull request #21272 from yuwata/netif-util-split
netif-util: move several functions from network-util.c to netif-util.c
2021-11-09 10:01:07 +01:00
Yu Watanabe fb076d5f6c sd-netlink: add more attributes for CAKE 2021-11-09 10:58:44 +09:00
Yu Watanabe b5cc5591fa netif-util: move several functions from network-util.[ch] to shared/netif-util.[ch]
These functions are not relevant to sd-network, and only used by
networkd, networkctl, and udevd.
2021-11-09 08:24:10 +09:00
Yu Watanabe f09d20256a arphrd-util: rename arphrd-list.[ch] -> arphrd-util.[ch] 2021-11-09 08:24:10 +09:00
Christian Brauner a6d1760024 build: preserve correct mode when generating files via jinja2
When using "capture : true" in custom_target()s the mode of the source
file is not preserved when the generated file is not installed and so
needs to be tweaked manually. Switch from output capture to creating the
target file and copy the permissions from the input file.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-08 12:06:48 +00:00
Lennart Poettering aedec452b9 tree-wide: always use TAKE_FD() when calling rearrange_stdio()
rearrange_stdio() invalidates specified fds even on failure, which means
we should always invalidate the fds we pass in no matter what. Let's
make this explicit by using TAKE_FD() for that everywhere.

Note that in many places we such invalidation doesnt get us much
behaviour-wise, since we don't use the variables anymore later. But
TAKE_FD() in a way is also documentation, it encodes explicitly that the
fds are invalidated here, so I think it's a good thing to always make
this explicit here.
2021-11-03 23:05:26 +00:00
Lennart Poettering 8f03de5323 tree-wide: port various places to use TAKE_PID() 2021-11-03 16:36:09 +01:00
Yu Watanabe 231c7645ca Merge pull request #21041 from yuwata/network-bpf-neighbor
network: introduce BPF to reject netlink messages about non-static neighbor
2021-10-20 13:30:32 +09:00
Yu Watanabe dc317a9aed sd-netlink: introduce sd_netlink_attach_filter() 2021-10-19 20:41:09 +09:00
Lennart Poettering aabb252577 Merge pull request #20905 from medhefgo/boot-cleanup
sd-boot: Code cleanups
2021-10-19 10:23:12 +02:00
Zbigniew Jędrzejewski-Szmek 33539ffe59 Merge pull request #20988 from DaanDeMeyer/rotate-reason
journal: Improve rotation logging
2021-10-19 09:53:31 +02:00
Yu Watanabe 0522729e19 tree-wide: use AF_NETLINK instead of PF_NETLINK 2021-10-18 22:46:37 +02:00
Daan De Meyer 012181eaef journal: Add two more log messages to journal_file_rotate_suggested()
This ensures every reason for rotation has an associated log message.
2021-10-18 16:48:06 +01:00
Daan De Meyer c8e6e1f10d journal: Add log level argument to journal_file_rotate_suggested()
When journald is rotating a file, we'd like to log the reason at
LOG_INFO or higher instead of LOG_DEBUG. For journalctl --header,
logging the reason at a level higher than LOG_DEBUG doesn't really
make sense. To accomodate both use cases, make the log level used
by journal_file_rotate_suggested() configurable.
2021-10-18 15:26:06 +02:00
Jan Janssen a36a0d1540 macro: Move ALIGN_TO to macro-fundamental.h and introduce CONST_ALIGN_TO 2021-10-17 11:56:05 +02:00
Zbigniew Jędrzejewski-Szmek 6b292fa17b Merge pull request #20996 from yuwata/udevadm-trigger-debug
test: show debug and verbose message
2021-10-15 09:44:59 +02:00
Lennart Poettering 2f82562bad alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhere
Let's define two helpers strdupa_safe() + strndupa_safe() which do the
same as their non-safe counterparts, except that they abort if called
with allocations larger than ALLOCA_MAX.

This should ensure that all our alloca() based allocations are subject
to this limit.

afaics glibc offers three alloca() based APIs: alloca() itself,
strndupa() + strdupa(). With this we have now replacements for all of
them, that take the limit into account.
2021-10-14 15:57:52 +02:00
Lennart Poettering 5222651ecc journal: drop unnecessary +1 in newa() expression
newa() does this internally anyway, no need to do this explicitly.
2021-10-14 15:57:52 +02:00
Lennart Poettering 698cec65c4 tree-wide: port all calls to alloca() to alloca_safe() 2021-10-14 15:57:52 +02:00
Yu Watanabe 6b652c03a4 sd-device-monitor: update log message to clarify the error will be ignored 2021-10-13 12:57:40 +09:00
Yu Watanabe 6f47ab1bb1 Merge pull request #20985 from yuwata/test-bus-node-enumerator
test: add more tests for sd-bus node enumerator
2021-10-12 15:20:47 +09:00
Yu Watanabe f21b863eeb test: use assert_se() instead of assert() 2021-10-12 15:20:28 +09:00
Yu Watanabe e660d66e1c test: add more node enumerator tests 2021-10-12 03:05:24 +09:00
Lennart Poettering 2aaf565a2d homed: take BSD file lock on LUKS file while activated
Fixes: #19758
2021-10-11 16:00:34 +02:00
Lennart Poettering a995ce4768 util: define initializer for 'struct ucred' that properly invalidates all fields
i.e. let's make sure to invalid uid/gid to UID_INVAID + GID_INVALID
instead of zero.
2021-10-11 15:37:37 +02:00
Zbigniew Jędrzejewski-Szmek 54ccd706ba Merge pull request #20744 from yuwata/udev-netlink
udev: use netlink more aggressively

I'm pasting the comment from https://github.com/systemd/systemd/pull/20744#issuecomment-934485287
which is quite informative. The code wasn't changed significantly since then:

atenart commented 6 days ago:
> I ran tests without (93caec7) and with this PR (06735f2) on Fedora, having a few udev rules
> using attributes eligible to be cached and creating 50 veth on 4 CPUs. Although the time spent
> running the test is variable between runs, I generally saw an improvement when using this PR, e.g:
>
> 249-910-g93caec7:
> real	0m3.691s
> user	0m0.022s
> sys	0m1.338s
> 
> 249-920-g06735f2:
> real	0m2.950s
> user	0m0.005s
> sys	0m0.399s
> 
> On a different system than the one used above, I even saw a 40% improvement; results depend
> on many parameters (distro, udev rules, concurrent daemons accessing sysfs, etc.).
> 
> Because it's quite hard to measure the improvement here (as the kernel behave differently between
> the two test cases), I also ran tests using a modified kernel not hitting the trylock logic. There was
> an improvement with this PR as well. (Take this with a grain of salt though, as the kernel was
> modified not using patches approved upstream).
2021-10-11 09:40:43 +02:00
Luca Boccassi ec4afb4606 libsystemd/sd-id128: use only internal hmac, remove khash/OpenSSL support
Using OpenSSL brings in an additional dependency for all users of
libsystemd.so even though it's just one API that makes use of it.

The khash implementation is awkward as it requires context switches and
computation inside the kernel, thus leaving the process.

Remove both from libsystemd.so, and use exclusively the internal hmac fallback.
While this is not optimized, the sd-id128 API is not used in
performance-critical contexts where hardware acceleration would make a
noticeable difference.
2021-10-08 13:11:00 +01:00
Lennart Poettering c53e07e249 xattr-util: merge various getxattr()/listxattr() helpers into getxattr_at_malloc() + listxattr_at_malloc()
Unfortunately fgetxattr() and flistxattr() don't work via O_PATH fds.
Let's thus add fallbacks to go via /proc/self/fd/ in these cases.

Also, let's merge all the various flavours we have here into singular
implementations that can do everything we need:

1. malloc() loop handling
2. by fd, by path, or combination (i.e. a proper openat() like API)
3. work on O_PATH
2021-10-07 11:49:22 +02:00
Yu Watanabe 18b1137977 sd-device: expose device_cache_sysattr_value() and device_get_cached_sysattr_value() 2021-10-06 16:02:06 +09:00
Yu Watanabe b63dd5aad8 sd-device: make device_get_cached_sysattr_value() distinguish if we have looked up the attribute 2021-10-06 16:00:55 +09:00
Lennart Poettering f435195925 basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch] 2021-10-05 16:14:37 +02:00
Lennart Poettering 9e5fd71799 basic: split out inotify-related calls from fs-util.h → inotify-util.h 2021-10-05 16:14:37 +02:00
Lennart Poettering d8e32c471f basic: split out glyph/emoji related calls from locale-util.[ch] into glyph-util.[ch]
These functions are used pretty much independently of locale, i.e. the
only info relevant is whether th locale is UTF-8 or not. Hence let's
give this its own pair of .c/.h files.
2021-10-05 16:14:37 +02:00
Lennart Poettering bf819d3ac2 basic: split out sync() family of calls from fs-util.[ch] into new c/h file
No changes in code, just some splitting out.
2021-10-05 15:47:32 +02:00
Yu Watanabe 8e310690b0 sd-netlink: add several attributes for nl80211 2021-09-29 15:38:59 +09:00
Yu Watanabe f3e235ffb2 sd-netlink, wifi-util: fix attribute type of NL80211_ATTR_SSID 2021-09-29 15:38:59 +09:00
Yu Watanabe a1d2ae065b sd-netlink: introduce sd_netlink_message_read_data_suffix0() 2021-09-29 15:38:59 +09:00
Yu Watanabe 84f7bd7698 sd-netlink: make sd_genl_message_new() or friends return -EOPNOTSUPP if a module is not supported by the kernel 2021-09-29 15:38:55 +09:00
Yu Watanabe 4d4d898a4b sd-netlink: also check multicast group to find suitable match callback 2021-09-29 15:36:42 +09:00
Yu Watanabe ec44d3f407 sd-netlink: allow to set dump flag for genl or netfilter messages 2021-09-29 15:35:08 +09:00
Yu Watanabe dbc35fe3aa sd-netlink: add type safe macro for sd_genl_add_match() 2021-09-29 15:33:50 +09:00
Yu Watanabe 52888279df sd-netlink: minor coding style fixes 2021-09-29 15:33:50 +09:00
Yu Watanabe 01afd0f7f5 tree-wide: make format_ifname() or friends return negative errno on failure
Also,
- drop unnecessary +1 from buffer size, as IF_NAMESIZE or IFNAMSIZ
  includes the nul at the end.
- format_ifname() does not update buffer on failure,
- introduces format_ifname_alloc(), FORMAT_IFNAME(), and their friends.
2021-09-29 03:37:06 +09:00
Yu Watanabe 73bf0f2ace Merge pull request #20738 from mrc0mmand/ci-llvm-13
ci: build with clang-13
2021-09-16 09:32:21 +09:00