Vincent Bernat [Sun, 2 Mar 2014 23:48:55 +0000 (00:48 +0100)]
lib: don't use strlcpy() when strcpy() just works
clang complains when we use strlcpy() with strlen() on the source. The
change was made because some other tools complained that we used
strcpy() instead of a more secure version. Since they don't agree, let's
switch to the saner thing to do: use strcpy() when it is safe to do.
Vincent Bernat [Thu, 20 Feb 2014 20:52:46 +0000 (21:52 +0100)]
lldpcli: check for privileges by checking access to control socket
Instead of relying on having used the suid bit to run the program, we
check if the real UID/GID could have opened the control socket. This
really fix #56.
Vincent Bernat [Thu, 20 Feb 2014 20:37:22 +0000 (21:37 +0100)]
lldpcli: root is privileged
For some reason, this bug was not catched before. It was expected that
`lldpcli` can be installed as suid `_lldpd` to give user read access to
the neighbor information. However, to avoid write access, we checked if
the user was privileged by checking equality of effective and real user
uid. However, even for root, they don't have to match. Maybe they
matched in the past?
Vincent Bernat [Wed, 19 Feb 2014 14:50:41 +0000 (15:50 +0100)]
interfaces: reset router and wlan capability bits
When adding capability for new interfaces, reset them if the interfaces
providing the capability are not present anymore. Also, add stationOnly
capability if no capability is currently present.
Vincent Bernat [Fri, 13 Dec 2013 22:25:04 +0000 (23:25 +0100)]
priv: add the ability to disable privilege separation
This is a compile time switch in ./configure. It should only be used for
debugging purposes or when memory and number of processes matter or for
running on platforms without a real `fork()` syscall. We add it to the
NEWS but we make no further mention in the documentation.
Vincent Bernat [Fri, 13 Dec 2013 21:48:41 +0000 (22:48 +0100)]
privsep: IO should specify the context
Currently, the context is not needed because IO is always done to the
"remote" process. If we remove privilege separation, the remote process
is ourselves and we need to know which file descriptor to use.
Vincent Bernat [Tue, 31 Dec 2013 14:00:23 +0000 (15:00 +0100)]
include: don't ship `linux/socket.h`
It needs to be paired with `sys/socket.h` (and we don't want to ship it
as it is bound to userland interface). On older libc, like Android's
bionic, `sys/socket.h` is almost empty and all the definitions,
including non-kernel related ones, are in `linux/socket.h`. If we ship
our version of `linux/socket.h`, we have an empty `linux/socket.h` and
an empty `sys/socket.h` and almost no definitions.
Since `linux/netlink.h` extract `__kernel_sa_family_t` from
`linux/socket.h` and we don't have it anymore, we just replace its
definition by `unsigned short`. Being a Linux kernel interface, it is
quite unlikely to change anytime soon.
Vincent Bernat [Mon, 9 Dec 2013 21:42:52 +0000 (22:42 +0100)]
lldp: don't hard-code sysname, sysdescr and portdescr
Instead of using "Not received" when we don't have them, just keep a
pointer to NULL. However, we need to handle that gracefully everywhere:
don't send them over SNMP, don't display them in lldpcli, be ready for
the fact that it should not be sent (even if this is not possible for
the local chassis), don't use it on places were we display the neighbor
and update tests.
Vincent Bernat [Fri, 22 Nov 2013 22:03:51 +0000 (23:03 +0100)]
coverity: fix TOCTOU problem when creating chroot
It is believed that checking for existence of a directory or a file
before an action is useless since it could be created after the check
and before the action. Therefore, it is better to just try to do the
action and handle any failure gracefully.
When setting up the chroot, instead of checking if it already exists, we
create it and don't display an error if it is already set up.
Vincent Bernat [Sun, 10 Nov 2013 15:10:34 +0000 (16:10 +0100)]
osx: update homebrew recipe
The patch is not needed anymore. We replace it with the appropriate
`./configure` option. We could use the shipped launchd file but it
does not contain provision to specify options to enable SNMP support.
Vincent Bernat [Fri, 8 Nov 2013 13:26:34 +0000 (14:26 +0100)]
lldpd: tell `lldpcli` to use the appropriate control socket
When using a non-default control socket, lldpd was not providing the
appropriate name to lldpcli which was then not able to configure lldpd
during startup.
Vincent Bernat [Wed, 23 Oct 2013 08:01:12 +0000 (10:01 +0200)]
privsep: put /etc/localtime in chroot
The chroot directory was created by lldpd if missing. We also copy
`/etc/localtime` in it if not already present. This allows us to
remove duplicate code in many init scripts. Since this file is not
essential, we don't make a fuzz for some edge cases.
Vincent Bernat [Tue, 22 Oct 2013 19:24:19 +0000 (21:24 +0200)]
systemd: also read /etc/sysconfig/lldpd
While systemd's author says that we should get rid of those
pseudo-configuration files, keeping compatibility with previous ways
to configure daemons seem a valid reason to keep them. `/etc/default`
is Debian specific. We also read the equivalent one for RedHat to
ensure that everything will also continue to work here.
Vincent Bernat [Sun, 13 Oct 2013 10:19:01 +0000 (12:19 +0200)]
tests: only test if we have `check` installed
There should have been a good reason to put `TESTS` outside the
conditional but I don't remember it. It works by putting `TESTS`
inside the conditional and avoid an odd error message when trying to
execute tests without check installed.
Vincent Bernat [Sat, 12 Oct 2013 15:29:26 +0000 (17:29 +0200)]
lib: fix a segfault introduced in ef3707 when freeing an atom
In the change "lldpd: make notifications work when a port goes down",
a regression was introduced. It is important to never call
`TAILQ_REMOVE` on a marshalled struct, like when we are in
liblldpctl. This is because the marshalling process does not keep a
real list (prev pointer is incorrect).
The change ef3707 did introduce a regression by calling TAILQ_REMOVE
in a case where it is useless. We only need to call TAILQ_REMOVE if we
won't empty the whole list. So when we call `lldpd_remote_cleanup()`
with `all` set to `1`, we don't need to call TAILQ_REMOVE.
Vincent Bernat [Sat, 12 Oct 2013 14:00:40 +0000 (16:00 +0200)]
seccomp: add support for seccomp through libseccomp
The support is only for the monitor process (running as root). It is
enabled when the monitor has been initiliazed, before the event loop.
The monitor has to open a lot of files and read them (files in /proc,
/sys). Moreover, for some files, it has to write to them (for example,
stdout, /dev/log and for writing interface aliases). Therefore, there
are many registered syscalls. It should be possible to filter more but
this would require some efforts.
Becuase it is difficult to reliably report errors to the user and we
may have to execute arbitrary code because we need to resolve
hostnames (and therefore, connect to nscd, LDAP or anything else
handled by NSS), this does not seem to be reliable enough, yet.
Moreover, displaying failed syscall is a bit hackhish.
Maybe we could enable it by default if we change the default behaviour
from killing the offending process to just return a failed errno. Or
just logging the problem.
Vincent Bernat [Sat, 28 Sep 2013 10:26:03 +0000 (12:26 +0200)]
dtrace: add systemtap/DTrace support
Let's dive into what is hot today. The support was mostly just tested
with systemtap but should works just fine with dtrace as well. We
should provide a tapset to help use all this.
Vincent Bernat [Sun, 15 Sep 2013 10:24:43 +0000 (12:24 +0200)]
configure: use a convenience library for fixed point arithmetic
automake >= 1.14 does not like building binaries from source in other
directories. To avoid a warning, `subdir-objects` option has to be
passed to `AM_INIT_AUTOMAKE`. Unfortunately, this breaks what worked
before. Fixed point tests are using `fixedpoint.c` from
`src/lib`. This seems to confuse dependency tracking. See:
In fact, we still have limitations on how stacking is done. Bonds are
expected to be done on physical devices. Bonds on bonds are not
supported. In fact, there are some setups that cannot work
correctly. For example, let's assume the following:
On paper, we can still retrieve the real MAC addresses of various
stuff. However, Linux will alter the MAC addresses of the
VLAN. Moreover, depending on how bond1 is built, it can have the same
MAC address than bond0 or a different one. If MAC addresses are
propagated to the root, there may or may not have conflicts.
Putting bonds on physical interfaces should be the only sane thing to
do. While we could accomodate more complex setup, let's not try to do
something quite complex that nobody will use.
Vincent Bernat [Sun, 15 Sep 2013 09:29:46 +0000 (11:29 +0200)]
linux: fix a regression in how enslaved devices' MAC addresses are retrieved
The MAC address of an enslaved device was not retrieved
correctly. `iflinux_get_permanent_mac()` was called with the master
device instead of the enslaved device. Most of the time, no warning
was issued except when the master device was a slave of another
device (for example, a bridge). This closes #45.
We don't use delegated requests and therefore, this call is not
necessary. It was put here out of safety but it seems that it can
trigger spurious alarms and microseconds timeout. This makes lldpd
consume a lot of CPU. We just remove this call from the event loop.
Vincent Bernat [Thu, 15 Aug 2013 09:08:39 +0000 (11:08 +0200)]
systemd: install service file using `systemdsystemunit_DATA`
When there is an autoconf variable `somethingdir`, we can use
`something_DATA` in automake to install things to this directory. This
is more convenient than using local targets We still have to protect
the use of those variables with conditional macros since they can be
empty or set to no. There is also a drawback about distcheck trying to
set prefix and not expecting things to be installed outside of prefix.
Do the same thing for OS X launchd daemon configuration file.
Vincent Bernat [Wed, 14 Aug 2013 17:17:23 +0000 (19:17 +0200)]
lib: fix notification by reading one byte at a time from Unix socket
Internally, several bytes will be read at once and the notification
should be detected earlier. This fixes a regression introduced in 5aeda65433fd41b7bb67f908d8c4741f045ce508 because we relied on datagram
boundary semantics. This was not important when pulling information
but we still used this semantic when pushing information. Closes: #43.
Vincent Bernat [Tue, 13 Aug 2013 19:33:29 +0000 (21:33 +0200)]
lldpd: make notifications work when a port goes down
We need to refactor a bit `lldpd_remote_cleanup()` to separate the
expiration process (checking each remote port to check if it is still
current) and the removal of remote port (which triggers the expire
function because we want to be notified when a neighbor disappear this
way).
Vincent Bernat [Sun, 11 Aug 2013 20:07:57 +0000 (22:07 +0200)]
interfaces: abstract a bit MAC address mangling for bonding devices
A variable in `struct lldpd_hardware` control the mangling. On the
other end, `hardware->h_ops->send()` should not be called directly
anymore. Instead, `interfaces_helper_send()` should be used instead.
Vincent Bernat [Thu, 25 Jul 2013 08:24:30 +0000 (10:24 +0200)]
linux: mangle MAC address for enslaved devices
With enslaved devices, we may end up with in a situation where we send
a packet with a source MAC address that may confuse switches. For
example:
1. eth0, MAC X connected to switch A.
2. eth1, MAC Y connected to switch B.
3. Active/backup bond is created, MAC X.
4. eth1 is active, eth0 is backup.
If we use the real MAC, eth0 will send LLDP packets with MAC X to
switch A that will learn this MAC and send packets on backup port eth0
and they will be discarded.
The solution until then was to use a zero MAC address in those
cases. However, it seems that some switches may be confused by such a
move. See #26.
Instead, we set the "local" bit to 1 if not already set. Otherwise, we
just use some arbitrary MAC address that I have on an unused 3Com
"Tornado" card. It is unlikely to be reused (100 MBps and it is in a
basement). If you happen to have an even older MAC address and are
willing to give it for lldpd, feel free to tell me. The later case
does not handle all problems but allievate the problem with switches
discarding or complaining about zero MAC address as a source.