Vincent Bernat [Mon, 4 Feb 2013 07:38:08 +0000 (08:38 +0100)]
build: check if libevent as provided by pkg-config is working
If a user installs both libevent 2.0.x and libevent 1.4.x, pkg-config
may report libevent 2.0.x where it really is 1.4.x. The system is
broken in this case but we work-around this by using the shipped
libevent.
Vincent Bernat [Sun, 3 Feb 2013 08:38:19 +0000 (09:38 +0100)]
interfaces: whitelist an interface before being checking lower
Some whitelisted interfaces, like dsa, have a lower interface in
managed mode but we still want to advertise on it. Move the check for
lower interface after whitelisting.
Vincent Bernat [Tue, 29 Jan 2013 20:42:37 +0000 (21:42 +0100)]
libevent: produce smaller binaries when shipping libevent
When shipping libevent, we try to build smaller binaries by disabling
unneeded stuff (openssl, threading, malloc replacement, debug stuff)
and enabling `--gc-sections`. On various tests, this remove 80K from
lldpd size (stripping excluded).
Vincent Bernat [Sat, 19 Jan 2013 15:13:50 +0000 (16:13 +0100)]
lldpd: invoke lldpcli at start
To configure itself, lldpd now invokes lldpcli when
starting. Currently, it does not really check if everything works as
expected but in the future, lldpcli will ask lldpd to "start".
The configuration files are:
- ${sysconfdir}/lldpd.conf
- ${sysconfdir}/lldpd.d/*.conf
Vincent Bernat [Thu, 17 Jan 2013 21:01:34 +0000 (22:01 +0100)]
priv: add ability to lock filter on Linux
This is a new feature which should be available in Linux 3.9. See:
http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git;a=commit;h=d59577b6ffd313d0ab3be39cb1ab47e29bdc9182
Vincent Bernat [Thu, 17 Jan 2013 08:02:48 +0000 (09:02 +0100)]
priv: create chroot if it does not exist
This is not the ideal situation since the chroot should maybe contain
some additional stuff (like `/etc/localtime` with GNU libc) to make it
work properly, but this is more convenient that leaving the user does
exactly the same things. Packagers are still expected to populate the
chroot correctly before starting lldpd.
Vincent Bernat [Mon, 14 Jan 2013 09:21:13 +0000 (10:21 +0100)]
priv: lock BPF interface on BSD
We move all BPF setup in the monitor process. When the socket is
configured, we lock it. This works for both OpenBSD and FreeBSD. This
feature does not seem to exist on Linux. However, for consistency, we
also move BPF filter setup in priv.c for Linux.
Vincent Bernat [Sun, 13 Jan 2013 12:15:52 +0000 (13:15 +0100)]
snmp: workaround unknown value for RONLY
This happens when Net-SNMP has been compiled with
NETSNMP_NO_LEGACY_DEFINITIONS defined. For example, on Mac OS X. This
seems a good way to deprecate an API still widely used just because it
is not used internally... <grin>
Vincent Bernat [Sun, 13 Jan 2013 01:53:37 +0000 (02:53 +0100)]
Small fixes detected by clang analyzer.
- log: mark `fatal*()` function as noreturn
- event: insert client in the list after its creation
- lldpcli: avoid confusion by initializing cargc to 0
- lldpd: avoid ambiguous use of strlen() in initialization
- lldp/edp: fix memory leaks
- tokenizer: fix a memory leak in low memory condition
- cdp: don't accept too short TLV for port description
Vincent Bernat [Sat, 12 Jan 2013 23:23:53 +0000 (00:23 +0100)]
build: more changelog drama
We need ChangeLog to be listed in `dist_doc_DATA` or
`doc_DATA`. Therefore, we list it in the former and if we happen to
install from git, we just ship an empty ChangeLog.
Vincent Bernat [Fri, 11 Jan 2013 00:25:32 +0000 (01:25 +0100)]
build: fix changelog generation
We really only want to generate changelog when building the dist
tarball. We force its generation using a fake PHONY target. We don't
list it as a dist_* something since it does not exist yet. Therefore,
we don't have to clean it.
Vincent Bernat [Thu, 10 Jan 2013 19:23:57 +0000 (20:23 +0100)]
Mac OS X support.
This includes bond, VLAN and bridge support. Mac OS X is pretty
similar to FreeBSD except for bonding which is different. Bonding code
is stolen from ifconfig.c. Header files from XNU are
shipped because they are missing from Mac OS X developer tools.
Still missing:
- integration into launchd
- homebrew formula
- DMI part (through ioreg)
Vincent Bernat [Mon, 7 Jan 2013 20:59:32 +0000 (21:59 +0100)]
priv: mirror the exit status of the child
When exiting because the child has exited, the privileged processus
will mirror the exit status and the signal that killed the child if
any. This allows monitoring daemon like systemd to detect an
unexpected exit.
Vincent Bernat [Sun, 6 Jan 2013 23:24:31 +0000 (00:24 +0100)]
debian: provide an upstart job
lldpd daemonization seems to confuse upstart (I think this is because
it also forks the monitor process, otherwise the daemonization is
pretty classic). Therefore, when we detect we are run by
upstart (because of UPSTART_JOB variable), we raise the SIGSTOP signal
instead of daemonizing. Upstart notices it and will resume us and
consider we are ready. No more misleading fork.
Vincent Bernat [Sun, 6 Jan 2013 13:45:53 +0000 (14:45 +0100)]
build: fix generation of ChangeLog
We must be able to have one when git is not present because we include
it in dist, but we also must generate it on each release. The previous
fix would keep the ChangeLog empty or not updated. We use a PHONY
target instead (and not a real PHONY target since we cannot add it
because automake doesn't like it).
Vincent Bernat [Sun, 6 Jan 2013 10:43:33 +0000 (11:43 +0100)]
lldpcli: make readline library optional.
And improve compatibility. We should be compatible with BSD
libedit. However, we are not compatible with older versions that lack
`rl_insert_text()` and `rl_delete_text()`.
Vincent Bernat [Sun, 6 Jan 2013 09:47:21 +0000 (10:47 +0100)]
lldpcli: switch to GNU Readline.
libedit is not available on old versions of Linux distro. We try to
use Readline API instead which may be compatible with the libedit
version available in BSD.
This means that we have to write our own tokenizer. This also means
that we can make Readline optional.
Vincent Bernat [Sat, 5 Jan 2013 15:59:41 +0000 (16:59 +0100)]
configure: detect libedit without pkg-config
BSD comes with libedit shipped and without pkg-config being able to
detect it. Fallback to manual detection of the headers and check if we
can compile a program with it.
Vincent Bernat [Sat, 5 Jan 2013 12:24:10 +0000 (13:24 +0100)]
lib: add a function to retrieve a map
Some values can only take a discrete number of int values. We have a
map to display them as string. We provide this map through a function
and we also accept values from this map as string input. This is a
slight change in the API but it should be backward compatible.
Vincent Bernat [Mon, 31 Dec 2012 17:57:07 +0000 (18:57 +0100)]
*bsd: listen on PF_ROUTE socket to get interface changes
Only OpenBSD is able to filter messages. We could filter messages for
FreeBSD and NetBSD after receiving them but we don't bother doing
it. Any change will trigger a rescan of the interfaces. Since this
cannot happen more than once per second, this should be OK for most
people.
Vincent Bernat [Mon, 31 Dec 2012 17:25:42 +0000 (18:25 +0100)]
event: use a separate event timer for each port
Each port will have its own live with its own timer. If a port just
appeared, it will have its own 30 seconds timer. We also notice
changes independently on each port, so the timer is reset on each
change on a given port.
Also, as a safeguard, update port-related information every 10
minutes. We can catch changes in addresses this way (otherwise,
detecting them via netlink is noisy).
Vincent Bernat [Sun, 30 Dec 2012 18:12:52 +0000 (19:12 +0100)]
marshal: ensure that two identic structures are serialized in the same way
Because we serialized pointers unchanged and use them to track
substructures, two identic structures located at different places in
the memory were serialized as two different buffers. It is easy to use
"dummy" pointers instead of real ones and then be able to compare two
structures by serializing them and compare the resulting buffers.
However, those two structures should be calloced to make this
works. When allocating from the stack, use of designated initializers
don't mean anything about padded memory (no guarantee that it will be
set to 0).
Vincent Bernat [Sun, 23 Dec 2012 10:11:38 +0000 (11:11 +0100)]
netlink: listen to netlink changes to trigger interface updates
This allows to detect "link down" or new interfaces in a timely
manner. There is still a global event loop for sending LLDPDU to each
port (no per-port sending loop).