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 <gradator@gradator.net>
This commit is contained in:
Sylvain Rochet 2018-06-14 23:31:09 +02:00
parent a48ff4aaf2
commit b9fe13c105

View File

@ -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));