oweals/ubox.git
5 years agokmodloader: added -v arg to modeprobe
Gerard Ryan [Sun, 20 Oct 2019 06:01:11 +0000 (16:01 +1000)]
kmodloader: added -v arg to modeprobe

This is primarily to satiate the usage by docker/libnetwork.

Signed-off-by: Gerard Ryan <G.M0N3Y.2503@gmail.com>
5 years agokmodloader: Increase path array size to make it always fit
Hauke Mehrtens [Sat, 15 Jun 2019 21:49:28 +0000 (23:49 +0200)]
kmodloader: Increase path array size to make it always fit

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>
5 years agokmodloader: fix and optimize loading of failed modules
Pavel Merzlyakov [Mon, 18 Mar 2019 10:53:01 +0000 (12:53 +0200)]
kmodloader: fix and optimize loading of failed modules

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>
5 years agokmodloader: increase module name length
Sergiy Kibrik [Fri, 22 Feb 2019 06:57:52 +0000 (06:57 +0000)]
kmodloader: increase module name length

Otherwise modules with long names, e.g. lttng (>32 chars) can't be loaded.

Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>
5 years agokmodloader: load_modprobe: abort after 2 attempts
Stijn Tintel [Tue, 18 Dec 2018 19:24:28 +0000 (21:24 +0200)]
kmodloader: load_modprobe: abort after 2 attempts

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>
6 years agologread: fix reconnect logd logic
John Crispin [Wed, 14 Feb 2018 08:08:54 +0000 (09:08 +0100)]
logread: fix reconnect logd logic

Signed-off-by: John Crispin <john@phrozen.org>
6 years agologrea: move the code setting up the request blob out of the main loop
John Crispin [Wed, 14 Feb 2018 07:47:03 +0000 (08:47 +0100)]
logrea: move the code setting up the request blob out of the main loop

Signed-off-by: John Crispin <john@phrozen.org>
6 years agologread: move output connection setup code out of main loop
John Crispin [Wed, 14 Feb 2018 07:44:27 +0000 (08:44 +0100)]
logread: move output connection setup code out of main loop

Signed-off-by: John Crispin <john@phrozen.org>
6 years agologread: cleanup pid file handling
John Crispin [Wed, 14 Feb 2018 07:40:13 +0000 (08:40 +0100)]
logread: cleanup pid file handling

Signed-off-by: John Crispin <john@phrozen.org>
6 years agoubox: Replace strerror(errno) with %m format.
Rosen Penev [Sat, 13 Jan 2018 20:46:04 +0000 (12:46 -0800)]
ubox: Replace strerror(errno) with %m format.

Saves 872 bytes on Ubuntu 16.04. No change in functionality.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years agoubox: Remove unnecessary memset calls.
Rosen Penev [Tue, 7 Nov 2017 20:22:09 +0000 (12:22 -0800)]
ubox: Remove unnecessary memset calls.

Change to calloc instead. Less verbose.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years agologd: move stripping of newlines to log_add()
Felix Fietkau [Mon, 6 Nov 2017 10:48:52 +0000 (11:48 +0100)]
logd: move stripping of newlines to log_add()

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologread: fix line buffer size
Felix Fietkau [Mon, 6 Nov 2017 10:47:57 +0000 (11:47 +0100)]
logread: fix line buffer size

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologread: remove leftover debug code
Felix Fietkau [Mon, 6 Nov 2017 10:46:24 +0000 (11:46 +0100)]
logread: remove leftover debug code

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologd: enforce line length limit for ubus based log messages as well
Felix Fietkau [Mon, 6 Nov 2017 10:34:31 +0000 (11:34 +0100)]
logd: enforce line length limit for ubus based log messages as well

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologread: use oneshot mode without -f, wait for logd to close
Felix Fietkau [Mon, 6 Nov 2017 10:28:33 +0000 (11:28 +0100)]
logread: use oneshot mode without -f, wait for logd to close

