git: 9eb0e8326d0f - main - tcp: provide macros to access inpcb and socket from a tcpcb
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 08 Nov 2022 18:24:57 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=9eb0e8326d0fe73ae947959c1df327238d3b2d53
commit 9eb0e8326d0fe73ae947959c1df327238d3b2d53
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-11-08 18:24:40 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-11-08 18:24:40 +0000
tcp: provide macros to access inpcb and socket from a tcpcb
There should be no functional changes with this commit.
Reviewed by: rscheff
Differential revision: https://reviews.freebsd.org/D37123
---
sys/dev/cxgbe/tom/t4_cpl_io.c | 12 +-
sys/dev/cxgbe/tom/t4_listen.c | 4 +-
sys/dev/cxgbe/tom/t4_tom.c | 8 +-
sys/kern/uipc_ktls.c | 2 +-
sys/netinet/cc/cc_cdg.c | 2 +-
sys/netinet/cc/cc_chd.c | 2 +-
sys/netinet/cc/cc_cubic.c | 6 +-
sys/netinet/cc/cc_dctcp.c | 2 +-
sys/netinet/cc/cc_htcp.c | 2 +-
sys/netinet/cc/cc_newreno.c | 6 +-
sys/netinet/cc/cc_vegas.c | 2 +-
sys/netinet/khelp/h_ertt.c | 4 +-
sys/netinet/tcp_fastopen.c | 7 +-
sys/netinet/tcp_hpts.c | 4 +-
sys/netinet/tcp_input.c | 59 +++++----
sys/netinet/tcp_log_buf.c | 69 +++++-----
sys/netinet/tcp_lro.c | 8 +-
sys/netinet/tcp_offload.c | 20 +--
sys/netinet/tcp_output.c | 51 ++++----
sys/netinet/tcp_ratelimit.c | 37 +++---
sys/netinet/tcp_reass.c | 24 ++--
sys/netinet/tcp_sack.c | 20 +--
sys/netinet/tcp_stacks/bbr.c | 151 ++++++++++------------
sys/netinet/tcp_stacks/rack.c | 209 +++++++++++++++----------------
sys/netinet/tcp_stacks/rack_bbr_common.c | 19 +--
sys/netinet/tcp_stats.c | 2 +-
sys/netinet/tcp_subr.c | 34 +++--
sys/netinet/tcp_timer.c | 80 ++++++------
sys/netinet/tcp_timewait.c | 2 +-
sys/netinet/tcp_usrreq.c | 18 +--
sys/netinet/tcp_var.h | 29 +++--
sys/netinet/toecore.c | 4 +-
32 files changed, 429 insertions(+), 470 deletions(-)
diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c
index 79c40658ba54..94b92dbf112b 100644
--- a/sys/dev/cxgbe/tom/t4_cpl_io.c
+++ b/sys/dev/cxgbe/tom/t4_cpl_io.c
@@ -306,7 +306,7 @@ static void
assign_rxopt(struct tcpcb *tp, uint16_t opt)
{
struct toepcb *toep = tp->t_toe;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
struct adapter *sc = td_adapter(toep->td);
INP_LOCK_ASSERT(inp);
@@ -442,7 +442,7 @@ void
t4_rcvd_locked(struct toedev *tod, struct tcpcb *tp)
{
struct adapter *sc = tod->tod_softc;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
struct socket *so = inp->inp_socket;
struct sockbuf *sb = &so->so_rcv;
struct toepcb *toep = tp->t_toe;
@@ -466,7 +466,7 @@ t4_rcvd_locked(struct toedev *tod, struct tcpcb *tp)
void
t4_rcvd(struct toedev *tod, struct tcpcb *tp)
{
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
struct socket *so = inp->inp_socket;
struct sockbuf *sb = &so->so_rcv;
@@ -1276,7 +1276,7 @@ t4_tod_output(struct toedev *tod, struct tcpcb *tp)
{
struct adapter *sc = tod->tod_softc;
#ifdef INVARIANTS
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
#endif
struct toepcb *toep = tp->t_toe;
@@ -1295,7 +1295,7 @@ t4_send_fin(struct toedev *tod, struct tcpcb *tp)
{
struct adapter *sc = tod->tod_softc;
#ifdef INVARIANTS
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
#endif
struct toepcb *toep = tp->t_toe;
@@ -1316,7 +1316,7 @@ t4_send_rst(struct toedev *tod, struct tcpcb *tp)
{
struct adapter *sc = tod->tod_softc;
#if defined(INVARIANTS)
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
#endif
struct toepcb *toep = tp->t_toe;
diff --git a/sys/dev/cxgbe/tom/t4_listen.c b/sys/dev/cxgbe/tom/t4_listen.c
index 4d98597409d6..e764df14b245 100644
--- a/sys/dev/cxgbe/tom/t4_listen.c
+++ b/sys/dev/cxgbe/tom/t4_listen.c
@@ -519,7 +519,7 @@ t4_listen_start(struct toedev *tod, struct tcpcb *tp)
struct adapter *sc = tod->tod_softc;
struct vi_info *vi;
struct port_info *pi;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
struct listen_ctx *lctx;
int i, rc, v;
struct offload_settings settings;
@@ -615,7 +615,7 @@ t4_listen_stop(struct toedev *tod, struct tcpcb *tp)
{
struct listen_ctx *lctx;
struct adapter *sc = tod->tod_softc;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
INP_WLOCK_ASSERT(inp);
diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index a923fbaf1a30..c6af1cd7d42c 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -366,7 +366,7 @@ static void
t4_pcb_detach(struct toedev *tod __unused, struct tcpcb *tp)
{
#if defined(KTR) || defined(INVARIANTS)
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
#endif
struct toepcb *toep = tp->t_toe;
@@ -820,7 +820,7 @@ t4_tcp_info(struct toedev *tod, struct tcpcb *tp, struct tcp_info *ti)
struct adapter *sc = tod->tod_softc;
struct toepcb *toep = tp->t_toe;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
MPASS(ti != NULL);
fill_tcp_info(sc, toep->tid, ti);
@@ -833,7 +833,7 @@ t4_alloc_tls_session(struct toedev *tod, struct tcpcb *tp,
{
struct toepcb *toep = tp->t_toe;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
MPASS(tls != NULL);
return (tls_alloc_ktls(toep, tls, direction));
@@ -918,7 +918,7 @@ t4_pmtu_update(struct toedev *tod, struct tcpcb *tp, tcp_seq seq, int mtu)
struct ulp_txpkt *ulpmc;
int idx, len;
struct wrq_cookie cookie;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
struct toepcb *toep = tp->t_toe;
struct adapter *sc = td_adapter(toep->td);
unsigned short *mtus = &sc->params.mtus[0];
diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c
index 83fcc9e70546..521c416b5234 100644
--- a/sys/kern/uipc_ktls.c
+++ b/sys/kern/uipc_ktls.c
@@ -3225,7 +3225,7 @@ ktls_disable_ifnet(void *arg)
struct ktls_session *tls;
tp = arg;
- inp = tp->t_inpcb;
+ inp = tptoinpcb(tp);
INP_WLOCK_ASSERT(inp);
so = inp->inp_socket;
SOCK_LOCK(so);
diff --git a/sys/netinet/cc/cc_cdg.c b/sys/netinet/cc/cc_cdg.c
index ca73d7b797f5..1bda96d33e65 100644
--- a/sys/netinet/cc/cc_cdg.c
+++ b/sys/netinet/cc/cc_cdg.c
@@ -297,7 +297,7 @@ cdg_cb_init(struct cc_var *ccv, void *ptr)
{
struct cdg *cdg_data;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
cdg_data = malloc(sizeof(struct cdg), M_CC_MEM, M_NOWAIT);
if (cdg_data == NULL)
diff --git a/sys/netinet/cc/cc_chd.c b/sys/netinet/cc/cc_chd.c
index 1d3bab6c8f46..d8bd764a1cba 100644
--- a/sys/netinet/cc/cc_chd.c
+++ b/sys/netinet/cc/cc_chd.c
@@ -324,7 +324,7 @@ chd_cb_init(struct cc_var *ccv, void *ptr)
{
struct chd *chd_data;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
chd_data = malloc(sizeof(struct chd), M_CC_MEM, M_NOWAIT);
if (chd_data == NULL)
diff --git a/sys/netinet/cc/cc_cubic.c b/sys/netinet/cc/cc_cubic.c
index 6e0f176b80c9..cb4c79378132 100644
--- a/sys/netinet/cc/cc_cubic.c
+++ b/sys/netinet/cc/cc_cubic.c
@@ -150,8 +150,8 @@ cubic_log_hystart_event(struct cc_var *ccv, struct cubic *cubicd, uint8_t mod, u
log.u_bbr.delivered = cubicd->css_lowrtt_fas;
log.u_bbr.pkt_epoch = ccv->flags;
TCP_LOG_EVENTP(tp, NULL,
- &tp->t_inpcb->inp_socket->so_rcv,
- &tp->t_inpcb->inp_socket->so_snd,
+ &tptosocket(tp)->so_rcv,
+ &tptosocket(tp)->so_snd,
TCP_HYSTART, 0,
0, &log, false, &tv);
}
@@ -387,7 +387,7 @@ cubic_cb_init(struct cc_var *ccv, void *ptr)
{
struct cubic *cubic_data;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
cubic_data = malloc(sizeof(struct cubic), M_CC_MEM, M_NOWAIT|M_ZERO);
if (cubic_data == NULL)
diff --git a/sys/netinet/cc/cc_dctcp.c b/sys/netinet/cc/cc_dctcp.c
index ce11e611a0e5..9963db7152ee 100644
--- a/sys/netinet/cc/cc_dctcp.c
+++ b/sys/netinet/cc/cc_dctcp.c
@@ -204,7 +204,7 @@ dctcp_cb_init(struct cc_var *ccv, void *ptr)
{
struct dctcp *dctcp_data;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
dctcp_data = malloc(sizeof(struct dctcp), M_CC_MEM, M_NOWAIT|M_ZERO);
if (dctcp_data == NULL)
diff --git a/sys/netinet/cc/cc_htcp.c b/sys/netinet/cc/cc_htcp.c
index 60c8b6f1e195..87d66345bd69 100644
--- a/sys/netinet/cc/cc_htcp.c
+++ b/sys/netinet/cc/cc_htcp.c
@@ -256,7 +256,7 @@ htcp_cb_init(struct cc_var *ccv, void *ptr)
{
struct htcp *htcp_data;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
htcp_data = malloc(sizeof(struct htcp), M_CC_MEM, M_NOWAIT);
if (htcp_data == NULL)
diff --git a/sys/netinet/cc/cc_newreno.c b/sys/netinet/cc/cc_newreno.c
index 43f3d81389f3..7118e6432707 100644
--- a/sys/netinet/cc/cc_newreno.c
+++ b/sys/netinet/cc/cc_newreno.c
@@ -160,8 +160,8 @@ newreno_log_hystart_event(struct cc_var *ccv, struct newreno *nreno, uint8_t mod
log.u_bbr.delivered = nreno->css_lowrtt_fas;
log.u_bbr.pkt_epoch = ccv->flags;
TCP_LOG_EVENTP(tp, NULL,
- &tp->t_inpcb->inp_socket->so_rcv,
- &tp->t_inpcb->inp_socket->so_snd,
+ &tptosocket(tp)->so_rcv,
+ &tptosocket(tp)->so_snd,
TCP_HYSTART, 0,
0, &log, false, &tv);
}
@@ -178,7 +178,7 @@ newreno_cb_init(struct cc_var *ccv, void *ptr)
{
struct newreno *nreno;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
ccv->cc_data = malloc(sizeof(struct newreno), M_CC_MEM, M_NOWAIT);
if (ccv->cc_data == NULL)
diff --git a/sys/netinet/cc/cc_vegas.c b/sys/netinet/cc/cc_vegas.c
index f5841a42c67c..2056537a1df0 100644
--- a/sys/netinet/cc/cc_vegas.c
+++ b/sys/netinet/cc/cc_vegas.c
@@ -187,7 +187,7 @@ vegas_cb_init(struct cc_var *ccv, void *ptr)
{
struct vegas *vegas_data;
- INP_WLOCK_ASSERT(ccv->ccvc.tcp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
if (ptr == NULL) {
vegas_data = malloc(sizeof(struct vegas), M_CC_MEM, M_NOWAIT);
if (vegas_data == NULL)
diff --git a/sys/netinet/khelp/h_ertt.c b/sys/netinet/khelp/h_ertt.c
index 541319285b35..5e35b0909e84 100644
--- a/sys/netinet/khelp/h_ertt.c
+++ b/sys/netinet/khelp/h_ertt.c
@@ -219,7 +219,7 @@ ertt_packet_measurement_hook(int hhook_type, int hhook_id, void *udata,
measurenext = measurenext_len = multiack = rts = rtt_bytes_adjust = 0;
acked = th->th_ack - tp->snd_una;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
/* Packet has provided new acknowledgements. */
if (acked > 0 || new_sacked_bytes) {
@@ -452,7 +452,7 @@ ertt_add_tx_segment_info_hook(int hhook_type, int hhook_id, void *udata,
len = thdp->len;
tso = thdp->tso;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
if (len > 0) {
txsi = uma_zalloc(txseginfo_zone, M_NOWAIT);
diff --git a/sys/netinet/tcp_fastopen.c b/sys/netinet/tcp_fastopen.c
index 9b6334529513..d1339031a00a 100644
--- a/sys/netinet/tcp_fastopen.c
+++ b/sys/netinet/tcp_fastopen.c
@@ -867,7 +867,7 @@ sysctl_net_inet_tcp_fastopen_client_enable(SYSCTL_HANDLER_ARGS)
void
tcp_fastopen_connect(struct tcpcb *tp)
{
- struct inpcb *inp;
+ struct inpcb *inp = tptoinpcb(tp);
struct tcp_fastopen_ccache_bucket *ccb;
struct tcp_fastopen_ccache_entry *cce;
sbintime_t now;
@@ -875,7 +875,6 @@ tcp_fastopen_connect(struct tcpcb *tp)
uint64_t psk_cookie;
psk_cookie = 0;
- inp = tp->t_inpcb;
cce = tcp_fastopen_ccache_lookup(&inp->inp_inc, &ccb);
if (cce) {
if (cce->disable_time == 0) {
@@ -955,7 +954,7 @@ tcp_fastopen_connect(struct tcpcb *tp)
void
tcp_fastopen_disable_path(struct tcpcb *tp)
{
- struct in_conninfo *inc = &tp->t_inpcb->inp_inc;
+ struct in_conninfo *inc = &tptoinpcb(tp)->inp_inc;
struct tcp_fastopen_ccache_bucket *ccb;
struct tcp_fastopen_ccache_entry *cce;
@@ -981,7 +980,7 @@ void
tcp_fastopen_update_cache(struct tcpcb *tp, uint16_t mss,
uint8_t cookie_len, uint8_t *cookie)
{
- struct in_conninfo *inc = &tp->t_inpcb->inp_inc;
+ struct in_conninfo *inc = &tptoinpcb(tp)->inp_inc;
struct tcp_fastopen_ccache_bucket *ccb;
struct tcp_fastopen_ccache_entry *cce;
diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c
index 3ed0c1e27c58..57114706baa3 100644
--- a/sys/netinet/tcp_hpts.c
+++ b/sys/netinet/tcp_hpts.c
@@ -463,8 +463,8 @@ tcp_hpts_log(struct tcp_hpts_entry *hpts, struct tcpcb *tp, struct timeval *tv,
log.u_bbr.pkt_epoch = hpts->p_runningslot;
log.u_bbr.use_lt_bw = 1;
TCP_LOG_EVENTP(tp, NULL,
- &tp->t_inpcb->inp_socket->so_rcv,
- &tp->t_inpcb->inp_socket->so_snd,
+ &tptosocket(tp)->so_rcv,
+ &tptosocket(tp)->so_snd,
BBR_LOG_HPTSDIAG, 0,
0, &log, false, tv);
}
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index ad399b9042e2..301c2837fc0c 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -299,7 +299,7 @@ cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs,
int32_t gput;
#endif
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tp->ccv->nsegs = nsegs;
tp->ccv->bytes_this_ack = BYTES_THIS_ACK(tp, th);
@@ -366,11 +366,11 @@ void
cc_conn_init(struct tcpcb *tp)
{
struct hc_metrics_lite metrics;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
u_int maxseg;
int rtt;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
tcp_hc_get(&inp->inp_inc, &metrics);
maxseg = tcp_maxseg(tp);
@@ -421,7 +421,7 @@ cc_conn_init(struct tcpcb *tp)
void inline
cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
#ifdef STATS
stats_voi_update_abs_u32(tp->t_stats, VOI_TCP_CSIG, type);
@@ -482,7 +482,7 @@ cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type)
void inline
cc_post_recovery(struct tcpcb *tp, struct tcphdr *th)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
/* XXXLAS: KASSERT that we're in recovery? */
@@ -514,7 +514,7 @@ cc_post_recovery(struct tcpcb *tp, struct tcphdr *th)
void inline
cc_ecnpkt_handler_flags(struct tcpcb *tp, uint16_t flags, uint8_t iptos)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
if (CC_ALGO(tp)->ecnpkt_handler != NULL) {
switch (iptos & IPTOS_ECN_MASK) {
@@ -1501,10 +1501,10 @@ static void
tcp_handle_wakeup(struct tcpcb *tp)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
if (tp->t_flags & TF_WAKESOR) {
- struct socket *so = tp->t_inpcb->inp_socket;
+ struct socket *so = tptosocket(tp);
tp->t_flags &= ~TF_WAKESOR;
SOCKBUF_LOCK_ASSERT(&so->so_rcv);
@@ -1522,7 +1522,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
uint32_t tiwin;
uint16_t nsegs;
char *s;
- struct in_conninfo *inc;
+ struct inpcb *inp = tptoinpcb(tp);
+ struct in_conninfo *inc = &inp->inp_inc;
struct mbuf *mfree;
struct tcpopt to;
int tfo_syn;
@@ -1538,13 +1539,12 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
short ostate = 0;
#endif
thflags = tcp_get_flags(th);
- inc = &tp->t_inpcb->inp_inc;
tp->sackhint.last_sack_ack = 0;
sack_changed = 0;
nsegs = max(1, m->m_pkthdr.lro_nsegs);
NET_EPOCH_ASSERT();
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN",
__func__));
KASSERT(tp->t_state != TCPS_TIME_WAIT, ("%s: TCPS_TIME_WAIT",
@@ -1683,7 +1683,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
if (to.to_flags & TOF_MSS)
mss = to.to_mss;
else
- if ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0)
+ if ((inp->inp_vflag & INP_IPV6) != 0)
mss = TCP6_MSS;
else
mss = TCP_MSS;
@@ -2848,7 +2848,7 @@ resume_partialack:
}
process_ACK:
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
/*
* Adjust for the SYN bit in sequence space,
@@ -3043,7 +3043,7 @@ process_ACK:
}
step6:
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
/*
* Update window information.
@@ -3128,7 +3128,7 @@ step6:
tp->rcv_up = tp->rcv_nxt;
}
dodata: /* XXX */
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
/*
* Process the segment text, merging it into the TCP sequencing queue,
@@ -3313,13 +3313,13 @@ dodata: /* XXX */
(void) tcp_output(tp);
check_delack:
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK;
tcp_timer_activate(tp, TT_DELACK, tcp_delacktime);
}
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
return;
dropafterack:
@@ -3353,14 +3353,14 @@ dropafterack:
TCP_PROBE3(debug__input, tp, th, m);
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
m_freem(m);
return;
dropwithreset:
if (tp != NULL) {
tcp_dropwithreset(m, th, tp, tlen, rstreason);
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
} else
tcp_dropwithreset(m, th, NULL, tlen, rstreason);
return;
@@ -3370,13 +3370,13 @@ drop:
* Drop space held by incoming segment and return.
*/
#ifdef TCPDEBUG
- if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
TCP_PROBE3(debug__input, tp, th, m);
if (tp != NULL) {
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
}
m_freem(m);
}
@@ -3398,7 +3398,7 @@ tcp_dropwithreset(struct mbuf *m, struct tcphdr *th, struct tcpcb *tp,
#endif
if (tp != NULL) {
- INP_LOCK_ASSERT(tp->t_inpcb);
+ INP_LOCK_ASSERT(tptoinpcb(tp));
}
/* Don't bother if destination was broadcast/multicast. */
@@ -3570,7 +3570,7 @@ tcp_pulloutofband(struct socket *so, struct tcphdr *th, struct mbuf *m,
char *cp = mtod(m, caddr_t) + cnt;
struct tcpcb *tp = sototcpcb(so);
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tp->t_iobc = *cp;
tp->t_oobflags |= TCPOOB_HAVEDATA;
@@ -3597,7 +3597,7 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt)
{
int delta;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
TCPSTAT_INC(tcps_rttupdated);
tp->t_rttupdated++;
@@ -3700,7 +3700,7 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer,
{
int mss = 0;
uint32_t maxmtu = 0;
- struct inpcb *inp = tp->t_inpcb;
+ struct inpcb *inp = tptoinpcb(tp);
struct hc_metrics_lite metrics;
#ifdef INET6
int isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0;
@@ -3711,7 +3711,7 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer,
size_t min_protoh = sizeof(struct tcpiphdr);
#endif
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
if (tp->t_port)
min_protoh += V_tcp_udp_tunneling_overhead;
@@ -3848,7 +3848,7 @@ tcp_mss(struct tcpcb *tp, int offer)
{
int mss;
uint32_t bufsize;
- struct inpcb *inp;
+ struct inpcb *inp = tptoinpcb(tp);
struct socket *so;
struct hc_metrics_lite metrics;
struct tcp_ifcap cap;
@@ -3859,7 +3859,6 @@ tcp_mss(struct tcpcb *tp, int offer)
tcp_mss_update(tp, offer, -1, &metrics, &cap);
mss = tp->t_maxseg;
- inp = tp->t_inpcb;
/*
* If there's a pipesize, change the socket buffer to that size,
@@ -3965,7 +3964,7 @@ tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to)
int snd_cnt = 0, limit = 0, del_data = 0, pipe = 0;
int maxseg = tcp_maxseg(tp);
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
/*
* Compute the amount of data that this ACK is indicating
@@ -4042,7 +4041,7 @@ tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th)
uint32_t ocwnd = tp->snd_cwnd;
u_int maxseg = tcp_maxseg(tp);
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tcp_timer_activate(tp, TT_REXMT, 0);
tp->t_rtttime = 0;
diff --git a/sys/netinet/tcp_log_buf.c b/sys/netinet/tcp_log_buf.c
index 6baf1bce4623..cefd194d4e85 100644
--- a/sys/netinet/tcp_log_buf.c
+++ b/sys/netinet/tcp_log_buf.c
@@ -499,7 +499,7 @@ static void
tcp_log_grow_tlb(char *tlb_id, struct tcpcb *tp)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
#ifdef STATS
if (V_tcp_perconn_stats_enable == 2 && tp->t_stats == NULL)
@@ -522,20 +522,21 @@ tcp_log_increment_reqcnt(struct tcp_log_id_bucket *tlb)
int
tcp_log_set_tag(struct tcpcb *tp, char *tag)
{
+ struct inpcb *inp = tptoinpcb(tp);
struct tcp_log_id_bucket *tlb;
int tree_locked;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
tree_locked = TREE_UNLOCKED;
tlb = tp->t_lib;
if (tlb == NULL) {
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
return (EOPNOTSUPP);
}
TCPID_BUCKET_REF(tlb);
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
TCPID_BUCKET_LOCK(tlb);
strlcpy(tlb->tlb_tag, tag, TCP_LOG_TAG_LEN);
if (!tcp_log_unref_bucket(tlb, &tree_locked, NULL))
@@ -562,13 +563,12 @@ tcp_log_set_id(struct tcpcb *tp, char *id)
{
struct tcp_log_id_bucket *tlb, *tmp_tlb;
struct tcp_log_id_node *tln;
- struct inpcb *inp;
+ struct inpcb *inp = tptoinpcb(tp);
int tree_locked, rv;
bool bucket_locked;
tlb = NULL;
tln = NULL;
- inp = tp->t_inpcb;
tree_locked = TREE_UNLOCKED;
bucket_locked = false;
@@ -922,7 +922,7 @@ tcp_log_get_id(struct tcpcb *tp, char *buf)
{
size_t len;
- INP_LOCK_ASSERT(tp->t_inpcb);
+ INP_LOCK_ASSERT(tptoinpcb(tp));
if (tp->t_lib != NULL) {
len = strlcpy(buf, tp->t_lib->tlb_id, TCP_LOG_ID_LEN);
KASSERT(len < TCP_LOG_ID_LEN,
@@ -944,18 +944,19 @@ tcp_log_get_id(struct tcpcb *tp, char *buf)
size_t
tcp_log_get_tag(struct tcpcb *tp, char *buf)
{
+ struct inpcb *inp = tptoinpcb(tp);
struct tcp_log_id_bucket *tlb;
size_t len;
int tree_locked;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
tree_locked = TREE_UNLOCKED;
tlb = tp->t_lib;
if (tlb != NULL) {
TCPID_BUCKET_REF(tlb);
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
TCPID_BUCKET_LOCK(tlb);
len = strlcpy(buf, tlb->tlb_tag, TCP_LOG_TAG_LEN);
KASSERT(len < TCP_LOG_TAG_LEN,
@@ -973,7 +974,7 @@ tcp_log_get_tag(struct tcpcb *tp, char *buf)
} else
TCPID_TREE_UNLOCK_ASSERT();
} else {
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
*buf = '\0';
len = 0;
}
@@ -990,7 +991,7 @@ u_int
tcp_log_get_id_cnt(struct tcpcb *tp)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
return ((tp->t_lib == NULL) ? 0 : tp->t_lib->tlb_refcnt);
}
@@ -1298,11 +1299,12 @@ tcp_log_expire(void *unused __unused)
static void
tcp_log_move_tp_to_node(struct tcpcb *tp, struct tcp_log_id_node *tln)
{
+ struct inpcb *inp = tptoinpcb(tp);
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
- tln->tln_ie = tp->t_inpcb->inp_inc.inc_ie;
- if (tp->t_inpcb->inp_inc.inc_flags & INC_ISIPV6)
+ tln->tln_ie = inp->inp_inc.inc_ie;
+ if (inp->inp_inc.inc_flags & INC_ISIPV6)
tln->tln_af = AF_INET6;
else
tln->tln_af = AF_INET;
@@ -1323,7 +1325,7 @@ tcp_log_tcpcbfini(struct tcpcb *tp)
struct tcp_log_mem *log_entry;
sbintime_t callouttime;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
TCP_LOG_EVENT(tp, NULL, NULL, NULL, TCP_LOG_CONNEND, 0, 0, NULL, false);
@@ -1383,11 +1385,13 @@ tcp_log_tcpcbfini(struct tcpcb *tp)
*/
if (tp->t_lin != NULL) {
+ struct inpcb *inp = tptoinpcb(tp);
+
/* Copy the relevant information to the log entry. */
tln = tp->t_lin;
- KASSERT(tln->tln_inp == tp->t_inpcb,
- ("%s: Mismatched inp (tln->tln_inp=%p, tp->t_inpcb=%p)",
- __func__, tln->tln_inp, tp->t_inpcb));
+ KASSERT(tln->tln_inp == inp,
+ ("%s: Mismatched inp (tln->tln_inp=%p, tp inpcb=%p)",
+ __func__, tln->tln_inp, inp));
tcp_log_move_tp_to_node(tp, tln);
/* Clear information from the PCB. */
@@ -1401,7 +1405,7 @@ tcp_log_tcpcbfini(struct tcpcb *tp)
* racing to lock this node when we move it to the expire
* queue.
*/
- in_pcbref(tp->t_inpcb);
+ in_pcbref(inp);
/*
* Store the entry on the expiry list. The exact behavior
@@ -1496,10 +1500,8 @@ static void
tcp_log_purge_tp_logbuf(struct tcpcb *tp)
{
struct tcp_log_mem *log_entry;
- struct inpcb *inp __diagused;
- inp = tp->t_inpcb;
- INP_WLOCK_ASSERT(inp);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
if (tp->t_lognum == 0)
return;
@@ -1533,7 +1535,7 @@ tcp_log_event_(struct tcpcb *tp, struct tcphdr *th, struct sockbuf *rxbuf,
("%s called with inconsistent func (%p) and line (%d) arguments",
__func__, func, line));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
if (tcp_disable_all_bb_logs) {
/*
* The global shutdown logging
@@ -1748,7 +1750,7 @@ tcp_log_state_change(struct tcpcb *tp, int state)
{
struct tcp_log_mem *log_entry;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
switch(state) {
case TCP_LOG_STATE_CLEAR:
while ((log_entry = STAILQ_FIRST(&tp->t_logs)) != NULL)
@@ -1786,7 +1788,7 @@ tcp_log_drain(struct tcpcb *tp)
struct tcp_log_mem *log_entry, *next;
int target, skip;
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
if ((target = tp->t_lognum / 2) == 0)
return;
@@ -1930,12 +1932,11 @@ tcp_log_getlogbuf(struct sockopt *sopt, struct tcpcb *tp)
struct tcp_log_stailq log_tailq;
struct tcp_log_mem *log_entry, *log_next;
struct tcp_log_buffer *out_entry;
- struct inpcb *inp;
+ struct inpcb *inp = tptoinpcb(tp);
size_t outsize, entrysize;
int error, outnum;
- INP_WLOCK_ASSERT(tp->t_inpcb);
- inp = tp->t_inpcb;
+ INP_WLOCK_ASSERT(inp);
/*
* Determine which log entries will fit in the buffer. As an
@@ -2153,12 +2154,11 @@ int
tcp_log_dump_tp_logbuf(struct tcpcb *tp, char *reason, int how, bool force)
{
struct tcp_log_dev_log_queue *entry;
- struct inpcb *inp;
+ struct inpcb *inp = tptoinpcb(tp);
#ifdef TCPLOG_DEBUG_COUNTERS
int num_entries;
#endif
- inp = tp->t_inpcb;
INP_WLOCK_ASSERT(inp);
/* If there are no log entries, there is nothing to do. */
@@ -2586,11 +2586,12 @@ done:
void
tcp_log_dump_tp_bucket_logbufs(struct tcpcb *tp, char *reason)
{
+ struct inpcb *inp = tptoinpcb(tp);
struct tcp_log_id_bucket *tlb;
int tree_locked;
/* Figure out our bucket and lock it. */
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(inp);
tlb = tp->t_lib;
if (tlb == NULL) {
/*
@@ -2598,11 +2599,11 @@ tcp_log_dump_tp_bucket_logbufs(struct tcpcb *tp, char *reason)
* session's traces.
*/
(void)tcp_log_dump_tp_logbuf(tp, reason, M_WAITOK, true);
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
return;
}
TCPID_BUCKET_REF(tlb);
- INP_WUNLOCK(tp->t_inpcb);
+ INP_WUNLOCK(inp);
TCPID_BUCKET_LOCK(tlb);
/* If we are the last reference, we have nothing more to do here. */
@@ -2632,7 +2633,7 @@ void
tcp_log_flowend(struct tcpcb *tp)
{
if (tp->t_logstate != TCP_LOG_STATE_OFF) {
- struct socket *so = tp->t_inpcb->inp_socket;
+ struct socket *so = tptosocket(tp);
TCP_LOG_EVENT(tp, NULL, &so->so_rcv, &so->so_snd,
TCP_LOG_FLOWEND, 0, 0, NULL, false);
}
diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c
index b0b9a812b3df..268be18edb37 100644
--- a/sys/netinet/tcp_lro.c
+++ b/sys/netinet/tcp_lro.c
@@ -718,11 +718,9 @@ tcp_lro_log(struct tcpcb *tp, const struct lro_ctrl *lc,
log.u_bbr.inhpts = 1;
else
log.u_bbr.inhpts = 0;
- TCP_LOG_EVENTP(tp, NULL,
- &tp->t_inpcb->inp_socket->so_rcv,
- &tp->t_inpcb->inp_socket->so_snd,
- TCP_LOG_LRO, 0,
- 0, &log, false, &tv);
+ TCP_LOG_EVENTP(tp, NULL, &tptosocket(tp)->so_rcv,
+ &tptosocket(tp)->so_snd,
+ TCP_LOG_LRO, 0, 0, &log, false, &tv);
}
}
#endif
diff --git a/sys/netinet/tcp_offload.c b/sys/netinet/tcp_offload.c
index 84a4bc3c31a3..b93d6027a01e 100644
--- a/sys/netinet/tcp_offload.c
+++ b/sys/netinet/tcp_offload.c
@@ -114,7 +114,7 @@ void
tcp_offload_listen_start(struct tcpcb *tp)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
EVENTHANDLER_INVOKE(tcp_offload_listen_start, tp);
}
@@ -123,7 +123,7 @@ void
tcp_offload_listen_stop(struct tcpcb *tp)
{
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
EVENTHANDLER_INVOKE(tcp_offload_listen_stop, tp);
}
@@ -134,7 +134,7 @@ tcp_offload_input(struct tcpcb *tp, struct mbuf *m)
struct toedev *tod = tp->tod;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tod->tod_input(tod, tp, m);
}
@@ -146,7 +146,7 @@ tcp_offload_output(struct tcpcb *tp)
int error, flags;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
flags = tcp_outflags[tp->t_state];
@@ -170,7 +170,7 @@ tcp_offload_rcvd(struct tcpcb *tp)
struct toedev *tod = tp->tod;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tod->tod_rcvd(tod, tp);
}
@@ -181,7 +181,7 @@ tcp_offload_ctloutput(struct tcpcb *tp, int sopt_dir, int sopt_name)
struct toedev *tod = tp->tod;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tod->tod_ctloutput(tod, tp, sopt_dir, sopt_name);
}
@@ -192,7 +192,7 @@ tcp_offload_tcp_info(struct tcpcb *tp, struct tcp_info *ti)
struct toedev *tod = tp->tod;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
tod->tod_tcp_info(tod, tp, ti);
}
@@ -204,7 +204,7 @@ tcp_offload_alloc_tls_session(struct tcpcb *tp, struct ktls_session *tls,
struct toedev *tod = tp->tod;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
- INP_WLOCK_ASSERT(tp->t_inpcb);
+ INP_WLOCK_ASSERT(tptoinpcb(tp));
return (tod->tod_alloc_tls_session(tod, tp, tls, direction));
}
@@ -215,7 +215,7 @@ tcp_offload_detach(struct tcpcb *tp)
struct toedev *tod = tp->tod;
KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
*** 2554 LINES SKIPPED ***