From nobody Fri Apr 7 19:21:38 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PtSsb0Q8Jz443th; Fri, 7 Apr 2023 19:21:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PtSsZ4zgfz3jyy; Fri, 7 Apr 2023 19:21:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680895298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8U8rrvz5dwjn7KRr5ByqCEgg9Fp6GgX4EI4BJDqy0Oc=; b=pvf5ELCsGSmP/VSXQRV2lefkPBFEuErWbLKnnObsW1BYMoFLiX5o3umMsxpcI9dMXKFTEh 9xc4i1/V1VSA6m2I+0Qz8BMuzr3pCq27Ht2A+jOxP/CIijpSDBFurL45KhcGSWZiOgltq7 PiPMFfU0Unj5X6CZSFiE3TFlNckwI7JLVK/k9Rec/MM4KTRVEfh/aaD4IhmCTF91w+Vc/E +ZBpv63OrBWJGHK/BTJlA/jWSEbx+ZoB4g1TU3t40TpKNNiXqOtnH96vRrx9gjEE6uvREU qIU0WJJwrwwVTW09F4tcUIldGxj3oZ/PBoYbocUpfiSWOZkaxo0iyv2p2lALjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680895298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8U8rrvz5dwjn7KRr5ByqCEgg9Fp6GgX4EI4BJDqy0Oc=; b=bzptD4paFFlrsxn5leUVT2vKv0Ym9MFfMq06LP0BM1mQWfs+g+M936oJUOZXqrTLjXlonN 3yGsE+eX5ewrXqsexIr5mx5VvP8MJ2224ClOnEf4IEczi63iOZ7WKXnjkZC/QbVGnHoWUR Aqb1hg0D6Tfs3bPTnFz/JXAQYrupmLp3sl/mFthoEoB/4F2kIzzPk6dPa22tsOUAfuJmnn P6dqEQyHkb458CMJs9yqw5liCBbf8chOOK/mlBfOdGTx6YOZy7SXB3+Lj9LowiUxzqVIpu iQUiPBd943DCJy+PlQPz7ZTe9NR4G4qgsfTJptNPUjq4xoJoSUH1YfDXmrFlbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680895298; a=rsa-sha256; cv=none; b=MzYz+t1ui6crz6Lg6Uccse+TGAkIOxabdZLthdtsBXw6g7n7uPpP0LzNyfGzMCydjWoeko SSBIHArZ6SDwElcw2p2bY0JAUGvLIDiGNnj0VAdJ5WJxvrh1KPSY0hJjlj+52O9vZ1Wpj4 bPF/QfWu3/LcPgSNEs56d/C4bAca++Giu/vc12pLaQ+OnMOidtUPFfjhS6jeXI3HMZh2/Q qp2h0dAUrfB1gZJBaqKHxheEsBTrn1C3cwUPuGe5EO14LcFxUjy7PxC3jPu7tp2H+TvEJN LL7X/DSWvVmIF5zFGNm3PXGtb9QV9mt/Sr1ErTMV1bKRGiSpdMjn5sFQjTTY9Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PtSsZ1wt1zxVh; Fri, 7 Apr 2023 19:21:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 337JLckL007596; Fri, 7 Apr 2023 19:21:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 337JLcKh007595; Fri, 7 Apr 2023 19:21:38 GMT (envelope-from git) Date: Fri, 7 Apr 2023 19:21:38 GMT Message-Id: <202304071921.337JLcKh007595@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 35bc0bcc5192 - main - tcp: reduce argument list to functions that pass a segment List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35bc0bcc5192c68412de9fbf76201d602dd219ca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=35bc0bcc5192c68412de9fbf76201d602dd219ca commit 35bc0bcc5192c68412de9fbf76201d602dd219ca Author: Gleb Smirnoff AuthorDate: 2023-04-07 19:18:05 +0000 Commit: Gleb Smirnoff CommitDate: 2023-04-07 19:18:06 +0000 tcp: reduce argument list to functions that pass a segment The socket argument is superfluous, as a tcpcb always has one and only one socket. Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D39434 --- sys/netinet/tcp_hpts.c | 2 +- sys/netinet/tcp_input.c | 11 ++++++----- sys/netinet/tcp_lro.c | 2 +- sys/netinet/tcp_stacks/bbr.c | 19 ++++++++++--------- sys/netinet/tcp_stacks/rack.c | 26 +++++++++++++------------- sys/netinet/tcp_stacks/rack_bbr_common.c | 12 ++++++------ sys/netinet/tcp_stacks/rack_bbr_common.h | 6 +----- sys/netinet/tcp_var.h | 17 +++++++---------- 8 files changed, 45 insertions(+), 50 deletions(-) diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c index 2dbd90784b56..644811b44a19 100644 --- a/sys/netinet/tcp_hpts.c +++ b/sys/netinet/tcp_hpts.c @@ -1332,7 +1332,7 @@ again: did_prefetch = 1; } if ((inp->inp_flags2 & INP_SUPPORTS_MBUFQ) && tp->t_in_pkt) { - error = (*tp->t_fb->tfb_do_queued_segments)(inp->inp_socket, tp, 0); + error = (*tp->t_fb->tfb_do_queued_segments)(tp, 0); if (error) { /* The input killed the connection */ goto skip_pacing; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 6cf14f2f1f7f..55d3e41a07c1 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1142,8 +1142,8 @@ tfo_socket_result: * the mbuf chain and unlocks the inpcb. */ TCP_PROBE5(receive, NULL, tp, m, tp, th); - tp->t_fb->tfb_tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, - iptos); + tp->t_fb->tfb_tcp_do_segment(tp, m, th, drop_hdrlen, + tlen, iptos); return (IPPROTO_DONE); } /* @@ -1379,7 +1379,7 @@ tfo_socket_result: if ((lookupflag & INPLOOKUP_RLOCKPCB) && INP_TRY_UPGRADE(inp) == 0) goto dropunlock; - tp->t_fb->tfb_tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, iptos); + tp->t_fb->tfb_tcp_do_segment(tp, m, th, drop_hdrlen, tlen, iptos); return (IPPROTO_DONE); dropwithreset: @@ -1493,8 +1493,8 @@ tcp_handle_wakeup(struct tcpcb *tp) } void -tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, - struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos) +tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, + int drop_hdrlen, int tlen, uint8_t iptos) { uint16_t thflags; int acked, ourfinisacked, needoutput = 0, sack_changed; @@ -1503,6 +1503,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, uint16_t nsegs; char *s; struct inpcb *inp = tptoinpcb(tp); + struct socket *so = tptosocket(tp); struct in_conninfo *inc = &inp->inp_inc; struct mbuf *mfree; struct tcpopt to; diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index 908f9cdd7ea4..c35fb0ef1035 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -1443,7 +1443,7 @@ tcp_lro_flush_tcphpts(struct lro_ctrl *lc, struct lro_entry *le) if (should_wake) { /* Wakeup */ counter_u64_add(tcp_inp_lro_wokeup_queue, 1); - if ((*tp->t_fb->tfb_do_queued_segments)(inp->inp_socket, tp, 0)) + if ((*tp->t_fb->tfb_do_queued_segments)(tp, 0)) inp = NULL; } if (inp != NULL) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index cf9f71d7851b..d95f0502755c 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -11261,11 +11261,12 @@ bbr_check_bbr_for_state(struct tcp_bbr *bbr, uint32_t cts, int32_t line, uint32_ } static int -bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, - struct tcpcb *tp, int32_t drop_hdrlen, int32_t tlen, uint8_t iptos, - int32_t nxt_pkt, struct timeval *tv) +bbr_do_segment_nounlock(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, + int32_t drop_hdrlen, int32_t tlen, uint8_t iptos, int32_t nxt_pkt, + struct timeval *tv) { struct inpcb *inp = tptoinpcb(tp); + struct socket *so = tptosocket(tp); int32_t thflags, retval; uint32_t cts, lcts; uint32_t tiwin; @@ -11428,7 +11429,7 @@ bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, if ((tp->t_flags & TF_SACK_PERMIT) == 0) { /* Bail */ tcp_switch_back_to_default(tp); - (*tp->t_fb->tfb_tcp_do_segment) (m, th, so, tp, drop_hdrlen, + (*tp->t_fb->tfb_tcp_do_segment)(tp, m, th, drop_hdrlen, tlen, iptos); return (1); } @@ -11590,15 +11591,15 @@ done_with_input: } static void -bbr_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, - struct tcpcb *tp, int32_t drop_hdrlen, int32_t tlen, uint8_t iptos) +bbr_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, + int32_t drop_hdrlen, int32_t tlen, uint8_t iptos) { struct timeval tv; int retval; /* First lets see if we have old packets */ if (tp->t_in_pkt) { - if (ctf_do_queued_segments(so, tp, 1)) { + if (ctf_do_queued_segments(tp, 1)) { m_freem(m); return; } @@ -11609,8 +11610,8 @@ bbr_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, /* Should not be should we kassert instead? */ tcp_get_usecs(&tv); } - retval = bbr_do_segment_nounlock(m, th, so, tp, - drop_hdrlen, tlen, iptos, 0, &tv); + retval = bbr_do_segment_nounlock(tp, m, th, drop_hdrlen, tlen, iptos, + 0, &tv); if (retval == 0) { INP_WUNLOCK(tptoinpcb(tp)); } diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 63d8c27e4c6d..48a422c1eb8a 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -453,9 +453,8 @@ static int32_t rack_ctor(void *mem, int32_t size, void *arg, int32_t how); static void rack_set_pace_segments(struct tcpcb *tp, struct tcp_rack *rack, uint32_t line, uint64_t *fill_override); static void -rack_do_segment(struct mbuf *m, struct tcphdr *th, - struct socket *so, struct tcpcb *tp, int32_t drop_hdrlen, int32_t tlen, - uint8_t iptos); +rack_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, + int32_t drop_hdrlen, int32_t tlen, uint8_t iptos); static void rack_dtor(void *mem, int32_t size, void *arg); static void rack_log_alt_to_to_cancel(struct tcp_rack *rack, @@ -16436,11 +16435,12 @@ rack_do_compressed_ack_processing(struct tcpcb *tp, struct socket *so, struct mb static int -rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, - struct tcpcb *tp, int32_t drop_hdrlen, int32_t tlen, uint8_t iptos, - int32_t nxt_pkt, struct timeval *tv) +rack_do_segment_nounlock(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, + int32_t drop_hdrlen, int32_t tlen, uint8_t iptos, int32_t nxt_pkt, + struct timeval *tv) { struct inpcb *inp = tptoinpcb(tp); + struct socket *so = tptosocket(tp); #ifdef TCP_ACCOUNTING uint64_t ts_val; #endif @@ -16823,7 +16823,7 @@ rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, if ((rack_sack_not_required == 0) && ((tp->t_flags & TF_SACK_PERMIT) == 0)) { tcp_switch_back_to_default(tp); - (*tp->t_fb->tfb_tcp_do_segment) (m, th, so, tp, drop_hdrlen, + (*tp->t_fb->tfb_tcp_do_segment)(tp, m, th, drop_hdrlen, tlen, iptos); #ifdef TCP_ACCOUNTING sched_unpin(); @@ -17006,15 +17006,15 @@ do_output_now: return (retval); } -void -rack_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, - struct tcpcb *tp, int32_t drop_hdrlen, int32_t tlen, uint8_t iptos) +static void +rack_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, + int32_t drop_hdrlen, int32_t tlen, uint8_t iptos) { struct timeval tv; /* First lets see if we have old packets */ if (tp->t_in_pkt) { - if (ctf_do_queued_segments(so, tp, 1)) { + if (ctf_do_queued_segments(tp, 1)) { m_freem(m); return; } @@ -17025,8 +17025,8 @@ rack_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, /* Should not be should we kassert instead? */ tcp_get_usecs(&tv); } - if (rack_do_segment_nounlock(m, th, so, tp, - drop_hdrlen, tlen, iptos, 0, &tv) == 0) { + if (rack_do_segment_nounlock(tp, m, th, drop_hdrlen, tlen, iptos, 0, + &tv) == 0) { INP_WUNLOCK(tptoinpcb(tp)); } } diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.c b/sys/netinet/tcp_stacks/rack_bbr_common.c index 1bc0823eef2a..7f5f8817466a 100644 --- a/sys/netinet/tcp_stacks/rack_bbr_common.c +++ b/sys/netinet/tcp_stacks/rack_bbr_common.c @@ -323,8 +323,8 @@ ctf_get_enet_type(struct ifnet *ifp, struct mbuf *m) * c) The push bit has been set by the peer */ -int -ctf_process_inbound_raw(struct tcpcb *tp, struct socket *so, struct mbuf *m, int has_pkt) +static int +ctf_process_inbound_raw(struct tcpcb *tp, struct mbuf *m, int has_pkt) { /* * We are passed a raw change of mbuf packets @@ -461,8 +461,8 @@ skip_vnet: KMOD_TCPSTAT_INC(tcps_rcvtotal); else KMOD_TCPSTAT_ADD(tcps_rcvtotal, (m->m_len / sizeof(struct tcp_ackent))); - retval = (*tp->t_fb->tfb_do_segment_nounlock)(m, th, so, tp, drop_hdrlen, tlen, - iptos, nxt_pkt, &tv); + retval = (*tp->t_fb->tfb_do_segment_nounlock)(tp, m, th, + drop_hdrlen, tlen, iptos, nxt_pkt, &tv); if (retval) { /* We lost the lock and tcb probably */ m = m_save; @@ -488,7 +488,7 @@ skipped_pkt: } int -ctf_do_queued_segments(struct socket *so, struct tcpcb *tp, int have_pkt) +ctf_do_queued_segments(struct tcpcb *tp, int have_pkt) { struct mbuf *m; @@ -497,7 +497,7 @@ ctf_do_queued_segments(struct socket *so, struct tcpcb *tp, int have_pkt) m = tp->t_in_pkt; tp->t_in_pkt = NULL; tp->t_tail_pkt = NULL; - if (ctf_process_inbound_raw(tp, so, m, have_pkt)) { + if (ctf_process_inbound_raw(tp, m, have_pkt)) { /* We lost the tcpcb (maybe a RST came in)? */ return(1); } diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.h b/sys/netinet/tcp_stacks/rack_bbr_common.h index e9c38c01c3c8..9ac4a5625a13 100644 --- a/sys/netinet/tcp_stacks/rack_bbr_common.h +++ b/sys/netinet/tcp_stacks/rack_bbr_common.h @@ -87,11 +87,7 @@ #ifdef _KERNEL /* We have only 7 bits in rack so assert its true */ CTASSERT((PACE_TMR_MASK & 0x80) == 0); -int -ctf_process_inbound_raw(struct tcpcb *tp, struct socket *so, - struct mbuf *m, int has_pkt); -int -ctf_do_queued_segments(struct socket *so, struct tcpcb *tp, int have_pkt); +int ctf_do_queued_segments(struct tcpcb *tp, int have_pkt); uint32_t ctf_outstanding(struct tcpcb *tp); uint32_t ctf_flight_size(struct tcpcb *tp, uint32_t rc_sacked); int diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index cc3d7c294eea..75f5e01e5882 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -594,14 +594,11 @@ struct tcptemp { struct tcp_function_block { char tfb_tcp_block_name[TCP_FUNCTION_NAME_LEN_MAX]; int (*tfb_tcp_output)(struct tcpcb *); - void (*tfb_tcp_do_segment)(struct mbuf *, struct tcphdr *, - struct socket *, struct tcpcb *, - int, int, uint8_t); - int (*tfb_do_queued_segments)(struct socket *, struct tcpcb *, int); - int (*tfb_do_segment_nounlock)(struct mbuf *, struct tcphdr *, - struct socket *, struct tcpcb *, - int, int, uint8_t, - int, struct timeval *); + void (*tfb_tcp_do_segment)(struct tcpcb *, struct mbuf *, + struct tcphdr *, int, int, uint8_t); + int (*tfb_do_segment_nounlock)(struct tcpcb *, struct mbuf *, + struct tcphdr *, int, int, uint8_t, int, struct timeval *); + int (*tfb_do_queued_segments)(struct tcpcb *, int); int (*tfb_tcp_ctloutput)(struct inpcb *inp, struct sockopt *sopt); /* Optional memory allocation/free routine */ int (*tfb_tcp_fb_init)(struct tcpcb *, void **); @@ -1378,8 +1375,8 @@ int tcp_input(struct mbuf **, int *, int); int tcp_autorcvbuf(struct mbuf *, struct tcphdr *, struct socket *, struct tcpcb *, int); int tcp_input_with_port(struct mbuf **, int *, int, uint16_t); -void tcp_do_segment(struct mbuf *, struct tcphdr *, - struct socket *, struct tcpcb *, int, int, uint8_t); +void tcp_do_segment(struct tcpcb *, struct mbuf *, struct tcphdr *, int, + int, uint8_t); int register_tcp_functions(struct tcp_function_block *blk, int wait); int register_tcp_functions_as_names(struct tcp_function_block *blk,