Commits


Standardize logging with bgpd OK claudio@


When system calls indicate an error they return -1, not some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.


Consistently use the variable "ttl" for get/setsockopt ok benno@ on an earlier version, input from Kapetanakis Giannis


Correctly set ttl for IPv4 and IPv6. Problem noted and fix from Kapetanakis Giannis, thanks! Input & OK jca.


use __func__ in log messages. fix some whitespace while here. From Hiltjo Posthuma hiltjo -AT codemadness -DOT- org, thanks! ok florian, claudio


Split "struct relayd" into two structs: "struct relayd" and "struct relayd_config". This way we can send all the relevant global configuration to the children, not just the flags and the opts. With input from and OK claudio@ benno@


Use SOCK_NONBLOCK in relayd as well. OK benno@


let the icmp check use getsockopt IP_IPDEFTTL to get the default ttl instead of using sysctl. makes it possible to pledge hce.


Increase the input side socket buffer size for "check icmp" not to drop the reply messages when "check icmp" is used with many hosts. ok reyk benno


Clean up the relayd headers with help of include-what-you-use and some manual review. Based on common practice, relayd.h now includes the necessary headers for itself. OK benno@


Adapt to <limits.h> universe. ok millert


Stop pulling in <arpa/inet.h> or <arpa/nameser.h> when unnecessary. *Do* pull it in when in_{port,addr}_h is needed and <netinet/in.h> isn't. ok reyk@


Remove unnecessary netinet/in_systm.h include. ok millert@


This diff changes relayd to use the monotonic clock instead of gettimeofday(). It was also bugging me for some time to have all these checks of gettimeofday()'s return value: it should not fail. So this diff introduces a void getmonotime(struct timeval *tv) that calls clock_gettime(CLOCK_MONOTONIC, &ts) and converts the output to a struct timeval that can be used with the existing code and the timeval-specific timer functions (timerclear, timersub, ...). It does not return a status but calls fatal() on error-that-should-not-happen. ok sthen@ chris@


use correct function name in fatal error message


Remove unnecessary pointer casts. No binary diff. OK benno@


Copy the host id value to the ICMP echo payload in network byte order and in a nicer way that silences the compiler. ok benno@


Fix ICMP checks by setting the socklen correctly before calling recvfrom(). ok benno@


Reorganize the relayd code to use the proc.c privsep API/commodity functions that are based on work for iked and smtpd. This simplifies the setup of privsep processes and moves some redundant and repeated code to a single place - which is always good from a quality and security point of view. The relayd version of proc.c is different to the current version in iked because it uses 1:N communications between processes, eg. a single parent process is talking to many forked relay children while iked only needs 1:1 communications. ok sthen@ pyr@


Update all logging and debug functions to use the __func__ macro instead of static function names. __func__ is C99 and perfectly fine to use. It also avoids printing errors; for example if a statement log_debug("foo:"..) was moved or copied from function foo() to bar() and the log message was not updated...


do not timeout disabled hosts in the icmp checks Thanks to Sebastian Benoit, closes pr6146


get the default ttl via sysctl instead of using IPDEFTTL


allow to modify the IP TTL value for host checks. this can be used to check if the host is only n hops away and not re-routed over a longer path.


change the way relayd reports check results: instead of logging an arbitrary string in debugging mode, it will store an error code (HCE_*) for each host. the error code can be translated to a string (in log.c) for debugging but it will also be passed to relayctl via the control socket. from a user point of view, this will print a human-readable error message in the "relayctl show hosts" output if a host is down because the check failed. the relayctl(8) manpage includes detailed explanations of the error messages including mitigations for the most-common problems. ok jmc@ (manpages) ok phessler@


Check gettimeofday() against -1; Add a missing error check in one place. OK reyk@