summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-ipv4ll.c
AgeCommit message (Collapse)Author
2015-10-24sd-*.h: clean up exported (or to-be-exported) header filesLennart Poettering
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.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
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-11sd-ipv4ll: allow initial address to be set explicitlyTom Gundersen
This is useful in case the daemon is restarted and the state of the IPv4LL client should be serialized/deserialized.
2015-09-22sd-ipv4ll: fix namespacingDavid Herrmann
Prefix all exported constants with SD_IPV4LL_* to avoid namespacing conflicts.
2015-09-22sd-ipv4acd: fix namespacingDavid Herrmann
Prefix all exported constants with SD_IPV4ACD to prevent namespacing conflicts.
2015-09-21sd-ipv4ll: do not assert_return when seed == 0Ronny Chevalier
Now that seed is an unsigned and not an array, we do not need to assert on it.
2015-09-18sd-ipv4acd: introduce new library split out from sd-ipv4llTom Gundersen
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-18sd-ipv4ll: simplify conflict handlingTom Gundersen
Use stop() and start() to drop some pulicate code.
2015-09-18sd-ipv4ll: rework callbacksTom Gundersen
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-18sd-ipv4ll: don't allow changing MAC address whilst runningTom Gundersen
This requires the caller to stop and restart the statemachine if they want to change the MAC address.
2015-09-18sd-ipv4ll: code cleanupsTom Gundersen
Simplify timeout handling.
2015-09-18sd-ipv4ll: remove duplicate packet verificationTom Gundersen
Most packets are filtered out by the BPF, so only check for the parts that may actually differ.
2015-09-18sd-ipv4ll: minor cleanupsTom Gundersen
2015-09-18sd-ipv4ll: split out on_conflict() from on_packet()Tom Gundersen
2015-09-18sd-ipv4ll: split run_state_machine() into on_packet() and on_timeout()Tom Gundersen
Simplify the code a bit, no functional change.
2015-09-18sd-ipv4ll: filter out unwanted ARP packets in the kernelTom Gundersen
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-09tree-wide: drop {} from one-line if blocksLennart Poettering
Patch via coccinelle.
2015-08-27network: get rid of more RefCnt usageLennart Poettering
A follow-up to 3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8
2015-08-06tree-wide: do not return error codes as boolThomas Hindoe Paaboel Andersen
2015-08-03sd-event: make sure sd_event_now() cannot failLennart Poettering
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.
2015-04-11shared: add random-util.[ch]Ronny Chevalier
2015-01-13refcnt: refcnt is unsigned, fix comparisonsTom Gundersen
This does not make a difference, but the code was confusing.
2014-11-04sd-event: rename sd_event_source_set_name() to sd_event_source_get_name()Lennart Poettering
To mirror the recent name change of the concept for sd_bus objects, follow the same logic for sd_event_source objects, too.
2014-08-30sd-ipv4ll: name the correct sourceTom Gundersen
2014-08-28sd-event: name event sources used in librariesTom Gundersen
This should help in debugging failing event sources.
2014-07-24libsystemd-network: use CLOCK_BOOTTIME instead of CLOCK_MONOTONIC where possibleTom Gundersen
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.
2014-04-27libnetworkd: add link local testsUmut Tezduyar Lindskog
- 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-11sd-ipv4ll: Add an explicit stop state for IPv4LLPatrik Flykt
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.
2014-04-11sd-ipv4ll: Add reference counting for IPv4LLPatrik Flykt
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.
2014-04-03networkd: smooth transition from ipv4ll to dhcp addressUmut Tezduyar Lindskog
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.
2014-03-24sd-event: rework API to support CLOCK_REALTIME_ALARM and ↵Lennart Poettering
CLOCK_BOOTTIME_ALARM, too
2014-03-21sd-ipv4ll/networkd: generate predictable addressesUmut Tezduyar Lindskog
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]
2014-03-21sd-dhcp-client/sd-ipv4ll: allow mac address to be updated at any timeTom Gundersen
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.
2014-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering
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.
2014-03-03sd-network: IPv4 link-local support [v2]Umut Tezduyar Lindskog
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]