summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* logd: add support for subscribing to the log objectHEADmasterFelix Fietkau2023-01-191-1/+4
| | | | | | Provides easier access to log messages Signed-off-by: Felix Fietkau <nbd@nbd.name>
* kmodloader: fix GCC fanalyzer warningsRosen Penev2022-08-131-0/+12
| | | | | | memory leaks and missing NULL checks. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* kmodloader: fix bad realloc usageRosen Penev2022-08-131-2/+4
| | | | | | | Both cppcheck and gcc's -fanalyzer complain here that realloc is being used improperly. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* kmodloader: fix compilation warning with not checking return of asprintfChristian Marangi2022-07-171-7/+15
| | | | | | | | | | | | | | | Fix the following compilation warning: kmodloader.c: In function 'main_loader': kmodloader.c:1027:41: error: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Werror=unused-result] make[1]: *** [package/Makefile:116: package/system/ubox/compile] Error 1 1027 | asprintf(&m->opts, "%s %s", prev, opts); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ While at it rework the function to not duplicate too much code with the error handling. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* kmodloader: support loading module options and blacklist from /etc/modules.confFelix Fietkau2022-01-061-6/+111
| | | | | | This has the same format as /etc/modules.d on a regular linux system Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logread: fix erroneous message "Logread connected to" with udpGiovanni Giacobbi2021-08-031-2/+8
| | | | | | | | | | | | | | | | | When streaming the syslog messages via udp, the socket connection always succeeds by definition, but it can still fail to send. In such case, the syslog keep repeating the following two messages: failed to send log data to ip:port via udp Logread connected to ip:port With this change, only one initial message "Logread connected to..." is logged. Also fixed capital letter for "failed to send" message. Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net> Signed-off-by: Daniel Golle <daniel@makrotopia.org> (string de-duplication)
* logd: fix privilege dropping orderGiovanni Giacobbi2021-08-031-4/+4
| | | | | Fixes: 41664054b8b1 ("logd: fix ignored return values in set{gid,uid}") Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
* logd: fix ignored return values in set{gid,uid}Petr Štetiar2021-03-221-2/+9
| | | | | | | | | | | | | | Ubuntu 18.05 with gcc-7.5 yields following error: ubox/log/logd.c:263:3: error: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Werror=unused-result] setuid(p->pw_uid); ^~~~~~~~~~~~~~~~~ ubox/log/logd.c:264:3: error: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Werror=unused-result] setgid(p->pw_gid); ^~~~~~~~~~~~~~~~~ Fixes: 9ef886819dd4 ("logd: self-degrade to 'logd' user after opening pipes") Signed-off-by: Petr Štetiar <ynezz@true.cz>
* logd: self-degrade to 'logd' user after opening pipesDaniel Golle2020-10-191-0/+8
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* kmodloader: added -a arg to modprobeGerard Ryan2019-12-311-30/+38
| | | | | | | | | | | -a treats all non-op trailing arguments as module names and attempts to load all of them. This behaviour mirrors the behaviour of the respective -a in /tools/modprobe.c from https://git.kernel.org. This is primarily to satiate the multiple modules passed by docker/libnetwork. Signed-off-by: Gerard Ryan <G.M0N3Y.2503@gmail.com>
* kmodloader: print an error when no kernel module dir can be foundPaul Fertser2019-12-281-1/+3
| | | | | | | | Do not just silently fail when kernel modules are nowhere to be found. This is essential for diagnosing mismatched kernel version failures. Signed-off-by: Paul Fertser <fercerpav@gmail.com>
* logread: add option to filter for facilitiesZefir Kurtisi2019-10-221-2/+27
| | | | | | | | | | | | This adds filtering options for facilities as follows: -z <facility> handle only messages with given facility (0-23), repeatable -Z <facility> ignore messages with given facility (0-23), repeatable With that * 'logread -z 2 -z 16' will display all MAIL and LOCAL0 messages, while * 'logread -Z 2 -Z 16' will display all but MAIL and LOCAL0 messages Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
* kmodloader: added -v arg to modeprobeGerard Ryan2019-10-211-2/+12
| | | | | | This is primarily to satiate the usage by docker/libnetwork. Signed-off-by: Gerard Ryan <G.M0N3Y.2503@gmail.com>
* kmodloader: Increase path array size to make it always fitHauke Mehrtens2019-06-161-1/+1
| | | | | | | | | | | | | When DEF_MOD_PATH (10 bytes), s (max 255 bytes) and ver.release (max 64 bytes) are all written into path, 256 bytes will not fit, increase the available size. All given sizes are given without terminating NULL byte and we add one byte to store the NULL byte. GCC 9.1 warns about this condition and we treat warnings as errors in ubox. Reported-by: Joseph Benden <joe@benden.us> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* kmodloader: fix and optimize loading of failed modulesPavel Merzlyakov2019-04-071-15/+24
| | | | | | | | | | | | | | | | | | | | | | | 1) Restore functionality which was lost in commit 876c7f5b. Again at boot time kmodloader can load all modules (/etc/modules.d/*) even if dependency information is completely missing. This functionality is important in case of hidden dependency (not symbol dependency). For example, in kernel 4.4.60 is hidden dependency between nf_nat_ipv6 and nf_conntrack_ipv6. We can't load nf_nat_ipv6 before nf_conntrack_ipv6 and modinfo do not show this dependency. Two sequential load attempts of nf_nat_ipv6 may not be enough (in my case it's definitely not enough). nf_nat_ipv4 has a similar problem. 2) Reduce count of attempts to load failed modules. Now kmodloader try to load failed modules after all others are loaded. main_loader: Count of failed and successful attempts to load nf_nat_ipv6.ko (kernel 4.4.60) depend on ubox version: COMMIT FAILED SUCCESSFUL TOTAL 128bc35f 53 1 54 876c7f5b 2 0 2 this 1 1 2 Signed-off-by: Pavel Merzlyakov <pavel.merzlyakov@gmail.com> Acked-by: Jo-Philipp Wich <jo@mein.io>
* kmodloader: increase module name lengthSergiy Kibrik2019-03-211-1/+3
| | | | | | Otherwise modules with long names, e.g. lttng (>32 chars) can't be loaded. Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>
* kmodloader: load_modprobe: abort after 2 attemptsStijn Tintel2018-12-181-2/+4
| | | | | | | | | | | | | | | | | | | | | The loop in load_modprobe causes dmesg to be flooded with errors when a module fails to load; e.g.: - gpio-nct5104d: Unsupported device 0xffff (246 times on x86 in Qemu) - jitterentropy: Initialization failed with host not compliant with requirements: 2 (229 times on brcm2708/bcm2708) On brcm2708/bcm2708 this also causes vmalloc allocation failures with kernel 4.14 when running headless. If kmod-drm-vc4 and kmod-video-bcm2835 are included in the image, they will be loaded before brcmfmac, and brcmfmac will fail to load: kmodloader: vmalloc: allocation failure: 249856 bytes, mode:0x14000c0(GFP_KERNEL), nodemask=(null) Break the loop after 2 failed attempts to fix these issues. Signed-off-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
* logread: fix reconnect logd logicJohn Crispin2018-02-141-7/+15
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* logrea: move the code setting up the request blob out of the main loopJohn Crispin2018-02-141-8/+9
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* logread: move output connection setup code out of main loopJohn Crispin2018-02-141-18/+25
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* logread: cleanup pid file handlingJohn Crispin2018-02-141-9/+11
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* ubox: Replace strerror(errno) with %m format.Rosen Penev2018-02-133-6/+6
| | | | | | Saves 872 bytes on Ubuntu 16.04. No change in functionality. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* ubox: Remove unnecessary memset calls.Rosen Penev2017-11-132-5/+2
| | | | | | Change to calloc instead. Less verbose. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* logd: move stripping of newlines to log_add()Felix Fietkau2017-11-061-11/+14
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logread: fix line buffer sizeFelix Fietkau2017-11-061-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logread: remove leftover debug codeFelix Fietkau2017-11-061-3/+1
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logd: enforce line length limit for ubus based log messages as wellFelix Fietkau2017-11-063-5/+13
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logread: use oneshot mode without -f, wait for logd to closeFelix Fietkau2017-11-061-2/+1
| | | | | | Fixes a race condition in dealing with larger amounts of log data Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logd: implement oneshot mode for stream log readFelix Fietkau2017-11-061-0/+18
| | | | | | | This will terminate the connection after all log messages have been sent. Useful for logread without follow Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logread: terminate after EOFFelix Fietkau2017-11-061-0/+6
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logd: only create pipe in stream modeFelix Fietkau2017-11-061-5/+5
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* logd: use uloop instead of ustream_fd for syslogFelix Fietkau2017-11-061-26/+35
| | | | | | | Using a stream buffer for a datagram socket makes no sense. This change fixes dealing with line buffer truncation on large incoming messages Signed-off-by: Felix Fietkau <nbd@nbd.name>
* log/syslog: Add missing static to two structs.Rosen Penev2017-11-061-2/+2
| | | | | | On x86, binary size goes down by 16 bytes. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* ubox: Replace { 0 } with {}.Rosen Penev2017-11-062-2/+2
| | | | | | The latter is more compatible with older GCC versions like 4.9. Additionally, initializing with { 0 } produces a warning that only the first field was initialized. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* kmodloader: log error message in case of out of memoryHans Dedecker2017-09-011-3/+10
| | | | | | Log "out of memory" error message in case of OOM Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* kmodloader: lift restriction on module alias infoHans Dedecker2017-08-311-10/+16
| | | | | | | | | | | kmodloader has a restriction of storing only 32 aliases for a given module; as modules can have easily more than 32 aliases let's remove the restriction by using a dynamic allocation mechanism when retrieving the aliases. While at it also check the get_module_info return value setting an error code in case NULL is returned. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* kmodloader: fix possible segfaultsHans Dedecker2017-08-311-0/+12
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* kmodloader: fix endianess checkHans Dedecker2017-08-301-2/+2
| | | | | | | | | | Use __BYTE_ORDER macro to check system endianess as the macro's __LITTLE_ENDIAN, __BIG_ENDIAN are defined irrespective of the sytem endianess leading to an endianess check failure on big endian systems. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Acked-by: John Crispin <john@phrozen.org>
* kmodloader: Check module endian before loadingFlorian Fainelli2017-07-021-0/+13
| | | | | | | | | | | | | | | | | If we manage to accidentally get a module installed that does not match the system endianess (there is currently nothing preventing that in OpenWrt/LEDE) we will hit a segmentation fault when doing this: sh = (Elf32_Shdr *) (map + e->e_shoff); because e->e_shoff will be wrongly encoded and this most likely will result in an invalid offset to de-reference from. Update elf_find_section() to check that the build time endianess of kmodloader matches that of the module, otherwise nothing would work really. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
* kmodloader/get_module_info: initialized aliases to make it more cleanAlexander Couzens2017-06-111-1/+1
| | | | | | | | Even when the callee looks onto the length is a good idea to zero the points. Found-by: Coverity Scan #1412541 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
* kmodloader: insmod: fix a memoryleak in error caseAlexander Couzens2017-06-111-4/+6
| | | | | Found-by: Coverity Scan #1412469 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
* kmodloader/get_module_name: null-terminate the stringAlexander Couzens2017-06-111-2/+2
| | | | | Found-by: Coverity Scan #1412291 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
* syslog: remove unnecessary sizeof struct between messagesDan Bugnar2017-03-101-1/+1
| | | | | | | The next message needs to be written after the data of current message. This was adding "sizeof(struct log_head)" bytes between messages. Signed-off-by: Dan Bugnar <danutbug@gmail.com>
* kmodloader: modprobe: return 0 for loaded modulesYousong Zhou2017-03-031-1/+1
| | | | | | | | | | | This is the default behaviour with modprobe from kmod package [1] unless it is explicitly told that the module is to be loaded for --first-time [1] http://www.kernel.org/pub/linux/utils/kernel/kmod/ Fixes FS#433 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* kmodloader: don't store aliases info in struct moduleYousong Zhou2017-02-231-28/+4
| | | | | | | | | | | | This also fixes FS#544 as the possible address alignment issue should now disappear function old new delta alloc_module 398 245 -153 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-153) Total: -153 bytes Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* cmake: fix typoFelix Fietkau2017-02-211-1/+1
| | | | | Fixes: fce9382b4b99 ("cmake: Check for getrandom system call") Signed-off-by: Felix Fietkau <nbd@nbd.name>
* kmodloader: fix not being able to find some modulesNathan Hintz2017-02-211-4/+7
| | | | | | | | | | kmodloader is using slightly different criteria for ordering the AVL tree versus what it uses to traverse it. This sometimes results in not being able to find some modules. Reference: https://bugs.lede-project.org/index.php?do=details&task_id=443 Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
* cmake: Check for getrandom system callFlorian Fainelli2017-02-091-4/+11
| | | | | | | In case we are building against a kernel that is too old and does not support SYS_getrandom, error out with a message indicating so. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
* kmodloader: support '-q' quiet optionKevin Darbyshire-Bryant2017-02-011-10/+29
| | | | | | | | | | The kernel opportunistically attempts to load modules in advanced with 'predicted' module names. Often these modules don't exist and hence kmodloader produces lots of logfile noise. The kernel commandline to modprobe from kworker proceses is '-q -- modulename' where '-q' means quiet. Support suppressing that noise. Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
* ubox: Add an option for more accurate timestamps in logWojciech Dubowik2017-02-012-4/+21
| | | | | | | Systemwide timestamps for syslog messages with ms accuracy are usefull for debugging timing problems. Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>