diff options
author | 2017-09-20 18:28:14 +0000 | |
---|---|---|
committer | 2017-09-20 18:28:14 +0000 | |
commit | 5cfa73ecd8515f875ec728d11cbf5041a406813d (patch) | |
tree | c1a3e59b68680e7063cc64f7ccacc4766c8a9d07 /sbin/dhclient/bpf.c | |
parent | Keep track of which keypair is in use by a TLS context. (diff) | |
download | wireguard-openbsd-5cfa73ecd8515f875ec728d11cbf5041a406813d.tar.xz wireguard-openbsd-5cfa73ecd8515f875ec728d11cbf5041a406813d.zip |
Make log messages more informative by using the
name of the function that failed and the significant
parameters. Distinguish between poll() errors and
problematic revents values.
Diffstat (limited to 'sbin/dhclient/bpf.c')
-rw-r--r-- | sbin/dhclient/bpf.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index c3e2405c11d..4416d8f39e9 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.68 2017/09/20 15:14:52 krw Exp $ */ +/* $OpenBSD: bpf.c,v 1.69 2017/09/20 18:28:14 krw Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -336,7 +336,8 @@ receive_packet(struct interface_info *ifi, struct sockaddr_in *from, { struct bpf_hdr hdr; struct dhcp_packet *packet = &ifi->recv_packet; - int length = 0, offset = 0; + ssize_t length = 0; + int offset = 0; /* * All this complexity is because BPF doesn't guarantee that @@ -352,8 +353,11 @@ receive_packet(struct interface_info *ifi, struct sockaddr_in *from, /* If the buffer is empty, fill it. */ if (ifi->rbuf_offset >= ifi->rbuf_len) { length = read(ifi->bfdesc, ifi->rbuf, ifi->rbuf_max); - if (length <= 0) - return length ; + if (length == -1) { + log_warn("%s: read(bfdesc)", log_procname); + return length; + } else if (length == 0) + return length; ifi->rbuf_offset = 0; ifi->rbuf_len = length; } |