| 3562 | } |
| 3563 | |
| 3564 | int |
| 3565 | in_pcboutput_txrtlmt_locked(struct inpcb *inp, struct ifnet *ifp, struct mbuf *mb, uint32_t max_pacing_rate) |
| 3566 | { |
| 3567 | int error; |
| 3568 | |
| 3569 | /* |
| 3570 | * If the existing send tag is for the wrong interface due to |
| 3571 | * a route change, first drop the existing tag. Set the |
| 3572 | * CHANGED flag so that we will keep trying to allocate a new |
| 3573 | * tag if we fail to allocate one this time. |
| 3574 | */ |
| 3575 | if (inp->inp_snd_tag != NULL && inp->inp_snd_tag->ifp != ifp) { |
| 3576 | in_pcbdetach_txrtlmt(inp); |
| 3577 | inp->inp_flags2 |= INP_RATE_LIMIT_CHANGED; |
| 3578 | } |
| 3579 | |
| 3580 | /* |
| 3581 | * NOTE: When attaching to a network interface a reference is |
| 3582 | * made to ensure the network interface doesn't go away until |
| 3583 | * all ratelimit connections are gone. The network interface |
| 3584 | * pointers compared below represent valid network interfaces, |
| 3585 | * except when comparing towards NULL. |
| 3586 | */ |
| 3587 | if (max_pacing_rate == 0 && inp->inp_snd_tag == NULL) { |
| 3588 | error = 0; |
| 3589 | } else if (!(ifp->if_capenable & IFCAP_TXRTLMT)) { |
| 3590 | if (inp->inp_snd_tag != NULL) |
| 3591 | in_pcbdetach_txrtlmt(inp); |
| 3592 | error = 0; |
| 3593 | } else if (inp->inp_snd_tag == NULL) { |
| 3594 | /* |
| 3595 | * In order to utilize packet pacing with RSS, we need |
| 3596 | * to wait until there is a valid RSS hash before we |
| 3597 | * can proceed: |
| 3598 | */ |
| 3599 | if (M_HASHTYPE_GET(mb) == M_HASHTYPE_NONE) { |
| 3600 | error = EAGAIN; |
| 3601 | } else { |
| 3602 | error = in_pcbattach_txrtlmt(inp, ifp, M_HASHTYPE_GET(mb), |
| 3603 | mb->m_pkthdr.flowid, max_pacing_rate, &inp->inp_snd_tag); |
| 3604 | } |
| 3605 | } else { |
| 3606 | error = in_pcbmodify_txrtlmt(inp, max_pacing_rate); |
| 3607 | } |
| 3608 | if (error == 0 || error == EOPNOTSUPP) |
| 3609 | inp->inp_flags2 &= ~INP_RATE_LIMIT_CHANGED; |
| 3610 | |
| 3611 | return (error); |
| 3612 | } |
| 3613 | |
| 3614 | /* |
| 3615 | * This function should be called when the INP_RATE_LIMIT_CHANGED flag |
no test coverage detected