]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/libsystemd-network/sd-dhcp6-client.c
libsystemd-network: use recv(..., 0) instead of read(...) (#3317)
authorTom Gundersen <teg@jklm.no>
Sat, 21 May 2016 21:00:32 +0000 (23:00 +0200)
committerEvgeny Vereshchagin <evvers@ya.ru>
Sat, 21 May 2016 21:00:32 +0000 (00:00 +0300)
commitcf447cb62d01137f4cbd1cd14b83b88823542bbf
tree1e9440ae56f2b50025b7d10e82d07d9e9ce51ea6
parent3da48d7aa9438029f45b84124b825634c2f091dc
libsystemd-network: use recv(..., 0) instead of read(...) (#3317)

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.
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp6-client.c