From fa66284f4bddf7686d2d5cfe40b387e0bbbba71a Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Thu, 23 Aug 2012 16:38:50 +0200 Subject: L2TP: Tear down tunnel when peer stops listening Stop sending messages on tunnels for which no peer is listening. Discard retransmissions too. Signed-off-by: Guillaume Nault --- accel-pppd/ctrl/l2tp/l2tp.c | 8 +++++++- accel-pppd/ctrl/l2tp/packet.c | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 43b210f..2d37d99 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -913,10 +913,16 @@ static int l2tp_conn_read(struct triton_md_handler_t *h) struct l2tp_conn_t *conn = container_of(h, typeof(*conn), hnd); struct l2tp_packet_t *pack, *p; struct l2tp_attr_t *msg_type; + int res; while (1) { - if (l2tp_recv(h->fd, &pack, NULL)) + res = l2tp_recv(h->fd, &pack, NULL); + if (res) { + if (res == -2) + /* No peer listening, tear down connection */ + l2tp_disconnect(conn); return 0; + } if (!pack) continue; diff --git a/accel-pppd/ctrl/l2tp/packet.c b/accel-pppd/ctrl/l2tp/packet.c index f8a46e7..60b9d36 100644 --- a/accel-pppd/ctrl/l2tp/packet.c +++ b/accel-pppd/ctrl/l2tp/packet.c @@ -147,8 +147,11 @@ int l2tp_recv(int fd, struct l2tp_packet_t **p, struct in_pktinfo *pkt_info) if (n < 0) { mempool_free(buf); - if (errno == EAGAIN) + if (errno == EAGAIN) { return -1; + } else if (errno == ECONNREFUSED) { + return -2; + } log_error("l2tp: recv: %s\n", strerror(errno)); return 0; } -- cgit v1.2.3