summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/l2tp
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2014-04-08 23:06:25 +0200
committerDmitry Kozlov <xeb@mail.ru>2014-04-11 06:47:42 +0400
commit2b911b95edc395a88513f359845e0457a760ab14 (patch)
tree34ece155796e8cab8b2ccdd463e1dd7e7c1ec4c6 /accel-pppd/ctrl/l2tp
parent4a16913ad3e0ba957fb0c4d440e8f91ae2df01d7 (diff)
downloadaccel-ppp-2b911b95edc395a88513f359845e0457a760ab14.tar.gz
accel-ppp-2b911b95edc395a88513f359845e0457a760ab14.zip
l2tp: don't initiate new sessions when sending window is full
Refuse to create new sessions when the local send queue is bigger than the peer's receive window (i.e. when there are already more outstanding messages than what the peer can currently accept). Only sessions initiated locally are affected, session requests from the peer are still handled normally. This avoids adding useless presure on the sending window when many sessions are created locally. If sessions were created, they'd add many ICRQ or OCRQ messages in the send queue and we'd have to wait for all these messages to be sent before being able to reply to messages from the peer. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl/l2tp')
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 325cfea..7807aa1 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -668,6 +668,17 @@ static int l2tp_session_send(struct l2tp_sess_t *sess,
return 0;
}
+static int l2tp_session_try_send(struct l2tp_sess_t *sess,
+ struct l2tp_packet_t *pack)
+{
+ if (sess->paren_conn->send_queue_len >= sess->paren_conn->peer_rcv_wnd_sz)
+ return -1;
+
+ l2tp_session_send(sess, pack);
+
+ return 0;
+}
+
static int l2tp_send_StopCCN(struct l2tp_conn_t *conn,
uint16_t res, uint16_t err)
{
@@ -2305,7 +2316,11 @@ static int l2tp_send_ICRQ(struct l2tp_sess_t *sess)
goto out_err;
}
- l2tp_session_send(sess, pack);
+ if (l2tp_session_try_send(sess, pack) < 0) {
+ log_session(log_error, sess, "impossible to send ICRQ:"
+ " too many outstanding packets in send queue\n");
+ goto out_err;
+ }
return 0;
@@ -2441,7 +2456,11 @@ static int l2tp_send_OCRQ(struct l2tp_sess_t *sess)
goto out_err;
}
- l2tp_session_send(sess, pack);
+ if (l2tp_session_try_send(sess, pack) < 0) {
+ log_session(log_error, sess, "impossible to send OCRQ:"
+ " too many outstanding packets in send queue\n");
+ goto out_err;
+ }
return 0;