summaryrefslogtreecommitdiff
path: root/src/daemon/dlt-daemon.c
Commit message (Collapse)AuthorAgeFilesLines
* Re-Initialize internal logging in daemon mode only (#459)lvklevankhanh2023-04-191-10/+0
| | | | | | | | | | | | | | | | * Re-Initialize internal logging in daemon mode only Re-Initialize internal logging is triggered twice during startup. This fixed might be a simplified initailization code for DLT. Signed-off-by: Le Van Khanh <Khanh.LeVan@vn.bosch.com> * Re-Initialize internal logging in daemon mode only Re-Initialize internal logging is triggered twice during startup. This fixed might be a simplified initailization code for DLT. Signed-off-by: Le Van Khanh <Khanh.LeVan@vn.bosch.com>
* logfile: exhance internal dlt logging by introducing size limits (#369)Daniel Weber2023-03-101-11/+41
| | | | | | | | | | | Enhance dlt logging such that multiple files are used as it is done for the offline traces. Add limit-specific config values for logging. For this purpose the pattern of index-based file names is used only. This approach of logging to multiple files and rotating in order to keep the limits ensures that dlt logs take care of available space on the underlying file system and do not grow infinitely. Signed-off-by: Daniel Weber <daniel.w.weber@daimler.com> Co-authored-by: Oleg Tropmann <oleg.tropmann@daimler.com>
* Fix for Resource and Memory Leak (#418)lti9hc2022-10-261-1/+3
| | | | | | | | | | | dlt_daemon_client.c Adding NULL check for tok dlt_daemon_offline_logstorage.c : Adding NULL check for application dlt_user.c : Fix for Memory Leak dlt-daemon.c : Fix for Resource Leak dlt_config_file_parser.c : Add termination character at the end of string dlt_offline_trace.c : Fix for Resource Leak Signed-off-by: Mvaradaraj2 manoj.varadaraj2@harman.com Co-authored-by: Le Tin <tin.le@vn.bosch.com>
* internal-logging: Fix issues with file logging (#378)Alexander Mohr2022-10-051-2/+20
| | | | | | | | | | | | | This commit fixes the following issues if access to the internal log file is not possible (logging_mode = DLT_LOG_TO_FILE) * dlt_log_free tried to call fclose on a nullptr Added a nullcheck for this * Access to log file might be denied but access to logs is still wanted Add a new CMake option WITH_DLT_FILE_LOGGING_SYSLOG_FALLBACK If this is set to ON and the logging moe is set to file, the dlt-daemon will fall back to syslog if opening the internal log file failed Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* dlt-gateway: Fix crash on invalid ip (#381)Alexander Mohr2022-09-281-1/+1
| | | | | | | | * dlt-gateway crashed when an invalid ip address was configured as a null pointer was used for strdup Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* dlt-daemon-connection: Start up even if not all bindings are valid (#380)Alexander Mohr2022-08-101-4/+10
| | | | | | | | dlt-daemon allows configuration of multiple addresses. Before this commit the daemon exits when the first binding fails. This commit changes the behavior so that the daemon only exits if none of the configured addresses can be opened. Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* enforce-trace-limit: ContextLogLevel is now enforced in the daemon (#382)Alexander Mohr2022-08-101-3/+20
| | | | | | if an application sends a message with a level below context level and the level enforcement is on, the message will be dropped Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* Support for Cygwin toolchain. (#351)DoctorNoobingstoneIPresume2021-11-151-1/+1
| | | | | | Also tested with the latest version running on Windows XP (gcc-5.4.0) (http://www.crouchingtigerhiddenfruitbat.org/cygwin/timemachine.html). Signed-off-by: Adder <adder_2003@yahoo.com>
* daemon: Do not exit when accept returns ECONNABORTED (#347)rvalovyi2021-11-031-0/+2
| | | | | | | | | | | | Scan of port 3490 from a Linux machine by 'nmap -v -p 3490 -Pn IP_address_of_QNX_board' leads to dlt-daemon crash. It is necessary to parse the code of the returned error in errno. If errno = ECONNABORTED it means there was an attempt to scan port 3490 and on this error there is no need to exit the application by error. Fix for the issue https://github.com/GENIVI/dlt-daemon/issues/341 Signed-off-by: Ruslan Valovyi <ruslan.valovyi@volvocars.com>
* dlt-daemon: Only create directories if they do not exist yetAlexander Mohr2021-10-211-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | dlt_mkdir_recursive runs mkdir for directories which already exist. This fails if the directory already exists and the dlt-daemon does not have the permissions to change the mode on the directory. On many systems the directories are not created by dlt-daemon itself but rather through the build system or while the root filesystem is created. At this stage the permissions are already set properly and they might be less permissive than what dlt-daemon expects but still sufficient. For example is rwx not necessary for each directory in the tree. Before this commit the following scenario would fail: * Path is set to /mnt/dlt/ * mnt has 755 permissions for root * dlt has 755 for dlt user As dlt daemon would try to run mkdir on /mnt dlt_mkdir_recursive would fail due to lack of permissions although the permissions are sufficient for dlt-daemon to work and write its files into /mnt/dlt/ With this commit /mnt would not be created anymore because it already exists. If the permissions are not sufficient for dlt-daemon to write in it will fail when trying to create files and exit at this point Signed-off-by: Alexander Mohr <alexander.m.mohr@daimler.com>
* dlt-daemon: create sockets using "android way"Sebastien RAILLET2021-10-121-38/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Before this commit, dlt-daemon sockets were created inside /data/local/tmp. This works but have many drawbacks: - /data/local/tmp isn't always a tmpfs depending of the android system you have. Means sockets are potentially created on a filesystem which binds to a real device - as the sockets are created by the dlt-daemon itself, this prevent the usage of specific SELinux labels / contexts as they will inherit the label / context from its parent location (e.g the ones from /data/local/tmp). This prevent a fine control of the SELinux label / context that you would like to apply on them * This commit adapts the dlt-daemon in such way: - application and control sockets are now created inside /dev/socket which is the standard path for sockets on android - these sockets are now created by init (see dlt-daemon.rc) and their fds are recovered by dlt-daemon through a specific android API (dlt_daemon_unix_android_get_socket). If the fds can't be recovered, we fallback to the previous mechanism by creating by ourself the sockets (even if this will prevent SELinux label / context on this socket) - all these modifications have been put under compilation flag for android Signed-off-by: Sebastien RAILLET <sebastien.raillet@marelli.com>
* daemon: Create parent directory for unix socketSaya Sugiura2021-10-051-5/+19
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* daemon: Enable to use FIFO on QNXSaya Sugiura2021-10-051-6/+14
| | | | | | | | | | | | It depends on OSes if maximum size of pipe can be configured per process or not. For example, on QNX it can be only set from pipe resource manager. Also flags used to set the value are only supported on Linux. Now DaemonFIFOSize option in dlt.conf is only relevant for Linux. Also -f option is added to build scripts to enable FIFO as IPC. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* fix malformed printf format strings (#295)Radek Kaczorowski2021-10-051-29/+33
| | | Co-authored-by: Saya Sugiura <39760799+ssugiura@users.noreply.github.com>
* daemon: Call dlt_daemon_configuration_load() properly (#330)kundatipradeep2021-09-141-6/+6
| | | As init_p2 does the offline trace initialization, load configuration should be called prior, as LoggingMode is set through run-timeconfiguration file. With original logic it results in offline trace write failed, it is not valid trace directory errors.
* daemon: Improve signal handler for timersBui Nguyen Quoc Thanh2021-06-301-41/+43
| | | | | | | | | | | | | In the initial implementation of timer_thread, the signals SIGUSR1 is blocked and only checked via sigpending. There will be an issue if the interval of timers are quite long. It could cause the main thread waits for a long time in case of termination gratefully. Fix: let the timer_thread be interrupted by signal SIGUSR1 and handle it properly then. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* daemon: check the conf inputsBui Nguyen Quoc Thanh2021-05-101-5/+35
| | | | | | | | | | | | | | The configuration of memory buffer size must be carefully parsed and validated to avoid segmentation fault Any misleading information in configuration file must be considered as major error and dlt-daemon should stop and raise error message to stderr This commit also corrects error handling of dlt_buffer_init_dynamic(). Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* Make dlt pipe only readable by user (#285)Mostafa2021-01-191-1/+1
| | | | | | security-wise dlt pip(FIFO) should be exclusively readable only by owner not the dlt group to prevent eavesdropping by clients Signed-off-by: Mostafa Emami <mustafaemami@gmail.com>
* other: fix remaining conversion warningsDinh Cong Toan2021-01-061-6/+6
| | | | | | | | | | | - Converting datatype to the correct one. - As macro do not perform type-checking before, so these functions used it with different datatype could create a lot of conversion warnings. For this reason, these warnings could be consider as normal information and will not be fixed. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* daemon: fix conversion warningsiod1hc2021-01-061-44/+56
| | | | | | | | | | | | | - Instead of casting frequently, change the data type of 'to_remove' to 'uint32_t' for the correct format, also adding temp variable to check return value. - Change data type of 2 variable 'offset' and 'sizecont' to 'size_t' (dlt_daemon_client.c), because these variable using many time with function 'sizeof', and they was used as local variable so it will not effect dlt library. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* gateway: fix compile warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-2/+2
| | | | | | | | | - Correct the data type of 'headersize' and 'datasize' variables in header 'dlt_common.h', then config those functions using this library. - Explicit the data type. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* logstorage: Implement general config to maintain logstorage loglevelSaya Sugiura2021-01-061-0/+3
| | | | | | | | | | | | Runtime log level setting from dlt-viewer or dlt-control doesn't work when logstorage is enabled. Adding MaintainLogstorageLogLevel=ON/OFF to [General] session of dlt_logstorage.conf to keep the current behaviour (=ON or 1 or not defined), or allow to change log level from dlt-viewer or dlt-control when the logstorage is enabled (=OFF or 0). Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com> Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* daemon: Correct order of runtime config load.Bui Nguyen Quoc Thanh2021-01-061-1/+17
| | | | | | | | Since order of runtime config load for app-ctx and dlt-runtime are different from each other, so they could not be in the same load_runtime function. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* daemon: Alternative of timerfd in QNXBui Nguyen Quoc Thanh2021-01-061-31/+177
| | | | | | | There is no timerfd_create in QNX so try to use threads to sleep and notify to main thread via unamed pipes. Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* Add support for logging with VSOCK (#255)Martin Ejdestig2020-12-141-38/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
* dlt-daemon: Adds an option to disable injection mode (#266)sebastienr2020-11-251-0/+4
| | | | | | A new option named "InjectionMode" allows to select if we want to enable / disable the feature Signed-off-by: Sebastien RAILLET <sebastien.raillet@marelli.com>
* dlt-daemon.c: fix printf format %d to %ld that formats a longKHANH LUONG HONG DUY2020-07-061-2/+2
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* limit logspam in gateway on client overflowFelix Herrmann2020-07-061-23/+7
| | | | | | | | update client buffer overflow counter in send function. Gather all overflow checks into dlt_daemon_client. Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* common: Isolate FIFO/Unix socketLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-4/+22
| | | | | | | | | | | | | | dlt_common - Add preprocessor DLT_USE_UNIX_SOCKET_IPC for dlt_log_set_fifo_basedir() and dltFifoBaseDir variable - Rename input parameter of dlt_log_set_fifo_basedir() dlt-daemon - Replace setting dltFifoBaseDir by dlt_log_set_fifo_basedir() and add preproc DLT_USE_UNIX_SOCKET_IPC - Update -h opt and flags.loggingFilename based on IPC type Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* daemon: Avoid spamming message buffer overflowBui Nguyen Quoc Thanh2020-07-061-19/+8
| | | | | | | | | | | | | - In existing implementation, control message "message_buffer_overflow" is sent for every incoming message which is dropped since buffer is full. So UDP and logstorage will receive a lot of these messages. That could be considered as unnecessary. - In order to reduce the useless effort to send "message_buffer_overflow" for every missing message, daemon will only send it out right after buffer is full or right after real client is connected. Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* gateway: Configurable interval timeBui Nguyen Quoc Thanh2020-07-061-2/+2
| | | | | | | | | - Introduce "General" section for dlt_gateway.conf - In new section, the interval is used for gateway timer. This entry is optional. By default, it is set to 1 second as the existing hardcoded value. Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* snprintf ret > 0 is not always an errorFelix Herrmann2020-07-061-6/+12
| | | | | | | | | snprintf returns the size the resulting string would take. In order to detect truncation, this size needs to be checked against the buffer size. Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* fix some gcc9 compiler warningsFelix Herrmann2020-07-061-7/+15
| | | | | | | | | Many stringop-truncation and stringop-overflow warnings are still there (so many). https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* Limit log messages on full bufferFelix Herrmann2020-07-061-3/+8
| | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com>
* daemon: Remove empty line in daemon logSaya Sugiura2020-07-061-16/+17
| | | | | | | New empty line was generated from daemon internal log because of '\n'. This is removed from daemon internal log and added to dlt_vlog(). Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Fixed empty internal message in dlt-daemon.c (#225)Francesco Montefoschi2020-04-291-1/+3
| | | | | | | | `dlt_daemon_log_internal` is called with with a null `local_str`. This has been introduced by mistake during a code refactoring. Code has been reverted to the previous version: https://github.com/GENIVI/dlt-daemon/commit/bfa7026b355db32d91374997cc86b56fedc3e861 Signed-off-by: Francesco Montefoschi <francesco.montefoschi@artgroup-spa.com>
* dlt-daemon: fix resource leakPhong Tran2019-12-111-0/+2
| | | | | | | return without close the file descriptor. reported by Resource leak (RESOURCE_LEAK) Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* dlt-offline-trace: fix bug and hardcode (#174) (#186)Vo Trung Chi2019-11-141-2/+1
| | | | | | | | Fix the issue that DLT offline trace creating mutiple files even after reaching MaxTrace size when filename is index based. Related to: https://github.com/GENIVI/dlt-daemon/pull/174 Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* Removed unused headers(epoll) in UDP connectionsunil.s2019-10-141-2/+6
| | | | Signed-off-by: sunil.s <sunil.s@lge.com>
* Fix: Propper usage of LoggingMode: "uncrustification"Sebastian Kloska2019-10-101-30/+30
| | | | Signed-off-by: Sebastian Kloska <sebastian.kloska@snafu.de>
* Fix: Propper usage of LoggingMode in ".../dlt-runtime.cfg"Sebastian Kloska2019-10-101-5/+5
| | | | | | | | | | | | | | | | | | * Symptom: no offline trace file gets created even if runtime config LoggingMode==(2|3). * Reason: runtime config gets read *after* offline logging setup. * Solution: Read runtime config *before* offline logging setup. * Make the "read runtime config" function set a proper default value for logging mode instead if the *_init_* function setting up the logging. Signed-off-by: Sebastian Kloska <sebastian.kloska@snafu.de>
* shm: Resend dlt msg when client connectVo Trung Chi2019-09-131-216/+53
| | | | | | | | After dlt-client connects to dlt-daemon successfully, all the stored dlt messages in daemon was not flushed to dlt client when using shared memory as IPC. It is harmonized with dlt_daemon_process_user_message_log(). Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* Add option in dlt.conf for bindAddress to specific IPs (#130)AdrianStoenescu2019-09-031-26/+95
| | | | | | | | | | | | | | | | | | | | | | | | Add the possibility to have in dlt.conf an option that specifies a set of IP addresses. The daemon will do a socket bind only for this list, therefore external connections will be limited to this set of IP addresses. If this option is not given, the default INADDR_ANY is used ("0.0.0.0") as before. The option in dlt.conf can look like this: BindAddress = 160.48.199.98;160.48.199.97;160.48.199.226,160.48.199.186;160.48.199.139;172.16.222.99 There can be as many addresses but only specified on one single line. They have to be delimited by ',' or ';'. ' ' (space) delimiter does not work. IPv6 addresses are supported as well. For instance: BindAddress = fe80::255:7bff:feb5:7df7 IPv6 addresses are acceptable only if DLT_USE_IPv6 flag is ON at compile time. IPv4 addresses are acceptable only if DLT_USE_IPv6 flag is OFF at compile time. One cannot have both IPv4 and IPv6 format in the same time. Signed-off-by: Adrian Stoenescu Adrian.Stoenescu@harman.com
* UDP Multicast implementation (#155)Sunil-K-S2019-08-231-0/+49
| | | | | The feature can be enabled by setting WITH_UDP_CONNECTION to ON. Signed-off-by: sunil.s <sunil.s@lge.com>
* daemon: fix compile error with DLT_IPC="UNIX_SOCKET" (#153)Vo Trung Chi2019-08-021-0/+2
| | | Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* using POSIX shared memory APIs (#90) (#151)Vo Trung Chi2019-08-011-3/+30
| | | | | Replace all Linux specific shared memory APIs with POSIX alternatives. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* Revert "Add option in dlt.conf for bindAddress to specific IPs (#130)"Saya Sugiura2019-08-011-95/+26
| | | | This reverts commit e8716cc5c950e50411b23a7a6cafa3c063c59e90.
* Add option to set owner group of daemon FIFO (#122)Jiri Popek2019-07-251-1/+37
| | | | | | | | | | New option to set owner group of daemon FIFO (Default: /tmp/dlt) is added in dlt.conf. If this option is used properly, more secure tracing can be realized. Only application that is in dlt_user_apps_group can write log message to daemon FIFO. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp>
* Add option in dlt.conf for bindAddress to specific IPs (#130)AdrianStoenescu2019-07-251-26/+95
| | | | | | | | | | | | | | | | | | | | | | | Add the possibility to have in dlt.conf an option that specifies a set of IP addresses. The daemon will do a socket bind only for this list, therefore external connections will be limited to this set of IP addresses. If this option is not given, the default INADDR_ANY is used ("0.0.0.0") as before. The option in dlt.conf can look like this: BindAddress = 160.48.199.98;160.48.199.97;160.48.199.226,160.48.199.186;160.48.199.139;172.16.222.99 There can be as many addresses but only specified on one single line. They have to be delimited by ',' or ';'. ' ' (space) delimiter does not work. IPv6 addresses are supported as well. For instance: BindAddress = fe80::255:7bff:feb5:7df7 IPv6 addresses are acceptable only if DLT_USE_IPv6 flag is ON at compile time. IPv4 addresses are acceptable only if DLT_USE_IPv6 flag is OFF at compile time. One cannot have both IPv4 and IPv6 format in the same time. Signed-off-by: Adrian Stoenescu Adrian.Stoenescu@harman.com
* doxygen: Remove licenceSaya Sugiura2019-07-191-2/+0
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>