Zbigniew Jędrzejewski-Szmek
90e74a66e6
tree-wide: define iterator inside of the macro
2020-09-08 12:14:05 +02:00
Zbigniew Jędrzejewski-Szmek
9e79123884
tree-wide: use SYNTHETIC_ERRNO with log_device_* in more places
2020-07-16 22:08:12 +02:00
Zbigniew Jędrzejewski-Szmek
aaffd34933
sd-device: use set_put_strdup() in one more place
2020-06-22 16:32:37 +02:00
Lennart Poettering
f6dbcebdc2
sd-device: check netlink netns matches host netns before using monitor
...
Tracking down #15931 confused the hell out of me, since running homed in
gdb from the command line worked fine, but doing so as a service failed.
Let's make this more debuggable and check if we live in the host netns
when allocating a new udev monitor.
This is just debug stuff, so that if things don't work, a quick debug
run will reveal what is going on.
That said, while we are at it, also fix unexpected closing of passed in
fd when failing.
2020-05-29 15:28:10 +09:00
Lennart Poettering
fb29cdbef2
tree-wide: make sure our control buffers are properly aligned
...
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.
Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.
Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
2020-05-07 14:39:44 +02:00
Yu Watanabe
92133d2878
tree-wide: drop socket.h when socket-util.h is included
2019-11-04 00:30:32 +09:00
Yu Watanabe
f5947a5e92
tree-wide: drop missing.h
2019-10-31 17:57:03 +09:00
Yu Watanabe
b07571735a
sd-device-monitor: use SO_DETACH_FILTER to remove BPF program
...
Fixes #11529 .
2019-01-23 15:11:47 +09:00
Yu Watanabe
ee0b9e721a
sd-device-monitor: fix ordering of setting buffer size
...
By b1c097af8d
(#10239 ), the receive buffer
size for uevents was set by SO_RCVBUF at first, and fallback to
use SO_RCVBUFFORCE. So, as SO_RCVBUF limits to the buffer size
net.core.rmem_max, which is usually much smaller than 128MB udevd requests,
uevents buffer size was not sufficient.
This fixes the ordering of the request: SO_RCVBUFFORCE first, and
fallback to SO_RCVBUF. Then, udevd's uevent buffer size can be set to
128MB.
This also revert 903893237a
.
Fixes #11314 and #10754 .
2019-01-11 21:52:23 +01:00
Yu Watanabe
903893237a
sd-device: do not change buffer size if the socket is already bound
...
From the results of CIs in #11076 , changing buffer size may cause
issue #10754 . So, let's prohibit to change the size if it is already
bound.
This also reverts commit 986ab0d2dc
.
2018-12-14 09:33:06 +09:00
Yu Watanabe
c821e84ac7
sd-device: do not modify socket option(s) if socket is passed by PID1
...
If the socket fd is passed by PID1, then it is created by .socket unit
and we have already set sufficient option(s) for the socket.
So, let's not touch the passed socket.
2018-12-14 09:28:33 +09:00
Yu Watanabe
a153a1de75
Revert "sd-device: do not call device_monitor_enable_receiving() for passed fd from pid1"
...
This reverts commit 916707cca5
.
As the CI results on #11076 , #10754 is not fixed by the commit,
but by 986ab0d2dc
. So, let's revert the
commit.
2018-12-14 09:24:31 +09:00
Zbigniew Jędrzejewski-Szmek
049af8ad0c
Split out part of mount-util.c into mountpoint-util.c
...
The idea is that anything which is related to actually manipulating mounts is
in mount-util.c, but functions for mountpoint introspection are moved to the
new file. Anything which requires libmount must be in mount-util.c.
This was supposed to be a preparation for further changes, with no functional
difference, but it results in a significant change in linkage:
$ ldd build/libnss_*.so.2
(before)
build/libnss_myhostname.so.2:
linux-vdso.so.1 (0x00007fff77bf5000)
librt.so.1 => /lib64/librt.so.1 (0x00007f4bbb7b2000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007f4bbb755000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4bbb734000)
libc.so.6 => /lib64/libc.so.6 (0x00007f4bbb56e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4bbb8c1000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f4bbb51b000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f4bbb512000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4bbb4e3000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4bbb45e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f4bbb458000)
build/libnss_mymachines.so.2:
linux-vdso.so.1 (0x00007ffc19cc0000)
librt.so.1 => /lib64/librt.so.1 (0x00007fdecb74b000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fdecb744000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007fdecb6e7000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdecb6c6000)
libc.so.6 => /lib64/libc.so.6 (0x00007fdecb500000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdecb8a9000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fdecb4ad000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fdecb4a2000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fdecb475000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fdecb3f0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fdecb3ea000)
build/libnss_resolve.so.2:
linux-vdso.so.1 (0x00007ffe8ef8e000)
librt.so.1 => /lib64/librt.so.1 (0x00007fcf314bd000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fcf314b6000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007fcf31459000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcf31438000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcf31272000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcf31615000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fcf3121f000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fcf31214000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcf311e7000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fcf31162000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fcf3115c000)
build/libnss_systemd.so.2:
linux-vdso.so.1 (0x00007ffda6d17000)
librt.so.1 => /lib64/librt.so.1 (0x00007f610b83c000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f610b835000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007f610b7d8000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f610b7b7000)
libc.so.6 => /lib64/libc.so.6 (0x00007f610b5f1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f610b995000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f610b59e000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f610b593000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f610b566000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f610b4e1000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f610b4db000)
(after)
build/libnss_myhostname.so.2:
linux-vdso.so.1 (0x00007fff0b5e2000)
librt.so.1 => /lib64/librt.so.1 (0x00007fde0c328000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fde0c307000)
libc.so.6 => /lib64/libc.so.6 (0x00007fde0c141000)
/lib64/ld-linux-x86-64.so.2 (0x00007fde0c435000)
build/libnss_mymachines.so.2:
linux-vdso.so.1 (0x00007ffdc30a7000)
librt.so.1 => /lib64/librt.so.1 (0x00007f06ecabb000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f06ecab4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f06eca93000)
libc.so.6 => /lib64/libc.so.6 (0x00007f06ec8cd000)
/lib64/ld-linux-x86-64.so.2 (0x00007f06ecc15000)
build/libnss_resolve.so.2:
linux-vdso.so.1 (0x00007ffe95747000)
librt.so.1 => /lib64/librt.so.1 (0x00007fa56a80f000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fa56a808000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa56a7e7000)
libc.so.6 => /lib64/libc.so.6 (0x00007fa56a621000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa56a964000)
build/libnss_systemd.so.2:
linux-vdso.so.1 (0x00007ffe67b51000)
librt.so.1 => /lib64/librt.so.1 (0x00007ffb32113000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007ffb3210c000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffb320eb000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffb31f25000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffb3226a000)
I don't quite understand what is going on here, but let's not be too picky.
2018-11-29 21:03:44 +01:00
Lennart Poettering
cb3108669d
tree-wide: more IOVEC_MAKE() conversions
2018-11-28 13:08:19 +09:00
Yu Watanabe
916707cca5
sd-device: do not call device_monitor_enable_receiving() for passed fd from pid1
...
Before c4b69e990f
, if the socket fd is
passed from pid1, `udev_monitor_enable_receiving()` (now it is a wrapper
of `device_monitor_enable_receiving`) was not called.
Let's preserve the original logic.
Fixes #10754 .
2018-11-25 20:14:17 +09:00
Yu Watanabe
f1d7b7874e
sd-device: check whether filter is updated or not in sd_device_monitor_filter_update()
2018-11-25 15:26:43 +09:00
Yu Watanabe
5cee547a94
sd-device: update log message
2018-11-25 14:06:56 +09:00
Yu Watanabe
779c923467
sd-device: fix return value on error path
2018-11-25 14:06:27 +09:00
Yu Watanabe
65fe9c319f
sd-device-monitor: fix subsystem filter
...
This fixes a bug introduced by 759d9f3f8d
.
Fixes #10882 .
2018-11-23 02:49:28 +09:00
Zbigniew Jędrzejewski-Szmek
886cf317c4
coccinelle: also mark previous synthetic errnos as such
2018-11-22 10:54:38 +01:00
Yu Watanabe
deb2b7348e
sd-device: drop priority and description from sd_device_monitor_attach_event() and sd_device_monitor_start()
...
Now we have sd_device_monitor_get_event_soruce(). So, it is not
necessary to include these parameters in the functions for sd_device_monitor.
2018-11-10 22:53:00 +09:00
Yu Watanabe
bf7712b63e
sd-device: add sd_device_monitor_get_event_source()
2018-11-10 22:53:00 +09:00
Yu Watanabe
c7d54daef9
sd-device: normalize debug messages
2018-11-06 15:45:22 +09:00
Yu Watanabe
dcdc2f61b1
sd-device: fix wrong assertion ( #10530 )
2018-10-26 10:16:00 +09:00
Yu Watanabe
b6124e64a5
sd-device-monitor: use log_device_*()
2018-10-23 22:44:07 +09:00
Lennart Poettering
347a19343c
Merge pull request #10462 from yuwata/test-sd-device-monitor
...
Add tests for sd_device_monitor and small cleanups
2018-10-19 22:05:50 +02:00
Yu Watanabe
b58d4d2d4f
sd-device-monitor: include error cause in log message
2018-10-19 11:57:54 +09:00
Yu Watanabe
a537eafe1d
sd-device-monitor: drop unnecessary condition
2018-10-19 11:57:29 +09:00
Yu Watanabe
9e5b649655
tree-wide: use setsockopt_int() more
2018-10-19 05:52:42 +09:00
Lennart Poettering
2ff48e981e
tree-wide: introduce setsockopt_int() helper and make use of it everywhere
...
As suggested by @heftig:
6d5e65f645 (commitcomment-30938667)
2018-10-18 19:50:29 +02:00
Yu Watanabe
b1c097af8d
sd-device: introduce sd_device_monitor
2018-10-17 03:30:54 +09:00