summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-dhcp/dhcp-network.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-12-20 16:16:11 +0100
committerTom Gundersen <teg@jklm.no>2013-12-22 14:27:15 +0100
commit1c8035a89747ed3aadc433bdd11b865cd0d02472 (patch)
tree358ffe8c7f1974308a5cb226cac397cbfa62713e /src/libsystemd-dhcp/dhcp-network.c
parentlibsystemd-dhcp: Use be32_t for IP addresses in network order. (diff)
downloadsystemd-1c8035a89747ed3aadc433bdd11b865cd0d02472.tar.xz
systemd-1c8035a89747ed3aadc433bdd11b865cd0d02472.zip
libsystemd-dhcp: Return proper error if bind fails
This also fixes a minor indentation damage. [tomegun: use close_noint_nofail() instead and drop 'err' variables]
Diffstat (limited to '')
-rw-r--r--src/libsystemd-dhcp/dhcp-network.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libsystemd-dhcp/dhcp-network.c b/src/libsystemd-dhcp/dhcp-network.c
index 83a30842c2..7fecf270f8 100644
--- a/src/libsystemd-dhcp/dhcp-network.c
+++ b/src/libsystemd-dhcp/dhcp-network.c
@@ -31,7 +31,7 @@
#include "dhcp-internal.h"
int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
- {
+{
int s;
s = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
@@ -46,7 +46,7 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
memset(link->ll.sll_addr, 0xff, ETH_ALEN);
if (bind(s, &link->sa, sizeof(link->ll)) < 0) {
- close(s);
+ close_nointr_nofail(s);
return -errno;
}
@@ -56,10 +56,8 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
const void *packet, size_t len)
{
- int err = 0;
-
if (sendto(s, packet, len, 0, &link->sa, sizeof(link->ll)) < 0)
- err = -errno;
+ return -errno;
- return err;
+ return 0;
}