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

Function tcp_set_pacing_rate

freebsd/netinet/tcp_ratelimit.c:1202–1259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1200}
1201
1202const struct tcp_hwrate_limit_table *
1203tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *ifp,
1204 uint64_t bytes_per_sec, int flags, int *error)
1205{
1206 const struct tcp_hwrate_limit_table *rte;
1207#ifdef KERN_TLS
1208 struct ktls_session *tls;
1209#endif
1210
1211 INP_WLOCK_ASSERT(tp->t_inpcb);
1212
1213 if (tp->t_inpcb->inp_snd_tag == NULL) {
1214 /*
1215 * We are setting up a rate for the first time.
1216 */
1217 if ((ifp->if_capenable & IFCAP_TXRTLMT) == 0) {
1218 /* Not supported by the egress */
1219 if (error)
1220 *error = ENODEV;
1221 return (NULL);
1222 }
1223#ifdef KERN_TLS
1224 tls = NULL;
1225 if (tp->t_inpcb->inp_socket->so_snd.sb_flags & SB_TLS_IFNET) {
1226 tls = tp->t_inpcb->inp_socket->so_snd.sb_tls_info;
1227
1228 if ((ifp->if_capenable & IFCAP_TXTLS_RTLMT) == 0 ||
1229 tls->mode != TCP_TLS_MODE_IFNET) {
1230 if (error)
1231 *error = ENODEV;
1232 return (NULL);
1233 }
1234 }
1235#endif
1236 rte = rt_setup_rate(tp->t_inpcb, ifp, bytes_per_sec, flags, error);
1237#ifdef KERN_TLS
1238 if (rte != NULL && tls != NULL && tls->snd_tag != NULL) {
1239 /*
1240 * Fake a route change error to reset the TLS
1241 * send tag. This will convert the existing
1242 * tag to a TLS ratelimit tag.
1243 */
1244 MPASS(tls->snd_tag->type == IF_SND_TAG_TYPE_TLS);
1245 ktls_output_eagain(tp->t_inpcb, tls);
1246 }
1247#endif
1248 } else {
1249 /*
1250 * We are modifying a rate, wrong interface?
1251 */
1252 if (error)
1253 *error = EINVAL;
1254 rte = NULL;
1255 }
1256 tp->t_pacing_rate = rte->rate;
1257 *error = 0;
1258 return (rte);
1259}

Callers 3

tcp_chg_pacing_rateFunction · 0.70
rack_get_pacing_delayFunction · 0.50
bbr.cFile · 0.50

Calls 2

rt_setup_rateFunction · 0.85
ktls_output_eagainFunction · 0.85

Tested by

no test coverage detected