tests/sys/netinet/tcp_hpts: Make a socket available in mock inpcbs
After commit9b76228006, tcp_hptsi() dereferences inp_socket in order to get the inpcb's VNET. This means that mock inpcbs created by the HPTS test fixture must set inp_socket. Also set the current VNET there; previously, it was NULL, and this was not noticed since VNET_DEBUG is disabled even in debug kernels. Fixes:9b76228006("inpcb: retire inp_vnet")
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
#include <sys/refcount.h>
|
#include <sys/refcount.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
|
||||||
@@ -369,9 +370,15 @@ static struct tcpcb *
|
|||||||
test_hpts_create_tcpcb(struct ktest_test_context *ctx, struct tcp_hptsi *pace)
|
test_hpts_create_tcpcb(struct ktest_test_context *ctx, struct tcp_hptsi *pace)
|
||||||
{
|
{
|
||||||
struct tcpcb *tp;
|
struct tcpcb *tp;
|
||||||
|
struct socket *so;
|
||||||
|
|
||||||
tp = malloc(sizeof(struct tcpcb), M_TCPHPTS, M_WAITOK | M_ZERO);
|
tp = malloc(sizeof(struct tcpcb), M_TCPHPTS, M_WAITOK | M_ZERO);
|
||||||
if (tp) {
|
if (tp) {
|
||||||
|
so = malloc(sizeof(struct socket), M_TCPHPTS,
|
||||||
|
M_WAITOK | M_ZERO);
|
||||||
|
so->so_vnet = curvnet;
|
||||||
|
tp->t_inpcb.inp_socket = so;
|
||||||
|
|
||||||
rw_init_flags(&tp->t_inpcb.inp_lock, "test-inp",
|
rw_init_flags(&tp->t_inpcb.inp_lock, "test-inp",
|
||||||
RW_RECURSE | RW_DUPOK);
|
RW_RECURSE | RW_DUPOK);
|
||||||
refcount_init(&tp->t_inpcb.inp_refcount, 1);
|
refcount_init(&tp->t_inpcb.inp_refcount, 1);
|
||||||
@@ -399,6 +406,7 @@ test_hpts_free_tcpcb(struct tcpcb *tp)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
INP_LOCK_DESTROY(&tp->t_inpcb);
|
INP_LOCK_DESTROY(&tp->t_inpcb);
|
||||||
|
free(tp->t_inpcb.inp_socket, M_TCPHPTS);
|
||||||
free(tp, M_TCPHPTS);
|
free(tp, M_TCPHPTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user