Vincent Bernat [Fri, 12 Mar 2010 13:47:05 +0000 (14:47 +0100)]
Allow to force a protocol.
This fixes ticket #34. By using the option to enable a protocol twice,
we are able to speak a protocol even when no peer is detected. In this
case, packets are sent even when another protocol is detected. A new
parameter has been added to get this behaviour for LLDP as well.
Vincent Bernat [Fri, 12 Mar 2010 16:12:52 +0000 (17:12 +0100)]
Remove unused chassis in lldpd_cleanup() instead of lldpd_port_cleanup().
In some cases, lldpd_port_cleanup() is called when a reference to the
chassis that will be removed is hold for updating. This happens when
we need to update the information on a chassis known by only one port:
1. we find that the chassis is still the same
2. we remove the port and hence remove the chassis which becomes
unused and freed
3. with the previous reference to the chassis, we try to update it
with new information while it has been freed.
Freeing in lldpd_cleanup() is more natural and less risky.
Vincent Bernat [Fri, 12 Mar 2010 11:03:24 +0000 (12:03 +0100)]
Retrieve FD_SETSIZE in a sane environment.
Since we import linux/if.h, in some environment, we may end up
importing kernel FD_SETSIZE that may be inappropriate (too large). For
example, on Sarge systems, FD_SETSIZE becomes 8192 instead of 1024 but
FD_ISSET is unable to handle this size.
Vincent Bernat [Wed, 10 Mar 2010 07:22:40 +0000 (08:22 +0100)]
Increase refcount of the local chassis when a new port is created.
Also add an explanation of refcount handling in a part of the code
that was a bit difficult to follow. Now, each time that p_chassis is
affected to a new value, c_refcount should be updated accordingly.
Vincent [Sat, 6 Mar 2010 08:53:40 +0000 (09:53 +0100)]
Avoid dereferencing a type-punned pointer.
When passing a file descriptor, we were dereferencing a unsigned char
pointer. This breaks strict-aliasing rules in C99. Moreover, we should
care about the alignment (even if in this case, this is aligned
because the previous member of the struct is an int). Therefore, we
use memcpy instead.
Vincent [Sat, 6 Mar 2010 08:41:53 +0000 (09:41 +0100)]
Free unused chassis.
When reference count for a chassis drops to 0, we free the chassis.
This cannot happen to the local chassis because a reference should be
held to it even without any local port.
Make lldpctl refuse attempts to change anything when running setuid.
When running setuid, lldpctl now refuses to set location data. This should
make it save to run the program setuid root by normal users including a
web-server f.e.
Vincent [Sat, 27 Feb 2010 09:18:03 +0000 (10:18 +0100)]
Allow to specify the AgentX socket to use (instead of the default one).
This means that AgentX can be configured to use tcp:127.0.0.1:705 (for
example). Since we are running in a chroot, we cannot use hostnames.
Any network socket should work. Unix sockets should work as before
(using privilege separation).
Vincent [Sat, 27 Feb 2010 08:53:38 +0000 (09:53 +0100)]
For Redhat, adapt init.d script to initialize the chroot.
The chroot is an empty directory containing a copy of /etc/localtime
to enable the use of the correct timestamp when logging for the
process trapped in the chroot.
Peter Kjellström [Fri, 12 Feb 2010 11:31:13 +0000 (12:31 +0100)]
Change handling of conditional builds in the spec file
Change handling of build options from using simple define statements
to using the RPMs bcond_without functionality. bcond_without instead
of bcond_with ensures that the old behaviour is preserved (all
options are still enabled by default). This change allows the
convenient "rpmbuild --without xxx" and is in line with:
Vincent Bernat [Sat, 5 Dec 2009 10:58:51 +0000 (11:58 +0100)]
Don't set MFS with MTU value.
Because there is no way to retrieve MFS value from Linux (unless we
try to set it to some arbitrary value), we did use the MTU instead.
This is incorrect, as notified in ticket #31.
Since some equipements could use this value to trigger an alert, we
prefer not to send any value. We don't seem able to detect for VLAN
support or Jumbo frames support.
Vincent Bernat [Wed, 28 Oct 2009 10:38:03 +0000 (11:38 +0100)]
Make netsnmp headers compatible with C99.
Disable inlining by adding -DNETSNMP_NO_INLINE to CFLAGS. Since we
only use header files, this should not be a problem. A more valid fix
would be to turn NETSNMP_INLINE into "extern inline" instead of just
"inline".
Without this fix, we get a lot of warnings with gcc 4.3.
Vincent Bernat [Thu, 15 Oct 2009 10:18:45 +0000 (12:18 +0200)]
Get timezone info before being in the chroot.
Depending on the libc, first implicit call to tzset() can be done when
invoking syslog() the first time. In most situation, this is done when
we are in a chroot and therefore, we cannot read /etc/localtime and
get an accurate timezone information. Therefore, we invoke tzset()
before being in chroot.
Vincent Bernat [Tue, 29 Sep 2009 14:44:59 +0000 (16:44 +0200)]
Rework autoconf stuff.
Update to autoconf 2.64.
Use custom macro for ethtool, netsnmp and argument handling to shorten
main configure.ac file.
Use less verbose build process by default.
For headers, missing header is fatal for now because we don't know how
to replace them. Better handling will be done later. We only target
Linux for now with GNU LibC: portability issues are narrow.
Some useful documentation about autoconf:
http://sources.redhat.com/autobook/ (a bit outdated)
http://www.freesoftwaremagazine.com/books/autotools_a_guide_to_autoconf_automake_libtool
http://www.flameeyes.eu/autotools-mythbuster/
Vincent Bernat [Thu, 24 Sep 2009 09:28:24 +0000 (11:28 +0200)]
Include manual pages into distribution.
By default, manual pages are not included in "make dist". We add them
by adding them in EXTRA_DIST. See:
http://gnu.huihoo.org/automake-1.4/html_node/automake_50.html
Vincent Bernat [Thu, 24 Sep 2009 08:27:15 +0000 (10:27 +0200)]
Use "void" instead of empty parameter list for function prototypes.
Using empty parameter list means that we don't know what are the
parameters of a function, while using "void" means that there is no
parameter for this function. Some compilers are ticky about this. See
C99 6.11.6 and 6.7.5.3 §14.
This also allows to fix a little bug: priv_ctl_create was called with
a parameter.
Vincent Bernat [Thu, 24 Sep 2009 08:13:27 +0000 (10:13 +0200)]
Use libtool convenience libraries for common files for lldpd and lldpctl.
Instead of directly linking common files, we use another libtool
convenience library (libcommon.la). We also separate server part of
ctl.c into a separate file to avoid -DCLIENT_ONLY flag which was
causing recompilation of most files.
We also move compatibility objects (like strcpy() function) into
libcommon.la.
Vincent Bernat [Thu, 9 Jul 2009 18:10:43 +0000 (20:10 +0200)]
Compilation fix for ancient gcc.
gcc 2.96 does not like "char frame[]" declaration and complains with
"array size missing in frame'". We circumvent this limitation by using
a one byte array instead of an undefined one.
Vincent Bernat [Wed, 23 Sep 2009 07:14:50 +0000 (09:14 +0200)]
Add '-k' flag to disable kernel version advertising.
From a suggestion and a patch proposed in ticket #19. With this flag,
system description is just the kernel name and software version as
advertised if LLDP-MED is enabled is set to "Unknown".
Vincent Bernat [Sun, 5 Jul 2009 17:30:56 +0000 (19:30 +0200)]
Unit tests for packing/unpacking.
We build a static library liblldpd.la to ease linking to tests.
liblldpd.la is equal to lldpd except:
- no main (but lldpd_main instead)
- no link to netsnmp (because libtool try to link many many more
things)
Vincent Bernat [Wed, 10 Jun 2009 13:22:29 +0000 (15:22 +0200)]
Use ifAlias from newer Linux kernels if available.
From 2.6.28, Linux allows to attach a description to an interface. We
grab this description from /sys/class/net/$IFACE/ifalias if it exists
and is not empty and use it as port description. In this case,
interface name is used as port ID.
Vincent Bernat [Tue, 9 Jun 2009 05:42:32 +0000 (07:42 +0200)]
Set h_ifindex correctly.
We also use this index as a way to define an interface. The following
comment has been added to lldpd.h:
An interface is uniquely identified by h_ifindex, h_ifname and h_ops.
This means if an interface becomes enslaved, it will be considered as
a new interface. The same applies for renaming and we include the
index in case of renaming to an existing interface.
Vincent Bernat [Sun, 24 May 2009 17:33:28 +0000 (19:33 +0200)]
Fix support for EDP with respect to multisystem support.
EDP VLAN are transmitted in another VLAN and therefore need to be
attached to the right existing system.