platform/upstream/systemd.git
10 years agobuild-sys: build bus-driverd if kdbus support is enabled
Lennart Poettering [Tue, 17 Dec 2013 00:36:59 +0000 (01:36 +0100)]
build-sys: build bus-driverd if kdbus support is enabled

10 years agobus: when entering an existing namespace to connect to a container's system bus also...
Lennart Poettering [Tue, 17 Dec 2013 00:03:09 +0000 (01:03 +0100)]
bus: when entering an existing namespace to connect to a container's system bus also switch over PID namespace

This is necessary to ensure that kdbus can collect creds of the
destination namespace when connecting.

10 years agocore: always create /dev/kdbus/ns (and make it private 0700) after setting up the...
Lennart Poettering [Tue, 17 Dec 2013 00:02:13 +0000 (01:02 +0100)]
core: always create /dev/kdbus/ns (and make it private 0700) after setting up the kdbus system bus

10 years agojournal-file: protect against alloca(0)
Thomas Hindoe Paaboel Andersen [Mon, 16 Dec 2013 22:35:30 +0000 (23:35 +0100)]
journal-file: protect against alloca(0)

10 years agobus: fix typo in systemd-bus-proxyd
Kay Sievers [Mon, 16 Dec 2013 22:25:32 +0000 (23:25 +0100)]
bus: fix typo in systemd-bus-proxyd

10 years agoAdd bus-driverd
Daniel Mack [Fri, 29 Nov 2013 23:45:53 +0000 (00:45 +0100)]
Add bus-driverd

systemd-bus-driverd is a small daemon that connects to kdbus and
implements the org.freedesktop.DBus interface. IOW, it provides the bus
functions  traditionally taken care for by dbus-daemon.

Calls are proxied to kdbus, either via libsystemd-bus (were applicable)
or with the open-coded use of ioctl().

Note that the implementation is not yet finished as the functions to
add and remove matches and to start services by name are still missing.

10 years agobus: when a busname unit refuses to activate a service it should flush the queue
Lennart Poettering [Mon, 16 Dec 2013 20:26:21 +0000 (21:26 +0100)]
bus: when a busname unit refuses to activate a service it should flush the queue

10 years agobus: also mask dbus.service in generator if kdbus is found
Lennart Poettering [Mon, 16 Dec 2013 20:06:34 +0000 (21:06 +0100)]
bus: also mask dbus.service in generator if kdbus is found

10 years agounits: properly make bus proxy socket of type Accept=yes
Lennart Poettering [Mon, 16 Dec 2013 20:02:55 +0000 (21:02 +0100)]
units: properly make bus proxy socket of type Accept=yes

10 years agosystemctl: properly initialize and free sd_bus_error in "systemctl cat"
Lennart Poettering [Mon, 16 Dec 2013 19:53:55 +0000 (20:53 +0100)]
systemctl: properly initialize and free sd_bus_error in "systemctl cat"

We need to properly initialize all error structs before use and free
them after use.

Also, there's no point in flushing stdout if we output a \n anyway...

10 years agobus: fix symlink to bus proxy socket
Lennart Poettering [Mon, 16 Dec 2013 19:39:44 +0000 (20:39 +0100)]
bus: fix symlink to bus proxy socket

10 years agobus: use GREEDY_REALLOC() when allocating message queues
Lennart Poettering [Mon, 16 Dec 2013 19:32:37 +0000 (20:32 +0100)]
bus: use GREEDY_REALLOC() when allocating message queues

10 years agobus: let's use GREEDY_REALLOC() when allocating space for containers
Lennart Poettering [Mon, 16 Dec 2013 19:00:25 +0000 (20:00 +0100)]
bus: let's use GREEDY_REALLOC() when allocating space for containers

10 years agoexecute: also set SO_SNDBUF when spawning a service with stdout/stderr connected...
Lennart Poettering [Mon, 16 Dec 2013 19:00:09 +0000 (20:00 +0100)]
execute: also set SO_SNDBUF when spawning a service with stdout/stderr connected to journald

10 years agoloopback-setup: remove stray hunk
Tom Gundersen [Mon, 16 Dec 2013 18:31:50 +0000 (19:31 +0100)]
loopback-setup: remove stray hunk

