| 1259 | } |
| 1260 | |
| 1261 | const struct tcp_hwrate_limit_table * |
| 1262 | tcp_chg_pacing_rate(const struct tcp_hwrate_limit_table *crte, |
| 1263 | struct tcpcb *tp, struct ifnet *ifp, |
| 1264 | uint64_t bytes_per_sec, int flags, int *error) |
| 1265 | { |
| 1266 | const struct tcp_hwrate_limit_table *nrte; |
| 1267 | const struct tcp_rate_set *rs; |
| 1268 | #ifdef KERN_TLS |
| 1269 | struct ktls_session *tls = NULL; |
| 1270 | #endif |
| 1271 | int is_indirect = 0; |
| 1272 | int err; |
| 1273 | |
| 1274 | INP_WLOCK_ASSERT(tp->t_inpcb); |
| 1275 | |
| 1276 | if (crte == NULL) { |
| 1277 | /* Wrong interface */ |
| 1278 | if (error) |
| 1279 | *error = EINVAL; |
| 1280 | return (NULL); |
| 1281 | } |
| 1282 | |
| 1283 | #ifdef KERN_TLS |
| 1284 | if (tp->t_inpcb->inp_socket->so_snd.sb_flags & SB_TLS_IFNET) { |
| 1285 | tls = tp->t_inpcb->inp_socket->so_snd.sb_tls_info; |
| 1286 | MPASS(tls->mode == TCP_TLS_MODE_IFNET); |
| 1287 | if (tls->snd_tag != NULL && |
| 1288 | tls->snd_tag->type != IF_SND_TAG_TYPE_TLS_RATE_LIMIT) { |
| 1289 | /* |
| 1290 | * NIC probably doesn't support ratelimit TLS |
| 1291 | * tags if it didn't allocate one when an |
| 1292 | * existing rate was present, so ignore. |
| 1293 | */ |
| 1294 | if (error) |
| 1295 | *error = EOPNOTSUPP; |
| 1296 | return (NULL); |
| 1297 | } |
| 1298 | } |
| 1299 | #endif |
| 1300 | if (tp->t_inpcb->inp_snd_tag == NULL) { |
| 1301 | /* Wrong interface */ |
| 1302 | if (error) |
| 1303 | *error = EINVAL; |
| 1304 | return (NULL); |
| 1305 | } |
| 1306 | rs = crte->ptbl; |
| 1307 | if ((rs->rs_flags & RS_IS_DEAD) || |
| 1308 | (crte->flags & HDWRPACE_IFPDEPARTED)) { |
| 1309 | /* Release the rate, and try anew */ |
| 1310 | re_rate: |
| 1311 | tcp_rel_pacing_rate(crte, tp); |
| 1312 | nrte = tcp_set_pacing_rate(tp, ifp, |
| 1313 | bytes_per_sec, flags, error); |
| 1314 | return (nrte); |
| 1315 | } |
| 1316 | if ((rs->rs_flags & RT_IS_INDIRECT ) == RT_IS_INDIRECT) |
| 1317 | is_indirect = 1; |
| 1318 | else |
no test coverage detected