summaryrefslogtreecommitdiff
path: root/src/libsystemd-dhcp/dhcp-network.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-12-20 17:16:11 +0200
committerTom Gundersen <teg@jklm.no>2013-12-22 14:27:15 +0100
commit1c8035a89747ed3aadc433bdd11b865cd0d02472 (patch)
tree358ffe8c7f1974308a5cb226cac397cbfa62713e /src/libsystemd-dhcp/dhcp-network.c
parent3b349af69aab440a625fedb21377e2bdc461098e (diff)
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 'src/libsystemd-dhcp/dhcp-network.c')
-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;
}