summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-server.c
AgeCommit message (Collapse)Author
2015-09-01Merge pull request #1108 from phomes/dont-shadow-globalsDavid Herrmann
tree-wide: do not shadow the global var timezone
2015-09-01tree-wide: do not shadow the global var timezoneThomas Hindoe Paaboel Andersen
2015-08-31sd-dhcp-server: simplify pool creationTom Gundersen
Merge sd_dhcp_server_set_address() and sd_dhcp_server_set_lease_pool() into sd_dhcp_server_configure_pool() as the behavior of the two former depends on the order they are called in. The flexibility is not needed, so let's just do this in one call.
2015-08-28sd-dhcp-server: improve predictability of leasesTom Gundersen
Rather than having all clients attempt to get the same leases (starting at the beginning of the pool), make each client star at a random offset into the pool determined by their client id. This greatly increases the chances of a given client receiving the same IP address even though both the client and server have lost any lease information (and distinct server instances handing out the same leases).
2015-08-27dhcp,network: support emitting DNS/NTP server information from DHCP serverLennart Poettering
For now, this is very simple and IP addresses have to be configured manually.
2015-08-27networkd: make DHCP lease timeouts configurableLennart Poettering
2015-08-26dhcp: rename index to ifindexLennart Poettering
This avoids confusion what this is, in particular as libc knows an index() function.
2015-08-26dhcp: store client id as void*, since we dont know what it isLennart Poettering
2015-08-26dhcp: properly handle error from ioctl()Lennart Poettering
2015-08-26dhcp: generic data should be void*, not uint8_t*Lennart Poettering
If we handly arbitrary data we should use "void*" pointers, not "uint8_t*", how go intended C to be used.
2015-08-26network: s/user_data/userdata/Lennart Poettering
Everywhere else we call the generic user data pointer just "userdata", rather than "user_data". Let's do this here, 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-26dhcp,network: implement RFC 4833 (DHCP Timezone option)Lennart Poettering
This one is simply to add: encode the tzdata timezone in the DHCP options and optionally make use of it.
2015-08-06tree-wide: do not return error codes as boolThomas Hindoe Paaboel Andersen
2015-08-04networkd: DHCP fix CID 1315105Susant Sahani
CID 1315105: Resource leaks (RESOURCE_LEAK) /src/libsystemd-network/sd-dhcp-server.c: 800 in dhcp_server_handle_message() *** CID 1315105: Resource leaks (RESOURCE_LEAK) /src/libsystemd-network/sd-dhcp-server.c: 800 in
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-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-03-27fix gcc warnings about uninitialized variablesHarald Hoyer
like: src/shared/install.c: In function ‘unit_file_lookup_state’: src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] return r < 0 ? r : state; ^ src/shared/install.c:1796:13: note: ‘r’ was declared here int r; ^
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-02-09treewide: correct typos and use consistent "MAC" spellingTorstein Husebø
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-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-08-14sd-dhcp-server: linebreaksTom Gundersen
Don't overflow unnecessarily.
2014-08-04sd-dhcp-server: always send out ROUTER and SUBNET_MASKTom Gundersen
For now we simply take these values from the server's address.
2014-08-03sd-dhcp-server: avoid returning garbage valueThomas Hindoe Paaboel Andersen
Force renewing with a pool size of 0 would return the uninitialized r.
2014-08-03sd-dhcp-server: check if r < 0Thomas Hindoe Paaboel Andersen
2014-07-28sd-dhcp-server: add forcerenew supportTom Gundersen
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-14sd-dhcp-server: make gcc happyTom Gundersen
It complains about optoffset possibly being uninitialized. It is wrong, but let's just initialize it.
2014-06-29networkd/sd-dhcp-server: only start dhcp server when necessaryTom Gundersen
2014-06-21sd-dhcp-server: change default lease time form 1m to 1hTom Gundersen
The short lease was useful for testing, but in real-world usage it is pointless to keep leases this short. That said, the cost of lease renewal is really low, so we keep the lease still relatively short at one hour to not get into hard-to-hit problems with lease exhaustion etc.
2014-06-21sd-dhcp-server: fix broadcast of DHCP packetsTom Gundersen
The destination IP address should be INADDR_BROADCAST, but was accidentally left as INADDR_ANY.
2014-06-20sd-dhcp-server: remove unused cleanup functionThomas Hindoe Paaboel Andersen
Removes _cleanup_dhcp_lease_free_. While the automatic cleanup functions are great to have this one is never used and causes a warning in clang.
2014-06-19dhcp-server: simplify dhcp server unref callLennart Poettering
No need to use HASHMAP_ITERATE when we destruct all entries anyway.
2014-06-18sd-dhcp-server: fix a leakThomas Hindoe Paaboel Andersen
We must use free instead of dhcp_lease_free here to avoid freeing client_id.data.
2014-06-13sd-dhcp-server: add RELEASE supportTom Gundersen
2014-06-13sd-dhcp-server: add dummy DECLINE supportTom Gundersen
2014-06-13sd-dhcp-server: track bound leasesTom Gundersen
Make sure we don't hand out the same IP twice. We still don't handle lease expiry.
2014-06-13sd-dhcp-server: add support for clients requesting lease lifetimeTom Gundersen
2014-06-13sd-dhcp-server: add basic NAK supportTom Gundersen
2014-06-13sd-dhcp-server: add basic REQUEST/ACK supportTom Gundersen
2014-06-13sd-dhcp-server: add basic DISCOVER/OFFER supportTom Gundersen
2014-06-13sd-dhcp-server: add support for sending messagesTom Gundersen
2014-06-13sd-dhcp-server: add support for setting the server addressTom Gundersen
2014-06-13sd-dhcp-server: bind to raw socket for sendingTom Gundersen
We would like to use the UDP socket, but we cannot as we need to specify the MAC address manually.
2014-06-13sd-dhcp-server: add basic message parsingTom Gundersen
Parse the maximum message size the client can accept and the client id, falling back to sane defaults if they are not set.
2014-06-13sd-dhcp-server: add basic message handling and verificationTom Gundersen
2014-06-13sd-dhcp-server: bind to a given interfaceTom Gundersen
We will (at least at first), restrict our focus to running the server on at most one interface.