summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/dhcp-network.c
AgeCommit message (Collapse)Author
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-07-29sd-network: make socket filter programs static const where possibleLennart Poettering
(also, fix some whitespace/indentation issues, and avoid "index" as identifier in order to not clash against libc's "index()" call)
2014-07-28dhcp-network: enable IP_FREEBIND for UDP socketsTom Gundersen
This allows the sockets to be bound to a specific address before it is configured, also enable SO_REUSEADDR to allow multiple DHCP clients to run at the same time.
2014-07-07dhcp-network: make clear that we are ANDing Fragment offset field with maskMichal Sekletar
Reading BPF assembly written as C macros is inherently difficult. Don't make it harder than necessary and provide clearer explanation in the comment.
2014-07-07dhcp-network: ignore IP packets with More Fragments (MF) flag setMichal Sekletar
We already ignore IP fragments, because we expect that Fragment offset (FO) field is not set. However first fragment in a fragmented IP flow will have all zeroes in FO field. We should ignore such packet as well, thus we need to look at MF flag in the IP header. Checking MF flag will filter out all except last packet in fragmented flows. Last one will be ruled out by next check for value of FO.
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-06-22dhcp-network: don't bother with IP fragmentsMichal Sekletar
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-18dhcp-network: remove TODOMichal Sekletar
There is no need to explicitly check version of L3 protocol in the ethernet header because we bind socket with .sll_protocol set to ETH_P_IP, thus we only receive IPv4 packets on the socket.
2014-06-13sd-dhcp-server: add basic functionality for creating/destroying server instanceTom Gundersen
2014-06-13dhcp-network: allow UDP socket to listen on any addressTom Gundersen
For this to work nicely we need to use REUSEADDR so that more than one socket can be open at the same time. Also, we request the ifindex to be appended to incoming messages, so we know whence it came.
2014-05-06sd-dhcp: network - don't leak sockets on failureTom Gundersen
Also some general cleanups
2014-05-06sd-dhcp: network - set TOS on outgoing packetsTom Gundersen
This should improve performance on busy wireless networks and the like. Inspired by a similar change in dnsmasq.
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-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-02sd-dhcp-client: use BPF on raw socketTom Gundersen
Filter out everything except UDP packets destined for the DHCP client port, this should avoid the vast majority of spurious wakeups. Filter based on [0], with permission. Possible improvemnts: also check for the DHCP magic cookie to drop invalid packets. Check for our xid to filter out packets destined for other clients. [0]: <https://github.com/ambrop72/badvpn/blob/master/dhcpclient/BDHCPClient.c#L57>
2014-04-01sd-dhcp-client: --omg-optimizedTom Gundersen
Passing the protocol to socket() is redundant as it will be specified again in bind(). Dropping the redundancy reduces the cost of bind() from ~30ms to ~0ms. For details see [0]. networkd in a container (i.e., with next to no network latency) can now negotiate a DHCP lease in 0.7 - 5 ms. Thanks to Kay for help with debugging and to Daniel Borkmann for the pointer to fix the problem. [0]: <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=902fefb82ef72a50c78cb4a20cc954b037a98d1c>
2014-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering
safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
2014-02-28sd-network: add new libraryTom Gundersen
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.