ktls: Write-lock the INP when changing a transmit TLS session.

The TCP rate pacing code relies on being able to read this pointer
safely while holding an INP lock.  The initial TLS session pointer is
set while holding the write lock already.

Reviewed by:	gallatin, hselasky
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D34086
This commit is contained in:
John Baldwin 2022-02-11 15:16:25 -08:00
parent fd8d4e53bc
commit cd0525f615

View File

@ -1454,6 +1454,7 @@ ktls_set_tx_mode(struct socket *so, int mode)
return (EBUSY);
}
INP_WLOCK(inp);
SOCKBUF_LOCK(&so->so_snd);
so->so_snd.sb_tls_info = tls_new;
if (tls_new->mode != TCP_TLS_MODE_SW)
@ -1475,7 +1476,6 @@ ktls_set_tx_mode(struct socket *so, int mode)
else
counter_u64_add(ktls_switch_to_sw, 1);
INP_WLOCK(inp);
return (0);
}