10 years agonetwork: more asserts to shut up scan-build
Thomas Hindoe Paaboel Andersen [Mon, 16 Dec 2013 17:55:59 +0000 (18:55 +0100)]
network: more asserts to shut up scan-build

10 years agokdbus.h: add alignment requirements
Kay Sievers [Mon, 16 Dec 2013 16:47:28 +0000 (17:47 +0100)]
kdbus.h: add alignment requirements

10 years agonetwork: use SETLINK to bring up interfaces
Tom Gundersen [Mon, 16 Dec 2013 13:37:51 +0000 (14:37 +0100)]
network: use SETLINK to bring up interfaces

10 years agortnl: replace message_append by typesafe versions
Tom Gundersen [Sun, 15 Dec 2013 13:00:20 +0000 (14:00 +0100)]
rtnl: replace message_append by typesafe versions

10 years agortnl: support interleaved reading and writing, and rewind
Tom Gundersen [Fri, 6 Dec 2013 16:19:55 +0000 (17:19 +0100)]
rtnl: support interleaved reading and writing, and rewind

10 years agortnl: simplify route_new()
Tom Gundersen [Sat, 7 Dec 2013 20:18:44 +0000 (21:18 +0100)]
rtnl: simplify route_new()

Drop most of the arguments and instead introduce set_dst_prefixlen().

10 years agortnl: simplify link_new()
Tom Gundersen [Fri, 6 Dec 2013 17:16:16 +0000 (18:16 +0100)]
rtnl: simplify link_new()

Drop most of the arguments and instead introduce link_set_{flags,type}.

10 years agortnl: match - only match on one type at a time
Tom Gundersen [Fri, 6 Dec 2013 14:20:36 +0000 (15:20 +0100)]
rtnl: match - only match on one type at a time

10 years agortnl: clean up/add asserts
Tom Gundersen [Fri, 6 Dec 2013 14:13:34 +0000 (15:13 +0100)]
rtnl: clean up/add asserts

10 years agortnl: add support for receiving route messages
Tom Gundersen [Fri, 6 Dec 2013 15:26:17 +0000 (16:26 +0100)]
rtnl: add support for receiving route messages

10 years agobus: increase the bus socket buffer to 8 MB similar, to the log socket buffers
Lennart Poettering [Mon, 16 Dec 2013 16:05:51 +0000 (17:05 +0100)]
bus: increase the bus socket buffer to 8 MB similar, to the log socket buffers

10 years agoupdate TODO
Lennart Poettering [Mon, 16 Dec 2013 16:05:42 +0000 (17:05 +0100)]
update TODO

10 years agoutil: try harder to increase the send/recv buffers of sockets
Lennart Poettering [Mon, 16 Dec 2013 16:04:36 +0000 (17:04 +0100)]
util: try harder to increase the send/recv buffers of sockets

If we have the priviliges we will try SO_SNDBUFFORCE/SO_RCVBUFFORCE and
only fall back to SO_SNDBUF/SO_RCVBUF if that fails.

10 years agocatalog: fix language detection
Zbigniew Jędrzejewski-Szmek [Mon, 16 Dec 2013 02:07:47 +0000 (21:07 -0500)]
catalog: fix language detection

Detection would fail if language was not specified in the filename
but a dot appeared somewhere higher in the path.

10 years agocore: refuse doing %h, %s, %U specifier resolving in PID 1
Lennart Poettering [Mon, 16 Dec 2013 03:59:31 +0000 (04:59 +0100)]
core: refuse doing %h, %s, %U specifier resolving in PID 1

These specifiers require NSS lookups to work, and we really shouldn't do
them from PID 1 hence. With this change they are now only supported for
user systemd instance, or when the configured user for a unit is root.

10 years agobuild-sys: warn if builds are not byte-by-byte reproducible due to usage of __DATE__...
Lennart Poettering [Mon, 16 Dec 2013 03:43:42 +0000 (04:43 +0100)]
build-sys: warn if builds are not byte-by-byte reproducible due to usage of __DATE__ and suchlike

10 years agoFix segv introduced by 2fd069b18e525860514a70d3ea08410ca122d3e2
Colin Walters [Mon, 16 Dec 2013 01:23:23 +0000 (20:23 -0500)]
Fix segv introduced by 2fd069b18e525860514a70d3ea08410ca122d3e2

