Commit Graph

338 Commits

Author SHA1 Message Date
Paul Gardner-Stephen
8231c7728a fix compilation warnings with gcc 8 2020-07-10 09:28:02 +09:30
Andrew Bettison
f91033820b Use explicit serverMode enum values everywhere 2018-06-01 17:40:09 +09:30
Jeremy Lakeman
35fefb1680 Fix compilation and real interfaces on android 2018-04-10 10:52:44 +09:30
Andrew Bettison
cf9e0b4730 Keep AF_UNIX and file-based interfaces up whenever config re-loads
Whenever the daemon re-loads its config, it keeps any socket-based
(AF_INET) SOCK_DGRAM interfaces open that are matched by the new config,
but it used to close and then re-open all local (AF_UNIX) interfaces and
file-based interfaces such as SOCK_FILE dummy files and SOCK_STREAM
device files.  This made it very difficult to develop the new
'routejava' test suite, because the Java API test harness always causes
a config re-load when it sets the REST API user/password in the config,
which caused the local socket interfaces to bounce, which interfered
with the reachability of nodes.

Now, local socket and file-based interfaces remain up after a config
re-load, as long as they are still matched by the new configuration.

Added INFO messages for interfaces that remain up after a config
re-load, and tweak interface up/down INFO messages to be consistent.
2018-04-05 18:12:23 +09:30
Jeremy Lakeman
d844b0f6bd Reduce coupling with console, dna_helper, monitor & directory_client features 2018-04-03 14:32:06 +09:30
Andrew Bettison
c35af0617a Fix header files for Xcode iOS build
- make "debug.h" a private header so that the DEBUG() macro does not
  interfere with Xcode Debug builds, which set DEBUG=1
- move all #include "debug.h" from headers into .c files
- move 'struct idebug' into a new public header "idebug.h" so that
  "log.h" can be public
- move HTTPD port number defs from "httpd.h" to "constants.h", so that
  "httpd.h" can be private and "conf.h" can be public
- add missing nested includes so each header compiles stand-alone
  without error
- #include "sodium.h" instead of <sodium.h>
- #include "sqlite3.h" instead of <sqlite3.h>
- add header guard to "fifo.h"
- fix header guard in "sync_keys.h"
2018-03-06 15:29:29 +10:30
Andrew Bettison
92fa6c196a Rewrite logging system
Rename the logging primitive functions and utility functions, prefixing
all with 'serval_log', eg: logMessage() -> serval_logf() etc.

Add an XPRINTF xhexdump() function and use it to implement the
serval_log_hexdump() utility, renamed from dump().  Add macros
WHY_dump(), WARN_dump(), HINT_dump() and DEBUG_dump(), and use them
everywhere.

Remove the 'log.console.dump_config' and 'log.file.dump_config'
configuration options; configuration is now dumped in every log prolog.

The logging system now constructs the log prolog by invoking the new
'log_prolog' trigger, so that it no longer depends on the version string
and configuration system.  Any system that wants to present a message in
the log prolog can define its own trigger, which calls standard log
primitives to print the message.

Split the logging system into a front-end (log.c) that provides the
logging primitives and is independent of the configuration system, and a
set of back-end "outputters" (log_output_console.c, log_output_file.c,
log_output_android.c) that may depend on the configuration system and
are decoupled from the front-end using the 'logoutput' link section.

These log outputters are explicitly linked into executables by the
Makefile rules, but could also be linked in using USE_FEATURE().  The
USE_FEATURE() calls have _not_ been added to servald_features.c, so that
different daemon executables can be built with the same feature set but
different log outputs.
2018-03-06 15:16:56 +10:30
Jeremy Lakeman
bb7d95ccd1 Log error reason if we fail to detect interface type from reading /sys/net 2017-11-20 15:05:36 +10:30
Jeremy Lakeman
577fbb34db Don't attempt to calculate the next alarm if the interface just went down 2017-11-20 10:39:32 +10:30
Jeremy Lakeman
ce2c276570 Detect Wifi and cabled ethernet on linux systems, allow matching by type in config 2017-11-07 16:53:19 +10:30
Jeremy Lakeman
0382e7990e Enable a more graceful shutdown of the server in most cases 2017-09-12 15:37:52 +09:30
Jeremy Lakeman
e158a38137 Clean up a number of memory leaks, as revealed by clang's sanitiser 2017-09-11 14:09:27 +09:30
Jeremy Lakeman
cf4306cff2 Fix warnings on android ndk 2017-08-29 13:19:35 +09:30
Jeremy Lakeman
0cc0f37b52 Failures to set socket options should only be warnings 2017-06-28 10:48:48 +09:30
Jeremy Lakeman
73136461ad Use offsetof macro for all AF_UNIX address length calculations 2017-04-26 15:52:33 +09:30
Andrew Bettison
1efe6686fc Use config.h instead of -DHAVE_FOO=1
swiftc(1) requires every -D option to be prefixed with -Xcc, which
is not easy to achieve using autoconf.

Now instead of setting configuration macros like HAVE_LSEEK64 on the
command line using -D, they are defined in config.h, which is generated
by ./configure, ignored by Git, and included by all headers and source
files that use any configuration macro.

