* This function should be called when the INP_RATE_LIMIT_CHANGED flag * is set in the fast path and will attach/detach/modify the TX rate * limit send tag based on the socket's so_max_pacing_rate value. */
| 3617 | * limit send tag based on the socket's so_max_pacing_rate value. |
| 3618 | */ |
| 3619 | void |
| 3620 | in_pcboutput_txrtlmt(struct inpcb *inp, struct ifnet *ifp, struct mbuf *mb) |
| 3621 | { |
| 3622 | struct socket *socket; |
| 3623 | uint32_t max_pacing_rate; |
| 3624 | bool did_upgrade; |
| 3625 | int error; |
| 3626 | |
| 3627 | if (inp == NULL) |
| 3628 | return; |
| 3629 | |
| 3630 | socket = inp->inp_socket; |
| 3631 | if (socket == NULL) |
| 3632 | return; |
| 3633 | |
| 3634 | if (!INP_WLOCKED(inp)) { |
| 3635 | /* |
| 3636 | * NOTE: If the write locking fails, we need to bail |
| 3637 | * out and use the non-ratelimited ring for the |
| 3638 | * transmit until there is a new chance to get the |
| 3639 | * write lock. |
| 3640 | */ |
| 3641 | if (!INP_TRY_UPGRADE(inp)) |
| 3642 | return; |
| 3643 | did_upgrade = 1; |
| 3644 | } else { |
| 3645 | did_upgrade = 0; |
| 3646 | } |
| 3647 | |
| 3648 | /* |
| 3649 | * NOTE: The so_max_pacing_rate value is read unlocked, |
| 3650 | * because atomic updates are not required since the variable |
| 3651 | * is checked at every mbuf we send. It is assumed that the |
| 3652 | * variable read itself will be atomic. |
| 3653 | */ |
| 3654 | max_pacing_rate = socket->so_max_pacing_rate; |
| 3655 | |
| 3656 | error = in_pcboutput_txrtlmt_locked(inp, ifp, mb, max_pacing_rate); |
| 3657 | |
| 3658 | if (did_upgrade) |
| 3659 | INP_DOWNGRADE(inp); |
| 3660 | } |
| 3661 | |
| 3662 | /* |
| 3663 | * Track route changes for TX rate limiting. |
no test coverage detected