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`.
Vincent Bernat [Fri, 13 Feb 2015 18:58:32 +0000 (19:58 +0100)]
interfaces: fallback to link local addresses for management
When no global address is found for a family, we fallback to a link
local address instead. For IPv4, this is 169.254.0.0/16 and for IPv6,
this is fe80::/64.
Vincent Bernat [Wed, 28 Jan 2015 13:50:12 +0000 (14:50 +0100)]
priv: rename "gethostbyname" priv function to "gethostname"
Because, it is not a wrapper around `gethostbyname()` but a way to get
local hostname. It currently uses `gethostbyname()` and therefore relies
on the presence of an IPv4 address in the system.
Vincent Bernat [Sun, 4 Jan 2015 17:13:23 +0000 (18:13 +0100)]
lldp: when MSAP changes, send a shutdown LLPDU
Chassis ID and port ID are not supposed to change. However, it is
possible for the port ID to change (for example, if the port name
changes or if the MAC addresses change). Since they should be constant,
we "fix" that by sending a shutdown LLPDU before any broadcasting any
change.
As a provision, this also applies to chassis ID even if it is currently
not possible for it to be changed.
Vincent Bernat [Mon, 15 Dec 2014 07:54:25 +0000 (08:54 +0100)]
man: `-I` option and the like also affect sending
Instead of using `listen` to describe the `-I` option, specify that it
also used to decide which interfaces LLDP will be enabled on, both for
listening and sending.
Vincent Bernat [Thu, 4 Dec 2014 00:02:29 +0000 (01:02 +0100)]
lldpd: decrease probability of collisions on port checksums
Instead of a 16-bit checksum, we use two 16-bit checkums, one for each
half of the serialized port. We now need more than 70000 ports to get a
50% chance of collision while we previously needed only 300 ports.
Vincent Bernat [Wed, 3 Dec 2014 21:05:34 +0000 (22:05 +0100)]
lldpd: fix timer initialization when checksum is 0
If the checksum computed over the port happens to be 0, the LLDPDU is
never scheduled for emission on this port. We ensure that a computed
checksum is never 0. If two different ports happen to have the same
checksum, we consider it unlikely enough to bear with the fact that the
timer will not be reset in this case.
Vincent Bernat [Tue, 4 Nov 2014 19:51:00 +0000 (20:51 +0100)]
lib: bump versioning
Even if the ABI stays the same, the ability to pass NULL is an interface
change (backward compatible). We don't want new versions of lldpcli to
interact with an old version of the library.
Vincent Bernat [Sun, 2 Nov 2014 15:25:21 +0000 (16:25 +0100)]
client: fix configuration modification
Handling of configuration change was messy. Whatever configuration item
needed to be updated, a whole lldpd_config structure was sent. The
daemon part was trying to guess what changed by assuming non-0 fields
need to be updated. However, when flags were added, the implementation
became inconsistent. Some flags used 1/2 for true/false, some others
kept 0/1. So, some flags were detected as changed while they were not.
Since we require to provide a current configuration before making any
change, we just copy the whole structure, modify what we want and send
it to the daemon. The daemon will then compare the new structure with
the old one to detect changes. Flags that were using 1/2 logic are now
just using 0/1 like others.