Fixes a race condition in dealing with larger amounts of log data

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologd: implement oneshot mode for stream log read
Felix Fietkau [Mon, 6 Nov 2017 10:27:46 +0000 (11:27 +0100)]
logd: implement oneshot mode for stream log read

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>
7 years agologread: terminate after EOF
Felix Fietkau [Mon, 6 Nov 2017 10:15:39 +0000 (11:15 +0100)]
logread: terminate after EOF

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologd: only create pipe in stream mode
Felix Fietkau [Mon, 6 Nov 2017 10:11:49 +0000 (11:11 +0100)]
logd: only create pipe in stream mode

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agologd: use uloop instead of ustream_fd for syslog
Felix Fietkau [Mon, 6 Nov 2017 09:46:38 +0000 (10:46 +0100)]
logd: use uloop instead of ustream_fd for syslog

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>
7 years agolog/syslog: Add missing static to two structs.
Rosen Penev [Mon, 30 Oct 2017 19:05:30 +0000 (12:05 -0700)]
log/syslog: Add missing static to two structs.

On x86, binary size goes down by 16 bytes.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years agoubox: Replace { 0 } with {}.
Rosen Penev [Mon, 30 Oct 2017 19:05:31 +0000 (12:05 -0700)]
ubox: Replace { 0 } with {}.

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>
7 years agokmodloader: log error message in case of out of memory
Hans Dedecker [Thu, 31 Aug 2017 12:08:11 +0000 (14:08 +0200)]
kmodloader: log error message in case of out of memory

Log "out of memory" error message in case of OOM

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
7 years agokmodloader: lift restriction on module alias info
Hans Dedecker [Wed, 30 Aug 2017 11:32:43 +0000 (13:32 +0200)]
kmodloader: lift restriction on module alias info

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>
7 years agokmodloader: fix possible segfaults
Hans Dedecker [Wed, 30 Aug 2017 13:09:49 +0000 (15:09 +0200)]
kmodloader: fix possible segfaults

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
7 years agokmodloader: fix endianess check
Hans Dedecker [Wed, 30 Aug 2017 13:23:58 +0000 (15:23 +0200)]
kmodloader: fix endianess check

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>
7 years agokmodloader: Check module endian before loading
Florian Fainelli [Fri, 30 Jun 2017 23:34:22 +0000 (16:34 -0700)]
kmodloader: Check module endian before loading

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>
7 years agokmodloader/get_module_info: initialized aliases to make it more clean
Alexander Couzens [Sun, 11 Jun 2017 10:33:34 +0000 (12:33 +0200)]
kmodloader/get_module_info: initialized aliases to make it more clean

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>
7 years agokmodloader: insmod: fix a memoryleak in error case
Alexander Couzens [Sun, 11 Jun 2017 10:20:59 +0000 (12:20 +0200)]
kmodloader: insmod: fix a memoryleak in error case

Found-by: Coverity Scan #1412469
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
7 years agokmodloader/get_module_name: null-terminate the string
Alexander Couzens [Sun, 11 Jun 2017 10:13:05 +0000 (12:13 +0200)]
kmodloader/get_module_name: null-terminate the string

Found-by: Coverity Scan #1412291
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
7 years agosyslog: remove unnecessary sizeof struct between messages
Dan Bugnar [Fri, 10 Mar 2017 10:06:29 +0000 (12:06 +0200)]
syslog: remove unnecessary sizeof struct between messages

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>
7 years agokmodloader: modprobe: return 0 for loaded modules
Yousong Zhou [Fri, 3 Mar 2017 02:32:48 +0000 (10:32 +0800)]
kmodloader: modprobe: return 0 for loaded modules

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>
7 years agokmodloader: don't store aliases info in struct module
Yousong Zhou [Thu, 23 Feb 2017 03:04:50 +0000 (11:04 +0800)]
kmodloader: don't store aliases info in struct module

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>
7 years agocmake: fix typo
Felix Fietkau [Tue, 21 Feb 2017 13:11:03 +0000 (14:11 +0100)]
cmake: fix typo

Fixes: fce9382b4b99 ("cmake: Check for getrandom system call")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years agokmodloader: fix not being able to find some modules
Nathan Hintz [Tue, 21 Feb 2017 05:14:24 +0000 (05:14 +0000)]
kmodloader: fix not being able to find some modules

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>
7 years agocmake: Check for getrandom system call
Florian Fainelli [Sun, 5 Feb 2017 02:41:34 +0000 (18:41 -0800)]
cmake: Check for getrandom system call

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>
7 years agokmodloader: support '-q' quiet option
Kevin Darbyshire-Bryant [Sun, 29 Jan 2017 09:23:15 +0000 (09:23 +0000)]
kmodloader: support '-q' quiet option

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>
7 years agoubox: Add an option for more accurate timestamps in log
Wojciech Dubowik [Mon, 23 Jan 2017 10:30:14 +0000 (11:30 +0100)]
ubox: Add an option for more accurate timestamps in log

