summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-client.c
AgeCommit message (Collapse)Author
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-27core: avoid compiler warning when compiling with -fexceptionsThomas Haller
Initialize auto variables with cleanup attribute, otherwise we get a compiler warning with -fexceptions. ./configure CFLAGS='-Wmaybe-uninitialized -fexceptions -O2'
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-15dhcp: assert the success of sd_event_now()Beniamino Galvani
The function must never fail.
2016-02-02dhcp: delay restarts after NAKsBeniamino Galvani
The server might answer to a DHCPREQUEST with a NAK and currently the client restarts the configuration process immediately. It was observed that this can easily generate loops in which the network is flooded with DISCOVER,OFFER,REQUEST,NAK sequences. RFC 2131 only states that "if the client receives a DHCPNAK message, the client restarts the configuration process" without further details. Add a delay with exponential backoff between retries after NAKs to limit the number of requests and cap the delay to 30 minutes.
2016-01-20dhcp: make DHCP_OPTION_* enum publicBeniamino Galvani
libsystemd-network provides the public function sd_dhcp_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 dhcp-protocol.h. Move the enum definition to the public header sd-dhcp-client.h and properly namespace values.
2015-12-02util-lib: update dns_name_to_wire_format() to optionally generate DNSSEC ↵Lennart Poettering
canonical names We'll need this later when putting together RR serializations to checksum.
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-27Merge pull request #2029 from teg/network-fixesMartin Pitt
Network fixes
2015-11-25dns-domain: simplify dns_name_is_root() and dns_name_is_single_label()Lennart Poettering
Let's change the return value to bool. If we encounter an error while parsing, return "false" instead of the actual parsing error, after all the specified hostname does not qualify for what the function is supposed to test. Dealing with the additional error codes was always cumbersome, and easily misused, like for example in the DHCP code. Let's also rename the functions from dns_name_root() to dns_name_is_root(), to indicate that this function checks something and returns a bool. Similar for dns_name_is_signal_label().
2015-11-25sd-dhcp: parse error message in DECLINE or NAKTom Gundersen
If a client sends a DECLINE or a server sends a NAK, they can include a string with a message to explain the error. Parse this and print it at debug level.
2015-11-25libsystemd-network: clean up recv functionsTom Gundersen
2015-11-17libsystemd-network: add support for "Client FQDN" DHCP optionBeniamino Galvani
This adds support for the Client Fully Qualified Domain Name (FQDN) option [RFC 4702] to libsystemd-network. The option can be used to exchange information about a DHCPv4 client's fully qualified domain name and about responsibility for updating the DNS RR related to the client's address assignment. Other popular DHCP clients (dhclient, dhcpcd) support this option and it would be useful to have it in networkd too.
2015-11-06doc: correct orthography, word forms and missing/extraneous wordsJan Engelhardt
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
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-22sd-dhcp: fix namespacingDavid Herrmann
Prefix all constants with SD_DHCP_CLIENT_* to avoid namespacing conflicts.
2015-08-27dhcp: don't underflow in lease time calculationsLennart Poettering
Don't underflow when calculating lease time.
2015-08-27dhcp: NTP servers should be requested by networkd but not implicitly by sd-dhcpLennart Poettering
The library so far always requested the NTP servers. This might be unnecessary in some uses, hence let's move the request into networkd instead.
2015-08-27dhcp: clean up dhcp4 lease objectLennart Poettering
a) drop handling of obsolete or unused DHCP options time_offset, mtu_aging_timeout, policy filter, mdr, ttl, ip forwarding settings. Should this become useful one day we can readd support for this. b) For subnet mask and broadcast it is not always clear whether 0 or 255.255.255.255 might be valid, hence maintain a boolean indicating validity next to it. c) serialize/deserialize broadcast address, lifetime, T1 and T2 together with the rest of the fields in dhcp_lease_save() and dhcp_lease_load(). d) consistently return ENODATA from getter functions for data that is missing in the lease. e) add missing getter calls for broadcast, lifetime, T1, T2. f) when decoding DHCP options, generate debug messages on parse failures, but try to proceed if possible. g) Similar, when deserializing a lease in dhcp_lease_load(), make sure we deal nicely with unparsable fields, to provide upgrade compat. h) fix some memory allocations
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-06-17sd-dhcp-client: readd deleted error checkThomas Hindoe Paaboel Andersen
Seems to have been removed by mistake in: 9021bb9f935c93b516b10c88db2a212a9e3a8140
2015-06-10util: introduce CMSG_FOREACH() macro and make use of it everywhereLennart Poettering
It's only marginally shorter then the usual for() loop, but certainly more readable.
2015-04-12dhcp: yes, infiniband has the larger MAC address length, but let the ↵Lennart Poettering
compuler figure that out...
2015-04-11shared: add random-util.[ch]Ronny Chevalier
2015-04-10Revert "sd-dhcp-client: fix strict aliasing issue"Lennart Poettering
This reverts commit 6ec8e7c763b7dfa82e25e31f6938122748d1608f. This doesn't fix any issues, just makes the code harder to read.
2015-03-14sd-dhcp-client: fix strict aliasing issueShawn Landden
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-12Revert "tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC"Lennart Poettering
This reverts commit d6d810fbf8071f8510450dbacd1d083f37603656. It's apparently not OK to pass MSG_CMSG_CLOEXEC to recvmsg() of raw sockets.
2015-02-10tree-wide: Always use recvmsg with MSG_CMSG_CLOEXECCristian Rodríguez
2015-01-22sd-dhcp-client: use RFC4361-complient ClientID by defaultTom Gundersen
In addition to the benefits listed in the RFC, this allows DHCP to work also in case several interfaces share the same MAC address on the same link (IPVLAN). Note that this will make the ClientID (so probably the assigned IP address) change on upgrades. If it is desired to avoid that we would have to remember and write back the ID (which the library supports, but networkd currently does not).
2015-01-22Assorted format fixesZbigniew Jędrzejewski-Szmek
Types used for pids and uids in various interfaces are unpredictable. Too bad.
2015-01-13refcnt: refcnt is unsigned, fix comparisonsTom Gundersen
This does not make a difference, but the code was confusing.
2014-12-30tree-wide: spelling fixesVeres Lajos
https://github.com/vlajos/misspell_fixer https://github.com/torstehu/systemd/commit/b6fdeb618cf2f3ce1645b3315f15f482710c7ffa Thanks to Torstein Husebo <torstein@huseboe.net>.
2014-12-11sd-dhcp-client: log if we fail to set up lease timersTom Gundersen
2014-11-19sd-dhcp-lease: load/save client IDDan Williams
The lease is usually tied to the client ID, so users of the lease may want to know what client ID it was acquired with.
2014-11-19sd-dhcp-client: allow getting/setting the client IDDan Williams
The client identifier can be in many different formats, not just the one that systemd creates from the Ethernet MAC address. Non- ethernet interfaces may have different client IDs formats. Users may also have custom client IDs that the wish to use to preserve lease options delivered by servers configured with the existing client ID.
2014-11-18sd-dhcp-client: fix REBOOT state handlingDan Williams
client->secs wasn't getting set in the REBOOT state, causing an assertion. REBOOT should work the same way as INIT, per RFC 2131: secs 2 Filled in by client, seconds elapsed since client began address acquisition or renewal process. REBOOT is necessary because some DHCP servers (eg on home routers) do not hand back the same IP address unless the 'ciaddr' field is filled with that address, which DISCOVER cannot do per the RFCs. This leads to multiple leases on machine reboot or DHCP client restart.
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-10-31sd-dhcp-client: clean up raw socket sd_event_source when creating new UDP socketDan Williams
The raw socket sd_event_source used for DHCP server solicitations was simply dropped on the floor when creating the new UDP socket after a lease has been acquired. Clean it up properly so we're not still listening and responding to events on it.
2014-10-11sd-dhcp-client: support non-Ethernet hardware addressesDan Williams
Like Infiniband. See RFC 4390 section 2.1 for details on DHCP and Infiniband; chaddr is zeroed, hlen is set to 0, and htype is set to ARPHRD_INFINIBAND because IB hardware addresses are 20 bytes in length.
2014-08-29Fix a few typos in log messagesRuben Kerkhof
2014-08-28sd-event: name event sources used in librariesTom Gundersen
This should help in debugging failing event sources.
2014-08-15util: never use ether_ntoa(), since it formats with %x, not %02x, which ↵Lennart Poettering
makes ethernet addresses look funny