4afd3348c7506dd1d36305b7bcb9feb8952b9d6b |
|
27-Nov-2015 |
Lennart Poettering <lennart@poettering.net> |
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. |
0c28d28834f71e74d5a2d8bcfb19938a34396036 |
|
17-Nov-2015 |
Lennart Poettering <lennart@poettering.net> |
sd-ipv4ll: fix error path if sd-ipv4acd allocation fails
Let's make sure the destructor cannot hit the n_ref == 0 case. |
933f9caeeb2b3c1b951d330e04beb04226e5a890 |
|
16-Nov-2015 |
Daniel Mack <daniel@zonque.org> |
siphash24: let siphash24_finalize() and siphash24() return the result directly
Rather than passing a pointer to return the result, return it directly
from the function calls.
Also, return the result in native endianess, and let the callers care
about the conversion. For hash tables and bloom filters, we don't care,
but in order to keep MAC addresses and DHCP client IDs stable, we
explicitly convert to LE. |
dbe81cbd2a93088236a2e4e41eeb33378940f7b9 |
|
16-Nov-2015 |
Martin Pitt <martin.pitt@ubuntu.com> |
siphash24: change result argument to uint64_t
Change the "out" parameter from uint8_t[8] to uint64_t. On architectures which
enforce pointer alignment this fixes crashes when we previously cast an
unaligned array to uint64_t*, and on others this should at least improve
performance as the compiler now aligns these properly.
This also simplifies the code in most cases by getting rid of typecasts. The
only place which we can't change is struct duid's en.id, as that is _packed_
and public API, so we can't enforce alignment of the "id" field and have to
use memcpy instead. |
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ce |
|
27-Oct-2015 |
Lennart Poettering <lennart@poettering.net> |
util-lib: split out allocation calls into alloc-util.[ch] |
04c0136989b7eb896bfb0fb176e11233d69e1453 |
|
24-Oct-2015 |
Lennart Poettering <lennart@poettering.net> |
sd-*.h: clean up exported (or to-be-exported) header files
Exported header files should not include internal headers. Fix that.
Exported header files should not use the bool type. So far we opted to
stick to C89 for exported headers, and hence use "int" for bools in
them. Continue to do so.
Exported header files should have #include lines for everything they use
including inttypes.h and sys/types.h, so that they may be included in
any order.
Exported header files should have C++ guards, hence add them.
Exported header files should not use gcc extensions like #pragma once,
get rid of it. |
07630cea1f3a845c09309f197ac7c4f11edd3b62 |
|
24-Oct-2015 |
Lennart Poettering <lennart@poettering.net> |
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. |
129dc1b489d924d28956b09a06f03d7607beb8ad |
|
11-Oct-2015 |
Tom Gundersen <teg@jklm.no> |
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. |
be19c5b5e0c0f78b8429b126936fa15856550a23 |
|
22-Sep-2015 |
David Herrmann <dh.herrmann@gmail.com> |
sd-ipv4ll: fix namespacing
Prefix all exported constants with SD_IPV4LL_* to avoid namespacing
conflicts. |
2237aa02f3e2739a1ebe9c0bc224b5125f5eb292 |
|
22-Sep-2015 |
David Herrmann <dh.herrmann@gmail.com> |
sd-ipv4acd: fix namespacing
Prefix all exported constants with SD_IPV4ACD to prevent namespacing
conflicts. |
56065db4214a62a4d9ed4465333fcded35322aa8 |
|
21-Sep-2015 |
Ronny Chevalier <chevalier.ronny@gmail.com> |
sd-ipv4ll: do not assert_return when seed == 0
Now that seed is an unsigned and not an array, we do not need to assert
on it. |
e3dca0089b7b50e2ec21409d1292727921d06102 |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
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. |
6af9144f5ff65cb9f6ae9999e7e0a9edc4841b2b |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: simplify conflict handling
Use stop() and start() to drop some pulicate code. |
b45e4eb679ad0c9a77c4fe6e404c8842d4097fdb |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
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. |
5707940ed31272d44ba2dcf0a74a3024256d2875 |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: don't allow changing MAC address whilst running
This requires the caller to stop and restart the statemachine if they want to
change the MAC address. |
94a355a1306ef51ab6c7f5264aaac35a54d5b54a |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: code cleanups
Simplify timeout handling. |
028e0b20563cbe5a7adb350e670181c77f4c9050 |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: remove duplicate packet verification
Most packets are filtered out by the BPF, so only check for the parts that may
actually differ. |
25d6213b4331e9cbf355f4e851fc5b4ee2ae4c0f |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: minor cleanups |
b26f7e8ec922f0d55733ab8d5b6c41212e5a4575 |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: split out on_conflict() from on_packet() |
8e5787b5e045e40c961ce97003f440090f545c1c |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: split run_state_machine() into on_packet() and on_timeout()
Simplify the code a bit, no functional change. |
996d16975b4d802335188a3be2bbc3635c1287f3 |
|
18-Sep-2015 |
Tom Gundersen <teg@jklm.no> |
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. |
ece174c5439021e32ebcc858842de9586072c006 |
|
09-Sep-2015 |
Lennart Poettering <lennart@poettering.net> |
tree-wide: drop {} from one-line if blocks
Patch via coccinelle. |
9c8e3101ceef00342263d57dce3fa61956824985 |
|
27-Aug-2015 |
Lennart Poettering <lennart@poettering.net> |
network: get rid of more RefCnt usage
A follow-up to 3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8 |
756775814cf69471f74ce853745bba69f2ba94ef |
|
06-Aug-2015 |
Thomas Hindoe Paaboel Andersen <phomes@gmail.com> |
tree-wide: do not return error codes as bool |
38a03f06a7393d2721c23f23f0589d2f6d0904af |
|
03-Aug-2015 |
Lennart Poettering <lennart@poettering.net> |
sd-event: make sure sd_event_now() cannot fail
Previously, if the event loop never ran before sd_event_now() would
fail. With this change it will instead fall back to invoking now(). This
way, the function cannot fail anymore, except for programming error when
invoking it with wrong parameters.
This takes into account the fact that many callers did not handle the
error condition correctly, and if the callers did, then they kept simply
invoking now() as fall back on their own. Hence let's shorten the code
using this call, and make things more robust, and let's just fall back
to now() internally.
Whether now() is used or the cache timestamp may still be detected via
the return value of sd_event_now(). If > 0 is returned, then the fall
back to now() was used, if == 0 is returned, then the cached value was
returned.
This patch also simplifies many of the invocations of sd_event_now():
the manual fall back to now() can be removed. Also, in cases where the
call is invoked withing void functions we can now protect the invocation
via assert_se(), acknowledging the fact that the call cannot fail
anymore except for programming errors with the parameters.
This change is inspired by #841. |
3df3e884ae1237ef0d4d23b0e80f4ffda95ac135 |
|
11-Apr-2015 |
Ronny Chevalier <chevalier.ronny@gmail.com> |
shared: add random-util.[ch] |
f0c4b1c3fd827b429ba36aa45fd39e0a023cbf2c |
|
13-Jan-2015 |
Tom Gundersen <teg@jklm.no> |
refcnt: refcnt is unsigned, fix comparisons
This does not make a difference, but the code was confusing. |
356779df90a2ecab5da2cb310ad0f8ebc9ca9f46 |
|
04-Nov-2014 |
Lennart Poettering <lennart@poettering.net> |
sd-event: rename sd_event_source_set_name() to sd_event_source_get_name()
To mirror the recent name change of the concept for sd_bus objects,
follow the same logic for sd_event_source objects, too. |
f697185e5b45287b6a62592129e726d8a636d3ff |
|
30-Aug-2014 |
Tom Gundersen <teg@jklm.no> |
sd-ipv4ll: name the correct source |
9021bb9f935c93b516b10c88db2a212a9e3a8140 |
|
28-Aug-2014 |
Tom Gundersen <teg@jklm.no> |
sd-event: name event sources used in libraries
This should help in debugging failing event sources. |
fa94c34b083b5b4019975624453e53d0cbad2a5d |
|
24-Jul-2014 |
Tom Gundersen <teg@jklm.no> |
libsystemd-network: use CLOCK_BOOTTIME instead of CLOCK_MONOTONIC where possible
The timeouts in the networking library (DHCP lease timeouts and similar) should not be affected
by suspend. In the cases where CLOCK_BOOTTIME is not implemented, it is still safe to fallback to
CLOCK_MONOTONIC, as the consumers of the library (i.e., networkd) _should_ renew the leases when
coming out of suspend. |
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5 |
|
27-Apr-2014 |
Umut Tezduyar Lindskog <umut.tezduyar@axis.com> |
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.] |
4d978a46693e4f23bc73da6a0bafacfcff2aba05 |
|
11-Apr-2014 |
Patrik Flykt <patrik.flykt@linux.intel.com> |
sd-ipv4ll: Add an explicit stop state for IPv4LL
Add an explicit stop state for IPv4LL so that the user can stop the
IPv4LL client from the callback. When returning from the callback,
check also the stop state in order to halt any further protocol
processing. |
56cd007ab83749b85670c9c7f560e083980c2ff4 |
|
11-Apr-2014 |
Patrik Flykt <patrik.flykt@linux.intel.com> |
sd-ipv4ll: Add reference counting for IPv4LL
Similar to DHCP, the IPv4LL library user can decide to free the LL
client any time the callback is called. Guard against freeing the
LL client in the callback by introducing proper reference counting.
Also update code using the IPv4LL library to properly handle a
returned NULL from the notify and stop functions if the IPv4LL
client was freed. |
aba496a58acf9d9c61314de71353550e579f85ee |
|
03-Apr-2014 |
Umut Tezduyar Lindskog <umut.tezduyar@axis.com> |
networkd: smooth transition from ipv4ll to dhcp address
Currently when both ipv4ll and dhcp are enabled, ipv4ll
address (if one has been claimed) is removed when dhcp
address is aquired. This is not the best thing to do
since there might be clients unaware of the removal
trying to communicate.
This patch provides a smooth transition between ipv4ll
and dhcp. If ipv4ll address was claimed [1] before dhcp,
address is marked as deprecated. Deprecated address is still
a valid address and packets can be received on it but address
cannot be selected as a source address. If dhcp lease cannot
be extended, then ipv4ll address is marked as valid again.
[1] If there is no collision, claiming IPv4LL takes between 4 to
7 seconds. |
6a0f1f6d5af7c7300d3db7a0ba2b068f8abd222b |
|
24-Mar-2014 |
Lennart Poettering <lennart@poettering.net> |
sd-event: rework API to support CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM, too |
b5db00e52ee2e20578839e4e4488f7b9af9abc38 |
|
21-Mar-2014 |
Umut Tezduyar Lindskog <umut.tezduyar@axis.com> |
sd-ipv4ll/networkd: generate predictable addresses
Increase the chance of using the same link local address between reboots. The
pseudo random sequence of addresses we attempt is now seeded with data that is
very likely to stay the same between reboots, but at the same time be unique
to the specific machine/nic.
First we try to use the ID_NET_NAME_* data from the udev db combined with the
machin-id, which is guaranteed to be unique and persistent, if available. If
that is not possible (e.g., in containers where we don't have access to the
udev db) we fallback to using the MAC address of the interface, which is
guaranteed to be unique, and likely to be persistent.
[tomegun: three minor changes:
- don't expose HASH_KEY in the siphash24 header
- get rid of some compile-warnings (and some casts at the same time),
by using uint8_t[8] rather than uint64_t in the api
- added commit message] |
4644fee04fb515787bcfbba53b3cabe58c81d317 |
|
21-Mar-2014 |
Tom Gundersen <teg@jklm.no> |
sd-dhcp-client/sd-ipv4ll: allow mac address to be updated at any time
If necessary, restart the clients to deal with a changing mac address
at runtime. This will solve the problem of starting clients on bridges
before they have received their final MAC address. |
03e334a1c7dc8c20c38902aa039440763acc9b17 |
|
18-Mar-2014 |
Lennart Poettering <lennart@poettering.net> |
util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:
fd = safe_close(fd);
Which will close an fd if it is open, and reset the fd variable
correctly.
By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards. |
5c1d3fc93d91384bbac29adf01074fa4375317ea |
|
03-Mar-2014 |
Umut Tezduyar Lindskog <umut.tezduyar@axis.com> |
sd-network: IPv4 link-local support [v2]
Implements IPv4LL with respect to RFC 3927
(http://tools.ietf.org/rfc/rfc3927.txt) and integrates it
with networkd. Majority of the IPv4LL state machine is
taken from avahi (http://avahi.org/) project's autoip.
IPv4LL can be enabled by IPv4LL=yes under [Network]
section of .network file.
IPv4LL works independent of DHCP but if DHCP lease is
aquired, then LL address will be dropped.
[tomegun: removed a trailing newline and a compiler warning] |