n->path is pointing to the value now, we set s = NULL above.

10 years agobuild-sys: add cppcheck target
Lennart Poettering [Sun, 15 Dec 2013 23:04:40 +0000 (00:04 +0100)]
build-sys: add cppcheck target

This uses --enable=all mode. Should be taken with a grain of salt
though. While many recommendations make sense we should probably keep
"int r" always on function scope, and many of the portability warnings
really don't matter to us because we only care for Linux/glibc.

10 years agoFix a few signed/unsigned format string issues
Zbigniew Jędrzejewski-Szmek [Sun, 15 Dec 2013 21:26:27 +0000 (16:26 -0500)]
Fix a few signed/unsigned format string issues

Since numbers involved are all small, behaviour was correct already.

https://bugzilla.redhat.com/show_bug.cgi?id=1043304

10 years agoFix a few resource leaks in error paths
Zbigniew Jędrzejewski-Szmek [Sun, 15 Dec 2013 21:25:04 +0000 (16:25 -0500)]
Fix a few resource leaks in error paths

https://bugzilla.redhat.com/show_bug.cgi?id=1043304

10 years agobus: _printf_ attributes should be on prototypes not function definitions for non...
Lennart Poettering [Sun, 15 Dec 2013 22:43:47 +0000 (23:43 +0100)]
bus: _printf_ attributes should be on prototypes not function definitions for non-static functions

10 years agobus: update kdbus monitoring interface
Kay Sievers [Sun, 15 Dec 2013 15:56:28 +0000 (16:56 +0100)]
bus: update kdbus monitoring interface

10 years agoudev-builtin-path: fix printf specifiers
Zbigniew Jędrzejewski-Szmek [Sun, 15 Dec 2013 04:09:14 +0000 (23:09 -0500)]
udev-builtin-path: fix printf specifiers

10 years agobus: return negative errno on error
Zbigniew Jędrzejewski-Szmek [Sun, 15 Dec 2013 03:18:49 +0000 (22:18 -0500)]
bus: return negative errno on error

https://bugs.freedesktop.org/show_bug.cgi?id=72688

10 years agotest-journal-syslog: use streq_ptr since we pass in NULL
Thomas Hindoe Paaboel Andersen [Sun, 15 Dec 2013 01:29:38 +0000 (02:29 +0100)]
test-journal-syslog: use streq_ptr since we pass in NULL

10 years agosystemctl: add the --plain option to the help message
Djalal Harouni [Sat, 14 Dec 2013 23:05:38 +0000 (00:05 +0100)]
systemctl: add the --plain option to the help message

10 years agoman: remove advice to avoid setting the same var more than once
Zbigniew Jędrzejewski-Szmek [Sat, 14 Dec 2013 22:30:25 +0000 (17:30 -0500)]
man: remove advice to avoid setting the same var more than once

So far the compatibility with .desktop settings hasn't been imporant
at all, and we do not want people to write convoluted unit
files.

10 years agoman: beef up ExecStart description
Zbigniew Jędrzejewski-Szmek [Sat, 14 Dec 2013 22:21:55 +0000 (17:21 -0500)]
man: beef up ExecStart description

We have lots of questions from people who assume that shell syntax works
here, so let's be very explicit what is allowed and what is not. A few
examples should also help.

http://bugs.debian.org/732156

10 years agobuild: use -ftrapv for development
Shawn Landden [Sat, 14 Dec 2013 17:27:44 +0000 (09:27 -0800)]
build: use -ftrapv for development

We want to find these bugs if they exist.

10 years agoAdd more _printf_'s for format-nonliterals
Thomas Hindoe Paaboel Andersen [Sat, 14 Dec 2013 12:09:07 +0000 (13:09 +0100)]
Add more _printf_'s for format-nonliterals

Clang is a bit more strict wrt format-nonliterals:
http://clang.llvm.org/docs/LanguageExtensions.html#format-string-checking

Adding these extra printf attributes also makes gcc able to find more
problems. E.g. this patch uncovers a format issue in udev-builtin-path_id.c

Some parts looked intetional about breaking the format-nonliteral check.
I added some supression for warnings there.

10 years agoevent: some snake-oil to speed up impossible error checks
Lennart Poettering [Sat, 14 Dec 2013 04:08:47 +0000 (05:08 +0100)]
event: some snake-oil to speed up impossible error checks

