Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_ratelimit.c
Show First 20 Lines • Show All 1,405 Lines • ▼ Show 20 Lines | if (tp->t_inpcb->inp_socket->so_snd.sb_flags & SB_TLS_IFNET) { | ||||
MPASS(tls->mode == TCP_TLS_MODE_IFNET); | MPASS(tls->mode == TCP_TLS_MODE_IFNET); | ||||
if (tls->snd_tag != NULL && | if (tls->snd_tag != NULL && | ||||
tls->snd_tag->sw->type != IF_SND_TAG_TYPE_TLS_RATE_LIMIT) { | tls->snd_tag->sw->type != IF_SND_TAG_TYPE_TLS_RATE_LIMIT) { | ||||
/* | /* | ||||
* NIC probably doesn't support ratelimit TLS | * NIC probably doesn't support ratelimit TLS | ||||
* tags if it didn't allocate one when an | * tags if it didn't allocate one when an | ||||
* existing rate was present, so ignore. | * existing rate was present, so ignore. | ||||
*/ | */ | ||||
tcp_rel_pacing_rate(crte, tp); | |||||
if (error) | if (error) | ||||
*error = EOPNOTSUPP; | *error = EOPNOTSUPP; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
if (tp->t_inpcb->inp_snd_tag == NULL) { | if (tp->t_inpcb->inp_snd_tag == NULL) { | ||||
/* Wrong interface */ | /* Wrong interface */ | ||||
tcp_rel_pacing_rate(crte, tp); | |||||
if (error) | if (error) | ||||
*error = EINVAL; | *error = EINVAL; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
rs = crte->ptbl; | rs = crte->ptbl; | ||||
if ((rs->rs_flags & RS_IS_DEAD) || | if ((rs->rs_flags & RS_IS_DEAD) || | ||||
(crte->flags & HDWRPACE_IFPDEPARTED)) { | (crte->flags & HDWRPACE_IFPDEPARTED)) { | ||||
/* Release the rate, and try anew */ | /* Release the rate, and try anew */ | ||||
Show All 22 Lines | #endif | ||||
/* Change rates to our new entry */ | /* Change rates to our new entry */ | ||||
#ifdef KERN_TLS | #ifdef KERN_TLS | ||||
if (tls != NULL) | if (tls != NULL) | ||||
err = ktls_modify_txrtlmt(tls, nrte->rate); | err = ktls_modify_txrtlmt(tls, nrte->rate); | ||||
else | else | ||||
#endif | #endif | ||||
err = in_pcbmodify_txrtlmt(tp->t_inpcb, nrte->rate); | err = in_pcbmodify_txrtlmt(tp->t_inpcb, nrte->rate); | ||||
if (err) { | if (err) { | ||||
struct tcp_rate_set *lrs; | |||||
uint64_t pre; | |||||
rl_decrement_using(nrte); | rl_decrement_using(nrte); | ||||
lrs = __DECONST(struct tcp_rate_set *, rs); | |||||
pre = atomic_fetchadd_64(&lrs->rs_flows_using, -1); | |||||
/* Do we still have a snd-tag attached? */ | /* Do we still have a snd-tag attached? */ | ||||
if (tp->t_inpcb->inp_snd_tag) | if (tp->t_inpcb->inp_snd_tag) | ||||
in_pcbdetach_txrtlmt(tp->t_inpcb); | in_pcbdetach_txrtlmt(tp->t_inpcb); | ||||
if (pre == 1) { | |||||
struct epoch_tracker et; | |||||
NET_EPOCH_ENTER(et); | |||||
mtx_lock(&rs_mtx); | |||||
/* | |||||
* Is it dead? | |||||
*/ | |||||
if (lrs->rs_flags & RS_IS_DEAD) | |||||
rs_defer_destroy(lrs); | |||||
mtx_unlock(&rs_mtx); | |||||
NET_EPOCH_EXIT(et); | |||||
} | |||||
if (error) | if (error) | ||||
*error = err; | *error = err; | ||||
return (NULL); | return (NULL); | ||||
} else { | } else { | ||||
#ifdef INET | #ifdef INET | ||||
counter_u64_add(rate_limit_chg, 1); | counter_u64_add(rate_limit_chg, 1); | ||||
#endif | #endif | ||||
} | } | ||||
▲ Show 20 Lines • Show All 261 Lines • Show Last 20 Lines |