Vincent Bernat [Wed, 20 May 2015 06:54:05 +0000 (08:54 +0200)]
build: compile libevent with -fPIC
When embedded, libevent is configured with `--disable-shared
--enable-static`. This makes libevent compiled without `-fPIC` and we
cannot build a PIE. Use `--with-pic` to force compilation with `-fPIC`.
Vincent Bernat [Tue, 19 May 2015 13:05:13 +0000 (15:05 +0200)]
build: add a switch to disable hardening functions
Even when the tests succeed, on some platforms, hardening CFLAGS
fail. For example, this is the case on OpenWRT. It seems that the
executable needs to be linked to libssp. Difficult to test if the
problem only happens at runtime since we can execute anything.
Vincent Bernat [Thu, 14 May 2015 22:45:51 +0000 (00:45 +0200)]
frame: change checksum function
At the end of function, we used to call ntohs() but we also call the
same function before providing the checksum to POKE_UINT16 (which will
in turn call ntohs). We remove those two first extra calls as they
aren't necessary.
Moreover, the SNMP agent uses this function and this makes it
endian-dependant. We don't want that.
The function is quite convulated and isn't a classic checksum
function. I don't remember how I came with this function but since there
is the special case for Cisco devices and I know this special case work
now, I don't want to change to another function which may breaks this
special case.
Add a NEWS entry to let people know, just in case.
Vincent Bernat [Sun, 10 May 2015 10:58:16 +0000 (12:58 +0200)]
build: automatic detection of optional features
`./configure` can now detect optional features. This works with XML and
JSON output as well as for SNMP support. The defaults are still the
same, so a user has to pass `auto` keyword to the requested option (for
example `--with-json=auto`).
This is a huge commit, but 90%+ of it is just splitting
'lib/atom-private.c' into smaller atoms and putting them
into the 'lib/atoms' folder.
Some glue code has been added, for constructing maps and builders.
For the 'struct atom_builder' type a 'nextb' field has been
appended at the end, to help make it a single-linked list of
'struct atom_builders's.
The 'next' field in 'struct atom_builder' is taken (hence 'nextb').
For the maps, a wrapper struct (called 'struct atom_map')
has been added on top of 'lldpctl_map_t' in order to create
single-linked list construct of maps.
The struct looks like:
struct atom_map {
int key; /* lldpctl_key_t equivalent */
struct atom_map *next; /* next 'struct atom_map' */
lldpctl_map_t map[]; /* has to be at the end to
to be statically init-ed */
}
The point of this is to register them at load-time so
that 'lldpctl_key_get_map()' can return them.
Each file in 'lib/atoms' registers it's own 'struct atom_builder's
and 'struct atom_map's.
The whole point of this is to be able to add a 'custom' and/or
'custom_list' atom(s) to be able to configure/broadcast other TLVs
in the future.
This mechanism is extensible to add other TLVs defined by
future standards.
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Vincent Bernat [Sat, 28 Mar 2015 08:57:43 +0000 (09:57 +0100)]
interfaces: management address is set to pattern on exact match
When the management pattern is an exact IP address, use it as is instead
of trying to match an interface. When a user doesn't want this
behavior (keeping the check), they should use something like
`192.168.1.15,0` or `!*,!!192.168.1.15` instead of the exact IP address.
This feature allows a user to advertise an out-of-band management IP
address.
Vincent Bernat [Wed, 18 Mar 2015 14:42:24 +0000 (15:42 +0100)]
Revert "priv: on Linux, when monitor dies, kill child"
This reverts commit 4747e964096a1b490de062460608805c46f0cfd2. This
commit is now useless due to the previous (more portable) commits. It is
harmless but also unneeded.
Vincent Bernat [Wed, 18 Mar 2015 14:35:10 +0000 (15:35 +0100)]
priv: use SOCK_STREAM for monitor communication
SOCK_SEQPACKET is better but not available everywhere. We can't just
fallback to SOCK_DGRAM since we lose the ability to detect when the
monitor dies. So, we use SOCK_STREAM (now possible with commit 004b5f944539). The code (stolen from OpenBSD) was already ready for
that.
Vincent Bernat [Wed, 18 Mar 2015 14:25:36 +0000 (15:25 +0100)]
priv: ensure we write exactly what will be read
When using SOCK_DGRAM/SOCK_SEQPACKET, it doesn't matter to write a bit
more since it is truncated. However, if we want to switch to
SOCK_STREAM, we must exactly write the right amount of bytes.
Vincent Bernat [Wed, 18 Mar 2015 14:14:41 +0000 (15:14 +0100)]
ctl: create control socket with close-on-exec semantic
Otherwise, when we spawn lldpcli, it inherits the file descriptor and
doesn't detect if the daemon dies just after because it is listening
itself to the Unix socket.
Vincent Bernat [Wed, 18 Mar 2015 13:21:46 +0000 (14:21 +0100)]
priv: use a SOCK_SEQPACKET for communication with monitor
This has the same semantics than SOCK_DGRAM but it also supports the
ability to notify the other end of end-of-file events. However, it may
not be widely implemented, hence the separate commit.
Vincent Bernat [Wed, 18 Mar 2015 09:00:44 +0000 (10:00 +0100)]
priv: on Linux, when monitor dies, kill child
When the monitor dies, it sends its child a TERM signal but if it
segfaults or is killed with an uncatchable signal, the child will
continue to run "unharmed". On Linux, it is possible to send a signal to
the child in this case, with `prctl()`. Do that.
Vincent Bernat [Thu, 19 Feb 2015 15:52:55 +0000 (16:52 +0100)]
configure: move CFLAGS/CPPFLAGS to LLDP_CFLAGS/LLDP_CPPFLAGS
The goal is to avoid the user to override those flags when using `make
CFLAGS=somethingelse`. This is to enable a user to use `make
CFLAGS=-Werror` since this flag cannot be used with `./configure`.