| 1517 | */ |
| 1518 | |
| 1519 | struct tcp_log_buffer * |
| 1520 | tcp_log_event_(struct tcpcb *tp, struct tcphdr *th, struct sockbuf *rxbuf, |
| 1521 | struct sockbuf *txbuf, uint8_t eventid, int errornum, uint32_t len, |
| 1522 | union tcp_log_stackspecific *stackinfo, int th_hostorder, |
| 1523 | const char *output_caller, const char *func, int line, const struct timeval *itv) |
| 1524 | { |
| 1525 | struct tcp_log_mem *log_entry; |
| 1526 | struct tcp_log_buffer *log_buf; |
| 1527 | int attempt_count = 0; |
| 1528 | struct tcp_log_verbose *log_verbose; |
| 1529 | uint32_t logsn; |
| 1530 | |
| 1531 | KASSERT((func == NULL && line == 0) || (func != NULL && line > 0), |
| 1532 | ("%s called with inconsistent func (%p) and line (%d) arguments", |
| 1533 | __func__, func, line)); |
| 1534 | |
| 1535 | INP_WLOCK_ASSERT(tp->t_inpcb); |
| 1536 | if (tcp_disable_all_bb_logs) { |
| 1537 | /* |
| 1538 | * The global shutdown logging |
| 1539 | * switch has been thrown. Call |
| 1540 | * the purge function that frees |
| 1541 | * purges out the logs and |
| 1542 | * turns off logging. |
| 1543 | */ |
| 1544 | tcp_log_purge_tp_logbuf(tp); |
| 1545 | return (NULL); |
| 1546 | } |
| 1547 | KASSERT(tp->t_logstate == TCP_LOG_STATE_HEAD || |
| 1548 | tp->t_logstate == TCP_LOG_STATE_TAIL || |
| 1549 | tp->t_logstate == TCP_LOG_STATE_CONTINUAL || |
| 1550 | tp->t_logstate == TCP_LOG_STATE_HEAD_AUTO || |
| 1551 | tp->t_logstate == TCP_LOG_STATE_TAIL_AUTO, |
| 1552 | ("%s called with unexpected tp->t_logstate (%d)", __func__, |
| 1553 | tp->t_logstate)); |
| 1554 | |
| 1555 | /* |
| 1556 | * Get the serial number. We do this early so it will |
| 1557 | * increment even if we end up skipping the log entry for some |
| 1558 | * reason. |
| 1559 | */ |
| 1560 | logsn = tp->t_logsn++; |
| 1561 | |
| 1562 | /* |
| 1563 | * Can we get a new log entry? If so, increment the lognum counter |
| 1564 | * here. |
| 1565 | */ |
| 1566 | retry: |
| 1567 | if (tp->t_lognum < tp->t_loglimit) { |
| 1568 | if ((log_entry = uma_zalloc(tcp_log_zone, M_NOWAIT)) != NULL) |
| 1569 | tp->t_lognum++; |
| 1570 | } else |
| 1571 | log_entry = NULL; |
| 1572 | |
| 1573 | /* Do we need to try to reuse? */ |
| 1574 | if (log_entry == NULL) { |
| 1575 | /* |
| 1576 | * Sacrifice auto-logged sessions without a log ID if |
no test coverage detected