| 1409 | } |
| 1410 | |
| 1411 | int |
| 1412 | sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, |
| 1413 | struct sctp_nets *net) |
| 1414 | { |
| 1415 | uint8_t net_was_pf; |
| 1416 | |
| 1417 | if (net->dest_state & SCTP_ADDR_PF) { |
| 1418 | net_was_pf = 1; |
| 1419 | } else { |
| 1420 | net_was_pf = 0; |
| 1421 | } |
| 1422 | if (net->hb_responded == 0) { |
| 1423 | if (net->ro._s_addr) { |
| 1424 | /* |
| 1425 | * Invalidate the src address if we did not get a |
| 1426 | * response last time. |
| 1427 | */ |
| 1428 | sctp_free_ifa(net->ro._s_addr); |
| 1429 | net->ro._s_addr = NULL; |
| 1430 | net->src_addr_selected = 0; |
| 1431 | } |
| 1432 | sctp_backoff_on_timeout(stcb, net, 1, 0, 0); |
| 1433 | if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { |
| 1434 | /* Assoc is over */ |
| 1435 | return (1); |
| 1436 | } |
| 1437 | } |
| 1438 | /* Zero PBA, if it needs it */ |
| 1439 | if (net->partial_bytes_acked) { |
| 1440 | net->partial_bytes_acked = 0; |
| 1441 | } |
| 1442 | if ((stcb->asoc.total_output_queue_size > 0) && |
| 1443 | (TAILQ_EMPTY(&stcb->asoc.send_queue)) && |
| 1444 | (TAILQ_EMPTY(&stcb->asoc.sent_queue))) { |
| 1445 | sctp_audit_stream_queues_for_size(inp, stcb); |
| 1446 | } |
| 1447 | if (!(net->dest_state & SCTP_ADDR_NOHB) && |
| 1448 | !((net_was_pf == 0) && (net->dest_state & SCTP_ADDR_PF))) { |
| 1449 | /* |
| 1450 | * when move to PF during threshold mangement, a HB has been |
| 1451 | * queued in that routine |
| 1452 | */ |
| 1453 | uint32_t ms_gone_by; |
| 1454 | |
| 1455 | if ((net->last_sent_time.tv_sec > 0) || |
| 1456 | (net->last_sent_time.tv_usec > 0)) { |
| 1457 | struct timeval diff; |
| 1458 | |
| 1459 | SCTP_GETTIME_TIMEVAL(&diff); |
| 1460 | timevalsub(&diff, &net->last_sent_time); |
| 1461 | ms_gone_by = (uint32_t)(diff.tv_sec * 1000) + |
| 1462 | (uint32_t)(diff.tv_usec / 1000); |
| 1463 | } else { |
| 1464 | ms_gone_by = 0xffffffff; |
| 1465 | } |
| 1466 | if ((ms_gone_by >= net->heart_beat_delay) || |
| 1467 | (net->dest_state & SCTP_ADDR_PF)) { |
| 1468 | sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED); |
no test coverage detected