summaryrefslogtreecommitdiff
path: root/llmnrd.c
AgeCommit message (Collapse)AuthorFilesLines
2020-09-10llmnrd: exit gracefully on select() EINTRTobias Klauser1-2/+3
If a signal was caught, select returns with errno set to EINTR. The signal handler already set llmnrd_running = false. This will also make sure the log message moved by commit a1a821814101 ("llmnrd: only async signal safe functions may be called in signal handler") will get logged correctly in all cases and the process will exit gracefully. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-09-10llmnrd: only async signal safe functions may be called in signal handlerDiego Santa Cruz1-1/+2
Signal handlers may only call async signal safe functions and logging is certainly not async signal safe, so move the log message to the main loop. While at it change "Interrupt" for "Signal" in the message which is more appropriate. Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
2020-03-28llmnrd: don't exit on SO_BINDTODEVICE failureJon Franklin1-1/+4
The -i option requires running llmnrd as root for SO_BINDTODEVICE to work. Packets are still filtered based on interface because only rtnl messages for addresses of the specified interface are considered in iface_nlmsg_change_addr. Instead log a warning only if SO_BINDTODEVICE fails. Signed-off-by: Jon Franklin <jvfranklin@gmail.com> [tk: small adjustments to commit message, check return value of iface_init] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-02-03llmnrd: set stdout to line bufferingmpvader1-0/+2
The log output of llmnrd works well when operated from a terminal; but not when its stdout is piped to a log-file or -tool; due to buffering: By default, stdout is buffered (line buffered if connected to a terminal), and stderr is unbuffered. [1] Changing stdout to line buffering fixes this. [1] https://www.gnu.org/software/libc/manual/html_node/Buffering-Concepts.html
2017-02-28llmnrd: Update copyright in version informationTobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-02-28llmnrd: Poll hostnameTobias Klauser1-2/+33
Poll "/proc/sys/kernel/hostname" and update the hostname when it was changed. systemd has a similar mechanism. Note that the hostname is not polled if it has been provided on the command line, or if "/proc/sys/kernel/hostname" cannot be opened. Patch contributed by @tbetker Fixes #23 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-10llmnrd: merge rtnl interface event loop into main select() loopsTobias Klauser1-9/+84
Instead of spawming a thread for the sole purpose of watching the rtnl for (presumably) seldom events, just merge the select() for all sockets together in one single main loop. This reduces unnecessary complexity and makes llmnrd no longer require any locking. It also allows us to handle signals in a thread-safe manner (as there aren't any ;) and thus the race condition on exit reported in #20 Closes #20 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-17llmnrd: Allow to bind to a specific network interfaceTobias Klauser1-3/+9
Add a command line option -i/--interface which allows to bind the llmnrd sockets to a specific interface. If used, requests are only answered on the specified interface. Example: llmnrd -i eth0 Closes #9 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-16llmnrd: Don't enumerate and store IPv6 addresses if IPv6 is disabledTobias Klauser1-1/+1
Currently IPv6 addresses are always enumerated via RTNL socket and then stored internally, even if llmnrd was started without the IPv6 command line option '-6'. Even though no queries on AF_INET6 sockets will be answered, this behavior might be confusing. Especially due to messages like: Added IPv6 address fe80::f0eb:aaff:feb3:ae58 on interface tap0 being logged. Explicitely disable IPv6 address enumeration on the RTNL socket to fix this behavior. Closes #8 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnrd: Use MAXHOSTNAMELEN for hostname buffer and zero-terminate stringTobias Klauser1-3/+4
Use MAXHOSTNAMELEN defined in sys/param.h to determine the size of the hostname buffer to allocate. Also make sure the string is properly zero-terminated in all cases, as in some cases it might be undefined whether a truncated string is properly terminated. Note: Also remove a TODO comment, as watching for hostname changes at runtime is outside the scope of llmnrd (also, avahi behaves the same). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-08-02llmnrd: Update copyrightTobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29llmnrd: Use SA_RESTART for installed signal handlersTobias Klauser1-0/+1
Make certain syscalls restartable after signal handler. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-04-29llmnrd: Add missing break in switchTobias Klauser1-0/+1
Discovered by the Coverity scanner CID 99693. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd: Add IPv6 supportTobias Klauser1-3/+8
Closes #5 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd: Join IP multicast group on each new interfaceTobias Klauser1-3/+6
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd: Fix usageTobias Klauser1-5/+5
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd: Support daemonizationTobias Klauser1-1/+5
No logging to syslog or dropping of privileges etc yet. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18build: Check if called from git repo when generating GIT_VERSIONTobias Klauser1-2/+2
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-18llmnrd, llmnr-query: Add git id to version outputTobias Klauser1-2/+3
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17all: Add version informationTobias Klauser1-5/+16
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-02-17llmnrd: Rename main.c to llmnrd.cTobias Klauser1-0/+150
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>