The dependency on Makefile has been replaced with a dependency on
Makefile.in and config.h, which helps avoid some redundant full
recompiles after running ./configure, because the configure script
does not overwrit config.h if its content does not change.
2016-10-19 16:27:20 +10:30
Jeremy Lakeman
b55926b081 Add configuration for idle_tick_ms so tests can complete faster without wasting power 2016-05-10 11:19:49 +09:30
Jeremy Lakeman
c78ee668d5 Add interface index to UP/DOWN monitor message 2016-04-27 13:16:00 +09:30
Jeremy Lakeman
884a6211eb Remove overlay_interface_find_name 2016-04-27 13:10:31 +09:30
Jeremy Lakeman
c04d015bc6 Don't continuously toggle fd blocking mode 2016-03-30 16:25:43 +10:30
Jeremy Lakeman
cf8932d5ba Use trigger for interface up/down 2016-03-08 10:16:20 +10:30
Jeremy Lakeman
b8f10fd40d Delay interface re-detection after errors to rate limit continuous failures 2016-02-10 10:23:27 +10:30
Jeremy Lakeman
389f16d2bb Establish a unicast link to a configured host on demand 2016-01-27 16:27:47 +10:30
Jeremy Lakeman
d0da910b19 Avoid undefined behaviour as highlighted by clang 2016-01-27 16:27:47 +10:30
Andrew Bettison
c3375d0501 Fix MDP client packet receive bug on OSX
Was failing because recvmsg(2) on OSX does not nul terminate the
pathname of local (AF_UNIX) sockets in the returned sockaddr buffer.
Zerofilling the buffer before calling recvmsg() does the trick.

In the process, improved debug and error logging, replacing
recvwithttl() with recv_message() and recv_message_frag().  The
mdp_net.c source file was retired.
2016-01-19 04:05:46 +10:30
Jeremy Lakeman
88020a840d Add size cast to avoid compilation warning for some linux compilers 2016-01-11 14:52:29 +10:30
Jeremy Lakeman
912806360c Tweak netlink setup code in an attempt to prevent gcc mis-optimization 2016-01-11 14:40:23 +10:30
Jeremy Lakeman
fd38ddb892 Attempt to recover from transient network errors 2015-11-23 09:48:51 +10:30
Jeremy Lakeman
a075a8edbc Retry socket binding when interfaces come up 2015-11-16 12:54:59 +10:30
Andrew Bettison
a060642fdb Add strbuf_local_buf() macro 2015-11-02 10:11:41 +10:30
Andrew Bettison
3ab7e04497 Add buf_strncpy_nul(), use in place of strlcpy() 2015-11-02 10:11:41 +10:30
Jeremy Lakeman
0c275e67ef Clean up compilation warnings 2015-10-19 13:45:57 +10:30
Jeremy Lakeman
3049252c8a Poll netlink socket for interface changes on linux systems 2015-10-12 18:11:44 +10:30
Jeremy Lakeman
79e8a94792 Add route_link.h 2015-09-28 11:58:48 +09:30
Andrew Bettison
7d9a5faa4e Move if(config.debug.xxx) tests into DEBUGF()
Original DEBUG() and DEBUGF() macros renamed to _DEBUG() and _DEBUGF()
New DEBUG() and DEBUGF() macros, first argument is flagname
New DEBUGF2(foo, bar, ...) macro does if(config.debug.foo||config.debug.bar) test
Replace almost all config.debug.xxx references to IF_DEBUG(xxx)
2015-07-13 16:00:05 +09:30
Jeremy Lakeman
fea91f3f82 Use configured reachable timeout for network links, read dummy files even when not ticking 2015-03-30 17:38:40 +10:30
Jeremy Lakeman
b048e8874f Reschedule alarm when tick_ms config changed 2015-03-23 13:35:22 +10:30
Jeremy Lakeman
f7dbe06836 Rearrange interface config to support unicast settings 2015-03-23 13:35:22 +10:30
Jeremy Lakeman
a9b9f51a9f Add support for mdp clients to provide a link layer packet transport 2015-03-02 15:44:34 +10:30
Andrew Bettison
7248d660e3 Fix non-deterministic assertion failure under load 2014-11-12 23:09:00 +10:30
gardners
6dca9fe6bf ensure netmask is set when initialising an interface. 2014-10-31 15:01:22 +10:30
gardners
6536953703 add debug output to diagnose interface selection based on
received address of packet.
2014-10-31 12:26:58 +10:30
Jeremy Lakeman
a37db8e958 Move most console commands to other files 2014-08-25 16:03:30 +09:30
Jeremy Lakeman
537a09812c Ignore some types of sendto errors 2014-06-27 12:45:53 +09:30
Jeremy Lakeman
f4e6841ed7 Ensure directory service tests aren't creating a global routing table 2014-06-16 17:22:46 +09:30
Jeremy Lakeman
dabd482ad8 Only send broadcast ticks every 5 seconds when we have no neighbours 2014-06-13 15:34:47 +09:30
Jeremy Lakeman
628a52ca87 Add monitor message for interface up/down events 2014-06-13 13:34:10 +09:30
Jeremy Lakeman
e5e848e838 Ensure interface and routing alarms stop when network interfaces are all down 2014-06-12 16:04:15 +09:30
Jeremy Lakeman
f93fba11af Stop polling interfaces if no phsical interfaces are enabled 2014-06-04 17:13:08 +09:30
Jeremy Lakeman
b6de3fcd34 Only send rhizome sync packets when we have neighbours 2014-05-30 15:03:22 +09:30