10 years agoevent: instead of reset the revents field when we get new revents data from epoll...
Lennart Poettering [Sat, 14 Dec 2013 04:08:15 +0000 (05:08 +0100)]
event: instead of reset the revents field when we get new revents data from epoll, OR it in

10 years agoevent: dynamically adjust size of events array instead of pre-allocating it possibly...
Lennart Poettering [Sat, 14 Dec 2013 04:07:13 +0000 (05:07 +0100)]
event: dynamically adjust size of events array instead of pre-allocating it possibly too large or too small

10 years agoutil: port last code over to new namespace utility calls
Lennart Poettering [Sat, 14 Dec 2013 04:06:40 +0000 (05:06 +0100)]
util: port last code over to new namespace utility calls

10 years agoutil: when joining a namespace make sure to reset all uids to 0 after
Lennart Poettering [Sat, 14 Dec 2013 04:04:49 +0000 (05:04 +0100)]
util: when joining a namespace make sure to reset all uids to 0 after
the transition

10 years agobus: when connecting to a container's kdbus instance, enter namespace first
Lennart Poettering [Fri, 13 Dec 2013 21:02:47 +0000 (22:02 +0100)]
bus: when connecting to a container's kdbus instance, enter namespace first

Previously we'd open the connection in the originating namespace, which
meant most peers of the bus would not be able to make sense of the
PID/UID/... identity of us since we didn't exist in the namespace they
run in. However they require this identity for privilege decisions,
hence disallowing access to anything from the host.

Instead, when connecting to a container, create a temporary subprocess,
make it join the container's namespace and then connect from there to
the kdbus instance. This is similar to how we do it for socket
conections already.

THis also unifies the namespacing code used by machinectl and the bus
APIs.

10 years agogetty-generator: fix stripping /dev/
Thomas Hindoe Paaboel Andersen [Fri, 13 Dec 2013 22:21:35 +0000 (23:21 +0100)]
getty-generator: fix stripping /dev/

10 years agobus: install systemd-bus-proxyd unit files for compatibility with dbus1
Lennart Poettering [Fri, 13 Dec 2013 19:29:35 +0000 (20:29 +0100)]
bus: install systemd-bus-proxyd unit files for compatibility with dbus1

10 years agogetty-generator: fix segfault when $container_ttys is not set
Lennart Poettering [Fri, 13 Dec 2013 19:36:02 +0000 (20:36 +0100)]
getty-generator: fix segfault when $container_ttys is not set

10 years agoevent: make gcc shut up
Lennart Poettering [Fri, 13 Dec 2013 16:39:52 +0000 (17:39 +0100)]
event: make gcc shut up

10 years agojournal: downgrade comments about sd_journal_print_with_location()
Lennart Poettering [Fri, 13 Dec 2013 16:33:20 +0000 (17:33 +0100)]
journal: downgrade comments about sd_journal_print_with_location()

Effectviely these calls are ABI anyway, so downgrade the comments a bit,
since it might actually be useful for language bindings to make use of
them.

10 years agoupdate TODO
Lennart Poettering [Fri, 13 Dec 2013 16:16:06 +0000 (17:16 +0100)]
update TODO

10 years agoman: document that systemd-getty-generator can start additional container gettys...
Lennart Poettering [Fri, 13 Dec 2013 16:15:05 +0000 (17:15 +0100)]
man: document that systemd-getty-generator can start additional container gettys on ptys

10 years agogetty-generator: look add an environment variable $container_ttys set for PID 1 and...
Lennart Poettering [Fri, 13 Dec 2013 15:37:58 +0000 (16:37 +0100)]
getty-generator: look add an environment variable $container_ttys set for PID 1 and start gettys on all ttys listed therein

10 years agonspawn: add new --setenv= switch to set an environment variable for the container...
Lennart Poettering [Fri, 13 Dec 2013 15:37:16 +0000 (16:37 +0100)]
nspawn: add new --setenv= switch to set an environment variable for the container to spawn

10 years agoman: document more error codes for sd_bus_request_name()
Lennart Poettering [Fri, 13 Dec 2013 15:01:54 +0000 (16:01 +0100)]
man: document more error codes for sd_bus_request_name()

