| 184 | |
| 185 | #ifdef _KERNEL |
| 186 | int |
| 187 | tcp_stats_sample_rollthedice(struct tcpcb *tp, void *seed_bytes, |
| 188 | size_t seed_len) |
| 189 | { |
| 190 | struct rm_priotracker tracker; |
| 191 | int tpl; |
| 192 | |
| 193 | tpl = -1; |
| 194 | |
| 195 | if (V_tcp_stats_nrates > 0) { |
| 196 | rm_rlock(&tcp_stats_tpl_sampling_lock, &tracker); |
| 197 | tpl = stats_tpl_sample_rollthedice(V_tcp_perconn_stats_sample_rates, |
| 198 | V_tcp_stats_nrates, seed_bytes, seed_len); |
| 199 | rm_runlock(&tcp_stats_tpl_sampling_lock, &tracker); |
| 200 | |
| 201 | if (tpl >= 0) { |
| 202 | INP_WLOCK_ASSERT(tp->t_inpcb); |
| 203 | if (tp->t_stats != NULL) |
| 204 | stats_blob_destroy(tp->t_stats); |
| 205 | tp->t_stats = stats_blob_alloc(tpl, 0); |
| 206 | if (tp->t_stats == NULL) |
| 207 | tpl = -ENOMEM; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | return (tpl); |
| 212 | } |
| 213 | |
| 214 | /* |
| 215 | * Callback function for stats_tpl_sample_rates() to interact with the TCP |
no test coverage detected