Commit Graph

23 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Lennart Poettering 810adae9e9 tree-wide: use proper unicode © instead of (C) where we can
Let's use a proper unicode copyright symbol where we can, it's prettier.

This important patch is very important.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek 3bf47e7392 test-ipv4ll: use assert_se consistently
We use assert_se in tests so that the asserts get evaluated even if compiled with NDEBUG.
2017-05-13 15:45:29 -04:00
Zbigniew Jędrzejewski-Szmek afc5fc1ffa tree-wide: drop assert.h includes
We provide an independent reimplementation in macro.h, and that's the one
we want to use. Including the system header is unnecessary and confusing.
2017-05-13 15:44:30 -04:00
Lennart Poettering 38958cd66e ipv4ll: change "seed" parameter to be uint64_t
Let's make clear this always has the same size, since otherwise it's not useful
for reproducible runs, which this is really about however.
2016-05-26 15:34:43 +02:00
Lennart Poettering 2f8e763376 sd-network: rename "index" field of the various clients to "ifindex"
A field "index" is not particularly precise and also might conflict with libc's
index() function definition. Also, pretty much everywhere else we call this
concept "ifindex", including in networkd, the primary user of these libraries.
Hence, let's fix this up and call this "ifindex" everywhere here too.
2016-05-26 15:34:42 +02:00
Lennart Poettering e095f51dd1 ipv4acd/ipv4ll: stop using read() on SOCK_DGRAM sockets
This is a follow-up to cf447cb62d.

Let's generally follow the rule to not use read() on SOCK_DGRAM sockets, let's
always use recv() on that.

Also, don't abort IPV4ACD logic in case we read a short packet. Simply log and
ignore.
2016-05-22 14:26:36 +02:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering 4afd3348c7 tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.
2015-11-27 19:19:36 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Tom Gundersen 129dc1b489 sd-ipv4ll: allow initial address to be set explicitly
This is useful in case the daemon is restarted and the state of the IPv4LL client should
be serialized/deserialized.
2015-10-11 15:04:16 +02:00
David Herrmann be19c5b5e0 sd-ipv4ll: fix namespacing
Prefix all exported constants with SD_IPV4LL_* to avoid namespacing
conflicts.
2015-09-22 15:08:28 +02:00
Ronny Chevalier 5625be76c7 test-ipv4ll: use unsigned instead of an array for a seed
ipv4ll use an unsigned instead of an uint8_t array. Hence, use an
unsigned seed instead of declaring an array and then dereferencing it
later.
2015-09-21 16:52:52 +02:00
Tom Gundersen e3dca0089b sd-ipv4acd: introduce new library split out from sd-ipv4ll
This splits the Address Conflict Detection out of the Link Local
library so that we can reuse it for DHCP and static addresses in
the future.

Implements RFC5227.
2015-09-18 15:14:43 +02:00
Tom Gundersen b45e4eb679 sd-ipv4ll: rework callbacks
Firstly, no longer distinguish between STOP and INIT states.

Secondly, do not trigger STOP events when calls to sd_ipv4ll_*() fail. The
caller is the one who would receive the event and will already know that the
call to sd_ipv4ll_*() has failed, so it is redundant.

STOP events will now only be triggered by calling sd_ipv4ll_stop() explicitly
or by some internal error in the library triggered by receiving a packet or
an expiring timeout (i.e., any error that would otherwise not be reported
back to the consumer of the library).

Lastly, follow CODING_STYLE and always return NULL on unref. Protect from
objects being destroyed in callbacks accordingly.
2015-09-18 15:14:43 +02:00
Tom Gundersen 996d16975b sd-ipv4ll: filter out unwanted ARP packets in the kernel
We currently process every ARP packet, but we should only care about the ones
relating to our IP address.

Also rename ipv4ll helpers to apr-utils.[ch], and rework the helpers a bit.
2015-09-18 15:14:42 +02:00
Lennart Poettering 89ca10c6a6 network: s/user_data/userdata/
Everywhere else we call the generic user data pointer just "userdata",
rather than "user_data". Let's do this here, too.
2015-08-26 22:47:53 +02:00
Thomas Hindoe Paaboel Andersen a64edefacb test-ipv4ll: clean up the event
shuts up valgrind/sanitizers
2015-04-13 23:38:02 +02:00
Umut Tezduyar Lindskog d9bf4f8c6c libnetworkd: add link local tests
- Also only allow positive ifindex on both dhcp and ipv4ll

[tomegun: the kernel always sets a positive ifindex, but some APIs accept
          ifindex=0 with various meanings, so we should protect against
          accidentally passing ifindex=0 along.]
2014-04-27 23:39:13 +02:00