MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_mss

Function tcp_mss

freebsd/netinet/tcp_input.c:3805–3877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3803}
3804
3805void
3806tcp_mss(struct tcpcb *tp, int offer)
3807{
3808 int mss;
3809 uint32_t bufsize;
3810 struct inpcb *inp;
3811 struct socket *so;
3812 struct hc_metrics_lite metrics;
3813 struct tcp_ifcap cap;
3814
3815 KASSERT(tp != NULL, ("%s: tp == NULL", __func__));
3816
3817 bzero(&cap, sizeof(cap));
3818 tcp_mss_update(tp, offer, -1, &metrics, &cap);
3819
3820 mss = tp->t_maxseg;
3821 inp = tp->t_inpcb;
3822
3823 /*
3824 * If there's a pipesize, change the socket buffer to that size,
3825 * don't change if sb_hiwat is different than default (then it
3826 * has been changed on purpose with setsockopt).
3827 * Make the socket buffers an integral number of mss units;
3828 * if the mss is larger than the socket buffer, decrease the mss.
3829 */
3830 so = inp->inp_socket;
3831 SOCKBUF_LOCK(&so->so_snd);
3832 if ((so->so_snd.sb_hiwat == V_tcp_sendspace) && metrics.rmx_sendpipe)
3833 bufsize = metrics.rmx_sendpipe;
3834 else
3835 bufsize = so->so_snd.sb_hiwat;
3836 if (bufsize < mss)
3837 mss = bufsize;
3838 else {
3839 bufsize = roundup(bufsize, mss);
3840 if (bufsize > sb_max)
3841 bufsize = sb_max;
3842 if (bufsize > so->so_snd.sb_hiwat)
3843 (void)sbreserve_locked(&so->so_snd, bufsize, so, NULL);
3844 }
3845 SOCKBUF_UNLOCK(&so->so_snd);
3846 /*
3847 * Sanity check: make sure that maxseg will be large
3848 * enough to allow some data on segments even if the
3849 * all the option space is used (40bytes). Otherwise
3850 * funny things may happen in tcp_output.
3851 *
3852 * XXXGL: shouldn't we reserve space for IP/IPv6 options?
3853 */
3854 tp->t_maxseg = max(mss, 64);
3855
3856 SOCKBUF_LOCK(&so->so_rcv);
3857 if ((so->so_rcv.sb_hiwat == V_tcp_recvspace) && metrics.rmx_recvpipe)
3858 bufsize = metrics.rmx_recvpipe;
3859 else
3860 bufsize = so->so_rcv.sb_hiwat;
3861 if (bufsize > mss) {
3862 bufsize = roundup(bufsize, mss);

Callers 6

tcp_syncache.cFile · 0.85
tcp_do_segmentFunction · 0.85
tcp_fastopen_connectFunction · 0.85
tcp_usr_sendFunction · 0.85
rack_do_segment_nounlockFunction · 0.85
bbr_do_segment_nounlockFunction · 0.85

Calls 4

bzeroFunction · 0.85
tcp_mss_updateFunction · 0.85
sbreserve_lockedFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected