summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/pfe.c
AgeCommit message (Collapse)Author
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-10-03Support more than one relay backup table. Instead of duplicating theReyk Floeter
code for main and backup table all over the place, turn the relay tables into a list attached to the relay. This improves the code and allows some other tricks with multiple tables later.
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-20Concurrent calls of "relayctl show sessions" could crash relayd. FixReyk Floeter
the show sessions handler by implementing it in an asynchronous way. Closes PR 6509 ok pyr@
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...
2010-11-16Add support for enable/disable table when using relays instead of redirects.Jonathan Gray
From Patrik Lundin and Linus Widstromer. ok reyk@
2010-08-01Allow fallback tables for relays, not just redirections.Stuart Henderson
Seems reasonable to jsg, ok phessler, no response from reyk or pyr
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@
2009-08-17also report routers and their host states in relayctlReyk Floeter
ok pyr@, jmc@ for man bits
2009-08-13add new 'router' functionality to dynamically add or remove routesReyk Floeter
based on health check results, using the existing table syntax. this allows to maintain multiple (uplink) gateways to implement link balancing or WAN link failover if no routing protocol or other keepalive method is available. works fine with or without net.inet.ip.multipath enabled. ok pyr@, jmc@ for manpages
2009-08-07rename 'struct session' to 'struct rsession' because it conflicts withReyk Floeter
another 'struct session' in sys/sysctl.h.
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-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
2009-04-01re-initialize tables after reload to handle new and changed tables.Reyk Floeter
From Pascal Lalonde, closes PR 6112
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-03Missing breaks.Jonathan Gray
ok pyr@
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-01-31add prefixes to names of structure elements to make it easier to grepReyk Floeter
for code, next struct relay. knf long line fixes will follow later. ok 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-20implement statistics for redirections, like the existing statisticsReyk Floeter
for relays. they can be viewed with the new "relayctl show redirects" command. (uses the previous change to pf_table.c to get the statistics) looks good pyr@
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-19spacingReyk Floeter
2007-11-15Do not insert proto_default inside the dynamically alloced protocol queue.Pierre-Yves Ritschard
Handle it as a special case in the one place where it actually matters instead.
2007-11-14do go through relays when none exist.Pierre-Yves Ritschard
2007-10-30untangle a mess in the state update logicReyk Floeter
2007-10-19Move relays from static TAILQs to allocated ones.Pierre-Yves Ritschard
This syncs it with other hoststated entities and will make reload easier. This is step 1 out of 7 for reload.
2007-10-19Add the ability to schedule an immediate check through hoststatectl.Pierre-Yves Ritschard
Especially useful when interval is rather long. I was supposed to commit this before 4.2.
2007-09-28Correct my mail address.Pierre-Yves Ritschard
2007-09-27Do not clear the changed flag to early, which prevented a tablePierre-Yves Ritschard
from being used by several services. ``looks fine'' reyk@
2007-09-07add an interface to dump running relay sessions to the control socketReyk Floeter
2007-06-19don't go through the effort of creating a SIGHUP handler throughPierre-Yves Ritschard
libevent just to ignore it, use SIG_IGN instead. this syncs hoststated with bgpd and (soon) ospfd.
2007-06-19Do not fatal out with ``pipe closed'' when a short read occurs on onePierre-Yves Ritschard
of our socket pairs. Instead disable listening on the pipe, terminate the event loop, and let the parent process's SIGCHLD handler do a clean shutdown. from an ospfd diff by claudio, ok claudio@
2007-06-12put the fd passing from bgpd back in to hoststated's version of imsg,Mathieu Sauve-Frankel
needed for layer 7 reload support. ok pyr@
2007-06-07(finally) Enable reload support for layer 3 configurations.Pierre-Yves Ritschard
Hoststated can be reloaded either by sending SIGHUP to the parent process or by using ``hoststatectl reload'' discussed and ok reyk@
2007-05-31simplify pfe_disable_eventsPierre-Yves Ritschard
2007-05-31split pfe's event registration in separate functions (like for hce)Pierre-Yves Ritschard
2007-05-31allocate table lists and service lists instead of using static structs.Pierre-Yves Ritschard
split the code to start the event loop in two functions. introduce merge_config which will be used later on.
2007-05-29when the time comes, let pfe_dispatch_parent be able to service morePierre-Yves Ritschard
than one message.
2007-05-29allow the control handling code to send messages back to the parent.Pierre-Yves Ritschard
forward IMSG_CTL_RELOAD which ends up not doing anything for now.