10 years agolibsystemd-bus: the same error codes for sd_bus_release_name() (for kdbus and dbus1)
Lukasz Skalski [Fri, 13 Dec 2013 11:12:24 +0000 (12:12 +0100)]
libsystemd-bus: the same error codes for sd_bus_release_name() (for kdbus and dbus1)

Due to this patch, sd_bus_release_name() function
returns the same code errors for kdbus and dbus1
if we try release non-existing name or foreign
name.

10 years agobuild-sys: fix help text for --enable-kdbus
Lukasz Skalski [Fri, 13 Dec 2013 09:26:55 +0000 (10:26 +0100)]
build-sys: fix help text for --enable-kdbus

10 years agoupdate TODO
Lennart Poettering [Fri, 13 Dec 2013 04:14:47 +0000 (05:14 +0100)]
update TODO

10 years agobus: when a connection terminated use ECONNRESET as error
Lennart Poettering [Fri, 13 Dec 2013 04:13:31 +0000 (05:13 +0100)]
bus: when a connection terminated use ECONNRESET as error

10 years agobus: rework how we attach fds to event loops
Lennart Poettering [Fri, 13 Dec 2013 04:12:46 +0000 (05:12 +0100)]
bus: rework how we attach fds to event loops

When trying a couple of addresses one after the other, make sure to
reattach the fds to the event loop.

10 years agoevent: add ability to change fd of an active event source
Lennart Poettering [Fri, 13 Dec 2013 04:13:59 +0000 (05:13 +0100)]
event: add ability to change fd of an active event source

10 years agoevent: allow to query userdata and watchdog state
Lennart Poettering [Fri, 13 Dec 2013 03:14:25 +0000 (04:14 +0100)]
event: allow to query userdata and watchdog state

10 years agoman: add another nspawn example
Zbigniew Jędrzejewski-Szmek [Fri, 13 Dec 2013 04:14:48 +0000 (23:14 -0500)]
man: add another nspawn example

Taken from https://bugs.freedesktop.org/show_bug.cgi?id=68369.

10 years agoevent: when unreffing an event source from its own handler, detach fd from epoll
Lennart Poettering [Fri, 13 Dec 2013 03:03:30 +0000 (04:03 +0100)]
event: when unreffing an event source from its own handler, detach fd from epoll

The pattern of unreffing an IO event source and then closing its fd is
frequently seen in even source callbacks. Previously this likely
resultet in us removing the fd from the epoll after it was closed which
is problematic, since while we were dispatching we always kept an extra
reference to event source objects because we might still need it later.

10 years agoevent: be more conservative when returning errors from event handler callbacks
Lennart Poettering [Fri, 13 Dec 2013 02:30:42 +0000 (03:30 +0100)]
event: be more conservative when returning errors from event handler callbacks

We really should return errors from event handlers if we have a
continous problem and don't know any other solution.

10 years agogit: update .gitignore
Lennart Poettering [Fri, 13 Dec 2013 01:43:35 +0000 (02:43 +0100)]
git: update .gitignore

10 years agonamespace: include boot id in private tmp directories
Lennart Poettering [Fri, 13 Dec 2013 01:05:04 +0000 (02:05 +0100)]
namespace: include boot id in private tmp directories

This way it is easy to only exclude directories from the current boot
from automatic clean up in /var/tmp.

Also, pick a longer name for the directories so that are globs in
tmp.conf can be simpler yet equally accurate.

10 years agoevent: rework sd-event exit logic
Lennart Poettering [Thu, 12 Dec 2013 21:21:25 +0000 (22:21 +0100)]
event: rework sd-event exit logic

With this change a failing event source handler will not cause the
entire event loop to fail. Instead, we just disable the specific event
source, log a message at debug level and go on.

This also introduces a new concept of "exit code" which can be stored in
the event loop and is returned by sd_event_loop(). We also rename "quit"
to "exit" everywhere else.

Altogether this should make things more robus and keep errors local
while still providing a way to return event loop errors in a clear way.

10 years agobus: fix make check
Lennart Poettering [Thu, 12 Dec 2013 21:18:09 +0000 (22:18 +0100)]
bus: fix make check

10 years agobus: properly parse NameOwnerChanged messages when caller explicitly wants to match...
Lennart Poettering [Thu, 12 Dec 2013 21:17:38 +0000 (22:17 +0100)]
bus: properly parse NameOwnerChanged messages when caller explicitly wants to match against names coming/going

