From b9fe13c105235c9b790a8a217f566548022ec8a5 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Thu, 14 Jun 2018 23:31:09 +0200 Subject: [PATCH] PPP, PPPoL2TP: fix ZLB packets Ns value Our Ns counter is the current slot rather than the next to ease packet retransmission. Therefore we increment the Ns counter before using the next slot instead of after. The RFC is written with post-increment in mind rather than pre-increment, thus when the RFC says that Ns in not incremented for ZLB packets it actually means that ZLB packets are sent with the next Ns without post-incrementing the Ns value, meaning the ZLB packet does not take a slot. Since we are using a pre-incremented value for real slots we need to send ZLB packets with our current Ns value plus one. Signed-off-by: Sylvain Rochet --- src/netif/ppp/pppol2tp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/netif/ppp/pppol2tp.c b/src/netif/ppp/pppol2tp.c index cd497650..8fb66fa1 100644 --- a/src/netif/ppp/pppol2tp.c +++ b/src/netif/ppp/pppol2tp.c @@ -549,7 +549,7 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, u16_t port, str break; /* Stop Control Connection Notification */ case PPPOL2TP_MESSAGETYPE_STOPCCN: - pppol2tp_send_zlb(l2tp, l2tp->our_ns); /* Ack the StopCCN before we switch to down state */ + pppol2tp_send_zlb(l2tp, l2tp->our_ns+1); /* Ack the StopCCN before we switch to down state */ if (l2tp->phase < PPPOL2TP_STATE_DATA) { pppol2tp_abort_connect(l2tp); } else if (l2tp->phase == PPPOL2TP_STATE_DATA) { @@ -701,7 +701,7 @@ nextavp: return; send_zlb: - pppol2tp_send_zlb(l2tp, l2tp->our_ns); + pppol2tp_send_zlb(l2tp, l2tp->our_ns+1); return; packet_too_short: PPPDEBUG(LOG_DEBUG, ("pppol2tp: packet too short: %d\n", p->len));