* Handle a transmit timeout. The peer has failed to respond * with an ack for our packet, so retransmit it. */
| 1446 | * with an ack for our packet, so retransmit it. |
| 1447 | */ |
| 1448 | static void |
| 1449 | ng_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. |
nothing calls this directly
no test coverage detected