summaryrefslogtreecommitdiffstats
path: root/src/udev (follow)
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-142-2/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-1436-54/+54
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-1411-22/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* scsi_id: use _cleanup_free_ on buffer allocated by get_file_optionsFilipe Brandenburger2018-06-081-3/+2
| | | | | | | | | | This simplifies the code a bit and hopefully fixes Coverity finding CID 1382966. There was not actually a resource leak here (Coverity seemed to be confused by thinking log_oom() could actually return 0), but the fix doesn't hurt and should make this code more resilient to future refactorings. Tested: builds fine, manually called scsi_id, seems to work ok.
* udev-builtin-usb_id: Check full range of size returned by read()Filipe Brandenburger2018-06-081-1/+1
| | | | | | | | | | | | | | | This shouldn't be necessary, since read() should never return a size larger than the size of the buffer passed in, but Coverity doesn't seem to understand that. We could possibly fix this with a model file for Coverity, but given changing the code is not that much of a biggie, let's just do that instead. Fixes CID 996458: Overflowed or truncated value (or a value computed from an overflowed or truncated value) `pos` used as array index. Tested: `ninja -C build/ test`, builds without warnings, test cases pass.
* Add macro for checking if some flags are setZbigniew Jędrzejewski-Szmek2018-06-041-1/+1
| | | | | | | | | This way we don't need to repeat the argument twice. I didn't replace all instances. I think it's better to leave out: - asserts - comparisons like x & y == x, which are mathematically equivalent, but here we aren't checking if flags are set, but if the argument fits in the flags.
* mtd: some basic code cleanupsLennart Poettering2018-05-103-33/+40
| | | | | | | | | | | | | | | | | | | While looking at our exit() invocations I noticed that the mtd_probe stuff uses 'exit(-1)' at various places, which is not really a good idea, as exit codes of processes on Linux are supposed to be in the range of 0…255. This patch cleans that up a bit, and fixes a number of other things: 1. Let's always let main() exit, nothing intermediary. We generally don't like code that invokes exit() on its own. 2. Close the file descriptors opened. 3. Some logging for errors is added, mostly on debug level. Please review this with extra care. As I don't have the right hardware to test this patch I only did superficial testing.
* udevadm: fix null dererefence on allocation errorZbigniew Jędrzejewski-Szmek2018-05-101-1/+2
| | | | CID #1390936.
* Merge pull request #8689 from davide125/staticZbigniew Jędrzejewski-Szmek2018-05-101-1/+18
|\ | | | | meson: add support for building static libsystemd and libudev
| * meson: recompile all sources for install_libudev_static and ↵Zbigniew Jędrzejewski-Szmek2018-05-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | install_libsystemd_static This means that when those targets are built, all the sources are built again, instead of reusing the work done to create libbasic.a and other convenience static libraries. It would be nice to not do this, but there seems to be no support in our toolchain for joining multiple static libraries into one. When linking a static library, any -l arguments are simply ignored by ar/gcc-ar, and .a libraries given as positional arguments are copied verbatim into the archive so they objects in them cannot be accessed. https://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries suggests either unzipping all the archives and putting them back togather, or using a linker script. Unzipping and zipping back together seems ugly. The other option is not very nice. The linker script language does not allow "+" to appear in the filenames, and filenames that meson generates use that, so files would have to be renamed before a linker script was used. And we would have to generate the linker script on the fly. Either way, this doesn't seem attractive. Since those static libraries are a niche use case, it seems reasonable to just go with the easiest and safest solution and recompile all the source files. Thanks to ccache, this is probably almost as cheap as actually reusing the convenience .a libraries. test-libsystemd-sym.c and test-libudev-sym.c compile fine with the generated static libs, so it seems that they indeed provide all the symbols they should.
| * meson: only build test-lib{systemd,udev}-static-sym for picDavide Cavalca2018-05-081-1/+3
| |
| * meson: add support for building static libsystemd and libudevDavide Cavalca2018-05-081-1/+16
| |
* | network,udev: sort included headersYu Watanabe2018-05-091-2/+2
| |
* | network,udev: make MACAddress= in [Match] section take multiple MAC addressesYu Watanabe2018-05-093-3/+4
| |
* | link: Add support to configure channels of the specified network device (#8882)Susant Sahani2018-05-085-0/+127
| | | | | | closes #8856
* | ethtool: get_glinksettings Fix copy (#8889)Susant Sahani2018-05-031-1/+1
| | | | | | It should be other way around.
* | udev: do not mark ari_enabled true when its sysattr value is 0 (#8870)Yu Watanabe2018-05-021-1/+1
| | | | | | Fixes #8869.
* | link: follow our rule of suffix settings with = in log messagesLennart Poettering2018-04-261-1/+1
| |
* | networkd,udev: clean up MTU handlingLennart Poettering2018-04-263-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This cleans up handling of MTU values across the codebase. Previously MTU values where stored sometimes in uint32_t, sometimes in uint16_t, sometimes unsigned and sometimes in size_t. This now unifies this to uint32_t across the codebase, as that's what netlink spits out, and what the majority was already using. Also, all MTU parameters are now parsed with config_parse_mtu() and config_parse_ipv6_mtu() is dropped as it is now unneeded. (Note there is one exception for the MTU typing: in the DCHPv4 code we continue to process the MTU as uint16_t value, as it is encoded like that in the protocol, and it's probably better stay close to the protocol there.)
* | tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-2512-41/+39
|/ | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* udevadm/hwdb: Return non-zero exit code on error when --strict is usedNicolas Boichat2018-04-231-5/+20
| | | | | | | - Add a new flag --strict to tell udevadm hwdb to return a non-zero code on error. - Make udevadm hwdb --update return an error when any parsing error occurs (only if strict flag is set).
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-04-193-4/+0
| | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* Merge pull request #8676 from keszybz/drop-license-boilerplateLennart Poettering2018-04-1012-156/+0
|\ | | | | Drop license boilerplate
| * tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-0612-156/+0
| | | | | | | | | | | | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* | systemd-udevd: limit children-max by available memory (#8668)Martin Wilck2018-04-071-0/+4
|/ | | | | | | | | | Udev workers consume typically 50-100MiB virtual memory. On systems with lots of CPUs and relatively low memory, that may easily cause workers to be OOM-killed. This patch limits the number of workers to 8 per GiB memory. But don't let the limit drop below the smallest value we had without this patch (8 + 1 * 2 = 10); on small systems, udev's memory footprint is likely lower.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-052-6/+3
|
* Merge pull request #8140 from stuarthayes/newLennart Poettering2018-03-281-23/+129
|\ | | | | udev: network device naming improvements (sr-iov, npar, slots)
| * udev: net_id: Improve predictable names for NPAR devicesStuart Hayes2018-03-261-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NPAR is a technology that allows a single network interface to be divided into number of partitions. The partitions show up as functions on the same PCI device... when there are more than 8 functions, ARI (alternative routing-ID interpretation) is used. With ARI is enabled, the 8 bit field that normally has 5 bits for the PCI device and 3 bits for the PCI function is instead interpreted as (implicit) device 0, with 8 bits for the function number. Because the linux kernel exposes the PCI device/function numbers to userspace the same regardless of whether ARI is enabled, systemd predictable device naming can generate unpredictable names in this case, because network names using the PCI slot use the function number, but not the device number, causing systemd to generate the same name for mulitple network devices (so some will revert to the "ethX" names). With this patch, device naming code checks if ARI is enabled for a PCI network device, and uses the full 8-bit function number for naming to avoid this situation. This should improve readability and predictability of device names. Here is an example of how this change would affect naming: before patch | after patch ----------------------------- ens2f0 | ens2f0 NPAR partition 0 (in PCI slot 2) ens2f1 | ens2f1 NPAR partition 1 ... ens2f7 | ens2f7 NPAR partition 7 eth1 | ens2f8 NPAR partition 8 eth2 | ens2f9 NPAR partition 9
| * udev: net_id: Improve predictable names for SR-IOV virtual devicesStuart Hayes2018-03-261-2/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With PCI SR-IOV, a number of virtual network devices can be enabled, all of which share the same physical network device. Currently, udev generates names for SR-IOV virtual functions as if they were independent network devices. With this change, the predictable network device naming code will check if a network device is an SR-IOV virtual device, and will generate a name based on the physical PCI device plus a "v%u" suffix. This should improve readability and predictability of device names. Here is an example of how this change would affect naming: before patch | after patch ----------------------------- eno1 | eno1 onboard NIC, physical function enp101s0f0 | eno1v0 onboard NIC, SR-IOV virtual func 0 enp101s0f1 | eno1v1 onboard NIC, SR-IOV virtual func 1
| * udev: net_id: search parent devices for PCI slot numberStuart Hayes2018-03-261-21/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | To generate predictable network device names, the code in udev-builting-net_id.c tries to match the PCI device address of the network device to the entries in /sys/bus/pci/slots. However, sometimes the slot number is not associated the network controller PCI device itself, but rather with one of its parents. This change will try to find a match in /sys/bus/pci/slots for the parents of the PCI network device, if it doesn't find a match for the device itself.
* | Merge pull request #8576 from keszybz/oss-fuzzEvgeny Vereshchagin2018-03-271-1/+3
|\ \ | | | | | | oss-fuzz adjustments and other cleanups
| * | tree-wide: add bsearch_safe and use where appropriateZbigniew Jędrzejewski-Szmek2018-03-261-1/+3
| |/ | | | | | | Should fix #8557.
* / label: rework label_fix() implementations (#8583)Lennart Poettering2018-03-272-3/+3
|/ | | | | | | | | | | | | | | | | | | | This reworks the SELinux and SMACK label fixing calls in a number of ways: 1. The two separate boolean arguments of these functions are converted into a flags type LabelFixFlags. 2. The operations are now implemented based on O_PATH. This should resolve TTOCTTOU races between determining the label for the file system object and applying it, as it it allows to pin the object while we are operating on it. 3. When changing a label fails we'll query the label previously set, and if matches what we want to set anyway we'll suppress the error. Also, all calls to label_fix() are now (void)ified, when we ignore the return values. Fixes: #8566
* tree-wide: tabs suck (#8527)Lennart Poettering2018-03-232-3/+3
|
* udev: don't label high-button mice as joysticks (#8493)Peter Hutterer2018-03-231-7/+15
| | | | | | | If a device exposes more than 16 mouse buttons, we run into the BTN_JOYSTICK range, also labelling it as joystick. And since 774ff9b this results in only ID_INPUT_JOYSTICK but no ID_INPUT_MOUSE. Fixes #8460
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-223-8/+4
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* Merge pull request #8508 from poettering/more-cocciZbigniew Jędrzejewski-Szmek2018-03-211-4/+3
|\ | | | | two new coccinelle rules files and their results
| * coccinelle: make use of DIV_ROUND_UP() wherever appropriateLennart Poettering2018-03-201-4/+3
| | | | | | | | Let's use our macros where we can
* | v3: Properly parsing SCSI Hyperv devices (#8509)Long Li2018-03-211-5/+8
|/ | | | | | | Since 2016, Hyperv devices moved to using standard way to expose UUID to sysfs. Fix the parsing function to work with the newer format. Change log: v2: changed code to work with both old and new path format v3: changed guid_str_len type to size_t, fixed length in char guid[] in handle_scsi_hyperv()
* v4l_id: check mplane video capture and output capailities (#8464)Jui-Chi Ricky Liang2018-03-201-2/+4
| | | | | Video devices using mplane buffer API declare capture and output capabilities with V4L2_CAP_VIDEO_CAPTURE_MPLANE and V4L2_CAP_VIDEO_OUTPUT_MPLANE.
* systemd-link: Remove UDP Fragmentation Offload support. (#8183)Rosen Penev2018-03-183-3/+1
| | | | | | | | Support was killed in kernel 4.15 as well as ethtool 4.13. Justification was lack of use by drivers and too much of a maintenance burden. https://www.spinics.net/lists/netdev/msg443815.html Also moved config_parse_warn_compat to conf-parser.[ch] to fix compile errors.
* udev: use startswith() instead of the combination of strneq() and strlen() ↵Yu Watanabe2018-03-161-3/+2
| | | | (#8459)
* udev/net-id: Fix check for address to keep interface names stable (#8458)Filipe Brandenburger2018-03-151-1/+1
| | | | | | | | | | | | | This was a bug inadvertently added by commit 73fc96c8ac0aa9. The intent of the check is to "match slot address with device by stripping the function" (as the comment above states it), for example match network device PCI address 0000:05:00.0 (including a .0 for function) to PCI slot address 0000:05:00, but changing that to a streq() call prevented the match. Change that to startswith(), which should both fix the bug and make the intent of the check more clear and prevent unintentional bugs from being introduced by future refactorings.
* basic/macros: rename noreturn into _noreturn_ (#8456)Franck Bui2018-03-151-1/+1
| | | | | | | | | | | | "noreturn" is reserved and can be used in other header files we include: [ 16s] In file included from /usr/include/gcrypt.h:30:0, [ 16s] from ../src/journal/journal-file.h:26, [ 16s] from ../src/journal/journal-vacuum.c:31: [ 16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token [ 16s] void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); Here we include grcrypt.h (which in turns include gpg-error.h) *after* we "noreturn" was defined in macro.h.
* coccinelle: similar to reallocarray() let's also systematically use ↵Lennart Poettering2018-03-021-1/+1
| | | | malloc_multiply()
* coccinelle: add reallocarray() coccinelle scriptLennart Poettering2018-03-022-5/+5
| | | | | Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
* udevadm: prevent segfault in blkid builtin when offset not specifiedDouglas Christman2018-03-011-3/+10
| | | | | | | | | | "--offset" takes an optional argument; if none is specified, stroull() will attempt to parse a NULL pointer. For example: $ udevadm test-builtin 'blkid --offset' /sys/dev/block/8:1 Update "--offset" to require an argument; also verify that the offset is not negative.
* Add note to udev.conf that changes to that file require a rebuild of the ↵Michael Biebl2018-02-271-0/+3
| | | | | | initramfs Based on debian/patches/udev_conf_comments from the old udev package.
* Merge pull request #8258 from keszybz/log-issuesLennart Poettering2018-02-232-51/+47
|\ | | | | Fix some logging issues
| * udev/net-id: check all snprintf return valuesZbigniew Jędrzejewski-Szmek2018-02-231-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc-8 throws an error if it knows snprintf might truncate output and the return value is ignored: ../src/udev/udev-builtin-net_id.c: In function 'dev_pci_slot': ../src/udev/udev-builtin-net_id.c:297:47: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] snprintf(str, sizeof str, "%s/%s/address", slots, dent->d_name); ^~ ../src/udev/udev-builtin-net_id.c:297:17: note: 'snprintf' output between 10 and 4360 bytes into a destination of size 4096 snprintf(str, sizeof str, "%s/%s/address", slots, dent->d_name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors Let's check all return values. This actually makes the code better, because there's no point in trying to open a file when the name has been truncated, etc.