git: 35bc0bcc5192 - main - tcp: reduce argument list to functions that pass a segment
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 07 Apr 2023 19:21:38 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=35bc0bcc5192c68412de9fbf76201d602dd219ca commit 35bc0bcc5192c68412de9fbf76201d602dd219ca Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2023-04-07 19:18:05 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> 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,