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

Function in_pcbattach_txrtlmt

freebsd/netinet/in_pcb.c:3494–3529  ·  view source on GitHub ↗

* Allocate a new TX rate limit send tag from the network interface * given by the "ifp" argument and save it in "inp->inp_snd_tag": */

Source from the content-addressed store, hash-verified

3492 * given by the "ifp" argument and save it in "inp->inp_snd_tag":
3493 */
3494int
3495in_pcbattach_txrtlmt(struct inpcb *inp, struct ifnet *ifp,
3496 uint32_t flowtype, uint32_t flowid, uint32_t max_pacing_rate, struct m_snd_tag **st)
3497
3498{
3499 union if_snd_tag_alloc_params params = {
3500 .rate_limit.hdr.type = (max_pacing_rate == -1U) ?
3501 IF_SND_TAG_TYPE_UNLIMITED : IF_SND_TAG_TYPE_RATE_LIMIT,
3502 .rate_limit.hdr.flowid = flowid,
3503 .rate_limit.hdr.flowtype = flowtype,
3504 .rate_limit.hdr.numa_domain = inp->inp_numa_domain,
3505 .rate_limit.max_rate = max_pacing_rate,
3506 .rate_limit.flags = M_NOWAIT,
3507 };
3508 int error;
3509
3510 INP_WLOCK_ASSERT(inp);
3511
3512 /*
3513 * If there is already a send tag, or the INP is being torn
3514 * down, allocating a new send tag is not allowed. Else send
3515 * tags may leak.
3516 */
3517 if (*st != NULL || (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) != 0)
3518 return (EINVAL);
3519
3520 error = m_snd_tag_alloc(ifp, &params, st);
3521#ifdef INET
3522 if (error == 0) {
3523 counter_u64_add(rate_limit_set_ok, 1);
3524 counter_u64_add(rate_limit_active, 1);
3525 } else if (error != EOPNOTSUPP)
3526 counter_u64_add(rate_limit_alloc_fail, 1);
3527#endif
3528 return (error);
3529}
3530
3531void
3532in_pcbdetach_tag(struct m_snd_tag *mst)

Callers 2

rt_setup_rateFunction · 0.85

Calls 2

m_snd_tag_allocFunction · 0.85
counter_u64_addFunction · 0.50

Tested by

no test coverage detected