Systemwide timestamps for syslog messages with ms accuracy are usefull
for debugging timing problems.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
7 years agokmodloader: make insert_module() idempotent
Yousong Zhou [Fri, 13 Jan 2017 17:00:35 +0000 (01:00 +0800)]
kmodloader: make insert_module() idempotent

To fix spurious error messages in the following situation

 1. scan loaded modules
 2. load wireguard.ko and the module itself will request xt_hashlimit to
    be loaded
 3. xt_hashlimit is still in PROBE state here so we also try to load it,
    but init_module() returns EEXIST

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agokmodloader: add module alias awareness
Yousong Zhou [Fri, 13 Jan 2017 17:00:34 +0000 (01:00 +0800)]
kmodloader: add module alias awareness

To achieve this, the following changes are made

 - scan module folders before scaning loaded modules
 - struct module was splited into struct module_node for the avl tree
   and struct module for storing actual info about modules

The other minor fix is that module.opts is now freed in free_modules()
when appliable

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agokmodloader: fix out-of-bound access when parsing .modinfo
Yousong Zhou [Fri, 13 Jan 2017 17:00:33 +0000 (01:00 +0800)]
kmodloader: fix out-of-bound access when parsing .modinfo

Fixes output of "modinfo nf_conntrack_ipv4"

    module:         /lib/modules/4.4.40/nf_conntrack_ipv4.ko
    license:        GPL
    alias:          ip_conntrack
    alias:          nf_conntrack-2
    depends:        nf_conntrack,nf_defrag_ipv4
    src:            %pI4 dst=%pI4

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agokmodloader: modprobe: skip possible command line arguments
Yousong Zhou [Fri, 13 Jan 2017 17:00:32 +0000 (01:00 +0800)]
kmodloader: modprobe: skip possible command line arguments

The kernel may invocate user mode modprobe with the following scheme

    modprobe -q -- <module_name>

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agokmodloader: log to kmsg when loading directories of modules
Yousong Zhou [Fri, 13 Jan 2017 17:00:31 +0000 (01:00 +0800)]
kmodloader: log to kmsg when loading directories of modules

syslog may not be ready yet before PREINIT

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agokmodloader: remove redundant glob wildcard char
Yousong Zhou [Fri, 13 Jan 2017 17:00:30 +0000 (01:00 +0800)]
kmodloader: remove redundant glob wildcard char

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agoubox: Initialize conditionally uninitialized variabled
Rosen Penev [Sun, 18 Dec 2016 00:48:47 +0000 (16:48 -0800)]
ubox: Initialize conditionally uninitialized variabled

fixes false positive warning from "-Wconditional-uninitialized in clang"

Signed-off by: Rosen Penev <rosenp@gmail.com>

7 years agoubox: Fix some memory leaks
Rosen Penev [Sun, 18 Dec 2016 01:12:28 +0000 (17:12 -0800)]
ubox: Fix some memory leaks

Avoids leaking memory when exiting early.

Signed-off by: Rosen <rosenp@gmail.com>

7 years agokmodloader: Fix typo in error message
Florian Fainelli [Sun, 4 Dec 2016 02:09:39 +0000 (18:09 -0800)]
kmodloader: Fix typo in error message

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
8 years agologd: put non-streamed log entries into one result message
Felix Fietkau [Mon, 26 Sep 2016 14:28:52 +0000 (16:28 +0200)]
logd: put non-streamed log entries into one result message

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agoubox/logd: free ubus context on exit
Alexandru Ardelean [Sat, 24 Sep 2016 08:03:13 +0000 (11:03 +0300)]
ubox/logd: free ubus context on exit

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years agoubox/logd: free regex's on log_shutdown() call
Alexandru Ardelean [Sat, 24 Sep 2016 08:03:12 +0000 (11:03 +0300)]
ubox/logd: free regex's on log_shutdown() call

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
8 years agologd: fix default initialization of line count
Felix Fietkau [Thu, 22 Sep 2016 18:20:29 +0000 (20:20 +0200)]
logd: fix default initialization of line count

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agologd: add support for sending log messages as replies
Felix Fietkau [Thu, 22 Sep 2016 14:55:28 +0000 (16:55 +0200)]
logd: add support for sending log messages as replies

