* 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": */
| 3492 | * given by the "ifp" argument and save it in "inp->inp_snd_tag": |
| 3493 | */ |
| 3494 | int |
| 3495 | in_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, ¶ms, 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 | |
| 3531 | void |
| 3532 | in_pcbdetach_tag(struct m_snd_tag *mst) |
no test coverage detected