From 37867847e5ef410231500cdafe6784022142d876 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 7 Dec 2011 21:59:23 +0000 Subject: [PATCH] Print error when write() to tun device fails. This happens on OpenBSD when writing IPv6 packets, for some reason. Silent failure is not recommended; much better to bitch about it. Signed-off-by: David Woodhouse --- tun.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tun.c b/tun.c index a66a196..6699143 100644 --- a/tun.c +++ b/tun.c @@ -668,10 +668,15 @@ int tun_mainloop(struct openconnect_info *vpninfo, int *timeout) #endif vpninfo->incoming_queue = this->next; - if (write(vpninfo->tun_fd, data, len) < 0 && - errno == ENOTCONN) { - vpninfo->quit_reason = "Client connection terminated"; - return 1; + if (write(vpninfo->tun_fd, data, len) < 0) { + /* Handle death of "script" socket */ + if (vpninfo->script_tun && errno == ENOTCONN) { + vpninfo->quit_reason = "Client connection terminated"; + return 1; + } + vpn_progress(vpninfo, PRG_ERR, + _("Failed to write incoming packet: %s\n"), + strerror(errno)); } free(this); } -- 2.7.4