Useful for JSON-RPC access via uhttpd

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agoadd getrandom to .gitignore
Felix Fietkau [Thu, 22 Sep 2016 14:39:49 +0000 (16:39 +0200)]
add getrandom to .gitignore

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agogetrandom: fix indentation, add missing return statement
Felix Fietkau [Fri, 5 Aug 2016 11:08:53 +0000 (13:08 +0200)]
getrandom: fix indentation, add missing return statement

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agofix segfault in kmodloader when no modules path was present
John Crispin [Wed, 17 Aug 2016 02:32:43 +0000 (04:32 +0200)]
fix segfault in kmodloader when no modules path was present

Signed-off-by: John Crispin <john@phrozen.org>
8 years agovalidate: fix datatype handling of default values
Jo-Philipp Wich [Sat, 16 Jul 2016 12:52:36 +0000 (14:52 +0200)]
validate: fix datatype handling of default values

Properly handle the datatype of default values when the corresponding uci
value is unset. Also consolidate the three default value code branches into
a single one.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years agokmodloader: fix lsmod depends output
Hauke Mehrtens [Wed, 13 Jul 2016 14:55:20 +0000 (16:55 +0200)]
kmodloader: fix lsmod depends output

Without this patch only the first dependency is shown, with this patch
all module dependencies are show.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
8 years agocmake: Find uci header file
Florian Fainelli [Fri, 1 Jul 2016 23:05:23 +0000 (16:05 -0700)]
cmake: Find uci header file

Add a CMake FIND_PATH and INCLUDE_DIRECTORIES searching for uci.h. Some
external toolchains which do not include standard locations would fail
to find the header otherwise.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
8 years agogetrandom: add helper for getrandom() syscall
Etienne CHAMPETIER [Thu, 9 Jun 2016 13:03:00 +0000 (13:03 +0000)]
getrandom: add helper for getrandom() syscall

getrandom() was introduced in version 3.17 of the Linux kernel.
By default getrandom() block until /dev/urandom pool has been initialized
and then read from it.
Read buffer is 256 bytes so getrandom() calls always succeed.

First usage will be to save a seed for /dev/urandom.

Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
8 years agokmodloader: fix NULL pointer deref in case m->depends is missing
Felix Fietkau [Mon, 7 Mar 2016 16:34:31 +0000 (17:34 +0100)]
kmodloader: fix NULL pointer deref in case m->depends is missing

Observed on an invalid module

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agokmodloader: clean up memory mapping and fix fd leaks in error handling
Jo-Philipp Wich [Tue, 9 Feb 2016 12:49:55 +0000 (13:49 +0100)]
kmodloader: clean up memory mapping and fix fd leaks in error handling

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
8 years agokmodloader: fix open() error handling
Jo-Philipp Wich [Tue, 9 Feb 2016 07:53:28 +0000 (08:53 +0100)]
kmodloader: fix open() error handling

Fixes kmodloader on systems without stdio and prevents fd leaks in case
descriptor zero is opened.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
8 years agologread: ensure that the len < sizeof(struct blob_attr) check runs before trying...
Felix Fietkau [Sun, 24 Jan 2016 08:19:53 +0000 (09:19 +0100)]
logread: ensure that the len < sizeof(struct blob_attr) check runs before trying to access the data

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agofix gcc format security error
Hauke Mehrtens [Sun, 22 Nov 2015 14:45:27 +0000 (15:45 +0100)]
fix gcc format security error

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
9 years agolog: allow filtering messages with a regexp pattern
Rafał Miłecki [Tue, 14 Jul 2015 06:43:55 +0000 (08:43 +0200)]
log: allow filtering messages with a regexp pattern

This allows printing/streaming/writing messages matching a specified
basic regular expression only.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agologd: optimize notify function
Luka Perkov [Tue, 21 Apr 2015 17:04:46 +0000 (19:04 +0200)]
logd: optimize notify function

No need to construct every time the same blob_buf for each client in the list.

Signed-off-by: Luka Perkov <luka@openwrt.org>
9 years agolog: make valgrind less complain by freeing allocated memory
Luka Perkov [Tue, 21 Apr 2015 17:04:45 +0000 (19:04 +0200)]
log: make valgrind less complain by freeing allocated memory

Signed-off-by: Luka Perkov <luka@openwrt.org>
9 years agolog: fix whitespaces
Luka Perkov [Tue, 21 Apr 2015 17:04:44 +0000 (19:04 +0200)]
log: fix whitespaces

Signed-off-by: Luka Perkov <luka@openwrt.org>
9 years agolog: remove unused callbacks
Luka Perkov [Tue, 21 Apr 2015 17:04:43 +0000 (19:04 +0200)]
log: remove unused callbacks

