summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-client.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-8/+4
|
* dhcp4: introduce new option 'duid-only' for ClientIdentifier= (#8350)Yu Watanabe2018-03-121-11/+31
| | | | | | | This makes users can configure DHCPv4 client with ClientIdentifier=duid-only. If set so, then DHCP client sends only DUID as the client identifier. This may not be RFC compliant, but some setups require this. Closes #7828.
* tree-wide: use "cannot" instead of "can not"Zbigniew Jędrzejewski-Szmek2018-02-081-6/+6
| | | | This is the usual spelling, and a bit shorter.
* tree-wide: adjust fall through comments so that gcc is happyShawn Landden2017-11-201-1/+0
| | | | | | | | Distcc removes comments, making the comment silencing not work. I know there was a decision against a macro in commit ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* sd-dhcp-client: validate hostnames stricter (#7308)Stefan Agner2017-11-161-2/+2
| | | | | | | | | | | | | | | | | Technically DNS allows any ASCII character to be used in the domain name. Also the DHCP specification for the FQDN option (RFC 4702) does not put restriction on labels. However, hostnames do have stricter requirements and typically should only use characters from a-z (case insensitve), 0-9 and minus. Currently we require hostname/FQDN to be either a hostname or a valid DNS name. Since dns_name_is_valid() allows any ASCII characters this allows to specify hostnames which are typically not valid. Check hostname/FQDN more strictly and require them to pass both tests. Specifically this requires the entire FQDN to be below 63.
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-5/+4
|
* tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`Andreas Rammhold2017-10-021-3/+1
| | | | | | The included cocci was used to generate the changes. Thanks to @flo-wer for pointing this case out.
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-10-021-1/+1
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* networkd: RFC7844, disable INIT-REBOOT state whenjuga02017-09-061-1/+8
| | | | Anonymize is true.
* networkd: RFC7844, do not set any other optionjuga02017-09-061-6/+10
| | | | | | when Anonymize is enabled. Use the Client variable to know whether it is enabled.
* networkd: do not send more PRL options when Anonymize is true.juga02017-09-061-5/+12
| | | | | * check that Client has reserved memory for PRL * do not send duplicated ROUTES option when Anonymize is true
* networkd: set PRL default options depending on Anonymize.juga02017-09-061-3/+37
| | | | Add also Client variable to know when Anonymize is true.
* tree-wide: when %m is used in log_*, always specify errno explicitlyZbigniew Jędrzejewski-Szmek2017-05-191-4/+4
| | | | | | | | All those uses were correct, but I think it's better to be explicit. Using implicit errno is too error prone, and with this change we can require (in the sense of a style guideline) that the code is always specified. Helpful query: git grep -n -P 'log_[^s][a-z]+\(.*%m'
* Include 'vendor class identifier option' into DHCPREQUEST message (#5380)Alexander Galanin2017-02-201-0/+9
|
* dhcp: bind udp sockets to interfaces (#4822)27o2016-12-071-1/+1
|
* sd-dhcp-client: use free_and_strdupZbigniew Jędrzejewski-Szmek2016-11-211-30/+4
| | | | | | This changes the return value a bit: 1 will be returned if the value is changed. But the return value was not documented, and the change should be for the good anyway. Current callers don't care.
* sd-dhcp: permit unsetting the hostname againLennart Poettering2016-11-211-5/+9
| | | | Let's handle NULL hostnames (for unsetting it) before we validate the name.
* networkd: support setting dhcp client listen port (#4631)Susant Sahani2016-11-101-6/+19
| | | | | | Allow setting custom port for the DHCP client to listen on in networkd. [DHCP] ListenPort=6677
* tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek2016-10-161-3/+1
|
* sd-network: don't needlessly abbreviate "callback" as "cb" in struct membersLennart Poettering2016-05-261-4/+7
| | | | | It's OK to abbreviate this in the local scope, but otherwise, let's not be needlessly terse.
* sd-network: fix up assertion chaosLennart Poettering2016-05-261-17/+24
| | | | | | 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.
* sd-network: rename "index" field of the various clients to "ifindex"Lennart Poettering2016-05-261-14/+13
| | | | | | | 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.
* sd-dhcp: shorten NUL initialization a bitLennart Poettering2016-05-261-1/+1
|
* sd-network: unify packet processing logic a bitLennart Poettering2016-05-261-3/+3
| | | | | Let's always check for errno being EAGAIN/EINTR the same way, and always log if we receive weirdly short packets.
* libsystemd-network: use recv(..., 0) instead of read(...) (#3317)Tom Gundersen2016-05-221-4/+1
| | | | | | | | | | | | | | | 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.
* sd-dhcp-client: fix busy loop reading zero sized DHCP UDP packets. (#3299)sadag2016-05-201-0/+3
|
* dh-dhcp{,6}-client: change the semantics of DUID settingZbigniew Jędrzejewski-Szmek2016-05-031-14/+24
| | | | | | | | | | | | | | | | | 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.
* sd-dhcp: change uint8_t *duid to const void*Zbigniew Jędrzejewski-Szmek2016-05-031-1/+1
|
* sd-dhcp{,6}-client: use standard indentation for functions argsZbigniew Jędrzejewski-Szmek2016-05-031-48/+95
|
* DHCP DUID, IAID configuration optionsVinay Kulkarni2016-03-301-1/+47
|
* Revert "DHCP DUID and IAID configurability"revert-2818-masterZbigniew Jędrzejewski-Szmek2016-03-211-46/+2
|
* DHCP DUID and IAID configurabilityVinay Kulkarni2016-03-091-2/+46
|
* core: avoid compiler warning when compiling with -fexceptionsThomas Haller2016-02-271-1/+1
| | | | | | | Initialize auto variables with cleanup attribute, otherwise we get a compiler warning with -fexceptions. ./configure CFLAGS='-Wmaybe-uninitialized -fexceptions -O2'
* libsystemd-network: sd-event uses 64bit priorities, expose them in the APIs ↵Lennart Poettering2016-02-201-2/+1
| | | | as such
* libsystemd-network: don't abbreviate "callback" as "cb" needlesslyLennart Poettering2016-02-201-2/+2
| | | | | This isn't an excercise in creating APIs that are hard to understand, hence let's call a callback a callback.
* networkd: FIONREAD is not reliable on some socketsLennart Poettering2016-02-161-14/+9
| | | | Fixes: #2457
* dhcp: assert the success of sd_event_now()Beniamino Galvani2016-02-151-1/+1
| | | | The function must never fail.
* dhcp: delay restarts after NAKsBeniamino Galvani2016-02-021-4/+25
| | | | | | | | | | | | | | 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.
* dhcp: make DHCP_OPTION_* enum publicBeniamino Galvani2016-01-201-23/+23
| | | | | | | | 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.
* util-lib: update dns_name_to_wire_format() to optionally generate DNSSEC ↵Lennart Poettering2015-12-021-1/+1
| | | | | | | canonical names We'll need this later when putting together RR serializations to checksum.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #2029 from teg/network-fixesMartin Pitt2015-11-271-25/+27
|\ | | | | Network fixes
| * sd-dhcp: parse error message in DECLINE or NAKTom Gundersen2015-11-251-4/+5
| | | | | | | | | | | | 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.
| * libsystemd-network: clean up recv functionsTom Gundersen2015-11-251-21/+22
| |
* | dns-domain: simplify dns_name_is_root() and dns_name_is_single_label()Lennart Poettering2015-11-251-2/+2
|/ | | | | | | | | | | | | | 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().
* libsystemd-network: add support for "Client FQDN" DHCP optionBeniamino Galvani2015-11-171-9/+44
| | | | | | | | | | | 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.
* doc: correct orthography, word forms and missing/extraneous wordsJan Engelhardt2015-11-061-1/+1
|
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-10/+11
| | | | | | | | | | | | | | 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.