MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_l2tp_seq_rack_timeout

Function ng_l2tp_seq_rack_timeout

freebsd/netgraph/ng_l2tp.c:1448–1499  ·  view source on GitHub ↗

* Handle a transmit timeout. The peer has failed to respond * with an ack for our packet, so retransmit it. */

Source from the content-addressed store, hash-verified

1446 * with an ack for our packet, so retransmit it.
1447 */
1448static void
1449ng_l2tp_seq_rack_timeout(node_p node, hook_p hook, void *arg1, int arg2)
1450{
1451 const priv_p priv = NG_NODE_PRIVATE(node);
1452 struct l2tp_seq *const seq = &priv->seq;
1453 struct mbuf *m;
1454 u_int delay;
1455
1456 /* Sanity check */
1457 L2TP_SEQ_CHECK(seq);
1458
1459 mtx_lock(&seq->mtx);
1460 /* Make sure callout is still active before doing anything */
1461 if (callout_pending(&seq->rack_timer) ||
1462 !callout_active(&seq->rack_timer)) {
1463 mtx_unlock(&seq->mtx);
1464 return;
1465 }
1466
1467 priv->stats.xmitRetransmits++;
1468
1469 /* Have we reached the retransmit limit? If so, notify owner. */
1470 if (seq->rexmits++ >= priv->conf.rexmit_max)
1471 ng_l2tp_seq_failure(priv);
1472
1473 /* Restart timer, this time with an increased delay */
1474 delay = (seq->rexmits > 12) ? (1 << 12) : (1 << seq->rexmits);
1475 if (delay > priv->conf.rexmit_max_to)
1476 delay = priv->conf.rexmit_max_to;
1477 ng_callout(&seq->rack_timer, node, NULL,
1478 hz * delay, ng_l2tp_seq_rack_timeout, NULL, 0);
1479
1480 /* Do slow-start/congestion algorithm windowing algorithm */
1481 seq->ns = seq->rack;
1482 seq->ssth = (seq->cwnd + 1) / 2;
1483 seq->cwnd = 1;
1484 seq->acks = 0;
1485
1486 /* Retransmit oldest unack'd packet */
1487 m = L2TP_COPY_MBUF(seq->xwin[0], M_NOWAIT);
1488 mtx_unlock(&seq->mtx);
1489 if (m == NULL)
1490 priv->stats.memoryFailures++;
1491 else
1492 ng_l2tp_xmit_ctrl(priv, m, seq->ns++);
1493
1494 /* callout_deactivate() is not needed here
1495 as ng_callout() is getting called each time */
1496
1497 /* Sanity check */
1498 L2TP_SEQ_CHECK(seq);
1499}
1500
1501/*
1502 * Transmit a control stream packet, payload optional.

Callers

nothing calls this directly

Calls 5

ng_l2tp_seq_failureFunction · 0.85
ng_l2tp_xmit_ctrlFunction · 0.85
ng_calloutFunction · 0.70
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected