summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-client.c
AgeCommit message (Collapse)Author
2014-08-01sd-dhcp-client: allow the max dhcp message size to be set to the MTU of the linkTom Gundersen
2014-07-28sd-dhcp-client: add support for FORCERENEWTom Gundersen
This partially implements RFC3203. Note that we are not fully compliant as we do not support authentication.
2014-07-28sd-dhcp-client: listen on UDP socket as soon as a lease is acquiredTom Gundersen
This is necessary in order to listen for FORCERENEW events.
2014-07-28sd-dhcp-client: drop event DHCP_EVENT_NO_LEASETom Gundersen
Keep this internal to the client and simply restart it when NAK is receieved, as per the RFC.
2014-07-28sd-dhcp-client: only verify UDP messagesTom Gundersen
RAW messages are verified by the BPF in the kernel.
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-07-15sd-dhcp-client: make request broadcasts opt-inTom Gundersen
It appears there is no good way to decide whether or not broadcasts should be enabled, there is hardware that must have broadcast, and there are networks that only allow unicast. So we give up and make this configurable. By default, unicast is used, but if the kernel were to inform us abotu certain interfaces requiring broadcast, we could change this to opt-in by default in those cases.
2014-07-14networkd: dhcp add vendor class indentifier option 60Susant Sahani
Vendor Class Identifier be used by DHCP clients to identify their vendor type and configuration. When using this option, vendors can define their own specific identifier values, such as to convey a particular hardware or operating system configuration or other identifying information. Vendor-specified DHCP options—features that let administrators assign separate options to clients with similar configuration requirements. For example, if DHCP-aware clients for example we want to separate different gateway and option for different set of people (dev/test/hr/finance) in a org or devices for example web/database servers or let's say in a embedded device etc and require a different default gateway or DNS server than the rest of clients.
2014-07-07dhcp-network: add check for DHCP.chaddrMichal Sekletar
Check that received DHCP packets actually include our MAC address in chaddr field. BPF interpreter has 32 bit wide registers but MAC address is 48 bits long so we have to do check in two steps.
2014-07-01networkd: send hostname to dhcp serverEugene Yakubovich
Send hostname (option 12) in DISCOVER and REQUEST messages so the DHCP server could use it to register with dynamic DNS and such. To opt-out of this behaviour set SendHostname to false in [DHCP] section of .network file [tomegun: rebased, made sure a failing set_hostname is a noop and moved config from DHCPv4 to DHCP]
2014-06-29sd-dhcp-client: don't fail hard if UDP socket can not be boundTom Gundersen
Even if we cannot renew the lease at T1, we will likely succeed at T2, so warn and ignore the failure. This could happen if for whatever reason the received address is not yet configured, or it has been lost.
2014-06-29sd-dhcp-client/networkd: set lifetimes for IPv4 addressesPatrik Flykt
Note that /proc/sys/net/ipv4/ip_dynaddr needs to be non-zero. [tomegun: hook up DHCP renew events to increase the lifetime when necessary]
2014-06-24sd-dhcp-client: return NULL from _unref() like the other sd-* librariesTom Gundersen
Let's keep this behavior consistent across our libraries. In order to keep the refcounting working, a DONT_DESTROY macro similar to the one in sd-bus was introduced.
2014-06-18sd-dhcp-client: check return from dhcp_option_appendThomas Hindoe Paaboel Andersen
2014-06-13sd-dhcp-client: fix invalid free() in client_send_request()Andreas Henriksson
static int client_send_request(...) in ./src/libsystemd-network/sd-dhcp-client.c tries to initialize "request" by calling client_message_init(...), which has atleast 5 error cases where it can return without that happening. This leads to the function finishing without "request" being initialized.
2014-06-03sd-dhcp-client: allways request broadcastCamilo Aguilar
On systems which cannot receive unicast packets until its IP stack has been configured we need to request broadcast packets. We are currently not able to reliably detect when this is necessary, so set it unconditionally for now. This is set on all packets, but the DHCP server will only broadcast the packets that are necessary, and unicast the rest. For more information please refer to this thread in CoreOS: https://github.com/coreos/bugs/issues/12 [tomegun: rephrased commit message]
2014-05-25Use %m instead of strerror(errno) where appropiateCristian Rodríguez
2014-05-21sd-dhcp-client: factor out dhcp packet allocationTom Gundersen
2014-05-21sd-dhcp: rely on FIONREAD workingTom Gundersen
This fallback will anyway never get tested, so rip it out.
2014-05-21sd-dhcp: option_append - support falling back to 'sname' and 'file'Tom Gundersen
2014-05-20sd-dhcp: refactor dhcp_option_appendTom Gundersen
Store a pointer to the options in the DHCPMessage struct, and pass this together with an offset around, rather than a uint8_t**. This avoids us having to (re)compute the pointer; and changes dhcp_option_append from adjusting both the pointer to the next option and the remaining size of the options, to just adjusting the current offset. This makes the code a bit simpler to follow IMHO, but there should be no functional change.
2014-05-09sd-dhcp-client: improve logging when stopping clientTom Gundersen
'Requested by user' was confusing, just drop it.
2014-05-06sd-dhcp-client: use asynchronous_close()Tom Gundersen
close() is a blocking call, which may slow things down measurably when running many dhcp clients in the same single-threaded main loop. Let's just use the asynchronous version instead to avoid the problem.
2014-05-06dhcp-network: don't pass ifindex to bind_udp_socketTom Gundersen
UDP sockets can anyway not be bound to specific netdev's. The packages would have to be filtered when received instead.
2014-04-27sd-dhcp-client: log positive error numberUmut Tezduyar Lindskog
Log error no for such client_stop(client, DHCP_EVENT_STOP)
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-20sd-dhcp-client: log ifindex and mac address when startingTom Gundersen
2014-04-12test-dhcp-client: unref lease objects to make valgrind happyZbigniew Jędrzejewski-Szmek
Also unref client objects in test code, and initalize logging, to DEBUG by default.
2014-04-12sd-dhcp-client: drop logging about T1/T2Tom Gundersen
These are redundant now that the REQUEST messages contain the same information.
2014-04-12sd-dhcp-client: improve loggingTom Gundersen
Specify what kind of REQUEST we send, and distinguish between REBOOT and START. Also log stop reasons as strings rather than numbers.
2014-04-12sd-dhcp-client: use client_initialiez and client_restart for REBOOTTom Gundersen
2014-04-11sd-dhcp-client: document message creation a bit moreTom Gundersen
Also reshuffle some code to make the correspondence with the RFC a bit more obvious. Small functional change: fail if we try to send a message from the wrong state.
2014-04-11sd-dhcp-client: assert that we can only create DISCOVER or REQUEST messagesTom Gundersen
2014-04-11sd-dhcp-client: rebind raw socket when resetting transaction idTom Gundersen
As we are now filtering the raw socket based on the transaction id, we must reset the BPF when we reset the transaction id.
2014-04-11sd-dhcp-client: Add an explicit stop state for the DHCP clientPatrik Flykt
Add an explicit stop state for the DHCP client so that the library user can issue a stop at any time the callback has been called. When returning from the callback, check also the stop state and stop any further DHCP processing.
2014-04-11sd-dhcp-client: Add reference counting for DHCPPatrik Flykt
The DHCP library user can decide to free the DHCP client any time the callback is called. After the callback has been called, other computations may still be needed - the best example being a full restart of the DHCP procedure in case of lease expiry. Fix this by introducing proper reference counting. Properly handle a returned NULL from the notify and stop functions if the DHCP client was freed.
2014-04-11sd-dhcp-client: recevie_message - verify cmsg_len before readingTom Gundersen
2014-04-06sd-dhcp-client: improve BPFTom Gundersen
Try a bit harder to make the kernel drop packets not for us. This should reduce the number of wakeups from n^2 to n in the number of dhcp clients, which admittedly only makes a differenc in very extreme cases.
2014-04-06sd-dhcp-client: eagerly drop too small packetsTom Gundersen
If they are too small to fit the IP+UDP+DHCP headers they can be of no use, so don't waste resources parsing them. This is at the cost of losing some verbosity in the logging.
2014-04-06sd-dhcp-client: move magic cookie into DHCPMessage structTom Gundersen
Also move the checking of it to the main message handler, rather than the options parser. Fix a bug, so we now drop the packet if any of the magic bytes don't match. Before we used to only drop the packet if they were all wrong.
2014-03-27silence warningsThomas Hindoe Paaboel Andersen
2014-03-24sd-event: rework API to support CLOCK_REALTIME_ALARM and ↵Lennart Poettering
CLOCK_BOOTTIME_ALARM, too
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-21sd-dhcp-client: add fallback subnet masksTom Gundersen
The DHCP RFC does not require the DHCP server to send a subnet mask, so if it is missing, let's try to use the default subnet masks based on address class. In case the class the address belongs to does not have a default subnet mask, we fail as before. Also improve logging when handling invalid dhcp messages, and simply ignore them rather than stop the whole dhcp client.
2014-03-21sd-dhcp-client: make timeout handling a bit more robustTom Gundersen
Accept any lease lifetime greater than one second. Server should not hand out extremely short leases, but let's not be the ones to fail. Do not fail when arming a timer in the past, but also only arm one such timer. Avoid rounding errors when computing the default timeouts, this may be an issue if we are handed a very short lease. Also, don't pass 'time_now' around, as that can be found in the event object when needed.
2014-03-20sd-dhcp-client: do not reset 'secs' when entering INIT-REBOOTTom Gundersen
Also keep start_time in sync, but that shouldn't matter.
2014-03-20sd-dhcp-client: don't pass around 'secs'Tom Gundersen
The value is stored in the client object, so get it there when needed.
2014-03-20libsystemd-network: Don't unnecessarily send too long packetsPatrik Flykt
Since the length used by options is known, send packets with no extra padding.
2014-03-20libsystemd-network: Prepend hardware type byte to client identifierPatrik Flykt
Even though client identifiers SHOULD be treated as opaque objects by DHCP servers, follow the recommendation of a hardware type field with value 0x01 (ethernet) followed by the hardware address as described in RFC 2132.
2014-03-19sd-dhcp-client: accept infinite lease lifetimeTom Gundersen
Otherwise we would fail with -EINVAL. Thanks to Brandon Philips <brandon.philips@coreos.com>, for reporting the bug.