From c3b02504bcdafb0e7fa8b9331e2894b86baa55c5 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Sun, 2 Mar 2008 08:40:47 +0000 Subject: [PATCH] Some "cleanup" of tcp_mss(): - Move the assigment of the socket down before we first need it. No need to do it at the beginning and then drop out the function by one of the returns before using it 100 lines further down. - Use t_maxopd which was assigned the "tcp_mssdflt" for the corrrect AF already instead of another #ifdef ? : #endif block doing the same. - Remove an unneeded (duplicate) assignment of mss to t_maxseg just before we possibly change mss and re-do the assignment without using t_maxseg in between. Reviewed by: silby No objections: net@ (silence) MFC after: 5 days --- sys/netinet/tcp_input.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 2cc288c5ede..009a1fd2528 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -2740,7 +2740,6 @@ tcp_mss(struct tcpcb *tp, int offer) maxmtu = tcp_maxmtu(&inp->inp_inc, &mtuflags); tp->t_maxopd = tp->t_maxseg = tcp_mssdflt; } - so = inp->inp_socket; /* * No route to sender, stay with default mss and return. @@ -2753,13 +2752,10 @@ tcp_mss(struct tcpcb *tp, int offer) case 0: /* * Offer == 0 means that there was no MSS on the SYN - * segment, in this case we use tcp_mssdflt. + * segment, in this case we use tcp_mssdflt as + * already assigned to t_maxopd above. */ - offer = -#ifdef INET6 - isipv6 ? tcp_v6mssdflt : -#endif - tcp_mssdflt; + offer = tp->t_maxopd; break; case -1: @@ -2829,7 +2825,6 @@ tcp_mss(struct tcpcb *tp, int offer) (origoffer == -1 || (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP)) mss -= TCPOLEN_TSTAMP_APPA; - tp->t_maxseg = mss; #if (MCLBYTES & (MCLBYTES - 1)) == 0 if (mss > MCLBYTES) @@ -2847,6 +2842,7 @@ tcp_mss(struct tcpcb *tp, int offer) * Make the socket buffers an integral number of mss units; * if the mss is larger than the socket buffer, decrease the mss. */ + so = inp->inp_socket; SOCKBUF_LOCK(&so->so_snd); if ((so->so_snd.sb_hiwat == tcp_sendspace) && metrics.rmx_sendpipe) bufsize = metrics.rmx_sendpipe;