Signed-off-by: Luka Perkov <luka@openwrt.org>
9 years agologread: add support for non-transparent-framing for Syslog over TCP
Etienne CHAMPETIER [Wed, 1 Apr 2015 23:14:01 +0000 (01:14 +0200)]
logread: add support for non-transparent-framing for Syslog over TCP

https://tools.ietf.org/html/rfc6587#section-3.4.2
the idea is to add \n or \0 as message trailer so it's easier
to find message end

v2: simplify, use \n by default, with optional \0

Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
9 years agoproperly handle return codes
John Crispin [Sat, 28 Mar 2015 14:38:09 +0000 (15:38 +0100)]
properly handle return codes

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoproperly handle return code of pipe() syscall
John Crispin [Sat, 28 Mar 2015 06:59:38 +0000 (07:59 +0100)]
properly handle return code of pipe() syscall

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agosyslog: use appropriate levels for logging
Christian Mehlis [Thu, 26 Mar 2015 13:51:21 +0000 (14:51 +0100)]
syslog: use appropriate levels for logging

Signed-off-by: Christian Mehlis <christian@m3hlis.de>
9 years agokmodloader: initialize module folders in insmod
Jo-Philipp Wich [Thu, 26 Feb 2015 21:17:31 +0000 (22:17 +0100)]
kmodloader: initialize module folders in insmod

Fixes a segmentation fault in 'insmod' operation mode, due to uninitialized
path list.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agokmodloader: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:48:05 +0000 (21:48 +0100)]
kmodloader: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agokmodloader: search kmods relative to LD_LIBRARY_PATH
Jo-Philipp Wich [Tue, 24 Feb 2015 22:55:09 +0000 (23:55 +0100)]
kmodloader: search kmods relative to LD_LIBRARY_PATH

When LD_LIBRARY_PATH is set, then scan for kmods in each directory pointed to
by it. This is mainly useful for early boot invocations of kmodloader, e.g.
during the extroot setup phase.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agohw_detect replaces this old code
John Crispin [Fri, 3 Oct 2014 15:54:19 +0000 (17:54 +0200)]
hw_detect replaces this old code

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoUse different loglevels
Michel Stam [Thu, 2 Oct 2014 11:42:45 +0000 (11:42 +0000)]
Use different loglevels

Ubox logs various messages during OpenWRT boot which are not
very interesting, such as the number of iterations made. This
fix implements several loglevels for debug/info/error so that
more useful messages are shown.

Signed-off-by: Michel Stam <m.stam@fugro.nl>
10 years agoRFC 3164 compliant remote logging
John Crispin [Tue, 16 Sep 2014 12:20:30 +0000 (14:20 +0200)]
RFC 3164 compliant remote logging

When logread daemon send a syslog message to another host, time, severity and facility are cut off.

The message contains only text. This patch adds time, severity and facility in the message as described in the RFC 3164.

Signed-off-by: Belkov Max <belkov-max@mail.ru>
10 years agoubox: exit(1) in logd if registering log object with ubus fails
Alexandru Ardelean [Fri, 8 Aug 2014 07:48:52 +0000 (07:48 +0000)]
ubox: exit(1) in logd if registering log object with ubus fails

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
10 years agovalidate: return error on failed validation
Luka Perkov [Fri, 27 Jun 2014 14:23:43 +0000 (14:23 +0000)]
validate: return error on failed validation

In the procd script (/lib/functions/procd.sh) uci_validate_section is in charge
of validating the uci config files. The uci_validate_section function checks
return code of validate_data tool; without this change in case of invalid
config values the function is not able to catch errors.

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agovalidate: add missing yes/no boolean values
Luka Perkov [Fri, 27 Jun 2014 08:09:04 +0000 (08:09 +0000)]
validate: add missing yes/no boolean values

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agovalidate: add valid bool types enabled/disabled
Luka Perkov [Fri, 27 Jun 2014 08:09:03 +0000 (08:09 +0000)]
validate: add valid bool types enabled/disabled

