Age | Commit message (Collapse) | Author |
|
This is similar to sd-login, but exposes the state of networkd rather than logind.
Include it in libsystemd-dhcp and rename it to libsystemd-network.
|
|
If an UDP packet has not passed through a hardware device, its checksum may not
have been computed. This is exposed through the TP_STATUS_CSUMNOTREADY sockopt.
When using raw sockets, skip checksum validation when TP_STATUS_CSUMNOTREADY
is set.
This is necessary for dhcp to work directly over a veth tunnel, e.g. as done
in systemd-nspawn.
|
|
|
|
|
|
The RFC does not specify that the packets from the DHCP server must come from
the DHCP server port, only that that's where they should be sent.
This fixes a problem when running networkd in VirtualBox.
Thanks to Sébastien Luttringer for reporting the bug and very patiently testing
various fixes.
|
|
This avoids the problem of broken DHCP servers sending us too big packets that don't fit in our buffer.
|
|
Also be more explicit about why packages are ignored.
|
|
This may be a common problem, so let's make it simpler to debug,
at least for now.
|
|
|
|
|
|
|
|
first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:
1. The object the new object is derived from is put first, if there is any
2. The object we are creating will be returned in the next arguments
3. This is followed by any additional arguments
Rationale:
For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.
Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.
Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
|
|
|
|
Upon startup the DHCP library will immediately send a DHCP Discover.
Handle the additional DHCP Discover checking and DHCP Offer sending
in test_addr_acq_recv_discover(). Write a zero UDP checksum, the
received XID and the faked MAC address into place to create a DHCP
message the library can accept.
Follow exactly the same steps when receiving a DHCP Request in
test_addr_acq_recv_request() and send the Ack. Check that the proper
addresses have been found by the DHCP library before exiting the
main loop and finishing the test.
|
|
Add a callback function that will handle the test case specific checking.
|
|
|
|
This fixes a regression introduced in e5002702.
|
|
We want to reuse these functions for the server library too.
|
|
|
|
Split the recevie_message callback into _raw and _udp parts and a generic
DHCPMessage handler.
Also always verify the xid/MAC, rather than only for udp messages.
|
|
Some DHCP servers will not work correctly if secs == 0, so round up
to at least 1.
|
|
|
|
This allows us users of the library to keep copies of old leases. This is
used by networkd to know what addresses to drop (if any) when the lease
expires.
In the future this may be used by DNAv4 and sd-dhcp-server.
|
|
Compute the 'secs' field as seconds since start of lease acquisition
procedure. Start off with a value of zero and increase it only for
each resent DHCP discover message. See the discussion before and
after http://www.ietf.org/mail-archive/web/dhcwg/current/msg05836.html
and Section 3.1 of RFC 2131.
|
|
Go back to Init state independent of the current state the client
is in.
|
|
A checksum field with value zero means no UDP checksum has been
computed for the packet.
|
|
|
|
|
|
This was originally included in the dhcp-client at my request, but it is not
really dhcp-specific and useful outside of it, so let's pull it out.
|
|
Unlike the other merged libs, the rest of libsystemd will never depend on
sd-dhcp-client, so there is no reason not to keep it separate.
|
|
|
|
My original patch only returned the first DNS server, but we might
want all of them.
|
|
|
|
We need to be able to stop the dhcp client at any time, and the function appears to be written to handle this.
|
|
GREEDY_REALLOC needs to have two size variables: one for the
allocated size, and a second one for the used size. Using
the allocated size only lead to leaving some elements unitialized
and assigning some more than once.
|
|
SipHash appears to be the new gold standard for hashing smaller strings
for hashtables these days, so let's make use of it.
|
|
|
|
Reuse existing functionality when adding T2 Rebinding support.
|
|
Factor out common code from timeout T1 handling and starting of
the DHCP client.
|
|
Expiration of T1 timeout takes the client to the Rebinding state,
where it attempts to renew its lease. Start by opening a DCHP unicast
socket as there now is a proper IP address set.
Compute the resend timer as half of the remaining time down to a
minimum of 60 seconds (RFC2131). Modify DHCP Request sending to send
only UDP DHCP data when unicasting. Also modify DHCP Ack/Nak
receiving such that the client_receive_ack() takes care of using
either the full IP, UDP, DHCP packet or only the DHCP payload
depending whether the client is in Requesting or Renewing state.
Finally always report DHCP_EVENT_IP_ACQUIRE from Requesting state
and only DHCP_EVENT_IP_CHANGE if the IP address was modified when
the lease was renewed.
|
|
Create a helper functions setting up an unicast DHCP UDP socket and
sending data. Add function stubs for the test program.
[tomegun: initialize structs when allocating, and drop unneccesary 'err']
|
|
|
|
Fix off-by-one error and notice that summing may need more than one
round for the result to be in the lower 16 bits.
|
|
When a DHCP Nak is received, return a DHCP_EVENT_NO_LEASE event. If
some other DHCP message is received or an error happens when parsing
options, return -ENOMSG in order to ignore the packet. There may be
more than one server serving the same subnet, each server will send
its Offer to the client.
|
|
|
|
|
|
This also fixes a minor indentation damage.
[tomegun: use close_noint_nofail() instead and drop 'err' variables]
|
|
|
|
Ignore DHCP Ack packets if they are found to be erroneous or have
an unexpected xid by setting the result to zero instead of propagating
an error. Also remember to report a DHCP Nak and stop the DHCP client.
|
|
test-fileio/test-strv:
Use the streq_ptr to make build-scan not worry about passing in a null
to a nonnull function.
test-dhcp-option:
Prevent a theoretical null pointer dereference
|