10 years agoman: update sd_bus_request_name() man page
Lennart Poettering [Thu, 12 Dec 2013 21:01:40 +0000 (22:01 +0100)]
man: update sd_bus_request_name() man page

10 years agobus: make sure exit-on-idle logic works on kdbus systems that do not generate NameLost
Lennart Poettering [Thu, 12 Dec 2013 20:25:47 +0000 (21:25 +0100)]
bus: make sure exit-on-idle logic works on kdbus systems that do not generate NameLost

10 years agobus: fix parsing of matches against empty strings
Lennart Poettering [Thu, 12 Dec 2013 20:25:31 +0000 (21:25 +0100)]
bus: fix parsing of matches against empty strings

10 years agoscan-build: silence some warnings
Thomas Hindoe Paaboel Andersen [Thu, 12 Dec 2013 22:08:47 +0000 (23:08 +0100)]
scan-build: silence some warnings

test-fileio/test-strv:
Use the streq_ptr to make build-scan not worry about passing in a null
to a nonnull function.

test-dhcp-option:
Prevent a theoretical null pointer dereference

10 years agobus: fix rewind logic
Lennart Poettering [Thu, 12 Dec 2013 19:43:37 +0000 (20:43 +0100)]
bus: fix rewind logic

10 years agoservice: process watchdog timeouts with lowest priority
Lennart Poettering [Thu, 12 Dec 2013 19:16:06 +0000 (20:16 +0100)]
service: process watchdog timeouts with lowest priority

10 years agobus: remove explicit activator-specific flags, the kdbus supports it now
Kay Sievers [Thu, 12 Dec 2013 19:26:48 +0000 (20:26 +0100)]
bus: remove explicit activator-specific flags, the kdbus supports it now

10 years agobus: update kdbus.h
Kay Sievers [Thu, 12 Dec 2013 19:19:12 +0000 (20:19 +0100)]
bus: update kdbus.h

10 years agobus: always pass valid timeout to kdbus
Lennart Poettering [Thu, 12 Dec 2013 19:00:19 +0000 (20:00 +0100)]
bus: always pass valid timeout to kdbus

10 years agobus: enforce endianess and marshalling for messages we send
Lennart Poettering [Thu, 12 Dec 2013 18:58:46 +0000 (19:58 +0100)]
bus: enforce endianess and marshalling for messages we send

10 years agotimedatectl: work with old timedated
Shawn Landden [Thu, 12 Dec 2013 18:00:03 +0000 (10:00 -0800)]
timedatectl: work with old timedated

Which does have TimeUSec. Should we specifically check for this method
instead of assuming time=0 means it doesn't exist?

