summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/hce.c
AgeCommit message (Collapse)Author
2024-05-18remove prototypes with no matching functionJonathan Gray
2022-06-03Check tls_config_new() for NULL returnTheo Buehler
This way we don't crash in tls_config_insecure_noverify_cert(). From Mateusz Piotrowski on bugs ok claudio
2021-02-22Use the F_CHECK_SENT and F_CHECK_DONE flags to determine whether aJonathan Matthew
previous attempt at running a check script has finished yet, so we can avoid building up a backlog of check requests. ok dlg@ tb@ giovanni@
2018-08-06replace the current log optionsSebastian Benoit
log updates|all with log state changes log host checks log connection [errors] The first two control the logging of host check results: either changes in host state only or all checks. The third option controls logging of connections in relay mode: Either log all connections, or only errors. Additionaly, errors will be logged with LOG_WARN and good connections will be logged with LOG_INFO, so they can be differentiated in syslog. ok and feedback from claudio@
2017-12-18always initialize the hce_launch_checks event timer.Sebastian Benoit
Fixes a crash when poll is run without any checks. Found and fixed by Hiltjo Posthuma (hiltjo -AT- codemadness -DOT- org). ok claudio@
2017-05-28use __func__ in log messages. fix some whitespace while here.Sebastian Benoit
From Hiltjo Posthuma hiltjo -AT codemadness -DOT- org, thanks! ok florian, claudio
2017-05-27Migrate relayd to use libtls for TLS. Still does the TLS privsep via theClaudio Jeker
engine but at least we can use a sane API for new features. Going in now so it is possible to work with this in tree. General agreement at d2k17.
2016-09-03Use the fork+exec privsep model in relayd; based on rzalamena@'s workReyk Floeter
for httpd with some (current and previous) changes for relayd. Once again, both daemons now share the same proc.c where most of the privsep "magic" happens. OK benno@ rzalamena@
2016-09-02Split "struct relayd" into two structs: "struct relayd" and "structReyk Floeter
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@
2016-09-02Terminate relayd using the socket status instead of watching SIGCHLDReyk Floeter
or killing child processes. - Based on rzalamena@'s diff for httpd. OK deraadt@ rzalamena@
2016-01-11This adds the host_error output and the http code (when available) to theSebastian Benoit
host-check log. ok claudio@
2015-12-02In most cases we don't need all arguments of proc_compose*_imsg(),Reyk Floeter
so add a shortcut proc_compose*() that skips all of them. Only use the full argument list if needed. The functions with full argument lists can eventually be replaced with a nicer transaction-based approach later. OK benno@
2015-11-28pledge: allow getsockopt IP_IPDEFTTL with promise inetSebastian Benoit
then relayd's host check engine can be pledged. ok reyk@, approach suggested by deraadt@ weeks ago.
2015-01-22Clean up the relayd headers with help of include-what-you-use and someReyk Floeter
manual review. Based on common practice, relayd.h now includes the necessary headers for itself. OK benno@
2015-01-16Adapt to <limits.h> universe.Theo de Raadt
ok millert
2014-12-12Change the keyword "ssl" to "tls" to reflect reality since weReyk Floeter
effectively disabled support for the SSL protocols. SSL remains a common term describing SSL/TLS, there is some controvery about this change, and the name really doesn't matter, but I feel confident about it now. (btw., sthen@ pointed out some historical context: http://tim.dierks.org/2014/05/security-standards-and-name-changes-in.html) OK benno@, with input from tedu@
2014-11-19Support exporting relayd statistics via AgentX/snmpdBret Lambert
This should be equivalent to the statistics available via the various relaydctl show commands okay benno@ reyk@
2014-10-25Remove unnecessary netinet/in_systm.h include.Lawrence Teo
ok millert@
2013-03-10This diff changes relayd to use the monotonic clock instead ofReyk Floeter
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@
2012-05-09Fix a desynchronization on host change during a running checkgiovanni
closes pr system/6627 diff submitted by Martin Matuska, thanks ok benno@
2012-01-21Only start the child processes after all of them reported to have loadedCamiel Dobbelaar
the config. Solves a race at startup time where processes can send status messages about hosts that other processes don't know about yet. (and have relayd abort with "desynchronized" or "invalid host id") ok henning pyr deraadt solves the problem ok from benno todd
2011-11-12fix function names in fatalx() messagesCamiel Dobbelaar
ok mikeb
2011-05-19Fix reload support in relayd(8) by reimplementing large parts of theReyk Floeter
daemon infrastructure. The previous design made it fairly hard to reload the complex data structures, especially relays and protocols. One of the reasons was that the privsep'd relayd processes had two ways of getting their configuration: 1) from memory after forking from the parent process and 2) and (partially) via imsgs after reload. The new implementation first forks the privsep'd children before the parents loads the configuration and sends it via imsgs to them; so it is only like 2) before. It is based on an approach that I first implemented for iked(8) and I also fixed many bugs in the code. Thanks to many testers including dlg@ sthen@ phessler@ ok pyr@ dlg@ sthen@
2011-05-09Reorganize the relayd code to use the proc.c privsep API/commodityReyk Floeter
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@
2011-05-05Update all logging and debug functions to use the __func__ macroReyk Floeter
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...
2011-02-08Log the time taken for all types of check, not just tcp checks.Stuart Henderson
ok pyr@
2010-11-30The relayd processes did already bump up the socket file descriptorReyk Floeter
resource limits to the maximum of the daemon class but the host check process (hce/health checks) didn't and was limited to a fairly low default of 128 open sockets (openfiles-cur=128 in login.conf). This was reached fairly quickly with "check tcp" of many hosts. This diff increases the maximum number of monitored hosts and concurrent health checks in relayd in a significant way and may fix issues for people that have around 100 or more hosts (or fewer hosts with multiple checked ports). tested by phessler@ ok jsg@
2010-05-14allocate all struct event's on the heap, it looks cleaner, feels betterReyk Floeter
and follows a suggestion in event.h. also don't mix signal() and signal_set()/signal_add(). ok jsg@ gilles@
2010-01-11add "log brief" and "log verbose" to change logging verbosityJonathan Gray
like several other things in the tree. ok reyk@ looks fine claudio@
2009-06-054 handed diff with eric:Pierre-Yves Ritschard
Stop pushing event handling in the imsg framework. Instead, provide a small glue layer on top of both imsg and libevent. This finally clearly separates event handling and imsg construction. Sidetrack bonus: remove the mega-ugly hack of having a dummy imsg_event_add stub in relayctl. This will make bgpd (and thus henning) happy. Next up are smtpd and ospfd. ok eric@
2009-06-05some KNF cleanup following the last sed.Pierre-Yves Ritschard
2009-06-05Make imsg completely async model agnostic by not requiring anPierre-Yves Ritschard
imsg_event_add function to be provided (which ended up being a named callback). Instead provide a wrapper in the daemon and call that everywhere. Previsously discussed with the usual suspects, ok eric@ though not too happy about the function name (imsg_compose_event).
2009-06-04Keep around the SSL session for each checked host. This way SSLReyk Floeter
caching can kick in on subsequent checks, making them faster and lighter on the server. From camield, closes PR 6137 (modified diff)
2009-06-02remove extra imsg_event_add() after EV_WRITE checks - this is notReyk Floeter
required because it is called later and there is no return before. ok gilles@
2009-06-02Libevent may do an upcall with both EV_READ and EV_WRITE set.Reyk Floeter
So change the code accordingly to allow that. Found by claudio@ in ospfd
2009-04-17keep the parent relations of hosts after reloading the configuration.Reyk Floeter
From Camiel Dobbelaar, closes PR 6066
2008-12-05change the way relayd reports check results: instead of logging anReyk Floeter
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@
2008-09-29spacingReyk Floeter
2008-08-08Check gettimeofday() against -1; Add a missing error check in one place.Thordur I. Bjornsson
OK reyk@
2008-07-19no need for using a TAILQ queue for the host children list, use aReyk Floeter
singly-linked SLIST instead. the only noticeable change is the reversed order to notify the children but it does not really matter here. also only walk through the children host list if the host itself is a potential parent.
2008-07-19If the new 'parent' keyword is specified for a host in a table,Reyk Floeter
inherit the state from another host with the specified Id; no additional check will be for the inheriting host. This helps in scenarios with lots of IP aliases that all point to the same service on the same host (like web hosting with many SSL domains). discussed with pyr, tested in different setups
2008-03-12nuke unused variable.Pierre-Yves Ritschard
2008-02-11Marry relayd with snmpd using new "send trap" option: Request to sendReyk Floeter
a SNMP trap when the state of a host changes. relayd(8) will try to (re-)connect to snmpd(8) and request it to send a trap to the registered trap receivers, see snmpd.conf(5) for more information about the configuration. ok pyr@ thib@
2008-01-31add prefixes to names of structure elements to make it easier to grepReyk Floeter
for code, start with struct relayd. finally. ok thib@
2007-12-08Rename everything which reffered to services refer to rdr for internalsPierre-Yves Ritschard
(for instance: rename struct service to struct rdr), refer to redirects otherwise (hoststatectl output). ok reyk@
2007-12-07hoststated gets renamed to relayd. easier to type, and actually saysReyk Floeter
what the daemon does - it is a relayer that pays attention to the status of pools of hosts; not a status checkers that happens to do some relaying
2007-11-24sort includes, adjust to style(9)Reyk Floeter
2007-11-21make sure all hosts are checked when hoststatectl poll is issued, nowPierre-Yves Ritschard
that check interval can differ from table to table. ok reyk@
2007-11-20Allow overriding the global interval in a table.Pierre-Yves Ritschard
Table specific intervals must be multiples of the global interval. help and ok reyk@
2007-11-19spacingReyk Floeter