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

Function tcp_stats_sample_rollthedice

freebsd/netinet/tcp_stats.c:186–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185#ifdef _KERNEL
186int
187tcp_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

Callers 1

tcp_log_grow_tlbFunction · 0.85

Calls 3

stats_blob_destroyFunction · 0.85
stats_blob_allocFunction · 0.85

Tested by

no test coverage detected