Before:
shawn@debian-T61:~/git/systemd$ ./timedatectl
      Local time: Wed 1969-12-31 16:00:00 PST
  Universal time: Thu 1970-01-01 00:00:00 UTC
        RTC time: n/a
        Timezone: America/Los_Angeles (PST, -0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 1969-10-26 01:59:59 PDT
                  Sun 1969-10-26 01:00:00 PST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 1970-04-26 01:59:59 PST
                  Sun 1970-04-26 03:00:00 PDT

After:
shawn@debian-T61:~/git/systemd$ ./timedatectl
      Local time: Wed 2013-12-11 14:03:21 PST
  Universal time: Wed 2013-12-11 22:03:21 UTC
        RTC time: n/a
        Timezone: America/Los_Angeles (PST, -0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2013-11-03 01:59:59 PDT
                  Sun 2013-11-03 01:00:00 PST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2014-03-09 01:59:59 PST
                  Sun 2014-03-09 03:00:00 PDT

10 years agobuild-sys: use internal library for dhcp client tests
Zbigniew Jędrzejewski-Szmek [Thu, 12 Dec 2013 16:42:45 +0000 (11:42 -0500)]
build-sys: use internal library for dhcp client tests

Also clean up AM_CFLAGS in a few places.

10 years agodhcp: Add function to free DHCP client data
Patrik Flykt [Mon, 9 Dec 2013 21:43:32 +0000 (23:43 +0200)]
dhcp: Add function to free DHCP client data

10 years agodhcp: Add notification callback
Patrik Flykt [Mon, 9 Dec 2013 21:43:31 +0000 (23:43 +0200)]
dhcp: Add notification callback

Define a notification callback and events for stopping and client
lease expiry. Add functions to fetch IP parameters from a lease.

10 years agodhcp: Compute expire, T1 and T2 timers
Patrik Flykt [Mon, 9 Dec 2013 21:43:30 +0000 (23:43 +0200)]
dhcp: Compute expire, T1 and T2 timers

Compute the default T1 and T2 timer values if they were not set by
the DHCP server. Verify that the values are reasonable.

10 years agodhcp: Process DHCP Ack/Nak message
Patrik Flykt [Mon, 9 Dec 2013 21:43:29 +0000 (23:43 +0200)]
dhcp: Process DHCP Ack/Nak message

Process a DHCP Ack/Nak in much the same way as an DHCP Offer. Factor
out header verification and process options sent. Add notification
functionality with discrete values for the outcome of the DHCP Ack/
Nak processing.

10 years agodhcp: Add maximum message size option
Patrik Flykt [Mon, 9 Dec 2013 21:43:28 +0000 (23:43 +0200)]
dhcp: Add maximum message size option

Add maximum message size option to keep some DHCP server implementations
from sending too big messages. See ConnMan commit
0c5c862749c05193cf4c513628328c6db02b5222.

10 years agodhcp: Send DHCP Request to acquire an IP address
Patrik Flykt [Mon, 9 Dec 2013 21:43:27 +0000 (23:43 +0200)]
dhcp: Send DHCP Request to acquire an IP address

Create and send a DHCP Request message reusing already existing parts
of the code. This causes factoring out IP and UDP header creation and
moving next timeout calculation to be done every time in the timer
callback function independent of DHCP state. Also add an exponential
part to the timer calculation, bail out if there are errors while
resending the DHCP message for the sixth or more times.

10 years agodhcp: Handle received DHCP Offer message
Patrik Flykt [Mon, 9 Dec 2013 21:43:26 +0000 (23:43 +0200)]
dhcp: Handle received DHCP Offer message

Create a function for handling the full IP, UDP and DHCP packet
and tie it to the main loop. Verify IP and UDP headers and checksum.
Creat a new lease structure with using the values supplied in the
DHCP message. Free the lease structure when client is stopped.

Split out socket handling into a creation and a sending part. As a
result modify the test code.

10 years agodhcp: Add timeout and main loop support
Patrik Flykt [Mon, 9 Dec 2013 21:43:25 +0000 (23:43 +0200)]
dhcp: Add timeout and main loop support

Require a main loop to be set when creating a DHCP client. Set up
a timer to resend DHCP Discover messages and add a 0-2 second
delay to the timeout value. Move to state Selecting after successful
sending of a Discover message.

10 years agobuild: Add dependency on libsystemd-bus needed for main loop
Patrik Flykt [Mon, 9 Dec 2013 21:43:24 +0000 (23:43 +0200)]
build: Add dependency on libsystemd-bus needed for main loop

10 years agodhcp: Add function to stop the DHCP client
Patrik Flykt [Mon, 9 Dec 2013 21:43:23 +0000 (23:43 +0200)]
dhcp: Add function to stop the DHCP client

The client is stopped and brought back to its initial state.

10 years agodhcp: Support seconds elapsed since start of DHCP negotiation
Patrik Flykt [Mon, 9 Dec 2013 21:43:22 +0000 (23:43 +0200)]
dhcp: Support seconds elapsed since start of DHCP negotiation

It was noticed by Grant Erickson in ConnMan commit
95e15c09350acf58d4707056ae2614570883ef66 that:

   "Certain DHCP servers, such as that implemented in Mac OS X
    (< 10.7) for its "Internet Sharing" feature, refuse to issue
    a DHCP lease to clients that have not set a non-zero value
    in their DISCOVER or REQUEST packets."

10 years agodhcp: Add test for discover DHCP packet creation
Patrik Flykt [Mon, 9 Dec 2013 21:43:21 +0000 (23:43 +0200)]
dhcp: Add test for discover DHCP packet creation

Set a fake MAC address and emulate raw packet sending. When the buffer
containing the Discover message is received, check selected IP and
UDP headers and compute IP header and UDP message checksums. Also
send the DHCP message for option parsing and expect a successful
outcome.