Re: git: 9b76228006d8 - main - inpcb: retire inp_vnet
Date: Thu, 16 Apr 2026 21:05:41 UTC
On Tue, Apr 14, 2026 at 04:06:03PM +0000, Gleb Smirnoff wrote:
> The branch main has been updated by glebius:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=9b76228006d8f0e45dea03d305eeac587d7a8500
>
> commit 9b76228006d8f0e45dea03d305eeac587d7a8500
> Author: Gleb Smirnoff <glebius@FreeBSD.org>
> AuthorDate: 2026-04-14 16:02:00 +0000
> Commit: Gleb Smirnoff <glebius@FreeBSD.org>
> CommitDate: 2026-04-14 16:02:00 +0000
>
> inpcb: retire inp_vnet
>
> Now that a functional inpcb can not outlive its socket, just use socket's
> vnet pointer.
> ---
> sys/kern/uipc_ktls.c | 4 ++--
> sys/netinet/in_pcb.c | 3 ---
> sys/netinet/in_pcb.h | 8 --------
> sys/netinet/tcp_hpts.c | 2 +-
> sys/netinet/tcp_timer.c | 10 +++++-----
> 5 files changed, 8 insertions(+), 19 deletions(-)
>
> diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c
> index 0112cf8b6941..4c3a4085b8db 100644
> --- a/sys/kern/uipc_ktls.c
> +++ b/sys/kern/uipc_ktls.c
> @@ -1797,7 +1797,7 @@ ktls_reset_send_tag(void *context, int pending)
> INP_WLOCK(inp);
> tp = intotcpcb(inp);
> if (!(tp->t_flags & TF_DISCONNECTED)) {
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> tp = tcp_drop(tp, ECONNABORTED);
> CURVNET_RESTORE();
> if (tp != NULL) {
> @@ -2475,7 +2475,7 @@ ktls_drop(struct socket *so, int error)
> NET_EPOCH_ENTER(et);
> INP_WLOCK(inp);
> if (!(tp->t_flags & TF_DISCONNECTED)) {
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> tp = tcp_drop(tp, error);
> CURVNET_RESTORE();
> if (tp != NULL)
> diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
> index af62aea91bf8..22c3287b93fd 100644
> --- a/sys/netinet/in_pcb.c
> +++ b/sys/netinet/in_pcb.c
> @@ -558,9 +558,6 @@ in_pcbinfo_init(struct inpcbinfo *pcbinfo, struct inpcbstorage *pcbstor,
>
> mtx_init(&pcbinfo->ipi_hash_lock, pcbstor->ips_hashlock_name,
> NULL, MTX_DEF);
> -#ifdef VIMAGE
> - pcbinfo->ipi_vnet = curvnet;
> -#endif
> CK_LIST_INIT(&pcbinfo->ipi_list_unconn);
> pcbinfo->ipi_count = 0;
>
> diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
> index 8663ba205b0a..1a6ce50aedbb 100644
> --- a/sys/netinet/in_pcb.h
> +++ b/sys/netinet/in_pcb.h
> @@ -299,7 +299,6 @@ struct xktls_session {
> #include <net/route.h>
> #include <sys/proc.h>
> #include <sys/sysctl.h>
> -#include <net/vnet.h>
> #include <vm/uma.h>
> #include <sys/ck.h>
>
> @@ -418,8 +417,6 @@ struct inpcb {
> };
> };
>
> -#define inp_vnet inp_pcbinfo->ipi_vnet
> -
> /*
> * Per-VNET pcb database for each high-level protocol (UDP, TCP, ...) in both
> * IPv4 and IPv6.
> @@ -478,11 +475,6 @@ struct inpcbinfo {
> * hashed by local port.
> */
> struct inpcblbgrouphead *ipi_lbgrouphashbase; /* (r:e/w:h) */
> -
> - /*
> - * Pointer to network stack instance
> - */
> - struct vnet *ipi_vnet; /* (c) */
> };
>
> /*
> diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c
> index 8dfbe126d46a..2bb78ed28372 100644
> --- a/sys/netinet/tcp_hpts.c
> +++ b/sys/netinet/tcp_hpts.c
> @@ -1359,7 +1359,7 @@ again:
> */
> __tcp_set_hpts(pace, tp);
> }
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
It's possible to have inp->inp_socket == NULL here. This is triggered
by the sys/netinet/tcp_hpts_test.py tests.
> /* Lets do any logging that we might want to */
> tcp_hpts_log(hpts, tp, &tv, slots_to_run, i, from_callout);
>
> diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
> index b409daf5895e..ca242f2be627 100644
> --- a/sys/netinet/tcp_timer.c
> +++ b/sys/netinet/tcp_timer.c
> @@ -315,7 +315,7 @@ tcp_timer_delack(struct tcpcb *tp)
>
> INP_WLOCK_ASSERT(inp);
>
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> tp->t_flags |= TF_ACKNOW;
> TCPSTAT_INC(tcps_delack);
> NET_EPOCH_ENTER(et);
> @@ -335,7 +335,7 @@ tcp_timer_2msl(struct tcpcb *tp)
> INP_WLOCK_ASSERT(inp);
>
> TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO);
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> tcp_log_end_status(tp, TCP_EI_STATUS_2MSL);
> tcp_free_sackholes(tp);
> /*
> @@ -385,7 +385,7 @@ tcp_timer_keep(struct tcpcb *tp)
> INP_WLOCK_ASSERT(inp);
>
> TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO);
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> /*
> * Because we don't regularly reset the keepalive callout in
> * the ESTABLISHED state, it may be that we don't actually need
> @@ -493,7 +493,7 @@ tcp_timer_persist(struct tcpcb *tp)
> INP_WLOCK_ASSERT(inp);
>
> TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO);
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> /*
> * Persistence timer into zero window.
> * Force a byte to be output, if possible.
> @@ -560,7 +560,7 @@ tcp_timer_rexmt(struct tcpcb *tp)
> INP_WLOCK_ASSERT(inp);
>
> TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO);
> - CURVNET_SET(inp->inp_vnet);
> + CURVNET_SET(inp->inp_socket->so_vnet);
> if (tp->t_fb->tfb_tcp_rexmit_tmr) {
> /* The stack has a timer action too. */
> (*tp->t_fb->tfb_tcp_rexmit_tmr)(tp);
>