summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2012-08-23 16:38:50 +0200
committerKozlov Dmitry <xeb@mail.ru>2012-08-23 21:35:11 +0400
commiteb1fe6921bccf5bf52495a28ea9c95b69f5c8bcb (patch)
tree1926c0762a5351ceeed7f28d791d7a208fdb089b
parent5c5d93e2a622bc6736267701aaaf0f472442590a (diff)
downloadaccel-ppp-eb1fe6921bccf5bf52495a28ea9c95b69f5c8bcb.tar.gz
accel-ppp-eb1fe6921bccf5bf52495a28ea9c95b69f5c8bcb.zip
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 <g.nault@alphalink.fr>
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c8
-rw-r--r--accel-pppd/ctrl/l2tp/packet.c5
2 files changed, 11 insertions, 2 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 01d0c90b..f6df3af7 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -920,10 +920,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 f8a46e7f..60b9d36c 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;
}