Vincent Bernat [Fri, 4 May 2012 20:22:56 +0000 (22:22 +0200)]
automake: libevent.la is not a convenience library
Since libevent.la is not a convenience library, we cannot merge it
into liblldpd.la. Therefore, we link it to lldpd directly (and don't
try to build a convenience library from it).
Vincent Bernat [Fri, 4 May 2012 09:48:40 +0000 (11:48 +0200)]
marshal: use zero-sized array instead of flexible arrays
With gcc 2.96, flexible arrays are not supported, even with
-std=gnu99. And with gcc 3.x, zero-sized arrays cannot be statically
initialized (with more than one element).
Vincent Bernat [Tue, 1 May 2012 13:28:41 +0000 (15:28 +0200)]
configure: enable compilation of a libevent archive
README.md has been updated for those instructions. We still rely on
libtool to make this work. Unfortunately, the generated libtool comes
too late: we can't use it...
Vincent Bernat [Mon, 30 Apr 2012 23:33:42 +0000 (01:33 +0200)]
lldpd: switch to libevent loop
This is a major change. Instead of a custom loop, we switch to
libevent. Only `levent.c` is aware of the event loop. Other parts do
not manipulate events. Currently, we still have a loop triggered every
30 seconds. This could change to be a per port handling.
Vincent Bernat [Fri, 27 Jan 2012 11:30:41 +0000 (12:30 +0100)]
configure: upgrade to libevent 2.x
Also, when linking with a static version of libevent, we enforce the
use of libtool ".la" file instead of ".a" to get appropriate
dependencies automatically and avoid a warning when linking inside a
".la".
Vincent Bernat [Thu, 1 Jul 2010 09:29:48 +0000 (11:29 +0200)]
Integration of libevent into the build system.
"configure" will check that libevent is present. It is possible to use
--with-libevent option to tell where libevent lives. We include the
possibility to use a static copy of libevent but with the absence of a
.pc file, we are not sure to handle all the dependencies correctly.
README file is updated with instructions about libevent, including
steps to build libevent inside lldpd.
Vincent Bernat [Tue, 1 May 2012 08:54:05 +0000 (10:54 +0200)]
lldpd: fix chassis copy
When a chassis is already known, we copy the new one over the old one
and keep the old one. With the addition of management addresses as a
list, the copy was incorrect. We fix it. This is kludgy. A better way
would be to use marshaling but marshaling is not able to do inplace
copy and it is not able to restore full list (previous pointer is not
restored).
Vincent Bernat [Tue, 1 May 2012 08:16:10 +0000 (10:16 +0200)]
valgrind: initialize some buffers to make valgrind happy
Valgrind does not understand some ioctl and thinks we are using
unitialized buffers while the ioctl will initialize them. We get rid
of those warnings by initializing them ourselves.
Vincent Bernat [Mon, 30 Apr 2012 23:50:03 +0000 (01:50 +0200)]
When running on valgrind, don't chroot or drop privileges
Valgrind documentation says:
You are encouraged to copy the valgrind/*.h headers into your
project's include directory, so your program doesn't have a
compile-time dependency on Valgrind being installed. The Valgrind
headers, unlike most of the rest of the code, are under a BSD-style
license so you may include them without worrying about license
incompatibility.
I don't like copying headers around. Therefore, there is an autoconf
check for valgrind headers.
João Valverde [Tue, 6 Mar 2012 14:08:59 +0000 (14:08 +0000)]
Support for multiple IPv4/IPv6 management addresses.
This patch introduces a new 'struct lldpd_mgmt' to store IPv4/IPv6
management addresses. These addresses are stored in a tail queue.
For the local chassis we currently only use one IPv4 and one IPv6 address.
Options for IPv6 addresses are the same as IPv4 (use -6).
Vincent Bernat [Wed, 29 Feb 2012 22:14:41 +0000 (23:14 +0100)]
lldpd: do not stay stuck in the receive loop
On some corner case conditions, we can stay stuck in the receive loop
because we did not send packets for more than 30 seconds. In this
case, we keep reset the timeout to 30 seconds and we cannot exit the
loop (since the first condition to exit the loop is to have reached
the timeout).
Therefore, we invert the condition. If we have stay too long in the
loop, just exit. We know for sure that we will hit lldpd_send_all()
soon and get back to a sane state.
Also, in receive only state, we are also stuck in the loop. This
forbids us to update data about local chassis and interfaces. We also
fix this.
Vincent Bernat [Sat, 25 Feb 2012 08:06:31 +0000 (09:06 +0100)]
redhat: make the init script compatible with RHEL < 5
On RHEL < 5, killproc, daemon and status does not allow to take a
pidfile as argument. We detect this and omit it to provide such an
argument if needed.
Vincent Bernat [Thu, 26 Jan 2012 22:52:13 +0000 (23:52 +0100)]
marshal: circumvent cast alignment problems using memcpy
gcc was issuing warnings like this:
marshal.c:290:5: warning: cast increases required alignment of target type [-Wcast-align]
They are harmless because for one of them, the target has been
malloced (and therefore is safely aligned to 8 bytes) and for the
other because we know that the target location is the location of a
pointer. For those later cases, assignment is replaced by memcpy().
Vincent Bernat [Thu, 26 Jan 2012 22:14:28 +0000 (23:14 +0100)]
Use %zu for printf() when argument is of kind size_t.
%zu is valid in C99 and is supported by GNU LibC. We'll see if there
exists a portability issue. In this case, %lu and a cast to unsigned
long should be used instead.
Vincent Bernat [Tue, 24 Jan 2012 09:59:39 +0000 (10:59 +0100)]
Change the way Chassis ID is assigned.
By default, chassis ID is assigned the chassis name. Once an
appropriate interface is discovered, the chassis ID is changed to the
MAC address of this interface. In most configurations, the chassis ID
is always set to the MAC address of the first interface, like this was
before this patch.
Vincent Bernat [Mon, 23 Jan 2012 18:55:49 +0000 (19:55 +0100)]
marshal: fix list marshalling and various other changes
Since last element and previous element are a pointer to a pointer, we
should handle this case differently. Unit tests are not failing
because the original memory space is still available on the stack. We
just ignore last and previous. This still allows to use the list for
the most useful operations: TAILQ_EMPTY, TAILQ_FOREACH and
TAILQ_REMOVE. We can't use TAILQ_INSERT_TAIL!
Another important change is that by default, macros will declare an
external structure. MARSHAL_EXPORT variable should be defined only for
one module. Otherwise, marshal structures will be defined several
times.
We also rename `_marshal_*` to `marshal_*_`. This enables more
graceful logging messages.
Vincent Bernat [Sat, 21 Jan 2012 13:42:42 +0000 (14:42 +0100)]
Add a new serialization engine.
The chosen approach is totally different compared to the existing
packing mechanism. Instead of describing the struct with some string
and trying to decode the structure like the compiler would do (with
alignments problem), the structure is now described by its size and
the list of pointers in it. Macros are provided to make this
easy. Here is an example:
This enables the use of pointers, with detection of circular
references and therefore support of lists.
While only pointers need to be described, it is also possible to add
sub structure to avoid specifying (again) its list of pointers if it
has already been specified.
The use of this mechanism should simplify the client/server code.
Vincent Bernat [Mon, 2 Jan 2012 07:27:43 +0000 (08:27 +0100)]
core: optimize BPF filter
When monitoring high trafic interfaces, the BPF filter can become
quite important. We optimize it a bit by first checking if the
ethernet address is a multicast one. If it is not, we only have to
check for EDP.
Vincent Bernat [Sat, 31 Dec 2011 09:52:03 +0000 (10:52 +0100)]
configure: check more SNMP stuff.
First, we check that netsnmp_enable_subagent() exists. Otherwise, this
means that Net-SNMP has been compiled without this feature.
Second, we check if <net-snmp/agent/util_funcs.h> header is
usable. There was incomplete installation of files required by this
header with NetSNMP 5.4 and situation got worse with NetSNMP 5.7. If
the header is not usable, we fallback to define the two functions that
we need.
Vincent Bernat [Fri, 2 Dec 2011 06:35:02 +0000 (07:35 +0100)]
Export TZ=/etc/localtime to fix timestamps.
While chrooted, syslog timestamps does not respect the configured
timezone despite the copy of /etc/localtime inside the chroot. Setting
TZ variable seems to fix this problem.
Vincent Bernat [Thu, 3 Nov 2011 21:44:54 +0000 (22:44 +0100)]
Extend whitelist with possibility to blacklist.
It is possible to specify patterns like "*,!eth1" to blacklist "eth1"
or something like "eth*,wlan*,!wlan*master" to listen to all eth
interfaces and wlan interfaces with the exception of interfaces like
"wlan0master".
Vincent Bernat [Wed, 26 Oct 2011 13:56:07 +0000 (15:56 +0200)]
Don't pack struct hmsg since we are not able to do unaligned access on some archs.
Packing was used because data was cast as a pointer and therefore,
header was padded excessively. Since we don't use it as a pointer, we
cast it as an incomplete array of chars. We don't need its size.