diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -2301,6 +2301,27 @@ return (mst->sw->snd_tag_modify(mst, ¶ms)); } +static void +ktls_drop(struct socket *so, int error) +{ + struct epoch_tracker et; + struct inpcb *inp = sotoinpcb(so); + struct tcpcb *tp; + + NET_EPOCH_ENTER(et); + INP_WLOCK(inp); + if (!(inp->inp_flags & INP_DROPPED)) { + tp = intotcpcb(inp); + CURVNET_SET(inp->inp_vnet); + tp = tcp_drop(tp, error); + CURVNET_RESTORE(); + if (tp != NULL) + INP_WUNLOCK(inp); + } else + INP_WUNLOCK(inp); + NET_EPOCH_EXIT(et); +} + static void ktls_decrypt(struct socket *so) { @@ -2358,10 +2379,7 @@ SOCKBUF_UNLOCK(sb); counter_u64_add(ktls_offload_corrupted_records, 1); - CURVNET_SET(so->so_vnet); - so->so_proto->pr_abort(so); - so->so_error = error; - CURVNET_RESTORE(); + ktls_drop(so, error); goto deref; } @@ -2887,8 +2905,7 @@ if (error == 0) { (void)so->so_proto->pr_ready(so, top, npages); } else { - so->so_proto->pr_abort(so); - so->so_error = EIO; + ktls_drop(so, EIO); mb_free_notready(top, total_pages); } @@ -2931,8 +2948,7 @@ if (error == 0) { (void)so->so_proto->pr_ready(so, m, npages); } else { - so->so_proto->pr_abort(so); - so->so_error = EIO; + ktls_drop(so, EIO); mb_free_notready(m, npages); } @@ -2996,8 +3012,7 @@ CURVNET_SET(so->so_vnet); if (error != 0) { - so->so_proto->pr_abort(so); - so->so_error = EIO; + ktls_drop(so, EIO); mb_free_notready(m, total_pages - npages); }