They are already supported in config_get_bool function found in OpenWrt
base-package.

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agovalidate: fix indentation
Luka Perkov [Fri, 27 Jun 2014 08:09:02 +0000 (08:09 +0000)]
validate: fix indentation

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agokmodloader: force size argument for syscall to unsigned long to fix issues with musl
Felix Fietkau [Wed, 28 May 2014 21:28:28 +0000 (23:28 +0200)]
kmodloader: force size argument for syscall to unsigned long to fix issues with musl

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoubox: only link libraries that are actually used
Felix Fietkau [Sun, 25 May 2014 20:00:58 +0000 (22:00 +0200)]
ubox: only link libraries that are actually used

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolog: remove superflous client_close call
John Crispin [Thu, 27 Mar 2014 12:04:24 +0000 (12:04 +0000)]
log: remove superflous client_close call

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agomount_root/block: these tools were moved to the fstools repo
John Crispin [Wed, 26 Mar 2014 14:48:24 +0000 (14:48 +0000)]
mount_root/block: these tools were moved to the fstools repo

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agologd: fix time passed via unix fd
John Crispin [Tue, 18 Mar 2014 06:58:38 +0000 (06:58 +0000)]
logd: fix time passed via unix fd

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agologd: fix internal buffer size
John Crispin [Wed, 12 Mar 2014 07:00:11 +0000 (07:00 +0000)]
logd: fix internal buffer size

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agologd: fix pipe close
John Crispin [Wed, 12 Mar 2014 04:01:42 +0000 (04:01 +0000)]
logd: fix pipe close

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agologd: transport log data via the new ubus fd api
John Crispin [Wed, 26 Feb 2014 02:57:30 +0000 (02:57 +0000)]
logd: transport log data via the new ubus fd api

this fixes the size limitation patch.

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agokmodloader: fix insmod when the passed parameter is a valid path
John Crispin [Wed, 26 Feb 2014 06:02:07 +0000 (06:02 +0000)]
kmodloader: fix insmod when the passed parameter is a valid path

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agovalidate: range and base arguments for numeric types, new types hexstring, regexp...
Jo-Philipp Wich [Fri, 21 Feb 2014 15:29:11 +0000 (16:29 +0100)]
validate: range and base arguments for numeric types, new types hexstring, regexp and uci

- make uinteger and integer types more strict, they will not accept
  leading spaces or plus signs anymore
- add optional base argument to uinteger and integer data types, e.g.
  integer(16) will accept -af or 0xaf, a base of 0 (the default) will
  use the underlying heuristics of strtol() / strtoul()
- add optional min and max options to string() datatype, e.g.
  string(3) only accepts strings longer than 3 chars, string(8, 63)
  will accept strings between 8 and 63 characters in length
- add hexstring([minlen [, maxlen]]) type which will accept
  long hex encoded strings whose length must be a multiple of 2
- add regexp(pattern) type which applies an extended POSIX regular
  expression on the value to test. The given pattern is implicitely
  anchored, e.g. regexp("[a-z]+") will match /^[a-z]+$/
- add uci(package, {@type|name}[, option]) type which tests the input
  against selected uci values, e.g.
* uci("network", "@interface") would allow values that match
  the name of any section of type "interface" in /e/c/network
* uci("network", "@interface", "ifname") would allow any value
  that matches one of the ifnames in any section of type
  interface in /e/c/network
* uci("system", "ntp", "server") would allow any value that
  matches on of the servers in the "server" option of the "ntp"
  section in /e/c/system

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agoblock: add more diagnostic messages
Jo-Philipp Wich [Wed, 4 Dec 2013 16:34:43 +0000 (16:34 +0000)]
block: add more diagnostic messages

10 years agomount_root: add more diagnostic messages
Jo-Philipp Wich [Wed, 4 Dec 2013 16:34:23 +0000 (16:34 +0000)]
mount_root: add more diagnostic messages

10 years agomount_root: try both $prefix/sbin/block and /sbin/block, fixes extroot with builtin...
Jo-Philipp Wich [Tue, 3 Dec 2013 18:14:48 +0000 (18:14 +0000)]
mount_root: try both $prefix/sbin/block and /sbin/block, fixes extroot with builtin block-mount

10 years agokmodloader: allow /etc/modules.d/ files to pass options
John Crispin [Wed, 22 Jan 2014 17:57:09 +0000 (17:57 +0000)]
kmodloader: allow /etc/modules.d/ files to pass options

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoubox: make logd use new ubus autoconnect
John Crispin [Wed, 22 Jan 2014 16:35:21 +0000 (16:35 +0000)]
ubox: make logd use new ubus autoconnect

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agologd: revert the log size changes
John Crispin [Wed, 22 Jan 2014 13:57:07 +0000 (13:57 +0000)]
logd: revert the log size changes

Signed-off-by: John Crispin <blogic@openwrt.org>