From 7fd81113e6cca7360dbec0dafcf694c11bca03f6 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 25 Apr 2023 19:23:52 +0200 Subject: [PATCH] Warn about tunnel buffer being full only once per second Otherwise, when the network output bandwidth is full, we additionally fill the disk with logs. --- l2tpns.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/l2tpns.c b/l2tpns.c index 3d722e5..0caf17b 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -1301,7 +1301,20 @@ void tunnelsend(uint8_t * buf, uint16_t l, tunnelidt t) if (sendto(udpfd[tunnel[t].indexudp], buf, l, 0, (void *) &addr, sizeof(addr)) < 0) { - LOG(0, ntohs((*(uint16_t *) (buf + 6))), t, "Error sending data out tunnel: %s (udpfd=%d, buf=%p, len=%d, dest=%s)\n", + sessionidt s = ntohs((*(uint16_t *) (buf + 6))); + if (errno == EAGAIN) + { + static time_t lastwarn; + time_t newtime = time(NULL); + + if (lastwarn != newtime) + { + lastwarn = newtime; + LOG(0, 0, t, "Error sending data out tunnel: buffer full\n"); + } + } + else + LOG(0, s, t, "Error sending data out tunnel: %s (udpfd=%d, buf=%p, len=%d, dest=%s)\n", strerror(errno), udpfd[tunnel[t].indexudp], buf, l, inet_ntoa(addr.sin_addr)); STAT(tunnel_tx_errors); return;