summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp6-client.c
AgeCommit message (Collapse)Author
2016-10-16tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek
2016-05-26sd-network: don't needlessly abbreviate "callback" as "cb" in struct membersLennart Poettering
It's OK to abbreviate this in the local scope, but otherwise, let's not be needlessly terse.
2016-05-26sd-network: fix up assertion chaosLennart Poettering
assert_return() should only be used to validate user-facing parameters and state, assert() should be used for checking our own internal state and parameters.
2016-05-26sd-network: rename "index" field of the various clients to "ifindex"Lennart Poettering
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-26sd-network: unify packet processing logic a bitLennart Poettering
Let's always check for errno being EAGAIN/EINTR the same way, and always log if we receive weirdly short packets.
2016-05-22libsystemd-network: use recv(..., 0) instead of read(...) (#3317)Tom Gundersen
According to recv(2) these should be the same, but that is not true. Passing a buffer of length 0 to read is defined to be a noop according to read(2), but passing a buffer of length 0 to recv will discard the pending pacet. We can easily hit this as we allocate our buffer size depending on the size of the incoming packet (using FIONREAD). As pointed out in issue #3299 simply sending an empty UDP packet to the DHCP client port will trigger a busy loop in networkd as we are polling on the socket but never discarding the empty packet. This reverts ad5ae47a0d159ea473c9730d7e0298a3e5d31cf6 but fixes the same issue.
2016-05-15sd-dhcp6-client: add log_errno macro and improve debug messages a bitZbigniew Jędrzejewski-Szmek
2016-05-15tree-wide: drop spurious "&"s when passing functions aroundZbigniew Jędrzejewski-Szmek
Also adjust indentation in various places.
2016-05-03dh-dhcp{,6}-client: change the semantics of DUID settingZbigniew Jędrzejewski-Szmek
Both versions of the code are changed to allow the caller to override DUID using simple rules: duid type and value may be specified, in which case the caller is responsible to providing the contents, or just duid type may be specified as DUID_TYPE_EN, in which case we we fill in the values. In the future more support for other types may be added, e.g. DUID_TYPE_LLT. There still remains and ugly discrepancy between dhcp4 and dhcp6 code: dhcp6 has sd_dhcp6_client_set_duid and sd_dhcp6_client_set_iaid and requires client->state to be DHCP6_STATE_STOPPED, while dhcp4 has sd_dhcp_client_set_iaid_duid and will reconfigure the client if it is not stopped. This commit doesn't touch that part. This addresses #3127 § 2.
2016-05-03sd-dhcp: change uint8_t *duid to const void*Zbigniew Jędrzejewski-Szmek
2016-05-03sd-dhcp{,6}-client: use standard indentation for functions argsZbigniew Jędrzejewski-Szmek
2016-03-30DHCP DUID, IAID configuration optionsVinay Kulkarni
2016-03-21Revert "DHCP DUID and IAID configurability"Zbigniew Jędrzejewski-Szmek
2016-03-09DHCP DUID and IAID configurabilityVinay Kulkarni
2016-02-20libsystemd-network: sd-event uses 64bit priorities, expose them in the APIs ↵Lennart Poettering
as such
2016-02-20libsystemd-network: don't abbreviate "callback" as "cb" needlesslyLennart Poettering
This isn't an excercise in creating APIs that are hard to understand, hence let's call a callback a callback.
2016-02-16networkd: FIONREAD is not reliable on some socketsLennart Poettering
Fixes: #2457
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-01-20dhcp: make DHCP6_OPTION_* enum publicBeniamino Galvani
libsystemd-network provides the public function sd_dhcp6_client_set_request_option() to enable the request of a given DHCP option. However the enum defining such options is defined in the internal header dhcp6-protocol.h. Move the enum definition to the public header sd-dhcp6-client.h and properly namespace values.
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
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-25libsystemd-network: clean up recv functionsTom Gundersen
2015-11-17sd-dhcp6-client: bind to link-local addressTom Gundersen
This ensures that several DHCPv6 clients can run on separate interfaces simultaneously.
2015-11-16networkd: ndisc/dhcpv6 - handle starting running clientsTom Gundersen
The clients may be triggered to be started repeatedly without being stopped first, simply swallow the error rather than failing the link.
2015-11-13networkd: dhcp6 - don't log about losing a lease we never hadTom Gundersen
2015-11-11sd-dhcp6-client: add is_running() methodTom Gundersen
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move string table stuff into its own string-table.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
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-11libsystemd-network: limit accuracy of timestamps in loggingTom Gundersen
We don't care about timestamps down to the last usec, round to the closest sec as that will be plenty for debugging purposes.
2015-09-24Merge pull request #1332 from thom311/masterTom Gundersen
sd-dhcp6: ensure canceling lease timers and refactor setting lease
2015-09-23sd-dhcp6-client: Prevent setting and restarting of DHCPv6 clientPatrik Flykt
Prevent modifications to index, MAC address, DUID and Information Request while the DHCPv6 client is running. Require the DHCPv6 client to be stopped first instead of always unconditionally restarting it if the caller calls sd_dhcp6_client_start() more than once. With this change, handling of for example incoming Router Advertisments becomes much easier.
2015-09-22sd-dhcp6: fix namespacingDavid Herrmann
Prefix all exported constants with SD_DHCP6_CLIENT_* to avoid any namespacing conflicts.
2015-09-22sd-dhcp6: ensure canceling lease timers and refactor setting leaseThomas Haller
Factor our common code to set/clear the client lease. Resetting the lease involves canceling old timers. Also, most importantly, when resetting the lease in client_receive_advertise(), ensure to cancel the timers too. It is not immediately clear, why at that point no timers would be pending. The lease-unref from sd_dhcp6_client_unref() can be omited, because of the preceeding client_reset() call.
2015-08-26dhcp: coding style fixesLennart Poettering
We place the opening bracket of a function on the same line as the function name. Let's do so in the DHCP sources too.
2015-08-26dhcp: stop using refcnt.hLennart Poettering
No need to invole atomic ops in single-threaded APIs, let's simplify this.
2015-08-26sd-dhcp: don't randomly ref objectsDavid Herrmann
In our API design, getter-functions don't ref objects. Calls like foo_get_bar() will not ref 'bar'. We never do that and there is no real reason to do it in single threaded APIs. If you need a ref-count, you better take it yourself *BEFORE* doing anything else on the parent object (as this might invalidate your pointer). Right now, sd_dhcp?_get_lease() refs the lease it returns. A lot of code-paths in systemd do not expect this and thus leak the lease reference. Fix this by changing the API to not ref returned objects.
2015-08-21sd-dhcp6: Support deprecated SNTP Configuration OptionPatrik Flykt
Although the SNTP option specified in RFC 4075 has been deprecated, some servers are still sending NTP information with this option. Use the SNTP information provided only if the NTP option is not present. Update the test case as SNTP information is also requested.
2015-08-21sd-dhcp6: Add support for DHCPv6 NTP Server OptionPatrik Flykt
Support NTP server and multicast addresses and NTP server domain names as specified in RFC 5908.
2015-08-21sd-dhcp6: Add support for DHCPv6 DNS Domain Search List optionPatrik Flykt
Support DHCPv6 DNS search list option as specified in RFC 3646. This option contains a list of DNS search domains encoded without compression as specified in Section 8. of RFC 3315.
2015-08-21sd-dhcp6: Add support for DHCPv6 DNS Recursive Name Server optionPatrik Flykt
Support DHCPv6 DNS server option as specified in RFC 3646. This option contains a list of IPv6 DNS server addresses.
2015-08-21sd-dhcp6-client: Save a DHCPv6 lease also with Information ReplyPatrik Flykt
As the lease structure contains interesting information, save it also for the Information Reply.
2015-08-21sd-dhcp6-client: Fix unreferencing DHCPv6 lease on client resetPatrik Flykt
When the DHCPv6 client is started by the library user or stopped for any reason, unref the DHCPv6 lease when resetting the DHCPv6 client data structure. This makes the DHCPv6 client always start from a clean state and not keep unnecessary an lease structure around when stopped. If this is not done, a previously existing lease information can be interpreted to be from another server when restarting DHCPv6.
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-21dhcp6: remove unnecessary if checkLennart Poettering
2015-04-14sd-dhcp6-client: unref lease when freeing the clientThomas Hindoe Paaboel Andersen
2015-04-11shared: add random-util.[ch]Ronny Chevalier
2015-03-04sd-dhcp6-client: delay setting the DUID and don't fail constructorThomas Haller
sd_dhcp6_client_new() tried to set the DUID based on the machine id. If the host has no /etc/machine-id, the constructor would fail making it impossible to create an sd_dhcp6_client instance. Relax this and create a DUID only later as needed. This way a caller caller can workaround a missing machine-id file and set a DUID of his choosing via sd_dhcp6_client_set_duid().
2015-01-21network: dhcp - split out dhcp_identifier_set_{iaid,duid_en} from dhcp6-clientTom Gundersen
This will also be used in dhcp4-client.